Switch BackgroundImageGeometry's m_phase from LayoutPoint to LayoutSize.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Feb 2015 20:42:41 +0000 (20:42 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Feb 2015 20:42:41 +0000 (20:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=141972

Reviewed by Simon Fraser.

Image geometry's phase represents distance.

No change in functionality.

* WebCore.order:
* platform/graphics/GraphicsLayer.h:
(WebCore::GraphicsLayer::setContentsTilePhase):
(WebCore::GraphicsLayer::contentsTilePhase):
* platform/graphics/texmap/TextureMapperLayer.cpp:
(WebCore::TextureMapperLayer::computePatternTransformIfNeeded):
(WebCore::TextureMapperLayer::setContentsTilePhase):
* platform/graphics/texmap/TextureMapperLayer.h:
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
(WebCore::CoordinatedGraphicsLayer::setContentsTilePhase):
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintFillLayerExtended):
(WebCore::BackgroundImageGeometry::setNoRepeatX):
(WebCore::BackgroundImageGeometry::setNoRepeatY):
(WebCore::BackgroundImageGeometry::useFixedAttachment):
(WebCore::BackgroundImageGeometry::relativePhase):
(WebCore::RenderBoxModelObject::pixelSnapBackgroundImageGeometryForPainting):
(WebCore::RenderBoxModelObject::getGeometryForBackgroundImage):
* rendering/RenderBoxModelObject.h:
(WebCore::BackgroundImageGeometry::phase):
(WebCore::BackgroundImageGeometry::setPhase):
(WebCore::BackgroundImageGeometry::setPhaseX):
(WebCore::BackgroundImageGeometry::setPhaseY):
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::resetContentsRect):
(WebCore::RenderLayerBacking::updateDirectlyCompositedBackgroundImage):
* rendering/svg/RenderSVGResourceMasker.cpp:
(WebCore::RenderSVGResourceMasker::drawMaskForRenderer):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@180580 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.order
Source/WebCore/platform/graphics/GraphicsLayer.h
Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h
Source/WebCore/rendering/RenderBoxModelObject.cpp
Source/WebCore/rendering/RenderBoxModelObject.h
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp

index d32f3eb..1fc31df 100644 (file)
@@ -1,3 +1,43 @@
+2015-02-24  Zalan Bujtas  <zalan@apple.com>
+
+        Switch BackgroundImageGeometry's m_phase from LayoutPoint to LayoutSize.
+        https://bugs.webkit.org/show_bug.cgi?id=141972
+
+        Reviewed by Simon Fraser.
+
+        Image geometry's phase represents distance.
+
+        No change in functionality.
+
+        * WebCore.order:
+        * platform/graphics/GraphicsLayer.h:
+        (WebCore::GraphicsLayer::setContentsTilePhase):
+        (WebCore::GraphicsLayer::contentsTilePhase):
+        * platform/graphics/texmap/TextureMapperLayer.cpp:
+        (WebCore::TextureMapperLayer::computePatternTransformIfNeeded):
+        (WebCore::TextureMapperLayer::setContentsTilePhase):
+        * platform/graphics/texmap/TextureMapperLayer.h:
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
+        (WebCore::CoordinatedGraphicsLayer::setContentsTilePhase):
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::paintFillLayerExtended):
+        (WebCore::BackgroundImageGeometry::setNoRepeatX):
+        (WebCore::BackgroundImageGeometry::setNoRepeatY):
+        (WebCore::BackgroundImageGeometry::useFixedAttachment):
+        (WebCore::BackgroundImageGeometry::relativePhase):
+        (WebCore::RenderBoxModelObject::pixelSnapBackgroundImageGeometryForPainting):
+        (WebCore::RenderBoxModelObject::getGeometryForBackgroundImage):
+        * rendering/RenderBoxModelObject.h:
+        (WebCore::BackgroundImageGeometry::phase):
+        (WebCore::BackgroundImageGeometry::setPhase):
+        (WebCore::BackgroundImageGeometry::setPhaseX):
+        (WebCore::BackgroundImageGeometry::setPhaseY):
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::resetContentsRect):
+        (WebCore::RenderLayerBacking::updateDirectlyCompositedBackgroundImage):
+        * rendering/svg/RenderSVGResourceMasker.cpp:
+        (WebCore::RenderSVGResourceMasker::drawMaskForRenderer):
+
 2015-02-24  Andreas Kling  <akling@apple.com>
 
         [Mac] WebKit abandons overlay scrollbar CALayers.
