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

Side by Side Diff: src/effects/gradients/SkSweepGradient.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 /* 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
11 static SkMatrix translate(SkScalar dx, SkScalar dy) {
12 SkMatrix matrix;
13 matrix.setTranslate(dx, dy);
14 return matrix;
15 }
16
11 SkSweepGradient::SkSweepGradient(SkScalar cx, SkScalar cy, const Descriptor& des c) 17 SkSweepGradient::SkSweepGradient(SkScalar cx, SkScalar cy, const Descriptor& des c)
12 : SkGradientShaderBase(desc) 18 : SkGradientShaderBase(desc, translate(-cx, -cy))
13 , fCenter(SkPoint::Make(cx, cy)) 19 , fCenter(SkPoint::Make(cx, cy))
14 { 20 {
15 fPtsToUnit.setTranslate(-cx, -cy);
16
17 // overwrite the tilemode to a canonical value (since sweep ignores it) 21 // overwrite the tilemode to a canonical value (since sweep ignores it)
18 fTileMode = SkShader::kClamp_TileMode; 22 fTileMode = SkShader::kClamp_TileMode;
19 } 23 }
20 24
21 SkShader::BitmapType SkSweepGradient::asABitmap(SkBitmap* bitmap, 25 SkShader::BitmapType SkSweepGradient::asABitmap(SkBitmap* bitmap,
22 SkMatrix* matrix, SkShader::TileMode* xy) const { 26 SkMatrix* matrix, SkShader::TileMode* xy) const {
23 if (bitmap) { 27 if (bitmap) {
24 this->getGradientTableBitmap(bitmap); 28 this->getGradientTableBitmap(bitmap);
25 } 29 }
26 if (matrix) { 30 if (matrix) {
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 str->appendScalar(fCenter.fX); 333 str->appendScalar(fCenter.fX);
330 str->append(", "); 334 str->append(", ");
331 str->appendScalar(fCenter.fY); 335 str->appendScalar(fCenter.fY);
332 str->append(") "); 336 str->append(") ");
333 337
334 this->INHERITED::toString(str); 338 this->INHERITED::toString(str);
335 339
336 str->append(")"); 340 str->append(")");
337 } 341 }
338 #endif 342 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/SkRadialGradient.cpp ('k') | src/effects/gradients/SkTwoPointConicalGradient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698