add a simple ascii-art debug thing for AA clips

BUG=skia:
R=reed@google.com

Author: humper@google.com

Review URL: https://codereview.chromium.org/450423002
This commit is contained in:
humper 2014-08-08 11:45:46 -07:00 committed by Commit bot
parent a50b8f0ec0
commit 6d42d9c7ff
2 changed files with 42 additions and 0 deletions

View File

@ -219,6 +219,46 @@ void SkAAClip::validate() const {
--yoff;
SkASSERT(yoff->fY == lastY);
}
static void dump_one_row(const uint8_t* SK_RESTRICT row,
int width, int leading_num) {
if (leading_num) {
SkDebugf( "%03d ", leading_num );
}
while (width > 0) {
int n = row[0];
int val = row[1];
char out = '.';
if (val == 0xff) {
out = '*';
} else if (val > 0) {
out = '+';
}
for (int i = 0 ; i < n ; i++) {
SkDebugf( "%c", out );
}
row += 2;
width -= n;
}
SkDebugf( "\n" );
}
void SkAAClip::debug(bool compress_y) const {
Iter iter(*this);
const int width = fBounds.width();
int y = fBounds.fTop;
while (!iter.done()) {
if (compress_y) {
dump_one_row(iter.data(), width, iter.bottom() - iter.top() + 1);
} else {
do {
dump_one_row(iter.data(), width, 0);
} while (++y < iter.bottom());
}
iter.next();
}
}
#endif
///////////////////////////////////////////////////////////////////////////////

View File

@ -75,8 +75,10 @@ public:
#ifdef SK_DEBUG
void validate() const;
void debug(bool compress_y=false) const;
#else
void validate() const {}
void debug(bool compress_y=false) const {}
#endif
private: