Bug 1464568 - Add an IPC call to get transform value for a given element on the compositor. r?kats,froydnj
This function returns the transform value modified by both OMTA and APZC.
Note that the transform conversion code is almost the same as the code dropped
in https://hg.mozilla.org/mozilla-central/rev/415811f3804f .
MozReview-Commit-ID: HmsMQp3O4n4
--- a/gfx/layers/ipc/LayerTransactionParent.cpp
+++ b/gfx/layers/ipc/LayerTransactionParent.cpp
@@ -739,16 +739,68 @@ LayerTransactionParent::RecvGetAnimation
*aTransform = *transform;
} else {
*aTransform = mozilla::void_t();
}
return IPC_OK();
}
mozilla::ipc::IPCResult
+LayerTransactionParent::RecvGetTransform(const LayerHandle& aLayerHandle,
+ MaybeTransform* aTransform)
+{
+ if (mDestroyed || !mLayerManager || mLayerManager->IsDestroyed()) {
+ return IPC_FAIL_NO_REASON(this);
+ }
+
+ Layer* layer = AsLayer(aLayerHandle);
+ if (!layer) {
+ return IPC_FAIL_NO_REASON(this);
+ }
+
+ mCompositorBridge->ApplyAsyncProperties(
+ this, CompositorBridgeParentBase::TransformsToSkip::NoneOfThem);
+
+ Matrix4x4 transform = layer->AsHostLayer()->GetShadowBaseTransform();
+ // Undo the scale transform applied by FrameTransformToTransformInDevice in
+ // AsyncCompositionManager.cpp.
+ if (ContainerLayer* c = layer->AsContainerLayer()) {
+ transform.PostScale(1.0f/c->GetInheritedXScale(),
+ 1.0f/c->GetInheritedYScale(),
+ 1.0f);
+ }
+ float scale = 1;
+ Point3D scaledOrigin;
+ Point3D transformOrigin;
+ for (uint32_t i = 0; i < layer->GetAnimations().Length(); i++) {
+ if (layer->GetAnimations()[i].data().type() == AnimationData::TTransformData) {
+ const TransformData& data = layer->GetAnimations()[i].data().get_TransformData();
+ scale = data.appUnitsPerDevPixel();
+ scaledOrigin =
+ Point3D(NS_round(NSAppUnitsToFloatPixels(data.origin().x, scale)),
+ NS_round(NSAppUnitsToFloatPixels(data.origin().y, scale)),
+ 0.0f);
+ transformOrigin = data.transformOrigin();
+ break;
+ }
+ }
+
+ // If our parent isn't a perspective layer, then the offset into reference
+ // frame coordinates will have been applied to us. Add an inverse translation
+ // to cancel it out.
+ if (!layer->GetParent() || !layer->GetParent()->GetTransformIsPerspective()) {
+ transform.PostTranslate(-scaledOrigin.x, -scaledOrigin.y, -scaledOrigin.z);
+ }
+
+ *aTransform = transform;
+
+ return IPC_OK();
+}
+
+mozilla::ipc::IPCResult
LayerTransactionParent::RecvSetAsyncScrollOffset(const FrameMetrics::ViewID& aScrollID,
const float& aX, const float& aY)
{
if (mDestroyed || !mLayerManager || mLayerManager->IsDestroyed()) {
return IPC_FAIL_NO_REASON(this);
}
mCompositorBridge->SetTestAsyncScrollOffset(GetId(), aScrollID, CSSPoint(aX, aY));
--- a/gfx/layers/ipc/LayerTransactionParent.h
+++ b/gfx/layers/ipc/LayerTransactionParent.h
@@ -120,16 +120,18 @@ protected:
mozilla::ipc::IPCResult RecvScheduleComposite() override;
mozilla::ipc::IPCResult RecvSetTestSampleTime(const TimeStamp& aTime) override;
mozilla::ipc::IPCResult RecvLeaveTestMode() override;
mozilla::ipc::IPCResult RecvGetAnimationOpacity(const uint64_t& aCompositorAnimationsId,
float* aOpacity,
bool* aHasAnimationOpacity) override;
mozilla::ipc::IPCResult RecvGetAnimationTransform(const uint64_t& aCompositorAnimationsId,
MaybeTransform* aTransform) override;
+ mozilla::ipc::IPCResult RecvGetTransform(const LayerHandle& aHandle,
+ MaybeTransform* aTransform) override;
mozilla::ipc::IPCResult RecvSetAsyncScrollOffset(const FrameMetrics::ViewID& aId,
const float& aX, const float& aY) override;
mozilla::ipc::IPCResult RecvSetAsyncZoom(const FrameMetrics::ViewID& aId,
const float& aValue) override;
mozilla::ipc::IPCResult RecvFlushApzRepaints() override;
mozilla::ipc::IPCResult RecvGetAPZTestData(APZTestData* aOutData) override;
mozilla::ipc::IPCResult RecvRequestProperty(const nsString& aProperty, float* aValue) override;
mozilla::ipc::IPCResult RecvSetConfirmedTargetAPZC(const uint64_t& aBlockId,
--- a/gfx/layers/ipc/PLayerTransaction.ipdl
+++ b/gfx/layers/ipc/PLayerTransaction.ipdl
@@ -83,16 +83,20 @@ parent:
// 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(uint64_t aCompositorAnimationId) returns (MaybeTransform transform);
+ // Returns the value of the transform applied to the layer by animation and
+ // APZC.
+ sync GetTransform(LayerHandle layer) returns (MaybeTransform transform);
+
// The next time the layer tree is composited, add this async scroll offset in
// CSS pixels for the given ViewID.
// Useful for testing rendering of async scrolling.
sync SetAsyncScrollOffset(ViewID id, float x, float y);
// The next time the layer tree is composited, include this async zoom in
// for the given ViewID.
// Useful for testing rendering of async zooming.
--- a/ipc/ipdl/sync-messages.ini
+++ b/ipc/ipdl/sync-messages.ini
@@ -995,16 +995,18 @@ description =
[PLayerTransaction::SetTestSampleTime]
description =
[PLayerTransaction::LeaveTestMode]
description =
[PLayerTransaction::GetAnimationOpacity]
description =
[PLayerTransaction::GetAnimationTransform]
description =
+[PLayerTransaction::GetTransform]
+description = test only
[PLayerTransaction::SetAsyncScrollOffset]
description =
[PLayerTransaction::SetAsyncZoom]
description =
[PLayerTransaction::GetAPZTestData]
description =
[PLayerTransaction::RequestProperty]
description =