[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
Родитель 1962832771
Коммит 1aef2ed83c
3 изменённых файлов: 9 добавлений и 18 удалений

Просмотреть файл

@ -41,9 +41,8 @@ public:
/** Create a PDF form XObject. Entries for the dictionary entries are /** Create a PDF form XObject. Entries for the dictionary entries are
* automatically added. * automatically added.
* @param device The set of graphical elements on this form. * @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(); virtual ~SkPDFFormXObject();
// The SkPDFObject interface. // The SkPDFObject interface.

Просмотреть файл

@ -440,18 +440,21 @@ void SkPDFDevice::drawDevice(const SkDraw& d, SkDevice* device, int x, int y,
SkDevice::drawDevice(d, device, x, y, paint); SkDevice::drawDevice(d, device, x, y, paint);
return; return;
} }
// Assume that a vector capable device means that it's a PDF Device. // Assume that a vector capable device means that it's a PDF Device.
// TODO(vandebo) handle the paint (alpha and compositing mode). // TODO(vandebo) handle the paint (alpha and compositing mode).
SkMatrix matrix;
matrix.setTranslate(x, y);
SkPDFDevice* pdfDevice = static_cast<SkPDFDevice*>(device); 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. fXObjectResources.push(xobject); // Transfer reference.
fContent.append("/X"); fContent.append("/X");
fContent.appendS32(fXObjectResources.count() - 1); fContent.appendS32(fXObjectResources.count() - 1);
fContent.append(" Do\n"); fContent.append(" Do\n");
setTransform(curTransform);
} }
const SkRefPtr<SkPDFDict>& SkPDFDevice::getResourceDict() { const SkRefPtr<SkPDFDict>& SkPDFDevice::getResourceDict() {

Просмотреть файл

@ -22,7 +22,7 @@
#include "SkStream.h" #include "SkStream.h"
#include "SkTypes.h" #include "SkTypes.h"
SkPDFFormXObject::SkPDFFormXObject(SkPDFDevice* device, const SkMatrix& matrix) SkPDFFormXObject::SkPDFFormXObject(SkPDFDevice* device)
: fContent(device->content(false)), : fContent(device->content(false)),
fDevice(device) { fDevice(device) {
SkMemoryStream* stream_data = new SkMemoryStream(fContent.c_str(), 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("Subtype", new SkPDFName("Form"))->unref();
insert("BBox", device->getMediaBox().get()); insert("BBox", device->getMediaBox().get());
insert("Resources", device->getResourceDict().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() {} SkPDFFormXObject::~SkPDFFormXObject() {}