Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Static Public Member Functions | List of all members
SkRasterPipeline Class Reference

#include <SkRasterPipeline.h>

Inheritance diagram for SkRasterPipeline:
SkRasterPipeline_< 256 > SkRasterPipeline_< bytes >

Classes

struct  StageList
 

Public Member Functions

 SkRasterPipeline (SkArenaAlloc *)
 
 SkRasterPipeline (const SkRasterPipeline &)=delete
 
 SkRasterPipeline (SkRasterPipeline &&)=default
 
SkRasterPipelineoperator= (const SkRasterPipeline &)=delete
 
SkRasterPipelineoperator= (SkRasterPipeline &&)=default
 
void reset ()
 
void append (SkRasterPipelineOp, void *=nullptr)
 
void append (SkRasterPipelineOp op, const void *ctx)
 
void append (SkRasterPipelineOp, uintptr_t ctx)
 
void extend (const SkRasterPipeline &)
 
void run (size_t x, size_t y, size_t w, size_t h) const
 
std::function< void(size_t, size_t, size_t, size_t)> compile () const
 
const StageListgetStageList () const
 
int getNumStages () const
 
void dump () const
 
void appendMatrix (SkArenaAlloc *, const SkMatrix &)
 
void appendConstantColor (SkArenaAlloc *, const float rgba[4])
 
void appendConstantColor (SkArenaAlloc *alloc, const SkColor4f &color)
 
void appendSetRGB (SkArenaAlloc *, const float rgb[3])
 
void appendSetRGB (SkArenaAlloc *alloc, const SkColor4f &color)
 
void appendLoad (SkColorType, const SkRasterPipeline_MemoryCtx *)
 
void appendLoadDst (SkColorType, const SkRasterPipeline_MemoryCtx *)
 
void appendStore (SkColorType, const SkRasterPipeline_MemoryCtx *)
 
void appendClampIfNormalized (const SkImageInfo &)
 
void appendTransferFunction (const skcms_TransferFunction &)
 
void appendStackRewind ()
 
bool empty () const
 

Static Public Member Functions

static const char * GetOpName (SkRasterPipelineOp op)
 

Detailed Description

Definition at line 68 of file SkRasterPipeline.h.

Constructor & Destructor Documentation

◆ SkRasterPipeline() [1/3]

SkRasterPipeline::SkRasterPipeline ( SkArenaAlloc alloc)
explicit

Definition at line 31 of file SkRasterPipeline.cpp.

31 : fAlloc(alloc) {
32 this->reset();
33}

◆ SkRasterPipeline() [2/3]

SkRasterPipeline::SkRasterPipeline ( const SkRasterPipeline )
delete

◆ SkRasterPipeline() [3/3]

SkRasterPipeline::SkRasterPipeline ( SkRasterPipeline &&  )
default

Member Function Documentation

◆ append() [1/3]

void SkRasterPipeline::append ( SkRasterPipelineOp  op,
const void *  ctx 
)
inline

Definition at line 81 of file SkRasterPipeline.h.

81{ this->append(op,const_cast<void*>(ctx)); }
void append(SkRasterPipelineOp, void *=nullptr)

◆ append() [2/3]

void SkRasterPipeline::append ( SkRasterPipelineOp  op,
uintptr_t  ctx 
)

Definition at line 161 of file SkRasterPipeline.cpp.

161 {
162 void* ptrCtx;
163 memcpy(&ptrCtx, &ctx, sizeof(ctx));
164 this->append(op, ptrCtx);
165}

◆ append() [3/3]

void SkRasterPipeline::append ( SkRasterPipelineOp  op,
void *  ctx = nullptr 
)

Definition at line 44 of file SkRasterPipeline.cpp.

