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

Side by Side Diff: bench/DisplacementBench.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/CoverageBench.cpp ('k') | bench/GameBench.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 "SkBitmapSource.h" 9 #include "SkBitmapSource.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 15 matching lines...) Expand all
26 if (!fInitialized) { 26 if (!fInitialized) {
27 this->makeBitmap(); 27 this->makeBitmap();
28 this->makeCheckerboard(); 28 this->makeCheckerboard();
29 fInitialized = true; 29 fInitialized = true;
30 } 30 }
31 } 31 }
32 32
33 void makeBitmap() { 33 void makeBitmap() {
34 const int w = this->isSmall() ? FILTER_WIDTH_SMALL : FILTER_WIDTH_LARGE; 34 const int w = this->isSmall() ? FILTER_WIDTH_SMALL : FILTER_WIDTH_LARGE;
35 const int h = this->isSmall() ? FILTER_HEIGHT_LARGE : FILTER_HEIGHT_LARG E; 35 const int h = this->isSmall() ? FILTER_HEIGHT_LARGE : FILTER_HEIGHT_LARG E;
36 fBitmap.setConfig(SkBitmap::kARGB_8888_Config, w, h); 36 fBitmap.allocN32Pixels(w, h);
37 fBitmap.allocPixels(); 37 SkCanvas canvas(fBitmap);
38 SkBitmapDevice device(fBitmap);
39 SkCanvas canvas(&device);
40 canvas.clear(0x00000000); 38 canvas.clear(0x00000000);
41 SkPaint paint; 39 SkPaint paint;
42 paint.setAntiAlias(true); 40 paint.setAntiAlias(true);
43 paint.setColor(0xFF884422); 41 paint.setColor(0xFF884422);
44 paint.setTextSize(SkIntToScalar(96)); 42 paint.setTextSize(SkIntToScalar(96));
45 const char* str = "g"; 43 const char* str = "g";
46 canvas.drawText(str, strlen(str), SkIntToScalar(15), SkIntToScalar(55), paint); 44 canvas.drawText(str, strlen(str), SkIntToScalar(15), SkIntToScalar(55), paint);
47 } 45 }
48 46
49 void makeCheckerboard() { 47 void makeCheckerboard() {
50 const int w = this->isSmall() ? FILTER_WIDTH_SMALL : FILTER_WIDTH_LARGE; 48 const int w = this->isSmall() ? FILTER_WIDTH_SMALL : FILTER_WIDTH_LARGE;
51 const int h = this->isSmall() ? FILTER_HEIGHT_LARGE : FILTER_HEIGHT_LARG E; 49 const int h = this->isSmall() ? FILTER_HEIGHT_LARGE : FILTER_HEIGHT_LARG E;
52 fCheckerboard.setConfig(SkBitmap::kARGB_8888_Config, w, h); 50 fCheckerboard.allocN32Pixels(w, h);
53 fCheckerboard.allocPixels(); 51 SkCanvas canvas(fCheckerboard);
54 SkBitmapDevice device(fCheckerboard);
55 SkCanvas canvas(&device);
56 canvas.clear(0x00000000); 52 canvas.clear(0x00000000);
57 SkPaint darkPaint; 53 SkPaint darkPaint;
58 darkPaint.setColor(0xFF804020); 54 darkPaint.setColor(0xFF804020);
59 SkPaint lightPaint; 55 SkPaint lightPaint;
60 lightPaint.setColor(0xFF244484); 56 lightPaint.setColor(0xFF244484);
61 for (int y = 0; y < h; y += 16) { 57 for (int y = 0; y < h; y += 16) {
62 for (int x = 0; x < w; x += 16) { 58 for (int x = 0; x < w; x += 16) {
63 canvas.save(); 59 canvas.save();
64 canvas.translate(SkIntToScalar(x), SkIntToScalar(y)); 60 canvas.translate(SkIntToScalar(x), SkIntToScalar(y));
65 canvas.drawRect(SkRect::MakeXYWH(0, 0, 8, 8), darkPaint); 61 canvas.drawRect(SkRect::MakeXYWH(0, 0, 8, 8), darkPaint);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 }; 165 };
170 166
171 /////////////////////////////////////////////////////////////////////////////// 167 ///////////////////////////////////////////////////////////////////////////////
172 168
173 DEF_BENCH( return new DisplacementZeroBench(true); ) 169 DEF_BENCH( return new DisplacementZeroBench(true); )
174 DEF_BENCH( return new DisplacementAlphaBench(true); ) 170 DEF_BENCH( return new DisplacementAlphaBench(true); )
175 DEF_BENCH( return new DisplacementFullBench(true); ) 171 DEF_BENCH( return new DisplacementFullBench(true); )
176 DEF_BENCH( return new DisplacementZeroBench(false); ) 172 DEF_BENCH( return new DisplacementZeroBench(false); )
177 DEF_BENCH( return new DisplacementAlphaBench(false); ) 173 DEF_BENCH( return new DisplacementAlphaBench(false); )
178 DEF_BENCH( return new DisplacementFullBench(false); ) 174 DEF_BENCH( return new DisplacementFullBench(false); )
OLDNEW
« no previous file with comments | « bench/CoverageBench.cpp ('k') | bench/GameBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698