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

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: address comments 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..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:
« 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