OLD | NEW |
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 Loading... |
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 |
OLD | NEW |