Title: [91137] trunk/Source
Revision
91137
Author
simon.fra...@apple.com
Date
2011-07-15 18:30:13 -0700 (Fri, 15 Jul 2011)

Log Message

2011-07-15  Simon Fraser  <simon.fra...@apple.com>

        Have GraphicsLayer pull their contentsScale, rather than pushing it onto them
        https://bugs.webkit.org/show_bug.cgi?id=64643

        Reviewed by Darin Adler.

        RenderLayerBacking would set the contentsScale on GraphicsLayers
        on creation, and update it when the pageScaleFactor changed. However,
        RenderLayerBacking doesn't really know what contentsScale is best
        for a layer, so instead, have GraphicsLayers call back through the
        GraphicsLayerClient to get the two relevant scale factors, and do
        their own computation of contentsScale.

        No testable behavior changes.

        * page/Frame.cpp:
        (WebCore::Frame::pageScaleFactorChanged): No need to pass the scale.

        * platform/graphics/GraphicsLayer.cpp:
        (WebCore::GraphicsLayer::notePageScaleFactorChangedIncludingDescendants):
        Recurse through the GraphicsLayer tree, calling pageScaleFactorChanged() on
        each layer.

        * platform/graphics/GraphicsLayer.h:
        (WebCore::GraphicsLayer::pageScaleFactorChanged):
        Remove contentsScale/setContentsScale

        * platform/graphics/GraphicsLayerClient.h:
        Add methods to fetch the backingScaleFactor() and pageScaleFactor().

        * platform/graphics/ca/GraphicsLayerCA.cpp:
        (WebCore::GraphicsLayerCA::GraphicsLayerCA): m_uncommittedChanges
        defaults to ContentsScaleChanged so we update contentsScale on
        the first flush.

        (WebCore::GraphicsLayerCA::setContentsToBackgroundColor):
        This was the wrong time to call updateContentsRect() and setupContentsLayer();
        those should be done at commit time, so moved to updateLayerBackgroundColor().
        (WebCore::GraphicsLayerCA::recursiveCommitChanges): Note whether we
        have any changes, and call didCommitChangesForLayer() on the client.
        (WebCore::GraphicsLayerCA::updateLayerBackgroundColor): Code moved to here.
        (WebCore::clampedContentsScaleForScale): No longer has any hysteresis
        on the scale, and now just clamps.
        (WebCore::GraphicsLayerCA::updateContentsScale): Fetch the scales
        from the client, and multiply them, then clamp.
        (WebCore::GraphicsLayerCA::requiresTiledLayer): This now takes
        contentsScale into account when deciding to use tiled layer,
        so that zooming in will cause layers to start tiling.
        (WebCore::GraphicsLayerCA::swapFromOrToTiledLayer): Don't call
        setContentsScale(), but rather updateContentsScale().
        (WebCore::GraphicsLayerCA::pageScaleFactorChanged): Set the bits
        for properties that depend on the scale.
        (WebCore::GraphicsLayerCA::noteChangesForScaleSensitiveProperties):
        Note that contentsScale needs to be updated. At some point we might also
        need to dirty other properties.
        * platform/graphics/ca/GraphicsLayerCA.h: Moved the m_allowTiledLayer
        bool for better packing. No need for a m_contentsScale member now.
        * rendering/RenderLayer.cpp: Removed pageScaleFactorChanged().
        * rendering/RenderLayer.h: Ditto.
        * rendering/RenderLayerBacking.cpp:
        (WebCore::RenderLayerBacking::createPrimaryGraphicsLayer): No need
        to push the contents scale.
        (WebCore::RenderLayerBacking::updateForegroundLayer): Ditto.
        (WebCore::RenderLayerBacking::updateMaskLayer): Ditto.
        (WebCore::RenderLayerBacking::pageScaleFactor): GraphicsLayerClient method.
        (WebCore::RenderLayerBacking::backingScaleFactor): GraphicsLayerClient method.
        (WebCore::RenderLayerBacking::didCommitChangesForLayer): Send through
        to the compositor.
        * rendering/RenderLayerBacking.h: GraphicsLayerClient methods.
        * rendering/RenderLayerCompositor.cpp:
        (WebCore::RenderLayerCompositor::didFlushChangesForLayer): We'll use
        this later.
        (WebCore::RenderLayerCompositor::backingScaleFactor): GraphicsLayerClient method.
        (WebCore::RenderLayerCompositor::pageScaleFactor): Ditto.
        (WebCore::RenderLayerCompositor::didCommitChangesForLayer): Ditto.
        (WebCore::RenderLayerCompositor::ensureRootLayer): No need to push the contents scale.
        (WebCore::RenderLayerCompositor::pageScaleFactorChanged): Just call notePageScaleFactorChangedIncludingDescendants()
        on the root GraphicsLayer.
        * rendering/RenderLayerCompositor.h: Added GraphicsLayerClient methods.

