Bug 868082. Allow SetIsFixedPosition to be used on layers with transforms. In CompositorParent, use the animated transform value as the base transform in CompositorParent::TransformFixedLayers when it has been set by the animation sampler. r=cwiis

--HG--
extra : rebase_source : 3b809428bf8740753a98defc30ad7b7d96339442
This commit is contained in:
Robert O'Callahan 2013-05-17 00:34:24 +12:00
parent 2075ff6575
commit 8b339cab63
6 changed files with 29 additions and 14 deletions

View File

@ -910,6 +910,12 @@ public:
uint64_t GetAnimationGeneration() { return mAnimationGeneration; }
void SetAnimationGeneration(uint64_t aCount) { mAnimationGeneration = aCount; }
/**
* Returns the local transform for this layer: either mTransform or,
* for shadow layers, GetShadowTransform()
*/
const gfx3DMatrix GetLocalTransform();
/**
* DRAWING PHASE ONLY
*
@ -1164,12 +1170,6 @@ protected:
// appends additional info to aTo.
virtual nsACString& PrintInfo(nsACString& aTo, const char* aPrefix);
/**
* Returns the local transform for this layer: either mTransform or,
* for shadow layers, GetShadowTransform()
*/
const gfx3DMatrix GetLocalTransform();
/**
* Returns the local opacity for this layer: either mOpacity or,
* for shadow layers, GetShadowOpacity()

View File

@ -169,7 +169,14 @@ AsyncCompositionManager::TransformFixedLayers(Layer* aLayer,
// The transform already takes the resolution scale into account. Since we
// will apply the resolution scale again when computing the effective
// transform, we must apply the inverse resolution scale here.
gfx3DMatrix layerTransform = aLayer->GetTransform();
LayerComposite* layerComposite = aLayer->AsLayerComposite();
gfx3DMatrix layerTransform;
if (layerComposite->GetShadowTransformSetByAnimation()) {
// Start with the animated transform
layerTransform = aLayer->GetLocalTransform();
} else {
layerTransform = aLayer->GetTransform();
}
Translate2D(layerTransform, translation);
if (ContainerLayer* c = aLayer->AsContainerLayer()) {
layerTransform.Scale(1.0f/c->GetPreXScale(),
@ -179,8 +186,8 @@ AsyncCompositionManager::TransformFixedLayers(Layer* aLayer,
layerTransform.ScalePost(1.0f/aLayer->GetPostXScale(),
1.0f/aLayer->GetPostYScale(),
1);
LayerComposite* layerComposite = aLayer->AsLayerComposite();
layerComposite->SetShadowTransform(layerTransform);
layerComposite->SetShadowTransformSetByAnimation(false);
const nsIntRect* clipRect = aLayer->GetClipRect();
if (clipRect) {
@ -308,6 +315,7 @@ SampleAnimations(Layer* aLayer, TimeStamp aPoint)
}
NS_ASSERTION(!aLayer->GetIsFixedPosition(), "Can't animate transforms on fixed-position layers");
layerComposite->SetShadowTransform(matrix);
layerComposite->SetShadowTransformSetByAnimation(true);
break;
}
default:
@ -378,6 +386,8 @@ AsyncCompositionManager::ApplyAsyncContentTransformToTree(TimeStamp aCurrentFram
1.0f/aLayer->GetPostYScale(),
1);
layerComposite->SetShadowTransform(transform);
NS_ASSERTION(!layerComposite->GetShadowTransformSetByAnimation(),
"overwriting animated transform!");
TransformFixedLayers(
aLayer,
@ -512,6 +522,8 @@ AsyncCompositionManager::TransformScrollableLayer(Layer* aLayer, const gfx3DMatr
1.0f/container->GetPostYScale(),
1);
layerComposite->SetShadowTransform(computedTransform);
NS_ASSERTION(!layerComposite->GetShadowTransformSetByAnimation(),
"overwriting animated transform!");
TransformFixedLayers(aLayer, fixedOffset, scaleDiff, fixedLayerMargins);
}

View File

@ -658,6 +658,7 @@ LayerComposite::LayerComposite(LayerManagerComposite *aManager)
, mCompositor(aManager->GetCompositor())
, mShadowOpacity(1.0)
, mUseShadowClipRect(false)
, mShadowTransformSetByAnimation(false)
, mDestroyed(false)
{ }

View File

@ -331,12 +331,17 @@ public:
{
mShadowTransform = aMatrix;
}
void SetShadowTransformSetByAnimation(bool aSetByAnimation)
{
mShadowTransformSetByAnimation = aSetByAnimation;
}
// These getters can be used anytime.
float GetShadowOpacity() { return mShadowOpacity; }
const nsIntRect* GetShadowClipRect() { return mUseShadowClipRect ? &mShadowClipRect : nullptr; }
const nsIntRegion& GetShadowVisibleRegion() { return mShadowVisibleRegion; }
const gfx3DMatrix& GetShadowTransform() { return mShadowTransform; }
bool GetShadowTransformSetByAnimation() { return mShadowTransformSetByAnimation; }
protected:
gfx3DMatrix mShadowTransform;
@ -346,6 +351,7 @@ protected:
RefPtr<Compositor> mCompositor;
float mShadowOpacity;
bool mUseShadowClipRect;
bool mShadowTransformSetByAnimation;
bool mDestroyed;
};

View File

@ -507,6 +507,7 @@ SetShadowProperties(Layer* aLayer)
LayerComposite* layerComposite = aLayer->AsLayerComposite();
// Set the layerComposite's base transform to the layer's base transform.
layerComposite->SetShadowTransform(aLayer->GetBaseTransform());
layerComposite->SetShadowTransformSetByAnimation(false);
layerComposite->SetShadowVisibleRegion(aLayer->GetVisibleRegion());
layerComposite->SetShadowClipRect(aLayer->GetClipRect());
layerComposite->SetShadowOpacity(aLayer->GetOpacity());

View File

@ -2147,12 +2147,7 @@ ContainerState::ProcessDisplayItems(const nsDisplayList& aList,
mParameters.mYScale);
}
// If a transform layer is marked as fixed then the shadow transform gets
// overwritten by CompositorParent when doing scroll compensation on
// fixed layers. This means we need to make sure transform layers are not
// marked as fixed.
ownLayer->SetIsFixedPosition(
isFixed && item->GetType() != nsDisplayItem::TYPE_TRANSFORM);
ownLayer->SetIsFixedPosition(isFixed);
// Update that layer's clip and visible rects.
NS_ASSERTION(ownLayer->Manager() == mManager, "Wrong manager");