OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkGraphics.h" | 10 #include "SkGraphics.h" |
11 #include "SkOSFile.h" | 11 #include "SkOSFile.h" |
12 #include "SkPicture.h" | 12 #include "SkPicture.h" |
13 #include "SkStream.h" | 13 #include "SkStream.h" |
14 #include "SkString.h" | 14 #include "SkString.h" |
15 #include "SkDumpCanvas.h" | 15 #include "SkDumpCanvas.h" |
16 | 16 |
17 static SkPicture* inspect(const char path[]) { | 17 static sk_sp<SkPicture> inspect(const char path[]) { |
18 SkFILEStream stream(path); | 18 SkFILEStream stream(path); |
19 if (!stream.isValid()) { | 19 if (!stream.isValid()) { |
20 printf("-- Can't open '%s'\n", path); | 20 printf("-- Can't open '%s'\n", path); |
21 return nullptr; | 21 return nullptr; |
22 } | 22 } |
23 | 23 |
24 printf("Opening '%s'...\n", path); | 24 printf("Opening '%s'...\n", path); |
25 | 25 |
26 { | 26 { |
27 int32_t header[3]; | 27 int32_t header[3]; |
28 if (stream.read(header, sizeof(header)) != sizeof(header)) { | 28 if (stream.read(header, sizeof(header)) != sizeof(header)) { |
29 printf("-- Failed to read header (12 bytes)\n"); | 29 printf("-- Failed to read header (12 bytes)\n"); |
30 return nullptr; | 30 return nullptr; |
31 } | 31 } |
32 printf("version:%d width:%d height:%d\n", header[0], header[1], header[2
]); | 32 printf("version:%d width:%d height:%d\n", header[0], header[1], header[2
]); |
33 } | 33 } |
34 | 34 |
35 stream.rewind(); | 35 stream.rewind(); |
36 SkPicture* pic = SkPicture::CreateFromStream(&stream); | 36 auto pic = SkPicture::MakeFromStream(&stream); |
37 if (nullptr == pic) { | 37 if (nullptr == pic) { |
38 SkDebugf("Could not create SkPicture: %s\n", path); | 38 SkDebugf("Could not create SkPicture: %s\n", path); |
39 return nullptr; | 39 return nullptr; |
40 } | 40 } |
41 printf("picture cullRect: [%f %f %f %f]\n", | 41 printf("picture cullRect: [%f %f %f %f]\n", |
42 pic->cullRect().fLeft, pic->cullRect().fTop, | 42 pic->cullRect().fLeft, pic->cullRect().fTop, |
43 pic->cullRect().fRight, pic->cullRect().fBottom); | 43 pic->cullRect().fRight, pic->cullRect().fBottom); |
44 return pic; | 44 return pic; |
45 } | 45 } |
46 | 46 |
(...skipping 17 matching lines...) Expand all Loading... |
64 | 64 |
65 bool doDumpOps = false; | 65 bool doDumpOps = false; |
66 | 66 |
67 int index = 1; | 67 int index = 1; |
68 if (!strcmp(argv[index], "--dump-ops")) { | 68 if (!strcmp(argv[index], "--dump-ops")) { |
69 index += 1; | 69 index += 1; |
70 doDumpOps = true; | 70 doDumpOps = true; |
71 } | 71 } |
72 | 72 |
73 for (; index < argc; ++index) { | 73 for (; index < argc; ++index) { |
74 SkAutoTUnref<SkPicture> pic(inspect(argv[index])); | 74 auto pic(inspect(argv[index])); |
75 if (doDumpOps) { | 75 if (doDumpOps) { |
76 dumpOps(pic); | 76 dumpOps(pic.get()); |
77 } | 77 } |
78 if (index < argc - 1) { | 78 if (index < argc - 1) { |
79 printf("\n"); | 79 printf("\n"); |
80 } | 80 } |
81 } | 81 } |
82 return 0; | 82 return 0; |
83 } | 83 } |
84 | 84 |
85 #if !defined SK_BUILD_FOR_IOS | 85 #if !defined SK_BUILD_FOR_IOS |
86 int main(int argc, char * const argv[]) { | 86 int main(int argc, char * const argv[]) { |
87 return tool_main(argc, (char**) argv); | 87 return tool_main(argc, (char**) argv); |
88 } | 88 } |
89 #endif | 89 #endif |
OLD | NEW |