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