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

Side by Side Diff: src/effects/gradients/SkSweepGradient.cpp

Issue 207683004: Extract most of the mutable state of SkShader into a separate Context object. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: scroggo's comments Created 6 years, 9 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 unified diff | Download patch
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
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 #include "SkSweepGradient.h" 9 #include "SkSweepGradient.h"
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 SkSweepGradient::SkSweepGradient(SkReadBuffer& buffer) 45 SkSweepGradient::SkSweepGradient(SkReadBuffer& buffer)
46 : INHERITED(buffer), 46 : INHERITED(buffer),
47 fCenter(buffer.readPoint()) { 47 fCenter(buffer.readPoint()) {
48 } 48 }
49 49
50 void SkSweepGradient::flatten(SkWriteBuffer& buffer) const { 50 void SkSweepGradient::flatten(SkWriteBuffer& buffer) const {
51 this->INHERITED::flatten(buffer); 51 this->INHERITED::flatten(buffer);
52 buffer.writePoint(fCenter); 52 buffer.writePoint(fCenter);
53 } 53 }
54 54
55 #if 0
55 // returns angle in a circle [0..2PI) -> [0..255] 56 // returns angle in a circle [0..2PI) -> [0..255]
56 static unsigned SkATan2_255(float y, float x) { 57 static unsigned SkATan2_255(float y, float x) {
57 // static const float g255Over2PI = 255 / (2 * SK_ScalarPI); 58 // static const float g255Over2PI = 255 / (2 * SK_ScalarPI);
58 static const float g255Over2PI = 40.584510488433314f; 59 static const float g255Over2PI = 40.584510488433314f;
59 60
60 float result = sk_float_atan2(y, x); 61 float result = sk_float_atan2(y, x);
61 if (result < 0) { 62 if (result < 0) {
62 result += 2 * SK_ScalarPI; 63 result += 2 * SK_ScalarPI;
63 } 64 }
64 SkASSERT(result >= 0); 65 SkASSERT(result >= 0);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 proc(matrix, SkIntToScalar(x) + SK_ScalarHalf, 150 proc(matrix, SkIntToScalar(x) + SK_ScalarHalf,
150 SkIntToScalar(y) + SK_ScalarHalf, &srcPt); 151 SkIntToScalar(y) + SK_ScalarHalf, &srcPt);
151 152
152 int index = SkATan2_255(srcPt.fY, srcPt.fX); 153 int index = SkATan2_255(srcPt.fY, srcPt.fX);
153 index >>= (8 - kCache16Bits); 154 index >>= (8 - kCache16Bits);
154 *dstC++ = cache[toggle + index]; 155 *dstC++ = cache[toggle + index];
155 toggle = next_dither_toggle16(toggle); 156 toggle = next_dither_toggle16(toggle);
156 } 157 }
157 } 158 }
158 } 159 }
160 #endif
159 161
160 ///////////////////////////////////////////////////////////////////// 162 /////////////////////////////////////////////////////////////////////
161 163
162 #if SK_SUPPORT_GPU 164 #if SK_SUPPORT_GPU
163 165
164 #include "GrTBackendEffectFactory.h" 166 #include "GrTBackendEffectFactory.h"
165 167
166 class GrGLSweepGradient : public GrGLGradientEffect { 168 class GrGLSweepGradient : public GrGLGradientEffect {
167 public: 169 public:
168 170
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 str->appendScalar(fCenter.fX); 295 str->appendScalar(fCenter.fX);
294 str->append(", "); 296 str->append(", ");
295 str->appendScalar(fCenter.fY); 297 str->appendScalar(fCenter.fY);
296 str->append(") "); 298 str->append(") ");
297 299
298 this->INHERITED::toString(str); 300 this->INHERITED::toString(str);
299 301
300 str->append(")"); 302 str->append(")");
301 } 303 }
302 #endif 304 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698