[Chromium] Remove contentsScale and related logic from GraphicsLayerChromium.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Sep 2012 22:23:29 +0000 (22:23 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Sep 2012 22:23:29 +0000 (22:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=95094

Patch by Jeff Timanus <twiz@chromium.org> on 2012-09-06
Reviewed by Adrienne Walker.

Source/Platform:

In the short term, the page-scale logic is to be unified in the CCLayerTreeHost class.  This is a first pass to
try to remove the page-scale logic from GraphicsLayerChromium.  This change should be a no-op in terms of
contentsScale behaviour.

* chromium/public/WebContentLayer.h:
(WebContentLayer):
    Export setBoundsContainPageScale() family of routines.

Source/WebCore:

In the short term, the page-scale logic is to be unified in the CCLayerTreeHost class.  This is a first pass to
try to remove the page-scale logic from GraphicsLayerChromium.  This change should be a no-op in terms of
contentsScale behaviour.

Testing covered by existing compositor layout and unit tests.

* platform/graphics/GraphicsLayer.h:
(WebCore::GraphicsLayer::setAppliesPageScale):
(WebCore::GraphicsLayer::appliesPageScale):
    These routines are now virtual, so that they can push the notification to setDisregardsContentsScale in
    LayerChromium.
* platform/graphics/chromium/GraphicsLayerChromium.cpp:
(WebCore::GraphicsLayerChromium::GraphicsLayerChromium):
(WebCore::GraphicsLayerChromium::setSize):
(WebCore::GraphicsLayerChromium::setTransform):
(WebCore::GraphicsLayerChromium::updateLayerPreserves3D):
(WebCore):
(WebCore::GraphicsLayerChromium::setAppliesPageScale):
(WebCore::GraphicsLayerChromium::appliesPageScale):
    Now forwards the appliesPageScaleStatus to the owned layer.
* platform/graphics/chromium/GraphicsLayerChromium.h:
(GraphicsLayerChromium):
(WebCore::GraphicsLayerChromium::contentsLayer):
* platform/graphics/chromium/LayerChromium.cpp:
(WebCore::LayerChromium::LayerChromium):
(WebCore::LayerChromium::setContentsScale):
(WebCore):
(WebCore::LayerChromium::setBoundsContainPageScale):
    setAppliesPageScale is renamed to setBoundsContainPageScale in LayerChromium.
* platform/graphics/chromium/LayerChromium.h:
(LayerChromium):
(WebCore::LayerChromium::boundsContainPageScale):
* platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
(WebCore):
(WebCore::setScale):
(WebCore::updateLayerScale):
(WebCore::CCLayerTreeHost::updateLayers):
    The contents scale of a layer is now applied in this routine.

Source/WebKit/chromium:

In the short term, the page-scale logic is to be unified in the CCLayerTreeHost class.  This is a first pass to
try to remove the page-scale logic from GraphicsLayerChromium.  This change should be a no-op in terms of
contentsScale behaviour.
This change exports the disregardsPageScale() set of functions from WebContentLayer to LayerChromium.

* src/NonCompositedContentHost.cpp:
(WebKit::NonCompositedContentHost::NonCompositedContentHost):
    Inform the layer associated with the NCCH that it is to disregard the page scale factor.
    Also remove now unused m_deviceScaleFactor and associated routines.
(WebKit::NonCompositedContentHost::setViewport):
* src/NonCompositedContentHost.h:
(NonCompositedContentHost):
* src/WebContentLayerImpl.cpp:
(WebKit::WebContentLayerImpl::setBoundsContainPageScale):
(WebKit):
(WebKit::WebContentLayerImpl::boundsContainPageScale):
* src/WebContentLayerImpl.h:
(WebContentLayerImpl):
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::updateLayerTreeViewport):
* tests/CCLayerTreeHostTest.cpp:
(NoScaleContentLayerChromium):
(WebKitTests::NoScaleContentLayerChromium::create):
(WebKitTests::NoScaleContentLayerChromium::NoScaleContentLayerChromium):
(WebKitTests):
(WebKitTests::CCLayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers::CCLayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers):
    Rebaselined to correspond to the new behaviour.  Because the layers are now assigned a contentsScale, the
    scale on the draw transforms remain identity.
* tests/GraphicsLayerChromiumTest.cpp:
(WebKit): Remove now obsolete unit-test.

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

17 files changed:
Source/Platform/ChangeLog
Source/Platform/chromium/public/WebContentLayer.h
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/GraphicsLayer.h
Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/GraphicsLayerChromium.h
Source/WebCore/platform/graphics/chromium/LayerChromium.cpp
Source/WebCore/platform/graphics/chromium/LayerChromium.h
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/NonCompositedContentHost.cpp
Source/WebKit/chromium/src/NonCompositedContentHost.h
Source/WebKit/chromium/src/WebContentLayerImpl.cpp
Source/WebKit/chromium/src/WebContentLayerImpl.h
Source/WebKit/chromium/src/WebViewImpl.cpp
Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp
Source/WebKit/chromium/tests/GraphicsLayerChromiumTest.cpp

index 701b1ce..2a932eb 100644 (file)
@@ -1,3 +1,18 @@
+2012-09-06  Jeff Timanus  <twiz@chromium.org>
+
+        [Chromium] Remove contentsScale and related logic from GraphicsLayerChromium.
+        https://bugs.webkit.org/show_bug.cgi?id=95094
+
+        Reviewed by Adrienne Walker.
+
+        In the short term, the page-scale logic is to be unified in the CCLayerTreeHost class.  This is a first pass to
+        try to remove the page-scale logic from GraphicsLayerChromium.  This change should be a no-op in terms of
+        contentsScale behaviour.
+
+        * chromium/public/WebContentLayer.h:
+        (WebContentLayer):
+            Export setBoundsContainPageScale() family of routines.
+
 2012-09-06  Tommy Widenflycht  <tommyw@google.com>
 
         MediaStream API: Add the local and remote description functionality to RTCPeerConnection
index 312107f..7bd2579 100644 (file)
@@ -45,8 +45,8 @@ public:
     // Defaults to false.
     virtual void setDoubleSided(bool) = 0;
 
-    // Set to apply a scale factor used when painting and drawing this layer's content. Defaults to 1.0.
-    virtual void setContentsScale(float) = 0;
+    virtual void setBoundsContainPageScale(bool) = 0;
+    virtual bool boundsContainPageScale() const = 0;
 
     // Set to render text in this layer with LCD antialiasing. Only set if you know that this layer will be
     // drawn in a way where this makes sense - i.e. opaque background, not rotated or scaled, etc.
index 85d81c2..1c23545 100644 (file)
@@ -1,3 +1,49 @@
+2012-09-06  Jeff Timanus  <twiz@chromium.org>
+
+        [Chromium] Remove contentsScale and related logic from GraphicsLayerChromium.
+        https://bugs.webkit.org/show_bug.cgi?id=95094
+
+        Reviewed by Adrienne Walker.
+
+        In the short term, the page-scale logic is to be unified in the CCLayerTreeHost class.  This is a first pass to
+        try to remove the page-scale logic from GraphicsLayerChromium.  This change should be a no-op in terms of
+        contentsScale behaviour.
+
+        Testing covered by existing compositor layout and unit tests.
+
+        * platform/graphics/GraphicsLayer.h:
+        (WebCore::GraphicsLayer::setAppliesPageScale):
+        (WebCore::GraphicsLayer::appliesPageScale):
+            These routines are now virtual, so that they can push the notification to setDisregardsContentsScale in
+            LayerChromium.
+        * platform/graphics/chromium/GraphicsLayerChromium.cpp:
+        (WebCore::GraphicsLayerChromium::GraphicsLayerChromium):
+        (WebCore::GraphicsLayerChromium::setSize):
+        (WebCore::GraphicsLayerChromium::setTransform):
+        (WebCore::GraphicsLayerChromium::updateLayerPreserves3D):
+        (WebCore):
+        (WebCore::GraphicsLayerChromium::setAppliesPageScale):
+        (WebCore::GraphicsLayerChromium::appliesPageScale):
+            Now forwards the appliesPageScaleStatus to the owned layer.
+        * platform/graphics/chromium/GraphicsLayerChromium.h:
+        (GraphicsLayerChromium):
+        (WebCore::GraphicsLayerChromium::contentsLayer):
+        * platform/graphics/chromium/LayerChromium.cpp:
+        (WebCore::LayerChromium::LayerChromium):
+        (WebCore::LayerChromium::setContentsScale):
+        (WebCore):
+        (WebCore::LayerChromium::setBoundsContainPageScale):
+            setAppliesPageScale is renamed to setBoundsContainPageScale in LayerChromium.
+        * platform/graphics/chromium/LayerChromium.h:
+        (LayerChromium):
+        (WebCore::LayerChromium::boundsContainPageScale):
+        * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
+        (WebCore):
+        (WebCore::setScale):
+        (WebCore::updateLayerScale):
+        (WebCore::CCLayerTreeHost::updateLayers):
+            The contents scale of a layer is now applied in this routine.
+
 2012-09-06  James Robinson  <jamesr@chromium.org>
 
         [chromium] Split platform geometry types into separate static target
         (WebCore::RTCPeerConnectionHandlerDummy::RTCPeerConnectionHandlerDummy):
         Use ASSERT_UNUSED() to suppress -Wunused-private-field warning
 
+>>>>>>> .r127747
 2012-09-05  Patrick Gansterer  <paroga@webkit.org>
 
         Build fix for Windows.
index 1556ce8..4233bc7 100644 (file)
@@ -368,8 +368,8 @@ public:
     virtual void setMaintainsPixelAlignment(bool maintainsAlignment) { m_maintainsPixelAlignment = maintainsAlignment; }
     virtual bool maintainsPixelAlignment() const { return m_maintainsPixelAlignment; }
     
-    void setAppliesPageScale(bool appliesScale = true) { m_appliesPageScale = appliesScale; }
-    bool appliesPageScale() const { return m_appliesPageScale; }
+    virtual void setAppliesPageScale(bool appliesScale = true) { m_appliesPageScale = appliesScale; }
+    virtual bool appliesPageScale() const { return m_appliesPageScale; }
 
     float pageScaleFactor() const { return m_client ? m_client->pageScaleFactor() : 1; }
     float deviceScaleFactor() const { return m_client ? m_client->deviceScaleFactor() : 1; }
@@ -501,4 +501,3 @@ void showGraphicsLayerTree(const WebCore::GraphicsLayer* layer);
 #endif // USE(ACCELERATED_COMPOSITING)
 
 #endif // GraphicsLayer_h
-
index 490b0e2..ad47842 100644 (file)
@@ -90,7 +90,6 @@ GraphicsLayerChromium::GraphicsLayerChromium(GraphicsLayerClient* client)
     , m_contentsLayerPurpose(NoContentsLayer)
     , m_contentsLayerHasBackgroundColor(false)
     , m_inSetChildren(false)
-    , m_pageScaleChanged(false)
     , m_scrollableArea(0)
 {
     m_opaqueRectTrackingContentLayerDelegate = adoptPtr(new OpaqueRectTrackingContentLayerDelegate(this));
@@ -102,8 +101,6 @@ GraphicsLayerChromium::GraphicsLayerChromium(GraphicsLayerClient* client)
 
     m_layer->layer()->setDrawsContent(m_drawsContent && m_contentsVisible);
     m_layer->layer()->setScrollClient(this);
-    if (client)
-        deviceOrPageScaleFactorChanged();
     updateDebugIndicators();
 }
 
@@ -227,20 +224,10 @@ void GraphicsLayerChromium::setSize(const FloatSize& size)
 
     GraphicsLayer::setSize(clampedSize);
     updateLayerSize();
-
-    if (m_pageScaleChanged) {
-        m_layer->layer()->invalidate();
-        if (m_linkHighlight)
-            m_linkHighlight->invalidate();
-    }
-    m_pageScaleChanged = false;
 }
 
 void GraphicsLayerChromium::setTransform(const TransformationMatrix& transform)
 {
-    // Call this method first to assign contents scale to our layer so the painter can apply the scale transform.
-    updateContentsScale();
-
     GraphicsLayer::setTransform(transform);
     updateTransform();
 }
