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

Unified Diff: src/core/SkColorSpace.cpp

Issue 2304753002: Add SkColorSpacePrimaries to help with making D50 matrices (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Simplify even more Created 4 years, 3 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/SkColorSpace.cpp
diff --git a/src/core/SkColorSpace.cpp b/src/core/SkColorSpace.cpp
index e6676066bb24beac7ee8125478d1715921829fb9..54bee247a27bdf4961ca0eab3ecc88c271626b2c 100644
--- a/src/core/SkColorSpace.cpp
+++ b/src/core/SkColorSpace.cpp
@@ -132,6 +132,26 @@ sk_sp<SkColorSpace> SkColorSpace::NewRGB(RenderTargetGamma gamma, const SkMatrix
}
}
+sk_sp<SkColorSpace> SkColorSpace::NewRGB(const SkTransferFn& coeffs, const SkMatrix44& toXYZD50) {
+ // TODO: Check if coeffs match sRGB, 2.2, or linear.
+ // TODO: Make sure coefficients describe a valid curve. Return nullptr if they don't.
+ void* memory = sk_malloc_throw(sizeof(SkGammas) + sizeof(SkTransferFn));
+ sk_sp<SkGammas> gammas = sk_sp<SkGammas>(new (memory) SkGammas());
+ void* storage = SkTAddOffset<void>(memory, sizeof(SkGammas));
+ memcpy(storage, &coeffs, sizeof(SkTransferFn));
+ gammas->fRedType = SkGammas::Type::kParam_Type;
+ gammas->fGreenType = SkGammas::Type::kParam_Type;
+ gammas->fBlueType = SkGammas::Type::kParam_Type;
+
+ SkGammas::Data data;
+ data.fParamOffset = 0;
+ gammas->fRedData = data;
+ gammas->fGreenData = data;
+ gammas->fBlueData = data;
+ return sk_sp<SkColorSpace>(new SkColorSpace_Base(nullptr, kNonStandard_SkGammaNamed,
+ std::move(gammas), toXYZD50, nullptr));
+}
+
static SkColorSpace* gAdobeRGB;
static SkColorSpace* gSRGB;
@@ -270,6 +290,8 @@ size_t SkColorSpace::writeToMemory(void* memory) const {
return sizeof(ColorSpaceHeader) + 12 * sizeof(float);
}
default:
+ // TODO: Fix this to serialize properly.
+
// Otherwise, write the gamma values and the matrix.
if (memory) {
*((ColorSpaceHeader*) memory) =
@@ -369,6 +391,8 @@ sk_sp<SkColorSpace> SkColorSpace::Deserialize(const void* data, size_t length) {
return NewICC(data, profileSize);
}
case ColorSpaceHeader::kFloatGamma_Flag: {
+ // TODO: Fix this to deserialize properly.
+
if (length < 15 * sizeof(float)) {
return nullptr;
}

Powered by Google App Engine
This is Rietveld 408576698