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

Side by Side Diff: gm/imagefiltersscaled.cpp

Issue 1817383002: switch surface to sk_sp (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/imagefilterscropexpand.cpp ('k') | gm/imagefilterstransformed.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 2014 Google Inc. 2 * Copyright 2014 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 "sk_tool_utils.h" 8 #include "sk_tool_utils.h"
9 #include "SkBlurImageFilter.h" 9 #include "SkBlurImageFilter.h"
10 #include "SkColor.h" 10 #include "SkColor.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) { 132 for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) {
133 filters[i]->unref(); 133 filters[i]->unref();
134 } 134 }
135 } 135 }
136 136
137 private: 137 private:
138 static sk_sp<SkImage> MakeGradientCircle(int width, int height) { 138 static sk_sp<SkImage> MakeGradientCircle(int width, int height) {
139 SkScalar x = SkIntToScalar(width / 2); 139 SkScalar x = SkIntToScalar(width / 2);
140 SkScalar y = SkIntToScalar(height / 2); 140 SkScalar y = SkIntToScalar(height / 2);
141 SkScalar radius = SkScalarMul(SkMinScalar(x, y), SkIntToScalar(4) / SkIn tToScalar(5)); 141 SkScalar radius = SkScalarMul(SkMinScalar(x, y), SkIntToScalar(4) / SkIn tToScalar(5));
142 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(width, hei ght)); 142 auto surface(SkSurface::MakeRasterN32Premul(width, height));
143 SkCanvas* canvas = surface->getCanvas(); 143 SkCanvas* canvas = surface->getCanvas();
144 canvas->clear(0x00000000); 144 canvas->clear(0x00000000);
145 SkColor colors[2]; 145 SkColor colors[2];
146 colors[0] = SK_ColorWHITE; 146 colors[0] = SK_ColorWHITE;
147 colors[1] = SK_ColorBLACK; 147 colors[1] = SK_ColorBLACK;
148 SkPaint paint; 148 SkPaint paint;
149 paint.setShader(SkGradientShader::MakeRadial(SkPoint::Make(x, y), radius , colors, nullptr, 149 paint.setShader(SkGradientShader::MakeRadial(SkPoint::Make(x, y), radius , colors, nullptr,
150 2, SkShader::kClamp_TileMod e)); 150 2, SkShader::kClamp_TileMod e));
151 canvas->drawCircle(x, y, radius, paint); 151 canvas->drawCircle(x, y, radius, paint);
152 152
153 return surface->makeImageSnapshot(); 153 return surface->makeImageSnapshot();
154 } 154 }
155 155
156 sk_sp<SkImage> fCheckerboard, fGradientCircle; 156 sk_sp<SkImage> fCheckerboard, fGradientCircle;
157 157
158 typedef GM INHERITED; 158 typedef GM INHERITED;
159 }; 159 };
160 160
161 ////////////////////////////////////////////////////////////////////////////// 161 //////////////////////////////////////////////////////////////////////////////
162 162
163 DEF_GM(return new ImageFiltersScaledGM;) 163 DEF_GM(return new ImageFiltersScaledGM;)
164 } 164 }
OLDNEW
« no previous file with comments | « gm/imagefilterscropexpand.cpp ('k') | gm/imagefilterstransformed.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698