Changeset 165341 in webkit


Ignore:
Timestamp:
Mar 8, 2014, 4:14:00 PM (11 years ago)
Author:
Alan Bujtas
Message:

Subpixel rendering: Simple compositing container layer (isSimpleContainerCompositingLayer) paints to wrong position.
https://bugs.webkit.org/show_bug.cgi?id=129861

Reviewed by Simon Fraser.

This patch ensures that both the simple and non-simple cases paint to the same position.
Simple compositing container layer codepath needs to take the fractional device pixel offset
into account when painting. Without the fractional value, the final paint rounding could push the
paint offset to a different position.
retina example:
compositing top-left: 0px 0px.
fractional offset: 0.3px 0.3px
painting coords without offseting: 0px 0px

with offseting: 0.5px 0.5px

Source/WebCore:

Tests: compositing/hidpi-simple-container-layer-on-device-pixel.html

  • WebCore.exp.in:
  • platform/graphics/GraphicsLayer.h:

(WebCore::GraphicsLayer::contentsRect):
(WebCore::GraphicsLayer::setContentsRect):
(WebCore::GraphicsLayer::contentsClippingRect):
(WebCore::GraphicsLayer::setContentsClippingRect):

  • platform/graphics/ca/GraphicsLayerCA.cpp:

(WebCore::GraphicsLayerCA::setContentsRect):
(WebCore::GraphicsLayerCA::setContentsClippingRect):
(WebCore::GraphicsLayerCA::updateContentsRects):

  • platform/graphics/ca/GraphicsLayerCA.h:
  • rendering/RenderLayerBacking.cpp:

(WebCore::RenderLayerBacking::updateGraphicsLayerGeometry):
(WebCore::RenderLayerBacking::updateDirectlyCompositedBackgroundColor):
(WebCore::RenderLayerBacking::updateDirectlyCompositedBackgroundImage):
(WebCore::RenderLayerBacking::contentOffsetInCompostingLayer):
(WebCore::RenderLayerBacking::backgroundBoxForPainting):

  • rendering/RenderLayerBacking.h:

LayoutTests:

  • compositing/hidpi-simple-container-layer-on-device-pixel-expected.html: Added.
  • compositing/hidpi-simple-container-layer-on-device-pixel.html: Added.
