• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2016 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 SkJsonWriteBuffer_DEFINED
9 #define SkJsonWriteBuffer_DEFINED
10 
11 #include "SkWriteBuffer.h"
12 
13 class SkJSONWriter;
14 class SkPath;
15 class UrlDataManager;
16 
17 class SkJsonWriteBuffer final : public SkWriteBuffer {
18 public:
SkJsonWriteBuffer(SkJSONWriter * writer,UrlDataManager * urlDataManager)19     SkJsonWriteBuffer(SkJSONWriter* writer, UrlDataManager* urlDataManager)
20         : fUrlDataManager(urlDataManager)
21         , fWriter(writer)
22         , fCount(0) {}
23 
24     void writePad32(const void* buffer, size_t bytes) override;
25     void writeByteArray(const void* data, size_t size) override;
26     void writeBool(bool value) override;
27     void writeScalar(SkScalar value) override;
28     void writeScalarArray(const SkScalar* value, uint32_t count) override;
29     void writeInt(int32_t value) override;
30     void writeIntArray(const int32_t* value, uint32_t count) override;
31     void writeUInt(uint32_t value) override;
32     void writeString(const char* value) override;
33 
34     void writeFlattenable(const SkFlattenable* flattenable) override;
35     void writeColor(SkColor color) override;
36     void writeColorArray(const SkColor* color, uint32_t count) override;
37     void writeColor4f(const SkColor4f& color) override;
38     void writeColor4fArray(const SkColor4f* color, uint32_t count) override;
39     void writePoint(const SkPoint& point) override;
40     void writePointArray(const SkPoint* point, uint32_t count) override;
41     void writePoint3(const SkPoint3& point) override;
42     void writeMatrix(const SkMatrix& matrix) override;
43     void writeIRect(const SkIRect& rect) override;
44     void writeRect(const SkRect& rect) override;
45     void writeRegion(const SkRegion& region) override;
46     void writePath(const SkPath& path) override;
47     size_t writeStream(SkStream* stream, size_t length) override;
48     void writeImage(const SkImage*) override;
49     void writeTypeface(SkTypeface* typeface) override;
50     void writePaint(const SkPaint& paint) override;
51 
52 private:
53     void append(const char* type);
54 
55     UrlDataManager* fUrlDataManager;
56     SkJSONWriter* fWriter;
57     int fCount;
58 };
59 
60 #endif
61