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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | gyp/bench.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/WritePixelsBench.cpp
===================================================================
--- bench/WritePixelsBench.cpp (revision 0)
+++ bench/WritePixelsBench.cpp (revision 0)
@@ -0,0 +1,77 @@
+
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkBenchmark.h"
+#include "SkCanvas.h"
+#include "SkConfig8888.h"
+#include "SkString.h"
+
+class WritePixelsBench : public SkBenchmark {
+public:
+ WritePixelsBench(void* param, SkCanvas::Config8888 config)
+ : INHERITED(param)
+ , fConfig(config)
+ , fName("writepix") {
+ switch (config) {
+ case SkCanvas::kNative_Premul_Config8888:
+ fName.append("_native_PM");
+ break;
+ case SkCanvas::kNative_Unpremul_Config8888:
+ fName.append("_native_UPM");
+ break;
+ case SkCanvas::kBGRA_Premul_Config8888:
+ fName.append("_bgra_PM");
+ break;
+ case SkCanvas::kBGRA_Unpremul_Config8888:
+ fName.append("_bgra_UPM");
+ break;
+ case SkCanvas::kRGBA_Premul_Config8888:
+ fName.append("_rgba_PM");
+ break;
+ case SkCanvas::kRGBA_Unpremul_Config8888:
+ fName.append("_rgba_UPM");
+ break;
+ default:
+ SK_CRASH();
+ break;
+ }
+ }
+
+protected:
+ virtual const char* onGetName() SK_OVERRIDE {
+ return fName.c_str();
+ }
+
+ virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ SkISize size = canvas->getDeviceSize();
+
+ canvas->clear(0xFFFF0000);
+
+ SkBitmap bmp;
+ bmp.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height());
+ canvas->readPixels(&bmp, 0, 0);
+
+ for (int loop = 0; loop < kLoopCount; ++loop) {
+ canvas->writePixels(bmp, 0, 0, fConfig);
+ }
+ }
+
+private:
+ static const int kLoopCount = SkBENCHLOOP(50);
+
+ SkCanvas::Config8888 fConfig;
+ SkString fName;
+
+ typedef SkBenchmark INHERITED;
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+DEF_BENCH( return SkNEW_ARGS(WritePixelsBench, (p, SkCanvas::kRGBA_Premul_Config8888)); )
+DEF_BENCH( return SkNEW_ARGS(WritePixelsBench, (p, SkCanvas::kRGBA_Unpremul_Config8888)); )
+
« 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