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

Side by Side Diff: bench/DecodeBench.cpp

Issue 23876006: Refactoring: get rid of the SkBenchmark void* parameter. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: sync to head 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/DashBench.cpp ('k') | bench/DeferredCanvasBench.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SkBenchmark.h" 8 #include "SkBenchmark.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCommandLineFlags.h" 10 #include "SkCommandLineFlags.h"
11 #include "SkImageDecoder.h" 11 #include "SkImageDecoder.h"
12 #include "SkString.h" 12 #include "SkString.h"
13 13
14 DEFINE_string(decodeBenchFilename, "resources/CMYK.jpeg", "Path to image for Dec odeBench."); 14 DEFINE_string(decodeBenchFilename, "resources/CMYK.jpeg", "Path to image for Dec odeBench.");
15 15
16 static const char* gConfigName[] = { 16 static const char* gConfigName[] = {
17 "ERROR", "a1", "a8", "index8", "565", "4444", "8888" 17 "ERROR", "a1", "a8", "index8", "565", "4444", "8888"
18 }; 18 };
19 19
20 class DecodeBench : public SkBenchmark { 20 class DecodeBench : public SkBenchmark {
21 SkBitmap::Config fPrefConfig; 21 SkBitmap::Config fPrefConfig;
22 SkString fName; 22 SkString fName;
23 public: 23 public:
24 DecodeBench(void* param, SkBitmap::Config c) : SkBenchmark(param) { 24 DecodeBench(SkBitmap::Config c) {
25 fPrefConfig = c; 25 fPrefConfig = c;
26 26
27 const char* fname = strrchr(FLAGS_decodeBenchFilename[0], '/'); 27 const char* fname = strrchr(FLAGS_decodeBenchFilename[0], '/');
28 if (fname) { 28 if (fname) {
29 fname++; // skip the slash 29 fname++; // skip the slash
30 } 30 }
31 fName.printf("decode_%s_%s", gConfigName[c], fname); 31 fName.printf("decode_%s_%s", gConfigName[c], fname);
32 fIsRendering = false; 32 fIsRendering = false;
33 } 33 }
34 34
35 protected: 35 protected:
36 virtual const char* onGetName() { 36 virtual const char* onGetName() {
37 return fName.c_str(); 37 return fName.c_str();
38 } 38 }
39 39
40 virtual void onDraw(SkCanvas*) { 40 virtual void onDraw(SkCanvas*) {
41 for (int i = 0; i < this->getLoops(); i++) { 41 for (int i = 0; i < this->getLoops(); i++) {
42 SkBitmap bm; 42 SkBitmap bm;
43 SkImageDecoder::DecodeFile(FLAGS_decodeBenchFilename[0], 43 SkImageDecoder::DecodeFile(FLAGS_decodeBenchFilename[0],
44 &bm, 44 &bm,
45 fPrefConfig, 45 fPrefConfig,
46 SkImageDecoder::kDecodePixels_Mode); 46 SkImageDecoder::kDecodePixels_Mode);
47 } 47 }
48 } 48 }
49 49
50 private: 50 private:
51 typedef SkBenchmark INHERITED; 51 typedef SkBenchmark INHERITED;
52 }; 52 };
53 53
54 static SkBenchmark* Fact0(void* p) { return new DecodeBench(p, SkBitmap::kARGB_8 888_Config); } 54 DEF_BENCH( return new DecodeBench(SkBitmap::kARGB_8888_Config); )
55 static SkBenchmark* Fact1(void* p) { return new DecodeBench(p, SkBitmap::kRGB_56 5_Config); } 55 DEF_BENCH( return new DecodeBench(SkBitmap::kRGB_565_Config); )
56 static SkBenchmark* Fact2(void* p) { return new DecodeBench(p, SkBitmap::kARGB_4 444_Config); } 56 DEF_BENCH( return new DecodeBench(SkBitmap::kARGB_4444_Config); )
57
58 static BenchRegistry gReg0(Fact0);
59 static BenchRegistry gReg1(Fact1);
60 static BenchRegistry gReg2(Fact2);
OLDNEW
« no previous file with comments | « bench/DashBench.cpp ('k') | bench/DeferredCanvasBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698