[chromium] Scale all compositor output by the defaultDeviceScaleFactor
authordanakj@chromium.org <danakj@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 May 2012 03:36:12 +0000 (03:36 +0000)
committerdanakj@chromium.org <danakj@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 May 2012 03:36:12 +0000 (03:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=86051

Reviewed by James Robinson.

Source/Platform:

* chromium/public/WebLayerTreeView.h:
(WebKit::WebLayerTreeView::Settings::Settings):
(Settings):

Source/WebCore:

On initialization, give the defaultDeviceScaleFactor to the compositor
to have it scale all output from WebCore's layout size to physical
pixels. This allows us to scale up to high-dpi devices without using
fixed-layout, so we can leave the WebCore frame size in layout pixels,
while drawing the frame into a larger physical pixel size.

CCLayerTreeHost becomes aware of the deviceScaleFactor and scales all
output by this factor by scaling the viewport and all drawing
transforms.

Anything that works in physical pixels (content space), uses the
deviceViewportSize() in place of the viewportSize(), since when
deviceScaleFactor != 1 in CCLayerTreeHost, the WebCore viewport
is no longer physical pixels.

Scroll positions are in layout pixels, and must be scaled to/from
content space within the compositor.

Unit tests: CCLayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers

* platform/graphics/chromium/LayerRendererChromium.h:
(LayerRendererChromiumClient):
(WebCore::LayerRendererChromium::viewportSize):
(WebCore::LayerRendererChromium::viewportWidth):
(WebCore::LayerRendererChromium::viewportHeight):
(LayerRendererChromium):
* platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
(WebCore::CCLayerTreeHost::initializeLayerRenderer):
(WebCore::CCLayerTreeHost::setViewportSize):
(WebCore::CCLayerTreeHost::updateLayers):
(WebCore::CCLayerTreeHost::paintLayerContents):
* platform/graphics/chromium/cc/CCLayerTreeHost.h:
(WebCore::CCSettings::CCSettings):
(CCSettings):
(CCLayerTreeHost):
(WebCore::CCLayerTreeHost::deviceViewportSize):
* platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
(WebCore::CCLayerTreeHostImpl::calculateRenderSurfaceLayerList):
(WebCore::CCLayerTreeHostImpl::calculateRenderPasses):
(WebCore::CCLayerTreeHostImpl::setViewportSize):
(WebCore::CCLayerTreeHostImpl::updateMaxScrollPosition):
(WebCore::CCLayerTreeHostImpl::scrollBegin):
(WebCore::CCLayerTreeHostImpl::computePinchZoomDeltas):
* platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
(WebCore::CCLayerTreeHostImpl::viewportSize):
(CCLayerTreeHostImpl):

Source/WebKit/chromium:

Add the applyDefaultDeviceScaleInCompositor setting. When enabled, we
apply the scale factor during compositing instead of applying it through
the pageScaleFactor.

NonCompositedContentHost is the GraphicLayerClient for the GraphicsLayer
containing the document's body. It needs to report the page/device scale
that should be used when scaling the contents of the GraphicsLayer, and
when changes occur to them such that its contentsSize or contentsScale
is affected.

Store the deviceScaleFactor being used in the compositor. The remainder
of the deviceScaleFactor() is being applied to the pageScale.

* public/WebSettings.h:
* src/NonCompositedContentHost.cpp:
(WebKit::NonCompositedContentHost::NonCompositedContentHost):
(WebKit::NonCompositedContentHost::setViewport):
* src/NonCompositedContentHost.h:
(NonCompositedContentHost):
* src/WebLayerTreeView.cpp:
(WebKit::WebLayerTreeView::Settings::operator CCSettings):
* src/WebSettingsImpl.cpp:
(WebKit::WebSettingsImpl::setApplyDefaultDeviceScaleFactorInCompositor):
(WebKit):
* src/WebSettingsImpl.h:
(WebSettingsImpl):
(WebKit::WebSettingsImpl::applyDefaultDeviceScaleFactorInCompositor):
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::WebViewImpl):
(WebKit::WebViewImpl::setPageScaleFactor):
(WebKit::WebViewImpl::setDeviceScaleFactor):
(WebKit::WebViewImpl::enableFixedLayoutMode):
(WebKit::WebViewImpl::computePageScaleFactorLimits):
(WebKit::WebViewImpl::setIsAcceleratedCompositingActive):
(WebKit::WebViewImpl::updateLayerTreeViewport):
* src/WebViewImpl.h:
* tests/CCLayerTreeHostTest.cpp:
(MockLayerTreeHostImpl):
(WTF::MockLayerTreeHost::createLayerTreeHostImpl):
(CCLayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers):
(WTF::CCLayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers::CCLayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers):
(WTF::CCLayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers::beginTest):
(WTF::CCLayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers::commitCompleteOnCCThread):
(WTF::CCLayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers::afterTest):
(WTF):
(WTF::TEST_F):
* tests/LayerRendererChromiumTest.cpp:
* tests/WebFrameTest.cpp:
(WebKit::TEST_F):

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

20 files changed:
Source/Platform/ChangeLog
Source/Platform/chromium/public/WebLayerTreeView.h
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/public/WebSettings.h
Source/WebKit/chromium/src/NonCompositedContentHost.cpp
Source/WebKit/chromium/src/NonCompositedContentHost.h
Source/WebKit/chromium/src/WebLayerTreeView.cpp
Source/WebKit/chromium/src/WebSettingsImpl.cpp
Source/WebKit/chromium/src/WebSettingsImpl.h
Source/WebKit/chromium/src/WebViewImpl.cpp
Source/WebKit/chromium/src/WebViewImpl.h
Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp
Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp
Source/WebKit/chromium/tests/WebFrameTest.cpp

index 01f6beb..a84e4ff 100644 (file)
@@ -1,3 +1,14 @@
+2012-05-17  Dana Jansens  <danakj@chromium.org>
+
+        [chromium] Scale all compositor output by the defaultDeviceScaleFactor
+        https://bugs.webkit.org/show_bug.cgi?id=86051
+
+        Reviewed by James Robinson.
+
+        * chromium/public/WebLayerTreeView.h:
+        (WebKit::WebLayerTreeView::Settings::Settings):
+        (Settings):
+
 2012-05-17  Ami Fischman  <fischman@chromium.org>
 
         [Chromium] Store HTTP version in WebURLResponse
