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

Unified Diff: bench/ImageBench.cpp

Issue 1261663004: add bench for gpu-image -> cpu-surface (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/ImageBench.cpp
diff --git a/bench/ImageBench.cpp b/bench/ImageBench.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e3fe230353ec907f738f12516e30822ef7c0450f
--- /dev/null
+++ b/bench/ImageBench.cpp
@@ -0,0 +1,57 @@
+/*
+ * 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 "SkCanvas.h"
+#include "SkImage.h"
+#include "SkSurface.h"
+
+class GPU2RasterImageBench : public Benchmark {
+public:
+ GPU2RasterImageBench() {
+ fName.set("gpu2raster_image");
+ }
+
+ bool isSuitableFor(Backend backend) override {
+ return kGPU_Backend == backend;
+ }
+
+protected:
+ const char* onGetName() override {
+ return fName.c_str();
+ }
+
+ void onPerCanvasPreDraw(SkCanvas* canvas) override {
+ // create a gpu-backed Image
+ SkImageInfo info = SkImageInfo::MakeN32Premul(500, 500);
+ SkAutoTUnref<SkSurface> surface(canvas->newSurface(info));
+ canvas->drawColor(SK_ColorRED);
+ fGpuImage.reset(surface->newImageSnapshot());
+
+ // create a cpu-backed Surface
+ fRasterSurface.reset(SkSurface::NewRaster(info));
+ }
+
+ void onDraw(const int loops, SkCanvas*) override {
+ // Time drawing a gpu-image into a raster-surface
+ for (int i = 0; i < loops; i++) {
+ for (int inner = 0; inner < 10; ++inner) {
+ fRasterSurface->getCanvas()->drawImage(fGpuImage, 0, 0);
+ }
+ }
+ }
+
+private:
+ SkString fName;
+ SkAutoTUnref<SkImage> fGpuImage;
+ SkAutoTUnref<SkSurface> fRasterSurface;
+
+ typedef Benchmark INHERITED;
+};
+
+
+DEF_BENCH( return new GPU2RasterImageBench; )
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698