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

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

Issue 793763003: Gradient shaders: make fPtsToUnit const, pre-cache getType(). (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
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * 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
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkTwoPointConicalGradient.h" 8 #include "SkTwoPointConicalGradient.h"
9 #include "SkTwoPointConicalGradient_gpu.h" 9 #include "SkTwoPointConicalGradient_gpu.h"
10 10
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 } else { 179 } else {
180 SkFixed index = mirror_tileproc(t); 180 SkFixed index = mirror_tileproc(t);
181 SkASSERT(index <= 0xFFFF); 181 SkASSERT(index <= 0xFFFF);
182 *dstC++ = cache[toggle + 182 *dstC++ = cache[toggle +
183 (index >> SkGradientShaderBase::kCache32Shift)]; 183 (index >> SkGradientShaderBase::kCache32Shift)];
184 } 184 }
185 toggle = next_dither_toggle(toggle); 185 toggle = next_dither_toggle(toggle);
186 } 186 }
187 } 187 }
188 188
189 void SkTwoPointConicalGradient::init() {
190 fRec.init(fCenter1, fRadius1, fCenter2, fRadius2, fFlippedGrad);
191 fPtsToUnit.reset();
192 }
193
194 ///////////////////////////////////////////////////////////////////// 189 /////////////////////////////////////////////////////////////////////
195 190
196 SkTwoPointConicalGradient::SkTwoPointConicalGradient( 191 SkTwoPointConicalGradient::SkTwoPointConicalGradient(
197 const SkPoint& start, SkScalar startRadius, 192 const SkPoint& start, SkScalar startRadius,
198 const SkPoint& end, SkScalar endRadius, 193 const SkPoint& end, SkScalar endRadius,
199 bool flippedGrad, const Descriptor& desc) 194 bool flippedGrad, const Descriptor& desc)
200 : SkGradientShaderBase(desc) 195 : SkGradientShaderBase(desc, SkMatrix::I())
201 , fCenter1(start) 196 , fCenter1(start)
202 , fCenter2(end) 197 , fCenter2(end)
203 , fRadius1(startRadius) 198 , fRadius1(startRadius)
204 , fRadius2(endRadius) 199 , fRadius2(endRadius)
205 , fFlippedGrad(flippedGrad) 200 , fFlippedGrad(flippedGrad)
206 { 201 {
207 // this is degenerate, and should be caught by our caller 202 // this is degenerate, and should be caught by our caller
208 SkASSERT(fCenter1 != fCenter2 || fRadius1 != fRadius2); 203 SkASSERT(fCenter1 != fCenter2 || fRadius1 != fRadius2);
209 this->init(); 204 fRec.init(fCenter1, fRadius1, fCenter2, fRadius2, fFlippedGrad);
210 } 205 }
211 206
212 bool SkTwoPointConicalGradient::isOpaque() const { 207 bool SkTwoPointConicalGradient::isOpaque() const {
213 // Because areas outside the cone are left untouched, we cannot treat the 208 // Because areas outside the cone are left untouched, we cannot treat the
214 // shader as opaque even if the gradient itself is opaque. 209 // shader as opaque even if the gradient itself is opaque.
215 // TODO(junov): Compute whether the cone fills the plane crbug.com/222380 210 // TODO(junov): Compute whether the cone fills the plane crbug.com/222380
216 return false; 211 return false;
217 } 212 }
218 213
219 size_t SkTwoPointConicalGradient::contextSize() const { 214 size_t SkTwoPointConicalGradient::contextSize() const {
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 str->appendScalar(fCenter2.fY); 430 str->appendScalar(fCenter2.fY);
436 str->append(") radius2: "); 431 str->append(") radius2: ");
437 str->appendScalar(fRadius2); 432 str->appendScalar(fRadius2);
438 str->append(" "); 433 str->append(" ");
439 434
440 this->INHERITED::toString(str); 435 this->INHERITED::toString(str);
441 436
442 str->append(")"); 437 str->append(")");
443 } 438 }
444 #endif 439 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/SkTwoPointConicalGradient.h ('k') | src/effects/gradients/SkTwoPointRadialGradient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698