44 {
45 SkASSERT(op != Op::uniform_color); // Please use appendConstantColor().
46 SkASSERT(op != Op::unbounded_uniform_color); // Please use appendConstantColor().
47 SkASSERT(op != Op::set_rgb); // Please use appendSetRGB().
48 SkASSERT(op != Op::unbounded_set_rgb); // Please use appendSetRGB().
49 SkASSERT(op != Op::parametric); // Please use appendTransferFunction().
50 SkASSERT(op != Op::gamma_); // Please use appendTransferFunction().
51 SkASSERT(op != Op::PQish); // Please use appendTransferFunction().
52 SkASSERT(op != Op::HLGish); // Please use appendTransferFunction().
53 SkASSERT(op != Op::HLGinvish); // Please use appendTransferFunction().
54 SkASSERT(op != Op::stack_checkpoint); // Please use appendStackRewind().
55 SkASSERT(op != Op::stack_rewind); // Please use appendStackRewind().
56 this->uncheckedAppend(op, ctx);
57}
#define SkASSERT(cond)
Definition: SkAssert.h:116
static void ABI stack_checkpoint(Params *params, SkRasterPipelineStage *program, F r, F g, F b, F a)
static void ABI stack_rewind(Params *params, SkRasterPipelineStage *program, F r, F g, F b, F a)

◆ appendClampIfNormalized()

void SkRasterPipeline::appendClampIfNormalized ( const SkImageInfo info)

Definition at line 534 of file SkRasterPipeline.cpp.

534 {
535 if (SkColorTypeIsNormalized(info.colorType())) {
536 this->uncheckedAppend(Op::clamp_01, nullptr);
537 }
538}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
static bool SkColorTypeIsNormalized(SkColorType ct)

◆ appendConstantColor() [1/2]

void SkRasterPipeline::appendConstantColor ( SkArenaAlloc alloc,
const float  rgba[4] 
)

Definition at line 257 of file SkRasterPipeline.cpp.

257 {
258 // r,g,b might be outside [0,1], but alpha should probably always be in [0,1].
259 SkASSERT(0 <= rgba[3] && rgba[3] <= 1);
260
261 if (rgba[0] == 0 && rgba[1] == 0 && rgba[2] == 0 && rgba[3] == 1) {
262 this->append(Op::black_color);
263 } else if (rgba[0] == 1 && rgba[1] == 1 && rgba[2] == 1 && rgba[3] == 1) {
264 this->append(Op::white_color);
265 } else {
266 auto ctx = alloc->make<SkRasterPipeline_UniformColorCtx>();
268 color.store(&ctx->r);
269
270 // uniform_color requires colors in range and can go lowp,
271 // while unbounded_uniform_color supports out-of-range colors too but not lowp.
272 if (0 <= rgba[0] && rgba[0] <= rgba[3] &&
273 0 <= rgba[1] && rgba[1] <= rgba[3] &&
274 0 <= rgba[2] && rgba[2] <= rgba[3]) {
275 // To make loads more direct, we store 8-bit values in 16-bit slots.
276 color = color * 255.0f + 0.5f;
277 ctx->rgba[0] = (uint16_t)color[0];
278 ctx->rgba[1] = (uint16_t)color[1];
279 ctx->rgba[2] = (uint16_t)color[2];
280 ctx->rgba[3] = (uint16_t)color[3];
281 this->uncheckedAppend(Op::uniform_color, ctx);
282 } else {
283 this->uncheckedAppend(Op::unbounded_uniform_color, ctx);
284 }
285 }
286}
static const uint32_t rgba[kNumPixels]
auto make(Ctor &&ctor) -> decltype(ctor(nullptr))
Definition: SkArenaAlloc.h:120
DlColor color
Definition: SkVx.h:83
static SKVX_ALWAYS_INLINE Vec Load(const void *ptr)
Definition: SkVx.h:109

◆ appendConstantColor() [2/2]

void SkRasterPipeline::appendConstantColor ( SkArenaAlloc alloc,
const SkColor4f color 
)
inline

Definition at line 115 of file SkRasterPipeline.h.

115 {
116 this->appendConstantColor(alloc, color.vec());
117 }
void appendConstantColor(SkArenaAlloc *, const float rgba[4])

◆ appendLoad()

void SkRasterPipeline::appendLoad ( SkColorType  ct,
const SkRasterPipeline_MemoryCtx ctx 
)

Definition at line 319 of file SkRasterPipeline.cpp.

