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