Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
SkDraw Class Reference

#include <SkDraw.h>

Inheritance diagram for SkDraw:
SkDrawBase SkGlyphRunListPainterCPU::BitmapDevicePainter SkBitmapDevice::BDDraw

Public Member Functions

 SkDraw ()
 
void drawBitmap (const SkBitmap &, const SkMatrix &, const SkRect *dstOrNull, const SkSamplingOptions &, const SkPaint &) const override
 
void drawSprite (const SkBitmap &, int x, int y, const SkPaint &) const
 
void drawGlyphRunList (SkCanvas *canvas, SkGlyphRunListPainterCPU *glyphPainter, const sktext::GlyphRunList &glyphRunList, const SkPaint &paint) const
 
void paintMasks (SkZip< const SkGlyph *, SkPoint > accepted, const SkPaint &paint) const override
 
void drawPoints (SkCanvas::PointMode, size_t count, const SkPoint[], const SkPaint &, SkDevice *) const
 
void drawVertices (const SkVertices *, sk_sp< SkBlender >, const SkPaint &, bool skipColorXform) const
 
void drawAtlas (const SkRSXform[], const SkRect[], const SkColor[], int count, sk_sp< SkBlender >, const SkPaint &)
 
- Public Member Functions inherited from SkDrawBase
 SkDrawBase ()
 
void drawPaint (const SkPaint &) const
 
void drawRect (const SkRect &prePaintRect, const SkPaint &, const SkMatrix *paintMatrix, const SkRect *postPaintRect) const
 
void drawRect (const SkRect &rect, const SkPaint &paint) const
 
void drawRRect (const SkRRect &, const SkPaint &) const
 
void drawPath (const SkPath &path, const SkPaint &paint, const SkMatrix *prePathMatrix=nullptr, bool pathIsMutable=false) const
 
void drawPathCoverage (const SkPath &src, const SkPaint &paint, SkBlitter *customBlitter=nullptr) const
 
void drawDevicePoints (SkCanvas::PointMode, size_t count, const SkPoint[], const SkPaint &, SkDevice *) const
 
void validate () const
 
- Public Member Functions inherited from SkGlyphRunListPainterCPU::BitmapDevicePainter
 BitmapDevicePainter ()=default
 
 BitmapDevicePainter (const BitmapDevicePainter &)=default
 
virtual ~BitmapDevicePainter ()=default
 
virtual void paintMasks (SkZip< const SkGlyph *, SkPoint > accepted, const SkPaint &paint) const =0
 
virtual void drawBitmap (const SkBitmap &, const SkMatrix &, const SkRect *dstOrNull, const SkSamplingOptions &, const SkPaint &) const =0
 

Additional Inherited Members

- Public Types inherited from SkDrawBase
enum  RectType { kHair_RectType , kFill_RectType , kStroke_RectType , kPath_RectType }
 
using BlitterChooser = SkBlitter *(const SkPixmap &dst, const SkMatrix &ctm, const SkPaint &, SkArenaAlloc *, bool drawCoverage, sk_sp< SkShader > clipShader, const SkSurfaceProps &)
 
- Static Public Member Functions inherited from SkDrawBase
static bool ComputeMaskBounds (const SkRect &devPathBounds, const SkIRect &clipBounds, const SkMaskFilter *filter, const SkMatrix *filterMatrix, SkIRect *bounds)
 
static bool DrawToMask (const SkPath &devPath, const SkIRect &clipBounds, const SkMaskFilter *, const SkMatrix *filterMatrix, SkMaskBuilder *dst, SkMaskBuilder::CreateMode mode, SkStrokeRec::InitStyle style)
 
static RectType ComputeRectType (const SkRect &, const SkPaint &, const SkMatrix &, SkPoint *strokeSize)
 
- Public Attributes inherited from SkDrawBase
SkPixmap fDst
 
BlitterChooserfBlitterChooser {nullptr}
 
const SkMatrixfCTM {nullptr}
 
const SkRasterClipfRC {nullptr}
 
const SkSurfacePropsfProps {nullptr}
 

Detailed Description

Definition at line 38 of file SkDraw.h.

Constructor & Destructor Documentation

