Changeset 83216 in webkit


Ignore:
Timestamp:
Apr 7, 2011 3:15:32 PM (13 years ago)
Author:
mitz@apple.com
Message:

<rdar://problem/9018212> Underline thickness is not uniform under non-integral scale factor
https://bugs.webkit.org/show_bug.cgi?id=58083

Reviewed by Simon Fraser.

Source/WebCore:

Test: fast/text/decorations-transformed.html

  • platform/graphics/GraphicsContext.h: Added a RoundingMode enum with two values. RoundAllSides

is the existing rounding mode, where each side of the rectangle snaps to the nearest pixel
gridline. RoundOriginAndDimensions snaps the origin to the nearest pixel gridpoint and rounds
the width and the height. In this new mode, translating a rectangle in user space never changes
its dimensions in device pixels.

  • platform/graphics/cg/GraphicsContextCG.cpp:

(WebCore::GraphicsContext::roundToDevicePixels): Implemented RoundOriginAndDimensions.
(WebCore::GraphicsContext::drawLineForText): Use RoundOriginAndDimensions, thus ensuring that
all underlines have the same thickness in device pixels.

  • platform/graphics/openvg/GraphicsContextOpenVG.cpp:

(WebCore::GraphicsContext::roundToDevicePixels): Added RoundingMode parameter, but did not implement it.

  • platform/graphics/qt/GraphicsContextQt.cpp:

(WebCore::GraphicsContext::roundToDevicePixels): Ditto.

  • platform/graphics/skia/GraphicsContextSkia.cpp:

(WebCore::GraphicsContext::roundToDevicePixels): Ditto.

  • platform/graphics/wince/GraphicsContextWinCE.cpp:

(WebCore::GraphicsContext::roundToDevicePixels): Ditto.

  • platform/graphics/wx/GraphicsContextWx.cpp:

(WebCore::GraphicsContext::roundToDevicePixels): Ditto.

  • rendering/InlineTextBox.cpp:

(WebCore::InlineTextBox::paintDecoration):

LayoutTests:

  • fast/text/decorations-transformed.html: Added.
  • platform/mac/fast/text/decorations-transformed-expected.checksum: Added.
  • platform/mac/fast/text/decorations-transformed-expected.png: Added.
  • platform/mac/fast/text/decorations-transformed-expected.txt: Added.
