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

Unified Diff: src/core/SkLinearBitmapPipeline_sample.h

Issue 2163683002: Correct sRGB <-> linear everywhere. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix! Created 4 years, 5 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
Index: src/core/SkLinearBitmapPipeline_sample.h
diff --git a/src/core/SkLinearBitmapPipeline_sample.h b/src/core/SkLinearBitmapPipeline_sample.h
index e957ae7e4d0268cc285b193d0ceb2d31f9184d47..a8beadbda0939378712a77ef65c67b663b3d56c1 100644
--- a/src/core/SkLinearBitmapPipeline_sample.h
+++ b/src/core/SkLinearBitmapPipeline_sample.h
@@ -158,19 +158,9 @@ public:
private:
static const size_t kColorTableSize = sizeof(Sk4f[256]) + 12;
Sk4f convertPixel(SkPMColor pmColor) {
- Sk4f pixel = to_4f(pmColor);
- float alpha = get_alpha(pixel);
- if (alpha != 0.0f) {
- float invAlpha = 1.0f / alpha;
- Sk4f normalize = {invAlpha, invAlpha, invAlpha, 1.0f / 255.0f};
- pixel = pixel * normalize;
- if (gammaType == kSRGB_SkGammaType) {
- pixel = linear_to_srgb(pixel);
- }
- return pixel;
- } else {
- return Sk4f{0.0f};
- }
+ return swizzle_rb_if_bgra(
+ (gammaType == kSRGB_SkGammaType) ? Sk4f_fromS32(pmColor)
+ : Sk4f_fromL32(pmColor));
}
SkAutoMalloc fColorTableStorage{kColorTableSize};
Sk4f* fColorTable;
@@ -183,11 +173,10 @@ public:
PixelConverter(const SkPixmap& srcPixmap) { }
Sk4f toSk4f(Element pixel) const {
- float gray = pixel * (1.0f/255.0f);
- Sk4f result = Sk4f{gray, gray, gray, 1.0f};
- return gammaType == kSRGB_SkGammaType
- ? srgb_to_linear(result)
- : result;
+ float gray = (gammaType == kSRGB_SkGammaType)
+ ? sk_linear_from_srgb[pixel]
+ : pixel * (1/255.0f);
+ return {gray, gray, gray, 1.0f};
}
};

Powered by Google App Engine
This is Rietveld 408576698