Backed out 3 changesets (bug 972703, bug 889959) for build failures and crashes
authorPhil Ringnalda <philringnalda@gmail.com>
Sun, 16 Feb 2014 15:17:01 -0800
changeset 169443 89b9078be02af6485b8d035281abe9a8fda69c7b
parent 169442 ef3d90780478ee8f8a0282231d794d55c4744497
child 169444 a033d0af07bf1706bc38d09bf208f80b575bc571
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
bugs972703, 889959
milestone30.0a1
backs outef3d90780478ee8f8a0282231d794d55c4744497
34c95e93767196340493e759da5d49e83886ecc8
5e25912d6696f5fe7b70fa88ecb68df673229bab
Backed out 3 changesets (bug 972703, bug 889959) for build failures and crashes CLOSED TREE Backed out changeset ef3d90780478 (bug 972703) Backed out changeset 34c95e937671 (bug 889959) Backed out changeset 5e25912d6696 (bug 889959)
gfx/layers/GrallocImages.cpp
gfx/layers/GrallocImages.h
gfx/layers/ImageContainer.cpp
gfx/layers/ImageContainer.h
gfx/layers/MacIOSurfaceImage.cpp
gfx/layers/MacIOSurfaceImage.h
gfx/layers/client/CanvasClient.cpp
gfx/layers/client/ImageClient.cpp
gfx/layers/composite/CompositableHost.h
gfx/layers/ipc/CompositableForwarder.h
gfx/layers/ipc/CompositorChild.cpp
gfx/layers/ipc/SharedPlanarYCbCrImage.cpp
gfx/layers/ipc/SharedPlanarYCbCrImage.h
gfx/layers/ipc/SharedRGBImage.cpp
gfx/layers/ipc/SharedRGBImage.h
layout/base/nsLayoutUtils.cpp
--- a/gfx/layers/GrallocImages.cpp
+++ b/gfx/layers/GrallocImages.cpp
@@ -375,17 +375,17 @@ GrallocImage::GetAsSourceSurface()
     return nullptr;
   }
 
   return surface;
 }
 
 
 TextureClient*
