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

Unified Diff: src/effects/gradients/SkClampRange.h

Issue 815623004: improve precision of gradients (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years 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 | « gyp/skia_for_chromium_defines.gypi ('k') | src/effects/gradients/SkClampRange.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/gradients/SkClampRange.h
diff --git a/src/effects/gradients/SkClampRange.h b/src/effects/gradients/SkClampRange.h
index 09386d7e71bb7e9bf37c2eaede1f83885e35463f..a71009d65436aa72d82a3c2f3a88ea5faf29da00 100644
--- a/src/effects/gradients/SkClampRange.h
+++ b/src/effects/gradients/SkClampRange.h
@@ -1,4 +1,3 @@
-
/*
* Copyright 2011 Google Inc.
*
@@ -6,14 +5,30 @@
* found in the LICENSE file.
*/
-
#ifndef SkClampRange_DEFINED
#define SkClampRange_DEFINED
#include "SkFixed.h"
+#include "SkScalar.h"
+
+#define SK_SUPPORT_LEGACY_GRADIENT_PRECISION
+
+#ifdef SK_SUPPORT_LEGACY_GRADIENT_PRECISION
+ #define SkGradFixed SkFixed
+ #define SkScalarToGradFixed SkScalarToFixed
+ #define SkFixedToGradFixed(x) (x)
+ #define SkGradFixedToFixed(x) (x)
+ #define kFracMax_SkGradFixed 0xFFFF
+#else
+ #define SkGradFixed SkFixed3232
+ #define SkScalarToGradFixed SkScalarToFixed3232
+ #define SkFixedToGradFixed SkFixedToFixed3232
+ #define SkGradFixedToFixed(x) (SkFixed)((x) >> 16)
+ #define kFracMax_SkGradFixed 0xFFFFFFFFLL
+#endif
/**
- * Iteration fixed fx by dx, clamping as you go to [0..0xFFFF], this class
+ * Iteration fixed fx by dx, clamping as you go to [0..kFracMax_SkGradFixed], this class
* computes the (up to) 3 spans there are:
*
* range0: use constant value V0
@@ -24,14 +39,14 @@ struct SkClampRange {
int fCount0; // count for fV0
int fCount1; // count for interpolating (fV0...fV1)
int fCount2; // count for fV1
- SkFixed fFx1; // initial fx value for the fCount1 range.
+ SkGradFixed fFx1; // initial fx value for the fCount1 range.
// only valid if fCount1 > 0
int fV0, fV1;
- void init(SkFixed fx, SkFixed dx, int count, int v0, int v1);
+ void init(SkGradFixed fx, SkGradFixed dx, int count, int v0, int v1);
private:
- void initFor1(SkFixed fx);
+ void initFor1(SkGradFixed fx);
};
#endif
« no previous file with comments | « gyp/skia_for_chromium_defines.gypi ('k') | src/effects/gradients/SkClampRange.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698