OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
4 * | 3 * |
5 * 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 |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
| 7 |
8 #include "SampleCode.h" | 8 #include "SampleCode.h" |
9 #include "SkBlurMask.h" | 9 #include "SkBlurMask.h" |
10 #include "SkBlurMaskFilter.h" | 10 #include "SkBlurMaskFilter.h" |
11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
12 #include "SkDevice.h" | 12 #include "SkDevice.h" |
13 | 13 |
14 namespace { | 14 static SkBitmap make_bitmap() { |
15 SkBitmap make_bitmap() { | |
16 SkBitmap bm; | 15 SkBitmap bm; |
17 bm.setConfig(SkBitmap::kARGB_8888_Config , 5, 5); | 16 bm.setConfig(SkBitmap::kARGB_8888_Config , 5, 5); |
18 bm.allocPixels(); | 17 bm.allocPixels(); |
19 | 18 |
20 for (int y = 0; y < bm.height(); y++) { | 19 for (int y = 0; y < bm.height(); y++) { |
21 uint32_t* p = bm.getAddr32(0, y); | 20 uint32_t* p = bm.getAddr32(0, y); |
22 for (int x = 0; x < bm.width(); x++) { | 21 for (int x = 0; x < bm.width(); x++) { |
23 p[x] = ((x + y) & 1) ? SK_ColorWHITE : SK_ColorBLACK; | 22 p[x] = ((x + y) & 1) ? SK_ColorWHITE : SK_ColorBLACK; |
24 } | 23 } |
25 } | 24 } |
26 bm.unlockPixels(); | 25 bm.unlockPixels(); |
27 return bm; | 26 return bm; |
28 } | 27 } |
29 } // unnamed namespace | |
30 | 28 |
31 class TextureDomainView : public SampleView { | 29 class TextureDomainView : public SampleView { |
32 SkBitmap fBM; | 30 SkBitmap fBM; |
33 | 31 |
34 public: | 32 public: |
35 TextureDomainView(){ | 33 TextureDomainView(){ |
36 fBM = make_bitmap(); | 34 fBM = make_bitmap(); |
37 } | 35 } |
38 | 36 |
39 protected: | 37 protected: |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 canvas->drawBitmapRect(fBM, NULL, dstRect, &paint); | 103 canvas->drawBitmapRect(fBM, NULL, dstRect, &paint); |
106 } | 104 } |
107 private: | 105 private: |
108 typedef SkView INHERITED; | 106 typedef SkView INHERITED; |
109 }; | 107 }; |
110 | 108 |
111 ////////////////////////////////////////////////////////////////////////////// | 109 ////////////////////////////////////////////////////////////////////////////// |
112 | 110 |
113 static SkView* MyFactory() { return new TextureDomainView; } | 111 static SkView* MyFactory() { return new TextureDomainView; } |
114 static SkViewRegister reg(MyFactory); | 112 static SkViewRegister reg(MyFactory); |
OLD | NEW |