epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 2 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * Copyright 2011 Google Inc. |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 4 | * |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 9 | |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 10 | #ifndef SkPDFDevice_DEFINED |
| 11 | #define SkPDFDevice_DEFINED |
| 12 | |
vandebo@chromium.org | b069c8c | 2011-05-24 17:19:38 +0000 | [diff] [blame] | 13 | #include "SkCanvas.h" |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 14 | #include "SkDevice.h" |
vandebo@chromium.org | a518086 | 2010-10-26 19:48:49 +0000 | [diff] [blame] | 15 | #include "SkPaint.h" |
| 16 | #include "SkPath.h" |
vandebo@chromium.org | 9fbdf87 | 2011-05-09 07:55:58 +0000 | [diff] [blame] | 17 | #include "SkRefCnt.h" |
| 18 | #include "SkStream.h" |
| 19 | #include "SkTScopedPtr.h" |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 20 | |
| 21 | class SkPDFArray; |
| 22 | class SkPDFDevice; |
| 23 | class SkPDFDict; |
vandebo@chromium.org | 28be72b | 2010-11-11 21:37:00 +0000 | [diff] [blame] | 24 | class SkPDFFont; |
vandebo@chromium.org | 6112c21 | 2011-05-13 03:50:38 +0000 | [diff] [blame] | 25 | class SkPDFFormXObject; |
vandebo@chromium.org | 9859428 | 2011-07-25 22:34:12 +0000 | [diff] [blame] | 26 | class SkPDFGlyphSetMap; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 27 | class SkPDFGraphicState; |
| 28 | class SkPDFObject; |
vandebo@chromium.org | da912d6 | 2011-03-08 18:31:02 +0000 | [diff] [blame] | 29 | class SkPDFShader; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 30 | class SkPDFStream; |
| 31 | |
vandebo@chromium.org | 9fbdf87 | 2011-05-09 07:55:58 +0000 | [diff] [blame] | 32 | // Private classes. |
| 33 | struct ContentEntry; |
| 34 | struct GraphicStateEntry; |
| 35 | |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 36 | /** \class SkPDFDevice |
| 37 | |
| 38 | The drawing context for the PDF backend. |
| 39 | */ |
| 40 | class SkPDFDevice : public SkDevice { |
| 41 | public: |
| 42 | /** Create a PDF drawing context with the given width and height. |
| 43 | * 72 points/in means letter paper is 612x792. |
ctguil@chromium.org | 1526129 | 2011-04-29 17:54:16 +0000 | [diff] [blame] | 44 | * @param pageSize Page size in points. |
| 45 | * @param contentSize The content size of the page in points. This will be |
| 46 | * combined with the initial transform to determine the drawing area |
| 47 | * (as reported by the width and height methods). Anything outside |
| 48 | * of the drawing area will be clipped. |
vandebo@chromium.org | 75f97e4 | 2011-04-11 23:24:18 +0000 | [diff] [blame] | 49 | * @param initialTransform The initial transform to apply to the page. |
| 50 | * This may be useful to, for example, move the origin in and |
| 51 | * over a bit to account for a margin, scale the canvas, |
| 52 | * or apply a rotation. Note1: the SkPDFDevice also applies |
| 53 | * a scale+translate transform to move the origin from the |
| 54 | * bottom left (PDF default) to the top left. Note2: drawDevice |
| 55 | * (used by layer restore) draws the device after this initial |
reed@google.com | cde9211 | 2011-07-06 20:00:52 +0000 | [diff] [blame] | 56 | * transform is applied, so the PDF device does an |
vandebo@chromium.org | 75f97e4 | 2011-04-11 23:24:18 +0000 | [diff] [blame] | 57 | * inverse scale+translate to accommodate the one that SkPDFDevice |
| 58 | * always does. |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 59 | */ |
ctguil@chromium.org | 769fa6a | 2011-08-20 00:36:18 +0000 | [diff] [blame] | 60 | // TODO(vandebo): The sizes should be SkSize and not SkISize. |
ctguil@chromium.org | 1526129 | 2011-04-29 17:54:16 +0000 | [diff] [blame] | 61 | SK_API SkPDFDevice(const SkISize& pageSize, const SkISize& contentSize, |
| 62 | const SkMatrix& initialTransform); |
| 63 | SK_API virtual ~SkPDFDevice(); |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 64 | |
reed@google.com | 982cb87 | 2011-12-07 18:34:08 +0000 | [diff] [blame] | 65 | virtual uint32_t getDeviceCapabilities() SK_OVERRIDE; |
vandebo@chromium.org | 35fc62b | 2010-10-26 19:47:30 +0000 | [diff] [blame] | 66 | |
reed@google.com | 982cb87 | 2011-12-07 18:34:08 +0000 | [diff] [blame] | 67 | virtual void clear(SkColor color) SK_OVERRIDE; |
vandebo@chromium.org | 77bcaa3 | 2011-04-15 20:57:37 +0000 | [diff] [blame] | 68 | |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 69 | /** These are called inside the per-device-layer loop for each draw call. |
| 70 | When these are called, we have already applied any saveLayer operations, |
| 71 | and are handling any looping from the paint, and any effects from the |
| 72 | DrawFilter. |
| 73 | */ |
reed@google.com | 982cb87 | 2011-12-07 18:34:08 +0000 | [diff] [blame] | 74 | virtual void drawPaint(const SkDraw&, const SkPaint& paint) SK_OVERRIDE; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 75 | virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, |
| 76 | size_t count, const SkPoint[], |
reed@google.com | 982cb87 | 2011-12-07 18:34:08 +0000 | [diff] [blame] | 77 | const SkPaint& paint) SK_OVERRIDE; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 78 | virtual void drawRect(const SkDraw&, const SkRect& r, const SkPaint& paint); |
vandebo@chromium.org | ff39032 | 2011-05-17 18:58:44 +0000 | [diff] [blame] | 79 | virtual void drawPath(const SkDraw&, const SkPath& origpath, |
vandebo@chromium.org | 02cc5aa | 2011-01-25 22:06:29 +0000 | [diff] [blame] | 80 | const SkPaint& paint, const SkMatrix* prePathMatrix, |
reed@google.com | 982cb87 | 2011-12-07 18:34:08 +0000 | [diff] [blame] | 81 | bool pathIsMutable) SK_OVERRIDE; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 82 | virtual void drawBitmap(const SkDraw&, const SkBitmap& bitmap, |
reed@android.com | f2b98d6 | 2010-12-20 18:26:13 +0000 | [diff] [blame] | 83 | const SkIRect* srcRectOrNull, |
reed@google.com | 982cb87 | 2011-12-07 18:34:08 +0000 | [diff] [blame] | 84 | const SkMatrix& matrix, const SkPaint&) SK_OVERRIDE; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 85 | virtual void drawSprite(const SkDraw&, const SkBitmap& bitmap, int x, int y, |
reed@google.com | 982cb87 | 2011-12-07 18:34:08 +0000 | [diff] [blame] | 86 | const SkPaint& paint) SK_OVERRIDE; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 87 | virtual void drawText(const SkDraw&, const void* text, size_t len, |
reed@google.com | 982cb87 | 2011-12-07 18:34:08 +0000 | [diff] [blame] | 88 | SkScalar x, SkScalar y, const SkPaint&) SK_OVERRIDE; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 89 | virtual void drawPosText(const SkDraw&, const void* text, size_t len, |
| 90 | const SkScalar pos[], SkScalar constY, |
reed@google.com | 982cb87 | 2011-12-07 18:34:08 +0000 | [diff] [blame] | 91 | int scalarsPerPos, const SkPaint&) SK_OVERRIDE; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 92 | virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len, |
| 93 | const SkPath& path, const SkMatrix* matrix, |
reed@google.com | 982cb87 | 2011-12-07 18:34:08 +0000 | [diff] [blame] | 94 | const SkPaint& paint) SK_OVERRIDE; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 95 | virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode, |
| 96 | int vertexCount, const SkPoint verts[], |
| 97 | const SkPoint texs[], const SkColor colors[], |
| 98 | SkXfermode* xmode, const uint16_t indices[], |
reed@google.com | 982cb87 | 2011-12-07 18:34:08 +0000 | [diff] [blame] | 99 | int indexCount, const SkPaint& paint) SK_OVERRIDE; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 100 | virtual void drawDevice(const SkDraw&, SkDevice*, int x, int y, |
reed@google.com | 982cb87 | 2011-12-07 18:34:08 +0000 | [diff] [blame] | 101 | const SkPaint&) SK_OVERRIDE; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 102 | |
ctguil@chromium.org | 8dcf74f | 2011-07-12 21:56:27 +0000 | [diff] [blame] | 103 | enum DrawingArea { |
ctguil@chromium.org | 9510ccc | 2011-07-27 00:10:51 +0000 | [diff] [blame] | 104 | kContent_DrawingArea, // Drawing area for the page content. |
| 105 | kMargin_DrawingArea, // Drawing area for the margin content. |
ctguil@chromium.org | 8dcf74f | 2011-07-12 21:56:27 +0000 | [diff] [blame] | 106 | }; |
| 107 | |
| 108 | /** Sets the drawing area for the device. Subsequent draw calls are directed |
ctguil@chromium.org | 769fa6a | 2011-08-20 00:36:18 +0000 | [diff] [blame] | 109 | * to the specific drawing area (margin or content). The default drawing |
ctguil@chromium.org | 8dcf74f | 2011-07-12 21:56:27 +0000 | [diff] [blame] | 110 | * area is the content drawing area. |
ctguil@chromium.org | 9510ccc | 2011-07-27 00:10:51 +0000 | [diff] [blame] | 111 | * |
| 112 | * Currently if margin content is drawn and then a complex (for PDF) xfer |
| 113 | * mode is used, like SrcIn, Clear, etc, the margin content will get |
| 114 | * clipped. A simple way to avoid the bug is to always draw the margin |
| 115 | * content last. |
ctguil@chromium.org | 8dcf74f | 2011-07-12 21:56:27 +0000 | [diff] [blame] | 116 | */ |
epoger@google.com | 17b7894 | 2011-08-26 14:40:38 +0000 | [diff] [blame] | 117 | SK_API void setDrawingArea(DrawingArea drawingArea); |
ctguil@chromium.org | 8dcf74f | 2011-07-12 21:56:27 +0000 | [diff] [blame] | 118 | |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 119 | // PDF specific methods. |
| 120 | |
reed@google.com | 1feb330 | 2011-07-20 18:43:19 +0000 | [diff] [blame] | 121 | /** Returns the resource dictionary for this device. |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 122 | */ |
reed@google.com | 1feb330 | 2011-07-20 18:43:19 +0000 | [diff] [blame] | 123 | SK_API SkPDFDict* getResourceDict(); |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 124 | |
vandebo@chromium.org | a518086 | 2010-10-26 19:48:49 +0000 | [diff] [blame] | 125 | /** Get the list of resources (PDF objects) used on this page. |
| 126 | * @param resourceList A list to append the resources to. |
vandebo@chromium.org | 188838c | 2012-03-09 22:16:58 +0000 | [diff] [blame] | 127 | * @param recursive If recursive is true, get the resources of the |
| 128 | * device's resources recursively. (Useful for adding |
| 129 | * objects to the catalog.) |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 130 | */ |
vandebo@chromium.org | 188838c | 2012-03-09 22:16:58 +0000 | [diff] [blame] | 131 | SK_API void getResources(SkTDArray<SkPDFObject*>* resourceList, |
| 132 | bool recursive) const; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 133 | |
vandebo@chromium.org | f0ec266 | 2011-05-29 05:55:42 +0000 | [diff] [blame] | 134 | /** Get the fonts used on this device. |
| 135 | */ |
vandebo@chromium.org | 3509f05 | 2011-05-30 20:52:33 +0000 | [diff] [blame] | 136 | SK_API const SkTDArray<SkPDFFont*>& getFontResources() const; |
vandebo@chromium.org | f0ec266 | 2011-05-29 05:55:42 +0000 | [diff] [blame] | 137 | |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 138 | /** Returns the media box for this device. |
| 139 | */ |
vandebo@chromium.org | 3509f05 | 2011-05-30 20:52:33 +0000 | [diff] [blame] | 140 | SK_API SkRefPtr<SkPDFArray> getMediaBox() const; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 141 | |
vandebo@chromium.org | c2a9b7f | 2011-02-24 23:22:30 +0000 | [diff] [blame] | 142 | /** Returns a SkStream with the page contents. The caller is responsible |
| 143 | for a reference to the returned value. |
reed@google.com | 5667afc | 2011-06-27 14:42:15 +0000 | [diff] [blame] | 144 | DEPRECATED: use copyContentToData() |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 145 | */ |
vandebo@chromium.org | 3509f05 | 2011-05-30 20:52:33 +0000 | [diff] [blame] | 146 | SK_API SkStream* content() const; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 147 | |
reed@google.com | 5667afc | 2011-06-27 14:42:15 +0000 | [diff] [blame] | 148 | /** Returns a SkStream with the page contents. The caller is responsible |
| 149 | * for calling data->unref() when it is finished. |
| 150 | */ |
| 151 | SK_API SkData* copyContentToData() const; |
vandebo@chromium.org | 9859428 | 2011-07-25 22:34:12 +0000 | [diff] [blame] | 152 | |
vandebo@chromium.org | 3509f05 | 2011-05-30 20:52:33 +0000 | [diff] [blame] | 153 | SK_API const SkMatrix& initialTransform() const { |
| 154 | return fInitialTransform; |
| 155 | } |
vandebo@chromium.org | 61d2678 | 2011-05-24 23:02:07 +0000 | [diff] [blame] | 156 | |
vandebo@chromium.org | 9859428 | 2011-07-25 22:34:12 +0000 | [diff] [blame] | 157 | /** Returns a SkPDFGlyphSetMap which represents glyph usage of every font |
| 158 | * that shows on this device. |
| 159 | */ |
| 160 | const SkPDFGlyphSetMap& getFontGlyphUsage() const { |
| 161 | return *(fFontGlyphUsage.get()); |
| 162 | } |
vandebo@chromium.org | 74b4619 | 2012-01-28 01:45:11 +0000 | [diff] [blame] | 163 | |
bsalomon@google.com | c698097 | 2011-11-02 19:57:21 +0000 | [diff] [blame] | 164 | protected: |
reed@google.com | 982cb87 | 2011-12-07 18:34:08 +0000 | [diff] [blame] | 165 | virtual bool onReadPixels(const SkBitmap& bitmap, int x, int y, |
| 166 | SkCanvas::Config8888) SK_OVERRIDE; |
vandebo@chromium.org | 9859428 | 2011-07-25 22:34:12 +0000 | [diff] [blame] | 167 | |
reed@google.com | b55deeb | 2012-01-06 14:43:09 +0000 | [diff] [blame] | 168 | virtual bool allowImageFilter(SkImageFilter*) SK_OVERRIDE; |
| 169 | |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 170 | private: |
ctguil@chromium.org | 769fa6a | 2011-08-20 00:36:18 +0000 | [diff] [blame] | 171 | // TODO(vandebo): push most of SkPDFDevice's state into a core object in |
vandebo@chromium.org | b069c8c | 2011-05-24 17:19:38 +0000 | [diff] [blame] | 172 | // order to get the right access levels without using friend. |
vandebo@chromium.org | 13d14a9 | 2011-05-24 23:12:41 +0000 | [diff] [blame] | 173 | friend class ScopedContentEntry; |
vandebo@chromium.org | a0c7edb | 2011-05-09 07:58:08 +0000 | [diff] [blame] | 174 | |
ctguil@chromium.org | 1526129 | 2011-04-29 17:54:16 +0000 | [diff] [blame] | 175 | SkISize fPageSize; |
vandebo@chromium.org | 9fbdf87 | 2011-05-09 07:55:58 +0000 | [diff] [blame] | 176 | SkISize fContentSize; |
vandebo@chromium.org | 75f97e4 | 2011-04-11 23:24:18 +0000 | [diff] [blame] | 177 | SkMatrix fInitialTransform; |
vandebo@chromium.org | 9fbdf87 | 2011-05-09 07:55:58 +0000 | [diff] [blame] | 178 | SkClipStack fExistingClipStack; |
| 179 | SkRegion fExistingClipRegion; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 180 | SkRefPtr<SkPDFDict> fResourceDict; |
| 181 | |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 182 | SkTDArray<SkPDFGraphicState*> fGraphicStateResources; |
| 183 | SkTDArray<SkPDFObject*> fXObjectResources; |
vandebo@chromium.org | 28be72b | 2010-11-11 21:37:00 +0000 | [diff] [blame] | 184 | SkTDArray<SkPDFFont*> fFontResources; |
vandebo@chromium.org | 421d644 | 2011-07-20 17:39:01 +0000 | [diff] [blame] | 185 | SkTDArray<SkPDFObject*> fShaderResources; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 186 | |
vandebo@chromium.org | 9fbdf87 | 2011-05-09 07:55:58 +0000 | [diff] [blame] | 187 | SkTScopedPtr<ContentEntry> fContentEntries; |
vandebo@chromium.org | b069c8c | 2011-05-24 17:19:38 +0000 | [diff] [blame] | 188 | ContentEntry* fLastContentEntry; |
ctguil@chromium.org | 8dcf74f | 2011-07-12 21:56:27 +0000 | [diff] [blame] | 189 | SkTScopedPtr<ContentEntry> fMarginContentEntries; |
| 190 | ContentEntry* fLastMarginContentEntry; |
| 191 | DrawingArea fDrawingArea; |
| 192 | |
| 193 | // Accessor and setter functions based on the current DrawingArea. |
ctguil@chromium.org | 9510ccc | 2011-07-27 00:10:51 +0000 | [diff] [blame] | 194 | SkTScopedPtr<ContentEntry>* getContentEntries(); |
ctguil@chromium.org | 8dcf74f | 2011-07-12 21:56:27 +0000 | [diff] [blame] | 195 | ContentEntry* getLastContentEntry(); |
| 196 | void setLastContentEntry(ContentEntry* contentEntry); |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 197 | |
vandebo@chromium.org | 9859428 | 2011-07-25 22:34:12 +0000 | [diff] [blame] | 198 | // Glyph ids used for each font on this device. |
| 199 | SkTScopedPtr<SkPDFGlyphSetMap> fFontGlyphUsage; |
| 200 | |
vandebo@chromium.org | a0c7edb | 2011-05-09 07:58:08 +0000 | [diff] [blame] | 201 | SkPDFDevice(const SkISize& layerSize, const SkClipStack& existingClipStack, |
| 202 | const SkRegion& existingClipRegion); |
| 203 | |
bsalomon@google.com | e97f085 | 2011-06-17 13:10:25 +0000 | [diff] [blame] | 204 | // override from SkDevice |
vandebo@chromium.org | 9859428 | 2011-07-25 22:34:12 +0000 | [diff] [blame] | 205 | virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config config, |
| 206 | int width, int height, |
bsalomon@google.com | e97f085 | 2011-06-17 13:10:25 +0000 | [diff] [blame] | 207 | bool isOpaque, |
reed@google.com | 982cb87 | 2011-12-07 18:34:08 +0000 | [diff] [blame] | 208 | Usage usage) SK_OVERRIDE; |
bsalomon@google.com | e97f085 | 2011-06-17 13:10:25 +0000 | [diff] [blame] | 209 | |
vandebo@chromium.org | 77bcaa3 | 2011-04-15 20:57:37 +0000 | [diff] [blame] | 210 | void init(); |
vandebo@chromium.org | 9859428 | 2011-07-25 22:34:12 +0000 | [diff] [blame] | 211 | void cleanUp(bool clearFontUsage); |
vandebo@chromium.org | 6112c21 | 2011-05-13 03:50:38 +0000 | [diff] [blame] | 212 | void createFormXObjectFromDevice(SkRefPtr<SkPDFFormXObject>* xobject); |
vandebo@chromium.org | 9fbdf87 | 2011-05-09 07:55:58 +0000 | [diff] [blame] | 213 | |
vandebo@chromium.org | 466f3d6 | 2011-05-18 23:06:29 +0000 | [diff] [blame] | 214 | // Clear the passed clip from all existing content entries. |
| 215 | void clearClipFromContent(const SkClipStack* clipStack, |
| 216 | const SkRegion& clipRegion); |
vandebo@chromium.org | 481aef6 | 2011-05-24 16:39:05 +0000 | [diff] [blame] | 217 | void drawFormXObjectWithClip(SkPDFFormXObject* form, |
| 218 | const SkClipStack* clipStack, |
| 219 | const SkRegion& clipRegion, |
| 220 | bool invertClip); |
vandebo@chromium.org | 466f3d6 | 2011-05-18 23:06:29 +0000 | [diff] [blame] | 221 | |
vandebo@chromium.org | b069c8c | 2011-05-24 17:19:38 +0000 | [diff] [blame] | 222 | // If the paint or clip is such that we shouldn't draw anything, this |
| 223 | // returns NULL and does not create a content entry. |
| 224 | // setUpContentEntry and finishContentEntry can be used directly, but |
vandebo@chromium.org | 13d14a9 | 2011-05-24 23:12:41 +0000 | [diff] [blame] | 225 | // the preferred method is to use the ScopedContentEntry helper class. |
vandebo@chromium.org | b069c8c | 2011-05-24 17:19:38 +0000 | [diff] [blame] | 226 | ContentEntry* setUpContentEntry(const SkClipStack* clipStack, |
| 227 | const SkRegion& clipRegion, |
| 228 | const SkMatrix& matrix, |
| 229 | const SkPaint& paint, |
| 230 | bool hasText, |
| 231 | SkRefPtr<SkPDFFormXObject>* dst); |
| 232 | void finishContentEntry(SkXfermode::Mode xfermode, |
| 233 | SkPDFFormXObject* dst); |
vandebo@chromium.org | 481aef6 | 2011-05-24 16:39:05 +0000 | [diff] [blame] | 234 | bool isContentEmpty(); |
| 235 | |
vandebo@chromium.org | 9fbdf87 | 2011-05-09 07:55:58 +0000 | [diff] [blame] | 236 | void populateGraphicStateEntryFromPaint(const SkMatrix& matrix, |
| 237 | const SkClipStack& clipStack, |
| 238 | const SkRegion& clipRegion, |
| 239 | const SkPaint& paint, |
| 240 | bool hasText, |
| 241 | GraphicStateEntry* entry); |
vandebo@chromium.org | 6112c21 | 2011-05-13 03:50:38 +0000 | [diff] [blame] | 242 | int addGraphicStateResource(SkPDFGraphicState* gs); |
vandebo@chromium.org | 9fbdf87 | 2011-05-09 07:55:58 +0000 | [diff] [blame] | 243 | |
vandebo@chromium.org | b069c8c | 2011-05-24 17:19:38 +0000 | [diff] [blame] | 244 | void updateFont(const SkPaint& paint, uint16_t glyphID, |
| 245 | ContentEntry* contentEntry); |
ctguil@chromium.org | 9db86bb | 2011-03-04 21:43:27 +0000 | [diff] [blame] | 246 | int getFontResourceIndex(SkTypeface* typeface, uint16_t glyphID); |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 247 | |
vandebo@chromium.org | b069c8c | 2011-05-24 17:19:38 +0000 | [diff] [blame] | 248 | void internalDrawPaint(const SkPaint& paint, ContentEntry* contentEntry); |
vandebo@chromium.org | 9fbdf87 | 2011-05-09 07:55:58 +0000 | [diff] [blame] | 249 | void internalDrawBitmap(const SkMatrix& matrix, |
vandebo@chromium.org | 78dad54 | 2011-05-11 18:46:03 +0000 | [diff] [blame] | 250 | const SkClipStack* clipStack, |
vandebo@chromium.org | 9fbdf87 | 2011-05-09 07:55:58 +0000 | [diff] [blame] | 251 | const SkRegion& clipRegion, |
| 252 | const SkBitmap& bitmap, |
| 253 | const SkIRect* srcRect, |
| 254 | const SkPaint& paint); |
| 255 | |
ctguil@chromium.org | 8dcf74f | 2011-07-12 21:56:27 +0000 | [diff] [blame] | 256 | /** Helper method for copyContentToData. It is responsible for copying the |
| 257 | * list of content entries |entry| to |data|. |
| 258 | */ |
| 259 | void copyContentEntriesToData(ContentEntry* entry, SkWStream* data) const; |
ctguil@chromium.org | 9510ccc | 2011-07-27 00:10:51 +0000 | [diff] [blame] | 260 | |
vandebo@chromium.org | 9fbdf87 | 2011-05-09 07:55:58 +0000 | [diff] [blame] | 261 | // Disable the default copy and assign implementation. |
| 262 | SkPDFDevice(const SkPDFDevice&); |
| 263 | void operator=(const SkPDFDevice&); |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 264 | }; |
| 265 | |
| 266 | #endif |