зеркало из https://github.com/mozilla/pjs.git
Bug 580531 - Push ImageContainer subclass' locks up into a superclass monitor. r=roc
This commit is contained in:
Родитель
df6496cfdc
Коммит
112ce7b8a4
|
@ -43,6 +43,7 @@
|
|||
#include "gfxPattern.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsCoreAnimationSupport.h"
|
||||
#include "mozilla/Monitor.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
@ -131,7 +132,7 @@ class THEBES_API ImageContainer {
|
|||
THEBES_INLINE_DECL_THREADSAFE_REFCOUNTING(ImageContainer)
|
||||
|
||||
public:
|
||||
ImageContainer() {}
|
||||
ImageContainer() : mMonitor("ImageContainer") {}
|
||||
virtual ~ImageContainer() {}
|
||||
|
||||
/**
|
||||
|
@ -139,6 +140,8 @@ public:
|
|||
* Picks the "best" format from the list and creates an Image of that
|
||||
* format.
|
||||
* Returns null if this backend does not support any of the formats.
|
||||
* Can be called on any thread. This method takes mMonitor when accessing
|
||||
* thread-shared state.
|
||||
*/
|
||||
virtual already_AddRefed<Image> CreateImage(const Image::Format* aFormats,
|
||||
PRUint32 aNumFormats) = 0;
|
||||
|
@ -146,6 +149,8 @@ public:
|
|||
/**
|
||||
* Set an Image as the current image to display. The Image must have
|
||||
* been created by this ImageContainer.
|
||||
* Can be called on any thread. This method takes mMonitor when accessing
|
||||
* thread-shared state.
|
||||
*
|
||||
* The Image data must not be modified after this method is called!
|
||||
*/
|
||||
|
@ -156,6 +161,8 @@ public:
|
|||
* This has to add a reference since otherwise there are race conditions
|
||||
* where the current image is destroyed before the caller can add
|
||||
* a reference.
|
||||
* Can be called on any thread. This method takes mMonitor when accessing
|
||||
* thread-shared state.
|
||||
*/
|
||||
virtual already_AddRefed<Image> GetCurrentImage() = 0;
|
||||
|
||||
|
@ -171,6 +178,8 @@ public:
|
|||
* Returns the size in aSize.
|
||||
* The returned surface will never be modified. The caller must not
|
||||
* modify it.
|
||||
* Can be called on any thread. This method takes mMonitor when accessing
|
||||
* thread-shared state.
|
||||
*/
|
||||
virtual already_AddRefed<gfxASurface> GetCurrentAsSurface(gfxIntSize* aSizeResult) = 0;
|
||||
|
||||
|
@ -187,13 +196,15 @@ public:
|
|||
|
||||
/**
|
||||
* Returns the size of the image in pixels.
|
||||
* Can be called on any thread. This method takes mMonitor when accessing
|
||||
* thread-shared state.
|
||||
*/
|
||||
virtual gfxIntSize GetCurrentSize() = 0;
|
||||
|
||||
/**
|
||||
* Set a new layer manager for this image container. It must be
|
||||
* either of the same type as the container's current layer manager,
|
||||
* or null. TRUE is returned on success.
|
||||
* or null. TRUE is returned on success. Main thread only.
|
||||
*/
|
||||
virtual PRBool SetLayerManager(LayerManager *aManager) = 0;
|
||||
|
||||
|
@ -201,20 +212,27 @@ public:
|
|||
* Sets a size that the image is expected to be rendered at.
|
||||
* This is a hint for image backends to optimize scaling.
|
||||
* Default implementation in this class is to ignore the hint.
|
||||
* Can be called on any thread. This method takes mMonitor when accessing
|
||||
* thread-shared state.
|
||||
*/
|
||||
virtual void SetScaleHint(const gfxIntSize& /* aScaleHint */) { }
|
||||
|
||||
/**
|
||||
* Get the layer manager type this image container was created with,
|
||||
* presumably its users might want to do something special if types do not
|
||||
* match.
|
||||
* match. Can be called on any thread.
|
||||
*/
|
||||
virtual LayerManager::LayersBackend GetBackendType() = 0;
|
||||
|
||||
protected:
|
||||
typedef mozilla::Monitor Monitor;
|
||||
LayerManager* mManager;
|
||||
|
||||
ImageContainer(LayerManager* aManager) : mManager(aManager) {}
|
||||
// Monitor to protect thread safe access to the "current image", and any
|
||||
// other state which is shared between threads.
|
||||
Monitor mMonitor;
|
||||
|
||||
ImageContainer(LayerManager* aManager) : mManager(aManager), mMonitor("ImageContainer") {}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -293,7 +293,7 @@ public:
|
|||
typedef gfxASurface::gfxImageFormat gfxImageFormat;
|
||||
|
||||
BasicImageContainer() :
|
||||
ImageContainer(nsnull), mMonitor("BasicImageContainer"),
|
||||
ImageContainer(nsnull),
|
||||
mScaleHint(-1, -1),
|
||||
mOffscreenFormat(gfxASurface::ImageFormatUnknown)
|
||||
{}
|
||||
|
@ -309,7 +309,6 @@ public:
|
|||
virtual LayerManager::LayersBackend GetBackendType() { return LayerManager::LAYERS_BASIC; }
|
||||
|
||||
protected:
|
||||
Monitor mMonitor;
|
||||
nsRefPtr<Image> mImage;
|
||||
gfxIntSize mScaleHint;
|
||||
gfxImageFormat mOffscreenFormat;
|
||||
|
|
|
@ -45,8 +45,6 @@
|
|||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
using mozilla::MutexAutoLock;
|
||||
|
||||
static already_AddRefed<ID3D10Texture2D>
|
||||
SurfaceToTexture(ID3D10Device *aDevice,
|
||||
gfxASurface *aSurface,
|
||||
|
@ -101,7 +99,6 @@ SurfaceToTexture(ID3D10Device *aDevice,
|
|||
ImageContainerD3D10::ImageContainerD3D10(ID3D10Device1 *aDevice)
|
||||
: ImageContainer(nsnull)
|
||||
, mDevice(aDevice)
|
||||
, mActiveImageLock("mozilla.layers.ImageContainerD3D10.mActiveImageLock")
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -124,7 +121,7 @@ ImageContainerD3D10::CreateImage(const Image::Format *aFormats,
|
|||
void
|
||||
ImageContainerD3D10::SetCurrentImage(Image *aImage)
|
||||
{
|
||||
MutexAutoLock lock(mActiveImageLock);
|
||||
MonitorAutoEnter mon(mMonitor);
|
||||
|
||||
mActiveImage = aImage;
|
||||
}
|
||||
|
@ -132,7 +129,7 @@ ImageContainerD3D10::SetCurrentImage(Image *aImage)
|
|||
already_AddRefed<Image>
|
||||
ImageContainerD3D10::GetCurrentImage()
|
||||
{
|
||||
MutexAutoLock lock(mActiveImageLock);
|
||||
MonitorAutoEnter mon(mMonitor);
|
||||
|
||||
nsRefPtr<Image> retval = mActiveImage;
|
||||
return retval.forget();
|
||||
|
@ -141,7 +138,7 @@ ImageContainerD3D10::GetCurrentImage()
|
|||
already_AddRefed<gfxASurface>
|
||||
ImageContainerD3D10::GetCurrentAsSurface(gfxIntSize *aSize)
|
||||
{
|
||||
MutexAutoLock lock(mActiveImageLock);
|
||||
MonitorAutoEnter mon(mMonitor);
|
||||
if (!mActiveImage) {
|
||||
return nsnull;
|
||||
}
|
||||
|
@ -164,7 +161,7 @@ ImageContainerD3D10::GetCurrentAsSurface(gfxIntSize *aSize)
|
|||
gfxIntSize
|
||||
ImageContainerD3D10::GetCurrentSize()
|
||||
{
|
||||
MutexAutoLock lock(mActiveImageLock);
|
||||
MonitorAutoEnter mon(mMonitor);
|
||||
if (!mActiveImage) {
|
||||
return gfxIntSize(0,0);
|
||||
}
|
||||
|
|
|
@ -41,7 +41,6 @@
|
|||
#include "LayerManagerD3D10.h"
|
||||
#include "ImageLayers.h"
|
||||
#include "yuv_convert.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
@ -71,12 +70,8 @@ public:
|
|||
void SetDevice(ID3D10Device1 *aDevice) { mDevice = aDevice; }
|
||||
|
||||
private:
|
||||
typedef mozilla::Mutex Mutex;
|
||||
|
||||
nsRefPtr<Image> mActiveImage;
|
||||
nsRefPtr<ID3D10Device1> mDevice;
|
||||
|
||||
Mutex mActiveImageLock;
|
||||
};
|
||||
|
||||
class THEBES_API ImageLayerD3D10 : public ImageLayer,
|
||||
|
|
|
@ -46,8 +46,6 @@
|
|||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
using mozilla::MutexAutoLock;
|
||||
|
||||
static already_AddRefed<IDirect3DTexture9>
|
||||
SurfaceToTexture(IDirect3DDevice9 *aDevice,
|
||||
gfxASurface *aSurface,
|
||||
|
@ -136,7 +134,6 @@ SurfaceToTexture(IDirect3DDevice9 *aDevice,
|
|||
ImageContainerD3D9::ImageContainerD3D9(IDirect3DDevice9 *aDevice)
|
||||
: ImageContainer(nsnull)
|
||||
, mDevice(aDevice)
|
||||
, mActiveImageLock("mozilla.layers.ImageContainerD3D9.mActiveImageLock")
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -159,7 +156,7 @@ ImageContainerD3D9::CreateImage(const Image::Format *aFormats,
|
|||
void
|
||||
ImageContainerD3D9::SetCurrentImage(Image *aImage)
|
||||
{
|
||||
MutexAutoLock lock(mActiveImageLock);
|
||||
MonitorAutoEnter mon(mMonitor);
|
||||
|
||||
mActiveImage = aImage;
|
||||
}
|
||||
|
@ -167,7 +164,7 @@ ImageContainerD3D9::SetCurrentImage(Image *aImage)
|
|||
already_AddRefed<Image>
|
||||
ImageContainerD3D9::GetCurrentImage()
|
||||
{
|
||||
MutexAutoLock lock(mActiveImageLock);
|
||||
MonitorAutoEnter mon(mMonitor);
|
||||
|
||||
nsRefPtr<Image> retval = mActiveImage;
|
||||
return retval.forget();
|
||||
|
@ -176,7 +173,7 @@ ImageContainerD3D9::GetCurrentImage()
|
|||
already_AddRefed<gfxASurface>
|
||||
ImageContainerD3D9::GetCurrentAsSurface(gfxIntSize *aSize)
|
||||
{
|
||||
MutexAutoLock lock(mActiveImageLock);
|
||||
MonitorAutoEnter mon(mMonitor);
|
||||
if (!mActiveImage) {
|
||||
return nsnull;
|
||||
}
|
||||
|
@ -199,7 +196,7 @@ ImageContainerD3D9::GetCurrentAsSurface(gfxIntSize *aSize)
|
|||
gfxIntSize
|
||||
ImageContainerD3D9::GetCurrentSize()
|
||||
{
|
||||
MutexAutoLock lock(mActiveImageLock);
|
||||
MonitorAutoEnter mon(mMonitor);
|
||||
if (!mActiveImage) {
|
||||
return gfxIntSize(0,0);
|
||||
}
|
||||
|
|
|
@ -41,7 +41,6 @@
|
|||
#include "LayerManagerD3D9.h"
|
||||
#include "ImageLayers.h"
|
||||
#include "yuv_convert.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
@ -71,13 +70,9 @@ public:
|
|||
void SetDevice(IDirect3DDevice9 *aDevice) { mDevice = aDevice; }
|
||||
|
||||
private:
|
||||
typedef mozilla::Mutex Mutex;
|
||||
|
||||
nsRefPtr<Image> mActiveImage;
|
||||
|
||||
nsRefPtr<IDirect3DDevice9> mDevice;
|
||||
|
||||
Mutex mActiveImageLock;
|
||||
};
|
||||
|
||||
class THEBES_API ImageLayerD3D9 : public ImageLayer,
|
||||
|
|
|
@ -51,8 +51,6 @@ using namespace mozilla::gl;
|
|||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
using mozilla::MutexAutoLock;
|
||||
|
||||
/**
|
||||
* This is an event used to unref a GLContext on the main thread and
|
||||
* optionally delete a texture associated with that context.
|
||||
|
@ -192,7 +190,6 @@ RecycleBin::GetTexture(TextureType aType, const gfxIntSize& aSize,
|
|||
ImageContainerOGL::ImageContainerOGL(LayerManagerOGL *aManager)
|
||||
: ImageContainer(aManager)
|
||||
, mRecycleBin(new RecycleBin())
|
||||
, mActiveImageLock("mozilla.layers.ImageContainerOGL.mActiveImageLock")
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -234,7 +231,7 @@ ImageContainerOGL::SetCurrentImage(Image *aImage)
|
|||
nsRefPtr<Image> oldImage;
|
||||
|
||||
{
|
||||
MutexAutoLock lock(mActiveImageLock);
|
||||
MonitorAutoEnter mon(mMonitor);
|
||||
|
||||
oldImage = mActiveImage.forget();
|
||||
mActiveImage = aImage;
|
||||
|
@ -247,7 +244,7 @@ ImageContainerOGL::SetCurrentImage(Image *aImage)
|
|||
already_AddRefed<Image>
|
||||
ImageContainerOGL::GetCurrentImage()
|
||||
{
|
||||
MutexAutoLock lock(mActiveImageLock);
|
||||
MonitorAutoEnter mon(mMonitor);
|
||||
|
||||
nsRefPtr<Image> retval = mActiveImage;
|
||||
return retval.forget();
|
||||
|
@ -256,7 +253,7 @@ ImageContainerOGL::GetCurrentImage()
|
|||
already_AddRefed<gfxASurface>
|
||||
ImageContainerOGL::GetCurrentAsSurface(gfxIntSize *aSize)
|
||||
{
|
||||
MutexAutoLock lock(mActiveImageLock);
|
||||
MonitorAutoEnter mon(mMonitor);
|
||||
|
||||
if (!mActiveImage) {
|
||||
*aSize = gfxIntSize(0,0);
|
||||
|
@ -314,7 +311,7 @@ ImageContainerOGL::GetCurrentAsSurface(gfxIntSize *aSize)
|
|||
gfxIntSize
|
||||
ImageContainerOGL::GetCurrentSize()
|
||||
{
|
||||
MutexAutoLock lock(mActiveImageLock);
|
||||
MonitorAutoEnter mon(mMonitor);
|
||||
if (!mActiveImage) {
|
||||
return gfxIntSize(0,0);
|
||||
}
|
||||
|
|
|
@ -159,13 +159,8 @@ public:
|
|||
virtual LayerManager::LayersBackend GetBackendType() { return LayerManager::LAYERS_OPENGL; }
|
||||
|
||||
private:
|
||||
typedef mozilla::Mutex Mutex;
|
||||
|
||||
nsRefPtr<RecycleBin> mRecycleBin;
|
||||
|
||||
// This protects mActiveImage
|
||||
Mutex mActiveImageLock;
|
||||
|
||||
nsRefPtr<Image> mActiveImage;
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче