OLD | NEW |
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 "SkBlurMask.h" | 9 #include "SkBlurMask.h" |
10 #include "SkBlurMaskFilter.h" | 10 #include "SkBlurMaskFilter.h" |
11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
12 | 12 |
13 #if SK_SUPPORT_GPU | 13 #if SK_SUPPORT_GPU |
14 #include "GrContext.h" | 14 #include "GrContext.h" |
15 #endif | 15 #endif |
16 | 16 |
17 // Create a black&white checked texture with 2 1-pixel rings | 17 // Create a black&white checked texture with 2 1-pixel rings |
18 // around the outside edge. The inner ring is red and the outer ring is blue. | 18 // around the outside edge. The inner ring is red and the outer ring is blue. |
19 static void make_ringed_bitmap(SkBitmap* result, int width, int height) { | 19 static void make_ringed_bitmap(SkBitmap* result, int width, int height) { |
20 SkASSERT(0 == width % 2 && 0 == height % 2); | 20 SkASSERT(0 == width % 2 && 0 == height % 2); |
21 | 21 |
22 static const SkPMColor kRed = SkPreMultiplyColor(SK_ColorRED); | 22 static const SkPMColor kRed = SkPreMultiplyColor(SK_ColorRED); |
23 static const SkPMColor kBlue = SkPreMultiplyColor(SK_ColorBLUE); | 23 static const SkPMColor kBlue = SkPreMultiplyColor(SK_ColorBLUE); |
24 static const SkPMColor kBlack = SkPreMultiplyColor(SK_ColorBLACK); | 24 static const SkPMColor kBlack = SkPreMultiplyColor(SK_ColorBLACK); |
25 static const SkPMColor kWhite = SkPreMultiplyColor(SK_ColorWHITE); | 25 static const SkPMColor kWhite = SkPreMultiplyColor(SK_ColorWHITE); |
26 | 26 |
27 result->setConfig(SkBitmap::kARGB_8888_Config, width, height, 0, | 27 result->allocN32Pixels(width, height, true); |
28 kOpaque_SkAlphaType); | |
29 result->allocPixels(); | |
30 SkAutoLockPixels lock(*result); | |
31 | 28 |
32 SkPMColor* scanline = result->getAddr32(0, 0); | 29 SkPMColor* scanline = result->getAddr32(0, 0); |
33 for (int x = 0; x < width; ++x) { | 30 for (int x = 0; x < width; ++x) { |
34 scanline[x] = kBlue; | 31 scanline[x] = kBlue; |
35 } | 32 } |
36 scanline = result->getAddr32(0, 1); | 33 scanline = result->getAddr32(0, 1); |
37 scanline[0] = kBlue; | 34 scanline[0] = kBlue; |
38 for (int x = 1; x < width - 1; ++x) { | 35 for (int x = 1; x < width - 1; ++x) { |
39 scanline[x] = kRed; | 36 scanline[x] = kRed; |
40 } | 37 } |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 static const int kSmallTextureSize = 6; | 269 static const int kSmallTextureSize = 6; |
273 static const int kMaxTextureSize = 32; | 270 static const int kMaxTextureSize = 32; |
274 | 271 |
275 SkBitmap fBitmapSmall; | 272 SkBitmap fBitmapSmall; |
276 SkBitmap fBitmapBig; | 273 SkBitmap fBitmapBig; |
277 | 274 |
278 typedef GM INHERITED; | 275 typedef GM INHERITED; |
279 }; | 276 }; |
280 | 277 |
281 DEF_GM( return new BleedGM(); ) | 278 DEF_GM( return new BleedGM(); ) |
OLD | NEW |