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 14 matching lines...) Expand all Loading... |
25 void make_bitmaps() { | 25 void make_bitmaps() { |
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.setConfig(SkBitmap::kARGB_8888_Config, 80, 80); | 35 fBitmap.allocN32Pixels(80, 80); |
36 fBitmap.allocPixels(); | |
37 SkBitmapDevice device(fBitmap); | 36 SkBitmapDevice device(fBitmap); |
38 SkCanvas canvas(&device); | 37 SkCanvas canvas(&device); |
39 canvas.clear(0x00000000); | 38 canvas.clear(0x00000000); |
40 SkPaint paint; | 39 SkPaint paint; |
41 paint.setAntiAlias(true); | 40 paint.setAntiAlias(true); |
42 paint.setColor(0xFF884422); | 41 paint.setColor(0xFF884422); |
43 paint.setTextSize(SkIntToScalar(96)); | 42 paint.setTextSize(SkIntToScalar(96)); |
44 const char* str = "g"; | 43 const char* str = "g"; |
45 canvas.drawText(str, strlen(str), SkIntToScalar(15), SkIntToScalar(55),
paint); | 44 canvas.drawText(str, strlen(str), SkIntToScalar(15), SkIntToScalar(55),
paint); |
46 } | 45 } |
47 | 46 |
48 void make_checkerboard(SkBitmap* bitmap, int w, int h) { | 47 void make_checkerboard(SkBitmap* bitmap, int w, int h) { |
49 bitmap->setConfig(SkBitmap::kARGB_8888_Config, w, h); | 48 bitmap->allocN32Pixels(w, h); |
50 bitmap->allocPixels(); | |
51 SkBitmapDevice device(*bitmap); | 49 SkBitmapDevice device(*bitmap); |
52 SkCanvas canvas(&device); | 50 SkCanvas canvas(&device); |
53 canvas.clear(0x00000000); | 51 canvas.clear(0x00000000); |
54 SkPaint darkPaint; | 52 SkPaint darkPaint; |
55 darkPaint.setColor(0xFF804020); | 53 darkPaint.setColor(0xFF804020); |
56 SkPaint lightPaint; | 54 SkPaint lightPaint; |
57 lightPaint.setColor(0xFF244484); | 55 lightPaint.setColor(0xFF244484); |
58 for (int y = 0; y < h; y += 16) { | 56 for (int y = 0; y < h; y += 16) { |
59 for (int x = 0; x < w; x += 16) { | 57 for (int x = 0; x < w; x += 16) { |
60 canvas.save(); | 58 canvas.save(); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 SkBitmap fBitmap, fCheckerboard, fSmall, fLarge, fLargeW, fLargeH; | 222 SkBitmap fBitmap, fCheckerboard, fSmall, fLarge, fLargeW, fLargeH; |
225 bool fInitialized; | 223 bool fInitialized; |
226 }; | 224 }; |
227 | 225 |
228 ////////////////////////////////////////////////////////////////////////////// | 226 ////////////////////////////////////////////////////////////////////////////// |
229 | 227 |
230 static GM* MyFactory(void*) { return new DisplacementMapGM; } | 228 static GM* MyFactory(void*) { return new DisplacementMapGM; } |
231 static GMRegistry reg(MyFactory); | 229 static GMRegistry reg(MyFactory); |
232 | 230 |
233 } | 231 } |
OLD | NEW |