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

Side by Side Diff: tools/skp_parser.cpp

Issue 2281733003: tools: skp_parser (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: skpparser->skp_parser Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « tools/skiaserve/Request.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include <iostream>
9
10 #include "SkDebugCanvas.h"
11 #include "SkNullCanvas.h"
12 #include "SkStream.h"
13
14 #ifdef SK_BUILD_FOR_WIN
15 #include <fcntl.h>
16 #include <io.h>
17 #endif
18
19 int main(int argc, char** argv) {
20 if (argc < 2) {
21 SkDebugf("Usage:\n %s SKP_FILE [DATA_URL]\n", argv[0]);
22 return 1;
23 }
24 SkFILEStream input(argv[1]);
25 if (!input.isValid()) {
26 SkDebugf("Bad file: '%s'\n", argv[1]);
27 return 2;
28 }
29 sk_sp<SkPicture> pic = SkPicture::MakeFromStream(&input);
30 if (!pic) {
31 SkDebugf("Bad skp: '%s'\n", argv[1]);
32 return 3;
33 }
34 SkISize size = pic->cullRect().roundOut().size();
35 SkDebugCanvas debugCanvas(size.width(), size.height());
36 pic->playback(&debugCanvas);
37 sk_sp<SkCanvas> nullCanvas(SkCreateNullCanvas());
38 UrlDataManager dataManager(SkString("data"));
39 Json::Value json = debugCanvas.toJSON(
40 dataManager, debugCanvas.getSize(), nullCanvas.get());
41 if (argc > 2) {
42 if (UrlDataManager::UrlData* data =
43 dataManager.getDataFromUrl(SkString(argv[2]))) {
44 SkData* skdata = data->fData.get();
45 SkASSERT(skdata);
46 #ifdef SK_BUILD_FOR_WIN
47 fflush(stdout);
48 (void)_setmode(_fileno(stdout), _O_BINARY);
49 #endif
50 fwrite(skdata->data(), skdata->size(), 1, stdout);
51 } else {
52 SkDebugf("Bad data url.\n");
53 return 4;
54 }
55 } else {
56 Json::StyledStreamWriter(" ").write(std::cout, json);
57 }
58 return 0;
59 }
OLDNEW
« no previous file with comments | « tools/skiaserve/Request.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698