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

Unified Diff: src/core/SkColorSpaceXform.cpp

Issue 2184543003: Perform color correction on png decodes (Closed) Base URL: https://skia.googlesource.com/skia.git@colorjpegs
Patch Set: Fixes Created 4 years, 4 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 | « src/core/SkColorSpaceXform.h ('k') | src/core/SkColorSpaceXformOpts.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkColorSpaceXform.cpp
diff --git a/src/core/SkColorSpaceXform.cpp b/src/core/SkColorSpaceXform.cpp
index 57b4fa6ddd41d68e61dfdc44fffc68487e66385b..4fa4746ad6d110487ff44f7a3c6603bbbcbdf8f0 100644
--- a/src/core/SkColorSpaceXform.cpp
+++ b/src/core/SkColorSpaceXform.cpp
@@ -633,101 +633,76 @@ SkColorSpaceXform_Base<kDst>::SkColorSpaceXform_Base(const sk_sp<SkColorSpace>&
dstSpace, kFromLinear);
}
-template <>
-void SkColorSpaceXform_Base<SkColorSpace::kSRGB_GammaNamed>
-::applyToRGBA(RGBA32* dst, const RGBA32* src, int len) const
-{
- if (fColorLUT) {
- handle_color_lut(dst, src, len, fColorLUT.get());
- src = dst;
- }
-
- color_xform_RGBA<SkColorSpace::kSRGB_GammaNamed, false, false>
- (dst, src, len, fSrcGammaTables, fSrcToDst, fDstGammaTables);
-}
-
-template <>
-void SkColorSpaceXform_Base<SkColorSpace::k2Dot2Curve_GammaNamed>
-::applyToRGBA(RGBA32* dst, const RGBA32* src, int len) const
-{
- if (fColorLUT) {
- handle_color_lut(dst, src, len, fColorLUT.get());
- src = dst;
- }
-
- color_xform_RGBA<SkColorSpace::k2Dot2Curve_GammaNamed, false, false>
- (dst, src, len, fSrcGammaTables, fSrcToDst, fDstGammaTables);
-}
-
-template <>
-void SkColorSpaceXform_Base<SkColorSpace::kNonStandard_GammaNamed>
-::applyToRGBA(RGBA32* dst, const RGBA32* src, int len) const
-{
- if (fColorLUT) {
- handle_color_lut(dst, src, len, fColorLUT.get());
- src = dst;
- }
-
- color_xform_RGBA<SkColorSpace::kNonStandard_GammaNamed, false, false>
- (dst, src, len, fSrcGammaTables, fSrcToDst, fDstGammaTables);
-}
-
-template <>
-void SkColorSpaceXform_Base<SkColorSpace::kSRGB_GammaNamed>
-::applyToBGRA(BGRA32* dst, const RGBA32* src, int len) const
-{
- if (fColorLUT) {
- handle_color_lut(dst, src, len, fColorLUT.get());
- src = dst;
- }
-
- color_xform_RGBA<SkColorSpace::kSRGB_GammaNamed, false, true>
- (dst, src, len, fSrcGammaTables, fSrcToDst, fDstGammaTables);
-}
-
-template <>
-void SkColorSpaceXform_Base<SkColorSpace::k2Dot2Curve_GammaNamed>
-::applyToBGRA(BGRA32* dst, const RGBA32* src, int len) const
-{
- if (fColorLUT) {
- handle_color_lut(dst, src, len, fColorLUT.get());
- src = dst;
- }
-
- color_xform_RGBA<SkColorSpace::k2Dot2Curve_GammaNamed, false, true>
- (dst, src, len, fSrcGammaTables, fSrcToDst, fDstGammaTables);
-}
-
-template <>
-void SkColorSpaceXform_Base<SkColorSpace::kNonStandard_GammaNamed>
-::applyToBGRA(BGRA32* dst, const RGBA32* src, int len) const
-{
- if (fColorLUT) {
- handle_color_lut(dst, src, len, fColorLUT.get());
- src = dst;
- }
-
- color_xform_RGBA<SkColorSpace::kNonStandard_GammaNamed, false, true>
- (dst, src, len, fSrcGammaTables, fSrcToDst, fDstGammaTables);
-}
-
-template <SkColorSpace::GammaNamed T>
-void SkColorSpaceXform_Base<T>
-::applyToF16(RGBAF16* dst, const RGBA32* src, int len) const
+template <SkColorSpace::GammaNamed kDst>
+void SkColorSpaceXform_Base<kDst>
+::apply(void* dst, const uint32_t* src, int len, SkColorType dstColorType, SkAlphaType dstAlphaType)
+const
{
if (fColorLUT) {
- size_t storageBytes = len * sizeof(RGBA32);
+ size_t storageBytes = len * sizeof(uint32_t);
#if defined(GOOGLE3)
// Stack frame size is limited in GOOGLE3.
- SkAutoSMalloc<256 * sizeof(RGBA32)> storage(storageBytes);
+ SkAutoSMalloc<256 * sizeof(uint32_t)> storage(storageBytes);
#else
- SkAutoSMalloc<1024 * sizeof(RGBA32)> storage(storageBytes);
+ SkAutoSMalloc<1024 * sizeof(uint32_t)> storage(storageBytes);
#endif
- handle_color_lut((RGBA32*) storage.get(), src, len, fColorLUT.get());
- src = (const RGBA32*) storage.get();
+ handle_color_lut((uint32_t*) storage.get(), src, len, fColorLUT.get());
+ src = (const uint32_t*) storage.get();
}
- color_xform_RGBA<SkColorSpace::kLinear_GammaNamed, false, false>
- (dst, src, len, fSrcGammaTables, fSrcToDst, fDstGammaTables);
+ switch (dstAlphaType) {
+ case kPremul_SkAlphaType:
+ switch (dstColorType) {
+ case kRGBA_8888_SkColorType:
+ return color_xform_RGBA<kDst, kPremul_SkAlphaType, kNo_SwapRB>
+ (dst, src, len, fSrcGammaTables, fSrcToDst, fDstGammaTables);
+ case kBGRA_8888_SkColorType:
+ return color_xform_RGBA<kDst, kPremul_SkAlphaType, kYes_SwapRB>
+ (dst, src, len, fSrcGammaTables, fSrcToDst, fDstGammaTables);
+ case kRGBA_F16_SkColorType:
+ return color_xform_RGBA
+ <SkColorSpace::kLinear_GammaNamed, kPremul_SkAlphaType, kNo_SwapRB>
+ (dst, src, len, fSrcGammaTables, fSrcToDst, fDstGammaTables);
+ default:
+ SkASSERT(false);
+ return;
+ }
+ break;
+ case kUnpremul_SkAlphaType:
+ switch (dstColorType) {
+ case kRGBA_8888_SkColorType:
+ return color_xform_RGBA<kDst, kUnpremul_SkAlphaType, kNo_SwapRB>
+ (dst, src, len, fSrcGammaTables, fSrcToDst, fDstGammaTables);
+ case kBGRA_8888_SkColorType:
+ return color_xform_RGBA<kDst, kUnpremul_SkAlphaType, kYes_SwapRB>
+ (dst, src, len, fSrcGammaTables, fSrcToDst, fDstGammaTables);
+ case kRGBA_F16_SkColorType:
+ return color_xform_RGBA
+ <SkColorSpace::kLinear_GammaNamed, kUnpremul_SkAlphaType, kNo_SwapRB>
+ (dst, src, len, fSrcGammaTables, fSrcToDst, fDstGammaTables);
+ default:
+ SkASSERT(false);
+ return;
+ }
+ case kOpaque_SkAlphaType:
+ switch (dstColorType) {
+ case kRGBA_8888_SkColorType:
+ return color_xform_RGBA<kDst, kOpaque_SkAlphaType, kNo_SwapRB>
+ (dst, src, len, fSrcGammaTables, fSrcToDst, fDstGammaTables);
+ case kBGRA_8888_SkColorType:
+ return color_xform_RGBA<kDst, kOpaque_SkAlphaType, kYes_SwapRB>
+ (dst, src, len, fSrcGammaTables, fSrcToDst, fDstGammaTables);
+ case kRGBA_F16_SkColorType:
+ return color_xform_RGBA
+ <SkColorSpace::kLinear_GammaNamed, kOpaque_SkAlphaType, kNo_SwapRB>
+ (dst, src, len, fSrcGammaTables, fSrcToDst, fDstGammaTables);
+ default:
+ SkASSERT(false);
+ return;
+ }
+ default:
+ SkASSERT(false);
+ return;
+ }
}
« no previous file with comments | « src/core/SkColorSpaceXform.h ('k') | src/core/SkColorSpaceXformOpts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698