◆ SkDraw()

SkDraw::SkDraw ( )

Definition at line 52 of file SkDraw.cpp.

52 {
54}
static SkBlitter * Choose(const SkPixmap &dst, const SkMatrix &ctm, const SkPaint &paint, SkArenaAlloc *, bool drawCoverage, sk_sp< SkShader > clipShader, const SkSurfaceProps &props)
Definition: SkBlitter.cpp:685
BlitterChooser * fBlitterChooser
Definition: SkDrawBase.h:154

Member Function Documentation

◆ drawAtlas()

void SkDraw::drawAtlas ( const SkRSXform  xform[],
const SkRect  textures[],
const SkColor  colors[],
int  count,
sk_sp< SkBlender blender,
const SkPaint paint 
)

Definition at line 71 of file SkDraw_atlas.cpp.

76 {
77 sk_sp<SkShader> atlasShader = paint.refShader();
78 if (!atlasShader) {
79 return;
80 }
81
83
85 p.setAntiAlias(false); // we never respect this for drawAtlas(or drawVertices)
86 p.setStyle(SkPaint::kFill_Style);
87 p.setShader(nullptr);
88 p.setMaskFilter(nullptr);
89
90 // The RSXForms can't contain perspective - only the CTM can.
91 const bool perspective = fCTM->hasPerspective();
92
93 auto transformShader = alloc.make<SkTransformShader>(*as_SB(atlasShader), perspective);
94
95 SkRasterPipeline pipeline(&alloc);
97 SkStageRec rec = {&pipeline, &alloc, fDst.colorType(), fDst.colorSpace(),
98 p.getColor4f(), props};
99 // We pass an identity matrix here rather than the CTM. The CTM gets folded into the
100 // per-triangle matrix.
101 if (!as_SB(transformShader)->appendRootStages(rec, SkMatrix::I())) {
102 return;
103 }
104
105 SkRasterPipeline_UniformColorCtx* uniformCtx = nullptr;
108 if (colors) {
109 // we will late-bind the values in ctx, once for each color in the loop
110 uniformCtx = alloc.make<SkRasterPipeline_UniformColorCtx>();
111 rec.fPipeline->append(SkRasterPipelineOp::uniform_color_dst, uniformCtx);
112 std::optional<SkBlendMode> bm = as_BB(blender)->asBlendMode();
113 if (!bm.has_value()) {
114 return;
115 }
117 }
118
119 bool isOpaque = !colors && transformShader->isOpaque();
120 if (p.getAlphaf() != 1) {
121 rec.fPipeline->append(SkRasterPipelineOp::scale_1_float, alloc.make<float>(p.getAlphaf()));
122 isOpaque = false;
123 }
124
125 auto blitter = SkCreateRasterPipelineBlitter(fDst, p, pipeline, isOpaque, &alloc,
126 fRC->clipShader());
127 if (!blitter) {
128 return;
129 }
130 SkPath scratchPath;
131
132 for (int i = 0; i < count; ++i) {
133 if (colors) {
134 SkColor4f c4 = SkColor4f::FromColor(colors[i]);
135 steps.apply(c4.vec());
136 load_color(uniformCtx, c4.premul().vec());
137 }
138
139 SkMatrix mx;
140 mx.setRSXform(xform[i]);
141 mx.preTranslate(-textures[i].fLeft, -textures[i].fTop);
142 mx.postConcat(*fCTM);
144 if (!mx.invert(&inv)) {
145 return;
146 }
147 if (transformShader->update(inv)) {
148 fill_rect(mx, *fRC, textures[i], blitter, &scratchPath);
149 }
150 }
151}
static SkM44 inv(const SkM44 &m)
Definition: 3d.cpp:26
int count
Definition: FontMgrTest.cpp:50
kUnpremul_SkAlphaType
void SkBlendMode_AppendStages(SkBlendMode mode, SkRasterPipeline *p)
Definition: SkBlendMode.cpp:97
SkBlenderBase * as_BB(SkBlender *blend)
Definition: SkBlenderBase.h:69
SkColorSpace * sk_srgb_singleton()
SkBlitter * SkCreateRasterPipelineBlitter(const SkPixmap &, const SkPaint &, const SkMatrix &ctm, SkArenaAlloc *, sk_sp< SkShader > clipShader, const SkSurfaceProps &props)
static void fill_rect(const SkMatrix &ctm, const SkRasterClip &rc, const SkRect &r, SkBlitter *blitter, SkPath *scratchPath)
static void load_color(SkRasterPipeline_UniformColorCtx *ctx, const float rgba[])
SkShaderBase * as_SB(SkShader *shader)
Definition: SkShaderBase.h:412
static SkSurfaceProps SkSurfacePropsCopyOrDefault(const SkSurfaceProps *props)
Definition: SkSurfacePriv.h:15
auto make(Ctor &&ctor) -> decltype(ctor(nullptr))
Definition: SkArenaAlloc.h:120
virtual std::optional< SkBlendMode > asBlendMode() const
Definition: SkBlenderBase.h:45
const SkSurfaceProps * fProps
Definition: SkDrawBase.h:157
const SkRasterClip * fRC
Definition: SkDrawBase.h:156
SkPixmap fDst
Definition: SkDrawBase.h:153
const SkMatrix * fCTM
Definition: SkDrawBase.h:155
SkMatrix & postConcat(const SkMatrix &other)
Definition: SkMatrix.cpp:683
bool invert(SkMatrix *inverse) const
Definition: SkMatrix.h:1206
SkMatrix & setRSXform(const SkRSXform &rsxForm)
Definition: SkMatrix.cpp:420
static const SkMatrix & I()
Definition: SkMatrix.cpp:1544
SkMatrix & preTranslate(SkScalar dx, SkScalar dy)
Definition: SkMatrix.cpp:263
bool hasPerspective() const
Definition: SkMatrix.h:312
@ kFill_Style
set to fill geometry
Definition: SkPaint.h:193
Definition: SkPath.h:59
SkColorType colorType() const
Definition: SkPixmap.h:173
SkColorSpace * colorSpace() const
Definition: SkPixmap.cpp:61
sk_sp< SkShader > clipShader() const
Definition: SkRasterClip.h:95
void append(SkRasterPipelineOp, void *=nullptr)
const Paint & paint
Definition: color_source.cc:38
PODArray< SkColor > colors
Definition: SkRecords.h:276
SkRasterPipeline * fPipeline
Definition: SkEffectPriv.h:21
SkColorSpace * fDstCS
Definition: SkEffectPriv.h:24

