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

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

Issue 1239103002: Fix visual bench memory leak (Closed) Base URL: https://skia.googlesource.com/skia.git@fixvb1
Patch Set: tweaks Created 5 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 | « tools/VisualBench/VisualBench.cpp ('k') | 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
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 "GMBench.h" 10 #include "GMBench.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 SkDebugf("Could not read %s as an SkPicture.\n", path); 61 SkDebugf("Could not read %s as an SkPicture.\n", path);
62 return false; 62 return false;
63 } 63 }
64 return true; 64 return true;
65 } 65 }
66 66
67 Benchmark* VisualBenchmarkStream::next() { 67 Benchmark* VisualBenchmarkStream::next() {
68 Benchmark* bench; 68 Benchmark* bench;
69 // skips non matching benches 69 // skips non matching benches
70 while ((bench = this->innerNext()) && 70 while ((bench = this->innerNext()) &&
71 SkCommandLineFlags::ShouldSkip(FLAGS_match, bench->getUniqueName())) { 71 (SkCommandLineFlags::ShouldSkip(FLAGS_match, bench->getUniqueName()) ||
72 !bench->isSuitableFor(Benchmark::kGPU_Backend))) {
73 bench->unref();
72 } 74 }
73 return bench; 75 return bench;
74 } 76 }
75 77
76 Benchmark* VisualBenchmarkStream::innerNext() { 78 Benchmark* VisualBenchmarkStream::innerNext() {
77 while (fBenches) { 79 while (fBenches) {
78 Benchmark* bench = fBenches->factory()(NULL); 80 Benchmark* bench = fBenches->factory()(NULL);
79 fBenches = fBenches->next(); 81 fBenches = fBenches->next();
80 if (bench->isVisual()) { 82 if (bench->isVisual()) {
81 fSourceType = "bench"; 83 fSourceType = "bench";
82 fBenchType = "micro"; 84 fBenchType = "micro";
83 return bench; 85 return bench;
84 } 86 }
87 bench->unref();
85 } 88 }
86 89
87 while (fGMs) { 90 while (fGMs) {
88 SkAutoTDelete<skiagm::GM> gm(fGMs->factory()(NULL)); 91 SkAutoTDelete<skiagm::GM> gm(fGMs->factory()(NULL));
89 fGMs = fGMs->next(); 92 fGMs = fGMs->next();
90 if (gm->runAsBench()) { 93 if (gm->runAsBench()) {
91 fSourceType = "gm"; 94 fSourceType = "gm";
92 fBenchType = "micro"; 95 fBenchType = "micro";
93 return SkNEW_ARGS(GMBench, (gm.detach())); 96 return SkNEW_ARGS(GMBench, (gm.detach()));
94 } 97 }
95 } 98 }
96 99
97 // Render skps 100 // Render skps
98 while (fCurrentSKP < fSKPs.count()) { 101 while (fCurrentSKP < fSKPs.count()) {
99 const SkString& path = fSKPs[fCurrentSKP++]; 102 const SkString& path = fSKPs[fCurrentSKP++];
100 SkAutoTUnref<SkPicture> pic; 103 SkAutoTUnref<SkPicture> pic;
101 if (!ReadPicture(path.c_str(), &pic)) { 104 if (!ReadPicture(path.c_str(), &pic)) {
102 continue; 105 continue;
103 } 106 }
104 107
105 SkString name = SkOSPath::Basename(path.c_str()); 108 SkString name = SkOSPath::Basename(path.c_str());
106 fSourceType = "skp"; 109 fSourceType = "skp";
107 fBenchType = "playback"; 110 fBenchType = "playback";
108 return SkNEW_ARGS(VisualSKPBench, (name.c_str(), pic.get())); 111 return SkNEW_ARGS(VisualSKPBench, (name.c_str(), pic.get()));
109 } 112 }
110 113
111 return NULL; 114 return NULL;
112 } 115 }
OLDNEW
« no previous file with comments | « tools/VisualBench/VisualBench.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698