2014-04-28 13:19:34 +00:00
|
|
|
/*
|
|
|
|
* 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 "SkCommandLineFlags.h"
|
|
|
|
#include "SkPicture.h"
|
2016-05-13 18:40:07 +00:00
|
|
|
#include "SkPictureAnalyzer.h"
|
2014-04-28 13:19:34 +00:00
|
|
|
#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;
|
|
|
|
|
2017-02-06 17:46:20 +00:00
|
|
|
int main(int argc, char** argv) {
|
2014-04-28 13:19:34 +00:00
|
|
|
#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;
|
|
|
|
}
|
|
|
|
|
2016-03-18 14:25:55 +00:00
|
|
|
sk_sp<SkPicture> picture(SkPicture::MakeFromStream(&inputStream));
|
|
|
|
if (nullptr == picture) {
|
2014-04-28 13:19:34 +00:00
|
|
|
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;
|
2016-03-29 16:03:52 +00:00
|
|
|
picture->playback(recorder.beginRecording(picture->cullRect().width(),
|
|
|
|
picture->cullRect().height(),
|
2015-08-27 14:41:13 +00:00
|
|
|
nullptr, 0));
|
2016-03-18 14:25:55 +00:00
|
|
|
sk_sp<SkPicture> recorded(recorder.finishRecordingAsPicture());
|
2014-04-28 13:19:34 +00:00
|
|
|
|
2016-05-13 18:40:07 +00:00
|
|
|
if (SkPictureGpuAnalyzer(recorded).suitableForGpuRasterization(nullptr)) {
|
2014-04-28 13:19:34 +00:00
|
|
|
SkDebugf("suitable\n");
|
|
|
|
} else {
|
|
|
|
SkDebugf("unsuitable\n");
|
|
|
|
}
|
2014-04-29 03:05:14 +00:00
|
|
|
|
2014-04-28 13:19:34 +00:00
|
|
|
return kSuccess;
|
|
|
|
#else
|
|
|
|
SkDebugf("gpuveto is only useful when GPU rendering is enabled\n");
|
|
|
|
return kError;
|
|
|
|
#endif
|
|
|
|
}
|