@@ -759,8 +746,6 @@ void GraphicsLayerChromium::updateLayerPreserves3D()
         // Set the old layer to opacity of 1. Further down we will set the opacity on the transform layer.
         m_layer->layer()->setOpacity(1);
 
-        m_layer->setContentsScale(contentsScale());
-
         // Move this layer to be a child of the transform layer.
         if (parent())
             parent()->platformLayer()->replaceChild(m_layer->layer(), m_transformLayer.get());
@@ -842,15 +827,6 @@ void GraphicsLayerChromium::updateContentsRect()
     contentsLayer->setBounds(IntSize(m_contentsRect.width(), m_contentsRect.height()));
 }
 
-void GraphicsLayerChromium::updateContentsScale()
-{
-    // If page scale is already applied then there's no need to apply it again.
-    if (appliesPageScale())
-        return;
-
-    m_layer->setContentsScale(contentsScale());
-}
-
 void GraphicsLayerChromium::setupContentsLayer(WebLayer* contentsLayer)
 {
     m_contentsLayer = contentsLayer;
@@ -877,20 +853,14 @@ void GraphicsLayerChromium::setupContentsLayer(WebLayer* contentsLayer)
     updateNames();
 }
 
-float GraphicsLayerChromium::contentsScale() const
+void GraphicsLayerChromium::setAppliesPageScale(bool appliesScale)
 {
-    if (!appliesPageScale())
-        return pageScaleFactor() * deviceScaleFactor();
-    return 1;
+    m_layer->setBoundsContainPageScale(appliesScale);
 }
 
