Bug 886219 - Make sure we release ImageBridge compositables and textures from the ImageBridge thread. r=nical

This commit is contained in:
Matt Woodrow 2013-10-02 16:05:35 +13:00
parent ae90722e6c
commit 126b90d8b4
4 changed files with 29 additions and 0 deletions

View File

@ -381,6 +381,20 @@ void ImageBridgeChild::DispatchReleaseImageClient(ImageClient* aClient)
NewRunnableFunction(&ReleaseImageClientNow, aClient)); NewRunnableFunction(&ReleaseImageClientNow, aClient));
} }
static void ReleaseTextureClientNow(TextureClient* aClient)
{
MOZ_ASSERT(InImageBridgeChildThread());
aClient->Release();
}
// static
void ImageBridgeChild::DispatchReleaseTextureClient(TextureClient* aClient)
{
sImageBridgeChildSingleton->GetMessageLoop()->PostTask(
FROM_HERE,
NewRunnableFunction(&ReleaseTextureClientNow, aClient));
}
static void UpdateImageClientNow(ImageClient* aClient, ImageContainer* aContainer) static void UpdateImageClientNow(ImageClient* aClient, ImageContainer* aContainer)
{ {
MOZ_ASSERT(aClient); MOZ_ASSERT(aClient);

View File

@ -237,6 +237,7 @@ public:
TemporaryRef<ImageClient> CreateImageClientNow(CompositableType aType); TemporaryRef<ImageClient> CreateImageClientNow(CompositableType aType);
static void DispatchReleaseImageClient(ImageClient* aClient); static void DispatchReleaseImageClient(ImageClient* aClient);
static void DispatchReleaseTextureClient(TextureClient* aClient);
static void DispatchImageClientUpdate(ImageClient* aClient, ImageContainer* aContainer); static void DispatchImageClientUpdate(ImageClient* aClient, ImageContainer* aContainer);
/** /**

View File

@ -15,6 +15,7 @@
#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor, etc #include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor, etc
#include "mozilla/layers/TextureClient.h" // for BufferTextureClient, etc #include "mozilla/layers/TextureClient.h" // for BufferTextureClient, etc
#include "mozilla/layers/YCbCrImageDataSerializer.h" #include "mozilla/layers/YCbCrImageDataSerializer.h"
#include "mozilla/layers/ImageBridgeChild.h" // for ImageBridgeChild
#include "mozilla/mozalloc.h" // for operator delete #include "mozilla/mozalloc.h" // for operator delete
#include "nsISupportsImpl.h" // for Image::AddRef #include "nsISupportsImpl.h" // for Image::AddRef
@ -35,6 +36,12 @@ SharedPlanarYCbCrImage::SharedPlanarYCbCrImage(ImageClient* aCompositable)
SharedPlanarYCbCrImage::~SharedPlanarYCbCrImage() { SharedPlanarYCbCrImage::~SharedPlanarYCbCrImage() {
MOZ_COUNT_DTOR(SharedPlanarYCbCrImage); MOZ_COUNT_DTOR(SharedPlanarYCbCrImage);
if (mCompositable->GetAsyncID() != 0 &&
!InImageBridgeChildThread()) {
ImageBridgeChild::DispatchReleaseTextureClient(mTextureClient.forget().drop());
ImageBridgeChild::DispatchReleaseImageClient(mCompositable.forget().drop());
}
} }

View File

@ -11,6 +11,7 @@
#include "mozilla/layers/ImageClient.h" // for ImageClient #include "mozilla/layers/ImageClient.h" // for ImageClient
#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor, etc #include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor, etc
#include "mozilla/layers/TextureClient.h" // for BufferTextureClient, etc #include "mozilla/layers/TextureClient.h" // for BufferTextureClient, etc
#include "mozilla/layers/ImageBridgeChild.h" // for ImageBridgeChild
#include "mozilla/mozalloc.h" // for operator delete, etc #include "mozilla/mozalloc.h" // for operator delete, etc
#include "nsAutoPtr.h" // for nsRefPtr #include "nsAutoPtr.h" // for nsRefPtr
#include "nsDebug.h" // for NS_WARNING, NS_ASSERTION #include "nsDebug.h" // for NS_WARNING, NS_ASSERTION
@ -183,6 +184,12 @@ SharedRGBImage::SharedRGBImage(ImageClient* aCompositable)
SharedRGBImage::~SharedRGBImage() SharedRGBImage::~SharedRGBImage()
{ {
MOZ_COUNT_DTOR(SharedRGBImage); MOZ_COUNT_DTOR(SharedRGBImage);
if (mCompositable->GetAsyncID() != 0 &&
!InImageBridgeChildThread()) {
ImageBridgeChild::DispatchReleaseTextureClient(mTextureClient.forget().drop());
ImageBridgeChild::DispatchReleaseImageClient(mCompositable.forget().drop());
}
} }
bool bool