From: reed@android.com Date: Mon, 23 Nov 2009 21:46:47 +0000 (+0000) Subject: outset the bounds if we're in hairline before quick-reject in SkDraw.cpp X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~19312 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=55e76b209c9249308a9ba3d75c2472dd55e9d298;p=platform%2Fupstream%2FlibSkiaSharp.git 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 --- diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp index 8fcdfa8..84ce0d2 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); } diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp index 7f0cc15..4f28cfe 100644 --- a/src/core/SkDraw.cpp +++ b/src/core/SkDraw.cpp @@ -694,6 +694,10 @@ void SkDraw::drawRect(const SkRect& rect, const SkPaint& paint) const { { SkIRect ir; devRect.roundOut(&ir); + if (paint.getStyle() != SkPaint::kFill_Style) { + // extra space for hairlines + ir.inset(-1, -1); + } if (fClip->quickReject(ir)) return; }