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

Side by Side Diff: tools/kilobench/kilobench.cpp

Issue 1811703002: return pictures as sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rely on RVO in picturerecorder Created 4 years, 9 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/gpuveto.cpp ('k') | tools/lua/lua_pictures.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 2016 Google Inc. 2 * Copyright 2016 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 "GrCaps.h" 8 #include "GrCaps.h"
9 #include "GrContextFactory.h" 9 #include "GrContextFactory.h"
10 #include "Benchmark.h" 10 #include "Benchmark.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 // skips non matching benches 97 // skips non matching benches
98 while ((bench = this->innerNext()) && 98 while ((bench = this->innerNext()) &&
99 (SkCommandLineFlags::ShouldSkip(FLAGS_match, bench->getUniqueName ()) || 99 (SkCommandLineFlags::ShouldSkip(FLAGS_match, bench->getUniqueName ()) ||
100 !bench->isSuitableFor(Benchmark::kGPU_Backend))) { 100 !bench->isSuitableFor(Benchmark::kGPU_Backend))) {
101 delete bench; 101 delete bench;
102 } 102 }
103 return bench; 103 return bench;
104 } 104 }
105 105
106 private: 106 private:
107 static bool ReadPicture(const char* path, SkAutoTUnref<SkPicture>* pic) { 107 static sk_sp<SkPicture> 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 return SkPicture::MakeFromStream(stream.get());
121 if (pic->get() == nullptr) {
122 SkDebugf("Could not read %s as an SkPicture.\n", path);
123 return false;
124 }
125 return true;
126 } 121 }
127 122
128 Benchmark* innerNext() { 123 Benchmark* innerNext() {
129 // Render skps 124 // Render skps
130 while (fCurrentSKP < fSKPs.count()) { 125 while (fCurrentSKP < fSKPs.count()) {
131 const SkString& path = fSKPs[fCurrentSKP++]; 126 const SkString& path = fSKPs[fCurrentSKP++];
132 SkAutoTUnref<SkPicture> pic; 127 auto pic = ReadPicture(path.c_str());
133 if (!ReadPicture(path.c_str(), &pic)) { 128 if (!pic) {
134 continue; 129 continue;
135 } 130 }
136 131
137 SkString name = SkOSPath::Basename(path.c_str()); 132 SkString name = SkOSPath::Basename(path.c_str());
138 return new VisualSKPBench(name.c_str(), pic.get()); 133 return new VisualSKPBench(name.c_str(), pic.get());
139 } 134 }
140 135
141 return nullptr; 136 return nullptr;
142 } 137 }
143 138
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 } 645 }
651 return 0; 646 return 0;
652 } 647 }
653 648
654 #if !defined SK_BUILD_FOR_IOS 649 #if !defined SK_BUILD_FOR_IOS
655 int main(int argc, char** argv) { 650 int main(int argc, char** argv) {
656 SkCommandLineFlags::Parse(argc, argv); 651 SkCommandLineFlags::Parse(argc, argv);
657 return kilobench_main(); 652 return kilobench_main();
658 } 653 }
659 #endif 654 #endif
OLDNEW
« no previous file with comments | « tools/gpuveto.cpp ('k') | tools/lua/lua_pictures.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698