Revert "Revert "Support single line objects and arrays""
This reverts commit a5a69cfb48
.
Bug: skia:
Change-Id: I08475d96255b9df13e5c86e1ef9c7f4739e51459
Reviewed-on: https://skia-review.googlesource.com/33202
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
f7332d3238
commit
80488229ea
@ -193,7 +193,7 @@ void GrCaps::dumpJSON(SkJSONWriter* writer) const {
|
|||||||
|
|
||||||
for (size_t i = 1; i < kGrPixelConfigCnt; ++i) {
|
for (size_t i = 1; i < kGrPixelConfigCnt; ++i) {
|
||||||
GrPixelConfig config = static_cast<GrPixelConfig>(i);
|
GrPixelConfig config = static_cast<GrPixelConfig>(i);
|
||||||
writer->beginObject();
|
writer->beginObject(nullptr, false);
|
||||||
writer->appendString("name", pixel_config_name(config));
|
writer->appendString("name", pixel_config_name(config));
|
||||||
writer->appendBool("renderable", this->isConfigRenderable(config, false));
|
writer->appendBool("renderable", this->isConfigRenderable(config, false));
|
||||||
writer->appendBool("renderableMSAA", this->isConfigRenderable(config, true));
|
writer->appendBool("renderableMSAA", this->isConfigRenderable(config, true));
|
||||||
|
@ -117,7 +117,7 @@ void GrShaderCaps::dumpJSON(SkJSONWriter* writer) const {
|
|||||||
for (int p = 0; p < kGrSLPrecisionCount; ++p) {
|
for (int p = 0; p < kGrSLPrecisionCount; ++p) {
|
||||||
if (fFloatPrecisions[s][p].supported()) {
|
if (fFloatPrecisions[s][p].supported()) {
|
||||||
GrSLPrecision precision = static_cast<GrSLPrecision>(p);
|
GrSLPrecision precision = static_cast<GrSLPrecision>(p);
|
||||||
writer->beginObject();
|
writer->beginObject(nullptr, false);
|
||||||
writer->appendString("precision", precision_to_string(precision));
|
writer->appendString("precision", precision_to_string(precision));
|
||||||
writer->appendS32("log_low", fFloatPrecisions[s][p].fLogRangeLow);
|
writer->appendS32("log_low", fFloatPrecisions[s][p].fLogRangeLow);
|
||||||
writer->appendS32("log_high", fFloatPrecisions[s][p].fLogRangeHigh);
|
writer->appendS32("log_high", fFloatPrecisions[s][p].fLogRangeHigh);
|
||||||
|
@ -1258,7 +1258,7 @@ void GrGLCaps::onDumpJSON(SkJSONWriter* writer) const {
|
|||||||
writer->beginArray("Stencil Formats");
|
writer->beginArray("Stencil Formats");
|
||||||
|
|
||||||
for (int i = 0; i < fStencilFormats.count(); ++i) {
|
for (int i = 0; i < fStencilFormats.count(); ++i) {
|
||||||
writer->beginObject();
|
writer->beginObject(nullptr, false);
|
||||||
writer->appendS32("stencil bits", fStencilFormats[i].fStencilBits);
|
writer->appendS32("stencil bits", fStencilFormats[i].fStencilBits);
|
||||||
writer->appendS32("total bits", fStencilFormats[i].fTotalBits);
|
writer->appendS32("total bits", fStencilFormats[i].fTotalBits);
|
||||||
writer->endObject();
|
writer->endObject();
|
||||||
@ -1339,7 +1339,7 @@ void GrGLCaps::onDumpJSON(SkJSONWriter* writer) const {
|
|||||||
writer->beginArray("configs");
|
writer->beginArray("configs");
|
||||||
|
|
||||||
for (int i = 0; i < kGrPixelConfigCnt; ++i) {
|
for (int i = 0; i < kGrPixelConfigCnt; ++i) {
|
||||||
writer->beginObject();
|
writer->beginObject(nullptr, false);
|
||||||
writer->appendHexU32("flags", fConfigTable[i].fFlags);
|
writer->appendHexU32("flags", fConfigTable[i].fFlags);
|
||||||
writer->appendHexU32("b_internal", fConfigTable[i].fFormats.fBaseInternalFormat);
|
writer->appendHexU32("b_internal", fConfigTable[i].fFormats.fBaseInternalFormat);
|
||||||
writer->appendHexU32("s_internal", fConfigTable[i].fFormats.fSizedInternalFormat);
|
writer->appendHexU32("s_internal", fConfigTable[i].fFormats.fSizedInternalFormat);
|
||||||
|
@ -53,12 +53,14 @@ public:
|
|||||||
, fMode(mode)
|
, fMode(mode)
|
||||||
, fState(State::kStart) {
|
, fState(State::kStart) {
|
||||||
fScopeStack.push_back(Scope::kNone);
|
fScopeStack.push_back(Scope::kNone);
|
||||||
|
fNewlineStack.push_back(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
~SkJSONWriter() {
|
~SkJSONWriter() {
|
||||||
this->flush();
|
this->flush();
|
||||||
delete[] fBlock;
|
delete[] fBlock;
|
||||||
SkASSERT(fScopeStack.count() == 1);
|
SkASSERT(fScopeStack.count() == 1);
|
||||||
|
SkASSERT(fNewlineStack.count() == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -85,7 +87,7 @@ public:
|
|||||||
if (State::kObjectValue == fState) {
|
if (State::kObjectValue == fState) {
|
||||||
this->write(",", 1);
|
this->write(",", 1);
|
||||||
}
|
}
|
||||||
this->newline();
|
this->separator(this->multiline());
|
||||||
this->write("\"", 1);
|
this->write("\"", 1);
|
||||||
this->write(name, strlen(name));
|
this->write(name, strlen(name));
|
||||||
this->write("\":", 2);
|
this->write("\":", 2);
|
||||||
@ -95,12 +97,17 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Adds a new object. A name must be supplied when called between beginObject() and
|
* Adds a new object. A name must be supplied when called between beginObject() and
|
||||||
* endObject(). Calls to beginObject() must be balanced by corresponding calls to endObject().
|
* endObject(). Calls to beginObject() must be balanced by corresponding calls to endObject().
|
||||||
|
* By default, objects are written out with one named value per line (when in kPretty mode).
|
||||||
|
* This can be overridden for a particular object by passing false for multiline, this will
|
||||||
|
* keep the entire object on a single line. This can help with readability in some situations.
|
||||||
|
* In kFast mode, this parameter is ignored.
|
||||||
*/
|
*/
|
||||||
void beginObject(const char* name = nullptr) {
|
void beginObject(const char* name = nullptr, bool multiline = true) {
|
||||||
this->appendName(name);
|
this->appendName(name);
|
||||||
this->beginValue(true);
|
this->beginValue(true);
|
||||||
this->write("{", 1);
|
this->write("{", 1);
|
||||||
fScopeStack.push_back(Scope::kObject);
|
fScopeStack.push_back(Scope::kObject);
|
||||||
|
fNewlineStack.push_back(multiline);
|
||||||
fState = State::kObjectBegin;
|
fState = State::kObjectBegin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,9 +118,10 @@ public:
|
|||||||
SkASSERT(Scope::kObject == this->scope());
|
SkASSERT(Scope::kObject == this->scope());
|
||||||
SkASSERT(State::kObjectBegin == fState || State::kObjectValue == fState);
|
SkASSERT(State::kObjectBegin == fState || State::kObjectValue == fState);
|
||||||
bool emptyObject = State::kObjectBegin == fState;
|
bool emptyObject = State::kObjectBegin == fState;
|
||||||
|
bool wasMultiline = this->multiline();
|
||||||
this->popScope();
|
this->popScope();
|
||||||
if (!emptyObject) {
|
if (!emptyObject) {
|
||||||
this->newline();
|
this->separator(wasMultiline);
|
||||||
}
|
}
|
||||||
this->write("}", 1);
|
this->write("}", 1);
|
||||||
}
|
}
|
||||||
@ -121,12 +129,17 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Adds a new array. A name must be supplied when called between beginObject() and
|
* Adds a new array. A name must be supplied when called between beginObject() and
|
||||||
* endObject(). Calls to beginArray() must be balanced by corresponding calls to endArray().
|
* endObject(). Calls to beginArray() must be balanced by corresponding calls to endArray().
|
||||||
|
* By default, arrays are written out with one value per line (when in kPretty mode).
|
||||||
|
* This can be overridden for a particular array by passing false for multiline, this will
|
||||||
|
* keep the entire array on a single line. This can help with readability in some situations.
|
||||||
|
* In kFast mode, this parameter is ignored.
|
||||||
*/
|
*/
|
||||||
void beginArray(const char* name = nullptr) {
|
void beginArray(const char* name = nullptr, bool multiline = true) {
|
||||||
this->appendName(name);
|
this->appendName(name);
|
||||||
this->beginValue(true);
|
this->beginValue(true);
|
||||||
this->write("[", 1);
|
this->write("[", 1);
|
||||||
fScopeStack.push_back(Scope::kArray);
|
fScopeStack.push_back(Scope::kArray);
|
||||||
|
fNewlineStack.push_back(multiline);
|
||||||
fState = State::kArrayBegin;
|
fState = State::kArrayBegin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,9 +150,10 @@ public:
|
|||||||
SkASSERT(Scope::kArray == this->scope());
|
SkASSERT(Scope::kArray == this->scope());
|
||||||
SkASSERT(State::kArrayBegin == fState || State::kArrayValue == fState);
|
SkASSERT(State::kArrayBegin == fState || State::kArrayValue == fState);
|
||||||
bool emptyArray = State::kArrayBegin == fState;
|
bool emptyArray = State::kArrayBegin == fState;
|
||||||
|
bool wasMultiline = this->multiline();
|
||||||
this->popScope();
|
this->popScope();
|
||||||
if (!emptyArray) {
|
if (!emptyArray) {
|
||||||
this->newline();
|
this->separator(wasMultiline);
|
||||||
}
|
}
|
||||||
this->write("]", 1);
|
this->write("]", 1);
|
||||||
}
|
}
|
||||||
@ -245,7 +259,7 @@ private:
|
|||||||
this->write(",", 1);
|
this->write(",", 1);
|
||||||
}
|
}
|
||||||
if (Scope::kArray == this->scope()) {
|
if (Scope::kArray == this->scope()) {
|
||||||
this->newline();
|
this->separator(this->multiline());
|
||||||
} else if (Scope::kObject == this->scope() && Mode::kPretty == fMode) {
|
} else if (Scope::kObject == this->scope() && Mode::kPretty == fMode) {
|
||||||
this->write(" ", 1);
|
this->write(" ", 1);
|
||||||
}
|
}
|
||||||
@ -256,11 +270,15 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void newline() {
|
void separator(bool multiline) {
|
||||||
if (Mode::kPretty == fMode) {
|
if (Mode::kPretty == fMode) {
|
||||||
this->write("\n", 1);
|
if (multiline) {
|
||||||
for (int i = 0; i < fScopeStack.count() - 1; ++i) {
|
this->write("\n", 1);
|
||||||
this->write(" ", 3);
|
for (int i = 0; i < fScopeStack.count() - 1; ++i) {
|
||||||
|
this->write(" ", 3);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this->write(" ", 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -284,8 +302,14 @@ private:
|
|||||||
return fScopeStack.back();
|
return fScopeStack.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool multiline() const {
|
||||||
|
SkASSERT(!fNewlineStack.empty());
|
||||||
|
return fNewlineStack.back();
|
||||||
|
}
|
||||||
|
|
||||||
void popScope() {
|
void popScope() {
|
||||||
fScopeStack.pop_back();
|
fScopeStack.pop_back();
|
||||||
|
fNewlineStack.pop_back();
|
||||||
switch (this->scope()) {
|
switch (this->scope()) {
|
||||||
case Scope::kNone:
|
case Scope::kNone:
|
||||||
fState = State::kEnd;
|
fState = State::kEnd;
|
||||||
@ -310,6 +334,7 @@ private:
|
|||||||
Mode fMode;
|
Mode fMode;
|
||||||
State fState;
|
State fState;
|
||||||
SkSTArray<16, Scope, true> fScopeStack;
|
SkSTArray<16, Scope, true> fScopeStack;
|
||||||
|
SkSTArray<16, bool, true> fNewlineStack;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user