Index: dm/DMPDFRasterizeTask.cpp |
diff --git a/dm/DMPDFRasterizeTask.cpp b/dm/DMPDFRasterizeTask.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ce6c10982fb503304d0ff8912ab01449aa8bf6b5 |
--- /dev/null |
+++ b/dm/DMPDFRasterizeTask.cpp |
@@ -0,0 +1,41 @@ |
+/* |
+ * 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 "DMPDFRasterizeTask.h" |
+#include "DMExpectationsTask.h" |
+#include "DMUtil.h" |
+#include "DMWriteTask.h" |
+#include "SkBitmap.h" |
+#include "SkCanvas.h" |
+#include "SkStream.h" |
+ |
+namespace DM { |
+ |
+PDFRasterizeTask::PDFRasterizeTask(const Task& parent, |
+ SkData* pdf, |
+ const Expectations& expectations, |
+ RasterizePdfProc proc) |
+ : CpuTask(parent) |
+ , fName(UnderJoin(parent.name().c_str(), "rasterize")) |
+ , fPdf(SkRef(pdf)) |
+ , fExpectations(expectations) |
+ , fRasterize(proc) {} |
+ |
+void PDFRasterizeTask::draw() { |
+ SkMemoryStream pdfStream(fPdf.get()); |
+ SkBitmap bitmap; |
+ |
+ if (!fRasterize(&pdfStream, &bitmap)) { |
+ this->fail(); |
+ } |
+ if (!fExpectations.check(*this, bitmap)) { |
+ this->fail(); |
+ this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap))); |
+ } |
+} |
+ |
+} // namespace DM |