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