Index: src/core/SkLinearBitmapPipeline.cpp |
diff --git a/src/core/SkLinearBitmapPipeline.cpp b/src/core/SkLinearBitmapPipeline.cpp |
index 58b3f3226f4359ce4e6af56ad4f5977fb8c63618..fd17917a34d0e69d529958374c9edd464c1fb8bf 100644 |
--- a/src/core/SkLinearBitmapPipeline.cpp |
+++ b/src/core/SkLinearBitmapPipeline.cpp |
@@ -713,7 +713,11 @@ public: |
} |
}; |
-template <SkColorProfileType colorProfile> |
+enum ShouldSizzle { |
+ kPassthrough = false, |
+ kSwizzle = true, |
mtklein_C
2016/02/29 20:15:54
Let's call this kSwapRB or kSwap02? It'd be nice
herb_g
2016/02/29 21:30:58
Done.
|
+}; |
+template <SkColorProfileType colorProfile, ShouldSizzle swizzle = kPassthrough> |
class RGBA8888 { |
public: |
RGBA8888(int width, const uint32_t* src) |
@@ -754,9 +758,12 @@ public: |
Sk4f getPixel(const uint32_t* src, int index) { |
Sk4b bytePixel = Sk4b::Load((uint8_t *)(&src[index])); |
+ if (kSwizzle == swizzle) { |
+ bytePixel = SkNx_shuffle<2, 1, 0, 3>(bytePixel); |
mtklein_C
2016/02/29 20:15:54
Is there some reason we need to swap the bytes bef
herb_g
2016/02/29 21:30:58
Done.
|
+ } |
Sk4f pixel = SkNx_cast<float, uint8_t>(bytePixel); |
pixel = pixel * Sk4f{1.0f/255.0f}; |
- if (colorProfile == kSRGB_SkColorProfileType) { |
+ if (kSRGB_SkColorProfileType == colorProfile) { |
mtklein_C
2016/02/29 20:15:54
This seems fine if you like this style, but I thin
herb_g
2016/02/29 21:30:58
Great. I do not like yoda ==.
|
pixel = sRGBFast::sRGBToLinear(pixel); |
} |
return pixel; |
@@ -919,19 +926,27 @@ 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<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()); |
+ } |
+ break; |
case kBGRA_8888_SkColorType: |
if (kN32_SkColorType == imageInfo.colorType()) { |
mtklein_C
2016/02/29 20:15:54
remove
herb_g
2016/02/29 21:30:58
Done.
|
if (imageInfo.profileType() == kSRGB_SkColorProfileType) { |
- sampleStage->Initialize<Sampler<RGBA8888<kSRGB_SkColorProfileType>>>( |
+ sampleStage->Initialize<Sampler<RGBA8888<kSRGB_SkColorProfileType, kSwizzle>>>( |
next, static_cast<int>(srcPixmap.rowBytes() / 4), |
srcPixmap.addr32()); |
} else { |
- sampleStage->Initialize<Sampler<RGBA8888<kLinear_SkColorProfileType>>>( |
+ sampleStage->Initialize<Sampler<RGBA8888<kLinear_SkColorProfileType, kSwizzle>>>( |
next, static_cast<int>(srcPixmap.rowBytes() / 4), |
srcPixmap.addr32()); |
} |
- } else { |
- SkFAIL("Not implemented. No 8888 Swizzle"); |
} |
break; |
default: |