blob: 249cd65f9d7fe212ef23eb547fa6c2e539080322 [file] [log] [blame]
fmalita93957f42015-01-30 09:03:29 -08001/*
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
fmalita93957f42015-01-30 09:03:29 -080013class SkXMLWriter;
14
15class SkSVGDevice : public SkBaseDevice {
16public:
fmalita2aafe6f2015-02-06 12:51:10 -080017 static SkBaseDevice* Create(const SkISize& size, SkXMLWriter* writer);
fmalita93957f42015-01-30 09:03:29 -080018
tfarina85665392015-05-04 06:40:31 -070019 SkImageInfo imageInfo() const override;
fmalita93957f42015-01-30 09:03:29 -080020
21protected:
tfarina85665392015-05-04 06:40:31 -070022 void drawPaint(const SkDraw&, const SkPaint& paint) override;
23 void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t count,
24 const SkPoint[], const SkPaint& paint) override;
25 void drawRect(const SkDraw&, const SkRect& r, const SkPaint& paint) override;
26 void drawOval(const SkDraw&, const SkRect& oval, const SkPaint& paint) override;
27 void drawRRect(const SkDraw&, const SkRRect& rr, const SkPaint& paint) override;
28 void drawPath(const SkDraw&, const SkPath& path,
29 const SkPaint& paint,
30 const SkMatrix* prePathMatrix = NULL,
31 bool pathIsMutable = false) override;
fmalita93957f42015-01-30 09:03:29 -080032
tfarina85665392015-05-04 06:40:31 -070033 void drawBitmap(const SkDraw&, const SkBitmap& bitmap,
34 const SkMatrix& matrix, const SkPaint& paint) override;
35 void drawSprite(const SkDraw&, const SkBitmap& bitmap,
36 int x, int y, const SkPaint& paint) override;
37 void drawBitmapRect(const SkDraw&, const SkBitmap&,
38 const SkRect* srcOrNull, const SkRect& dst,
39 const SkPaint& paint,
40 SkCanvas::DrawBitmapRectFlags flags) override;
fmalita93957f42015-01-30 09:03:29 -080041
tfarina85665392015-05-04 06:40:31 -070042 void drawText(const SkDraw&, const void* text, size_t len,
43 SkScalar x, SkScalar y, const SkPaint& paint) override;
44 void drawPosText(const SkDraw&, const void* text, size_t len,
45 const SkScalar pos[], int scalarsPerPos,
46 const SkPoint& offset, const SkPaint& paint) override;
47 void drawTextOnPath(const SkDraw&, const void* text, size_t len,
48 const SkPath& path, const SkMatrix* matrix,
49 const SkPaint& paint) override;
50 void drawVertices(const SkDraw&, SkCanvas::VertexMode, int vertexCount,
51 const SkPoint verts[], const SkPoint texs[],
52 const SkColor colors[], SkXfermode* xmode,
53 const uint16_t indices[], int indexCount,
54 const SkPaint& paint) override;
fmalita93957f42015-01-30 09:03:29 -080055
tfarina85665392015-05-04 06:40:31 -070056 void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y,
57 const SkPaint&) override;
58 const SkBitmap& onAccessBitmap() override;
fmalita93957f42015-01-30 09:03:29 -080059
60private:
fmalita2aafe6f2015-02-06 12:51:10 -080061 SkSVGDevice(const SkISize& size, SkXMLWriter* writer);
fmalita93957f42015-01-30 09:03:29 -080062 virtual ~SkSVGDevice();
63
fmalita827da232015-02-27 07:44:47 -080064 void drawBitmapCommon(const SkDraw& draw, const SkBitmap& bm, const SkPaint& paint);
65
fmalita532faa92015-02-03 05:44:40 -080066 class AutoElement;
67 class ResourceBucket;
fmalita93957f42015-01-30 09:03:29 -080068
fmalita2aafe6f2015-02-06 12:51:10 -080069 SkXMLWriter* fWriter;
fmalita532faa92015-02-03 05:44:40 -080070 SkAutoTDelete<AutoElement> fRootElement;
71 SkAutoTDelete<ResourceBucket> fResourceBucket;
72 SkBitmap fLegacyBitmap;
fmalita93957f42015-01-30 09:03:29 -080073};
74
75#endif // SkSVGDevice_DEFINED