◆ drawBitmap()

void SkDraw::drawBitmap ( const SkBitmap bitmap,
const SkMatrix prematrix,
const SkRect dstOrNull,
const SkSamplingOptions sampling,
const SkPaint origPaint 
) const
overridevirtual

Implements SkGlyphRunListPainterCPU::BitmapDevicePainter.

Definition at line 303 of file SkDraw.cpp.

305 {
306 SkDEBUGCODE(this->validate();)
307
308 // nothing to draw
309 if (fRC->isEmpty() ||
310 bitmap.width() == 0 || bitmap.height() == 0 ||
311 bitmap.colorType() == kUnknown_SkColorType) {
312 return;
313 }
314
316 if (origPaint.getStyle() != SkPaint::kFill_Style) {
317 paint.writable()->setStyle(SkPaint::kFill_Style);
318 }
319
320 SkMatrix matrix = *fCTM * prematrix;
321
322 if (clipped_out(matrix, *fRC, bitmap.width(), bitmap.height())) {
323 return;
324 }
325
326 if (!SkColorTypeIsAlphaOnly(bitmap.colorType()) &&
327 SkTreatAsSprite(matrix, bitmap.dimensions(), sampling, paint->isAntiAlias())) {
328 //
329 // It is safe to call lock pixels now, since we know the matrix is
330 // (more or less) identity.
331 //
332 SkPixmap pmap;
333 if (!bitmap.peekPixels(&pmap)) {
334 return;
335 }
336 int ix = SkScalarRoundToInt(matrix.getTranslateX());
337 int iy = SkScalarRoundToInt(matrix.getTranslateY());
338 if (clipHandlesSprite(*fRC, ix, iy, pmap)) {
340 // blitter will be owned by the allocator.
341 SkBlitter* blitter = SkBlitter::ChooseSprite(fDst, *paint, pmap, ix, iy, &allocator,
342 fRC->clipShader());
343 if (blitter) {
344 SkScan::FillIRect(SkIRect::MakeXYWH(ix, iy, pmap.width(), pmap.height()),
345 *fRC, blitter);
346 return;
347 }
348 // if !blitter, then we fall-through to the slower case
349 }
350 }
351
352 // now make a temp draw on the stack, and use it
353 //
354 SkDraw draw(*this);
355 draw.fCTM = &matrix;
356
357 // For a long time, the CPU backend treated A8 bitmaps as coverage, rather than alpha. This was
358 // inconsistent with the GPU backend (skbug.com/9692). When this was fixed, it altered behavior
359 // for some Android apps (b/231400686). Thus: keep the old behavior in the framework.
360#if defined(SK_SUPPORT_LEGACY_ALPHA_BITMAP_AS_COVERAGE)
361 if (bitmap.colorType() == kAlpha_8_SkColorType && !paint->getColorFilter()) {
362 draw.drawBitmapAsMask(bitmap, sampling, *paint);
363 return;
364 }
365#endif
366
367 SkPaint paintWithShader = make_paint_with_image(*paint, bitmap, sampling);
368 const SkRect srcBounds = SkRect::MakeIWH(bitmap.width(), bitmap.height());
369 if (dstBounds) {
370 this->drawRect(srcBounds, paintWithShader, &prematrix, dstBounds);
371 } else {
372 draw.drawRect(srcBounds, paintWithShader);
373 }
374}
@ kAlpha_8_SkColorType
pixel with alpha in 8-bit byte
Definition: SkColorType.h:21
@ kUnknown_SkColorType
uninitialized
Definition: SkColorType.h:20
static bool clipHandlesSprite(const SkRasterClip &clip, int x, int y, const SkPixmap &pmap)
Definition: SkDraw.cpp:299
static SkPaint make_paint_with_image(const SkPaint &origPaint, const SkBitmap &bitmap, const SkSamplingOptions &sampling, SkMatrix *matrix=nullptr)
Definition: SkDraw.cpp:42
static bool clipped_out(const SkMatrix &m, const SkRasterClip &c, const SkRect &srcR)
Definition: SkDraw.cpp:285
static bool SkColorTypeIsAlphaOnly(SkColorType ct)
bool SkTreatAsSprite(const SkMatrix &mat, const SkISize &size, const SkSamplingOptions &sampling, bool isAntiAlias)
Definition: SkMatrix.cpp:1614
#define SkScalarRoundToInt(x)
Definition: SkScalar.h:37
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
int width() const
Definition: SkBitmap.h:149
static SkBlitter * ChooseSprite(const SkPixmap &dst, const SkPaint &, const SkPixmap &src, int left, int top, SkArenaAlloc *, sk_sp< SkShader > clipShader)
void drawRect(const SkRect &prePaintRect, const SkPaint &, const SkMatrix *paintMatrix, const SkRect *postPaintRect) const
Definition: SkDrawBase.cpp:159
void validate() const
Definition: SkDrawBase.h:162
Definition: SkDraw.h:38
Style getStyle() const
Definition: SkPaint.h:204
int width() const
Definition: SkPixmap.h:160
int height() const
Definition: SkPixmap.h:166
bool isEmpty() const
Definition: SkRasterClip.h:47
static void FillIRect(const SkIRect &, const SkRasterClip &, SkBlitter *)
Definition: SkScan.cpp:65
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
SkSamplingOptions sampling
Definition: SkRecords.h:337
Definition: bitmap.py:1
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
Definition: SkRect.h:104
static SkRect MakeIWH(int w, int h)
Definition: SkRect.h:623

