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