Bug 606411: Remove ImageContainerD3D10 dependencies on LayerManagerD3D10. r=roc a=blocking-final
authorBas Schouten <bschouten@mozilla.com>
Tue, 26 Oct 2010 00:24:57 +0200
changeset 56466 c7c309313eb39fc37d75e02111fcaac6edfc66c2
parent 56464 5796d98f408496e7439e7d41158bb2b0f6cf64e1
child 56467 290ad164b6562b44be4028905031d3e2a6b22b48
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, blocking-final
bugs606411
milestone2.0b8pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 606411: Remove ImageContainerD3D10 dependencies on LayerManagerD3D10. r=roc a=blocking-final
gfx/layers/d3d10/ImageLayerD3D10.cpp
gfx/layers/d3d10/ImageLayerD3D10.h
--- a/gfx/layers/d3d10/ImageLayerD3D10.cpp
+++ b/gfx/layers/d3d10/ImageLayerD3D10.cpp
@@ -41,32 +41,33 @@
 
 namespace mozilla {
 namespace layers {
 
 using mozilla::MutexAutoLock;
 
 ImageContainerD3D10::ImageContainerD3D10(LayerManagerD3D10 *aManager)
   : ImageContainer(aManager)
+  , mDevice(aManager->device())
   , mActiveImageLock("mozilla.layers.ImageContainerD3D10.mActiveImageLock")
 {
 }
 
 already_AddRefed<Image>
 ImageContainerD3D10::CreateImage(const Image::Format *aFormats,
-                               PRUint32 aNumFormats)
+                                 PRUint32 aNumFormats)
 {
   if (!aNumFormats) {
     return nsnull;
   }
   nsRefPtr<Image> img;
   if (aFormats[0] == Image::PLANAR_YCBCR) {
-    img = new PlanarYCbCrImageD3D10(static_cast<LayerManagerD3D10*>(mManager));
+    img = new PlanarYCbCrImageD3D10(mDevice);
   } else if (aFormats[0] == Image::CAIRO_SURFACE) {
-    img = new CairoImageD3D10(static_cast<LayerManagerD3D10*>(mManager));
+    img = new CairoImageD3D10(mDevice);
   }
   return img.forget();
 }
 
 void
 ImageContainerD3D10::SetCurrentImage(Image *aImage)
 {
   MutexAutoLock lock(mActiveImageLock);
@@ -207,21 +208,21 @@ ImageLayerD3D10::RenderLayer(float aOpac
         (float)cairoImage->mSize.height)
       );
   }
 
   technique->GetPassByIndex(0)->Apply(0);
   device()->Draw(4, 0);
 }
 
-PlanarYCbCrImageD3D10::PlanarYCbCrImageD3D10(mozilla::layers::LayerManagerD3D10* aManager)
+PlanarYCbCrImageD3D10::PlanarYCbCrImageD3D10(ID3D10Device1 *aDevice)
   : PlanarYCbCrImage(static_cast<ImageD3D10*>(this))
+  , mDevice(aDevice)
   , mHasData(PR_FALSE)
 {
-  mDevice = aManager->device();
 }
 
 void
 PlanarYCbCrImageD3D10::SetData(const PlanarYCbCrImage::Data &aData)
 {
   // XXX - For D3D10Ex we really should just copy to systemmem surfaces here.
   // For now, we copy the data
   int width_shift = 0;
@@ -376,18 +377,18 @@ CairoImageD3D10::SetData(const CairoImag
   D3D10_SUBRESOURCE_DATA data;
   
   CD3D10_TEXTURE2D_DESC desc(DXGI_FORMAT_B8G8R8A8_UNORM, mSize.width, mSize.height, 1, 1);
   desc.Usage = D3D10_USAGE_IMMUTABLE;
   
   data.pSysMem = imageSurface->Data();
   data.SysMemPitch = imageSurface->Stride();
 
-  mManager->device()->CreateTexture2D(&desc, &data, getter_AddRefs(mTexture));
-  mManager->device()->CreateShaderResourceView(mTexture, NULL, getter_AddRefs(mSRView));
+  mDevice->CreateTexture2D(&desc, &data, getter_AddRefs(mTexture));
+  mDevice->CreateShaderResourceView(mTexture, NULL, getter_AddRefs(mSRView));
 }
 
 already_AddRefed<gfxASurface>
 CairoImageD3D10::GetAsSurface()
 {
   return nsnull;
 }
 
--- a/gfx/layers/d3d10/ImageLayerD3D10.h
+++ b/gfx/layers/d3d10/ImageLayerD3D10.h
@@ -64,16 +64,17 @@ public:
   virtual gfxIntSize GetCurrentSize();
 
   virtual PRBool SetLayerManager(LayerManager *aManager);
 
 private:
   typedef mozilla::Mutex Mutex;
 
   nsRefPtr<Image> mActiveImage;
+  nsRefPtr<ID3D10Device1> mDevice;
 
   Mutex mActiveImageLock;
 };
 
 class THEBES_API ImageLayerD3D10 : public ImageLayer,
                                    public LayerD3D10
 {
 public:
@@ -95,17 +96,17 @@ class THEBES_API ImageD3D10
 public:
   virtual already_AddRefed<gfxASurface> GetAsSurface() = 0;
 };
 
 class THEBES_API PlanarYCbCrImageD3D10 : public PlanarYCbCrImage,
                                          public ImageD3D10
 {
 public:
-  PlanarYCbCrImageD3D10(LayerManagerD3D10 *aManager);
+  PlanarYCbCrImageD3D10(ID3D10Device1 *aDevice);
   ~PlanarYCbCrImageD3D10() {}
 
   virtual void SetData(const Data &aData);
 
   /*
    * Upload the data from out mData into our textures. For now we use this to
    * make sure the textures are created and filled on the main thread.
    */
@@ -129,27 +130,27 @@ public:
   gfx::YUVType mType; 
 };
 
 
 class THEBES_API CairoImageD3D10 : public CairoImage,
                                    public ImageD3D10
 {
 public:
-  CairoImageD3D10(LayerManagerD3D10 *aManager)
+  CairoImageD3D10(ID3D10Device1 *aDevice)
     : CairoImage(static_cast<ImageD3D10*>(this))
-    , mManager(aManager)
+    , mDevice(aDevice)
   { }
   ~CairoImageD3D10();
 
   virtual void SetData(const Data &aData);
 
   virtual already_AddRefed<gfxASurface> GetAsSurface();
 
+  nsRefPtr<ID3D10Device1> mDevice;
   nsRefPtr<ID3D10Texture2D> mTexture;
   nsRefPtr<ID3D10ShaderResourceView> mSRView;
   gfxIntSize mSize;
-  LayerManagerD3D10 *mManager;
 };
 
 } /* layers */
 } /* mozilla */
 #endif /* GFX_IMAGELAYERD3D10_H */