• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "SkClipStackDevice.h"
12 #include "SkTemplates.h"
13 
14 class SkXMLWriter;
15 
16 class SkSVGDevice : public SkClipStackDevice {
17 public:
18     static SkBaseDevice* Create(const SkISize& size, SkXMLWriter* writer);
19 
20 protected:
21     void drawPaint(const SkPaint& paint) override;
22     void drawPoints(SkCanvas::PointMode mode, size_t count,
23                     const SkPoint[], const SkPaint& paint) override;
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,
28                   const SkPaint& paint,
29                   const SkMatrix* prePathMatrix = nullptr,
30                   bool pathIsMutable = false) override;
31 
32     void drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, const SkPaint& paint) override;
33     void drawSprite(const SkBitmap& bitmap,
34                     int x, int y, const SkPaint& paint) override;
35     void drawBitmapRect(const SkBitmap&,
36                         const SkRect* srcOrNull, const SkRect& dst,
37                         const SkPaint& paint, SkCanvas::SrcRectConstraint) override;
38 
39     void drawText(const void* text, size_t len,
40                   SkScalar x, SkScalar y, const SkPaint& paint) override;
41     void drawPosText(const void* text, size_t len,
42                      const SkScalar pos[], int scalarsPerPos,
43                      const SkPoint& offset, const SkPaint& paint) override;
44     void drawTextOnPath(const void* text, size_t len,
45                         const SkPath& path, const SkMatrix* matrix,
46                         const SkPaint& paint) override;
47     void drawVertices(const SkVertices*, SkBlendMode, const SkPaint& paint) override;
48 
49     void drawDevice(SkBaseDevice*, int x, int y,
50                     const SkPaint&) override;
51 
52 private:
53     SkSVGDevice(const SkISize& size, SkXMLWriter* writer);
54     ~SkSVGDevice() override;
55 
56     struct MxCp;
57     void drawBitmapCommon(const MxCp&, const SkBitmap& bm, const SkPaint& paint);
58 
59     class AutoElement;
60     class ResourceBucket;
61 
62     SkXMLWriter*                    fWriter;
63     std::unique_ptr<AutoElement>    fRootElement;
64     std::unique_ptr<ResourceBucket> fResourceBucket;
65 
66     typedef SkClipStackDevice INHERITED;
67 };
68 
69 #endif // SkSVGDevice_DEFINED
70