#include "SkDevice.h"
#include "SkMatrix.h"
#include "SkNWayCanvas.h"
+#include "SkPDFDevice.h"
+#include "SkPDFDocument.h"
#include "SkPaint.h"
#include "SkPath.h"
#include "SkPicture.h"
"test step %s, SkNWayCanvas indirect canvas 1 state consistency";
static const char* const kNWayIndirect2StateAssertMessageFormat =
"test step %s, SkNWayCanvas indirect canvas 2 state consistency";
+static const char* const kPdfAssertMessageFormat =
+ "PDF sanity check failed %s";
static void createBitmap(SkBitmap* bm, SkBitmap::Config config, SkColor color) {
bm->setConfig(config, kWidth, kHeight);
class CanvasTestStep {
public:
- CanvasTestStep() {
+ CanvasTestStep(bool fEnablePdfTesting = true) {
*testStepArray().append() = this;
fAssertMessageFormat = kDefaultAssertMessageFormat;
+ this->fEnablePdfTesting = fEnablePdfTesting;
}
virtual ~CanvasTestStep() { }
fAssertMessageFormat = format;
}
+ bool enablePdfTesting() { return fEnablePdfTesting; }
+
private:
SkString fAssertMessage;
const char* fAssertMessageFormat;
+ bool fEnablePdfTesting;
};
///////////////////////////////////////////////////////////////////////////////
}; \
static NAME##_TestStep NAME##_TestStepInstance;
+#define TEST_STEP_NO_PDF(NAME, FUNCTION) \
+class NAME##_TestStep : public CanvasTestStep{ \
+public: \
+ NAME##_TestStep() : CanvasTestStep(false) {} \
+ virtual void draw(SkCanvas* canvas, skiatest::Reporter* reporter) { \
+ FUNCTION (canvas, reporter, this); \
+ } \
+ virtual const char* name() const {return #NAME ;} \
+}; \
+static NAME##_TestStep NAME##_TestStepInstance;
+
#define SIMPLE_TEST_STEP(NAME, CALL) \
static void NAME##TestStep(SkCanvas* canvas, skiatest::Reporter*, \
CanvasTestStep*) { \
canvas->drawVertices(SkCanvas::kTriangleFan_VertexMode, 4, pts, pts,
NULL, NULL, NULL, 0, paint);
}
-TEST_STEP(DrawVerticesShader, DrawVerticesShaderTestStep);
+// NYI: issue 240.
+TEST_STEP_NO_PDF(DrawVerticesShader, DrawVerticesShaderTestStep);
static void DrawPictureTestStep(SkCanvas* canvas,
skiatest::Reporter* reporter,
}
};
+static void TestPdfDevice(skiatest::Reporter* reporter,
+ CanvasTestStep* testStep) {
+ SkISize pageSize = SkISize::Make(kWidth, kHeight);
+ SkPDFDevice device(pageSize, pageSize, SkMatrix::I());
+ SkCanvas canvas(&device);
+ testStep->setAssertMessageFormat(kPdfAssertMessageFormat);
+ testStep->draw(&canvas, reporter);
+ SkPDFDocument doc;
+ doc.appendPage(&device);
+ SkDynamicMemoryWStream stream;
+ doc.emitPDF(&stream);
+}
+
// The following class groups static functions that need to access
// the privates members of SkDeferredCanvas
class SkDeferredCanvasTester {
TestOverrideStateConsistency(reporter, testStepArray()[testStep]);
SkPictureTester::TestPictureFlattenedObjectReuse(reporter,
testStepArray()[testStep], 0);
+ if (testStepArray()[testStep]->enablePdfTesting()) {
+ TestPdfDevice(reporter, testStepArray()[testStep]);
+ }
}
// Explicitly call reset(), so we don't leak the pixels (since kTestBitmap is a global)