skia2/tools/debugger/SkJsonWriteBuffer.h
brianosman fad98562d8 Prototype code that turns any/every flattenable into JSON
This makes inspecting things in SkDebugger far more useful - any filter
or other complex object on the paint is ultimately visible. You still
have to do some guess work to figure out what the fields actually mean,
but you can at least cross-reference with the code in flatten().

Screenshots:
Before: https://screenshot.googleplex.com/a6JM5HBBe6G.png
After : https://screenshot.googleplex.com/XQfr4YJ6mnH.png

Changes to public API are just removals and changes to make
some functions virtual.

TBR=reed@google.com

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1920423002

Review-Url: https://codereview.chromium.org/1920423002
2016-05-04 11:06:28 -07:00

61 lines
2.0 KiB
C++

/*
* Copyright 2016 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)
, fJson(Json::objectValue) {}
bool isCrossProcess() const override { return false; }
void writeByteArray(const void* data, size_t size) 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 writeString(const char* value) override;
void writeFlattenable(const SkFlattenable* flattenable) override;
void writeColor(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;
};
#endif