Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(290)

Unified Diff: tools/gpuveto.cpp

Issue 259663004: gpuveto tool (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gyp/tools.gyp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gpuveto.cpp
===================================================================
--- tools/gpuveto.cpp (revision 0)
+++ tools/gpuveto.cpp (revision 0)
@@ -0,0 +1,66 @@
+/*
+ * 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 then returns
+// the value of the suitableForGpuRasterization method.
+// Return codes:
+static const int kUnsuitable = 0;
+static const int kSuitable = 1;
+static const int kError = 2;
+
+int tool_main(int argc, char** argv);
+int tool_main(int argc, char** argv) {
+ 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;
+ }
+
+ SkPictureRecorder recorder;
+ picture->draw(recorder.beginRecording(picture->width(), picture->height(), NULL, 0));
+ SkAutoTUnref<SkPicture> recorded(recorder.endRecording());
+
+ return recorded->suitableForGpuRasterization(NULL) ? kSuitable : kUnsuitable;
bsalomon 2014/04/25 13:54:43 Should the tool really return an error code rather
rmistry 2014/04/25 16:22:19 Yes lets please return an error code.
+}
+
+#if !defined SK_BUILD_FOR_IOS
+int main(int argc, char * const argv[]) {
+ return tool_main(argc, (char**) argv);
+}
+#endif
Property changes on: tools\gpuveto.cpp
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « gyp/tools.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698