2012-06-14 18:58:40 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2012 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "SkBitmap.h"
|
|
|
|
#include "SkCanvas.h"
|
2013-06-12 18:28:36 +00:00
|
|
|
#include "SkGraphics.h"
|
2012-06-14 18:58:40 +00:00
|
|
|
#include "SkOSFile.h"
|
|
|
|
#include "SkPicture.h"
|
|
|
|
#include "SkStream.h"
|
|
|
|
#include "SkString.h"
|
2012-08-31 15:41:37 +00:00
|
|
|
#include "SkDumpCanvas.h"
|
2012-06-14 18:58:40 +00:00
|
|
|
|
2016-03-18 14:25:55 +00:00
|
|
|
static sk_sp<SkPicture> inspect(const char path[]) {
|
2012-06-14 18:58:40 +00:00
|
|
|
SkFILEStream stream(path);
|
|
|
|
if (!stream.isValid()) {
|
|
|
|
printf("-- Can't open '%s'\n", path);
|
2015-08-27 14:41:13 +00:00
|
|
|
return nullptr;
|
2012-06-14 18:58:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
printf("Opening '%s'...\n", path);
|
|
|
|
|
|
|
|
{
|
|
|
|
int32_t header[3];
|
|
|
|
if (stream.read(header, sizeof(header)) != sizeof(header)) {
|
|
|
|
printf("-- Failed to read header (12 bytes)\n");
|
2015-08-27 14:41:13 +00:00
|
|
|
return nullptr;
|
2012-06-14 18:58:40 +00:00
|
|
|
}
|
|
|
|
printf("version:%d width:%d height:%d\n", header[0], header[1], header[2]);
|
|
|
|
}
|
|
|
|
|
|
|
|
stream.rewind();
|
2016-03-18 14:25:55 +00:00
|
|
|
auto pic = SkPicture::MakeFromStream(&stream);
|
2015-08-27 14:41:13 +00:00
|
|
|
if (nullptr == pic) {
|
2013-06-12 18:28:36 +00:00
|
|
|
SkDebugf("Could not create SkPicture: %s\n", path);
|
2015-08-27 14:41:13 +00:00
|
|
|
return nullptr;
|
2013-06-12 18:28:36 +00:00
|
|
|
}
|
2016-03-29 16:03:52 +00:00
|
|
|
printf("picture cullRect: [%f %f %f %f]\n",
|
2014-08-29 15:03:56 +00:00
|
|
|
pic->cullRect().fLeft, pic->cullRect().fTop,
|
|
|
|
pic->cullRect().fRight, pic->cullRect().fBottom);
|
2012-08-31 15:41:37 +00:00
|
|
|
return pic;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dumpOps(SkPicture* pic) {
|
2013-01-15 20:17:47 +00:00
|
|
|
#ifdef SK_DEVELOPER
|
2012-08-31 15:41:37 +00:00
|
|
|
SkDebugfDumper dumper;
|
|
|
|
SkDumpCanvas canvas(&dumper);
|
2014-06-04 12:40:44 +00:00
|
|
|
canvas.drawPicture(pic);
|
2013-01-15 20:17:47 +00:00
|
|
|
#else
|
|
|
|
printf("SK_DEVELOPER mode not enabled\n");
|
|
|
|
#endif
|
2012-06-14 18:58:40 +00:00
|
|
|
}
|
|
|
|
|
2012-10-02 18:33:14 +00:00
|
|
|
int tool_main(int argc, char** argv);
|
|
|
|
int tool_main(int argc, char** argv) {
|
2013-06-12 18:28:36 +00:00
|
|
|
SkAutoGraphics ag;
|
2012-06-14 18:58:40 +00:00
|
|
|
if (argc < 2) {
|
2012-09-27 13:09:58 +00:00
|
|
|
printf("Usage: pinspect [--dump-ops] filename [filename ...]\n");
|
|
|
|
return 1;
|
2012-06-14 18:58:40 +00:00
|
|
|
}
|
2012-08-31 15:41:37 +00:00
|
|
|
|
|
|
|
bool doDumpOps = false;
|
|
|
|
|
|
|
|
int index = 1;
|
|
|
|
if (!strcmp(argv[index], "--dump-ops")) {
|
|
|
|
index += 1;
|
|
|
|
doDumpOps = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (; index < argc; ++index) {
|
2016-03-18 14:25:55 +00:00
|
|
|
auto pic(inspect(argv[index]));
|
2012-08-31 15:41:37 +00:00
|
|
|
if (doDumpOps) {
|
2016-03-18 14:25:55 +00:00
|
|
|
dumpOps(pic.get());
|
2012-08-31 15:41:37 +00:00
|
|
|
}
|
|
|
|
if (index < argc - 1) {
|
2012-06-14 18:58:40 +00:00
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2012-10-02 18:33:14 +00:00
|
|
|
|
|
|
|
#if !defined SK_BUILD_FOR_IOS
|
|
|
|
int main(int argc, char * const argv[]) {
|
|
|
|
return tool_main(argc, (char**) argv);
|
|
|
|
}
|
|
|
|
#endif
|