2011-07-15  Simon Fraser  <simon.fra...@apple.com>

        Have GraphicsLayer pull their contentsScale, rather than pushing it onto them
        https://bugs.webkit.org/show_bug.cgi?id=64643

        Reviewed by Darin Adler.

        Impement new GraphicsLayerClient methods related to contents scale,
        and don't push the scale.

        * WebProcess/WebPage/ca/LayerTreeHostCA.cpp:
        (WebKit::LayerTreeHostCA::initialize):
        (WebKit::LayerTreeHostCA::backingScaleFactor):
        (WebKit::LayerTreeHostCA::pageScaleFactor):
        (WebKit::LayerTreeHostCA::createPageOverlayLayer):
        * WebProcess/WebPage/ca/LayerTreeHostCA.h:
        (WebKit::LayerTreeHostCA::didCommitChangesForLayer):

2011-07-15  Simon Fraser  <simon.fra...@apple.com>

        Have GraphicsLayer pull their contentsScale, rather than pushing it onto them
        https://bugs.webkit.org/show_bug.cgi?id=64643

        Reviewed by Darin Adler.

        Impement new GraphicsLayerClient methods related to contents scale.

        * src/PageOverlay.cpp:
        (WebKit::OverlayGraphicsLayerClientImpl::backingScaleFactor):
        (WebKit::OverlayGraphicsLayerClientImpl::pageScaleFactor):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (91136 => 91137)


--- trunk/Source/WebCore/ChangeLog	2011-07-16 01:10:59 UTC (rev 91136)
+++ trunk/Source/WebCore/ChangeLog	2011-07-16 01:30:13 UTC (rev 91137)
@@ -1,3 +1,84 @@
+2011-07-15  Simon Fraser  <simon.fra...@apple.com>
+
+        Have GraphicsLayer pull their contentsScale, rather than pushing it onto them
+        https://bugs.webkit.org/show_bug.cgi?id=64643
+
+        Reviewed by Darin Adler.
+
+        RenderLayerBacking would set the contentsScale on GraphicsLayers
+        on creation, and update it when the pageScaleFactor changed. However,
+        RenderLayerBacking doesn't really know what contentsScale is best
+        for a layer, so instead, have GraphicsLayers call back through the
+        GraphicsLayerClient to get the two relevant scale factors, and do
+        their own computation of contentsScale.
+
+        No testable behavior changes.
+
+        * page/Frame.cpp:
+        (WebCore::Frame::pageScaleFactorChanged): No need to pass the scale.
+
+        * platform/graphics/GraphicsLayer.cpp:
+        (WebCore::GraphicsLayer::notePageScaleFactorChangedIncludingDescendants):
+        Recurse through the GraphicsLayer tree, calling pageScaleFactorChanged() on 
+        each layer.
+
+        * platform/graphics/GraphicsLayer.h:
+        (WebCore::GraphicsLayer::pageScaleFactorChanged):
+        Remove contentsScale/setContentsScale
+        
+        * platform/graphics/GraphicsLayerClient.h:
+        Add methods to fetch the backingScaleFactor() and pageScaleFactor().
+        
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::GraphicsLayerCA): m_uncommittedChanges
+        defaults to ContentsScaleChanged so we update contentsScale on
+        the first flush.
+        
+        (WebCore::GraphicsLayerCA::setContentsToBackgroundColor):
+        This was the wrong time to call updateContentsRect() and setupContentsLayer();
+        those should be done at commit time, so moved to updateLayerBackgroundColor().
+        (WebCore::GraphicsLayerCA::recursiveCommitChanges): Note whether we
+        have any changes, and call didCommitChangesForLayer() on the client.
+        (WebCore::GraphicsLayerCA::updateLayerBackgroundColor): Code moved to here.
+        (WebCore::clampedContentsScaleForScale): No longer has any hysteresis
+        on the scale, and now just clamps.
+        (WebCore::GraphicsLayerCA::updateContentsScale): Fetch the scales
+        from the client, and multiply them, then clamp.
+        (WebCore::GraphicsLayerCA::requiresTiledLayer): This now takes
+        contentsScale into account when deciding to use tiled layer,
+        so that zooming in will cause layers to start tiling.
+        (WebCore::GraphicsLayerCA::swapFromOrToTiledLayer): Don't call
+        setContentsScale(), but rather updateContentsScale().
+        (WebCore::GraphicsLayerCA::pageScaleFactorChanged): Set the bits
+        for properties that depend on the scale.
+        (WebCore::GraphicsLayerCA::noteChangesForScaleSensitiveProperties):
+        Note that contentsScale needs to be updated. At some point we might also
+        need to dirty other properties.
+        * platform/graphics/ca/GraphicsLayerCA.h: Moved the m_allowTiledLayer
+        bool for better packing. No need for a m_contentsScale member now.
+        * rendering/RenderLayer.cpp: Removed pageScaleFactorChanged().
+        * rendering/RenderLayer.h: Ditto.
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::createPrimaryGraphicsLayer): No need
+        to push the contents scale.
+        (WebCore::RenderLayerBacking::updateForegroundLayer): Ditto.
+        (WebCore::RenderLayerBacking::updateMaskLayer): Ditto.
+        (WebCore::RenderLayerBacking::pageScaleFactor): GraphicsLayerClient method.
+        (WebCore::RenderLayerBacking::backingScaleFactor): GraphicsLayerClient method.
+        (WebCore::RenderLayerBacking::didCommitChangesForLayer): Send through
+        to the compositor.
+        * rendering/RenderLayerBacking.h: GraphicsLayerClient methods.
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::didFlushChangesForLayer): We'll use
+        this later.
+        (WebCore::RenderLayerCompositor::backingScaleFactor): GraphicsLayerClient method.
+        (WebCore::RenderLayerCompositor::pageScaleFactor): Ditto.
+        (WebCore::RenderLayerCompositor::didCommitChangesForLayer): Ditto.
+        (WebCore::RenderLayerCompositor::ensureRootLayer): No need to push the contents scale.
+        (WebCore::RenderLayerCompositor::pageScaleFactorChanged): Just call notePageScaleFactorChangedIncludingDescendants()
+        on the root GraphicsLayer.
+        * rendering/RenderLayerCompositor.h: Added GraphicsLayerClient methods.
+
 2011-07-15  Jon Honeycutt  <jhoneyc...@apple.com>
 
         Build fix. Unreviewed.

