Bug 580531 - Push ImageContainer subclass' locks up into a superclass monitor. r=roc
This commit is contained in:
@@ -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") {}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user