319 {
320 switch (ct) {
321 case kUnknown_SkColorType: SkASSERT(false); break;
322
323 case kAlpha_8_SkColorType: this->append(Op::load_a8, ctx); break;
324 case kA16_unorm_SkColorType: this->append(Op::load_a16, ctx); break;
325 case kA16_float_SkColorType: this->append(Op::load_af16, ctx); break;
326 case kRGB_565_SkColorType: this->append(Op::load_565, ctx); break;
327 case kARGB_4444_SkColorType: this->append(Op::load_4444, ctx); break;
328 case kR8G8_unorm_SkColorType: this->append(Op::load_rg88, ctx); break;
329 case kR16G16_unorm_SkColorType: this->append(Op::load_rg1616, ctx); break;
330 case kR16G16_float_SkColorType: this->append(Op::load_rgf16, ctx); break;
331 case kRGBA_8888_SkColorType: this->append(Op::load_8888, ctx); break;
332 case kRGBA_1010102_SkColorType: this->append(Op::load_1010102, ctx); break;
333 case kR16G16B16A16_unorm_SkColorType:this->append(Op::load_16161616,ctx); break;
335 case kRGBA_F16_SkColorType: this->append(Op::load_f16, ctx); break;
336 case kRGBA_F32_SkColorType: this->append(Op::load_f32, ctx); break;
337 case kRGBA_10x6_SkColorType: this->append(Op::load_10x6, ctx); break;
338
339 case kGray_8_SkColorType: this->append(Op::load_a8, ctx);
340 this->append(Op::alpha_to_gray);
341 break;
342
343 case kR8_unorm_SkColorType: this->append(Op::load_a8, ctx);
344 this->append(Op::alpha_to_red);
345 break;
346
347 case kRGB_888x_SkColorType: this->append(Op::load_8888, ctx);
348 this->append(Op::force_opaque);
349 break;
350
351 case kBGRA_1010102_SkColorType: this->append(Op::load_1010102, ctx);
352 this->append(Op::swap_rb);
353 break;
354
355 case kRGB_101010x_SkColorType: this->append(Op::load_1010102, ctx);
356 this->append(Op::force_opaque);
357 break;
358
359 case kBGR_101010x_SkColorType: this->append(Op::load_1010102, ctx);
360 this->append(Op::force_opaque);
361 this->append(Op::swap_rb);
362 break;
363
364 case kBGRA_10101010_XR_SkColorType: this->append(Op::load_10101010_xr, ctx);
365 this->append(Op::swap_rb);
366 break;
367
368 case kBGR_101010x_XR_SkColorType: this->append(Op::load_1010102_xr, ctx);
369 this->append(Op::force_opaque);
370 this->append(Op::swap_rb);
371 break;
372
373 case kBGRA_8888_SkColorType: this->append(Op::load_8888, ctx);
374 this->append(Op::swap_rb);
375 break;
376
378 this->append(Op::load_8888, ctx);
380 break;
381 }
382}
@ kR16G16B16A16_unorm_SkColorType
pixel with a little endian uint16_t for red, green, blue
Definition: SkColorType.h:50
@ kRGBA_10x6_SkColorType
pixel with 10 used bits (most significant) followed by 6 unused
Definition: SkColorType.h:33
@ kR8_unorm_SkColorType
Definition: SkColorType.h:54
@ kBGR_101010x_SkColorType
pixel with 10 bits each for blue, green, red; in 32-bit word
Definition: SkColorType.h:30
@ kARGB_4444_SkColorType
pixel with 4 bits for alpha, red, green, blue; in 16-bit word
Definition: SkColorType.h:23
@ kR8G8_unorm_SkColorType
pixel with a uint8_t for red and green
Definition: SkColorType.h:43
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
Definition: SkColorType.h:26
@ kA16_unorm_SkColorType
pixel with a little endian uint16_t for alpha
Definition: SkColorType.h:48
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
Definition: SkColorType.h:38
@ kAlpha_8_SkColorType
pixel with alpha in 8-bit byte
Definition: SkColorType.h:21
@ kRGB_101010x_SkColorType
pixel with 10 bits each for red, green, blue; in 32-bit word
Definition: SkColorType.h:29
@ kSRGBA_8888_SkColorType
Definition: SkColorType.h:53
@ kGray_8_SkColorType
pixel with grayscale level in 8-bit byte
Definition: SkColorType.h:35
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
Definition: SkColorType.h:22
@ kBGRA_10101010_XR_SkColorType
pixel with 10 bits each for blue, green, red, alpha; in 64-bit word, extended range
Definition: SkColorType.h:32
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition: SkColorType.h:24
@ kRGB_888x_SkColorType
pixel with 8 bits each for red, green, blue; in 32-bit word
Definition: SkColorType.h:25
@ kBGRA_1010102_SkColorType
10 bits for blue, green, red; 2 bits for alpha; in 32-bit word
Definition: SkColorType.h:28
@ kA16_float_SkColorType
pixel with a half float for alpha
Definition: SkColorType.h:45
@ kRGBA_F32_SkColorType
pixel using C float for red, green, blue, alpha; in 128-bit word
Definition: SkColorType.h:40
@ kRGBA_1010102_SkColorType
10 bits for red, green, blue; 2 bits for alpha; in 32-bit word
Definition: SkColorType.h:27
@ kBGR_101010x_XR_SkColorType
pixel with 10 bits each for blue, green, red; in 32-bit word, extended range
Definition: SkColorType.h:31
@ kR16G16_unorm_SkColorType
pixel with a little endian uint16_t for red and green
Definition: SkColorType.h:49
@ kRGBA_F16Norm_SkColorType
pixel with half floats in [0,1] for red, green, blue, alpha;
Definition: SkColorType.h:36
@ kUnknown_SkColorType
uninitialized
Definition: SkColorType.h:20
@ kR16G16_float_SkColorType
pixel with a half float for red and green
Definition: SkColorType.h:46
void appendTransferFunction(const skcms_TransferFunction &)
const skcms_TransferFunction * skcms_sRGB_TransferFunction()
Definition: skcms.cc:1587