index f10677b..5795d0e 100644 (file)
@@ -2864,7 +2864,7 @@ __ZNK7WebCore20RenderBoxModelObject10paddingTopEv
 __ZNK7WebCore20RenderBoxModelObject13paddingBottomEv
 __ZN7WebCore15GraphicsLayerCA15setContentsRectERKNS_7IntRectE
 __ZN7WebCore13GraphicsLayer19setContentsTileSizeERKNS_7IntSizeE
-__ZN7WebCore13GraphicsLayer20setContentsTilePhaseERKNS_8IntPointE
+__ZN7WebCore13GraphicsLayer20setContentsTilePhaseERKNS_9FloatSizeE
 __ZN7WebCore18RenderLayerBacking18updateDrawsContentEb
 __ZNK7WebCore18RenderLayerBacking22containsPaintedContentEv
 __ZN7WebCore18RenderLayerBacking23registerScrollingLayersEv
index e58bf24..cfea5eb 100644 (file)
@@ -361,8 +361,8 @@ public:
     virtual void setContentsNeedsDisplay() { };
 
     // The tile phase is relative to the GraphicsLayer bounds.
-    virtual void setContentsTilePhase(const FloatPoint& p) { m_contentsTilePhase = p; }
-    FloatPoint contentsTilePhase() const { return m_contentsTilePhase; }
+    virtual void setContentsTilePhase(const FloatSize& p) { m_contentsTilePhase = p; }
+    FloatSize contentsTilePhase() const { return m_contentsTilePhase; }
 
     virtual void setContentsTileSize(const FloatSize& s) { m_contentsTileSize = s; }
     FloatSize contentsTileSize() const { return m_contentsTileSize; }
@@ -599,7 +599,7 @@ protected:
     FloatRect m_contentsRect;
     FloatRoundedRect m_contentsClippingRect;
     FloatRoundedRect m_masksToBoundsRect;
-    FloatPoint m_contentsTilePhase;
+    FloatSize m_contentsTilePhase;
     FloatSize m_contentsTileSize;
 
     int m_repaintCount;
index 1593f6d..604f7af 100644 (file)
@@ -101,7 +101,7 @@ void TextureMapperLayer::computePatternTransformIfNeeded()
     m_patternTransformDirty = false;
     m_patternTransform =
         TransformationMatrix::rectToRect(FloatRect(FloatPoint::zero(), m_state.contentsTileSize), FloatRect(FloatPoint::zero(), m_state.contentsRect.size()))
-        .multiply(TransformationMatrix().translate(m_state.contentsTilePhase.x() / m_state.contentsRect.width(), m_state.contentsTilePhase.y() / m_state.contentsRect.height()));
+        .multiply(TransformationMatrix().translate(m_state.contentsTilePhase.width() / m_state.contentsRect.width(), m_state.contentsTilePhase.height() / m_state.contentsRect.height()));
 }
 
 void TextureMapperLayer::paintSelf(const TextureMapperPaintOptions& options)
@@ -554,7 +554,7 @@ void TextureMapperLayer::setContentsTileSize(const FloatSize& size)
     m_patternTransformDirty = true;
 }
 
