Changeset 171119 in webkit


Ignore:
Timestamp:
Jul 15, 2014, 3:25:50 PM (11 years ago)
Author:
Simon Fraser
Message:

[iOS] Fix issues drawing subsampled image elements and CSS images
https://bugs.webkit.org/show_bug.cgi?id=134944
<rdar://problem/17634095>

Reviewed by Dean Jackson.

After r170675 it is important for BitmapImage::draw() to be given a srcRect computed
using the original size of the image, not the subsampled size.

So fix various code paths that end up in image drawing to use the originalSize(),
which requires giving Image a virtual function that just returns size(), and hence has
a FloatSize return value.

Tested by setting a very low subsampling threshold and browsing various sites.

A better longterm fix will happen via bug 134916.

  • platform/graphics/BitmapImage.cpp:

(WebCore::BitmapImage::originalSize):

  • platform/graphics/BitmapImage.h:
  • platform/graphics/GraphicsContext.cpp:

(WebCore::GraphicsContext::drawImage):

  • platform/graphics/Image.cpp:

(WebCore::Image::drawTiled):
(WebCore::Image::computeIntrinsicDimensions):

  • platform/graphics/Image.h:

(WebCore::Image::originalSize):

  • platform/graphics/cg/BitmapImageCG.cpp:

(WebCore::BitmapImage::BitmapImage): Just use m_size for initializing the other members.
(WebCore::BitmapImage::draw):

  • platform/graphics/cg/GraphicsContext3DCG.cpp:

(WebCore::GraphicsContext3D::ImageExtractor::extractImage):

  • platform/graphics/cg/ImageCG.cpp:

(WebCore::Image::drawPattern):

