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

Side by Side Diff: experimental/tools/gmtoskp.cpp

Issue 885733002: Fold gmtoskp into DM, as --src gm --config skp. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 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 | « dm/DMSrcSink.cpp ('k') | gyp/experimental.gyp » ('j') | 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 2014 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 "SkCanvas.h"
9 #include "SkForceLinking.h"
10 #include "SkGraphics.h"
11 #include "SkOSFile.h"
12 #include "SkPicture.h"
13 #include "SkPictureRecorder.h"
14 #include "SkStream.h"
15 #include "SkTemplates.h"
16 #include "flags/SkCommandLineFlags.h"
17 #include "gm.h"
18
19 DEFINE_string2(match,
20 m,
21 NULL,
22 "[~][^]substring[$] [...] of GM name to run.\n"
23 "Multiple matches may be separated by spaces.\n"
24 "~ causes a matching GM to always be skipped\n"
25 "^ requires the start of the GM to match\n"
26 "$ requires the end of the GM to match\n"
27 "^ and $ requires an exact match\n"
28 "If a GM does not match any list entry,\n"
29 "it is skipped unless some list entry starts with ~");
30
31 DEFINE_string2(writePath, w, "", "Write output in this directory as .skps.");
32
33 __SK_FORCE_IMAGE_DECODER_LINKING;
34
35 static void gmtoskp(skiagm::GM* gm, SkWStream* outputStream) {
36 SkPictureRecorder pictureRecorder;
37 SkRect bounds = SkRect::MakeWH(SkIntToScalar(gm->getISize().width()),
38 SkIntToScalar(gm->getISize().height()));
39 SkCanvas* canvas = pictureRecorder.beginRecording(bounds, NULL, 0);
40 canvas->concat(gm->getInitialTransform());
41 gm->draw(canvas);
42 canvas->flush();
43 SkAutoTUnref<SkPicture> pict(pictureRecorder.endRecordingAsPicture());
44 pict->serialize(outputStream, NULL);
45 }
46
47 int main(int argc, char** argv) {
48 SkAutoGraphics ag;
49 SkCommandLineFlags::SetUsage("");
50 SkCommandLineFlags::Parse(argc, argv);
51 if (FLAGS_writePath.isEmpty()) {
52 SkDebugf("You need to specify a --writePath option");
53 return 1;
54 }
55 const char* writePath = FLAGS_writePath[0];
56 if (!sk_mkdir(writePath)) {
57
58 return 2;
59 }
60 for (const skiagm::GMRegistry* reg = skiagm::GMRegistry::Head();
61 reg != NULL;
62 reg = reg->next()) {
63 SkAutoTDelete<skiagm::GM> gm(reg->factory()(NULL));
64 if (!gm.get()) {
65 continue;
66 }
67 const char* name = gm->getName();
68 if (!SkCommandLineFlags::ShouldSkip(FLAGS_match, name)) {
69 SkString path = SkOSPath::Join(writePath, name);
70 path.append(".skp");
71 SkFILEWStream outputStream(path.c_str());
72 if (!outputStream.isValid()) {
73 SkDebugf("Could not open file %s\n", path.c_str());
74 return 3;
75 }
76 gmtoskp(gm, &outputStream);
77 }
78 }
79 return 0;
80 }
OLDNEW
« no previous file with comments | « dm/DMSrcSink.cpp ('k') | gyp/experimental.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698