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" |
Florin Malita | ab54e73 | 2018-07-27 09:47:15 -0400 | [diff] [blame^] | 22 | #include "SkTextBlobPriv.h" |
Hal Canary | 7cbf5e3 | 2017-07-12 13:10:23 -0400 | [diff] [blame] | 23 | #include "SkKeyedImage.h" |
halcanary | 2be7e01 | 2016-03-28 11:58:08 -0700 | [diff] [blame] | 24 | |
Herb Derby | 736db10 | 2018-07-19 12:52:16 -0400 | [diff] [blame] | 25 | class SkGlyphRunList; |
Hal Canary | 7cbf5e3 | 2017-07-12 13:10:23 -0400 | [diff] [blame] | 26 | class SkKeyedImage; |
martina.kollarova | b8d6af1 | 2016-06-29 05:12:31 -0700 | [diff] [blame] | 27 | class SkPath; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 28 | class SkPDFArray; |
halcanary | a1f1ee9 | 2015-02-20 06:17:26 -0800 | [diff] [blame] | 29 | class SkPDFCanon; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 30 | class SkPDFDevice; |
halcanary | 989da4a | 2016-03-21 14:33:17 -0700 | [diff] [blame] | 31 | class SkPDFDocument; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 32 | class SkPDFDict; |
vandebo@chromium.org | 28be72b | 2010-11-11 21:37:00 +0000 | [diff] [blame] | 33 | class SkPDFFont; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 34 | class SkPDFObject; |
halcanary | 4b1e17e | 2016-07-27 14:49:46 -0700 | [diff] [blame] | 35 | class SkPDFStream; |
scroggo@google.com | a8e33a9 | 2013-11-08 18:02:53 +0000 | [diff] [blame] | 36 | class SkRRect; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 37 | |
Hal Canary | a062258 | 2017-06-29 18:51:35 -0400 | [diff] [blame] | 38 | /** |
| 39 | * \class SkPDFDevice |
| 40 | * |
| 41 | * An SkPDFDevice is the drawing context for a page or layer of PDF |
| 42 | * content. |
| 43 | */ |
Mike Reed | f0fb929 | 2017-02-21 13:15:07 -0500 | [diff] [blame] | 44 | class SkPDFDevice final : public SkClipStackDevice { |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 45 | public: |
Hal Canary | a062258 | 2017-06-29 18:51:35 -0400 | [diff] [blame] | 46 | /** |
halcanary | a1f1ee9 | 2015-02-20 06:17:26 -0800 | [diff] [blame] | 47 | * @param pageSize Page size in point units. |
| 48 | * 1 point == 127/360 mm == 1/72 inch |
Hal Canary | a062258 | 2017-06-29 18:51:35 -0400 | [diff] [blame] | 49 | * @param document A non-null pointer back to the |
| 50 | * PDFDocument object. The document is repsonsible for |
halcanary | 989da4a | 2016-03-21 14:33:17 -0700 | [diff] [blame] | 51 | * de-duplicating across pages (via the SkPDFCanon) and |
| 52 | * for early serializing of large immutable objects, such |
| 53 | * as images (via SkPDFDocument::serialize()). |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 54 | */ |
Hal Canary | a062258 | 2017-06-29 18:51:35 -0400 | [diff] [blame] | 55 | SkPDFDevice(SkISize pageSize, SkPDFDocument* document); |
halcanary | a1f1ee9 | 2015-02-20 06:17:26 -0800 | [diff] [blame] | 56 | |
Hal Canary | a062258 | 2017-06-29 18:51:35 -0400 | [diff] [blame] | 57 | /** |
| 58 | * Apply a scale-and-translate transform to move the origin from the |
| 59 | * bottom left (PDF default) to the top left (Skia default). |
| 60 | */ |
| 61 | void setFlip(); |
Hal Canary | 51329c9 | 2017-06-27 14:28:37 -0400 | [diff] [blame] | 62 | |
| 63 | sk_sp<SkPDFDevice> makeCongruentDevice() { |
Hal Canary | a062258 | 2017-06-29 18:51:35 -0400 | [diff] [blame] | 64 | return sk_make_sp<SkPDFDevice>(fPageSize, fDocument); |
halcanary | a1f1ee9 | 2015-02-20 06:17:26 -0800 | [diff] [blame] | 65 | } |
| 66 | |
Brian Salomon | d3b6597 | 2017-03-22 12:05:03 -0400 | [diff] [blame] | 67 | ~SkPDFDevice() override; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 68 | |
Hal Canary | a062258 | 2017-06-29 18:51:35 -0400 | [diff] [blame] | 69 | /** |
| 70 | * These are called inside the per-device-layer loop for each draw call. |
| 71 | * When these are called, we have already applied any saveLayer |
Ben Wagner | 2c312c4 | 2018-06-27 14:46:46 -0400 | [diff] [blame] | 72 | * operations, and are handling any looping from the paint. |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 73 | */ |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 74 | void drawPaint(const SkPaint& paint) override; |
| 75 | void drawPoints(SkCanvas::PointMode mode, |
tfarina | fa4f6cb | 2014-12-21 10:27:07 -0800 | [diff] [blame] | 76 | size_t count, const SkPoint[], |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 77 | const SkPaint& paint) override; |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 78 | void drawRect(const SkRect& r, const SkPaint& paint) override; |
| 79 | void drawOval(const SkRect& oval, const SkPaint& paint) override; |
| 80 | void drawRRect(const SkRRect& rr, const SkPaint& paint) override; |
| 81 | void drawPath(const SkPath& origpath, |
tfarina | fa4f6cb | 2014-12-21 10:27:07 -0800 | [diff] [blame] | 82 | const SkPaint& paint, const SkMatrix* prePathMatrix, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 83 | bool pathIsMutable) override; |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 84 | void drawBitmapRect(const SkBitmap& bitmap, const SkRect* src, |
reed | 562fe47 | 2015-07-28 07:35:14 -0700 | [diff] [blame] | 85 | const SkRect& dst, const SkPaint&, SkCanvas::SrcRectConstraint) override; |
Hal Canary | b964238 | 2017-06-27 09:58:56 -0400 | [diff] [blame] | 86 | void drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, const SkPaint&) override; |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 87 | void drawSprite(const SkBitmap& bitmap, int x, int y, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 88 | const SkPaint& paint) override; |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 89 | void drawImage(const SkImage*, |
halcanary | 7a14b31 | 2015-10-01 07:28:13 -0700 | [diff] [blame] | 90 | SkScalar x, |
| 91 | SkScalar y, |
| 92 | const SkPaint&) override; |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 93 | void drawImageRect(const SkImage*, |
halcanary | 7a14b31 | 2015-10-01 07:28:13 -0700 | [diff] [blame] | 94 | const SkRect* src, |
| 95 | const SkRect& dst, |
| 96 | const SkPaint&, |
| 97 | SkCanvas::SrcRectConstraint) override; |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 98 | void drawPosText(const void* text, size_t len, |
tfarina | fa4f6cb | 2014-12-21 10:27:07 -0800 | [diff] [blame] | 99 | const SkScalar pos[], int scalarsPerPos, |
Hal Canary | 98caedd | 2018-07-23 10:50:49 -0400 | [diff] [blame] | 100 | const SkPoint& offset, const SkPaint&) override { SkASSERT(false); } |
Herb Derby | b935cf8 | 2018-07-26 16:54:18 -0400 | [diff] [blame] | 101 | void drawGlyphRunList(const SkGlyphRunList& glyphRunList) override; |
Ruiqi Mao | f510149 | 2018-06-29 14:32:21 -0400 | [diff] [blame] | 102 | void drawVertices(const SkVertices*, const SkMatrix* bones, int boneCount, SkBlendMode, |
| 103 | const SkPaint&) override; |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 104 | void drawDevice(SkBaseDevice*, int x, int y, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 105 | const SkPaint&) override; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 106 | |
| 107 | // PDF specific methods. |
| 108 | |
halcanary | 8103a34 | 2016-03-08 15:10:16 -0800 | [diff] [blame] | 109 | /** Create the resource dictionary for this device. */ |
| 110 | sk_sp<SkPDFDict> makeResourceDict() const; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 111 | |
wangxianzhu | ef6c50a | 2015-09-17 20:38:02 -0700 | [diff] [blame] | 112 | /** Add our annotations (link to urls and destinations) to the supplied |
| 113 | * array. |
| 114 | * @param array Array to add annotations to. |
| 115 | */ |
| 116 | void appendAnnotations(SkPDFArray* array) const; |
| 117 | |
epoger@google.com | b58772f | 2013-03-08 09:09:10 +0000 | [diff] [blame] | 118 | /** Add our named destinations to the supplied dictionary. |
| 119 | * @param dict Dictionary to add destinations to. |
| 120 | * @param page The PDF object representing the page for this device. |
| 121 | */ |
halcanary | 6d62270 | 2015-03-25 08:45:42 -0700 | [diff] [blame] | 122 | void appendDestinations(SkPDFDict* dict, SkPDFObject* page) const; |
epoger@google.com | b58772f | 2013-03-08 09:09:10 +0000 | [diff] [blame] | 123 | |
halcanary | 8103a34 | 2016-03-08 15:10:16 -0800 | [diff] [blame] | 124 | /** Returns a copy of the media box for this device. */ |
| 125 | sk_sp<SkPDFArray> copyMediaBox() const; |
halcanary | 51d04d3 | 2016-03-08 13:03:55 -0800 | [diff] [blame] | 126 | |
halcanary | 8103a34 | 2016-03-08 15:10:16 -0800 | [diff] [blame] | 127 | /** Returns a SkStream with the page contents. |
halcanary | 51d04d3 | 2016-03-08 13:03:55 -0800 | [diff] [blame] | 128 | */ |
mtklein | 5f939ab | 2016-03-16 10:28:35 -0700 | [diff] [blame] | 129 | std::unique_ptr<SkStreamAsset> content() const; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 130 | |
halcanary | 989da4a | 2016-03-21 14:33:17 -0700 | [diff] [blame] | 131 | SkPDFCanon* getCanon() const; |
halcanary | 26b5d15 | 2015-03-25 08:38:03 -0700 | [diff] [blame] | 132 | |
Hal Canary | 22b2d8c | 2017-07-19 14:46:12 -0400 | [diff] [blame] | 133 | SkIRect bounds() const { return this->imageInfo().bounds(); } |
| 134 | |
halcanary | 2be7e01 | 2016-03-28 11:58:08 -0700 | [diff] [blame] | 135 | // It is important to not confuse GraphicStateEntry with SkPDFGraphicState, the |
| 136 | // later being our representation of an object in the PDF file. |
| 137 | struct GraphicStateEntry { |
| 138 | GraphicStateEntry(); |
| 139 | |
| 140 | // Compare the fields we care about when setting up a new content entry. |
| 141 | bool compareInitialState(const GraphicStateEntry& b); |
| 142 | |
| 143 | SkMatrix fMatrix; |
| 144 | // We can't do set operations on Paths, though PDF natively supports |
| 145 | // intersect. If the clip stack does anything other than intersect, |
| 146 | // we have to fall back to the region. Treat fClipStack as authoritative. |
| 147 | // See https://bugs.skia.org/221 |
| 148 | SkClipStack fClipStack; |
halcanary | 2be7e01 | 2016-03-28 11:58:08 -0700 | [diff] [blame] | 149 | |
| 150 | // When emitting the content entry, we will ensure the graphic state |
| 151 | // is set to these values first. |
| 152 | SkColor fColor; |
| 153 | SkScalar fTextScaleX; // Zero means we don't care what the value is. |
| 154 | SkPaint::Style fTextFill; // Only if TextScaleX is non-zero. |
| 155 | int fShaderIndex; |
| 156 | int fGraphicStateIndex; |
halcanary | 2be7e01 | 2016-03-28 11:58:08 -0700 | [diff] [blame] | 157 | }; |
| 158 | |
edisonn@google.com | 73a7ea3 | 2013-11-11 20:55:15 +0000 | [diff] [blame] | 159 | protected: |
reed | e8f3062 | 2016-03-23 18:59:25 -0700 | [diff] [blame] | 160 | sk_sp<SkSurface> makeSurface(const SkImageInfo&, const SkSurfaceProps&) override; |
edisonn@google.com | 73a7ea3 | 2013-11-11 20:55:15 +0000 | [diff] [blame] | 161 | |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 162 | void drawAnnotation(const SkRect&, const char key[], SkData* value) override; |
reed | f70b531 | 2016-03-04 16:36:20 -0800 | [diff] [blame] | 163 | |
Florin Malita | 53f77bd | 2017-04-28 13:48:37 -0400 | [diff] [blame] | 164 | void drawSpecial(SkSpecialImage*, int x, int y, const SkPaint&, |
| 165 | SkImage*, const SkMatrix&) override; |
reed | e51c356 | 2016-07-19 14:33:20 -0700 | [diff] [blame] | 166 | sk_sp<SkSpecialImage> makeSpecial(const SkBitmap&) override; |
| 167 | sk_sp<SkSpecialImage> makeSpecial(const SkImage*) override; |
| 168 | sk_sp<SkSpecialImage> snapSpecial() override; |
brianosman | 04a44d0 | 2016-09-21 09:46:57 -0700 | [diff] [blame] | 169 | SkImageFilterCache* getImageFilterCache() override; |
reed | e51c356 | 2016-07-19 14:33:20 -0700 | [diff] [blame] | 170 | |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 171 | private: |
halcanary | 91fcb3e | 2016-03-04 13:53:22 -0800 | [diff] [blame] | 172 | struct RectWithData { |
| 173 | SkRect rect; |
halcanary | d7b2885 | 2016-03-07 12:39:14 -0800 | [diff] [blame] | 174 | sk_sp<SkData> data; |
halcanary | 91fcb3e | 2016-03-04 13:53:22 -0800 | [diff] [blame] | 175 | }; |
| 176 | |
| 177 | struct NamedDestination { |
halcanary | d7b2885 | 2016-03-07 12:39:14 -0800 | [diff] [blame] | 178 | sk_sp<SkData> nameData; |
halcanary | 91fcb3e | 2016-03-04 13:53:22 -0800 | [diff] [blame] | 179 | SkPoint point; |
halcanary | 91fcb3e | 2016-03-04 13:53:22 -0800 | [diff] [blame] | 180 | }; |
| 181 | |
ctguil@chromium.org | 769fa6a | 2011-08-20 00:36:18 +0000 | [diff] [blame] | 182 | // 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] | 183 | // order to get the right access levels without using friend. |
vandebo@chromium.org | 13d14a9 | 2011-05-24 23:12:41 +0000 | [diff] [blame] | 184 | friend class ScopedContentEntry; |
vandebo@chromium.org | a0c7edb | 2011-05-09 07:58:08 +0000 | [diff] [blame] | 185 | |
ctguil@chromium.org | 1526129 | 2011-04-29 17:54:16 +0000 | [diff] [blame] | 186 | SkISize fPageSize; |
vandebo@chromium.org | 75f97e4 | 2011-04-11 23:24:18 +0000 | [diff] [blame] | 187 | SkMatrix fInitialTransform; |
vandebo@chromium.org | 9fbdf87 | 2011-05-09 07:55:58 +0000 | [diff] [blame] | 188 | SkClipStack fExistingClipStack; |
wangxianzhu | ef6c50a | 2015-09-17 20:38:02 -0700 | [diff] [blame] | 189 | |
halcanary | 91fcb3e | 2016-03-04 13:53:22 -0800 | [diff] [blame] | 190 | SkTArray<RectWithData> fLinkToURLs; |
| 191 | SkTArray<RectWithData> fLinkToDestinations; |
| 192 | SkTArray<NamedDestination> fNamedDestinations; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 193 | |
halcanary | be27a11 | 2015-04-01 13:31:19 -0700 | [diff] [blame] | 194 | SkTDArray<SkPDFObject*> fGraphicStateResources; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 195 | SkTDArray<SkPDFObject*> fXObjectResources; |
vandebo@chromium.org | 28be72b | 2010-11-11 21:37:00 +0000 | [diff] [blame] | 196 | SkTDArray<SkPDFFont*> fFontResources; |
vandebo@chromium.org | 421d644 | 2011-07-20 17:39:01 +0000 | [diff] [blame] | 197 | SkTDArray<SkPDFObject*> fShaderResources; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 198 | |
halcanary | 2be7e01 | 2016-03-28 11:58:08 -0700 | [diff] [blame] | 199 | struct ContentEntry { |
| 200 | GraphicStateEntry fState; |
| 201 | SkDynamicMemoryWStream fContent; |
| 202 | }; |
| 203 | SkSinglyLinkedList<ContentEntry> fContentEntries; |
ctguil@chromium.org | 8dcf74f | 2011-07-12 21:56:27 +0000 | [diff] [blame] | 204 | |
halcanary | 989da4a | 2016-03-21 14:33:17 -0700 | [diff] [blame] | 205 | SkPDFDocument* fDocument; |
halcanary | a1f1ee9 | 2015-02-20 06:17:26 -0800 | [diff] [blame] | 206 | |
Hal Canary | a062258 | 2017-06-29 18:51:35 -0400 | [diff] [blame] | 207 | //////////////////////////////////////////////////////////////////////////// |
halcanary | a1f1ee9 | 2015-02-20 06:17:26 -0800 | [diff] [blame] | 208 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 209 | SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override; |
bsalomon@google.com | e97f085 | 2011-06-17 13:10:25 +0000 | [diff] [blame] | 210 | |
vandebo@chromium.org | 77bcaa3 | 2011-04-15 20:57:37 +0000 | [diff] [blame] | 211 | void init(); |
halcanary | 3c35fb3 | 2016-06-30 11:55:07 -0700 | [diff] [blame] | 212 | void cleanUp(); |
Hal Canary | b4bd5ef | 2017-07-26 09:16:01 -0400 | [diff] [blame] | 213 | // Set alpha to true if making a transparency group form x-objects. |
| 214 | sk_sp<SkPDFObject> makeFormXObjectFromDevice(bool alpha = false); |
vandebo@chromium.org | 9fbdf87 | 2011-05-09 07:55:58 +0000 | [diff] [blame] | 215 | |
vandebo@chromium.org | 3b41621 | 2013-10-30 20:48:05 +0000 | [diff] [blame] | 216 | void drawFormXObjectWithMask(int xObjectIndex, |
halcanary | dabd4f0 | 2016-08-03 11:16:56 -0700 | [diff] [blame] | 217 | sk_sp<SkPDFObject> mask, |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 218 | const SkClipStack& clipStack, |
reed | 374772b | 2016-10-05 17:33:02 -0700 | [diff] [blame] | 219 | SkBlendMode, |
vandebo@chromium.org | 481aef6 | 2011-05-24 16:39:05 +0000 | [diff] [blame] | 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 |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 223 | // returns nullptr and does not create a content entry. |
vandebo@chromium.org | b069c8c | 2011-05-24 17:19:38 +0000 | [diff] [blame] | 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. |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 226 | ContentEntry* setUpContentEntry(const SkClipStack& clipStack, |
vandebo@chromium.org | b069c8c | 2011-05-24 17:19:38 +0000 | [diff] [blame] | 227 | const SkMatrix& matrix, |
| 228 | const SkPaint& paint, |
| 229 | bool hasText, |
halcanary | dabd4f0 | 2016-08-03 11:16:56 -0700 | [diff] [blame] | 230 | sk_sp<SkPDFObject>* dst); |
reed | 374772b | 2016-10-05 17:33:02 -0700 | [diff] [blame] | 231 | void finishContentEntry(SkBlendMode, sk_sp<SkPDFObject> dst, SkPath* shape); |
vandebo@chromium.org | 481aef6 | 2011-05-24 16:39:05 +0000 | [diff] [blame] | 232 | bool isContentEmpty(); |
| 233 | |
vandebo@chromium.org | 9fbdf87 | 2011-05-09 07:55:58 +0000 | [diff] [blame] | 234 | void populateGraphicStateEntryFromPaint(const SkMatrix& matrix, |
| 235 | const SkClipStack& clipStack, |
vandebo@chromium.org | 9fbdf87 | 2011-05-09 07:55:58 +0000 | [diff] [blame] | 236 | const SkPaint& paint, |
| 237 | bool hasText, |
| 238 | GraphicStateEntry* entry); |
halcanary | be27a11 | 2015-04-01 13:31:19 -0700 | [diff] [blame] | 239 | int addGraphicStateResource(SkPDFObject* gs); |
vandebo@chromium.org | 3b41621 | 2013-10-30 20:48:05 +0000 | [diff] [blame] | 240 | int addXObjectResource(SkPDFObject* xObject); |
vandebo@chromium.org | 9fbdf87 | 2011-05-09 07:55:58 +0000 | [diff] [blame] | 241 | |
ctguil@chromium.org | 9db86bb | 2011-03-04 21:43:27 +0000 | [diff] [blame] | 242 | int getFontResourceIndex(SkTypeface* typeface, uint16_t glyphID); |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 243 | |
Hal Canary | 98caedd | 2018-07-23 10:50:49 -0400 | [diff] [blame] | 244 | void internalDrawGlyphRun(const SkGlyphRun& glyphRun, SkPoint offset); |
halcanary | 4ed2f01 | 2016-08-15 18:40:07 -0700 | [diff] [blame] | 245 | |
vandebo@chromium.org | b069c8c | 2011-05-24 17:19:38 +0000 | [diff] [blame] | 246 | void internalDrawPaint(const SkPaint& paint, ContentEntry* contentEntry); |
halcanary | a50151d | 2016-03-25 11:57:49 -0700 | [diff] [blame] | 247 | |
Hal Canary | 7cbf5e3 | 2017-07-12 13:10:23 -0400 | [diff] [blame] | 248 | void internalDrawImageRect(SkKeyedImage, |
| 249 | const SkRect* src, |
| 250 | const SkRect& dst, |
| 251 | const SkPaint&, |
| 252 | const SkMatrix& canvasTransformationMatrix); |
vandebo@chromium.org | 9fbdf87 | 2011-05-09 07:55:58 +0000 | [diff] [blame] | 253 | |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 254 | void internalDrawPath(const SkClipStack&, |
| 255 | const SkMatrix&, |
| 256 | const SkPath&, |
| 257 | const SkPaint&, |
| 258 | const SkMatrix* prePathMatrix, |
| 259 | bool pathIsMutable); |
| 260 | |
Hal Canary | d12a676 | 2017-05-26 17:01:16 -0400 | [diff] [blame] | 261 | void internalDrawPathWithFilter(const SkClipStack& clipStack, |
| 262 | const SkMatrix& ctm, |
| 263 | const SkPath& origPath, |
| 264 | const SkPaint& paint, |
| 265 | const SkMatrix* prePathMatrix); |
| 266 | |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 267 | bool handleInversePath(const SkPath& origPath, |
edisonn@google.com | a9ebd16 | 2013-10-07 13:22:21 +0000 | [diff] [blame] | 268 | const SkPaint& paint, bool pathIsMutable, |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 269 | const SkMatrix* prePathMatrix = nullptr); |
vandebo@chromium.org | 238be8c | 2012-07-13 20:06:02 +0000 | [diff] [blame] | 270 | |
Hal Canary | 51329c9 | 2017-06-27 14:28:37 -0400 | [diff] [blame] | 271 | void addSMaskGraphicState(sk_sp<SkPDFDevice> maskDevice, SkDynamicMemoryWStream*); |
| 272 | void clearMaskOnGraphicState(SkDynamicMemoryWStream*); |
commit-bot@chromium.org | 5e00989 | 2013-10-14 13:42:12 +0000 | [diff] [blame] | 273 | |
Hal Canary | b4e528d | 2018-03-09 16:02:15 -0500 | [diff] [blame] | 274 | bool hasEmptyClip() const { return this->cs().isEmpty(this->bounds()); } |
| 275 | |
Hal Canary | 51329c9 | 2017-06-27 14:28:37 -0400 | [diff] [blame] | 276 | typedef SkClipStackDevice INHERITED; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 277 | }; |
| 278 | |
| 279 | #endif |