39 fTailPointer =
nullptr;
41 fMemoryCtxInfos.
clear();
46 SkASSERT(op != Op::unbounded_uniform_color);
48 SkASSERT(op != Op::unbounded_set_rgb);
56 this->uncheckedAppend(op, ctx);
59uint8_t* SkRasterPipeline::tailPointer() {
62 fTailPointer = fAlloc->
make<uint8_t>(0xFF);
68 bool isLoad =
false, isStore =
false;
71#define COLOR_TYPE_CASE(stage_ct, sk_ct) \
72 case Op::load_##stage_ct: \
73 case Op::load_##stage_ct##_dst: \
77 case Op::store_##stage_ct: \
100#undef COLOR_TYPE_CASE
108 case Op::srcover_rgba_8888: {
129 this->addMemoryContext(&embossCtx->
add,
132 this->addMemoryContext(&embossCtx->
mul,
137 case Op::init_lane_masks: {
139 initCtx->tail = this->tailPointer();
142 case Op::branch_if_all_lanes_active: {
144 branchCtx->tail = this->tailPointer();
151 fStages = fAlloc->
make<StageList>(StageList{fStages, op, ctx});
154 if (isLoad || isStore) {
156 this->addMemoryContext(
163 memcpy(&ptrCtx, &ctx,
sizeof(ctx));
174 if (
src.fRewindCtx && !fRewindCtx) {
179 int n =
src.fNumStages;
183 stages[n].
prev = &stages[n-1];
186 switch (stages[n].stage) {
188 stages[n].ctx = fRewindCtx;
191 case Op::init_lane_masks: {
193 ctx->tail = this->tailPointer();
196 case Op::branch_if_all_lanes_active: {
198 ctx->tail = this->tailPointer();
208 stages[0].
prev = fStages;
210 fStages = &stages[
src.fNumStages - 1];
211 fNumStages +=
src.fNumStages;
213 this->addMemoryContext(
info.context,
info.bytesPerPixel,
info.load,
info.store);
218 const char*
name =
"";
220 #define M(x) case Op::x: name = #x; break;
228 SkDebugf(
"SkRasterPipeline, %d stages\n", fNumStages);
229 std::vector<const char*> stages;
230 for (
auto st = fStages; st; st = st->
prev) {
234 for (
const char*
name : stages) {
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)
254 this->uncheckedAppend(op, arg);
262 this->
append(Op::black_color);
264 this->
append(Op::white_color);
268 color.store(&ctx->r);
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);
283 this->uncheckedAppend(Op::unbounded_uniform_color, ctx);
296 trans[0] =
matrix.getTranslateX();
297 trans[1] =
matrix.getTranslateY();
298 this->
append(Op::matrix_translate, trans);
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);
310 if (!
matrix.hasPerspective()) {
312 this->
append(Op::matrix_2x3, storage);
314 this->
append(Op::matrix_perspective, storage);
340 this->
append(Op::alpha_to_gray);
344 this->
append(Op::alpha_to_red);
348 this->
append(Op::force_opaque);
352 this->
append(Op::swap_rb);
356 this->
append(Op::force_opaque);
360 this->
append(Op::force_opaque);
361 this->
append(Op::swap_rb);
365 this->
append(Op::swap_rb);
369 this->
append(Op::force_opaque);
370 this->
append(Op::swap_rb);
374 this->
append(Op::swap_rb);
378 this->
append(Op::load_8888, ctx);
405 this->
append(Op::alpha_to_gray_dst);
409 this->
append(Op::alpha_to_red_dst);
413 this->
append(Op::force_opaque_dst);
417 this->
append(Op::swap_rb_dst);
421 this->
append(Op::force_opaque_dst);
425 this->
append(Op::force_opaque_dst);
426 this->
append(Op::swap_rb_dst);
430 this->
append(Op::force_opaque_dst);
431 this->
append(Op::swap_rb_dst);
435 this->
append(Op::swap_rb_dst);
439 this->
append(Op::swap_rb_dst);
444 this->
append(Op::load_8888_dst, ctx);
445 this->
append(Op::swap_src_dst);
447 this->
append(Op::swap_src_dst);
474 this->
append(Op::store_8888, ctx);
478 this->
append(Op::store_1010102, ctx);
482 this->
append(Op::store_1010102, ctx);
486 this->
append(Op::swap_rb);
487 this->
append(Op::store_1010102, ctx);
491 this->
append(Op::swap_rb);
492 this->
append(Op::store_1010102_xr, ctx);
496 this->
append(Op::store_10101010_xr, ctx);
500 this->
append(Op::store_a8, ctx);
504 this->
append(Op::store_8888, ctx);
509 this->
append(Op::store_8888, ctx);
515 void* ctx =
const_cast<void*
>(
static_cast<const void*
>(&tf));
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);
523 this->uncheckedAppend(Op::parametric, ctx);
536 this->uncheckedAppend(Op::clamp_01,
nullptr);
560 for (
const StageList* st = fStages; st; st = st->prev) {
561 int opIndex = (
int)st->stage;
574 for (
const StageList* st = fStages; st; st = st->prev) {
575 int opIndex = (
int)st->stage;
591 if (this->buildLowpPipeline(ip)) {
595 this->buildHighpPipeline(ip);
599int SkRasterPipeline::stagesNeeded()
const {
601 int stages = fNumStages + 1;
615 int stagesNeeded = this->stagesNeeded();
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));
630 SkSpan{patches.data(), numMemoryCtxs},
636 return [](size_t, size_t, size_t, size_t) {};
639 int stagesNeeded = this->stagesNeeded();
643 int numMemoryCtxs = fMemoryCtxInfos.
size();
646 for (
int i = 0;
i < numMemoryCtxs; ++
i) {
647 patches[
i].
info = fMemoryCtxInfos[
i];
649 memset(patches[
i].scratch, 0,
sizeof(patches[
i].scratch));
651 uint8_t* tailPointer = fTailPointer;
653 auto start_pipeline = this->buildPipeline(program + stagesNeeded);
654 return [=](
size_t x,
size_t y,
size_t w,
size_t h) {
656 SkSpan{patches, numMemoryCtxs},
666 std::find_if(fMemoryCtxInfos.
begin(), fMemoryCtxInfos.
end(),
668 if (
info != fMemoryCtxInfos.
end()) {
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
static const uint32_t rgba[kNumPixels]
static const uint64_t f16[kNumPixels]
@ kR16G16B16A16_unorm_SkColorType
pixel with a little endian uint16_t for red, green, blue
@ kRGBA_10x6_SkColorType
pixel with 10 used bits (most significant) followed by 6 unused
@ kBGR_101010x_SkColorType
pixel with 10 bits each for blue, green, red; in 32-bit word
@ kARGB_4444_SkColorType
pixel with 4 bits for alpha, red, green, blue; in 16-bit word
@ kR8G8_unorm_SkColorType
pixel with a uint8_t for red and green
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
@ kA16_unorm_SkColorType
pixel with a little endian uint16_t for alpha
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
@ kAlpha_8_SkColorType
pixel with alpha in 8-bit byte
@ kRGB_101010x_SkColorType
pixel with 10 bits each for red, green, blue; in 32-bit word
@ kSRGBA_8888_SkColorType
@ kGray_8_SkColorType
pixel with grayscale level in 8-bit byte
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
@ kBGRA_10101010_XR_SkColorType
pixel with 10 bits each for blue, green, red, alpha; in 64-bit word, extended range
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
@ kRGB_888x_SkColorType
pixel with 8 bits each for red, green, blue; in 32-bit word
@ kBGRA_1010102_SkColorType
10 bits for blue, green, red; 2 bits for alpha; in 32-bit word
@ kA16_float_SkColorType
pixel with a half float for alpha
@ kRGBA_F32_SkColorType
pixel using C float for red, green, blue, alpha; in 128-bit word
@ kRGBA_1010102_SkColorType
10 bits for red, green, blue; 2 bits for alpha; in 32-bit word
@ kBGR_101010x_XR_SkColorType
pixel with 10 bits each for blue, green, red; in 32-bit word, extended range
@ kR16G16_unorm_SkColorType
pixel with a little endian uint16_t for red and green
@ kRGBA_F16Norm_SkColorType
pixel with half floats in [0,1] for red, green, blue, alpha;
@ kUnknown_SkColorType
uninitialized
@ kR16G16_float_SkColorType
pixel with a half float for red and green
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static bool SkColorTypeIsNormalized(SkColorType ct)
SK_API int SkColorTypeBytesPerPixel(SkColorType ct)
#define SK_RASTER_PIPELINE_OPS_ALL(M)
static constexpr int kNumRasterPipelineLowpOps
#define COLOR_TYPE_CASE(stage_ct, sk_ct)
bool gForceHighPrecisionRasterPipeline
static void prepend_to_pipeline(SkRasterPipelineStage *&ip, SkOpts::StageFn stageFn, void *ctx)
T * makeArrayDefault(size_t count)
T * makeArray(size_t count)
auto make(Ctor &&ctor) -> decltype(ctor(nullptr))
@ kTranslate_Mask
translation SkMatrix
@ kScale_Mask
scale SkMatrix
@ kIdentity_Mask
identity SkMatrix; all bits clear
void appendClampIfNormalized(const SkImageInfo &)
void run(size_t x, size_t y, size_t w, size_t h) const
void appendTransferFunction(const skcms_TransferFunction &)
void appendLoad(SkColorType, const SkRasterPipeline_MemoryCtx *)
void appendStore(SkColorType, const SkRasterPipeline_MemoryCtx *)
SkRasterPipeline(SkArenaAlloc *)
void append(SkRasterPipelineOp, void *=nullptr)
void appendSetRGB(SkArenaAlloc *, const float rgb[3])
static const char * GetOpName(SkRasterPipelineOp op)
std::function< void(size_t, size_t, size_t, size_t)> compile() const
void extend(const SkRasterPipeline &)
void appendLoadDst(SkColorType, const SkRasterPipeline_MemoryCtx *)
void appendConstantColor(SkArenaAlloc *, const float rgba[4])
void appendMatrix(SkArenaAlloc *, const SkMatrix &)
Dart_NativeFunction function
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)
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)
void(* start_pipeline_lowp)(size_t, size_t, size_t, size_t, SkRasterPipelineStage *, SkSpan< SkRasterPipeline_MemoryCtxPatch >, uint8_t *)
void(* start_pipeline_highp)(size_t, size_t, size_t, size_t, SkRasterPipelineStage *, SkSpan< SkRasterPipeline_MemoryCtxPatch >, uint8_t *)
StageFn just_return_highp
unsigned useCenter Optional< SkMatrix > matrix
DEF_SWITCHES_START aot vmservice shared library name
skcms_TFType skcms_TransferFunction_getType(const skcms_TransferFunction *tf)
const skcms_TransferFunction * skcms_sRGB_Inverse_TransferFunction()
const skcms_TransferFunction * skcms_sRGB_TransferFunction()
SkRasterPipeline_MemoryCtx add
SkRasterPipeline_MemoryCtx mul
SkRasterPipeline_MemoryCtxInfo info
static SKVX_ALWAYS_INLINE Vec Load(const void *ptr)