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 "SkOffsetImageFilter.h" | 9 #include "SkOffsetImageFilter.h" |
10 #include "SkBitmapSource.h" | 10 #include "SkBitmapSource.h" |
11 | 11 |
12 #define WIDTH 400 | 12 #define WIDTH 400 |
13 #define HEIGHT 100 | 13 #define HEIGHT 100 |
14 #define MARGIN 12 | 14 #define MARGIN 12 |
15 | 15 |
16 namespace skiagm { | 16 namespace skiagm { |
17 | 17 |
18 class OffsetImageFilterGM : public GM { | 18 class OffsetImageFilterGM : public GM { |
19 public: | 19 public: |
20 OffsetImageFilterGM() : fInitialized(false) { | 20 OffsetImageFilterGM() : fInitialized(false) { |
21 this->setBGColor(0xFF000000); | 21 this->setBGColor(0xFF000000); |
22 } | 22 } |
23 | 23 |
24 protected: | 24 protected: |
25 virtual SkString onShortName() { | 25 virtual SkString onShortName() { |
26 return SkString("offsetimagefilter"); | 26 return SkString("offsetimagefilter"); |
27 } | 27 } |
28 | 28 |
29 void make_bitmap() { | 29 void make_bitmap() { |
30 fBitmap.setConfig(SkBitmap::kARGB_8888_Config, 80, 80); | 30 fBitmap.allocN32Pixels(80, 80); |
31 fBitmap.allocPixels(); | |
32 SkBitmapDevice device(fBitmap); | 31 SkBitmapDevice device(fBitmap); |
33 SkCanvas canvas(&device); | 32 SkCanvas canvas(&device); |
34 canvas.clear(0x00000000); | 33 canvas.clear(0x00000000); |
35 SkPaint paint; | 34 SkPaint paint; |
36 paint.setAntiAlias(true); | 35 paint.setAntiAlias(true); |
37 paint.setColor(0xD000D000); | 36 paint.setColor(0xD000D000); |
38 paint.setTextSize(SkIntToScalar(96)); | 37 paint.setTextSize(SkIntToScalar(96)); |
39 const char* str = "e"; | 38 const char* str = "e"; |
40 canvas.drawText(str, strlen(str), SkIntToScalar(15), SkIntToScalar(65),
paint); | 39 canvas.drawText(str, strlen(str), SkIntToScalar(15), SkIntToScalar(65),
paint); |
41 } | 40 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 SkBitmap fBitmap, fCheckerboard; | 112 SkBitmap fBitmap, fCheckerboard; |
114 bool fInitialized; | 113 bool fInitialized; |
115 }; | 114 }; |
116 | 115 |
117 ////////////////////////////////////////////////////////////////////////////// | 116 ////////////////////////////////////////////////////////////////////////////// |
118 | 117 |
119 static GM* MyFactory(void*) { return new OffsetImageFilterGM; } | 118 static GM* MyFactory(void*) { return new OffsetImageFilterGM; } |
120 static GMRegistry reg(MyFactory); | 119 static GMRegistry reg(MyFactory); |
121 | 120 |
122 } | 121 } |
OLD | NEW |