SkSVGDevice.h 2.4 KB

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