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

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 | « no previous file | 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..d0023d394c45cbd35505fd94dbbb609a11c33401 100644
--- a/src/effects/gradients/SkClampRange.h
+++ b/src/effects/gradients/SkClampRange.h
@@ -1,4 +1,3 @@
-
/*
* Copyright 2011 Google Inc.
*
@@ -6,14 +5,41 @@
* found in the LICENSE file.
*/
-
#ifndef SkClampRange_DEFINED
#define SkClampRange_DEFINED
#include "SkFixed.h"
+#include "SkScalar.h"
+
+#define SK_SUPPORT_LEGACY_GRADIENT_PRECISION
+
+typedef int64_t SkF32Dot32;
caryclark 2014/12/18 19:40:56 is this different from SkFixed3232 ?
reed1 2014/12/18 20:17:49 Done.
+
+static inline SkF32Dot32 SkFixedToF32Dot32(SkFixed value) {
caryclark 2014/12/18 19:40:56 looks like SkFixedToFixed3232 ?
reed1 2014/12/18 20:17:49 Done.
+ SkF32Dot32 value32 = value;
+ return value32 << 16;
+}
+
+static inline SkF32Dot32 SkScalarToF32Dot32(SkScalar x) {
caryclark 2014/12/18 19:40:56 looks like SkFloatToFixed3232 ?
reed1 2014/12/18 20:17:49 Done.
+ return (SkF32Dot32)(x * (1LL << 32));
+}
+
+#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 SkF32Dot32
+ #define SkScalarToGradFixed SkScalarToF32Dot32
+ #define SkFixedToGradFixed SkFixedToF32Dot32
+ #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 +50,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 | « no previous file | src/effects/gradients/SkClampRange.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698