index 94f9e33..2b0f30a 100644 (file)
@@ -59,6 +59,7 @@ public:
             , threadedAnimationEnabled(false)
             , defaultTileSize(WebSize(256, 256))
             , maxUntiledLayerSize(WebSize(512, 512))
+            , deviceScaleFactor(1)
         {
         }
 
@@ -72,6 +73,7 @@ public:
         bool threadedAnimationEnabled;
         WebSize defaultTileSize;
         WebSize maxUntiledLayerSize;
+        float deviceScaleFactor;
 #if WEBKIT_IMPLEMENTATION
         operator WebCore::CCSettings() const;
 #endif
index e6a3d69..66787cc 100644 (file)
@@ -1,3 +1,57 @@
+2012-05-17  Dana Jansens  <danakj@chromium.org>
+
+        [chromium] Scale all compositor output by the defaultDeviceScaleFactor
+        https://bugs.webkit.org/show_bug.cgi?id=86051
+
+        Reviewed by James Robinson.
+
+        On initialization, give the defaultDeviceScaleFactor to the compositor
+        to have it scale all output from WebCore's layout size to physical
+        pixels. This allows us to scale up to high-dpi devices without using
+        fixed-layout, so we can leave the WebCore frame size in layout pixels,
+        while drawing the frame into a larger physical pixel size.
+
+        CCLayerTreeHost becomes aware of the deviceScaleFactor and scales all
+        output by this factor by scaling the viewport and all drawing
+        transforms.
+
+        Anything that works in physical pixels (content space), uses the
+        deviceViewportSize() in place of the viewportSize(), since when
+        deviceScaleFactor != 1 in CCLayerTreeHost, the WebCore viewport
+        is no longer physical pixels.
+
+        Scroll positions are in layout pixels, and must be scaled to/from
+        content space within the compositor.
+
+        Unit tests: CCLayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers
+
+        * platform/graphics/chromium/LayerRendererChromium.h:
+        (LayerRendererChromiumClient):
+        (WebCore::LayerRendererChromium::viewportSize):
+        (WebCore::LayerRendererChromium::viewportWidth):
+        (WebCore::LayerRendererChromium::viewportHeight):
+        (LayerRendererChromium):
+        * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
+        (WebCore::CCLayerTreeHost::initializeLayerRenderer):
+        (WebCore::CCLayerTreeHost::setViewportSize):
+        (WebCore::CCLayerTreeHost::updateLayers):
+        (WebCore::CCLayerTreeHost::paintLayerContents):
+        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
+        (WebCore::CCSettings::CCSettings):
+        (CCSettings):
+        (CCLayerTreeHost):
+        (WebCore::CCLayerTreeHost::deviceViewportSize):
+        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
+        (WebCore::CCLayerTreeHostImpl::calculateRenderSurfaceLayerList):
+        (WebCore::CCLayerTreeHostImpl::calculateRenderPasses):
+        (WebCore::CCLayerTreeHostImpl::setViewportSize):
+        (WebCore::CCLayerTreeHostImpl::updateMaxScrollPosition):
+        (WebCore::CCLayerTreeHostImpl::scrollBegin):
+        (WebCore::CCLayerTreeHostImpl::computePinchZoomDeltas):
+        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
+        (WebCore::CCLayerTreeHostImpl::viewportSize):
+        (CCLayerTreeHostImpl):
+
 2012-05-17  Hayato Ito  <hayato@chromium.org>
 
         [Shadow DOM] Add an assertion to make sure a visited node is not an active insertion point.
