Bug 1400407 - Part 1: Cleanup WebVR dead code
- 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
--- a/gfx/gl/SharedSurface.cpp
+++ b/gfx/gl/SharedSurface.cpp
@@ -318,22 +318,17 @@ SurfaceFactory::~SurfaceFactory()
already_AddRefed<layers::SharedSurfaceTextureClient>
SurfaceFactory::NewTexClient(const gfx::IntSize& size, const layers::LayersIPCChannel* aLayersChannel)
{
while (!mRecycleFreePool.empty()) {
RefPtr<layers::SharedSurfaceTextureClient> cur = mRecycleFreePool.front();
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();
}
}
StopRecycling(cur);
}
--- a/gfx/layers/ipc/PTexture.ipdl
+++ b/gfx/layers/ipc/PTexture.ipdl
@@ -4,32 +4,31 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
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";
using struct mozilla::layers::FrameMetrics from "FrameMetrics.h";
using mozilla::layers::TextureFlags from "mozilla/layers/CompositorTypes.h";
namespace mozilla {
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__();
parent:
/**
* Asynchronously tell the compositor side to remove the texture.
*/
--- a/gfx/vr/ipc/PVRManager.ipdl
+++ b/gfx/vr/ipc/PVRManager.ipdl
@@ -1,17 +1,16 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: sw=2 ts=8 et :
*/
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
include LayersSurfaces;
-include protocol PTexture;
include protocol PVRLayer;
include LayersMessages;
include GamepadEventTypes;
include "VRMessageUtils.h";
using struct mozilla::gfx::VRFieldOfView from "gfxVR.h";
using struct mozilla::gfx::VRDisplayInfo from "gfxVR.h";
@@ -28,23 +27,19 @@ namespace gfx {
/**
* The PVRManager protocol is used to enable communication of VR display
* enumeration and sensor state between the compositor thread and
* content threads/processes.
*/
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
// asynchronously to children via UpdateDisplayInfo.
async RefreshDisplays();
// Reset the sensor of the display identified by aDisplayID so that the current
// sensor state is the "Zero" position.
--- a/gfx/vr/ipc/VRLayerParent.h
+++ b/gfx/vr/ipc/VRLayerParent.h
@@ -31,17 +31,16 @@ protected:
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
virtual ~VRLayerParent();
void Destroy();
bool mIPCOpen;
uint32_t mVRDisplayID;
- gfx::IntSize mSize;
gfx::Rect mLeftEyeRect;
gfx::Rect mRightEyeRect;
uint32_t mGroup;
};
} // namespace gfx
} // namespace mozilla
--- a/gfx/vr/ipc/VRManagerChild.cpp
+++ b/gfx/vr/ipc/VRManagerChild.cpp
@@ -34,18 +34,17 @@ namespace gfx {
static StaticRefPtr<VRManagerChild> sVRManagerChildSingleton;
static StaticRefPtr<VRManagerParent> sVRManagerParentSingleton;
void ReleaseVRManagerParentSingleton() {
sVRManagerParentSingleton = nullptr;
}
VRManagerChild::VRManagerChild()
- : TextureForwarder()
- , mDisplaysInitialized(false)
+ : mDisplaysInitialized(false)
, mMessageLoop(MessageLoop::current())
, mFrameRequestCallbackCounter(0)
, mBackend(layers::LayersBackend::LAYERS_NONE)
, mPromiseID(0)
, mVRMockDisplay(nullptr)
{
MOZ_ASSERT(NS_IsMainThread());
@@ -162,31 +161,16 @@ VRManagerChild::Destroy()
RefPtr<VRManagerChild> selfRef = this;
// The DeferredDestroyVRManager task takes ownership of
// the VRManagerChild and will release it when it runs.
MessageLoop::current()->PostTask(
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)
{
return VRLayerChild::CreateIPDLActor();
}
bool
@@ -329,69 +313,26 @@ VRManagerChild::RecvParentAsyncMessages(
default:
NS_ERROR("unknown AsyncParentMessageData type");
return IPC_FAIL_NO_REASON(this);
}
}
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<TextureClient> client = mTexturesWaitingRecycled.Get(aTextureId);
- if (!client) {
- return;
- }
- mTexturesWaitingRecycled.Remove(aTextureId);
-}
-
void
VRManagerChild::NotifyNotUsed(uint64_t aTextureId, uint64_t aFwdTransactionId)
{
RefPtr<TextureClient> client = mTexturesWaitingRecycled.Get(aTextureId);
if (!client) {
return;
}
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,
uint32_t aGroup)
{
PVRLayerChild* vrLayerChild = AllocPVRLayerChild(aDisplayID, aGroup);
// Do the DOM labeling.
if (aTarget) {
--- a/gfx/vr/ipc/VRManagerChild.h
+++ b/gfx/vr/ipc/VRManagerChild.h
@@ -28,24 +28,19 @@ namespace layers {
class SyncObjectClient;
class TextureClient;
}
namespace gfx {
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();
// Indicate that an observer wants to receive VR events.
void AddListener(dom::VREventObserver* aObserver);
// Indicate that an observer should no longer receive VR events.
void RemoveListener(dom::VREventObserver* aObserver);
@@ -59,36 +54,24 @@ public:
static void InitSameProcess();
static void InitWithGPUProcess(Endpoint<PVRManagerChild>&& aEndpoint);
static bool InitForContent(Endpoint<PVRManagerChild>&& aEndpoint);
static bool ReinitForContent(Endpoint<PVRManagerChild>&& aEndpoint);
static void ShutDown();
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);
static void IdentifyTextureHost(const layers::TextureFactoryIdentifier& aIdentifier);
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);
void RunFrameRequestCallbacks();
void UpdateDisplayInfo(nsTArray<VRDisplayInfo>& aDisplayUpdates);
void FireDOMVRDisplayMountedEvent(uint32_t aDisplayID);
void FireDOMVRDisplayUnmountedEvent(uint32_t aDisplayID);
@@ -99,22 +82,16 @@ public:
virtual void HandleFatalError(const char* aName, const char* aMsg) const override;
protected:
explicit VRManagerChild();
~VRManagerChild();
void Destroy();
static void DeferredDestroy(RefPtr<VRManagerChild> 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;
virtual mozilla::ipc::IPCResult RecvUpdateDisplayInfo(nsTArray<VRDisplayInfo>&& aDisplayUpdates) override;
virtual mozilla::ipc::IPCResult RecvParentAsyncMessages(InfallibleTArray<AsyncParentMessageData>&& aMessages) override;
@@ -123,36 +100,20 @@ protected:
virtual mozilla::ipc::IPCResult RecvReplyGamepadVibrateHaptic(const uint32_t& aPromiseID) override;
virtual mozilla::ipc::IPCResult RecvReplyCreateVRServiceTestDisplay(const nsCString& aID,
const uint32_t& aPromiseID,
const uint32_t& aDeviceID) override;
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);
void FireDOMVRDisplayUnmountedEventInternal(uint32_t aDisplayID);
void FireDOMVRDisplayConnectEventInternal(uint32_t aDisplayID);
void FireDOMVRDisplayDisconnectEventInternal(uint32_t aDisplayID);
void FireDOMVRDisplayPresentChangeEventInternal(uint32_t aDisplayID);
/**
--- a/gfx/vr/ipc/VRManagerParent.cpp
+++ b/gfx/vr/ipc/VRManagerParent.cpp
@@ -16,18 +16,17 @@
#include "VRManager.h"
#include "gfxVRPuppet.h"
namespace mozilla {
using namespace layers;
namespace gfx {
VRManagerParent::VRManagerParent(ProcessId aChildProcessId, bool aIsContentChild)
- : HostIPCAllocator()
- , mDisplayTestID(0)
+ : mDisplayTestID(0)
, mControllerTestID(0)
, mHaveEventListener(false)
, mHaveControllerListener(false)
, mIsContentChild(aIsContentChild)
{
MOZ_COUNT_CTOR(VRManagerParent);
MOZ_ASSERT(NS_IsMainThread());
@@ -36,31 +35,16 @@ VRManagerParent::VRManagerParent(Process
VRManagerParent::~VRManagerParent()
{
MOZ_ASSERT(!mVRManagerHolder);
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)
{
RefPtr<VRLayerParent> layer;
layer = new VRLayerParent(aDisplayID,
aGroup);
VRManager* vm = VRManager::Get();
@@ -74,62 +58,22 @@ VRManagerParent::AllocPVRLayerParent(con
bool
VRManagerParent::DeallocPVRLayerParent(PVRLayerParent* actor)
{
delete 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<AsyncParentMessageData>& aMessage)
-{
- MOZ_ASSERT_UNREACHABLE("unexpected to be called");
-}
-
-base::ProcessId
-VRManagerParent::GetChildProcessId()
-{
- return OtherPid();
-}
-
-void
VRManagerParent::RegisterWithManager()
{
VRManager* vm = VRManager::Get();
vm->AddVRManagerParent(this);
mVRManagerHolder = vm;
}
void
--- a/gfx/vr/ipc/VRManagerParent.h
+++ b/gfx/vr/ipc/VRManagerParent.h
@@ -23,60 +23,34 @@ namespace gfx {
class VRManager;
namespace impl {
class VRDisplayPuppet;
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);
static VRManagerParent* CreateSameProcess();
static bool CreateForGPUProcess(Endpoint<PVRManagerParent>&& aEndpoint);
static bool CreateForContent(Endpoint<PVRManagerParent>&& 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<AsyncParentMessageData>& 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;
virtual void ActorDestroy(ActorDestroyReason why) override;
void OnChannelConnected(int32_t pid) override;
virtual mozilla::ipc::IPCResult RecvRefreshDisplays() override;