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

Side by Side Diff: gm/xfermodes3.cpp

Issue 1793303002: Reland of "more shader-->sp conversions (patchset #5 id:80001 of https://codereview.chromium… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: make pictureRef a value, so its clearer what's going on 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/xfermodes2.cpp ('k') | tests/BitmapHeapTest.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 2013 Google Inc. 2 * Copyright 2013 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 "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkGradientShader.h" 10 #include "SkGradientShader.h"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 SkPackARGB32(0xFF, 0xD6, 0xD3, 0xD6), 178 SkPackARGB32(0xFF, 0xD6, 0xD3, 0xD6),
179 SkPackARGB32(0xFF, 0x42, 0x41, 0x42) 179 SkPackARGB32(0xFF, 0x42, 0x41, 0x42)
180 }; 180 };
181 SkBitmap bg; 181 SkBitmap bg;
182 bg.allocN32Pixels(2, 2, true); 182 bg.allocN32Pixels(2, 2, true);
183 SkAutoLockPixels bgAlp(bg); 183 SkAutoLockPixels bgAlp(bg);
184 memcpy(bg.getPixels(), kCheckData, sizeof(kCheckData)); 184 memcpy(bg.getPixels(), kCheckData, sizeof(kCheckData));
185 185
186 SkMatrix lm; 186 SkMatrix lm;
187 lm.setScale(SkIntToScalar(kCheckSize), SkIntToScalar(kCheckSize)); 187 lm.setScale(SkIntToScalar(kCheckSize), SkIntToScalar(kCheckSize));
188 fBGShader.reset(SkShader::CreateBitmapShader(bg, 188 fBGShader = SkShader::MakeBitmapShader(bg, SkShader::kRepeat_TileMode,
189 SkShader::kRepeat_TileMode, 189 SkShader::kRepeat_TileMode, &lm);
190 SkShader::kRepeat_TileMode,
191 &lm));
192 190
193 SkPaint bmpPaint; 191 SkPaint bmpPaint;
194 static const SkPoint kCenter = { SkIntToScalar(kSize) / 2, SkIntToScalar (kSize) / 2 }; 192 const SkPoint kCenter = { SkIntToScalar(kSize) / 2, SkIntToScalar(kSize) / 2 };
195 static const SkColor kColors[] = { SK_ColorTRANSPARENT, 0x80800000, 193 const SkColor kColors[] = {
196 0xF020F060, SK_ColorWHITE }; 194 SK_ColorTRANSPARENT, 0x80800000, 0xF020F060, SK_ColorWHITE
197 bmpPaint.setShader(SkGradientShader::CreateRadial(kCenter, 195 };
198 3 * SkIntToScalar(kSiz e) / 4, 196 bmpPaint.setShader(SkGradientShader::MakeRadial(kCenter, 3 * SkIntToScal ar(kSize) / 4,
199 kColors, 197 kColors, nullptr, SK_ARR AY_COUNT(kColors),
200 nullptr, 198 SkShader::kRepeat_TileMo de));
201 SK_ARRAY_COUNT(kColors ),
202 SkShader::kRepeat_Tile Mode))->unref();
203 199
204 SkBitmap bmp; 200 SkBitmap bmp;
205 bmp.allocN32Pixels(kSize, kSize); 201 bmp.allocN32Pixels(kSize, kSize);
206 SkCanvas bmpCanvas(bmp); 202 SkCanvas bmpCanvas(bmp);
207 203
208 bmpCanvas.clear(SK_ColorTRANSPARENT); 204 bmpCanvas.clear(SK_ColorTRANSPARENT);
209 SkRect rect = { SkIntToScalar(kSize) / 8, SkIntToScalar(kSize) / 8, 205 SkRect rect = { SkIntToScalar(kSize) / 8, SkIntToScalar(kSize) / 8,
210 7 * SkIntToScalar(kSize) / 8, 7 * SkIntToScalar(kSize) / 8}; 206 7 * SkIntToScalar(kSize) / 8, 7 * SkIntToScalar(kSize) / 8};
211 bmpCanvas.drawRect(rect, bmpPaint); 207 bmpCanvas.drawRect(rect, bmpPaint);
212 208
213 fBmpShader.reset(SkShader::CreateBitmapShader(bmp, 209 fBmpShader = SkShader::MakeBitmapShader(bmp, SkShader::kClamp_TileMode,
214 SkShader::kClamp_TileMode, 210 SkShader::kClamp_TileMode);
215 SkShader::kClamp_TileMode) );
216 } 211 }
217 212
218 enum { 213 enum {
219 kCheckSize = 8, 214 kCheckSize = 8,
220 kSize = 30, 215 kSize = 30,
221 kTestsPerRow = 15, 216 kTestsPerRow = 15,
222 }; 217 };
223 218
224 SkAutoTUnref<SkShader> fBGShader; 219 sk_sp<SkShader> fBGShader;
225 SkAutoTUnref<SkShader> fBmpShader; 220 sk_sp<SkShader> fBmpShader;
226 221
227 typedef GM INHERITED; 222 typedef GM INHERITED;
228 }; 223 };
229 224
230 ////////////////////////////////////////////////////////////////////////////// 225 //////////////////////////////////////////////////////////////////////////////
231 226
232 DEF_GM(return new Xfermodes3GM;) 227 DEF_GM(return new Xfermodes3GM;)
233 228
234 } 229 }
OLDNEW
« no previous file with comments | « gm/xfermodes2.cpp ('k') | tests/BitmapHeapTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698