Location:
trunk/Source/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r171116 r171119  
     12014-07-15  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [iOS] Fix issues drawing subsampled image elements and CSS images
     4        https://bugs.webkit.org/show_bug.cgi?id=134944
     5        <rdar://problem/17634095>
     6
     7        Reviewed by Dean Jackson.
     8
     9        After r170675 it is important for BitmapImage::draw() to be given a srcRect computed
     10        using the original size of the image, not the subsampled size.
     11       
     12        So fix various code paths that end up in image drawing to use the originalSize(),
     13        which requires giving Image a virtual function that just returns size(), and hence has
     14        a FloatSize return value.
     15       
     16        Tested by setting a very low subsampling threshold and browsing various sites.
     17       
     18        A better longterm fix will happen via bug 134916.
     19
     20        * platform/graphics/BitmapImage.cpp:
     21        (WebCore::BitmapImage::originalSize):
     22        * platform/graphics/BitmapImage.h:
     23        * platform/graphics/GraphicsContext.cpp:
     24        (WebCore::GraphicsContext::drawImage):
     25        * platform/graphics/Image.cpp:
     26        (WebCore::Image::drawTiled):
     27        (WebCore::Image::computeIntrinsicDimensions):
     28        * platform/graphics/Image.h:
     29        (WebCore::Image::originalSize):
     30        * platform/graphics/cg/BitmapImageCG.cpp:
     31        (WebCore::BitmapImage::BitmapImage): Just use m_size for initializing the other members.
     32        (WebCore::BitmapImage::draw):
     33        * platform/graphics/cg/GraphicsContext3DCG.cpp:
     34        (WebCore::GraphicsContext3D::ImageExtractor::extractImage):
     35        * platform/graphics/cg/ImageCG.cpp:
     36        (WebCore::Image::drawPattern):
     37
    1382014-07-15  Brent Fulgham  <bfulgham@apple.com>
    239
  • trunk/Source/WebCore/platform/graphics/BitmapImage.cpp

    r170675 r171119  
    262262
    263263#if PLATFORM(IOS)
    264 IntSize BitmapImage::originalSize() const
     264FloatSize BitmapImage::originalSize() const
    265265{
    266266    updateSize();
  • trunk/Source/WebCore/platform/graphics/BitmapImage.h

    r170675 r171119  
    139139    IntSize sizeRespectingOrientation(ImageOrientationDescription = ImageOrientationDescription()) const;
    140140#if PLATFORM(IOS)
    141     virtual IntSize originalSize() const;
     141    virtual FloatSize originalSize() const override;
    142142    IntSize originalSizeRespectingOrientation() const;
    143143#endif
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp

    r170947 r171119  
    582582    if (!image)
    583583        return;
    584     drawImage(image, colorSpace, destination, FloatRect(FloatPoint(), image->size()), imagePaintingOptions);
     584   
     585#if PLATFORM(IOS)
     586    FloatRect srcRect(FloatPoint(), image->originalSize());
     587#else
     588    FloatRect srcRect(FloatPoint(), image->size());
     589#endif
     590       
     591    drawImage(image, colorSpace, destination, srcRect, imagePaintingOptions);
    585592}
    586593
  • trunk/Source/WebCore/platform/graphics/Image.cpp

    r169512 r171119  
    104104    ASSERT(!isBitmapImage() || notSolidColor());
    105105
     106#if PLATFORM(IOS)
     107    FloatSize intrinsicTileSize = originalSize();
     108#else
    106109    FloatSize intrinsicTileSize = size();
     110#endif
    107111    if (hasRelativeWidth())
    108112        intrinsicTileSize.setWidth(scaledTileSize.width());
     
    258262void Image::computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio)
    259263{
     264#if PLATFORM(IOS)
     265    intrinsicRatio = originalSize();
     266#else
    260267    intrinsicRatio = size();
     268#endif
    261269    intrinsicWidth = Length(intrinsicRatio.width(), Fixed);
    262270    intrinsicHeight = Length(intrinsicRatio.height(), Fixed);
  • trunk/Source/WebCore/platform/graphics/Image.h

    r168894 r171119  
    104104    virtual bool getHotSpot(IntPoint&) const { return false; }
    105105
     106#if PLATFORM(IOS)
     107    virtual FloatSize originalSize() const { return size(); }
     108#endif
     109
    106110    bool setData(PassRefPtr<SharedBuffer> data, bool allDataReceived);
    107111    virtual bool dataChanged(bool /*allDataReceived*/) { return false; }
  • trunk/Source/WebCore/platform/graphics/cg/BitmapImageCG.cpp

    r170675 r171119  
    102102    // Since we don't have a decoder, we can't figure out the image orientation.
    103103    // Set m_sizeRespectingOrientation to be the same as m_size so it's not 0x0.
    104     m_sizeRespectingOrientation = IntSize(width, height);
    105 
    106 #if PLATFORM(IOS)
    107     m_originalSize = IntSize(width, height);
    108     m_originalSizeRespectingOrientation = IntSize(width, height);
     104    m_sizeRespectingOrientation = m_size;
     105
     106#if PLATFORM(IOS)
     107    m_originalSize = m_size;
     108    m_originalSizeRespectingOrientation = m_size;
    109109#endif
    110110
     
    203203
    204204#if PLATFORM(IOS)
    205     if (m_originalSize.width() && m_originalSize.height())
     205    if (m_originalSize != m_size && !m_originalSize.isEmpty())
    206206        srcRectForCurrentFrame.scale(m_size.width() / static_cast<float>(m_originalSize.width()), m_size.height() / static_cast<float>(m_originalSize.height()));
    207207
  • trunk/Source/WebCore/platform/graphics/cg/GraphicsContext3DCG.cpp

    r170675 r171119  
    336336        float scaleHint = 1;
    337337        if (m_image->isBitmapImage()) {
    338             IntSize originalSize = toBitmapImage(m_image)->originalSize();
    339             if (originalSize.width() && originalSize.height())
    340                 scaleHint = std::min<float>(1.0f, std::max(m_image->size().width() / originalSize.width(), m_image->size().width() / originalSize.height()));
     338            FloatSize originalSize = toBitmapImage(m_image)->originalSize();
     339            if (!originalSize.isEmpty())
     340                scaleHint = std::min<float>(1, std::max(m_image->size().width() / originalSize.width(), m_image->size().width() / originalSize.height()));
    341341        }
    342342        m_decodedImage = adoptCF(decoder.createFrameAtIndex(0, &scaleHint));
  • trunk/Source/WebCore/platform/graphics/cg/ImageCG.cpp

    r165676 r171119  
    117117
    118118    RetainPtr<CGImageRef> subImage;
    119     if (tileRect.size() == size())
     119#if PLATFORM(IOS)
     120    FloatSize imageSize = originalSize();
     121#else
     122    FloatSize imageSize = size();
     123#endif
     124    if (tileRect.size() == imageSize)
    120125        subImage = tileImage;
    121126    else {
Note: See TracChangeset for help on using the changeset viewer.