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 "SkBitmapDevice.h" | 13 #include "SkBitmapDevice.h" |
14 #include "SkCanvas.h" | 14 #include "SkCanvas.h" |
15 #include "SkPaint.h" | 15 #include "SkPaint.h" |
16 #include "SkPath.h" | 16 #include "SkPath.h" |
| 17 #include "SkPicture.h" |
17 #include "SkRect.h" | 18 #include "SkRect.h" |
18 #include "SkRefCnt.h" | 19 #include "SkRefCnt.h" |
19 #include "SkStream.h" | 20 #include "SkStream.h" |
20 #include "SkTDArray.h" | 21 #include "SkTDArray.h" |
21 #include "SkTemplates.h" | 22 #include "SkTemplates.h" |
22 | 23 |
23 class SkPDFArray; | 24 class SkPDFArray; |
24 class SkPDFDevice; | 25 class SkPDFDevice; |
25 class SkPDFDict; | 26 class SkPDFDict; |
26 class SkPDFFont; | 27 class SkPDFFont; |
27 class SkPDFFormXObject; | 28 class SkPDFFormXObject; |
28 class SkPDFGlyphSetMap; | 29 class SkPDFGlyphSetMap; |
29 class SkPDFGraphicState; | 30 class SkPDFGraphicState; |
30 class SkPDFObject; | 31 class SkPDFObject; |
31 class SkPDFResourceDict; | 32 class SkPDFResourceDict; |
32 class SkPDFShader; | 33 class SkPDFShader; |
33 class SkPDFStream; | 34 class SkPDFStream; |
34 template <typename T> class SkTSet; | 35 template <typename T> class SkTSet; |
35 | 36 |
36 // Private classes. | 37 // Private classes. |
37 struct ContentEntry; | 38 struct ContentEntry; |
38 struct GraphicStateEntry; | 39 struct GraphicStateEntry; |
39 struct NamedDestination; | 40 struct NamedDestination; |
40 | 41 |
41 typedef bool (*EncodeToDCTStream)(SkWStream* stream, const SkBitmap& bitmap, con
st SkIRect& rect); | |
42 | |
43 /** \class SkPDFDevice | 42 /** \class SkPDFDevice |
44 | 43 |
45 The drawing context for the PDF backend. | 44 The drawing context for the PDF backend. |
46 */ | 45 */ |
47 class SkPDFDevice : public SkBitmapDevice { | 46 class SkPDFDevice : public SkBitmapDevice { |
48 public: | 47 public: |
49 /** Create a PDF drawing context with the given width and height. | 48 /** Create a PDF drawing context with the given width and height. |
50 * 72 points/in means letter paper is 612x792. | 49 * 72 points/in means letter paper is 612x792. |
51 * @param pageSize Page size in points. | 50 * @param pageSize Page size in points. |
52 * @param contentSize The content size of the page in points. This will be | 51 * @param contentSize The content size of the page in points. This will be |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 * @param encoder The encoder to encode a bitmap as JPEG (DCT). | 132 * @param encoder The encoder to encode a bitmap as JPEG (DCT). |
134 * Result of encodings are cached, if the encoder changes the | 133 * Result of encodings are cached, if the encoder changes the |
135 * behaivor dynamically and an image is added to a second catalog, | 134 * behaivor dynamically and an image is added to a second catalog, |
136 * we will likely use the result of the first encoding call. | 135 * we will likely use the result of the first encoding call. |
137 * By returning false from the encoder function, the encoder result | 136 * By returning false from the encoder function, the encoder result |
138 * is not used. | 137 * is not used. |
139 * Callers might not want to encode small images, as the time spent | 138 * Callers might not want to encode small images, as the time spent |
140 * encoding and decoding might not be worth the space savings, | 139 * encoding and decoding might not be worth the space savings, |
141 * if any at all. | 140 * if any at all. |
142 */ | 141 */ |
143 void setDCTEncoder(EncodeToDCTStream encoder) { | 142 void setDCTEncoder(SkPicture::EncodeBitmap encoder) { |
144 fEncoder = encoder; | 143 fEncoder = encoder; |
145 } | 144 } |
146 | 145 |
147 // PDF specific methods. | 146 // PDF specific methods. |
148 | 147 |
149 /** Returns the resource dictionary for this device. | 148 /** Returns the resource dictionary for this device. |
150 */ | 149 */ |
151 SK_API SkPDFResourceDict* getResourceDict(); | 150 SK_API SkPDFResourceDict* getResourceDict(); |
152 | 151 |
153 /** Get the fonts used on this device. | 152 /** Get the fonts used on this device. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 const SkClipStack* fClipStack; | 224 const SkClipStack* fClipStack; |
226 | 225 |
227 // Accessor and setter functions based on the current DrawingArea. | 226 // Accessor and setter functions based on the current DrawingArea. |
228 SkAutoTDelete<ContentEntry>* getContentEntries(); | 227 SkAutoTDelete<ContentEntry>* getContentEntries(); |
229 ContentEntry* getLastContentEntry(); | 228 ContentEntry* getLastContentEntry(); |
230 void setLastContentEntry(ContentEntry* contentEntry); | 229 void setLastContentEntry(ContentEntry* contentEntry); |
231 | 230 |
232 // Glyph ids used for each font on this device. | 231 // Glyph ids used for each font on this device. |
233 SkAutoTDelete<SkPDFGlyphSetMap> fFontGlyphUsage; | 232 SkAutoTDelete<SkPDFGlyphSetMap> fFontGlyphUsage; |
234 | 233 |
235 EncodeToDCTStream fEncoder; | 234 SkPicture::EncodeBitmap fEncoder; |
236 | 235 |
237 SkPDFDevice(const SkISize& layerSize, const SkClipStack& existingClipStack, | 236 SkPDFDevice(const SkISize& layerSize, const SkClipStack& existingClipStack, |
238 const SkRegion& existingClipRegion); | 237 const SkRegion& existingClipRegion); |
239 | 238 |
240 // override from SkBaseDevice | 239 // override from SkBaseDevice |
241 virtual SkBaseDevice* onCreateCompatibleDevice(SkBitmap::Config config, | 240 virtual SkBaseDevice* onCreateCompatibleDevice(SkBitmap::Config config, |
242 int width, int height, | 241 int width, int height, |
243 bool isOpaque, | 242 bool isOpaque, |
244 Usage usage) SK_OVERRIDE; | 243 Usage usage) SK_OVERRIDE; |
245 | 244 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 const SkMatrix& matrix); | 306 const SkMatrix& matrix); |
308 void handleLinkToNamedDest(SkData* nameData, const SkRect& r, | 307 void handleLinkToNamedDest(SkData* nameData, const SkRect& r, |
309 const SkMatrix& matrix); | 308 const SkMatrix& matrix); |
310 void defineNamedDestination(SkData* nameData, const SkPoint& point, | 309 void defineNamedDestination(SkData* nameData, const SkPoint& point, |
311 const SkMatrix& matrix); | 310 const SkMatrix& matrix); |
312 | 311 |
313 typedef SkBitmapDevice INHERITED; | 312 typedef SkBitmapDevice INHERITED; |
314 }; | 313 }; |
315 | 314 |
316 #endif | 315 #endif |
OLD | NEW |