-void GraphicsLayerChromium::deviceOrPageScaleFactorChanged()
+bool GraphicsLayerChromium::appliesPageScale() const
 {
-    updateContentsScale();
-    // Invalidations are clamped to the layer's bounds but we receive the scale changed notification before receiving
-    // the new layer bounds. When the scale changes, we really want to invalidate the post-scale layer bounds, so we
-    // remember that the scale has changed and then invalidate the full layer bounds when we receive the new size.
-    m_pageScaleChanged = true;
+    return m_layer->boundsContainPageScale();
 }
 
 void GraphicsLayerChromium::paint(GraphicsContext& context, const IntRect& clip)
index 1b815e9..d5816b4 100644 (file)
@@ -133,7 +133,9 @@ public:
 
     virtual void setDebugBackgroundColor(const Color&);
     virtual void setDebugBorder(const Color&, float borderWidth);
-    virtual void deviceOrPageScaleFactorChanged();
+
+    virtual void setAppliesPageScale(bool appliesScale) OVERRIDE;
+    virtual bool appliesPageScale() const OVERRIDE;
 
     void setScrollableArea(ScrollableArea* scrollableArea) { m_scrollableArea = scrollableArea; }
     ScrollableArea* scrollableArea() const { return m_scrollableArea; }
@@ -152,7 +154,6 @@ public:
 
     // Exposed for tests.
     WebKit::WebLayer* contentsLayer() const { return m_contentsLayer; }
