Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
StencilMaskHelper.h
Go to the documentation of this file.
1/*
2 * Copyright 2020 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 StencilMaskHelper_DEFINED
9#define StencilMaskHelper_DEFINED
10
13
14class GrShape;
16class SkMatrix;
17struct SkRect;
18class SkRRect;
19
20namespace skgpu::ganesh {
21
23
24/**
25 * The StencilMaskHelper helps generate clip masks using the stencil buffer.
26 * It is intended to be used as:
27 *
28 * StencilMaskHelper helper;
29 * helper.init(...);
30 *
31 * draw one or more paths/rects specifying the required boolean ops
32 *
33 * helper.finish();
34 *
35 * The result of this process will be the mask stored in the clip bits of the stencil buffer.
36 */
38public:
39 // Configure the helper to update the stencil mask within the given rectangle, respecting the
40 // set window rectangles. It will use the provided context and render target to draw into, both
41 // of which must outlive the helper.
43
44 // Returns true if the stencil mask must be redrawn
45 bool init(const SkIRect& maskBounds, uint32_t genID,
46 const GrWindowRectangles& windowRects, int numFPs);
47
48 // Draw a single rect into the stencil clip using the specified op
49 void drawRect(const SkRect& rect, const SkMatrix& matrix, SkRegion::Op, GrAA);
50
51 // Draw a single filled path into the stencil clip with the specified op
52 bool drawPath(const SkPath& path, const SkMatrix& matrix, SkRegion::Op, GrAA);
53
54 // Draw a single shape into the stencil clip assuming a simple fill style, with the specified op
55 bool drawShape(const GrShape& shape, const SkMatrix& matrix, SkRegion::Op, GrAA);
56
57 // Reset the stencil buffer's clip bit to in or out.
58 void clear(bool insideStencil);
59
60 // Marks the last rendered stencil mask on the render target context
61 void finish();
62
63private:
64 GrRecordingContext* fContext;
66 StencilClip fClip;
67 int fNumFPs;
68
70};
71
72} // namespace skgpu::ganesh
73
74#endif // StencilMaskHelper_DEFINED
GrAA
SkNoncopyable()=default
void drawRect(const SkRect &rect, const SkMatrix &matrix, SkRegion::Op, GrAA)
bool init(const SkIRect &maskBounds, uint32_t genID, const GrWindowRectangles &windowRects, int numFPs)
bool drawPath(const SkPath &path, const SkMatrix &matrix, SkRegion::Op, GrAA)
bool drawShape(const GrShape &shape, const SkMatrix &matrix, SkRegion::Op, GrAA)