blob: 51d046de60ead54c19927e1231d5c8dc8a9065d9 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * Copyright 2011 Google Inc.
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +00004 *
epoger@google.comec3ed6a2011-07-28 14:26:00 +00005 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +00007 */
8
epoger@google.comec3ed6a2011-07-28 14:26:00 +00009
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +000010#ifndef SkPDFDevice_DEFINED
11#define SkPDFDevice_DEFINED
12
robertphillips@google.com1f2f3382013-08-29 11:54:56 +000013#include "SkBitmapDevice.h"
commit-bot@chromium.org5e009892013-10-14 13:42:12 +000014#include "SkBitmap.h"
vandebo@chromium.orgb069c8c2011-05-24 17:19:38 +000015#include "SkCanvas.h"
vandebo@chromium.orga5180862010-10-26 19:48:49 +000016#include "SkPaint.h"
17#include "SkPath.h"
commit-bot@chromium.org608ea652013-10-03 19:29:21 +000018#include "SkPicture.h"
vandebo@chromium.org238be8c2012-07-13 20:06:02 +000019#include "SkRect.h"
vandebo@chromium.org9fbdf872011-05-09 07:55:58 +000020#include "SkRefCnt.h"
21#include "SkStream.h"
epoger@google.comb58772f2013-03-08 09:09:10 +000022#include "SkTDArray.h"
commit-bot@chromium.orge0294402013-08-29 22:14:04 +000023#include "SkTemplates.h"
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +000024
25class SkPDFArray;
26class SkPDFDevice;
27class SkPDFDict;
vandebo@chromium.org28be72b2010-11-11 21:37:00 +000028class SkPDFFont;
vandebo@chromium.org6112c212011-05-13 03:50:38 +000029class SkPDFFormXObject;
vandebo@chromium.org98594282011-07-25 22:34:12 +000030class SkPDFGlyphSetMap;
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +000031class SkPDFGraphicState;
32class SkPDFObject;
commit-bot@chromium.org47401352013-07-23 21:49:29 +000033class SkPDFResourceDict;
vandebo@chromium.orgda912d62011-03-08 18:31:02 +000034class SkPDFShader;
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +000035class SkPDFStream;
scroggo@google.coma8e33a92013-11-08 18:02:53 +000036class SkRRect;
edisonn@google.coma20e42c2013-05-31 18:04:20 +000037template <typename T> class SkTSet;
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +000038
vandebo@chromium.org9fbdf872011-05-09 07:55:58 +000039// Private classes.
40struct ContentEntry;
41struct GraphicStateEntry;
epoger@google.comb58772f2013-03-08 09:09:10 +000042struct NamedDestination;
vandebo@chromium.org9fbdf872011-05-09 07:55:58 +000043
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +000044/** \class SkPDFDevice
45
46 The drawing context for the PDF backend.
47*/
robertphillips@google.com1f2f3382013-08-29 11:54:56 +000048class SkPDFDevice : public SkBitmapDevice {
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +000049public:
50 /** Create a PDF drawing context with the given width and height.
51 * 72 points/in means letter paper is 612x792.
ctguil@chromium.org15261292011-04-29 17:54:16 +000052 * @param pageSize Page size in points.
53 * @param contentSize The content size of the page in points. This will be
54 * combined with the initial transform to determine the drawing area
55 * (as reported by the width and height methods). Anything outside
56 * of the drawing area will be clipped.
vandebo@chromium.org75f97e42011-04-11 23:24:18 +000057 * @param initialTransform The initial transform to apply to the page.
58 * This may be useful to, for example, move the origin in and
59 * over a bit to account for a margin, scale the canvas,
60 * or apply a rotation. Note1: the SkPDFDevice also applies
61 * a scale+translate transform to move the origin from the
62 * bottom left (PDF default) to the top left. Note2: drawDevice
63 * (used by layer restore) draws the device after this initial
reed@google.comcde92112011-07-06 20:00:52 +000064 * transform is applied, so the PDF device does an
vandebo@chromium.org75f97e42011-04-11 23:24:18 +000065 * inverse scale+translate to accommodate the one that SkPDFDevice
66 * always does.
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +000067 */
commit-bot@chromium.org5e009892013-10-14 13:42:12 +000068 // Deprecated, please use SkDocument::CreatePdf() instead.
ctguil@chromium.org15261292011-04-29 17:54:16 +000069 SK_API SkPDFDevice(const SkISize& pageSize, const SkISize& contentSize,
70 const SkMatrix& initialTransform);
71 SK_API virtual ~SkPDFDevice();
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +000072
reed@google.com982cb872011-12-07 18:34:08 +000073 virtual uint32_t getDeviceCapabilities() SK_OVERRIDE;
vandebo@chromium.org35fc62b2010-10-26 19:47:30 +000074
reed@google.com982cb872011-12-07 18:34:08 +000075 virtual void clear(SkColor color) SK_OVERRIDE;
vandebo@chromium.org77bcaa32011-04-15 20:57:37 +000076
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +000077 /** These are called inside the per-device-layer loop for each draw call.
78 When these are called, we have already applied any saveLayer operations,
79 and are handling any looping from the paint, and any effects from the
80 DrawFilter.
81 */
reed@google.com982cb872011-12-07 18:34:08 +000082 virtual void drawPaint(const SkDraw&, const SkPaint& paint) SK_OVERRIDE;
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +000083 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode,
84 size_t count, const SkPoint[],
reed@google.com982cb872011-12-07 18:34:08 +000085 const SkPaint& paint) SK_OVERRIDE;
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +000086 virtual void drawRect(const SkDraw&, const SkRect& r, const SkPaint& paint);
scroggo@google.coma8e33a92013-11-08 18:02:53 +000087 virtual void drawRRect(const SkDraw&, const SkRRect& rr,
88 const SkPaint& paint) SK_OVERRIDE;
vandebo@chromium.orgff390322011-05-17 18:58:44 +000089 virtual void drawPath(const SkDraw&, const SkPath& origpath,
vandebo@chromium.org02cc5aa2011-01-25 22:06:29 +000090 const SkPaint& paint, const SkMatrix* prePathMatrix,
reed@google.com982cb872011-12-07 18:34:08 +000091 bool pathIsMutable) SK_OVERRIDE;
edisonn@google.com2ae67e72013-02-12 01:06:38 +000092 virtual void drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap,
93 const SkRect* src, const SkRect& dst,
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +000094 const SkPaint& paint,
95 SkCanvas::DrawBitmapRectFlags flags) SK_OVERRIDE;
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +000096 virtual void drawBitmap(const SkDraw&, const SkBitmap& bitmap,
reed@google.com982cb872011-12-07 18:34:08 +000097 const SkMatrix& matrix, const SkPaint&) SK_OVERRIDE;
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +000098 virtual void drawSprite(const SkDraw&, const SkBitmap& bitmap, int x, int y,
reed@google.com982cb872011-12-07 18:34:08 +000099 const SkPaint& paint) SK_OVERRIDE;
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +0000100 virtual void drawText(const SkDraw&, const void* text, size_t len,
reed@google.com982cb872011-12-07 18:34:08 +0000101 SkScalar x, SkScalar y, const SkPaint&) SK_OVERRIDE;
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +0000102 virtual void drawPosText(const SkDraw&, const void* text, size_t len,
103 const SkScalar pos[], SkScalar constY,
reed@google.com982cb872011-12-07 18:34:08 +0000104 int scalarsPerPos, const SkPaint&) SK_OVERRIDE;
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +0000105 virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len,
106 const SkPath& path, const SkMatrix* matrix,
reed@google.com982cb872011-12-07 18:34:08 +0000107 const SkPaint& paint) SK_OVERRIDE;
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +0000108 virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode,
109 int vertexCount, const SkPoint verts[],
110 const SkPoint texs[], const SkColor colors[],
111 SkXfermode* xmode, const uint16_t indices[],
reed@google.com982cb872011-12-07 18:34:08 +0000112 int indexCount, const SkPaint& paint) SK_OVERRIDE;
robertphillips@google.com1f2f3382013-08-29 11:54:56 +0000113 virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y,
reed@google.com982cb872011-12-07 18:34:08 +0000114 const SkPaint&) SK_OVERRIDE;
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +0000115
robertphillips@google.com40a1ae42012-07-13 15:36:15 +0000116 virtual void onAttachToCanvas(SkCanvas* canvas) SK_OVERRIDE;
117 virtual void onDetachFromCanvas() SK_OVERRIDE;
118
ctguil@chromium.org8dcf74f2011-07-12 21:56:27 +0000119 enum DrawingArea {
ctguil@chromium.org9510ccc2011-07-27 00:10:51 +0000120 kContent_DrawingArea, // Drawing area for the page content.
121 kMargin_DrawingArea, // Drawing area for the margin content.
ctguil@chromium.org8dcf74f2011-07-12 21:56:27 +0000122 };
123
124 /** Sets the drawing area for the device. Subsequent draw calls are directed
ctguil@chromium.org769fa6a2011-08-20 00:36:18 +0000125 * to the specific drawing area (margin or content). The default drawing
ctguil@chromium.org8dcf74f2011-07-12 21:56:27 +0000126 * area is the content drawing area.
ctguil@chromium.org9510ccc2011-07-27 00:10:51 +0000127 *
128 * Currently if margin content is drawn and then a complex (for PDF) xfer
129 * mode is used, like SrcIn, Clear, etc, the margin content will get
130 * clipped. A simple way to avoid the bug is to always draw the margin
131 * content last.
ctguil@chromium.org8dcf74f2011-07-12 21:56:27 +0000132 */
epoger@google.com17b78942011-08-26 14:40:38 +0000133 SK_API void setDrawingArea(DrawingArea drawingArea);
ctguil@chromium.org8dcf74f2011-07-12 21:56:27 +0000134
edisonn@google.comd9dfa182013-04-24 13:01:01 +0000135 /** Sets the DCTEncoder for images.
136 * @param encoder The encoder to encode a bitmap as JPEG (DCT).
137 * Result of encodings are cached, if the encoder changes the
138 * behaivor dynamically and an image is added to a second catalog,
139 * we will likely use the result of the first encoding call.
140 * By returning false from the encoder function, the encoder result
141 * is not used.
142 * Callers might not want to encode small images, as the time spent
143 * encoding and decoding might not be worth the space savings,
144 * if any at all.
145 */
commit-bot@chromium.org608ea652013-10-03 19:29:21 +0000146 void setDCTEncoder(SkPicture::EncodeBitmap encoder) {
edisonn@google.comd9dfa182013-04-24 13:01:01 +0000147 fEncoder = encoder;
148 }
149
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +0000150 // PDF specific methods.
151
reed@google.com1feb3302011-07-20 18:43:19 +0000152 /** Returns the resource dictionary for this device.
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +0000153 */
commit-bot@chromium.org47401352013-07-23 21:49:29 +0000154 SK_API SkPDFResourceDict* getResourceDict();
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +0000155
vandebo@chromium.orgf0ec2662011-05-29 05:55:42 +0000156 /** Get the fonts used on this device.
157 */
vandebo@chromium.org3509f052011-05-30 20:52:33 +0000158 SK_API const SkTDArray<SkPDFFont*>& getFontResources() const;
vandebo@chromium.orgf0ec2662011-05-29 05:55:42 +0000159
epoger@google.comb58772f2013-03-08 09:09:10 +0000160 /** Add our named destinations to the supplied dictionary.
161 * @param dict Dictionary to add destinations to.
162 * @param page The PDF object representing the page for this device.
163 */
164 void appendDestinations(SkPDFDict* dict, SkPDFObject* page);
165
reed@google.com2a006c12012-09-19 17:05:55 +0000166 /** Returns a copy of the media box for this device. The caller is required
167 * to unref() this when it is finished.
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +0000168 */
reed@google.com2a006c12012-09-19 17:05:55 +0000169 SK_API SkPDFArray* copyMediaBox() const;
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +0000170
reed@google.com2a006c12012-09-19 17:05:55 +0000171 /** Get the annotations from this page, or NULL if there are none.
vandebo@chromium.org238be8c2012-07-13 20:06:02 +0000172 */
reed@google.com2a006c12012-09-19 17:05:55 +0000173 SK_API SkPDFArray* getAnnotations() const { return fAnnotations; }
vandebo@chromium.org238be8c2012-07-13 20:06:02 +0000174
vandebo@chromium.orgc2a9b7f2011-02-24 23:22:30 +0000175 /** Returns a SkStream with the page contents. The caller is responsible
176 for a reference to the returned value.
reed@google.com5667afc2011-06-27 14:42:15 +0000177 DEPRECATED: use copyContentToData()
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +0000178 */
vandebo@chromium.org3509f052011-05-30 20:52:33 +0000179 SK_API SkStream* content() const;
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +0000180
reed@google.com5667afc2011-06-27 14:42:15 +0000181 /** Returns a SkStream with the page contents. The caller is responsible
182 * for calling data->unref() when it is finished.
183 */
184 SK_API SkData* copyContentToData() const;
vandebo@chromium.org98594282011-07-25 22:34:12 +0000185
vandebo@chromium.org3509f052011-05-30 20:52:33 +0000186 SK_API const SkMatrix& initialTransform() const {
187 return fInitialTransform;
188 }
vandebo@chromium.org61d26782011-05-24 23:02:07 +0000189
vandebo@chromium.org98594282011-07-25 22:34:12 +0000190 /** Returns a SkPDFGlyphSetMap which represents glyph usage of every font
191 * that shows on this device.
192 */
193 const SkPDFGlyphSetMap& getFontGlyphUsage() const {
194 return *(fFontGlyphUsage.get());
195 }
vandebo@chromium.org74b46192012-01-28 01:45:11 +0000196
reed@google.comb55deeb2012-01-06 14:43:09 +0000197
commit-bot@chromium.org8c294902013-10-21 17:14:37 +0000198 /**
199 * rasterDpi - the DPI at which features without native PDF support
200 * will be rasterized (e.g. draw image with perspective,
201 * draw text with perspective, ...)
202 * A larger DPI would create a PDF that reflects the original
203 * intent with better fidelity, but it can make for larger
204 * PDF files too, which would use more memory while rendering,
205 * and it would be slower to be processed or sent online or
206 * to printer.
207 */
208 void setRasterDpi(SkScalar rasterDpi) {
209 fRasterDpi = rasterDpi;
210 }
211
edisonn@google.com73a7ea32013-11-11 20:55:15 +0000212protected:
213 virtual bool onReadPixels(const SkBitmap& bitmap, int x, int y,
214 SkCanvas::Config8888) SK_OVERRIDE;
215
216 virtual bool allowImageFilter(SkImageFilter*) SK_OVERRIDE;
217
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +0000218private:
ctguil@chromium.org769fa6a2011-08-20 00:36:18 +0000219 // TODO(vandebo): push most of SkPDFDevice's state into a core object in
vandebo@chromium.orgb069c8c2011-05-24 17:19:38 +0000220 // order to get the right access levels without using friend.
vandebo@chromium.org13d14a92011-05-24 23:12:41 +0000221 friend class ScopedContentEntry;
vandebo@chromium.orga0c7edb2011-05-09 07:58:08 +0000222
ctguil@chromium.org15261292011-04-29 17:54:16 +0000223 SkISize fPageSize;
vandebo@chromium.org9fbdf872011-05-09 07:55:58 +0000224 SkISize fContentSize;
vandebo@chromium.org75f97e42011-04-11 23:24:18 +0000225 SkMatrix fInitialTransform;
vandebo@chromium.org9fbdf872011-05-09 07:55:58 +0000226 SkClipStack fExistingClipStack;
227 SkRegion fExistingClipRegion;
reed@google.com2a006c12012-09-19 17:05:55 +0000228 SkPDFArray* fAnnotations;
commit-bot@chromium.org47401352013-07-23 21:49:29 +0000229 SkPDFResourceDict* fResourceDict;
epoger@google.comb58772f2013-03-08 09:09:10 +0000230 SkTDArray<NamedDestination*> fNamedDestinations;
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +0000231
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +0000232 SkTDArray<SkPDFGraphicState*> fGraphicStateResources;
233 SkTDArray<SkPDFObject*> fXObjectResources;
vandebo@chromium.org28be72b2010-11-11 21:37:00 +0000234 SkTDArray<SkPDFFont*> fFontResources;
vandebo@chromium.org421d6442011-07-20 17:39:01 +0000235 SkTDArray<SkPDFObject*> fShaderResources;
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +0000236
commit-bot@chromium.orge0294402013-08-29 22:14:04 +0000237 SkAutoTDelete<ContentEntry> fContentEntries;
vandebo@chromium.orgb069c8c2011-05-24 17:19:38 +0000238 ContentEntry* fLastContentEntry;
commit-bot@chromium.orge0294402013-08-29 22:14:04 +0000239 SkAutoTDelete<ContentEntry> fMarginContentEntries;
ctguil@chromium.org8dcf74f2011-07-12 21:56:27 +0000240 ContentEntry* fLastMarginContentEntry;
241 DrawingArea fDrawingArea;
242
robertphillips@google.com40a1ae42012-07-13 15:36:15 +0000243 const SkClipStack* fClipStack;
244
ctguil@chromium.org8dcf74f2011-07-12 21:56:27 +0000245 // Accessor and setter functions based on the current DrawingArea.
commit-bot@chromium.orge0294402013-08-29 22:14:04 +0000246 SkAutoTDelete<ContentEntry>* getContentEntries();
ctguil@chromium.org8dcf74f2011-07-12 21:56:27 +0000247 ContentEntry* getLastContentEntry();
248 void setLastContentEntry(ContentEntry* contentEntry);
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +0000249
vandebo@chromium.org98594282011-07-25 22:34:12 +0000250 // Glyph ids used for each font on this device.
commit-bot@chromium.orge0294402013-08-29 22:14:04 +0000251 SkAutoTDelete<SkPDFGlyphSetMap> fFontGlyphUsage;
vandebo@chromium.org98594282011-07-25 22:34:12 +0000252
commit-bot@chromium.org608ea652013-10-03 19:29:21 +0000253 SkPicture::EncodeBitmap fEncoder;
commit-bot@chromium.org8c294902013-10-21 17:14:37 +0000254 SkScalar fRasterDpi;
edisonn@google.comd9dfa182013-04-24 13:01:01 +0000255
vandebo@chromium.orga0c7edb2011-05-09 07:58:08 +0000256 SkPDFDevice(const SkISize& layerSize, const SkClipStack& existingClipStack,
257 const SkRegion& existingClipRegion);
258
robertphillips@google.com1f2f3382013-08-29 11:54:56 +0000259 // override from SkBaseDevice
260 virtual SkBaseDevice* onCreateCompatibleDevice(SkBitmap::Config config,
261 int width, int height,
262 bool isOpaque,
263 Usage usage) SK_OVERRIDE;
bsalomon@google.come97f0852011-06-17 13:10:25 +0000264
vandebo@chromium.org77bcaa32011-04-15 20:57:37 +0000265 void init();
vandebo@chromium.org98594282011-07-25 22:34:12 +0000266 void cleanUp(bool clearFontUsage);
reed@google.comfc641d02012-09-20 17:52:20 +0000267 SkPDFFormXObject* createFormXObjectFromDevice();
vandebo@chromium.org9fbdf872011-05-09 07:55:58 +0000268
vandebo@chromium.org3b416212013-10-30 20:48:05 +0000269 void drawFormXObjectWithMask(int xObjectIndex,
270 SkPDFFormXObject* mask,
vandebo@chromium.org481aef62011-05-24 16:39:05 +0000271 const SkClipStack* clipStack,
272 const SkRegion& clipRegion,
vandebo@chromium.org3b416212013-10-30 20:48:05 +0000273 SkXfermode::Mode mode,
vandebo@chromium.org481aef62011-05-24 16:39:05 +0000274 bool invertClip);
vandebo@chromium.org466f3d62011-05-18 23:06:29 +0000275
vandebo@chromium.orgb069c8c2011-05-24 17:19:38 +0000276 // If the paint or clip is such that we shouldn't draw anything, this
277 // returns NULL and does not create a content entry.
278 // setUpContentEntry and finishContentEntry can be used directly, but
vandebo@chromium.org13d14a92011-05-24 23:12:41 +0000279 // the preferred method is to use the ScopedContentEntry helper class.
vandebo@chromium.orgb069c8c2011-05-24 17:19:38 +0000280 ContentEntry* setUpContentEntry(const SkClipStack* clipStack,
281 const SkRegion& clipRegion,
282 const SkMatrix& matrix,
283 const SkPaint& paint,
284 bool hasText,
reed@google.comfc641d02012-09-20 17:52:20 +0000285 SkPDFFormXObject** dst);
vandebo@chromium.orgb069c8c2011-05-24 17:19:38 +0000286 void finishContentEntry(SkXfermode::Mode xfermode,
vandebo@chromium.org3b416212013-10-30 20:48:05 +0000287 SkPDFFormXObject* dst,
288 SkPath* shape);
vandebo@chromium.org481aef62011-05-24 16:39:05 +0000289 bool isContentEmpty();
290
vandebo@chromium.org9fbdf872011-05-09 07:55:58 +0000291 void populateGraphicStateEntryFromPaint(const SkMatrix& matrix,
292 const SkClipStack& clipStack,
293 const SkRegion& clipRegion,
294 const SkPaint& paint,
295 bool hasText,
296 GraphicStateEntry* entry);
vandebo@chromium.org6112c212011-05-13 03:50:38 +0000297 int addGraphicStateResource(SkPDFGraphicState* gs);
vandebo@chromium.org3b416212013-10-30 20:48:05 +0000298 int addXObjectResource(SkPDFObject* xObject);
vandebo@chromium.org9fbdf872011-05-09 07:55:58 +0000299
vandebo@chromium.orgb069c8c2011-05-24 17:19:38 +0000300 void updateFont(const SkPaint& paint, uint16_t glyphID,
301 ContentEntry* contentEntry);
ctguil@chromium.org9db86bb2011-03-04 21:43:27 +0000302 int getFontResourceIndex(SkTypeface* typeface, uint16_t glyphID);
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +0000303
vandebo@chromium.orgb069c8c2011-05-24 17:19:38 +0000304 void internalDrawPaint(const SkPaint& paint, ContentEntry* contentEntry);
vandebo@chromium.org9fbdf872011-05-09 07:55:58 +0000305 void internalDrawBitmap(const SkMatrix& matrix,
vandebo@chromium.org78dad542011-05-11 18:46:03 +0000306 const SkClipStack* clipStack,
vandebo@chromium.org9fbdf872011-05-09 07:55:58 +0000307 const SkRegion& clipRegion,
308 const SkBitmap& bitmap,
309 const SkIRect* srcRect,
310 const SkPaint& paint);
311
ctguil@chromium.org8dcf74f2011-07-12 21:56:27 +0000312 /** Helper method for copyContentToData. It is responsible for copying the
313 * list of content entries |entry| to |data|.
314 */
315 void copyContentEntriesToData(ContentEntry* entry, SkWStream* data) const;
ctguil@chromium.org9510ccc2011-07-27 00:10:51 +0000316
commit-bot@chromium.orgd2623a12013-08-08 02:52:05 +0000317#ifdef SK_PDF_USE_PATHOPS
commit-bot@chromium.org92ffe7d2013-07-31 22:54:31 +0000318 bool handleInversePath(const SkDraw& d, const SkPath& origPath,
edisonn@google.coma9ebd162013-10-07 13:22:21 +0000319 const SkPaint& paint, bool pathIsMutable,
320 const SkMatrix* prePathMatrix = NULL);
commit-bot@chromium.orgd2623a12013-08-08 02:52:05 +0000321#endif
epoger@google.comb58772f2013-03-08 09:09:10 +0000322 bool handleRectAnnotation(const SkRect& r, const SkMatrix& matrix,
323 const SkPaint& paint);
324 bool handlePointAnnotation(const SkPoint* points, size_t count,
325 const SkMatrix& matrix, const SkPaint& paint);
326 SkPDFDict* createLinkAnnotation(const SkRect& r, const SkMatrix& matrix);
327 void handleLinkToURL(SkData* urlData, const SkRect& r,
328 const SkMatrix& matrix);
329 void handleLinkToNamedDest(SkData* nameData, const SkRect& r,
330 const SkMatrix& matrix);
331 void defineNamedDestination(SkData* nameData, const SkPoint& point,
332 const SkMatrix& matrix);
vandebo@chromium.org238be8c2012-07-13 20:06:02 +0000333
robertphillips@google.com1f2f3382013-08-29 11:54:56 +0000334 typedef SkBitmapDevice INHERITED;
commit-bot@chromium.org5e009892013-10-14 13:42:12 +0000335
336 // TODO(edisonn): Only SkDocument_PDF and SkPDFImageShader should be able to create
337 // an SkPDFDevice
338 //friend class SkDocument_PDF;
339 //friend class SkPDFImageShader;
vandebo@chromium.org9b49dc02010-10-20 22:23:29 +0000340};
341
342#endif