Bug 1540581 - P17. Remove DXGITextureData object. r=nical
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 11 Apr 2019 12:39:08 +0000
changeset 469144 30dac503bc7aee22dde7ec7ce2ba7f7641fc8594
parent 469143 9853765f91f94eb74662fdc3268286dbd0c155d5
child 469145 841b6b61757792b59cee7412512e16e9a61b8989
push id35856
push usercsabou@mozilla.com
push dateFri, 12 Apr 2019 03:19:48 +0000
treeherdermozilla-central@940684cd1065 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1540581
milestone68.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 1540581 - P17. Remove DXGITextureData object. r=nical Only D3D11TextureData inherits from it and isn't used directly. Differential Revision: https://phabricator.services.mozilla.com/D26472
gfx/layers/d3d11/TextureD3D11.cpp
gfx/layers/d3d11/TextureD3D11.h
--- a/gfx/layers/d3d11/TextureD3D11.cpp
+++ b/gfx/layers/d3d11/TextureD3D11.cpp
@@ -249,33 +249,25 @@ static void UnlockD3DTexture(T* aTexture
   if (mutex) {
     HRESULT hr = mutex->ReleaseSync(0);
     if (FAILED(hr)) {
       NS_WARNING("Failed to unlock the texture");
     }
   }
 }
 
-DXGITextureData::DXGITextureData(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
-                                 bool aNeedsClear, bool aNeedsClearWhite,
-                                 bool aIsForOutOfBandContent)
-    : mSize(aSize),
-      mFormat(aFormat),
-      mNeedsClear(aNeedsClear),
-      mNeedsClearWhite(aNeedsClearWhite),
-      mHasSynchronization(false),
-      mIsForOutOfBandContent(aIsForOutOfBandContent) {}
-
 D3D11TextureData::D3D11TextureData(ID3D11Texture2D* aTexture,
                                    gfx::IntSize aSize,
                                    gfx::SurfaceFormat aFormat,
                                    TextureAllocationFlags aFlags)
-    : DXGITextureData(aSize, aFormat, aFlags & ALLOC_CLEAR_BUFFER,
-                      aFlags & ALLOC_CLEAR_BUFFER_WHITE,
-                      aFlags & ALLOC_FOR_OUT_OF_BAND_CONTENT),
+    : mSize(aSize),
+      mFormat(aFormat),
+      mNeedsClear(aFlags & ALLOC_CLEAR_BUFFER),
+      mNeedsClearWhite(aFlags & ALLOC_CLEAR_BUFFER_WHITE),
+      mIsForOutOfBandContent(aFlags & ALLOC_FOR_OUT_OF_BAND_CONTENT),
       mTexture(aTexture),
       mAllocationFlags(aFlags) {
   MOZ_ASSERT(aTexture);
   mHasSynchronization = HasKeyedMutex(aTexture);
 }
 
 static void DestroyDrawTarget(RefPtr<DrawTarget>& aDT,
                               RefPtr<ID3D11Texture2D>& aTexture) {
@@ -320,17 +312,17 @@ bool D3D11TextureData::Lock(OpenMode aMo
       Unlock();
       return false;
     }
   }
 
   return true;
 }
 
