OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 paint.setColor(SK_ColorBLUE); | 25 paint.setColor(SK_ColorBLUE); |
26 canvas.drawCircle(SkIntToScalar(W)/2, SkIntToScalar(H)/2, SkIntToScalar(W)/2
, paint); | 26 canvas.drawCircle(SkIntToScalar(W)/2, SkIntToScalar(H)/2, SkIntToScalar(W)/2
, paint); |
27 } | 27 } |
28 | 28 |
29 class ExtractBitmapGM : public GM { | 29 class ExtractBitmapGM : public GM { |
30 public: | 30 public: |
31 ExtractBitmapGM() {} | 31 ExtractBitmapGM() {} |
32 | 32 |
33 protected: | 33 protected: |
34 // overrides from SkEventSink | 34 // overrides from SkEventSink |
35 virtual SkString onShortName() SK_OVERRIDE { | 35 SkString onShortName() SK_OVERRIDE { |
36 return SkString("extractbitmap"); | 36 return SkString("extractbitmap"); |
37 } | 37 } |
38 | 38 |
39 virtual SkISize onISize() SK_OVERRIDE { | 39 SkISize onISize() SK_OVERRIDE { |
40 return SkISize::Make(600, 600); | 40 return SkISize::Make(600, 600); |
41 } | 41 } |
42 | 42 |
43 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 43 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
44 SkBitmap bitmap; | 44 SkBitmap bitmap; |
45 create_bitmap(&bitmap); | 45 create_bitmap(&bitmap); |
46 int x = bitmap.width() / 2; | 46 int x = bitmap.width() / 2; |
47 int y = bitmap.height() / 2; | 47 int y = bitmap.height() / 2; |
48 | 48 |
49 canvas->translate(SkIntToScalar(20), SkIntToScalar(20)); | 49 canvas->translate(SkIntToScalar(20), SkIntToScalar(20)); |
50 | 50 |
51 canvas->drawBitmap(bitmap, 0, 0); | 51 canvas->drawBitmap(bitmap, 0, 0); |
52 | 52 |
53 { | 53 { |
(...skipping 23 matching lines...) Expand all Loading... |
77 private: | 77 private: |
78 typedef GM INHERITED; | 78 typedef GM INHERITED; |
79 }; | 79 }; |
80 | 80 |
81 ////////////////////////////////////////////////////////////////////////////// | 81 ////////////////////////////////////////////////////////////////////////////// |
82 | 82 |
83 static GM* MyFactory(void*) { return new ExtractBitmapGM; } | 83 static GM* MyFactory(void*) { return new ExtractBitmapGM; } |
84 static GMRegistry reg(MyFactory); | 84 static GMRegistry reg(MyFactory); |
85 | 85 |
86 } | 86 } |
OLD | NEW |