diff options
author | vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2010-10-26 19:54:45 +0000 |
---|---|---|
committer | vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2010-10-26 19:54:45 +0000 |
commit | eb6c7596af1a1fc7860e27ff2f678a33b2576c0f (patch) | |
tree | 6bf6ef07f98630a780b914f3a78bae52e8936c2c /src/pdf/SkPDFDevice.cpp | |
parent | 7d71f7f655cab6b6194f6c765ca33c1a6d512f5e (diff) |
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
Diffstat (limited to 'src/pdf/SkPDFDevice.cpp')
-rw-r--r-- | src/pdf/SkPDFDevice.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp index 4f8a9aac97..da2e306d71 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 @@ void SkPDFDevice::drawVertices(const SkDraw&, SkCanvas::VertexMode, 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() { |