Bug 612103 - Part 2: Do not attempt to draw with a shader resource view belonging to an old device. r=jrmuizel a=blocking-final
authorBas Schouten <bschouten@mozilla.com>
Wed, 12 Jan 2011 01:52:29 +0100
changeset 60335 c8e72631d44b7a9a98387ea38808b0a3fe32611a
parent 60334 04ae4e309307427ebf8927073ac2edc3f3968d88
child 60336 397fbc5af0fb7f8dbedce51cebcf899d0269f184
push id17942
push userbschouten@mozilla.com
push dateWed, 12 Jan 2011 00:52:55 +0000
treeherdermozilla-central@c8e72631d44b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel, blocking-final
bugs612103
milestone2.0b10pre
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 612103 - Part 2: Do not attempt to draw with a shader resource view belonging to an old device. r=jrmuizel a=blocking-final
gfx/layers/d3d10/ImageLayerD3D10.cpp
--- a/gfx/layers/d3d10/ImageLayerD3D10.cpp
+++ b/gfx/layers/d3d10/ImageLayerD3D10.cpp
@@ -228,23 +228,31 @@ ImageLayerD3D10::RenderLayer()
       }
       
       hasAlpha = surf->GetContentType() == gfxASurface::CONTENT_COLOR_ALPHA;
       
       device()->CreateShaderResourceView(texture, NULL, getter_AddRefs(srView));
     } else {
       ImageContainerD3D10 *container =
         static_cast<ImageContainerD3D10*>(GetContainer());
+
       if (container->device() != device()) {
         container->SetDevice(device());
       }
 
       // image->GetFormat() == Image::CAIRO_SURFACE
       CairoImageD3D10 *cairoImage =
         static_cast<CairoImageD3D10*>(image.get());
+      
+      if (cairoImage->mDevice != device()) {
+        // This shader resource view was for an old device! Can't draw that
+        // now.
+        return;
+      }
+
       srView = cairoImage->mSRView;
       hasAlpha = cairoImage->mHasAlpha;
       size = cairoImage->mSize;
     }
 
     if (hasAlpha) {
       if (mFilter == gfxPattern::FILTER_NEAREST) {
         technique = effect()->GetTechniqueByName("RenderRGBALayerPremulPoint");
@@ -273,16 +281,22 @@ ImageLayerD3D10::RenderLayer()
   } else if (image->GetFormat() == Image::PLANAR_YCBCR) {
     PlanarYCbCrImageD3D10 *yuvImage =
       static_cast<PlanarYCbCrImageD3D10*>(image.get());
 
     if (!yuvImage->HasData()) {
       return;
     }
 
+    if (yuvImage->mDevice != device()) {
+	// These shader resources were created for an old device! Can't draw
+	// that here.
+	return;
+    }
+
     // TODO: At some point we should try to deal with mFilter here, you don't
     // really want to use point filtering in the case of NEAREST, since that
     // would also use point filtering for Chroma upsampling. Where most likely
     // the user would only want point filtering for final RGB image upsampling.
 
     technique = effect()->GetTechniqueByName("RenderYCbCrLayer");
 
     effect()->GetVariableByName("tY")->AsShaderResource()->SetResource(yuvImage->mYView);