Bug 1323957 - Follow-up to remove PCompositable entrails in the graphics branch. r=mattwoodrow?

MozReview-Commit-ID: 2wZlT33ty86
This commit is contained in:
Kartikaya Gupta 2017-01-18 13:47:27 -05:00
Родитель b66c471aef
Коммит c8008e5222
6 изменённых файлов: 55 добавлений и 65 удалений

Просмотреть файл

@ -11,11 +11,11 @@ include "mozilla/GfxMessageUtils.h";
include "mozilla/layers/WebRenderMessageUtils.h";
include WebRenderMessages;
include protocol PCompositable;
include protocol PCompositorBridge;
include protocol PTexture;
using struct mozilla::layers::TextureInfo from "mozilla/layers/CompositorTypes.h";
using mozilla::layers::CompositableHandle from "mozilla/layers/LayersTypes.h";
using mozilla::wr::ByteBuffer from "mozilla/webrender/WebRenderTypes.h";
using mozilla::wr::ImageKey from "mozilla/webrender/WebRenderTypes.h";
@ -25,10 +25,10 @@ namespace layers {
sync protocol PWebRenderBridge
{
manager PCompositorBridge;
manages PCompositable;
parent:
async PCompositable(TextureInfo aTextureInfo);
async NewCompositable(CompositableHandle handle, TextureInfo info);
async ReleaseCompositable(CompositableHandle compositable);
sync Create(IntSize aSize);
sync AddImage(IntSize aSize, uint32_t aStride,
@ -42,8 +42,8 @@ parent:
async DPEnd(WebRenderCommand[] commands, OpDestroy[] toDestroy, uint64_t fwdTransactionId, uint64_t transactionId);
sync DPSyncEnd(WebRenderCommand[] commands, OpDestroy[] toDestroy, uint64_t fwdTransactionId, uint64_t transactionId);
sync DPGetSnapshot(PTexture texture);
async AddExternalImageId(uint64_t aImageId, uint64_t aAsyncContainerId);
async AddExternalImageIdForCompositable(uint64_t aImageId, PCompositable aCompositable);
async AddExternalImageId(uint64_t aImageId, CompositableHandle aHandle);
async AddExternalImageIdForCompositable(uint64_t aImageId, CompositableHandle aHandle);
async RemoveExternalImageId(uint64_t aImageId);
async SetLayerObserverEpoch(uint64_t layerObserverEpoch);
async ClearCachedResources();

Просмотреть файл

@ -7,7 +7,6 @@
include LayersSurfaces;
include LayersMessages;
include protocol PCompositable;
include protocol PTexture;
using WrBorderSide from "mozilla/webrender/webrender_ffi.h";

Просмотреть файл

@ -7,7 +7,6 @@
#include "mozilla/layers/WebRenderBridgeChild.h"
#include "gfxPlatform.h"
#include "mozilla/layers/CompositableChild.h"
#include "mozilla/layers/CompositableClient.h"
#include "mozilla/layers/CompositorBridgeChild.h"
#include "mozilla/layers/ImageDataSerializer.h"
@ -99,12 +98,12 @@ WebRenderBridgeChild::GetNextExternalImageId()
}
uint64_t
WebRenderBridgeChild::AllocExternalImageId(uint64_t aAsyncContainerID)
WebRenderBridgeChild::AllocExternalImageId(const CompositableHandle& aHandle)
{
MOZ_ASSERT(!mDestroyed);
uint64_t imageId = GetNextExternalImageId();
SendAddExternalImageId(imageId, aAsyncContainerID);
SendAddExternalImageId(imageId, aHandle);
return imageId;
}
@ -112,14 +111,10 @@ uint64_t
WebRenderBridgeChild::AllocExternalImageIdForCompositable(CompositableClient* aCompositable)
{
MOZ_ASSERT(!mDestroyed);
MOZ_ASSERT(aCompositable->GetIPDLActor());
if (!aCompositable->GetIPDLActor()) {
return 0;
}
MOZ_ASSERT(aCompositable->IsConnected());
uint64_t imageId = GetNextExternalImageId();
SendAddExternalImageIdForCompositable(imageId, aCompositable->GetIPDLActor());
SendAddExternalImageIdForCompositable(imageId, aCompositable->GetIPCHandle());
return imageId;
}
@ -149,32 +144,20 @@ WebRenderBridgeChild::GetLayersIPCActor()
return static_cast<LayersIPCActor*>(GetCompositorBridgeChild());
}
PCompositableChild*
WebRenderBridgeChild::AllocPCompositableChild(const TextureInfo& aInfo)
{
MOZ_ASSERT(!mDestroyed);
return CompositableChild::CreateActor();
}
bool
WebRenderBridgeChild::DeallocPCompositableChild(PCompositableChild* aActor)
{
CompositableChild::DestroyActor(aActor);
return true;
}
void
WebRenderBridgeChild::Connect(CompositableClient* aCompositable,
ImageContainer* aImageContainer)
{
MOZ_ASSERT(aCompositable);
PCompositableChild* actor =
SendPCompositableConstructor(aCompositable->GetTextureInfo());
if (!actor) {
return;
}
aCompositable->InitIPDLActor(actor);
static uint64_t sNextID = 1;
uint64_t id = sNextID++;
mCompositables.Put(id, aCompositable);
CompositableHandle handle(id);
aCompositable->InitIPDL(handle);
SendNewCompositable(handle, aCompositable->GetTextureInfo());
}
void
@ -206,6 +189,15 @@ WebRenderBridgeChild::AddOpDestroy(const OpDestroy& aOp, bool aSynchronously)
return true;
}
void
WebRenderBridgeChild::ReleaseCompositable(const CompositableHandle& aHandle)
{
if (!DestroyInTransaction(aHandle)) {
SendReleaseCompositable(aHandle);
}
mCompositables.Remove(aHandle.Value());
}
bool
WebRenderBridgeChild::DestroyInTransaction(PTextureChild* aTexture, bool aSynchronously)
{
@ -213,9 +205,9 @@ WebRenderBridgeChild::DestroyInTransaction(PTextureChild* aTexture, bool aSynchr
}
bool
WebRenderBridgeChild::DestroyInTransaction(PCompositableChild* aCompositable, bool aSynchronously)
WebRenderBridgeChild::DestroyInTransaction(const CompositableHandle& aHandle)
{
return AddOpDestroy(OpDestroy(aCompositable), aSynchronously);
return AddOpDestroy(OpDestroy(aHandle), false);
}
void
@ -233,7 +225,7 @@ WebRenderBridgeChild::RemoveTextureFromCompositable(CompositableClient* aComposi
AddWebRenderCommand(
CompositableOperation(
nullptr, aCompositable->GetIPDLActor(),
aCompositable->GetIPCHandle(),
OpRemoveTexture(nullptr, aTexture->GetIPDLActor())));
if (aTexture->GetFlags() & TextureFlags::DEALLOCATE_CLIENT) {
MarkSyncTransaction();
@ -273,7 +265,7 @@ WebRenderBridgeChild::UseTextures(CompositableClient* aCompositable,
}
GetCompositorBridgeChild()->HoldUntilCompositableRefReleasedIfNecessary(t.mTextureClient);
}
AddWebRenderCommand(CompositableOperation(nullptr, aCompositable->GetIPDLActor(),
AddWebRenderCommand(CompositableOperation(aCompositable->GetIPCHandle(),
OpUseTexture(textures)));
}

Просмотреть файл

@ -41,7 +41,7 @@ public:
TextureForwarder* GetTextureForwarder() override;
LayersIPCActor* GetLayersIPCActor() override;
uint64_t AllocExternalImageId(uint64_t aAsyncContainerID);
uint64_t AllocExternalImageId(const CompositableHandle& aHandle);
uint64_t AllocExternalImageIdForCompositable(CompositableClient* aCompositable);
void DeallocExternalImageId(uint64_t aImageId);
@ -49,7 +49,6 @@ public:
* Clean this up, finishing with SendShutDown() which will cause __delete__
* to be sent from the parent side.
*/
using CompositableForwarder::Destroy;
void Destroy();
bool IPCOpen() const { return mIPCOpen && !mDestroyed; }
bool IsDestroyed() const { return mDestroyed; }
@ -66,10 +65,6 @@ private:
uint64_t GetNextExternalImageId();
// manage PCompositable
PCompositableChild* AllocPCompositableChild(const TextureInfo& aInfo) override;
bool DeallocPCompositableChild(PCompositableChild* aActor) override;
// CompositableForwarder
void Connect(CompositableClient* aCompositable,
ImageContainer* aImageContainer = nullptr) override;
@ -78,8 +73,9 @@ private:
void UpdateTextureRegion(CompositableClient* aCompositable,
const ThebesBufferData& aThebesBufferData,
const nsIntRegion& aUpdatedRegion) override;
void ReleaseCompositable(const CompositableHandle& aHandle) override;
bool DestroyInTransaction(PTextureChild* aTexture, bool aSynchronously) override;
bool DestroyInTransaction(PCompositableChild* aCompositable, bool aSynchronously) override;
bool DestroyInTransaction(const CompositableHandle& aHandle);
void RemoveTextureFromCompositable(CompositableClient* aCompositable,
TextureClient* aTexture) override;
void UseTextures(CompositableClient* aCompositable,
@ -108,6 +104,7 @@ private:
nsTArray<WebRenderCommand> mCommands;
nsTArray<OpDestroy> mDestroyedActors;
nsDataHashtable<nsUint64HashKey, CompositableClient*> mCompositables;
bool mIsInTransaction;
bool mSyncTransaction;

Просмотреть файл

@ -464,7 +464,7 @@ WebRenderBridgeParent::RecvDPGetSnapshot(PTextureParent* aTexture)
mozilla::ipc::IPCResult
WebRenderBridgeParent::RecvAddExternalImageId(const uint64_t& aImageId,
const uint64_t& aAsyncContainerId)
const CompositableHandle& aHandle)
{
if (mDestroyed) {
return IPC_OK();
@ -475,7 +475,7 @@ WebRenderBridgeParent::RecvAddExternalImageId(const uint64_t& aImageId,
if (!imageBridge) {
return IPC_FAIL_NO_REASON(this);
}
CompositableHost* host = imageBridge->FindCompositable(aAsyncContainerId);
RefPtr<CompositableHost> host = imageBridge->FindCompositable(aHandle);
if (!host) {
NS_ERROR("CompositableHost not found in the map!");
return IPC_FAIL_NO_REASON(this);
@ -495,14 +495,14 @@ WebRenderBridgeParent::RecvAddExternalImageId(const uint64_t& aImageId,
mozilla::ipc::IPCResult
WebRenderBridgeParent::RecvAddExternalImageIdForCompositable(const uint64_t& aImageId,
PCompositableParent* aCompositable)
const CompositableHandle& aHandle)
{
if (mDestroyed) {
return IPC_OK();
}
MOZ_ASSERT(!mExternalImageIds.Get(aImageId).get());
CompositableHost* host = CompositableHost::FromIPDLActor(aCompositable);
RefPtr<CompositableHost> host = FindCompositable(aHandle);
if (host->GetType() != CompositableType::IMAGE &&
host->GetType() != CompositableType::CONTENT_SINGLE &&
host->GetType() != CompositableType::CONTENT_DOUBLE) {
@ -687,20 +687,21 @@ WebRenderBridgeParent::IsSameProcess() const
return OtherPid() == base::GetCurrentProcId();
}
PCompositableParent*
WebRenderBridgeParent::AllocPCompositableParent(const TextureInfo& aInfo)
mozilla::ipc::IPCResult
WebRenderBridgeParent::RecvNewCompositable(const CompositableHandle& aHandle,
const TextureInfo& aInfo)
{
PCompositableParent* actor = CompositableHost::CreateIPDLActor(this, aInfo);
CompositableHost* compositable = CompositableHost::FromIPDLActor(actor);
MOZ_ASSERT(compositable);
compositable->SetCompositor(mCompositor);
return actor;
if (!AddCompositable(aHandle, aInfo)) {
return IPC_FAIL_NO_REASON(this);
}
return IPC_OK();
}
bool
WebRenderBridgeParent::DeallocPCompositableParent(PCompositableParent* aActor)
mozilla::ipc::IPCResult
WebRenderBridgeParent::RecvReleaseCompositable(const CompositableHandle& aHandle)
{
return CompositableHost::DestroyIPDLActor(aActor);
ReleaseCompositable(aHandle);
return IPC_OK();
}
void

Просмотреть файл

@ -59,6 +59,10 @@ public:
layers::Compositor* Compositor() { return mCompositor.get(); }
CompositorVsyncScheduler* CompositorScheduler() { return mCompositorScheduler.get(); }
mozilla::ipc::IPCResult RecvNewCompositable(const CompositableHandle& aHandle,
const TextureInfo& aInfo) override;
mozilla::ipc::IPCResult RecvReleaseCompositable(const CompositableHandle& aHandle) override;
mozilla::ipc::IPCResult RecvCreate(const gfx::IntSize& aSize) override;
mozilla::ipc::IPCResult RecvShutdown() override;
mozilla::ipc::IPCResult RecvAddImage(const gfx::IntSize& aSize,
@ -84,9 +88,9 @@ public:
mozilla::ipc::IPCResult RecvDPGetSnapshot(PTextureParent* aTexture) override;
mozilla::ipc::IPCResult RecvAddExternalImageId(const uint64_t& aImageId,
const uint64_t& aAsyncContainerId) override;
const CompositableHandle& aHandle) override;
mozilla::ipc::IPCResult RecvAddExternalImageIdForCompositable(const uint64_t& aImageId,
PCompositableParent* aCompositable) override;
const CompositableHandle& aHandle) override;
mozilla::ipc::IPCResult RecvRemoveExternalImageId(const uint64_t& aImageId) override;
mozilla::ipc::IPCResult RecvSetLayerObserverEpoch(const uint64_t& aLayerObserverEpoch) override;
@ -118,9 +122,6 @@ public:
private:
virtual ~WebRenderBridgeParent();
virtual PCompositableParent* AllocPCompositableParent(const TextureInfo& aInfo) override;
bool DeallocPCompositableParent(PCompositableParent* aActor) override;
void DeleteOldImages();
void ProcessWebrenderCommands(InfallibleTArray<WebRenderCommand>& commands);
void ScheduleComposition();