Changeset 46002 in webkit


Ignore:
Timestamp:
Jul 16, 2009, 5:47:47 PM (16 years ago)
Author:
mitz@apple.com
Message:

WebCore:

Reviewed by Simon Fraser.

REGRESSION (r41238) Repainted portion of a scaled image does not line up with full image
https://bugs.webkit.org/show_bug.cgi?id=26747
rdar://problem/7009243

Test: fast/repaint/background-misaligned.html

  • platform/graphics/Image.cpp: (WebCore::Image::drawTiled): Moved a variable definition closer to where it is used.
  • platform/graphics/cg/ImageCG.cpp: (WebCore::BitmapImage::draw): In the subimage code path, compute a pixel-aligned source rect, because the subiamge is always pixel-aligned in source space, and adjust the destination rect to preserve the source -> destination mapping. Clip to the (original) destination rect to prevent bleeding out.

LayoutTests:

Reviewed by Simon Fraser.

REGRESSION (r41238) Repainted portion of a scaled image does not line up with full image
https://bugs.webkit.org/show_bug.cgi?id=26747
rdar://problem/7009243

  • fast/repaint/background-misaligned.html: Added.
  • platform/mac/fast/backgrounds/size/backgroundSize15-expected.checksum:
  • platform/mac/fast/backgrounds/size/backgroundSize15-expected.png:
  • platform/mac/fast/borders/border-image-rotate-transform-expected.checksum:
  • platform/mac/fast/borders/border-image-rotate-transform-expected.png:
  • platform/mac/fast/repaint/background-misaligned-expected.checksum: Added.
  • platform/mac/fast/repaint/background-misaligned-expected.png: Added.
  • platform/mac/fast/repaint/background-misaligned-expected.txt: Added.
