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/private/SkTemplates.h" 12 #include "src/core/SkClipStackDevice.h" 13 14 class SkXMLWriter; 15 16 class SkSVGDevice final : public SkClipStackDevice { 17 public: 18 static sk_sp<SkBaseDevice> Make(const SkISize& size, std::unique_ptr<SkXMLWriter>, 19 uint32_t flags); 20 21 protected: 22 void drawPaint(const SkPaint& paint) override; 23 void drawAnnotation(const SkRect& rect, const char key[], SkData* value) override; 24 void drawPoints(SkCanvas::PointMode mode, size_t count, 25 const SkPoint[], const SkPaint& paint) override; 26 void drawRect(const SkRect& r, const SkPaint& paint) override; 27 void drawOval(const SkRect& oval, const SkPaint& paint) override; 28 void drawRRect(const SkRRect& rr, const SkPaint& paint) override; 29 void drawPath(const SkPath& path, 30 const SkPaint& paint, 31 bool pathIsMutable = false) override; 32 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 void drawGlyphRunList(const SkGlyphRunList& glyphRunList) override; 39 void drawVertices(const SkVertices*, const SkVertices::Bone bones[], int boneCount, SkBlendMode, 40 const SkPaint& paint) override; 41 42 void drawDevice(SkBaseDevice*, int x, int y, 43 const SkPaint&) override; 44 45 private: 46 SkSVGDevice(const SkISize& size, std::unique_ptr<SkXMLWriter>, uint32_t); 47 ~SkSVGDevice() override; 48 49 void drawGlyphRunAsText(const SkGlyphRun&, const SkPoint&, const SkPaint&); 50 void drawGlyphRunAsPath(const SkGlyphRun&, const SkPoint&, const SkPaint&); 51 52 struct MxCp; 53 void drawBitmapCommon(const MxCp&, const SkBitmap& bm, const SkPaint& paint); 54 55 class AutoElement; 56 class ResourceBucket; 57 58 const std::unique_ptr<SkXMLWriter> fWriter; 59 const std::unique_ptr<ResourceBucket> fResourceBucket; 60 const uint32_t fFlags; 61 62 std::unique_ptr<AutoElement> fRootElement; 63 64 typedef SkClipStackDevice INHERITED; 65 }; 66 67 #endif // SkSVGDevice_DEFINED 68