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

Side by Side Diff: gm/gradientDirtyLaundry.cpp

Issue 283273002: remove unused (by clients) SkUnitMapper (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: fix legacy call Created 6 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 | Annotate | Revision Log
« no previous file with comments | « gm/drawbitmaprect.cpp ('k') | gm/gradient_matrix.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 /* 2 /*
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 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 "gm.h" 8 #include "gm.h"
9 #include "SkGradientShader.h" 9 #include "SkGradientShader.h"
10 10
(...skipping 17 matching lines...) Expand all
28 }; 28 };
29 29
30 //static const SkScalar gPos[] = { SK_Scalar1*999/2000, SK_Scalar1*1001/2000 }; 30 //static const SkScalar gPos[] = { SK_Scalar1*999/2000, SK_Scalar1*1001/2000 };
31 31
32 static const GradData gGradData[] = { 32 static const GradData gGradData[] = {
33 { 40, gColors, NULL }, 33 { 40, gColors, NULL },
34 // { 2, gColors, gPos }, 34 // { 2, gColors, gPos },
35 // { 2, gCol2, NULL }, 35 // { 2, gCol2, NULL },
36 }; 36 };
37 37
38 static SkShader* MakeLinear(const SkPoint pts[2], const GradData& data, 38 static SkShader* MakeLinear(const SkPoint pts[2], const GradData& data, SkShader ::TileMode tm) {
39 SkShader::TileMode tm, SkUnitMapper* mapper) { 39 return SkGradientShader::CreateLinear(pts, data.fColors, data.fPos, data.fCo unt, tm);
40 return SkGradientShader::CreateLinear(pts, data.fColors, data.fPos,
41 data.fCount, tm, mapper);
42 } 40 }
43 41
44 static SkShader* MakeRadial(const SkPoint pts[2], const GradData& data, 42 static SkShader* MakeRadial(const SkPoint pts[2], const GradData& data, SkShader ::TileMode tm) {
45 SkShader::TileMode tm, SkUnitMapper* mapper) {
46 SkPoint center; 43 SkPoint center;
47 center.set(SkScalarAve(pts[0].fX, pts[1].fX), 44 center.set(SkScalarAve(pts[0].fX, pts[1].fX),
48 SkScalarAve(pts[0].fY, pts[1].fY)); 45 SkScalarAve(pts[0].fY, pts[1].fY));
49 return SkGradientShader::CreateRadial(center, center.fX, data.fColors, 46 return SkGradientShader::CreateRadial(center, center.fX, data.fColors,
50 data.fPos, data.fCount, tm, mapper); 47 data.fPos, data.fCount, tm);
51 } 48 }
52 49
53 static SkShader* MakeSweep(const SkPoint pts[2], const GradData& data, 50 static SkShader* MakeSweep(const SkPoint pts[2], const GradData& data, SkShader: :TileMode) {
54 SkShader::TileMode, SkUnitMapper* mapper) {
55 SkPoint center; 51 SkPoint center;
56 center.set(SkScalarAve(pts[0].fX, pts[1].fX), 52 center.set(SkScalarAve(pts[0].fX, pts[1].fX),
57 SkScalarAve(pts[0].fY, pts[1].fY)); 53 SkScalarAve(pts[0].fY, pts[1].fY));
58 return SkGradientShader::CreateSweep(center.fX, center.fY, data.fColors, 54 return SkGradientShader::CreateSweep(center.fX, center.fY, data.fColors, dat a.fPos, data.fCount);
59 data.fPos, data.fCount, mapper);
60 } 55 }
61 56
62 57
63 typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data, 58 typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data, SkSha der::TileMode tm);
64 SkShader::TileMode tm, SkUnitMapper* mapper); 59
65 static const GradMaker gGradMakers[] = { 60 static const GradMaker gGradMakers[] = {
66 MakeLinear, MakeRadial, MakeSweep, 61 MakeLinear, MakeRadial, MakeSweep,
67 }; 62 };
68 63
69 /////////////////////////////////////////////////////////////////////////////// 64 ///////////////////////////////////////////////////////////////////////////////
70 65
71 class GradientsGM : public GM { 66 class GradientsGM : public GM {
72 public: 67 public:
73 GradientsGM() { 68 GradientsGM() {
74 this->setBGColor(0xFFDDDDDD); 69 this->setBGColor(0xFFDDDDDD);
(...skipping 13 matching lines...) Expand all
88 }; 83 };
89 SkShader::TileMode tm = SkShader::kClamp_TileMode; 84 SkShader::TileMode tm = SkShader::kClamp_TileMode;
90 SkRect r = { 0, 0, SkIntToScalar(100), SkIntToScalar(100) }; 85 SkRect r = { 0, 0, SkIntToScalar(100), SkIntToScalar(100) };
91 SkPaint paint; 86 SkPaint paint;
92 paint.setAntiAlias(true); 87 paint.setAntiAlias(true);
93 88
94 canvas->translate(SkIntToScalar(20), SkIntToScalar(20)); 89 canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
95 for (size_t i = 0; i < SK_ARRAY_COUNT(gGradData); i++) { 90 for (size_t i = 0; i < SK_ARRAY_COUNT(gGradData); i++) {
96 canvas->save(); 91 canvas->save();
97 for (size_t j = 0; j < SK_ARRAY_COUNT(gGradMakers); j++) { 92 for (size_t j = 0; j < SK_ARRAY_COUNT(gGradMakers); j++) {
98 SkShader* shader = gGradMakers[j](pts, gGradData[i], tm, NULL); 93 SkShader* shader = gGradMakers[j](pts, gGradData[i], tm);
99 paint.setShader(shader)->unref(); 94 paint.setShader(shader)->unref();
100 canvas->drawRect(r, paint); 95 canvas->drawRect(r, paint);
101 canvas->translate(0, SkIntToScalar(120)); 96 canvas->translate(0, SkIntToScalar(120));
102 } 97 }
103 canvas->restore(); 98 canvas->restore();
104 canvas->translate(SkIntToScalar(120), 0); 99 canvas->translate(SkIntToScalar(120), 0);
105 } 100 }
106 } 101 }
107 102
108 private: 103 private:
109 typedef GM INHERITED; 104 typedef GM INHERITED;
110 }; 105 };
111 106
112 /////////////////////////////////////////////////////////////////////////////// 107 ///////////////////////////////////////////////////////////////////////////////
113 108
114 static GM* MyFactory(void*) { return new GradientsGM; } 109 static GM* MyFactory(void*) { return new GradientsGM; }
115 static GMRegistry reg(MyFactory); 110 static GMRegistry reg(MyFactory);
OLDNEW
« no previous file with comments | « gm/drawbitmaprect.cpp ('k') | gm/gradient_matrix.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698