OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 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 #include "SampleCode.h" | 8 #include "SampleCode.h" |
9 #include "SkBlurMask.h" | 9 #include "SkBlurMask.h" |
10 #include "SkBlurMaskFilter.h" | 10 #include "SkBlurMaskFilter.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 data.fPos, data.fCount, tm); | 190 data.fPos, data.fCount, tm); |
191 } | 191 } |
192 | 192 |
193 static SkShader* MakeSweep(const SkPoint pts[2], const GradData& data, SkShader:
:TileMode tm) { | 193 static SkShader* MakeSweep(const SkPoint pts[2], const GradData& data, SkShader:
:TileMode tm) { |
194 SkPoint center; | 194 SkPoint center; |
195 center.set(SkScalarAve(pts[0].fX, pts[1].fX), | 195 center.set(SkScalarAve(pts[0].fX, pts[1].fX), |
196 SkScalarAve(pts[0].fY, pts[1].fY)); | 196 SkScalarAve(pts[0].fY, pts[1].fY)); |
197 return SkGradientShader::CreateSweep(center.fX, center.fY, data.fColors, dat
a.fPos, data.fCount); | 197 return SkGradientShader::CreateSweep(center.fX, center.fY, data.fColors, dat
a.fPos, data.fCount); |
198 } | 198 } |
199 | 199 |
200 static SkShader* Make2Radial(const SkPoint pts[2], const GradData& data, SkShade
r::TileMode tm) { | 200 static SkShader* Make2Conical(const SkPoint pts[2], const GradData& data, SkShad
er::TileMode tm) { |
201 SkPoint center0, center1; | 201 SkPoint center0, center1; |
202 center0.set(SkScalarAve(pts[0].fX, pts[1].fX), | 202 center0.set(SkScalarAve(pts[0].fX, pts[1].fX), |
203 SkScalarAve(pts[0].fY, pts[1].fY)); | 203 SkScalarAve(pts[0].fY, pts[1].fY)); |
204 center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5), | 204 center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5), |
205 SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4)); | 205 SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4)); |
206 return SkGradientShader::CreateTwoPointRadial( | 206 return SkGradientShader::CreateTwoPointConical( |
207 center1, (pts[1].fX - pts[0].f
X) / 7, | 207 center1, (pts[1].fX - pts[0].f
X) / 7, |
208 center0, (pts[1].fX - pts[0].f
X) / 2, | 208 center0, (pts[1].fX - pts[0].f
X) / 2, |
209 data.fColors, data.fPos, data.
fCount, tm); | 209 data.fColors, data.fPos, data.
fCount, tm); |
210 } | 210 } |
211 | 211 |
212 typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data, SkSha
der::TileMode tm); | 212 typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data, SkSha
der::TileMode tm); |
213 static const GradMaker gGradMakers[] = { | 213 static const GradMaker gGradMakers[] = { |
214 MakeLinear, MakeRadial, MakeSweep, Make2Radial | 214 MakeLinear, MakeRadial, MakeSweep, Make2Conical |
215 }; | 215 }; |
216 | 216 |
217 static void gradient_slide(SkCanvas* canvas) { | 217 static void gradient_slide(SkCanvas* canvas) { |
218 SkPoint pts[2] = { | 218 SkPoint pts[2] = { |
219 { 0, 0 }, | 219 { 0, 0 }, |
220 { SkIntToScalar(100), SkIntToScalar(100) } | 220 { SkIntToScalar(100), SkIntToScalar(100) } |
221 }; | 221 }; |
222 SkShader::TileMode tm = SkShader::kClamp_TileMode; | 222 SkShader::TileMode tm = SkShader::kClamp_TileMode; |
223 SkRect r = { 0, 0, SkIntToScalar(100), SkIntToScalar(100) }; | 223 SkRect r = { 0, 0, SkIntToScalar(100), SkIntToScalar(100) }; |
224 SkPaint paint; | 224 SkPaint paint; |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 } | 718 } |
719 | 719 |
720 private: | 720 private: |
721 typedef SampleView INHERITED; | 721 typedef SampleView INHERITED; |
722 }; | 722 }; |
723 | 723 |
724 ////////////////////////////////////////////////////////////////////////////// | 724 ////////////////////////////////////////////////////////////////////////////// |
725 | 725 |
726 static SkView* MyFactory() { return new SlideView; } | 726 static SkView* MyFactory() { return new SlideView; } |
727 static SkViewRegister reg(MyFactory); | 727 static SkViewRegister reg(MyFactory); |
OLD | NEW |