fmalita | 93957f4 | 2015-01-30 09:03:29 -0800 | [diff] [blame] | 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 | |
fmalita | 93957f4 | 2015-01-30 09:03:29 -0800 | [diff] [blame] | 13 | class SkXMLWriter; |
| 14 | |
| 15 | class SkSVGDevice : public SkBaseDevice { |
| 16 | public: |
fmalita | 2aafe6f | 2015-02-06 12:51:10 -0800 | [diff] [blame] | 17 | static SkBaseDevice* Create(const SkISize& size, SkXMLWriter* writer); |
fmalita | 93957f4 | 2015-01-30 09:03:29 -0800 | [diff] [blame] | 18 | |
tfarina | 8566539 | 2015-05-04 06:40:31 -0700 | [diff] [blame] | 19 | SkImageInfo imageInfo() const override; |
fmalita | 93957f4 | 2015-01-30 09:03:29 -0800 | [diff] [blame] | 20 | |
| 21 | protected: |
tfarina | 8566539 | 2015-05-04 06:40:31 -0700 | [diff] [blame] | 22 | 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, |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 30 | const SkMatrix* prePathMatrix = nullptr, |
tfarina | 8566539 | 2015-05-04 06:40:31 -0700 | [diff] [blame] | 31 | bool pathIsMutable = false) override; |
fmalita | 93957f4 | 2015-01-30 09:03:29 -0800 | [diff] [blame] | 32 | |
tfarina | 8566539 | 2015-05-04 06:40:31 -0700 | [diff] [blame] | 33 | 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, |
reed | 562fe47 | 2015-07-28 07:35:14 -0700 | [diff] [blame] | 39 | const SkPaint& paint, SkCanvas::SrcRectConstraint) override; |
fmalita | 93957f4 | 2015-01-30 09:03:29 -0800 | [diff] [blame] | 40 | |
tfarina | 8566539 | 2015-05-04 06:40:31 -0700 | [diff] [blame] | 41 | void drawText(const SkDraw&, const void* text, size_t len, |
| 42 | SkScalar x, SkScalar y, const SkPaint& paint) override; |
| 43 | void drawPosText(const SkDraw&, const void* text, size_t len, |
| 44 | const SkScalar pos[], int scalarsPerPos, |
| 45 | const SkPoint& offset, const SkPaint& paint) override; |
| 46 | void drawTextOnPath(const SkDraw&, const void* text, size_t len, |
| 47 | const SkPath& path, const SkMatrix* matrix, |
| 48 | const SkPaint& paint) override; |
| 49 | void drawVertices(const SkDraw&, SkCanvas::VertexMode, int vertexCount, |
| 50 | const SkPoint verts[], const SkPoint texs[], |
| 51 | const SkColor colors[], SkXfermode* xmode, |
| 52 | const uint16_t indices[], int indexCount, |
| 53 | const SkPaint& paint) override; |
fmalita | 93957f4 | 2015-01-30 09:03:29 -0800 | [diff] [blame] | 54 | |
tfarina | 8566539 | 2015-05-04 06:40:31 -0700 | [diff] [blame] | 55 | void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, |
| 56 | const SkPaint&) override; |
| 57 | const SkBitmap& onAccessBitmap() override; |
fmalita | 93957f4 | 2015-01-30 09:03:29 -0800 | [diff] [blame] | 58 | |
| 59 | private: |
fmalita | 2aafe6f | 2015-02-06 12:51:10 -0800 | [diff] [blame] | 60 | SkSVGDevice(const SkISize& size, SkXMLWriter* writer); |
fmalita | 93957f4 | 2015-01-30 09:03:29 -0800 | [diff] [blame] | 61 | virtual ~SkSVGDevice(); |
| 62 | |
fmalita | 827da23 | 2015-02-27 07:44:47 -0800 | [diff] [blame] | 63 | void drawBitmapCommon(const SkDraw& draw, const SkBitmap& bm, const SkPaint& paint); |
| 64 | |
fmalita | 532faa9 | 2015-02-03 05:44:40 -0800 | [diff] [blame] | 65 | class AutoElement; |
| 66 | class ResourceBucket; |
fmalita | 93957f4 | 2015-01-30 09:03:29 -0800 | [diff] [blame] | 67 | |
fmalita | 2aafe6f | 2015-02-06 12:51:10 -0800 | [diff] [blame] | 68 | SkXMLWriter* fWriter; |
fmalita | 532faa9 | 2015-02-03 05:44:40 -0800 | [diff] [blame] | 69 | SkAutoTDelete<AutoElement> fRootElement; |
| 70 | SkAutoTDelete<ResourceBucket> fResourceBucket; |
| 71 | SkBitmap fLegacyBitmap; |
robertphillips | 9a53fd7 | 2015-06-22 09:46:59 -0700 | [diff] [blame] | 72 | |
| 73 | typedef SkBaseDevice INHERITED; |
fmalita | 93957f4 | 2015-01-30 09:03:29 -0800 | [diff] [blame] | 74 | }; |
| 75 | |
| 76 | #endif // SkSVGDevice_DEFINED |