centralize RP loads and stores
This gets all the main places we set up loads and stores in SkRasterPipeline. Some tests and benches still use the old generic append() method, and I think that's fine, and same with some of the image codec code. Change-Id: Ia27f106887f1a8d95d76e2366c17ab30eec504c1 Reviewed-on: https://skia-review.googlesource.com/154868 Auto-Submit: Mike Klein <mtklein@google.com> Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
9ec77b5574
commit
afa35022d9
@ -114,24 +114,7 @@ public:
|
||||
fPaintColor = paint.getColor4f();
|
||||
|
||||
SkRasterPipeline p(fAlloc);
|
||||
void* ctx = &fSrcPtr;
|
||||
switch (fSource.colorType()) {
|
||||
case kAlpha_8_SkColorType: p.append(SkRasterPipeline::load_a8, ctx); break;
|
||||
case kGray_8_SkColorType: p.append(SkRasterPipeline::load_g8, ctx); break;
|
||||
case kRGB_565_SkColorType: p.append(SkRasterPipeline::load_565, ctx); break;
|
||||
case kARGB_4444_SkColorType: p.append(SkRasterPipeline::load_4444, ctx); break;
|
||||
case kBGRA_8888_SkColorType: p.append(SkRasterPipeline::load_bgra, ctx); break;
|
||||
case kRGBA_8888_SkColorType: p.append(SkRasterPipeline::load_8888, ctx); break;
|
||||
case kRGBA_1010102_SkColorType: p.append(SkRasterPipeline::load_1010102, ctx); break;
|
||||
case kRGBA_F16_SkColorType: p.append(SkRasterPipeline::load_f16, ctx); break;
|
||||
case kRGBA_F32_SkColorType: p.append(SkRasterPipeline::load_f32, ctx); break;
|
||||
|
||||
case kRGB_888x_SkColorType: p.append(SkRasterPipeline::load_8888, ctx);
|
||||
p.append(SkRasterPipeline::force_opaque ); break;
|
||||
case kRGB_101010x_SkColorType: p.append(SkRasterPipeline::load_1010102, ctx);
|
||||
p.append(SkRasterPipeline::force_opaque ); break;
|
||||
default: SkASSERT(false);
|
||||
}
|
||||
p.append_load(fSource.colorType(), &fSrcPtr);
|
||||
|
||||
if (fSource.colorType() == kAlpha_8_SkColorType) {
|
||||
// The color for A8 images comes from the (sRGB) paint color.
|
||||
|
@ -179,46 +179,7 @@ static void convert_with_pipeline(const SkImageInfo& dstInfo, void* dstRow, size
|
||||
dst = { (void*)dstRow, (int)(dstRB / dstInfo.bytesPerPixel()) };
|
||||
|
||||
SkRasterPipeline_<256> pipeline;
|
||||
switch (srcInfo.colorType()) {
|
||||
case kRGBA_8888_SkColorType:
|
||||
pipeline.append(SkRasterPipeline::load_8888, &src);
|
||||
break;
|
||||
case kRGB_888x_SkColorType:
|
||||
pipeline.append(SkRasterPipeline::load_8888, &src);
|
||||
pipeline.append(SkRasterPipeline::force_opaque);
|
||||
break;
|
||||
case kBGRA_8888_SkColorType:
|
||||
pipeline.append(SkRasterPipeline::load_bgra, &src);
|
||||
break;
|
||||
case kRGBA_1010102_SkColorType:
|
||||
pipeline.append(SkRasterPipeline::load_1010102, &src);
|
||||
break;
|
||||
case kRGB_101010x_SkColorType:
|
||||
pipeline.append(SkRasterPipeline::load_1010102, &src);
|
||||
pipeline.append(SkRasterPipeline::force_opaque);
|
||||
break;
|
||||
case kRGB_565_SkColorType:
|
||||
pipeline.append(SkRasterPipeline::load_565, &src);
|
||||
break;
|
||||
case kRGBA_F16_SkColorType:
|
||||
pipeline.append(SkRasterPipeline::load_f16, &src);
|
||||
break;
|
||||
case kRGBA_F32_SkColorType:
|
||||
pipeline.append(SkRasterPipeline::load_f32, &src);
|
||||
break;
|
||||
case kGray_8_SkColorType:
|
||||
pipeline.append(SkRasterPipeline::load_g8, &src);
|
||||
break;
|
||||
case kAlpha_8_SkColorType:
|
||||
pipeline.append(SkRasterPipeline::load_a8, &src);
|
||||
break;
|
||||
case kARGB_4444_SkColorType:
|
||||
pipeline.append(SkRasterPipeline::load_4444, &src);
|
||||
break;
|
||||
case kUnknown_SkColorType:
|
||||
SkASSERT(false);
|
||||
break;
|
||||
}
|
||||
pipeline.append_load(srcInfo.colorType(), &src);
|
||||
|
||||
SkColorSpaceXformSteps steps{srcInfo.colorSpace(), srcInfo.alphaType(),
|
||||
dstInfo.colorSpace(), dstInfo.alphaType()};
|
||||
@ -237,48 +198,7 @@ static void convert_with_pipeline(const SkImageInfo& dstInfo, void* dstRow, size
|
||||
pipeline.append(SkRasterPipeline::dither, &dither_rate);
|
||||
}
|
||||
|
||||
switch (dstInfo.colorType()) {
|
||||
case kRGBA_8888_SkColorType:
|
||||
pipeline.append(SkRasterPipeline::store_8888, &dst);
|
||||
break;
|
||||
case kRGB_888x_SkColorType:
|
||||
pipeline.append(SkRasterPipeline::force_opaque);
|
||||
pipeline.append(SkRasterPipeline::store_8888, &dst);
|
||||
break;
|
||||
case kBGRA_8888_SkColorType:
|
||||
pipeline.append(SkRasterPipeline::store_bgra, &dst);
|
||||
break;
|
||||
case kRGBA_1010102_SkColorType:
|
||||
pipeline.append(SkRasterPipeline::store_1010102, &dst);
|
||||
break;
|
||||
case kRGB_101010x_SkColorType:
|
||||
pipeline.append(SkRasterPipeline::force_opaque);
|
||||
pipeline.append(SkRasterPipeline::store_1010102, &dst);
|
||||
break;
|
||||
case kRGB_565_SkColorType:
|
||||
pipeline.append(SkRasterPipeline::store_565, &dst);
|
||||
break;
|
||||
case kRGBA_F16_SkColorType:
|
||||
pipeline.append(SkRasterPipeline::store_f16, &dst);
|
||||
break;
|
||||
case kRGBA_F32_SkColorType:
|
||||
pipeline.append(SkRasterPipeline::store_f32, &dst);
|
||||
break;
|
||||
case kARGB_4444_SkColorType:
|
||||
pipeline.append(SkRasterPipeline::store_4444, &dst);
|
||||
break;
|
||||
case kAlpha_8_SkColorType:
|
||||
pipeline.append(SkRasterPipeline::store_a8, &dst);
|
||||
break;
|
||||
case kGray_8_SkColorType:
|
||||
pipeline.append(SkRasterPipeline::luminance_to_alpha);
|
||||
pipeline.append(SkRasterPipeline::store_a8, &dst);
|
||||
break;
|
||||
case kUnknown_SkColorType:
|
||||
SkASSERT(false);
|
||||
break;
|
||||
}
|
||||
|
||||
pipeline.append_store(dstInfo.colorType(), &dst);
|
||||
pipeline.run(0,0, srcInfo.width(), srcInfo.height());
|
||||
}
|
||||
|
||||
|
@ -193,3 +193,78 @@ void SkRasterPipeline::append_matrix(SkArenaAlloc* alloc, const SkMatrix& matrix
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SkRasterPipeline::append_load(SkColorType ct, const SkJumper_MemoryCtx* ctx) {
|
||||
switch (ct) {
|
||||
case kUnknown_SkColorType: SkASSERT(false); break;
|
||||
|
||||
case kGray_8_SkColorType: this->append(load_g8, ctx); break;
|
||||
case kAlpha_8_SkColorType: this->append(load_a8, ctx); break;
|
||||
case kRGB_565_SkColorType: this->append(load_565, ctx); break;
|
||||
case kARGB_4444_SkColorType: this->append(load_4444, ctx); break;
|
||||
case kBGRA_8888_SkColorType: this->append(load_bgra, ctx); break;
|
||||
case kRGBA_8888_SkColorType: this->append(load_8888, ctx); break;
|
||||
case kRGBA_1010102_SkColorType: this->append(load_1010102, ctx); break;
|
||||
case kRGBA_F16_SkColorType: this->append(load_f16, ctx); break;
|
||||
case kRGBA_F32_SkColorType: this->append(load_f32, ctx); break;
|
||||
|
||||
case kRGB_888x_SkColorType: this->append(load_8888, ctx);
|
||||
this->append(force_opaque);
|
||||
break;
|
||||
|
||||
case kRGB_101010x_SkColorType: this->append(load_1010102, ctx);
|
||||
this->append(force_opaque);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SkRasterPipeline::append_load_dst(SkColorType ct, const SkJumper_MemoryCtx* ctx) {
|
||||
switch (ct) {
|
||||
case kUnknown_SkColorType: SkASSERT(false); break;
|
||||
|
||||
case kGray_8_SkColorType: this->append(load_g8_dst, ctx); break;
|
||||
case kAlpha_8_SkColorType: this->append(load_a8_dst, ctx); break;
|
||||
case kRGB_565_SkColorType: this->append(load_565_dst, ctx); break;
|
||||
case kARGB_4444_SkColorType: this->append(load_4444_dst, ctx); break;
|
||||
case kBGRA_8888_SkColorType: this->append(load_bgra_dst, ctx); break;
|
||||
case kRGBA_8888_SkColorType: this->append(load_8888_dst, ctx); break;
|
||||
case kRGBA_1010102_SkColorType: this->append(load_1010102_dst, ctx); break;
|
||||
case kRGBA_F16_SkColorType: this->append(load_f16_dst, ctx); break;
|
||||
case kRGBA_F32_SkColorType: this->append(load_f32_dst, ctx); break;
|
||||
|
||||
case kRGB_888x_SkColorType: this->append(load_8888_dst, ctx);
|
||||
this->append(force_opaque_dst);
|
||||
break;
|
||||
|
||||
case kRGB_101010x_SkColorType: this->append(load_1010102_dst, ctx);
|
||||
this->append(force_opaque_dst);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SkRasterPipeline::append_store(SkColorType ct, const SkJumper_MemoryCtx* ctx) {
|
||||
switch (ct) {
|
||||
case kUnknown_SkColorType: SkASSERT(false); break;
|
||||
|
||||
case kAlpha_8_SkColorType: this->append(store_a8, ctx); break;
|
||||
case kRGB_565_SkColorType: this->append(store_565, ctx); break;
|
||||
case kARGB_4444_SkColorType: this->append(store_4444, ctx); break;
|
||||
case kBGRA_8888_SkColorType: this->append(store_bgra, ctx); break;
|
||||
case kRGBA_8888_SkColorType: this->append(store_8888, ctx); break;
|
||||
case kRGBA_1010102_SkColorType: this->append(store_1010102, ctx); break;
|
||||
case kRGBA_F16_SkColorType: this->append(store_f16, ctx); break;
|
||||
case kRGBA_F32_SkColorType: this->append(store_f32, ctx); break;
|
||||
|
||||
case kRGB_888x_SkColorType: this->append(force_opaque);
|
||||
this->append(store_8888, ctx);
|
||||
break;
|
||||
|
||||
case kRGB_101010x_SkColorType: this->append(force_opaque);
|
||||
this->append(store_1010102, ctx);
|
||||
break;
|
||||
|
||||
case kGray_8_SkColorType: this->append(luminance_to_alpha);
|
||||
this->append(store_a8, ctx);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "SkTypes.h"
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include "../jumper/SkJumper.h"
|
||||
|
||||
/**
|
||||
* SkRasterPipeline provides a cheap way to chain together a pixel processing pipeline.
|
||||
@ -154,8 +155,13 @@ public:
|
||||
this->append_set_rgb(alloc, color.vec());
|
||||
}
|
||||
|
||||
void append_load (SkColorType, const SkJumper_MemoryCtx*);
|
||||
void append_load_dst(SkColorType, const SkJumper_MemoryCtx*);
|
||||
void append_store (SkColorType, const SkJumper_MemoryCtx*);
|
||||
|
||||
bool empty() const { return fStages == nullptr; }
|
||||
|
||||
|
||||
private:
|
||||
struct StageList {
|
||||
StageList* prev;
|
||||
|
@ -255,25 +255,7 @@ SkBlitter* SkRasterPipelineBlitter::Create(const SkPixmap& dst,
|
||||
}
|
||||
|
||||
void SkRasterPipelineBlitter::append_load_dst(SkRasterPipeline* p) const {
|
||||
const void* ctx = &fDstPtr;
|
||||
switch (fDst.info().colorType()) {
|
||||
default: break;
|
||||
|
||||
case kGray_8_SkColorType: p->append(SkRasterPipeline::load_g8_dst, ctx); break;
|
||||
case kAlpha_8_SkColorType: p->append(SkRasterPipeline::load_a8_dst, ctx); break;
|
||||
case kRGB_565_SkColorType: p->append(SkRasterPipeline::load_565_dst, ctx); break;
|
||||
case kARGB_4444_SkColorType: p->append(SkRasterPipeline::load_4444_dst, ctx); break;
|
||||
case kBGRA_8888_SkColorType: p->append(SkRasterPipeline::load_bgra_dst, ctx); break;
|
||||
case kRGBA_8888_SkColorType: p->append(SkRasterPipeline::load_8888_dst, ctx); break;
|
||||
case kRGBA_1010102_SkColorType: p->append(SkRasterPipeline::load_1010102_dst, ctx); break;
|
||||
case kRGBA_F16_SkColorType: p->append(SkRasterPipeline::load_f16_dst, ctx); break;
|
||||
case kRGBA_F32_SkColorType: p->append(SkRasterPipeline::load_f32_dst, ctx); break;
|
||||
|
||||
case kRGB_888x_SkColorType: p->append(SkRasterPipeline::load_8888_dst, ctx);
|
||||
p->append(SkRasterPipeline::force_opaque_dst ); break;
|
||||
case kRGB_101010x_SkColorType: p->append(SkRasterPipeline::load_1010102_dst, ctx);
|
||||
p->append(SkRasterPipeline::force_opaque_dst ); break;
|
||||
}
|
||||
p->append_load_dst(fDst.info().colorType(), &fDstPtr);
|
||||
if (fDst.info().alphaType() == kUnpremul_SkAlphaType) {
|
||||
p->append(SkRasterPipeline::premul_dst);
|
||||
}
|
||||
@ -287,26 +269,7 @@ void SkRasterPipelineBlitter::append_store(SkRasterPipeline* p) const {
|
||||
p->append(SkRasterPipeline::dither, &fDitherRate);
|
||||
}
|
||||
|
||||
const void* ctx = &fDstPtr;
|
||||
switch (fDst.info().colorType()) {
|
||||
default: break;
|
||||
|
||||
case kGray_8_SkColorType: p->append(SkRasterPipeline::luminance_to_alpha);
|
||||
p->append(SkRasterPipeline::store_a8, ctx); break;
|
||||
case kAlpha_8_SkColorType: p->append(SkRasterPipeline::store_a8, ctx); break;
|
||||
case kRGB_565_SkColorType: p->append(SkRasterPipeline::store_565, ctx); break;
|
||||
case kARGB_4444_SkColorType: p->append(SkRasterPipeline::store_4444, ctx); break;
|
||||
case kBGRA_8888_SkColorType: p->append(SkRasterPipeline::store_bgra, ctx); break;
|
||||
case kRGBA_8888_SkColorType: p->append(SkRasterPipeline::store_8888, ctx); break;
|
||||
case kRGBA_1010102_SkColorType: p->append(SkRasterPipeline::store_1010102, ctx); break;
|
||||
case kRGBA_F16_SkColorType: p->append(SkRasterPipeline::store_f16, ctx); break;
|
||||
case kRGBA_F32_SkColorType: p->append(SkRasterPipeline::store_f32, ctx); break;
|
||||
|
||||
case kRGB_888x_SkColorType: p->append(SkRasterPipeline::force_opaque );
|
||||
p->append(SkRasterPipeline::store_8888, ctx); break;
|
||||
case kRGB_101010x_SkColorType: p->append(SkRasterPipeline::force_opaque );
|
||||
p->append(SkRasterPipeline::store_1010102, ctx); break;
|
||||
}
|
||||
p->append_store(fDst.info().colorType(), &fDstPtr);
|
||||
}
|
||||
|
||||
void SkRasterPipelineBlitter::burst_shade(int x, int y, int w) {
|
||||
|
@ -41,13 +41,8 @@ public:
|
||||
src_ctx = { (void*)src, 0 },
|
||||
aa_ctx = { (void*)aa, 0 };
|
||||
|
||||
if (kN32_SkColorType == kBGRA_8888_SkColorType) {
|
||||
p.append(SkRasterPipeline::load_bgra_dst, &dst_ctx);
|
||||
p.append(SkRasterPipeline::load_bgra , &src_ctx);
|
||||
} else {
|
||||
p.append(SkRasterPipeline::load_8888_dst, &dst_ctx);
|
||||
p.append(SkRasterPipeline::load_8888, &src_ctx);
|
||||
}
|
||||
p.append_load (kN32_SkColorType, &src_ctx);
|
||||
p.append_load_dst(kN32_SkColorType, &dst_ctx);
|
||||
|
||||
if (SkBlendMode_ShouldPreScaleCoverage(fMode, /*rgb_coverage=*/false)) {
|
||||
if (aa) {
|
||||
@ -61,11 +56,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
if (kN32_SkColorType == kBGRA_8888_SkColorType) {
|
||||
p.append(SkRasterPipeline::store_bgra, &dst_ctx);
|
||||
} else {
|
||||
p.append(SkRasterPipeline::store_8888, &dst_ctx);
|
||||
}
|
||||
p.append_store(kN32_SkColorType, &dst_ctx);
|
||||
p.run(0, 0, count,1);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user