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 "SkImageDecoder.h" | 12 #include "SkImageDecoder.h" |
13 #include "SkPicture.h" | 13 #include "SkPicture.h" |
14 #include "SkStream.h" | 14 #include "SkStream.h" |
15 #include "SkString.h" | 15 #include "SkString.h" |
16 #include "SkDumpCanvas.h" | 16 #include "SkDumpCanvas.h" |
17 #include "SkForceLinking.h" | |
18 | |
19 __SK_FORCE_IMAGE_DECODER_LINKING; | |
20 | |
21 // Defined in PictureRenderingFlags.cpp | |
22 extern bool lazy_decode_bitmap(const void* buffer, size_t size, SkBitmap* bitmap
); | |
23 | 17 |
24 static SkPicture* inspect(const char path[]) { | 18 static SkPicture* inspect(const char path[]) { |
25 SkFILEStream stream(path); | 19 SkFILEStream stream(path); |
26 if (!stream.isValid()) { | 20 if (!stream.isValid()) { |
27 printf("-- Can't open '%s'\n", path); | 21 printf("-- Can't open '%s'\n", path); |
28 return NULL; | 22 return NULL; |
29 } | 23 } |
30 | 24 |
31 printf("Opening '%s'...\n", path); | 25 printf("Opening '%s'...\n", path); |
32 | 26 |
33 { | 27 { |
34 int32_t header[3]; | 28 int32_t header[3]; |
35 if (stream.read(header, sizeof(header)) != sizeof(header)) { | 29 if (stream.read(header, sizeof(header)) != sizeof(header)) { |
36 printf("-- Failed to read header (12 bytes)\n"); | 30 printf("-- Failed to read header (12 bytes)\n"); |
37 return NULL; | 31 return NULL; |
38 } | 32 } |
39 printf("version:%d width:%d height:%d\n", header[0], header[1], header[2
]); | 33 printf("version:%d width:%d height:%d\n", header[0], header[1], header[2
]); |
40 } | 34 } |
41 | 35 |
42 stream.rewind(); | 36 stream.rewind(); |
43 SkPicture* pic = SkPicture::CreateFromStream(&stream, &lazy_decode_bitmap); | 37 SkPicture* pic = SkPicture::CreateFromStream(&stream, &SkImageDecoder::LazyD
ecodeBitmap); |
44 if (NULL == pic) { | 38 if (NULL == pic) { |
45 SkDebugf("Could not create SkPicture: %s\n", path); | 39 SkDebugf("Could not create SkPicture: %s\n", path); |
46 return NULL; | 40 return NULL; |
47 } | 41 } |
48 printf("picture size:[%d %d]\n", pic->width(), pic->height()); | 42 printf("picture size:[%d %d]\n", pic->width(), pic->height()); |
49 return pic; | 43 return pic; |
50 } | 44 } |
51 | 45 |
52 static void dumpOps(SkPicture* pic) { | 46 static void dumpOps(SkPicture* pic) { |
53 #ifdef SK_DEVELOPER | 47 #ifdef SK_DEVELOPER |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 } | 79 } |
86 } | 80 } |
87 return 0; | 81 return 0; |
88 } | 82 } |
89 | 83 |
90 #if !defined SK_BUILD_FOR_IOS | 84 #if !defined SK_BUILD_FOR_IOS |
91 int main(int argc, char * const argv[]) { | 85 int main(int argc, char * const argv[]) { |
92 return tool_main(argc, (char**) argv); | 86 return tool_main(argc, (char**) argv); |
93 } | 87 } |
94 #endif | 88 #endif |
OLD | NEW |