Changeset 114548 in webkit


Ignore:
Timestamp:
Apr 18, 2012 1:05:10 PM (12 years ago)
Author:
leviw@chromium.org
Message:

GraphicsContextCG's roundToDevicePixels should round even when there's no transform
https://bugs.webkit.org/show_bug.cgi?id=84191

Reviewed by Eric Seidel.

When painting with the identify transform, the roundToDevicePixels function in GraphicsContextCG
does an early return that simply returns the FloatRect that was passed in. This proved to be a
problem in sub-pixel layout, as we wouldn't adjust the paint rect for text underline, and it could
end up being more than one pixel wide. Adding a roundedIntRect method on FloatRect for the simple
short-circuit case.

No new tests. No change in behavior before switching to sub-pixel layout.

  • platform/graphics/FloatRect.cpp:

(WebCore::roundedIntRect):

  • platform/graphics/FloatRect.h:
  • platform/graphics/cg/GraphicsContextCG.cpp:

(WebCore::GraphicsContext::roundToDevicePixels):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r114545 r114548  
     12012-04-18  Levi Weintraub  <leviw@chromium.org>
     2
     3        GraphicsContextCG's roundToDevicePixels should round even when there's no transform
     4        https://bugs.webkit.org/show_bug.cgi?id=84191
     5
     6        Reviewed by Eric Seidel.
     7
     8        When painting with the identify transform, the roundToDevicePixels function in GraphicsContextCG
     9        does an early return that simply returns the FloatRect that was passed in. This proved to be a
     10        problem in sub-pixel layout, as we wouldn't adjust the paint rect for text underline, and it could
     11        end up being more than one pixel wide. Adding a roundedIntRect method on FloatRect for the simple
     12        short-circuit case.
     13
     14        No new tests. No change in behavior before switching to sub-pixel layout.
     15
     16        * platform/graphics/FloatRect.cpp:
     17        (WebCore::roundedIntRect):
     18        * platform/graphics/FloatRect.h:
     19        * platform/graphics/cg/GraphicsContextCG.cpp:
     20        (WebCore::GraphicsContext::roundToDevicePixels):
     21
    1222012-04-18  Keishi Hattori  <keishi@webkit.org>
    223
  • trunk/Source/WebCore/platform/graphics/FloatRect.cpp

    r113879 r114548  
    237237}
    238238
     239IntRect roundedIntRect(const FloatRect& rect)
     240{
     241    return IntRect(roundedIntPoint(rect.location()), roundedIntSize(rect.size()));
     242}
     243
    239244FloatRect mapRect(const FloatRect& r, const FloatRect& srcRect, const FloatRect& destRect)
    240245{
  • trunk/Source/WebCore/platform/graphics/FloatRect.h

    r109256 r114548  
    289289IntRect enclosedIntRect(const FloatRect&);
    290290
     291IntRect roundedIntRect(const FloatRect&);
     292
    291293// Map rect r from srcRect to an equivalent rect in destRect.
    292294FloatRect mapRect(const FloatRect& r, const FloatRect& srcRect, const FloatRect& destRect);
  • trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp

    r113486 r114548  
    13141314
    13151315    if (m_data->m_userToDeviceTransformKnownToBeIdentity)
    1316         return rect;
     1316        return roundedIntRect(rect);
    13171317
    13181318    CGAffineTransform deviceMatrix = CGContextGetUserSpaceToDeviceSpaceTransform(platformContext());
    13191319    if (CGAffineTransformIsIdentity(deviceMatrix)) {
    13201320        m_data->m_userToDeviceTransformKnownToBeIdentity = true;
    1321         return rect;
     1321        return roundedIntRect(rect);
    13221322    }
    13231323
Note: See TracChangeset for help on using the changeset viewer.