-GrallocImage::GetTextureClient(CompositableClient* aClient)
+GrallocImage::GetTextureClient()
 {
   if (!mTextureClient) {
     const SurfaceDescriptor& sd = GetSurfaceDescriptor();
     if (sd.type() != SurfaceDescriptor::TSurfaceDescriptorGralloc) {
       return nullptr;
     }
     const SurfaceDescriptorGralloc& desc = sd.get_SurfaceDescriptorGralloc();
     TextureFlags flags = desc.external() ? TEXTURE_DEALLOCATE_CLIENT : 0;
--- a/gfx/layers/GrallocImages.h
+++ b/gfx/layers/GrallocImages.h
@@ -144,17 +144,17 @@ public:
     if (mGraphicBufferLocked.get()) {
       return mGraphicBufferLocked->GetSurfaceDescriptor();
     }
     return SurfaceDescriptor();
   }
 
   virtual ISharedImage* AsSharedImage() MOZ_OVERRIDE { return this; }
 
-  virtual TextureClient* GetTextureClient(CompositableClient* aClient) MOZ_OVERRIDE;
+  virtual TextureClient* GetTextureClient() MOZ_OVERRIDE;
 
   virtual uint8_t* GetBuffer()
   {
     return static_cast<uint8_t*>(GetNativeBuffer());
   }
 
 private:
   bool mBufferAllocated;
--- a/gfx/layers/ImageContainer.cpp
+++ b/gfx/layers/ImageContainer.cpp
@@ -17,39 +17,41 @@
 #include "mozilla/layers/ImageBridgeChild.h"  // for ImageBridgeChild
 #include "mozilla/layers/ImageClient.h"  // for ImageClient
 #include "nsISupportsUtils.h"           // for NS_IF_ADDREF
 #include "YCbCrUtils.h"                 // for YCbCr conversions
 #ifdef MOZ_WIDGET_GONK
 #include "GrallocImages.h"
 #endif
 #include "gfx2DGlue.h"
-#include "mozilla/gfx/2D.h"
 
 #ifdef XP_MACOSX
 #include "mozilla/gfx/QuartzSupport.h"
 #include "MacIOSurfaceImage.h"
 #endif
 
 #ifdef XP_WIN
 #include "gfxD2DSurface.h"
 #include "gfxWindowsPlatform.h"
 #include <d3d10_1.h>
 #include "d3d10/ImageLayerD3D10.h"
 #include "D3D9SurfaceImage.h"
 #endif
 
 using namespace mozilla::ipc;
 using namespace android;
-using namespace mozilla::gfx;
+using mozilla::gfx::DataSourceSurface;
+using mozilla::gfx::SourceSurface;
 
 
 namespace mozilla {
 namespace layers {
 
+class DataSourceSurface;
+class SourceSurface;
 
 Atomic<int32_t> Image::sSerialCounter(0);
 
 TemporaryRef<gfx::SourceSurface>
 Image::GetAsSourceSurface()
 {
   nsRefPtr<gfxASurface> surface = DeprecatedGetAsSurface();
   return gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(nullptr, surface);
@@ -704,50 +706,10 @@ RemoteBitmapImage::GetAsSourceSurface()
     memcpy(newSurf->GetData() + newSurf->Stride() * y,
            mData + mStride * y,
            mSize.width * 4);
   }
 
   return newSurf;
 }
 
-CairoImage::CairoImage()
-  : Image(nullptr, ImageFormat::CAIRO_SURFACE)
-{}
-
-CairoImage::~CairoImage()
-{
-}
-
-TextureClient*
-CairoImage::GetTextureClient(CompositableClient *aClient)
-{
-  CompositableForwarder* forwarder = aClient->GetForwarder();
-  RefPtr<TextureClient> textureClient = mTextureClients.Get(forwarder->GetSerial());
-  if (textureClient) {
-    return textureClient;
-  }
-
-  RefPtr<SourceSurface> surface = GetAsSourceSurface();
-  MOZ_ASSERT(surface);
-
-  textureClient = aClient->CreateTextureClientForDrawing(surface->GetFormat(),
-                                                         TEXTURE_FLAGS_DEFAULT);
-  MOZ_ASSERT(textureClient->AsTextureClientDrawTarget());
-  if (!textureClient->AsTextureClientDrawTarget()->AllocateForSurface(surface->GetSize()) ||
-      !textureClient->Lock(OPEN_WRITE_ONLY)) {
-    return nullptr;
-  }
-
-  {
-    // We must not keep a reference to the DrawTarget after it has been unlocked.
-    RefPtr<DrawTarget> dt = textureClient->AsTextureClientDrawTarget()->GetAsDrawTarget();
-    dt->CopySurface(surface, IntRect(IntPoint(), surface->GetSize()), IntPoint());
-  }
-
-  textureClient->Unlock();
-
-  mTextureClients.Put(forwarder->GetSerial(), textureClient);
-  return textureClient;
-}
-
 } // namespace
 } // namespace
--- a/gfx/layers/ImageContainer.h
+++ b/gfx/layers/ImageContainer.h
@@ -23,17 +23,16 @@
 #include "nsDebug.h"                    // for NS_ASSERTION
 #include "nsISupportsImpl.h"            // for Image::Release, etc
 #include "nsRect.h"                     // for nsIntRect
 #include "nsSize.h"                     // for nsIntSize
 #include "nsTArray.h"                   // for nsTArray
 #include "mozilla/Atomics.h"
 #include "nsThreadUtils.h"
 #include "mozilla/gfx/2D.h"
-#include "nsDataHashtable.h"
 
 #ifndef XPCOM_GLUE_AVOID_NSPR
 /**
  * We need to be able to hold a reference to a gfxASurface from Image
  * subclasses. This is potentially a problem since Images can be addrefed
  * or released off the main thread. We can ensure that we never AddRef
  * a gfxASurface off the main thread, but we might want to Release due
  * to an Image being destroyed off the main thread.
@@ -142,18 +141,16 @@ namespace mozilla {
 class CrossProcessMutex;
 
 namespace layers {
 
 class ImageClient;
 class SharedPlanarYCbCrImage;
 class DeprecatedSharedPlanarYCbCrImage;
 class TextureClient;
-class CompositableClient;
-class CompositableForwarder;
 class SurfaceDescriptor;
 
 struct ImageBackendData
 {
   virtual ~ImageBackendData() {}
 
 protected:
   ImageBackendData() {}
@@ -163,17 +160,17 @@ protected:
 class ISharedImage {
 public:
     virtual uint8_t* GetBuffer() = 0;
 
     /**
      * For use with the CompositableClient only (so that the later can
      * synchronize the TextureClient with the TextureHost).
      */
