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" |
Hal Canary | b10f92e | 2018-11-16 17:01:50 -0500 | [diff] [blame] | 16 | #include "SkKeyedImage.h" |
Hal Canary | 7480158 | 2018-12-18 16:30:41 -0500 | [diff] [blame] | 17 | #include "SkPDFTypes.h" |
vandebo@chromium.org | a518086 | 2010-10-26 19:48:49 +0000 | [diff] [blame] | 18 | #include "SkPaint.h" |
vandebo@chromium.org | 238be8c | 2012-07-13 20:06:02 +0000 | [diff] [blame] | 19 | #include "SkRect.h" |
vandebo@chromium.org | 9fbdf87 | 2011-05-09 07:55:58 +0000 | [diff] [blame] | 20 | #include "SkRefCnt.h" |
| 21 | #include "SkStream.h" |
Hal Canary | b10f92e | 2018-11-16 17:01:50 -0500 | [diff] [blame] | 22 | #include "SkTHash.h" |
Florin Malita | ab54e73 | 2018-07-27 09:47:15 -0400 | [diff] [blame] | 23 | #include "SkTextBlobPriv.h" |
halcanary | 2be7e01 | 2016-03-28 11:58:08 -0700 | [diff] [blame] | 24 | |
Hal Canary | 9e41c21 | 2018-09-03 12:00:23 -0400 | [diff] [blame] | 25 | #include <vector> |
| 26 | |
Herb Derby | 736db10 | 2018-07-19 12:52:16 -0400 | [diff] [blame] | 27 | class SkGlyphRunList; |
Hal Canary | 7cbf5e3 | 2017-07-12 13:10:23 -0400 | [diff] [blame] | 28 | class SkKeyedImage; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 29 | class SkPDFArray; |
| 30 | class SkPDFDevice; |
| 31 | class SkPDFDict; |
Hal Canary | 4ca9fa3 | 2018-12-21 16:15:01 -0500 | [diff] [blame] | 32 | class SkPDFDocument; |
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; |
Hal Canary | 4ca9fa3 | 2018-12-21 16:15:01 -0500 | [diff] [blame] | 35 | class SkPath; |
scroggo@google.com | a8e33a9 | 2013-11-08 18:02:53 +0000 | [diff] [blame] | 36 | class SkRRect; |
Hal Canary | b10f92e | 2018-11-16 17:01:50 -0500 | [diff] [blame] | 37 | struct SkPDFIndirectReference; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 38 | |
Hal Canary | a062258 | 2017-06-29 18:51:35 -0400 | [diff] [blame] | 39 | /** |
| 40 | * \class SkPDFDevice |
| 41 | * |
| 42 | * An SkPDFDevice is the drawing context for a page or layer of PDF |
| 43 | * content. |
| 44 | */ |
Mike Reed | f0fb929 | 2017-02-21 13:15:07 -0500 | [diff] [blame] | 45 | class SkPDFDevice final : public SkClipStackDevice { |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 46 | public: |
Hal Canary | a062258 | 2017-06-29 18:51:35 -0400 | [diff] [blame] | 47 | /** |
halcanary | a1f1ee9 | 2015-02-20 06:17:26 -0800 | [diff] [blame] | 48 | * @param pageSize Page size in point units. |
| 49 | * 1 point == 127/360 mm == 1/72 inch |
Hal Canary | a062258 | 2017-06-29 18:51:35 -0400 | [diff] [blame] | 50 | * @param document A non-null pointer back to the |
Hal Canary | ac907bd | 2019-01-09 14:00:49 -0500 | [diff] [blame] | 51 | * PDFDocument object. The document is responsible for |
Hal Canary | 4ca9fa3 | 2018-12-21 16:15:01 -0500 | [diff] [blame] | 52 | * de-duplicating across pages (via the SkPDFDocument) and |
halcanary | 989da4a | 2016-03-21 14:33:17 -0700 | [diff] [blame] | 53 | * for early serializing of large immutable objects, such |
| 54 | * as images (via SkPDFDocument::serialize()). |
Hal Canary | 7d06ab2 | 2018-09-10 14:39:13 -0400 | [diff] [blame] | 55 | * @param initialTransform Transform to be applied to the entire page. |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 56 | */ |
Hal Canary | 7d06ab2 | 2018-09-10 14:39:13 -0400 | [diff] [blame] | 57 | SkPDFDevice(SkISize pageSize, SkPDFDocument* document, |
| 58 | const SkMatrix& initialTransform = SkMatrix::I()); |
Hal Canary | 51329c9 | 2017-06-27 14:28:37 -0400 | [diff] [blame] | 59 | |
| 60 | sk_sp<SkPDFDevice> makeCongruentDevice() { |
Hal Canary | 813b5ac | 2018-09-28 12:30:37 -0400 | [diff] [blame] | 61 | return sk_make_sp<SkPDFDevice>(this->size(), fDocument); |
halcanary | a1f1ee9 | 2015-02-20 06:17:26 -0800 | [diff] [blame] | 62 | } |
| 63 | |
Brian Salomon | d3b6597 | 2017-03-22 12:05:03 -0400 | [diff] [blame] | 64 | ~SkPDFDevice() override; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 65 | |
Hal Canary | a062258 | 2017-06-29 18:51:35 -0400 | [diff] [blame] | 66 | /** |
| 67 | * These are called inside the per-device-layer loop for each draw call. |
| 68 | * When these are called, we have already applied any saveLayer |
Ben Wagner | 2c312c4 | 2018-06-27 14:46:46 -0400 | [diff] [blame] | 69 | * operations, and are handling any looping from the paint. |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 70 | */ |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 71 | void drawPaint(const SkPaint& paint) override; |
| 72 | void drawPoints(SkCanvas::PointMode mode, |
tfarina | fa4f6cb | 2014-12-21 10:27:07 -0800 | [diff] [blame] | 73 | size_t count, const SkPoint[], |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 74 | const SkPaint& paint) override; |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 75 | void drawRect(const SkRect& r, const SkPaint& paint) override; |
| 76 | void drawOval(const SkRect& oval, const SkPaint& paint) override; |
| 77 | void drawRRect(const SkRRect& rr, const SkPaint& paint) override; |
Robert Phillips | 137ca52 | 2018-08-15 10:14:33 -0400 | [diff] [blame] | 78 | void drawPath(const SkPath& origpath, const SkPaint& paint, bool pathIsMutable) override; |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 79 | void drawBitmapRect(const SkBitmap& bitmap, const SkRect* src, |
reed | 562fe47 | 2015-07-28 07:35:14 -0700 | [diff] [blame] | 80 | const SkRect& dst, const SkPaint&, SkCanvas::SrcRectConstraint) override; |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 81 | void drawSprite(const SkBitmap& bitmap, int x, int y, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 82 | const SkPaint& paint) override; |
Michael Ludwig | b7d64b9 | 2019-02-11 11:09:15 -0500 | [diff] [blame] | 83 | |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 84 | void drawImageRect(const SkImage*, |
halcanary | 7a14b31 | 2015-10-01 07:28:13 -0700 | [diff] [blame] | 85 | const SkRect* src, |
| 86 | const SkRect& dst, |
| 87 | const SkPaint&, |
| 88 | SkCanvas::SrcRectConstraint) override; |
Herb Derby | b935cf8 | 2018-07-26 16:54:18 -0400 | [diff] [blame] | 89 | void drawGlyphRunList(const SkGlyphRunList& glyphRunList) override; |
Ruiqi Mao | c97a339 | 2018-08-15 10:44:19 -0400 | [diff] [blame] | 90 | void drawVertices(const SkVertices*, const SkVertices::Bone bones[], int boneCount, SkBlendMode, |
Ruiqi Mao | f510149 | 2018-06-29 14:32:21 -0400 | [diff] [blame] | 91 | const SkPaint&) override; |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 92 | void drawDevice(SkBaseDevice*, int x, int y, |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 93 | const SkPaint&) override; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 94 | |
| 95 | // PDF specific methods. |
| 96 | |
Hal Canary | 9e41c21 | 2018-09-03 12:00:23 -0400 | [diff] [blame] | 97 | /** Create the resource dictionary for this device. Destructive. */ |
Hal Canary | 7480158 | 2018-12-18 16:30:41 -0500 | [diff] [blame] | 98 | std::unique_ptr<SkPDFDict> makeResourceDict(); |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 99 | |
Hal Canary | 9e41c21 | 2018-09-03 12:00:23 -0400 | [diff] [blame] | 100 | /** return annotations (link to urls and destinations) or nulltpr */ |
Hal Canary | 7480158 | 2018-12-18 16:30:41 -0500 | [diff] [blame] | 101 | std::unique_ptr<SkPDFArray> getAnnotations(); |
wangxianzhu | ef6c50a | 2015-09-17 20:38:02 -0700 | [diff] [blame] | 102 | |
epoger@google.com | b58772f | 2013-03-08 09:09:10 +0000 | [diff] [blame] | 103 | /** Add our named destinations to the supplied dictionary. |
| 104 | * @param dict Dictionary to add destinations to. |
| 105 | * @param page The PDF object representing the page for this device. |
| 106 | */ |
Hal Canary | fba5b6c | 2018-12-18 12:55:18 -0500 | [diff] [blame] | 107 | void appendDestinations(SkPDFDict* dict, SkPDFIndirectReference page) const; |
epoger@google.com | b58772f | 2013-03-08 09:09:10 +0000 | [diff] [blame] | 108 | |
halcanary | 8103a34 | 2016-03-08 15:10:16 -0800 | [diff] [blame] | 109 | /** Returns a SkStream with the page contents. |
halcanary | 51d04d3 | 2016-03-08 13:03:55 -0800 | [diff] [blame] | 110 | */ |
Hal Canary | b400d4d | 2018-09-26 16:33:52 -0400 | [diff] [blame] | 111 | std::unique_ptr<SkStreamAsset> content(); |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 112 | |
Hal Canary | 813b5ac | 2018-09-28 12:30:37 -0400 | [diff] [blame] | 113 | SkISize size() const { return this->imageInfo().dimensions(); } |
Hal Canary | 22b2d8c | 2017-07-19 14:46:12 -0400 | [diff] [blame] | 114 | SkIRect bounds() const { return this->imageInfo().bounds(); } |
| 115 | |
halcanary | 2be7e01 | 2016-03-28 11:58:08 -0700 | [diff] [blame] | 116 | // It is important to not confuse GraphicStateEntry with SkPDFGraphicState, the |
| 117 | // later being our representation of an object in the PDF file. |
| 118 | struct GraphicStateEntry { |
Hal Canary | a9adb6f | 2018-09-24 10:33:34 -0400 | [diff] [blame] | 119 | SkMatrix fMatrix = SkMatrix::I(); |
Hal Canary | b400d4d | 2018-09-26 16:33:52 -0400 | [diff] [blame] | 120 | uint32_t fClipStackGenID = SkClipStack::kWideOpenGenID; |
Hal Canary | 04ac461 | 2018-10-10 13:09:43 -0400 | [diff] [blame] | 121 | SkColor4f fColor = {0, 0, 0, 1}; |
Hal Canary | a9adb6f | 2018-09-24 10:33:34 -0400 | [diff] [blame] | 122 | SkScalar fTextScaleX = 1; // Zero means we don't care what the value is. |
| 123 | SkPaint::Style fTextFill = SkPaint::kFill_Style; // Only if TextScaleX is non-zero. |
| 124 | int fShaderIndex = -1; |
| 125 | int fGraphicStateIndex = -1; |
halcanary | 2be7e01 | 2016-03-28 11:58:08 -0700 | [diff] [blame] | 126 | }; |
| 127 | |
Hal Canary | 575be30 | 2018-09-28 15:01:14 -0400 | [diff] [blame] | 128 | void DrawGlyphRunAsPath(SkPDFDevice* dev, const SkGlyphRun& glyphRun, SkPoint offset); |
| 129 | |
edisonn@google.com | 73a7ea3 | 2013-11-11 20:55:15 +0000 | [diff] [blame] | 130 | protected: |
reed | e8f3062 | 2016-03-23 18:59:25 -0700 | [diff] [blame] | 131 | sk_sp<SkSurface> makeSurface(const SkImageInfo&, const SkSurfaceProps&) override; |
edisonn@google.com | 73a7ea3 | 2013-11-11 20:55:15 +0000 | [diff] [blame] | 132 | |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 133 | void drawAnnotation(const SkRect&, const char key[], SkData* value) override; |
reed | f70b531 | 2016-03-04 16:36:20 -0800 | [diff] [blame] | 134 | |
Florin Malita | 53f77bd | 2017-04-28 13:48:37 -0400 | [diff] [blame] | 135 | void drawSpecial(SkSpecialImage*, int x, int y, const SkPaint&, |
| 136 | SkImage*, const SkMatrix&) override; |
reed | e51c356 | 2016-07-19 14:33:20 -0700 | [diff] [blame] | 137 | sk_sp<SkSpecialImage> makeSpecial(const SkBitmap&) override; |
| 138 | sk_sp<SkSpecialImage> makeSpecial(const SkImage*) override; |
| 139 | sk_sp<SkSpecialImage> snapSpecial() override; |
brianosman | 04a44d0 | 2016-09-21 09:46:57 -0700 | [diff] [blame] | 140 | SkImageFilterCache* getImageFilterCache() override; |
reed | e51c356 | 2016-07-19 14:33:20 -0700 | [diff] [blame] | 141 | |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 142 | private: |
halcanary | 91fcb3e | 2016-03-04 13:53:22 -0800 | [diff] [blame] | 143 | struct RectWithData { |
| 144 | SkRect rect; |
halcanary | d7b2885 | 2016-03-07 12:39:14 -0800 | [diff] [blame] | 145 | sk_sp<SkData> data; |
halcanary | 91fcb3e | 2016-03-04 13:53:22 -0800 | [diff] [blame] | 146 | }; |
| 147 | |
| 148 | struct NamedDestination { |
halcanary | d7b2885 | 2016-03-07 12:39:14 -0800 | [diff] [blame] | 149 | sk_sp<SkData> nameData; |
halcanary | 91fcb3e | 2016-03-04 13:53:22 -0800 | [diff] [blame] | 150 | SkPoint point; |
halcanary | 91fcb3e | 2016-03-04 13:53:22 -0800 | [diff] [blame] | 151 | }; |
| 152 | |
ctguil@chromium.org | 769fa6a | 2011-08-20 00:36:18 +0000 | [diff] [blame] | 153 | // 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] | 154 | // order to get the right access levels without using friend. |
vandebo@chromium.org | 13d14a9 | 2011-05-24 23:12:41 +0000 | [diff] [blame] | 155 | friend class ScopedContentEntry; |
vandebo@chromium.org | a0c7edb | 2011-05-09 07:58:08 +0000 | [diff] [blame] | 156 | |
vandebo@chromium.org | 75f97e4 | 2011-04-11 23:24:18 +0000 | [diff] [blame] | 157 | SkMatrix fInitialTransform; |
wangxianzhu | ef6c50a | 2015-09-17 20:38:02 -0700 | [diff] [blame] | 158 | |
Hal Canary | 9e41c21 | 2018-09-03 12:00:23 -0400 | [diff] [blame] | 159 | std::vector<RectWithData> fLinkToURLs; |
| 160 | std::vector<RectWithData> fLinkToDestinations; |
| 161 | std::vector<NamedDestination> fNamedDestinations; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 162 | |
Hal Canary | 9a3f554 | 2018-12-10 19:59:07 -0500 | [diff] [blame] | 163 | SkTHashSet<SkPDFIndirectReference> fGraphicStateResources; |
| 164 | SkTHashSet<SkPDFIndirectReference> fXObjectResources; |
| 165 | SkTHashSet<SkPDFIndirectReference> fShaderResources; |
Hal Canary | b10f92e | 2018-11-16 17:01:50 -0500 | [diff] [blame] | 166 | SkTHashSet<SkPDFIndirectReference> fFontResources; |
Dominic Mazzoni | 656cefe | 2018-09-25 20:29:15 -0700 | [diff] [blame] | 167 | int fNodeId; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 168 | |
Hal Canary | 42137de | 2018-10-08 16:00:37 -0400 | [diff] [blame] | 169 | SkDynamicMemoryWStream fContent; |
| 170 | SkDynamicMemoryWStream fContentBuffer; |
| 171 | bool fNeedsExtraSave = false; |
Hal Canary | b400d4d | 2018-09-26 16:33:52 -0400 | [diff] [blame] | 172 | struct GraphicStackState { |
Hal Canary | 42137de | 2018-10-08 16:00:37 -0400 | [diff] [blame] | 173 | GraphicStackState(SkDynamicMemoryWStream* s = nullptr); |
Hal Canary | b400d4d | 2018-09-26 16:33:52 -0400 | [diff] [blame] | 174 | void updateClip(const SkClipStack* clipStack, const SkIRect& bounds); |
| 175 | void updateMatrix(const SkMatrix& matrix); |
| 176 | void updateDrawingState(const SkPDFDevice::GraphicStateEntry& state); |
| 177 | void push(); |
| 178 | void pop(); |
| 179 | void drainStack(); |
| 180 | SkPDFDevice::GraphicStateEntry* currentEntry() { return &fEntries[fStackDepth]; } |
Hal Canary | b5b7279 | 2018-09-28 08:49:33 -0400 | [diff] [blame] | 181 | // Must use stack for matrix, and for clip, plus one for no matrix or clip. |
| 182 | static constexpr int kMaxStackDepth = 2; |
Hal Canary | b400d4d | 2018-09-26 16:33:52 -0400 | [diff] [blame] | 183 | SkPDFDevice::GraphicStateEntry fEntries[kMaxStackDepth + 1]; |
| 184 | int fStackDepth = 0; |
| 185 | SkDynamicMemoryWStream* fContentStream; |
halcanary | 2be7e01 | 2016-03-28 11:58:08 -0700 | [diff] [blame] | 186 | }; |
Hal Canary | b400d4d | 2018-09-26 16:33:52 -0400 | [diff] [blame] | 187 | GraphicStackState fActiveStackState; |
halcanary | 989da4a | 2016-03-21 14:33:17 -0700 | [diff] [blame] | 188 | SkPDFDocument* fDocument; |
halcanary | a1f1ee9 | 2015-02-20 06:17:26 -0800 | [diff] [blame] | 189 | |
Hal Canary | a062258 | 2017-06-29 18:51:35 -0400 | [diff] [blame] | 190 | //////////////////////////////////////////////////////////////////////////// |
halcanary | a1f1ee9 | 2015-02-20 06:17:26 -0800 | [diff] [blame] | 191 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 192 | SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override; |
bsalomon@google.com | e97f085 | 2011-06-17 13:10:25 +0000 | [diff] [blame] | 193 | |
Hal Canary | b4bd5ef | 2017-07-26 09:16:01 -0400 | [diff] [blame] | 194 | // Set alpha to true if making a transparency group form x-objects. |
Hal Canary | 9a3f554 | 2018-12-10 19:59:07 -0500 | [diff] [blame] | 195 | SkPDFIndirectReference makeFormXObjectFromDevice(bool alpha = false); |
vandebo@chromium.org | 9fbdf87 | 2011-05-09 07:55:58 +0000 | [diff] [blame] | 196 | |
Hal Canary | 9a3f554 | 2018-12-10 19:59:07 -0500 | [diff] [blame] | 197 | void drawFormXObjectWithMask(SkPDFIndirectReference xObject, |
| 198 | SkPDFIndirectReference sMask, |
reed | 374772b | 2016-10-05 17:33:02 -0700 | [diff] [blame] | 199 | SkBlendMode, |
vandebo@chromium.org | 481aef6 | 2011-05-24 16:39:05 +0000 | [diff] [blame] | 200 | bool invertClip); |
vandebo@chromium.org | 466f3d6 | 2011-05-18 23:06:29 +0000 | [diff] [blame] | 201 | |
vandebo@chromium.org | b069c8c | 2011-05-24 17:19:38 +0000 | [diff] [blame] | 202 | // 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] | 203 | // returns nullptr and does not create a content entry. |
vandebo@chromium.org | b069c8c | 2011-05-24 17:19:38 +0000 | [diff] [blame] | 204 | // setUpContentEntry and finishContentEntry can be used directly, but |
vandebo@chromium.org | 13d14a9 | 2011-05-24 23:12:41 +0000 | [diff] [blame] | 205 | // the preferred method is to use the ScopedContentEntry helper class. |
Hal Canary | b400d4d | 2018-09-26 16:33:52 -0400 | [diff] [blame] | 206 | SkDynamicMemoryWStream* setUpContentEntry(const SkClipStack* clipStack, |
Hal Canary | 9a3f554 | 2018-12-10 19:59:07 -0500 | [diff] [blame] | 207 | const SkMatrix& matrix, |
| 208 | const SkPaint& paint, |
Hal Canary | 8f37ce5 | 2018-12-28 11:40:10 -0500 | [diff] [blame] | 209 | SkScalar, |
Hal Canary | 9a3f554 | 2018-12-10 19:59:07 -0500 | [diff] [blame] | 210 | SkPDFIndirectReference* dst); |
| 211 | void finishContentEntry(const SkClipStack*, SkBlendMode, SkPDFIndirectReference, SkPath*); |
vandebo@chromium.org | 481aef6 | 2011-05-24 16:39:05 +0000 | [diff] [blame] | 212 | bool isContentEmpty(); |
| 213 | |
Herb Derby | 95e1760 | 2018-12-06 17:11:43 -0500 | [diff] [blame] | 214 | void internalDrawGlyphRun(const SkGlyphRun& glyphRun, SkPoint offset, const SkPaint& runPaint); |
| 215 | void drawGlyphRunAsPath(const SkGlyphRun& glyphRun, SkPoint offset, const SkPaint& runPaint); |
halcanary | 4ed2f01 | 2016-08-15 18:40:07 -0700 | [diff] [blame] | 216 | |
Hal Canary | 7cbf5e3 | 2017-07-12 13:10:23 -0400 | [diff] [blame] | 217 | void internalDrawImageRect(SkKeyedImage, |
| 218 | const SkRect* src, |
| 219 | const SkRect& dst, |
| 220 | const SkPaint&, |
| 221 | const SkMatrix& canvasTransformationMatrix); |
vandebo@chromium.org | 9fbdf87 | 2011-05-09 07:55:58 +0000 | [diff] [blame] | 222 | |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 223 | void internalDrawPath(const SkClipStack&, |
| 224 | const SkMatrix&, |
| 225 | const SkPath&, |
| 226 | const SkPaint&, |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 227 | bool pathIsMutable); |
| 228 | |
Hal Canary | d12a676 | 2017-05-26 17:01:16 -0400 | [diff] [blame] | 229 | void internalDrawPathWithFilter(const SkClipStack& clipStack, |
| 230 | const SkMatrix& ctm, |
| 231 | const SkPath& origPath, |
Robert Phillips | 137ca52 | 2018-08-15 10:14:33 -0400 | [diff] [blame] | 232 | const SkPaint& paint); |
Hal Canary | d12a676 | 2017-05-26 17:01:16 -0400 | [diff] [blame] | 233 | |
Robert Phillips | 137ca52 | 2018-08-15 10:14:33 -0400 | [diff] [blame] | 234 | bool handleInversePath(const SkPath& origPath, const SkPaint& paint, bool pathIsMutable); |
vandebo@chromium.org | 238be8c | 2012-07-13 20:06:02 +0000 | [diff] [blame] | 235 | |
Hal Canary | 51329c9 | 2017-06-27 14:28:37 -0400 | [diff] [blame] | 236 | void addSMaskGraphicState(sk_sp<SkPDFDevice> maskDevice, SkDynamicMemoryWStream*); |
| 237 | void clearMaskOnGraphicState(SkDynamicMemoryWStream*); |
Hal Canary | 9a3f554 | 2018-12-10 19:59:07 -0500 | [diff] [blame] | 238 | void setGraphicState(SkPDFIndirectReference gs, SkDynamicMemoryWStream*); |
| 239 | void drawFormXObject(SkPDFIndirectReference xObject, SkDynamicMemoryWStream*); |
commit-bot@chromium.org | 5e00989 | 2013-10-14 13:42:12 +0000 | [diff] [blame] | 240 | |
Hal Canary | b4e528d | 2018-03-09 16:02:15 -0500 | [diff] [blame] | 241 | bool hasEmptyClip() const { return this->cs().isEmpty(this->bounds()); } |
| 242 | |
Hal Canary | 9e41c21 | 2018-09-03 12:00:23 -0400 | [diff] [blame] | 243 | void reset(); |
| 244 | |
Hal Canary | 51329c9 | 2017-06-27 14:28:37 -0400 | [diff] [blame] | 245 | typedef SkClipStackDevice INHERITED; |
vandebo@chromium.org | 9b49dc0 | 2010-10-20 22:23:29 +0000 | [diff] [blame] | 246 | }; |
| 247 | |
| 248 | #endif |