[PDF] Start from an identity transform for drawDevice.

drawDevice, like drawSprite should start from the identity transform instead of applying the passed translation on top of the current transform.

Review URL: http://codereview.appspot.com/4023066

git-svn-id: http://skia.googlecode.com/svn/trunk@757 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
vandebo@chromium.org 2011-02-03 21:46:10 +00:00
parent 1962832771
commit 1aef2ed83c
3 changed files with 9 additions and 18 deletions

View File

@ -41,9 +41,8 @@ public:
/** Create a PDF form XObject. Entries for the dictionary entries are
* automatically added.
* @param device The set of graphical elements on this form.
* @param matrix The mapping from user space to form space.
*/
SkPDFFormXObject(SkPDFDevice* device, const SkMatrix& matrix);
explicit SkPDFFormXObject(SkPDFDevice* device);
virtual ~SkPDFFormXObject();
// The SkPDFObject interface.

View File

@ -440,18 +440,21 @@ void SkPDFDevice::drawDevice(const SkDraw& d, SkDevice* device, int x, int y,
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);
SkMatrix matrix;
matrix.setTranslate(x, y);
SkMatrix curTransform = setTransform(matrix);
SkPDFFormXObject* xobject = new SkPDFFormXObject(pdfDevice);
fXObjectResources.push(xobject); // Transfer reference.
fContent.append("/X");
fContent.appendS32(fXObjectResources.count() - 1);
fContent.append(" Do\n");
setTransform(curTransform);
}
const SkRefPtr<SkPDFDict>& SkPDFDevice::getResourceDict() {

View File

@ -22,7 +22,7 @@
#include "SkStream.h"
#include "SkTypes.h"
SkPDFFormXObject::SkPDFFormXObject(SkPDFDevice* device, const SkMatrix& matrix)
SkPDFFormXObject::SkPDFFormXObject(SkPDFDevice* device)
: fContent(device->content(false)),
fDevice(device) {
SkMemoryStream* stream_data = new SkMemoryStream(fContent.c_str(),
@ -35,17 +35,6 @@ SkPDFFormXObject::SkPDFFormXObject(SkPDFDevice* device, const SkMatrix& matrix)
insert("Subtype", new SkPDFName("Form"))->unref();
insert("BBox", device->getMediaBox().get());
insert("Resources", device->getResourceDict().get());
if (!matrix.isIdentity()) {
SkRefPtr<SkPDFArray> transformArray = new SkPDFArray();
transformArray->unref(); // SkRefPtr and new both took a reference.
transformArray->reserve(6);
SkScalar transform[6];
SkAssertResult(matrix.pdfTransform(transform));
for (size_t i = 0; i < SK_ARRAY_COUNT(transform); i++)
transformArray->append(new SkPDFScalar(transform[i]))->unref();
insert("Matrix", transformArray.get());
}
}
SkPDFFormXObject::~SkPDFFormXObject() {}