Location:
trunk
Files:
4 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r83214 r83216  
     12011-04-07  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Simon Fraser.
     4
     5        <rdar://problem/9018212> Underline thickness is not uniform under non-integral scale factor
     6        https://bugs.webkit.org/show_bug.cgi?id=58083
     7
     8        * fast/text/decorations-transformed.html: Added.
     9        * platform/mac/fast/text/decorations-transformed-expected.checksum: Added.
     10        * platform/mac/fast/text/decorations-transformed-expected.png: Added.
     11        * platform/mac/fast/text/decorations-transformed-expected.txt: Added.
     12
    1132011-04-07  Jer Noble  <jer.noble@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r83213 r83216  
     12011-04-07  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Simon Fraser.
     4
     5        <rdar://problem/9018212> Underline thickness is not uniform under non-integral scale factor
     6        https://bugs.webkit.org/show_bug.cgi?id=58083
     7
     8        Test: fast/text/decorations-transformed.html
     9
     10        * platform/graphics/GraphicsContext.h: Added a RoundingMode enum with two values. RoundAllSides
     11        is the existing rounding mode, where each side of the rectangle snaps to the nearest pixel
     12        gridline. RoundOriginAndDimensions snaps the origin to the nearest pixel gridpoint and rounds
     13        the width and the height. In this new mode, translating a rectangle in user space never changes
     14        its dimensions in device pixels.
     15        * platform/graphics/cg/GraphicsContextCG.cpp:
     16        (WebCore::GraphicsContext::roundToDevicePixels): Implemented RoundOriginAndDimensions.
     17        (WebCore::GraphicsContext::drawLineForText): Use RoundOriginAndDimensions, thus ensuring that
     18        all underlines have the same thickness in device pixels.
     19        * platform/graphics/openvg/GraphicsContextOpenVG.cpp:
     20        (WebCore::GraphicsContext::roundToDevicePixels): Added RoundingMode parameter, but did not implement it.
     21        * platform/graphics/qt/GraphicsContextQt.cpp:
     22        (WebCore::GraphicsContext::roundToDevicePixels): Ditto.
     23        * platform/graphics/skia/GraphicsContextSkia.cpp:
     24        (WebCore::GraphicsContext::roundToDevicePixels): Ditto.
     25        * platform/graphics/wince/GraphicsContextWinCE.cpp:
     26        (WebCore::GraphicsContext::roundToDevicePixels): Ditto.
     27        * platform/graphics/wx/GraphicsContextWx.cpp:
     28        (WebCore::GraphicsContext::roundToDevicePixels): Ditto.
     29        * rendering/InlineTextBox.cpp:
     30        (WebCore::InlineTextBox::paintDecoration):
     31
    1322011-04-06  Vitaly Repeshko  <vitalyr@chromium.org>
    233
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.h

    r83044 r83216  
    350350        void drawHighlightForText(const Font&, const TextRun&, const FloatPoint&, int h, const Color& backgroundColor, ColorSpace, int from = 0, int to = -1);
    351351
    352         FloatRect roundToDevicePixels(const FloatRect&);
     352        enum RoundingMode {
     353            RoundAllSides,
     354            RoundOriginAndDimensions
     355        };
     356        FloatRect roundToDevicePixels(const FloatRect&, RoundingMode = RoundAllSides);
    353357
    354358        void drawLineForText(const FloatPoint&, float width, bool printing);
  • trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp

    r81161 r83216  
    11681168}
    11691169
    1170 FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& rect)
     1170FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& rect, RoundingMode roundingMode)
    11711171{
    11721172    // It is not enough just to round to pixels in device space. The rotation part of the
     
    11931193    deviceOrigin.x = roundf(deviceOrigin.x);
    11941194    deviceOrigin.y = roundf(deviceOrigin.y);
    1195     deviceLowerRight.x = roundf(deviceLowerRight.x);
    1196     deviceLowerRight.y = roundf(deviceLowerRight.y);
     1195    if (roundingMode == RoundAllSides) {
     1196        deviceLowerRight.x = roundf(deviceLowerRight.x);
     1197        deviceLowerRight.y = roundf(deviceLowerRight.y);
     1198    } else {
     1199        deviceLowerRight.x = deviceOrigin.x + roundf(rect.width() * deviceScaleX);
     1200        deviceLowerRight.y = deviceOrigin.y + roundf(rect.height() * deviceScaleY);
     1201    }
    11971202
    11981203    // Don't let the height or width round to 0 unless either was originally 0
     
    12331238        // makes our thickness more than double, then there must be a shrinking-scale factor and rounding to pixels
    12341239        // in device space will make the underlines too thick.
    1235         CGRect lineRect = roundToDevicePixels(FloatRect(x, y, lineLength, adjustedThickness));
     1240        CGRect lineRect = roundToDevicePixels(FloatRect(x, y, lineLength, adjustedThickness), RoundOriginAndDimensions);
    12361241        if (lineRect.size.height < thickness * 2.0) {
    12371242            x = lineRect.origin.x;
  • trunk/Source/WebCore/platform/graphics/openvg/GraphicsContextOpenVG.cpp

    r78704 r83216  
    258258}
    259259
    260 FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& rect)
     260FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& rect, RoundingMode)
    261261{
    262262    if (paintingDisabled())
  • trunk/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp

    r82462 r83216  
    901901}
    902902
    903 FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& frect)
     903FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& frect, RoundingMode)
    904904{
    905905    // It is not enough just to round to pixels in device space. The rotation part of the
  • trunk/Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp

    r83002 r83216  
    869869}
    870870
    871 FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& rect)
     871FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& rect, RoundingMode)
    872872{
    873873    return rect;
  • trunk/Source/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp

    r79052 r83216  
    13011301
    13021302
    1303 FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& frect)
     1303FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& frect, RoundingMode)
    13041304{
    13051305    notImplemented();
  • trunk/Source/WebCore/platform/graphics/wx/GraphicsContextWx.cpp

    r78852 r83216  
    417417
    418418
    419 FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& frect)
     419FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& frect, RoundingMode)
    420420{
    421421    FloatRect result;
Note: See TracChangeset for help on using the changeset viewer.