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

Unified Diff: dm/DMPDFTask.cpp

Issue 316643003: DM: SKP source / PDF backend (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: cast Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dm/DMPDFTask.h ('k') | dm/DMSKPTask.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DMPDFTask.cpp
diff --git a/dm/DMPDFTask.cpp b/dm/DMPDFTask.cpp
index e50e9ecb70fcaa194e7e20668b29bbe1615a5855..ecca1300c88f540c01d902eaa586e0ab8220ec94 100644
--- a/dm/DMPDFTask.cpp
+++ b/dm/DMPDFTask.cpp
@@ -6,7 +6,6 @@
*/
#include "DMPDFTask.h"
-#include "DMExpectationsTask.h"
#include "DMPDFRasterizeTask.h"
#include "DMUtil.h"
#include "DMWriteTask.h"
@@ -21,16 +20,24 @@ DEFINE_bool(pdf, false, "PDF backend master switch.");
namespace DM {
-PDFTask::PDFTask(const char* suffix,
+PDFTask::PDFTask(const char* config,
Reporter* reporter,
TaskRunner* taskRunner,
- const Expectations& expectations,
skiagm::GMRegistry::Factory factory,
RasterizePdfProc rasterizePdfProc)
: CpuTask(reporter, taskRunner)
, fGM(factory(NULL))
- , fName(UnderJoin(fGM->getName(), suffix))
- , fExpectations(expectations)
+ , fName(UnderJoin(fGM->getName(), config))
+ , fRasterize(rasterizePdfProc) {}
+
+PDFTask::PDFTask(Reporter* reporter,
+ TaskRunner* taskRunner,
+ SkPicture* picture,
+ SkString filename,
+ RasterizePdfProc rasterizePdfProc)
+ : CpuTask(reporter, taskRunner)
+ , fPicture(SkRef(picture))
+ , fName(UnderJoin(FileToTaskName(filename).c_str(), "pdf"))
, fRasterize(rasterizePdfProc) {}
namespace {
@@ -59,17 +66,24 @@ private:
} // namespace
void PDFTask::draw() {
- SinglePagePDF pdf(fGM->width(), fGM->height());
- //TODO(mtklein): GM doesn't do this. Why not?
- //pdf.canvas()->concat(fGM->getInitialTransform());
- fGM->draw(pdf.canvas());
+ SkAutoTUnref<SkData> pdfData;
+ bool rasterize = true;
+ if (fGM.get()) {
+ rasterize = 0 == (fGM->getFlags() & skiagm::GM::kSkipPDFRasterization_Flag);
+ SinglePagePDF pdf(fGM->width(), fGM->height());
+ //TODO(mtklein): GM doesn't do this. Why not?
+ //pdf.canvas()->concat(fGM->getInitialTransform());
+ fGM->draw(pdf.canvas());
+ pdfData.reset(pdf.end());
+ } else {
+ SinglePagePDF pdf(SkIntToScalar(fPicture->width()), SkIntToScalar(fPicture->height()));
+ fPicture->draw(pdf.canvas());
+ pdfData.reset(pdf.end());
+ }
- SkAutoTUnref<SkData> pdfData(pdf.end());
SkASSERT(pdfData.get());
-
- if (!(fGM->getFlags() & skiagm::GM::kSkipPDFRasterization_Flag)) {
- this->spawnChild(SkNEW_ARGS(PDFRasterizeTask,
- (*this, pdfData.get(), fExpectations, fRasterize)));
+ if (rasterize) {
+ this->spawnChild(SkNEW_ARGS(PDFRasterizeTask, (*this, pdfData.get(), fRasterize)));
}
this->spawnChild(SkNEW_ARGS(WriteTask, (*this, pdfData.get(), ".pdf")));
}
@@ -78,7 +92,7 @@ bool PDFTask::shouldSkip() const {
if (!FLAGS_pdf) {
return true;
}
- if (fGM->getFlags() & skiagm::GM::kSkipPDF_Flag) {
+ if (fGM.get() && 0 != (fGM->getFlags() & skiagm::GM::kSkipPDF_Flag)) {
return true;
}
return false;
« no previous file with comments | « dm/DMPDFTask.h ('k') | dm/DMSKPTask.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698