Bug 1300682 - Part 3: Split KnowsCompositor into a standalone header. r=nical
authorMatt Woodrow <mwoodrow@mozilla.com>
Fri, 07 Oct 2016 21:13:32 +1300
changeset 316886 0d5d1841286616dabd27d2cb629c46793bcf3ee4
parent 316885 9aec9ca6a65915dfbb370c3e7a5af3bbd1c6ed2e
child 316887 19e24514eb8f6101cf52fe3f2c06a75e7f244b39
push id82560
push usermwoodrow@mozilla.com
push dateFri, 07 Oct 2016 08:13:28 +0000
treeherdermozilla-inbound@4b28c86a0536 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1300682
milestone52.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 1300682 - Part 3: Split KnowsCompositor into a standalone header. r=nical
gfx/layers/ipc/KnowsCompositor.h
gfx/layers/ipc/ShadowLayers.cpp
gfx/layers/ipc/TextureForwarder.h
gfx/layers/moz.build
new file mode 100755
--- /dev/null
+++ b/gfx/layers/ipc/KnowsCompositor.h
@@ -0,0 +1,85 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* 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/. */
+
+#ifndef MOZILLA_LAYERS_KNOWSCOMPOSITOR
+#define MOZILLA_LAYERS_KNOWSCOMPOSITOR
+
+#include "mozilla/layers/LayersTypes.h"  // for LayersBackend
+#include "mozilla/layers/CompositorTypes.h"
+
+namespace mozilla {
+namespace layers {
+
+class SyncObject;
+class TextureForwarder;
+class LayersIPCActor;
+
+/**
+ * An abstract interface for classes that are tied to a specific Compositor across
+ * IPDL and uses TextureFactoryIdentifier to describe this Compositor.
+ */
+class KnowsCompositor {
+public:
+  NS_IMETHOD_(MozExternalRefCountType) AddRef(void) = 0;
+  NS_IMETHOD_(MozExternalRefCountType) Release(void) = 0;
+
+  KnowsCompositor();
+  ~KnowsCompositor();
+
+  void IdentifyTextureHost(const TextureFactoryIdentifier& aIdentifier);
+
+  SyncObject* GetSyncObject() { return mSyncObject; }
+
+  int32_t GetMaxTextureSize() const
+  {
+    return mTextureFactoryIdentifier.mMaxTextureSize;
+  }
+
+  /**
+   * Returns the type of backend that is used off the main thread.
+   * We only don't allow changing the backend type at runtime so this value can
+   * be queried once and will not change until Gecko is restarted.
+   */
+  LayersBackend GetCompositorBackendType() const
+  {
+    return mTextureFactoryIdentifier.mParentBackend;
+  }
+
+  bool SupportsTextureBlitting() const
+  {
+    return mTextureFactoryIdentifier.mSupportsTextureBlitting;
+  }
+
+  bool SupportsPartialUploads() const
+  {
+    return mTextureFactoryIdentifier.mSupportsPartialUploads;
+  }
+
+  const TextureFactoryIdentifier& GetTextureFactoryIdentifier() const
+  {
+    return mTextureFactoryIdentifier;
+  }
+
+  int32_t GetSerial() { return mSerial; }
+
+  /**
+   * Helpers for finding other related interface. These are infallible.
+   */
+  virtual TextureForwarder* GetTextureForwarder() = 0;
+  virtual LayersIPCActor* GetLayersIPCActor() = 0;
+
+protected:
+  TextureFactoryIdentifier mTextureFactoryIdentifier;
+  RefPtr<SyncObject> mSyncObject;
+
+  const int32_t mSerial;
+  static mozilla::Atomic<int32_t> sSerialCounter;
+};
+
+} // namespace layers
+} // namespace mozilla
+
+#endif
--- a/gfx/layers/ipc/ShadowLayers.cpp
+++ b/gfx/layers/ipc/ShadowLayers.cpp
@@ -169,16 +169,23 @@ struct AutoTxnEnd {
 void
 KnowsCompositor::IdentifyTextureHost(const TextureFactoryIdentifier& aIdentifier)
 {
   mTextureFactoryIdentifier = aIdentifier;
 
   mSyncObject = SyncObject::CreateSyncObject(aIdentifier.mSyncHandle);
 }
 
+KnowsCompositor::KnowsCompositor()
+  : mSerial(++sSerialCounter)
+{}
+
+KnowsCompositor::~KnowsCompositor()
+{}
+
 ShadowLayerForwarder::ShadowLayerForwarder(ClientLayerManager* aClientLayerManager)
  : mClientLayerManager(aClientLayerManager)
  , mMessageLoop(MessageLoop::current())
  , mDiagnosticTypes(DiagnosticTypes::NO_DIAGNOSTIC)
  , mIsFirstPaint(false)
  , mWindowOverlayChanged(false)
  , mPaintSyncId(0)
 {
--- a/gfx/layers/ipc/TextureForwarder.h
+++ b/gfx/layers/ipc/TextureForwarder.h
@@ -4,19 +4,19 @@
  * 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/. */
 
 #ifndef MOZILLA_LAYERS_TEXTUREFORWARDER
 #define MOZILLA_LAYERS_TEXTUREFORWARDER
 
 #include <stdint.h>                     // for int32_t, uint64_t
 #include "gfxTypes.h"
-#include "mozilla/layers/ISurfaceAllocator.h"  // for ISurfaceAllocator
 #include "mozilla/layers/LayersTypes.h"  // for LayersBackend
 #include "mozilla/layers/TextureClient.h"  // for TextureClient
+#include "mozilla/layers/KnowsCompositor.h"
 
 namespace mozilla {
 namespace layers {
 
 /**
  * An abstract interface for classes that implement the autogenerated
  * IPDL actor class. Lets us check if they are still valid for IPC.
  */
@@ -26,33 +26,41 @@ public:
 };
 
 /**
  * An abstract interface for LayersIPCActors that implement a top-level
  * IPDL protocol so also have their own channel.
  * Has their own MessageLoop for message dispatch, and can allocate
  * shmem.
  */
-class LayersIPCChannel : public LayersIPCActor
-                       , public ShmemAllocator {
+class LayersIPCChannel : public LayersIPCActor {
 public:
   NS_IMETHOD_(MozExternalRefCountType) AddRef(void) = 0;
   NS_IMETHOD_(MozExternalRefCountType) Release(void) = 0;
 
   virtual bool IsSameProcess() const = 0;
 
   virtual bool UsesImageBridge() const { return false; }
 
   virtual base::ProcessId GetParentPid() const = 0;
 
   virtual MessageLoop* GetMessageLoop() const = 0;
 
   virtual FixedSizeSmallShmemSectionAllocator* GetTileLockAllocator() { return nullptr; }
 
   virtual void CancelWaitForRecycle(uint64_t aTextureId) = 0;
+
+  virtual bool AllocShmem(size_t aSize,
+                          mozilla::ipc::SharedMemory::SharedMemoryType aShmType,
+                          mozilla::ipc::Shmem* aShmem) = 0;
+  virtual bool AllocUnsafeShmem(size_t aSize,
+                                mozilla::ipc::SharedMemory::SharedMemoryType aShmType,
+                                mozilla::ipc::Shmem* aShmem) = 0;
+  virtual void DeallocShmem(mozilla::ipc::Shmem& aShmem) = 0;
+
 protected:
   virtual ~LayersIPCChannel() {}
 };
 
 /**
  * An abstract interface for classes that can allocate PTexture objects
  * across IPDL. Currently a sub-class of LayersIPCChannel for simplicity
  * since all our implementations use both, but could be independant if needed.
@@ -64,75 +72,12 @@ public:
    */
   virtual PTextureChild* CreateTexture(
     const SurfaceDescriptor& aSharedData,
     LayersBackend aLayersBackend,
     TextureFlags aFlags,
     uint64_t aSerial) = 0;
 };
 
-/**
- * An abstract interface for classes that are tied to a specific Compositor across
- * IPDL and uses TextureFactoryIdentifier to describe this Compositor.
- */
-class KnowsCompositor {
-public:
-  NS_IMETHOD_(MozExternalRefCountType) AddRef(void) = 0;
-  NS_IMETHOD_(MozExternalRefCountType) Release(void) = 0;
-
-  KnowsCompositor()
-    : mSerial(++sSerialCounter)
-  {}
-
-  void IdentifyTextureHost(const TextureFactoryIdentifier& aIdentifier);
-
-  SyncObject* GetSyncObject() { return mSyncObject; }
-
-  int32_t GetMaxTextureSize() const
-  {
-    return mTextureFactoryIdentifier.mMaxTextureSize;
-  }
-
-  /**
-   * Returns the type of backend that is used off the main thread.
-   * We only don't allow changing the backend type at runtime so this value can
-   * be queried once and will not change until Gecko is restarted.
-   */
-  LayersBackend GetCompositorBackendType() const
-  {
-    return mTextureFactoryIdentifier.mParentBackend;
-  }
-
-  bool SupportsTextureBlitting() const
-  {
-    return mTextureFactoryIdentifier.mSupportsTextureBlitting;
-  }
-
-  bool SupportsPartialUploads() const
-  {
-    return mTextureFactoryIdentifier.mSupportsPartialUploads;
-  }
-
-  const TextureFactoryIdentifier& GetTextureFactoryIdentifier() const
-  {
-    return mTextureFactoryIdentifier;
-  }
-
-  int32_t GetSerial() { return mSerial; }
-
-  /**
-   * Helpers for finding other related interface. These are infallible.
-   */
-  virtual TextureForwarder* GetTextureForwarder() = 0;
-  virtual LayersIPCActor* GetLayersIPCActor() = 0;
-
-protected:
-  TextureFactoryIdentifier mTextureFactoryIdentifier;
-  RefPtr<SyncObject> mSyncObject;
-
-  const int32_t mSerial;
-  static mozilla::Atomic<int32_t> sSerialCounter;
-};
-
 } // namespace layers
 } // namespace mozilla
 
 #endif
--- a/gfx/layers/moz.build
+++ b/gfx/layers/moz.build
@@ -171,16 +171,17 @@ EXPORTS.mozilla.layers += [
     'ipc/FenceUtils.h',
     'ipc/GonkNativeHandle.h',
     'ipc/GonkNativeHandleUtils.h',
     'ipc/ImageBridgeChild.h',
     'ipc/ImageBridgeParent.h',
     'ipc/ImageContainerChild.h',
     'ipc/ImageContainerParent.h',
     'ipc/ISurfaceAllocator.h',
+    'ipc/KnowsCompositor.h',
     'ipc/LayerAnimationUtils.h',
     'ipc/LayerTransactionChild.h',
     'ipc/LayerTransactionParent.h',
     'ipc/LayerTreeOwnerTracker.h',
     'ipc/RemoteContentController.h',
     'ipc/ShadowLayerChild.h',
     'ipc/ShadowLayers.h',
     'ipc/SharedBufferManagerChild.h',