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.allocN32Pixels(100, 100); | 25 fBitmap.allocN32Pixels(100, 100); |
26 SkBitmapDevice device(fBitmap); | 26 SkCanvas canvas(fBitmap); |
27 SkCanvas canvas(&device); | |
28 canvas.clear(0x00000000); | 27 canvas.clear(0x00000000); |
29 SkPaint paint; | 28 SkPaint paint; |
30 paint.setAntiAlias(true); | 29 paint.setAntiAlias(true); |
31 paint.setColor(0xFFFFFFFF); | 30 paint.setColor(0xFFFFFFFF); |
32 paint.setTextSize(SkIntToScalar(96)); | 31 paint.setTextSize(SkIntToScalar(96)); |
33 const char* str = "e"; | 32 const char* str = "e"; |
34 canvas.drawText(str, strlen(str), SkIntToScalar(20), SkIntToScalar(70),
paint); | 33 canvas.drawText(str, strlen(str), SkIntToScalar(20), SkIntToScalar(70),
paint); |
35 } | 34 } |
36 | 35 |
37 virtual SkISize onISize() SK_OVERRIDE { return SkISize::Make(500, 150); } | 36 virtual SkISize onISize() SK_OVERRIDE { return SkISize::Make(500, 150); } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 } | 80 } |
82 | 81 |
83 private: | 82 private: |
84 SkBitmap fBitmap; | 83 SkBitmap fBitmap; |
85 typedef GM INHERITED; | 84 typedef GM INHERITED; |
86 }; | 85 }; |
87 | 86 |
88 /////////////////////////////////////////////////////////////////////////////// | 87 /////////////////////////////////////////////////////////////////////////////// |
89 | 88 |
90 DEF_GM( return new BitmapSourceGM; ) | 89 DEF_GM( return new BitmapSourceGM; ) |
OLD | NEW |