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 |
11 #define SkPDFDevice_DEFINED | 11 #define SkPDFDevice_DEFINED |
12 | 12 |
13 #include "SkCanvas.h" | 13 #include "SkCanvas.h" |
14 #include "SkDevice.h" | 14 #include "SkDevice.h" |
15 #include "SkPaint.h" | 15 #include "SkPaint.h" |
16 #include "SkPath.h" | 16 #include "SkPath.h" |
17 #include "SkRect.h" | 17 #include "SkRect.h" |
18 #include "SkRefCnt.h" | 18 #include "SkRefCnt.h" |
19 #include "SkStream.h" | 19 #include "SkStream.h" |
| 20 #include "SkTDArray.h" |
20 #include "SkTScopedPtr.h" | 21 #include "SkTScopedPtr.h" |
21 | 22 |
22 class SkPDFArray; | 23 class SkPDFArray; |
23 class SkPDFDevice; | 24 class SkPDFDevice; |
24 class SkPDFDict; | 25 class SkPDFDict; |
25 class SkPDFFont; | 26 class SkPDFFont; |
26 class SkPDFFormXObject; | 27 class SkPDFFormXObject; |
27 class SkPDFGlyphSetMap; | 28 class SkPDFGlyphSetMap; |
28 class SkPDFGraphicState; | 29 class SkPDFGraphicState; |
29 class SkPDFObject; | 30 class SkPDFObject; |
30 class SkPDFShader; | 31 class SkPDFShader; |
31 class SkPDFStream; | 32 class SkPDFStream; |
32 | 33 |
33 // Private classes. | 34 // Private classes. |
34 struct ContentEntry; | 35 struct ContentEntry; |
35 struct GraphicStateEntry; | 36 struct GraphicStateEntry; |
| 37 struct NamedDestination; |
36 | 38 |
37 /** \class SkPDFDevice | 39 /** \class SkPDFDevice |
38 | 40 |
39 The drawing context for the PDF backend. | 41 The drawing context for the PDF backend. |
40 */ | 42 */ |
41 class SkPDFDevice : public SkDevice { | 43 class SkPDFDevice : public SkDevice { |
42 public: | 44 public: |
43 /** Create a PDF drawing context with the given width and height. | 45 /** Create a PDF drawing context with the given width and height. |
44 * 72 points/in means letter paper is 612x792. | 46 * 72 points/in means letter paper is 612x792. |
45 * @param pageSize Page size in points. | 47 * @param pageSize Page size in points. |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 * device's resources recursively. (Useful for adding | 137 * device's resources recursively. (Useful for adding |
136 * objects to the catalog.) | 138 * objects to the catalog.) |
137 */ | 139 */ |
138 SK_API void getResources(SkTDArray<SkPDFObject*>* resourceList, | 140 SK_API void getResources(SkTDArray<SkPDFObject*>* resourceList, |
139 bool recursive) const; | 141 bool recursive) const; |
140 | 142 |
141 /** Get the fonts used on this device. | 143 /** Get the fonts used on this device. |
142 */ | 144 */ |
143 SK_API const SkTDArray<SkPDFFont*>& getFontResources() const; | 145 SK_API const SkTDArray<SkPDFFont*>& getFontResources() const; |
144 | 146 |
| 147 /** Add our named destinations to the supplied dictionary. |
| 148 * @param dict Dictionary to add destinations to. |
| 149 * @param page The PDF object representing the page for this device. |
| 150 */ |
| 151 void appendDestinations(SkPDFDict* dict, SkPDFObject* page); |
| 152 |
145 /** Returns a copy of the media box for this device. The caller is required | 153 /** Returns a copy of the media box for this device. The caller is required |
146 * to unref() this when it is finished. | 154 * to unref() this when it is finished. |
147 */ | 155 */ |
148 SK_API SkPDFArray* copyMediaBox() const; | 156 SK_API SkPDFArray* copyMediaBox() const; |
149 | 157 |
150 /** Get the annotations from this page, or NULL if there are none. | 158 /** Get the annotations from this page, or NULL if there are none. |
151 */ | 159 */ |
152 SK_API SkPDFArray* getAnnotations() const { return fAnnotations; } | 160 SK_API SkPDFArray* getAnnotations() const { return fAnnotations; } |
153 | 161 |
154 /** Returns a SkStream with the page contents. The caller is responsible | 162 /** Returns a SkStream with the page contents. The caller is responsible |
(...skipping 29 matching lines...) Expand all Loading... |
184 // order to get the right access levels without using friend. | 192 // order to get the right access levels without using friend. |
185 friend class ScopedContentEntry; | 193 friend class ScopedContentEntry; |
186 | 194 |
187 SkISize fPageSize; | 195 SkISize fPageSize; |
188 SkISize fContentSize; | 196 SkISize fContentSize; |
189 SkMatrix fInitialTransform; | 197 SkMatrix fInitialTransform; |
190 SkClipStack fExistingClipStack; | 198 SkClipStack fExistingClipStack; |
191 SkRegion fExistingClipRegion; | 199 SkRegion fExistingClipRegion; |
192 SkPDFArray* fAnnotations; | 200 SkPDFArray* fAnnotations; |
193 SkPDFDict* fResourceDict; | 201 SkPDFDict* fResourceDict; |
| 202 SkTDArray<NamedDestination*> fNamedDestinations; |
194 | 203 |
195 SkTDArray<SkPDFGraphicState*> fGraphicStateResources; | 204 SkTDArray<SkPDFGraphicState*> fGraphicStateResources; |
196 SkTDArray<SkPDFObject*> fXObjectResources; | 205 SkTDArray<SkPDFObject*> fXObjectResources; |
197 SkTDArray<SkPDFFont*> fFontResources; | 206 SkTDArray<SkPDFFont*> fFontResources; |
198 SkTDArray<SkPDFObject*> fShaderResources; | 207 SkTDArray<SkPDFObject*> fShaderResources; |
199 | 208 |
200 SkTScopedPtr<ContentEntry> fContentEntries; | 209 SkTScopedPtr<ContentEntry> fContentEntries; |
201 ContentEntry* fLastContentEntry; | 210 ContentEntry* fLastContentEntry; |
202 SkTScopedPtr<ContentEntry> fMarginContentEntries; | 211 SkTScopedPtr<ContentEntry> fMarginContentEntries; |
203 ContentEntry* fLastMarginContentEntry; | 212 ContentEntry* fLastMarginContentEntry; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 const SkRegion& clipRegion, | 275 const SkRegion& clipRegion, |
267 const SkBitmap& bitmap, | 276 const SkBitmap& bitmap, |
268 const SkIRect* srcRect, | 277 const SkIRect* srcRect, |
269 const SkPaint& paint); | 278 const SkPaint& paint); |
270 | 279 |
271 /** Helper method for copyContentToData. It is responsible for copying the | 280 /** Helper method for copyContentToData. It is responsible for copying the |
272 * list of content entries |entry| to |data|. | 281 * list of content entries |entry| to |data|. |
273 */ | 282 */ |
274 void copyContentEntriesToData(ContentEntry* entry, SkWStream* data) const; | 283 void copyContentEntriesToData(ContentEntry* entry, SkWStream* data) const; |
275 | 284 |
276 bool handleAnnotations(const SkRect& r, const SkMatrix& matrix, | 285 bool handleRectAnnotation(const SkRect& r, const SkMatrix& matrix, |
277 const SkPaint& paint); | 286 const SkPaint& paint); |
| 287 bool handlePointAnnotation(const SkPoint* points, size_t count, |
| 288 const SkMatrix& matrix, const SkPaint& paint); |
| 289 SkPDFDict* createLinkAnnotation(const SkRect& r, const SkMatrix& matrix); |
| 290 void handleLinkToURL(SkData* urlData, const SkRect& r, |
| 291 const SkMatrix& matrix); |
| 292 void handleLinkToNamedDest(SkData* nameData, const SkRect& r, |
| 293 const SkMatrix& matrix); |
| 294 void defineNamedDestination(SkData* nameData, const SkPoint& point, |
| 295 const SkMatrix& matrix); |
278 | 296 |
279 typedef SkDevice INHERITED; | 297 typedef SkDevice INHERITED; |
280 }; | 298 }; |
281 | 299 |
282 #endif | 300 #endif |
OLD | NEW |