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