aboutsummaryrefslogtreecommitdiffhomepage
path: root/dm/DMSKPTask.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dm/DMSKPTask.cpp')
-rw-r--r--dm/DMSKPTask.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/dm/DMSKPTask.cpp b/dm/DMSKPTask.cpp
new file mode 100644
index 0000000000..d633594ffc
--- /dev/null
+++ b/dm/DMSKPTask.cpp
@@ -0,0 +1,31 @@
+#include "DMSKPTask.h"
+#include "DMUtil.h"
+#include "DMWriteTask.h"
+
+#include "SkCommandLineFlags.h"
+#include "SkPictureRecorder.h"
+
+DEFINE_int32(skpMaxWidth, 1000, "Max SKPTask viewport width.");
+DEFINE_int32(skpMaxHeight, 1000, "Max SKPTask viewport height.");
+
+namespace DM {
+
+SKPTask::SKPTask(Reporter* r,
+ TaskRunner* tr,
+ const SkPicture* pic,
+ SkString filename)
+ : CpuTask(r, tr)
+ , fPicture(SkRef(pic))
+ , fName(FileToTaskName(filename)) {}
+
+void SKPTask::draw() {
+ const int width = SkTMin(SkScalarCeilToInt(fPicture->cullRect().width()), FLAGS_skpMaxWidth),
+ height = SkTMin(SkScalarCeilToInt(fPicture->cullRect().height()), FLAGS_skpMaxHeight);
+ SkBitmap bitmap;
+ AllocatePixels(kN32_SkColorType, width, height, &bitmap);
+ DrawPicture(*fPicture, &bitmap);
+
+ this->spawnChild(SkNEW_ARGS(WriteTask, (*this, "SKP", bitmap)));
+}
+
+} // namespace DM