index a92cf82..1a2ebed 100644 (file)
@@ -66,7 +66,7 @@ class ScopedEnsureFramebufferAllocation;
 
 class LayerRendererChromiumClient {
 public:
-    virtual const IntSize& viewportSize() const = 0;
+    virtual const IntSize& deviceViewportSize() const = 0;
     virtual const CCSettings& settings() const = 0;
     virtual void didLoseContext() = 0;
     virtual void onSwapBuffersComplete() = 0;
@@ -90,10 +90,6 @@ public:
     GraphicsContext3D* context();
     bool contextSupportsMapSub() const { return m_capabilities.usingMapSub; }
 
-    const IntSize& viewportSize() { return m_client->viewportSize(); }
-    int viewportWidth() { return viewportSize().width(); }
-    int viewportHeight() { return viewportSize().height(); }
-
     void viewportChanged();
 
     void beginDrawingFrame(CCRenderSurface* defaultRenderSurface);
@@ -150,6 +146,10 @@ protected:
     bool initialize();
 
 private:
+    const IntSize& viewportSize() { return m_client->deviceViewportSize(); }
+    int viewportWidth() { return viewportSize().width(); }
+    int viewportHeight() { return viewportSize().height(); }
+
     void drawQuad(const CCDrawQuad*, const FloatRect& surfaceDamageRect);
     void drawCheckerboardQuad(const CCCheckerboardDrawQuad*);
     void drawDebugBorderQuad(const CCDebugBorderDrawQuad*);
index 5c5ef6f..f82ac37 100644 (file)
@@ -143,8 +143,8 @@ void CCLayerTreeHost::initializeLayerRenderer()
     // Update m_settings based on partial update capability.
     m_settings.maxPartialTextureUpdates = min(m_settings.maxPartialTextureUpdates, m_proxy->maxPartialTextureUpdates());
 
-    m_contentsTextureManager = TextureManager::create(TextureManager::highLimitBytes(viewportSize()),
-                                                      TextureManager::reclaimLimitBytes(viewportSize()),
+    m_contentsTextureManager = TextureManager::create(TextureManager::highLimitBytes(deviceViewportSize()),
+                                                      TextureManager::reclaimLimitBytes(deviceViewportSize()),
                                                       m_proxy->layerRendererCapabilities().maxTextureSize);
 
     m_layerRendererInitialized = true;
@@ -367,6 +367,10 @@ void CCLayerTreeHost::setViewportSize(const IntSize& viewportSize)
         return;
 
     m_viewportSize = viewportSize;
+
+    m_deviceViewportSize = viewportSize;
+    m_deviceViewportSize.scale(m_settings.deviceScaleFactor);
+
     setNeedsCommit();
 }
 
@@ -483,9 +487,9 @@ void CCLayerTreeHost::updateLayers(LayerChromium* rootLayer, CCTextureUpdater& u
 
     if (!rootLayer->renderSurface())
         rootLayer->createRenderSurface();
-    rootLayer->renderSurface()->setContentRect(IntRect(IntPoint(0, 0), viewportSize()));
+    rootLayer->renderSurface()->setContentRect(IntRect(IntPoint(0, 0), deviceViewportSize()));
 
-    IntRect rootClipRect(IntPoint(), viewportSize());
+    IntRect rootClipRect(IntPoint(), deviceViewportSize());
     rootLayer->setClipRect(rootClipRect);
 
     LayerList updateList;
@@ -494,10 +498,12 @@ void CCLayerTreeHost::updateLayers(LayerChromium* rootLayer, CCTextureUpdater& u
     RenderSurfaceChromium* rootRenderSurface = rootLayer->renderSurface();
     rootRenderSurface->clearLayerList();
 
-    TransformationMatrix identityMatrix;
     {
         TRACE_EVENT("CCLayerTreeHost::updateLayers::calcDrawEtc", this, 0);
-        CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(rootLayer, rootLayer, identityMatrix, identityMatrix, updateList, rootRenderSurface->layerList(), layerRendererCapabilities().maxTextureSize);
+        TransformationMatrix identityMatrix;
+        TransformationMatrix deviceScaleTransform;
+        deviceScaleTransform.scale(m_settings.deviceScaleFactor);
+        CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(rootLayer, rootLayer, deviceScaleTransform, identityMatrix, updateList, rootRenderSurface->layerList(), layerRendererCapabilities().maxTextureSize);
     }
 
     // Reset partial texture update requests.
@@ -575,7 +581,7 @@ void CCLayerTreeHost::paintLayerContents(const LayerList& renderSurfaceLayerList
     typedef CCLayerIterator<LayerChromium, Vector<RefPtr<LayerChromium> >, RenderSurfaceChromium, CCLayerIteratorActions::FrontToBack> CCLayerIteratorType;
 
     bool recordMetricsForFrame = true; // FIXME: In the future, disable this when about:tracing is off.
-    CCOcclusionTracker occlusionTracker(IntRect(IntPoint(), viewportSize()), recordMetricsForFrame);
+    CCOcclusionTracker occlusionTracker(IntRect(IntPoint(), deviceViewportSize()), recordMetricsForFrame);
     occlusionTracker.setMinimumTrackingSize(CCOcclusionTracker::preferredMinimumTrackingSize());
 
     CCLayerIteratorType end = CCLayerIteratorType::end(&renderSurfaceLayerList);
index 1dcdb7e..3a863f7 100644 (file)
@@ -85,7 +85,9 @@ struct CCSettings {
             , threadedAnimationEnabled(false)
             , maxPartialTextureUpdates(std::numeric_limits<size_t>::max())
             , defaultTileSize(IntSize(256, 256))
-            , maxUntiledLayerSize(IntSize(512, 512)) { }
+            , maxUntiledLayerSize(IntSize(512, 512))
+            , deviceScaleFactor(1)
+    { }
 
     bool acceleratePainting;
     bool showFPSCounter;
@@ -100,6 +102,7 @@ struct CCSettings {
     size_t maxPartialTextureUpdates;
     IntSize defaultTileSize;
     IntSize maxUntiledLayerSize;
+    float deviceScaleFactor;
 };
 
 // Provides information on an Impl's rendering capabilities back to the CCLayerTreeHost
@@ -213,6 +216,8 @@ public:
     void setViewportSize(const IntSize&);
 
     const IntSize& viewportSize() const { return m_viewportSize; }
+    // Gives the viewport size in device/content space.
+    const IntSize& deviceViewportSize() const { return m_deviceViewportSize; }
 
     void setPageScaleFactorAndLimits(float pageScaleFactor, float minPageScaleFactor, float maxPageScaleFactor);
 
@@ -281,6 +286,7 @@ private:
     CCSettings m_settings;
 
     IntSize m_viewportSize;
+    IntSize m_deviceViewportSize;
     bool m_visible;
     typedef HashMap<GraphicsContext3D*, RefPtr<RateLimiter> > RateLimiterMap;
     RateLimiterMap m_rateLimiters;
index 49c69be..e7a06aa 100644 (file)
@@ -251,14 +251,16 @@ void CCLayerTreeHostImpl::calculateRenderSurfaceLayerList(CCLayerList& renderSur
     if (!m_rootLayerImpl->renderSurface())
         m_rootLayerImpl->createRenderSurface();
     m_rootLayerImpl->renderSurface()->clearLayerList();
-    m_rootLayerImpl->renderSurface()->setContentRect(IntRect(IntPoint(), viewportSize()));
+    m_rootLayerImpl->renderSurface()->setContentRect(IntRect(IntPoint(), deviceViewportSize()));
 
-    m_rootLayerImpl->setClipRect(IntRect(IntPoint(), viewportSize()));
+    m_rootLayerImpl->setClipRect(IntRect(IntPoint(), deviceViewportSize()));
 
     {
-        TransformationMatrix identityMatrix;
         TRACE_EVENT("CCLayerTreeHostImpl::calcDrawEtc", this, 0);
-        CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(m_rootLayerImpl.get(), m_rootLayerImpl.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, m_rootLayerImpl->renderSurface()->layerList(), &m_layerSorter, layerRendererCapabilities().maxTextureSize);
+        TransformationMatrix identityMatrix;
+        TransformationMatrix deviceScaleTransform;
+        deviceScaleTransform.scale(m_settings.deviceScaleFactor);
+        CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(m_rootLayerImpl.get(), m_rootLayerImpl.get(), deviceScaleTransform, identityMatrix, renderSurfaceLayerList, m_rootLayerImpl->renderSurface()->layerList(), &m_layerSorter, layerRendererCapabilities().maxTextureSize);
     }
 }
 
@@ -295,7 +297,7 @@ bool CCLayerTreeHostImpl::calculateRenderPasses(CCRenderPassList& passes, CCLaye
     if (layerRendererCapabilities().usingPartialSwap)
         scissorRect = enclosingIntRect(m_rootDamageRect);
     else
-        scissorRect = IntRect(IntPoint(), viewportSize());
+        scissorRect = IntRect(IntPoint(), deviceViewportSize());
 
     bool recordMetricsForFrame = true; // FIXME: In the future, disable this when about:tracing is off.
     CCOcclusionTrackerImpl occlusionTracker(scissorRect, recordMetricsForFrame);
@@ -552,6 +554,10 @@ void CCLayerTreeHostImpl::setViewportSize(const IntSize& viewportSize)
         return;
 
     m_viewportSize = viewportSize;
+
+    m_deviceViewportSize = viewportSize;
+    m_deviceViewportSize.scale(m_settings.deviceScaleFactor);
+
     updateMaxScrollPosition();
 
     if (m_layerRenderer)
@@ -628,8 +634,11 @@ void CCLayerTreeHostImpl::updateMaxScrollPosition()
             viewBounds = clipLayer->bounds();
     }
     viewBounds.scale(1 / m_pageScaleDelta);
+    viewBounds.scale(m_settings.deviceScaleFactor);
 
+    // maxScroll is computed in physical pixels, but scroll positions are in layout pixels.
     IntSize maxScroll = contentSize() - expandedIntSize(viewBounds);
+    maxScroll.scale(1 / m_settings.deviceScaleFactor);
     // The viewport may be larger than the contents in some cases, such as
     // having a vertical scrollbar but no horizontal overflow.
     maxScroll.clampNegativeToZero();
@@ -657,8 +666,13 @@ CCInputHandlerClient::ScrollStatus CCLayerTreeHostImpl::scrollBegin(const IntPoi
         return ScrollFailed;
     }
 
-    IntPoint scrollLayerContentPoint(m_scrollLayerImpl->screenSpaceTransform().inverse().mapPoint(viewportPoint));
-    if (m_scrollLayerImpl->nonFastScrollableRegion().contains(scrollLayerContentPoint)) {
+    IntPoint deviceViewportPoint = viewportPoint;
+    deviceViewportPoint.scale(m_settings.deviceScaleFactor, m_settings.deviceScaleFactor);
+
+    // The inverse of the screen space transform takes us from physical pixels to layout pixels.
+    IntPoint scrollLayerPoint(m_scrollLayerImpl->screenSpaceTransform().inverse().mapPoint(deviceViewportPoint));
+
+    if (m_scrollLayerImpl->nonFastScrollableRegion().contains(scrollLayerPoint)) {
         TRACE_EVENT("scrollBegin Failed nonFastScrollableRegion", this, 0);
         return ScrollFailed;
     }
@@ -757,8 +771,9 @@ void CCLayerTreeHostImpl::computePinchZoomDeltas(CCScrollAndScaleSet* scrollInfo
     FloatSize scrollEnd = scrollBegin + anchor;
     scrollEnd.scale(m_minPageScale / scaleBegin);
     scrollEnd -= anchor;
-    scrollEnd = scrollEnd.shrunkTo(roundedIntSize(scaledContentsSize - m_viewportSize)).expandedTo(FloatSize(0, 0));
+    scrollEnd = scrollEnd.shrunkTo(roundedIntSize(scaledContentsSize - m_deviceViewportSize)).expandedTo(FloatSize(0, 0));
     scrollEnd.scale(1 / pageScaleDeltaToSend);
+    scrollEnd.scale(m_settings.deviceScaleFactor);
 
     makeScrollAndScaleSet(scrollInfo, roundedIntSize(scrollEnd), m_minPageScale);
 }
index 13a8cd6..9333c16 100644 (file)
@@ -105,7 +105,7 @@ public:
     void didDrawAllLayers(const FrameData&);
 
     // LayerRendererChromiumClient implementation
-    virtual const IntSize& viewportSize() const OVERRIDE { return m_viewportSize; }
+    virtual const IntSize& deviceViewportSize() const OVERRIDE { return m_deviceViewportSize; }
     virtual const CCSettings& settings() const OVERRIDE { return m_settings; }
     virtual void didLoseContext() OVERRIDE;
     virtual void onSwapBuffersComplete() OVERRIDE;
@@ -144,10 +144,11 @@ public:
     int sourceFrameNumber() const { return m_sourceFrameNumber; }
     void setSourceFrameNumber(int frameNumber) { m_sourceFrameNumber = frameNumber; }
 
+    const IntSize& viewportSize() const { return m_viewportSize; }
     void setViewportSize(const IntSize&);
 
-    void setPageScaleFactorAndLimits(float pageScale, float minPageScale, float maxPageScale);
     float pageScale() const { return m_pageScale; }
+    void setPageScaleFactorAndLimits(float pageScale, float minPageScale, float maxPageScale);
 
     PassOwnPtr<CCScrollAndScaleSet> processScrollDeltas();
 
@@ -170,6 +171,9 @@ protected:
     void animatePageScale(double monotonicTime);
     void animateGestures(double monotonicTime);
 
+    // Exposed for testing.
+    void calculateRenderSurfaceLayerList(CCLayerList&);
+
     // Virtual for testing.
     virtual void animateLayers(double monotonicTime, double wallClockTime);
 
@@ -187,7 +191,6 @@ private:
     void adjustScrollsForPageScaleChange(float);
     void updateMaxScrollPosition();
     void trackDamageForAllSurfaces(CCLayerImpl* rootDrawLayer, const CCLayerList& renderSurfaceLayerList);
-    void calculateRenderSurfaceLayerList(CCLayerList&);
 
     // Returns false if the frame should not be displayed. This function should
     // only be called from prepareToDraw, as didDrawAllLayers must be called
@@ -205,6 +208,7 @@ private:
     CCLayerImpl* m_scrollLayerImpl;
     CCSettings m_settings;
     IntSize m_viewportSize;
+    IntSize m_deviceViewportSize;
     bool m_visible;
 
     OwnPtr<CCHeadsUpDisplay> m_headsUpDisplay;
index 9924f4d..eb80020 100644 (file)
@@ -1,3 +1,60 @@
+2012-05-17  Dana Jansens  <danakj@chromium.org>
+
+        [chromium] Scale all compositor output by the defaultDeviceScaleFactor
+        https://bugs.webkit.org/show_bug.cgi?id=86051
+
+        Reviewed by James Robinson.
+
+        Add the applyDefaultDeviceScaleInCompositor setting. When enabled, we
+        apply the scale factor during compositing instead of applying it through
+        the pageScaleFactor.
+
+        NonCompositedContentHost is the GraphicLayerClient for the GraphicsLayer
+        containing the document's body. It needs to report the page/device scale
+        that should be used when scaling the contents of the GraphicsLayer, and
+        when changes occur to them such that its contentsSize or contentsScale
+        is affected.
+
+        Store the deviceScaleFactor being used in the compositor. The remainder
+        of the deviceScaleFactor() is being applied to the pageScale.
+
+        * public/WebSettings.h:
+        * src/NonCompositedContentHost.cpp:
+        (WebKit::NonCompositedContentHost::NonCompositedContentHost):
+        (WebKit::NonCompositedContentHost::setViewport):
+        * src/NonCompositedContentHost.h:
+        (NonCompositedContentHost):
+        * src/WebLayerTreeView.cpp:
+        (WebKit::WebLayerTreeView::Settings::operator CCSettings):
+        * src/WebSettingsImpl.cpp:
+        (WebKit::WebSettingsImpl::setApplyDefaultDeviceScaleFactorInCompositor):
+        (WebKit):
+        * src/WebSettingsImpl.h:
+        (WebSettingsImpl):
+        (WebKit::WebSettingsImpl::applyDefaultDeviceScaleFactorInCompositor):
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::WebViewImpl):
+        (WebKit::WebViewImpl::setPageScaleFactor):
+        (WebKit::WebViewImpl::setDeviceScaleFactor):
+        (WebKit::WebViewImpl::enableFixedLayoutMode):
+        (WebKit::WebViewImpl::computePageScaleFactorLimits):
+        (WebKit::WebViewImpl::setIsAcceleratedCompositingActive):
+        (WebKit::WebViewImpl::updateLayerTreeViewport):
+        * src/WebViewImpl.h:
+        * tests/CCLayerTreeHostTest.cpp:
+        (MockLayerTreeHostImpl):
+        (WTF::MockLayerTreeHost::createLayerTreeHostImpl):
+        (CCLayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers):
+        (WTF::CCLayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers::CCLayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers):
+        (WTF::CCLayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers::beginTest):
+        (WTF::CCLayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers::commitCompleteOnCCThread):
+        (WTF::CCLayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers::afterTest):
+        (WTF):
+        (WTF::TEST_F):
+        * tests/LayerRendererChromiumTest.cpp:
+        * tests/WebFrameTest.cpp:
+        (WebKit::TEST_F):
+
 2012-05-17  Vangelis Kokkevis  <vangelis@chromium.org>
 
         Expose layer tiling size options to WebSettings.
index 17bb909..7e11141 100644 (file)
@@ -64,6 +64,7 @@ public:
     virtual void setMinimumFontSize(int) = 0;
     virtual void setMinimumLogicalFontSize(int) = 0;
     virtual void setDefaultDeviceScaleFactor(int) = 0;
+    virtual void setApplyDefaultDeviceScaleFactorInCompositor(bool) = 0;
     virtual void setDefaultTextEncodingName(const WebString&) = 0;
     virtual void setJavaScriptEnabled(bool) = 0;
     virtual void setWebSecurityEnabled(bool) = 0;
index 6d11d8a..b1eecdd 100644 (file)
@@ -39,6 +39,7 @@ namespace WebKit {
 NonCompositedContentHost::NonCompositedContentHost(PassOwnPtr<WebCore::LayerPainterChromium> contentPaint)
     : m_contentPaint(contentPaint)
     , m_showDebugBorders(false)
+    , m_deviceScaleFactor(1.0)
 {
     m_graphicsLayer = WebCore::GraphicsLayer::create(this);
 #ifndef NDEBUG
@@ -92,7 +93,7 @@ static void reserveScrollbarLayers(WebCore::LayerChromium* layer, WebCore::Layer
         layer->setAlwaysReserveTextures(true);
 }
 
-void NonCompositedContentHost::setViewport(const WebCore::IntSize& viewportSize, const WebCore::IntSize& contentsSize, const WebCore::IntPoint& scrollPosition, float pageScale, int layerAdjustX)
+void NonCompositedContentHost::setViewport(const WebCore::IntSize& viewportSize, const WebCore::IntSize& contentsSize, const WebCore::IntPoint& scrollPosition, float deviceScale, int layerAdjustX)
 {
     if (!scrollLayer())
         return;
@@ -105,6 +106,8 @@ void NonCompositedContentHost::setViewport(const WebCore::IntSize& viewportSize,
     // Due to the possibility of pinch zoom, the noncomposited layer is always
     // assumed to be scrollable.
     scrollLayer()->setScrollable(true);
+    m_deviceScaleFactor = deviceScale;
+    m_graphicsLayer->deviceOrPageScaleFactorChanged();
     m_graphicsLayer->setSize(contentsSize);
 
     m_layerAdjustX = layerAdjustX;
@@ -119,9 +122,6 @@ void NonCompositedContentHost::setViewport(const WebCore::IntSize& viewportSize,
     } else if (visibleRectChanged)
         m_graphicsLayer->setNeedsDisplay();
 
-    if (m_graphicsLayer->pageScaleFactor() != pageScale)
-        m_graphicsLayer->deviceOrPageScaleFactorChanged();
-
     WebCore::LayerChromium* clipLayer = scrollLayer()->parent();
     WebCore::LayerChromium* rootLayer = clipLayer;
     while (rootLayer->parent())
index be9f509..ace408a 100644 (file)
@@ -57,7 +57,7 @@ public:
     void invalidateRect(const WebCore::IntRect&);
     void setBackgroundColor(const WebCore::Color&);
     void setScrollLayer(WebCore::GraphicsLayer*);
-    void setViewport(const WebCore::IntSize& viewportSize, const WebCore::IntSize& contentsSize, const WebCore::IntPoint& scrollPosition, float pageScale, int layerAdjustX);
+    void setViewport(const WebCore::IntSize& viewportSize, const WebCore::IntSize& contentsSize, const WebCore::IntPoint& scrollPosition, float deviceScale, int layerAdjustX);
     void protectVisibleTileTextures();
     WebCore::GraphicsLayer* topLevelRootLayer() const { return m_graphicsLayer.get(); }
 
@@ -73,6 +73,11 @@ 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; }
 
     WebCore::LayerChromium* scrollLayer();
 
@@ -81,6 +86,7 @@ private:
     WebCore::IntSize m_viewportSize;
     int m_layerAdjustX;
     bool m_showDebugBorders;
+    float m_deviceScaleFactor;
 };
 
 } // namespace WebKit
index 8d53b71..a4d7d91 100644 (file)
@@ -50,6 +50,7 @@ WebLayerTreeView::Settings::operator CCSettings() const
     settings.threadedAnimationEnabled = threadedAnimationEnabled;
     settings.defaultTileSize = defaultTileSize;
     settings.maxUntiledLayerSize = maxUntiledLayerSize;
+    settings.deviceScaleFactor = deviceScaleFactor;
 
     // FIXME: showFPSCounter / showPlatformLayerTree / maxPartialTextureUpdates aren't supported currently.
     return settings;
index 4db30fa..a9b729d 100644 (file)
@@ -51,6 +51,7 @@ WebSettingsImpl::WebSettingsImpl(Settings* settings)
     , m_showPlatformLayerTree(false)
     , m_showPaintRects(false)
     , m_viewportEnabled(false)
+    , m_applyDefaultDeviceScaleFactorInCompositor(false)
     , m_defaultTileSize(WebSize(256, 256))
     , m_maxUntiledLayerSize(WebSize(512, 512))
 {
@@ -117,6 +118,11 @@ void WebSettingsImpl::setDefaultDeviceScaleFactor(int defaultDeviceScaleFactor)
     m_settings->setDefaultDeviceScaleFactor(defaultDeviceScaleFactor);
 }
 
+void WebSettingsImpl::setApplyDefaultDeviceScaleFactorInCompositor(bool applyDefaultDeviceScaleFactorInCompositor)
+{
+    m_applyDefaultDeviceScaleFactorInCompositor = applyDefaultDeviceScaleFactorInCompositor;
+}
+
 void WebSettingsImpl::setDefaultTextEncodingName(const WebString& encoding)
 {
     m_settings->setDefaultTextEncodingName((String)encoding);
index a1f97ca..ebea771 100644 (file)
@@ -55,6 +55,7 @@ public:
     virtual void setMinimumFontSize(int);
     virtual void setMinimumLogicalFontSize(int);
     virtual void setDefaultDeviceScaleFactor(int);
+    virtual void setApplyDefaultDeviceScaleFactorInCompositor(bool);
     virtual void setDefaultTextEncodingName(const WebString&);
     virtual void setJavaScriptEnabled(bool);
     virtual void setWebSecurityEnabled(bool);
@@ -146,6 +147,7 @@ public:
     bool showFPSCounter() const { return m_showFPSCounter; }
     bool showPlatformLayerTree() const { return m_showPlatformLayerTree; }
     bool showPaintRects() const { return m_showPaintRects; }
+    bool applyDefaultDeviceScaleFactorInCompositor() const { return m_applyDefaultDeviceScaleFactorInCompositor; }
     WebSize defaultTileSize() const { return m_defaultTileSize; }
     WebSize maxUntiledLayerSize() const { return m_maxUntiledLayerSize; }
 
@@ -155,6 +157,7 @@ private:
     bool m_showPlatformLayerTree;
     bool m_showPaintRects;
     bool m_viewportEnabled;
+    bool m_applyDefaultDeviceScaleFactorInCompositor;
     WebSize m_defaultTileSize;
     WebSize m_maxUntiledLayerSize;
 };
index e1b02e3..3b35b45 100644 (file)
@@ -396,6 +396,7 @@ WebViewImpl::WebViewImpl(WebViewClient* client)
     , m_compositorCreationFailed(false)
     , m_recreatingGraphicsContext(false)
     , m_compositorSurfaceReady(false)
+    , m_deviceScaleInCompositor(1)
 #endif
 #if ENABLE(INPUT_SPEECH)
     , m_speechInputClient(SpeechInputClientImpl::create(client))
@@ -2361,6 +2362,12 @@ void WebViewImpl::setPageScaleFactor(float scaleFactor, const WebPoint& origin)
     if (!scaleFactor)
         scaleFactor = 1;
 
+    if (m_deviceScaleInCompositor != 1) {
+        // Don't allow page scaling when compositor scaling is being used,
+        // as they are currently incompatible.
+        ASSERT(scaleFactor == 1);
+    }
+
     scaleFactor = clampPageScaleFactorToLimits(scaleFactor);
     WebPoint clampedOrigin = clampOffsetAtScale(origin, scaleFactor);
     page()->setPageScaleFactor(scaleFactor, clampedOrigin);
@@ -2381,6 +2388,13 @@ void WebViewImpl::setDeviceScaleFactor(float scaleFactor)
         return;
 
     page()->setDeviceScaleFactor(scaleFactor);
+
+    if (m_deviceScaleInCompositor != 1) {
+        // Don't allow page scaling when compositor scaling is being used,
+        // as they are currently incompatible. This means the deviceScale
+        // needs to match the one in the compositor.
+        ASSERT(scaleFactor == m_deviceScaleInCompositor);
+    }
 }
 
 bool WebViewImpl::isFixedLayoutModeEnabled() const
@@ -2408,10 +2422,8 @@ void WebViewImpl::enableFixedLayoutMode(bool enable)
 
 #if USE(ACCELERATED_COMPOSITING)
     // Also notify the base layer, which RenderLayerCompositor does not see.
-    if (m_nonCompositedContentHost) {
-        m_nonCompositedContentHost->topLevelRootLayer()->deviceOrPageScaleFactorChanged();
+    if (m_nonCompositedContentHost)
         updateLayerTreeViewport();
-    }
 #endif
 }
 
@@ -2445,8 +2457,8 @@ bool WebViewImpl::computePageScaleFactorLimits()
     if (!mainFrame() || !page() || !page()->mainFrame() || !page()->mainFrame()->view())
         return false;
 
-    m_minimumPageScaleFactor = min(max(m_pageDefinedMinimumPageScaleFactor, minPageScaleFactor), maxPageScaleFactor) * deviceScaleFactor();
-    m_maximumPageScaleFactor = max(min(m_pageDefinedMaximumPageScaleFactor, maxPageScaleFactor), minPageScaleFactor) * deviceScaleFactor();
+    m_minimumPageScaleFactor = min(max(m_pageDefinedMinimumPageScaleFactor, minPageScaleFactor), maxPageScaleFactor) * (deviceScaleFactor() / m_deviceScaleInCompositor);
+    m_maximumPageScaleFactor = max(min(m_pageDefinedMaximumPageScaleFactor, maxPageScaleFactor), minPageScaleFactor) * (deviceScaleFactor() / m_deviceScaleInCompositor);
 
     int viewWidthNotIncludingScrollbars = page()->mainFrame()->view()->visibleContentRect(false).width();
     int contentsWidth = mainFrame()->contentsSize().width;
@@ -3395,6 +3407,17 @@ void WebViewImpl::setIsAcceleratedCompositingActive(bool active)
         m_nonCompositedContentHost = NonCompositedContentHost::create(WebViewImplContentPainter::create(this));
         m_nonCompositedContentHost->setShowDebugBorders(page()->settings()->showDebugBorders());
 
+        if (m_webSettings->applyDefaultDeviceScaleFactorInCompositor() && page()->settings()->defaultDeviceScaleFactor() != 1) {
+            ASSERT(page()->settings()->defaultDeviceScaleFactor());
+
+            m_deviceScaleInCompositor = page()->settings()->defaultDeviceScaleFactor();
+            layerTreeViewSettings.deviceScaleFactor = m_deviceScaleInCompositor;
+            setDeviceScaleFactor(m_deviceScaleInCompositor);
+            // When applying a scale factor in the compositor, we disallow page
+            // scaling as they are currently incompatible.
+            setPageScaleFactorLimits(1, 1);
+        }
+
         m_layerTreeView.initialize(this, m_rootLayer, layerTreeViewSettings);
         if (!m_layerTreeView.isNull()) {
             m_layerTreeView.setPageScaleFactorAndLimits(pageScaleFactor(), m_minimumPageScaleFactor, m_maximumPageScaleFactor);
@@ -3538,7 +3561,12 @@ void WebViewImpl::updateLayerTreeViewport()
         // layer.
         layerAdjustX = -view->contentsSize().width() + view->visibleContentRect(false).width();
     }
-    m_nonCompositedContentHost->setViewport(visibleRect.size(), view->contentsSize(), scroll, pageScaleFactor(), layerAdjustX);
+
+    // 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, deviceScale, layerAdjustX);
+
     m_layerTreeView.setViewportSize(size());
     m_layerTreeView.setPageScaleFactorAndLimits(pageScaleFactor(), m_minimumPageScaleFactor, m_maximumPageScaleFactor);
 }
index 06d7438..856a57a 100644 (file)
@@ -778,6 +778,7 @@ private:
     // If true, the graphics context is being restored.
     bool m_recreatingGraphicsContext;
     bool m_compositorSurfaceReady;
+    float m_deviceScaleInCompositor;
 #endif
     static const WebInputEvent* m_currentInputEvent;
 
index a560be8..77a3b82 100644 (file)
@@ -58,6 +58,12 @@ using namespace WebKit;
 using namespace WebKitTests;
 using namespace WTF;
 
+#define EXPECT_EQ_RECT(a, b) \
+    EXPECT_EQ(a.x(), b.x()); \
+    EXPECT_EQ(a.y(), b.y()); \
+    EXPECT_EQ(a.width(), b.width()); \
+    EXPECT_EQ(a.height(), b.height());
+
 namespace {
 
 // Used by test stubs to notify the test when something interesting happens.
@@ -113,6 +119,10 @@ public:
         m_testHooks->drawLayersOnCCThread(this);
     }
 
+    // Make these public.
+    typedef Vector<CCLayerImpl*> CCLayerList;
+    using CCLayerTreeHostImpl::calculateRenderSurfaceLayerList;
+
 protected:
     virtual void animateLayers(double monotonicTime, double wallClockTime)
     {
@@ -156,9 +166,9 @@ public:
     virtual PassOwnPtr<CCLayerTreeHostImpl> createLayerTreeHostImpl(CCLayerTreeHostImplClient* client)
     {
         // For these tests, we will enable threaded animations.
-        CCSettings settings;
-        settings.threadedAnimationEnabled = true;
-        return MockLayerTreeHostImpl::create(m_testHooks, settings, client);
+        CCSettings copySettings = settings();
+        copySettings.threadedAnimationEnabled = true;
+        return MockLayerTreeHostImpl::create(m_testHooks, copySettings, client);
     }
 
 private:
@@ -1744,6 +1754,114 @@ public:
     void notifySyncRequired() { }
 };
 
+class CCLayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers : public CCLayerTreeHostTest {
+public:
+
+    CCLayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers()
+        : m_rootLayer(ContentLayerChromium::create(&m_delegate))
+        , m_childLayer(ContentLayerChromium::create(&m_delegate))
+    {
+        m_settings.deviceScaleFactor = 1.5;
+    }
+
+    virtual void beginTest()
+    {
+        // The device viewport should be scaled by the device scale factor.
+        m_layerTreeHost->setViewportSize(IntSize(40, 40));
+        EXPECT_EQ(IntSize(40, 40), m_layerTreeHost->viewportSize());
+        EXPECT_EQ(IntSize(60, 60), m_layerTreeHost->deviceViewportSize());
+
+        m_rootLayer->addChild(m_childLayer);
+
+        m_rootLayer->setIsDrawable(true);
+        m_rootLayer->setBounds(IntSize(30, 30));
+        m_rootLayer->setAnchorPoint(FloatPoint(0, 0));
+
+        m_childLayer->setIsDrawable(true);
+        m_childLayer->setPosition(IntPoint(2, 2));
+        m_childLayer->setBounds(IntSize(10, 10));
+        m_childLayer->setAnchorPoint(FloatPoint(0, 0));
+
+        m_layerTreeHost->setRootLayer(m_rootLayer);
+    }
+
+    virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl* impl)
+    {
+        // Get access to protected methods.
+        MockLayerTreeHostImpl* mockImpl = static_cast<MockLayerTreeHostImpl*>(impl);
+
+        // Should only do one commit.
+        EXPECT_EQ(0, impl->sourceFrameNumber());
+        // Device scale factor should come over to impl.
+        EXPECT_NEAR(impl->settings().deviceScaleFactor, 1.5, 0.00001);
+
+        // Both layers are on impl.
+        ASSERT_EQ(1u, impl->rootLayer()->children().size());
+
+        // Device viewport is scaled.
+        EXPECT_EQ(IntSize(40, 40), impl->viewportSize());
+        EXPECT_EQ(IntSize(60, 60), impl->deviceViewportSize());
+
+        CCLayerImpl* root = impl->rootLayer();
+        CCLayerImpl* child = impl->rootLayer()->children()[0].get();
+
+        // Positions remain in layout pixels.
+        EXPECT_EQ(IntPoint(0, 0), root->position());
+        EXPECT_EQ(IntPoint(2, 2), child->position());
+
+        // Compute all the layer transforms for the frame.
+        MockLayerTreeHostImpl::CCLayerList renderSurfaceLayerList;
+        mockImpl->calculateRenderSurfaceLayerList(renderSurfaceLayerList);
+
+        // Both layers should be drawing into the root render surface.
+        ASSERT_EQ(1u, renderSurfaceLayerList.size());
+        ASSERT_EQ(root->renderSurface(), renderSurfaceLayerList[0]->renderSurface());
+        ASSERT_EQ(2u, root->renderSurface()->layerList().size());
+
+        // The root render surface is the size of the viewport.
+        EXPECT_EQ_RECT(IntRect(0, 0, 60, 60), root->renderSurface()->contentRect());
+
+        TransformationMatrix scaleTransform;
+        scaleTransform.scale(impl->settings().deviceScaleFactor);
+
+        // The root layer is scaled by 2x.
+        TransformationMatrix rootScreenSpaceTransform = scaleTransform;
+        TransformationMatrix rootDrawTransform = scaleTransform;
+        rootDrawTransform.translate(root->bounds().width() * 0.5, root->bounds().height() * 0.5);
+
+        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.
+        TransformationMatrix childScreenSpaceTransform = scaleTransform;
+        childScreenSpaceTransform.translate(2, 2);
+        TransformationMatrix childDrawTransform = scaleTransform;
+        childDrawTransform.translate(2, 2);
+        childDrawTransform.translate(child->bounds().width() * 0.5, child->bounds().height() * 0.5);
+
+        EXPECT_EQ(childDrawTransform, child->drawTransform());
+        EXPECT_EQ(childScreenSpaceTransform, child->screenSpaceTransform());
+
+        endTest();
+    }
+
+    virtual void afterTest()
+    {
+        m_rootLayer.clear();
+        m_childLayer.clear();
+    }
+
+private:
+    MockContentLayerDelegate m_delegate;
+    RefPtr<ContentLayerChromium> m_rootLayer;
+    RefPtr<ContentLayerChromium> m_childLayer;
+};
+
+TEST_F(CCLayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers, runMultiThread)
+{
+    runTest(true);
+}
+
 // Verify atomicity of commits and reuse of textures.
 class CCLayerTreeHostTestAtomicCommit : public CCLayerTreeHostTest {
 public:
@@ -1997,12 +2115,6 @@ TEST_F(CCLayerTreeHostTestAtomicCommitWithPartialUpdate, runMultiThread)
     runTest(true);
 }
 
-#define EXPECT_EQ_RECT(a, b) \
-    EXPECT_EQ(a.x(), b.x()); \
-    EXPECT_EQ(a.y(), b.y()); \
-    EXPECT_EQ(a.width(), b.width()); \
-    EXPECT_EQ(a.height(), b.height());
-
 class TestLayerChromium : public LayerChromium {
 public:
     static PassRefPtr<TestLayerChromium> create() { return adoptRef(new TestLayerChromium()); }
index 13f04a2..8445feb 100644 (file)
@@ -71,7 +71,7 @@ public:
     }
 
     // LayerRendererChromiumClient methods.
-    virtual const IntSize& viewportSize() const OVERRIDE { static IntSize fakeSize; return fakeSize; }
+    virtual const IntSize& deviceViewportSize() const OVERRIDE { static IntSize fakeSize; return fakeSize; }
     virtual const CCSettings& settings() const OVERRIDE { static CCSettings fakeSettings; return fakeSettings; }
     virtual void didLoseContext() OVERRIDE { }
     virtual void onSwapBuffersComplete() OVERRIDE { }
index f687a84..74251f3 100644 (file)
 
 #include "config.h"
 
+#include "WebFrame.h"
+
+#include "Frame.h"
 #include "FrameTestHelpers.h"
 #include "ResourceError.h"
 #include "WebDocument.h"
 #include "WebFindOptions.h"
 #include "WebFormElement.h"
-#include "WebFrame.h"
 #include "WebFrameClient.h"
 #include "WebRange.h"
 #include "WebScriptSource.h"
@@ -233,11 +235,18 @@ TEST_F(WebFrameTest, DeviceScaleFactorUsesDefaultWithoutViewportTag)
     webView->layout();
 
     EXPECT_EQ(2, webView->deviceScaleFactor());
+
+    // Device scale factor should be a component of page scale factor in fixed-layout, so a scale of 1 becomes 2.
+    webView->setPageScaleFactorLimits(1, 2);
+    EXPECT_EQ(2, webView->pageScaleFactor());
+
+    // Force the layout to happen before leaving the test.
+    webView->mainFrame()->contentAsText(1024).utf8();
 }
 #endif
 
 #if ENABLE(GESTURE_EVENTS)
-TEST_F(WebFrameTest, FAILS_DivAutoZoomParamsTest)
+TEST_F(WebFrameTest, DivAutoZoomParamsTest)
 {
     registerMockedHttpURLLoad("get_scale_for_auto_zoom_into_div_test.html");
 
@@ -297,7 +306,6 @@ TEST_F(WebFrameTest, FAILS_DivAutoZoomParamsTest)
     webViewImpl->computeScaleAndScrollForHitRect(doubleTapPoint, WebViewImpl::DoubleTap, scale, scroll);
     EXPECT_FLOAT_EQ(3, scale);
 
-
     // Test for Non-doubletap scaling
     webViewImpl->setPageScaleFactor(1, WebPoint(0, 0));
     webViewImpl->setDeviceScaleFactor(4);
@@ -305,6 +313,9 @@ TEST_F(WebFrameTest, FAILS_DivAutoZoomParamsTest)
     // Test zooming into div.
     webViewImpl->computeScaleAndScrollForHitRect(WebRect(250, 250, 10, 10), WebViewImpl::FindInPage, scale, scroll);
     EXPECT_NEAR(pageWidth / divWidth, scale, 0.1);
+
+    // Drop any pending fake mouse events from zooming before leaving the test.
+    webViewImpl->page()->mainFrame()->eventHandler()->clear();
 }
 #endif