vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 1 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 2 | * Copyright 2011 Google Inc. |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 3 | * |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #ifndef SkPDFDevice_DEFINED |
| 9 | #define SkPDFDevice_DEFINED |
| 10 | |
commit-bot@chromium.org | 5e00989 | 2013-10-14 13:42:12 +0000 | [diff] [blame] | 11 | #include "SkBitmap.h" |
vandebo@chromium.org | b069c8c | 2011-05-24 17:19:38 +0000 | [diff] [blame] | 12 | #include "SkCanvas.h" |
bungeman | d3ebb48 | 2015-08-05 13:57:49 -0700 | [diff] [blame] | 13 | #include "SkClipStack.h" |
Mike Reed | f0fb929 | 2017-02-21 13:15:07 -0500 | [diff] [blame] | 14 | #include "SkClipStackDevice.h" |
halcanary | 91fcb3e | 2016-03-04 13:53:22 -0800 | [diff] [blame] | 15 | #include "SkData.h" |
vandebo@chromium.org | a518086 | 2010-10-26 19:48:49 +0000 | [diff] [blame] | 16 | #include "SkPaint.h" |
vandebo@chromium.org | 238be8c | 2012-07-13 20:06:02 +0000 | [diff] [blame] | 17 | #include "SkRect.h" |
vandebo@chromium.org | 9fbdf87 | 2011-05-09 07:55:58 +0000 | [diff] [blame] | 18 | #include "SkRefCnt.h" |
halcanary | 4ed2f01 | 2016-08-15 18:40:07 -0700 | [diff] [blame] | 19 | #include "SkSinglyLinkedList.h" |
vandebo@chromium.org | 9fbdf87 | 2011-05-09 07:55:58 +0000 | [diff] [blame] | 20 | #include "SkStream.h" |
epoger@google.com | b58772f | 2013-03-08 09:09:10 +0000 | [diff] [blame] | 21 | #include "SkTDArray.h" |
halcanary | 4ed2f01 | 2016-08-15 18:40:07 -0700 | [diff] [blame] | 22 | #include "SkTextBlob.h" |
halcanary | 2be7e01 | 2016-03-28 11:58:08 -0700 | [diff] [blame] | 23 | |
Hal Canary | f50ff39 | 2016-09-30 10:25:39 -0400 | [diff] [blame] | 24 | class SkImageSubset; |
martina.kollarova | b8d6af1 | 2016-06-29 05:12:31 -0700 | [diff] [blame] | 25 | class SkPath; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 26 | class SkPDFArray; |
halcanary | a1f1ee9 | 2015-02-20 06:17:26 -0800 | [diff] [blame] | 27 | class SkPDFCanon; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 28 | class SkPDFDevice; |
halcanary | 989da4a | 2016-03-21 14:33:17 -0700 | [diff] [blame] | 29 | class SkPDFDocument; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 30 | class SkPDFDict; |
vandebo@chromium.org | 28be72b | 2010-11-11 21:37:00 +0000 | [diff] [blame] | 31 | class SkPDFFont; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 32 | class SkPDFObject; |
halcanary | 4b1e17e | 2016-07-27 14:49:46 -0700 | [diff] [blame] | 33 | class SkPDFStream; |
scroggo@google.com | a8e33a9 | 2013-11-08 18:02:53 +0000 | [diff] [blame] | 34 | class SkRRect; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 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 | */ |
Mike Reed | f0fb929 | 2017-02-21 13:15:07 -0500 | [diff] [blame] | 40 | class SkPDFDevice final : public SkClipStackDevice { |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 41 | public: |
halcanary | a1f1ee9 | 2015-02-20 06:17:26 -0800 | [diff] [blame] | 42 | /** Create a PDF drawing context. SkPDFDevice applies a |
| 43 | * scale-and-translate transform to move the origin from the |
| 44 | * bottom left (PDF default) to the top left (Skia default). |
| 45 | * @param pageSize Page size in point units. |
| 46 | * 1 point == 127/360 mm == 1/72 inch |
| 47 | * @param rasterDpi the DPI at which features without native PDF |
| 48 | * support will be rasterized (e.g. draw image with |
| 49 | * perspective, draw text with perspective, ...). A |
| 50 | * larger DPI would create a PDF that reflects the |
| 51 | * original intent with better fidelity, but it can make |
| 52 | * for larger PDF files too, which would use more memory |
| 53 | * while rendering, and it would be slower to be processed |
| 54 | * or sent online or to printer. A good choice is |
| 55 | * SK_ScalarDefaultRasterDPI(72.0f). |
halcanary | 989da4a | 2016-03-21 14:33:17 -0700 | [diff] [blame] | 56 | * @param SkPDFDocument. A non-null pointer back to the |
| 57 | * document. The document is repsonsible for |
| 58 | * de-duplicating across pages (via the SkPDFCanon) and |
| 59 | * for early serializing of large immutable objects, such |
| 60 | * as images (via SkPDFDocument::serialize()). |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 61 | */ |
halcanary | a1f1ee9 | 2015-02-20 06:17:26 -0800 | [diff] [blame] | 62 | static SkPDFDevice* Create(SkISize pageSize, |
| 63 | SkScalar rasterDpi, |
halcanary | 989da4a | 2016-03-21 14:33:17 -0700 | [diff] [blame] | 64 | SkPDFDocument* doc) { |
| 65 | return new SkPDFDevice(pageSize, rasterDpi, doc, true); |
halcanary | a1f1ee9 | 2015-02-20 06:17:26 -0800 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | /** Create a PDF drawing context without fipping the y-axis. */ |
| 69 | static SkPDFDevice* CreateUnflipped(SkISize pageSize, |
| 70 | SkScalar rasterDpi, |
halcanary | 989da4a | 2016-03-21 14:33:17 -0700 | [diff] [blame] | 71 | SkPDFDocument* doc) { |
| 72 | return new SkPDFDevice(pageSize, rasterDpi, doc, false); |
halcanary | a1f1ee9 | 2015-02-20 06:17:26 -0800 | [diff] [blame] | 73 | } |
| 74 | |
Brian Salomon | d3b6597 | 2017-03-22 12:05:03 -0400 | [diff] [blame] | 75 | ~SkPDFDevice() override; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 76 | |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 77 | /** 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 | */ |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 82 | void drawPaint(const SkPaint& paint) override; |
| 83 | void drawPoints(SkCanvas::PointMode mode, |
tfarina | fa4f6cb | 2014-12-21 10:27:07 -0800 | [diff] [blame] | 84 | size_t count, const SkPoint[], |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 85 | const SkPaint& paint) override; |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 86 | void drawRect(const SkRect& r, const SkPaint& paint) override; |
| 87 | void drawOval(const SkRect& oval, const SkPaint& paint) override; |
| 88 | void drawRRect(const SkRRect& rr, const SkPaint& paint) override; |
| 89 | void drawPath(const SkPath& origpath, |
tfarina | fa4f6cb | 2014-12-21 10:27:07 -0800 | [diff] [blame] | 90 | const SkPaint& paint, const SkMatrix* prePathMatrix, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 91 | bool pathIsMutable) override; |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 92 | void drawBitmapRect(const SkBitmap& bitmap, const SkRect* src, |
reed | 562fe47 | 2015-07-28 07:35:14 -0700 | [diff] [blame] | 93 | const SkRect& dst, const SkPaint&, SkCanvas::SrcRectConstraint) override; |
Hal Canary | b964238 | 2017-06-27 09:58:56 -0400 | [diff] [blame^] | 94 | void drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, const SkPaint&) override; |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 95 | void drawSprite(const SkBitmap& bitmap, int x, int y, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 96 | const SkPaint& paint) override; |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 97 | void drawImage(const SkImage*, |
halcanary | 7a14b31 | 2015-10-01 07:28:13 -0700 | [diff] [blame] | 98 | SkScalar x, |
| 99 | SkScalar y, |
| 100 | const SkPaint&) override; |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 101 | void drawImageRect(const SkImage*, |
halcanary | 7a14b31 | 2015-10-01 07:28:13 -0700 | [diff] [blame] | 102 | const SkRect* src, |
| 103 | const SkRect& dst, |
| 104 | const SkPaint&, |
| 105 | SkCanvas::SrcRectConstraint) override; |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 106 | void drawText(const void* text, size_t len, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 107 | SkScalar x, SkScalar y, const SkPaint&) override; |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 108 | void drawPosText(const void* text, size_t len, |
tfarina | fa4f6cb | 2014-12-21 10:27:07 -0800 | [diff] [blame] | 109 | const SkScalar pos[], int scalarsPerPos, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 110 | const SkPoint& offset, const SkPaint&) override; |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 111 | void drawTextBlob(const SkTextBlob*, SkScalar x, SkScalar y, |
halcanary | e06ca96 | 2016-09-09 05:34:55 -0700 | [diff] [blame] | 112 | const SkPaint &, SkDrawFilter*) override; |
Mike Reed | 2f6b5a4 | 2017-03-19 15:04:17 -0400 | [diff] [blame] | 113 | void drawVertices(const SkVertices*, SkBlendMode, const SkPaint&) override; |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 114 | void drawDevice(SkBaseDevice*, int x, int y, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 115 | const SkPaint&) override; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 116 | |
| 117 | // PDF specific methods. |
| 118 | |
halcanary | 8103a34 | 2016-03-08 15:10:16 -0800 | [diff] [blame] | 119 | /** Create the resource dictionary for this device. */ |
| 120 | sk_sp<SkPDFDict> makeResourceDict() const; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 121 | |
wangxianzhu | ef6c50a | 2015-09-17 20:38:02 -0700 | [diff] [blame] | 122 | /** Add our annotations (link to urls and destinations) to the supplied |
| 123 | * array. |
| 124 | * @param array Array to add annotations to. |
| 125 | */ |
| 126 | void appendAnnotations(SkPDFArray* array) const; |
| 127 | |
epoger@google.com | b58772f | 2013-03-08 09:09:10 +0000 | [diff] [blame] | 128 | /** Add our named destinations to the supplied dictionary. |
| 129 | * @param dict Dictionary to add destinations to. |
| 130 | * @param page The PDF object representing the page for this device. |
| 131 | */ |
halcanary | 6d62270 | 2015-03-25 08:45:42 -0700 | [diff] [blame] | 132 | void appendDestinations(SkPDFDict* dict, SkPDFObject* page) const; |
epoger@google.com | b58772f | 2013-03-08 09:09:10 +0000 | [diff] [blame] | 133 | |
halcanary | 8103a34 | 2016-03-08 15:10:16 -0800 | [diff] [blame] | 134 | /** Returns a copy of the media box for this device. */ |
| 135 | sk_sp<SkPDFArray> copyMediaBox() const; |
halcanary | 51d04d3 | 2016-03-08 13:03:55 -0800 | [diff] [blame] | 136 | |
halcanary | 8103a34 | 2016-03-08 15:10:16 -0800 | [diff] [blame] | 137 | /** Returns a SkStream with the page contents. |
halcanary | 51d04d3 | 2016-03-08 13:03:55 -0800 | [diff] [blame] | 138 | */ |
mtklein | 5f939ab | 2016-03-16 10:28:35 -0700 | [diff] [blame] | 139 | std::unique_ptr<SkStreamAsset> content() const; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 140 | |
halcanary | 989da4a | 2016-03-21 14:33:17 -0700 | [diff] [blame] | 141 | SkPDFCanon* getCanon() const; |
halcanary | 26b5d15 | 2015-03-25 08:38:03 -0700 | [diff] [blame] | 142 | |
halcanary | 2be7e01 | 2016-03-28 11:58:08 -0700 | [diff] [blame] | 143 | // It is important to not confuse GraphicStateEntry with SkPDFGraphicState, the |
| 144 | // later being our representation of an object in the PDF file. |
| 145 | struct GraphicStateEntry { |
| 146 | GraphicStateEntry(); |
| 147 | |
| 148 | // Compare the fields we care about when setting up a new content entry. |
| 149 | bool compareInitialState(const GraphicStateEntry& b); |
| 150 | |
| 151 | SkMatrix fMatrix; |
| 152 | // We can't do set operations on Paths, though PDF natively supports |
| 153 | // intersect. If the clip stack does anything other than intersect, |
| 154 | // we have to fall back to the region. Treat fClipStack as authoritative. |
| 155 | // See https://bugs.skia.org/221 |
| 156 | SkClipStack fClipStack; |
halcanary | 2be7e01 | 2016-03-28 11:58:08 -0700 | [diff] [blame] | 157 | |
| 158 | // When emitting the content entry, we will ensure the graphic state |
| 159 | // is set to these values first. |
| 160 | SkColor fColor; |
| 161 | SkScalar fTextScaleX; // Zero means we don't care what the value is. |
| 162 | SkPaint::Style fTextFill; // Only if TextScaleX is non-zero. |
| 163 | int fShaderIndex; |
| 164 | int fGraphicStateIndex; |
halcanary | 2be7e01 | 2016-03-28 11:58:08 -0700 | [diff] [blame] | 165 | }; |
| 166 | |
edisonn@google.com | 73a7ea3 | 2013-11-11 20:55:15 +0000 | [diff] [blame] | 167 | protected: |
reed | e8f3062 | 2016-03-23 18:59:25 -0700 | [diff] [blame] | 168 | sk_sp<SkSurface> makeSurface(const SkImageInfo&, const SkSurfaceProps&) override; |
edisonn@google.com | 73a7ea3 | 2013-11-11 20:55:15 +0000 | [diff] [blame] | 169 | |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 170 | void drawAnnotation(const SkRect&, const char key[], SkData* value) override; |
reed | f70b531 | 2016-03-04 16:36:20 -0800 | [diff] [blame] | 171 | |
Florin Malita | 53f77bd | 2017-04-28 13:48:37 -0400 | [diff] [blame] | 172 | void drawSpecial(SkSpecialImage*, int x, int y, const SkPaint&, |
| 173 | SkImage*, const SkMatrix&) override; |
reed | e51c356 | 2016-07-19 14:33:20 -0700 | [diff] [blame] | 174 | sk_sp<SkSpecialImage> makeSpecial(const SkBitmap&) override; |
| 175 | sk_sp<SkSpecialImage> makeSpecial(const SkImage*) override; |
| 176 | sk_sp<SkSpecialImage> snapSpecial() override; |
brianosman | 04a44d0 | 2016-09-21 09:46:57 -0700 | [diff] [blame] | 177 | SkImageFilterCache* getImageFilterCache() override; |
reed | e51c356 | 2016-07-19 14:33:20 -0700 | [diff] [blame] | 178 | |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 179 | private: |
halcanary | 91fcb3e | 2016-03-04 13:53:22 -0800 | [diff] [blame] | 180 | struct RectWithData { |
| 181 | SkRect rect; |
halcanary | d7b2885 | 2016-03-07 12:39:14 -0800 | [diff] [blame] | 182 | sk_sp<SkData> data; |
halcanary | 91fcb3e | 2016-03-04 13:53:22 -0800 | [diff] [blame] | 183 | }; |
| 184 | |
| 185 | struct NamedDestination { |
halcanary | d7b2885 | 2016-03-07 12:39:14 -0800 | [diff] [blame] | 186 | sk_sp<SkData> nameData; |
halcanary | 91fcb3e | 2016-03-04 13:53:22 -0800 | [diff] [blame] | 187 | SkPoint point; |
halcanary | 91fcb3e | 2016-03-04 13:53:22 -0800 | [diff] [blame] | 188 | }; |
| 189 | |
ctguil@chromium.org | 769fa6a | 2011-08-20 00:36:18 +0000 | [diff] [blame] | 190 | // 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] | 191 | // order to get the right access levels without using friend. |
vandebo@chromium.org | 13d14a9 | 2011-05-24 23:12:41 +0000 | [diff] [blame] | 192 | friend class ScopedContentEntry; |
vandebo@chromium.org | a0c7edb | 2011-05-09 07:58:08 +0000 | [diff] [blame] | 193 | |
ctguil@chromium.org | 1526129 | 2011-04-29 17:54:16 +0000 | [diff] [blame] | 194 | SkISize fPageSize; |
vandebo@chromium.org | 75f97e4 | 2011-04-11 23:24:18 +0000 | [diff] [blame] | 195 | SkMatrix fInitialTransform; |
vandebo@chromium.org | 9fbdf87 | 2011-05-09 07:55:58 +0000 | [diff] [blame] | 196 | SkClipStack fExistingClipStack; |
wangxianzhu | ef6c50a | 2015-09-17 20:38:02 -0700 | [diff] [blame] | 197 | |
halcanary | 91fcb3e | 2016-03-04 13:53:22 -0800 | [diff] [blame] | 198 | SkTArray<RectWithData> fLinkToURLs; |
| 199 | SkTArray<RectWithData> fLinkToDestinations; |
| 200 | SkTArray<NamedDestination> fNamedDestinations; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 201 | |
halcanary | be27a11 | 2015-04-01 13:31:19 -0700 | [diff] [blame] | 202 | SkTDArray<SkPDFObject*> fGraphicStateResources; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 203 | SkTDArray<SkPDFObject*> fXObjectResources; |
vandebo@chromium.org | 28be72b | 2010-11-11 21:37:00 +0000 | [diff] [blame] | 204 | SkTDArray<SkPDFFont*> fFontResources; |
vandebo@chromium.org | 421d644 | 2011-07-20 17:39:01 +0000 | [diff] [blame] | 205 | SkTDArray<SkPDFObject*> fShaderResources; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 206 | |
halcanary | 2be7e01 | 2016-03-28 11:58:08 -0700 | [diff] [blame] | 207 | struct ContentEntry { |
| 208 | GraphicStateEntry fState; |
| 209 | SkDynamicMemoryWStream fContent; |
| 210 | }; |
| 211 | SkSinglyLinkedList<ContentEntry> fContentEntries; |
ctguil@chromium.org | 8dcf74f | 2011-07-12 21:56:27 +0000 | [diff] [blame] | 212 | |
commit-bot@chromium.org | 8c29490 | 2013-10-21 17:14:37 +0000 | [diff] [blame] | 213 | SkScalar fRasterDpi; |
edisonn@google.com | d9dfa18 | 2013-04-24 13:01:01 +0000 | [diff] [blame] | 214 | |
halcanary | 989da4a | 2016-03-21 14:33:17 -0700 | [diff] [blame] | 215 | SkPDFDocument* fDocument; |
halcanary | a1f1ee9 | 2015-02-20 06:17:26 -0800 | [diff] [blame] | 216 | //////////////////////////////////////////////////////////////////////////// |
| 217 | |
| 218 | SkPDFDevice(SkISize pageSize, |
| 219 | SkScalar rasterDpi, |
halcanary | 989da4a | 2016-03-21 14:33:17 -0700 | [diff] [blame] | 220 | SkPDFDocument* doc, |
halcanary | a1f1ee9 | 2015-02-20 06:17:26 -0800 | [diff] [blame] | 221 | bool flip); |
| 222 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 223 | SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override; |
bsalomon@google.com | e97f085 | 2011-06-17 13:10:25 +0000 | [diff] [blame] | 224 | |
vandebo@chromium.org | 77bcaa3 | 2011-04-15 20:57:37 +0000 | [diff] [blame] | 225 | void init(); |
halcanary | 3c35fb3 | 2016-06-30 11:55:07 -0700 | [diff] [blame] | 226 | void cleanUp(); |
halcanary | 4b1e17e | 2016-07-27 14:49:46 -0700 | [diff] [blame] | 227 | sk_sp<SkPDFObject> makeFormXObjectFromDevice(); |
vandebo@chromium.org | 9fbdf87 | 2011-05-09 07:55:58 +0000 | [diff] [blame] | 228 | |
vandebo@chromium.org | 3b41621 | 2013-10-30 20:48:05 +0000 | [diff] [blame] | 229 | void drawFormXObjectWithMask(int xObjectIndex, |
halcanary | dabd4f0 | 2016-08-03 11:16:56 -0700 | [diff] [blame] | 230 | sk_sp<SkPDFObject> mask, |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 231 | const SkClipStack& clipStack, |
reed | 374772b | 2016-10-05 17:33:02 -0700 | [diff] [blame] | 232 | SkBlendMode, |
vandebo@chromium.org | 481aef6 | 2011-05-24 16:39:05 +0000 | [diff] [blame] | 233 | bool invertClip); |
vandebo@chromium.org | 466f3d6 | 2011-05-18 23:06:29 +0000 | [diff] [blame] | 234 | |
vandebo@chromium.org | b069c8c | 2011-05-24 17:19:38 +0000 | [diff] [blame] | 235 | // If the paint or clip is such that we shouldn't draw anything, this |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 236 | // returns nullptr and does not create a content entry. |
vandebo@chromium.org | b069c8c | 2011-05-24 17:19:38 +0000 | [diff] [blame] | 237 | // setUpContentEntry and finishContentEntry can be used directly, but |
vandebo@chromium.org | 13d14a9 | 2011-05-24 23:12:41 +0000 | [diff] [blame] | 238 | // the preferred method is to use the ScopedContentEntry helper class. |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 239 | ContentEntry* setUpContentEntry(const SkClipStack& clipStack, |
vandebo@chromium.org | b069c8c | 2011-05-24 17:19:38 +0000 | [diff] [blame] | 240 | const SkMatrix& matrix, |
| 241 | const SkPaint& paint, |
| 242 | bool hasText, |
halcanary | dabd4f0 | 2016-08-03 11:16:56 -0700 | [diff] [blame] | 243 | sk_sp<SkPDFObject>* dst); |
reed | 374772b | 2016-10-05 17:33:02 -0700 | [diff] [blame] | 244 | void finishContentEntry(SkBlendMode, sk_sp<SkPDFObject> dst, SkPath* shape); |
vandebo@chromium.org | 481aef6 | 2011-05-24 16:39:05 +0000 | [diff] [blame] | 245 | bool isContentEmpty(); |
| 246 | |
vandebo@chromium.org | 9fbdf87 | 2011-05-09 07:55:58 +0000 | [diff] [blame] | 247 | void populateGraphicStateEntryFromPaint(const SkMatrix& matrix, |
| 248 | const SkClipStack& clipStack, |
vandebo@chromium.org | 9fbdf87 | 2011-05-09 07:55:58 +0000 | [diff] [blame] | 249 | const SkPaint& paint, |
| 250 | bool hasText, |
| 251 | GraphicStateEntry* entry); |
halcanary | be27a11 | 2015-04-01 13:31:19 -0700 | [diff] [blame] | 252 | int addGraphicStateResource(SkPDFObject* gs); |
vandebo@chromium.org | 3b41621 | 2013-10-30 20:48:05 +0000 | [diff] [blame] | 253 | int addXObjectResource(SkPDFObject* xObject); |
vandebo@chromium.org | 9fbdf87 | 2011-05-09 07:55:58 +0000 | [diff] [blame] | 254 | |
ctguil@chromium.org | 9db86bb | 2011-03-04 21:43:27 +0000 | [diff] [blame] | 255 | int getFontResourceIndex(SkTypeface* typeface, uint16_t glyphID); |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 256 | |
halcanary | 4ed2f01 | 2016-08-15 18:40:07 -0700 | [diff] [blame] | 257 | |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 258 | void internalDrawText( const void*, size_t, const SkScalar pos[], |
halcanary | e06ca96 | 2016-09-09 05:34:55 -0700 | [diff] [blame] | 259 | SkTextBlob::GlyphPositioning, SkPoint, const SkPaint&, |
| 260 | const uint32_t*, uint32_t, const char*); |
halcanary | 4ed2f01 | 2016-08-15 18:40:07 -0700 | [diff] [blame] | 261 | |
vandebo@chromium.org | b069c8c | 2011-05-24 17:19:38 +0000 | [diff] [blame] | 262 | void internalDrawPaint(const SkPaint& paint, ContentEntry* contentEntry); |
halcanary | a50151d | 2016-03-25 11:57:49 -0700 | [diff] [blame] | 263 | |
| 264 | void internalDrawImage(const SkMatrix& origMatrix, |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 265 | const SkClipStack& clipStack, |
Hal Canary | f50ff39 | 2016-09-30 10:25:39 -0400 | [diff] [blame] | 266 | SkImageSubset imageSubset, |
halcanary | 7a14b31 | 2015-10-01 07:28:13 -0700 | [diff] [blame] | 267 | const SkPaint& paint); |
vandebo@chromium.org | 9fbdf87 | 2011-05-09 07:55:58 +0000 | [diff] [blame] | 268 | |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 269 | void internalDrawPath(const SkClipStack&, |
| 270 | const SkMatrix&, |
| 271 | const SkPath&, |
| 272 | const SkPaint&, |
| 273 | const SkMatrix* prePathMatrix, |
| 274 | bool pathIsMutable); |
| 275 | |
Hal Canary | d12a676 | 2017-05-26 17:01:16 -0400 | [diff] [blame] | 276 | void internalDrawPathWithFilter(const SkClipStack& clipStack, |
| 277 | const SkMatrix& ctm, |
| 278 | const SkPath& origPath, |
| 279 | const SkPaint& paint, |
| 280 | const SkMatrix* prePathMatrix); |
| 281 | |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 282 | bool handleInversePath(const SkPath& origPath, |
edisonn@google.com | a9ebd16 | 2013-10-07 13:22:21 +0000 | [diff] [blame] | 283 | const SkPaint& paint, bool pathIsMutable, |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 284 | const SkMatrix* prePathMatrix = nullptr); |
vandebo@chromium.org | 238be8c | 2012-07-13 20:06:02 +0000 | [diff] [blame] | 285 | |
Mike Reed | f0fb929 | 2017-02-21 13:15:07 -0500 | [diff] [blame] | 286 | typedef SkClipStackDevice INHERITED; |
commit-bot@chromium.org | 5e00989 | 2013-10-14 13:42:12 +0000 | [diff] [blame] | 287 | |
| 288 | // TODO(edisonn): Only SkDocument_PDF and SkPDFImageShader should be able to create |
| 289 | // an SkPDFDevice |
| 290 | //friend class SkDocument_PDF; |
| 291 | //friend class SkPDFImageShader; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 292 | }; |
| 293 | |
| 294 | #endif |