-void TextureMapperLayer::setContentsTilePhase(const FloatPoint& phase)
+void TextureMapperLayer::setContentsTilePhase(const FloatSize& phase)
 {
     if (phase == m_state.contentsTilePhase)
         return;
index 5bf783d..2e76d7c 100644 (file)
@@ -102,7 +102,7 @@ public:
     void setOpacity(float);
     void setSolidColor(const Color&);
     void setContentsTileSize(const FloatSize&);
-    void setContentsTilePhase(const FloatPoint&);
+    void setContentsTilePhase(const FloatSize&);
     void setFilters(const FilterOperations&);
 
     bool hasFilters() const
@@ -209,7 +209,7 @@ private:
         float opacity;
         FloatRect contentsRect;
         FloatSize contentsTileSize;
-        FloatPoint contentsTilePhase;
+        FloatSize contentsTilePhase;
         TextureMapperLayer* maskLayer;
         TextureMapperLayer* replicaLayer;
         Color solidColor;
index 720d25e..e15d2da 100644 (file)
@@ -355,7 +355,7 @@ void CoordinatedGraphicsLayer::setContentsTileSize(const FloatSize& s)
     didChangeLayerState();
 }
 
-void CoordinatedGraphicsLayer::setContentsTilePhase(const FloatPoint& p)
+void CoordinatedGraphicsLayer::setContentsTilePhase(const FloatSize& p)
 {
     if (contentsTilePhase() == p)
         return;
index 67832e8..a216ad5 100644 (file)
@@ -85,7 +85,7 @@ public:
     virtual void setBackfaceVisibility(bool) override;
     virtual void setOpacity(float) override;
     virtual void setContentsRect(const FloatRect&) override;
-    virtual void setContentsTilePhase(const FloatPoint&) override;
+    virtual void setContentsTilePhase(const FloatSize&) override;
     virtual void setContentsTileSize(const FloatSize&) override;
     virtual void setContentsToImage(Image*) override;
     virtual void setContentsToSolidColor(const Color&) override;
index 44fd486..14f2b77 100644 (file)
@@ -139,7 +139,7 @@ struct CoordinatedGraphicsLayerState {
     TransformationMatrix transform;
     TransformationMatrix childrenTransform;
     FloatRect contentsRect;
-    FloatPoint contentsTilePhase;
+    FloatSize contentsTilePhase;
     FloatSize contentsTileSize;
     float opacity;
     Color solidColor;
index 8eefc32..be8bc73 100644 (file)
@@ -859,7 +859,7 @@ void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, co
                 bool useLowQualityScaling = shouldPaintAtLowQuality(context, image.get(), bgLayer, geometry.tileSize());
                 if (image.get())
                     image->setSpaceSize(geometry.spaceSize());
-                context->drawTiledImage(image.get(), style().colorSpace(), geometry.destRect(), geometry.relativePhase(), geometry.tileSize(), ImagePaintingOptions(compositeOp, bgLayer->blendMode(), ImageOrientationDescription(), useLowQualityScaling));
+                context->drawTiledImage(image.get(), style().colorSpace(), geometry.destRect(), toLayoutPoint(geometry.relativePhase()), geometry.tileSize(), ImagePaintingOptions(compositeOp, bgLayer->blendMode(), ImageOrientationDescription(), useLowQualityScaling));
             }
         }
     }
