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 "SkDevice.h" 12 #include "SkTemplates.h" 13 14 class SkXMLWriter; 15 16 class SkSVGDevice : public SkBaseDevice { 17 public: 18 static SkBaseDevice* Create(const SkISize& size, SkXMLWriter* writer); 19 20 protected: 21 void drawPaint(const SkDraw&, const SkPaint& paint) override; 22 void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t count, 23 const SkPoint[], const SkPaint& paint) override; 24 void drawRect(const SkDraw&, const SkRect& r, const SkPaint& paint) override; 25 void drawOval(const SkDraw&, const SkRect& oval, const SkPaint& paint) override; 26 void drawRRect(const SkDraw&, const SkRRect& rr, const SkPaint& paint) override; 27 void drawPath(const SkDraw&, const SkPath& path, 28 const SkPaint& paint, 29 const SkMatrix* prePathMatrix = nullptr, 30 bool pathIsMutable = false) override; 31 32 void drawBitmap(const SkDraw&, const SkBitmap& bitmap, 33 const SkMatrix& matrix, const SkPaint& paint) override; 34 void drawSprite(const SkDraw&, const SkBitmap& bitmap, 35 int x, int y, const SkPaint& paint) override; 36 void drawBitmapRect(const SkDraw&, const SkBitmap&, 37 const SkRect* srcOrNull, const SkRect& dst, 38 const SkPaint& paint, SkCanvas::SrcRectConstraint) override; 39 40 void drawText(const SkDraw&, const void* text, size_t len, 41 SkScalar x, SkScalar y, const SkPaint& paint) override; 42 void drawPosText(const SkDraw&, const void* text, size_t len, 43 const SkScalar pos[], int scalarsPerPos, 44 const SkPoint& offset, const SkPaint& paint) override; 45 void drawTextOnPath(const SkDraw&, const void* text, size_t len, 46 const SkPath& path, const SkMatrix* matrix, 47 const SkPaint& paint) override; 48 void drawVertices(const SkDraw&, SkCanvas::VertexMode, int vertexCount, 49 const SkPoint verts[], const SkPoint texs[], 50 const SkColor colors[], SkXfermode* xmode, 51 const uint16_t indices[], int indexCount, 52 const SkPaint& paint) override; 53 54 void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, 55 const SkPaint&) override; 56 57 private: 58 SkSVGDevice(const SkISize& size, SkXMLWriter* writer); 59 virtual ~SkSVGDevice(); 60 61 void drawBitmapCommon(const SkDraw& draw, const SkBitmap& bm, const SkPaint& paint); 62 63 class AutoElement; 64 class ResourceBucket; 65 66 SkXMLWriter* fWriter; 67 SkAutoTDelete<AutoElement> fRootElement; 68 SkAutoTDelete<ResourceBucket> fResourceBucket; 69 70 typedef SkBaseDevice INHERITED; 71 }; 72 73 #endif // SkSVGDevice_DEFINED 74