Avi Drissman | 3f7a9d8 | 2022-09-08 20:55:42 | [diff] [blame] | 1 | // Copyright 2017 The Chromium Authors |
enne | 34f6084c | 2017-02-02 22:39:08 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CC_PAINT_PAINT_CANVAS_H_ |
| 6 | #define CC_PAINT_PAINT_CANVAS_H_ |
| 7 | |
enne | d250157 | 2017-03-09 19:59:17 | [diff] [blame] | 8 | #include "base/compiler_specific.h" |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 9 | #include "base/memory/raw_ptr.h" |
enne | ea15ddb | 2017-03-22 01:49:08 | [diff] [blame] | 10 | #include "base/memory/ref_counted.h" |
enne | 7b64edf3 | 2017-02-16 20:10:02 | [diff] [blame] | 11 | #include "build/build_config.h" |
Tao Bai | 1e1deb41 | 2019-07-21 16:14:00 | [diff] [blame] | 12 | #include "cc/paint/node_id.h" |
enne | 34f6084c | 2017-02-02 22:39:08 | [diff] [blame] | 13 | #include "cc/paint/paint_export.h" |
vmpstr | 94cfa88 | 2017-04-14 01:19:35 | [diff] [blame] | 14 | #include "cc/paint/paint_image.h" |
Florin Malita | 3efd8535 | 2024-01-12 19:25:40 | [diff] [blame] | 15 | #include "cc/paint/refcounted_buffer.h" |
Avery Musbach | dc01059f | 2022-01-12 22:10:59 | [diff] [blame] | 16 | #include "cc/paint/skottie_color_map.h" |
Eric Sum | 4cf51cc | 2021-11-09 02:21:38 | [diff] [blame] | 17 | #include "cc/paint/skottie_frame_data.h" |
Eric Sum | c743571 | 2022-02-22 18:33:44 | [diff] [blame] | 18 | #include "cc/paint/skottie_text_property_value.h" |
enne | 34f6084c | 2017-02-02 22:39:08 | [diff] [blame] | 19 | #include "third_party/skia/include/core/SkCanvas.h" |
Peter Kasting | 73ee7ef | 2021-07-20 19:47:56 | [diff] [blame] | 20 | |
| 21 | class SkTextBlob; |
enne | 34f6084c | 2017-02-02 22:39:08 | [diff] [blame] | 22 | |
Florin Malita | 1593577 | 2019-02-06 21:52:24 | [diff] [blame] | 23 | namespace printing { |
| 24 | class MetafileSkia; |
| 25 | } // namespace printing |
| 26 | |
ckitagawa | 53eeaef | 2019-11-08 15:17:34 | [diff] [blame] | 27 | namespace paint_preview { |
| 28 | class PaintPreviewTracker; |
| 29 | } // namespace paint_preview |
| 30 | |
enne | 34f6084c | 2017-02-02 22:39:08 | [diff] [blame] | 31 | namespace cc { |
Malay Keshav | cf4ceef1 | 2018-10-19 17:56:51 | [diff] [blame] | 32 | class SkottieWrapper; |
enne | d250157 | 2017-03-09 19:59:17 | [diff] [blame] | 33 | class PaintFlags; |
Xianzhu Wang | dee05a0 | 2022-12-19 22:06:09 | [diff] [blame] | 34 | class PaintRecord; |
enne | 59df29de | 2017-05-02 03:23:37 | [diff] [blame] | 35 | |
Justin Novosad | 2756a7d5 | 2021-06-09 15:50:38 | [diff] [blame] | 36 | enum class UsePaintCache { kDisabled = 0, kEnabled }; |
| 37 | |
Adrienne Walker | 26aac6e5 | 2018-10-23 19:23:37 | [diff] [blame] | 38 | // PaintCanvas is the cc/paint wrapper of SkCanvas. It has a more restricted |
| 39 | // interface than SkCanvas (trimmed back to only what Chrome uses). Its reason |
| 40 | // for existence is so that it can do custom serialization logic into a |
| 41 | // PaintOpBuffer which (unlike SkPicture) is mutable, handles image replacement, |
| 42 | // and can be serialized in custom ways (such as using the transfer cache). |
| 43 | // |
| 44 | // PaintCanvas is usually implemented by either: |
| 45 | // (1) SkiaPaintCanvas, which is backed by an SkCanvas, usually for rasterizing. |
| 46 | // (2) RecordPaintCanvas, which records paint commands into a PaintOpBuffer. |
| 47 | // |
| 48 | // SkiaPaintCanvas allows callers to go from PaintCanvas to SkCanvas (or |
| 49 | // PaintRecord to SkPicture), but this is a one way trip. There is no way to go |
| 50 | // from SkCanvas to PaintCanvas or from SkPicture back into PaintRecord. |
enne | d250157 | 2017-03-09 19:59:17 | [diff] [blame] | 51 | class CC_PAINT_EXPORT PaintCanvas { |
enne | 34f6084c | 2017-02-02 22:39:08 | [diff] [blame] | 52 | public: |
Vladimir Levin | f06d1cd7 | 2019-03-13 18:24:10 | [diff] [blame] | 53 | PaintCanvas() = default; |
| 54 | PaintCanvas(const PaintCanvas&) = delete; |
| 55 | virtual ~PaintCanvas() = default; |
| 56 | |
| 57 | PaintCanvas& operator=(const PaintCanvas&) = delete; |
khushalsagar | b74f912 | 2017-03-22 04:37:47 | [diff] [blame] | 58 | |
enne | 59df29de | 2017-05-02 03:23:37 | [diff] [blame] | 59 | // TODO(enne): this only appears to mostly be used to determine if this is |
| 60 | // recording or not, so could be simplified or removed. |
enne | 98c9f805 | 2017-03-15 19:38:22 | [diff] [blame] | 61 | virtual SkImageInfo imageInfo() const = 0; |
enne | d250157 | 2017-03-09 19:59:17 | [diff] [blame] | 62 | |
Tom Anderson | bec0951 | 2019-09-16 20:32:16 | [diff] [blame] | 63 | virtual void* accessTopLayerPixels(SkImageInfo* info, |
| 64 | size_t* rowBytes, |
| 65 | SkIPoint* origin = nullptr) = 0; |
| 66 | |
enne | d250157 | 2017-03-09 19:59:17 | [diff] [blame] | 67 | // TODO(enne): It would be nice to get rid of flush() entirely, as it |
| 68 | // doesn't really make sense for recording. However, this gets used by |
zhuoyu.qian | 4689dde2 | 2017-10-16 04:11:48 | [diff] [blame] | 69 | // PaintCanvasVideoRenderer which takes a PaintCanvas to paint both |
enne | d250157 | 2017-03-09 19:59:17 | [diff] [blame] | 70 | // software and hardware video. This is super entangled with ImageBuffer |
| 71 | // and canvas/video painting in Blink where the same paths are used for |
| 72 | // both recording and gpu work. |
enne | 98c9f805 | 2017-03-15 19:38:22 | [diff] [blame] | 73 | virtual void flush() = 0; |
enne | d250157 | 2017-03-09 19:59:17 | [diff] [blame] | 74 | |
enne | 98c9f805 | 2017-03-15 19:38:22 | [diff] [blame] | 75 | virtual int save() = 0; |
Xianzhu Wang | 33e6323 | 2022-12-24 18:30:37 | [diff] [blame] | 76 | virtual int saveLayer(const PaintFlags& flags) = 0; |
| 77 | virtual int saveLayer(const SkRect& bounds, const PaintFlags& flags) = 0; |
Jean-Philippe Gravel | 3f6f331 | 2023-01-19 21:10:33 | [diff] [blame] | 78 | virtual int saveLayerAlphaf(float alpha) = 0; |
| 79 | virtual int saveLayerAlphaf(const SkRect& bounds, float alpha) = 0; |
enne | 98c9f805 | 2017-03-15 19:38:22 | [diff] [blame] | 80 | |
| 81 | virtual void restore() = 0; |
| 82 | virtual int getSaveCount() const = 0; |
| 83 | virtual void restoreToCount(int save_count) = 0; |
| 84 | virtual void translate(SkScalar dx, SkScalar dy) = 0; |
| 85 | virtual void scale(SkScalar sx, SkScalar sy) = 0; |
Vladimir Levin | 32c16e13 | 2021-11-19 20:26:48 | [diff] [blame] | 86 | void scale(SkScalar s) { scale(s, s); } |
enne | 98c9f805 | 2017-03-15 19:38:22 | [diff] [blame] | 87 | virtual void rotate(SkScalar degrees) = 0; |
Aaron Krajeski | 8a128e23 | 2020-12-15 21:47:06 | [diff] [blame] | 88 | virtual void concat(const SkM44& matrix) = 0; |
Aaron Krajeski | 5e542c8 | 2020-12-05 01:50:21 | [diff] [blame] | 89 | virtual void setMatrix(const SkM44& matrix) = 0; |
| 90 | |
enne | 98c9f805 | 2017-03-15 19:38:22 | [diff] [blame] | 91 | virtual void clipRect(const SkRect& rect, |
| 92 | SkClipOp op, |
| 93 | bool do_anti_alias) = 0; |
| 94 | void clipRect(const SkRect& rect, SkClipOp op) { clipRect(rect, op, false); } |
| 95 | void clipRect(const SkRect& rect, bool do_anti_alias) { |
| 96 | clipRect(rect, SkClipOp::kIntersect, do_anti_alias); |
enne | d250157 | 2017-03-09 19:59:17 | [diff] [blame] | 97 | } |
enne | 98c9f805 | 2017-03-15 19:38:22 | [diff] [blame] | 98 | void clipRect(const SkRect& rect) { |
| 99 | clipRect(rect, SkClipOp::kIntersect, false); |
enne | d250157 | 2017-03-09 19:59:17 | [diff] [blame] | 100 | } |
| 101 | |
enne | 98c9f805 | 2017-03-15 19:38:22 | [diff] [blame] | 102 | virtual void clipRRect(const SkRRect& rrect, |
| 103 | SkClipOp op, |
| 104 | bool do_anti_alias) = 0; |
| 105 | void clipRRect(const SkRRect& rrect, bool do_anti_alias) { |
| 106 | clipRRect(rrect, SkClipOp::kIntersect, do_anti_alias); |
enne | d250157 | 2017-03-09 19:59:17 | [diff] [blame] | 107 | } |
enne | 98c9f805 | 2017-03-15 19:38:22 | [diff] [blame] | 108 | void clipRRect(const SkRRect& rrect, SkClipOp op) { |
| 109 | clipRRect(rrect, op, false); |
enne | d250157 | 2017-03-09 19:59:17 | [diff] [blame] | 110 | } |
enne | 98c9f805 | 2017-03-15 19:38:22 | [diff] [blame] | 111 | void clipRRect(const SkRRect& rrect) { |
| 112 | clipRRect(rrect, SkClipOp::kIntersect, false); |
enne | d250157 | 2017-03-09 19:59:17 | [diff] [blame] | 113 | } |
enne | d250157 | 2017-03-09 19:59:17 | [diff] [blame] | 114 | |
enne | 98c9f805 | 2017-03-15 19:38:22 | [diff] [blame] | 115 | virtual void clipPath(const SkPath& path, |
| 116 | SkClipOp op, |
Justin Novosad | 2756a7d5 | 2021-06-09 15:50:38 | [diff] [blame] | 117 | bool do_anti_alias, |
| 118 | UsePaintCache) = 0; |
| 119 | void clipPath(const SkPath& path, SkClipOp op, bool do_anti_alias) { |
| 120 | clipPath(path, op, do_anti_alias, UsePaintCache::kEnabled); |
| 121 | } |
| 122 | void clipPath(const SkPath& path, SkClipOp op) { |
| 123 | clipPath(path, op, /*do_anti_alias=*/false, UsePaintCache::kEnabled); |
| 124 | } |
enne | 98c9f805 | 2017-03-15 19:38:22 | [diff] [blame] | 125 | void clipPath(const SkPath& path, bool do_anti_alias) { |
Justin Novosad | 2756a7d5 | 2021-06-09 15:50:38 | [diff] [blame] | 126 | clipPath(path, SkClipOp::kIntersect, do_anti_alias, |
| 127 | UsePaintCache::kEnabled); |
enne | d250157 | 2017-03-09 19:59:17 | [diff] [blame] | 128 | } |
enne | 98c9f805 | 2017-03-15 19:38:22 | [diff] [blame] | 129 | |
enne | 98c9f805 | 2017-03-15 19:38:22 | [diff] [blame] | 130 | virtual bool getLocalClipBounds(SkRect* bounds) const = 0; |
enne | 98c9f805 | 2017-03-15 19:38:22 | [diff] [blame] | 131 | virtual bool getDeviceClipBounds(SkIRect* bounds) const = 0; |
Aaron Krajeski | 859caf63 | 2022-07-13 21:38:14 | [diff] [blame] | 132 | virtual void drawColor(SkColor4f color, SkBlendMode mode) = 0; |
| 133 | void drawColor(SkColor4f color) { drawColor(color, SkBlendMode::kSrcOver); } |
enne | 59df29de | 2017-05-02 03:23:37 | [diff] [blame] | 134 | |
| 135 | // TODO(enne): This is a synonym for drawColor with kSrc. Remove it. |
Aaron Krajeski | f325d98 | 2022-07-08 16:12:35 | [diff] [blame] | 136 | virtual void clear(SkColor4f color) = 0; |
enne | 98c9f805 | 2017-03-15 19:38:22 | [diff] [blame] | 137 | |
| 138 | virtual void drawLine(SkScalar x0, |
| 139 | SkScalar y0, |
| 140 | SkScalar x1, |
| 141 | SkScalar y1, |
| 142 | const PaintFlags& flags) = 0; |
| 143 | virtual void drawRect(const SkRect& rect, const PaintFlags& flags) = 0; |
| 144 | virtual void drawIRect(const SkIRect& rect, const PaintFlags& flags) = 0; |
| 145 | virtual void drawOval(const SkRect& oval, const PaintFlags& flags) = 0; |
| 146 | virtual void drawRRect(const SkRRect& rrect, const PaintFlags& flags) = 0; |
| 147 | virtual void drawDRRect(const SkRRect& outer, |
| 148 | const SkRRect& inner, |
| 149 | const PaintFlags& flags) = 0; |
enne | 98c9f805 | 2017-03-15 19:38:22 | [diff] [blame] | 150 | virtual void drawRoundRect(const SkRect& rect, |
| 151 | SkScalar rx, |
| 152 | SkScalar ry, |
| 153 | const PaintFlags& flags) = 0; |
Justin Novosad | 2756a7d5 | 2021-06-09 15:50:38 | [diff] [blame] | 154 | virtual void drawPath(const SkPath& path, |
| 155 | const PaintFlags& flags, |
| 156 | UsePaintCache) = 0; |
| 157 | void drawPath(const SkPath& path, const PaintFlags& flags) { |
| 158 | drawPath(path, flags, UsePaintCache::kEnabled); |
| 159 | } |
vmpstr | 94cfa88 | 2017-04-14 01:19:35 | [diff] [blame] | 160 | virtual void drawImage(const PaintImage& image, |
enne | 98c9f805 | 2017-03-15 19:38:22 | [diff] [blame] | 161 | SkScalar left, |
| 162 | SkScalar top, |
Mike Reed | 859086a | 2021-01-23 18:19:15 | [diff] [blame] | 163 | const SkSamplingOptions&, |
enne | 98c9f805 | 2017-03-15 19:38:22 | [diff] [blame] | 164 | const PaintFlags* flags) = 0; |
vmpstr | 94cfa88 | 2017-04-14 01:19:35 | [diff] [blame] | 165 | void drawImage(const PaintImage& image, SkScalar left, SkScalar top) { |
Mike Reed | 859086a | 2021-01-23 18:19:15 | [diff] [blame] | 166 | drawImage(image, left, top, SkSamplingOptions(), nullptr); |
enne | d250157 | 2017-03-09 19:59:17 | [diff] [blame] | 167 | } |
| 168 | |
vmpstr | 94cfa88 | 2017-04-14 01:19:35 | [diff] [blame] | 169 | virtual void drawImageRect(const PaintImage& image, |
enne | 98c9f805 | 2017-03-15 19:38:22 | [diff] [blame] | 170 | const SkRect& src, |
| 171 | const SkRect& dst, |
Mike Reed | 859086a | 2021-01-23 18:19:15 | [diff] [blame] | 172 | const SkSamplingOptions&, |
enne | 98c9f805 | 2017-03-15 19:38:22 | [diff] [blame] | 173 | const PaintFlags* flags, |
jongdeok.kim | 50b37707 | 2020-05-15 22:16:12 | [diff] [blame] | 174 | SkCanvas::SrcRectConstraint constraint) = 0; |
Mike Reed | 859086a | 2021-01-23 18:19:15 | [diff] [blame] | 175 | void drawImageRect(const PaintImage& image, |
| 176 | const SkRect& src, |
| 177 | const SkRect& dst, |
| 178 | SkCanvas::SrcRectConstraint constraint) { |
| 179 | drawImageRect(image, src, dst, SkSamplingOptions(), nullptr, constraint); |
| 180 | } |
enne | d250157 | 2017-03-09 19:59:17 | [diff] [blame] | 181 | |
Florin Malita | 3efd8535 | 2024-01-12 19:25:40 | [diff] [blame] | 182 | virtual void drawVertices(scoped_refptr<RefCountedBuffer<SkPoint>> vertices, |
| 183 | scoped_refptr<RefCountedBuffer<SkPoint>> uvs, |
| 184 | scoped_refptr<RefCountedBuffer<uint16_t>> indices, |
| 185 | const PaintFlags& flags) = 0; |
| 186 | |
Malay Keshav | cf4ceef1 | 2018-10-19 17:56:51 | [diff] [blame] | 187 | // Draws the frame of the |skottie| animation specified by the normalized time |
| 188 | // t [0->first frame..1->last frame] at the destination bounds given by |dst| |
Eric Sum | 4cf51cc | 2021-11-09 02:21:38 | [diff] [blame] | 189 | // onto the canvas. |images| is a map from asset id to the corresponding image |
| 190 | // to use when rendering this frame; it may be empty if this animation frame |
| 191 | // does not contain any images in it. |
Malay Keshav | cf4ceef1 | 2018-10-19 17:56:51 | [diff] [blame] | 192 | virtual void drawSkottie(scoped_refptr<SkottieWrapper> skottie, |
| 193 | const SkRect& dst, |
Eric Sum | 4cf51cc | 2021-11-09 02:21:38 | [diff] [blame] | 194 | float t, |
Avery Musbach | dc01059f | 2022-01-12 22:10:59 | [diff] [blame] | 195 | SkottieFrameDataMap images, |
Eric Sum | c743571 | 2022-02-22 18:33:44 | [diff] [blame] | 196 | const SkottieColorMap& color_map, |
| 197 | SkottieTextPropertyValueMap text_map) = 0; |
Malay Keshav | cf4ceef1 | 2018-10-19 17:56:51 | [diff] [blame] | 198 | |
Khushal | 464808c9 | 2018-10-19 23:45:59 | [diff] [blame] | 199 | virtual void drawTextBlob(sk_sp<SkTextBlob> blob, |
enne | 98c9f805 | 2017-03-15 19:38:22 | [diff] [blame] | 200 | SkScalar x, |
| 201 | SkScalar y, |
| 202 | const PaintFlags& flags) = 0; |
enne | d250157 | 2017-03-09 19:59:17 | [diff] [blame] | 203 | |
Tao Bai | edaf8709 | 2019-01-30 23:12:54 | [diff] [blame] | 204 | virtual void drawTextBlob(sk_sp<SkTextBlob> blob, |
| 205 | SkScalar x, |
| 206 | SkScalar y, |
Tao Bai | 1e1deb41 | 2019-07-21 16:14:00 | [diff] [blame] | 207 | NodeId node_id, |
| 208 | const PaintFlags& flags) = 0; |
Tao Bai | edaf8709 | 2019-01-30 23:12:54 | [diff] [blame] | 209 | |
Adrienne Walker | 15ce2350 | 2017-05-08 18:08:15 | [diff] [blame] | 210 | // Unlike SkCanvas::drawPicture, this only plays back the PaintRecord and does |
| 211 | // not add an additional clip. This is closer to SkPicture::playback. |
Xianzhu Wang | dee05a0 | 2022-12-19 22:06:09 | [diff] [blame] | 212 | virtual void drawPicture(PaintRecord record) = 0; |
enne | d250157 | 2017-03-09 19:59:17 | [diff] [blame] | 213 | |
Aaron Krajeski | e18de51 | 2021-04-15 15:17:03 | [diff] [blame] | 214 | virtual SkM44 getLocalToDevice() const = 0; |
enne | d250157 | 2017-03-09 19:59:17 | [diff] [blame] | 215 | |
Justin Novosad | dae42507 | 2021-11-11 19:50:43 | [diff] [blame] | 216 | virtual bool NeedsFlush() const = 0; |
| 217 | |
Florin Malita | 1593577 | 2019-02-06 21:52:24 | [diff] [blame] | 218 | // Used for printing |
enne | 5fa117a | 2017-04-04 20:56:58 | [diff] [blame] | 219 | enum class AnnotationType { |
Ho Cheung | 0636519 | 2023-09-14 17:09:54 | [diff] [blame] | 220 | kUrl, |
| 221 | kNameDestination, |
| 222 | kLinkToDestination, |
enne | 5fa117a | 2017-04-04 20:56:58 | [diff] [blame] | 223 | }; |
| 224 | virtual void Annotate(AnnotationType type, |
| 225 | const SkRect& rect, |
| 226 | sk_sp<SkData> data) = 0; |
Florin Malita | 1593577 | 2019-02-06 21:52:24 | [diff] [blame] | 227 | printing::MetafileSkia* GetPrintingMetafile() const { return metafile_; } |
| 228 | void SetPrintingMetafile(printing::MetafileSkia* metafile) { |
| 229 | metafile_ = metafile; |
| 230 | } |
ckitagawa | 53eeaef | 2019-11-08 15:17:34 | [diff] [blame] | 231 | paint_preview::PaintPreviewTracker* GetPaintPreviewTracker() const { |
| 232 | return tracker_; |
| 233 | } |
| 234 | void SetPaintPreviewTracker(paint_preview::PaintPreviewTracker* tracker) { |
| 235 | tracker_ = tracker; |
| 236 | } |
enne | d250157 | 2017-03-09 19:59:17 | [diff] [blame] | 237 | |
Wei Li | 2a9bfe4 | 2018-01-13 05:42:56 | [diff] [blame] | 238 | // Subclasses can override to handle custom data. |
| 239 | virtual void recordCustomData(uint32_t id) {} |
| 240 | |
Dominic Mazzoni | cf5d6b0 | 2020-03-06 19:49:12 | [diff] [blame] | 241 | // Used for marked content in PDF files. |
| 242 | virtual void setNodeId(int) = 0; |
| 243 | |
enne | 59df29de | 2017-05-02 03:23:37 | [diff] [blame] | 244 | private: |
Lei Zhang | 2b17b61 | 2023-08-24 16:05:05 | [diff] [blame] | 245 | raw_ptr<printing::MetafileSkia> metafile_ = nullptr; |
Bartek Nowierski | f5eeeba | 2024-01-25 12:49:39 | [diff] [blame] | 246 | raw_ptr<paint_preview::PaintPreviewTracker, DanglingUntriaged> tracker_ = |
| 247 | nullptr; |
enne | 34f6084c | 2017-02-02 22:39:08 | [diff] [blame] | 248 | }; |
| 249 | |
enne | d250157 | 2017-03-09 19:59:17 | [diff] [blame] | 250 | class CC_PAINT_EXPORT PaintCanvasAutoRestore { |
| 251 | public: |
enne | 98c9f805 | 2017-03-15 19:38:22 | [diff] [blame] | 252 | PaintCanvasAutoRestore(PaintCanvas* canvas, bool save) : canvas_(canvas) { |
enne | d250157 | 2017-03-09 19:59:17 | [diff] [blame] | 253 | if (canvas_) { |
| 254 | save_count_ = canvas_->getSaveCount(); |
| 255 | if (save) { |
| 256 | canvas_->save(); |
| 257 | } |
| 258 | } |
| 259 | } |
| 260 | |
enne | 98c9f805 | 2017-03-15 19:38:22 | [diff] [blame] | 261 | ~PaintCanvasAutoRestore() { |
enne | d250157 | 2017-03-09 19:59:17 | [diff] [blame] | 262 | if (canvas_) { |
| 263 | canvas_->restoreToCount(save_count_); |
| 264 | } |
| 265 | } |
| 266 | |
enne | 98c9f805 | 2017-03-15 19:38:22 | [diff] [blame] | 267 | void restore() { |
enne | d250157 | 2017-03-09 19:59:17 | [diff] [blame] | 268 | if (canvas_) { |
| 269 | canvas_->restoreToCount(save_count_); |
| 270 | canvas_ = nullptr; |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | private: |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 275 | raw_ptr<PaintCanvas> canvas_ = nullptr; |
enne | d250157 | 2017-03-09 19:59:17 | [diff] [blame] | 276 | int save_count_ = 0; |
| 277 | }; |
| 278 | |
enne | 34f6084c | 2017-02-02 22:39:08 | [diff] [blame] | 279 | } // namespace cc |
| 280 | |
| 281 | #endif // CC_PAINT_PAINT_CANVAS_H_ |