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

Side by Side Diff: bench/WritePixelsBench.cpp

Issue 22895012: added WritePixelsBench (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: fixed Mac bug Created 7 years, 4 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 | « no previous file | gyp/bench.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1
2 /*
3 * Copyright 2013 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9 #include "SkBenchmark.h"
10 #include "SkCanvas.h"
11 #include "SkConfig8888.h"
12 #include "SkString.h"
13
14 class WritePixelsBench : public SkBenchmark {
15 public:
16 WritePixelsBench(void* param, SkCanvas::Config8888 config)
17 : INHERITED(param)
18 , fConfig(config)
19 , fName("writepix") {
20 switch (config) {
21 case SkCanvas::kNative_Premul_Config8888:
22 fName.append("_native_PM");
23 break;
24 case SkCanvas::kNative_Unpremul_Config8888:
25 fName.append("_native_UPM");
26 break;
27 case SkCanvas::kBGRA_Premul_Config8888:
28 fName.append("_bgra_PM");
29 break;
30 case SkCanvas::kBGRA_Unpremul_Config8888:
31 fName.append("_bgra_UPM");
32 break;
33 case SkCanvas::kRGBA_Premul_Config8888:
34 fName.append("_rgba_PM");
35 break;
36 case SkCanvas::kRGBA_Unpremul_Config8888:
37 fName.append("_rgba_UPM");
38 break;
39 default:
40 SK_CRASH();
41 break;
42 }
43 }
44
45 protected:
46 virtual const char* onGetName() SK_OVERRIDE {
47 return fName.c_str();
48 }
49
50 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
51 SkISize size = canvas->getDeviceSize();
52
53 canvas->clear(0xFFFF0000);
54
55 SkBitmap bmp;
56 bmp.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height());
57 canvas->readPixels(&bmp, 0, 0);
58
59 for (int loop = 0; loop < kLoopCount; ++loop) {
60 canvas->writePixels(bmp, 0, 0, fConfig);
61 }
62 }
63
64 private:
65 static const int kLoopCount = SkBENCHLOOP(50);
66
67 SkCanvas::Config8888 fConfig;
68 SkString fName;
69
70 typedef SkBenchmark INHERITED;
71 };
72
73 //////////////////////////////////////////////////////////////////////////////
74
75 DEF_BENCH( return SkNEW_ARGS(WritePixelsBench, (p, SkCanvas::kRGBA_Premul_Config 8888)); )
76 DEF_BENCH( return SkNEW_ARGS(WritePixelsBench, (p, SkCanvas::kRGBA_Unpremul_Conf ig8888)); )
77
OLDNEW
« no previous file with comments | « no previous file | gyp/bench.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698