blob: 53b53d252254c2ce5489d409be3d7f3236e993b9 [file] [log] [blame]
Michael Ludwig0f809022019-06-04 09:14:37 -04001/*
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
11enum class GrQuadAAFlags;
Michael Ludwig61328202019-06-19 14:48:58 +000012enum class GrAA : bool;
Michael Ludwig0f809022019-06-04 09:14:37 -040013enum class GrAAType : unsigned;
14class GrQuad;
Michael Ludwig61328202019-06-19 14:48:58 +000015struct SkRect;
Michael Ludwig0f809022019-06-04 09:14:37 -040016
17namespace 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 Ludwig61328202019-06-19 14:48:58 +000024 /**
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 Ludwiged71b7e2019-06-21 13:47:02 -040028 * cropRect is visually the same. This function assumes that the 'quad' coordinates are finite.
Michael Ludwig61328202019-06-19 14:48:58 +000029 *
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 Ludwig0f809022019-06-04 09:14:37 -040041}; // namespace GrQuadUtils
42
43#endif