-    float contentsScale() const;
 
 private:
     void updateNames();
@@ -170,7 +171,6 @@ private:
     void updateContentsImage();
     void updateContentsVideo();
     void updateContentsRect();
-    void updateContentsScale();
 
     enum ContentsLayerPurpose {
         NoContentsLayer = 0,
@@ -203,7 +203,6 @@ private:
     ContentsLayerPurpose m_contentsLayerPurpose;
     bool m_contentsLayerHasBackgroundColor : 1;
     bool m_inSetChildren;
-    bool m_pageScaleChanged;
 
     typedef HashMap<String, int> AnimationIdMap;
     AnimationIdMap m_animationIdMap;
index 34a1730..2418fde 100644 (file)
@@ -92,6 +92,7 @@ LayerChromium::LayerChromium()
     , m_drawTransformIsAnimating(false)
     , m_screenSpaceTransformIsAnimating(false)
     , m_contentsScale(1.0)
+    , m_boundsContainPageScale(false)
     , m_layerAnimationDelegate(0)
     , m_layerScrollClient(0)
 {
@@ -617,6 +618,16 @@ void LayerChromium::setContentsScale(float contentsScale)
     if (!needsContentsScale() || m_contentsScale == contentsScale)
         return;
     m_contentsScale = contentsScale;
+
+    setNeedsDisplay();
+}
+
+void LayerChromium::setBoundsContainPageScale(bool boundsContainPageScale)
+{
+    if (boundsContainPageScale == m_boundsContainPageScale)
+        return;
+
+    m_boundsContainPageScale = boundsContainPageScale;
     setNeedsDisplay();
 }
 
index 9761e7c..ee0ea77 100644 (file)
@@ -250,6 +250,10 @@ public:
     float contentsScale() const { return m_contentsScale; }
     void setContentsScale(float);
 
+    // When true, the layer's contents are not scaled by the current page scale factor.
+    void setBoundsContainPageScale(bool);
+    bool boundsContainPageScale() const { return m_boundsContainPageScale; }
+
     // Returns true if any of the layer's descendants has content to draw.
     bool descendantDrawsContent();
 
@@ -385,6 +389,7 @@ private:
     // Uses target surface space.
     IntRect m_drawableContentRect;
     float m_contentsScale;
+    bool m_boundsContainPageScale;
 
     WebKit::WebAnimationDelegate* m_layerAnimationDelegate;
     WebKit::WebLayerScrollClient* m_layerScrollClient;
index 4026ee8..7031e82 100644 (file)
@@ -464,7 +464,6 @@ bool CCLayerTreeHost::initializeRendererIfNeeded()
     return true;
 }
 