Location:
trunk
Files:
2 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r165340 r165341  
     12014-03-08  Zalan Bujtas  <zalan@apple.com>
     2
     3        Subpixel rendering: Simple compositing container layer (isSimpleContainerCompositingLayer) paints to wrong position.
     4        https://bugs.webkit.org/show_bug.cgi?id=129861
     5
     6        Reviewed by Simon Fraser.
     7
     8        This patch ensures that both the simple and non-simple cases paint to the same position.
     9        Simple compositing container layer codepath needs to take the fractional device pixel offset
     10        into account when painting. Without the fractional value, the final paint rounding could push the
     11        paint offset to a different position.
     12        retina example:
     13        compositing top-left: 0px 0px.
     14        fractional offset: 0.3px 0.3px
     15        painting coords without offseting: 0px 0px
     16                           with offseting: 0.5px 0.5px
     17
     18        * compositing/hidpi-simple-container-layer-on-device-pixel-expected.html: Added.
     19        * compositing/hidpi-simple-container-layer-on-device-pixel.html: Added.
     20
    1212014-03-08  Martin Robinson  <mrobinson@igalia.com>
    222
  • trunk/Source/WebCore/ChangeLog

    r165339 r165341  
     12014-03-08  Zalan Bujtas  <zalan@apple.com>
     2
     3        Subpixel rendering: Simple compositing container layer (isSimpleContainerCompositingLayer) paints to wrong position.
     4        https://bugs.webkit.org/show_bug.cgi?id=129861
     5
     6        Reviewed by Simon Fraser.
     7
     8        This patch ensures that both the simple and non-simple cases paint to the same position.
     9        Simple compositing container layer codepath needs to take the fractional device pixel offset
     10        into account when painting. Without the fractional value, the final paint rounding could push the
     11        paint offset to a different position.
     12        retina example:
     13        compositing top-left: 0px 0px.
     14        fractional offset: 0.3px 0.3px
     15        painting coords without offseting: 0px 0px
     16                           with offseting: 0.5px 0.5px
     17
     18        Tests: compositing/hidpi-simple-container-layer-on-device-pixel.html
     19
     20        * WebCore.exp.in:
     21        * platform/graphics/GraphicsLayer.h:
     22        (WebCore::GraphicsLayer::contentsRect):
     23        (WebCore::GraphicsLayer::setContentsRect):
     24        (WebCore::GraphicsLayer::contentsClippingRect):
     25        (WebCore::GraphicsLayer::setContentsClippingRect):
     26        * platform/graphics/ca/GraphicsLayerCA.cpp:
     27        (WebCore::GraphicsLayerCA::setContentsRect):
     28        (WebCore::GraphicsLayerCA::setContentsClippingRect):
     29        (WebCore::GraphicsLayerCA::updateContentsRects):
     30        * platform/graphics/ca/GraphicsLayerCA.h:
     31        * rendering/RenderLayerBacking.cpp:
     32        (WebCore::RenderLayerBacking::updateGraphicsLayerGeometry):
     33        (WebCore::RenderLayerBacking::updateDirectlyCompositedBackgroundColor):
     34        (WebCore::RenderLayerBacking::updateDirectlyCompositedBackgroundImage):
     35        (WebCore::RenderLayerBacking::contentOffsetInCompostingLayer):
     36        (WebCore::RenderLayerBacking::backgroundBoxForPainting):
     37        * rendering/RenderLayerBacking.h:
     38
    1392014-03-08  Oliver Hunt  <oliver@apple.com>
    240
  • trunk/Source/WebCore/WebCore.exp.in

    r165327 r165341  
    537537__ZN7WebCore15GraphicsLayerCA15removeAnimationERKN3WTF6StringE
    538538__ZN7WebCore15GraphicsLayerCA15setBoundsOriginERKNS_10FloatPointE
    539 __ZN7WebCore15GraphicsLayerCA15setContentsRectERKNS_7IntRectE
     539__ZN7WebCore15GraphicsLayerCA15setContentsRectERKNS_9FloatRectE
    540540__ZN7WebCore15GraphicsLayerCA15setDrawsContentEb
    541541__ZN7WebCore15GraphicsLayerCA15setNeedsDisplayEv
     
    563563__ZN7WebCore15GraphicsLayerCA21setNeedsDisplayInRectERKNS_9FloatRectENS_13GraphicsLayer17ShouldClipToLayerE
    564564__ZN7WebCore15GraphicsLayerCA21setShowRepaintCounterEb
    565 __ZN7WebCore15GraphicsLayerCA23setContentsClippingRectERKNS_7IntRectE
     565__ZN7WebCore15GraphicsLayerCA23setContentsClippingRectERKNS_9FloatRectE
    566566__ZN7WebCore15GraphicsLayerCA23setContentsNeedsDisplayEv
    567567__ZN7WebCore15GraphicsLayerCA23setContentsToSolidColorERKNS_5ColorE
  • trunk/Source/WebCore/platform/graphics/GraphicsLayer.h

    r164415 r165341  
    3131#include "FloatPoint.h"
    3232#include "FloatPoint3D.h"
     33#include "FloatRect.h"
    3334#include "FloatSize.h"
    3435#include "GraphicsLayerClient.h"
     
    6061namespace WebCore {
    6162
    62 class FloatRect;
    6363class GraphicsContext;
    6464class GraphicsLayerFactory;
     
    377377
    378378    // Set that the position/size of the contents (image or video).
    379     IntRect contentsRect() const { return m_contentsRect; }
    380     virtual void setContentsRect(const IntRect& r) { m_contentsRect = r; }
    381 
    382     IntRect contentsClippingRect() const { return m_contentsClippingRect; }
    383     virtual void setContentsClippingRect(const IntRect& r) { m_contentsClippingRect = r; }
     379    FloatRect contentsRect() const { return m_contentsRect; }
     380    virtual void setContentsRect(const FloatRect& r) { m_contentsRect = r; }
     381
     382    FloatRect contentsClippingRect() const { return m_contentsClippingRect; }
     383    virtual void setContentsClippingRect(const FloatRect& r) { m_contentsClippingRect = r; }
    384384
    385385    // Transitions are identified by a special animation name that cannot clash with a keyframe identifier.
     
    605605    FloatPoint m_replicatedLayerPosition; // For a replica layer, the position of the replica.
    606606
    607     IntRect m_contentsRect;
    608     IntRect m_contentsClippingRect;
     607    FloatRect m_contentsRect;
     608    FloatRect m_contentsClippingRect;
    609609    IntPoint m_contentsTilePhase;
    610610    IntSize m_contentsTileSize;
  • trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp

    r164412 r165341  
    765765}
    766766
    767 void GraphicsLayerCA::setContentsRect(const IntRect& rect)
     767void GraphicsLayerCA::setContentsRect(const FloatRect& rect)
    768768{
    769769    if (rect == m_contentsRect)
     
    774774}
    775775
    776 void GraphicsLayerCA::setContentsClippingRect(const IntRect& rect)
     776void GraphicsLayerCA::setContentsClippingRect(const FloatRect& rect)
    777777{
    778778    if (rect == m_contentsClippingRect)
     
    20392039        clippingBounds.setSize(m_contentsClippingRect.size());
    20402040
    2041         contentOrigin = toLayoutPoint(m_contentsRect.location() - m_contentsClippingRect.location());
     2041        contentOrigin = FloatPoint(m_contentsRect.location() - m_contentsClippingRect.location());
    20422042
    20432043        m_contentsClippingLayer->setPosition(clippingOrigin);
  • trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h

    r164412 r165341  
    112112    virtual void setContentsNeedsDisplay();
    113113   
    114     virtual void setContentsRect(const IntRect&);
    115     virtual void setContentsClippingRect(const IntRect&) override;
     114    virtual void setContentsRect(const FloatRect&) override;
     115    virtual void setContentsClippingRect(const FloatRect&) override;
    116116   
    117117    virtual void suspendAnimations(double time);
  • trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp

    r161570 r165341  
    329329/* \reimp (GraphicsLayer.h)
    330330*/
    331 void GraphicsLayerTextureMapper::setContentsRect(const IntRect& value)
     331void GraphicsLayerTextureMapper::setContentsRect(const FloatRect& value)
    332332{
    333333    if (value == contentsRect())
  • trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h

    r162139 r165341  
    6464    virtual void setBackfaceVisibility(bool b);
    6565    virtual void setOpacity(float opacity);
    66     virtual void setContentsRect(const IntRect& r);
     66    virtual void setContentsRect(const FloatRect&);
    6767    virtual void setReplicatedByLayer(GraphicsLayer*);
    6868    virtual void setContentsToImage(Image*);
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp

    r163079 r165341  
    566566}
    567567
    568 void TextureMapperLayer::setContentsRect(const IntRect& contentsRect)
     568void TextureMapperLayer::setContentsRect(const FloatRect& contentsRect)
    569569{
    570570    if (contentsRect == m_state.contentsRect)
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h

    r163079 r165341  
    8787    void setTransform(const TransformationMatrix&);
    8888    void setChildrenTransform(const TransformationMatrix&);
    89     void setContentsRect(const IntRect&);
     89    void setContentsRect(const FloatRect&);
    9090    void setMasksToBounds(bool);
    9191    void setDrawsContent(bool);
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp

    r161570 r165341  
    335335}
    336336
    337 void CoordinatedGraphicsLayer::setContentsRect(const IntRect& r)
     337void CoordinatedGraphicsLayer::setContentsRect(const FloatRect& r)
    338338{
    339339    if (contentsRect() == r)
     
    823823{
    824824    ASSERT(m_coordinatedImageBacking);
    825     return tiledBackingStoreVisibleRect().intersects(contentsRect());
     825    return tiledBackingStoreVisibleRect().intersects(IntRect(contentsRect()));
    826826}
    827827
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h

    r162139 r165341  
    8585    virtual void setBackfaceVisibility(bool) override;
    8686    virtual void setOpacity(float) override;
    87     virtual void setContentsRect(const IntRect&) override;
     87    virtual void setContentsRect(const FloatRect&) override;
    8888    virtual void setContentsTilePhase(const IntPoint&) override;
    8989    virtual void setContentsTileSize(const IntSize&) override;
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h

    r162644 r165341  
    142142    TransformationMatrix transform;
    143143    TransformationMatrix childrenTransform;
    144     IntRect contentsRect;
     144    FloatRect contentsRect;
    145145    IntPoint contentsTilePhase;
    146146    IntSize contentsTileSize;
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r165190 r165341  
    15571557    // An unset (invalid) color will remove the solid color.
    15581558    m_graphicsLayer->setContentsToSolidColor(backgroundColor);
    1559     IntRect contentsRect = backgroundBox();
     1559    FloatRect contentsRect = backgroundBoxForPainting();
    15601560    m_graphicsLayer->setContentsRect(contentsRect);
    15611561    m_graphicsLayer->setContentsClippingRect(contentsRect);
     
    16101610    }
    16111611
    1612     IntRect destRect = backgroundBox();
     1612    IntRect destRect = pixelSnappedIntRect(LayoutRect(backgroundBoxForPainting()));
    16131613    IntPoint phase;
    16141614    IntSize tileSize;
     
    19461946LayoutSize RenderLayerBacking::contentOffsetInCompostingLayer() const
    19471947{
    1948     return LayoutSize(-m_compositedBounds.x(), -m_compositedBounds.y());
     1948    return LayoutSize(-m_compositedBounds.x(), -m_compositedBounds.y()) + m_devicePixelFractionFromRenderer;
    19491949}
    19501950
     
    19881988}
    19891989
    1990 IntRect RenderLayerBacking::backgroundBox() const
     1990FloatRect RenderLayerBacking::backgroundBoxForPainting() const
    19911991{
    19921992    if (!renderer().isBox())
    1993         return IntRect();
     1993        return FloatRect();
    19941994
    19951995    LayoutRect backgroundBox = backgroundRectForBox(toRenderBox(renderer()));
    19961996    backgroundBox.move(contentOffsetInCompostingLayer());
    1997     return pixelSnappedIntRect(backgroundBox);
     1997    return pixelSnappedForPainting(backgroundBox, deviceScaleFactor());
    19981998}
    19991999
  • trunk/Source/WebCore/rendering/RenderLayerBacking.h

    r164759 r165341  
    195195
    196196    LayoutRect contentsBox() const;
    197     IntRect backgroundBox() const;
    198197   
    199198    // For informative purposes only.
     
    216215
    217216private:
     217    FloatRect backgroundBoxForPainting() const;
     218
    218219    void createPrimaryGraphicsLayer();
    219220    void destroyGraphicsLayers();
Note: See TracChangeset for help on using the changeset viewer.