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

Side by Side Diff: bench/ImageFilterDAGBench.cpp

Issue 359473004: draft gpu support in nanobench (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: winders Created 6 years, 5 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 | bench/nanobench.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "Benchmark.h" 8 #include "Benchmark.h"
9 #include "SkBlurImageFilter.h" 9 #include "SkBlurImageFilter.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
11 #include "SkMergeImageFilter.h" 11 #include "SkMergeImageFilter.h"
12 12
13 enum { kNumInputs = 5 }; 13 enum { kNumInputs = 5 };
14 14
15 // Exercise a blur filter connected to 5 inputs of the same merge filter. 15 // Exercise a blur filter connected to 5 inputs of the same merge filter.
16 // This bench shows an improvement in performance once cacheing of re-used 16 // This bench shows an improvement in performance once cacheing of re-used
17 // nodes is implemented, since the DAG is no longer flattened to a tree. 17 // nodes is implemented, since the DAG is no longer flattened to a tree.
18 18
19 class ImageFilterDAGBench : public Benchmark { 19 class ImageFilterDAGBench : public Benchmark {
20 public: 20 public:
21 ImageFilterDAGBench() { 21 ImageFilterDAGBench() {}
22 }
23 22
24 protected: 23 protected:
25 virtual const char* onGetName() SK_OVERRIDE { 24 virtual const char* onGetName() SK_OVERRIDE {
26 return "image_filter_dag"; 25 return "image_filter_dag";
27 } 26 }
28 27
29 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { 28 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
30 SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create(20.0f, 20.0f) ); 29 for (int j = 0; j < loops; j++) {
31 SkImageFilter* inputs[kNumInputs]; 30 SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create(20.0f, 20 .0f));
32 for (int i = 0; i < kNumInputs; ++i) { 31 SkImageFilter* inputs[kNumInputs];
33 inputs[i] = blur.get(); 32 for (int i = 0; i < kNumInputs; ++i) {
33 inputs[i] = blur.get();
34 }
35 SkAutoTUnref<SkImageFilter> merge(SkMergeImageFilter::Create(inputs, kNumInputs));
36 SkPaint paint;
37 paint.setImageFilter(merge);
38 SkRect rect = SkRect::Make(SkIRect::MakeWH(400, 400));
39 canvas->drawRect(rect, paint);
34 } 40 }
35 SkAutoTUnref<SkImageFilter> merge(SkMergeImageFilter::Create(inputs, kNu mInputs));
36 SkPaint paint;
37 paint.setImageFilter(merge);
38 SkRect rect = SkRect::Make(SkIRect::MakeWH(400, 400));
39 canvas->drawRect(rect, paint);
40 } 41 }
41 42
42 private: 43 private:
43 typedef Benchmark INHERITED; 44 typedef Benchmark INHERITED;
44 }; 45 };
45 46
46 DEF_BENCH(return new ImageFilterDAGBench;) 47 DEF_BENCH(return new ImageFilterDAGBench;)
OLDNEW
« no previous file with comments | « no previous file | bench/nanobench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698