Bug 1464568 - Add an argument to ApplyAsyncProperties() to apply the transform by APZC or not. r?kats
In the next patch, we will introduce a new IPC function to get transform value
modified by both animations and APZC.
MozReview-Commit-ID: Uf5UHg5Jm
--- a/gfx/layers/composite/AsyncCompositionManager.cpp
+++ b/gfx/layers/composite/AsyncCompositionManager.cpp
@@ -1244,19 +1244,20 @@ AsyncCompositionManager::ApplyAsyncTrans
void
AsyncCompositionManager::GetFrameUniformity(FrameUniformityData* aOutData)
{
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
mLayerTransformRecorder.EndTest(aOutData);
}
bool
-AsyncCompositionManager::TransformShadowTree(TimeStamp aCurrentFrame,
- TimeDuration aVsyncRate,
- TransformsToSkip aSkip)
+AsyncCompositionManager::TransformShadowTree(
+ TimeStamp aCurrentFrame,
+ TimeDuration aVsyncRate,
+ CompositorBridgeParentBase::TransformsToSkip aSkip)
{
AUTO_PROFILER_LABEL("AsyncCompositionManager::TransformShadowTree", GRAPHICS);
Layer* root = mLayerManager->GetRoot();
if (!root) {
return false;
}
@@ -1295,17 +1296,17 @@ AsyncCompositionManager::TransformShadow
}
#endif // defined(MOZ_WIDGET_ANDROID)
// Reset the previous time stamp if we don't already have any running
// animations to avoid using the time which is far behind for newly
// started animations.
mPreviousFrameTimeStamp = wantNextFrame ? aCurrentFrame : TimeStamp();
- if (!(aSkip & TransformsToSkip::APZ)) {
+ if (!(aSkip & CompositorBridgeParentBase::TransformsToSkip::APZ)) {
// 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
--- a/gfx/layers/composite/AsyncCompositionManager.h
+++ b/gfx/layers/composite/AsyncCompositionManager.h
@@ -14,16 +14,17 @@
#include "mozilla/TimeStamp.h" // for TimeStamp
#include "mozilla/dom/ScreenOrientation.h" // for ScreenOrientation
#include "mozilla/gfx/BasePoint.h" // for BasePoint
#include "mozilla/gfx/Matrix.h" // for Matrix4x4
#include "mozilla/layers/FrameUniformityData.h" // For FrameUniformityData
#include "mozilla/layers/LayersMessages.h" // for TargetConfig
#include "mozilla/RefPtr.h" // for nsRefPtr
#include "nsISupportsImpl.h" // for LayerManager::AddRef, etc
+#include "CompositorBridgeParent.h" // for TransformsToSkip
namespace mozilla {
namespace layers {
class Layer;
class LayerManagerComposite;
class AutoResolveRefLayers;
class CompositorBridgeParent;
@@ -78,20 +79,21 @@ public:
* (or for whatever reason wants to refresh the viewport information).
* The information refresh happens because the compositor will call
* AndroidDynamicToolbarAnimator::FirstPaint() on the next frame of composition.
*/
void ForceIsFirstPaint() { mIsFirstPaint = true; }
// Sample transforms for layer trees. Return true to request
// another animation frame.
- enum class TransformsToSkip : uint8_t { NoneOfThem = 0, APZ = 1 };
- bool TransformShadowTree(TimeStamp aCurrentFrame,
- TimeDuration aVsyncRate,
- TransformsToSkip aSkip = TransformsToSkip::NoneOfThem);
+ bool TransformShadowTree(
+ TimeStamp aCurrentFrame,
+ TimeDuration aVsyncRate,
+ CompositorBridgeParentBase::TransformsToSkip aSkip =
+ CompositorBridgeParentBase::TransformsToSkip::NoneOfThem);
// Calculates the correct rotation and applies the transform to
// our layer manager
void ComputeRotation();
// Call after updating our layer tree.
void Updated(bool isFirstPaint, const TargetConfig& aTargetConfig)
{
@@ -231,18 +233,16 @@ private:
// The following two fields are only needed on Fennec with C++ APZ, because
// then we need to reposition the gecko scrollbar to deal with the
// dynamic toolbar shifting content around.
FrameMetrics::ViewID mRootScrollableId;
ScreenMargin mFixedLayerMargins;
#endif
};
-MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(AsyncCompositionManager::TransformsToSkip)
-
class MOZ_STACK_CLASS AutoResolveRefLayers {
public:
explicit AutoResolveRefLayers(AsyncCompositionManager* aManager,
CompositorBridgeParent* aCompositor = nullptr,
bool* aHasRemoteContent = nullptr,
bool* aResolvePlugins = nullptr) :
mManager(aManager)
{
--- a/gfx/layers/ipc/CompositorBridgeParent.cpp
+++ b/gfx/layers/ipc/CompositorBridgeParent.cpp
@@ -1387,31 +1387,31 @@ CompositorBridgeParent::SetTestSampleTim
void
CompositorBridgeParent::LeaveTestMode(const LayersId& aId)
{
mTestTime = Nothing();
}
void
-CompositorBridgeParent::ApplyAsyncProperties(LayerTransactionParent* aLayerTree)
+CompositorBridgeParent::ApplyAsyncProperties(LayerTransactionParent* aLayerTree,
+ TransformsToSkip aSkip)
{
// NOTE: This should only be used for testing. For example, when mTestTime is
// non-empty, or when called from test-only methods like
// LayerTransactionParent::RecvGetAnimationTransform.
// Synchronously update the layer tree
if (aLayerTree->GetRoot()) {
AutoResolveRefLayers resolve(mCompositionManager);
SetShadowProperties(mLayerManager->GetRoot());
TimeStamp time = mTestTime.valueOr(mCompositorScheduler->GetLastComposeTime());
bool requestNextFrame =
- mCompositionManager->TransformShadowTree(time, mVsyncRate,
- AsyncCompositionManager::TransformsToSkip::APZ);
+ mCompositionManager->TransformShadowTree(time, mVsyncRate, aSkip);
if (!requestNextFrame) {
CancelCurrentCompositeTask();
// Pretend we composited in case someone is waiting for this event.
TimeStamp now = TimeStamp::Now();
DidComposite(now, now);
}
}
}
--- a/gfx/layers/ipc/CompositorBridgeParent.h
+++ b/gfx/layers/ipc/CompositorBridgeParent.h
@@ -108,17 +108,19 @@ public:
virtual AsyncCompositionManager* GetCompositionManager(LayerTransactionParent* aLayerTree) { return nullptr; }
virtual void NotifyClearCachedResources(LayerTransactionParent* aLayerTree) { }
virtual void ScheduleComposite(LayerTransactionParent* aLayerTree) { }
virtual bool SetTestSampleTime(const LayersId& aId,
const TimeStamp& aTime) { return true; }
virtual void LeaveTestMode(const LayersId& aId) { }
- virtual void ApplyAsyncProperties(LayerTransactionParent* aLayerTree) = 0;
+ enum class TransformsToSkip : uint8_t { NoneOfThem = 0, APZ = 1 };
+ virtual void ApplyAsyncProperties(LayerTransactionParent* aLayerTree,
+ TransformsToSkip aSkip) = 0;
virtual void SetTestAsyncScrollOffset(const LayersId& aLayersId,
const FrameMetrics::ViewID& aScrollId,
const CSSPoint& aPoint) = 0;
virtual void SetTestAsyncZoom(const LayersId& aLayersId,
const FrameMetrics::ViewID& aScrollId,
const LayerToParentLayerScale& aZoom) = 0;
virtual void FlushApzRepaints(const LayersId& aLayersId) = 0;
virtual void GetAPZTestData(const LayersId& aLayersId,
@@ -173,16 +175,18 @@ protected:
~CompositorBridgeParentBase() override;
bool mCanSend;
private:
RefPtr<CompositorManagerParent> mCompositorManager;
};
+MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(CompositorBridgeParentBase::TransformsToSkip)
+
class CompositorBridgeParent final : public CompositorBridgeParentBase
, public CompositorController
, public CompositorVsyncSchedulerOwner
{
friend class CompositorThreadHolder;
friend class InProcessCompositorSession;
friend class gfx::GPUProcessManager;
friend class gfx::GPUParent;
@@ -232,17 +236,18 @@ public:
void ShadowLayersUpdated(LayerTransactionParent* aLayerTree,
const TransactionInfo& aInfo,
bool aHitTestUpdate) override;
void ScheduleComposite(LayerTransactionParent* aLayerTree) override;
bool SetTestSampleTime(const LayersId& aId,
const TimeStamp& aTime) override;
void LeaveTestMode(const LayersId& aId) override;
- void ApplyAsyncProperties(LayerTransactionParent* aLayerTree) override;
+ void ApplyAsyncProperties(LayerTransactionParent* aLayerTree,
+ TransformsToSkip aSkip) override;
CompositorAnimationStorage* GetAnimationStorage();
void SetTestAsyncScrollOffset(const LayersId& aLayersId,
const FrameMetrics::ViewID& aScrollId,
const CSSPoint& aPoint) override;
void SetTestAsyncZoom(const LayersId& aLayersId,
const FrameMetrics::ViewID& aScrollId,
const LayerToParentLayerScale& aZoom) override;
void FlushApzRepaints(const LayersId& aLayersId) override;
--- a/gfx/layers/ipc/CrossProcessCompositorBridgeParent.cpp
+++ b/gfx/layers/ipc/CrossProcessCompositorBridgeParent.cpp
@@ -461,28 +461,29 @@ CrossProcessCompositorBridgeParent::Leav
}
MOZ_ASSERT(state->mParent);
state->mParent->LeaveTestMode(aId);
}
void
CrossProcessCompositorBridgeParent::ApplyAsyncProperties(
- LayerTransactionParent* aLayerTree)
+ LayerTransactionParent* aLayerTree,
+ TransformsToSkip aSkip)
{
LayersId id = aLayerTree->GetId();
MOZ_ASSERT(id.IsValid());
const CompositorBridgeParent::LayerTreeState* state =
CompositorBridgeParent::GetIndirectShadowTree(id);
if (!state) {
return;
}
MOZ_ASSERT(state->mParent);
- state->mParent->ApplyAsyncProperties(aLayerTree);
+ state->mParent->ApplyAsyncProperties(aLayerTree, aSkip);
}
void
CrossProcessCompositorBridgeParent::SetTestAsyncScrollOffset(
const LayersId& aLayersId,
const FrameMetrics::ViewID& aScrollId,
const CSSPoint& aPoint)
{
--- a/gfx/layers/ipc/CrossProcessCompositorBridgeParent.h
+++ b/gfx/layers/ipc/CrossProcessCompositorBridgeParent.h
@@ -83,17 +83,18 @@ public:
void ShadowLayersUpdated(LayerTransactionParent* aLayerTree,
const TransactionInfo& aInfo,
bool aHitTestUpdate) override;
void ScheduleComposite(LayerTransactionParent* aLayerTree) override;
void NotifyClearCachedResources(LayerTransactionParent* aLayerTree) override;
bool SetTestSampleTime(const LayersId& aId,
const TimeStamp& aTime) override;
void LeaveTestMode(const LayersId& aId) override;
- void ApplyAsyncProperties(LayerTransactionParent* aLayerTree) override;
+ void ApplyAsyncProperties(LayerTransactionParent* aLayerTree,
+ TransformsToSkip aSkip) override;
void SetTestAsyncScrollOffset(const LayersId& aLayersId,
const FrameMetrics::ViewID& aScrollId,
const CSSPoint& aPoint) override;
void SetTestAsyncZoom(const LayersId& aLayersId,
const FrameMetrics::ViewID& aScrollId,
const LayerToParentLayerScale& aZoom) override;
void FlushApzRepaints(const LayersId& aLayersId) override;
void GetAPZTestData(const LayersId& aLayersId,
--- a/gfx/layers/ipc/LayerTransactionParent.cpp
+++ b/gfx/layers/ipc/LayerTransactionParent.cpp
@@ -695,17 +695,18 @@ LayerTransactionParent::RecvGetAnimation
float* aOpacity,
bool* aHasAnimationOpacity)
{
*aHasAnimationOpacity = false;
if (mDestroyed || !mLayerManager || mLayerManager->IsDestroyed()) {
return IPC_FAIL_NO_REASON(this);
}
- mCompositorBridge->ApplyAsyncProperties(this);
+ mCompositorBridge->ApplyAsyncProperties(
+ this, CompositorBridgeParentBase::TransformsToSkip::APZ);
if (!mAnimStorage) {
return IPC_FAIL_NO_REASON(this);
}
Maybe<float> opacity = mAnimStorage->GetAnimationOpacity(aCompositorAnimationsId);
if (opacity) {
*aOpacity = *opacity;
@@ -721,17 +722,18 @@ LayerTransactionParent::RecvGetAnimation
if (mDestroyed || !mLayerManager || mLayerManager->IsDestroyed()) {
return IPC_FAIL_NO_REASON(this);
}
// Make sure we apply the latest animation style or else we can end up with
// a race between when we temporarily clear the animation transform (in
// CompositorBridgeParent::SetShadowProperties) and when animation recalculates
// the value.
- mCompositorBridge->ApplyAsyncProperties(this);
+ mCompositorBridge->ApplyAsyncProperties(
+ this, CompositorBridgeParentBase::TransformsToSkip::APZ);
if (!mAnimStorage) {
return IPC_FAIL_NO_REASON(this);
}
Maybe<Matrix4x4> transform = mAnimStorage->GetAnimationTransform(aCompositorAnimationsId);
if (transform) {
*aTransform = *transform;