Bug 732091 - Part 5: Make the compositor notify Java when the page size changes or when a first paint occurs. r=bgirard

This commit is contained in:
Ali Juma 2012-03-12 11:50:27 -04:00
parent 00f07c4874
commit 665b50af00
2 changed files with 34 additions and 16 deletions

View File

@ -178,7 +178,6 @@ CompositorParent::Composite()
}
#ifdef MOZ_WIDGET_ANDROID
RequestViewTransform();
TransformShadowTree();
#endif
@ -260,34 +259,52 @@ CompositorParent::TransformShadowTree()
#ifdef MOZ_WIDGET_ANDROID
Layer* layer = GetPrimaryScrollableLayer();
ShadowLayer* shadow = layer->AsShadowLayer();
gfx3DMatrix shadowTransform = layer->GetTransform();
ContainerLayer* container = layer->AsContainerLayer();
const FrameMetrics* metrics = &container->GetFrameMetrics();
const gfx3DMatrix& rootTransform = mLayerManager->GetRoot()->GetTransform();
const gfx3DMatrix& currentTransform = layer->GetTransform();
float rootScaleX = GetXScale(rootTransform);
float rootScaleY = GetYScale(rootTransform);
if (mIsFirstPaint && metrics) {
nsIntPoint scrollOffset = metrics->mViewportScrollOffset;
mContentSize = metrics->mContentSize;
mozilla::AndroidBridge::Bridge()->SetFirstPaintViewport(scrollOffset.x, scrollOffset.y,
1/rootScaleX, mContentSize.width,
mContentSize.height);
mIsFirstPaint = false;
} else if (metrics && (metrics->mContentSize != mContentSize)) {
mContentSize = metrics->mContentSize;
mozilla::AndroidBridge::Bridge()->SetPageSize(1/rootScaleX, mContentSize.width,
mContentSize.height);
}
// We request the view transform from Java after sending the above notifications,
// so that Java can take these into account in its response.
RequestViewTransform();
// Handle transformations for asynchronous panning and zooming. We determine the
// zoom used by Gecko from the transformation set on the root layer, and we
// determine the scroll offset used by Gecko from the frame metrics of the
// primary scrollable layer. We compare this to the desired zoom and scroll
// offset in the view transform we obtained from Java in order to compute the
// transformation we need to apply.
if (metrics && metrics->IsScrollable()) {
float tempScaleDiffX = GetXScale(mLayerManager->GetRoot()->GetTransform()) * mXScale;
float tempScaleDiffY = GetYScale(mLayerManager->GetRoot()->GetTransform()) * mYScale;
float tempScaleDiffX = rootScaleX * mXScale;
float tempScaleDiffY = rootScaleY * mYScale;
nsIntPoint metricsScrollOffset = metrics->mViewportScrollOffset;
nsIntPoint scrollCompensation(
(mScrollOffset.x / tempScaleDiffX - metricsScrollOffset.x) * mXScale,
(mScrollOffset.y / tempScaleDiffY - metricsScrollOffset.y) * mYScale);
ViewTransform treeTransform(-scrollCompensation, mXScale,
mYScale);
shadowTransform = gfx3DMatrix(treeTransform) * currentTransform;
shadow->SetShadowTransform(shadowTransform);
ViewTransform treeTransform(-scrollCompensation, mXScale, mYScale);
shadow->SetShadowTransform(gfx3DMatrix(treeTransform) * currentTransform);
} else {
ViewTransform treeTransform(nsIntPoint(0,0), mXScale,
mYScale);
shadowTransform = gfx3DMatrix(treeTransform) * currentTransform;
shadow->SetShadowTransform(shadowTransform);
ViewTransform treeTransform(nsIntPoint(0,0), mXScale, mYScale);
shadow->SetShadowTransform(gfx3DMatrix(treeTransform) * currentTransform);
}
#endif
}

View File

@ -143,6 +143,7 @@ private:
float mXScale;
float mYScale;
nsIntPoint mScrollOffset;
nsIntSize mContentSize;
// When this flag is set, the next composition will be the first for a
// particular document (i.e. the document displayed on the screen will change).