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; 12 enum class GrAA : bool; 13 enum class GrAAType : unsigned; 14 class GrQuad; 15 struct SkRect; 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 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 28 * cropRect is visually the same. This function assumes that the 'quad' coordinates are finite. 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 41 }; // namespace GrQuadUtils 42 43 #endif 44