mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Bug 979658 part 4 - Rename PLayerTransaction.GetTransform to GetAnimationTransform; r=dzbarsky
PLayerTransaction.GetTransform doesn't actually return the same kind of value when the transform on the layer is not set by animation. This is because it uses information stored with the animation to undo various transforms. We shouldn't pretend to return something useful/similar when we don't have that information available. This patch renames GetTransform to GetAnimationTransform and makes it return a union that has type void_t if the layer is not transformed by animation.
This commit is contained in:
parent
e3b4d6f388
commit
84d1a1f391
@ -3649,12 +3649,15 @@ nsDOMWindowUtils::GetOMTAStyle(nsIDOMElement* aElement,
|
||||
FrameLayerBuilder::GetDedicatedLayer(frame,
|
||||
nsDisplayItem::TYPE_TRANSFORM);
|
||||
if (layer) {
|
||||
gfx3DMatrix matrix;
|
||||
ShadowLayerForwarder* forwarder = layer->Manager()->AsShadowForwarder();
|
||||
if (forwarder && forwarder->HasShadowManager()) {
|
||||
forwarder->GetShadowManager()->SendGetTransform(
|
||||
layer->AsShadowableLayer()->GetShadow(), &matrix);
|
||||
cssValue = nsComputedDOMStyle::MatrixToCSSValue(matrix);
|
||||
MaybeTransform transform;
|
||||
forwarder->GetShadowManager()->SendGetAnimationTransform(
|
||||
layer->AsShadowableLayer()->GetShadow(), &transform);
|
||||
if (transform.type() == MaybeTransform::Tgfx3DMatrix) {
|
||||
cssValue =
|
||||
nsComputedDOMStyle::MatrixToCSSValue(transform.get_gfx3DMatrix());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -569,27 +569,40 @@ LayerTransactionParent::RecvGetOpacity(PLayerParent* aParent,
|
||||
}
|
||||
|
||||
bool
|
||||
LayerTransactionParent::RecvGetTransform(PLayerParent* aParent,
|
||||
gfx3DMatrix* aTransform)
|
||||
LayerTransactionParent::RecvGetAnimationTransform(PLayerParent* aParent,
|
||||
MaybeTransform* aTransform)
|
||||
{
|
||||
if (mDestroyed || !layer_manager() || layer_manager()->IsDestroyed()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Layer* layer = cast(aParent)->AsLayer();
|
||||
if (!layer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// This method is specific to transforms applied by animation.
|
||||
// This is because this method uses the information stored with an animation
|
||||
// such as the origin of the reference frame corresponding to the layer, to
|
||||
// recover the untranslated transform from the shadow transform. For
|
||||
// transforms that are not set by animation we don't have this information
|
||||
// available.
|
||||
if (!layer->AsLayerComposite()->GetShadowTransformSetByAnimation()) {
|
||||
*aTransform = mozilla::void_t();
|
||||
return true;
|
||||
}
|
||||
|
||||
// The following code recovers the untranslated transform
|
||||
// from the shadow transform by undoing the translations in
|
||||
// AsyncCompositionManager::SampleValue.
|
||||
|
||||
Layer* layer = cast(aParent)->AsLayer();
|
||||
if (!layer) {
|
||||
return false;
|
||||
}
|
||||
gfx::To3DMatrix(layer->AsLayerComposite()->GetShadowTransform(), *aTransform);
|
||||
gfx3DMatrix transform;
|
||||
gfx::To3DMatrix(layer->AsLayerComposite()->GetShadowTransform(), transform);
|
||||
if (ContainerLayer* c = layer->AsContainerLayer()) {
|
||||
// Undo the scale transform applied by AsyncCompositionManager::SampleValue
|
||||
aTransform->ScalePost(1.0f/c->GetInheritedXScale(),
|
||||
1.0f/c->GetInheritedYScale(),
|
||||
1.0f);
|
||||
transform.ScalePost(1.0f/c->GetInheritedXScale(),
|
||||
1.0f/c->GetInheritedYScale(),
|
||||
1.0f);
|
||||
}
|
||||
float scale = 1;
|
||||
gfxPoint3D scaledOrigin;
|
||||
@ -611,23 +624,23 @@ LayerTransactionParent::RecvGetTransform(PLayerParent* aParent,
|
||||
|
||||
// Undo the translation to the origin of the reference frame applied by
|
||||
// AsyncCompositionManager::SampleValue
|
||||
aTransform->Translate(-scaledOrigin);
|
||||
transform.Translate(-scaledOrigin);
|
||||
|
||||
// Undo the rebasing applied by
|
||||
// nsDisplayTransform::GetResultingTransformMatrixInternal
|
||||
*aTransform =
|
||||
nsLayoutUtils::ChangeMatrixBasis(-scaledOrigin - transformOrigin,
|
||||
*aTransform);
|
||||
transform = nsLayoutUtils::ChangeMatrixBasis(-scaledOrigin - transformOrigin,
|
||||
transform);
|
||||
|
||||
// Convert to CSS pixels (this undoes the operations performed by
|
||||
// nsStyleTransformMatrix::ProcessTranslatePart which is called from
|
||||
// nsDisplayTransform::GetResultingTransformMatrix)
|
||||
double devPerCss =
|
||||
double(scale) / double(nsDeviceContext::AppUnitsPerCSSPixel());
|
||||
aTransform->_41 *= devPerCss;
|
||||
aTransform->_42 *= devPerCss;
|
||||
aTransform->_43 *= devPerCss;
|
||||
transform._41 *= devPerCss;
|
||||
transform._42 *= devPerCss;
|
||||
transform._43 *= devPerCss;
|
||||
|
||||
*aTransform = transform;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -95,8 +95,9 @@ protected:
|
||||
virtual bool RecvForceComposite() MOZ_OVERRIDE;
|
||||
virtual bool RecvGetOpacity(PLayerParent* aParent,
|
||||
float* aOpacity) MOZ_OVERRIDE;
|
||||
virtual bool RecvGetTransform(PLayerParent* aParent,
|
||||
gfx3DMatrix* aTransform) MOZ_OVERRIDE;
|
||||
virtual bool RecvGetAnimationTransform(PLayerParent* aParent,
|
||||
MaybeTransform* aTransform)
|
||||
MOZ_OVERRIDE;
|
||||
|
||||
virtual PGrallocBufferParent*
|
||||
AllocPGrallocBufferParent(const IntSize& aSize,
|
||||
|
@ -17,6 +17,7 @@ include protocol PTexture;
|
||||
include "mozilla/GfxMessageUtils.h";
|
||||
|
||||
using struct mozilla::layers::TextureInfo from "mozilla/layers/CompositorTypes.h";
|
||||
using struct mozilla::void_t from "ipc/IPCMessageUtils.h";
|
||||
|
||||
/**
|
||||
* The layers protocol is spoken between thread contexts that manage
|
||||
@ -29,6 +30,11 @@ using struct mozilla::layers::TextureInfo from "mozilla/layers/CompositorTypes.h
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
union MaybeTransform {
|
||||
gfx3DMatrix;
|
||||
void_t;
|
||||
};
|
||||
|
||||
sync protocol PLayerTransaction {
|
||||
manager PRenderFrame or PCompositor;
|
||||
manages PLayer;
|
||||
@ -76,7 +82,13 @@ parent:
|
||||
returns (EditReply[] reply);
|
||||
|
||||
sync GetOpacity(PLayer layer) returns (float opacity);
|
||||
sync GetTransform(PLayer layer) returns (gfx3DMatrix transform);
|
||||
|
||||
// Returns the value of the transform applied to the layer by animation after
|
||||
// factoring out translation components introduced to account for the offset
|
||||
// of the corresponding frame and transform origin and after converting to CSS
|
||||
// pixels. If the layer is not transformed by animation, the return value will
|
||||
// be void_t.
|
||||
sync GetAnimationTransform(PLayer layer) returns (MaybeTransform transform);
|
||||
|
||||
// We don't need to send a sync transaction if
|
||||
// no transaction operate require a swap.
|
||||
|
Loading…
Reference in New Issue
Block a user