Michael Ludwig | 0f80902 | 2019-06-04 09:14:37 -0400 | [diff] [blame] | 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 | |
| 8 | #ifndef GrQuadUtils_DEFINED |
| 9 | #define GrQuadUtils_DEFINED |
| 10 | |
| 11 | enum class GrQuadAAFlags; |
Michael Ludwig | 6132820 | 2019-06-19 14:48:58 +0000 | [diff] [blame] | 12 | enum class GrAA : bool; |
Michael Ludwig | 0f80902 | 2019-06-04 09:14:37 -0400 | [diff] [blame] | 13 | enum class GrAAType : unsigned; |
| 14 | class GrQuad; |
Michael Ludwig | 6132820 | 2019-06-19 14:48:58 +0000 | [diff] [blame] | 15 | struct SkRect; |
Michael Ludwig | 0f80902 | 2019-06-04 09:14:37 -0400 | [diff] [blame] | 16 | |
| 17 | namespace GrQuadUtils { |
| 18 | |
| 19 | // Resolve disagreements between the overall requested AA type and the per-edge quad AA flags. |
| 20 | // Both outAAType and outEdgeFlags will be updated. |
| 21 | void ResolveAAType(GrAAType requestedAAType, GrQuadAAFlags requestedEdgeFlags, |
| 22 | const GrQuad& quad, GrAAType* outAAtype, GrQuadAAFlags* outEdgeFlags); |
| 23 | |
Michael Ludwig | 6132820 | 2019-06-19 14:48:58 +0000 | [diff] [blame] | 24 | /** |
| 25 | * Crops quad to the provided device-space axis-aligned rectangle. If the intersection of this |
| 26 | * quad (projected) and cropRect results in a quadrilateral, this returns true. If not, this |
| 27 | * quad may be updated to be a smaller quad of the same type such that its intersection with |
Michael Ludwig | ed71b7e | 2019-06-21 13:47:02 -0400 | [diff] [blame] | 28 | * cropRect is visually the same. This function assumes that the 'quad' coordinates are finite. |
Michael Ludwig | 6132820 | 2019-06-19 14:48:58 +0000 | [diff] [blame] | 29 | * |
| 30 | * The provided edge flags are updated to reflect edges clipped by cropRect (toggling on or off |
| 31 | * based on cropAA policy). If provided, the local coordinates will be updated to reflect the |
| 32 | * updated device coordinates of this quad. |
| 33 | * |
| 34 | * 'local' may be null, in which case the new local coordinates will not be calculated. This is |
| 35 | * useful when it's known a paint does not require local coordinates. However, neither |
| 36 | * 'edgeFlags' nore 'quad' can be null. |
| 37 | */ |
| 38 | bool CropToRect(const SkRect& cropRect, GrAA cropAA, GrQuadAAFlags* edgeFlags, GrQuad* quad, |
| 39 | GrQuad* local=nullptr); |
| 40 | |
Michael Ludwig | 0f80902 | 2019-06-04 09:14:37 -0400 | [diff] [blame] | 41 | }; // namespace GrQuadUtils |
| 42 | |
| 43 | #endif |