◆ appendLoadDst()

void SkRasterPipeline::appendLoadDst ( SkColorType  ct,
const SkRasterPipeline_MemoryCtx ctx 
)

Definition at line 384 of file SkRasterPipeline.cpp.

384 {
385 switch (ct) {
386 case kUnknown_SkColorType: SkASSERT(false); break;
387
388 case kAlpha_8_SkColorType: this->append(Op::load_a8_dst, ctx); break;
389 case kA16_unorm_SkColorType: this->append(Op::load_a16_dst, ctx); break;
390 case kA16_float_SkColorType: this->append(Op::load_af16_dst, ctx); break;
391 case kRGB_565_SkColorType: this->append(Op::load_565_dst, ctx); break;
392 case kARGB_4444_SkColorType: this->append(Op::load_4444_dst, ctx); break;
393 case kR8G8_unorm_SkColorType: this->append(Op::load_rg88_dst, ctx); break;
394 case kR16G16_unorm_SkColorType: this->append(Op::load_rg1616_dst, ctx); break;
395 case kR16G16_float_SkColorType: this->append(Op::load_rgf16_dst, ctx); break;
396 case kRGBA_8888_SkColorType: this->append(Op::load_8888_dst, ctx); break;
397 case kRGBA_1010102_SkColorType: this->append(Op::load_1010102_dst, ctx); break;
398 case kR16G16B16A16_unorm_SkColorType: this->append(Op::load_16161616_dst,ctx); break;
400 case kRGBA_F16_SkColorType: this->append(Op::load_f16_dst, ctx); break;
401 case kRGBA_F32_SkColorType: this->append(Op::load_f32_dst, ctx); break;
402 case kRGBA_10x6_SkColorType: this->append(Op::load_10x6_dst, ctx); break;
403
404 case kGray_8_SkColorType: this->append(Op::load_a8_dst, ctx);
405 this->append(Op::alpha_to_gray_dst);
406 break;
407
408 case kR8_unorm_SkColorType: this->append(Op::load_a8_dst, ctx);
409 this->append(Op::alpha_to_red_dst);
410 break;
411
412 case kRGB_888x_SkColorType: this->append(Op::load_8888_dst, ctx);
413 this->append(Op::force_opaque_dst);
414 break;
415
416 case kBGRA_1010102_SkColorType: this->append(Op::load_1010102_dst, ctx);
417 this->append(Op::swap_rb_dst);
418 break;
419
420 case kRGB_101010x_SkColorType: this->append(Op::load_1010102_dst, ctx);
421 this->append(Op::force_opaque_dst);
422 break;
423
424 case kBGR_101010x_SkColorType: this->append(Op::load_1010102_dst, ctx);
425 this->append(Op::force_opaque_dst);
426 this->append(Op::swap_rb_dst);
427 break;
428
429 case kBGR_101010x_XR_SkColorType: this->append(Op::load_1010102_xr_dst, ctx);
430 this->append(Op::force_opaque_dst);
431 this->append(Op::swap_rb_dst);
432 break;
433
434 case kBGRA_10101010_XR_SkColorType: this->append(Op::load_10101010_xr_dst, ctx);
435 this->append(Op::swap_rb_dst);
436 break;
437
438 case kBGRA_8888_SkColorType: this->append(Op::load_8888_dst, ctx);
439 this->append(Op::swap_rb_dst);
440 break;
441
443 // TODO: We could remove the double-swap if we had _dst versions of all the TF stages
444 this->append(Op::load_8888_dst, ctx);
445 this->append(Op::swap_src_dst);
447 this->append(Op::swap_src_dst);
448 break;
449 }
450}

