fmalita | 93957f4 | 2015-01-30 09:03:29 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef SkSVGDevice_DEFINED |
| 9 | #define SkSVGDevice_DEFINED |
| 10 | |
Mike Reed | c5e641c | 2017-02-17 14:38:11 -0500 | [diff] [blame] | 11 | #include "SkClipStackDevice.h" |
senorblanco | 900c367 | 2016-04-27 11:31:23 -0700 | [diff] [blame] | 12 | #include "SkTemplates.h" |
fmalita | 93957f4 | 2015-01-30 09:03:29 -0800 | [diff] [blame] | 13 | |
fmalita | 93957f4 | 2015-01-30 09:03:29 -0800 | [diff] [blame] | 14 | class SkXMLWriter; |
| 15 | |
Mike Reed | c5e641c | 2017-02-17 14:38:11 -0500 | [diff] [blame] | 16 | class SkSVGDevice : public SkClipStackDevice { |
fmalita | 93957f4 | 2015-01-30 09:03:29 -0800 | [diff] [blame] | 17 | public: |
Florin Malita | 562017b | 2019-02-14 13:42:15 -0500 | [diff] [blame^] | 18 | static sk_sp<SkBaseDevice> Make(const SkISize& size, std::unique_ptr<SkXMLWriter>); |
fmalita | 93957f4 | 2015-01-30 09:03:29 -0800 | [diff] [blame] | 19 | |
fmalita | 93957f4 | 2015-01-30 09:03:29 -0800 | [diff] [blame] | 20 | protected: |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 21 | void drawPaint(const SkPaint& paint) override; |
Bryce Thomas | fd5a508 | 2018-02-06 14:53:05 -0800 | [diff] [blame] | 22 | void drawAnnotation(const SkRect& rect, const char key[], SkData* value) override; |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 23 | void drawPoints(SkCanvas::PointMode mode, size_t count, |
tfarina | 8566539 | 2015-05-04 06:40:31 -0700 | [diff] [blame] | 24 | const SkPoint[], const SkPaint& paint) override; |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 25 | void drawRect(const SkRect& r, const SkPaint& paint) override; |
| 26 | void drawOval(const SkRect& oval, const SkPaint& paint) override; |
| 27 | void drawRRect(const SkRRect& rr, const SkPaint& paint) override; |
| 28 | void drawPath(const SkPath& path, |
tfarina | 8566539 | 2015-05-04 06:40:31 -0700 | [diff] [blame] | 29 | const SkPaint& paint, |
tfarina | 8566539 | 2015-05-04 06:40:31 -0700 | [diff] [blame] | 30 | bool pathIsMutable = false) override; |
fmalita | 93957f4 | 2015-01-30 09:03:29 -0800 | [diff] [blame] | 31 | |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 32 | void drawSprite(const SkBitmap& bitmap, |
tfarina | 8566539 | 2015-05-04 06:40:31 -0700 | [diff] [blame] | 33 | int x, int y, const SkPaint& paint) override; |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 34 | void drawBitmapRect(const SkBitmap&, |
tfarina | 8566539 | 2015-05-04 06:40:31 -0700 | [diff] [blame] | 35 | const SkRect* srcOrNull, const SkRect& dst, |
reed | 562fe47 | 2015-07-28 07:35:14 -0700 | [diff] [blame] | 36 | const SkPaint& paint, SkCanvas::SrcRectConstraint) override; |
Herb Derby | d708bd6 | 2018-08-29 15:59:34 -0400 | [diff] [blame] | 37 | void drawGlyphRunList(const SkGlyphRunList& glyphRunList) override; |
Ruiqi Mao | c97a339 | 2018-08-15 10:44:19 -0400 | [diff] [blame] | 38 | void drawVertices(const SkVertices*, const SkVertices::Bone bones[], int boneCount, SkBlendMode, |
Ruiqi Mao | f510149 | 2018-06-29 14:32:21 -0400 | [diff] [blame] | 39 | const SkPaint& paint) override; |
fmalita | 93957f4 | 2015-01-30 09:03:29 -0800 | [diff] [blame] | 40 | |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 41 | void drawDevice(SkBaseDevice*, int x, int y, |
tfarina | 8566539 | 2015-05-04 06:40:31 -0700 | [diff] [blame] | 42 | const SkPaint&) override; |
fmalita | 93957f4 | 2015-01-30 09:03:29 -0800 | [diff] [blame] | 43 | |
| 44 | private: |
Florin Malita | 562017b | 2019-02-14 13:42:15 -0500 | [diff] [blame^] | 45 | SkSVGDevice(const SkISize& size, std::unique_ptr<SkXMLWriter>); |
Brian Salomon | d3b6597 | 2017-03-22 12:05:03 -0400 | [diff] [blame] | 46 | ~SkSVGDevice() override; |
fmalita | 93957f4 | 2015-01-30 09:03:29 -0800 | [diff] [blame] | 47 | |
Mike Reed | c5e641c | 2017-02-17 14:38:11 -0500 | [diff] [blame] | 48 | struct MxCp; |
| 49 | void drawBitmapCommon(const MxCp&, const SkBitmap& bm, const SkPaint& paint); |
fmalita | 827da23 | 2015-02-27 07:44:47 -0800 | [diff] [blame] | 50 | |
fmalita | 532faa9 | 2015-02-03 05:44:40 -0800 | [diff] [blame] | 51 | class AutoElement; |
| 52 | class ResourceBucket; |
fmalita | 93957f4 | 2015-01-30 09:03:29 -0800 | [diff] [blame] | 53 | |
Florin Malita | 562017b | 2019-02-14 13:42:15 -0500 | [diff] [blame^] | 54 | std::unique_ptr<SkXMLWriter> fWriter; |
Ben Wagner | 145dbcd | 2016-11-03 14:40:50 -0400 | [diff] [blame] | 55 | std::unique_ptr<AutoElement> fRootElement; |
| 56 | std::unique_ptr<ResourceBucket> fResourceBucket; |
robertphillips | 9a53fd7 | 2015-06-22 09:46:59 -0700 | [diff] [blame] | 57 | |
Mike Reed | c5e641c | 2017-02-17 14:38:11 -0500 | [diff] [blame] | 58 | typedef SkClipStackDevice INHERITED; |
fmalita | 93957f4 | 2015-01-30 09:03:29 -0800 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | #endif // SkSVGDevice_DEFINED |