Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
GrSWMaskHelper.h
Go to the documentation of this file.
1/*
2 * Copyright 2012 Google Inc.
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 GrSWMaskHelper_DEFINED
9#define GrSWMaskHelper_DEFINED
10
16#include "src/core/SkDrawBase.h"
19
20class GrShape;
21class GrStyledShape;
23class GrTextureProxy;
24
25/**
26 * The GrSWMaskHelper helps generate clip masks using the software rendering
27 * path. It is intended to be used as:
28 *
29 * GrSWMaskHelper helper(context);
30 * helper.init(...);
31 *
32 * draw one or more paths/rects specifying the required boolean ops
33 *
34 * toTextureView(); // to get it from the internal bitmap to the GPU
35 *
36 * The result of this process will be the final mask (on the GPU) in the
37 * upper left hand corner of the texture.
38 */
40public:
42 : fPixels(pixels ? pixels : &fPixelsStorage) { }
43
44 // set up the internal state in preparation for draws. Since many masks
45 // may be accumulated in the helper during creation, "resultBounds"
46 // allows the caller to specify the region of interest - to limit the
47 // amount of work.
48 bool init(const SkIRect& resultBounds);
49
50 // Draw a single rect into the accumulation bitmap using the specified op
51 void drawRect(const SkRect& rect, const SkMatrix& matrix, GrAA, uint8_t alpha);
52
53 // Draw a single rrect into the accumulation bitmap using the specified op
54 void drawRRect(const SkRRect& rrect, const SkMatrix& matrix, GrAA,
55 uint8_t alpha);
56
57 // Draw a single path into the accumuation bitmap using the specified op
58 void drawShape(const GrStyledShape&, const SkMatrix& matrix, GrAA,
59 uint8_t alpha);
60 // Like the GrStyledShape variant, but assumes a simple fill style
61 void drawShape(const GrShape&, const SkMatrix& matrix, GrAA, uint8_t alpha);
62
64
65 // Reset the internal bitmap
66 void clear(uint8_t alpha) {
67 fPixels->erase(SkColorSetARGB(alpha, 0xFF, 0xFF, 0xFF));
68 }
69
70private:
71 SkVector fTranslate;
72 SkAutoPixmapStorage* fPixels;
73 SkAutoPixmapStorage fPixelsStorage;
74 SkDrawBase fDraw;
75 SkRasterClip fRasterClip;
76
77 using INHERITED = SkNoncopyable;
78};
79
80#endif // GrSWMaskHelper_DEFINED
GrAA
SkBackingFit
static constexpr SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
Definition SkColor.h:49
void drawRect(const SkRect &rect, const SkMatrix &matrix, GrAA, uint8_t alpha)
void drawRRect(const SkRRect &rrect, const SkMatrix &matrix, GrAA, uint8_t alpha)
void drawShape(const GrStyledShape &, const SkMatrix &matrix, GrAA, uint8_t alpha)
GrSWMaskHelper(SkAutoPixmapStorage *pixels=nullptr)
void clear(uint8_t alpha)
bool init(const SkIRect &resultBounds)
GrSurfaceProxyView toTextureView(GrRecordingContext *, SkBackingFit fit)
SkNoncopyable()=default
bool erase(SkColor color, const SkIRect &subset) const
Definition SkPixmap.cpp:742