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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | 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 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "Benchmark.h"
9 #include "SkTileImageFilter.h"
10 #include "SkCanvas.h"
11 #include "SkPaint.h"
12 #include "SkString.h"
13
14 #define WIDTH 512
15 #define HEIGHT 512
16
17
robertphillips 2016/01/05 20:45:48 // This bench is interesting because ... ? I'm as
Stephen White 2016/01/05 20:50:09 Done.
18 class TileImageFilterBench : public Benchmark {
19 public:
20 TileImageFilterBench(int tileSize) : fTileSize(tileSize) {
21 if (tileSize > 0) {
22 fName.printf("tile_image_filter_tiled_%d", tileSize);
23 } else {
24 fName.printf("tile_image_filter");
25 }
26 }
27
28 protected:
29 const char* onGetName() override {
30 return fName.c_str();
31 }
32
33 void onDraw(int loops, SkCanvas* canvas) override {
34 SkPaint paint;
35 SkAutoTUnref<SkImageFilter> tile(SkTileImageFilter::Create(
36 SkRect::MakeWH(50, 50),
37 SkRect::MakeWH(WIDTH, HEIGHT),
38 nullptr));
39 paint.setImageFilter(tile);
40
41 for (int i = 0; i < loops; i++) {
42 if (fTileSize > 0) {
43 for (int y = 0; y < HEIGHT; y += fTileSize) {
44 for (int x = 0; x < WIDTH; x += fTileSize) {
45 canvas->save();
46 canvas->clipRect(SkRect::MakeXYWH(x, y, fTileSize, fTile Size));
47 canvas->drawRect(SkRect::MakeWH(WIDTH, HEIGHT), paint);
48 canvas->restore();
49 }
50 }
51 } else {
52 canvas->drawRect(SkRect::MakeWH(WIDTH, HEIGHT), paint);
53 }
54 }
55 }
56
57 private:
58 SkString fName;
59 // Note: this is the tile size used for tiled rendering, not for the size
60 // of the SkTileImageFilter source rect.
61 int fTileSize;
62 typedef Benchmark INHERITED;
63 };
64
65 DEF_BENCH(return new TileImageFilterBench(0);)
66 DEF_BENCH(return new TileImageFilterBench(32);)
67 DEF_BENCH(return new TileImageFilterBench(64);)
OLDNEW
« 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