From c47e74bd3c77326c28afa1987a33f7875b3c20d2 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Thu, 1 Mar 2012 10:14:07 +1100 Subject: Bug #3494492. Prevent AlphaRectangle() from drawing blurry rectangle under Direct2D. From Marko Njezic. --- win32/PlatWin.cxx | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'win32') diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index baa2e9ef5..c760e2c4c 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -1457,17 +1457,28 @@ void SurfaceD2D::RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesir void SurfaceD2D::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill, ColourDesired outline, int alphaOutline, int /* flags*/ ) { if (pRenderTarget) { - D2D1_ROUNDED_RECT roundedRectFill = D2D1::RoundedRect( - D2D1::RectF(rc.left+1.0, rc.top+1.0, rc.right-1.0, rc.bottom-1.0), - cornerSize, cornerSize); - D2DPenColour(fill, alphaFill); - pRenderTarget->FillRoundedRectangle(roundedRectFill, pBrush); - - D2D1_ROUNDED_RECT roundedRect = D2D1::RoundedRect( - D2D1::RectF(rc.left + 0.5, rc.top+0.5, rc.right - 0.5, rc.bottom-0.5), - cornerSize, cornerSize); - D2DPenColour(outline, alphaOutline); - pRenderTarget->DrawRoundedRectangle(roundedRect, pBrush); + if (cornerSize == 0) { + // When corner size is zero, draw square rectangle to prevent blurry pixels at corners + D2D1_RECT_F rectFill = D2D1::RectF(RoundFloat(rc.left) + 1.0, rc.top + 1.0, RoundFloat(rc.right) - 1.0, rc.bottom - 1.0); + D2DPenColour(fill, alphaFill); + pRenderTarget->FillRectangle(rectFill, pBrush); + + D2D1_RECT_F rectOutline = D2D1::RectF(RoundFloat(rc.left) + 0.5, rc.top + 0.5, RoundFloat(rc.right) - 0.5, rc.bottom - 0.5); + D2DPenColour(outline, alphaOutline); + pRenderTarget->DrawRectangle(rectOutline, pBrush); + } else { + D2D1_ROUNDED_RECT roundedRectFill = D2D1::RoundedRect( + D2D1::RectF(RoundFloat(rc.left) + 1.0, rc.top + 1.0, RoundFloat(rc.right) - 1.0, rc.bottom - 1.0), + cornerSize, cornerSize); + D2DPenColour(fill, alphaFill); + pRenderTarget->FillRoundedRectangle(roundedRectFill, pBrush); + + D2D1_ROUNDED_RECT roundedRect = D2D1::RoundedRect( + D2D1::RectF(RoundFloat(rc.left) + 0.5, rc.top + 0.5, RoundFloat(rc.right) - 0.5, rc.bottom - 0.5), + cornerSize, cornerSize); + D2DPenColour(outline, alphaOutline); + pRenderTarget->DrawRoundedRectangle(roundedRect, pBrush); + } } } -- cgit v1.2.3