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

Side by Side Diff: gm/drawbitmaprect.cpp

Issue 140593005: add legacy/helper allocN32Pixels, and convert gm to use it (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « gm/downsamplebitmap.cpp ('k') | gm/dropshadowimagefilter.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
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"
11 #include "SkColorPriv.h" 11 #include "SkColorPriv.h"
12 #include "SkGradientShader.h" 12 #include "SkGradientShader.h"
13 #include "SkShader.h" 13 #include "SkShader.h"
14 14
15 namespace skiagm { 15 namespace skiagm {
16 16
17 static SkBitmap make_chessbm(int w, int h) { 17 static SkBitmap make_chessbm(int w, int h) {
18 SkBitmap bm; 18 SkBitmap bm;
19 bm.setConfig(SkBitmap::kARGB_8888_Config , w, h); 19 bm.allocN32Pixels(w, h);
20 bm.allocPixels();
21 20
22 for (int y = 0; y < bm.height(); y++) { 21 for (int y = 0; y < bm.height(); y++) {
23 uint32_t* p = bm.getAddr32(0, y); 22 uint32_t* p = bm.getAddr32(0, y);
24 for (int x = 0; x < bm.width(); x++) { 23 for (int x = 0; x < bm.width(); x++) {
25 p[x] = ((x + y) & 1) ? SK_ColorWHITE : SK_ColorBLACK; 24 p[x] = ((x + y) & 1) ? SK_ColorWHITE : SK_ColorBLACK;
26 } 25 }
27 } 26 }
28 bm.unlockPixels(); 27 bm.unlockPixels();
29 return bm; 28 return bm;
30 } 29 }
31 30
32 static void makebm(SkBitmap* bm, SkBitmap::Config config, int w, int h) { 31 static void makebm(SkBitmap* bm, SkBitmap::Config config, int w, int h) {
33 bm->setConfig(config, w, h); 32 bm->allocConfigPixels(config, w, h);
34 bm->allocPixels();
35 bm->eraseColor(SK_ColorTRANSPARENT); 33 bm->eraseColor(SK_ColorTRANSPARENT);
36 34
37 SkCanvas canvas(*bm); 35 SkCanvas canvas(*bm);
38 36
39 SkScalar wScalar = SkIntToScalar(w); 37 SkScalar wScalar = SkIntToScalar(w);
40 SkScalar hScalar = SkIntToScalar(h); 38 SkScalar hScalar = SkIntToScalar(h);
41 39
42 SkPoint pt = { wScalar / 2, hScalar / 2 }; 40 SkPoint pt = { wScalar / 2, hScalar / 2 };
43 41
44 SkScalar radius = 4 * SkMaxScalar(wScalar, hScalar); 42 SkScalar radius = 4 * SkMaxScalar(wScalar, hScalar);
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 typedef GM INHERITED; 178 typedef GM INHERITED;
181 }; 179 };
182 180
183 ////////////////////////////////////////////////////////////////////////////// 181 //////////////////////////////////////////////////////////////////////////////
184 182
185 #ifndef SK_BUILD_FOR_ANDROID 183 #ifndef SK_BUILD_FOR_ANDROID
186 static GM* MyFactory(void*) { return new DrawBitmapRectGM; } 184 static GM* MyFactory(void*) { return new DrawBitmapRectGM; }
187 static GMRegistry reg(MyFactory); 185 static GMRegistry reg(MyFactory);
188 #endif 186 #endif
189 } 187 }
OLDNEW
« no previous file with comments | « gm/downsamplebitmap.cpp ('k') | gm/dropshadowimagefilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698