• 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   write(const SkM44&) override;
41     void   writeMatrix(const SkMatrix& matrix) override;
42     void   writeIRect(const SkIRect& rect) override;
43     void   writeRect(const SkRect& rect) override;
44     void   writeRegion(const SkRegion& region) override;
45     void   writePath(const SkPath& path) override;
46     size_t writeStream(SkStream* stream, size_t length) override;
47     void   writeImage(const SkImage*) override;
48     void   writeTypeface(SkTypeface* typeface) override;
49     void   writePaint(const SkPaint& paint) override;
50 
51 private:
52     void append(const char* type);
53 
54     UrlDataManager* fUrlDataManager;
55     SkJSONWriter*   fWriter;
56     int             fCount;
57 };
58 
59 #endif
60