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 | 9 |
10 #include "SkBitmapSource.h" | 10 #include "SkBitmapSource.h" |
11 | 11 |
12 // This GM exercises the SkBitmapSource ImageFilter class. | 12 // This GM exercises the SkBitmapSource ImageFilter class. |
13 | 13 |
14 class BitmapSourceGM : public skiagm::GM { | 14 class BitmapSourceGM : public skiagm::GM { |
15 public: | 15 public: |
16 BitmapSourceGM() { | 16 BitmapSourceGM() { |
17 } | 17 } |
18 | 18 |
19 protected: | 19 protected: |
20 virtual SkString onShortName() SK_OVERRIDE { | 20 virtual SkString onShortName() SK_OVERRIDE { |
21 return SkString("bitmapsource"); | 21 return SkString("bitmapsource"); |
22 } | 22 } |
23 | 23 |
24 void makeBitmap() { | 24 void makeBitmap() { |
25 fBitmap.setConfig(SkBitmap::kARGB_8888_Config, 100, 100); | 25 fBitmap.allocN32Pixels(100, 100); |
26 fBitmap.allocPixels(); | |
27 SkBitmapDevice device(fBitmap); | 26 SkBitmapDevice device(fBitmap); |
28 SkCanvas canvas(&device); | 27 SkCanvas canvas(&device); |
29 canvas.clear(0x00000000); | 28 canvas.clear(0x00000000); |
30 SkPaint paint; | 29 SkPaint paint; |
31 paint.setAntiAlias(true); | 30 paint.setAntiAlias(true); |
32 paint.setColor(0xFFFFFFFF); | 31 paint.setColor(0xFFFFFFFF); |
33 paint.setTextSize(SkIntToScalar(96)); | 32 paint.setTextSize(SkIntToScalar(96)); |
34 const char* str = "e"; | 33 const char* str = "e"; |
35 canvas.drawText(str, strlen(str), SkIntToScalar(20), SkIntToScalar(70),
paint); | 34 canvas.drawText(str, strlen(str), SkIntToScalar(20), SkIntToScalar(70),
paint); |
36 } | 35 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 } | 81 } |
83 | 82 |
84 private: | 83 private: |
85 SkBitmap fBitmap; | 84 SkBitmap fBitmap; |
86 typedef GM INHERITED; | 85 typedef GM INHERITED; |
87 }; | 86 }; |
88 | 87 |
89 /////////////////////////////////////////////////////////////////////////////// | 88 /////////////////////////////////////////////////////////////////////////////// |
90 | 89 |
91 DEF_GM( return new BitmapSourceGM; ) | 90 DEF_GM( return new BitmapSourceGM; ) |
OLD | NEW |