aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkConvertPixels.cpp
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2018-03-19 16:06:44 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-03-19 21:17:15 +0000
commit19eaf2dbe785a06b76f11c2066c302f0aa89d5d2 (patch)
tree9bf1bcf8fe794da174ba19b1c5cfed84f0f274e5 /src/core/SkConvertPixels.cpp
parent56dc04bdc160b71a1e77fdb9e30fde4e860077ae (diff)
Revert "Revert "New read pixels implementation that is simpler but does all conversions on CPU.""
This reverts commit be5947c2f38a79b7c709accfb1047d8fd06a0227. Bug: skia: Change-Id: I06dc15b31042d7827511d0ac2a7f4262c3f09622 Reviewed-on: https://skia-review.googlesource.com/115079 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/core/SkConvertPixels.cpp')
-rw-r--r--src/core/SkConvertPixels.cpp59
1 files changed, 58 insertions, 1 deletions
diff --git a/src/core/SkConvertPixels.cpp b/src/core/SkConvertPixels.cpp
index 725730a1e4..8a8f2ba153 100644
--- a/src/core/SkConvertPixels.cpp
+++ b/src/core/SkConvertPixels.cpp
@@ -184,6 +184,30 @@ static void convert_to_alpha8(uint8_t* dst, size_t dstRB, const SkImageInfo& src
}
break;
}
+ case kRGBA_1010102_SkColorType: {
+ auto src32 = (const uint32_t*) src;
+ for (int y = 0; y < srcInfo.height(); y++) {
+ for (int x = 0; x < srcInfo.width(); x++) {
+ switch (src32[x] >> 30) {
+ case 0:
+ dst[x] = 0;
+ break;
+ case 1:
+ dst[x] = 0x55;
+ break;
+ case 2:
+ dst[x] = 0xAA;
+ break;
+ case 3:
+ dst[x] = 0xFF;
+ break;
+ }
+ }
+ dst = SkTAddOffset<uint8_t>(dst, dstRB);
+ src32 = SkTAddOffset<const uint32_t>(src32, srcRB);
+ }
+ break;
+ }
case kARGB_4444_SkColorType: {
auto src16 = (const uint16_t*) src;
for (int y = 0; y < srcInfo.height(); y++) {
@@ -225,9 +249,20 @@ static void convert_with_pipeline(const SkImageInfo& dstInfo, void* dstRow, size
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;
@@ -325,9 +360,20 @@ static void convert_with_pipeline(const SkImageInfo& dstInfo, void* dstRow, size
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;
@@ -345,6 +391,16 @@ static void convert_with_pipeline(const SkImageInfo& dstInfo, void* dstRow, size
pipeline.run(0,0, srcInfo.width(), srcInfo.height());
}
+static bool swizzle_and_multiply_color_type(SkColorType ct) {
+ switch (ct) {
+ case kRGBA_8888_SkColorType:
+ case kBGRA_8888_SkColorType:
+ return true;
+ default:
+ return false;
+ }
+}
+
void SkConvertPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB,
const SkImageInfo& srcInfo, const void* srcPixels, size_t srcRB,
SkColorTable* ctable, SkTransferFunctionBehavior behavior) {
@@ -361,7 +417,8 @@ void SkConvertPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB,
SkASSERT(srcInfo.colorSpace() || !isColorAware);
// Fast Path 2: Simple swizzles and premuls.
- if (4 == srcInfo.bytesPerPixel() && 4 == dstInfo.bytesPerPixel() && !isColorAware) {
+ if (swizzle_and_multiply_color_type(srcInfo.colorType()) &&
+ swizzle_and_multiply_color_type(dstInfo.colorType()) && !isColorAware) {
swizzle_and_multiply(dstInfo, dstPixels, dstRB, srcInfo, srcPixels, srcRB);
return;
}