Changeset 169620 in webkit


Ignore:
Timestamp:
Jun 5, 2014 11:18:40 AM (10 years ago)
Author:
Alan Bujtas
Message:

Subpixel rendering: border-radius painting falls back to rectangle when the snapped rounded rect becomes non-renderable.
https://bugs.webkit.org/show_bug.cgi?id=133491

Reviewed by Simon Fraser.

Pixel snapping can change the rectangle's size when it is on a certain subpixel position. (usually it does not)
This patch ensures that the snapped rect is still renderable by adjusting the radii as well.

Source/WebCore:
Test: fast/borders/hidpi-border-radius-with-subpixel-margin-not-renderable.html

  • platform/graphics/RoundedRect.cpp:

(WebCore::RoundedRect::Radii::scale):
(WebCore::RoundedRect::pixelSnappedRoundedRectForPainting):

  • platform/graphics/RoundedRect.h:

LayoutTests:

  • fast/borders/hidpi-border-radius-with-subpixel-margin-not-renderable-expected.html: Added.
  • fast/borders/hidpi-border-radius-with-subpixel-margin-not-renderable.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r169617 r169620  
     12014-06-05  Zalan Bujtas  <zalan@apple.com>
     2
     3        Subpixel rendering: border-radius painting falls back to rectangle when the snapped rounded rect becomes non-renderable.
     4        https://bugs.webkit.org/show_bug.cgi?id=133491
     5
     6        Reviewed by Simon Fraser.
     7
     8        Pixel snapping can change the rectangle's size when it is on a certain subpixel position. (usually it does not)
     9        This patch ensures that the snapped rect is still renderable by adjusting the radii as well.
     10
     11        * fast/borders/hidpi-border-radius-with-subpixel-margin-not-renderable-expected.html: Added.
     12        * fast/borders/hidpi-border-radius-with-subpixel-margin-not-renderable.html: Added.
     13
    1142014-06-05  Frédéric Wang  <fred.wang@free.fr>
    215
  • trunk/Source/WebCore/ChangeLog

    r169619 r169620  
     12014-06-05  Zalan Bujtas  <zalan@apple.com>
     2
     3        Subpixel rendering: border-radius painting falls back to rectangle when the snapped rounded rect becomes non-renderable.
     4        https://bugs.webkit.org/show_bug.cgi?id=133491
     5
     6        Reviewed by Simon Fraser.
     7
     8        Pixel snapping can change the rectangle's size when it is on a certain subpixel position. (usually it does not)
     9        This patch ensures that the snapped rect is still renderable by adjusting the radii as well.
     10
     11        Test: fast/borders/hidpi-border-radius-with-subpixel-margin-not-renderable.html
     12
     13        * platform/graphics/RoundedRect.cpp:
     14        (WebCore::RoundedRect::Radii::scale):
     15        (WebCore::RoundedRect::pixelSnappedRoundedRectForPainting):
     16        * platform/graphics/RoundedRect.h:
     17
    1182014-06-05  Commit Queue  <commit-queue@webkit.org>
    219
  • trunk/Source/WebCore/platform/graphics/RoundedRect.cpp

    r165671 r169620  
    4444void RoundedRect::Radii::scale(float factor)
    4545{
    46     if (factor == 1)
     46    scale(factor, factor);
     47}
     48
     49void RoundedRect::Radii::scale(float horizontalFactor, float verticalFactor)
     50{
     51    if (horizontalFactor == 1 && verticalFactor == 1)
    4752        return;
    4853
    4954    // If either radius on a corner becomes zero, reset both radii on that corner.
    50     m_topLeft.scale(factor);
     55    m_topLeft.scale(horizontalFactor, verticalFactor);
    5156    if (!m_topLeft.width() || !m_topLeft.height())
    5257        m_topLeft = LayoutSize();
    53     m_topRight.scale(factor);
     58    m_topRight.scale(horizontalFactor, verticalFactor);
    5459    if (!m_topRight.width() || !m_topRight.height())
    5560        m_topRight = LayoutSize();
    56     m_bottomLeft.scale(factor);
     61    m_bottomLeft.scale(horizontalFactor, verticalFactor);
    5762    if (!m_bottomLeft.width() || !m_bottomLeft.height())
    5863        m_bottomLeft = LayoutSize();
    59     m_bottomRight.scale(factor);
     64    m_bottomRight.scale(horizontalFactor, verticalFactor);
    6065    if (!m_bottomRight.width() || !m_bottomRight.height())
    6166        m_bottomRight = LayoutSize();
    62 
    6367}
    6468
     
    241245{
    242246    LayoutRect originalRect = rect();
    243     FloatRect paintingRect = pixelSnappedForPainting(rect(), deviceScaleFactor);
    244     FloatRoundedRect::Radii paintingRadii = radii();
    245     paintingRadii.shrink(paintingRect.y() - originalRect.y(), originalRect.maxY() - paintingRect.maxY(), paintingRect.x() - originalRect.x(), originalRect.maxX() - paintingRect.maxX());
    246     return FloatRoundedRect(paintingRect, paintingRadii);
     247    FloatRect pixelSnappedRect = pixelSnappedForPainting(originalRect, deviceScaleFactor);
     248    Radii adjustedRadii = radii();
     249    // Snapping usually does not alter size, but when it does, we need to make sure that the final rect is still renderable by distributing the size delta proportionally.
     250    adjustedRadii.scale(pixelSnappedRect.width() / originalRect.width(), pixelSnappedRect.height() / originalRect.height());
     251    return FloatRoundedRect(pixelSnappedRect, adjustedRadii);
    247252}
    248253
  • trunk/Source/WebCore/platform/graphics/RoundedRect.h

    r166383 r169620  
    6565
    6666        void scale(float factor);
     67        void scale(float horizontalFactor, float verticalFactor);
    6768        void expand(const LayoutUnit& topWidth, const LayoutUnit& bottomWidth, const LayoutUnit& leftWidth, const LayoutUnit& rightWidth);
    6869        void expand(const LayoutUnit& size) { expand(size, size, size, size); }
Note: See TracChangeset for help on using the changeset viewer.