◆ drawGlyphRunList()

void SkDraw::drawGlyphRunList ( SkCanvas canvas,
SkGlyphRunListPainterCPU glyphPainter,
const sktext::GlyphRunList glyphRunList,
const SkPaint paint 
) const

Definition at line 126 of file SkDraw_text.cpp.

129 {
130
131 SkDEBUGCODE(this->validate();)
132
133 if (fRC->isEmpty()) {
134 return;
135 }
136
137 glyphPainter->drawForBitmapDevice(canvas, this, glyphRunList, paint, *fCTM);
138}
void drawForBitmapDevice(SkCanvas *canvas, const BitmapDevicePainter *bitmapDevice, const sktext::GlyphRunList &glyphRunList, const SkPaint &paint, const SkMatrix &drawMatrix)

◆ drawPoints()

void SkDraw::drawPoints ( SkCanvas::PointMode  mode,
size_t  count,
const SkPoint  pts[],
const SkPaint paint,
SkDevice device 
) const

Definition at line 237 of file SkDraw.cpp.

239 {
240 // if we're in lines mode, force count to be even
242 count &= ~(size_t)1;
243 }
244
245 SkASSERT(pts != nullptr);
246 SkDEBUGCODE(this->validate();)
247
248 // nothing to draw
249 if (!count || fRC->isEmpty()) {
250 return;
251 }
252
253 PtProcRec rec;
254 if (!device && rec.init(mode, paint, fCTM, fRC)) {
255 SkAutoBlitterChoose blitter(*this, nullptr, paint);
256
257 SkPoint devPts[MAX_DEV_PTS];
258 SkBlitter* bltr = blitter.get();
259 PtProcRec::Proc proc = rec.chooseProc(&bltr);
260 // we have to back up subsequent passes if we're in polygon mode
261 const size_t backup = (SkCanvas::kPolygon_PointMode == mode);
262
263 do {
264 int n = SkToInt(count);
265 if (n > MAX_DEV_PTS) {
266 n = MAX_DEV_PTS;
267 }
268 fCTM->mapPoints(devPts, pts, n);
269 if (!SkIsFinite(&devPts[0].fX, n * 2)) {
270 return;
271 }
272 proc(rec, devPts, n, bltr);
273 pts += n - backup;
274 SkASSERT(SkToInt(count) >= n);
275 count -= n;
276 if (count > 0) {
277 count += backup;
278 }
279 } while (count != 0);
280 } else {
281 this->drawDevicePoints(mode, count, pts, paint, device);
282 }
283}
#define SkASSERT(cond)
Definition: SkAssert.h:116
#define MAX_DEV_PTS
Definition: SkDraw.cpp:235
static bool SkIsFinite(T x, Pack... values)
constexpr int SkToInt(S x)
Definition: SkTo.h:29
@ kLines_PointMode
draw each pair of points as a line segment
Definition: SkCanvas.h:1242
@ kPolygon_PointMode
draw the array of points as a open polygon
Definition: SkCanvas.h:1243
void drawDevicePoints(SkCanvas::PointMode, size_t count, const SkPoint[], const SkPaint &, SkDevice *) const
Definition: SkDrawBase.cpp:597
void mapPoints(SkPoint dst[], const SkPoint src[], int count) const
Definition: SkMatrix.cpp:770
VkDevice device
Definition: main.cc:53
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
Definition: switches.h:228
void(* Proc)(const PtProcRec &, const SkPoint devPts[], int count, SkBlitter *)
Definition: SkDraw.cpp:66
bool init(SkCanvas::PointMode, const SkPaint &, const SkMatrix *matrix, const SkRasterClip *)
Definition: SkDraw.cpp:152
Proc chooseProc(SkBlitter **blitter)
Definition: SkDraw.cpp:191

