blob: 0e22910412ae92e49d5425d3131dba8a3fee954a [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
Mike Reedc5e641c2017-02-17 14:38:11 -050011#include "SkClipStackDevice.h"
senorblanco900c3672016-04-27 11:31:23 -070012#include "SkTemplates.h"
fmalita93957f42015-01-30 09:03:29 -080013
fmalita93957f42015-01-30 09:03:29 -080014class SkXMLWriter;
15
Mike Reedc5e641c2017-02-17 14:38:11 -050016class SkSVGDevice : public SkClipStackDevice {
fmalita93957f42015-01-30 09:03:29 -080017public:
fmalita2aafe6f2015-02-06 12:51:10 -080018 static SkBaseDevice* Create(const SkISize& size, SkXMLWriter* writer);
fmalita93957f42015-01-30 09:03:29 -080019
fmalita93957f42015-01-30 09:03:29 -080020protected:
Mike Reeda1361362017-03-07 09:37:29 -050021 void drawPaint(const SkPaint& paint) override;
22 void drawPoints(SkCanvas::PointMode mode, size_t count,
tfarina85665392015-05-04 06:40:31 -070023 const SkPoint[], const SkPaint& paint) override;
Mike Reeda1361362017-03-07 09:37:29 -050024 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,
tfarina85665392015-05-04 06:40:31 -070028 const SkPaint& paint,
halcanary96fcdcc2015-08-27 07:41:13 -070029 const SkMatrix* prePathMatrix = nullptr,
tfarina85665392015-05-04 06:40:31 -070030 bool pathIsMutable = false) override;
fmalita93957f42015-01-30 09:03:29 -080031
Hal Canaryb9642382017-06-27 09:58:56 -040032 void drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, const SkPaint& paint) override;
Mike Reeda1361362017-03-07 09:37:29 -050033 void drawSprite(const SkBitmap& bitmap,
tfarina85665392015-05-04 06:40:31 -070034 int x, int y, const SkPaint& paint) override;
Mike Reeda1361362017-03-07 09:37:29 -050035 void drawBitmapRect(const SkBitmap&,
tfarina85665392015-05-04 06:40:31 -070036 const SkRect* srcOrNull, const SkRect& dst,
reed562fe472015-07-28 07:35:14 -070037 const SkPaint& paint, SkCanvas::SrcRectConstraint) override;
fmalita93957f42015-01-30 09:03:29 -080038
Mike Reeda1361362017-03-07 09:37:29 -050039 void drawText(const void* text, size_t len,
tfarina85665392015-05-04 06:40:31 -070040 SkScalar x, SkScalar y, const SkPaint& paint) override;
Mike Reeda1361362017-03-07 09:37:29 -050041 void drawPosText(const void* text, size_t len,
tfarina85665392015-05-04 06:40:31 -070042 const SkScalar pos[], int scalarsPerPos,
43 const SkPoint& offset, const SkPaint& paint) override;
Mike Reeda1361362017-03-07 09:37:29 -050044 void drawTextOnPath(const void* text, size_t len,
tfarina85665392015-05-04 06:40:31 -070045 const SkPath& path, const SkMatrix* matrix,
46 const SkPaint& paint) override;
Mike Reed2f6b5a42017-03-19 15:04:17 -040047 void drawVertices(const SkVertices*, SkBlendMode, const SkPaint& paint) override;
fmalita93957f42015-01-30 09:03:29 -080048
Mike Reeda1361362017-03-07 09:37:29 -050049 void drawDevice(SkBaseDevice*, int x, int y,
tfarina85665392015-05-04 06:40:31 -070050 const SkPaint&) override;
fmalita93957f42015-01-30 09:03:29 -080051
52private:
fmalita2aafe6f2015-02-06 12:51:10 -080053 SkSVGDevice(const SkISize& size, SkXMLWriter* writer);
Brian Salomond3b65972017-03-22 12:05:03 -040054 ~SkSVGDevice() override;
fmalita93957f42015-01-30 09:03:29 -080055
Mike Reedc5e641c2017-02-17 14:38:11 -050056 struct MxCp;
57 void drawBitmapCommon(const MxCp&, const SkBitmap& bm, const SkPaint& paint);
fmalita827da232015-02-27 07:44:47 -080058
fmalita532faa92015-02-03 05:44:40 -080059 class AutoElement;
60 class ResourceBucket;
fmalita93957f42015-01-30 09:03:29 -080061
Ben Wagner145dbcd2016-11-03 14:40:50 -040062 SkXMLWriter* fWriter;
63 std::unique_ptr<AutoElement> fRootElement;
64 std::unique_ptr<ResourceBucket> fResourceBucket;
robertphillips9a53fd72015-06-22 09:46:59 -070065
Mike Reedc5e641c2017-02-17 14:38:11 -050066 typedef SkClipStackDevice INHERITED;
fmalita93957f42015-01-30 09:03:29 -080067};
68
69#endif // SkSVGDevice_DEFINED