diff --git a/gfx/layers/d3d10/ImageLayerD3D10.cpp b/gfx/layers/d3d10/ImageLayerD3D10.cpp index d5b83e44a93..f598e1d969e 100644 --- a/gfx/layers/d3d10/ImageLayerD3D10.cpp +++ b/gfx/layers/d3d10/ImageLayerD3D10.cpp @@ -50,7 +50,11 @@ SurfaceToTexture(ID3D10Device *aDevice, gfxASurface *aSurface, const gfxIntSize &aSize) { - if (aSurface && aSurface->GetType() == gfxASurface::SurfaceTypeD2D) { + if (!aSurface) { + return NULL; + } + + if (aSurface->GetType() == gfxASurface::SurfaceTypeD2D) { void *data = aSurface->GetData(&gKeyD3D10Texture); if (data) { nsRefPtr texture = static_cast(data); @@ -67,7 +71,7 @@ SurfaceToTexture(ID3D10Device *aDevice, if (!imageSurface) { imageSurface = new gfxImageSurface(aSize, gfxASurface::ImageFormatARGB32); - + nsRefPtr context = new gfxContext(imageSurface); context->SetSource(aSurface); context->SetOperator(gfxContext::OPERATOR_SOURCE); @@ -75,13 +79,13 @@ SurfaceToTexture(ID3D10Device *aDevice, } D3D10_SUBRESOURCE_DATA data; - + CD3D10_TEXTURE2D_DESC desc(DXGI_FORMAT_B8G8R8A8_UNORM, imageSurface->GetSize().width, imageSurface->GetSize().height, 1, 1); desc.Usage = D3D10_USAGE_IMMUTABLE; - + data.pSysMem = imageSurface->Data(); data.SysMemPitch = imageSurface->Stride();