Modified: trunk/Source/WebCore/page/Frame.cpp (91136 => 91137)


--- trunk/Source/WebCore/page/Frame.cpp	2011-07-16 01:10:59 UTC (rev 91136)
+++ trunk/Source/WebCore/page/Frame.cpp	2011-07-16 01:30:13 UTC (rev 91137)
@@ -1111,7 +1111,7 @@
 
     RenderView* root = contentRenderer();
     if (root && root->compositor())
-        root->compositor()->pageScaleFactorChanged(scale);
+        root->compositor()->pageScaleFactorChanged();
 }
 #endif
 

Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp (91136 => 91137)


--- trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp	2011-07-16 01:10:59 UTC (rev 91136)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp	2011-07-16 01:30:13 UTC (rev 91137)
@@ -222,6 +222,22 @@
     }
 }
 
+void GraphicsLayer::notePageScaleFactorChangedIncludingDescendants()
+{
+    pageScaleFactorChanged();
+
+    if (m_maskLayer)
+        m_maskLayer->pageScaleFactorChanged();
+
+    if (m_replicaLayer)
+        m_replicaLayer->notePageScaleFactorChangedIncludingDescendants();
+
+    const Vector<GraphicsLayer*>& childLayers = children();
+    size_t numChildren = childLayers.size();
+    for (size_t i = 0; i < numChildren; ++i)
+        childLayers[i]->notePageScaleFactorChangedIncludingDescendants();
+}
+
 void GraphicsLayer::setReplicatedByLayer(GraphicsLayer* layer)
 {
     if (layer)

Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayer.h (91136 => 91137)


--- trunk/Source/WebCore/platform/graphics/GraphicsLayer.h	2011-07-16 01:10:59 UTC (rev 91136)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayer.h	2011-07-16 01:30:13 UTC (rev 91137)
@@ -325,11 +325,6 @@
     // For hosting this GraphicsLayer in a native layer hierarchy.
     virtual PlatformLayer* platformLayer() const { return 0; }
     
-    // Change the scale at which the contents are rendered. Note that contentsScale may not return
-    // the same value passed to setContentsScale(), because of clamping and hysteresis.
-    virtual float contentsScale() const { return 1; }
-    virtual void setContentsScale(float) { }
-
     void dumpLayer(TextStream&, int indent = 0, LayerTreeAsTextBehavior = LayerTreeAsTextBehaviorNormal) const;
 
     int repaintCount() const { return m_repaintCount; }
@@ -355,6 +350,9 @@
     virtual void distributeOpacity(float);
     virtual float accumulatedOpacity() const;
 
+    virtual void pageScaleFactorChanged() { }
+    void notePageScaleFactorChangedIncludingDescendants();
+
     // Some compositing systems may do internal batching to synchronize compositing updates
     // with updates drawn into the window. These methods flush internal batched state on this layer
     // and descendant layers, and this layer only.

Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayerClient.h (91136 => 91137)


--- trunk/Source/WebCore/platform/graphics/GraphicsLayerClient.h	2011-07-16 01:10:59 UTC (rev 91136)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayerClient.h	2011-07-16 01:30:13 UTC (rev 91137)
@@ -62,6 +62,12 @@
     virtual void notifySyncRequired(const GraphicsLayer*) = 0;
     
     virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect& inClip) = 0;
+    virtual void didCommitChangesForLayer(const GraphicsLayer*) const = 0;
+
+    // Multiplier for backing store size, related to high DPI.
+    virtual float backingScaleFactor() const = 0;
+    // Scaling factor of the page.
+    virtual float pageScaleFactor() const = 0;
     
     virtual bool showDebugBorders() const = 0;
     virtual bool showRepaintCounter() const = 0;

Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (91136 => 91137)


