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

Unified Diff: bench/MipMapBench.cpp

Issue 873293003: add bench for building mipmaps (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 11 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/MipMapBench.cpp
diff --git a/bench/MipMapBench.cpp b/bench/MipMapBench.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cb4658ae0f14b9958dd7848c53b43083d6607cd0
--- /dev/null
+++ b/bench/MipMapBench.cpp
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "Benchmark.h"
+#include "SkBitmap.h"
+#include "SkMipMap.h"
+
+class MipMapBench: public Benchmark {
+ SkBitmap fBitmap;
+
+public:
+ MipMapBench() {}
+
+protected:
+ bool isSuitableFor(Backend backend) SK_OVERRIDE {
+ return kNonRendering_Backend == backend;
+ }
+
+ const char* onGetName() SK_OVERRIDE { return "mipmap_build"; }
+
+ void onPreDraw() SK_OVERRIDE {
+ fBitmap.allocN32Pixels(1000, 1000, true);
+ fBitmap.eraseColor(SK_ColorWHITE); // so we don't read uninitialized memory
+ }
+
+ void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
+ for (int i = 0; i < loops; i++) {
+ SkMipMap::Build(fBitmap, NULL)->unref();
+ }
+ }
+
+private:
+ typedef Benchmark INHERITED;
+};
+
+DEF_BENCH( return new MipMapBench; )
« 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