@@ -1036,20 +1036,20 @@ LayoutSize RenderBoxModelObject::calculateFillTileSize(const FillLayer* fillLaye
 void BackgroundImageGeometry::setNoRepeatX(LayoutUnit xOffset)
 {
     m_destRect.move(std::max<LayoutUnit>(xOffset, 0), 0);
-    m_phase.setX(-std::min<LayoutUnit>(xOffset, 0));
+    m_phase.setWidth(-std::min<LayoutUnit>(xOffset, 0));
     m_destRect.setWidth(m_tileSize.width() + std::min<float>(xOffset, 0));
 }
 void BackgroundImageGeometry::setNoRepeatY(LayoutUnit yOffset)
 {
     m_destRect.move(0, std::max<LayoutUnit>(yOffset, 0));
-    m_phase.setY(-std::min<LayoutUnit>(yOffset, 0));
+    m_phase.setHeight(-std::min<LayoutUnit>(yOffset, 0));
     m_destRect.setHeight(m_tileSize.height() + std::min<float>(yOffset, 0));
 }
 
 void BackgroundImageGeometry::useFixedAttachment(const LayoutPoint& attachmentPoint)
 {
     FloatPoint alignedPoint = attachmentPoint;
-    m_phase.move(std::max<LayoutUnit>(alignedPoint.x() - m_destRect.x(), 0), std::max<LayoutUnit>(alignedPoint.y() - m_destRect.y(), 0));
+    m_phase.expand(std::max<LayoutUnit>(alignedPoint.x() - m_destRect.x(), 0), std::max<LayoutUnit>(alignedPoint.y() - m_destRect.y(), 0));
 }
 
 void BackgroundImageGeometry::clip(const LayoutRect& clipRect)
@@ -1057,9 +1057,9 @@ void BackgroundImageGeometry::clip(const LayoutRect& clipRect)
     m_destRect.intersect(clipRect);
 }
 
-LayoutPoint BackgroundImageGeometry::relativePhase() const
+LayoutSize BackgroundImageGeometry::relativePhase() const
 {
-    LayoutPoint phase = m_phase;
+    LayoutSize phase = m_phase;
     phase += m_destRect.location() - m_destOrigin;
     return phase;
 }
@@ -1098,7 +1098,8 @@ void RenderBoxModelObject::pixelSnapBackgroundImageGeometryForPainting(Backgroun
     geometry.setSpaceSize(LayoutSize(snapRectToDevicePixels(LayoutRect(LayoutPoint(), geometry.spaceSize()), deviceScaleFactor).size()));
     geometry.setDestOrigin(LayoutPoint(roundPointToDevicePixels(geometry.destOrigin(), deviceScaleFactor)));
     geometry.setDestRect(LayoutRect(snapRectToDevicePixels(geometry.destRect(), deviceScaleFactor)));
-    geometry.setPhase(LayoutPoint(roundPointToDevicePixels(geometry.phase(), deviceScaleFactor)));
+    FloatSize pixelSnappedPhase = toFloatSize(roundPointToDevicePixels(toLayoutPoint(geometry.phase()), deviceScaleFactor));
+    geometry.setPhase(LayoutSize(pixelSnappedPhase));
 }
 
 void RenderBoxModelObject::calculateBackgroundImageGeometry(const RenderLayerModelObject* paintContainer, const FillLayer* fillLayer, const LayoutRect& paintRect,
@@ -1250,7 +1251,7 @@ void RenderBoxModelObject::calculateBackgroundImageGeometry(const RenderLayerMod
     pixelSnapBackgroundImageGeometryForPainting(geometry);
 }
 
-void RenderBoxModelObject::getGeometryForBackgroundImage(const RenderLayerModelObject* paintContainer, FloatRect& destRect, FloatPoint& phase, FloatSize& tileSize) const
+void RenderBoxModelObject::getGeometryForBackgroundImage(const RenderLayerModelObject* paintContainer, FloatRect& destRect, FloatSize& phase, FloatSize& tileSize) const
 {
     const FillLayer* backgroundLayer = style().backgroundLayers();
     BackgroundImageGeometry geometry;
index 24c0802..87b8847 100644 (file)
@@ -78,20 +78,19 @@ public:
     void setDestRect(const LayoutRect& destRect) { m_destRect = destRect; }
     
     // Returns the phase relative to the destination rectangle.
-    LayoutPoint relativePhase() const;
-    
-    LayoutPoint phase() const { return m_phase; }
-    void setPhase(const LayoutPoint& phase) { m_phase = phase; }
+    LayoutSize relativePhase() const;
     
+    LayoutSize phase() const { return m_phase; }
+    void setPhase(const LayoutSize& phase) { m_phase = phase; }
+    void setPhaseX(LayoutUnit deltaX) { m_phase.setWidth(deltaX); }
+    void setPhaseY(LayoutUnit deltaY) { m_phase.setHeight(deltaY); }
+
     LayoutSize tileSize() const { return m_tileSize; }
     void setTileSize(const LayoutSize& tileSize) { m_tileSize = tileSize; }
     
     LayoutSize spaceSize() const { return m_space; }
     void setSpaceSize(const LayoutSize& space) { m_space = space; }
     
-    void setPhaseX(LayoutUnit  x) { m_phase.setX(x); }
-    void setPhaseY(LayoutUnit y) { m_phase.setY(y); }
-    
     void setNoRepeatX(LayoutUnit xOffset);
     void setNoRepeatY(LayoutUnit yOffset);
     
@@ -105,7 +104,7 @@ public:
 private:
     LayoutRect m_destRect;
     LayoutPoint m_destOrigin;
-    LayoutPoint m_phase;
+    LayoutSize m_phase;
     LayoutSize m_tileSize;
     LayoutSize m_space;
     bool m_hasNonLocalGeometry; // Has background-attachment: fixed. Implies that we can't always cheaply compute destRect.
@@ -236,7 +235,7 @@ public:
 
     bool canHaveBoxInfoInRegion() const { return !isFloating() && !isReplaced() && !isInline() && !isTableCell() && isRenderBlock() && !isRenderSVGBlock(); }
 
-    void getGeometryForBackgroundImage(const RenderLayerModelObject* paintContainer, FloatRect& destRect, FloatPoint& phase, FloatSize& tileSize) const;
+    void getGeometryForBackgroundImage(const RenderLayerModelObject* paintContainer, FloatRect& destRect, FloatSize& phase, FloatSize& tileSize) const;
     void contentChanged(ContentChangeType);
     bool hasAcceleratedCompositing() const;
 
index 83fec26..ed83151 100644 (file)
@@ -1122,7 +1122,7 @@ void RenderLayerBacking::resetContentsRect()
     }
 
     m_graphicsLayer->setContentsTileSize(IntSize());
-    m_graphicsLayer->setContentsTilePhase(IntPoint());
+    m_graphicsLayer->setContentsTilePhase(IntSize());
 }
 
 void RenderLayerBacking::updateDrawsContent()
