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

Unified Diff: bench/TileImageFilterBench.cpp

Issue 1559403003: Add a bench to test SkTileImageFilter. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove more useless crud Created 4 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/TileImageFilterBench.cpp
diff --git a/bench/TileImageFilterBench.cpp b/bench/TileImageFilterBench.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..949baea6d716c9a7511377a095ad0ab7da799167
--- /dev/null
+++ b/bench/TileImageFilterBench.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2016 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 "SkTileImageFilter.h"
+#include "SkCanvas.h"
+#include "SkPaint.h"
+#include "SkString.h"
+
+#define WIDTH 512
+#define HEIGHT 512
+
+
robertphillips 2016/01/05 20:45:48 // This bench is interesting because ... ? I'm as
Stephen White 2016/01/05 20:50:09 Done.
+class TileImageFilterBench : public Benchmark {
+public:
+ TileImageFilterBench(int tileSize) : fTileSize(tileSize) {
+ if (tileSize > 0) {
+ fName.printf("tile_image_filter_tiled_%d", tileSize);
+ } else {
+ fName.printf("tile_image_filter");
+ }
+ }
+
+protected:
+ const char* onGetName() override {
+ return fName.c_str();
+ }
+
+ void onDraw(int loops, SkCanvas* canvas) override {
+ SkPaint paint;
+ SkAutoTUnref<SkImageFilter> tile(SkTileImageFilter::Create(
+ SkRect::MakeWH(50, 50),
+ SkRect::MakeWH(WIDTH, HEIGHT),
+ nullptr));
+ paint.setImageFilter(tile);
+
+ for (int i = 0; i < loops; i++) {
+ if (fTileSize > 0) {
+ for (int y = 0; y < HEIGHT; y += fTileSize) {
+ for (int x = 0; x < WIDTH; x += fTileSize) {
+ canvas->save();
+ canvas->clipRect(SkRect::MakeXYWH(x, y, fTileSize, fTileSize));
+ canvas->drawRect(SkRect::MakeWH(WIDTH, HEIGHT), paint);
+ canvas->restore();
+ }
+ }
+ } else {
+ canvas->drawRect(SkRect::MakeWH(WIDTH, HEIGHT), paint);
+ }
+ }
+ }
+
+private:
+ SkString fName;
+ // Note: this is the tile size used for tiled rendering, not for the size
+ // of the SkTileImageFilter source rect.
+ int fTileSize;
+ typedef Benchmark INHERITED;
+};
+
+DEF_BENCH(return new TileImageFilterBench(0);)
+DEF_BENCH(return new TileImageFilterBench(32);)
+DEF_BENCH(return new TileImageFilterBench(64);)
« 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