--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2011-07-16 01:10:59 UTC (rev 91136)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2011-07-16 01:30:13 UTC (rev 91137)
@@ -249,9 +249,8 @@
     : GraphicsLayer(client)
     , m_contentsLayerPurpose(NoContentsLayer)
     , m_contentsLayerHasBackgroundColor(false)
-    , m_uncommittedChanges(NoChange)
-    , m_contentsScale(1)
     , m_allowTiledLayer(true)
+    , m_uncommittedChanges(ContentsScaleChanged)
 {
     m_layer = PlatformCALayer::create(PlatformCALayer::LayerTypeWebLayer, this);
 
@@ -679,8 +678,6 @@
 #ifndef NDEBUG
         m_contentsLayer->setName("Background Color Layer");
 #endif
-        updateContentsRect();
-        setupContentsLayer(m_contentsLayer.get());
     } else {
         m_contentsLayerPurpose = NoContentsLayer;
         m_contentsLayer = 0;
@@ -807,6 +804,8 @@
 
 void GraphicsLayerCA::recursiveCommitChanges()
 {
+    bool hadChanges = m_uncommittedChanges;
+    
     commitLayerChangesBeforeSublayers();
 
     if (m_maskLayer)
@@ -826,6 +825,9 @@
         static_cast<GraphicsLayerCA*>(m_maskLayer)->commitLayerChangesAfterSublayers();
 
     commitLayerChangesAfterSublayers();
+
+    if (hadChanges && client())
+        client()->didCommitChangesForLayer(this);
 }
 
 void GraphicsLayerCA::commitLayerChangesBeforeSublayers()
@@ -1247,6 +1249,9 @@
     if (!m_contentsLayer)
         return;
 
+    setupContentsLayer(m_contentsLayer.get());
+    updateContentsRect();
+
     if (m_backgroundColorSet)
         m_contentsLayer->setBackgroundColor(m_backgroundColor);
     else
@@ -1937,31 +1942,13 @@
     return (property == AnimatedPropertyBackgroundColor) ? m_contentsLayerClones.get() : primaryLayerClones();
 }
 
-void GraphicsLayerCA::setContentsScale(float scale)
+static float clampedContentsScaleForScale(float scale)
 {
-    float newScale = clampedContentsScaleForScale(scale);
-    if (newScale == m_contentsScale)
-        return;
-
-    m_contentsScale = newScale;
-    noteLayerPropertyChanged(ContentsScaleChanged);
-}
-
-float GraphicsLayerCA::clampedContentsScaleForScale(float scale) const
-{
     // Define some limits as a sanity check for the incoming scale value
     // those too small to see.
     const float maxScale = 10.0f;
     const float minScale = 0.01f;
-    
-    // Avoid very slight scale changes that would be doing extra work for no benefit
-    const float maxAllowableDelta = 0.05f;
-
-    // Clamp
-    float result = max(minScale, min(scale, maxScale));
-
-    // If it hasn't changed much, don't do any work
-    return ((fabs(result - m_contentsScale) / m_contentsScale) < maxAllowableDelta) ? m_contentsScale : result;
+    return max(minScale, min(scale, maxScale));
 }
 
 void GraphicsLayerCA::updateContentsScale()
@@ -1970,7 +1957,12 @@
     if (needTiledLayer != m_usingTiledLayer)
         swapFromOrToTiledLayer(needTiledLayer);
 
-    m_layer->setContentsScale(m_contentsScale);
+    float backingScaleFactor = m_client ? m_client->backingScaleFactor() : 1;
+    float pageScaleFactor = m_client ? m_client->pageScaleFactor() : 1;
+
+    float contentsScale = clampedContentsScaleForScale(pageScaleFactor * backingScaleFactor);
+    
+    m_layer->setContentsScale(contentsScale);
     if (drawsContent())
         m_layer->setNeedsDisplay();
 }
@@ -2023,8 +2015,10 @@
     if (!m_drawsContent || !m_allowTiledLayer)
         return false;
 
+    float contentsScale = m_client ? m_client->backingScaleFactor() * m_client->pageScaleFactor() : 1;
+
     // FIXME: catch zero-size height or width here (or earlier)?
-    return size.width() > cMaxPixelDimension || size.height() > cMaxPixelDimension;
+    return size.width() * contentsScale > cMaxPixelDimension || size.height() * contentsScale > cMaxPixelDimension;
 }
 
 void GraphicsLayerCA::swapFromOrToTiledLayer(bool useTiledLayer)
@@ -2033,8 +2027,6 @@
     RefPtr<PlatformCALayer> oldLayer = m_layer;
     
     m_layer = PlatformCALayer::create(useTiledLayer ? PlatformCALayer::LayerTypeWebTiledLayer : PlatformCALayer::LayerTypeWebLayer, this);
