aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-31 15:41:37 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-31 15:41:37 +0000
commitb1d47e211c95779ed283b78a85abbd0bd5668871 (patch)
tree74eeb0f01c0c2286b346d9c33d7854505f8dda08
parent4258c2c9b88ebbe51c6f65bc9e0c047ca9c7fccb (diff)
add --dump-ops option to pinspect, which will invoke SkDumpCanvas on the picture(s)
git-svn-id: http://skia.googlecode.com/svn/trunk@5370 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--tools/pinspect.cpp38
1 files changed, 29 insertions, 9 deletions
diff --git a/tools/pinspect.cpp b/tools/pinspect.cpp
index 0105734bfe..cec2013add 100644
--- a/tools/pinspect.cpp
+++ b/tools/pinspect.cpp
@@ -12,12 +12,13 @@
#include "SkPicture.h"
#include "SkStream.h"
#include "SkString.h"
+#include "SkDumpCanvas.h"
-static void inspect(const char path[]) {
+static SkPicture* inspect(const char path[]) {
SkFILEStream stream(path);
if (!stream.isValid()) {
printf("-- Can't open '%s'\n", path);
- return;
+ return NULL;
}
printf("Opening '%s'...\n", path);
@@ -26,23 +27,42 @@ static void inspect(const char path[]) {
int32_t header[3];
if (stream.read(header, sizeof(header)) != sizeof(header)) {
printf("-- Failed to read header (12 bytes)\n");
- return;
+ return NULL;
}
printf("version:%d width:%d height:%d\n", header[0], header[1], header[2]);
}
stream.rewind();
- SkPicture pic(&stream);
- printf("picture size:[%d %d]\n", pic.width(), pic.height());
+ SkPicture* pic = SkNEW_ARGS(SkPicture, (&stream));
+ printf("picture size:[%d %d]\n", pic->width(), pic->height());
+ return pic;
+}
+
+static void dumpOps(SkPicture* pic) {
+ SkDebugfDumper dumper;
+ SkDumpCanvas canvas(&dumper);
+ canvas.drawPicture(*pic);
}
int main(int argc, char* const argv[]) {
if (argc < 2) {
- printf("Usage: pinspect filename [filename ...]\n");
+ printf("Usage: pinspect [--dump_ops] filename [filename ...]\n");
}
- for (int i = 1; i < argc; ++i) {
- inspect(argv[i]);
- if (i < argc - 1) {
+
+ bool doDumpOps = false;
+
+ int index = 1;
+ if (!strcmp(argv[index], "--dump-ops")) {
+ index += 1;
+ doDumpOps = true;
+ }
+
+ for (; index < argc; ++index) {
+ SkAutoTUnref<SkPicture> pic(inspect(argv[index]));
+ if (doDumpOps) {
+ dumpOps(pic);
+ }
+ if (index < argc - 1) {
printf("\n");
}
}