Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1026)

Side by Side Diff: tools/pinspect.cpp

Issue 16034015: Use image decoding in pinspect (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Use lazy decoder. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« gyp/tools.gyp ('K') | « gyp/tools.gyp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
9 #include "SkBitmap.h" 8 #include "SkBitmap.h"
10 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkGraphics.h"
11 #include "SkOSFile.h" 11 #include "SkOSFile.h"
12 #include "SkImageDecoder.h"
scroggo 2013/06/12 16:10:05 I don't think this is needed now that you're not p
12 #include "SkPicture.h" 13 #include "SkPicture.h"
13 #include "SkStream.h" 14 #include "SkStream.h"
14 #include "SkString.h" 15 #include "SkString.h"
15 #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 );
16 23
17 static SkPicture* inspect(const char path[]) { 24 static SkPicture* inspect(const char path[]) {
18 SkFILEStream stream(path); 25 SkFILEStream stream(path);
19 if (!stream.isValid()) { 26 if (!stream.isValid()) {
20 printf("-- Can't open '%s'\n", path); 27 printf("-- Can't open '%s'\n", path);
21 return NULL; 28 return NULL;
22 } 29 }
23 30
24 printf("Opening '%s'...\n", path); 31 printf("Opening '%s'...\n", path);
25 32
26 { 33 {
27 int32_t header[3]; 34 int32_t header[3];
28 if (stream.read(header, sizeof(header)) != sizeof(header)) { 35 if (stream.read(header, sizeof(header)) != sizeof(header)) {
29 printf("-- Failed to read header (12 bytes)\n"); 36 printf("-- Failed to read header (12 bytes)\n");
30 return NULL; 37 return NULL;
31 } 38 }
32 printf("version:%d width:%d height:%d\n", header[0], header[1], header[2 ]); 39 printf("version:%d width:%d height:%d\n", header[0], header[1], header[2 ]);
33 } 40 }
34 41
35 stream.rewind(); 42 stream.rewind();
36 SkPicture* pic = SkNEW_ARGS(SkPicture, (&stream)); 43 bool success = false;
44 SkPicture* pic = SkNEW_ARGS(SkPicture, (&stream, &success, &lazy_decode_bitm ap));
45 if (!success) {
46 SkDebugf("Could not create SkPicture: %s\n", path);
47 return pic;
48 }
37 printf("picture size:[%d %d]\n", pic->width(), pic->height()); 49 printf("picture size:[%d %d]\n", pic->width(), pic->height());
38 return pic; 50 return pic;
39 } 51 }
40 52
41 static void dumpOps(SkPicture* pic) { 53 static void dumpOps(SkPicture* pic) {
42 #ifdef SK_DEVELOPER 54 #ifdef SK_DEVELOPER
43 SkDebugfDumper dumper; 55 SkDebugfDumper dumper;
44 SkDumpCanvas canvas(&dumper); 56 SkDumpCanvas canvas(&dumper);
45 canvas.drawPicture(*pic); 57 canvas.drawPicture(*pic);
46 #else 58 #else
47 printf("SK_DEVELOPER mode not enabled\n"); 59 printf("SK_DEVELOPER mode not enabled\n");
48 #endif 60 #endif
49 } 61 }
50 62
51 int tool_main(int argc, char** argv); 63 int tool_main(int argc, char** argv);
52 int tool_main(int argc, char** argv) { 64 int tool_main(int argc, char** argv) {
65 SkAutoGraphics ag;
53 if (argc < 2) { 66 if (argc < 2) {
54 printf("Usage: pinspect [--dump-ops] filename [filename ...]\n"); 67 printf("Usage: pinspect [--dump-ops] filename [filename ...]\n");
55 return 1; 68 return 1;
56 } 69 }
57 70
58 bool doDumpOps = false; 71 bool doDumpOps = false;
59 72
60 int index = 1; 73 int index = 1;
61 if (!strcmp(argv[index], "--dump-ops")) { 74 if (!strcmp(argv[index], "--dump-ops")) {
62 index += 1; 75 index += 1;
(...skipping 10 matching lines...) Expand all
73 } 86 }
74 } 87 }
75 return 0; 88 return 0;
76 } 89 }
77 90
78 #if !defined SK_BUILD_FOR_IOS 91 #if !defined SK_BUILD_FOR_IOS
79 int main(int argc, char * const argv[]) { 92 int main(int argc, char * const argv[]) {
80 return tool_main(argc, (char**) argv); 93 return tool_main(argc, (char**) argv);
81 } 94 }
82 #endif 95 #endif
OLDNEW
« gyp/tools.gyp ('K') | « gyp/tools.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698