Bug 1274145 - Add HostIPCAllocator r=nical
authorSotaro Ikeda <sotaro.ikeda.g@gmail.com>
Thu, 19 May 2016 06:04:14 -0700
changeset 298078 9107ca27ed84838bf9e76420c28cf7da26fd1a6c
parent 298077 e68856caffda95b24eaaf1911a7ad3cdb06f7d68
child 298079 96c9c230f5442fa3b63b3ffb49ee448eb049e4b0
push id77028
push usersikeda@mozilla.com
push dateThu, 19 May 2016 13:04:37 +0000
treeherdermozilla-inbound@9107ca27ed84 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1274145
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1274145 - Add HostIPCAllocator r=nical
gfx/layers/composite/TextureHost.cpp
gfx/layers/composite/TextureHost.h
gfx/layers/ipc/CompositableTransactionParent.h
gfx/layers/ipc/CompositorBridgeParent.cpp
gfx/layers/ipc/CompositorBridgeParent.h
gfx/layers/ipc/ISurfaceAllocator.h
--- a/gfx/layers/composite/TextureHost.cpp
+++ b/gfx/layers/composite/TextureHost.cpp
@@ -60,17 +60,17 @@ namespace layers {
 
 /**
  * TextureParent is the host-side IPDL glue between TextureClient and TextureHost.
  * It is an IPDL actor just like LayerParent, CompositableParent, etc.
  */
 class TextureParent : public ParentActor<PTextureParent>
 {
 public:
-  explicit TextureParent(ISurfaceAllocator* aAllocator);
+  explicit TextureParent(HostIPCAllocator* aAllocator);
 
   ~TextureParent();
 
   bool Init(const SurfaceDescriptor& aSharedData,
             const LayersBackend& aLayersBackend,
             const TextureFlags& aFlags);
 
   void CompositorRecycle();
@@ -78,24 +78,24 @@ public:
   virtual bool RecvClientRecycle() override;
 
   virtual bool RecvRecycleTexture(const TextureFlags& aTextureFlags) override;
 
   TextureHost* GetTextureHost() { return mTextureHost; }
 
   virtual void Destroy() override;
 
-  ISurfaceAllocator* mSurfaceAllocator;
+  HostIPCAllocator* mSurfaceAllocator;
   RefPtr<TextureHost> mWaitForClientRecycle;
   RefPtr<TextureHost> mTextureHost;
 };
 
 ////////////////////////////////////////////////////////////////////////////////
 PTextureParent*
-TextureHost::CreateIPDLActor(ISurfaceAllocator* aAllocator,
+TextureHost::CreateIPDLActor(HostIPCAllocator* aAllocator,
                              const SurfaceDescriptor& aSharedData,
                              LayersBackend aLayersBackend,
                              TextureFlags aFlags)
 {
   if (aSharedData.type() == SurfaceDescriptor::TSurfaceDescriptorBuffer &&
       aSharedData.get_SurfaceDescriptorBuffer().data().type() == MemoryOrShmem::Tuintptr_t &&
       !aAllocator->IsSameProcess())
   {
@@ -890,17 +890,17 @@ size_t MemoryTextureHost::GetBufferSize(
 {
   // MemoryTextureHost just trusts that the buffer size is large enough to read
   // anything we need to. That's because MemoryTextureHost has to trust the buffer
   // pointer anyway, so the security model here is just that MemoryTexture's
   // are restricted to same-process clients.
   return std::numeric_limits<size_t>::max();
 }
 
-TextureParent::TextureParent(ISurfaceAllocator* aSurfaceAllocator)
+TextureParent::TextureParent(HostIPCAllocator* aSurfaceAllocator)
 : mSurfaceAllocator(aSurfaceAllocator)
 {
   MOZ_COUNT_CTOR(TextureParent);
 }
 
 TextureParent::~TextureParent()
 {
   MOZ_COUNT_DTOR(TextureParent);
--- a/gfx/layers/composite/TextureHost.h
+++ b/gfx/layers/composite/TextureHost.h
@@ -38,16 +38,17 @@ class Shmem;
 
 namespace layers {
 
 class BufferDescriptor;
 class Compositor;
 class CompositableParentManager;
 class CompositorBridgeParent;
 class SurfaceDescriptor;
+class HostIPCAllocator;
 class ISurfaceAllocator;
 class TextureHostOGL;
 class TextureSourceOGL;
 class TextureSourceD3D9;
 class TextureSourceD3D11;
 class TextureSourceBasic;
 class DataTextureSource;
 class PTextureParent;
@@ -477,17 +478,17 @@ public:
   /**
    * Allocate and deallocate a TextureParent actor.
    *
    * TextureParent< is an implementation detail of TextureHost that is not
    * exposed to the rest of the code base. CreateIPDLActor and DestroyIPDLActor
    * are for use with the managing IPDL protocols only (so that they can
    * implement AllocPTextureParent and DeallocPTextureParent).
    */
-  static PTextureParent* CreateIPDLActor(ISurfaceAllocator* aAllocator,
+  static PTextureParent* CreateIPDLActor(HostIPCAllocator* aAllocator,
                                          const SurfaceDescriptor& aSharedData,
                                          LayersBackend aLayersBackend,
                                          TextureFlags aFlags);
   static bool DestroyIPDLActor(PTextureParent* actor);
 
   /**
    * Destroy the TextureChild/Parent pair.
    */
--- a/gfx/layers/ipc/CompositableTransactionParent.h
+++ b/gfx/layers/ipc/CompositableTransactionParent.h
@@ -20,30 +20,25 @@ namespace layers {
 class CompositableHost;
 
 typedef std::vector<mozilla::layers::EditReply> EditReplyVector;
 
 // Since PCompositble has two potential manager protocols, we can't just call
 // the Manager() method usually generated when there's one manager protocol,
 // so both manager protocols implement this and we keep a reference to them
 // through this interface.
-class CompositableParentManager : public ISurfaceAllocator
+class CompositableParentManager : public HostIPCAllocator
 {
 public:
   virtual void SendFenceHandleIfPresent(PTextureParent* aTexture) = 0;
 
   virtual void SendAsyncMessage(const InfallibleTArray<AsyncParentMessageData>& aMessage) = 0;
 
   void SendPendingAsyncMessages();
 
-  /**
-   * Get child side's process Id.
-   */
-  virtual base::ProcessId GetChildProcessId() = 0;
-
   void DestroyActor(const OpDestroy& aOp);
 
 protected:
   /**
    * Handle the IPDL messages that affect PCompositable actors.
    */
   bool ReceiveCompositableUpdate(const CompositableOperation& aEdit,
                                  EditReplyVector& replyv);
--- a/gfx/layers/ipc/CompositorBridgeParent.cpp
+++ b/gfx/layers/ipc/CompositorBridgeParent.cpp
@@ -1801,17 +1801,17 @@ CompositorBridgeParent::RequestNotifyLay
  * This class handles layer updates pushed directly from child processes to
  * the compositor thread. It's associated with a CompositorBridgeParent on the
  * compositor thread. While it uses the PCompositorBridge protocol to manage
  * these updates, it doesn't actually drive compositing itself. For that it
  * hands off work to the CompositorBridgeParent it's associated with.
  */
 class CrossProcessCompositorBridgeParent final : public PCompositorBridgeParent,
                                                  public ShadowLayersManager,
-                                                 public ISurfaceAllocator,
+                                                 public HostIPCAllocator,
                                                  public ShmemAllocator
 {
   friend class CompositorBridgeParent;
 
 public:
   explicit CrossProcessCompositorBridgeParent(Transport* aTransport)
     : mTransport(aTransport)
     , mSubprocess(nullptr)
@@ -1959,16 +1959,21 @@ public:
                           mozilla::ipc::Shmem* aShmem) override;
 
   virtual bool AllocUnsafeShmem(size_t aSize,
                                 mozilla::ipc::SharedMemory::SharedMemoryType aType,
                                 mozilla::ipc::Shmem* aShmem) override;
 
   virtual void DeallocShmem(mozilla::ipc::Shmem& aShmem) override;
 
+  virtual base::ProcessId GetChildProcessId() override
+  {
+    return OtherPid();
+  }
+
 protected:
   void OnChannelConnected(int32_t pid) override {
     mCompositorThreadHolder = CompositorThreadHolder::GetSingleton();
   }
 private:
   // Private destructor, to discourage deletion outside of Release():
   virtual ~CrossProcessCompositorBridgeParent();
 
--- a/gfx/layers/ipc/CompositorBridgeParent.h
+++ b/gfx/layers/ipc/CompositorBridgeParent.h
@@ -198,17 +198,17 @@ public:
   virtual void ObserveUpdate(uint64_t aLayersId, bool aActive) = 0;
 
 protected:
   virtual ~CompositorUpdateObserver() {}
 };
 
 class CompositorBridgeParent final : public PCompositorBridgeParent,
                                      public ShadowLayersManager,
-                                     public ISurfaceAllocator,
+                                     public HostIPCAllocator,
                                      public ShmemAllocator
 {
   friend class CompositorVsyncScheduler;
   friend class CompositorThreadHolder;
 
 public:
   explicit CompositorBridgeParent(widget::CompositorWidgetProxy* aWidget,
                                   CSSToLayoutDeviceScale aScale,
@@ -296,16 +296,20 @@ public:
                           mozilla::ipc::Shmem* aShmem) override;
 
   virtual bool AllocUnsafeShmem(size_t aSize,
                                 mozilla::ipc::SharedMemory::SharedMemoryType aType,
                                 mozilla::ipc::Shmem* aShmem) override;
 
   virtual void DeallocShmem(mozilla::ipc::Shmem& aShmem) override;
 
+  virtual base::ProcessId GetChildProcessId() override
+  {
+    return OtherPid();
+  }
   /**
    * Request that the compositor be recreated due to a shared device reset.
    * This must be called on the main thread, and blocks until a task posted
    * to the compositor thread has completed.
    *
    * Note that this posts a task directly, rather than using synchronous
    * IPDL, and waits on a monitor notification from the compositor thread.
    * We do this as a best-effort attempt to jump any IPDL messages that
--- a/gfx/layers/ipc/ISurfaceAllocator.h
+++ b/gfx/layers/ipc/ISurfaceAllocator.h
@@ -43,16 +43,17 @@ namespace layers {
 
 class CompositableForwarder;
 class ShadowLayerForwarder;
 
 class ShmemAllocator;
 class ShmemSectionAllocator;
 class LegacySurfaceDescriptorAllocator;
 class ClientIPCAllocator;
+class HostIPCAllocator;
 
 enum BufferCapabilities {
   DEFAULT_BUFFER_CAPS = 0,
   /**
    * The allocated buffer must be efficiently mappable as a DataSourceSurface.
    */
   MAP_AS_IMAGE_SURFACE = 1 << 0,
   /**
@@ -87,16 +88,18 @@ public:
   virtual ShmemSectionAllocator* AsShmemSectionAllocator() { return nullptr; }
 
   virtual CompositableForwarder* AsCompositableForwarder() { return nullptr; }
 
   virtual ShadowLayerForwarder* AsLayerForwarder() { return nullptr; }
 
   virtual ClientIPCAllocator* AsClientAllocator() { return nullptr; }
 
+  virtual HostIPCAllocator* AsHostIPCAllocator() { return nullptr; }
+
   virtual LegacySurfaceDescriptorAllocator*
   AsLegacySurfaceDescriptorAllocator() { return nullptr; }
 
   // ipc info
 
   virtual bool IPCOpen() const { return true; }
 
   virtual bool IsSameProcess() const = 0;
@@ -117,16 +120,29 @@ class ClientIPCAllocator : public ISurfa
 public:
   virtual ClientIPCAllocator* AsClientAllocator() override { return this; }
 
   virtual MessageLoop * GetMessageLoop() const = 0;
 
   virtual int32_t GetMaxTextureSize() const { return gfxPrefs::MaxTextureSize(); }
 };
 
+/// Methods that are specific to the host/parent side.
+class HostIPCAllocator : public ISurfaceAllocator
+{
+public:
+  virtual HostIPCAllocator* AsHostIPCAllocator() override { return this; }
+
+  /**
+   * Get child side's process Id.
+   */
+  virtual base::ProcessId GetChildProcessId() = 0;
+};
+
+
 /// An allocator can provide shared memory.
 ///
 /// The allocated shmems can be deallocated on either process, as long as they
 /// belong to the same channel.
 class ShmemAllocator
 {
 public:
   virtual bool AllocShmem(size_t aSize,