Location:
trunk
Files:
4 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r45999 r46002  
     12009-07-16  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Simon Fraser.
     4
     5        REGRESSION (r41238) Repainted portion of a scaled image does not line up with full image
     6        https://bugs.webkit.org/show_bug.cgi?id=26747
     7        rdar://problem/7009243
     8
     9        * fast/repaint/background-misaligned.html: Added.
     10        * platform/mac/fast/backgrounds/size/backgroundSize15-expected.checksum:
     11        * platform/mac/fast/backgrounds/size/backgroundSize15-expected.png:
     12        * platform/mac/fast/borders/border-image-rotate-transform-expected.checksum:
     13        * platform/mac/fast/borders/border-image-rotate-transform-expected.png:
     14        * platform/mac/fast/repaint/background-misaligned-expected.checksum: Added.
     15        * platform/mac/fast/repaint/background-misaligned-expected.png: Added.
     16        * platform/mac/fast/repaint/background-misaligned-expected.txt: Added.
     17
    1182009-07-16  Adam Barth  <abarth@webkit.org>
    219
  • trunk/LayoutTests/platform/mac/fast/backgrounds/size/backgroundSize15-expected.checksum

    r38121 r46002  
    1 89976d505fed69efe0567a33826f55e5
     153b43a341ede2d5fa5bd7466300e5e3a
  • trunk/LayoutTests/platform/mac/fast/borders/border-image-rotate-transform-expected.checksum

    r38008 r46002  
    1 d125613bee8d4934e96c382f8ff1d2e4
     10cf932e7fd01d2f2d35a2173d17c6bc7
  • trunk/WebCore/ChangeLog

    r46001 r46002  
     12009-07-16  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Simon Fraser.
     4
     5        REGRESSION (r41238) Repainted portion of a scaled image does not line up with full image
     6        https://bugs.webkit.org/show_bug.cgi?id=26747
     7        rdar://problem/7009243
     8
     9        Test: fast/repaint/background-misaligned.html
     10
     11        * platform/graphics/Image.cpp:
     12        (WebCore::Image::drawTiled): Moved a variable definition closer to where
     13        it is used.
     14        * platform/graphics/cg/ImageCG.cpp:
     15        (WebCore::BitmapImage::draw): In the subimage code path, compute a
     16        pixel-aligned source rect, because the subiamge is always pixel-aligned
     17        in source space, and adjust the destination rect to preserve the
     18        source -> destination mapping. Clip to the (original) destination rect
     19        to prevent bleeding out.
     20
    1212009-07-16  Jeremy Orlow  <jorlow@chromium.org>
    222
  • trunk/WebCore/platform/graphics/Image.cpp

    r40761 r46002  
    120120    FloatSize scale(scaledTileSize.width() / intrinsicTileSize.width(),
    121121                    scaledTileSize.height() / intrinsicTileSize.height());
    122     TransformationMatrix patternTransform = TransformationMatrix().scaleNonUniform(scale.width(), scale.height());
    123122
    124123    FloatRect oneTileRect;
     
    138137    }
    139138
     139    TransformationMatrix patternTransform = TransformationMatrix().scaleNonUniform(scale.width(), scale.height());
    140140    FloatRect tileRect(FloatPoint(), intrinsicTileSize);   
    141141    drawPattern(ctxt, tileRect, patternTransform, oneTileRect.location(), op, destRect);
  • trunk/WebCore/platform/graphics/cg/ImageCG.cpp

    r45780 r46002  
    167167        // into the destination rect. See <rdar://problem/6112909>.
    168168        shouldUseSubimage = (interpolationQuality == kCGInterpolationHigh || interpolationQuality == kCGInterpolationDefault) && srcRect.size() != destRect.size();
     169        float xScale = srcRect.width() / destRect.width();
     170        float yScale = srcRect.height() / destRect.height();
    169171        if (shouldUseSubimage) {
    170             image = CGImageCreateWithImageInRect(image, srcRect);
     172            FloatRect subimageRect = srcRect;
     173            float leftPadding = srcRect.x() - floorf(srcRect.x());
     174            float topPadding = srcRect.y() - floorf(srcRect.y());
     175
     176            subimageRect.move(-leftPadding, -topPadding);
     177            adjustedDestRect.move(-leftPadding / xScale, -topPadding / yScale);
     178
     179            subimageRect.setWidth(ceilf(subimageRect.width() + leftPadding));
     180            adjustedDestRect.setWidth(subimageRect.width() / xScale);
     181
     182            subimageRect.setHeight(ceilf(subimageRect.height() + topPadding));
     183            adjustedDestRect.setHeight(subimageRect.height() / yScale);
     184
     185            image = CGImageCreateWithImageInRect(image, subimageRect);
    171186            if (currHeight < srcRect.bottom()) {
    172187                ASSERT(CGImageGetHeight(image) == currHeight - CGRectIntegral(srcRect).origin.y);
    173                 adjustedDestRect.setHeight(destRect.height() / srcRect.height() * CGImageGetHeight(image));
     188                adjustedDestRect.setHeight(CGImageGetHeight(image) / yScale);
    174189            }
    175190        } else {
    176             float xScale = srcRect.width() / destRect.width();
    177             float yScale = srcRect.height() / destRect.height();
    178 
    179191            adjustedDestRect.setLocation(FloatPoint(destRect.x() - srcRect.x() / xScale, destRect.y() - srcRect.y() / yScale));
    180192            adjustedDestRect.setSize(FloatSize(selfSize.width() / xScale, selfSize.height() / yScale));
    181 
    182             CGContextClipToRect(context, destRect);
    183193        }
     194
     195        CGContextClipToRect(context, destRect);
    184196    }
    185197
     
    188200        adjustedDestRect.setHeight(adjustedDestRect.height() * currHeight / selfSize.height());
    189201
     202    ctxt->setCompositeOperation(compositeOp);
     203
    190204    // Flip the coords.
    191     ctxt->setCompositeOperation(compositeOp);
    192     CGContextTranslateCTM(context, adjustedDestRect.x(), adjustedDestRect.bottom());
    193205    CGContextScaleCTM(context, 1, -1);
    194     adjustedDestRect.setLocation(FloatPoint());
     206    adjustedDestRect.setY(-adjustedDestRect.bottom());
    195207
    196208    // Draw the image.
Note: See TracChangeset for help on using the changeset viewer.