Index: src/core/SkColorSpacePriv.h |
diff --git a/src/core/SkColorSpacePriv.h b/src/core/SkColorSpacePriv.h |
index e7c8aaa10382345f44a30449f43fe1b55844952e..7c7b9d0c2146978f66ca385fa79276898e7bb486 100644 |
--- a/src/core/SkColorSpacePriv.h |
+++ b/src/core/SkColorSpacePriv.h |
@@ -10,3 +10,16 @@ |
inline bool color_space_almost_equal(float a, float b) { |
return SkTAbs(a - b) < 0.01f; |
} |
+ |
+inline void set_gamma_value(SkGammaCurve* gamma, float value) { |
+ if (color_space_almost_equal(2.2f, value)) { |
+ gamma->fNamed = SkColorSpace::k2Dot2Curve_GammaNamed; |
+ } else if (color_space_almost_equal(1.0f, value)) { |
+ gamma->fNamed = SkColorSpace::kLinear_GammaNamed; |
+ } else if (color_space_almost_equal(0.0f, value)) { |
+ SkColorSpacePrintf("Treating invalid zero gamma as linear."); |
+ gamma->fNamed = SkColorSpace::kLinear_GammaNamed; |
+ } else { |
+ gamma->fValue = value; |
+ } |
+} |