RESOLVED FIXED 51374
Cairo's ContextShadow may mis-render some box shadows
https://bugs.webkit.org/show_bug.cgi?id=51374
Summary Cairo's ContextShadow may mis-render some box shadows
Simon Fraser (smfr)
Reported 2010-12-20 21:02:56 PST
After porting ContextShadow to Mac, I sees some combinations of border-radius and shadow blur that it mis-renders. Example coming.
Attachments
Testcase (2.07 KB, text/html)
2010-12-20 21:03 PST, Simon Fraser (smfr)
no flags
Proposed patch (3.65 KB, patch)
2010-12-21 03:54 PST, Alejandro G. Castro
no flags
Patch (36.03 KB, patch)
2010-12-23 04:45 PST, Alejandro G. Castro
mrobinson: review+
Simon Fraser (smfr)
Comment 1 2010-12-20 21:03:40 PST
Created attachment 77081 [details] Testcase
Simon Fraser (smfr)
Comment 2 2010-12-20 21:22:24 PST
I think the top of ContextShadow::drawRectShadow() should read: float radiusTwice = m_blurDistance * 2; // Size of the tiling side. int sideTileWidth = 1; // Find the extra space needed from the curve of the corners. int extraWidthFromCornerRadii = radiusTwice + max(topLeftRadius.width(), bottomLeftRadius.width()) + radiusTwice + max(topRightRadius.width(), bottomRightRadius.width()); int extraHeightFromCornerRadii = radiusTwice + max(topLeftRadius.height(), topRightRadius.height()) + radiusTwice + max(bottomLeftRadius.height(), bottomRightRadius.height()); // The length of a side of the buffer is the enough space for four blur radii, // the radii of the corners, and then 1 pixel to draw the side tiles. IntSize shadowTemplateSize = IntSize(sideTileWidth + extraWidthFromCornerRadii, sideTileWidth + extraHeightFromCornerRadii); // drawShadowedRect still does not work with rotations. // https://bugs.webkit.org/show_bug.cgi?id=45042 CGContextRef cgContext = context->platformContext(); if ((!context->getCTM().isIdentityOrTranslationOrFlipped()) || (shadowTemplateSize.width() > rect.width()) || (shadowTemplateSize.height() > rect.height()) || (m_type != BlurShadow)) { drawRectShadowWithoutTiling(cgContext, rect, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius, 1); return; }
Alejandro G. Castro
Comment 3 2010-12-21 00:44:41 PST
(In reply to comment #1) > Created an attachment (id=77081) [details] > Testcase Yep, it fails for me also in webkitgtk, we had solved this issues I guess in some of the refactorings before applying the patch we did not check it correctly.
Alejandro G. Castro
Comment 4 2010-12-21 03:54:28 PST
Created attachment 77099 [details] Proposed patch
Alejandro G. Castro
Comment 5 2010-12-21 03:55:49 PST
(In reply to comment #2) > I think the top of ContextShadow::drawRectShadow() should read: > > [...] > > if ((!context->getCTM().isIdentityOrTranslationOrFlipped()) || (shadowTemplateSize.width() > rect.width()) > || (shadowTemplateSize.height() > rect.height()) || (m_type != BlurShadow)) { > drawRectShadowWithoutTiling(cgContext, rect, topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius, 1); > return; > } You are right, the problem is the calculation of the internal space required for the corner shadows, I've refactored the code with your proposal in the patch. Thanks.
Martin Robinson
Comment 6 2010-12-21 07:50:48 PST
Comment on attachment 77099 [details] Proposed patch Great, though we should definitely include the test case with pixel results to avoid this in the future.
Alejandro G. Castro
Comment 7 2010-12-23 04:45:27 PST
Martin Robinson
Comment 8 2010-12-23 07:14:36 PST
Comment on attachment 77327 [details] Patch Thank you!
Alejandro G. Castro
Comment 9 2011-01-07 02:27:09 PST
Note You need to log in before you can comment on or make changes to this bug.