skia2/tools/gpuveto.cpp
kjlubick 1de415f2c3 Revert of Make SkPicture/SkImageGenerator default to SkCodec (patchset #7 id:120001 of https://codereview.chromium.org/1671193002/ )
Reason for revert:
Breaks Ubuntu and Mac CMAKE

Original issue's description:
> Make SkPicture/SkImageGenerator default to SkCodec
>
> Remove reference to SkImageDecoder from SkPicture. Make the default
> InstallPixelRefProc passed to CreateFromStream use
> SkImageGenerator::NewFromEncoded instead.
>
> Make SkImageGenerator::NewFromEncoded create an SkCodecImageGenerator.
> Remove the old version that used SkImageDecoder.
>
> Remove all versions of lazy_decode_bitmap/LazyDecodeBitmap. The default
> now behaves lazily.
>
> Update all clients to use the default.
>
> Move SkImageDecoderGenerator into KtxTest.cpp, and use it directly.
>
> BUG=skia:4691
> BUG=skia:4290
> GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1671193002
>
> Committed: https://skia.googlesource.com/skia/+/026388a01864c74208ad57d1ba4f711602d101c6

TBR=msarett@google.com,reed@google.com,scroggo@google.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:4691

Review URL: https://codereview.chromium.org/1685963004
2016-02-10 11:25:07 -08:00

81 lines
2.4 KiB
C++

/*
* 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 (nullptr == 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->playback(recorder.beginRecording(picture->cullRect().width(),
picture->cullRect().height(),
nullptr, 0));
SkAutoTUnref<SkPicture> recorded(recorder.endRecording());
if (recorded->suitableForGpuRasterization(nullptr)) {
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