WebCore/ChangeLog

 12010-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
1152010-05-24 Sheriff Bot <webkit.review.bot@gmail.com>
216
317 Unreviewed, rolling out r60068.
60075

WebCore/platform/graphics/GraphicsContext.cpp

@@void GraphicsContext::drawTiledImage(Ima
441441 if (useLowQualityScale)
442442 restore();
443443}
 444
 445void 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
 458void 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}
444475
445476void GraphicsContext::addRoundedRectClip(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight,
446477 const IntSize& bottomLeft, const IntSize& bottomRight)
60073

WebCore/platform/graphics/GraphicsContext.h

@@namespace WebCore {
229229 void drawTiledImage(Image*, ColorSpace styleColorSpace, const IntRect& destRect, const IntRect& srcRect,
230230 Image::TileRule hRule = Image::StretchTile, Image::TileRule vRule = Image::StretchTile,
231231 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);
232237
233238 void setImageInterpolationQuality(InterpolationQuality);
234239 InterpolationQuality imageInterpolationQuality() const;
60073

WebCore/rendering/RenderBoxModelObject.cpp

@@bool RenderBoxModelObject::paintNinePiec
865865 // The top left corner rect is (tx, ty, leftWidth, topWidth)
866866 // The rect to use from within the image is obtained from our slice, and is (0, 0, leftSlice, topSlice)
867867 if (drawTop)
868  graphicsContext->drawImage(image, colorSpace, IntRect(tx, ty, leftWidth, topWidth),
869  IntRect(0, 0, leftSlice, topSlice), op);
 868 graphicsContext->drawImage(image, colorSpace, graphicsContext->roundToDevicePixels(FloatRect(tx, ty, leftWidth, topWidth)),
 869 FloatRect(0, 0, leftSlice, topSlice), op);
870870
871871 // The bottom left corner rect is (tx, ty + h - bottomWidth, leftWidth, bottomWidth)
872872 // The rect to use from within the image is (0, imageHeight - bottomSlice, leftSlice, botomSlice)
873873 if (drawBottom)
874  graphicsContext->drawImage(image, colorSpace, IntRect(tx, ty + h - bottomWidth, leftWidth, bottomWidth),
875  IntRect(0, imageHeight - bottomSlice, leftSlice, bottomSlice), op);
 874 graphicsContext->drawImage(image, colorSpace, graphicsContext->roundToDevicePixels(FloatRect(tx, ty + h - bottomWidth, leftWidth, bottomWidth)),
 875 FloatRect(0, imageHeight - bottomSlice, leftSlice, bottomSlice), op);
876876
877877 // Paint the left edge.
878878 // Have to scale and tile into the border rect.
879  graphicsContext->drawTiledImage(image, colorSpace, IntRect(tx, ty + topWidth, leftWidth,
880  h - topWidth - bottomWidth),
881  IntRect(0, topSlice, leftSlice, imageHeight - topSlice - bottomSlice),
 879 graphicsContext->drawTiledImage(image, colorSpace, graphicsContext->roundToDevicePixels(FloatRect(tx, ty + topWidth, leftWidth, h - topWidth - bottomWidth)),
 880 FloatRect(0, topSlice, leftSlice, imageHeight - topSlice - bottomSlice),
882881 Image::StretchTile, (Image::TileRule)vRule, op);
883882 }
884883

@@bool RenderBoxModelObject::paintNinePiec
887886 // The top right corner rect is (tx + w - rightWidth, ty, rightWidth, topWidth)
888887 // The rect to use from within the image is obtained from our slice, and is (imageWidth - rightSlice, 0, rightSlice, topSlice)
889888 if (drawTop)
890  graphicsContext->drawImage(image, colorSpace, IntRect(tx + w - rightWidth, ty, rightWidth, topWidth),
891  IntRect(imageWidth - rightSlice, 0, rightSlice, topSlice), op);
 889 graphicsContext->drawImage(image, colorSpace, graphicsContext->roundToDevicePixels(FloatRect(tx + w - rightWidth, ty, rightWidth, topWidth)),
 890 FloatRect(imageWidth - rightSlice, 0, rightSlice, topSlice), op);
892891
893892 // The bottom right corner rect is (tx + w - rightWidth, ty + h - bottomWidth, rightWidth, bottomWidth)
894893 // The rect to use from within the image is (imageWidth - rightSlice, imageHeight - bottomSlice, rightSlice, bottomSlice)
895894 if (drawBottom)
896  graphicsContext->drawImage(image, colorSpace, IntRect(tx + w - rightWidth, ty + h - bottomWidth, rightWidth, bottomWidth),
897  IntRect(imageWidth - rightSlice, imageHeight - bottomSlice, rightSlice, bottomSlice), op);
 895 graphicsContext->drawImage(image, colorSpace, graphicsContext->roundToDevicePixels(FloatRect(tx + w - rightWidth, ty + h - bottomWidth, rightWidth, bottomWidth)),
 896 FloatRect(imageWidth - rightSlice, imageHeight - bottomSlice, rightSlice, bottomSlice), op);
898897
899898 // Paint the right edge.
900  graphicsContext->drawTiledImage(image, colorSpace, IntRect(tx + w - rightWidth, ty + topWidth, rightWidth,
901  h - topWidth - bottomWidth),
902  IntRect(imageWidth - rightSlice, topSlice, rightSlice, imageHeight - topSlice - bottomSlice),
 899 graphicsContext->drawTiledImage(image, colorSpace, graphicsContext->roundToDevicePixels(FloatRect(tx + w - rightWidth, ty + topWidth, rightWidth, h - topWidth - bottomWidth)),
 900 FloatRect(imageWidth - rightSlice, topSlice, rightSlice, imageHeight - topSlice - bottomSlice),
903901 Image::StretchTile, (Image::TileRule)vRule, op);
904902 }
905903
906904 // Paint the top edge.
907905 if (drawTop)
908  graphicsContext->drawTiledImage(image, colorSpace, IntRect(tx + leftWidth, ty, w - leftWidth - rightWidth, topWidth),
909  IntRect(leftSlice, 0, imageWidth - rightSlice - leftSlice, topSlice),
 906 graphicsContext->drawTiledImage(image, colorSpace, graphicsContext->roundToDevicePixels(FloatRect(tx + leftWidth, ty, w - leftWidth - rightWidth, topWidth)),
 907 FloatRect(leftSlice, 0, imageWidth - rightSlice - leftSlice, topSlice),
910908 (Image::TileRule)hRule, Image::StretchTile, op);
911909
912910 // Paint the bottom edge.
913911 if (drawBottom)
914  graphicsContext->drawTiledImage(image, colorSpace, IntRect(tx + leftWidth, ty + h - bottomWidth,
915  w - leftWidth - rightWidth, bottomWidth),
916  IntRect(leftSlice, imageHeight - bottomSlice, imageWidth - rightSlice - leftSlice, bottomSlice),
 912 graphicsContext->drawTiledImage(image, colorSpace, graphicsContext->roundToDevicePixels(FloatRect(tx + leftWidth, ty + h - bottomWidth, w - leftWidth - rightWidth, bottomWidth)),
 913 FloatRect(leftSlice, imageHeight - bottomSlice, imageWidth - rightSlice - leftSlice, bottomSlice),
917914 (Image::TileRule)hRule, Image::StretchTile, op);
918915
919916 // Paint the middle.
920917 if (drawMiddle)
921  graphicsContext->drawTiledImage(image, colorSpace, IntRect(tx + leftWidth, ty + topWidth, w - leftWidth - rightWidth,
922  h - topWidth - bottomWidth),
923  IntRect(leftSlice, topSlice, imageWidth - rightSlice - leftSlice, imageHeight - topSlice - bottomSlice),
 918 graphicsContext->drawTiledImage(image, colorSpace, graphicsContext->roundToDevicePixels(FloatRect(tx + leftWidth, ty + topWidth, w - leftWidth - rightWidth, h - topWidth - bottomWidth)),
 919 FloatRect(leftSlice, topSlice, imageWidth - rightSlice - leftSlice, imageHeight - topSlice - bottomSlice),
924920 (Image::TileRule)hRule, (Image::TileRule)vRule, op);
925921
926922 return true;
60073