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

Side by Side Diff: gm/blurrect.cpp

Issue 1776973003: partial switch over to sp usage of shaders (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: move into lua container 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 | « gm/bleed.cpp ('k') | gm/blurroundrect.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 2012 Google Inc. 2 * Copyright 2012 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 "SkBlurMask.h" 9 #include "SkBlurMask.h"
10 #include "SkBlurMaskFilter.h" 10 #include "SkBlurMaskFilter.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 path.setFillType(SkPath::kEvenOdd_FillType); 51 path.setFillType(SkPath::kEvenOdd_FillType);
52 52
53 canvas->drawPath(path, p); 53 canvas->drawPath(path, p);
54 } 54 }
55 55
56 #include "SkGradientShader.h" 56 #include "SkGradientShader.h"
57 57
58 /* 58 /*
59 * Spits out a dummy gradient to test blur with shader on paint 59 * Spits out a dummy gradient to test blur with shader on paint
60 */ 60 */
61 static SkShader* MakeRadial() { 61 static sk_sp<SkShader> MakeRadial() {
62 SkPoint pts[2] = { 62 SkPoint pts[2] = {
63 { 0, 0 }, 63 { 0, 0 },
64 { SkIntToScalar(100), SkIntToScalar(100) } 64 { SkIntToScalar(100), SkIntToScalar(100) }
65 }; 65 };
66 SkShader::TileMode tm = SkShader::kClamp_TileMode; 66 SkShader::TileMode tm = SkShader::kClamp_TileMode;
67 const SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, }; 67 const SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, };
68 const SkScalar pos[] = { SK_Scalar1/4, SK_Scalar1*3/4 }; 68 const SkScalar pos[] = { SK_Scalar1/4, SK_Scalar1*3/4 };
69 SkMatrix scale; 69 SkMatrix scale;
70 scale.setScale(0.5f, 0.5f); 70 scale.setScale(0.5f, 0.5f);
71 scale.postTranslate(25.f, 25.f); 71 scale.postTranslate(25.f, 25.f);
72 SkPoint center0, center1; 72 SkPoint center0, center1;
73 center0.set(SkScalarAve(pts[0].fX, pts[1].fX), 73 center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
74 SkScalarAve(pts[0].fY, pts[1].fY)); 74 SkScalarAve(pts[0].fY, pts[1].fY));
75 center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5), 75 center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
76 SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4)); 76 SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
77 return SkGradientShader::CreateTwoPointConical(center1, (pts[1].fX - pts[0]. fX) / 7, 77 return SkGradientShader::MakeTwoPointConical(center1, (pts[1].fX - pts[0].fX ) / 7,
78 center0, (pts[1].fX - pts[0].f X) / 2, 78 center0, (pts[1].fX - pts[0].fX ) / 2,
79 colors, pos, SK_ARRAY_COUNT(co lors), tm, 79 colors, pos, SK_ARRAY_COUNT(col ors), tm,
80 0, &scale); 80 0, &scale);
81 } 81 }
82 82
83 typedef void (*PaintProc)(SkPaint*, SkScalar width); 83 typedef void (*PaintProc)(SkPaint*, SkScalar width);
84 84
85 class BlurRectGM : public skiagm::GM { 85 class BlurRectGM : public skiagm::GM {
86 SkAutoTUnref<SkMaskFilter> fMaskFilters[kLastEnum_SkBlurStyle + 1]; 86 SkAutoTUnref<SkMaskFilter> fMaskFilters[kLastEnum_SkBlurStyle + 1];
87 SkString fName; 87 SkString fName;
88 SkAlpha fAlpha; 88 SkAlpha fAlpha;
89 public: 89 public:
90 BlurRectGM(const char name[], U8CPU alpha) 90 BlurRectGM(const char name[], U8CPU alpha)
(...skipping 25 matching lines...) Expand all
116 SkScalar scales[] = { SK_Scalar1, 0.6f }; 116 SkScalar scales[] = { SK_Scalar1, 0.6f };
117 117
118 for (size_t s = 0; s < SK_ARRAY_COUNT(scales); ++s) { 118 for (size_t s = 0; s < SK_ARRAY_COUNT(scales); ++s) {
119 canvas->save(); 119 canvas->save();
120 for (size_t f = 0; f < SK_ARRAY_COUNT(fMaskFilters); ++f) { 120 for (size_t f = 0; f < SK_ARRAY_COUNT(fMaskFilters); ++f) {
121 SkPaint paint; 121 SkPaint paint;
122 paint.setMaskFilter(fMaskFilters[f]); 122 paint.setMaskFilter(fMaskFilters[f]);
123 paint.setAlpha(fAlpha); 123 paint.setAlpha(fAlpha);
124 124
125 SkPaint paintWithRadial = paint; 125 SkPaint paintWithRadial = paint;
126 paintWithRadial.setShader(MakeRadial())->unref(); 126 paintWithRadial.setShader(MakeRadial());
127 127
128 static const Proc procs[] = { 128 static const Proc procs[] = {
129 fill_rect, draw_donut, draw_donut_skewed 129 fill_rect, draw_donut, draw_donut_skewed
130 }; 130 };
131 131
132 canvas->save(); 132 canvas->save();
133 canvas->scale(scales[s], scales[s]); 133 canvas->scale(scales[s], scales[s]);
134 this->drawProcs(canvas, r, paint, false, procs, SK_ARRAY_COUNT(p rocs)); 134 this->drawProcs(canvas, r, paint, false, procs, SK_ARRAY_COUNT(p rocs));
135 canvas->translate(r.width() * 4/3, 0); 135 canvas->translate(r.width() * 4/3, 0);
136 this->drawProcs(canvas, r, paintWithRadial, false, procs, SK_ARR AY_COUNT(procs)); 136 this->drawProcs(canvas, r, paintWithRadial, false, procs, SK_ARR AY_COUNT(procs));
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 if (bm.height() > max_height) 225 if (bm.height() > max_height)
226 max_height = bm.height(); 226 max_height = bm.height();
227 } 227 }
228 } 228 }
229 } 229 }
230 } 230 }
231 231
232 ////////////////////////////////////////////////////////////////////////////// 232 //////////////////////////////////////////////////////////////////////////////
233 233
234 DEF_GM(return new BlurRectGM("blurrects", 0xFF);) 234 DEF_GM(return new BlurRectGM("blurrects", 0xFF);)
OLDNEW
« no previous file with comments | « gm/bleed.cpp ('k') | gm/blurroundrect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698