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 sk_sp<SkBaseDevice> Make(const SkISize& size, std::unique_ptr<SkXMLWriter>); 19 20 protected: 21 void drawPaint(const SkPaint& paint) override; 22 void drawAnnotation(const SkRect& rect, const char key[], SkData* value) override; 23 void drawPoints(SkCanvas::PointMode mode, size_t count, 24 const SkPoint[], const SkPaint& paint) override; 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, 29 const SkPaint& paint, 30 bool pathIsMutable = false) override; 31 32 void drawSprite(const SkBitmap& bitmap, 33 int x, int y, const SkPaint& paint) override; 34 void drawBitmapRect(const SkBitmap&, 35 const SkRect* srcOrNull, const SkRect& dst, 36 const SkPaint& paint, SkCanvas::SrcRectConstraint) override; 37 void drawGlyphRunList(const SkGlyphRunList& glyphRunList) override; 38 void drawVertices(const SkVertices*, const SkVertices::Bone bones[], int boneCount, SkBlendMode, 39 const SkPaint& paint) override; 40 41 void drawDevice(SkBaseDevice*, int x, int y, 42 const SkPaint&) override; 43 44 private: 45 SkSVGDevice(const SkISize& size, std::unique_ptr<SkXMLWriter>); 46 ~SkSVGDevice() override; 47 48 struct MxCp; 49 void drawBitmapCommon(const MxCp&, const SkBitmap& bm, const SkPaint& paint); 50 51 class AutoElement; 52 class ResourceBucket; 53 54 std::unique_ptr<SkXMLWriter> fWriter; 55 std::unique_ptr<AutoElement> fRootElement; 56 std::unique_ptr<ResourceBucket> fResourceBucket; 57 58 typedef SkClipStackDevice INHERITED; 59 }; 60 61 #endif // SkSVGDevice_DEFINED 62