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

Unified Diff: ui/gfx/skia_color_space_util.cc

Issue 2697413002: color: Add analytic transfer functions in shaders (Closed)
Patch Set: Disable on android Created 3 years, 10 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 | « ui/gfx/skia_color_space_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/skia_color_space_util.cc
diff --git a/ui/gfx/skia_color_space_util.cc b/ui/gfx/skia_color_space_util.cc
index 60617e764b96ae9d2b58a41780f77aa232add497..2dda075fe65c1b129c6488b6019aea778c29132d 100644
--- a/ui/gfx/skia_color_space_util.cc
+++ b/ui/gfx/skia_color_space_util.cc
@@ -10,11 +10,9 @@
namespace gfx {
namespace {
-
-const float kEpsilon = 1.f / 256.f;
}
-float EvalSkTransferFn(const SkColorSpaceTransferFn& fn, float x) {
+float SkTransferFnEval(const SkColorSpaceTransferFn& fn, float x) {
if (x < 0.f)
return 0.f;
if (x < fn.fD)
@@ -39,7 +37,32 @@ SkColorSpaceTransferFn SkTransferFnInverse(const SkColorSpaceTransferFn& fn) {
return fn_inv;
}
+bool SkTransferFnsApproximatelyCancel(const SkColorSpaceTransferFn& a,
+ const SkColorSpaceTransferFn& b) {
+ const float kStep = 1.f / 8.f;
+ const float kEpsilon = 2.5f / 256.f;
+ for (float x = 0; x <= 1.f; x += kStep) {
+ float a_of_x = SkTransferFnEval(a, x);
+ float b_of_a_of_x = SkTransferFnEval(b, a_of_x);
+ if (std::abs(b_of_a_of_x - x) > kEpsilon)
+ return false;
+ }
+ return true;
+}
+
+bool SkTransferFnIsApproximatelyIdentity(const SkColorSpaceTransferFn& a) {
+ const float kStep = 1.f / 8.f;
+ const float kEpsilon = 2.5f / 256.f;
+ for (float x = 0; x <= 1.f; x += kStep) {
+ float a_of_x = SkTransferFnEval(a, x);
+ if (std::abs(a_of_x - x) > kEpsilon)
+ return false;
+ }
+ return true;
+}
+
bool SkMatrixIsApproximatelyIdentity(const SkMatrix44& m) {
+ const float kEpsilon = 1.f / 256.f;
for (int i = 0; i < 4; ++i) {
for (int j = 0; j < 4; ++j) {
float identity_value = i == j ? 1 : 0;
« no previous file with comments | « ui/gfx/skia_color_space_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698