2 * Copyright 2012 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"
11 #include "SkGraphics.h"
13 #include "SkImageDecoder.h"
14 #include "SkPicture.h"
17 #include "SkDumpCanvas.h"
19 static SkPicture* inspect(const char path[]) {
20 SkFILEStream stream(path);
21 if (!stream.isValid()) {
22 printf("-- Can't open '%s'\n", path);
26 printf("Opening '%s'...\n", path);
30 if (stream.read(header, sizeof(header)) != sizeof(header)) {
31 printf("-- Failed to read header (12 bytes)\n");
34 printf("version:%d width:%d height:%d\n", header[0], header[1], header[2]);
38 SkPicture* pic = SkPicture::CreateFromStream(&stream, &sk_tools::LazyDecodeBitmap);
40 SkDebugf("Could not create SkPicture: %s\n", path);
43 printf("picture cullRect: [%f %f %f %f]\n",
44 pic->cullRect().fLeft, pic->cullRect().fTop,
45 pic->cullRect().fRight, pic->cullRect().fBottom);
49 static void dumpOps(SkPicture* pic) {
51 SkDebugfDumper dumper;
52 SkDumpCanvas canvas(&dumper);
53 canvas.drawPicture(pic);
55 printf("SK_DEVELOPER mode not enabled\n");
59 int tool_main(int argc, char** argv);
60 int tool_main(int argc, char** argv) {
63 printf("Usage: pinspect [--dump-ops] filename [filename ...]\n");
67 bool doDumpOps = false;
70 if (!strcmp(argv[index], "--dump-ops")) {
75 for (; index < argc; ++index) {
76 SkAutoTUnref<SkPicture> pic(inspect(argv[index]));
80 if (index < argc - 1) {
87 #if !defined SK_BUILD_FOR_IOS
88 int main(int argc, char * const argv[]) {
89 return tool_main(argc, (char**) argv);