Add batch information to json
BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1705093002 Review URL: https://codereview.chromium.org/1705093002
This commit is contained in:
parent
91e457d17f
commit
6b3cf73af5
@ -674,6 +674,12 @@
|
||||
},
|
||||
}],
|
||||
|
||||
[ 'skia_build_server', {
|
||||
'defines': [
|
||||
'GR_BATCH_DEBUGGING_OUTPUT=1',
|
||||
],
|
||||
}],
|
||||
|
||||
], # end 'conditions'
|
||||
# The Xcode SYMROOT must be at the root. See build/common.gypi in chromium for more details
|
||||
'xcode_settings': {
|
||||
|
@ -67,7 +67,7 @@ public:
|
||||
batch->fBounds = bounds;
|
||||
}
|
||||
|
||||
SkString toJson() const;
|
||||
SkString toJson(bool prettyPrint = false) const;
|
||||
|
||||
void reset() { SkASSERT(GR_BATCH_DEBUGGING_OUTPUT && fStack.empty()); fFrames.reset(); }
|
||||
|
||||
|
@ -87,14 +87,17 @@ static SkString pretty_print_json(SkString json) {
|
||||
return prettyPrintJson.prettify(json);
|
||||
}
|
||||
|
||||
SkString GrAuditTrail::toJson() const {
|
||||
SkString GrAuditTrail::toJson(bool prettyPrint) const {
|
||||
SkString json;
|
||||
json.append("{");
|
||||
JsonifyTArray(&json, "Stacks", fFrames);
|
||||
json.append("}");
|
||||
|
||||
// TODO if this becomes a performance issue we should make pretty print configurable
|
||||
return pretty_print_json(json);
|
||||
if (prettyPrint) {
|
||||
return pretty_print_json(json);
|
||||
} else {
|
||||
return json;
|
||||
}
|
||||
}
|
||||
|
||||
SkString GrAuditTrail::Frame::toJson() const {
|
||||
|
@ -331,12 +331,12 @@ SkTDArray <SkDrawCommand*>& SkDebugCanvas::getDrawCommands() {
|
||||
return fCommandVector;
|
||||
}
|
||||
|
||||
Json::Value SkDebugCanvas::toJSON(UrlDataManager& urlDataManager, int n) {
|
||||
Json::Value SkDebugCanvas::toJSON(UrlDataManager& urlDataManager, int n, SkCanvas* canvas) {
|
||||
Json::Value result = Json::Value(Json::objectValue);
|
||||
result[SKDEBUGCANVAS_ATTRIBUTE_VERSION] = Json::Value(SKDEBUGCANVAS_VERSION);
|
||||
Json::Value commands = Json::Value(Json::arrayValue);
|
||||
for (int i = 0; i < this->getSize() && i <= n; i++) {
|
||||
commands[i] = this->getDrawCommandAt(i)->toJSON(urlDataManager);
|
||||
commands[i] = this->getDrawCommandAt(i)->drawToAndCollectJSON(canvas, urlDataManager);
|
||||
}
|
||||
result[SKDEBUGCANVAS_ATTRIBUTE_COMMANDS] = commands;
|
||||
return result;
|
||||
|
@ -151,7 +151,7 @@ public:
|
||||
SkDebugCanvas::getSize(). The encoder may use the UrlDataManager to store binary data such
|
||||
as images, referring to them via URLs embedded in the JSON.
|
||||
*/
|
||||
Json::Value toJSON(UrlDataManager& urlDataManager, int n);
|
||||
Json::Value toJSON(UrlDataManager& urlDataManager, int n, SkCanvas*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Inherited from SkCanvas
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
|
||||
#include "SkDrawCommand.h"
|
||||
|
||||
#include "SkBlurMaskFilter.h"
|
||||
#include "SkColorFilter.h"
|
||||
#include "SkDashPathEffect.h"
|
||||
@ -24,7 +25,13 @@
|
||||
#include "SkValidatingReadBuffer.h"
|
||||
#include "SkWriteBuffer.h"
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "GrContext.h"
|
||||
#include "GrRenderTarget.h"
|
||||
#endif
|
||||
|
||||
#define SKDEBUGCANVAS_ATTRIBUTE_COMMAND "command"
|
||||
#define SKDEBUGCANVAS_ATTRIBUTE_AUDITTRAIL "auditTrail"
|
||||
#define SKDEBUGCANVAS_ATTRIBUTE_MATRIX "matrix"
|
||||
#define SKDEBUGCANVAS_ATTRIBUTE_COORDS "coords"
|
||||
#define SKDEBUGCANVAS_ATTRIBUTE_BOUNDS "bounds"
|
||||
@ -218,6 +225,37 @@ Json::Value SkDrawCommand::toJSON(UrlDataManager& urlDataManager) const {
|
||||
return result;
|
||||
}
|
||||
|
||||
Json::Value SkDrawCommand::drawToAndCollectJSON(SkCanvas* canvas,
|
||||
UrlDataManager& urlDataManager) const {
|
||||
Json::Value result;
|
||||
result[SKDEBUGCANVAS_ATTRIBUTE_COMMAND] = this->GetCommandString(fOpType);
|
||||
|
||||
SkASSERT(canvas);
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget();
|
||||
if (rt) {
|
||||
GrContext* ctx = rt->getContext();
|
||||
if(ctx) {
|
||||
this->execute(canvas);
|
||||
GrAuditTrail* at = ctx->getAuditTrail();
|
||||
|
||||
// TODO if this is inefficient we could add a method to GrAuditTrail which takes
|
||||
// a Json::Value and is only compiled in this file
|
||||
Json::Value parsedFromString;
|
||||
Json::Reader reader;
|
||||
SkDEBUGCODE(bool parsingSuccessful = )reader.parse(at->toJson().c_str(),
|
||||
parsedFromString);
|
||||
SkASSERT(parsingSuccessful);
|
||||
|
||||
result[SKDEBUGCANVAS_ATTRIBUTE_AUDITTRAIL] = parsedFromString;
|
||||
at->reset();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
#define INSTALL_FACTORY(name) factories.set(SkString(GetCommandString(k ## name ##_OpType)), \
|
||||
(FROM_JSON) Sk ## name ## Command::fromJSON)
|
||||
SkDrawCommand* SkDrawCommand::fromJSON(Json::Value& command, UrlDataManager& urlDataManager) {
|
||||
|
@ -102,6 +102,8 @@ public:
|
||||
|
||||
virtual Json::Value toJSON(UrlDataManager& urlDataManager) const;
|
||||
|
||||
Json::Value drawToAndCollectJSON(SkCanvas*, UrlDataManager& urlDataManager) const;
|
||||
|
||||
/* Converts a JSON representation of a command into a newly-allocated SkDrawCommand object. It
|
||||
* is the caller's responsibility to delete this object. This method may return null if an error
|
||||
* occurs.
|
||||
|
@ -136,13 +136,18 @@ SkData* writeCanvasToPng(SkCanvas* canvas) {
|
||||
return buffer.copyToData();
|
||||
}
|
||||
|
||||
SkData* setupAndDrawToCanvasReturnPng(Request* request, int n) {
|
||||
SkCanvas* getCanvasFromRequest(Request* request) {
|
||||
GrContextFactory* factory = request->fContextFactory;
|
||||
SkGLContext* gl = factory->getContextInfo(GrContextFactory::kNative_GLContextType,
|
||||
GrContextFactory::kNone_GLContextOptions).fGLContext;
|
||||
gl->makeCurrent();
|
||||
SkASSERT(request->fDebugCanvas);
|
||||
SkCanvas* target = request->fSurface->getCanvas();
|
||||
return target;
|
||||
}
|
||||
|
||||
SkData* setupAndDrawToCanvasReturnPng(Request* request, int n) {
|
||||
SkCanvas* target = getCanvasFromRequest(request);
|
||||
request->fDebugCanvas->drawTo(target, n);
|
||||
return writeCanvasToPng(target);
|
||||
}
|
||||
@ -195,9 +200,9 @@ static int SendData(MHD_Connection* connection, const SkData* data, const char*
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int SendJSON(MHD_Connection* connection, SkDebugCanvas* debugCanvas,
|
||||
static int SendJSON(MHD_Connection* connection, SkCanvas* canvas, SkDebugCanvas* debugCanvas,
|
||||
UrlDataManager* urlDataManager, int n) {
|
||||
Json::Value root = debugCanvas->toJSON(*urlDataManager, n);
|
||||
Json::Value root = debugCanvas->toJSON(*urlDataManager, n, canvas);
|
||||
SkDynamicMemoryWStream stream;
|
||||
stream.writeText(Json::FastWriter().write(root).c_str());
|
||||
|
||||
@ -261,7 +266,8 @@ public:
|
||||
} else {
|
||||
sscanf(commands[1].c_str(), "%d", &n);
|
||||
}
|
||||
return SendJSON(connection, request->fDebugCanvas, &request->fUrlDataManager, n);
|
||||
return SendJSON(connection, getCanvasFromRequest(request), request->fDebugCanvas,
|
||||
&request->fUrlDataManager, n);
|
||||
}
|
||||
|
||||
// /cmd/N, for now only delete supported
|
||||
|
Loading…
Reference in New Issue
Block a user