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

Unified Diff: src/core/SkColorSpace.cpp

Issue 2117773002: Refactor parsing and storage of SkGammas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Read fixed 0.16 properly 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
« no previous file with comments | « no previous file | 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 894c4b99b7564c0040be2b8826c47d3efcdf5c30..ba278dfcd69d81bde8235f0e392f96c7c67a14f8 100644
--- a/src/core/SkColorSpace.cpp
+++ b/src/core/SkColorSpace.cpp
@@ -22,9 +22,10 @@ SkColorSpace_Base::SkColorSpace_Base(GammaNamed gammaNamed, const SkMatrix44& to
, fProfileData(nullptr)
{}
-SkColorSpace_Base::SkColorSpace_Base(sk_sp<SkColorLookUpTable> colorLUT, sk_sp<SkGammas> gammas,
- const SkMatrix44& toXYZD50, sk_sp<SkData> profileData)
- : INHERITED(kNonStandard_GammaNamed, toXYZD50, kUnknown_Named)
+SkColorSpace_Base::SkColorSpace_Base(sk_sp<SkColorLookUpTable> colorLUT, GammaNamed gammaNamed,
+ sk_sp<SkGammas> gammas, const SkMatrix44& toXYZD50,
+ sk_sp<SkData> profileData)
+ : INHERITED(gammaNamed, toXYZD50, kUnknown_Named)
, fColorLUT(std::move(colorLUT))
, fGammas(std::move(gammas))
, fProfileData(std::move(profileData))
@@ -68,16 +69,31 @@ static bool xyz_almost_equal(const SkMatrix44& toXYZD50, const float* standard)
}
sk_sp<SkColorSpace> SkColorSpace_Base::NewRGB(float values[3], const SkMatrix44& toXYZD50) {
- SkGammaCurve curves[3];
- set_gamma_value(&curves[0], values[0]);
- set_gamma_value(&curves[1], values[1]);
- set_gamma_value(&curves[2], values[2]);
+ if (0.0f > values[0] || 0.0f > values[1] || 0.0f > values[2]) {
+ return nullptr;
+ }
+
+ GammaNamed gammaNamed = kNonStandard_GammaNamed;
+ if (color_space_almost_equal(2.2f, values[0]) &&
+ color_space_almost_equal(2.2f, values[1]) &&
+ color_space_almost_equal(2.2f, values[2])) {
+ gammaNamed = k2Dot2Curve_GammaNamed;
+ } else if (color_space_almost_equal(1.0f, values[0]) &&
+ color_space_almost_equal(1.0f, values[1]) &&
+ color_space_almost_equal(1.0f, values[2])) {
+ gammaNamed = kLinear_GammaNamed;
+ }
- GammaNamed gammaNamed = SkGammas::Named(curves);
if (kNonStandard_GammaNamed == gammaNamed) {
- sk_sp<SkGammas> gammas(new SkGammas(std::move(curves[0]), std::move(curves[1]),
- std::move(curves[2])));
- return sk_sp<SkColorSpace>(new SkColorSpace_Base(nullptr, gammas, toXYZD50, nullptr));
+ sk_sp<SkGammas> gammas = sk_sp<SkGammas>(new SkGammas());
+ gammas->fRedType = SkGammas::Type::kValue_Type;
+ gammas->fGreenType = SkGammas::Type::kValue_Type;
+ gammas->fBlueType = SkGammas::Type::kValue_Type;
+ gammas->fRedData.fValue = values[0];
+ gammas->fGreenData.fValue = values[1];
+ gammas->fBlueData.fValue = values[2];
+ return sk_sp<SkColorSpace>(new SkColorSpace_Base(nullptr, kNonStandard_GammaNamed, gammas,
+ toXYZD50, nullptr));
}
return SkColorSpace_Base::NewRGB(gammaNamed, toXYZD50);
« no previous file with comments | « no previous file | src/core/SkColorSpacePriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698