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

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

Issue 1427533002: Flush GrContext between benchmark draw loops (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Check for SK_SUPPORT_GPU Created 5 years, 1 month 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 | « samplecode/SampleApp.cpp ('k') | tools/VisualBench/VisualSKPBench.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 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>
11 #include "GMBench.h" 11 #include "GMBench.h"
12 #include "SkOSFile.h" 12 #include "SkOSFile.h"
13 #include "SkPath.h" 13 #include "SkPath.h"
14 #include "SkPictureRecorder.h" 14 #include "SkPictureRecorder.h"
15 #include "SkStream.h" 15 #include "SkStream.h"
16 #include "sk_tool_utils.h" 16 #include "sk_tool_utils.h"
17 #include "VisualFlags.h" 17 #include "VisualFlags.h"
18 #include "VisualSKPBench.h" 18 #include "VisualSKPBench.h"
19 19
20 #if SK_SUPPORT_GPU
21 #include "GrContext.h"
22 #endif
23
20 DEFINE_bool(cpu, false, "Run in CPU mode?"); 24 DEFINE_bool(cpu, false, "Run in CPU mode?");
21 DEFINE_string2(match, m, nullptr, 25 DEFINE_string2(match, m, nullptr,
22 "[~][^]substring[$] [...] of bench name to run.\n" 26 "[~][^]substring[$] [...] of bench name to run.\n"
23 "Multiple matches may be separated by spaces.\n" 27 "Multiple matches may be separated by spaces.\n"
24 "~ causes a matching bench to always be skipped\n" 28 "~ causes a matching bench to always be skipped\n"
25 "^ requires the start of the bench to match\n" 29 "^ requires the start of the bench to match\n"
26 "$ requires the end of the bench to match\n" 30 "$ requires the end of the bench to match\n"
27 "^ and $ requires an exact match\n" 31 "^ and $ requires an exact match\n"
28 "If a bench does not match any list entry,\n" 32 "If a bench does not match any list entry,\n"
29 "it is skipped unless some list entry starts with ~"); 33 "it is skipped unless some list entry starts with ~");
(...skipping 15 matching lines...) Expand all
45 paint.setStyle(SkPaint::kStroke_Style); 49 paint.setStyle(SkPaint::kStroke_Style);
46 paint.setStrokeWidth(2); 50 paint.setStrokeWidth(2);
47 51
48 SkPaint perlinPaint; 52 SkPaint perlinPaint;
49 perlinPaint.setShader(SkPerlinNoiseShader::CreateTurbulence(0.1f, 0.1f, 1, 0, 53 perlinPaint.setShader(SkPerlinNoiseShader::CreateTurbulence(0.1f, 0.1f, 1, 0,
50 nullptr))->u nref(); 54 nullptr))->u nref();
51 SkRect rect = SkRect::MakeLTRB(0., 0., 400., 400.); 55 SkRect rect = SkRect::MakeLTRB(0., 0., 400., 400.);
52 for (int i = 0; i < loops; i++) { 56 for (int i = 0; i < loops; i++) {
53 canvas->drawPath(fPath, paint); 57 canvas->drawPath(fPath, paint);
54 canvas->drawRect(rect, perlinPaint); 58 canvas->drawRect(rect, perlinPaint);
59 #if SK_SUPPORT_GPU
60 // Ensure the GrContext doesn't batch across draw loops.
61 if (GrContext* context = canvas->getGrContext()) {
62 context->flush();
63 }
64 #endif
55 } 65 }
56 } 66 }
57 SkPath fPath; 67 SkPath fPath;
58 }; 68 };
59 69
60 VisualBenchmarkStream::VisualBenchmarkStream() 70 VisualBenchmarkStream::VisualBenchmarkStream()
61 : fBenches(BenchRegistry::Head()) 71 : fBenches(BenchRegistry::Head())
62 , fGMs(skiagm::GMRegistry::Head()) 72 , fGMs(skiagm::GMRegistry::Head())
63 , fSourceType(nullptr) 73 , fSourceType(nullptr)
64 , fBenchType(nullptr) 74 , fBenchType(nullptr)
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } 169 }
160 170
161 SkString name = SkOSPath::Basename(path.c_str()); 171 SkString name = SkOSPath::Basename(path.c_str());
162 fSourceType = "skp"; 172 fSourceType = "skp";
163 fBenchType = "playback"; 173 fBenchType = "playback";
164 return new VisualSKPBench(name.c_str(), pic.get()); 174 return new VisualSKPBench(name.c_str(), pic.get());
165 } 175 }
166 176
167 return nullptr; 177 return nullptr;
168 } 178 }
OLDNEW
« no previous file with comments | « samplecode/SampleApp.cpp ('k') | tools/VisualBench/VisualSKPBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698