-
 void CCLayerTreeHost::updateLayers(CCTextureUpdateQueue& queue, size_t memoryAllocationLimitBytes)
 {
     ASSERT(m_rendererInitialized);
@@ -481,10 +480,37 @@ void CCLayerTreeHost::updateLayers(CCTextureUpdateQueue& queue, size_t memoryAll
     updateLayers(rootLayer(), queue);
 }
 
+static void setScale(LayerChromium* layer, float deviceScaleFactor, float pageScaleFactor)
+{
+    if (layer->boundsContainPageScale())
+        layer->setContentsScale(deviceScaleFactor);
+    else
+        layer->setContentsScale(deviceScaleFactor * pageScaleFactor);
+}
+
+static void updateLayerScale(LayerChromium* layer, float deviceScaleFactor, float pageScaleFactor)
+{
+    setScale(layer, deviceScaleFactor, pageScaleFactor);
+
+    LayerChromium* maskLayer = layer->maskLayer();
+    if (maskLayer)
+        setScale(maskLayer, deviceScaleFactor, pageScaleFactor);
+
+    LayerChromium* replicaMaskLayer = layer->replicaLayer() ? layer->replicaLayer()->maskLayer() : 0;
+    if (replicaMaskLayer)
+        setScale(replicaMaskLayer, deviceScaleFactor, pageScaleFactor);
+
+    const Vector<RefPtr<LayerChromium> >& children = layer->children();
+    for (unsigned int i = 0; i < children.size(); ++i)
+        updateLayerScale(children[i].get(), deviceScaleFactor, pageScaleFactor);
+}
+
 void CCLayerTreeHost::updateLayers(LayerChromium* rootLayer, CCTextureUpdateQueue& queue)
 {
     TRACE_EVENT0("cc", "CCLayerTreeHost::updateLayers");
 
+    updateLayerScale(rootLayer, m_deviceScaleFactor, m_pageScaleFactor);
+
     LayerList updateList;
 
     {
index 1a0d2c5..417ee86 100644 (file)
@@ -1,3 +1,41 @@
+2012-09-06  Jeff Timanus  <twiz@chromium.org>
+
+        [Chromium] Remove contentsScale and related logic from GraphicsLayerChromium.
+        https://bugs.webkit.org/show_bug.cgi?id=95094
+
+        Reviewed by Adrienne Walker.
+
+        In the short term, the page-scale logic is to be unified in the CCLayerTreeHost class.  This is a first pass to
+        try to remove the page-scale logic from GraphicsLayerChromium.  This change should be a no-op in terms of
+        contentsScale behaviour.
+        This change exports the disregardsPageScale() set of functions from WebContentLayer to LayerChromium.
+
+        * src/NonCompositedContentHost.cpp:
+        (WebKit::NonCompositedContentHost::NonCompositedContentHost):
+            Inform the layer associated with the NCCH that it is to disregard the page scale factor.
+            Also remove now unused m_deviceScaleFactor and associated routines.
+        (WebKit::NonCompositedContentHost::setViewport):
+        * src/NonCompositedContentHost.h:
+        (NonCompositedContentHost):
+        * src/WebContentLayerImpl.cpp:
+        (WebKit::WebContentLayerImpl::setBoundsContainPageScale):
+        (WebKit):
+        (WebKit::WebContentLayerImpl::boundsContainPageScale):
+        * src/WebContentLayerImpl.h:
+        (WebContentLayerImpl):
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::updateLayerTreeViewport):
+        * tests/CCLayerTreeHostTest.cpp:
+        (NoScaleContentLayerChromium):
+        (WebKitTests::NoScaleContentLayerChromium::create):
+        (WebKitTests::NoScaleContentLayerChromium::NoScaleContentLayerChromium):
+        (WebKitTests):
+        (WebKitTests::CCLayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers::CCLayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers):
+            Rebaselined to correspond to the new behaviour.  Because the layers are now assigned a contentsScale, the
+            scale on the draw transforms remain identity.
+        * tests/GraphicsLayerChromiumTest.cpp:
+        (WebKit): Remove now obsolete unit-test.
+
 2012-09-06  Adrienne Walker  <enne@google.com>
 
         [chromium] Remove Scrollbar/Settings dependencies from ScrollbarLayerChromiumTest
index 4df4204..ae99ba8 100644 (file)
@@ -42,13 +42,13 @@ NonCompositedContentHost::NonCompositedContentHost(WebViewImpl* webView)
     : m_webView(webView)
     , m_opaque(true)
     , m_showDebugBorders(false)
-    , m_deviceScaleFactor(1.0)
 {
     m_graphicsLayer = WebCore::GraphicsLayer::create(this);
 #ifndef NDEBUG
     m_graphicsLayer->setName("non-composited content");
 #endif
     m_graphicsLayer->setDrawsContent(true);
+    m_graphicsLayer->setAppliesPageScale(true);
     WebContentLayer* layer = static_cast<WebCore::GraphicsLayerChromium*>(m_graphicsLayer.get())->contentLayer();
     layer->setUseLCDText(true);
     layer->layer()->setOpaque(true);
@@ -88,7 +88,7 @@ void NonCompositedContentHost::setScrollLayer(WebCore::GraphicsLayer* layer)
     ASSERT(haveScrollLayer());
 }
 
-void NonCompositedContentHost::setViewport(const WebCore::IntSize& viewportSize, const WebCore::IntSize& contentsSize, const WebCore::IntPoint& scrollPosition, const WebCore::IntPoint& scrollOrigin, float deviceScale)
+void NonCompositedContentHost::setViewport(const WebCore::IntSize& viewportSize, const WebCore::IntSize& contentsSize, const WebCore::IntPoint& scrollPosition, const WebCore::IntPoint& scrollOrigin)
 {
     if (!haveScrollLayer())
         return;
@@ -102,8 +102,6 @@ void NonCompositedContentHost::setViewport(const WebCore::IntSize& viewportSize,
     // Due to the possibility of pinch zoom, the noncomposited layer is always
     // assumed to be scrollable.
     layer->setScrollable(true);
-    m_deviceScaleFactor = deviceScale;
-    m_graphicsLayer->deviceOrPageScaleFactorChanged();
     m_graphicsLayer->setSize(contentsSize);
 
     // In RTL-style pages, the origin of the initial containing block for the
index 08b5f6a..69776d9 100644 (file)
@@ -58,7 +58,7 @@ public:
     void setBackgroundColor(const WebCore::Color&);
     void setOpaque(bool);
     void setScrollLayer(WebCore::GraphicsLayer*);
-    void setViewport(const WebCore::IntSize& viewportSize, const WebCore::IntSize& contentsSize, const WebCore::IntPoint& scrollPosition, const WebCore::IntPoint& scrollOrigin, float deviceScale);
+    void setViewport(const WebCore::IntSize& viewportSize, const WebCore::IntSize& contentsSize, const WebCore::IntPoint& scrollPosition, const WebCore::IntPoint& scrollOrigin);
     WebCore::GraphicsLayer* topLevelRootLayer() const { return m_graphicsLayer.get(); }
 
     void setShowDebugBorders(bool);
@@ -73,11 +73,6 @@ private:
     virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect);
     virtual bool showDebugBorders(const WebCore::GraphicsLayer*) const;
     virtual bool showRepaintCounter(const WebCore::GraphicsLayer*) const;
-    // The deviceScaleFactor given to the GraphicsLayer can be non-1 when the
-    // contents are scaled in the compositor instead of by the pageScaleFactor.
-    // However, the pageScaleFactor is always baked into the GraphicsLayer's
-    // size, so it is always 1 for the GraphicsLayer.
-    virtual float deviceScaleFactor() const OVERRIDE { return m_deviceScaleFactor; }
 
     bool haveScrollLayer();
     WebLayer* scrollLayer();
@@ -89,7 +84,6 @@ private:
 
     bool m_opaque;
     bool m_showDebugBorders;
-    float m_deviceScaleFactor;
 };
 
 } // namespace WebKit
index c151c34..862b19b 100644 (file)
@@ -65,9 +65,14 @@ void WebContentLayerImpl::setDoubleSided(bool doubleSided)
     m_layer->layer()->setDoubleSided(doubleSided);
 }
 
