Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(503)

Unified Diff: src/core/SkLinearBitmapPipeline.cpp

Issue 1746153002: Add swizzle for rgb8888. (Closed) Base URL: https://skia.googlesource.com/skia.git@sample-span-20160229
Patch Set: What was I thinking? Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/opts/SkNx_neon.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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:
« no previous file with comments | « no previous file | src/opts/SkNx_neon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698