-bool DXGITextureData::PrepareDrawTargetInLock(OpenMode aMode) {
+bool D3D11TextureData::PrepareDrawTargetInLock(OpenMode aMode) {
   // Make sure that successful write-lock means we will have a DrawTarget to
   // write into.
   if (!mDrawTarget &&
       (aMode & OpenMode::OPEN_WRITE || mNeedsClear || mNeedsClearWhite)) {
     mDrawTarget = BorrowDrawTarget();
     if (!mDrawTarget) {
       return false;
     }
@@ -349,17 +341,17 @@ bool DXGITextureData::PrepareDrawTargetI
     mNeedsClearWhite = false;
   }
 
   return true;
 }
 
 void D3D11TextureData::Unlock() { UnlockD3DTexture(mTexture.get()); }
 
-void DXGITextureData::FillInfo(TextureData::Info& aInfo) const {
+void D3D11TextureData::FillInfo(TextureData::Info& aInfo) const {
   aInfo.size = mSize;
   aInfo.format = mFormat;
   aInfo.supportsMoz2D = true;
   aInfo.hasIntermediateBuffer = false;
   aInfo.hasSynchronization = mHasSynchronization;
 }
 
 void D3D11TextureData::SyncWithObject(SyncObjectClient* aSyncObject) {
@@ -369,17 +361,17 @@ void D3D11TextureData::SyncWithObject(Sy
   }
 
   MOZ_ASSERT(aSyncObject->GetSyncType() == SyncObjectClient::SyncType::D3D11);
   SyncObjectD3D11Client* sync =
       static_cast<SyncObjectD3D11Client*>(aSyncObject);
   sync->RegisterTexture(mTexture);
 }
 
-bool DXGITextureData::SerializeSpecific(
+bool D3D11TextureData::SerializeSpecific(
     SurfaceDescriptorD3D10* const aOutDesc) {
   RefPtr<IDXGIResource> resource;
   GetDXGIResource((IDXGIResource**)getter_AddRefs(resource));
   if (!resource) {
     return false;
   }
   HANDLE sharedHandle;
   HRESULT hr = resource->GetSharedHandle(&sharedHandle);
@@ -388,25 +380,25 @@ bool DXGITextureData::SerializeSpecific(
     return false;
   }
 
   *aOutDesc = SurfaceDescriptorD3D10((WindowsHandle)sharedHandle, mFormat,
                                      mSize, mYUVColorSpace);
   return true;
 }
 
-bool DXGITextureData::Serialize(SurfaceDescriptor& aOutDescriptor) {
+bool D3D11TextureData::Serialize(SurfaceDescriptor& aOutDescriptor) {
   SurfaceDescriptorD3D10 desc;
   if (!SerializeSpecific(&desc)) return false;
 
   aOutDescriptor = std::move(desc);
   return true;
 }
 
-void DXGITextureData::GetSubDescriptor(GPUVideoSubDescriptor* const aOutDesc) {
+void D3D11TextureData::GetSubDescriptor(GPUVideoSubDescriptor* const aOutDesc) {
   SurfaceDescriptorD3D10 ret;
   if (!SerializeSpecific(&ret)) return;
 
   *aOutDesc = std::move(ret);
 }
 
 D3D11TextureData* D3D11TextureData::Create(IntSize aSize, SurfaceFormat aFormat,
                                            TextureAllocationFlags aFlags,
--- a/gfx/layers/d3d11/TextureD3D11.h
+++ b/gfx/layers/d3d11/TextureD3D11.h
@@ -38,98 +38,91 @@ class MOZ_RAII AutoTextureLock final {
 
  private:
   RefPtr<IDXGIKeyedMutex> mMutex;
   HRESULT mResult;
 };
 
 class CompositorD3D11;
 
-class DXGITextureData : public TextureData {
- public:
-  void FillInfo(TextureData::Info& aInfo) const override;
-
-  bool SerializeSpecific(SurfaceDescriptorD3D10* aOutDesc);
-  bool Serialize(SurfaceDescriptor& aOutDescrptor) override;
-  void GetSubDescriptor(GPUVideoSubDescriptor* aOutDesc) override;
-
-  gfx::YUVColorSpace GetYUVColorSpace() const { return mYUVColorSpace; }
-  void SetYUVColorSpace(gfx::YUVColorSpace aColorSpace) {
-    mYUVColorSpace = aColorSpace;
-  }
-
-  gfx::IntSize GetSize() const { return mSize; }
-  gfx::SurfaceFormat GetSurfaceFormat() const { return mFormat; }
-
- protected:
-  bool PrepareDrawTargetInLock(OpenMode aMode);
-
-  DXGITextureData(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
-                  bool aNeedsClear, bool aNeedsClearWhite,
-                  bool aIsForOutOfBandContent);
-
-  virtual void GetDXGIResource(IDXGIResource** aOutResource) = 0;
-
-  // Hold on to the DrawTarget because it is expensive to create one each
-  // ::Lock.
-  RefPtr<gfx::DrawTarget> mDrawTarget;
-  gfx::IntSize mSize;
-  gfx::SurfaceFormat mFormat;
-  gfx::YUVColorSpace mYUVColorSpace = gfx::YUVColorSpace::UNKNOWN;
-  bool mNeedsClear;
-  bool mNeedsClearWhite;
-  bool mHasSynchronization;
-  bool mIsForOutOfBandContent;
-};
-
-class D3D11TextureData : public DXGITextureData {
+class D3D11TextureData final : public TextureData {
  public:
   // If aDevice is null, use one provided by gfxWindowsPlatform.
-  static D3D11TextureData* Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
-                                 TextureAllocationFlags aAllocFlags,
-                                 ID3D11Device* aDevice = nullptr);
+  static D3D11TextureData* Create(gfx::IntSize aSize,
+                                  gfx::SurfaceFormat aFormat,
+                                  TextureAllocationFlags aAllocFlags,
+                                  ID3D11Device* aDevice = nullptr);
   static D3D11TextureData* Create(gfx::SourceSurface* aSurface,
-                                 TextureAllocationFlags aAllocFlags,
-                                 ID3D11Device* aDevice = nullptr);
+                                  TextureAllocationFlags aAllocFlags,
+                                  ID3D11Device* aDevice = nullptr);
 
   bool UpdateFromSurface(gfx::SourceSurface* aSurface) override;
 
   bool Lock(OpenMode aMode) override;
 
   void Unlock() override;
 
   already_AddRefed<gfx::DrawTarget> BorrowDrawTarget() override;
 
   TextureData* CreateSimilar(LayersIPCChannel* aAllocator,
                              LayersBackend aLayersBackend, TextureFlags aFlags,
                              TextureAllocationFlags aAllocFlags) const override;
 
   void SyncWithObject(SyncObjectClient* aSyncObject) override;
 
-  ID3D11Texture2D* GetD3D11Texture() { return mTexture; }
+  ID3D11Texture2D* GetD3D11Texture() const { return mTexture; }
 
   void Deallocate(LayersIPCChannel* aAllocator) override;
 
   D3D11TextureData* AsD3D11TextureData() override { return this; }
 
   TextureAllocationFlags GetTextureAllocationFlags() const {
     return mAllocationFlags;
   }
 
- protected:
-  virtual ~D3D11TextureData();
+  void FillInfo(TextureData::Info& aInfo) const override;
+
+  bool Serialize(SurfaceDescriptor& aOutDescrptor) override;
+  void GetSubDescriptor(GPUVideoSubDescriptor* aOutDesc) override;
+
+  gfx::YUVColorSpace GetYUVColorSpace() const { return mYUVColorSpace; }
+  void SetYUVColorSpace(gfx::YUVColorSpace aColorSpace) {
+    mYUVColorSpace = aColorSpace;
+  }
+
+  gfx::IntSize GetSize() const { return mSize; }
+  gfx::SurfaceFormat GetSurfaceFormat() const { return mFormat; }
+
+ private:
   D3D11TextureData(ID3D11Texture2D* aTexture, gfx::IntSize aSize,
                    gfx::SurfaceFormat aFormat, TextureAllocationFlags aFlags);
+  virtual ~D3D11TextureData();
 
-  void GetDXGIResource(IDXGIResource** aOutResource) override;
+  void GetDXGIResource(IDXGIResource** aOutResource);
+
+  bool PrepareDrawTargetInLock(OpenMode aMode);
+
+  bool SerializeSpecific(SurfaceDescriptorD3D10* aOutDesc);
 
-  static D3D11TextureData* Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
-                                 gfx::SourceSurface* aSurface,
-                                 TextureAllocationFlags aAllocFlags,
-                                 ID3D11Device* aDevice = nullptr);
+  static D3D11TextureData* Create(gfx::IntSize aSize,
+                                  gfx::SurfaceFormat aFormat,
+                                  gfx::SourceSurface* aSurface,
+                                  TextureAllocationFlags aAllocFlags,
+                                  ID3D11Device* aDevice = nullptr);
+
+  // Hold on to the DrawTarget because it is expensive to create one each
+  // ::Lock.
+  RefPtr<gfx::DrawTarget> mDrawTarget;
+  gfx::IntSize mSize;
+  gfx::SurfaceFormat mFormat;
+  gfx::YUVColorSpace mYUVColorSpace = gfx::YUVColorSpace::UNKNOWN;
+  bool mNeedsClear;
+  bool mNeedsClearWhite;
+  bool mHasSynchronization;
+  bool mIsForOutOfBandContent;
 
   RefPtr<ID3D11Texture2D> mTexture;
   const TextureAllocationFlags mAllocationFlags;
 };
 
 class DXGIYCbCrTextureData : public TextureData {
   friend class gl::GLBlitHelper;