Bug 1357754 - Trigger the APZ hit-testing tree rebuild. r=jrmuizel
This is the code that takes the incoming WebRender transaction and tells
APZ to rebuild the hit-testing tree from it.
MozReview-Commit-ID: DTuRmp5QZpg
--- a/gfx/layers/wr/WebRenderBridgeParent.cpp
+++ b/gfx/layers/wr/WebRenderBridgeParent.cpp
@@ -6,16 +6,17 @@
#include "mozilla/layers/WebRenderBridgeParent.h"
#include "CompositableHost.h"
#include "GLContext.h"
#include "GLContextProvider.h"
#include "mozilla/Range.h"
#include "mozilla/layers/AnimationHelper.h"
+#include "mozilla/layers/APZCTreeManager.h"
#include "mozilla/layers/Compositor.h"
#include "mozilla/layers/CompositorBridgeParent.h"
#include "mozilla/layers/CompositorThread.h"
#include "mozilla/layers/CompositorVsyncScheduler.h"
#include "mozilla/layers/ImageBridgeParent.h"
#include "mozilla/layers/ImageDataSerializer.h"
#include "mozilla/layers/TextureHost.h"
#include "mozilla/layers/WebRenderCompositableHolder.h"
@@ -303,18 +304,59 @@ WebRenderBridgeParent::HandleDPEnd(const
AutoWebRenderBridgeParentAsyncMessageSender autoAsyncMessageSender(this, &aToDestroy);
++mWrEpoch; // Update webrender epoch
ProcessWebRenderCommands(aSize, aCommands, wr::NewEpoch(mWrEpoch),
dl, dlDesc, aux, auxDesc);
HoldPendingTransactionId(mWrEpoch, aTransactionId);
mScrollData = aScrollData;
- // TODO: pass the WebRenderScrollData to APZ (this will happen in a future
- // patch)
+ UpdateAPZ();
+}
+
+void
+WebRenderBridgeParent::UpdateAPZ()
+{
+ if (!mCompositorBridge) {
+ return;
+ }
+
+ CompositorBridgeParent* cbp;
+ uint64_t rootLayersId;
+ WebRenderBridgeParent* rootWrbp;
+ if (mWidget) {
+ // This WebRenderBridgeParent is attached to the root
+ // CompositorBridgeParent.
+ cbp = static_cast<CompositorBridgeParent*>(mCompositorBridge);
+ rootLayersId = wr::AsUint64(mPipelineId);
+ rootWrbp = this;
+ } else {
+ // This WebRenderBridgeParent is attached to a
+ // CrossProcessCompositorBridgeParent so we have an extra level of
+ // indirection to unravel.
+ uint64_t layersId = wr::AsUint64(mPipelineId);
+ CompositorBridgeParent::LayerTreeState* lts =
+ CompositorBridgeParent::GetIndirectShadowTree(layersId);
+ MOZ_ASSERT(lts);
+ cbp = lts->mParent;
+ rootLayersId = cbp->RootLayerTreeId();
+ lts = CompositorBridgeParent::GetIndirectShadowTree(rootLayersId);
+ MOZ_ASSERT(lts);
+ rootWrbp = lts->mWrBridge.get();
+ }
+
+ MOZ_ASSERT(cbp);
+ if (!rootWrbp) {
+ return;
+ }
+ if (RefPtr<APZCTreeManager> apzc = cbp->GetAPZCTreeManager()) {
+ apzc->UpdateHitTestingTree(rootLayersId, rootWrbp->GetScrollData(),
+ mScrollData.IsFirstPaint(), wr::AsUint64(mPipelineId),
+ /* TODO: propagate paint sequence number */ 0);
+ }
}
const WebRenderScrollData&
WebRenderBridgeParent::GetScrollData() const
{
MOZ_ASSERT(mozilla::layers::CompositorThreadHolder::IsInCompositorThread());
return mScrollData;
}
--- a/gfx/layers/wr/WebRenderBridgeParent.h
+++ b/gfx/layers/wr/WebRenderBridgeParent.h
@@ -155,16 +155,17 @@ public:
aNotifications->AppendElements(Move(mImageCompositeNotifications));
}
uint32_t GetIdNameSpace()
{
return mIdNameSpace;
}
+ void UpdateAPZ();
const WebRenderScrollData& GetScrollData() const;
private:
virtual ~WebRenderBridgeParent();
void DeleteOldImages();
void ProcessWebRenderCommands(const gfx::IntSize &aSize, InfallibleTArray<WebRenderParentCommand>& commands, const wr::Epoch& aEpoch,
const ByteBuffer& dl,