SkDebugCanvas ignore batch bounds if they are offscreen

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

Review URL: https://codereview.chromium.org/1754633002
This commit is contained in:
joshualitt 2016-03-01 07:15:52 -08:00 committed by Commit bot
parent fd5a26080d
commit 1d7decffbc
3 changed files with 16 additions and 0 deletions

View File

@ -129,6 +129,7 @@ public:
// a performance issue, but until then its nice to decouple
struct BatchInfo {
SkRect fBounds;
uint32_t fRenderTargetUniqueID;
struct Batch {
int fClientID;
SkRect fBounds;
@ -168,6 +169,7 @@ private:
SkString toJson() const;
SkRect fBounds;
Batches fChildren;
uint32_t fRenderTargetUniqueID;
};
typedef SkTArray<SkAutoTDelete<BatchNode>, true> BatchList;

View File

@ -36,6 +36,7 @@ void GrAuditTrail::batchingResultNew(GrBatch* batch) {
fIDLookup.set(batch, fCurrentBatch->fBatchListID);
BatchNode* batchNode = new BatchNode;
batchNode->fBounds = fCurrentBatch->fBounds;
batchNode->fRenderTargetUniqueID = batch->renderTargetUniqueID();
batchNode->fChildren.push_back(fCurrentBatch);
fBatchList.emplace_back(batchNode);
}
@ -62,6 +63,7 @@ void GrAuditTrail::getBoundsByClientID(SkTArray<BatchInfo>* outInfo, int clientI
// they have a different clientID
const BatchNode* bn = fBatchList[currentBatchListID];
outBatchInfo.fBounds = bn->fBounds;
outBatchInfo.fRenderTargetUniqueID = bn->fRenderTargetUniqueID;
for (int j = 0; j < bn->fChildren.count(); j++) {
BatchInfo::Batch& outBatch = outBatchInfo.fBatches.push_back();
const Batch* currentBatch = bn->fChildren[j];
@ -212,6 +214,7 @@ SkString GrAuditTrail::Batch::toJson() const {
SkString GrAuditTrail::BatchNode::toJson() const {
SkString json;
json.append("{");
json.appendf("\"RenderTarget\": \"%u\",", fRenderTargetUniqueID);
skrect_to_json(&json, "Bounds", fBounds);
JsonifyTArray(&json, "Batches", fChildren, true);
json.append("}");

View File

@ -17,6 +17,7 @@
#include "GrAuditTrail.h"
#include "GrContext.h"
#include "GrRenderTarget.h"
#include "SkGpuDevice.h"
#endif
#define SKDEBUGCANVAS_VERSION 1
@ -330,6 +331,12 @@ void SkDebugCanvas::drawTo(SkCanvas* canvas, int index) {
#if SK_SUPPORT_GPU
// draw any batches if required and issue a full reset onto GrAuditTrail
if (at) {
// get the render target of the top device so we can ignore batches drawn offscreen
SkBaseDevice* bd = canvas->getDevice_just_for_deprecated_compatibility_testing();
SkGpuDevice* gbd = reinterpret_cast<SkGpuDevice*>(bd);
uint32_t rtID = gbd->accessRenderTarget()->getUniqueID();
// get the bounding boxes to draw
GrAuditTrail::AutoEnable ae(at);
SkTArray<GrAuditTrail::BatchInfo> childrenBounds;
at->getBoundsByClientID(&childrenBounds, index);
@ -337,6 +344,10 @@ void SkDebugCanvas::drawTo(SkCanvas* canvas, int index) {
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(1);
for (int i = 0; i < childrenBounds.count(); i++) {
if (childrenBounds[i].fRenderTargetUniqueID != rtID) {
// offscreen draw, ignore for now
continue;
}
paint.setColor(SK_ColorBLACK);
canvas->drawRect(childrenBounds[i].fBounds, paint);
for (int j = 0; j < childrenBounds[i].fBatches.count(); j++) {