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) { | 11 static SkMatrix translate(SkScalar dx, SkScalar dy) { |
12 SkMatrix matrix; | 12 SkMatrix matrix; |
13 matrix.setTranslate(dx, dy); | 13 matrix.setTranslate(dx, dy); |
14 return matrix; | 14 return matrix; |
15 } | 15 } |
16 | 16 |
17 SkSweepGradient::SkSweepGradient(SkScalar cx, SkScalar cy, const Descriptor& des
c) | 17 SkSweepGradient::SkSweepGradient(SkScalar cx, SkScalar cy, const Descriptor& des
c) |
18 : SkGradientShaderBase(desc, translate(-cx, -cy)) | 18 : SkGradientShaderBase(desc, translate(-cx, -cy)) |
19 , fCenter(SkPoint::Make(cx, cy)) | 19 , fCenter(SkPoint::Make(cx, cy)) |
20 { | 20 { |
21 // overwrite the tilemode to a canonical value (since sweep ignores it) | 21 // overwrite the tilemode to a canonical value (since sweep ignores it) |
22 fTileMode = SkShader::kClamp_TileMode; | 22 fTileMode = SkShader::kClamp_TileMode; |
23 } | 23 } |
24 | 24 |
25 SkShader::BitmapType SkSweepGradient::asABitmap(SkBitmap* bitmap, | |
26 SkMatrix* matrix, SkShader::TileMode* xy) const { | |
27 if (bitmap) { | |
28 this->getGradientTableBitmap(bitmap); | |
29 } | |
30 if (matrix) { | |
31 *matrix = fPtsToUnit; | |
32 } | |
33 if (xy) { | |
34 xy[0] = fTileMode; | |
35 xy[1] = kClamp_TileMode; | |
36 } | |
37 return kSweep_BitmapType; | |
38 } | |
39 | |
40 SkShader::GradientType SkSweepGradient::asAGradient(GradientInfo* info) const { | 25 SkShader::GradientType SkSweepGradient::asAGradient(GradientInfo* info) const { |
41 if (info) { | 26 if (info) { |
42 commonAsAGradient(info); | 27 commonAsAGradient(info); |
43 info->fPoint[0] = fCenter; | 28 info->fPoint[0] = fCenter; |
44 } | 29 } |
45 return kSweep_GradientType; | 30 return kSweep_GradientType; |
46 } | 31 } |
47 | 32 |
48 SkFlattenable* SkSweepGradient::CreateProc(SkReadBuffer& buffer) { | 33 SkFlattenable* SkSweepGradient::CreateProc(SkReadBuffer& buffer) { |
49 DescriptorScope desc; | 34 DescriptorScope desc; |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 str->appendScalar(fCenter.fX); | 314 str->appendScalar(fCenter.fX); |
330 str->append(", "); | 315 str->append(", "); |
331 str->appendScalar(fCenter.fY); | 316 str->appendScalar(fCenter.fY); |
332 str->append(") "); | 317 str->append(") "); |
333 | 318 |
334 this->INHERITED::toString(str); | 319 this->INHERITED::toString(str); |
335 | 320 |
336 str->append(")"); | 321 str->append(")"); |
337 } | 322 } |
338 #endif | 323 #endif |
OLD | NEW |