◆ drawSprite()

void SkDraw::drawSprite ( const SkBitmap bitmap,
int  x,
int  y,
const SkPaint origPaint 
) const

Definition at line 376 of file SkDraw.cpp.

376 {
377 SkDEBUGCODE(this->validate();)
378
379 // nothing to draw
380 if (fRC->isEmpty() ||
381 bitmap.width() == 0 || bitmap.height() == 0 ||
382 bitmap.colorType() == kUnknown_SkColorType) {
383 return;
384 }
385
386 const SkIRect bounds = SkIRect::MakeXYWH(x, y, bitmap.width(), bitmap.height());
387
388 if (fRC->quickReject(bounds)) {
389 return; // nothing to draw
390 }
391
392 SkPaint paint(origPaint);
393 paint.setStyle(SkPaint::kFill_Style);
394
395 SkPixmap pmap;
396 if (!bitmap.peekPixels(&pmap)) {
397 return;
398 }
399
400 if (nullptr == paint.getColorFilter() && clipHandlesSprite(*fRC, x, y, pmap)) {
401 // blitter will be owned by the allocator.
403 SkBlitter* blitter = SkBlitter::ChooseSprite(fDst, paint, pmap, x, y, &allocator,
404 fRC->clipShader());
405 if (blitter) {
406 SkScan::FillIRect(bounds, *fRC, blitter);
407 return;
408 }
409 }
410
412 SkRect r;
413
414 // get a scalar version of our rect
415 r.set(bounds);
416
417 // create shader with offset
418 matrix.setTranslate(r.fLeft, r.fTop);
420 SkDraw draw(*this);
421 draw.fCTM = &SkMatrix::I();
422 // call ourself with a rect
423 draw.drawRect(r, paintWithShader);
424}
bool quickReject(const SkIRect &rect) const
Definition: SkRasterClip.h:85
double y
double x
Optional< SkRect > bounds
Definition: SkRecords.h:189
SkSamplingOptions(SkFilterMode::kLinear))
Definition: SkRect.h:32
SkScalar fLeft
smaller x-axis bounds
Definition: extension.cpp:14
void set(const SkIRect &src)
Definition: SkRect.h:849
SkScalar fTop
smaller y-axis bounds
Definition: extension.cpp:15

