OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 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 #include "SkBlurMask.h" | 9 #include "SkBlurMask.h" |
10 #include "SkBlurMaskFilter.h" | 10 #include "SkBlurMaskFilter.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 for (int y = 0; y < bm.height(); y++) { | 21 for (int y = 0; y < bm.height(); y++) { |
22 uint32_t* p = bm.getAddr32(0, y); | 22 uint32_t* p = bm.getAddr32(0, y); |
23 for (int x = 0; x < bm.width(); x++) { | 23 for (int x = 0; x < bm.width(); x++) { |
24 p[x] = ((x + y) & 1) ? SK_ColorWHITE : SK_ColorBLACK; | 24 p[x] = ((x + y) & 1) ? SK_ColorWHITE : SK_ColorBLACK; |
25 } | 25 } |
26 } | 26 } |
27 bm.unlockPixels(); | 27 bm.unlockPixels(); |
28 return bm; | 28 return bm; |
29 } | 29 } |
30 | 30 |
31 static void makebm(SkBitmap* bm, SkBitmap::Config config, int w, int h) { | 31 static void makebm(SkBitmap* bm, int w, int h) { |
32 bm->allocConfigPixels(config, w, h); | 32 bm->allocN32Pixels(w, h); |
33 bm->eraseColor(SK_ColorTRANSPARENT); | 33 bm->eraseColor(SK_ColorTRANSPARENT); |
34 | 34 |
35 SkCanvas canvas(*bm); | 35 SkCanvas canvas(*bm); |
36 | 36 |
37 SkScalar wScalar = SkIntToScalar(w); | 37 SkScalar wScalar = SkIntToScalar(w); |
38 SkScalar hScalar = SkIntToScalar(h); | 38 SkScalar hScalar = SkIntToScalar(h); |
39 | 39 |
40 SkPoint pt = { wScalar / 2, hScalar / 2 }; | 40 SkPoint pt = { wScalar / 2, hScalar / 2 }; |
41 | 41 |
42 SkScalar radius = 4 * SkMaxScalar(wScalar, hScalar); | 42 SkScalar radius = 4 * SkMaxScalar(wScalar, hScalar); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 protected: | 82 protected: |
83 SkString onShortName() { | 83 SkString onShortName() { |
84 return SkString("drawbitmaprect"); | 84 return SkString("drawbitmaprect"); |
85 } | 85 } |
86 | 86 |
87 SkISize onISize() { return make_isize(gSize, gSize); } | 87 SkISize onISize() { return make_isize(gSize, gSize); } |
88 | 88 |
89 virtual void onDraw(SkCanvas* canvas) { | 89 virtual void onDraw(SkCanvas* canvas) { |
90 static const int kBmpSize = 2048; | 90 static const int kBmpSize = 2048; |
91 if (fLargeBitmap.isNull()) { | 91 if (fLargeBitmap.isNull()) { |
92 makebm(&fLargeBitmap, | 92 makebm(&fLargeBitmap, kBmpSize, kBmpSize); |
93 SkBitmap::kARGB_8888_Config, | |
94 kBmpSize, kBmpSize); | |
95 } | 93 } |
96 SkRect dstRect = { 0, 0, SkIntToScalar(64), SkIntToScalar(64)}; | 94 SkRect dstRect = { 0, 0, SkIntToScalar(64), SkIntToScalar(64)}; |
97 static const int kMaxSrcRectSize = 1 << (SkNextLog2(kBmpSize) + 2); | 95 static const int kMaxSrcRectSize = 1 << (SkNextLog2(kBmpSize) + 2); |
98 | 96 |
99 static const int kPadX = 30; | 97 static const int kPadX = 30; |
100 static const int kPadY = 40; | 98 static const int kPadY = 40; |
101 SkPaint paint; | 99 SkPaint paint; |
102 paint.setAlpha(0x20); | 100 paint.setAlpha(0x20); |
103 canvas->drawBitmapRect(fLargeBitmap, NULL, | 101 canvas->drawBitmapRect(fLargeBitmap, NULL, |
104 SkRect::MakeWH(gSize * SK_Scalar1, | 102 SkRect::MakeWH(gSize * SK_Scalar1, |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 typedef GM INHERITED; | 176 typedef GM INHERITED; |
179 }; | 177 }; |
180 | 178 |
181 ////////////////////////////////////////////////////////////////////////////// | 179 ////////////////////////////////////////////////////////////////////////////// |
182 | 180 |
183 #ifndef SK_BUILD_FOR_ANDROID | 181 #ifndef SK_BUILD_FOR_ANDROID |
184 static GM* MyFactory(void*) { return new DrawBitmapRectGM; } | 182 static GM* MyFactory(void*) { return new DrawBitmapRectGM; } |
185 static GMRegistry reg(MyFactory); | 183 static GMRegistry reg(MyFactory); |
186 #endif | 184 #endif |
187 } | 185 } |
OLD | NEW |