Remove an uncessary and unused parameter for partially generating the JSON command list
All caller were passing the maxium value, those that weren't still function if they are made to. Change-Id: Id9b5d8dbbbdf10a02ea0f3b21d500059ec383e3a Reviewed-on: https://skia-review.googlesource.com/c/skia/+/259808 Commit-Queue: Nathaniel Nifong <nifong@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
This commit is contained in:
parent
1cc767bd0d
commit
a072b7b275
@ -1684,7 +1684,7 @@ Error DebugSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) cons
|
||||
UrlDataManager dataManager(SkString("data"));
|
||||
SkJSONWriter writer(dst, SkJSONWriter::Mode::kPretty);
|
||||
writer.beginObject(); // root
|
||||
debugCanvas.toJSON(writer, dataManager, debugCanvas.getSize(), nullCanvas.get());
|
||||
debugCanvas.toJSON(writer, dataManager, nullCanvas.get());
|
||||
writer.endObject(); // root
|
||||
writer.flush();
|
||||
return "";
|
||||
|
@ -156,7 +156,7 @@ class SkpDebugPlayer {
|
||||
SkDynamicMemoryWStream stream;
|
||||
SkJSONWriter writer(&stream, SkJSONWriter::Mode::kFast);
|
||||
writer.beginObject(); // root
|
||||
frames[fp]->toJSON(writer, udm, getSize(), surface->getCanvas());
|
||||
frames[fp]->toJSON(writer, udm, surface->getCanvas());
|
||||
writer.endObject(); // root
|
||||
writer.flush();
|
||||
auto skdata = stream.detachAsData();
|
||||
|
@ -1705,7 +1705,7 @@ DEF_FUZZ(_DumpCanvas, fuzz) {
|
||||
SkDynamicMemoryWStream stream;
|
||||
SkJSONWriter writer(&stream, SkJSONWriter::Mode::kPretty);
|
||||
writer.beginObject(); // root
|
||||
debugCanvas.toJSON(writer, dataManager, debugCanvas.getSize(), nullCanvas.get());
|
||||
debugCanvas.toJSON(writer, dataManager, nullCanvas.get());
|
||||
writer.endObject(); // root
|
||||
writer.flush();
|
||||
sk_sp<SkData> json = stream.detachAsData();
|
||||
|
@ -229,12 +229,12 @@ GrAuditTrail* DebugCanvas::getAuditTrail(SkCanvas* canvas) {
|
||||
return at;
|
||||
}
|
||||
|
||||
void DebugCanvas::drawAndCollectOps(int n, SkCanvas* canvas) {
|
||||
void DebugCanvas::drawAndCollectOps(SkCanvas* canvas) {
|
||||
GrAuditTrail* at = this->getAuditTrail(canvas);
|
||||
if (at) {
|
||||
// loop over all of the commands and draw them, this is to collect reordering
|
||||
// information
|
||||
for (int i = 0; i < this->getSize() && i <= n; i++) {
|
||||
for (int i = 0; i < this->getSize(); i++) {
|
||||
GrAuditTrail::AutoCollectOps enable(at, i);
|
||||
fCommandVector[i]->execute(canvas);
|
||||
}
|
||||
@ -257,16 +257,15 @@ void DebugCanvas::cleanupAuditTrail(SkCanvas* canvas) {
|
||||
|
||||
void DebugCanvas::toJSON(SkJSONWriter& writer,
|
||||
UrlDataManager& urlDataManager,
|
||||
int n,
|
||||
SkCanvas* canvas) {
|
||||
this->drawAndCollectOps(n, canvas);
|
||||
this->drawAndCollectOps(canvas);
|
||||
|
||||
// now collect json
|
||||
GrAuditTrail* at = this->getAuditTrail(canvas);
|
||||
writer.appendS32(SKDEBUGCANVAS_ATTRIBUTE_VERSION, SKDEBUGCANVAS_VERSION);
|
||||
writer.beginArray(SKDEBUGCANVAS_ATTRIBUTE_COMMANDS);
|
||||
|
||||
for (int i = 0; i < this->getSize() && i <= n; i++) {
|
||||
for (int i = 0; i < this->getSize(); i++) {
|
||||
writer.beginObject(); // command
|
||||
this->getDrawCommandAt(i)->toJSON(writer, urlDataManager);
|
||||
|
||||
@ -281,8 +280,8 @@ void DebugCanvas::toJSON(SkJSONWriter& writer,
|
||||
this->cleanupAuditTrail(canvas);
|
||||
}
|
||||
|
||||
void DebugCanvas::toJSONOpsTask(SkJSONWriter& writer, int n, SkCanvas* canvas) {
|
||||
this->drawAndCollectOps(n, canvas);
|
||||
void DebugCanvas::toJSONOpsTask(SkJSONWriter& writer, SkCanvas* canvas) {
|
||||
this->drawAndCollectOps(canvas);
|
||||
|
||||
GrAuditTrail* at = this->getAuditTrail(canvas);
|
||||
if (at) {
|
||||
|
@ -113,13 +113,13 @@ public:
|
||||
void toggleCommand(int index, bool toggle);
|
||||
|
||||
/**
|
||||
Returns a JSON object representing up to the Nth draw, where N is less than
|
||||
DebugCanvas::getSize(). The encoder may use the UrlDataManager to store binary data such
|
||||
Returns a JSON object representing all commands in the picture.
|
||||
The encoder may use the UrlDataManager to store binary data such
|
||||
as images, referring to them via URLs embedded in the JSON.
|
||||
*/
|
||||
void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager, int n, SkCanvas*);
|
||||
void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager, SkCanvas*);
|
||||
|
||||
void toJSONOpsTask(SkJSONWriter& writer, int n, SkCanvas*);
|
||||
void toJSONOpsTask(SkJSONWriter& writer, SkCanvas*);
|
||||
|
||||
void detachCommands(SkTDArray<DrawCommand*>* dst) { fCommandVector.swap(*dst); }
|
||||
|
||||
@ -245,7 +245,7 @@ private:
|
||||
|
||||
GrAuditTrail* getAuditTrail(SkCanvas*);
|
||||
|
||||
void drawAndCollectOps(int n, SkCanvas*);
|
||||
void drawAndCollectOps(SkCanvas*);
|
||||
void cleanupAuditTrail(SkCanvas*);
|
||||
|
||||
typedef SkCanvasVirtualEnforcer<SkCanvas> INHERITED;
|
||||
|
@ -215,7 +215,7 @@ bool Request::initPictureFromStream(SkStream* stream) {
|
||||
return true;
|
||||
}
|
||||
|
||||
sk_sp<SkData> Request::getJsonOps(int n) {
|
||||
sk_sp<SkData> Request::getJsonOps() {
|
||||
SkCanvas* canvas = this->getCanvas();
|
||||
SkDynamicMemoryWStream stream;
|
||||
SkJSONWriter writer(&stream, SkJSONWriter::Mode::kFast);
|
||||
@ -224,20 +224,20 @@ sk_sp<SkData> Request::getJsonOps(int n) {
|
||||
writer.appendString("mode", fGPUEnabled ? "gpu" : "cpu");
|
||||
writer.appendBool("drawGpuOpBounds", fDebugCanvas->getDrawGpuOpBounds());
|
||||
writer.appendS32("colorMode", fColorMode);
|
||||
fDebugCanvas->toJSON(writer, fUrlDataManager, n, canvas);
|
||||
fDebugCanvas->toJSON(writer, fUrlDataManager, canvas);
|
||||
|
||||
writer.endObject(); // root
|
||||
writer.flush();
|
||||
return stream.detachAsData();
|
||||
}
|
||||
|
||||
sk_sp<SkData> Request::getJsonOpsTask(int n) {
|
||||
sk_sp<SkData> Request::getJsonOpsTask() {
|
||||
SkCanvas* canvas = this->getCanvas();
|
||||
SkASSERT(fGPUEnabled);
|
||||
SkDynamicMemoryWStream stream;
|
||||
SkJSONWriter writer(&stream, SkJSONWriter::Mode::kFast);
|
||||
|
||||
fDebugCanvas->toJSONOpsTask(writer, n, canvas);
|
||||
fDebugCanvas->toJSONOpsTask(writer, canvas);
|
||||
|
||||
writer.flush();
|
||||
return stream.detachAsData();
|
||||
|
@ -48,12 +48,12 @@ struct Request {
|
||||
bool initPictureFromStream(SkStream*);
|
||||
|
||||
// Returns the json list of ops as an SkData
|
||||
sk_sp<SkData> getJsonOps(int n);
|
||||
sk_sp<SkData> getJsonOps();
|
||||
|
||||
// Returns a json list of ops as an SkData
|
||||
sk_sp<SkData> getJsonOpsTask(int n);
|
||||
sk_sp<SkData> getJsonOpsTask();
|
||||
|
||||
// Returns json with the viewMatrix and clipRect
|
||||
// Returns json with the viewMatrix and clipRect at the given command
|
||||
sk_sp<SkData> getJsonInfo(int n);
|
||||
|
||||
// returns the color of the pixel at (x,y) in the canvas
|
||||
|
@ -28,16 +28,9 @@ int CmdHandler::handle(Request* request, MHD_Connection* connection,
|
||||
return MHD_NO;
|
||||
}
|
||||
|
||||
// /cmd or /cmd/N
|
||||
// /cmd
|
||||
if (0 == strcmp(method, MHD_HTTP_METHOD_GET)) {
|
||||
int n;
|
||||
if (commands.count() == 1) {
|
||||
n = request->getLastOp();
|
||||
} else {
|
||||
sscanf(commands[1].c_str(), "%d", &n);
|
||||
}
|
||||
|
||||
sk_sp<SkData> data(request->getJsonOps(n));
|
||||
sk_sp<SkData> data(request->getJsonOps());
|
||||
return SendData(connection, data.get(), "application/json");
|
||||
}
|
||||
|
||||
|
@ -29,9 +29,7 @@ int OpsHandler::handle(Request* request, MHD_Connection* connection, const char*
|
||||
|
||||
// /ops
|
||||
if (0 == strcmp(method, MHD_HTTP_METHOD_GET)) {
|
||||
int n = request->getLastOp();
|
||||
|
||||
sk_sp<SkData> data(request->getJsonOpsTask(n));
|
||||
sk_sp<SkData> data(request->getJsonOpsTask());
|
||||
return SendData(connection, data.get(), "application/json");
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ int main(int argc, char** argv) {
|
||||
SkDynamicMemoryWStream stream;
|
||||
SkJSONWriter writer(&stream, SkJSONWriter::Mode::kPretty);
|
||||
writer.beginObject(); // root
|
||||
debugCanvas.toJSON(writer, dataManager, debugCanvas.getSize(), nullCanvas.get());
|
||||
debugCanvas.toJSON(writer, dataManager, nullCanvas.get());
|
||||
writer.endObject(); // root
|
||||
writer.flush();
|
||||
if (argc > 2) {
|
||||
|
Loading…
Reference in New Issue
Block a user