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
Родитель 37ee84f25f
Коммит c00e35e764
4 изменённых файлов: 29 добавлений и 0 удалений

Просмотреть файл

@ -381,6 +381,20 @@ void ImageBridgeChild::DispatchReleaseImageClient(ImageClient* 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)
{
MOZ_ASSERT(aClient);

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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