OLD | NEW |
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 "GrContextFactory.h" | 8 #include "GrContextFactory.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkOSFile.h" | 10 #include "SkOSFile.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 "using %i so there can be a true median.\n", | 179 "using %i so there can be a true median.\n", |
180 FLAGS_samples, FLAGS_samples + 1); | 180 FLAGS_samples, FLAGS_samples + 1); |
181 ++FLAGS_samples; | 181 ++FLAGS_samples; |
182 } | 182 } |
183 | 183 |
184 // Parse the config. | 184 // Parse the config. |
185 const SkCommandLineConfigGpu* config = nullptr; // Initialize for spurious w
arning. | 185 const SkCommandLineConfigGpu* config = nullptr; // Initialize for spurious w
arning. |
186 SkCommandLineConfigArray configs; | 186 SkCommandLineConfigArray configs; |
187 ParseConfigs(FLAGS_config, &configs); | 187 ParseConfigs(FLAGS_config, &configs); |
188 if (configs.count() != 1 || !(config = configs[0]->asConfigGpu())) { | 188 if (configs.count() != 1 || !(config = configs[0]->asConfigGpu())) { |
189 exitf(ExitErr::kUsage, "invalid config %s; must specify one (and only on
e) GPU config", | 189 exitf(ExitErr::kUsage, "invalid config %s, must specify one (and only on
e) GPU config", |
190 join(FLAGS_config).c_str()); | 190 join(FLAGS_config).c_str()); |
191 } | 191 } |
192 | 192 |
193 // Parse the skp. | 193 // Parse the skp. |
194 if (FLAGS_skp.count() != 1) { | 194 if (FLAGS_skp.count() != 1) { |
195 exitf(ExitErr::kUsage, "invalid skp \"%s\"; one (and only one) skp must
be specified.", | 195 exitf(ExitErr::kUsage, "invalid skp %s, must specify (and only one) skp
path name.", |
196 join(FLAGS_skp).c_str()); | 196 join(FLAGS_skp).c_str()); |
197 } | 197 } |
198 const char* skpfile = FLAGS_skp[0]; | 198 const char* skpfile = FLAGS_skp[0]; |
199 std::unique_ptr<SkStream> skpstream(SkStream::MakeFromFile(skpfile)); | 199 std::unique_ptr<SkStream> skpstream(SkStream::MakeFromFile(skpfile)); |
200 if (!skpstream) { | 200 if (!skpstream) { |
201 exitf(ExitErr::kIO, "failed to open skp file %s", skpfile); | 201 exitf(ExitErr::kIO, "failed to open skp file %s", skpfile); |
202 } | 202 } |
203 sk_sp<SkPicture> skp = SkPicture::MakeFromStream(skpstream.get()); | 203 sk_sp<SkPicture> skp = SkPicture::MakeFromStream(skpstream.get()); |
204 if (!skp) { | 204 if (!skp) { |
205 exitf(ExitErr::kData, "failed to parse skp file %s", skpfile); | 205 exitf(ExitErr::kData, "failed to parse skp file %s", skpfile); |
206 } | 206 } |
207 int width = SkTMin(SkScalarCeilToInt(skp->cullRect().width()), 2048), | 207 int width = SkTMin(SkScalarCeilToInt(skp->cullRect().width()), 2048), |
208 height = SkTMin(SkScalarCeilToInt(skp->cullRect().height()), 2048); | 208 height = SkTMin(SkScalarCeilToInt(skp->cullRect().height()), 2048); |
209 if (FLAGS_verbosity >= 2 && | 209 if (FLAGS_verbosity >= 3 && |
210 (width != skp->cullRect().width() || height != skp->cullRect().height())
) { | 210 (width != skp->cullRect().width() || height != skp->cullRect().height())
) { |
211 fprintf(stderr, "NOTE: %s is too large (%ix%i); cropping to %ix%i.\n", | 211 fprintf(stderr, "%s is too large (%ix%i), cropping to %ix%i.\n", |
212 skpfile, SkScalarCeilToInt(skp->cullRect().width()), | 212 SkOSPath::Basename(skpfile).c_str(), |
| 213 SkScalarCeilToInt(skp->cullRect().width()), |
213 SkScalarCeilToInt(skp->cullRect().height()), width, heig
ht); | 214 SkScalarCeilToInt(skp->cullRect().height()), width, heig
ht); |
214 } | 215 } |
215 | 216 |
216 // Create a context. | 217 // Create a context. |
217 sk_gpu_test::GrContextFactory factory; | 218 sk_gpu_test::GrContextFactory factory; |
218 sk_gpu_test::ContextInfo ctxInfo = | 219 sk_gpu_test::ContextInfo ctxInfo = |
219 factory.getContextInfo(config->getContextType(), config->getContextOptio
ns()); | 220 factory.getContextInfo(config->getContextType(), config->getContextOptio
ns()); |
220 GrContext* ctx = ctxInfo.grContext(); | 221 GrContext* ctx = ctxInfo.grContext(); |
221 if (!ctx) { | 222 if (!ctx) { |
222 exitf(ExitErr::kUnavailable, "failed to create context for config %s", | 223 exitf(ExitErr::kUnavailable, "failed to create context for config %s", |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 | 318 |
318 static void exitf(ExitErr err, const char* format, ...) { | 319 static void exitf(ExitErr err, const char* format, ...) { |
319 fprintf(stderr, ExitErr::kSoftware == err ? "INTERNAL ERROR: " : "ERROR: "); | 320 fprintf(stderr, ExitErr::kSoftware == err ? "INTERNAL ERROR: " : "ERROR: "); |
320 va_list args; | 321 va_list args; |
321 va_start(args, format); | 322 va_start(args, format); |
322 vfprintf(stderr, format, args); | 323 vfprintf(stderr, format, args); |
323 va_end(args); | 324 va_end(args); |
324 fprintf(stderr, ExitErr::kSoftware == err ? "; this should never happen.\n":
".\n"); | 325 fprintf(stderr, ExitErr::kSoftware == err ? "; this should never happen.\n":
".\n"); |
325 exit((int)err); | 326 exit((int)err); |
326 } | 327 } |
OLD | NEW |