diff --git a/gfx/layers/client/ClientLayerManager.cpp b/gfx/layers/client/ClientLayerManager.cpp index 9e7f1ff27d9e..c38c97698f97 100644 --- a/gfx/layers/client/ClientLayerManager.cpp +++ b/gfx/layers/client/ClientLayerManager.cpp @@ -445,9 +445,7 @@ ClientLayerManager::ProgressiveUpdateCallback(bool aHasPendingNewThebesContent, // This is derived from the code in // gfx/layers/ipc/CompositorParent.cpp::TransformShadowTree. - const gfx3DMatrix& rootTransform = GetRoot()->GetTransform(); - CSSToLayerScale paintScale = metrics.mDevPixelsPerCSSPixel - / LayerToLayoutDeviceScale(rootTransform.GetXScale(), rootTransform.GetYScale()); + CSSToLayerScale paintScale = metrics.LayersPixelsPerCSSPixel(); const CSSRect& metricsDisplayPort = (aDrawingCritical && !metrics.mCriticalDisplayPort.IsEmpty()) ? metrics.mCriticalDisplayPort : metrics.mDisplayPort; diff --git a/gfx/layers/composite/AsyncCompositionManager.cpp b/gfx/layers/composite/AsyncCompositionManager.cpp index a55d4dc75401..7ade94b70776 100644 --- a/gfx/layers/composite/AsyncCompositionManager.cpp +++ b/gfx/layers/composite/AsyncCompositionManager.cpp @@ -484,14 +484,8 @@ AsyncCompositionManager::ApplyAsyncContentTransformToTree(TimeStamp aCurrentFram &treeTransform, scrollOffset); - const gfx3DMatrix& rootTransform = mLayerManager->GetRoot()->GetTransform(); const FrameMetrics& metrics = container->GetFrameMetrics(); - // XXX We use rootTransform instead of metrics.mResolution here because on - // Fennec the resolution is set on the root layer rather than the scrollable layer. - // The SyncFrameMetrics call and the paintScale variable are used on Fennec only - // so it doesn't affect any other platforms. See bug 732971. - CSSToLayerScale paintScale = metrics.mDevPixelsPerCSSPixel - / LayerToLayoutDeviceScale(rootTransform.GetXScale(), rootTransform.GetYScale()); + CSSToLayerScale paintScale = metrics.LayersPixelsPerCSSPixel(); CSSRect displayPort(metrics.mCriticalDisplayPort.IsEmpty() ? metrics.mDisplayPort : metrics.mCriticalDisplayPort); LayerMargin fixedLayerMargins(0, 0, 0, 0); @@ -522,15 +516,7 @@ AsyncCompositionManager::ApplyAsyncContentTransformToTree(TimeStamp aCurrentFram // Apply resolution scaling to the old transform - the layer tree as it is // doesn't have the necessary transform to display correctly. -#ifdef MOZ_WIDGET_ANDROID - // XXX We use rootTransform instead of the resolution on the individual layer's - // FrameMetrics on Fennec because the resolution is set on the root layer rather - // than the scrollable layer. See bug 732971. On non-Fennec we do the right thing. - LayoutDeviceToLayerScale resolution(1.0 / rootTransform.GetXScale(), - 1.0 / rootTransform.GetYScale()); -#else LayoutDeviceToLayerScale resolution = metrics.mCumulativeResolution; -#endif oldTransform.Scale(resolution.scale, resolution.scale, 1); AlignFixedAndStickyLayers(aLayer, aLayer, oldTransform, fixedLayerMargins); @@ -542,7 +528,7 @@ AsyncCompositionManager::ApplyAsyncContentTransformToTree(TimeStamp aCurrentFram } void -AsyncCompositionManager::TransformScrollableLayer(Layer* aLayer, const LayoutDeviceToLayerScale& aResolution) +AsyncCompositionManager::TransformScrollableLayer(Layer* aLayer) { LayerComposite* layerComposite = aLayer->AsLayerComposite(); ContainerLayer* container = aLayer->AsContainerLayer(); @@ -555,7 +541,7 @@ AsyncCompositionManager::TransformScrollableLayer(Layer* aLayer, const LayoutDev gfx3DMatrix treeTransform; - CSSToLayerScale geckoZoom = metrics.mDevPixelsPerCSSPixel * aResolution; + CSSToLayerScale geckoZoom = metrics.LayersPixelsPerCSSPixel(); LayerIntPoint scrollOffsetLayerPixels = RoundedToInt(metrics.mScrollOffset * geckoZoom); @@ -606,9 +592,9 @@ AsyncCompositionManager::TransformScrollableLayer(Layer* aLayer, const LayoutDev // transformation we need to apply. LayerToScreenScale zoomAdjust = userZoom / geckoZoom; - LayerIntPoint geckoScroll(0, 0); + LayerPoint geckoScroll(0, 0); if (metrics.IsScrollable()) { - geckoScroll = scrollOffsetLayerPixels; + geckoScroll = metrics.mScrollOffset * geckoZoom; } LayerPoint translation = (userScroll / zoomAdjust) - geckoScroll; @@ -633,7 +619,7 @@ AsyncCompositionManager::TransformScrollableLayer(Layer* aLayer, const LayoutDev // Apply resolution scaling to the old transform - the layer tree as it is // doesn't have the necessary transform to display correctly. - oldTransform.Scale(aResolution.scale, aResolution.scale, 1); + oldTransform.Scale(metrics.mResolution.scale, metrics.mResolution.scale, 1); // Make sure that overscroll and under-zoom are represented in the old // transform so that fixed position content moves and scales accordingly. @@ -706,18 +692,7 @@ AsyncCompositionManager::TransformShadowTree(TimeStamp aCurrentFrame) for (uint32_t i = 0; i < scrollableLayers.Length(); i++) { if (scrollableLayers[i]) { -#ifdef MOZ_WIDGET_ANDROID - // XXX We use rootTransform instead of the resolution on the individual layer's - // FrameMetrics on Fennec because the resolution is set on the root layer rather - // than the scrollable layer. See bug 732971. On non-Fennec we do the right thing. - const gfx3DMatrix& rootTransform = root->GetTransform(); - LayoutDeviceToLayerScale resolution(1.0 / rootTransform.GetXScale(), - 1.0 / rootTransform.GetYScale()); -#else - LayoutDeviceToLayerScale resolution = - scrollableLayers[i]->AsContainerLayer()->GetFrameMetrics().mCumulativeResolution; -#endif - TransformScrollableLayer(scrollableLayers[i], resolution); + TransformScrollableLayer(scrollableLayers[i]); } } } diff --git a/gfx/layers/composite/AsyncCompositionManager.h b/gfx/layers/composite/AsyncCompositionManager.h index cc636ba09e05..d97c3385f64a 100644 --- a/gfx/layers/composite/AsyncCompositionManager.h +++ b/gfx/layers/composite/AsyncCompositionManager.h @@ -117,7 +117,7 @@ public: bool IsFirstPaint() { return mIsFirstPaint; } private: - void TransformScrollableLayer(Layer* aLayer, const LayoutDeviceToLayerScale& aResolution); + void TransformScrollableLayer(Layer* aLayer); // Return true if an AsyncPanZoomController content transform was // applied for |aLayer|. *aWantNextFrame is set to true if the // controller wants another animation frame. diff --git a/gfx/layers/composite/LayerManagerComposite.cpp b/gfx/layers/composite/LayerManagerComposite.cpp index df14682943c0..9a5edadb4bb3 100644 --- a/gfx/layers/composite/LayerManagerComposite.cpp +++ b/gfx/layers/composite/LayerManagerComposite.cpp @@ -541,14 +541,10 @@ LayerManagerComposite::ComputeRenderIntegrity() Layer* primaryScrollable = GetPrimaryScrollableLayer(); if (primaryScrollable) { // This is derived from the code in - // gfx/layers/ipc/CompositorParent.cpp::TransformShadowTree. - const gfx3DMatrix& rootTransform = root->GetTransform(); - float devPixelRatioX = 1 / rootTransform.GetXScale(); - float devPixelRatioY = 1 / rootTransform.GetYScale(); - - gfx3DMatrix transform = primaryScrollable->GetEffectiveTransform(); - transform.ScalePost(devPixelRatioX, devPixelRatioY, 1); + // AsyncCompositionManager::TransformScrollableLayer const FrameMetrics& metrics = primaryScrollable->AsContainerLayer()->GetFrameMetrics(); + gfx3DMatrix transform = primaryScrollable->GetEffectiveTransform(); + transform.ScalePost(metrics.mResolution.scale, metrics.mResolution.scale, 1); // Clip the screen rect to the document bounds gfxRect documentBounds = diff --git a/gfx/layers/composite/ThebesLayerComposite.cpp b/gfx/layers/composite/ThebesLayerComposite.cpp index 68d8f55d5ff1..06cce91691be 100644 --- a/gfx/layers/composite/ThebesLayerComposite.cpp +++ b/gfx/layers/composite/ThebesLayerComposite.cpp @@ -264,15 +264,10 @@ ThebesLayerComposite::GetCompositionBounds() parentMetrics.mCompositionBounds.width, parentMetrics.mCompositionBounds.height); - // Calculate the scale transform applied to the root layer to determine - // the content resolution. - Layer* rootLayer = Manager()->GetRoot(); - const gfx3DMatrix& rootTransform = rootLayer->GetTransform(); - LayerToCSSScale scale(rootTransform.GetXScale(), - rootTransform.GetYScale()); + const FrameMetrics& metrics = scrollableLayer->GetFrameMetrics(); + LayerToCSSScale scale(1 / metrics.mResolution.scale); // Get the content document bounds, in screen-space. - const FrameMetrics& metrics = scrollableLayer->GetFrameMetrics(); const LayerIntRect content = RoundedToInt(metrics.mScrollableRect / scale); // !!! WTF. this code is just wrong. See bug 881451. gfx::Point scrollOffset = diff --git a/mobile/android/base/gfx/GeckoLayerClient.java b/mobile/android/base/gfx/GeckoLayerClient.java index 967c167be07f..0a6537679c7d 100644 --- a/mobile/android/base/gfx/GeckoLayerClient.java +++ b/mobile/android/base/gfx/GeckoLayerClient.java @@ -470,7 +470,7 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget // Always abort updates if the resolution has changed. There's no use // in drawing at the incorrect resolution. if (!FloatUtils.fuzzyEquals(resolution, viewportMetrics.zoomFactor)) { - Log.d(LOGTAG, "Aborting draw due to resolution change"); + Log.d(LOGTAG, "Aborting draw due to resolution change: " + resolution + " != " + viewportMetrics.zoomFactor); mProgressiveUpdateData.abort = true; return mProgressiveUpdateData; } diff --git a/mobile/android/chrome/content/browser.js b/mobile/android/chrome/content/browser.js index d949dec195cb..c0c9aef56abd 100644 --- a/mobile/android/chrome/content/browser.js +++ b/mobile/android/chrome/content/browser.js @@ -2911,7 +2911,7 @@ Tab.prototype = { // we should never be drawing background tabs at resolutions other than the user- // visible zoom. for foreground tabs, however, if we are drawing at some other // resolution, we need to set the resolution as specified. - let cwu = window.top.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils); + let cwu = this.browser.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils); if (BrowserApp.selectedTab == this) { if (resolution != this._drawZoom) { this._drawZoom = resolution; @@ -2930,8 +2930,6 @@ Tab.prototype = { let geckoScrollY = this.browser.contentWindow.scrollY; aDisplayPort = this._dirtiestHackEverToWorkAroundGeckoRounding(aDisplayPort, geckoScrollX, geckoScrollY); - cwu = this.browser.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils); - let displayPort = { x: (aDisplayPort.left / resolution) - geckoScrollX, y: (aDisplayPort.top / resolution) - geckoScrollY, @@ -3193,7 +3191,7 @@ Tab.prototype = { if (aForce || !fuzzyEquals(aZoom, this._zoom)) { this._zoom = aZoom; if (BrowserApp.selectedTab == this) { - let cwu = window.top.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils); + let cwu = this.browser.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils); this._drawZoom = aZoom; cwu.setResolution(aZoom / window.devicePixelRatio, aZoom / window.devicePixelRatio); }