From 546e1baf07e19b1a2cbc746e1b08e6e6e317862f Mon Sep 17 00:00:00 2001 From: Mike Reed Date: Fri, 25 Sep 2009 12:02:27 -0400 Subject: disable antialiasing for bitmaps Since we are never rotated, and when we are zoomed, the antialiasing can double-draw the shared border for images that are meant to seam (ala nine-patch) http://b/issue?id=2105990&cookieId=2009268085657820 --- WebCore/platform/graphics/android/ImageAndroid.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/WebCore/platform/graphics/android/ImageAndroid.cpp b/WebCore/platform/graphics/android/ImageAndroid.cpp index 93aacbc..16a450f 100644 --- a/WebCore/platform/graphics/android/ImageAndroid.cpp +++ b/WebCore/platform/graphics/android/ImageAndroid.cpp @@ -172,6 +172,19 @@ static void round_scaled(SkIRect* dst, const WebCore::FloatRect& src, SkScalarRound(SkFloatToScalar((src.y() + src.height()) * sy))); } +static inline void fixPaintForBitmapsThatMaySeam(SkPaint* paint) { + /* Bitmaps may be drawn to seem next to other images. If we are drawn + zoomed, or at fractional coordinates, we may see cracks/edges if + we antialias, because that will cause us to draw the same pixels + more than once (e.g. from the left and right bitmaps that share + an edge). + + Disabling antialiasing fixes this, and since so far we are never + rotated at non-multiple-of-90 angles, this seems to do no harm + */ + paint->setAntiAlias(false); +} + void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dstRect, const FloatRect& srcRect, CompositeOperator compositeOp) { @@ -214,6 +227,7 @@ void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dstRect, ctxt->setupFillPaint(&paint); // need global alpha among other things paint.setFilterBitmap(true); paint.setXfermodeMode(WebCoreCompositeToSkiaComposite(compositeOp)); + fixPaintForBitmapsThatMaySeam(&paint); canvas->drawBitmapRect(bitmap, &srcR, dstR, &paint); #ifdef TRACE_SUBSAMPLED_BITMAPS @@ -287,6 +301,7 @@ void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& srcRect, // now paint is the only owner of shader paint.setXfermodeMode(WebCoreCompositeToSkiaComposite(compositeOp)); paint.setFilterBitmap(true); + fixPaintForBitmapsThatMaySeam(&paint); SkMatrix matrix(patternTransform); -- cgit v1.1