Back out e9ca04f323d0 (bug 928806) on suspicion of causing ASan and Linux debug gtest crashes
authorPhil Ringnalda <philringnalda@gmail.com>
Sun, 15 Dec 2013 13:58:28 -0800
changeset 160548 f8fea5ea69a1d504af7f3903e18a949f765e1eba
parent 160547 4afced469f9d348b47fdce694327bf6f2778b9ae
child 160549 1566a2e95c3bb8a630626b322e1ad6652aa79863
child 160561 9b1b17c33d72893cbc34dce3c03f517e31f085e1
child 160579 8eeb02bba511c1be5b508fb9d1a2212e7ff7baf4
push idunknown
push userunknown
push dateunknown
bugs928806
milestone29.0a1
backs oute9ca04f323d0106f095ce2c0dd77f634ceea0652
Back out e9ca04f323d0 (bug 928806) on suspicion of causing ASan and Linux debug gtest crashes CLOSED TREE
gfx/layers/YCbCrImageDataSerializer.cpp
gfx/layers/YCbCrImageDataSerializer.h
gfx/layers/ipc/SharedPlanarYCbCrImage.cpp
--- a/gfx/layers/YCbCrImageDataSerializer.cpp
+++ b/gfx/layers/YCbCrImageDataSerializer.cpp
@@ -148,47 +148,35 @@ static size_t ComputeOffset(uint32_t aSi
 // Minimum required shmem size in bytes
 size_t
 YCbCrImageDataSerializer::ComputeMinBufferSize(uint32_t aSize)
 {
   return ComputeOffset(aSize) + MOZ_ALIGN_WORD(sizeof(YCbCrBufferInfo));
 }
 
 void
-YCbCrImageDataSerializer::InitializeBufferInfo(uint32_t aYOffset,
-                                               uint32_t aCbOffset,
-                                               uint32_t aCrOffset,
-                                               const gfx::IntSize& aYSize,
+YCbCrImageDataSerializer::InitializeBufferInfo(const gfx::IntSize& aYSize,
                                                const gfx::IntSize& aCbCrSize,
                                                StereoMode aStereoMode)
 {
   YCbCrBufferInfo* info = GetYCbCrBufferInfo(mData);
-  uint32_t info_size = MOZ_ALIGN_WORD(sizeof(YCbCrBufferInfo));
-  info->mYOffset = info_size + aYOffset;
-  info->mCbOffset = info_size + aCbOffset;
-  info->mCrOffset = info_size + aCrOffset;
+  info->mYOffset = MOZ_ALIGN_WORD(sizeof(YCbCrBufferInfo));
+  info->mCbOffset = info->mYOffset
+                  + MOZ_ALIGN_WORD(aYSize.width * aYSize.height);
+  info->mCrOffset = info->mCbOffset
+                  + MOZ_ALIGN_WORD(aCbCrSize.width * aCbCrSize.height);
+
   info->mYWidth = aYSize.width;
   info->mYHeight = aYSize.height;
   info->mCbCrWidth = aCbCrSize.width;
   info->mCbCrHeight = aCbCrSize.height;
   info->mStereoMode = aStereoMode;
 }
 
 void
-YCbCrImageDataSerializer::InitializeBufferInfo(const gfx::IntSize& aYSize,
-                                               const gfx::IntSize& aCbCrSize,
-                                               StereoMode aStereoMode)
-{
-  uint32_t yOffset = MOZ_ALIGN_WORD(sizeof(YCbCrBufferInfo));
-  uint32_t cbOffset = yOffset + MOZ_ALIGN_WORD(aYSize.width * aYSize.height);
-  uint32_t crOffset = cbOffset + MOZ_ALIGN_WORD(aCbCrSize.width * aCbCrSize.height);
-  return InitializeBufferInfo(yOffset, cbOffset, crOffset, aYSize, aCbCrSize, aStereoMode);
-}
-
-void
 YCbCrImageDataSerializer::InitializeBufferInfo(const gfxIntSize& aYSize,
                                                const gfxIntSize& aCbCrSize,
                                                StereoMode aStereoMode)
 {
   InitializeBufferInfo(gfx::IntSize(aYSize.width, aYSize.height),
                        gfx::IntSize(aCbCrSize.width, aCbCrSize.height),
                        aStereoMode);
 }
--- a/gfx/layers/YCbCrImageDataSerializer.h
+++ b/gfx/layers/YCbCrImageDataSerializer.h
@@ -109,22 +109,16 @@ public:
                                      const gfxIntSize& aCbCrSize);
   static size_t ComputeMinBufferSize(uint32_t aSize);
 
   /**
    * Write the image informations in the buffer for given dimensions.
    * The provided pointer should point to the beginning of the (chunk of)
    * buffer on which we want to store the image.
    */
-  void InitializeBufferInfo(uint32_t aYOffset,
-                            uint32_t aCbOffset,
-                            uint32_t aCrOffset,
-                            const gfx::IntSize& aYSize,
-                            const gfx::IntSize& aCbCrSize,
-                            StereoMode aStereoMode);
   void InitializeBufferInfo(const gfx::IntSize& aYSize,
                             const gfx::IntSize& aCbCrSize,
                             StereoMode aStereoMode);
   void InitializeBufferInfo(const gfxIntSize& aYSize,
                             const gfxIntSize& aCbCrSize,
                             StereoMode aStereoMode);
 
   bool CopyData(const uint8_t* aYData,
--- a/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp
+++ b/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp
@@ -138,31 +138,18 @@ SharedPlanarYCbCrImage::AllocateAndGetNe
   return serializer.GetData();
 }
 
 void
 SharedPlanarYCbCrImage::SetDataNoCopy(const Data &aData)
 {
   mData = aData;
   mSize = aData.mPicSize;
-  /* SetDataNoCopy is used to update YUV plane offsets without (re)allocating
-   * memory previously allocated with AllocateAndGetNewBuffer().
-   * serializer.GetData() returns the address of the memory previously allocated
-   * with AllocateAndGetNewBuffer(), that we subtract from the Y, Cb, Cr
-   * channels to compute 0-based offsets to pass to InitializeBufferInfo.
-   */
   YCbCrImageDataSerializer serializer(mTextureClient->GetBuffer());
-  uint8_t *base = serializer.GetData();
-  uint32_t yOffset = aData.mYChannel - base;
-  uint32_t cbOffset = aData.mCbChannel - base;
-  uint32_t crOffset = aData.mCrChannel - base;
-  serializer.InitializeBufferInfo(yOffset,
-                                  cbOffset,
-                                  crOffset,
-                                  aData.mYSize,
+  serializer.InitializeBufferInfo(aData.mYSize,
                                   aData.mCbCrSize,
                                   aData.mStereoMode);
 }
 
 uint8_t*
 SharedPlanarYCbCrImage::AllocateBuffer(uint32_t aSize)
 {
   NS_ABORT_IF_FALSE(!mTextureClient->IsAllocated(),