Bug 620665 - Part 1: Expose backend type on ImageContainers. r=roc a=blocking-beta9
authorBas Schouten <bschouten@mozilla.com>
Wed, 29 Dec 2010 01:07:00 +0000
changeset 59714 908ac46a28ffde30cfb27009e9cc92e65555ea24
parent 59713 aa25ead3690382f79c2ac86f250434b2ddf6a13a
child 59715 7c4ca41be5524176ef03fca8e4f3e2f7fcd91cae
push idunknown
push userunknown
push dateunknown
reviewersroc, blocking-beta9
bugs620665
milestone2.0b9pre
Bug 620665 - Part 1: Expose backend type on ImageContainers. r=roc a=blocking-beta9
gfx/layers/ImageLayers.h
gfx/layers/basic/BasicImages.cpp
gfx/layers/d3d10/ImageLayerD3D10.h
gfx/layers/d3d9/ImageLayerD3D9.h
gfx/layers/opengl/ImageLayerOGL.h
--- a/gfx/layers/ImageLayers.h
+++ b/gfx/layers/ImageLayers.h
@@ -190,16 +190,23 @@ 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.
    */
   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.
+   */
+  virtual LayerManager::LayersBackend GetBackendType() = 0;
+
 protected:
   LayerManager* mManager;
 
   ImageContainer(LayerManager* aManager) : mManager(aManager) {}
 };
 
 /**
  * A Layer which renders an Image.
--- a/gfx/layers/basic/BasicImages.cpp
+++ b/gfx/layers/basic/BasicImages.cpp
@@ -300,16 +300,17 @@ public:
                                               PRUint32 aNumFormats);
   virtual void SetCurrentImage(Image* aImage);
   virtual already_AddRefed<Image> GetCurrentImage();
   virtual already_AddRefed<gfxASurface> GetCurrentAsSurface(gfxIntSize* aSize);
   virtual gfxIntSize GetCurrentSize();
   virtual PRBool SetLayerManager(LayerManager *aManager);
   virtual void SetScaleHint(const gfxIntSize& aScaleHint);
   void SetOffscreenFormat(gfxImageFormat aFormat) { mOffscreenFormat = aFormat; }
+  virtual LayerManager::LayersBackend GetBackendType() { return LayerManager::LAYERS_BASIC; }
 
 protected:
   Monitor mMonitor;
   nsRefPtr<Image> mImage;
   gfxIntSize mScaleHint;
   gfxImageFormat mOffscreenFormat;
 };
 
--- a/gfx/layers/d3d10/ImageLayerD3D10.h
+++ b/gfx/layers/d3d10/ImageLayerD3D10.h
@@ -60,16 +60,18 @@ public:
   virtual already_AddRefed<Image> GetCurrentImage();
 
   virtual already_AddRefed<gfxASurface> GetCurrentAsSurface(gfxIntSize* aSize);
 
   virtual gfxIntSize GetCurrentSize();
 
   virtual PRBool SetLayerManager(LayerManager *aManager);
 
+  virtual LayerManager::LayersBackend GetBackendType() { return LayerManager::LAYERS_D3D10; }
+
 private:
   typedef mozilla::Mutex Mutex;
 
   nsRefPtr<Image> mActiveImage;
   nsRefPtr<ID3D10Device1> mDevice;
 
   Mutex mActiveImageLock;
 };
--- a/gfx/layers/d3d9/ImageLayerD3D9.h
+++ b/gfx/layers/d3d9/ImageLayerD3D9.h
@@ -60,16 +60,18 @@ public:
   virtual already_AddRefed<Image> GetCurrentImage();
 
   virtual already_AddRefed<gfxASurface> GetCurrentAsSurface(gfxIntSize* aSize);
 
   virtual gfxIntSize GetCurrentSize();
 
   virtual PRBool SetLayerManager(LayerManager *aManager);
 
+  virtual LayerManager::LayersBackend GetBackendType() { return LayerManager::LAYERS_D3D9; }
+
 private:
   typedef mozilla::Mutex Mutex;
 
   nsRefPtr<Image> mActiveImage;
 
   Mutex mActiveImageLock;
 };
 
--- a/gfx/layers/opengl/ImageLayerOGL.h
+++ b/gfx/layers/opengl/ImageLayerOGL.h
@@ -151,16 +151,18 @@ public:
   virtual already_AddRefed<Image> GetCurrentImage();
 
   virtual already_AddRefed<gfxASurface> GetCurrentAsSurface(gfxIntSize* aSize);
 
   virtual gfxIntSize GetCurrentSize();
 
   virtual PRBool SetLayerManager(LayerManager *aManager);
 
+  virtual LayerManager::LayersBackend GetBackendType() { return LayerManager::LAYERS_OPENGL; }
+
 private:
   typedef mozilla::Mutex Mutex;
 
   nsRefPtr<RecycleBin> mRecycleBin;
 
   // This protects mActiveImage
   Mutex mActiveImageLock;