Bug 1035598 - Apply async scale correctly to ContainerLayers whose content does not start at the origin. r=kats,mattwoodrow

This commit is contained in:
Botond Ballo
2014-07-22 18:10:54 -04:00
parent 397792585f
commit aa52ff7f09

View File

@@ -509,9 +509,25 @@ SampleAnimations(Layer* aLayer, TimeStamp aPoint)
}
Matrix4x4
CombineWithCSSTransform(const gfx3DMatrix& treeTransform, Layer* aLayer)
AdjustAndCombineWithCSSTransform(const gfx3DMatrix& asyncTransform, Layer* aLayer)
{
return ToMatrix4x4(treeTransform) * aLayer->GetTransform();
Matrix4x4 result = ToMatrix4x4(asyncTransform);
// Container layers start at the origin, but they are clipped to where they
// actually have content on the screen. The tree transform is meant to apply
// to the clipped area. If the tree transform includes a scale component,
// then applying it to container as-is will produce incorrect results. To
// avoid this, translate the layer so that the clip rect starts at the origin,
// apply the tree transform, and translate back.
if (const nsIntRect* shadowClipRect = aLayer->AsLayerComposite()->GetShadowClipRect()) {
if (shadowClipRect->TopLeft() != nsIntPoint()) { // avoid a gratuitous change of basis
result.ChangeBasis(shadowClipRect->x, shadowClipRect->y, 0);
}
}
// Combine the async transform with the layer's CSS transform.
result = result * aLayer->GetTransform();
return result;
}
bool
@@ -535,11 +551,11 @@ AsyncCompositionManager::ApplyAsyncContentTransformToTree(TimeStamp aCurrentFram
LayerComposite* layerComposite = aLayer->AsLayerComposite();
Matrix4x4 oldTransform = aLayer->GetTransform();
ViewTransform treeTransformWithoutOverscroll, overscrollTransform;
ViewTransform asyncTransformWithoutOverscroll, overscrollTransform;
ScreenPoint scrollOffset;
*aWantNextFrame |=
controller->SampleContentTransformForFrame(aCurrentFrame,
&treeTransformWithoutOverscroll,
&asyncTransformWithoutOverscroll,
scrollOffset,
&overscrollTransform);
@@ -549,7 +565,7 @@ AsyncCompositionManager::ApplyAsyncContentTransformToTree(TimeStamp aCurrentFram
metrics.mDisplayPort : metrics.mCriticalDisplayPort);
LayerMargin fixedLayerMargins(0, 0, 0, 0);
ScreenPoint offset(0, 0);
SyncFrameMetrics(scrollOffset, treeTransformWithoutOverscroll.mScale.scale,
SyncFrameMetrics(scrollOffset, asyncTransformWithoutOverscroll.mScale.scale,
metrics.mScrollableRect, mLayersUpdated, displayPort,
paintScale, mIsFirstPaint, fixedLayerMargins, offset);
@@ -559,8 +575,8 @@ AsyncCompositionManager::ApplyAsyncContentTransformToTree(TimeStamp aCurrentFram
// Apply the render offset
mLayerManager->GetCompositor()->SetScreenRenderOffset(offset);
Matrix4x4 transform = CombineWithCSSTransform(
treeTransformWithoutOverscroll * overscrollTransform, aLayer);
Matrix4x4 transform = AdjustAndCombineWithCSSTransform(
asyncTransformWithoutOverscroll * overscrollTransform, aLayer);
// GetTransform already takes the pre- and post-scale into account. Since we
// will apply the pre- and post-scale again when computing the effective
@@ -584,8 +600,8 @@ AsyncCompositionManager::ApplyAsyncContentTransformToTree(TimeStamp aCurrentFram
// the overscroll transform when computing the 'aCurrentTransformForRoot'
// parameter. This ensures that the overscroll transform is not unapplied,
// and therefore that the visual effect applies to fixed and sticky layers.
Matrix4x4 transformWithoutOverscroll = CombineWithCSSTransform(
treeTransformWithoutOverscroll, aLayer);
Matrix4x4 transformWithoutOverscroll = AdjustAndCombineWithCSSTransform(
asyncTransformWithoutOverscroll, aLayer);
AlignFixedAndStickyLayers(aLayer, aLayer, oldTransform,
transformWithoutOverscroll, fixedLayerMargins);
@@ -654,9 +670,9 @@ ApplyAsyncTransformToScrollbarForContent(TimeStamp aCurrentFrame, ContainerLayer
// block accomplishes that and throws away the temp variables.
// TODO: it might be cleaner to do a pass through the layer tree to advance all the APZC
// transforms before updating the layer shadow transforms. That will allow removal of this code.
ViewTransform treeTransform;
ViewTransform asyncTransform;
ScreenPoint scrollOffset;
apzc->SampleContentTransformForFrame(aCurrentFrame, &treeTransform, scrollOffset);
apzc->SampleContentTransformForFrame(aCurrentFrame, &asyncTransform, scrollOffset);
}
gfx3DMatrix asyncTransform = gfx3DMatrix(apzc->GetCurrentAsyncTransform());