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

Side by Side Diff: tools/VisualBench/VisualBenchmarkStream.cpp

Issue 1443263002: Optimize visualbench offscreen blits (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix msvc warnings Created 5 years 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 | tools/VisualBench/VisualSKPBench.h » ('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 2015 Google Inc. 2 * Copyright 2015 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 8
9 #include <VisualBench/VisualBenchmarkStream.h> 9 #include <VisualBench/VisualBenchmarkStream.h>
10 #include <VisualBench/WrappedBenchmark.h> 10 #include <VisualBench/WrappedBenchmark.h>
(...skipping 21 matching lines...) Expand all
32 "If a bench does not match any list entry,\n" 32 "If a bench does not match any list entry,\n"
33 "it is skipped unless some list entry starts with ~"); 33 "it is skipped unless some list entry starts with ~");
34 DEFINE_string(skps, "skps", "Directory to read skps from."); 34 DEFINE_string(skps, "skps", "Directory to read skps from.");
35 35
36 // We draw a big nonAA path to warmup the gpu / cpu 36 // We draw a big nonAA path to warmup the gpu / cpu
37 #include "SkPerlinNoiseShader.h" 37 #include "SkPerlinNoiseShader.h"
38 class WarmupBench : public Benchmark { 38 class WarmupBench : public Benchmark {
39 public: 39 public:
40 WarmupBench() { 40 WarmupBench() {
41 sk_tool_utils::make_big_path(fPath); 41 sk_tool_utils::make_big_path(fPath);
42 fPerlinRect = SkRect::MakeLTRB(0., 0., 400., 400.);
42 } 43 }
43 private: 44 private:
44 const char* onGetName() override { return "warmupbench"; } 45 const char* onGetName() override { return "warmupbench"; }
46 SkIPoint onGetSize() override {
47 int w = SkScalarCeilToInt(SkTMax(fPath.getBounds().right(), fPerlinRect. right()));
48 int h = SkScalarCeilToInt(SkTMax(fPath.getBounds().bottom(), fPerlinRect .bottom()));
49 return SkIPoint::Make(w, h);
50 }
45 void onDraw(int loops, SkCanvas* canvas) override { 51 void onDraw(int loops, SkCanvas* canvas) override {
46 // We draw a big path to warm up the cpu, and then use perlin noise shad er to warm up the 52 // We draw a big path to warm up the cpu, and then use perlin noise shad er to warm up the
47 // gpu 53 // gpu
48 SkPaint paint; 54 SkPaint paint;
49 paint.setStyle(SkPaint::kStroke_Style); 55 paint.setStyle(SkPaint::kStroke_Style);
50 paint.setStrokeWidth(2); 56 paint.setStrokeWidth(2);
51 57
52 SkPaint perlinPaint; 58 SkPaint perlinPaint;
53 perlinPaint.setShader(SkPerlinNoiseShader::CreateTurbulence(0.1f, 0.1f, 1, 0, 59 perlinPaint.setShader(SkPerlinNoiseShader::CreateTurbulence(0.1f, 0.1f, 1, 0,
54 nullptr))->u nref(); 60 nullptr))->u nref();
55 SkRect rect = SkRect::MakeLTRB(0., 0., 400., 400.);
56 for (int i = 0; i < loops; i++) { 61 for (int i = 0; i < loops; i++) {
57 canvas->drawPath(fPath, paint); 62 canvas->drawPath(fPath, paint);
58 canvas->drawRect(rect, perlinPaint); 63 canvas->drawRect(fPerlinRect, perlinPaint);
59 #if SK_SUPPORT_GPU 64 #if SK_SUPPORT_GPU
60 // Ensure the GrContext doesn't batch across draw loops. 65 // Ensure the GrContext doesn't batch across draw loops.
61 if (GrContext* context = canvas->getGrContext()) { 66 if (GrContext* context = canvas->getGrContext()) {
62 context->flush(); 67 context->flush();
63 } 68 }
64 #endif 69 #endif
65 } 70 }
66 } 71 }
67 SkPath fPath; 72 SkPath fPath;
73 SkRect fPerlinRect;
68 }; 74 };
69 75
70 VisualBenchmarkStream::VisualBenchmarkStream(const SkSurfaceProps& surfaceProps) 76 VisualBenchmarkStream::VisualBenchmarkStream(const SkSurfaceProps& surfaceProps)
71 : fSurfaceProps(surfaceProps) 77 : fSurfaceProps(surfaceProps)
72 , fBenches(BenchRegistry::Head()) 78 , fBenches(BenchRegistry::Head())
73 , fGMs(skiagm::GMRegistry::Head()) 79 , fGMs(skiagm::GMRegistry::Head())
74 , fSourceType(nullptr) 80 , fSourceType(nullptr)
75 , fBenchType(nullptr) 81 , fBenchType(nullptr)
76 , fCurrentSKP(0) 82 , fCurrentSKP(0)
77 , fIsWarmedUp(false) { 83 , fIsWarmedUp(false) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 } 176 }
171 177
172 SkString name = SkOSPath::Basename(path.c_str()); 178 SkString name = SkOSPath::Basename(path.c_str());
173 fSourceType = "skp"; 179 fSourceType = "skp";
174 fBenchType = "playback"; 180 fBenchType = "playback";
175 return new VisualSKPBench(name.c_str(), pic.get()); 181 return new VisualSKPBench(name.c_str(), pic.get());
176 } 182 }
177 183
178 return nullptr; 184 return nullptr;
179 } 185 }
OLDNEW
« no previous file with comments | « no previous file | tools/VisualBench/VisualSKPBench.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698