GrQuadUtils.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright 2019 Google LLC
  3. *
  4. * Use of this source code is governed by a BSD-style license that can be
  5. * found in the LICENSE file.
  6. */
  7. #ifndef GrQuadUtils_DEFINED
  8. #define GrQuadUtils_DEFINED
  9. enum class GrQuadAAFlags;
  10. enum class GrAA : bool;
  11. enum class GrAAType : unsigned;
  12. class GrQuad;
  13. struct SkRect;
  14. namespace GrQuadUtils {
  15. // Resolve disagreements between the overall requested AA type and the per-edge quad AA flags.
  16. // Both outAAType and outEdgeFlags will be updated.
  17. void ResolveAAType(GrAAType requestedAAType, GrQuadAAFlags requestedEdgeFlags,
  18. const GrQuad& quad, GrAAType* outAAtype, GrQuadAAFlags* outEdgeFlags);
  19. /**
  20. * Crops quad to the provided device-space axis-aligned rectangle. If the intersection of this
  21. * quad (projected) and cropRect results in a quadrilateral, this returns true. If not, this
  22. * quad may be updated to be a smaller quad of the same type such that its intersection with
  23. * cropRect is visually the same. This function assumes that the 'quad' coordinates are finite.
  24. *
  25. * The provided edge flags are updated to reflect edges clipped by cropRect (toggling on or off
  26. * based on cropAA policy). If provided, the local coordinates will be updated to reflect the
  27. * updated device coordinates of this quad.
  28. *
  29. * 'local' may be null, in which case the new local coordinates will not be calculated. This is
  30. * useful when it's known a paint does not require local coordinates. However, neither
  31. * 'edgeFlags' nore 'quad' can be null.
  32. */
  33. bool CropToRect(const SkRect& cropRect, GrAA cropAA, GrQuadAAFlags* edgeFlags, GrQuad* quad,
  34. GrQuad* local=nullptr);
  35. }; // namespace GrQuadUtils
  36. #endif