◆ drawVertices()

void SkDraw::drawVertices ( const SkVertices vertices,
sk_sp< SkBlender blender,
const SkPaint paint,
bool  skipColorXform 
) const

Definition at line 309 of file SkDraw_vertices.cpp.

312 {
313 SkVerticesPriv info(vertices->priv());
314 const int vertexCount = info.vertexCount();
315 const int indexCount = info.indexCount();
316
317 // abort early if there is nothing to draw
318 if (vertexCount < 3 || (indexCount > 0 && indexCount < 3) || fRC->isEmpty()) {
319 return;
320 }
321 SkMatrix ctmInv;
322 if (!fCTM->invert(&ctmInv)) {
323 return;
324 }
325
326 constexpr size_t kDefVertexCount = 16;
327 constexpr size_t kOuterSize = sizeof(SkTriColorShader) +
328 (2 * sizeof(SkPoint) + sizeof(SkColor4f)) * kDefVertexCount;
330
331 SkPoint* dev2 = nullptr;
332 SkPoint3* dev3 = nullptr;
333
334 if (fCTM->hasPerspective()) {
335 dev3 = outerAlloc.makeArray<SkPoint3>(vertexCount);
336 fCTM->mapHomogeneousPoints(dev3, info.positions(), vertexCount);
337 // similar to the bounds check for 2d points (below)
338 if (!SkIsFinite((const SkScalar*)dev3, vertexCount * 3)) {
339 return;
340 }
341 } else {
342 dev2 = outerAlloc.makeArray<SkPoint>(vertexCount);
343 fCTM->mapPoints(dev2, info.positions(), vertexCount);
344
346 // this also sets bounds to empty if we see a non-finite value
347 bounds.setBounds(dev2, vertexCount);
348 if (bounds.isEmpty()) {
349 return;
350 }
351 }
352
353 this->drawFixedVertices(
354 vertices, std::move(blender), paint, ctmInv, dev2, dev3, &outerAlloc, skipColorXform);
355}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
SkRGBA4f< kUnpremul_SkAlphaType > SkColor4f
Definition: SkColor.h:426
T * makeArray(size_t count)
Definition: SkArenaAlloc.h:181
void mapHomogeneousPoints(SkPoint3 dst[], const SkPoint3 src[], int count) const
Definition: SkMatrix.cpp:1066
SkVerticesPriv priv()
float SkScalar
Definition: extension.cpp:12

◆ paintMasks()

void SkDraw::paintMasks ( SkZip< const SkGlyph *, SkPoint accepted,
const SkPaint paint 
) const
overridevirtual

Implements SkGlyphRunListPainterCPU::BitmapDevicePainter.

