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 #include "SkDisplacementMapEffect.h" | 9 #include "SkDisplacementMapEffect.h" |
10 #include "SkBitmapSource.h" | 10 #include "SkBitmapSource.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 make_bitmap(); | 26 make_bitmap(); |
27 make_checkerboard(&fCheckerboard, 80, 80); | 27 make_checkerboard(&fCheckerboard, 80, 80); |
28 make_checkerboard(&fSmall, 64, 64); | 28 make_checkerboard(&fSmall, 64, 64); |
29 make_checkerboard(&fLarge, 96, 96); | 29 make_checkerboard(&fLarge, 96, 96); |
30 make_checkerboard(&fLargeW, 96, 64); | 30 make_checkerboard(&fLargeW, 96, 64); |
31 make_checkerboard(&fLargeH, 64, 96); | 31 make_checkerboard(&fLargeH, 64, 96); |
32 } | 32 } |
33 | 33 |
34 void make_bitmap() { | 34 void make_bitmap() { |
35 fBitmap.allocN32Pixels(80, 80); | 35 fBitmap.allocN32Pixels(80, 80); |
36 SkCanvas canvas(fBitmap); | 36 SkBitmapDevice device(fBitmap); |
| 37 SkCanvas canvas(&device); |
37 canvas.clear(0x00000000); | 38 canvas.clear(0x00000000); |
38 SkPaint paint; | 39 SkPaint paint; |
39 paint.setAntiAlias(true); | 40 paint.setAntiAlias(true); |
40 paint.setColor(0xFF884422); | 41 paint.setColor(0xFF884422); |
41 paint.setTextSize(SkIntToScalar(96)); | 42 paint.setTextSize(SkIntToScalar(96)); |
42 const char* str = "g"; | 43 const char* str = "g"; |
43 canvas.drawText(str, strlen(str), SkIntToScalar(15), SkIntToScalar(55),
paint); | 44 canvas.drawText(str, strlen(str), SkIntToScalar(15), SkIntToScalar(55),
paint); |
44 } | 45 } |
45 | 46 |
46 void make_checkerboard(SkBitmap* bitmap, int w, int h) { | 47 void make_checkerboard(SkBitmap* bitmap, int w, int h) { |
47 bitmap->allocN32Pixels(w, h); | 48 bitmap->allocN32Pixels(w, h); |
48 SkCanvas canvas(*bitmap); | 49 SkBitmapDevice device(*bitmap); |
| 50 SkCanvas canvas(&device); |
49 canvas.clear(0x00000000); | 51 canvas.clear(0x00000000); |
50 SkPaint darkPaint; | 52 SkPaint darkPaint; |
51 darkPaint.setColor(0xFF804020); | 53 darkPaint.setColor(0xFF804020); |
52 SkPaint lightPaint; | 54 SkPaint lightPaint; |
53 lightPaint.setColor(0xFF244484); | 55 lightPaint.setColor(0xFF244484); |
54 for (int y = 0; y < h; y += 16) { | 56 for (int y = 0; y < h; y += 16) { |
55 for (int x = 0; x < w; x += 16) { | 57 for (int x = 0; x < w; x += 16) { |
56 canvas.save(); | 58 canvas.save(); |
57 canvas.translate(SkIntToScalar(x), SkIntToScalar(y)); | 59 canvas.translate(SkIntToScalar(x), SkIntToScalar(y)); |
58 canvas.drawRect(SkRect::MakeXYWH(0, 0, 8, 8), darkPaint); | 60 canvas.drawRect(SkRect::MakeXYWH(0, 0, 8, 8), darkPaint); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 SkBitmap fBitmap, fCheckerboard, fSmall, fLarge, fLargeW, fLargeH; | 222 SkBitmap fBitmap, fCheckerboard, fSmall, fLarge, fLargeW, fLargeH; |
221 bool fInitialized; | 223 bool fInitialized; |
222 }; | 224 }; |
223 | 225 |
224 ////////////////////////////////////////////////////////////////////////////// | 226 ////////////////////////////////////////////////////////////////////////////// |
225 | 227 |
226 static GM* MyFactory(void*) { return new DisplacementMapGM; } | 228 static GM* MyFactory(void*) { return new DisplacementMapGM; } |
227 static GMRegistry reg(MyFactory); | 229 static GMRegistry reg(MyFactory); |
228 | 230 |
229 } | 231 } |
OLD | NEW |