Subpixel rendering: Move background images to device pixel boundaries.
https://bugs.webkit.org/show_bug.cgi?id=131144

Reviewed by Simon Fraser.

Replace integral snapping with device pixel snapping.
Background image geometry calculation uses LayoutUnits and we snap to device pixels right before painting.

Source/WebCore:

Tests: fast/backgrounds/hidpi-bitmap-background-on-subpixel-position.html
       fast/backgrounds/hidpi-bitmap-background-origin-on-subpixel-position.html
       fast/backgrounds/hidpi-bitmap-background-repeat-on-subpixel-position.html
       fast/backgrounds/hidpi-generated-gradient-background-on-subpixel-position.html

* platform/graphics/GraphicsLayer.h:
(WebCore::GraphicsLayer::setContentsTilePhase):
(WebCore::GraphicsLayer::contentsTilePhase):
(WebCore::GraphicsLayer::setContentsTileSize):
(WebCore::GraphicsLayer::contentsTileSize):
* platform/graphics/texmap/TextureMapperLayer.cpp:
(WebCore::TextureMapperLayer::setContentsTileSize):
(WebCore::TextureMapperLayer::setContentsTilePhase):
* platform/graphics/texmap/TextureMapperLayer.h:
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
(WebCore::CoordinatedGraphicsLayer::setContentsTileSize):
(WebCore::CoordinatedGraphicsLayer::setContentsTilePhase):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
* platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h:
* rendering/RenderBox.cpp:
(WebCore::RenderBox::repaintLayerRectsForImage):
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintFillLayerExtended):
(WebCore::resolveWidthForRatio):
(WebCore::resolveHeightForRatio):
(WebCore::resolveAgainstIntrinsicWidthOrHeightAndRatio):
(WebCore::resolveAgainstIntrinsicRatio):
(WebCore::RenderBoxModelObject::calculateImageIntrinsicDimensions):
(WebCore::RenderBoxModelObject::calculateFillTileSize):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::setNoRepeatX):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::setNoRepeatY):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::useFixedAttachment):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::clip):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::relativePhase):
(WebCore::getSpace):
(WebCore::RenderBoxModelObject::pixelSnapBackgroundImageGeometryForPainting):
(WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry):
(WebCore::RenderBoxModelObject::getGeometryForBackgroundImage):
(WebCore::RenderBoxModelObject::paintNinePieceImage):
(WebCore::applySubPixelHeuristicForTileSize): Deleted.
* rendering/RenderBoxModelObject.h:
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::destOrigin):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::setDestOrigin):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::destRect):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::setDestRect):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::phase):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::setPhase):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::tileSize):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::setTileSize):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::spaceSize):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::setSpaceSize):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::setPhaseX):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::setPhaseY):
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateDirectlyCompositedBackgroundImage):
* rendering/shapes/ShapeOutsideInfo.cpp:
(WebCore::getShapeImageAndRect):

LayoutTests:

* css3/background/background-repeat-round-auto1-expected.html:
* css3/background/background-repeat-round-auto1.html:
* css3/background/background-repeat-round-auto2-expected.html:
* css3/background/background-repeat-round-auto2.html:
* css3/background/background-repeat-round-border-expected.html:
* css3/background/background-repeat-round-border.html:
* css3/background/background-repeat-round-content-expected.html:
* css3/background/background-repeat-round-content.html:
* css3/background/background-repeat-space-content-expected.html:
* css3/background/background-repeat-space-content.html:
* css3/background/background-repeat-space-padding-expected.html:
* css3/background/background-repeat-space-padding.html:
* css3/masking/mask-repeat-round-auto1-expected.html:
* css3/masking/mask-repeat-round-auto1.html:
* css3/masking/mask-repeat-round-auto2-expected.html:
* css3/masking/mask-repeat-round-auto2.html:
* css3/masking/mask-repeat-round-border-expected.html:
* css3/masking/mask-repeat-round-border.html:
* css3/masking/mask-repeat-round-content-expected.html:
* css3/masking/mask-repeat-round-content.html:
* css3/masking/mask-repeat-space-content-expected.html:
* css3/masking/mask-repeat-space-content.html:
* css3/masking/mask-repeat-space-padding-expected.html:
* css3/masking/mask-repeat-space-padding.html:
* fast/backgrounds/hidpi-bitmap-background-on-subpixel-position-expected.html: Added.
* fast/backgrounds/hidpi-bitmap-background-on-subpixel-position.html: Added.
* fast/backgrounds/hidpi-bitmap-background-origin-on-subpixel-position-expected.html: Added.
* fast/backgrounds/hidpi-bitmap-background-origin-on-subpixel-position.html: Added.
* fast/backgrounds/hidpi-bitmap-background-repeat-on-subpixel-position-expected.html: Added.
* fast/backgrounds/hidpi-bitmap-background-repeat-on-subpixel-position.html: Added.
* fast/backgrounds/hidpi-generated-gradient-background-on-subpixel-position-expected.html: Added.
* fast/backgrounds/hidpi-generated-gradient-background-on-subpixel-position.html: Added.
* fast/backgrounds/resources/black25x25.png: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166784 268f45cc-cd09-0410-ab3c-d52691b4dbfc
46 files changed