| OLD | NEW |
| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 fGMs = nullptr; | 97 fGMs = nullptr; |
| 98 fBenches = nullptr; | 98 fBenches = nullptr; |
| 99 } | 99 } |
| 100 | 100 |
| 101 // seed with an initial benchmark | 101 // seed with an initial benchmark |
| 102 // NOTE the initial benchmark will not have preTimingHooks called, but that
is okay because | 102 // NOTE the initial benchmark will not have preTimingHooks called, but that
is okay because |
| 103 // it is the warmupbench | 103 // it is the warmupbench |
| 104 this->next(); | 104 this->next(); |
| 105 } | 105 } |
| 106 | 106 |
| 107 bool VisualBenchmarkStream::ReadPicture(const char* path, SkAutoTUnref<SkPicture
>* pic) { | 107 sk_sp<SkPicture> VisualBenchmarkStream::ReadPicture(const char path[]) { |
| 108 // Not strictly necessary, as it will be checked again later, | 108 // Not strictly necessary, as it will be checked again later, |
| 109 // but helps to avoid a lot of pointless work if we're going to skip it. | 109 // but helps to avoid a lot of pointless work if we're going to skip it. |
| 110 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path)) { | 110 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path)) { |
| 111 return false; | 111 return nullptr; |
| 112 } | 112 } |
| 113 | 113 |
| 114 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(path)); | 114 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(path)); |
| 115 if (stream.get() == nullptr) { | 115 if (stream.get() == nullptr) { |
| 116 SkDebugf("Could not read %s.\n", path); | 116 SkDebugf("Could not read %s.\n", path); |
| 117 return false; | 117 return nullptr; |
| 118 } | 118 } |
| 119 | 119 |
| 120 pic->reset(SkPicture::CreateFromStream(stream.get())); | 120 auto pic = SkPicture::MakeFromStream(stream.get()); |
| 121 if (pic->get() == nullptr) { | 121 if (!pic) { |
| 122 SkDebugf("Could not read %s as an SkPicture.\n", path); | 122 SkDebugf("Could not read %s as an SkPicture.\n", path); |
| 123 return false; | |
| 124 } | 123 } |
| 125 return true; | 124 return pic; |
| 126 } | 125 } |
| 127 | 126 |
| 128 Benchmark* VisualBenchmarkStream::next() { | 127 Benchmark* VisualBenchmarkStream::next() { |
| 129 Benchmark* bench; | 128 Benchmark* bench; |
| 130 if (FLAGS_warmup && !fIsWarmedUp) { | 129 if (FLAGS_warmup && !fIsWarmedUp) { |
| 131 fIsWarmedUp = true; | 130 fIsWarmedUp = true; |
| 132 bench = new WarmupBench; | 131 bench = new WarmupBench; |
| 133 } else { | 132 } else { |
| 134 // skips non matching benches | 133 // skips non matching benches |
| 135 while ((bench = this->innerNext()) && | 134 while ((bench = this->innerNext()) && |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 if (gm->runAsBench()) { | 167 if (gm->runAsBench()) { |
| 169 fSourceType = "gm"; | 168 fSourceType = "gm"; |
| 170 fBenchType = "micro"; | 169 fBenchType = "micro"; |
| 171 return new GMBench(gm.release()); | 170 return new GMBench(gm.release()); |
| 172 } | 171 } |
| 173 } | 172 } |
| 174 | 173 |
| 175 // Render skps | 174 // Render skps |
| 176 while (fCurrentSKP < fSKPs.count()) { | 175 while (fCurrentSKP < fSKPs.count()) { |
| 177 const SkString& path = fSKPs[fCurrentSKP++]; | 176 const SkString& path = fSKPs[fCurrentSKP++]; |
| 178 SkAutoTUnref<SkPicture> pic; | 177 sk_sp<SkPicture> pic = ReadPicture(path.c_str()); |
| 179 if (!ReadPicture(path.c_str(), &pic)) { | 178 if (!pic) { |
| 180 continue; | 179 continue; |
| 181 } | 180 } |
| 182 | 181 |
| 183 SkString name = SkOSPath::Basename(path.c_str()); | 182 SkString name = SkOSPath::Basename(path.c_str()); |
| 184 fSourceType = "skp"; | 183 fSourceType = "skp"; |
| 185 fBenchType = "playback"; | 184 fBenchType = "playback"; |
| 186 return new VisualSKPBench(name.c_str(), pic.get()); | 185 return new VisualSKPBench(name.c_str(), pic.get()); |
| 187 } | 186 } |
| 188 | 187 |
| 189 return nullptr; | 188 return nullptr; |
| 190 } | 189 } |
| OLD | NEW |