Debian Codegraph @

src/svg/SkSVGDevice.h

raw
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
11 #include "include/core/SkCanvas.h"
12 #include "include/core/SkRefCnt.h"
13 #include "include/core/SkSpan.h"
14 #include "include/core/SkTypes.h"
15 #include "include/private/base/SkTArray.h"
16 #include "include/private/base/SkTypeTraits.h"
17 #include "include/svg/SkSVGCanvas.h"
18 #include "include/utils/SkParsePath.h"
19 #include "src/core/SkClipStackDevice.h"
20
21 #include <cstdint>
22 #include <memory>
23
24 namespace sktext {
25 class GlyphRunList;
26 }
27
28 class SkDevice;
29 class SkBitmap;
30 class SkBlender;
31 class SkClipStack;
32 class SkData;
33 class SkImage;
34 class SkMesh;
35 class SkPaint;
36 class SkPath;
37 class SkRRect;
38 class SkVertices;
39 class SkXMLWriter;
40 struct SkISize;
41 struct SkPoint;
42 struct SkRect;
43 struct SkSamplingOptions;
44
45 class SkSVGDevice final : public SkClipStackDevice {
46 public:
47 static sk_sp<SkDevice> Make(const SkISize& size,
48 std::unique_ptr<SkXMLWriter>,
49 SkSVGCanvas::Options opts);
50
51 void drawPaint(const SkPaint& paint) override;
52 void drawAnnotation(const SkRect& rect, const char key[], SkData* value) override;
53 void drawPoints(SkCanvas::PointMode, SkSpan<const SkPoint>, const SkPaint&) override;
54 void drawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
55 const SkSamplingOptions&, const SkPaint& paint,
56 SkCanvas::SrcRectConstraint constraint) override;
57 void drawRect(const SkRect& r, const SkPaint& paint) override;
58 void drawOval(const SkRect& oval, const SkPaint& paint) override;
59 void drawRRect(const SkRRect& rr, const SkPaint& paint) override;
60 void drawPath(const SkPath& path,
61 const SkPaint& paint) override;
62
63 void drawVertices(const SkVertices*, sk_sp<SkBlender>, const SkPaint&, bool) override;
64 void drawMesh(const SkMesh&, sk_sp<SkBlender>, const SkPaint&) override;
65
66 private:
67 SkSVGDevice(const SkISize& size, std::unique_ptr<SkXMLWriter>, SkSVGCanvas::Options);
68 ~SkSVGDevice() override;
69
70 void onDrawGlyphRunList(SkCanvas*, const sktext::GlyphRunList&, const SkPaint& paint) override;
71
72 struct MxCp;
73 void drawBitmapCommon(const MxCp&, const SkBitmap& bm, const SkPaint& paint);
74
75 void syncClipStack(const SkClipStack&);
76
77 SkParsePath::PathEncoding pathEncoding() const;
78
79 class AutoElement;
80 class ResourceBucket;
81
82 const std::unique_ptr<SkXMLWriter> fWriter;
83 const std::unique_ptr<ResourceBucket> fResourceBucket;
84 const SkSVGCanvas::Options fOpts;
85
86 struct ClipRec {
87 std::unique_ptr<AutoElement> fClipPathElem;
88 uint32_t fGenID;
89
90 static_assert(::sk_is_trivially_relocatable<decltype(fClipPathElem)>::value);
91
92 using sk_is_trivially_relocatable = std::true_type;
93 };
94
95 std::unique_ptr<AutoElement> fRootElement;
96 skia_private::TArray<ClipRec> fClipStack;
97 };
98
99 #endif // SkSVGDevice_DEFINED