Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2281)

Unified Diff: tools/debugger/SkJsonWriteBuffer.h

Issue 1920423002: Prototype code that turns any/every flattenable into JSON (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase and review feedback Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/debugger/SkJsonWriteBuffer.h
diff --git a/tools/debugger/SkJsonWriteBuffer.h b/tools/debugger/SkJsonWriteBuffer.h
new file mode 100644
index 0000000000000000000000000000000000000000..765305d444ccb8277305ae0020998e56581c5aa2
--- /dev/null
+++ b/tools/debugger/SkJsonWriteBuffer.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkJsonWriteBuffer_DEFINED
+#define SkJsonWriteBuffer_DEFINED
+
+#include "SkWriteBuffer.h"
+
+#include "SkJSONCPP.h"
+
+class SkPath;
+class UrlDataManager;
+
+class SkJsonWriteBuffer final : public SkWriteBuffer {
+public:
+ SkJsonWriteBuffer(UrlDataManager* urlDataManager)
+ : fUrlDataManager(urlDataManager)
+ , fFieldCount(0) {}
+
+ bool isCrossProcess() const override { return false; }
+
+ void writeByteArray(const void* data, size_t size) override;
+ void writeDataAsByteArray(SkData* data) override;
+ void writeBool(bool value) override;
+ void writeScalar(SkScalar value) override;
+ void writeScalarArray(const SkScalar* value, uint32_t count) override;
+ void writeInt(int32_t value) override;
+ void writeIntArray(const int32_t* value, uint32_t count) override;
+ void writeUInt(uint32_t value) override;
+ void write32(int32_t value) override;
+ void writeString(const char* value) override;
+ void writeEncodedString(const void* value, size_t byteLength,
+ SkPaint::TextEncoding encoding) override;
+ void writeFunctionPtr(void* ptr) override;
+
+ void writeFlattenable(const SkFlattenable* flattenable) override;
+ void writeColor(const SkColor& color) override;
+ void writeColorArray(const SkColor* color, uint32_t count) override;
+ void writePoint(const SkPoint& point) override;
+ void writePointArray(const SkPoint* point, uint32_t count) override;
+ void writeMatrix(const SkMatrix& matrix) override;
+ void writeIRect(const SkIRect& rect) override;
+ void writeRect(const SkRect& rect) override;
+ void writeRegion(const SkRegion& region) override;
+ void writePath(const SkPath& path) override;
+ size_t writeStream(SkStream* stream, size_t length) override;
+ void writeBitmap(const SkBitmap& bitmap) override;
+ void writeImage(const SkImage*) override;
+ void writeTypeface(SkTypeface* typeface) override;
+ void writePaint(const SkPaint& paint) override;
+
+ const Json::Value& getValue() const { return fJson; }
+
+private:
+ void append(const char* type, const Json::Value& value);
+
+ UrlDataManager* fUrlDataManager;
+ Json::Value fJson;
+ uint32_t fFieldCount;
+};
+
+#endif

Powered by Google App Engine
This is Rietveld 408576698