Chromium Code Reviews| Index: tools/debugger/SkDrawCommand.cpp |
| diff --git a/tools/debugger/SkDrawCommand.cpp b/tools/debugger/SkDrawCommand.cpp |
| index f23c41a0e90d2bbccf3c7600049e00ad19565306..2102e3c4494f8ed718742c245b65ae4ca12a29be 100644 |
| --- a/tools/debugger/SkDrawCommand.cpp |
| +++ b/tools/debugger/SkDrawCommand.cpp |
| @@ -8,6 +8,10 @@ |
| #include "SkDrawCommand.h" |
| + |
| +#include "GrContext.h" |
| +#include "GrRenderTarget.h" |
| + |
| #include "SkBlurMaskFilter.h" |
| #include "SkColorFilter.h" |
| #include "SkDashPathEffect.h" |
| @@ -218,6 +222,35 @@ 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); |
| + |
| + if (canvas) { |
|
ethannicholas
2016/02/17 16:16:07
Why is the canvas to draw to optional in a method
joshualitt
2016/02/17 16:31:02
Acknowledged.
|
| + 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["batches"] = parsedFromString; |
|
ethannicholas
2016/02/17 16:16:07
Could we define a SKDEBUGCANVAS_ATTRIBUTE_BATCHES
joshualitt
2016/02/17 16:31:02
Acknowledged.
|
| + at->reset(); |
|
ethannicholas
2016/02/17 16:16:07
Resetting the auditor in between every single draw
joshualitt
2016/02/17 16:31:02
discussed offline
|
| + } |
| + } |
| + } |
| + 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) { |