const DM::Expectations& expectations,
DM::Reporter* reporter,
DM::TaskRunner* tasks) {
-#define START(name, type, ...) \
- if (lowercase(configs[j]).equals(name)) { \
- tasks->add(SkNEW_ARGS(DM::type, \
- (name, reporter, tasks, expectations, gms[i], ## __VA_ARGS__))); \
+#define START(name, type, ...) \
+ if (lowercase(configs[j]).equals(name)) { \
+ tasks->add(SkNEW_ARGS(DM::type, (name, reporter, tasks, gms[i], ## __VA_ARGS__))); \
}
for (int i = 0; i < gms.count(); i++) {
for (int j = 0; j < configs.count(); j++) {
- START("565", CpuGMTask, kRGB_565_SkColorType);
- START("8888", CpuGMTask, kN32_SkColorType);
- START("gpu", GpuGMTask, native, 0);
- START("msaa4", GpuGMTask, native, 4);
- START("msaa16", GpuGMTask, native, 16);
- START("nvprmsaa4", GpuGMTask, nvpr, 4);
- START("nvprmsaa16", GpuGMTask, nvpr, 16);
- START("gpunull", GpuGMTask, null, 0);
- START("gpudebug", GpuGMTask, debug, 0);
- START("angle", GpuGMTask, angle, 0);
- START("mesa", GpuGMTask, mesa, 0);
+ START("565", CpuGMTask, expectations, kRGB_565_SkColorType);
+ START("8888", CpuGMTask, expectations, kN32_SkColorType);
+ START("gpu", GpuGMTask, expectations, native, 0);
+ START("msaa4", GpuGMTask, expectations, native, 4);
+ START("msaa16", GpuGMTask, expectations, native, 16);
+ START("nvprmsaa4", GpuGMTask, expectations, nvpr, 4);
+ START("nvprmsaa16", GpuGMTask, expectations, nvpr, 16);
+ START("gpunull", GpuGMTask, expectations, null, 0);
+ START("gpudebug", GpuGMTask, expectations, debug, 0);
+ START("angle", GpuGMTask, expectations, angle, 0);
+ START("mesa", GpuGMTask, expectations, mesa, 0);
START("pdf", PDFTask, RASTERIZE_PDF_PROC);
}
}
exit(1);
}
- tasks->add(SkNEW_ARGS(DM::SKPTask, (reporter, tasks, pic.detach(), filename)));
+ tasks->add(SkNEW_ARGS(DM::SKPTask, (reporter, tasks, pic->clone(), filename)));
+ tasks->add(SkNEW_ARGS(DM::PDFTask, (reporter, tasks, pic->clone(), filename,
+ RASTERIZE_PDF_PROC)));
}
}
CpuGMTask::CpuGMTask(const char* config,
Reporter* reporter,
TaskRunner* taskRunner,
- const Expectations& expectations,
skiagm::GMRegistry::Factory gmFactory,
+ const Expectations& expectations,
SkColorType colorType)
: CpuTask(reporter, taskRunner)
, fGMFactory(gmFactory)
CpuGMTask(const char* config,
Reporter*,
TaskRunner*,
- const Expectations&,
skiagm::GMRegistry::Factory,
+ const Expectations&,
SkColorType);
virtual void draw() SK_OVERRIDE;
GpuGMTask::GpuGMTask(const char* config,
Reporter* reporter,
TaskRunner* taskRunner,
- const Expectations& expectations,
skiagm::GMRegistry::Factory gmFactory,
+ const Expectations& expectations,
GrContextFactory::GLContextType contextType,
int sampleCount)
: GpuTask(reporter, taskRunner)
GpuGMTask(const char* config,
Reporter*,
TaskRunner*,
- const Expectations&,
skiagm::GMRegistry::Factory,
+ const Expectations&,
GrContextFactory::GLContextType,
int sampleCount);
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();
+ if (fRasterize(&pdfStream, &bitmap)) {
this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
+ } else {
+ this->fail();
}
}
#ifndef DMPDFRasterizeTask_DEFINED
#define DMPDFRasterizeTask_DEFINED
-#include "DMExpectations.h"
#include "DMTask.h"
#include "SkBitmap.h"
#include "SkData.h"
public:
PDFRasterizeTask(const Task& parent,
SkData* pdf,
- const Expectations&,
RasterizePdfProc);
virtual void draw() SK_OVERRIDE;
private:
const SkString fName;
SkAutoTUnref<SkData> fPdf;
- const Expectations& fExpectations;
RasterizePdfProc fRasterize;
};
*/
#include "DMPDFTask.h"
-#include "DMExpectationsTask.h"
#include "DMPDFRasterizeTask.h"
#include "DMUtil.h"
#include "DMWriteTask.h"
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 {
} // 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")));
}
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;
#ifndef DMPDFTask_DEFINED
#define DMPDFTask_DEFINED
-#include "DMPDFRasterizeTask.h"
#include "DMExpectations.h"
+#include "DMPDFRasterizeTask.h"
#include "DMTask.h"
#include "SkBitmap.h"
+#include "SkPicture.h"
#include "SkString.h"
#include "SkTemplates.h"
#include "gm.h"
namespace DM {
-// This task renders a GM using Skia's PDF backend.
+// This task renders a GM or SKP using Skia's PDF backend.
// If rasterizePdfProc is non-NULL, it will spawn a PDFRasterizeTask.
class PDFTask : public CpuTask {
public:
- PDFTask(const char* suffix,
+ PDFTask(const char*,
Reporter*,
TaskRunner*,
- const Expectations&,
skiagm::GMRegistry::Factory,
RasterizePdfProc);
+ PDFTask(Reporter*,
+ TaskRunner*,
+ SkPicture*,
+ SkString name,
+ RasterizePdfProc);
+
virtual void draw() SK_OVERRIDE;
virtual bool shouldSkip() const SK_OVERRIDE;
virtual SkString name() const SK_OVERRIDE { return fName; }
private:
+ // One of these two will be set.
SkAutoTDelete<skiagm::GM> fGM;
+ SkAutoTUnref<SkPicture> fPicture;
+
const SkString fName;
- const Expectations& fExpectations;
RasterizePdfProc fRasterize;
};
namespace DM {
-// foo_bar.skp -> foo-bar_skp
-static SkString filename_to_task_name(SkString filename) {
- for (size_t i = 0; i < filename.size(); i++) {
- if ('_' == filename[i]) { filename[i] = '-'; }
- if ('.' == filename[i]) { filename[i] = '_'; }
- }
- return filename;
-}
-
SKPTask::SKPTask(Reporter* r, TaskRunner* tr, SkPicture* pic, SkString filename)
- : CpuTask(r, tr), fPicture(SkRef(pic)), fName(filename_to_task_name(filename)) {}
+ : CpuTask(r, tr), fPicture(SkRef(pic)), fName(FileToTaskName(filename)) {}
void SKPTask::draw() {
SkBitmap bitmap;
return s;
}
+SkString FileToTaskName(SkString filename) {
+ for (size_t i = 0; i < filename.size(); i++) {
+ if ('_' == filename[i]) { filename[i] = '-'; }
+ if ('.' == filename[i]) { filename[i] = '_'; }
+ }
+ return filename;
+}
+
SkPicture* RecordPicture(skiagm::GM* gm, uint32_t recordFlags, SkBBHFactory* factory) {
const SkISize size = gm->getISize();
SkPictureRecorder recorder;
// UnderJoin("a", "b") -> "a_b"
SkString UnderJoin(const char* a, const char* b);
+// "foo_bar.skp" -> "foo-bar_skp"
+SkString FileToTaskName(SkString);
+
// Draw gm to picture. Passes recordFlags to SkPictureRecorder::beginRecording().
SkPicture* RecordPicture(skiagm::GM* gm,
uint32_t recordFlags = 0,