OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "gm.h" | 8 #include "gm.h" |
9 | 9 |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 SkCanvas canvas(*bm); | 34 SkCanvas canvas(*bm); |
35 canvas.drawCircle(10, 10, 10, circlePaint); | 35 canvas.drawCircle(10, 10, 10, circlePaint); |
36 } | 36 } |
37 | 37 |
38 static void adopt_shader(SkPaint* paint, SkShader* shader) { | 38 static void adopt_shader(SkPaint* paint, SkShader* shader) { |
39 paint->setShader(shader); | 39 paint->setShader(shader); |
40 SkSafeUnref(shader); | 40 SkSafeUnref(shader); |
41 } | 41 } |
42 | 42 |
43 class BitmapShaderGM : public GM { | 43 class BitmapShaderGM : public GM { |
44 public: | |
45 | 44 |
46 BitmapShaderGM() { | 45 protected: |
| 46 void onOnceBeforeDraw() SK_OVERRIDE { |
47 this->setBGColor(SK_ColorGRAY); | 47 this->setBGColor(SK_ColorGRAY); |
48 draw_bm(&fBitmap); | 48 draw_bm(&fBitmap); |
49 draw_mask(&fMask); | 49 draw_mask(&fMask); |
50 } | 50 } |
51 | 51 |
52 protected: | |
53 virtual SkString onShortName() { | 52 virtual SkString onShortName() { |
54 return SkString("bitmapshaders"); | 53 return SkString("bitmapshaders"); |
55 } | 54 } |
56 | 55 |
57 virtual SkISize onISize() { | 56 virtual SkISize onISize() { |
58 return SkISize::Make(150, 100); | 57 return SkISize::Make(150, 100); |
59 } | 58 } |
60 | 59 |
61 virtual void onDraw(SkCanvas* canvas) { | 60 virtual void onDraw(SkCanvas* canvas) { |
62 SkPaint paint; | 61 SkPaint paint; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 109 |
111 typedef GM INHERITED; | 110 typedef GM INHERITED; |
112 }; | 111 }; |
113 | 112 |
114 ////////////////////////////////////////////////////////////////////////////// | 113 ////////////////////////////////////////////////////////////////////////////// |
115 | 114 |
116 static GM* MyFactory(void*) { return new BitmapShaderGM; } | 115 static GM* MyFactory(void*) { return new BitmapShaderGM; } |
117 static GMRegistry reg(MyFactory); | 116 static GMRegistry reg(MyFactory); |
118 | 117 |
119 } | 118 } |
OLD | NEW |