-    m_layer->setContentsScale(m_contentsScale);
-
     m_usingTiledLayer = useTiledLayer;
     
     if (useTiledLayer) {
@@ -2065,7 +2057,7 @@
     updateContentsOpaque();
     updateBackfaceVisibility();
     updateLayerBackgroundColor();
-    
+    updateContentsScale();
     updateOpacityOnLayer();
     
 #ifndef NDEBUG
@@ -2370,6 +2362,16 @@
 #endif
 }
 
+void GraphicsLayerCA::pageScaleFactorChanged()
+{
+    noteChangesForScaleSensitiveProperties();
+}
+
+void GraphicsLayerCA::noteChangesForScaleSensitiveProperties()
+{
+    noteLayerPropertyChanged(ContentsScaleChanged);
+}
+
 void GraphicsLayerCA::noteSublayersChanged()
 {
     noteLayerPropertyChanged(ChildrenChanged);

Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h (91136 => 91137)


--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h	2011-07-16 01:10:59 UTC (rev 91136)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h	2011-07-16 01:30:13 UTC (rev 91137)
@@ -56,9 +56,6 @@
     virtual PlatformLayer* platformLayer() const;
     virtual PlatformCALayer* platformCALayer() const { return primaryLayer(); }
 
-    virtual float contentsScale() const { return m_contentsScale; }
-    virtual void setContentsScale(float);
-
     virtual bool setChildren(const Vector<GraphicsLayer*>&);
     virtual void addChild(GraphicsLayer*);
     virtual void addChildAtIndex(GraphicsLayer*, int index);
@@ -119,6 +116,8 @@
 
     virtual void layerDidDisplay(PlatformLayer*);
 
+    virtual void pageScaleFactorChanged();
+
     void recursiveCommitChanges();
 
     virtual void syncCompositingState();
@@ -331,6 +330,7 @@
     typedef unsigned LayerChangeFlags;
     void noteLayerPropertyChanged(LayerChangeFlags flags);
     void noteSublayersChanged();
+    void noteChangesForScaleSensitiveProperties();
 
     void repaintLayerDirtyRects();
 
@@ -353,6 +353,7 @@
     
     ContentsLayerPurpose m_contentsLayerPurpose;
     bool m_contentsLayerHasBackgroundColor : 1;
+    bool m_allowTiledLayer : 1;
 
     RetainPtr<CGImageRef> m_uncorrectedContentsImage;
     RetainPtr<CGImageRef> m_pendingContentsImage;
@@ -396,13 +397,9 @@
     AnimationsMap m_runningAnimations;
 
     Vector<FloatRect> m_dirtyRects;
+    FloatSize m_pixelAlignmentOffset;
     
     LayerChangeFlags m_uncommittedChanges;
-
-    float clampedContentsScaleForScale(float) const;
-    float m_contentsScale;
-    
-    bool m_allowTiledLayer;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (91136 => 91137)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2011-07-16 01:10:59 UTC (rev 91136)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2011-07-16 01:30:13 UTC (rev 91137)
@@ -4165,14 +4165,6 @@
     m_reflection->setStyle(newStyle.release());
 }
 
-void RenderLayer::pageScaleFactorChanged(float scale)
-{
-#if USE(ACCELERATED_COMPOSITING)
-    if (m_backing)
-        m_backing->pageScaleFactorChanged(scale);
-#endif
-}
-
 } // namespace WebCore
 
 #ifndef NDEBUG

Modified: trunk/Source/WebCore/rendering/RenderLayer.h (91136 => 91137)


--- trunk/Source/WebCore/rendering/RenderLayer.h	2011-07-16 01:10:59 UTC (rev 91136)
+++ trunk/Source/WebCore/rendering/RenderLayer.h	2011-07-16 01:30:13 UTC (rev 91137)
@@ -613,8 +613,6 @@
     void setMustOverlapCompositedLayers(bool b) { m_mustOverlapCompositedLayers = b; }
 #endif
 
-    void pageScaleFactorChanged(float);
-
     friend class RenderLayerBacking;
     friend class RenderLayerCompositor;
     friend class RenderBoxModelObject;

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (91136 => 91137)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2011-07-16 01:10:59 UTC (rev 91136)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2011-07-16 01:30:13 UTC (rev 91137)
@@ -116,11 +116,6 @@
 #endif
     m_graphicsLayer = createGraphicsLayer(layerName);
     
-    ASSERT(renderer());
-    ASSERT(renderer()->document());
-    ASSERT(renderer()->document()->frame());
-    m_graphicsLayer->setContentsScale(pageScaleFactor() * backingScaleFactor());
-
     updateLayerOpacity(renderer()->style());
     updateLayerTransform(renderer()->style());
 }
@@ -652,7 +647,6 @@
             m_foregroundLayer = createGraphicsLayer(layerName);
             m_foregroundLayer->setDrawsContent(true);
             m_foregroundLayer->setPaintingPhase(GraphicsLayerPaintForeground);