Definition at line 52 of file SkDraw_text.cpp.

52 {
53 // The size used for a typical blitter.
56 *fCTM,
57 paint,
58 &alloc,
59 false,
60 fRC->clipShader(),
62
63 SkAAClipBlitterWrapper wrapper{*fRC, blitter};
64 blitter = wrapper.getBlitter();
65
66 bool useRegion = fRC->isBW() && !fRC->isRect();
67
68 if (useRegion) {
69 for (auto [glyph, pos] : accepted) {
71 SkMask mask = glyph->mask(pos);
72
73 SkRegion::Cliperator clipper(fRC->bwRgn(), mask.fBounds);
74
75 if (!clipper.done()) {
76 if (SkMask::kARGB32_Format == mask.fFormat) {
77 SkBitmap bm;
79 const_cast<uint8_t*>(mask.fImage),
80 mask.fRowBytes);
81 bm.setImmutable();
82 this->drawSprite(bm, mask.fBounds.x(), mask.fBounds.y(), paint);
83 } else {
84 const SkIRect& cr = clipper.rect();
85 do {
86 blitter->blitMask(mask, cr);
87 clipper.next();
88 } while (!clipper.done());
89 }
90 }
91 }
92 }
93 } else {
94 SkIRect clipBounds = fRC->isBW() ? fRC->bwRgn().getBounds()
95 : fRC->aaRgn().getBounds();
96 for (auto [glyph, pos] : accepted) {
98 SkMask mask = glyph->mask(pos);
99 SkIRect storage;
100 const SkIRect* bounds = &mask.fBounds;
101
102 // this extra test is worth it, assuming that most of the time it succeeds
103 // since we can avoid writing to storage
104 if (!clipBounds.containsNoEmptyCheck(mask.fBounds)) {
105 if (!storage.intersect(mask.fBounds, clipBounds)) {
106 continue;
107 }
108 bounds = &storage;
109 }
110
111 if (SkMask::kARGB32_Format == mask.fFormat) {
112 SkBitmap bm;
114 const_cast<uint8_t*>(mask.fImage),
115 mask.fRowBytes);
116 bm.setImmutable();
117 this->drawSprite(bm, mask.fBounds.x(), mask.fBounds.y(), paint);
118 } else {
119 blitter->blitMask(mask, *bounds);
120 }
121 }
122 }
123 }
124}
SkPoint pos
static bool check_glyph_position(SkPoint position)
Definition: SkDraw_text.cpp:41
const SkIRect & getBounds() const
Definition: SkAAClip.h:34
void setImmutable()
Definition: SkBitmap.cpp:400
bool installPixels(const SkImageInfo &info, void *pixels, size_t rowBytes, void(*releaseProc)(void *addr, void *context), void *context)
Definition: SkBitmap.cpp:323
virtual void blitMask(const SkMask &, const SkIRect &clip)
Definition: SkBlitter.cpp:201
void drawSprite(const SkBitmap &, int x, int y, const SkPaint &) const
Definition: SkDraw.cpp:376
const SkAAClip & aaRgn() const
Definition: SkRasterClip.h:45
const SkRegion & bwRgn() const
Definition: SkRasterClip.h:44
bool isRect() const
Definition: SkRasterClip.h:52
bool isBW() const
Definition: SkRasterClip.h:42
const SkIRect & getBounds() const
Definition: SkRegion.h:165
constexpr int32_t x() const
Definition: SkRect.h:141
constexpr int32_t y() const
Definition: SkRect.h:148
bool intersect(const SkIRect &r)
Definition: SkRect.h:513
bool containsNoEmptyCheck(const SkIRect &r) const
Definition: SkRect.h:499
constexpr SkISize size() const
Definition: SkRect.h:172
static SkImageInfo MakeN32Premul(int width, int height)
Definition: SkMask.h:25
const uint32_t fRowBytes
Definition: SkMask.h:43
@ kARGB32_Format
SkPMColor.
Definition: SkMask.h:30
uint8_t const *const fImage
Definition: SkMask.h:41
const SkIRect fBounds
Definition: SkMask.h:42
const Format fFormat
Definition: SkMask.h:44

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