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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 const SkPoint texs[], const SkColor colors[], | 124 const SkPoint texs[], const SkColor colors[], |
125 SkXfermode* xmode, const uint16_t indices[], | 125 SkXfermode* xmode, const uint16_t indices[], |
126 int indexCount, const SkPaint& paint) override; | 126 int indexCount, const SkPaint& paint) override; |
127 void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, | 127 void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, |
128 const SkPaint&) override; | 128 const SkPaint&) override; |
129 | 129 |
130 void onAttachToCanvas(SkCanvas* canvas) override; | 130 void onAttachToCanvas(SkCanvas* canvas) override; |
131 void onDetachFromCanvas() override; | 131 void onDetachFromCanvas() override; |
132 SkImageInfo imageInfo() const override; | 132 SkImageInfo imageInfo() const override; |
133 | 133 |
134 enum DrawingArea { | |
135 kContent_DrawingArea, // Drawing area for the page content. | |
136 kMargin_DrawingArea, // Drawing area for the margin content. | |
137 }; | |
138 | |
139 /** Sets the drawing area for the device. Subsequent draw calls are directed | |
140 * to the specific drawing area (margin or content). The default drawing | |
141 * area is the content drawing area. | |
142 * | |
143 * Currently if margin content is drawn and then a complex (for PDF) xfer | |
144 * mode is used, like SrcIn, Clear, etc, the margin content will get | |
145 * clipped. A simple way to avoid the bug is to always draw the margin | |
146 * content last. | |
147 */ | |
148 void setDrawingArea(DrawingArea drawingArea); | |
149 | |
150 // PDF specific methods. | 134 // PDF specific methods. |
151 | 135 |
152 /** Create the resource dictionary for this device. */ | 136 /** Create the resource dictionary for this device. */ |
153 sk_sp<SkPDFDict> makeResourceDict() const; | 137 sk_sp<SkPDFDict> makeResourceDict() const; |
154 | 138 |
155 /** Get the fonts used on this device. | 139 /** Get the fonts used on this device. |
156 */ | 140 */ |
157 const SkTDArray<SkPDFFont*>& getFontResources() const; | 141 const SkTDArray<SkPDFFont*>& getFontResources() const; |
158 | 142 |
159 /** Add our annotations (link to urls and destinations) to the supplied | 143 /** Add our annotations (link to urls and destinations) to the supplied |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 SkTArray<RectWithData> fLinkToDestinations; | 227 SkTArray<RectWithData> fLinkToDestinations; |
244 SkTArray<NamedDestination> fNamedDestinations; | 228 SkTArray<NamedDestination> fNamedDestinations; |
245 | 229 |
246 SkTDArray<SkPDFObject*> fGraphicStateResources; | 230 SkTDArray<SkPDFObject*> fGraphicStateResources; |
247 SkTDArray<SkPDFObject*> fXObjectResources; | 231 SkTDArray<SkPDFObject*> fXObjectResources; |
248 SkTDArray<SkPDFFont*> fFontResources; | 232 SkTDArray<SkPDFFont*> fFontResources; |
249 SkTDArray<SkPDFObject*> fShaderResources; | 233 SkTDArray<SkPDFObject*> fShaderResources; |
250 | 234 |
251 SkAutoTDelete<ContentEntry> fContentEntries; | 235 SkAutoTDelete<ContentEntry> fContentEntries; |
252 ContentEntry* fLastContentEntry; | 236 ContentEntry* fLastContentEntry; |
253 SkAutoTDelete<ContentEntry> fMarginContentEntries; | |
254 ContentEntry* fLastMarginContentEntry; | |
255 DrawingArea fDrawingArea; | |
256 | 237 |
257 const SkClipStack* fClipStack; | 238 const SkClipStack* fClipStack; |
258 | 239 |
259 // Accessor and setter functions based on the current DrawingArea. | |
260 SkAutoTDelete<ContentEntry>* getContentEntries(); | |
261 | |
262 // Glyph ids used for each font on this device. | 240 // Glyph ids used for each font on this device. |
263 SkAutoTDelete<SkPDFGlyphSetMap> fFontGlyphUsage; | 241 SkAutoTDelete<SkPDFGlyphSetMap> fFontGlyphUsage; |
264 | 242 |
265 SkScalar fRasterDpi; | 243 SkScalar fRasterDpi; |
266 | 244 |
267 SkBitmap fLegacyBitmap; | 245 SkBitmap fLegacyBitmap; |
268 | 246 |
269 SkPDFDocument* fDocument; | 247 SkPDFDocument* fDocument; |
270 //////////////////////////////////////////////////////////////////////////// | 248 //////////////////////////////////////////////////////////////////////////// |
271 | 249 |
272 SkPDFDevice(SkISize pageSize, | 250 SkPDFDevice(SkISize pageSize, |
273 SkScalar rasterDpi, | 251 SkScalar rasterDpi, |
274 SkPDFDocument* doc, | 252 SkPDFDocument* doc, |
275 bool flip); | 253 bool flip); |
276 | 254 |
277 ContentEntry* getLastContentEntry(); | |
278 void setLastContentEntry(ContentEntry* contentEntry); | |
279 | |
280 SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override; | 255 SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override; |
281 | 256 |
282 void init(); | 257 void init(); |
283 void cleanUp(bool clearFontUsage); | 258 void cleanUp(bool clearFontUsage); |
284 SkPDFFormXObject* createFormXObjectFromDevice(); | 259 SkPDFFormXObject* createFormXObjectFromDevice(); |
285 | 260 |
286 void drawFormXObjectWithMask(int xObjectIndex, | 261 void drawFormXObjectWithMask(int xObjectIndex, |
287 SkPDFFormXObject* mask, | 262 SkPDFFormXObject* mask, |
288 const SkClipStack* clipStack, | 263 const SkClipStack* clipStack, |
289 const SkRegion& clipRegion, | 264 const SkRegion& clipRegion, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 | 313 |
339 typedef SkBaseDevice INHERITED; | 314 typedef SkBaseDevice INHERITED; |
340 | 315 |
341 // TODO(edisonn): Only SkDocument_PDF and SkPDFImageShader should be able to
create | 316 // TODO(edisonn): Only SkDocument_PDF and SkPDFImageShader should be able to
create |
342 // an SkPDFDevice | 317 // an SkPDFDevice |
343 //friend class SkDocument_PDF; | 318 //friend class SkDocument_PDF; |
344 //friend class SkPDFImageShader; | 319 //friend class SkPDFImageShader; |
345 }; | 320 }; |
346 | 321 |
347 #endif | 322 #endif |
OLD | NEW |