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

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: remove comment 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
« no previous file with comments | « no previous file | 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"
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;
16 20
17 static SkPicture* inspect(const char path[]) { 21 static SkPicture* inspect(const char path[]) {
18 SkFILEStream stream(path); 22 SkFILEStream stream(path);
19 if (!stream.isValid()) { 23 if (!stream.isValid()) {
20 printf("-- Can't open '%s'\n", path); 24 printf("-- Can't open '%s'\n", path);
21 return NULL; 25 return NULL;
22 } 26 }
23 27
24 printf("Opening '%s'...\n", path); 28 printf("Opening '%s'...\n", path);
25 29
26 { 30 {
27 int32_t header[3]; 31 int32_t header[3];
28 if (stream.read(header, sizeof(header)) != sizeof(header)) { 32 if (stream.read(header, sizeof(header)) != sizeof(header)) {
29 printf("-- Failed to read header (12 bytes)\n"); 33 printf("-- Failed to read header (12 bytes)\n");
30 return NULL; 34 return NULL;
31 } 35 }
32 printf("version:%d width:%d height:%d\n", header[0], header[1], header[2 ]); 36 printf("version:%d width:%d height:%d\n", header[0], header[1], header[2 ]);
33 } 37 }
34 38
35 stream.rewind(); 39 stream.rewind();
36 SkPicture* pic = SkNEW_ARGS(SkPicture, (&stream)); 40 bool success = false;
41 SkPicture* pic = SkNEW_ARGS(SkPicture, (&stream, &success, &SkImageDecoder:: DecodeMemory));
42 if (!success) {
43 SkDebugf("Could not create SkPicture");
caryclark 2013/06/12 12:03:11 include the path that failed in the printf, and te
sglez 2013/06/12 15:37:36 Done.
44 return pic;
45 }
37 printf("picture size:[%d %d]\n", pic->width(), pic->height()); 46 printf("picture size:[%d %d]\n", pic->width(), pic->height());
38 return pic; 47 return pic;
39 } 48 }
40 49
41 static void dumpOps(SkPicture* pic) { 50 static void dumpOps(SkPicture* pic) {
42 #ifdef SK_DEVELOPER 51 #ifdef SK_DEVELOPER
43 SkDebugfDumper dumper; 52 SkDebugfDumper dumper;
44 SkDumpCanvas canvas(&dumper); 53 SkDumpCanvas canvas(&dumper);
45 canvas.drawPicture(*pic); 54 canvas.drawPicture(*pic);
46 #else 55 #else
47 printf("SK_DEVELOPER mode not enabled\n"); 56 printf("SK_DEVELOPER mode not enabled\n");
48 #endif 57 #endif
49 } 58 }
50 59
51 int tool_main(int argc, char** argv); 60 int tool_main(int argc, char** argv);
52 int tool_main(int argc, char** argv) { 61 int tool_main(int argc, char** argv) {
62 SkAutoGraphics ag;
53 if (argc < 2) { 63 if (argc < 2) {
54 printf("Usage: pinspect [--dump-ops] filename [filename ...]\n"); 64 printf("Usage: pinspect [--dump-ops] filename [filename ...]\n");
55 return 1; 65 return 1;
56 } 66 }
57 67
58 bool doDumpOps = false; 68 bool doDumpOps = false;
59 69
60 int index = 1; 70 int index = 1;
61 if (!strcmp(argv[index], "--dump-ops")) { 71 if (!strcmp(argv[index], "--dump-ops")) {
62 index += 1; 72 index += 1;
(...skipping 10 matching lines...) Expand all
73 } 83 }
74 } 84 }
75 return 0; 85 return 0;
76 } 86 }
77 87
78 #if !defined SK_BUILD_FOR_IOS 88 #if !defined SK_BUILD_FOR_IOS
79 int main(int argc, char * const argv[]) { 89 int main(int argc, char * const argv[]) {
80 return tool_main(argc, (char**) argv); 90 return tool_main(argc, (char**) argv);
81 } 91 }
82 #endif 92 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698