Bug 732971 - For Fennec move the resolution from the top-level presShell to the content presShell. r=BenWa

The bulk of this patch is fixing up pieces of code that infer the resolution
as the inverse of the scaling transform on the root layer. This used to be
how various bits of gfx code obtained the resolution, but now that we can set
the resolution on the actual presShell that contains the content, we can also
just read the resolution from the FrameMetrics directly.
This commit is contained in:
Kartikaya Gupta 2013-10-29 09:27:50 -04:00
Родитель 5b8181c580
Коммит b6add35df3
7 изменённых файлов: 17 добавлений и 55 удалений

Просмотреть файл

@ -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;

Просмотреть файл

@ -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]);
}
}
}

Просмотреть файл

@ -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.

Просмотреть файл

@ -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 =

Просмотреть файл

@ -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 =

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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);
}