-    virtual TextureClient* GetTextureClient(CompositableClient* aClient) = 0;
+    virtual TextureClient* GetTextureClient() = 0;
 };
 
 /**
  * A class representing a buffer of pixel data. The data can be in one
  * of various formats including YCbCr.
  * 
  * Create an image using an ImageContainer. Fill the image with data, and
  * then call ImageContainer::SetImage to display it. An image must not be
@@ -903,18 +900,17 @@ protected:
   nsRefPtr<BufferRecycleBin> mRecycleBin;
 };
 
 /**
  * Currently, the data in a CairoImage surface is treated as being in the
  * device output color space. This class is very simple as all backends
  * have to know about how to deal with drawing a cairo image.
  */
-class CairoImage : public Image,
-                   public ISharedImage {
+class CairoImage : public Image {
 public:
   struct Data {
     gfxASurface* mDeprecatedSurface;
     gfx::IntSize mSize;
 
     // mSourceSurface wraps mDeprrecatedSurface's data, therefore it should not
     // outlive mDeprecatedSurface
     RefPtr<gfx::SourceSurface> mSourceSurface;
@@ -938,32 +934,26 @@ public:
   }
 
   virtual already_AddRefed<gfxASurface> DeprecatedGetAsSurface()
   {
     nsRefPtr<gfxASurface> surface = mDeprecatedSurface.get();
     return surface.forget();
   }
 
-  virtual ISharedImage* AsSharedImage() { return this; }
-  virtual uint8_t* GetBuffer() { return nullptr; }
-  virtual TextureClient* GetTextureClient(CompositableClient* aClient);
-
   gfx::IntSize GetSize() { return mSize; }
 
-  CairoImage();
-  ~CairoImage();
+  CairoImage() : Image(nullptr, ImageFormat::CAIRO_SURFACE) {}
 
   nsCountedRef<nsMainThreadSurfaceRef> mDeprecatedSurface;
   gfx::IntSize mSize;
 
   // mSourceSurface wraps mDeprrecatedSurface's data, therefore it should not
   // outlive mDeprecatedSurface
   nsCountedRef<nsMainThreadSourceSurfaceRef> mSourceSurface;
-  nsDataHashtable<nsUint32HashKey, RefPtr<TextureClient> >  mTextureClients;
 };
 
 class RemoteBitmapImage : public Image {
 public:
   RemoteBitmapImage() : Image(nullptr, ImageFormat::REMOTE_IMAGE_BITMAP) {}
 
   already_AddRefed<gfxASurface> DeprecatedGetAsSurface();
   TemporaryRef<gfx::SourceSurface> GetAsSourceSurface();
--- a/gfx/layers/MacIOSurfaceImage.cpp
+++ b/gfx/layers/MacIOSurfaceImage.cpp
@@ -5,17 +5,17 @@
 
 #include "MacIOSurfaceImage.h"
 #include "mozilla/layers/MacIOSurfaceTextureClientOGL.h"
 
 using namespace mozilla;
 using namespace mozilla::layers;
 
 TextureClient*
-MacIOSurfaceImage::GetTextureClient(CompositableClient* aClient)
+MacIOSurfaceImage::GetTextureClient()
 {
   if (!mTextureClient) {
     RefPtr<MacIOSurfaceTextureClientOGL> buffer =
       new MacIOSurfaceTextureClientOGL(TEXTURE_FLAGS_DEFAULT);
     buffer->InitWith(mSurface);
     mTextureClient = buffer;
   }
   return mTextureClient;
--- a/gfx/layers/MacIOSurfaceImage.h
+++ b/gfx/layers/MacIOSurfaceImage.h
@@ -46,17 +46,17 @@ public:
 
     mSurface->Unlock();
 
     return imgSurface.forget();
   }
 
   virtual TemporaryRef<gfx::SourceSurface> GetAsSourceSurface();
 
-  virtual TextureClient* GetTextureClient(CompositableClient* aClient) MOZ_OVERRIDE;
+  virtual TextureClient* GetTextureClient() MOZ_OVERRIDE;
   virtual uint8_t* GetBuffer() MOZ_OVERRIDE { return nullptr; }
 
   MacIOSurfaceImage() : Image(nullptr, ImageFormat::MAC_IOSURFACE) {}
 
 private:
   RefPtr<MacIOSurface> mSurface;
   RefPtr<TextureClient> mTextureClient;
 };
--- a/gfx/layers/client/CanvasClient.cpp
+++ b/gfx/layers/client/CanvasClient.cpp
@@ -128,17 +128,17 @@ CanvasClientSurfaceStream::Update(gfx::I
       printf_stderr("Unexpected non-Gralloc SharedSurface in IPC path!");
       MOZ_ASSERT(false);
       return;
     }
 
     SharedSurface_Gralloc* grallocSurf = SharedSurface_Gralloc::Cast(surf);
 
     GrallocTextureClientOGL* grallocTextureClient =
-      static_cast<GrallocTextureClientOGL*>(grallocSurf->GetTextureClient(this));
+      static_cast<GrallocTextureClientOGL*>(grallocSurf->GetTextureClient());
 
     // If IPDLActor is null means this TextureClient didn't AddTextureClient yet
     if (!grallocTextureClient->GetIPDLActor()) {
       grallocTextureClient->SetTextureFlags(mTextureInfo.mTextureFlags);
       AddTextureClient(grallocTextureClient);
     }
 
     if (grallocTextureClient->GetIPDLActor()) {
--- a/gfx/layers/client/ImageClient.cpp
+++ b/gfx/layers/client/ImageClient.cpp
@@ -140,19 +140,19 @@ ImageClientSingle::UpdateImageInternal(I
   if (!image) {
     return false;
   }
 
   if (mLastPaintedImageSerial == image->GetSerial()) {
     return true;
   }
 
-  if (image->AsSharedImage() && image->AsSharedImage()->GetTextureClient(this)) {
+  if (image->AsSharedImage() && image->AsSharedImage()->GetTextureClient()) {
     // fast path: no need to allocate and/or copy image data
-    RefPtr<TextureClient> texture = image->AsSharedImage()->GetTextureClient(this);
+    RefPtr<TextureClient> texture = image->AsSharedImage()->GetTextureClient();
 
 
     if (mFrontBuffer) {
       GetForwarder()->RemoveTextureFromCompositable(this, mFrontBuffer);
     }
     mFrontBuffer = texture;
     if (!AddTextureClient(texture)) {
       mFrontBuffer = nullptr;
--- a/gfx/layers/composite/CompositableHost.h
+++ b/gfx/layers/composite/CompositableHost.h
@@ -260,16 +260,17 @@ public:
   // not async.
   // Only force detach if the IPDL tree is being shutdown.
   void Detach(Layer* aLayer = nullptr, AttachFlags aFlags = NO_FLAGS)
   {
     if (!mKeepAttached ||
         aLayer == mLayer ||
         aFlags & FORCE_DETACH) {
       SetLayer(nullptr);
+      SetCompositor(nullptr);
       mAttached = false;
       mKeepAttached = false;
       if (mBackendData) {
         mBackendData->ClearData();
       }
     }
   }
   bool IsAttached() { return mAttached; }
--- a/gfx/layers/ipc/CompositableForwarder.h
+++ b/gfx/layers/ipc/CompositableForwarder.h
@@ -43,18 +43,17 @@ class PTextureChild;
  */
 class CompositableForwarder : public ISurfaceAllocator
 {
   friend class AutoOpenSurface;
   friend class DeprecatedTextureClientShmem;
 public:
 
   CompositableForwarder()
-    : mSerial(++sSerialCounter)
-    , mMultiProcess(false)
+    : mMultiProcess(false)
   {}
 
   /**
    * Setup the IPDL actor for aCompositable to be part of layers
    * transactions.
    */
   virtual void Connect(CompositableClient* aCompositable) = 0;
 
@@ -242,22 +241,18 @@ public:
     return mMultiProcess;
   }
 
   const TextureFactoryIdentifier& GetTextureFactoryIdentifier() const
   {
     return mTextureFactoryIdentifier;
   }
 
-  int32_t GetSerial() { return mSerial; }
-
 protected:
   TextureFactoryIdentifier mTextureFactoryIdentifier;
+  bool mMultiProcess;
   nsTArray<RefPtr<TextureClient> > mTexturesToRemove;
-  const int32_t mSerial;
-  static mozilla::Atomic<int32_t> sSerialCounter;
-  bool mMultiProcess;
 };
 
 } // namespace
 } // namespace
 
 #endif
--- a/gfx/layers/ipc/CompositorChild.cpp
+++ b/gfx/layers/ipc/CompositorChild.cpp
@@ -23,18 +23,16 @@
 
 using mozilla::layers::LayerTransactionChild;
 
 namespace mozilla {
 namespace layers {
 
 /*static*/ CompositorChild* CompositorChild::sCompositor;
 
-Atomic<int32_t> CompositableForwarder::sSerialCounter(0);
-
 CompositorChild::CompositorChild(ClientLayerManager *aLayerManager)
   : mLayerManager(aLayerManager)
 {
   MOZ_COUNT_CTOR(CompositorChild);
 }
 
 CompositorChild::~CompositorChild()
 {
--- a/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp
+++ b/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp
@@ -58,17 +58,17 @@ DeprecatedSharedPlanarYCbCrImage::~Depre
   if (mAllocated) {
     SurfaceDescriptor desc;
     DropToSurfaceDescriptor(desc);
     mSurfaceAllocator->DestroySharedSurface(&desc);
   }
 }
 
 TextureClient*
-SharedPlanarYCbCrImage::GetTextureClient(CompositableClient* aClient)
+SharedPlanarYCbCrImage::GetTextureClient()
 {
   return mTextureClient.get();
 }
 
 uint8_t*
 SharedPlanarYCbCrImage::GetBuffer()
 {
   return mTextureClient->GetBuffer();
--- a/gfx/layers/ipc/SharedPlanarYCbCrImage.h
+++ b/gfx/layers/ipc/SharedPlanarYCbCrImage.h
@@ -92,17 +92,17 @@ private:
 class SharedPlanarYCbCrImage : public PlanarYCbCrImage
                              , public ISharedImage
 {
 public:
   SharedPlanarYCbCrImage(ImageClient* aCompositable);
   ~SharedPlanarYCbCrImage();
 
   virtual ISharedImage* AsSharedImage() MOZ_OVERRIDE { return this; }
-  virtual TextureClient* GetTextureClient(CompositableClient* aClient) MOZ_OVERRIDE;
+  virtual TextureClient* GetTextureClient() MOZ_OVERRIDE;
   virtual uint8_t* GetBuffer() MOZ_OVERRIDE;
 
   virtual already_AddRefed<gfxASurface> DeprecatedGetAsSurface() MOZ_OVERRIDE;
   virtual TemporaryRef<gfx::SourceSurface> GetAsSourceSurface() MOZ_OVERRIDE;
   virtual void SetData(const PlanarYCbCrData& aData) MOZ_OVERRIDE;
   virtual void SetDataNoCopy(const Data &aData) MOZ_OVERRIDE;
 
   virtual bool Allocate(PlanarYCbCrData& aData);
--- a/gfx/layers/ipc/SharedRGBImage.cpp
+++ b/gfx/layers/ipc/SharedRGBImage.cpp
@@ -229,17 +229,17 @@ SharedRGBImage::GetSize()
 size_t
 SharedRGBImage::GetBufferSize()
 {
   return mTextureClient ? mTextureClient->GetBufferSize()
                         : 0;
 }
 
 TextureClient*
-SharedRGBImage::GetTextureClient(CompositableClient* aClient)
+SharedRGBImage::GetTextureClient()
 {
   return mTextureClient.get();
 }
 
 already_AddRefed<gfxASurface>
 SharedRGBImage::DeprecatedGetAsSurface()
 {
   return nullptr;
--- a/gfx/layers/ipc/SharedRGBImage.h
+++ b/gfx/layers/ipc/SharedRGBImage.h
@@ -81,17 +81,17 @@ public:
   /**
    * Returns a DeprecatedSharedRGBImage* iff the descriptor was initialized with
    * ToSurfaceDescriptor.
    */
   static DeprecatedSharedRGBImage* FromSurfaceDescriptor(const SurfaceDescriptor& aDescriptor);
 
   bool AllocateBuffer(nsIntSize aSize, gfxImageFormat aImageFormat);
 
-  TextureClient* GetTextureClient(CompositableClient* aClient) MOZ_OVERRIDE { return nullptr; }
+  TextureClient* GetTextureClient() MOZ_OVERRIDE { return nullptr; }
 
 protected:
   gfx::IntSize mSize;
   gfxImageFormat mImageFormat;
   RefPtr<ISurfaceAllocator> mSurfaceAllocator;
 
   bool mAllocated;
   ipc::Shmem *mShmem;
@@ -105,17 +105,17 @@ class SharedRGBImage : public Image
                      , public ISharedImage
 {
 public:
   SharedRGBImage(ImageClient* aCompositable);
   ~SharedRGBImage();
 
   virtual ISharedImage* AsSharedImage() MOZ_OVERRIDE { return this; }
 
-  virtual TextureClient* GetTextureClient(CompositableClient* aClient) MOZ_OVERRIDE;
+  virtual TextureClient* GetTextureClient() MOZ_OVERRIDE;
 
   virtual uint8_t* GetBuffer() MOZ_OVERRIDE;
 
   gfx::IntSize GetSize();
 
   size_t GetBufferSize();
 
   already_AddRefed<gfxASurface> DeprecatedGetAsSurface();
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -1634,55 +1634,36 @@ nsLayoutUtils::ChangeMatrixBasis(const g
   return result; 
 }
 
 /**
  * Given a gfxFloat, constrains its value to be between nscoord_MIN and nscoord_MAX.
  *
  * @param aVal The value to constrain (in/out)
  */
-static void ConstrainToCoordValues(gfxFloat& aVal)
+static void ConstrainToCoordValues(gfxFloat &aVal)
 {
   if (aVal <= nscoord_MIN)
     aVal = nscoord_MIN;
   else if (aVal >= nscoord_MAX)
     aVal = nscoord_MAX;
 }
 
-static void ConstrainToCoordValues(gfxFloat& aStart, gfxFloat& aSize)
-{
-  MOZ_ASSERT(aSize >= 0);
-  gfxFloat max = aStart + aSize;
-
-  // Clamp the end points to within nscoord range
-  ConstrainToCoordValues(aStart);
-  ConstrainToCoordValues(max);
-
-  aSize = max - aStart;
-  // If the width if still greater than the max nscoord, then bring both
-  // endpoints in by the same amount until it fits.
-  if (aSize > nscoord_MAX) {
-    gfxFloat excess = aSize - nscoord_MAX;
-    excess /= 2;
-
-    aStart += excess;
-    aSize = nscoord_MAX;
-  }
-}
-
 nsRect
 nsLayoutUtils::RoundGfxRectToAppRect(const gfxRect &aRect, float aFactor)
 {
   /* Get a new gfxRect whose units are app units by scaling by the specified factor. */
   gfxRect scaledRect = aRect;
   scaledRect.ScaleRoundOut(aFactor);
 
   /* We now need to constrain our results to the max and min values for coords. */
-  ConstrainToCoordValues(scaledRect.x, scaledRect.width);
-  ConstrainToCoordValues(scaledRect.y, scaledRect.height);
+  ConstrainToCoordValues(scaledRect.x);
+  ConstrainToCoordValues(scaledRect.y);
+  ConstrainToCoordValues(scaledRect.width);
+  ConstrainToCoordValues(scaledRect.height);
 
   /* Now typecast everything back.  This is guaranteed to be safe. */
   return nsRect(nscoord(scaledRect.X()), nscoord(scaledRect.Y()),
                 nscoord(scaledRect.Width()), nscoord(scaledRect.Height()));
 }
 
 
 nsRegion