blob: 2d7922a29f34cce31ec6fd36fbbcb4c197a33f1f [file] [log] [blame]
fmalita93957f42015-01-30 09:03:29 -08001/*
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 Reedc5e641c2017-02-17 14:38:11 -050011#include "SkClipStackDevice.h"
senorblanco900c3672016-04-27 11:31:23 -070012#include "SkTemplates.h"
fmalita93957f42015-01-30 09:03:29 -080013
fmalita93957f42015-01-30 09:03:29 -080014class SkXMLWriter;
15
Mike Reedc5e641c2017-02-17 14:38:11 -050016class SkSVGDevice : public SkClipStackDevice {
fmalita93957f42015-01-30 09:03:29 -080017public:
Florin Malita562017b2019-02-14 13:42:15 -050018 static sk_sp<SkBaseDevice> Make(const SkISize& size, std::unique_ptr<SkXMLWriter>);
fmalita93957f42015-01-30 09:03:29 -080019
fmalita93957f42015-01-30 09:03:29 -080020protected:
Mike Reeda1361362017-03-07 09:37:29 -050021 void drawPaint(const SkPaint& paint) override;
Bryce Thomasfd5a5082018-02-06 14:53:05 -080022 void drawAnnotation(const SkRect& rect, const char key[], SkData* value) override;
Mike Reeda1361362017-03-07 09:37:29 -050023 void drawPoints(SkCanvas::PointMode mode, size_t count,
tfarina85665392015-05-04 06:40:31 -070024 const SkPoint[], const SkPaint& paint) override;
Mike Reeda1361362017-03-07 09:37:29 -050025 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,
tfarina85665392015-05-04 06:40:31 -070029 const SkPaint& paint,
tfarina85665392015-05-04 06:40:31 -070030 bool pathIsMutable = false) override;
fmalita93957f42015-01-30 09:03:29 -080031
Mike Reeda1361362017-03-07 09:37:29 -050032 void drawSprite(const SkBitmap& bitmap,
tfarina85665392015-05-04 06:40:31 -070033 int x, int y, const SkPaint& paint) override;
Mike Reeda1361362017-03-07 09:37:29 -050034 void drawBitmapRect(const SkBitmap&,
tfarina85665392015-05-04 06:40:31 -070035 const SkRect* srcOrNull, const SkRect& dst,
reed562fe472015-07-28 07:35:14 -070036 const SkPaint& paint, SkCanvas::SrcRectConstraint) override;
Herb Derbyd708bd62018-08-29 15:59:34 -040037 void drawGlyphRunList(const SkGlyphRunList& glyphRunList) override;
Ruiqi Maoc97a3392018-08-15 10:44:19 -040038 void drawVertices(const SkVertices*, const SkVertices::Bone bones[], int boneCount, SkBlendMode,
Ruiqi Maof5101492018-06-29 14:32:21 -040039 const SkPaint& paint) override;
fmalita93957f42015-01-30 09:03:29 -080040
Mike Reeda1361362017-03-07 09:37:29 -050041 void drawDevice(SkBaseDevice*, int x, int y,
tfarina85665392015-05-04 06:40:31 -070042 const SkPaint&) override;
fmalita93957f42015-01-30 09:03:29 -080043
44private:
Florin Malita562017b2019-02-14 13:42:15 -050045 SkSVGDevice(const SkISize& size, std::unique_ptr<SkXMLWriter>);
Brian Salomond3b65972017-03-22 12:05:03 -040046 ~SkSVGDevice() override;
fmalita93957f42015-01-30 09:03:29 -080047
Mike Reedc5e641c2017-02-17 14:38:11 -050048 struct MxCp;
49 void drawBitmapCommon(const MxCp&, const SkBitmap& bm, const SkPaint& paint);
fmalita827da232015-02-27 07:44:47 -080050
fmalita532faa92015-02-03 05:44:40 -080051 class AutoElement;
52 class ResourceBucket;
fmalita93957f42015-01-30 09:03:29 -080053
Florin Malita562017b2019-02-14 13:42:15 -050054 std::unique_ptr<SkXMLWriter> fWriter;
Ben Wagner145dbcd2016-11-03 14:40:50 -040055 std::unique_ptr<AutoElement> fRootElement;
56 std::unique_ptr<ResourceBucket> fResourceBucket;
robertphillips9a53fd72015-06-22 09:46:59 -070057
Mike Reedc5e641c2017-02-17 14:38:11 -050058 typedef SkClipStackDevice INHERITED;
fmalita93957f42015-01-30 09:03:29 -080059};
60
61#endif // SkSVGDevice_DEFINED