1 /*
2 * Copyright 2016 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 #include "include/core/SkColor.h"
9 #include "include/core/SkPaint.h"
10 #include "include/core/SkShader.h"
11 #include "include/private/SkTo.h"
12 #include "src/core/SkArenaAlloc.h"
13 #include "src/core/SkBlendModePriv.h"
14 #include "src/core/SkBlitter.h"
15 #include "src/core/SkColorFilterBase.h"
16 #include "src/core/SkColorSpacePriv.h"
17 #include "src/core/SkColorSpaceXformSteps.h"
18 #include "src/core/SkMatrixProvider.h"
19 #include "src/core/SkOpts.h"
20 #include "src/core/SkRasterPipeline.h"
21 #include "src/core/SkUtils.h"
22 #include "src/shaders/SkShaderBase.h"
23
24 class SkRasterPipelineBlitter final : public SkBlitter {
25 public:
26 // This is our common entrypoint for creating the blitter once we've sorted out shaders.
27 static SkBlitter* Create(const SkPixmap&, const SkPaint&, SkArenaAlloc*,
28 const SkRasterPipeline& shaderPipeline,
29 bool is_opaque, bool is_constant,
30 sk_sp<SkShader> clipShader);
31
SkRasterPipelineBlitter(SkPixmap dst,SkBlendMode blend,SkArenaAlloc * alloc)32 SkRasterPipelineBlitter(SkPixmap dst,
33 SkBlendMode blend,
34 SkArenaAlloc* alloc)
35 : fDst(dst)
36 , fBlend(blend)
37 , fAlloc(alloc)
38 , fColorPipeline(alloc)
39 {}
40
41 void blitH (int x, int y, int w) override;
42 void blitAntiH (int x, int y, const SkAlpha[], const int16_t[]) override;
43 void blitAntiH2(int x, int y, U8CPU a0, U8CPU a1) override;
44 void blitAntiV2(int x, int y, U8CPU a0, U8CPU a1) override;
45 void blitMask (const SkMask&, const SkIRect& clip) override;
46 void blitRect (int x, int y, int width, int height) override;
47 void blitV (int x, int y, int height, SkAlpha alpha) override;
48
49 private:
50 void append_load_dst (SkRasterPipeline*) const;
51 void append_store (SkRasterPipeline*) const;
52
53 // these check internally, and only append if there was a native clipShader
54 void append_clip_scale (SkRasterPipeline*) const;
55 void append_clip_lerp (SkRasterPipeline*) const;
56
57 SkPixmap fDst;
58 SkBlendMode fBlend;
59 SkArenaAlloc* fAlloc;
60 SkRasterPipeline fColorPipeline;
61 // set to pipeline storage (for alpha) if we have a clipShader
62 void* fClipShaderBuffer = nullptr; // "native" : float or U16
63
64 SkRasterPipeline_MemoryCtx
65 fDstPtr = {nullptr,0}, // Always points to the top-left of fDst.
66 fMaskPtr = {nullptr,0}; // Updated each call to blitMask().
67 SkRasterPipeline_EmbossCtx fEmbossCtx; // Used only for k3D_Format masks.
68
69 // We may be able to specialize blitH() or blitRect() into a memset.
70 void (*fMemset2D)(SkPixmap*, int x,int y, int w,int h, uint64_t color) = nullptr;
71 uint64_t fMemsetColor = 0; // Big enough for largest memsettable dst format, F16.
72
73 // Built lazily on first use.
74 std::function<void(size_t, size_t, size_t, size_t)> fBlitRect,
75 fBlitAntiH,
76 fBlitMaskA8,
77 fBlitMaskLCD16,
78 fBlitMask3D;
79
80 // These values are pointed to by the blit pipelines above,
81 // which allows us to adjust them from call to call.
82 float fCurrentCoverage = 0.0f;
83 float fDitherRate = 0.0f;
84
85 using INHERITED = SkBlitter;
86 };
87
SkCreateRasterPipelineBlitter(const SkPixmap & dst,const SkPaint & paint,const SkMatrixProvider & matrixProvider,SkArenaAlloc * alloc,sk_sp<SkShader> clipShader)88 SkBlitter* SkCreateRasterPipelineBlitter(const SkPixmap& dst,
89 const SkPaint& paint,
90 const SkMatrixProvider& matrixProvider,
91 SkArenaAlloc* alloc,
92 sk_sp<SkShader> clipShader) {
93 SkColorSpace* dstCS = dst.colorSpace();
94 SkColorType dstCT = dst.colorType();
95 SkColor4f paintColor = paint.getColor4f();
96 SkColorSpaceXformSteps(sk_srgb_singleton(), kUnpremul_SkAlphaType,
97 dstCS, kUnpremul_SkAlphaType).apply(paintColor.vec());
98
99 auto shader = as_SB(paint.getShader());
100
101 SkRasterPipeline_<256> shaderPipeline;
102 if (!shader) {
103 // Having no shader makes things nice and easy... just use the paint color.
104 shaderPipeline.append_constant_color(alloc, paintColor.premul().vec());
105 bool is_opaque = paintColor.fA == 1.0f,
106 is_constant = true;
107 return SkRasterPipelineBlitter::Create(dst, paint, alloc,
108 shaderPipeline, is_opaque, is_constant,
109 std::move(clipShader));
110 }
111
112 bool is_opaque = shader->isOpaque() && paintColor.fA == 1.0f;
113 bool is_constant = shader->isConstant();
114
115 if (shader->appendStages(
116 {&shaderPipeline, alloc, dstCT, dstCS, paint, nullptr, matrixProvider})) {
117 if (paintColor.fA != 1.0f) {
118 shaderPipeline.append(SkRasterPipeline::scale_1_float,
119 alloc->make<float>(paintColor.fA));
120 }
121 return SkRasterPipelineBlitter::Create(dst, paint, alloc,
122 shaderPipeline, is_opaque, is_constant,
123 std::move(clipShader));
124 }
125
126 // The shader can't draw with SkRasterPipeline.
127 return nullptr;
128 }
129
SkCreateRasterPipelineBlitter(const SkPixmap & dst,const SkPaint & paint,const SkRasterPipeline & shaderPipeline,bool is_opaque,SkArenaAlloc * alloc,sk_sp<SkShader> clipShader)130 SkBlitter* SkCreateRasterPipelineBlitter(const SkPixmap& dst,
131 const SkPaint& paint,
132 const SkRasterPipeline& shaderPipeline,
133 bool is_opaque,
134 SkArenaAlloc* alloc,
135 sk_sp<SkShader> clipShader) {
136 bool is_constant = false; // If this were the case, it'd be better to just set a paint color.
137 return SkRasterPipelineBlitter::Create(dst, paint, alloc,
138 shaderPipeline, is_opaque, is_constant,
139 clipShader);
140 }
141
Create(const SkPixmap & dst,const SkPaint & paint,SkArenaAlloc * alloc,const SkRasterPipeline & shaderPipeline,bool is_opaque,bool is_constant,sk_sp<SkShader> clipShader)142 SkBlitter* SkRasterPipelineBlitter::Create(const SkPixmap& dst,
143 const SkPaint& paint,
144 SkArenaAlloc* alloc,
145 const SkRasterPipeline& shaderPipeline,
146 bool is_opaque,
147 bool is_constant,
148 sk_sp<SkShader> clipShader) {
149 auto blitter = alloc->make<SkRasterPipelineBlitter>(dst,
150 paint.getBlendMode(),
151 alloc);
152
153
154 // Our job in this factory is to fill out the blitter's color pipeline.
155 // This is the common front of the full blit pipelines, each constructed lazily on first use.
156 // The full blit pipelines handle reading and writing the dst, blending, coverage, dithering.
157 auto colorPipeline = &blitter->fColorPipeline;
158
159 if (clipShader) {
160 auto clipP = colorPipeline;
161 SkPaint clipPaint; // just need default values
162 SkColorType clipCT = kRGBA_8888_SkColorType;
163 SkColorSpace* clipCS = nullptr;
164 SkSimpleMatrixProvider clipMatrixProvider(SkMatrix::I());
165 SkStageRec rec = {clipP, alloc, clipCT, clipCS, clipPaint, nullptr, clipMatrixProvider};
166 if (as_SB(clipShader)->appendStages(rec)) {
167 struct Storage {
168 // large enough for highp (float) or lowp(U16)
169 float fA[SkRasterPipeline_kMaxStride];
170 };
171 auto storage = alloc->make<Storage>();
172 clipP->append(SkRasterPipeline::store_src_a, storage->fA);
173 blitter->fClipShaderBuffer = storage->fA;
174 is_constant = false;
175 } else {
176 return nullptr;
177 }
178 }
179
180 // Let's get the shader in first.
181 colorPipeline->extend(shaderPipeline);
182
183 // If there's a color filter it comes next.
184 if (auto colorFilter = paint.getColorFilter()) {
185 SkSimpleMatrixProvider matrixProvider(SkMatrix::I());
186 SkStageRec rec = {
187 colorPipeline, alloc, dst.colorType(), dst.colorSpace(), paint, nullptr, matrixProvider
188 };
189 if (!as_CFB(colorFilter)->appendStages(rec, is_opaque)) {
190 return nullptr;
191 }
192 is_opaque = is_opaque && as_CFB(colorFilter)->isAlphaUnchanged();
193 }
194
195 // Not all formats make sense to dither (think, F16). We set their dither rate
196 // to zero. We only dither non-constant shaders, so is_constant won't change here.
197 if (paint.isDither() && !is_constant) {
198 switch (dst.info().colorType()) {
199 case kARGB_4444_SkColorType: blitter->fDitherRate = 1/15.0f; break;
200 case kRGB_565_SkColorType: blitter->fDitherRate = 1/63.0f; break;
201 case kGray_8_SkColorType:
202 case kRGB_888x_SkColorType:
203 case kRGBA_8888_SkColorType:
204 case kBGRA_8888_SkColorType: blitter->fDitherRate = 1/255.0f; break;
205 case kRGB_101010x_SkColorType:
206 case kRGBA_1010102_SkColorType:
207 case kBGR_101010x_SkColorType:
208 case kBGRA_1010102_SkColorType: blitter->fDitherRate = 1/1023.0f; break;
209
210 case kUnknown_SkColorType:
211 case kAlpha_8_SkColorType:
212 case kRGBA_F16_SkColorType:
213 case kRGBA_F16Norm_SkColorType:
214 case kRGBA_F32_SkColorType:
215 case kR8G8_unorm_SkColorType:
216 case kA16_float_SkColorType:
217 case kA16_unorm_SkColorType:
218 case kR16G16_float_SkColorType:
219 case kR16G16_unorm_SkColorType:
220 case kR16G16B16A16_unorm_SkColorType: blitter->fDitherRate = 0.0f; break;
221 }
222 if (blitter->fDitherRate > 0.0f) {
223 colorPipeline->append(SkRasterPipeline::dither, &blitter->fDitherRate);
224 }
225 }
226
227 // We're logically done here. The code between here and return blitter is all optimization.
228
229 // A pipeline that's still constant here can collapse back into a constant color.
230 if (is_constant) {
231 SkColor4f constantColor;
232 SkRasterPipeline_MemoryCtx constantColorPtr = { &constantColor, 0 };
233 colorPipeline->append_gamut_clamp_if_normalized(dst.info());
234 colorPipeline->append(SkRasterPipeline::store_f32, &constantColorPtr);
235 colorPipeline->run(0,0,1,1);
236 colorPipeline->reset();
237 colorPipeline->append_constant_color(alloc, constantColor);
238
239 is_opaque = constantColor.fA == 1.0f;
240 }
241
242 // We can strength-reduce SrcOver into Src when opaque.
243 if (is_opaque && blitter->fBlend == SkBlendMode::kSrcOver) {
244 blitter->fBlend = SkBlendMode::kSrc;
245 }
246
247 // When we're drawing a constant color in Src mode, we can sometimes just memset.
248 // (The previous two optimizations help find more opportunities for this one.)
249 if (is_constant && blitter->fBlend == SkBlendMode::kSrc) {
250 // Run our color pipeline all the way through to produce what we'd memset when we can.
251 // Not all blits can memset, so we need to keep colorPipeline too.
252 SkRasterPipeline_<256> p;
253 p.extend(*colorPipeline);
254 p.append_gamut_clamp_if_normalized(dst.info());
255 blitter->fDstPtr = SkRasterPipeline_MemoryCtx{&blitter->fMemsetColor, 0};
256 blitter->append_store(&p);
257 p.run(0,0,1,1);
258
259 switch (blitter->fDst.shiftPerPixel()) {
260 case 0: blitter->fMemset2D = [](SkPixmap* dst, int x,int y, int w,int h, uint64_t c) {
261 void* p = dst->writable_addr(x,y);
262 while (h --> 0) {
263 memset(p, c, w);
264 p = SkTAddOffset<void>(p, dst->rowBytes());
265 }
266 }; break;
267
268 case 1: blitter->fMemset2D = [](SkPixmap* dst, int x,int y, int w,int h, uint64_t c) {
269 SkOpts::rect_memset16(dst->writable_addr16(x,y), c, w, dst->rowBytes(), h);
270 }; break;
271
272 case 2: blitter->fMemset2D = [](SkPixmap* dst, int x,int y, int w,int h, uint64_t c) {
273 SkOpts::rect_memset32(dst->writable_addr32(x,y), c, w, dst->rowBytes(), h);
274 }; break;
275
276 case 3: blitter->fMemset2D = [](SkPixmap* dst, int x,int y, int w,int h, uint64_t c) {
277 SkOpts::rect_memset64(dst->writable_addr64(x,y), c, w, dst->rowBytes(), h);
278 }; break;
279
280 // TODO(F32)?
281 }
282 }
283
284 blitter->fDstPtr = SkRasterPipeline_MemoryCtx{
285 blitter->fDst.writable_addr(),
286 blitter->fDst.rowBytesAsPixels(),
287 };
288
289 return blitter;
290 }
291
append_load_dst(SkRasterPipeline * p) const292 void SkRasterPipelineBlitter::append_load_dst(SkRasterPipeline* p) const {
293 p->append_load_dst(fDst.info().colorType(), &fDstPtr);
294 if (fDst.info().alphaType() == kUnpremul_SkAlphaType) {
295 p->append(SkRasterPipeline::premul_dst);
296 }
297 }
298
append_store(SkRasterPipeline * p) const299 void SkRasterPipelineBlitter::append_store(SkRasterPipeline* p) const {
300 if (fDst.info().alphaType() == kUnpremul_SkAlphaType) {
301 p->append(SkRasterPipeline::unpremul);
302 }
303 p->append_store(fDst.info().colorType(), &fDstPtr);
304 }
305
append_clip_scale(SkRasterPipeline * p) const306 void SkRasterPipelineBlitter::append_clip_scale(SkRasterPipeline* p) const {
307 if (fClipShaderBuffer) {
308 p->append(SkRasterPipeline::scale_native, fClipShaderBuffer);
309 }
310 }
311
append_clip_lerp(SkRasterPipeline * p) const312 void SkRasterPipelineBlitter::append_clip_lerp(SkRasterPipeline* p) const {
313 if (fClipShaderBuffer) {
314 p->append(SkRasterPipeline::lerp_native, fClipShaderBuffer);
315 }
316 }
317
blitH(int x,int y,int w)318 void SkRasterPipelineBlitter::blitH(int x, int y, int w) {
319 this->blitRect(x,y,w,1);
320 }
321
blitRect(int x,int y,int w,int h)322 void SkRasterPipelineBlitter::blitRect(int x, int y, int w, int h) {
323 if (fMemset2D) {
324 fMemset2D(&fDst, x,y, w,h, fMemsetColor);
325 return;
326 }
327
328 if (!fBlitRect) {
329 SkRasterPipeline p(fAlloc);
330 p.extend(fColorPipeline);
331 p.append_gamut_clamp_if_normalized(fDst.info());
332 if (fBlend == SkBlendMode::kSrcOver
333 && (fDst.info().colorType() == kRGBA_8888_SkColorType ||
334 fDst.info().colorType() == kBGRA_8888_SkColorType)
335 && !fDst.colorSpace()
336 && fDst.info().alphaType() != kUnpremul_SkAlphaType
337 && fDitherRate == 0.0f) {
338 if (fDst.info().colorType() == kBGRA_8888_SkColorType) {
339 p.append(SkRasterPipeline::swap_rb);
340 }
341 this->append_clip_scale(&p);
342 p.append(SkRasterPipeline::srcover_rgba_8888, &fDstPtr);
343 } else {
344 if (fBlend != SkBlendMode::kSrc) {
345 this->append_load_dst(&p);
346 SkBlendMode_AppendStages(fBlend, &p);
347 this->append_clip_lerp(&p);
348 } else if (fClipShaderBuffer) {
349 this->append_load_dst(&p);
350 this->append_clip_lerp(&p);
351 }
352 this->append_store(&p);
353 }
354 fBlitRect = p.compile();
355 }
356
357 fBlitRect(x,y,w,h);
358 }
359
blitAntiH(int x,int y,const SkAlpha aa[],const int16_t runs[])360 void SkRasterPipelineBlitter::blitAntiH(int x, int y, const SkAlpha aa[], const int16_t runs[]) {
361 if (!fBlitAntiH) {
362 SkRasterPipeline p(fAlloc);
363 p.extend(fColorPipeline);
364 p.append_gamut_clamp_if_normalized(fDst.info());
365 if (SkBlendMode_ShouldPreScaleCoverage(fBlend, /*rgb_coverage=*/false)) {
366 p.append(SkRasterPipeline::scale_1_float, &fCurrentCoverage);
367 this->append_clip_scale(&p);
368 this->append_load_dst(&p);
369 SkBlendMode_AppendStages(fBlend, &p);
370 } else {
371 this->append_load_dst(&p);
372 SkBlendMode_AppendStages(fBlend, &p);
373 p.append(SkRasterPipeline::lerp_1_float, &fCurrentCoverage);
374 this->append_clip_lerp(&p);
375 }
376
377 this->append_store(&p);
378 fBlitAntiH = p.compile();
379 }
380
381 for (int16_t run = *runs; run > 0; run = *runs) {
382 switch (*aa) {
383 case 0x00: break;
384 case 0xff: this->blitH(x,y,run); break;
385 default:
386 fCurrentCoverage = *aa * (1/255.0f);
387 fBlitAntiH(x,y,run,1);
388 }
389 x += run;
390 runs += run;
391 aa += run;
392 }
393 }
394
blitAntiH2(int x,int y,U8CPU a0,U8CPU a1)395 void SkRasterPipelineBlitter::blitAntiH2(int x, int y, U8CPU a0, U8CPU a1) {
396 SkIRect clip = {x,y, x+2,y+1};
397 uint8_t coverage[] = { (uint8_t)a0, (uint8_t)a1 };
398
399 SkMask mask;
400 mask.fImage = coverage;
401 mask.fBounds = clip;
402 mask.fRowBytes = 2;
403 mask.fFormat = SkMask::kA8_Format;
404
405 this->blitMask(mask, clip);
406 }
407
blitAntiV2(int x,int y,U8CPU a0,U8CPU a1)408 void SkRasterPipelineBlitter::blitAntiV2(int x, int y, U8CPU a0, U8CPU a1) {
409 SkIRect clip = {x,y, x+1,y+2};
410 uint8_t coverage[] = { (uint8_t)a0, (uint8_t)a1 };
411
412 SkMask mask;
413 mask.fImage = coverage;
414 mask.fBounds = clip;
415 mask.fRowBytes = 1;
416 mask.fFormat = SkMask::kA8_Format;
417
418 this->blitMask(mask, clip);
419 }
420
blitV(int x,int y,int height,SkAlpha alpha)421 void SkRasterPipelineBlitter::blitV(int x, int y, int height, SkAlpha alpha) {
422 SkIRect clip = {x,y, x+1,y+height};
423
424 SkMask mask;
425 mask.fImage = α
426 mask.fBounds = clip;
427 mask.fRowBytes = 0; // so we reuse the 1 "row" for all of height
428 mask.fFormat = SkMask::kA8_Format;
429
430 this->blitMask(mask, clip);
431 }
432
blitMask(const SkMask & mask,const SkIRect & clip)433 void SkRasterPipelineBlitter::blitMask(const SkMask& mask, const SkIRect& clip) {
434 if (mask.fFormat == SkMask::kBW_Format) {
435 // TODO: native BW masks?
436 return INHERITED::blitMask(mask, clip);
437 }
438
439 // ARGB and SDF masks shouldn't make it here.
440 SkASSERT(mask.fFormat == SkMask::kA8_Format
441 || mask.fFormat == SkMask::kLCD16_Format
442 || mask.fFormat == SkMask::k3D_Format);
443
444 auto extract_mask_plane = [&mask](int plane, SkRasterPipeline_MemoryCtx* ctx) {
445 // LCD is 16-bit per pixel; A8 and 3D are 8-bit per pixel.
446 size_t bpp = mask.fFormat == SkMask::kLCD16_Format ? 2 : 1;
447
448 // Select the right mask plane. Usually plane == 0 and this is just mask.fImage.
449 auto ptr = (uintptr_t)mask.fImage
450 + plane * mask.computeImageSize();
451
452 // Update ctx to point "into" this current mask, but lined up with fDstPtr at (0,0).
453 // This sort of trickery upsets UBSAN (pointer-overflow) so our ptr must be a uintptr_t.
454 // mask.fRowBytes is a uint32_t, which would break our addressing math on 64-bit builds.
455 size_t rowBytes = mask.fRowBytes;
456 ctx->stride = rowBytes / bpp;
457 ctx->pixels = (void*)(ptr - mask.fBounds.left() * bpp
458 - mask.fBounds.top() * rowBytes);
459 };
460
461 extract_mask_plane(0, &fMaskPtr);
462 if (mask.fFormat == SkMask::k3D_Format) {
463 extract_mask_plane(1, &fEmbossCtx.mul);
464 extract_mask_plane(2, &fEmbossCtx.add);
465 }
466
467 // Lazily build whichever pipeline we need, specialized for each mask format.
468 if (mask.fFormat == SkMask::kA8_Format && !fBlitMaskA8) {
469 SkRasterPipeline p(fAlloc);
470 p.extend(fColorPipeline);
471 p.append_gamut_clamp_if_normalized(fDst.info());
472 if (SkBlendMode_ShouldPreScaleCoverage(fBlend, /*rgb_coverage=*/false)) {
473 p.append(SkRasterPipeline::scale_u8, &fMaskPtr);
474 this->append_clip_scale(&p);
475 this->append_load_dst(&p);
476 SkBlendMode_AppendStages(fBlend, &p);
477 } else {
478 this->append_load_dst(&p);
479 SkBlendMode_AppendStages(fBlend, &p);
480 p.append(SkRasterPipeline::lerp_u8, &fMaskPtr);
481 this->append_clip_lerp(&p);
482 }
483 this->append_store(&p);
484 fBlitMaskA8 = p.compile();
485 }
486 if (mask.fFormat == SkMask::kLCD16_Format && !fBlitMaskLCD16) {
487 SkRasterPipeline p(fAlloc);
488 p.extend(fColorPipeline);
489 p.append_gamut_clamp_if_normalized(fDst.info());
490 if (SkBlendMode_ShouldPreScaleCoverage(fBlend, /*rgb_coverage=*/true)) {
491 // Somewhat unusually, scale_565 needs dst loaded first.
492 this->append_load_dst(&p);
493 p.append(SkRasterPipeline::scale_565, &fMaskPtr);
494 this->append_clip_scale(&p);
495 SkBlendMode_AppendStages(fBlend, &p);
496 } else {
497 this->append_load_dst(&p);
498 SkBlendMode_AppendStages(fBlend, &p);
499 p.append(SkRasterPipeline::lerp_565, &fMaskPtr);
500 this->append_clip_lerp(&p);
501 }
502 this->append_store(&p);
503 fBlitMaskLCD16 = p.compile();
504 }
505 if (mask.fFormat == SkMask::k3D_Format && !fBlitMask3D) {
506 SkRasterPipeline p(fAlloc);
507 p.extend(fColorPipeline);
508 // This bit is where we differ from kA8_Format:
509 p.append(SkRasterPipeline::emboss, &fEmbossCtx);
510 // Now onward just as kA8.
511 p.append_gamut_clamp_if_normalized(fDst.info());
512 if (SkBlendMode_ShouldPreScaleCoverage(fBlend, /*rgb_coverage=*/false)) {
513 p.append(SkRasterPipeline::scale_u8, &fMaskPtr);
514 this->append_clip_scale(&p);
515 this->append_load_dst(&p);
516 SkBlendMode_AppendStages(fBlend, &p);
517 } else {
518 this->append_load_dst(&p);
519 SkBlendMode_AppendStages(fBlend, &p);
520 p.append(SkRasterPipeline::lerp_u8, &fMaskPtr);
521 this->append_clip_lerp(&p);
522 }
523 this->append_store(&p);
524 fBlitMask3D = p.compile();
525 }
526
527 std::function<void(size_t,size_t,size_t,size_t)>* blitter = nullptr;
528 switch (mask.fFormat) {
529 case SkMask::kA8_Format: blitter = &fBlitMaskA8; break;
530 case SkMask::kLCD16_Format: blitter = &fBlitMaskLCD16; break;
531 case SkMask::k3D_Format: blitter = &fBlitMask3D; break;
532 default:
533 SkASSERT(false);
534 return;
535 }
536
537 SkASSERT(blitter);
538 (*blitter)(clip.left(),clip.top(), clip.width(),clip.height());
539 }
540