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

Side by Side Diff: gm/gradientDirtyLaundry.cpp

Issue 1790353002: Revert of more shader-->sp conversions (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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 | « no previous file | 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, nullptr }, 33 { 40, gColors, nullptr },
34 // { 2, gColors, gPos }, 34 // { 2, gColors, gPos },
35 // { 2, gCol2, nullptr }, 35 // { 2, gCol2, nullptr },
36 }; 36 };
37 37
38 static sk_sp<SkShader> MakeLinear(const SkPoint pts[2], const GradData& data, Sk Shader::TileMode tm) { 38 static SkShader* MakeLinear(const SkPoint pts[2], const GradData& data, SkShader ::TileMode tm) {
39 return SkGradientShader::MakeLinear(pts, data.fColors, data.fPos, data.fCoun t, tm); 39 return SkGradientShader::CreateLinear(pts, data.fColors, data.fPos, data.fCo unt, tm);
40 } 40 }
41 41
42 static sk_sp<SkShader> MakeRadial(const SkPoint pts[2], const GradData& data, Sk Shader::TileMode tm) { 42 static SkShader* MakeRadial(const SkPoint pts[2], const GradData& data, SkShader ::TileMode tm) {
43 const SkPoint pt{ SkScalarAve(pts[0].fX, pts[1].fX), SkScalarAve(pts[0].fY, pts[1].fY) }; 43 SkPoint center;
44 return SkGradientShader::MakeRadial(pt, pt.fX, data.fColors, data.fPos, data .fCount, tm); 44 center.set(SkScalarAve(pts[0].fX, pts[1].fX),
45 SkScalarAve(pts[0].fY, pts[1].fY));
46 return SkGradientShader::CreateRadial(center, center.fX, data.fColors,
47 data.fPos, data.fCount, tm);
45 } 48 }
46 49
47 static sk_sp<SkShader> MakeSweep(const SkPoint pts[2], const GradData& data, SkS hader::TileMode) { 50 static SkShader* MakeSweep(const SkPoint pts[2], const GradData& data, SkShader: :TileMode) {
48 const SkPoint pt{ SkScalarAve(pts[0].fX, pts[1].fX), SkScalarAve(pts[0].fY, pts[1].fY) }; 51 SkPoint center;
49 return SkGradientShader::MakeSweep(pt.fX, pt.fY, data.fColors, data.fPos, da ta.fCount); 52 center.set(SkScalarAve(pts[0].fX, pts[1].fX),
53 SkScalarAve(pts[0].fY, pts[1].fY));
54 return SkGradientShader::CreateSweep(center.fX, center.fY, data.fColors, dat a.fPos, data.fCount);
50 } 55 }
51 56
52 57
53 typedef sk_sp<SkShader> (*GradMaker)(const SkPoint pts[2], const GradData&, SkSh ader::TileMode); 58 typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data, SkSha der::TileMode tm);
54 59
55 static const GradMaker gGradMakers[] = { 60 static const GradMaker gGradMakers[] = {
56 MakeLinear, MakeRadial, MakeSweep, 61 MakeLinear, MakeRadial, MakeSweep,
57 }; 62 };
58 63
59 /////////////////////////////////////////////////////////////////////////////// 64 ///////////////////////////////////////////////////////////////////////////////
60 65
61 class GradientsGM : public GM { 66 class GradientsGM : public GM {
62 public: 67 public:
63 GradientsGM() { 68 GradientsGM() {
(...skipping 10 matching lines...) Expand all
74 }; 79 };
75 SkShader::TileMode tm = SkShader::kClamp_TileMode; 80 SkShader::TileMode tm = SkShader::kClamp_TileMode;
76 SkRect r = { 0, 0, SkIntToScalar(100), SkIntToScalar(100) }; 81 SkRect r = { 0, 0, SkIntToScalar(100), SkIntToScalar(100) };
77 SkPaint paint; 82 SkPaint paint;
78 paint.setAntiAlias(true); 83 paint.setAntiAlias(true);
79 84
80 canvas->translate(SkIntToScalar(20), SkIntToScalar(20)); 85 canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
81 for (size_t i = 0; i < SK_ARRAY_COUNT(gGradData); i++) { 86 for (size_t i = 0; i < SK_ARRAY_COUNT(gGradData); i++) {
82 canvas->save(); 87 canvas->save();
83 for (size_t j = 0; j < SK_ARRAY_COUNT(gGradMakers); j++) { 88 for (size_t j = 0; j < SK_ARRAY_COUNT(gGradMakers); j++) {
84 paint.setShader(gGradMakers[j](pts, gGradData[i], tm)); 89 SkShader* shader = gGradMakers[j](pts, gGradData[i], tm);
90 paint.setShader(shader)->unref();
85 canvas->drawRect(r, paint); 91 canvas->drawRect(r, paint);
86 canvas->translate(0, SkIntToScalar(120)); 92 canvas->translate(0, SkIntToScalar(120));
87 } 93 }
88 canvas->restore(); 94 canvas->restore();
89 canvas->translate(SkIntToScalar(120), 0); 95 canvas->translate(SkIntToScalar(120), 0);
90 } 96 }
91 } 97 }
92 98
93 private: 99 private:
94 typedef GM INHERITED; 100 typedef GM INHERITED;
95 }; 101 };
96 102
97 /////////////////////////////////////////////////////////////////////////////// 103 ///////////////////////////////////////////////////////////////////////////////
98 104
99 static GM* MyFactory(void*) { return new GradientsGM; } 105 static GM* MyFactory(void*) { return new GradientsGM; }
100 static GMRegistry reg(MyFactory); 106 static GMRegistry reg(MyFactory);
OLDNEW
« no previous file with comments | « no previous file | gm/gradient_matrix.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698