Add return value on GrRecordReplaceDraw

This assists debugging layer hoisting errors (e.g., when a layer is hoisted but not actually used in subsequent rendering).

Review URL: https://codereview.chromium.org/694533004
This commit is contained in:
robertphillips 2014-10-30 11:54:31 -07:00 committed by Commit bot
parent 189fc98e08
commit 0882fdcc15
2 changed files with 27 additions and 18 deletions

View File

@ -66,16 +66,19 @@ public:
, fReplacements(replacements)
, fInitialMatrix(initialMatrix)
, fCallback(callback)
, fIndex(0) {
, fIndex(0)
, fNumReplaced(0) {
}
void draw() {
int draw() {
const SkBBoxHierarchy* bbh = fPicture->fBBH.get();
const SkRecord* record = fPicture->fRecord.get();
if (NULL == record) {
return;
return 0;
}
fNumReplaced = 0;
fOps.rewind();
if (bbh) {
@ -91,7 +94,7 @@ public:
for (fIndex = 0; fIndex < fOps.count(); ++fIndex) {
if (fCallback && fCallback->abortDrawing()) {
return;
return fNumReplaced;
}
record->visit<void>(fOps[fIndex], *this);
@ -100,12 +103,14 @@ public:
} else {
for (fIndex = 0; fIndex < (int) record->count(); ++fIndex) {
if (fCallback && fCallback->abortDrawing()) {
return;
return fNumReplaced;
}
record->visit<void>(fIndex, *this);
}
}
return fNumReplaced;
}
// Same as Draw for all ops except DrawPicture and SaveLayer.
@ -118,7 +123,7 @@ public:
// Draw sub-pictures with the same replacement list but a different picture
ReplaceDraw draw(fCanvas, dp.picture, fReplacements, fInitialMatrix, fCallback);
draw.draw();
fNumReplaced += draw.draw();
}
void operator()(const SkRecords::SaveLayer& sl) {
@ -131,12 +136,14 @@ public:
startOffset = fIndex;
}
const SkMatrix& ctm = fCanvas->getTotalMatrix();
const GrReplacements::ReplacementInfo* ri = fReplacements->lookupByStart(
fPicture->uniqueID(),
startOffset,
fCanvas->getTotalMatrix());
ctm);
if (ri) {
fNumReplaced++;
draw_replacement_bitmap(ri, fCanvas, fInitialMatrix);
if (fPicture->fBBH.get()) {
@ -163,18 +170,19 @@ private:
SkTDArray<unsigned> fOps;
int fIndex;
int fNumReplaced;
typedef Draw INHERITED;
};
void GrRecordReplaceDraw(const SkPicture* picture,
SkCanvas* canvas,
const GrReplacements* replacements,
const SkMatrix& initialMatrix,
SkDrawPictureCallback* callback) {
int GrRecordReplaceDraw(const SkPicture* picture,
SkCanvas* canvas,
const GrReplacements* replacements,
const SkMatrix& initialMatrix,
SkDrawPictureCallback* callback) {
SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/);
ReplaceDraw draw(canvas, picture, replacements, initialMatrix, callback);
draw.draw();
return draw.draw();
}

View File

@ -101,10 +101,11 @@ private:
// Draw an SkPicture into an SkCanvas replacing saveLayer/restore blocks with
// drawBitmap calls. A convenience wrapper around SkRecords::Draw.
void GrRecordReplaceDraw(const SkPicture*,
SkCanvas*,
const GrReplacements*,
const SkMatrix& initialMatrix,
SkDrawPictureCallback*);
// It returns the number of saveLayer/restore blocks replaced with drawBitmap calls.
int GrRecordReplaceDraw(const SkPicture*,
SkCanvas*,
const GrReplacements*,
const SkMatrix& initialMatrix,
SkDrawPictureCallback*);
#endif // GrRecordReplaceDraw_DEFINED