◆ appendMatrix()

void SkRasterPipeline::appendMatrix ( SkArenaAlloc alloc,
const SkMatrix matrix 
)

Definition at line 288 of file SkRasterPipeline.cpp.

288 {
289 SkMatrix::TypeMask mt = matrix.getType();
290
291 if (mt == SkMatrix::kIdentity_Mask) {
292 return;
293 }
294 if (mt == SkMatrix::kTranslate_Mask) {
295 float* trans = alloc->makeArrayDefault<float>(2);
296 trans[0] = matrix.getTranslateX();
297 trans[1] = matrix.getTranslateY();
298 this->append(Op::matrix_translate, trans);
299 } else if ((mt | (SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask)) ==
301 float* scaleTrans = alloc->makeArrayDefault<float>(4);
302 scaleTrans[0] = matrix.getScaleX();
303 scaleTrans[1] = matrix.getScaleY();
304 scaleTrans[2] = matrix.getTranslateX();
305 scaleTrans[3] = matrix.getTranslateY();
306 this->append(Op::matrix_scale_translate, scaleTrans);
307 } else {
308 float* storage = alloc->makeArrayDefault<float>(9);
309 matrix.get9(storage);
310 if (!matrix.hasPerspective()) {
311 // note: asAffine and the 2x3 stage really only need 6 entries
312 this->append(Op::matrix_2x3, storage);
313 } else {
314 this->append(Op::matrix_perspective, storage);
315 }
316 }
317}
T * makeArrayDefault(size_t count)
Definition: SkArenaAlloc.h:171
@ kTranslate_Mask
translation SkMatrix
Definition: SkMatrix.h:193
@ kScale_Mask
scale SkMatrix
Definition: SkMatrix.h:194
@ kIdentity_Mask
identity SkMatrix; all bits clear
Definition: SkMatrix.h:192
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258

◆ appendSetRGB() [1/2]

void SkRasterPipeline::appendSetRGB ( SkArenaAlloc alloc,
const float  rgb[3] 
)

Definition at line 240 of file SkRasterPipeline.cpp.

240 {
241 auto arg = alloc->makeArrayDefault<float>(3);
242 arg[0] = rgb[0];
243 arg[1] = rgb[1];
244 arg[2] = rgb[2];
245
246 auto op = Op::unbounded_set_rgb;
247 if (0 <= rgb[0] && rgb[0] <= 1 &&
248 0 <= rgb[1] && rgb[1] <= 1 &&
249 0 <= rgb[2] && rgb[2] <= 1)
250 {
251 op = Op::set_rgb;
252 }
253
254 this->uncheckedAppend(op, arg);
255}

◆ appendSetRGB() [2/2]

void SkRasterPipeline::appendSetRGB ( SkArenaAlloc alloc,
const SkColor4f color 
)
inline

Definition at line 122 of file SkRasterPipeline.h.

