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

Side by Side Diff: bench/MagnifierBench.cpp

Issue 322963002: hide SkBitmap::setConfig (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 6 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
« no previous file with comments | « bench/ImageCacheBench.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 "SkBitmapDevice.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkMagnifierImageFilter.h" 10 #include "SkMagnifierImageFilter.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 for (int i = 0; i < loops; i++) { 47 for (int i = 0; i < loops; i++) {
48 canvas->drawBitmap(fCheckerboard, 0, 0, &paint); 48 canvas->drawBitmap(fCheckerboard, 0, 0, &paint);
49 } 49 }
50 } 50 }
51 51
52 private: 52 private:
53 void make_checkerboard() { 53 void make_checkerboard() {
54 const int w = fIsSmall ? FILTER_WIDTH_SMALL : FILTER_WIDTH_LARGE; 54 const int w = fIsSmall ? FILTER_WIDTH_SMALL : FILTER_WIDTH_LARGE;
55 const int h = fIsSmall ? FILTER_HEIGHT_LARGE : FILTER_HEIGHT_LARGE; 55 const int h = fIsSmall ? FILTER_HEIGHT_LARGE : FILTER_HEIGHT_LARGE;
56 fCheckerboard.setConfig(SkBitmap::kARGB_8888_Config, w, h); 56 fCheckerboard.allocN32Pixels(w, h);
57 fCheckerboard.allocPixels(); 57 SkCanvas canvas(fCheckerboard);
58 SkBitmapDevice device(fCheckerboard);
59 SkCanvas canvas(&device);
60 canvas.clear(0x00000000); 58 canvas.clear(0x00000000);
61 SkPaint darkPaint; 59 SkPaint darkPaint;
62 darkPaint.setColor(0xFF804020); 60 darkPaint.setColor(0xFF804020);
63 SkPaint lightPaint; 61 SkPaint lightPaint;
64 lightPaint.setColor(0xFF244484); 62 lightPaint.setColor(0xFF244484);
65 for (int y = 0; y < h; y += 16) { 63 for (int y = 0; y < h; y += 16) {
66 for (int x = 0; x < w; x += 16) { 64 for (int x = 0; x < w; x += 16) {
67 canvas.save(); 65 canvas.save();
68 canvas.translate(SkIntToScalar(x), SkIntToScalar(y)); 66 canvas.translate(SkIntToScalar(x), SkIntToScalar(y));
69 canvas.drawRect(SkRect::MakeXYWH(0, 0, 8, 8), darkPaint); 67 canvas.drawRect(SkRect::MakeXYWH(0, 0, 8, 8), darkPaint);
70 canvas.drawRect(SkRect::MakeXYWH(8, 0, 8, 8), lightPaint); 68 canvas.drawRect(SkRect::MakeXYWH(8, 0, 8, 8), lightPaint);
71 canvas.drawRect(SkRect::MakeXYWH(0, 8, 8, 8), lightPaint); 69 canvas.drawRect(SkRect::MakeXYWH(0, 8, 8, 8), lightPaint);
72 canvas.drawRect(SkRect::MakeXYWH(8, 8, 8, 8), darkPaint); 70 canvas.drawRect(SkRect::MakeXYWH(8, 8, 8, 8), darkPaint);
73 canvas.restore(); 71 canvas.restore();
74 } 72 }
75 } 73 }
76 } 74 }
77 75
78 bool fIsSmall; 76 bool fIsSmall;
79 bool fInitialized; 77 bool fInitialized;
80 SkBitmap fCheckerboard; 78 SkBitmap fCheckerboard;
81 typedef SkBenchmark INHERITED; 79 typedef SkBenchmark INHERITED;
82 }; 80 };
83 81
84 /////////////////////////////////////////////////////////////////////////////// 82 ///////////////////////////////////////////////////////////////////////////////
85 83
86 DEF_BENCH( return new MagnifierBench(true); ) 84 DEF_BENCH( return new MagnifierBench(true); )
87 DEF_BENCH( return new MagnifierBench(false); ) 85 DEF_BENCH( return new MagnifierBench(false); )
OLDNEW
« no previous file with comments | « bench/ImageCacheBench.cpp ('k') | bench/MergeBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698