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

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: change to clearer enum. 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 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:
« 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