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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1
2 /* 1 /*
3 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
4 * 3 *
5 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 5 * found in the LICENSE file.
7 */ 6 */
8 7
9
10 #ifndef SkClampRange_DEFINED 8 #ifndef SkClampRange_DEFINED
11 #define SkClampRange_DEFINED 9 #define SkClampRange_DEFINED
12 10
13 #include "SkFixed.h" 11 #include "SkFixed.h"
12 #include "SkScalar.h"
13
14 #define SK_SUPPORT_LEGACY_GRADIENT_PRECISION
15
16 #ifdef SK_SUPPORT_LEGACY_GRADIENT_PRECISION
17 #define SkGradFixed SkFixed
18 #define SkScalarToGradFixed SkScalarToFixed
19 #define SkFixedToGradFixed(x) (x)
20 #define SkGradFixedToFixed(x) (x)
21 #define kFracMax_SkGradFixed 0xFFFF
22 #else
23 #define SkGradFixed SkFixed3232
24 #define SkScalarToGradFixed SkScalarToFixed3232
25 #define SkFixedToGradFixed SkFixedToFixed3232
26 #define SkGradFixedToFixed(x) (SkFixed)((x) >> 16)
27 #define kFracMax_SkGradFixed 0xFFFFFFFFLL
28 #endif
14 29
15 /** 30 /**
16 * Iteration fixed fx by dx, clamping as you go to [0..0xFFFF], this class 31 * Iteration fixed fx by dx, clamping as you go to [0..kFracMax_SkGradFixed], t his class
17 * computes the (up to) 3 spans there are: 32 * computes the (up to) 3 spans there are:
18 * 33 *
19 * range0: use constant value V0 34 * range0: use constant value V0
20 * range1: iterate as usual fx += dx 35 * range1: iterate as usual fx += dx
21 * range2: use constant value V1 36 * range2: use constant value V1
22 */ 37 */
23 struct SkClampRange { 38 struct SkClampRange {
24 int fCount0; // count for fV0 39 int fCount0; // count for fV0
25 int fCount1; // count for interpolating (fV0...fV1) 40 int fCount1; // count for interpolating (fV0...fV1)
26 int fCount2; // count for fV1 41 int fCount2; // count for fV1
27 SkFixed fFx1; // initial fx value for the fCount1 range. 42 SkGradFixed fFx1; // initial fx value for the fCount1 range.
28 // only valid if fCount1 > 0 43 // only valid if fCount1 > 0
29 int fV0, fV1; 44 int fV0, fV1;
30 45
31 void init(SkFixed fx, SkFixed dx, int count, int v0, int v1); 46 void init(SkGradFixed fx, SkGradFixed dx, int count, int v0, int v1);
32 47
33 private: 48 private:
34 void initFor1(SkFixed fx); 49 void initFor1(SkGradFixed fx);
35 }; 50 };
36 51
37 #endif 52 #endif
OLDNEW
« 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