Index: src/core/SkLinearBitmapPipeline.cpp |
diff --git a/src/core/SkLinearBitmapPipeline.cpp b/src/core/SkLinearBitmapPipeline.cpp |
index fa5648492577d2f3c183e15f2e8095a7f0ecdbbf..efcc01280bc20050af83d3a18d9c8157fab24817 100644 |
--- a/src/core/SkLinearBitmapPipeline.cpp |
+++ b/src/core/SkLinearBitmapPipeline.cpp |
@@ -707,10 +707,14 @@ public: |
} |
}; |
-template <SkColorProfileType colorProfile> |
-class RGBA8888 { |
+enum class ColorOrder { |
+ kRGBA = false, |
+ kBGRA = true, |
+}; |
+template <SkColorProfileType colorProfile, ColorOrder colorOrder> |
+class Pixel8888 { |
public: |
- RGBA8888(int width, const uint32_t* src) |
+ Pixel8888(int width, const uint32_t* src) |
: fSrc{src}, fWidth{width}{ } |
void VECTORCALL getFewPixels(int n, Sk4s xs, Sk4s ys, Sk4f* px0, Sk4f* px1, Sk4f* px2) { |
@@ -749,6 +753,9 @@ public: |
Sk4f getPixel(const uint32_t* src, int index) { |
Sk4b bytePixel = Sk4b::Load((uint8_t *)(&src[index])); |
Sk4f pixel = SkNx_cast<float, uint8_t>(bytePixel); |
+ if (colorOrder == ColorOrder::kBGRA) { |
+ pixel = SkNx_shuffle<2, 1, 0, 3>(pixel); |
+ } |
pixel = pixel * Sk4f{1.0f/255.0f}; |
if (colorProfile == kSRGB_SkColorProfileType) { |
pixel = sRGBFast::sRGBToLinear(pixel); |
@@ -913,19 +920,29 @@ static SkLinearBitmapPipeline::BilerpProcessorInterface* choose_pixel_sampler( |
const SkImageInfo& imageInfo = srcPixmap.info(); |
switch (imageInfo.colorType()) { |
case kRGBA_8888_SkColorType: |
+ if (imageInfo.profileType() == kSRGB_SkColorProfileType) { |
+ sampleStage->Initialize<Sampler<Pixel8888<kSRGB_SkColorProfileType, |
mtklein
2016/02/29 22:04:26
these calls to Initialize() are not very pretty.
mtklein
2016/03/01 15:17:55
Very pretty now!
|
+ ColorOrder::kRGBA>>>( |
+ next, static_cast<int>(srcPixmap.rowBytes() / 4), |
+ srcPixmap.addr32()); |
+ } else { |
+ sampleStage->Initialize<Sampler<Pixel8888<kLinear_SkColorProfileType, |
+ ColorOrder::kRGBA>>>( |
+ next, static_cast<int>(srcPixmap.rowBytes() / 4), |
+ srcPixmap.addr32()); |
+ } |
+ break; |
case kBGRA_8888_SkColorType: |
- if (kN32_SkColorType == imageInfo.colorType()) { |
- if (imageInfo.profileType() == kSRGB_SkColorProfileType) { |
- sampleStage->Initialize<Sampler<RGBA8888<kSRGB_SkColorProfileType>>>( |
- next, static_cast<int>(srcPixmap.rowBytes() / 4), |
- srcPixmap.addr32()); |
- } else { |
- sampleStage->Initialize<Sampler<RGBA8888<kLinear_SkColorProfileType>>>( |
- next, static_cast<int>(srcPixmap.rowBytes() / 4), |
- srcPixmap.addr32()); |
- } |
+ if (imageInfo.profileType() == kSRGB_SkColorProfileType) { |
+ sampleStage->Initialize<Sampler<Pixel8888<kSRGB_SkColorProfileType, |
+ ColorOrder::kBGRA>>>( |
+ next, static_cast<int>(srcPixmap.rowBytes() / 4), |
+ srcPixmap.addr32()); |
} else { |
- SkFAIL("Not implemented. No 8888 Swizzle"); |
+ sampleStage->Initialize<Sampler<Pixel8888<kLinear_SkColorProfileType, |
+ ColorOrder::kBGRA>>>( |
+ next, static_cast<int>(srcPixmap.rowBytes() / 4), |
+ srcPixmap.addr32()); |
} |
break; |
default: |