2016-01-08 15:19:47 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GrAuditTrail_DEFINED
|
|
|
|
#define GrAuditTrail_DEFINED
|
|
|
|
|
2016-01-11 18:39:11 +00:00
|
|
|
#include "GrConfig.h"
|
2016-01-12 14:45:24 +00:00
|
|
|
#include "SkRect.h"
|
2016-01-08 15:19:47 +00:00
|
|
|
#include "SkString.h"
|
|
|
|
#include "SkTArray.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* GrAuditTrail collects a list of draw ops, detailed information about those ops, and can dump them
|
|
|
|
* to json.
|
|
|
|
*/
|
|
|
|
class GrAuditTrail {
|
|
|
|
public:
|
2016-01-12 14:45:24 +00:00
|
|
|
void addOp(const SkString& name) {
|
2016-01-11 18:39:11 +00:00
|
|
|
SkASSERT(GR_BATCH_DEBUGGING_OUTPUT);
|
2016-01-08 15:19:47 +00:00
|
|
|
fOps.push_back().fName = name;
|
|
|
|
}
|
|
|
|
|
2016-01-12 14:45:24 +00:00
|
|
|
void addBatch(const SkString& name, const SkRect& bounds) {
|
|
|
|
SkASSERT(GR_BATCH_DEBUGGING_OUTPUT);
|
|
|
|
Op::Batch& batch = fOps.back().fBatches.push_back();
|
|
|
|
batch.fName = name;
|
|
|
|
batch.fBounds = bounds;
|
|
|
|
}
|
|
|
|
|
2016-01-08 15:19:47 +00:00
|
|
|
SkString toJson() const;
|
|
|
|
|
2016-01-11 18:39:11 +00:00
|
|
|
void reset() { SkASSERT(GR_BATCH_DEBUGGING_OUTPUT); fOps.reset(); }
|
2016-01-08 15:19:47 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
struct Op {
|
|
|
|
SkString toJson() const;
|
2016-01-12 14:45:24 +00:00
|
|
|
struct Batch {
|
|
|
|
SkString toJson() const;
|
|
|
|
SkString fName;
|
|
|
|
SkRect fBounds;
|
|
|
|
};
|
|
|
|
|
2016-01-08 15:19:47 +00:00
|
|
|
SkString fName;
|
2016-01-12 14:45:24 +00:00
|
|
|
SkTArray<Batch> fBatches;
|
2016-01-08 15:19:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
SkTArray<Op> fOps;
|
|
|
|
};
|
|
|
|
|
2016-01-11 18:39:11 +00:00
|
|
|
#define GR_AUDIT_TRAIL_INVOKE_GUARD(invoke, ...) \
|
|
|
|
if (GR_BATCH_DEBUGGING_OUTPUT) { \
|
|
|
|
invoke(__VA_ARGS__); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GR_AUDIT_TRAIL_ADDOP(audit_trail, opname) \
|
|
|
|
GR_AUDIT_TRAIL_INVOKE_GUARD(audit_trail->addOp, opname);
|
|
|
|
|
|
|
|
#define GR_AUDIT_TRAIL_RESET(audit_trail) \
|
|
|
|
GR_AUDIT_TRAIL_INVOKE_GUARD(audit_trail->reset);
|
|
|
|
|
2016-01-12 14:45:24 +00:00
|
|
|
#define GR_AUDIT_TRAIL_ADDBATCH(audit_trail, batchname, bounds) \
|
|
|
|
GR_AUDIT_TRAIL_INVOKE_GUARD(audit_trail->addBatch, SkString(batchname), bounds);
|
|
|
|
|
2016-01-08 15:19:47 +00:00
|
|
|
#endif
|