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

Side by Side Diff: gm/imagefilters.cpp

Issue 1821103004: Revert of Revert[2] of "switch colorfilters to sk_sp (patchset #11 id:200001 of https://codereview.chromium.o… (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 | « gm/fadefilter.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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 } else { 133 } else {
134 dx = 0; 134 dx = 0;
135 dy = offset; 135 dy = offset;
136 } 136 }
137 } 137 }
138 } 138 }
139 139
140 DEF_SIMPLE_GM(savelayer_with_backdrop, canvas, 830, 550) { 140 DEF_SIMPLE_GM(savelayer_with_backdrop, canvas, 830, 550) {
141 SkColorMatrix cm; 141 SkColorMatrix cm;
142 cm.setSaturation(10); 142 cm.setSaturation(10);
143 auto cf(SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat)); 143 SkAutoTUnref<SkColorFilter> cf(SkColorMatrixFilter::Create(cm));
144 const SkScalar kernel[] = { 4, 0, 4, 0, -15, 0, 4, 0, 4 }; 144 const SkScalar kernel[] = { 4, 0, 4, 0, -15, 0, 4, 0, 4 };
145 SkImageFilter* filters[] = { 145 SkImageFilter* filters[] = {
146 SkBlurImageFilter::Create(10, 10), 146 SkBlurImageFilter::Create(10, 10),
147 SkDilateImageFilter::Create(8, 8), 147 SkDilateImageFilter::Create(8, 8),
148 SkMatrixConvolutionImageFilter::Create({ 3, 3 }, kernel, 1, 0, { 0, 0 }, 148 SkMatrixConvolutionImageFilter::Create({ 3, 3 }, kernel, 1, 0, { 0, 0 },
149 SkMatrixConvolutionImageFilter::kClam pToBlack_TileMode, 149 SkMatrixConvolutionImageFilter::kClam pToBlack_TileMode,
150 true), 150 true),
151 SkColorFilterImageFilter::Create(cf.get()), 151 SkColorFilterImageFilter::Create(cf),
152 }; 152 };
153 153
154 const struct { 154 const struct {
155 SkScalar fSx, fSy, fTx, fTy; 155 SkScalar fSx, fSy, fTx, fTy;
156 } xforms[] = { 156 } xforms[] = {
157 { 1, 1, 0, 0 }, 157 { 1, 1, 0, 0 },
158 { 0.5f, 0.5f, 530, 0 }, 158 { 0.5f, 0.5f, 530, 0 },
159 { 0.25f, 0.25f, 530, 275 }, 159 { 0.25f, 0.25f, 530, 275 },
160 { 0.125f, 0.125f, 530, 420 }, 160 { 0.125f, 0.125f, 530, 420 },
161 }; 161 };
162 162
163 SkPaint paint; 163 SkPaint paint;
164 paint.setFilterQuality(kMedium_SkFilterQuality); 164 paint.setFilterQuality(kMedium_SkFilterQuality);
165 sk_sp<SkImage> image(GetResourceAsImage("mandrill_512.png")); 165 sk_sp<SkImage> image(GetResourceAsImage("mandrill_512.png"));
166 166
167 canvas->translate(20, 20); 167 canvas->translate(20, 20);
168 for (const auto& xform : xforms) { 168 for (const auto& xform : xforms) {
169 canvas->save(); 169 canvas->save();
170 canvas->translate(xform.fTx, xform.fTy); 170 canvas->translate(xform.fTx, xform.fTy);
171 canvas->scale(xform.fSx, xform.fSy); 171 canvas->scale(xform.fSx, xform.fSy);
172 canvas->drawImage(image, 0, 0, &paint); 172 canvas->drawImage(image, 0, 0, &paint);
173 draw_set(canvas, filters, SK_ARRAY_COUNT(filters)); 173 draw_set(canvas, filters, SK_ARRAY_COUNT(filters));
174 canvas->restore(); 174 canvas->restore();
175 } 175 }
176 176
177 for (auto& filter : filters) { 177 for (auto& filter : filters) {
178 filter->unref(); 178 filter->unref();
179 } 179 }
180 } 180 }
OLDNEW
« no previous file with comments | « gm/fadefilter.cpp ('k') | gm/imagefiltersbase.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698