| Differences between
and this patch
- WebCore/ChangeLog +14 lines
Lines 1-3 WebCore/ChangeLog_sec1
1
2010-05-24  Damian Kaleta  <dkaleta@apple.com>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
         Pixel cracks in border images when drawing with a scale factor > 1
6
		https://bugs.webkit.org/show_bug.cgi?id=15720
7
8
        * platform/graphics/GraphicsContext.cpp:
9
        (WebCore::GraphicsContext::drawTiledImage):
10
        * platform/graphics/GraphicsContext.h: Added two new methods to support drawing using FloatRect
11
        * rendering/RenderBoxModelObject.cpp:
12
        (WebCore::RenderBoxModelObject::paintNinePieceImage): Each element of a 9-piece image is first adjusted to the pixel 
13
        boundaries of its parent and then uses the new methods that can accept FloatRects as an argument to draw an image.
14
1
2010-05-24  Sheriff Bot  <webkit.review.bot@gmail.com>
15
2010-05-24  Sheriff Bot  <webkit.review.bot@gmail.com>
2
16
3
        Unreviewed, rolling out r60068.
17
        Unreviewed, rolling out r60068.
- WebCore/platform/graphics/GraphicsContext.cpp +31 lines
Lines 441-446 void GraphicsContext::drawTiledImage(Ima WebCore/platform/graphics/GraphicsContext.cpp_sec1
441
    if (useLowQualityScale)
441
    if (useLowQualityScale)
442
        restore();
442
        restore();
443
}
443
}
444
    
445
void GraphicsContext::drawTiledImage(Image* image, ColorSpace styleColorSpace, const FloatRect& rect, const FloatPoint& srcPoint, const IntSize& tileSize, CompositeOperator op, bool useLowQualityScale)
446
{
447
    if (paintingDisabled() || !image)
448
        return;
449
    if (useLowQualityScale) {
450
        save();
451
        setImageInterpolationQuality(InterpolationLow);
452
    }
453
    image->drawTiled(this, rect, srcPoint, tileSize, styleColorSpace, op);
454
    if (useLowQualityScale)
455
        restore();
456
}
457
458
void GraphicsContext::drawTiledImage(Image* image, ColorSpace styleColorSpace, const FloatRect& dest, const FloatRect& srcRect, Image::TileRule hRule, Image::TileRule vRule, CompositeOperator op, bool useLowQualityScale)
459
{
460
    if (paintingDisabled() || !image)
461
        return;
462
    
463
    if (useLowQualityScale) {
464
        save();
465
        setImageInterpolationQuality(InterpolationLow);
466
    }
467
    if (hRule == Image::StretchTile && vRule == Image::StretchTile)
468
        // Just do a scale.
469
        drawImage(image, styleColorSpace, dest, srcRect, op);
470
    else
471
        image->drawTiled(this, dest, srcRect, hRule, vRule, styleColorSpace, op);
472
    if (useLowQualityScale)
473
        restore();
474
}
444
475
445
void GraphicsContext::addRoundedRectClip(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight,
476
void GraphicsContext::addRoundedRectClip(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight,
446
    const IntSize& bottomLeft, const IntSize& bottomRight)
477
    const IntSize& bottomLeft, const IntSize& bottomRight)
