Index: src/core/SkLinearBitmapPipeline.cpp |
diff --git a/src/core/SkLinearBitmapPipeline.cpp b/src/core/SkLinearBitmapPipeline.cpp |
index 58b3f3226f4359ce4e6af56ad4f5977fb8c63618..dd396e06ccbb1a54f598cb127f56e94183adf4fa 100644 |
--- a/src/core/SkLinearBitmapPipeline.cpp |
+++ b/src/core/SkLinearBitmapPipeline.cpp |
@@ -713,10 +713,14 @@ public: |
} |
}; |
-template <SkColorProfileType colorProfile> |
-class RGBA8888 { |
+enum ShouldSizzle { |
mtklein
2016/02/29 21:34:07
spelling....
let's either make this an enum class
herb_g
2016/02/29 21:54:56
Done.
|
+ k8888Passthrough = false, |
+ k8888RBSwap = true, |
mtklein
2016/02/29 21:34:07
I don't understand why 8888 is important here?
herb_g
2016/02/29 21:54:56
Acknowledged.
|
+}; |
+template <SkColorProfileType colorProfile, ShouldSizzle swizzle = k8888Passthrough> |
mtklein
2016/02/29 21:34:07
I think this might read more clearly without a def
herb_g
2016/02/29 21:54:56
Done.
|
+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) { |
@@ -755,6 +759,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 (swizzle == k8888RBSwap) { |
+ pixel = SkNx_shuffle<2, 1, 0, 3>(pixel); |
+ } |
pixel = pixel * Sk4f{1.0f/255.0f}; |
if (colorProfile == kSRGB_SkColorProfileType) { |
pixel = sRGBFast::sRGBToLinear(pixel); |
@@ -919,19 +926,25 @@ 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>>>( |
+ next, static_cast<int>(srcPixmap.rowBytes() / 4), |
+ srcPixmap.addr32()); |
+ } else { |
+ sampleStage->Initialize<Sampler<Pixel8888<kLinear_SkColorProfileType>>>( |
+ 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, k8888RBSwap>>>( |
+ next, static_cast<int>(srcPixmap.rowBytes() / 4), |
+ srcPixmap.addr32()); |
} else { |
- SkFAIL("Not implemented. No 8888 Swizzle"); |
+ sampleStage->Initialize<Sampler<Pixel8888<kLinear_SkColorProfileType, k8888RBSwap>>>( |
+ next, static_cast<int>(srcPixmap.rowBytes() / 4), |
+ srcPixmap.addr32()); |
} |
break; |
default: |