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

Unified Diff: src/core/SkColorSpace.cpp

Issue 1986833002: SkColorSpace follow-ups (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: New SkGammas constructor that takes SkGammaCurves Created 4 years, 7 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/SkColorSpace.h ('k') | src/core/SkColorSpacePriv.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkColorSpace.cpp
diff --git a/src/core/SkColorSpace.cpp b/src/core/SkColorSpace.cpp
index 172082b781e9b69fb5b3f984a16497a0c3436ae0..b3fad724915d0a39d1f22a56a8433579e3420786 100644
--- a/src/core/SkColorSpace.cpp
+++ b/src/core/SkColorSpace.cpp
@@ -554,7 +554,7 @@ bool load_matrix(SkMatrix44* toXYZ, const uint8_t* src, size_t len) {
return true;
}
-bool SkColorSpace::LoadA2B0(SkColorLookUpTable* colorLUT, sk_sp<SkGammas> gammas, SkMatrix44* toXYZ,
+bool SkColorSpace::LoadA2B0(SkColorLookUpTable* colorLUT, SkGammaCurve* gammas, SkMatrix44* toXYZ,
const uint8_t* src, size_t len) {
if (len < 32) {
SkColorSpacePrintf("A to B tag is too small (%d bytes).", len);
@@ -604,7 +604,7 @@ bool SkColorSpace::LoadA2B0(SkColorLookUpTable* colorLUT, sk_sp<SkGammas> gammas
uint32_t offsetToMCurves = read_big_endian_int(src + 20);
if (0 != offsetToMCurves && offsetToMCurves < len) {
- if (!SkColorSpace::LoadGammas(&gammas->fRed, outputChannels, src + offsetToMCurves,
+ if (!SkColorSpace::LoadGammas(gammas, outputChannels, src + offsetToMCurves,
len - offsetToMCurves)) {
SkColorSpacePrintf("Failed to read M curves from A to B tag.\n");
}
@@ -680,23 +680,25 @@ sk_sp<SkColorSpace> SkColorSpace::NewICC(const void* base, size_t len) {
// It is not uncommon to see missing or empty gamma tags. This indicates
// that we should use unit gamma.
- sk_sp<SkGammas> gammas(new SkGammas());
+ SkGammaCurve curves[3];
r = ICCTag::Find(tags.get(), tagCount, kTAG_rTRC);
g = ICCTag::Find(tags.get(), tagCount, kTAG_gTRC);
b = ICCTag::Find(tags.get(), tagCount, kTAG_bTRC);
- if (!r || !SkColorSpace::LoadGammas(&gammas->fRed, 1,
+ if (!r || !SkColorSpace::LoadGammas(&curves[0], 1,
r->addr((const uint8_t*) base), r->fLength)) {
SkColorSpacePrintf("Failed to read R gamma tag.\n");
}
- if (!g || !SkColorSpace::LoadGammas(&gammas->fGreen, 1,
+ if (!g || !SkColorSpace::LoadGammas(&curves[1], 1,
g->addr((const uint8_t*) base), g->fLength)) {
SkColorSpacePrintf("Failed to read G gamma tag.\n");
}
- if (!b || !SkColorSpace::LoadGammas(&gammas->fBlue, 1,
+ if (!b || !SkColorSpace::LoadGammas(&curves[2], 1,
b->addr((const uint8_t*) base), b->fLength)) {
SkColorSpacePrintf("Failed to read B gamma tag.\n");
}
+ sk_sp<SkGammas> gammas(new SkGammas(std::move(curves[0]), std::move(curves[1]),
+ std::move(curves[2])));
SkMatrix44 mat(SkMatrix44::kUninitialized_Constructor);
mat.set3x3ColMajorf(toXYZ);
if (gammas->isValues()) {
@@ -716,13 +718,15 @@ sk_sp<SkColorSpace> SkColorSpace::NewICC(const void* base, size_t len) {
const ICCTag* a2b0 = ICCTag::Find(tags.get(), tagCount, kTAG_A2B0);
if (a2b0) {
SkAutoTDelete<SkColorLookUpTable> colorLUT(new SkColorLookUpTable());
- sk_sp<SkGammas> gammas(new SkGammas());
+ SkGammaCurve curves[3];
SkMatrix44 toXYZ(SkMatrix44::kUninitialized_Constructor);
- if (!SkColorSpace::LoadA2B0(colorLUT, gammas, &toXYZ,
+ if (!SkColorSpace::LoadA2B0(colorLUT, curves, &toXYZ,
a2b0->addr((const uint8_t*) base), a2b0->fLength)) {
return_null("Failed to parse A2B0 tag");
}
+ sk_sp<SkGammas> gammas(new SkGammas(std::move(curves[0]), std::move(curves[1]),
+ std::move(curves[2])));
if (colorLUT->fTable) {
return sk_sp<SkColorSpace>(new SkColorSpace(colorLUT.release(), gammas, toXYZ));
} else if (gammas->isValues()) {
« no previous file with comments | « src/core/SkColorSpace.h ('k') | src/core/SkColorSpacePriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698