Bug 1565255 - Backout Bug 1552734 r=nical a=ryanvm
authorsotaro <sotaro.ikeda.g@gmail.com>
Wed, 17 Jul 2019 14:10:47 +0000
changeset 544699 29185afc3f8960aba202fb4fd1e263ff498d1dd3
parent 544698 4fc420cd0c74ebabc7b82ff6006f6efbde96478f
child 544700 34fca225d15c50b205f5fdcbb2c9bd1d198f7c38
push id2131
push userffxbld-merge
push dateMon, 26 Aug 2019 18:30:20 +0000
treeherdermozilla-release@b19ffb3ca153 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical, ryanvm
bugs1565255, 1552734, 1531898
milestone69.0
Bug 1565255 - Backout Bug 1552734 r=nical a=ryanvm Since Bug 1531898 fix, fix of Bug 1552734 is not necessary anymore. The backout reduces memory usage. Differential Revision: https://phabricator.services.mozilla.com/D38257
gfx/layers/D3D11YCbCrImage.cpp
gfx/layers/D3D11YCbCrImage.h
gfx/layers/client/ImageClient.cpp
gfx/layers/client/ImageClient.h
--- a/gfx/layers/D3D11YCbCrImage.cpp
+++ b/gfx/layers/D3D11YCbCrImage.cpp
@@ -19,109 +19,89 @@ using namespace mozilla::gfx;
 namespace mozilla {
 namespace layers {
 
 D3D11YCbCrImage::D3D11YCbCrImage()
     : Image(NULL, ImageFormat::D3D11_YCBCR_IMAGE) {}
 
 D3D11YCbCrImage::~D3D11YCbCrImage() {}
 
-/* static */
-already_AddRefed<TextureClient>
-D3D11YCbCrImage::CreateAndCopyDataToDXGIYCbCrTextureData(
-    KnowsCompositor* aAllocator, ImageContainer* aContainer,
-    const PlanarYCbCrData& aData) {
-  if (!aAllocator || !aContainer) {
-    return nullptr;
-  }
+bool D3D11YCbCrImage::SetData(KnowsCompositor* aAllocator,
+                              ImageContainer* aContainer,
+                              const PlanarYCbCrData& aData) {
+  mPictureRect = IntRect(aData.mPicX, aData.mPicY, aData.mPicSize.width,
+                         aData.mPicSize.height);
+  mYSize = aData.mYSize;
+  mCbCrSize = aData.mCbCrSize;
+  mColorDepth = aData.mColorDepth;
+  mColorSpace = aData.mYUVColorSpace;
 
   D3D11YCbCrRecycleAllocator* allocator =
       aContainer->GetD3D11YCbCrRecycleAllocator(aAllocator);
   if (!allocator) {
-    return nullptr;
+    return false;
   }
 
   RefPtr<ID3D11Device> device = gfx::DeviceManagerDx::Get()->GetImageDevice();
   if (!device) {
-    return nullptr;
+    return false;
   }
 
-  RefPtr<TextureClient> textureClient;
-
   {
     DXGIYCbCrTextureAllocationHelper helper(aData, TextureFlags::DEFAULT,
                                             device);
-    textureClient = allocator->CreateOrRecycle(helper);
+    mTextureClient = allocator->CreateOrRecycle(helper);
   }
 
-  if (!textureClient) {
-    return nullptr;
+  if (!mTextureClient) {
+    return false;
   }
 
   DXGIYCbCrTextureData* data =
-      textureClient->GetInternalData()->AsDXGIYCbCrTextureData();
+      mTextureClient->GetInternalData()->AsDXGIYCbCrTextureData();
 
   ID3D11Texture2D* textureY = data->GetD3D11Texture(0);
   ID3D11Texture2D* textureCb = data->GetD3D11Texture(1);
   ID3D11Texture2D* textureCr = data->GetD3D11Texture(2);
 
   RefPtr<ID3D10Multithread> mt;
   HRESULT hr = device->QueryInterface((ID3D10Multithread**)getter_AddRefs(mt));
 
   if (FAILED(hr) || !mt) {
     gfxCriticalError() << "Multithread safety interface not supported. " << hr;
-    return nullptr;
+    return false;
   }
 
   if (!mt->GetMultithreadProtected()) {
     gfxCriticalError() << "Device used not marked as multithread-safe.";
-    return nullptr;
+    return false;
   }
 
   D3D11MTAutoEnter mtAutoEnter(mt.forget());
 
   RefPtr<ID3D11DeviceContext> ctx;
   device->GetImmediateContext(getter_AddRefs(ctx));
   if (!ctx) {
     gfxCriticalError() << "Failed to get immediate context.";
-    return nullptr;
+    return false;
   }
 
   AutoLockD3D11Texture lockY(textureY);
   AutoLockD3D11Texture lockCb(textureCb);
   AutoLockD3D11Texture lockCr(textureCr);
 
   ctx->UpdateSubresource(textureY, 0, nullptr, aData.mYChannel, aData.mYStride,
                          aData.mYStride * aData.mYSize.height);
   ctx->UpdateSubresource(textureCb, 0, nullptr, aData.mCbChannel,
                          aData.mCbCrStride,
                          aData.mCbCrStride * aData.mCbCrSize.height);
   ctx->UpdateSubresource(textureCr, 0, nullptr, aData.mCrChannel,
                          aData.mCbCrStride,
                          aData.mCbCrStride * aData.mCbCrSize.height);
 
-  return textureClient.forget();
-}
-
-bool D3D11YCbCrImage::SetData(KnowsCompositor* aAllocator,
-                              ImageContainer* aContainer,
-                              const PlanarYCbCrData& aData) {
-  mPictureRect = IntRect(aData.mPicX, aData.mPicY, aData.mPicSize.width,
-                         aData.mPicSize.height);
-  mYSize = aData.mYSize;
-  mCbCrSize = aData.mCbCrSize;
-  mColorDepth = aData.mColorDepth;
-  mColorSpace = aData.mYUVColorSpace;
-
-  mTextureClient =
-      CreateAndCopyDataToDXGIYCbCrTextureData(aAllocator, aContainer, aData);
-  if (!mTextureClient) {
-    return false;
-  }
-
   return true;
 }
 
 IntSize D3D11YCbCrImage::GetSize() const { return mPictureRect.Size(); }
 
 TextureClient* D3D11YCbCrImage::GetTextureClient(
     KnowsCompositor* aKnowsCompositor) {
   return mTextureClient;
--- a/gfx/layers/D3D11YCbCrImage.h
+++ b/gfx/layers/D3D11YCbCrImage.h
@@ -54,21 +54,16 @@ class D3D11YCbCrRecycleAllocator : publi
 
 class D3D11YCbCrImage : public Image {
   friend class gl::GLBlitHelper;
 
  public:
   D3D11YCbCrImage();
   virtual ~D3D11YCbCrImage();
 
-  static already_AddRefed<TextureClient>
-  CreateAndCopyDataToDXGIYCbCrTextureData(KnowsCompositor* aAllocator,
-                                          ImageContainer* aContainer,
-                                          const PlanarYCbCrData& aData);
-
   // Copies the surface into a sharable texture's surface, and initializes
   // the image.
   bool SetData(KnowsCompositor* aAllocator, ImageContainer* aContainer,
                const PlanarYCbCrData& aData);
 
   gfx::IntSize GetSize() const override;
 
   already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override;
--- a/gfx/layers/client/ImageClient.cpp
+++ b/gfx/layers/client/ImageClient.cpp
@@ -29,21 +29,16 @@
 #include "mozilla/layers/TextureClient.h"     // for TextureClient, etc
 #include "mozilla/layers/TextureClientOGL.h"  // for SurfaceTextureClient
 #include "mozilla/mozalloc.h"                 // for operator delete, etc
 #include "nsCOMPtr.h"                         // for already_AddRefed
 #include "nsDebug.h"                          // for NS_WARNING, NS_ASSERTION
 #include "nsISupportsImpl.h"                  // for Image::Release, etc
 #include "nsRect.h"                           // for mozilla::gfx::IntRect
 
-#ifdef XP_WIN
-#  include "mozilla/WindowsVersion.h"
-#  include "mozilla/layers/D3D11YCbCrImage.h"
-#endif
-
 namespace mozilla {
 namespace layers {
 
 using namespace mozilla::gfx;
 
 /* static */
 already_AddRefed<ImageClient> ImageClient::CreateImageClient(
     CompositableType aCompositableHostType, CompositableForwarder* aForwarder,
@@ -91,45 +86,24 @@ void ImageClientSingle::FlushAllImages()
     // generate a frame before the texture gets cleared.
     RemoveTexture(b.mTextureClient, Some(wr::RenderRoot::Default));
   }
   mBuffers.Clear();
 }
 
 /* static */
 already_AddRefed<TextureClient> ImageClient::CreateTextureClientForImage(
-    Image* aImage, KnowsCompositor* aKnowsCompositor,
-    ImageContainer* aContainer) {
+    Image* aImage, KnowsCompositor* aKnowsCompositor) {
   RefPtr<TextureClient> texture;
   if (aImage->GetFormat() == ImageFormat::PLANAR_YCBCR) {
     PlanarYCbCrImage* ycbcr = static_cast<PlanarYCbCrImage*>(aImage);
     const PlanarYCbCrData* data = ycbcr->GetData();
     if (!data) {
       return nullptr;
     }
-
-#if XP_WIN
-    // We disable this code path on Windows version earlier of Windows 8 due to
-    // intermittent crashes with old drivers. See bug 1405110.
-    // DXGIYCbCrTextureData can only handle YCbCr images using 3 non-interleaved
-    // planes non-zero mSkip value indicates that one of the plane would be
-    // interleaved.
-    if (IsWin8OrLater() && XRE_IsContentProcess() && aKnowsCompositor &&
-        aKnowsCompositor->SupportsD3D11() &&
-        aKnowsCompositor->GetTextureForwarder() &&
-        aKnowsCompositor->GetTextureForwarder()->UsesImageBridge() &&
-        aContainer && data->mYSkip == 0 && data->mCbSkip == 0 &&
-        data->mCrSkip == 0) {
-      texture = D3D11YCbCrImage::CreateAndCopyDataToDXGIYCbCrTextureData(
-          aKnowsCompositor, aContainer, *data);
-      if (texture) {
-        return texture.forget();
-      }
-    }
-#endif
     texture = TextureClient::CreateForYCbCr(
         aKnowsCompositor, data->mYSize, data->mYStride, data->mCbCrSize,
         data->mCbCrStride, data->mStereoMode, data->mColorDepth,
         data->mYUVColorSpace, TextureFlags::DEFAULT);
     if (!texture) {
       return nullptr;
     }
 
@@ -241,17 +215,17 @@ bool ImageClientSingle::UpdateImage(Imag
         mBuffers.RemoveElementAt(i);
       }
     }
 
     if (!texture) {
       // Slow path, we should not be hitting it very often and if we do it means
       // we are using an Image class that is not backed by textureClient and we
       // should fix it.
-      texture = CreateTextureClientForImage(image, GetForwarder(), aContainer);
+      texture = CreateTextureClientForImage(image, GetForwarder());
     }
 
     if (!texture) {
       return false;
     }
 
     // We check if the texture's allocator is still open, since in between media
     // decoding a frame and adding it to the compositable, we could have
--- a/gfx/layers/client/ImageClient.h
+++ b/gfx/layers/client/ImageClient.h
@@ -66,18 +66,17 @@ class ImageClient : public CompositableC
   virtual void FlushAllImages() {}
 
   virtual void RemoveTexture(TextureClient* aTexture,
                              const Maybe<wr::RenderRoot>& aRenderRoot) override;
 
   virtual ImageClientSingle* AsImageClientSingle() { return nullptr; }
 
   static already_AddRefed<TextureClient> CreateTextureClientForImage(
-      Image* aImage, KnowsCompositor* aForwarder,
-      ImageContainer* aContainer = nullptr);
+      Image* aImage, KnowsCompositor* aForwarder);
 
   uint32_t GetLastUpdateGenerationCounter() {
     return mLastUpdateGenerationCounter;
   }
 
   virtual RefPtr<TextureClient> GetForwardedTexture() { return nullptr; }
 
  protected: