Bug 1317774 - Add gfx code needed to use WebRender in gecko. r=gfx

The overall architecture here is that we add a new layers type, LAYERS_WR,
which can be used in place of client layers. The WebRenderLayerManager, in
the EndTransaction call, paints content into images and ships them over the
PWebRenderBridge to the compositor thread. The WebRenderBridgeParent code on
the compositor side talks to WebRender via the API in webrender.h.

MozReview-Commit-ID: JKLTLJWVXiN
This commit is contained in:
Mozilla Graphics Team
2016-11-16 08:54:51 -05:00
parent 6f7d6c416d
commit 8d165b3b75
34 changed files with 1738 additions and 0 deletions

View File

@@ -48,6 +48,7 @@
#include "mozilla/layers/LayersTypes.h"
#include "mozilla/layers/PLayerTransactionParent.h"
#include "mozilla/layers/RemoteContentController.h"
#include "mozilla/layers/WebRenderBridgeParent.h"
#include "mozilla/layout/RenderFrameParent.h"
#include "mozilla/media/MediaSystemResourceService.h" // for MediaSystemResourceService
#include "mozilla/mozalloc.h" // for operator new, etc
@@ -246,6 +247,54 @@ CrossProcessCompositorBridgeParent::DeallocPAPZParent(PAPZParent* aActor)
return true;
}
PWebRenderBridgeParent*
CrossProcessCompositorBridgeParent::AllocPWebRenderBridgeParent(const uint64_t& aPipelineId)
{
#ifndef MOZ_ENABLE_WEBRENDER
// Extra guard since this in the parent process and we don't want a malicious
// child process invoking this codepath before it's ready
MOZ_RELEASE_ASSERT(false);
#endif
// Check to see if this child process has access to this layer tree.
if (!LayerTreeOwnerTracker::Get()->IsMapped(aPipelineId, OtherPid())) {
NS_ERROR("Unexpected layers id in AllocPAPZCTreeManagerParent; dropping message...");
return nullptr;
}
MonitorAutoLock lock(*sIndirectLayerTreesLock);
MOZ_ASSERT(sIndirectLayerTrees.find(aPipelineId) != sIndirectLayerTrees.end());
MOZ_ASSERT(sIndirectLayerTrees[aPipelineId].mWRBridge == nullptr);
CompositorBridgeParent* cbp = sIndirectLayerTrees[aPipelineId].mParent;
WebRenderBridgeParent* root = sIndirectLayerTrees[cbp->RootLayerTreeId()].mWRBridge.get();
WebRenderBridgeParent* parent = new WebRenderBridgeParent(
aPipelineId, nullptr, root->GLContext(), root->WindowState());
parent->AddRef(); // IPDL reference
sIndirectLayerTrees[aPipelineId].mWRBridge = parent;
return parent;
}
bool
CrossProcessCompositorBridgeParent::DeallocPWebRenderBridgeParent(PWebRenderBridgeParent* aActor)
{
#ifndef MOZ_ENABLE_WEBRENDER
// Extra guard since this in the parent process and we don't want a malicious
// child process invoking this codepath before it's ready
MOZ_RELEASE_ASSERT(false);
#endif
WebRenderBridgeParent* parent = static_cast<WebRenderBridgeParent*>(aActor);
{
MonitorAutoLock lock(*sIndirectLayerTreesLock);
auto it = sIndirectLayerTrees.find(parent->PipelineId());
if (it != sIndirectLayerTrees.end()) {
it->second.mWRBridge = nullptr;
}
}
parent->Release(); // IPDL reference
return true;
}
mozilla::ipc::IPCResult
CrossProcessCompositorBridgeParent::RecvNotifyChildCreated(const uint64_t& child)
{