122 {
123 this->appendSetRGB(alloc, color.vec());
124 }
void appendSetRGB(SkArenaAlloc *, const float rgb[3])

◆ appendStackRewind()

void SkRasterPipeline::appendStackRewind ( )

Definition at line 540 of file SkRasterPipeline.cpp.

540 {
541 if (!fRewindCtx) {
542 fRewindCtx = fAlloc->make<SkRasterPipeline_RewindCtx>();
543 }
544 this->uncheckedAppend(Op::stack_rewind, fRewindCtx);
545}

◆ appendStore()

void SkRasterPipeline::appendStore ( SkColorType  ct,
const SkRasterPipeline_MemoryCtx ctx 
)

Definition at line 452 of file SkRasterPipeline.cpp.

452 {
453 switch (ct) {
454 case kUnknown_SkColorType: SkASSERT(false); break;
455
456 case kAlpha_8_SkColorType: this->append(Op::store_a8, ctx); break;
457 case kR8_unorm_SkColorType: this->append(Op::store_r8, ctx); break;
458 case kA16_unorm_SkColorType: this->append(Op::store_a16, ctx); break;
459 case kA16_float_SkColorType: this->append(Op::store_af16, ctx); break;
460 case kRGB_565_SkColorType: this->append(Op::store_565, ctx); break;
461 case kARGB_4444_SkColorType: this->append(Op::store_4444, ctx); break;
462 case kR8G8_unorm_SkColorType: this->append(Op::store_rg88, ctx); break;
463 case kR16G16_unorm_SkColorType: this->append(Op::store_rg1616, ctx); break;
464 case kR16G16_float_SkColorType: this->append(Op::store_rgf16, ctx); break;
465 case kRGBA_8888_SkColorType: this->append(Op::store_8888, ctx); break;
466 case kRGBA_1010102_SkColorType: this->append(Op::store_1010102, ctx); break;
467 case kR16G16B16A16_unorm_SkColorType: this->append(Op::store_16161616,ctx); break;
469 case kRGBA_F16_SkColorType: this->append(Op::store_f16, ctx); break;
470 case kRGBA_F32_SkColorType: this->append(Op::store_f32, ctx); break;
471 case kRGBA_10x6_SkColorType: this->append(Op::store_10x6, ctx); break;
472
473 case kRGB_888x_SkColorType: this->append(Op::force_opaque);
474 this->append(Op::store_8888, ctx);
475 break;
476
477 case kBGRA_1010102_SkColorType: this->append(Op::swap_rb);
478 this->append(Op::store_1010102, ctx);
479 break;
480
481 case kRGB_101010x_SkColorType: this->append(Op::force_opaque);
482 this->append(Op::store_1010102, ctx);
483 break;
484
485 case kBGR_101010x_SkColorType: this->append(Op::force_opaque);
486 this->append(Op::swap_rb);
487 this->append(Op::store_1010102, ctx);
488 break;
489
490 case kBGR_101010x_XR_SkColorType: this->append(Op::force_opaque);
491 this->append(Op::swap_rb);
492 this->append(Op::store_1010102_xr, ctx);
493 break;
494
495 case kBGRA_10101010_XR_SkColorType: this->append(Op::swap_rb);
496 this->append(Op::store_10101010_xr, ctx);
497 break;
498
499 case kGray_8_SkColorType: this->append(Op::bt709_luminance_or_luma_to_alpha);
500 this->append(Op::store_a8, ctx);
501 break;
502
503 case kBGRA_8888_SkColorType: this->append(Op::swap_rb);
504 this->append(Op::store_8888, ctx);
505 break;
506
509 this->append(Op::store_8888, ctx);
510 break;
511 }
512}
const skcms_TransferFunction * skcms_sRGB_Inverse_TransferFunction()
Definition: skcms.cc:1591

◆ appendTransferFunction()

void SkRasterPipeline::appendTransferFunction ( const skcms_TransferFunction tf)

Definition at line 514 of file SkRasterPipeline.cpp.

