aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--dm/DM.cpp1
-rw-r--r--dm/DMSrcSink.cpp17
-rw-r--r--dm/DMSrcSink.h9
-rw-r--r--experimental/tools/gmtoskp.cpp80
-rw-r--r--gyp/experimental.gyp22
5 files changed, 27 insertions, 102 deletions
diff --git a/dm/DM.cpp b/dm/DM.cpp
index 5b99a4c214..900eb58a03 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -208,6 +208,7 @@ static Sink* create_sink(const char* tag) {
SINK("565", RasterSink, kRGB_565_SkColorType);
SINK("8888", RasterSink, kN32_SkColorType);
SINK("pdf", PDFSink);
+ SINK("skp", SKPSink);
}
#undef SINK
return NULL;
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index 4e79c63b4a..7979dff9bd 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -197,6 +197,23 @@ Error PDFSink::draw(const Src& src, SkBitmap*, SkWStream* dst) const {
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+SKPSink::SKPSink() {}
+
+Error SKPSink::draw(const Src& src, SkBitmap*, SkWStream* dst) const {
+ SkSize size;
+ size = src.size();
+ SkPictureRecorder recorder;
+ Error err = src.draw(recorder.beginRecording(size.width(), size.height()));
+ if (!err.isEmpty()) {
+ return err;
+ }
+ SkAutoTUnref<SkPicture> pic(recorder.endRecording());
+ pic->serialize(dst);
+ return "";
+}
+
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
RasterSink::RasterSink(SkColorType colorType) : fColorType(colorType) {}
Error RasterSink::draw(const Src& src, SkBitmap* dst, SkWStream*) const {
diff --git a/dm/DMSrcSink.h b/dm/DMSrcSink.h
index 0683d81960..e163a24253 100644
--- a/dm/DMSrcSink.h
+++ b/dm/DMSrcSink.h
@@ -117,6 +117,15 @@ private:
SkColorType fColorType;
};
+class SKPSink : public Sink {
+public:
+ SKPSink();
+
+ Error draw(const Src&, SkBitmap*, SkWStream*) const SK_OVERRIDE;
+ int enclave() const SK_OVERRIDE { return kAnyThread_Enclave; }
+ const char* fileExtension() const SK_OVERRIDE { return "skp"; }
+};
+
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
class ViaMatrix : public Sink {
diff --git a/experimental/tools/gmtoskp.cpp b/experimental/tools/gmtoskp.cpp
deleted file mode 100644
index 124c7f6760..0000000000
--- a/experimental/tools/gmtoskp.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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 "SkCanvas.h"
-#include "SkForceLinking.h"
-#include "SkGraphics.h"
-#include "SkOSFile.h"
-#include "SkPicture.h"
-#include "SkPictureRecorder.h"
-#include "SkStream.h"
-#include "SkTemplates.h"
-#include "flags/SkCommandLineFlags.h"
-#include "gm.h"
-
-DEFINE_string2(match,
- m,
- NULL,
- "[~][^]substring[$] [...] of GM name to run.\n"
- "Multiple matches may be separated by spaces.\n"
- "~ causes a matching GM to always be skipped\n"
- "^ requires the start of the GM to match\n"
- "$ requires the end of the GM to match\n"
- "^ and $ requires an exact match\n"
- "If a GM does not match any list entry,\n"
- "it is skipped unless some list entry starts with ~");
-
-DEFINE_string2(writePath, w, "", "Write output in this directory as .skps.");
-
-__SK_FORCE_IMAGE_DECODER_LINKING;
-
-static void gmtoskp(skiagm::GM* gm, SkWStream* outputStream) {
- SkPictureRecorder pictureRecorder;
- SkRect bounds = SkRect::MakeWH(SkIntToScalar(gm->getISize().width()),
- SkIntToScalar(gm->getISize().height()));
- SkCanvas* canvas = pictureRecorder.beginRecording(bounds, NULL, 0);
- canvas->concat(gm->getInitialTransform());
- gm->draw(canvas);
- canvas->flush();
- SkAutoTUnref<SkPicture> pict(pictureRecorder.endRecordingAsPicture());
- pict->serialize(outputStream, NULL);
-}
-
-int main(int argc, char** argv) {
- SkAutoGraphics ag;
- SkCommandLineFlags::SetUsage("");
- SkCommandLineFlags::Parse(argc, argv);
- if (FLAGS_writePath.isEmpty()) {
- SkDebugf("You need to specify a --writePath option");
- return 1;
- }
- const char* writePath = FLAGS_writePath[0];
- if (!sk_mkdir(writePath)) {
-
- return 2;
- }
- for (const skiagm::GMRegistry* reg = skiagm::GMRegistry::Head();
- reg != NULL;
- reg = reg->next()) {
- SkAutoTDelete<skiagm::GM> gm(reg->factory()(NULL));
- if (!gm.get()) {
- continue;
- }
- const char* name = gm->getName();
- if (!SkCommandLineFlags::ShouldSkip(FLAGS_match, name)) {
- SkString path = SkOSPath::Join(writePath, name);
- path.append(".skp");
- SkFILEWStream outputStream(path.c_str());
- if (!outputStream.isValid()) {
- SkDebugf("Could not open file %s\n", path.c_str());
- return 3;
- }
- gmtoskp(gm, &outputStream);
- }
- }
- return 0;
-}
diff --git a/gyp/experimental.gyp b/gyp/experimental.gyp
index 6405e81576..ffc1753e68 100644
--- a/gyp/experimental.gyp
+++ b/gyp/experimental.gyp
@@ -105,27 +105,5 @@
'tools.gyp:sk_tool_utils',
],
},
- {
- 'target_name': 'gmtoskp',
- 'type': 'executable',
- 'sources': [
- '../experimental/tools/gmtoskp.cpp',
- '../gm/gm.cpp',
- ],
- 'include_dirs': [
- '../tools',
- '../src/effects',
- '../src/core',
- '../src/gpu',
- '../third_party/etc1',
- ],
- 'dependencies': [
- 'skia_lib.gyp:skia_lib',
- 'tools.gyp:resources',
- 'tools.gyp:sk_tool_utils',
- 'gputest.gyp:skgputest',
- ],
- 'includes': [ 'gmslides.gypi', ],
- },
],
}