diff options
author | vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-02-24 23:14:04 +0000 |
---|---|---|
committer | vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-02-24 23:14:04 +0000 |
commit | f60a001d1a0052fe21956d8d222d9ba1b5a05981 (patch) | |
tree | 9a34daf105a69210b27d548c655e6a17acd0619c /include/pdf | |
parent | 112706d4c566e283890322bb246b4b86d59837e1 (diff) |
[PDF] Change the way flip origin is done.
The PDF shader matrix is dependent on flip origin or not, so we need to set it at device creation time.
Review URL: http://codereview.appspot.com/4216046
git-svn-id: http://skia.googlecode.com/svn/trunk@855 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/pdf')
-rw-r--r-- | include/pdf/SkPDFDevice.h | 18 | ||||
-rw-r--r-- | include/pdf/SkPDFFormXObject.h | 2 |
2 files changed, 16 insertions, 4 deletions
diff --git a/include/pdf/SkPDFDevice.h b/include/pdf/SkPDFDevice.h index 5bcc8e3d36..f9247a7122 100644 --- a/include/pdf/SkPDFDevice.h +++ b/include/pdf/SkPDFDevice.h @@ -42,12 +42,24 @@ class SkPDFDeviceFactory : public SkDeviceFactory { */ class SkPDFDevice : public SkDevice { public: + /** Skia generally uses the top left as the origin and PDFs natively use + the bottom left. We can move the origin to the top left in the PDF + with a transform, but we have to be careful to apply the transform + only once. + */ + enum OriginTransform { + kFlip_OriginTransform, + kNoFlip_OriginTransform, + }; + /** Create a PDF drawing context with the given width and height. * 72 points/in means letter paper is 612x792. * @param width Page width in points. * @param height Page height in points. + * @param flipOrigin Flip the origin from lower left to upper left. */ - SkPDFDevice(int width, int height); + SkPDFDevice(int width, int height, + OriginTransform flipOrigin = kFlip_OriginTransform); virtual ~SkPDFDevice(); virtual SkDeviceFactory* getDeviceFactory() { @@ -121,13 +133,13 @@ public: SkRefPtr<SkPDFArray> getMediaBox() const; /** Returns a string with the page contents. - * @param flipOrigin Flip the origin between top and bottom. */ - SkString content(bool flipOrigin) const; + SkString content() const; private: int fWidth; int fHeight; + OriginTransform fFlipOrigin; SkRefPtr<SkPDFDict> fResourceDict; SkTDArray<SkPDFGraphicState*> fGraphicStateResources; diff --git a/include/pdf/SkPDFFormXObject.h b/include/pdf/SkPDFFormXObject.h index ed1656680b..41719f0820 100644 --- a/include/pdf/SkPDFFormXObject.h +++ b/include/pdf/SkPDFFormXObject.h @@ -28,7 +28,7 @@ class SkPDFCatalog; /** \class SkPDFFormXObject - A form XObject; a self containted description of graphics objects. A form + A form XObject; a self contained description of graphics objects. A form XObject is basically a page object with slightly different syntax, that can be drawn onto a page. */ |