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

Side by Side Diff: src/animator/SkDrawGradient.cpp

Issue 117053002: remove SK_SCALAR_IS_[FLOAT,FIXED] and assume floats (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkDrawGradient.h" 10 #include "SkDrawGradient.h"
11 #include "SkAnimateMaker.h" 11 #include "SkAnimateMaker.h"
12 #include "SkAnimatorScript.h" 12 #include "SkAnimatorScript.h"
13 #include "SkGradientShader.h" 13 #include "SkGradientShader.h"
14 #include "SkUnitMapper.h" 14 #include "SkUnitMapper.h"
15 15
16 static SkScalar SkUnitToScalar(U16CPU x) { 16 static SkScalar SkUnitToScalar(U16CPU x) {
17 #ifdef SK_SCALAR_IS_FLOAT
18 return x / 65535.0f; 17 return x / 65535.0f;
19 #else
20 return x + (x >> 8);
21 #endif
22 } 18 }
23 19
24 static U16CPU SkScalarToUnit(SkScalar x) { 20 static U16CPU SkScalarToUnit(SkScalar x) {
25 SkScalar pin = SkScalarPin(x, 0, SK_Scalar1); 21 SkScalar pin = SkScalarPin(x, 0, SK_Scalar1);
26 #ifdef SK_SCALAR_IS_FLOAT
27 return (int) (pin * 65535.0f); 22 return (int) (pin * 65535.0f);
28 #else
29 return pin - (pin >= 32768);
30 #endif
31 } 23 }
32 24
33 class SkDrawGradientUnitMapper : public SkUnitMapper { 25 class SkDrawGradientUnitMapper : public SkUnitMapper {
34 public: 26 public:
35 SkDrawGradientUnitMapper(SkAnimateMaker* maker, const char* script) : fMaker (maker), fScript(script) { 27 SkDrawGradientUnitMapper(SkAnimateMaker* maker, const char* script) : fMaker (maker), fScript(script) {
36 } 28 }
37 29
38 SK_DECLARE_UNFLATTENABLE_OBJECT() 30 SK_DECLARE_UNFLATTENABLE_OBJECT()
39 31
40 protected: 32 protected:
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 SkShader* SkDrawRadialGradient::getShader() { 209 SkShader* SkDrawRadialGradient::getShader() {
218 if (addPrelude() == 0) 210 if (addPrelude() == 0)
219 return NULL; 211 return NULL;
220 SkShader* shader = SkGradientShader::CreateRadial(center, 212 SkShader* shader = SkGradientShader::CreateRadial(center,
221 radius, fColors.begin(), offsets.begin(), fColors.count(), (SkShader::Ti leMode) tileMode, fUnitMapper); 213 radius, fColors.begin(), offsets.begin(), fColors.count(), (SkShader::Ti leMode) tileMode, fUnitMapper);
222 SkAutoTDelete<SkShader> autoDel(shader); 214 SkAutoTDelete<SkShader> autoDel(shader);
223 addPostlude(shader); 215 addPostlude(shader);
224 (void)autoDel.detach(); 216 (void)autoDel.detach();
225 return shader; 217 return shader;
226 } 218 }
OLDNEW
« no previous file with comments | « src/animator/SkDrawColor.cpp ('k') | src/animator/SkScript.cpp » ('j') | src/core/SkCanvas.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698