- WebCore/platform/graphics/GraphicsContext.h +5 lines
Lines 229-234 namespace WebCore { WebCore/platform/graphics/GraphicsContext.h_sec1
229
        void drawTiledImage(Image*, ColorSpace styleColorSpace, const IntRect& destRect, const IntRect& srcRect,
229
        void drawTiledImage(Image*, ColorSpace styleColorSpace, const IntRect& destRect, const IntRect& srcRect,
230
                            Image::TileRule hRule = Image::StretchTile, Image::TileRule vRule = Image::StretchTile,
230
                            Image::TileRule hRule = Image::StretchTile, Image::TileRule vRule = Image::StretchTile,
231
                            CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
231
                            CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
232
        void drawTiledImage(Image*, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatPoint& srcPoint, const IntSize& tileSize,
233
                            CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
234
        void drawTiledImage(Image*, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect,
235
                            Image::TileRule hRule = Image::StretchTile, Image::TileRule vRule = Image::StretchTile,
236
                            CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
232
237
233
        void setImageInterpolationQuality(InterpolationQuality);
238
        void setImageInterpolationQuality(InterpolationQuality);
234
        InterpolationQuality imageInterpolationQuality() const;
239
        InterpolationQuality imageInterpolationQuality() const;
- WebCore/rendering/RenderBoxModelObject.cpp -22 / +18 lines
Lines 865-884 bool RenderBoxModelObject::paintNinePiec WebCore/rendering/RenderBoxModelObject.cpp_sec1
865
        // The top left corner rect is (tx, ty, leftWidth, topWidth)
865
        // The top left corner rect is (tx, ty, leftWidth, topWidth)
866
        // The rect to use from within the image is obtained from our slice, and is (0, 0, leftSlice, topSlice)
866
        // The rect to use from within the image is obtained from our slice, and is (0, 0, leftSlice, topSlice)
867
        if (drawTop)
867
        if (drawTop)
868
            graphicsContext->drawImage(image, colorSpace, IntRect(tx, ty, leftWidth, topWidth),
868
            graphicsContext->drawImage(image, colorSpace, graphicsContext->roundToDevicePixels(FloatRect(tx, ty, leftWidth, topWidth)),
869
                                       IntRect(0, 0, leftSlice, topSlice), op);
869
                                       FloatRect(0, 0, leftSlice, topSlice), op);
870
870
871
        // The bottom left corner rect is (tx, ty + h - bottomWidth, leftWidth, bottomWidth)
871
        // The bottom left corner rect is (tx, ty + h - bottomWidth, leftWidth, bottomWidth)
872
        // The rect to use from within the image is (0, imageHeight - bottomSlice, leftSlice, botomSlice)
872
        // The rect to use from within the image is (0, imageHeight - bottomSlice, leftSlice, botomSlice)
873
        if (drawBottom)
873
        if (drawBottom)
874
            graphicsContext->drawImage(image, colorSpace, IntRect(tx, ty + h - bottomWidth, leftWidth, bottomWidth),
874
            graphicsContext->drawImage(image, colorSpace, graphicsContext->roundToDevicePixels(FloatRect(tx, ty + h - bottomWidth, leftWidth, bottomWidth)),
875
                                       IntRect(0, imageHeight - bottomSlice, leftSlice, bottomSlice), op);
875
                                       FloatRect(0, imageHeight - bottomSlice, leftSlice, bottomSlice), op);
876
876
877
        // Paint the left edge.
877
        // Paint the left edge.
878
        // Have to scale and tile into the border rect.
878
        // Have to scale and tile into the border rect.
879
        graphicsContext->drawTiledImage(image, colorSpace, IntRect(tx, ty + topWidth, leftWidth,
879
        graphicsContext->drawTiledImage(image, colorSpace, graphicsContext->roundToDevicePixels(FloatRect(tx, ty + topWidth, leftWidth, h - topWidth - bottomWidth)),
880
                                        h - topWidth - bottomWidth),
880
                                        FloatRect(0, topSlice, leftSlice, imageHeight - topSlice - bottomSlice),
881
                                        IntRect(0, topSlice, leftSlice, imageHeight - topSlice - bottomSlice),
882
                                        Image::StretchTile, (Image::TileRule)vRule, op);
881
                                        Image::StretchTile, (Image::TileRule)vRule, op);
883
    }
882
    }
884
883
Lines 887-926 bool RenderBoxModelObject::paintNinePiec WebCore/rendering/RenderBoxModelObject.cpp_sec2
887
        // The top right corner rect is (tx + w - rightWidth, ty, rightWidth, topWidth)
886
        // The top right corner rect is (tx + w - rightWidth, ty, rightWidth, topWidth)
888
        // The rect to use from within the image is obtained from our slice, and is (imageWidth - rightSlice, 0, rightSlice, topSlice)
887
        // The rect to use from within the image is obtained from our slice, and is (imageWidth - rightSlice, 0, rightSlice, topSlice)
889
        if (drawTop)
888
        if (drawTop)
890
            graphicsContext->drawImage(image, colorSpace, IntRect(tx + w - rightWidth, ty, rightWidth, topWidth),
889
            graphicsContext->drawImage(image, colorSpace, graphicsContext->roundToDevicePixels(FloatRect(tx + w - rightWidth, ty, rightWidth, topWidth)),
891
                                       IntRect(imageWidth - rightSlice, 0, rightSlice, topSlice), op);
890
                                       FloatRect(imageWidth - rightSlice, 0, rightSlice, topSlice), op);
892
891
893
        // The bottom right corner rect is (tx + w - rightWidth, ty + h - bottomWidth, rightWidth, bottomWidth)
892
        // The bottom right corner rect is (tx + w - rightWidth, ty + h - bottomWidth, rightWidth, bottomWidth)
894
        // The rect to use from within the image is (imageWidth - rightSlice, imageHeight - bottomSlice, rightSlice, bottomSlice)
893
        // The rect to use from within the image is (imageWidth - rightSlice, imageHeight - bottomSlice, rightSlice, bottomSlice)
895
        if (drawBottom)
894
        if (drawBottom)
896
            graphicsContext->drawImage(image, colorSpace, IntRect(tx + w - rightWidth, ty + h - bottomWidth, rightWidth, bottomWidth),
895
            graphicsContext->drawImage(image, colorSpace, graphicsContext->roundToDevicePixels(FloatRect(tx + w - rightWidth, ty + h - bottomWidth, rightWidth, bottomWidth)),
897
                                       IntRect(imageWidth - rightSlice, imageHeight - bottomSlice, rightSlice, bottomSlice), op);
896
                                       FloatRect(imageWidth - rightSlice, imageHeight - bottomSlice, rightSlice, bottomSlice), op);
898
897
899
        // Paint the right edge.
898
        // Paint the right edge.
900
        graphicsContext->drawTiledImage(image, colorSpace, IntRect(tx + w - rightWidth, ty + topWidth, rightWidth,
899
        graphicsContext->drawTiledImage(image, colorSpace, graphicsContext->roundToDevicePixels(FloatRect(tx + w - rightWidth, ty + topWidth, rightWidth, h - topWidth - bottomWidth)),
901
                                        h - topWidth - bottomWidth),
900
                                        FloatRect(imageWidth - rightSlice, topSlice, rightSlice, imageHeight - topSlice - bottomSlice),
902
                                        IntRect(imageWidth - rightSlice, topSlice, rightSlice, imageHeight - topSlice - bottomSlice),
903
                                        Image::StretchTile, (Image::TileRule)vRule, op);
901
                                        Image::StretchTile, (Image::TileRule)vRule, op);
904
    }
902
    }
905
903
906
    // Paint the top edge.
904
    // Paint the top edge.
907
    if (drawTop)
905
    if (drawTop)
908
        graphicsContext->drawTiledImage(image, colorSpace, IntRect(tx + leftWidth, ty, w - leftWidth - rightWidth, topWidth),
906
        graphicsContext->drawTiledImage(image, colorSpace, graphicsContext->roundToDevicePixels(FloatRect(tx + leftWidth, ty, w - leftWidth - rightWidth, topWidth)),
909
                                        IntRect(leftSlice, 0, imageWidth - rightSlice - leftSlice, topSlice),
907
                                        FloatRect(leftSlice, 0, imageWidth - rightSlice - leftSlice, topSlice),
910
                                        (Image::TileRule)hRule, Image::StretchTile, op);
908
                                        (Image::TileRule)hRule, Image::StretchTile, op);
911
909
912
    // Paint the bottom edge.
910
    // Paint the bottom edge.
913
    if (drawBottom)
911
    if (drawBottom)
914
        graphicsContext->drawTiledImage(image, colorSpace, IntRect(tx + leftWidth, ty + h - bottomWidth,
912
        graphicsContext->drawTiledImage(image, colorSpace, graphicsContext->roundToDevicePixels(FloatRect(tx + leftWidth, ty + h - bottomWidth, w - leftWidth - rightWidth, bottomWidth)),
915
                                        w - leftWidth - rightWidth, bottomWidth),
913
                                        FloatRect(leftSlice, imageHeight - bottomSlice, imageWidth - rightSlice - leftSlice, bottomSlice),
916
                                        IntRect(leftSlice, imageHeight - bottomSlice, imageWidth - rightSlice - leftSlice, bottomSlice),
917
                                        (Image::TileRule)hRule, Image::StretchTile, op);
914
                                        (Image::TileRule)hRule, Image::StretchTile, op);
918
915
919
    // Paint the middle.
916
    // Paint the middle.
920
    if (drawMiddle)
917
    if (drawMiddle)
921
        graphicsContext->drawTiledImage(image, colorSpace, IntRect(tx + leftWidth, ty + topWidth, w - leftWidth - rightWidth,
918
        graphicsContext->drawTiledImage(image, colorSpace, graphicsContext->roundToDevicePixels(FloatRect(tx + leftWidth, ty + topWidth, w - leftWidth - rightWidth, h - topWidth - bottomWidth)),
922
                                        h - topWidth - bottomWidth),
919
                                        FloatRect(leftSlice, topSlice, imageWidth - rightSlice - leftSlice, imageHeight - topSlice - bottomSlice),
923
                                        IntRect(leftSlice, topSlice, imageWidth - rightSlice - leftSlice, imageHeight - topSlice - bottomSlice),
924
                                        (Image::TileRule)hRule, (Image::TileRule)vRule, op);
920
                                        (Image::TileRule)hRule, (Image::TileRule)vRule, op);
925
921
926
    return true;
922
    return true;

Return to Bug 15720