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

Side by Side Diff: gm/gradients.cpp

Issue 1117423003: remove redundant/deprecated TwoPointRadial gradiet -- use TwoPointConical (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 months 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
« no previous file with comments | « gm/blurroundrect.cpp ('k') | gm/gradients_no_texture.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 "gm.h" 8 #include "gm.h"
9 #include "SkGradientShader.h" 9 #include "SkGradientShader.h"
10 10
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 data.fPos, data.fCount, 0, &localMatrix ); 63 data.fPos, data.fCount, 0, &localMatrix );
64 } 64 }
65 65
66 static SkShader* Make2Radial(const SkPoint pts[2], const GradData& data, 66 static SkShader* Make2Radial(const SkPoint pts[2], const GradData& data,
67 SkShader::TileMode tm, const SkMatrix& localMatrix) { 67 SkShader::TileMode tm, const SkMatrix& localMatrix) {
68 SkPoint center0, center1; 68 SkPoint center0, center1;
69 center0.set(SkScalarAve(pts[0].fX, pts[1].fX), 69 center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
70 SkScalarAve(pts[0].fY, pts[1].fY)); 70 SkScalarAve(pts[0].fY, pts[1].fY));
71 center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5), 71 center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
72 SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4)); 72 SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
73 return SkGradientShader::CreateTwoPointRadial( 73 return SkGradientShader::CreateTwoPointConical(
74 center1, (pts[1].fX - pts[0].f X) / 7, 74 center1, (pts[1].fX - pts[0]. fX) / 7,
75 center0, (pts[1].fX - pts[0].f X) / 2, 75 center0, (pts[1].fX - pts[0]. fX) / 2,
76 data.fColors, data.fPos, data. fCount, tm, 76 data.fColors, data.fPos, data .fCount, tm,
77 0, &localMatrix); 77 0, &localMatrix);
78 } 78 }
79 79
80 static SkShader* Make2Conical(const SkPoint pts[2], const GradData& data, 80 static SkShader* Make2Conical(const SkPoint pts[2], const GradData& data,
81 SkShader::TileMode tm, const SkMatrix& localMatrix) { 81 SkShader::TileMode tm, const SkMatrix& localMatrix) {
82 SkPoint center0, center1; 82 SkPoint center0, center1;
83 SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 10); 83 SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 10);
84 SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3); 84 SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3);
85 center0.set(pts[0].fX + radius0, pts[0].fY + radius0); 85 center0.set(pts[0].fX + radius0, pts[0].fY + radius0);
86 center1.set(pts[1].fX - radius1, pts[1].fY - radius1); 86 center1.set(pts[1].fX - radius1, pts[1].fY - radius1);
87 return SkGradientShader::CreateTwoPointConical(center1, radius1, 87 return SkGradientShader::CreateTwoPointConical(center1, radius1,
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 this->drawBG(canvas); 266 this->drawBG(canvas);
267 267
268 SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorGREEN, SK_Color RED }; 268 SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorGREEN, SK_Color RED };
269 SkScalar pos[] = { 0, 0.01f, 0.99f, SK_Scalar1 }; 269 SkScalar pos[] = { 0, 0.01f, 0.99f, SK_Scalar1 };
270 SkPoint c0; 270 SkPoint c0;
271 c0.iset(-80, 25); 271 c0.iset(-80, 25);
272 SkScalar r0 = SkIntToScalar(70); 272 SkScalar r0 = SkIntToScalar(70);
273 SkPoint c1; 273 SkPoint c1;
274 c1.iset(0, 25); 274 c1.iset(0, 25);
275 SkScalar r1 = SkIntToScalar(150); 275 SkScalar r1 = SkIntToScalar(150);
276 SkShader* s = SkGradientShader::CreateTwoPointRadial(c0, r0, c1, r1, col ors, 276 SkShader* s = SkGradientShader::CreateTwoPointConical(c0, r0, c1, r1, co lors,
277 pos, SK_ARRAY_COUNT (pos), 277 pos, SK_ARRAY_COUN T(pos),
278 SkShader::kClamp_Ti leMode); 278 SkShader::kClamp_T ileMode);
279 SkPaint paint; 279 SkPaint paint;
280 paint.setShader(s)->unref(); 280 paint.setShader(s)->unref();
281 canvas->drawPaint(paint); 281 canvas->drawPaint(paint);
282 } 282 }
283 283
284 private: 284 private:
285 typedef GM INHERITED; 285 typedef GM INHERITED;
286 }; 286 };
287 DEF_GM( return new GradientsDegenrate2PointGM; ) 287 DEF_GM( return new GradientsDegenrate2PointGM; )
288 288
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 paint.setShader(fShader); 456 paint.setShader(fShader);
457 canvas->drawRect(SkRect::MakeWH(500, 500), paint); 457 canvas->drawRect(SkRect::MakeWH(500, 500), paint);
458 } 458 }
459 459
460 private: 460 private:
461 typedef GM INHERITED; 461 typedef GM INHERITED;
462 }; 462 };
463 DEF_GM( return new RadialGradient3GM; ) 463 DEF_GM( return new RadialGradient3GM; )
464 464
465 } 465 }
OLDNEW
« no previous file with comments | « gm/blurroundrect.cpp ('k') | gm/gradients_no_texture.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698