514 {
515 void* ctx = const_cast<void*>(static_cast<const void*>(&tf));
516 switch (skcms_TransferFunction_getType(&tf)) {
517 case skcms_TFType_Invalid: SkASSERT(false); break;
518
520 if (tf.a == 1 && tf.b == 0 && tf.c == 0 && tf.d == 0 && tf.e == 0 && tf.f == 0) {
521 this->uncheckedAppend(Op::gamma_, ctx);
522 } else {
523 this->uncheckedAppend(Op::parametric, ctx);
524 }
525 break;
526 case skcms_TFType_PQish: this->uncheckedAppend(Op::PQish, ctx); break;
527 case skcms_TFType_HLGish: this->uncheckedAppend(Op::HLGish, ctx); break;
528 case skcms_TFType_HLGinvish: this->uncheckedAppend(Op::HLGinvish, ctx); break;
529 }
530}
skcms_TFType skcms_TransferFunction_getType(const skcms_TransferFunction *tf)
Definition: skcms.cc:183
@ skcms_TFType_Invalid
Definition: skcms_public.h:55
@ skcms_TFType_HLGish
Definition: skcms_public.h:58
@ skcms_TFType_sRGBish
Definition: skcms_public.h:56
@ skcms_TFType_HLGinvish
Definition: skcms_public.h:59
@ skcms_TFType_PQish
Definition: skcms_public.h:57

◆ compile()

std::function< void(size_t, size_t, size_t, size_t)> SkRasterPipeline::compile ( ) const

Definition at line 634 of file SkRasterPipeline.cpp.

634 {
635 if (this->empty()) {
636 return [](size_t, size_t, size_t, size_t) {};
637 }
638
639 int stagesNeeded = this->stagesNeeded();
640
641 SkRasterPipelineStage* program = fAlloc->makeArray<SkRasterPipelineStage>(stagesNeeded);
642
643 int numMemoryCtxs = fMemoryCtxInfos.size();
645 fAlloc->makeArray<SkRasterPipeline_MemoryCtxPatch>(numMemoryCtxs);
646 for (int i = 0; i < numMemoryCtxs; ++i) {
647 patches[i].info = fMemoryCtxInfos[i];
648 patches[i].backup = nullptr;
649 memset(patches[i].scratch, 0, sizeof(patches[i].scratch));
650 }
651 uint8_t* tailPointer = fTailPointer;
652
653 auto start_pipeline = this->buildPipeline(program + stagesNeeded);
654 return [=](size_t x, size_t y, size_t w, size_t h) {
655 start_pipeline(x, y, x + w, y + h, program,
656 SkSpan{patches, numMemoryCtxs},
657 tailPointer);
658 };
659}
T * makeArray(size_t count)
Definition: SkArenaAlloc.h:181
bool empty() const
int size() const
Definition: SkTArray.h:421
double y
double x
static void start_pipeline(size_t dx, size_t dy, size_t xlimit, size_t ylimit, SkRasterPipelineStage *program, SkSpan< SkRasterPipeline_MemoryCtxPatch > memoryCtxPatches, uint8_t *tailPointer)
SkScalar w
SkScalar h
SkRasterPipeline_MemoryCtxInfo info

◆ dump()

void SkRasterPipeline::dump ( ) const

Definition at line 227 of file SkRasterPipeline.cpp.

227 {
228 SkDebugf("SkRasterPipeline, %d stages\n", fNumStages);
229 std::vector<const char*> stages;
230 for (auto st = fStages; st; st = st->prev) {
231 stages.push_back(GetOpName(st->stage));
232 }
233 std::reverse(stages.begin(), stages.end());
234 for (const char* name : stages) {
235 SkDebugf("\t%s\n", name);
236 }
237 SkDebugf("\n");
238}
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static const char * GetOpName(SkRasterPipelineOp op)
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

◆ empty()

bool SkRasterPipeline::empty ( ) const
inline

Definition at line 136 of file SkRasterPipeline.h.

136{ return fStages == nullptr; }

◆ extend()

void SkRasterPipeline::extend ( const SkRasterPipeline src)

Definition at line 167 of file SkRasterPipeline.cpp.

