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

Side by Side Diff: gm/imagefilters.cpp

Issue 1852743002: Update SkBlurImageFilter to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update to ToT & address code review comments Created 4 years, 8 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/imageblurtiled.cpp ('k') | gm/imagefiltersbase.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 2015 Google Inc. 2 * Copyright 2015 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 "SkBlurImageFilter.h" 9 #include "SkBlurImageFilter.h"
10 #include "SkColorMatrixFilter.h" 10 #include "SkColorMatrixFilter.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 // 80 //
81 // Expect the two to draw the same (modulo the extra border of pixels when the c lip is larger) 81 // Expect the two to draw the same (modulo the extra border of pixels when the c lip is larger)
82 // 82 //
83 DEF_SIMPLE_GM(fast_slow_blurimagefilter, canvas, 620, 260) { 83 DEF_SIMPLE_GM(fast_slow_blurimagefilter, canvas, 620, 260) {
84 sk_sp<SkImage> image(make_image(canvas)); 84 sk_sp<SkImage> image(make_image(canvas));
85 const SkRect r = SkRect::MakeIWH(image->width(), image->height()); 85 const SkRect r = SkRect::MakeIWH(image->width(), image->height());
86 86
87 canvas->translate(10, 10); 87 canvas->translate(10, 10);
88 for (SkScalar sigma = 8; sigma <= 128; sigma *= 2) { 88 for (SkScalar sigma = 8; sigma <= 128; sigma *= 2) {
89 SkPaint paint; 89 SkPaint paint;
90 SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create(sigma, sigma) ); 90 paint.setImageFilter(SkBlurImageFilter::Make(sigma, sigma, nullptr));
91 paint.setImageFilter(blur);
92 91
93 canvas->save(); 92 canvas->save();
94 // we outset the clip by 1, to fall out of the fast-case in drawImage 93 // we outset the clip by 1, to fall out of the fast-case in drawImage
95 // i.e. the clip is larger than the image 94 // i.e. the clip is larger than the image
96 for (SkScalar outset = 0; outset <= 1; ++outset) { 95 for (SkScalar outset = 0; outset <= 1; ++outset) {
97 canvas->save(); 96 canvas->save();
98 canvas->clipRect(r.makeOutset(outset, outset)); 97 canvas->clipRect(r.makeOutset(outset, outset));
99 canvas->drawImage(image, 0, 0, &paint); 98 canvas->drawImage(image, 0, 0, &paint);
100 canvas->restore(); 99 canvas->restore();
101 canvas->translate(0, r.height() + 20); 100 canvas->translate(0, r.height() + 20);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 135 }
137 } 136 }
138 } 137 }
139 138
140 DEF_SIMPLE_GM(savelayer_with_backdrop, canvas, 830, 550) { 139 DEF_SIMPLE_GM(savelayer_with_backdrop, canvas, 830, 550) {
141 SkColorMatrix cm; 140 SkColorMatrix cm;
142 cm.setSaturation(10); 141 cm.setSaturation(10);
143 auto cf(SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat)); 142 auto cf(SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat));
144 const SkScalar kernel[] = { 4, 0, 4, 0, -15, 0, 4, 0, 4 }; 143 const SkScalar kernel[] = { 4, 0, 4, 0, -15, 0, 4, 0, 4 };
145 SkImageFilter* filters[] = { 144 SkImageFilter* filters[] = {
146 SkBlurImageFilter::Create(10, 10), 145 SkBlurImageFilter::Make(10, 10, nullptr).release(),
147 SkDilateImageFilter::Create(8, 8), 146 SkDilateImageFilter::Create(8, 8),
148 SkMatrixConvolutionImageFilter::Create({ 3, 3 }, kernel, 1, 0, { 0, 0 }, 147 SkMatrixConvolutionImageFilter::Create({ 3, 3 }, kernel, 1, 0, { 0, 0 },
149 SkMatrixConvolutionImageFilter::kClam pToBlack_TileMode, 148 SkMatrixConvolutionImageFilter::kClam pToBlack_TileMode,
150 true), 149 true),
151 SkColorFilterImageFilter::Create(cf.get()), 150 SkColorFilterImageFilter::Create(cf.get()),
152 }; 151 };
153 152
154 const struct { 153 const struct {
155 SkScalar fSx, fSy, fTx, fTy; 154 SkScalar fSx, fSy, fTx, fTy;
156 } xforms[] = { 155 } xforms[] = {
(...skipping 14 matching lines...) Expand all
171 canvas->scale(xform.fSx, xform.fSy); 170 canvas->scale(xform.fSx, xform.fSy);
172 canvas->drawImage(image, 0, 0, &paint); 171 canvas->drawImage(image, 0, 0, &paint);
173 draw_set(canvas, filters, SK_ARRAY_COUNT(filters)); 172 draw_set(canvas, filters, SK_ARRAY_COUNT(filters));
174 canvas->restore(); 173 canvas->restore();
175 } 174 }
176 175
177 for (auto& filter : filters) { 176 for (auto& filter : filters) {
178 filter->unref(); 177 filter->unref();
179 } 178 }
180 } 179 }
OLDNEW
« no previous file with comments | « gm/imageblurtiled.cpp ('k') | gm/imagefiltersbase.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698