Changeset 202348 in webkit


Ignore:
Timestamp:
Jun 22, 2016 1:44:26 PM (8 years ago)
Author:
Simon Fraser
Message:

REGRESSION (r201629): Weird button glitching on github.com
https://bugs.webkit.org/show_bug.cgi?id=159031
rdar://problem/26880332

Reviewed by Tim Horton.

Source/WebCore:

r201629 changed the logic slightly when creating an image buffer for a scaled context;
it set the buffer context's scale to the scale in the source context, but this failed
to take into account the rounding up of the buffer size, which the old code did.

Fix by reverting to the old behavior.

Since buffer sizes can only be integral, changed compatibleBufferSize() to return
an IntSize.

Test: fast/backgrounds/scaled-gradient-background.html

  • platform/graphics/ImageBuffer.cpp:

(WebCore::ImageBuffer::createCompatibleBuffer):
(WebCore::ImageBuffer::compatibleBufferSize):

  • platform/graphics/ImageBuffer.h:
  • platform/graphics/IntRect.h:

(WebCore::IntRect::area):

  • platform/graphics/IntSize.h:

(WebCore::IntSize::area): Make this return an unsigned.

LayoutTests:

  • fast/backgrounds/scaled-gradient-background-expected.html: Added.
  • fast/backgrounds/scaled-gradient-background.html: Added.
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r202344 r202348  
     12016-06-22  Simon Fraser  <simon.fraser@apple.com>
     2
     3        REGRESSION (r201629): Weird button glitching on github.com
     4        https://bugs.webkit.org/show_bug.cgi?id=159031
     5        rdar://problem/26880332
     6
     7        Reviewed by Tim Horton.
     8
     9        * fast/backgrounds/scaled-gradient-background-expected.html: Added.
     10        * fast/backgrounds/scaled-gradient-background.html: Added.
     11
    1122016-06-22  Alexey Proskuryakov  <ap@apple.com>
    213
  • trunk/Source/WebCore/ChangeLog

    r202345 r202348  
     12016-06-22  Simon Fraser  <simon.fraser@apple.com>
     2
     3        REGRESSION (r201629): Weird button glitching on github.com
     4        https://bugs.webkit.org/show_bug.cgi?id=159031
     5        rdar://problem/26880332
     6
     7        Reviewed by Tim Horton.
     8
     9        r201629 changed the logic slightly when creating an image buffer for a scaled context;
     10        it set the buffer context's scale to the scale in the source context, but this failed
     11        to take into account the rounding up of the buffer size, which the old code did.
     12
     13        Fix by reverting to the old behavior.
     14
     15        Since buffer sizes can only be integral, changed compatibleBufferSize() to return
     16        an IntSize.
     17
     18        Test: fast/backgrounds/scaled-gradient-background.html
     19
     20        * platform/graphics/ImageBuffer.cpp:
     21        (WebCore::ImageBuffer::createCompatibleBuffer):
     22        (WebCore::ImageBuffer::compatibleBufferSize):
     23        * platform/graphics/ImageBuffer.h:
     24        * platform/graphics/IntRect.h:
     25        (WebCore::IntRect::area):
     26        * platform/graphics/IntSize.h:
     27        (WebCore::IntSize::area): Make this return an unsigned.
     28
    1292016-06-22  Anders Carlsson  <andersca@apple.com>
    230
  • trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp

    r201629 r202348  
    170170        return nullptr;
    171171
    172     FloatSize scaledSize = ImageBuffer::compatibleBufferSize(size, context);
    173 
    174     auto buffer = ImageBuffer::createCompatibleBuffer(expandedIntSize(scaledSize), 1, ColorSpaceSRGB, context, hasAlpha);
     172    IntSize scaledSize = ImageBuffer::compatibleBufferSize(size, context);
     173
     174    auto buffer = ImageBuffer::createCompatibleBuffer(scaledSize, 1, ColorSpaceSRGB, context, hasAlpha);
    175175    if (!buffer)
    176176        return nullptr;
    177177
    178178    // Set up a corresponding scale factor on the graphics context.
    179     buffer->context().scale(context.scaleFactor());
     179    buffer->context().scale(FloatSize(scaledSize.width() / size.width(), scaledSize.height() / size.height()));
    180180    return buffer;
    181181}
     
    186186}
    187187
    188 FloatSize ImageBuffer::compatibleBufferSize(const FloatSize& size, const GraphicsContext& context)
     188IntSize ImageBuffer::compatibleBufferSize(const FloatSize& size, const GraphicsContext& context)
    189189{
    190190    // Enlarge the buffer size if the context's transform is scaling it so we need a higher
    191191    // resolution than one pixel per unit.
    192     return size * context.scaleFactor();
     192    return expandedIntSize(size * context.scaleFactor());
    193193}
    194194
  • trunk/Source/WebCore/platform/graphics/ImageBuffer.h

    r201629 r202348  
    8484    static std::unique_ptr<ImageBuffer> createCompatibleBuffer(const FloatSize&, float resolutionScale, ColorSpace, const GraphicsContext&, bool hasAlpha);
    8585
    86     static FloatSize compatibleBufferSize(const FloatSize&, const GraphicsContext&);
     86    static IntSize compatibleBufferSize(const FloatSize&, const GraphicsContext&);
    8787    bool isCompatibleWithContext(const GraphicsContext&) const;
    8888
  • trunk/Source/WebCore/platform/graphics/IntRect.h

    r191216 r202348  
    8686    int width() const { return m_size.width(); }
    8787    int height() const { return m_size.height(); }
     88   
     89    unsigned area() const { return m_size.area(); }
    8890
    8991    void setX(int x) { m_location.setX(x); }
  • trunk/Source/WebCore/platform/graphics/IntSize.h

    r199956 r202348  
    126126    IntSize constrainedBetween(const IntSize& min, const IntSize& max) const;
    127127
    128     int area() const
    129     {
    130         return m_width * m_height;
     128    unsigned area() const
     129    {
     130        return abs(m_width) * abs(m_height);
    131131    }
    132132
Note: See TracChangeset for help on using the changeset viewer.