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 #include "SkBenchmark.h" | 7 #include "SkBenchmark.h" |
| 8 #include "SkBitmapDevice.h" |
8 #include "SkBitmapSource.h" | 9 #include "SkBitmapSource.h" |
9 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
10 #include "SkDevice.h" | |
11 #include "SkMergeImageFilter.h" | 11 #include "SkMergeImageFilter.h" |
12 | 12 |
13 #define FILTER_WIDTH_SMALL SkIntToScalar(32) | 13 #define FILTER_WIDTH_SMALL SkIntToScalar(32) |
14 #define FILTER_HEIGHT_SMALL SkIntToScalar(32) | 14 #define FILTER_HEIGHT_SMALL SkIntToScalar(32) |
15 #define FILTER_WIDTH_LARGE SkIntToScalar(256) | 15 #define FILTER_WIDTH_LARGE SkIntToScalar(256) |
16 #define FILTER_HEIGHT_LARGE SkIntToScalar(256) | 16 #define FILTER_HEIGHT_LARGE SkIntToScalar(256) |
17 | 17 |
18 class MergeBench : public SkBenchmark { | 18 class MergeBench : public SkBenchmark { |
19 public: | 19 public: |
20 MergeBench(void* param, bool small) : INHERITED(param), fIsSmall(small), fIn
itialized(false) { | 20 MergeBench(void* param, bool small) : INHERITED(param), fIsSmall(small), fIn
itialized(false) { |
(...skipping 25 matching lines...) Expand all Loading... |
46 SkImageFilter* first = new SkBitmapSource(fCheckerboard); | 46 SkImageFilter* first = new SkBitmapSource(fCheckerboard); |
47 SkImageFilter* second = new SkBitmapSource(fBitmap); | 47 SkImageFilter* second = new SkBitmapSource(fBitmap); |
48 SkAutoUnref aur0(first); | 48 SkAutoUnref aur0(first); |
49 SkAutoUnref aur1(second); | 49 SkAutoUnref aur1(second); |
50 return new SkMergeImageFilter(first, second); | 50 return new SkMergeImageFilter(first, second); |
51 } | 51 } |
52 | 52 |
53 void make_bitmap() { | 53 void make_bitmap() { |
54 fBitmap.setConfig(SkBitmap::kARGB_8888_Config, 80, 80); | 54 fBitmap.setConfig(SkBitmap::kARGB_8888_Config, 80, 80); |
55 fBitmap.allocPixels(); | 55 fBitmap.allocPixels(); |
56 SkDevice device(fBitmap); | 56 SkBitmapDevice device(fBitmap); |
57 SkCanvas canvas(&device); | 57 SkCanvas canvas(&device); |
58 canvas.clear(0x00000000); | 58 canvas.clear(0x00000000); |
59 SkPaint paint; | 59 SkPaint paint; |
60 paint.setAntiAlias(true); | 60 paint.setAntiAlias(true); |
61 paint.setColor(0xFF884422); | 61 paint.setColor(0xFF884422); |
62 paint.setTextSize(SkIntToScalar(96)); | 62 paint.setTextSize(SkIntToScalar(96)); |
63 const char* str = "g"; | 63 const char* str = "g"; |
64 canvas.drawText(str, strlen(str), SkIntToScalar(15), SkIntToScalar(55),
paint); | 64 canvas.drawText(str, strlen(str), SkIntToScalar(15), SkIntToScalar(55),
paint); |
65 } | 65 } |
66 | 66 |
67 void make_checkerboard() { | 67 void make_checkerboard() { |
68 fCheckerboard.setConfig(SkBitmap::kARGB_8888_Config, 80, 80); | 68 fCheckerboard.setConfig(SkBitmap::kARGB_8888_Config, 80, 80); |
69 fCheckerboard.allocPixels(); | 69 fCheckerboard.allocPixels(); |
70 SkDevice device(fCheckerboard); | 70 SkBitmapDevice device(fCheckerboard); |
71 SkCanvas canvas(&device); | 71 SkCanvas canvas(&device); |
72 canvas.clear(0x00000000); | 72 canvas.clear(0x00000000); |
73 SkPaint darkPaint; | 73 SkPaint darkPaint; |
74 darkPaint.setColor(0xFF804020); | 74 darkPaint.setColor(0xFF804020); |
75 SkPaint lightPaint; | 75 SkPaint lightPaint; |
76 lightPaint.setColor(0xFF244484); | 76 lightPaint.setColor(0xFF244484); |
77 for (int y = 0; y < 80; y += 16) { | 77 for (int y = 0; y < 80; y += 16) { |
78 for (int x = 0; x < 80; x += 16) { | 78 for (int x = 0; x < 80; x += 16) { |
79 canvas.save(); | 79 canvas.save(); |
80 canvas.translate(SkIntToScalar(x), SkIntToScalar(y)); | 80 canvas.translate(SkIntToScalar(x), SkIntToScalar(y)); |
(...skipping 10 matching lines...) Expand all Loading... |
91 bool fInitialized; | 91 bool fInitialized; |
92 SkBitmap fBitmap, fCheckerboard; | 92 SkBitmap fBitmap, fCheckerboard; |
93 | 93 |
94 typedef SkBenchmark INHERITED; | 94 typedef SkBenchmark INHERITED; |
95 }; | 95 }; |
96 | 96 |
97 /////////////////////////////////////////////////////////////////////////////// | 97 /////////////////////////////////////////////////////////////////////////////// |
98 | 98 |
99 DEF_BENCH( return new MergeBench(p, true); ) | 99 DEF_BENCH( return new MergeBench(p, true); ) |
100 DEF_BENCH( return new MergeBench(p, false); ) | 100 DEF_BENCH( return new MergeBench(p, false); ) |
OLD | NEW |