From 07bf2f89682ea65d30b6bd2ea9f01cc979e620da Mon Sep 17 00:00:00 2001 From: "Kearwood \"Kip\" Gilbert" Date: Thu, 14 Sep 2017 17:10:15 -0700 Subject: [PATCH] Bug 1400407 - Part 1: Cleanup WebVR dead code,r=daoshengmu,r=jgilbert - VRManagerChild no longer needs to be a TextureForwarder - VRManagerParent no longer descends from HostIPCAllocator or ShmemAllocator - PVRManager no longer manages PTexture's - VRLayerParent::mSize was not used and has been removed MozReview-Commit-ID: 3bNN5FR5j7M --HG-- extra : rebase_source : 634277825c00057bca6f8c77cdc942de61d61e9c --- gfx/gl/SharedSurface.cpp | 7 +--- gfx/layers/ipc/PTexture.ipdl | 3 +- gfx/vr/ipc/PVRManager.ipdl | 5 --- gfx/vr/ipc/VRLayerParent.h | 1 - gfx/vr/ipc/VRManagerChild.cpp | 61 +--------------------------------- gfx/vr/ipc/VRManagerChild.h | 43 ++---------------------- gfx/vr/ipc/VRManagerParent.cpp | 58 +------------------------------- gfx/vr/ipc/VRManagerParent.h | 30 ++--------------- 8 files changed, 8 insertions(+), 200 deletions(-) diff --git a/gfx/gl/SharedSurface.cpp b/gfx/gl/SharedSurface.cpp index 96648bf36401..7c64b3d2fc26 100644 --- a/gfx/gl/SharedSurface.cpp +++ b/gfx/gl/SharedSurface.cpp @@ -323,12 +323,7 @@ SurfaceFactory::NewTexClient(const gfx::IntSize& size, const layers::LayersIPCCh mRecycleFreePool.pop(); if (cur->Surf()->mSize == size){ - // In the general case, textureClients transit textures through - // CompositorForwarder. But, the textureClient created by VRManagerChild - // has a different LayerIPCChannel, PVRManager. Therefore, textureClients - // need to be separated into different cases. - if ((aLayersChannel && aLayersChannel == cur->GetAllocator()) || - (cur->GetAllocator() != gfx::VRManagerChild::Get())) { + if (aLayersChannel && aLayersChannel == cur->GetAllocator()) { cur->Surf()->WaitForBufferOwnership(); return cur.forget(); } diff --git a/gfx/layers/ipc/PTexture.ipdl b/gfx/layers/ipc/PTexture.ipdl index 403ca0da1179..f42a3ed80417 100644 --- a/gfx/layers/ipc/PTexture.ipdl +++ b/gfx/layers/ipc/PTexture.ipdl @@ -9,7 +9,6 @@ include LayersSurfaces; include protocol PLayerTransaction; include protocol PCompositorBridge; include protocol PImageBridge; -include protocol PVRManager; include protocol PVideoBridge; include "mozilla/GfxMessageUtils.h"; include "mozilla/layers/LayersMessageUtils.h"; @@ -24,7 +23,7 @@ namespace layers { * PTexture is the IPDL glue between a TextureClient and a TextureHost. */ sync protocol PTexture { - manager PImageBridge or PCompositorBridge or PVRManager or PVideoBridge; + manager PImageBridge or PCompositorBridge or PVideoBridge; child: async __delete__(); diff --git a/gfx/vr/ipc/PVRManager.ipdl b/gfx/vr/ipc/PVRManager.ipdl index 241a6533b3ac..1e3649215791 100644 --- a/gfx/vr/ipc/PVRManager.ipdl +++ b/gfx/vr/ipc/PVRManager.ipdl @@ -6,7 +6,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ include LayersSurfaces; -include protocol PTexture; include protocol PVRLayer; include LayersMessages; include GamepadEventTypes; @@ -33,13 +32,9 @@ namespace gfx { */ sync protocol PVRManager { - manages PTexture; manages PVRLayer; parent: - async PTexture(SurfaceDescriptor aSharedData, LayersBackend aBackend, - TextureFlags aTextureFlags, uint64_t aSerial); - async PVRLayer(uint32_t aDisplayID, uint32_t aGroup); // (Re)Enumerate VR Displays. An updated list of VR displays will be returned diff --git a/gfx/vr/ipc/VRLayerParent.h b/gfx/vr/ipc/VRLayerParent.h index d11d787682e6..ec7fa78f3314 100644 --- a/gfx/vr/ipc/VRLayerParent.h +++ b/gfx/vr/ipc/VRLayerParent.h @@ -36,7 +36,6 @@ protected: bool mIPCOpen; uint32_t mVRDisplayID; - gfx::IntSize mSize; gfx::Rect mLeftEyeRect; gfx::Rect mRightEyeRect; uint32_t mGroup; diff --git a/gfx/vr/ipc/VRManagerChild.cpp b/gfx/vr/ipc/VRManagerChild.cpp index 42fdd353d2d2..a469bfded3a7 100644 --- a/gfx/vr/ipc/VRManagerChild.cpp +++ b/gfx/vr/ipc/VRManagerChild.cpp @@ -39,8 +39,7 @@ void ReleaseVRManagerParentSingleton() { } VRManagerChild::VRManagerChild() - : TextureForwarder() - , mDisplaysInitialized(false) + : mDisplaysInitialized(false) , mMessageLoop(MessageLoop::current()) , mFrameRequestCallbackCounter(0) , mBackend(layers::LayersBackend::LAYERS_NONE) @@ -167,21 +166,6 @@ VRManagerChild::Destroy() NewRunnableFunction(DeferredDestroy, selfRef)); } -layers::PTextureChild* -VRManagerChild::AllocPTextureChild(const SurfaceDescriptor&, - const LayersBackend&, - const TextureFlags&, - const uint64_t&) -{ - return TextureClient::CreateIPDLActor(); -} - -bool -VRManagerChild::DeallocPTextureChild(PTextureChild* actor) -{ - return TextureClient::DestroyIPDLActor(actor); -} - PVRLayerChild* VRManagerChild::AllocPVRLayerChild(const uint32_t& aDisplayID, const uint32_t& aGroup) @@ -334,27 +318,6 @@ VRManagerChild::RecvParentAsyncMessages(InfallibleTArray return IPC_OK(); } -PTextureChild* -VRManagerChild::CreateTexture(const SurfaceDescriptor& aSharedData, - LayersBackend aLayersBackend, - TextureFlags aFlags, - uint64_t aSerial, - wr::MaybeExternalImageId& aExternalImageId, - nsIEventTarget* aTarget) -{ - return SendPTextureConstructor(aSharedData, aLayersBackend, aFlags, aSerial); -} - -void -VRManagerChild::CancelWaitForRecycle(uint64_t aTextureId) -{ - RefPtr client = mTexturesWaitingRecycled.Get(aTextureId); - if (!client) { - return; - } - mTexturesWaitingRecycled.Remove(aTextureId); -} - void VRManagerChild::NotifyNotUsed(uint64_t aTextureId, uint64_t aFwdTransactionId) { @@ -365,28 +328,6 @@ VRManagerChild::NotifyNotUsed(uint64_t aTextureId, uint64_t aFwdTransactionId) mTexturesWaitingRecycled.Remove(aTextureId); } -bool -VRManagerChild::AllocShmem(size_t aSize, - ipc::SharedMemory::SharedMemoryType aType, - ipc::Shmem* aShmem) -{ - return PVRManagerChild::AllocShmem(aSize, aType, aShmem); -} - -bool -VRManagerChild::AllocUnsafeShmem(size_t aSize, - ipc::SharedMemory::SharedMemoryType aType, - ipc::Shmem* aShmem) -{ - return PVRManagerChild::AllocUnsafeShmem(aSize, aType, aShmem); -} - -bool -VRManagerChild::DeallocShmem(ipc::Shmem& aShmem) -{ - return PVRManagerChild::DeallocShmem(aShmem); -} - PVRLayerChild* VRManagerChild::CreateVRLayer(uint32_t aDisplayID, nsIEventTarget* aTarget, diff --git a/gfx/vr/ipc/VRManagerChild.h b/gfx/vr/ipc/VRManagerChild.h index 18814efcbafb..d0fed3cb77a1 100644 --- a/gfx/vr/ipc/VRManagerChild.h +++ b/gfx/vr/ipc/VRManagerChild.h @@ -33,14 +33,9 @@ class VRLayerChild; class VRDisplayClient; class VRManagerChild : public PVRManagerChild - , public layers::TextureForwarder - , public layers::KnowsCompositor { public: - NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VRManagerChild, override); - - TextureForwarder* GetTextureForwarder() override { return this; } - LayersIPCActor* GetLayersIPCActor() override { return this; } + NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VRManagerChild); static VRManagerChild* Get(); @@ -64,15 +59,6 @@ public: static bool IsCreated(); - virtual PTextureChild* CreateTexture( - const SurfaceDescriptor& aSharedData, - layers::LayersBackend aLayersBackend, - TextureFlags aFlags, - uint64_t aSerial, - wr::MaybeExternalImageId& aExternalImageId, - nsIEventTarget* aTarget = nullptr) override; - virtual void CancelWaitForRecycle(uint64_t aTextureId) override; - PVRLayerChild* CreateVRLayer(uint32_t aDisplayID, nsIEventTarget* aTarget, uint32_t aGroup); @@ -81,9 +67,6 @@ public: layers::LayersBackend GetBackendType() const; layers::SyncObjectClient* GetSyncObject() { return mSyncObject; } - virtual MessageLoop* GetMessageLoop() const override { return mMessageLoop; } - virtual base::ProcessId GetParentPid() const override { return OtherPid(); } - nsresult ScheduleFrameRequestCallback(mozilla::dom::FrameRequestCallback& aCallback, int32_t *aHandle); void CancelFrameRequestCallback(int32_t aHandle); @@ -104,12 +87,6 @@ protected: void Destroy(); static void DeferredDestroy(RefPtr aVRManagerChild); - virtual PTextureChild* AllocPTextureChild(const SurfaceDescriptor& aSharedData, - const layers::LayersBackend& aLayersBackend, - const TextureFlags& aFlags, - const uint64_t& aSerial) override; - virtual bool DeallocPTextureChild(PTextureChild* actor) override; - virtual PVRLayerChild* AllocPVRLayerChild(const uint32_t& aDisplayID, const uint32_t& aGroup) override; virtual bool DeallocPVRLayerChild(PVRLayerChild* actor) override; @@ -128,26 +105,10 @@ protected: virtual mozilla::ipc::IPCResult RecvReplyCreateVRServiceTestController(const nsCString& aID, const uint32_t& aPromiseID, const uint32_t& aDeviceID) override; - - // ShmemAllocator - - virtual bool AllocShmem(size_t aSize, - ipc::SharedMemory::SharedMemoryType aType, - ipc::Shmem* aShmem) override; - - virtual bool AllocUnsafeShmem(size_t aSize, - ipc::SharedMemory::SharedMemoryType aType, - ipc::Shmem* aShmem) override; - - virtual bool DeallocShmem(ipc::Shmem& aShmem) override; - - virtual bool IsSameProcess() const override + bool IsSameProcess() const { return OtherPid() == base::GetCurrentProcId(); } - - friend class layers::CompositorBridgeChild; - private: void FireDOMVRDisplayMountedEventInternal(uint32_t aDisplayID); diff --git a/gfx/vr/ipc/VRManagerParent.cpp b/gfx/vr/ipc/VRManagerParent.cpp index 32a002956cd1..64d4487def00 100644 --- a/gfx/vr/ipc/VRManagerParent.cpp +++ b/gfx/vr/ipc/VRManagerParent.cpp @@ -21,8 +21,7 @@ using namespace layers; namespace gfx { VRManagerParent::VRManagerParent(ProcessId aChildProcessId, bool aIsContentChild) - : HostIPCAllocator() - , mDisplayTestID(0) + : mDisplayTestID(0) , mControllerTestID(0) , mHaveEventListener(false) , mHaveControllerListener(false) @@ -41,21 +40,6 @@ VRManagerParent::~VRManagerParent() MOZ_COUNT_DTOR(VRManagerParent); } -PTextureParent* -VRManagerParent::AllocPTextureParent(const SurfaceDescriptor& aSharedData, - const LayersBackend& aLayersBackend, - const TextureFlags& aFlags, - const uint64_t& aSerial) -{ - return layers::TextureHost::CreateIPDLActor(this, aSharedData, aLayersBackend, aFlags, aSerial, Nothing()); -} - -bool -VRManagerParent::DeallocPTextureParent(PTextureParent* actor) -{ - return layers::TextureHost::DestroyIPDLActor(actor); -} - PVRLayerParent* VRManagerParent::AllocPVRLayerParent(const uint32_t& aDisplayID, const uint32_t& aGroup) @@ -78,52 +62,12 @@ VRManagerParent::DeallocPVRLayerParent(PVRLayerParent* actor) return true; } -bool -VRManagerParent::AllocShmem(size_t aSize, - ipc::SharedMemory::SharedMemoryType aType, - ipc::Shmem* aShmem) -{ - return PVRManagerParent::AllocShmem(aSize, aType, aShmem); -} - -bool -VRManagerParent::AllocUnsafeShmem(size_t aSize, - ipc::SharedMemory::SharedMemoryType aType, - ipc::Shmem* aShmem) -{ - return PVRManagerParent::AllocUnsafeShmem(aSize, aType, aShmem); -} - -void -VRManagerParent::DeallocShmem(ipc::Shmem& aShmem) -{ - PVRManagerParent::DeallocShmem(aShmem); -} - bool VRManagerParent::IsSameProcess() const { return OtherPid() == base::GetCurrentProcId(); } -void -VRManagerParent::NotifyNotUsed(PTextureParent* aTexture, uint64_t aTransactionId) -{ - MOZ_ASSERT_UNREACHABLE("unexpected to be called"); -} - -void -VRManagerParent::SendAsyncMessage(const InfallibleTArray& aMessage) -{ - MOZ_ASSERT_UNREACHABLE("unexpected to be called"); -} - -base::ProcessId -VRManagerParent::GetChildProcessId() -{ - return OtherPid(); -} - void VRManagerParent::RegisterWithManager() { diff --git a/gfx/vr/ipc/VRManagerParent.h b/gfx/vr/ipc/VRManagerParent.h index 43540d5751b9..92814abf0452 100644 --- a/gfx/vr/ipc/VRManagerParent.h +++ b/gfx/vr/ipc/VRManagerParent.h @@ -28,9 +28,8 @@ class VRControllerPuppet; } // namespace impl class VRManagerParent final : public PVRManagerParent - , public HostIPCAllocator - , public ShmemAllocator { + NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VRManagerParent); public: explicit VRManagerParent(ProcessId aChildProcessId, bool aIsContentChild); @@ -38,40 +37,15 @@ public: static bool CreateForGPUProcess(Endpoint&& aEndpoint); static bool CreateForContent(Endpoint&& aEndpoint); - virtual base::ProcessId GetChildProcessId() override; - - // ShmemAllocator - - virtual ShmemAllocator* AsShmemAllocator() override { return this; } - - virtual bool AllocShmem(size_t aSize, - ipc::SharedMemory::SharedMemoryType aType, - ipc::Shmem* aShmem) override; - - virtual bool AllocUnsafeShmem(size_t aSize, - ipc::SharedMemory::SharedMemoryType aType, - ipc::Shmem* aShmem) override; - - virtual void DeallocShmem(ipc::Shmem& aShmem) override; - - virtual bool IsSameProcess() const override; + bool IsSameProcess() const; bool HaveEventListener(); bool HaveControllerListener(); - - virtual void NotifyNotUsed(PTextureParent* aTexture, uint64_t aTransactionId) override; - virtual void SendAsyncMessage(const InfallibleTArray& aMessage) override; bool SendGamepadUpdate(const GamepadChangeEvent& aGamepadEvent); bool SendReplyGamepadVibrateHaptic(const uint32_t& aPromiseID); protected: ~VRManagerParent(); - virtual PTextureParent* AllocPTextureParent(const SurfaceDescriptor& aSharedData, - const LayersBackend& aLayersBackend, - const TextureFlags& aFlags, - const uint64_t& aSerial) override; - virtual bool DeallocPTextureParent(PTextureParent* actor) override; - virtual PVRLayerParent* AllocPVRLayerParent(const uint32_t& aDisplayID, const uint32_t& aGroup) override; virtual bool DeallocPVRLayerParent(PVRLayerParent* actor) override;