Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(820)

Side by Side Diff: bench/MagnifierBench.cpp

Issue 22978012: Split SkDevice into SkBaseDevice and SkBitmapDevice (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Updating to ToT (10994) Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « bench/DisplacementBench.cpp ('k') | bench/MergeBench.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkCanvas.h" 9 #include "SkCanvas.h"
9 #include "SkDevice.h"
10 #include "SkMagnifierImageFilter.h" 10 #include "SkMagnifierImageFilter.h"
11 #include "SkRandom.h" 11 #include "SkRandom.h"
12 12
13 #define FILTER_WIDTH_SMALL 32 13 #define FILTER_WIDTH_SMALL 32
14 #define FILTER_HEIGHT_SMALL 32 14 #define FILTER_HEIGHT_SMALL 32
15 #define FILTER_WIDTH_LARGE 256 15 #define FILTER_WIDTH_LARGE 256
16 #define FILTER_HEIGHT_LARGE 256 16 #define FILTER_HEIGHT_LARGE 256
17 17
18 class MagnifierBench : public SkBenchmark { 18 class MagnifierBench : public SkBenchmark {
19 public: 19 public:
(...skipping 25 matching lines...) Expand all
45 SkIntToScalar(h / 2)), 100))->unref(); 45 SkIntToScalar(h / 2)), 100))->unref();
46 canvas->drawBitmap(fCheckerboard, 0, 0, &paint); 46 canvas->drawBitmap(fCheckerboard, 0, 0, &paint);
47 } 47 }
48 48
49 private: 49 private:
50 void make_checkerboard() { 50 void make_checkerboard() {
51 const int w = fIsSmall ? FILTER_WIDTH_SMALL : FILTER_WIDTH_LARGE; 51 const int w = fIsSmall ? FILTER_WIDTH_SMALL : FILTER_WIDTH_LARGE;
52 const int h = fIsSmall ? FILTER_HEIGHT_LARGE : FILTER_HEIGHT_LARGE; 52 const int h = fIsSmall ? FILTER_HEIGHT_LARGE : FILTER_HEIGHT_LARGE;
53 fCheckerboard.setConfig(SkBitmap::kARGB_8888_Config, w, h); 53 fCheckerboard.setConfig(SkBitmap::kARGB_8888_Config, w, h);
54 fCheckerboard.allocPixels(); 54 fCheckerboard.allocPixels();
55 SkDevice device(fCheckerboard); 55 SkBitmapDevice device(fCheckerboard);
56 SkCanvas canvas(&device); 56 SkCanvas canvas(&device);
57 canvas.clear(0x00000000); 57 canvas.clear(0x00000000);
58 SkPaint darkPaint; 58 SkPaint darkPaint;
59 darkPaint.setColor(0xFF804020); 59 darkPaint.setColor(0xFF804020);
60 SkPaint lightPaint; 60 SkPaint lightPaint;
61 lightPaint.setColor(0xFF244484); 61 lightPaint.setColor(0xFF244484);
62 for (int y = 0; y < h; y += 16) { 62 for (int y = 0; y < h; y += 16) {
63 for (int x = 0; x < w; x += 16) { 63 for (int x = 0; x < w; x += 16) {
64 canvas.save(); 64 canvas.save();
65 canvas.translate(SkIntToScalar(x), SkIntToScalar(y)); 65 canvas.translate(SkIntToScalar(x), SkIntToScalar(y));
66 canvas.drawRect(SkRect::MakeXYWH(0, 0, 8, 8), darkPaint); 66 canvas.drawRect(SkRect::MakeXYWH(0, 0, 8, 8), darkPaint);
67 canvas.drawRect(SkRect::MakeXYWH(8, 0, 8, 8), lightPaint); 67 canvas.drawRect(SkRect::MakeXYWH(8, 0, 8, 8), lightPaint);
68 canvas.drawRect(SkRect::MakeXYWH(0, 8, 8, 8), lightPaint); 68 canvas.drawRect(SkRect::MakeXYWH(0, 8, 8, 8), lightPaint);
69 canvas.drawRect(SkRect::MakeXYWH(8, 8, 8, 8), darkPaint); 69 canvas.drawRect(SkRect::MakeXYWH(8, 8, 8, 8), darkPaint);
70 canvas.restore(); 70 canvas.restore();
71 } 71 }
72 } 72 }
73 } 73 }
74 74
75 bool fIsSmall; 75 bool fIsSmall;
76 bool fInitialized; 76 bool fInitialized;
77 SkBitmap fCheckerboard; 77 SkBitmap fCheckerboard;
78 typedef SkBenchmark INHERITED; 78 typedef SkBenchmark INHERITED;
79 }; 79 };
80 80
81 /////////////////////////////////////////////////////////////////////////////// 81 ///////////////////////////////////////////////////////////////////////////////
82 82
83 DEF_BENCH( return new MagnifierBench(p, true); ) 83 DEF_BENCH( return new MagnifierBench(p, true); )
84 DEF_BENCH( return new MagnifierBench(p, false); ) 84 DEF_BENCH( return new MagnifierBench(p, false); )
OLDNEW
« no previous file with comments | « bench/DisplacementBench.cpp ('k') | bench/MergeBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698