add bgra as 1st class format
This is a start to eliminating swap_rb as a stage. I've just hit the main hot spots here. Going to look into the ~dozen other spots to see how they should work next. Change-Id: I26fb46a042facf7bd6fff3b47c9fcee86d7142fd Reviewed-on: https://skia-review.googlesource.com/20982 Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Mike Reed <reed@google.com>
This commit is contained in:
parent
5ce3972055
commit
111f8a9eea
@ -64,16 +64,18 @@ struct SkJumper_constants;
|
|||||||
M(move_src_dst) M(move_dst_src) \
|
M(move_src_dst) M(move_dst_src) \
|
||||||
M(clamp_0) M(clamp_1) M(clamp_a) M(clamp_a_dst) \
|
M(clamp_0) M(clamp_1) M(clamp_a) M(clamp_a_dst) \
|
||||||
M(unpremul) M(premul) \
|
M(unpremul) M(premul) \
|
||||||
M(set_rgb) M(swap_rb) M(swap_rb_dst) \
|
M(set_rgb) M(swap_rb) \
|
||||||
M(from_srgb) M(from_srgb_dst) M(to_srgb) \
|
M(from_srgb) M(from_srgb_dst) M(to_srgb) \
|
||||||
M(constant_color) M(seed_shader) M(dither) \
|
M(constant_color) M(seed_shader) M(dither) \
|
||||||
M(load_a8) M(load_a8_dst) M(store_a8) \
|
M(gather_i8) \
|
||||||
M(load_g8) M(load_g8_dst) \
|
M(load_a8) M(load_a8_dst) M(store_a8) M(gather_a8) \
|
||||||
M(load_565) M(load_565_dst) M(store_565) \
|
M(load_g8) M(load_g8_dst) M(gather_g8) \
|
||||||
M(load_4444) M(load_4444_dst) M(store_4444) \
|
M(load_565) M(load_565_dst) M(store_565) M(gather_565) \
|
||||||
M(load_f16) M(load_f16_dst) M(store_f16) \
|
M(load_4444) M(load_4444_dst) M(store_4444) M(gather_4444) \
|
||||||
|
M(load_f16) M(load_f16_dst) M(store_f16) M(gather_f16) \
|
||||||
M(load_f32) M(load_f32_dst) M(store_f32) \
|
M(load_f32) M(load_f32_dst) M(store_f32) \
|
||||||
M(load_8888) M(load_8888_dst) M(store_8888) \
|
M(load_8888) M(load_8888_dst) M(store_8888) M(gather_8888) \
|
||||||
|
M(load_bgra) M(load_bgra_dst) M(store_bgra) M(gather_bgra) \
|
||||||
M(load_u16_be) M(load_rgb_u16_be) M(store_u16_be) \
|
M(load_u16_be) M(load_rgb_u16_be) M(store_u16_be) \
|
||||||
M(load_tables_u16_be) M(load_tables_rgb_u16_be) \
|
M(load_tables_u16_be) M(load_tables_rgb_u16_be) \
|
||||||
M(load_tables) M(load_rgba) M(store_rgba) \
|
M(load_tables) M(load_rgba) M(store_rgba) \
|
||||||
@ -96,8 +98,6 @@ struct SkJumper_constants;
|
|||||||
M(clamp_x) M(mirror_x) M(repeat_x) \
|
M(clamp_x) M(mirror_x) M(repeat_x) \
|
||||||
M(clamp_y) M(mirror_y) M(repeat_y) \
|
M(clamp_y) M(mirror_y) M(repeat_y) \
|
||||||
M(clamp_x_1) M(mirror_x_1) M(repeat_x_1) \
|
M(clamp_x_1) M(mirror_x_1) M(repeat_x_1) \
|
||||||
M(gather_a8) M(gather_g8) M(gather_i8) \
|
|
||||||
M(gather_565) M(gather_4444) M(gather_8888) M(gather_f16) \
|
|
||||||
M(bilinear_nx) M(bilinear_px) M(bilinear_ny) M(bilinear_py) \
|
M(bilinear_nx) M(bilinear_px) M(bilinear_ny) M(bilinear_py) \
|
||||||
M(bicubic_n3x) M(bicubic_n1x) M(bicubic_p1x) M(bicubic_p3x) \
|
M(bicubic_n3x) M(bicubic_n1x) M(bicubic_p1x) M(bicubic_p3x) \
|
||||||
M(bicubic_n3y) M(bicubic_n1y) M(bicubic_p1y) M(bicubic_p3y) \
|
M(bicubic_n3y) M(bicubic_n1y) M(bicubic_p1y) M(bicubic_p3y) \
|
||||||
|
@ -227,13 +227,10 @@ void SkRasterPipelineBlitter::append_load_d(SkRasterPipeline* p) const {
|
|||||||
case kAlpha_8_SkColorType: p->append(SkRasterPipeline::load_a8_dst, &fDstPtr); break;
|
case kAlpha_8_SkColorType: p->append(SkRasterPipeline::load_a8_dst, &fDstPtr); break;
|
||||||
case kRGB_565_SkColorType: p->append(SkRasterPipeline::load_565_dst, &fDstPtr); break;
|
case kRGB_565_SkColorType: p->append(SkRasterPipeline::load_565_dst, &fDstPtr); break;
|
||||||
case kARGB_4444_SkColorType: p->append(SkRasterPipeline::load_4444_dst, &fDstPtr); break;
|
case kARGB_4444_SkColorType: p->append(SkRasterPipeline::load_4444_dst, &fDstPtr); break;
|
||||||
case kBGRA_8888_SkColorType:
|
case kBGRA_8888_SkColorType: p->append(SkRasterPipeline::load_bgra_dst, &fDstPtr); break;
|
||||||
case kRGBA_8888_SkColorType: p->append(SkRasterPipeline::load_8888_dst, &fDstPtr); break;
|
case kRGBA_8888_SkColorType: p->append(SkRasterPipeline::load_8888_dst, &fDstPtr); break;
|
||||||
case kRGBA_F16_SkColorType: p->append(SkRasterPipeline::load_f16_dst, &fDstPtr); break;
|
case kRGBA_F16_SkColorType: p->append(SkRasterPipeline::load_f16_dst, &fDstPtr); break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
|
||||||
if (fDst.info().colorType() == kBGRA_8888_SkColorType) {
|
|
||||||
p->append(SkRasterPipeline::swap_rb_dst);
|
|
||||||
}
|
}
|
||||||
if (fDst.info().gammaCloseToSRGB()) {
|
if (fDst.info().gammaCloseToSRGB()) {
|
||||||
p->append_from_srgb_dst(fDst.info().alphaType());
|
p->append_from_srgb_dst(fDst.info().alphaType());
|
||||||
@ -250,15 +247,12 @@ void SkRasterPipelineBlitter::append_store(SkRasterPipeline* p) const {
|
|||||||
p->append(SkRasterPipeline::dither, &fDitherRate);
|
p->append(SkRasterPipeline::dither, &fDitherRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fDst.info().colorType() == kBGRA_8888_SkColorType) {
|
|
||||||
p->append(SkRasterPipeline::swap_rb);
|
|
||||||
}
|
|
||||||
switch (fDst.info().colorType()) {
|
switch (fDst.info().colorType()) {
|
||||||
case kGray_8_SkColorType: p->append(SkRasterPipeline::luminance_to_alpha); // fallthru
|
case kGray_8_SkColorType: p->append(SkRasterPipeline::luminance_to_alpha); // fallthru
|
||||||
case kAlpha_8_SkColorType: p->append(SkRasterPipeline::store_a8, &fDstPtr); break;
|
case kAlpha_8_SkColorType: p->append(SkRasterPipeline::store_a8, &fDstPtr); break;
|
||||||
case kRGB_565_SkColorType: p->append(SkRasterPipeline::store_565, &fDstPtr); break;
|
case kRGB_565_SkColorType: p->append(SkRasterPipeline::store_565, &fDstPtr); break;
|
||||||
case kARGB_4444_SkColorType: p->append(SkRasterPipeline::store_4444, &fDstPtr); break;
|
case kARGB_4444_SkColorType: p->append(SkRasterPipeline::store_4444, &fDstPtr); break;
|
||||||
case kBGRA_8888_SkColorType:
|
case kBGRA_8888_SkColorType: p->append(SkRasterPipeline::store_bgra, &fDstPtr); break;
|
||||||
case kRGBA_8888_SkColorType: p->append(SkRasterPipeline::store_8888, &fDstPtr); break;
|
case kRGBA_8888_SkColorType: p->append(SkRasterPipeline::store_8888, &fDstPtr); break;
|
||||||
case kRGBA_F16_SkColorType: p->append(SkRasterPipeline::store_f16, &fDstPtr); break;
|
case kRGBA_F16_SkColorType: p->append(SkRasterPipeline::store_f16, &fDstPtr); break;
|
||||||
default: break;
|
default: break;
|
||||||
|
@ -75,9 +75,10 @@ using StartPipelineFn = void(size_t,size_t,size_t,void**,K*);
|
|||||||
M(set_rgb) \
|
M(set_rgb) \
|
||||||
M(premul) \
|
M(premul) \
|
||||||
M(load_8888) M(load_8888_dst) M(store_8888) \
|
M(load_8888) M(load_8888_dst) M(store_8888) \
|
||||||
|
M(load_bgra) M(load_bgra_dst) M(store_bgra) \
|
||||||
M(load_a8) M(load_a8_dst) M(store_a8) \
|
M(load_a8) M(load_a8_dst) M(store_a8) \
|
||||||
M(load_g8) M(load_g8_dst) \
|
M(load_g8) M(load_g8_dst) \
|
||||||
M(swap_rb) M(swap_rb_dst) \
|
M(swap_rb) \
|
||||||
M(srcover_rgba_8888) \
|
M(srcover_rgba_8888) \
|
||||||
M(lerp_1_float) \
|
M(lerp_1_float) \
|
||||||
M(lerp_u8) \
|
M(lerp_u8) \
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -520,12 +520,6 @@ STAGE(swap_rb) {
|
|||||||
b = tmp;
|
b = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
STAGE(swap_rb_dst) {
|
|
||||||
auto tmp = dr;
|
|
||||||
dr = db;
|
|
||||||
db = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
STAGE(move_src_dst) {
|
STAGE(move_src_dst) {
|
||||||
dr = r;
|
dr = r;
|
||||||
dg = g;
|
dg = g;
|
||||||
@ -906,6 +900,29 @@ STAGE(store_8888) {
|
|||||||
store(ptr, px, tail);
|
store(ptr, px, tail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STAGE(load_bgra) {
|
||||||
|
auto ptr = *(const uint32_t**)ctx + x;
|
||||||
|
from_8888(load<U32>(ptr, tail), &b,&g,&r,&a);
|
||||||
|
}
|
||||||
|
STAGE(load_bgra_dst) {
|
||||||
|
auto ptr = *(const uint32_t**)ctx + x;
|
||||||
|
from_8888(load<U32>(ptr, tail), &db,&dg,&dr,&da);
|
||||||
|
}
|
||||||
|
STAGE(gather_bgra) {
|
||||||
|
const uint32_t* ptr;
|
||||||
|
U32 ix = ix_and_ptr(&ptr, ctx, r,g);
|
||||||
|
from_8888(gather(ptr, ix), &b,&g,&r,&a);
|
||||||
|
}
|
||||||
|
STAGE(store_bgra) {
|
||||||
|
auto ptr = *(uint32_t**)ctx + x;
|
||||||
|
|
||||||
|
U32 px = round(b, 255.0f)
|
||||||
|
| round(g, 255.0f) << 8
|
||||||
|
| round(r, 255.0f) << 16
|
||||||
|
| round(a, 255.0f) << 24;
|
||||||
|
store(ptr, px, tail);
|
||||||
|
}
|
||||||
|
|
||||||
STAGE(load_f16) {
|
STAGE(load_f16) {
|
||||||
auto ptr = *(const uint64_t**)ctx + x;
|
auto ptr = *(const uint64_t**)ctx + x;
|
||||||
|
|
||||||
|
@ -249,6 +249,19 @@ STAGE(store_8888) {
|
|||||||
store(ptr, to_8888(r,g,b,a), tail);
|
store(ptr, to_8888(r,g,b,a), tail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STAGE(load_bgra) {
|
||||||
|
auto ptr = *(const uint32_t**)ctx + x;
|
||||||
|
from_8888(load<U32>(ptr, tail), &b,&g,&r,&a);
|
||||||
|
}
|
||||||
|
STAGE(load_bgra_dst) {
|
||||||
|
auto ptr = *(const uint32_t**)ctx + x;
|
||||||
|
from_8888(load<U32>(ptr, tail), &db,&dg,&dr,&da);
|
||||||
|
}
|
||||||
|
STAGE(store_bgra) {
|
||||||
|
auto ptr = *(uint32_t**)ctx + x;
|
||||||
|
store(ptr, to_8888(b,g,r,a), tail);
|
||||||
|
}
|
||||||
|
|
||||||
STAGE(load_a8) {
|
STAGE(load_a8) {
|
||||||
auto ptr = *(const uint8_t**)ctx + x;
|
auto ptr = *(const uint8_t**)ctx + x;
|
||||||
r = g = b = 0.0f;
|
r = g = b = 0.0f;
|
||||||
@ -334,12 +347,6 @@ STAGE(swap_rb) {
|
|||||||
r = b;
|
r = b;
|
||||||
b = tmp;
|
b = tmp;
|
||||||
}
|
}
|
||||||
STAGE(swap_rb_dst) {
|
|
||||||
auto tmp = dr;
|
|
||||||
dr = db;
|
|
||||||
db = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
STAGE(move_src_dst) {
|
STAGE(move_src_dst) {
|
||||||
dr = r;
|
dr = r;
|
||||||
dg = g;
|
dg = g;
|
||||||
|
@ -336,8 +336,8 @@ bool SkImageShader::onAppendStages(SkRasterPipeline* p, SkColorSpace* dstCS, SkA
|
|||||||
case kGray_8_SkColorType: p->append(SkRasterPipeline::gather_g8, gather); break;
|
case kGray_8_SkColorType: p->append(SkRasterPipeline::gather_g8, gather); break;
|
||||||
case kRGB_565_SkColorType: p->append(SkRasterPipeline::gather_565, gather); break;
|
case kRGB_565_SkColorType: p->append(SkRasterPipeline::gather_565, gather); break;
|
||||||
case kARGB_4444_SkColorType: p->append(SkRasterPipeline::gather_4444, gather); break;
|
case kARGB_4444_SkColorType: p->append(SkRasterPipeline::gather_4444, gather); break;
|
||||||
case kRGBA_8888_SkColorType:
|
case kBGRA_8888_SkColorType: p->append(SkRasterPipeline::gather_bgra, gather); break;
|
||||||
case kBGRA_8888_SkColorType: p->append(SkRasterPipeline::gather_8888, gather); break;
|
case kRGBA_8888_SkColorType: p->append(SkRasterPipeline::gather_8888, gather); break;
|
||||||
case kRGBA_F16_SkColorType: p->append(SkRasterPipeline::gather_f16, gather); break;
|
case kRGBA_F16_SkColorType: p->append(SkRasterPipeline::gather_f16, gather); break;
|
||||||
default: SkASSERT(false);
|
default: SkASSERT(false);
|
||||||
}
|
}
|
||||||
@ -396,11 +396,7 @@ bool SkImageShader::onAppendStages(SkRasterPipeline* p, SkColorSpace* dstCS, SkA
|
|||||||
p->append(SkRasterPipeline::move_dst_src);
|
p->append(SkRasterPipeline::move_dst_src);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto effective_color_type = [](SkColorType ct) {
|
if (info.colorType() == kIndex_8_SkColorType && kN32_SkColorType == kBGRA_8888_SkColorType) {
|
||||||
return ct == kIndex_8_SkColorType ? kN32_SkColorType : ct;
|
|
||||||
};
|
|
||||||
|
|
||||||
if (effective_color_type(info.colorType()) == kBGRA_8888_SkColorType) {
|
|
||||||
p->append(SkRasterPipeline::swap_rb);
|
p->append(SkRasterPipeline::swap_rb);
|
||||||
}
|
}
|
||||||
if (info.colorType() == kAlpha_8_SkColorType) {
|
if (info.colorType() == kAlpha_8_SkColorType) {
|
||||||
|
Loading…
Reference in New Issue
Block a user