167 {
168 if (src.empty()) {
169 return;
170 }
171 // Create a rewind context if `src` has one already, but we don't. If we _do_ already have one,
172 // we need to keep it, since we already have rewind ops that reference it. Either way, we need
173 // to rewrite all the rewind ops to point to _our_ rewind context; we only get that checkpoint.
174 if (src.fRewindCtx && !fRewindCtx) {
175 fRewindCtx = fAlloc->make<SkRasterPipeline_RewindCtx>();
176 }
177 auto stages = fAlloc->makeArrayDefault<StageList>(src.fNumStages);
178
179 int n = src.fNumStages;
180 const StageList* st = src.fStages;
181 while (n --> 1) {
182 stages[n] = *st;
183 stages[n].prev = &stages[n-1];
184
185 // We make sure that all ops use _our_ stack context and tail pointer.
186 switch (stages[n].stage) {
187 case Op::stack_rewind: {
188 stages[n].ctx = fRewindCtx;
189 break;
190 }
191 case Op::init_lane_masks: {
192 auto* ctx = (SkRasterPipeline_InitLaneMasksCtx*)stages[n].ctx;
193 ctx->tail = this->tailPointer();
194 break;
195 }
196 case Op::branch_if_all_lanes_active: {
197 auto* ctx = (SkRasterPipeline_BranchIfAllLanesActiveCtx*)stages[n].ctx;
198 ctx->tail = this->tailPointer();
199 break;
200 }
201 default:
202 break;
203 }
204
205 st = st->prev;
206 }
207 stages[0] = *st;
208 stages[0].prev = fStages;
209
210 fStages = &stages[src.fNumStages - 1];
211 fNumStages += src.fNumStages;
212 for (const SkRasterPipeline_MemoryCtxInfo& info : src.fMemoryCtxInfos) {
213 this->addMemoryContext(info.context, info.bytesPerPixel, info.load, info.store);
214 }
215}

◆ getNumStages()

int SkRasterPipeline::getNumStages ( ) const
inline

Definition at line 102 of file SkRasterPipeline.h.

102{ return fNumStages; }

◆ GetOpName()

const char * SkRasterPipeline::GetOpName ( SkRasterPipelineOp  op)
static

Definition at line 217 of file SkRasterPipeline.cpp.

217 {
218 const char* name = "";
219 switch (op) {
220 #define M(x) case Op::x: name = #x; break;
222 #undef M
223 }
224 return name;
225}
#define SK_RASTER_PIPELINE_OPS_ALL(M)

◆ getStageList()

const StageList * SkRasterPipeline::getStageList ( ) const
inline

Definition at line 101 of file SkRasterPipeline.h.

101{ return fStages; }

◆ operator=() [1/2]

SkRasterPipeline & SkRasterPipeline::operator= ( const SkRasterPipeline )
delete

◆ operator=() [2/2]

SkRasterPipeline & SkRasterPipeline::operator= ( SkRasterPipeline &&  )
default

◆ reset()

void SkRasterPipeline::reset ( )

Definition at line 35 of file SkRasterPipeline.cpp.

35 {
36 // We intentionally leave the alloc alone here; we don't own it.
37 fRewindCtx = nullptr;
38 fStages = nullptr;
39 fTailPointer = nullptr;
40 fNumStages = 0;
41 fMemoryCtxInfos.clear();
42}

◆ run()

void SkRasterPipeline::run ( size_t  x,
size_t  y,
size_t  w,
size_t  h 
) const

Definition at line 610 of file SkRasterPipeline.cpp.

610 {
611 if (this->empty()) {
612 return;
613 }
614
615 int stagesNeeded = this->stagesNeeded();
616
617 // Best to not use fAlloc here... we can't bound how often run() will be called.
618 AutoSTMalloc<32, SkRasterPipelineStage> program(stagesNeeded);
619
620 int numMemoryCtxs = fMemoryCtxInfos.size();
622 for (int i = 0; i < numMemoryCtxs; ++i) {
623 patches[i].info = fMemoryCtxInfos[i];
624 patches[i].backup = nullptr;
625 memset(patches[i].scratch, 0, sizeof(patches[i].scratch));
626 }
627
628 auto start_pipeline = this->buildPipeline(program.get() + stagesNeeded);
629 start_pipeline(x, y, x + w, y + h, program.get(),
630 SkSpan{patches.data(), numMemoryCtxs},
631 fTailPointer);
632}

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