OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkLightingImageFilter.h" | 9 #include "SkLightingImageFilter.h" |
10 | 10 |
11 #define WIDTH 330 | 11 #define WIDTH 330 |
12 #define HEIGHT 440 | 12 #define HEIGHT 440 |
13 | 13 |
14 namespace skiagm { | 14 namespace skiagm { |
15 | 15 |
16 class ImageLightingGM : public GM { | 16 class ImageLightingGM : public GM { |
17 public: | 17 public: |
18 ImageLightingGM() : fInitialized(false) { | 18 ImageLightingGM() : fInitialized(false) { |
19 this->setBGColor(0xFF000000); | 19 this->setBGColor(0xFF000000); |
20 } | 20 } |
21 | 21 |
22 protected: | 22 protected: |
23 virtual SkString onShortName() { | 23 virtual SkString onShortName() { |
24 return SkString("lighting"); | 24 return SkString("lighting"); |
25 } | 25 } |
26 | 26 |
27 void make_bitmap() { | 27 void make_bitmap() { |
28 fBitmap.setConfig(SkBitmap::kARGB_8888_Config, 100, 100); | 28 fBitmap.allocN32Pixels(100, 100); |
29 fBitmap.allocPixels(); | |
30 SkBitmapDevice device(fBitmap); | 29 SkBitmapDevice device(fBitmap); |
31 SkCanvas canvas(&device); | 30 SkCanvas canvas(&device); |
32 canvas.clear(0x00000000); | 31 canvas.clear(0x00000000); |
33 SkPaint paint; | 32 SkPaint paint; |
34 paint.setAntiAlias(true); | 33 paint.setAntiAlias(true); |
35 paint.setColor(0xFFFFFFFF); | 34 paint.setColor(0xFFFFFFFF); |
36 paint.setTextSize(SkIntToScalar(96)); | 35 paint.setTextSize(SkIntToScalar(96)); |
37 const char* str = "e"; | 36 const char* str = "e"; |
38 canvas.drawText(str, strlen(str), SkIntToScalar(20), SkIntToScalar(70),
paint); | 37 canvas.drawText(str, strlen(str), SkIntToScalar(20), SkIntToScalar(70),
paint); |
39 } | 38 } |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 SkBitmap fBitmap; | 118 SkBitmap fBitmap; |
120 bool fInitialized; | 119 bool fInitialized; |
121 }; | 120 }; |
122 | 121 |
123 ////////////////////////////////////////////////////////////////////////////// | 122 ////////////////////////////////////////////////////////////////////////////// |
124 | 123 |
125 static GM* MyFactory(void*) { return new ImageLightingGM; } | 124 static GM* MyFactory(void*) { return new ImageLightingGM; } |
126 static GMRegistry reg(MyFactory); | 125 static GMRegistry reg(MyFactory); |
127 | 126 |
128 } | 127 } |
OLD | NEW |