| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #ifndef SkPDFDevice_DEFINED | 10 #ifndef SkPDFDevice_DEFINED |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 class SkPDFGraphicState; | 32 class SkPDFGraphicState; |
| 33 class SkPDFObject; | 33 class SkPDFObject; |
| 34 class SkPDFShader; | 34 class SkPDFShader; |
| 35 class SkPDFStream; | 35 class SkPDFStream; |
| 36 class SkRRect; | 36 class SkRRect; |
| 37 | 37 |
| 38 // Private classes. | 38 // Private classes. |
| 39 struct ContentEntry; | 39 struct ContentEntry; |
| 40 struct GraphicStateEntry; | 40 struct GraphicStateEntry; |
| 41 struct NamedDestination; | 41 struct NamedDestination; |
| 42 struct RectWithData; |
| 42 | 43 |
| 43 /** \class SkPDFDevice | 44 /** \class SkPDFDevice |
| 44 | 45 |
| 45 The drawing context for the PDF backend. | 46 The drawing context for the PDF backend. |
| 46 */ | 47 */ |
| 47 class SkPDFDevice : public SkBaseDevice { | 48 class SkPDFDevice : public SkBaseDevice { |
| 48 public: | 49 public: |
| 49 /** Create a PDF drawing context. SkPDFDevice applies a | 50 /** Create a PDF drawing context. SkPDFDevice applies a |
| 50 * scale-and-translate transform to move the origin from the | 51 * scale-and-translate transform to move the origin from the |
| 51 * bottom left (PDF default) to the top left (Skia default). | 52 * bottom left (PDF default) to the top left (Skia default). |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 // PDF specific methods. | 136 // PDF specific methods. |
| 136 | 137 |
| 137 /** Create the resource dictionary for this device. | 138 /** Create the resource dictionary for this device. |
| 138 */ | 139 */ |
| 139 SkPDFDict* createResourceDict() const; | 140 SkPDFDict* createResourceDict() const; |
| 140 | 141 |
| 141 /** Get the fonts used on this device. | 142 /** Get the fonts used on this device. |
| 142 */ | 143 */ |
| 143 const SkTDArray<SkPDFFont*>& getFontResources() const; | 144 const SkTDArray<SkPDFFont*>& getFontResources() const; |
| 144 | 145 |
| 146 /** Add our annotations (link to urls and destinations) to the supplied |
| 147 * array. |
| 148 * @param array Array to add annotations to. |
| 149 */ |
| 150 void appendAnnotations(SkPDFArray* array) const; |
| 151 |
| 145 /** Add our named destinations to the supplied dictionary. | 152 /** Add our named destinations to the supplied dictionary. |
| 146 * @param dict Dictionary to add destinations to. | 153 * @param dict Dictionary to add destinations to. |
| 147 * @param page The PDF object representing the page for this device. | 154 * @param page The PDF object representing the page for this device. |
| 148 */ | 155 */ |
| 149 void appendDestinations(SkPDFDict* dict, SkPDFObject* page) const; | 156 void appendDestinations(SkPDFDict* dict, SkPDFObject* page) const; |
| 150 | 157 |
| 151 /** Returns a copy of the media box for this device. The caller is required | 158 /** Returns a copy of the media box for this device. The caller is required |
| 152 * to unref() this when it is finished. | 159 * to unref() this when it is finished. |
| 153 */ | 160 */ |
| 154 SkPDFArray* copyMediaBox() const; | 161 SkPDFArray* copyMediaBox() const; |
| 155 | 162 |
| 156 /** Get the annotations from this page, or NULL if there are none. | |
| 157 */ | |
| 158 SkPDFArray* getAnnotations() const { return fAnnotations; } | |
| 159 | |
| 160 /** Returns a SkStream with the page contents. The caller is responsible | 163 /** Returns a SkStream with the page contents. The caller is responsible |
| 161 * for a deleting the returned value. | 164 * for a deleting the returned value. |
| 162 */ | 165 */ |
| 163 SkStreamAsset* content() const; | 166 SkStreamAsset* content() const; |
| 164 | 167 |
| 165 /** Writes the page contents to the stream. */ | 168 /** Writes the page contents to the stream. */ |
| 166 void writeContent(SkWStream*) const; | 169 void writeContent(SkWStream*) const; |
| 167 | 170 |
| 168 const SkMatrix& initialTransform() const { | 171 const SkMatrix& initialTransform() const { |
| 169 return fInitialTransform; | 172 return fInitialTransform; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 190 private: | 193 private: |
| 191 // TODO(vandebo): push most of SkPDFDevice's state into a core object in | 194 // TODO(vandebo): push most of SkPDFDevice's state into a core object in |
| 192 // order to get the right access levels without using friend. | 195 // order to get the right access levels without using friend. |
| 193 friend class ScopedContentEntry; | 196 friend class ScopedContentEntry; |
| 194 | 197 |
| 195 SkISize fPageSize; | 198 SkISize fPageSize; |
| 196 SkISize fContentSize; | 199 SkISize fContentSize; |
| 197 SkMatrix fInitialTransform; | 200 SkMatrix fInitialTransform; |
| 198 SkClipStack fExistingClipStack; | 201 SkClipStack fExistingClipStack; |
| 199 SkRegion fExistingClipRegion; | 202 SkRegion fExistingClipRegion; |
| 200 SkPDFArray* fAnnotations; | 203 |
| 204 SkTDArray<RectWithData*> fLinkToURLs; |
| 205 SkTDArray<RectWithData*> fLinkToDestinations; |
| 201 SkTDArray<NamedDestination*> fNamedDestinations; | 206 SkTDArray<NamedDestination*> fNamedDestinations; |
| 202 | 207 |
| 203 SkTDArray<SkPDFObject*> fGraphicStateResources; | 208 SkTDArray<SkPDFObject*> fGraphicStateResources; |
| 204 SkTDArray<SkPDFObject*> fXObjectResources; | 209 SkTDArray<SkPDFObject*> fXObjectResources; |
| 205 SkTDArray<SkPDFFont*> fFontResources; | 210 SkTDArray<SkPDFFont*> fFontResources; |
| 206 SkTDArray<SkPDFObject*> fShaderResources; | 211 SkTDArray<SkPDFObject*> fShaderResources; |
| 207 | 212 |
| 208 SkAutoTDelete<ContentEntry> fContentEntries; | 213 SkAutoTDelete<ContentEntry> fContentEntries; |
| 209 ContentEntry* fLastContentEntry; | 214 ContentEntry* fLastContentEntry; |
| 210 SkAutoTDelete<ContentEntry> fMarginContentEntries; | 215 SkAutoTDelete<ContentEntry> fMarginContentEntries; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 /** Helper method for copyContentToData. It is responsible for copying the | 290 /** Helper method for copyContentToData. It is responsible for copying the |
| 286 * list of content entries |entry| to |data|. | 291 * list of content entries |entry| to |data|. |
| 287 */ | 292 */ |
| 288 void copyContentEntriesToData(ContentEntry* entry, SkWStream* data) const; | 293 void copyContentEntriesToData(ContentEntry* entry, SkWStream* data) const; |
| 289 | 294 |
| 290 bool handleInversePath(const SkDraw& d, const SkPath& origPath, | 295 bool handleInversePath(const SkDraw& d, const SkPath& origPath, |
| 291 const SkPaint& paint, bool pathIsMutable, | 296 const SkPaint& paint, bool pathIsMutable, |
| 292 const SkMatrix* prePathMatrix = NULL); | 297 const SkMatrix* prePathMatrix = NULL); |
| 293 bool handlePointAnnotation(const SkPoint* points, size_t count, | 298 bool handlePointAnnotation(const SkPoint* points, size_t count, |
| 294 const SkMatrix& matrix, SkAnnotation* annot); | 299 const SkMatrix& matrix, SkAnnotation* annot); |
| 295 void addAnnotation(SkPDFDict*); | 300 bool handlePathAnnotation(const SkPath& path, const SkDraw& d, |
| 301 SkAnnotation* annot); |
| 296 | 302 |
| 297 typedef SkBaseDevice INHERITED; | 303 typedef SkBaseDevice INHERITED; |
| 298 | 304 |
| 299 // TODO(edisonn): Only SkDocument_PDF and SkPDFImageShader should be able to
create | 305 // TODO(edisonn): Only SkDocument_PDF and SkPDFImageShader should be able to
create |
| 300 // an SkPDFDevice | 306 // an SkPDFDevice |
| 301 //friend class SkDocument_PDF; | 307 //friend class SkDocument_PDF; |
| 302 //friend class SkPDFImageShader; | 308 //friend class SkPDFImageShader; |
| 303 }; | 309 }; |
| 304 | 310 |
| 305 #endif | 311 #endif |
| OLD | NEW |