gpuveto tool

This CL adds a command line tool to report the suitableForGpuRasterization status of a single skp file.

R=bsalomon@google.com, rmistry@google.com

Author: robertphillips@google.com

Review URL: https://codereview.chromium.org/259663004

git-svn-id: http://skia.googlecode.com/svn/trunk@14393 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
commit-bot@chromium.org 2014-04-28 13:19:34 +00:00
parent 5729387fe0
commit fe78847f12
2 changed files with 97 additions and 1 deletions

View File

@ -18,6 +18,7 @@
'bench_record',
'bench_playback',
'filter',
'gpuveto',
'lua_app',
'lua_pictures',
'pinspect',
@ -198,7 +199,24 @@
'skia_lib.gyp:skia_lib',
],
},
{
'target_name': 'gpuveto',
'type': 'executable',
'sources': [
'../tools/gpuveto.cpp',
'../tools/LazyDecodeBitmap.cpp',
],
'include_dirs': [
'../src/core/',
'../src/images',
'../src/lazy',
'../tools/flags',
],
'dependencies': [
'flags.gyp:flags',
'skia_lib.gyp:skia_lib',
],
},
{
'target_name': 'lua_app',
'type': 'executable',

78
tools/gpuveto.cpp Normal file
View File

@ -0,0 +1,78 @@
/*
* Copyright 2014 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "LazyDecodeBitmap.h"
#include "SkCommandLineFlags.h"
#include "SkPicture.h"
#include "SkPictureRecorder.h"
#include "SkStream.h"
DEFINE_string2(readFile, r, "", "skp file to process.");
DEFINE_bool2(quiet, q, false, "quiet");
// This tool just loads a single skp, replays into a new SkPicture (to
// regenerate the GPU-specific tracking information) and reports
// the value of the suitableForGpuRasterization method.
// Return codes:
static const int kSuccess = 0;
static const int kError = 1;
int tool_main(int argc, char** argv);
int tool_main(int argc, char** argv) {
#if SK_SUPPORT_GPU
SkCommandLineFlags::SetUsage("Reports on an skp file's suitability for GPU rasterization");
SkCommandLineFlags::Parse(argc, argv);
if (FLAGS_readFile.count() != 1) {
if (!FLAGS_quiet) {
SkDebugf("Missing input file\n");
}
return kError;
}
SkFILEStream inputStream(FLAGS_readFile[0]);
if (!inputStream.isValid()) {
if (!FLAGS_quiet) {
SkDebugf("Couldn't open file\n");
}
return kError;
}
SkPicture::InstallPixelRefProc proc = &sk_tools::LazyDecodeBitmap;
SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(&inputStream, proc));
if (NULL == picture.get()) {
if (!FLAGS_quiet) {
SkDebugf("Could not read the SkPicture\n");
}
return kError;
}
// The SkPicture tracking information is only generated during recording
// an isn't serialized. Replay the picture to regenerated the tracking data.
SkPictureRecorder recorder;
picture->draw(recorder.beginRecording(picture->width(), picture->height(), NULL, 0));
SkAutoTUnref<SkPicture> recorded(recorder.endRecording());
if (recorded->suitableForGpuRasterization(NULL)) {
SkDebugf("suitable\n");
} else {
SkDebugf("unsuitable\n");
}
return kSuccess;
#else
SkDebugf("gpuveto is only useful when GPU rendering is enabled\n");
return kError;
#endif
}
#if !defined SK_BUILD_FOR_IOS
int main(int argc, char * const argv[]) {
return tool_main(argc, (char**) argv);
}
#endif