-void WebContentLayerImpl::setContentsScale(float scale)
+void WebContentLayerImpl::setBoundsContainPageScale(bool boundsContainPageScale)
 {
-    m_layer->layer()->setContentsScale(scale);
+    return m_layer->layer()->setBoundsContainPageScale(boundsContainPageScale);
+}
+
+bool WebContentLayerImpl::boundsContainPageScale() const
+{
+    return m_layer->layer()->boundsContainPageScale();
 }
 
 void WebContentLayerImpl::setUseLCDText(bool enable)
index 95ccab8..45fa79b 100644 (file)
@@ -42,7 +42,8 @@ public:
     // WebContentLayer implementation.
     virtual WebLayer* layer() OVERRIDE;
     virtual void setDoubleSided(bool)  OVERRIDE;
-    virtual void setContentsScale(float)  OVERRIDE;
+    virtual void setBoundsContainPageScale(bool) OVERRIDE;
+    virtual bool boundsContainPageScale() const OVERRIDE;
     virtual void setUseLCDText(bool)  OVERRIDE;
     virtual void setDrawCheckerboardForMissingTiles(bool)  OVERRIDE;
 
index cf14091..14c4bb4 100644 (file)
@@ -3981,14 +3981,14 @@ void WebViewImpl::updateLayerTreeViewport()
     IntRect visibleRect = view->visibleContentRect(true /* include scrollbars */);
     IntPoint scroll(view->scrollX(), view->scrollY());
 
