Bug 1639874 - Fix YCbCrTextureClientAllocationHelper::IsCompatible() r=jrmuizel
authorsotaro <sotaro.ikeda.g@gmail.com>
Thu, 21 May 2020 18:53:42 +0000
changeset 531540 d1343cbbfca37e4651a7e3179197b5c4b68c8841
parent 531539 78e1e47675dc093169b753b9e9735da4a2a1ef54
child 531541 94877a07905449afb0dac9c6426c6c47bf870e49
push id116713
push usersikeda.birchill@mozilla.com
push dateThu, 21 May 2020 21:56:50 +0000
treeherderautoland@d1343cbbfca3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1639874
milestone78.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 1639874 - Fix YCbCrTextureClientAllocationHelper::IsCompatible() r=jrmuizel IsCompatible() also needs to check YStride and CbCrStride. They also affect to buffer size. Differential Revision: https://phabricator.services.mozilla.com/D76323
gfx/layers/BufferTexture.cpp
gfx/layers/BufferTexture.h
gfx/layers/ImageDataSerializer.cpp
gfx/layers/ImageDataSerializer.h
gfx/layers/client/TextureClientRecycleAllocator.cpp
gfx/layers/ipc/SharedPlanarYCbCrImage.cpp
--- a/gfx/layers/BufferTexture.cpp
+++ b/gfx/layers/BufferTexture.cpp
@@ -222,16 +222,24 @@ void BufferTextureData::FillInfo(Texture
 gfx::IntSize BufferTextureData::GetSize() const {
   return ImageDataSerializer::SizeFromBufferDescriptor(mDescriptor);
 }
 
 Maybe<gfx::IntSize> BufferTextureData::GetCbCrSize() const {
   return ImageDataSerializer::CbCrSizeFromBufferDescriptor(mDescriptor);
 }
 
+Maybe<int32_t> BufferTextureData::GetYStride() const {
+  return ImageDataSerializer::YStrideFromBufferDescriptor(mDescriptor);
+}
+
+Maybe<int32_t> BufferTextureData::GetCbCrStride() const {
+  return ImageDataSerializer::CbCrStrideFromBufferDescriptor(mDescriptor);
+}
+
 Maybe<gfx::YUVColorSpace> BufferTextureData::GetYUVColorSpace() const {
   return ImageDataSerializer::YUVColorSpaceFromBufferDescriptor(mDescriptor);
 }
 
 Maybe<gfx::ColorDepth> BufferTextureData::GetColorDepth() const {
   return ImageDataSerializer::ColorDepthFromBufferDescriptor(mDescriptor);
 }
 
--- a/gfx/layers/BufferTexture.h
+++ b/gfx/layers/BufferTexture.h
@@ -56,16 +56,20 @@ class BufferTextureData : public Texture
 
   BufferTextureData* AsBufferTextureData() override { return this; }
 
   // Don't use this.
   void SetDescriptor(BufferDescriptor&& aDesc);
 
   Maybe<gfx::IntSize> GetCbCrSize() const;
 
+  Maybe<int32_t> GetYStride() const;
+
+  Maybe<int32_t> GetCbCrStride() const;
+
   Maybe<gfx::YUVColorSpace> GetYUVColorSpace() const;
 
   Maybe<gfx::ColorDepth> GetColorDepth() const;
 
   Maybe<StereoMode> GetStereoMode() const;
 
  protected:
   gfx::IntSize GetSize() const;
--- a/gfx/layers/ImageDataSerializer.cpp
+++ b/gfx/layers/ImageDataSerializer.cpp
@@ -149,17 +149,41 @@ gfx::IntSize SizeFromBufferDescriptor(co
 Maybe<gfx::IntSize> CbCrSizeFromBufferDescriptor(
     const BufferDescriptor& aDescriptor) {
   switch (aDescriptor.type()) {
     case BufferDescriptor::TRGBDescriptor:
       return Nothing();
     case BufferDescriptor::TYCbCrDescriptor:
       return Some(aDescriptor.get_YCbCrDescriptor().cbCrSize());
     default:
-      MOZ_CRASH("GFX:  CbCrSizeFromBufferDescriptor");
+      MOZ_CRASH("GFX: CbCrSizeFromBufferDescriptor");
+  }
+}
+
+Maybe<int32_t> YStrideFromBufferDescriptor(
+    const BufferDescriptor& aDescriptor) {
+  switch (aDescriptor.type()) {
+    case BufferDescriptor::TRGBDescriptor:
+      return Nothing();
+    case BufferDescriptor::TYCbCrDescriptor:
+      return Some(aDescriptor.get_YCbCrDescriptor().yStride());
+    default:
+      MOZ_CRASH("GFX: YStrideFromBufferDescriptor");
+  }
+}
+
+Maybe<int32_t> CbCrStrideFromBufferDescriptor(
+    const BufferDescriptor& aDescriptor) {
+  switch (aDescriptor.type()) {
+    case BufferDescriptor::TRGBDescriptor:
+      return Nothing();
+    case BufferDescriptor::TYCbCrDescriptor:
+      return Some(aDescriptor.get_YCbCrDescriptor().cbCrStride());
+    default:
+      MOZ_CRASH("GFX: CbCrStrideFromBufferDescriptor");
   }
 }
 
 Maybe<gfx::YUVColorSpace> YUVColorSpaceFromBufferDescriptor(
     const BufferDescriptor& aDescriptor) {
   switch (aDescriptor.type()) {
     case BufferDescriptor::TRGBDescriptor:
       return Nothing();
--- a/gfx/layers/ImageDataSerializer.h
+++ b/gfx/layers/ImageDataSerializer.h
@@ -55,16 +55,21 @@ void ComputeYCbCrOffsets(int32_t yStride
 gfx::SurfaceFormat FormatFromBufferDescriptor(
     const BufferDescriptor& aDescriptor);
 
 gfx::IntSize SizeFromBufferDescriptor(const BufferDescriptor& aDescriptor);
 
 Maybe<gfx::IntSize> CbCrSizeFromBufferDescriptor(
     const BufferDescriptor& aDescriptor);
 
+Maybe<int32_t> YStrideFromBufferDescriptor(const BufferDescriptor& aDescriptor);
+
+Maybe<int32_t> CbCrStrideFromBufferDescriptor(
+    const BufferDescriptor& aDescriptor);
+
 Maybe<gfx::YUVColorSpace> YUVColorSpaceFromBufferDescriptor(
     const BufferDescriptor& aDescriptor);
 
 Maybe<gfx::ColorDepth> ColorDepthFromBufferDescriptor(
     const BufferDescriptor& aDescriptor);
 
 Maybe<gfx::ColorRange> ColorRangeFromBufferDescriptor(
     const BufferDescriptor& aDescriptor);
--- a/gfx/layers/client/TextureClientRecycleAllocator.cpp
+++ b/gfx/layers/client/TextureClientRecycleAllocator.cpp
@@ -78,16 +78,20 @@ bool YCbCrTextureClientAllocationHelper:
     TextureClient* aTextureClient) {
   MOZ_ASSERT(aTextureClient->GetFormat() == gfx::SurfaceFormat::YUV);
 
   BufferTextureData* bufferData =
       aTextureClient->GetInternalData()->AsBufferTextureData();
   if (!bufferData || aTextureClient->GetSize() != mData.mYSize ||
       bufferData->GetCbCrSize().isNothing() ||
       bufferData->GetCbCrSize().ref() != mData.mCbCrSize ||
+      bufferData->GetYStride().isNothing() ||
+      bufferData->GetYStride().ref() != mData.mYStride ||
+      bufferData->GetCbCrStride().isNothing() ||
+      bufferData->GetCbCrStride().ref() != mData.mCbCrStride ||
       bufferData->GetYUVColorSpace().isNothing() ||
       bufferData->GetYUVColorSpace().ref() != mData.mYUVColorSpace ||
       bufferData->GetColorDepth().isNothing() ||
       bufferData->GetColorDepth().ref() != mData.mColorDepth ||
       bufferData->GetStereoMode().isNothing() ||
       bufferData->GetStereoMode().ref() != mData.mStereoMode) {
     return false;
   }
--- a/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp
+++ b/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp
@@ -41,17 +41,17 @@ SharedPlanarYCbCrImage::SharedPlanarYCbC
 
 SharedPlanarYCbCrImage::~SharedPlanarYCbCrImage() {
   MOZ_COUNT_DTOR(SharedPlanarYCbCrImage);
 }
 
 TextureClientRecycleAllocator* SharedPlanarYCbCrImage::RecycleAllocator() {
   static const uint32_t MAX_POOLED_VIDEO_COUNT = 5;
 
-  if (!mRecycleAllocator && mCompositable && mCompositable) {
+  if (!mRecycleAllocator && mCompositable) {
     if (!mCompositable->HasTextureClientRecycler()) {
       // Initialize TextureClientRecycler
       mCompositable->GetTextureClientRecycler()->SetMaxPoolSize(
           MAX_POOLED_VIDEO_COUNT);
     }
     mRecycleAllocator = mCompositable->GetTextureClientRecycler();
   }
   return mRecycleAllocator;