-            m_foregroundLayer->setContentsScale(pageScaleFactor() * backingScaleFactor());
             layerChanged = true;
         }
     } else if (m_foregroundLayer) {
@@ -675,7 +669,6 @@
             m_maskLayer = createGraphicsLayer("Mask");
             m_maskLayer->setDrawsContent(true);
             m_maskLayer->setPaintingPhase(GraphicsLayerPaintMask);
-            m_maskLayer->setContentsScale(pageScaleFactor() * backingScaleFactor());
             layerChanged = true;
         }
     } else if (m_maskLayer) {
@@ -1248,6 +1241,21 @@
     }
 }
 
+float RenderLayerBacking::pageScaleFactor() const
+{
+    return compositor()->pageScaleFactor();
+}
+
+float RenderLayerBacking::backingScaleFactor() const
+{
+    return compositor()->backingScaleFactor();
+}
+
+void RenderLayerBacking::didCommitChangesForLayer(const GraphicsLayer*) const
+{
+    compositor()->didFlushChangesForLayer(m_owningLayer);
+}
+
 bool RenderLayerBacking::showDebugBorders() const
 {
     return compositor() ? compositor()->compositorShowDebugBorders() : false;
@@ -1467,39 +1475,6 @@
     return ContainerCompositingLayer;
 }
 
-void RenderLayerBacking::pageScaleFactorChanged(float scale)
-{
-    float combinedScale = scale * backingScaleFactor();
-
-    if (m_graphicsLayer)
-        m_graphicsLayer->setContentsScale(combinedScale);
-
-    if (m_foregroundLayer)
-        m_foregroundLayer->setContentsScale(combinedScale);
-
-    if (m_maskLayer)
-        m_maskLayer->setContentsScale(combinedScale);
-}
-
-float RenderLayerBacking::pageScaleFactor() const
-{
-    Frame* frame = renderer()->document()->frame();
-    if (!frame)
-        return 1;
-    return frame->pageScaleFactor();
-}
-
-float RenderLayerBacking::backingScaleFactor() const
-{
-    Frame* frame = renderer()->document()->frame();
-    if (!frame)
-        return 1;
-    Page* page = frame->page();
-    if (!page)
-        return 1;
-    return page->chrome()->scaleFactor();
-}
-
 } // namespace WebCore
 
 #endif // USE(ACCELERATED_COMPOSITING)

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.h (91136 => 91137)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.h	2011-07-16 01:10:59 UTC (rev 91136)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.h	2011-07-16 01:30:13 UTC (rev 91137)
@@ -128,6 +128,10 @@
 
     virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect& clip);
 
+    virtual float backingScaleFactor() const;
+    virtual float pageScaleFactor() const;
+    virtual void didCommitChangesForLayer(const GraphicsLayer*) const;
+
     virtual bool showDebugBorders() const;
     virtual bool showRepaintCounter() const;
 
@@ -136,8 +140,6 @@
     // For informative purposes only.
     CompositingLayerType compositingLayerType() const;
     
-    void pageScaleFactorChanged(float);
-
     GraphicsLayer* layerForHorizontalScrollbar() const { return m_layerForHorizontalScrollbar.get(); }
     GraphicsLayer* layerForVerticalScrollbar() const { return m_layerForVerticalScrollbar.get(); }
     GraphicsLayer* layerForScrollCorner() const { return m_layerForScrollCorner.get(); }
@@ -193,9 +195,6 @@
     static int graphicsLayerToCSSProperty(AnimatedPropertyID);
     static AnimatedPropertyID cssToGraphicsLayerProperty(int);
 
-    float pageScaleFactor() const;
-    float backingScaleFactor() const;
-
 #ifndef NDEBUG
     String nameForLayer() const;
 #endif

Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (91136 => 91137)


--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2011-07-16 01:10:59 UTC (rev 91136)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2011-07-16 01:30:13 UTC (rev 91137)
@@ -207,6 +207,10 @@
     m_flushingLayers = false;
 }
 
+void RenderLayerCompositor::didFlushChangesForLayer(RenderLayer*)
+{
+}
+
 RenderLayerCompositor* RenderLayerCompositor::enclosingCompositorFlushingLayers() const
 {
     if (!m_renderView->frameView())
@@ -1532,6 +1536,33 @@
     }
 }
 
