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: |
fmalita | 2aafe6f | 2015-02-06 12:51:10 -0800 | [diff] [blame] | 18 | static SkBaseDevice* Create(const SkISize& size, SkXMLWriter* writer); |
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; |
| 22 | void drawPoints(SkCanvas::PointMode mode, size_t count, |
tfarina | 8566539 | 2015-05-04 06:40:31 -0700 | [diff] [blame] | 23 | const SkPoint[], const SkPaint& paint) override; |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 24 | void drawRect(const SkRect& r, const SkPaint& paint) override; |
| 25 | void drawOval(const SkRect& oval, const SkPaint& paint) override; |
| 26 | void drawRRect(const SkRRect& rr, const SkPaint& paint) override; |
| 27 | void drawPath(const SkPath& path, |
tfarina | 8566539 | 2015-05-04 06:40:31 -0700 | [diff] [blame] | 28 | const SkPaint& paint, |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 29 | const SkMatrix* prePathMatrix = nullptr, |
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 | |
Hal Canary | b964238 | 2017-06-27 09:58:56 -0400 | [diff] [blame] | 32 | void drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, const SkPaint& paint) override; |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 33 | void drawSprite(const SkBitmap& bitmap, |
tfarina | 8566539 | 2015-05-04 06:40:31 -0700 | [diff] [blame] | 34 | int x, int y, const SkPaint& paint) override; |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 35 | void drawBitmapRect(const SkBitmap&, |
tfarina | 8566539 | 2015-05-04 06:40:31 -0700 | [diff] [blame] | 36 | const SkRect* srcOrNull, const SkRect& dst, |
reed | 562fe47 | 2015-07-28 07:35:14 -0700 | [diff] [blame] | 37 | const SkPaint& paint, SkCanvas::SrcRectConstraint) override; |
fmalita | 93957f4 | 2015-01-30 09:03:29 -0800 | [diff] [blame] | 38 | |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 39 | void drawText(const void* text, size_t len, |
tfarina | 8566539 | 2015-05-04 06:40:31 -0700 | [diff] [blame] | 40 | SkScalar x, SkScalar y, const SkPaint& paint) override; |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 41 | void drawPosText(const void* text, size_t len, |
tfarina | 8566539 | 2015-05-04 06:40:31 -0700 | [diff] [blame] | 42 | const SkScalar pos[], int scalarsPerPos, |
| 43 | const SkPoint& offset, const SkPaint& paint) override; |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 44 | void drawTextOnPath(const void* text, size_t len, |
tfarina | 8566539 | 2015-05-04 06:40:31 -0700 | [diff] [blame] | 45 | const SkPath& path, const SkMatrix* matrix, |
| 46 | const SkPaint& paint) override; |
Mike Reed | 2f6b5a4 | 2017-03-19 15:04:17 -0400 | [diff] [blame] | 47 | void drawVertices(const SkVertices*, SkBlendMode, const SkPaint& paint) override; |
fmalita | 93957f4 | 2015-01-30 09:03:29 -0800 | [diff] [blame] | 48 | |
Mike Reed | a136136 | 2017-03-07 09:37:29 -0500 | [diff] [blame] | 49 | void drawDevice(SkBaseDevice*, int x, int y, |
tfarina | 8566539 | 2015-05-04 06:40:31 -0700 | [diff] [blame] | 50 | const SkPaint&) override; |
fmalita | 93957f4 | 2015-01-30 09:03:29 -0800 | [diff] [blame] | 51 | |
| 52 | private: |
fmalita | 2aafe6f | 2015-02-06 12:51:10 -0800 | [diff] [blame] | 53 | SkSVGDevice(const SkISize& size, SkXMLWriter* writer); |
Brian Salomon | d3b6597 | 2017-03-22 12:05:03 -0400 | [diff] [blame] | 54 | ~SkSVGDevice() override; |
fmalita | 93957f4 | 2015-01-30 09:03:29 -0800 | [diff] [blame] | 55 | |
Mike Reed | c5e641c | 2017-02-17 14:38:11 -0500 | [diff] [blame] | 56 | struct MxCp; |
| 57 | void drawBitmapCommon(const MxCp&, const SkBitmap& bm, const SkPaint& paint); |
fmalita | 827da23 | 2015-02-27 07:44:47 -0800 | [diff] [blame] | 58 | |
fmalita | 532faa9 | 2015-02-03 05:44:40 -0800 | [diff] [blame] | 59 | class AutoElement; |
| 60 | class ResourceBucket; |
fmalita | 93957f4 | 2015-01-30 09:03:29 -0800 | [diff] [blame] | 61 | |
Ben Wagner | 145dbcd | 2016-11-03 14:40:50 -0400 | [diff] [blame] | 62 | SkXMLWriter* fWriter; |
| 63 | std::unique_ptr<AutoElement> fRootElement; |
| 64 | std::unique_ptr<ResourceBucket> fResourceBucket; |
robertphillips | 9a53fd7 | 2015-06-22 09:46:59 -0700 | [diff] [blame] | 65 | |
Mike Reed | c5e641c | 2017-02-17 14:38:11 -0500 | [diff] [blame] | 66 | typedef SkClipStackDevice INHERITED; |
fmalita | 93957f4 | 2015-01-30 09:03:29 -0800 | [diff] [blame] | 67 | }; |
| 68 | |
| 69 | #endif // SkSVGDevice_DEFINED |