Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
skgpu::graphite::RasterMaskHelper Class Reference

#include <RasterPathUtils.h>

Inheritance diagram for skgpu::graphite::RasterMaskHelper:
SkNoncopyable

Public Member Functions

 RasterMaskHelper (SkAutoPixmapStorage *pixels)
 
bool init (SkISize pixmapSize)
 
void drawShape (const Shape &shape, const Transform &transform, const SkStrokeRec &strokeRec, const SkIRect &resultBounds)
 

Detailed Description

The RasterMaskHelper helps generate masks using the software rendering path. It is intended to be used as:

RasterMaskHelper helper(pixmapstorage); helper.init(...); helper.drawShape(...);

The result of this process will be the mask rendered in the Pixmap, at the upper left hand corner of the bounds.

TODO: this could be extended to support clip masks, similar to GrSWMaskHelper.

Definition at line 37 of file RasterPathUtils.h.

Constructor & Destructor Documentation

◆ RasterMaskHelper()

skgpu::graphite::RasterMaskHelper::RasterMaskHelper ( SkAutoPixmapStorage pixels)
inline

Definition at line 39 of file RasterPathUtils.h.

39: fPixels(pixels) {}

Member Function Documentation

◆ drawShape()

void skgpu::graphite::RasterMaskHelper::drawShape ( const Shape shape,
const Transform transform,
const SkStrokeRec strokeRec,
const SkIRect resultBounds 
)

Definition at line 41 of file RasterPathUtils.cpp.

44 {
45 fRasterClip.setRect(resultBounds);
46
48 paint.setBlendMode(SkBlendMode::kSrc); // "Replace" mode
49 paint.setAntiAlias(true);
50 // SkPaint's color is unpremul so this will produce alpha in every channel.
51 paint.setColor(SK_ColorWHITE);
52 strokeRec.applyToPaint(&paint);
53
54 SkMatrix translatedMatrix = SkMatrix(transform);
55 // The atlas transform of the shape is the linear-components (scale, rotation, skew) of
56 // `localToDevice` translated by the top-left offset of the resultBounds.
57 // We will need to translate draws so the bound's UL corner is at the origin
58 translatedMatrix.postTranslate(resultBounds.x(), resultBounds.y());
59
60 fDraw.fCTM = &translatedMatrix;
61 SkPath path = shape.asPath();
62 if (path.isInverseFillType()) {
63 // The shader will handle the inverse fill in this case
64 path.toggleInverseFillType();
65 }
66 fDraw.drawPathCoverage(path, paint);
67}
constexpr SkColor SK_ColorWHITE
Definition SkColor.h:122
void drawPathCoverage(const SkPath &src, const SkPaint &paint, SkBlitter *customBlitter=nullptr) const
Definition SkDrawBase.h:69
const SkMatrix * fCTM
Definition SkDrawBase.h:153
SkMatrix & postTranslate(SkScalar dx, SkScalar dy)
Definition SkMatrix.cpp:281
bool setRect(const SkIRect &)
void applyToPaint(SkPaint *paint) const
const Paint & paint
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition switches.h:57
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
Definition p3.cpp:47
constexpr int32_t x() const
Definition SkRect.h:141
constexpr int32_t y() const
Definition SkRect.h:148

◆ init()

bool skgpu::graphite::RasterMaskHelper::init ( SkISize  pixmapSize)

Definition at line 19 of file RasterPathUtils.cpp.

19 {
20 if (!fPixels) {
21 return false;
22 }
23
24 // Allocate pixmap if needed
25 if (!fPixels->addr()) {
26 const SkImageInfo bmImageInfo = SkImageInfo::MakeA8(pixmapSize);
27 if (!fPixels->tryAlloc(bmImageInfo)) {
28 return false;
29 }
30 fPixels->erase(0);
31 } else if (fPixels->dimensions() != pixmapSize) {
32 return false;
33 }
34
36 fDraw.fDst = *fPixels;
37 fDraw.fRC = &fRasterClip;
38 return true;
39}
SkBlitter * SkA8Blitter_Choose(const SkPixmap &dst, const SkMatrix &ctm, const SkPaint &paint, SkArenaAlloc *alloc, bool drawCoverage, sk_sp< SkShader > clipShader, const SkSurfaceProps &)
bool tryAlloc(const SkImageInfo &)
BlitterChooser * fBlitterChooser
Definition SkDrawBase.h:152
const SkRasterClip * fRC
Definition SkDrawBase.h:154
SkPixmap fDst
Definition SkDrawBase.h:151
bool erase(SkColor color, const SkIRect &subset) const
Definition SkPixmap.cpp:742
const void * addr() const
Definition SkPixmap.h:153
SkISize dimensions() const
Definition SkPixmap.h:171
static SkImageInfo MakeA8(int width, int height)

The documentation for this class was generated from the following files: