Bug 818575 - Make TransformShadowTree transform all descendant scrollable layers instead of just the first. r=roc a=blocking-basecamp

This commit is contained in:
Matt Woodrow 2013-01-10 22:10:20 +13:00
Родитель 8e4ca058c8
Коммит a84a375464
4 изменённых файлов: 163 добавлений и 108 удалений

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

@ -229,6 +229,36 @@ LayerManager::GetPrimaryScrollableLayer()
return mRoot;
}
void
LayerManager::GetScrollableLayers(nsTArray<Layer*>& aArray)
{
if (!mRoot) {
return;
}
nsTArray<Layer*> queue;
queue.AppendElement(mRoot);
while (!queue.IsEmpty()) {
ContainerLayer* containerLayer = queue.LastElement()->AsContainerLayer();
queue.RemoveElementAt(queue.Length() - 1);
if (!containerLayer) {
continue;
}
const FrameMetrics& frameMetrics = containerLayer->GetFrameMetrics();
if (frameMetrics.IsScrollable()) {
aArray.AppendElement(containerLayer);
continue;
}
Layer* child = containerLayer->GetFirstChild();
while (child) {
queue.AppendElement(child);
child = child->GetNextSibling();
}
}
}
already_AddRefed<gfxASurface>
LayerManager::CreateOptimalSurface(const gfxIntSize &aSize,
gfxASurface::gfxImageFormat aFormat)

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

@ -285,6 +285,12 @@ public:
*/
Layer* GetPrimaryScrollableLayer();
/**
* Returns a list of all descendant layers for which
* GetFrameMetrics().IsScrollable() is true.
*/
void GetScrollableLayers(nsTArray<Layer*>& aArray);
/**
* CONSTRUCTION PHASE ONLY
* Called when a managee has mutated.

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

@ -829,37 +829,17 @@ CompositorParent::ApplyAsyncContentTransformToTree(TimeStamp aCurrentFrame,
return appliedTransform;
}
bool
CompositorParent::TransformShadowTree(TimeStamp aCurrentFrame)
void
CompositorParent::TransformScrollableLayer(Layer* aLayer, const gfx3DMatrix& aRootTransform)
{
bool wantNextFrame = false;
Layer* layer = mLayerManager->GetPrimaryScrollableLayer();
ShadowLayer* shadow = layer->AsShadowLayer();
ContainerLayer* container = layer->AsContainerLayer();
Layer* root = mLayerManager->GetRoot();
// NB: we must sample animations *before* sampling pan/zoom
// transforms.
wantNextFrame |= SampleAnimations(root, aCurrentFrame);
ShadowLayer* shadow = aLayer->AsShadowLayer();
ContainerLayer* container = aLayer->AsContainerLayer();
const FrameMetrics& metrics = container->GetFrameMetrics();
// We must apply the resolution scale before a pan/zoom transform, so we call
// GetTransform here.
const gfx3DMatrix& rootTransform = root->GetTransform();
const gfx3DMatrix& currentTransform = layer->GetTransform();
const gfx3DMatrix& currentTransform = aLayer->GetTransform();
// FIXME/bug 775437: unify this interface with the ~native-fennec
// derived code
//
// Attempt to apply an async content transform to any layer that has
// an async pan zoom controller (which means that it is rendered
// async using Gecko). If this fails, fall back to transforming the
// primary scrollable layer. "Failing" here means that we don't
// find a frame that is async scrollable. Note that the fallback
// code also includes Fennec which is rendered async. Fennec uses
// its own platform-specific async rendering that is done partially
// in Gecko and partially in Java.
if (!ApplyAsyncContentTransformToTree(aCurrentFrame, root, &wantNextFrame)) {
gfx3DMatrix treeTransform;
// Translate fixed position layers so that they stay in the correct position
@ -867,8 +847,8 @@ CompositorParent::TransformShadowTree(TimeStamp aCurrentFrame)
gfxPoint offset;
gfxPoint scaleDiff;
float rootScaleX = rootTransform.GetXScale(),
rootScaleY = rootTransform.GetYScale();
float rootScaleX = aRootTransform.GetXScale(),
rootScaleY = aRootTransform.GetYScale();
// The ratio of layers pixels to device pixels. The Java
// compositor wants to see values in units of device pixels, so we
// map our FrameMetrics values to that space. This is not exposed
@ -962,7 +942,45 @@ CompositorParent::TransformShadowTree(TimeStamp aCurrentFrame)
1.0f/container->GetPostYScale(),
1);
shadow->SetShadowTransform(computedTransform);
TransformFixedLayers(layer, offset, scaleDiff);
TransformFixedLayers(aLayer, offset, scaleDiff);
}
bool
CompositorParent::TransformShadowTree(TimeStamp aCurrentFrame)
{
bool wantNextFrame = false;
Layer* root = mLayerManager->GetRoot();
// NB: we must sample animations *before* sampling pan/zoom
// transforms.
wantNextFrame |= SampleAnimations(root, aCurrentFrame);
const gfx3DMatrix& rootTransform = root->GetTransform();
// FIXME/bug 775437: unify this interface with the ~native-fennec
// derived code
//
// Attempt to apply an async content transform to any layer that has
// an async pan zoom controller (which means that it is rendered
// async using Gecko). If this fails, fall back to transforming the
// primary scrollable layer. "Failing" here means that we don't
// find a frame that is async scrollable. Note that the fallback
// code also includes Fennec which is rendered async. Fennec uses
// its own platform-specific async rendering that is done partially
// in Gecko and partially in Java.
if (!ApplyAsyncContentTransformToTree(aCurrentFrame, root, &wantNextFrame)) {
nsAutoTArray<Layer*,1> scrollableLayers;
#ifdef MOZ_WIDGET_ANDROID
scrollableLayers.AppendElement(mLayerManager->GetPrimaryScrollableLayer());
#else
mLayerManager->GetScrollableLayers(scrollableLayers);
#endif
for (uint32_t i = 0; i < scrollableLayers.Length(); i++) {
if (scrollableLayers[i]) {
TransformScrollableLayer(scrollableLayers[i], rootTransform);
}
}
}
return wantNextFrame;

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

@ -176,6 +176,7 @@ private:
// Sample transforms for layer trees. Return true to request
// another animation frame.
bool TransformShadowTree(TimeStamp aCurrentFrame);
void TransformScrollableLayer(Layer* aLayer, const gfx3DMatrix& aRootTransform);
// Return true if an AsyncPanZoomController content transform was
// applied for |aLayer|. *aWantNextFrame is set to true if the
// controller wants another animation frame.