-    // This part of the deviceScale will be used to scale the contents of
-    // the NCCH's GraphicsLayer.
-    float deviceScale = m_deviceScaleInCompositor;
-    m_nonCompositedContentHost->setViewport(visibleRect.size(), view->contentsSize(), scroll, view->scrollOrigin(), deviceScale);
+    m_nonCompositedContentHost->setViewport(visibleRect.size(), view->contentsSize(), scroll, view->scrollOrigin());
 
     IntSize layoutViewportSize = size();
     IntSize deviceViewportSize = size();
-    deviceViewportSize.scale(deviceScale);
+
+    // This part of the deviceScale will be used to scale the contents of
+    // the NCCH's GraphicsLayer.
+    deviceViewportSize.scale(m_deviceScaleInCompositor);
     m_layerTreeView->setViewportSize(layoutViewportSize, deviceViewportSize);
     m_layerTreeView->setPageScaleFactorAndLimits(pageScaleFactor(), m_minimumPageScaleFactor, m_maximumPageScaleFactor);
 }
index 5219302..ca0dcb3 100644 (file)
@@ -1279,11 +1279,22 @@ public:
     void notifySyncRequired() { }
 };
 
+class NoScaleContentLayerChromium : public ContentLayerChromium {
+public:
+    static PassRefPtr<NoScaleContentLayerChromium> create(ContentLayerChromiumClient* client) { return adoptRef(new NoScaleContentLayerChromium(client)); }
+
+    virtual bool needsContentsScale() const OVERRIDE { return false; }
+
+private:
+    explicit NoScaleContentLayerChromium(ContentLayerChromiumClient* client)
+        : ContentLayerChromium(client) { }
+};
+
 class CCLayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers : public CCLayerTreeHostTest {
 public:
 
     CCLayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers()
-        : m_rootLayer(ContentLayerChromium::create(&m_client))
+        : m_rootLayer(NoScaleContentLayerChromium::create(&m_client))
         , m_childLayer(ContentLayerChromium::create(&m_client))
     {
     }
@@ -1345,6 +1356,11 @@ public:
         // The root render surface is the size of the viewport.
         EXPECT_RECT_EQ(IntRect(0, 0, 60, 60), root->renderSurface()->contentRect());
 
+        // The content bounds of the child should be scaled.
+        IntSize childBoundsScaled = child->bounds();
+        childBoundsScaled.scale(1.5);
+        EXPECT_EQ(childBoundsScaled, child->contentBounds());
+
         WebTransformationMatrix scaleTransform;
         scaleTransform.scale(impl->deviceScaleFactor());
 
@@ -1355,11 +1371,10 @@ public:
         EXPECT_EQ(rootDrawTransform, root->drawTransform());
         EXPECT_EQ(rootScreenSpaceTransform, root->screenSpaceTransform());
 
-        // The child is at position 2,2, so translate by 2,2 before applying the scale by 2x.
-        WebTransformationMatrix childScreenSpaceTransform = scaleTransform;
-        childScreenSpaceTransform.translate(2, 2);
-        WebTransformationMatrix childDrawTransform = scaleTransform;
-        childDrawTransform.translate(2, 2);
+        // The child is at position 2,2, which is transformed to 3,3 after the scale
+        WebTransformationMatrix childScreenSpaceTransform;
+        childScreenSpaceTransform.translate(3, 3);
+        WebTransformationMatrix childDrawTransform = childScreenSpaceTransform;
 
         EXPECT_EQ(childDrawTransform, child->drawTransform());
         EXPECT_EQ(childScreenSpaceTransform, child->screenSpaceTransform());
@@ -1375,7 +1390,7 @@ public:
 
 private:
     MockContentLayerChromiumClient m_client;
-    RefPtr<ContentLayerChromium> m_rootLayer;
+    RefPtr<NoScaleContentLayerChromium> m_rootLayer;
     RefPtr<ContentLayerChromium> m_childLayer;
 };
 
index fc7f23f..7fab0d2 100644 (file)
@@ -122,11 +122,6 @@ TEST_F(GraphicsLayerChromiumTest, updateLayerPreserves3DWithAnimations)
     ASSERT_FALSE(m_platformLayer->hasActiveAnimation());
 }
 
-TEST_F(GraphicsLayerChromiumTest, shouldStartWithCorrectContentsScale)
-{
-    EXPECT_EQ(2, m_graphicsLayer->contentsScale());
-}
-
 class FakeScrollableArea : public ScrollableArea {
 public:
     virtual bool isActive() const OVERRIDE { return false; }