Add PDF support for drawDevice using a form xobject.
This depends on:
http://codereview.appspot.com/2719041
http://codereview.appspot.com/2720041
http://codereview.appspot.com/2721041
Review URL: http://codereview.appspot.com/2710042
git-svn-id: http://skia.googlecode.com/svn/trunk@621 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index 4f8a9aa..da2e306 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -21,6 +21,7 @@
#include "SkPath.h"
#include "SkPDFImage.h"
#include "SkPDFGraphicState.h"
+#include "SkPDFFormXObject.h"
#include "SkPDFTypes.h"
#include "SkPDFStream.h"
#include "SkRect.h"
@@ -273,9 +274,25 @@
NOT_IMPLEMENTED("drawVerticies", true);
}
-void SkPDFDevice::drawDevice(const SkDraw&, SkDevice*, int x, int y,
- const SkPaint&) {
- SkASSERT(false);
+void SkPDFDevice::drawDevice(const SkDraw& d, SkDevice* device, int x, int y,
+ const SkPaint& paint) {
+ if ((device->getDeviceCapabilities() & kVector_Capability) == 0) {
+ // If we somehow get a raster device, do what our parent would do.
+ SkDevice::drawDevice(d, device, x, y, paint);
+ return;
+ }
+
+ // Assume that a vector capable device means that it's a PDF Device.
+ // TODO(vandebo) handle the paint (alpha and compositing mode).
+ SkMatrix matrix;
+ matrix.setTranslate(x, y);
+ SkPDFDevice* pdfDevice = static_cast<SkPDFDevice*>(device);
+
+ SkPDFFormXObject* xobject = new SkPDFFormXObject(pdfDevice, matrix);
+ fXObjectResources.push(xobject); // Transfer reference.
+ fContent.append("/X");
+ fContent.appendS32(fXObjectResources.count() - 1);
+ fContent.append(" Do\n");
}
const SkRefPtr<SkPDFDict>& SkPDFDevice::getResourceDict() {