@@ -1652,7 +1652,7 @@ void RenderLayerBacking::updateDirectlyCompositedBackgroundImage(bool isSimpleCo
     }
 
     FloatRect destRect = backgroundBoxForPainting();
-    FloatPoint phase;
+    FloatSize phase;
     FloatSize tileSize;
 
     RefPtr<Image> image = style.backgroundLayers()->image()->cachedImage()->image();
index 011871b..bd86e85 100644 (file)
@@ -147,8 +147,8 @@ void RenderSVGResourceMasker::drawMaskForRenderer(RenderElement& renderer, const
 
     FloatRect oneTileRect;
     FloatSize actualTileSize(geometry.tileSize().width() + geometry.spaceSize().width(), geometry.tileSize().height() + geometry.spaceSize().height());
-    oneTileRect.setX(geometry.destRect().x() + fmodf(fmodf(-geometry.relativePhase().x(), actualTileSize.width()) - actualTileSize.width(), actualTileSize.width()));
-    oneTileRect.setY(geometry.destRect().y() + fmodf(fmodf(-geometry.relativePhase().y(), actualTileSize.height()) - actualTileSize.height(), actualTileSize.height()));
+    oneTileRect.setX(geometry.destRect().x() + fmodf(fmodf(-geometry.relativePhase().width(), actualTileSize.width()) - actualTileSize.width(), actualTileSize.width()));
+    oneTileRect.setY(geometry.destRect().y() + fmodf(fmodf(-geometry.relativePhase().height(), actualTileSize.height()) - actualTileSize.height(), actualTileSize.height()));
     oneTileRect.setSize(geometry.tileSize());
     
     FloatSize intrinsicTileSize = maskerData->maskImage->logicalSize();