OLD | NEW |
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 Loading... |
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 } |
OLD | NEW |