2 * Copyright 2014 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #include "LazyDecodeBitmap.h"
9 #include "SkCommandLineFlags.h"
10 #include "SkPicture.h"
11 #include "SkPictureRecorder.h"
14 DEFINE_string2(readFile, r, "", "skp file to process.");
15 DEFINE_bool2(quiet, q, false, "quiet");
17 // This tool just loads a single skp, replays into a new SkPicture (to
18 // regenerate the GPU-specific tracking information) and reports
19 // the value of the suitableForGpuRasterization method.
21 static const int kSuccess = 0;
22 static const int kError = 1;
24 int tool_main(int argc, char** argv);
25 int tool_main(int argc, char** argv) {
27 SkCommandLineFlags::SetUsage("Reports on an skp file's suitability for GPU rasterization");
28 SkCommandLineFlags::Parse(argc, argv);
30 if (FLAGS_readFile.count() != 1) {
32 SkDebugf("Missing input file\n");
37 SkFILEStream inputStream(FLAGS_readFile[0]);
38 if (!inputStream.isValid()) {
40 SkDebugf("Couldn't open file\n");
45 SkPicture::InstallPixelRefProc proc = &sk_tools::LazyDecodeBitmap;
47 SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(&inputStream, proc));
48 if (NULL == picture.get()) {
50 SkDebugf("Could not read the SkPicture\n");
55 // The SkPicture tracking information is only generated during recording
56 // an isn't serialized. Replay the picture to regenerated the tracking data.
57 SkPictureRecorder recorder;
58 picture->playback(recorder.beginRecording(picture->cullRect().width(),
59 picture->cullRect().height(),
61 SkAutoTUnref<SkPicture> recorded(recorder.endRecording());
63 if (recorded->suitableForGpuRasterization(NULL)) {
64 SkDebugf("suitable\n");
66 SkDebugf("unsuitable\n");
71 SkDebugf("gpuveto is only useful when GPU rendering is enabled\n");
76 #if !defined SK_BUILD_FOR_IOS
77 int main(int argc, char * const argv[]) {
78 return tool_main(argc, (char**) argv);