+float RenderLayerCompositor::backingScaleFactor() const
+{
+    Frame* frame = m_renderView->frameView()->frame();
+    if (!frame)
+        return 1;
+    Page* page = frame->page();
+    if (!page)
+        return 1;
+    return page->chrome()->scaleFactor();
+}
+
+float RenderLayerCompositor::pageScaleFactor() const
+{
+    Frame* frame = m_renderView->frameView()->frame();
+    if (!frame)
+        return 1;
+    Page* page = frame->page();
+    if (!page)
+        return 1;
+    return page->mainFrame()->pageScaleFactor();
+}
+
+void RenderLayerCompositor::didCommitChangesForLayer(const GraphicsLayer*) const
+{
+    // Nothing to do here yet.
+}
+
 static bool shouldCompositeOverflowControls(ScrollView* view)
 {
     if (view->platformWidget())
@@ -1617,7 +1648,7 @@
     if (!m_rootContentLayer) {
         m_rootContentLayer = GraphicsLayer::create(0);
 #ifndef NDEBUG
-        m_rootContentLayer->setName("Root platform");
+        m_rootContentLayer->setName("content root");
 #endif
         m_rootContentLayer->setSize(FloatSize(m_renderView->maxXLayoutOverflow(), m_renderView->maxYLayoutOverflow()));
         m_rootContentLayer->setPosition(FloatPoint());
@@ -1640,13 +1671,13 @@
             // Create a clipping layer if this is an iframe
             m_clipLayer = GraphicsLayer::create(this);
 #ifndef NDEBUG
-            m_clipLayer->setName("iframe Clipping");
+            m_clipLayer->setName("frame clipping");
 #endif
             m_clipLayer->setMasksToBounds(true);
             
             m_scrollLayer = GraphicsLayer::create(this);
 #ifndef NDEBUG
-            m_scrollLayer->setName("iframe scrolling");
+            m_scrollLayer->setName("frame scrolling");
 #endif
 
             // Hook them up
@@ -1847,32 +1878,15 @@
     return false;
 }
 
-void RenderLayerCompositor::pageScaleFactorChanged(float scale, RenderLayer* layer)
+void RenderLayerCompositor::pageScaleFactorChanged()
 {
-    if (!layer)
-        layer = rootRenderLayer();
+    // Start at the RenderView's layer, since that's where the scale is applied.
+    RenderLayer* viewLayer = m_renderView->layer();
+    if (!viewLayer->isComposited())
+        return;
 
-    layer->pageScaleFactorChanged(scale);
-
-    if (layer->isStackingContext()) {
-        if (Vector<RenderLayer*>* negZOrderList = layer->negZOrderList()) {
-            size_t listSize = negZOrderList->size();
-            for (size_t i = 0; i < listSize; ++i)
-                pageScaleFactorChanged(scale, negZOrderList->at(i));
-        }
-
-        if (Vector<RenderLayer*>* posZOrderList = layer->posZOrderList()) {
-            size_t listSize = posZOrderList->size();
-            for (size_t i = 0; i < listSize; ++i)
-                pageScaleFactorChanged(scale, posZOrderList->at(i));
-        }
-    }
-
-    if (Vector<RenderLayer*>* normalFlowList = layer->normalFlowList()) {
-        size_t listSize = normalFlowList->size();
-        for (size_t i = 0; i < listSize; ++i)
-            pageScaleFactorChanged(scale, normalFlowList->at(i));
-    }
+    if (GraphicsLayer* rootLayer = viewLayer->backing()->graphicsLayer())
+        rootLayer->notePageScaleFactorChangedIncludingDescendants();
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.h (91136 => 91137)


--- trunk/Source/WebCore/rendering/RenderLayerCompositor.h	2011-07-16 01:10:59 UTC (rev 91136)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.h	2011-07-16 01:30:13 UTC (rev 91137)
@@ -93,6 +93,9 @@
     // flushPendingLayerChanges() flushes the entire GraphicsLayer tree, which can cross frame boundaries.
     // This call returns the rootmost compositor that is being flushed (including self).
     RenderLayerCompositor* enclosingCompositorFlushingLayers() const;
+
+    // Called when the GraphicsLayer for the given RenderLayer has flushed changes inside of flushPendingLayerChanges().
+    void didFlushChangesForLayer(RenderLayer*);
     
     // Rebuild the tree of compositing layers
     void updateCompositingLayers(CompositingUpdateType = CompositingUpdateAfterLayoutOrStyleChange, RenderLayer* updateRoot = 0);
@@ -184,7 +187,11 @@
     bool compositorShowDebugBorders() const { return m_showDebugBorders; }
     bool compositorShowRepaintCounter() const { return m_showRepaintCounter; }
 
-    void pageScaleFactorChanged(float, RenderLayer* = 0);
+    virtual float backingScaleFactor() const;
+    virtual float pageScaleFactor() const;
+    virtual void didCommitChangesForLayer(const GraphicsLayer*) const;
+    
+    void pageScaleFactorChanged();
 
     GraphicsLayer* layerForHorizontalScrollbar() const { return m_layerForHorizontalScrollbar.get(); }
     GraphicsLayer* layerForVerticalScrollbar() const { return m_layerForVerticalScrollbar.get(); }

Modified: trunk/Source/WebKit/chromium/ChangeLog (91136 => 91137)


--- trunk/Source/WebKit/chromium/ChangeLog	2011-07-16 01:10:59 UTC (rev 91136)
+++ trunk/Source/WebKit/chromium/ChangeLog	2011-07-16 01:30:13 UTC (rev 91137)
@@ -1,3 +1,16 @@
+2011-07-15  Simon Fraser  <simon.fra...@apple.com>
+
+        Have GraphicsLayer pull their contentsScale, rather than pushing it onto them
+        https://bugs.webkit.org/show_bug.cgi?id=64643
+
+        Reviewed by Darin Adler.
+        
+        Impement new GraphicsLayerClient methods related to contents scale.
+
+        * src/PageOverlay.cpp:
+        (WebKit::OverlayGraphicsLayerClientImpl::backingScaleFactor):
+        (WebKit::OverlayGraphicsLayerClientImpl::pageScaleFactor):
+
 2011-07-15  Sheriff Bot  <webkit.review....@gmail.com>
 
         Unreviewed.  Rolled DEPS.

Modified: trunk/Source/WebKit/chromium/src/PageOverlay.cpp (91136 => 91137)


--- trunk/Source/WebKit/chromium/src/PageOverlay.cpp	2011-07-16 01:10:59 UTC (rev 91136)
+++ trunk/Source/WebKit/chromium/src/PageOverlay.cpp	2011-07-16 01:30:13 UTC (rev 91137)
@@ -70,6 +70,17 @@
         m_pageOverlayClient->paintPageOverlay(context);
     }
 
+    // Multiplier for backing store size, related to high DPI.
+    virtual float backingScaleFactor() const
+    {
+        return 1;
+    }
+
+    virtual float pageScaleFactor() const
+    {
+        return 1;
+    }
+
     virtual bool showDebugBorders() const
     {
         return m_webViewImpl->page()->settings()->showDebugBorders();

Modified: trunk/Source/WebKit2/ChangeLog (91136 => 91137)


--- trunk/Source/WebKit2/ChangeLog	2011-07-16 01:10:59 UTC (rev 91136)
+++ trunk/Source/WebKit2/ChangeLog	2011-07-16 01:30:13 UTC (rev 91137)
@@ -1,3 +1,21 @@
+2011-07-15  Simon Fraser  <simon.fra...@apple.com>
+
+        Have GraphicsLayer pull their contentsScale, rather than pushing it onto them
+        https://bugs.webkit.org/show_bug.cgi?id=64643
+
+        Reviewed by Darin Adler.
+        
+        Impement new GraphicsLayerClient methods related to contents scale,
+        and don't push the scale.
+
+        * WebProcess/WebPage/ca/LayerTreeHostCA.cpp:
+        (WebKit::LayerTreeHostCA::initialize):
+        (WebKit::LayerTreeHostCA::backingScaleFactor):
+        (WebKit::LayerTreeHostCA::pageScaleFactor):
+        (WebKit::LayerTreeHostCA::createPageOverlayLayer):
+        * WebProcess/WebPage/ca/LayerTreeHostCA.h:
+        (WebKit::LayerTreeHostCA::didCommitChangesForLayer):
+
 2011-07-15  Ada Chan  <adac...@apple.com>
 
         Implement "Jump to Selection" in WebKit2

Modified: trunk/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.cpp (91136 => 91137)


--- trunk/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.cpp	2011-07-16 01:10:59 UTC (rev 91136)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.cpp	2011-07-16 01:30:13 UTC (rev 91137)
@@ -67,7 +67,6 @@
     m_nonCompositedContentLayer->setDrawsContent(true);
     m_nonCompositedContentLayer->setContentsOpaque(m_webPage->drawsBackground() && !m_webPage->drawsTransparentBackground());
     m_nonCompositedContentLayer->setSize(m_webPage->size());
-    m_nonCompositedContentLayer->setContentsScale(m_webPage->userSpaceScaleFactor());
     if (m_webPage->corePage()->settings()->acceleratedDrawingEnabled())
         m_nonCompositedContentLayer->setAcceleratesDrawing(true);
 
@@ -207,6 +206,16 @@
     return m_webPage->corePage()->settings()->showRepaintCounter();
 }
 
+float LayerTreeHostCA::backingScaleFactor() const
+{
+    return m_webPage->userSpaceScaleFactor();
+}
+
+float LayerTreeHostCA::pageScaleFactor() const
+{
+    return 1;
+}
+
 void LayerTreeHostCA::performScheduledLayerFlush()
 {
     {
@@ -253,7 +262,6 @@
 
     m_pageOverlayLayer->setDrawsContent(true);
     m_pageOverlayLayer->setSize(m_webPage->size());
-    m_pageOverlayLayer->setContentsScale(m_webPage->userSpaceScaleFactor());
 
     m_rootLayer->addChild(m_pageOverlayLayer.get());
 }

Modified: trunk/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.h (91136 => 91137)


--- trunk/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.h	2011-07-16 01:10:59 UTC (rev 91136)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.h	2011-07-16 01:30:13 UTC (rev 91137)
@@ -74,6 +74,9 @@
     virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect);
     virtual bool showDebugBorders() const;
     virtual bool showRepaintCounter() const;
+    virtual float backingScaleFactor() const;
+    virtual float pageScaleFactor() const;
+    virtual void didCommitChangesForLayer(const WebCore::GraphicsLayer*) const { }
 
     // LayerTreeHostCA
     virtual void platformInitialize(LayerTreeContext&) = 0;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to