diff options
author | 2009-11-23 21:46:47 +0000 | |
---|---|---|
committer | 2009-11-23 21:46:47 +0000 | |
commit | 55e76b209c9249308a9ba3d75c2472dd55e9d298 (patch) | |
tree | cfbb9987d1a1a37ddf355a5d3d750eb4567cf94d /samplecode/SampleApp.cpp | |
parent | 4417740a480786ca65379ba5b398c500ba34ee18 (diff) |
outset the bounds if we're in hairline before quick-reject in SkDraw.cpp
git-svn-id: http://skia.googlecode.com/svn/trunk@445 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'samplecode/SampleApp.cpp')
-rw-r--r-- | samplecode/SampleApp.cpp | 47 |
1 files changed, 42 insertions, 5 deletions
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp index 8fcdfa8715..84ce0d2d05 100644 --- a/samplecode/SampleApp.cpp +++ b/samplecode/SampleApp.cpp @@ -254,6 +254,31 @@ SampleWindow::~SampleWindow() { delete fGLCanvas; } +static SkBitmap capture_bitmap(SkCanvas* canvas) { + SkBitmap bm; + const SkBitmap& src = canvas->getDevice()->accessBitmap(false); + src.copyTo(&bm, src.config()); + return bm; +} + +static bool bitmap_diff(SkCanvas* canvas, const SkBitmap& orig, + SkBitmap* diff) { + const SkBitmap& src = canvas->getDevice()->accessBitmap(false); + + SkAutoLockPixels alp0(src); + SkAutoLockPixels alp1(orig); + for (int y = 0; y < src.height(); y++) { + const void* srcP = src.getAddr(0, y); + const void* origP = orig.getAddr(0, y); + size_t bytes = src.width() * src.bytesPerPixel(); + if (memcmp(srcP, origP, bytes)) { + SkDebugf("---------- difference on line %d\n", y); + return true; + } + } + return false; +} + #define XCLIP_N 8 #define YCLIP_N 8 @@ -262,23 +287,35 @@ void SampleWindow::draw(SkCanvas* canvas) { gAnimTime = SkTime::GetMSecs(); if (fNClip) { - // this->INHERITED::draw(canvas); - // SkBitmap orig = capture_bitmap(canvas); + this->INHERITED::draw(canvas); + SkBitmap orig = capture_bitmap(canvas); const SkScalar w = this->width(); const SkScalar h = this->height(); const SkScalar cw = w / XCLIP_N; const SkScalar ch = h / YCLIP_N; for (int y = 0; y < YCLIP_N; y++) { + SkRect r; + r.fTop = y * ch; + r.fBottom = (y + 1) * ch; + if (y == YCLIP_N - 1) { + r.fBottom = h; + } for (int x = 0; x < XCLIP_N; x++) { SkAutoCanvasRestore acr(canvas, true); - SkRect r = { - x * cw, y * ch, (x + 1) * cw, (y + 1) * ch - }; + r.fLeft = x * cw; + r.fRight = (x + 1) * cw; + if (x == XCLIP_N - 1) { + r.fRight = w; + } canvas->clipRect(r); this->INHERITED::draw(canvas); } } + + SkBitmap diff; + if (bitmap_diff(canvas, orig, &diff)) { + } } else { this->INHERITED::draw(canvas); } |