Null-check D3D10 devices in a few places. (bug 1225645, r=bas)

This commit is contained in:
David Anderson 2015-11-18 12:16:54 -08:00
Родитель 6458429618
Коммит ca5b902f03
3 изменённых файлов: 25 добавлений и 0 удалений

Просмотреть файл

@ -472,6 +472,9 @@ DrawTargetD2D::DrawSurfaceWithShadow(SourceSurface *aSurface,
} }
srView = static_cast<SourceSurfaceD2DTarget*>(aSurface)->GetSRView(); srView = static_cast<SourceSurfaceD2DTarget*>(aSurface)->GetSRView();
if (!srView) {
return;
}
EnsureViews(); EnsureViews();
@ -759,6 +762,11 @@ DrawTargetD2D::DrawSurfaceWithShadow(SourceSurface *aSurface,
mDevice->Draw(4, 0); mDevice->Draw(4, 0);
RefPtr<ID3D10ShaderResourceView> srView = static_cast<SourceSurfaceD2DTarget*>(aSurface)->GetSRView();
if (!srView) {
return;
}
mPrivateData->mEffect->GetVariableByName("QuadDesc")->AsVector()-> mPrivateData->mEffect->GetVariableByName("QuadDesc")->AsVector()->
SetFloatVector(ShaderConstantRectD3D10(-1.0f + ((aDest.x / mSize.width) * 2.0f), SetFloatVector(ShaderConstantRectD3D10(-1.0f + ((aDest.x / mSize.width) * 2.0f),
1.0f - (aDest.y / mSize.height * 2.0f), 1.0f - (aDest.y / mSize.height * 2.0f),

Просмотреть файл

@ -96,6 +96,11 @@ SourceSurfaceD2DTarget::GetSRView()
return mSRView; return mSRView;
} }
if (!Factory::GetDirect3D10Device()) {
gfxCriticalError() << "Invalid D3D10 device in D2D target surface";
return nullptr;
}
HRESULT hr = Factory::GetDirect3D10Device()->CreateShaderResourceView(mTexture, nullptr, getter_AddRefs(mSRView)); HRESULT hr = Factory::GetDirect3D10Device()->CreateShaderResourceView(mTexture, nullptr, getter_AddRefs(mSRView));
if (FAILED(hr)) { if (FAILED(hr)) {

Просмотреть файл

@ -370,6 +370,9 @@ TextureClientD3D11::Unlock()
if (NS_IsMainThread() && mReadbackSink && mTexture10) { if (NS_IsMainThread() && mReadbackSink && mTexture10) {
ID3D10Device* device = gfxWindowsPlatform::GetPlatform()->GetD3D10Device(); ID3D10Device* device = gfxWindowsPlatform::GetPlatform()->GetD3D10Device();
if (!device) {
return;
}
D3D10_TEXTURE2D_DESC desc; D3D10_TEXTURE2D_DESC desc;
mTexture10->GetDesc(&desc); mTexture10->GetDesc(&desc);
@ -588,6 +591,9 @@ TextureClientD3D11::AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlag
} }
} else { } else {
ID3D10Device* device = gfxWindowsPlatform::GetPlatform()->GetD3D10Device(); ID3D10Device* device = gfxWindowsPlatform::GetPlatform()->GetD3D10Device();
if (!device) {
return false;
}
CD3D10_TEXTURE2D_DESC newDesc(DXGI_FORMAT_B8G8R8A8_UNORM, CD3D10_TEXTURE2D_DESC newDesc(DXGI_FORMAT_B8G8R8A8_UNORM,
aSize.width, aSize.height, 1, 1, aSize.width, aSize.height, 1, 1,
@ -1235,6 +1241,9 @@ SyncObjectD3D11::FinalizeFrame()
if (!mD3D10Texture && mD3D10SyncedTextures.size()) { if (!mD3D10Texture && mD3D10SyncedTextures.size()) {
ID3D10Device* device = gfxWindowsPlatform::GetPlatform()->GetD3D10Device(); ID3D10Device* device = gfxWindowsPlatform::GetPlatform()->GetD3D10Device();
if (!device) {
return;
}
hr = device->OpenSharedResource(mHandle, __uuidof(ID3D10Texture2D), (void**)(ID3D10Texture2D**)getter_AddRefs(mD3D10Texture)); hr = device->OpenSharedResource(mHandle, __uuidof(ID3D10Texture2D), (void**)(ID3D10Texture2D**)getter_AddRefs(mD3D10Texture));
@ -1305,6 +1314,9 @@ SyncObjectD3D11::FinalizeFrame()
box.back = box.bottom = box.right = 1; box.back = box.bottom = box.right = 1;
ID3D10Device* device = gfxWindowsPlatform::GetPlatform()->GetD3D10Device(); ID3D10Device* device = gfxWindowsPlatform::GetPlatform()->GetD3D10Device();
if (!device) {
return;
}
for (auto iter = mD3D10SyncedTextures.begin(); iter != mD3D10SyncedTextures.end(); iter++) { for (auto iter = mD3D10SyncedTextures.begin(); iter != mD3D10SyncedTextures.end(); iter++) {
device->CopySubresourceRegion(mD3D10Texture, 0, 0, 0, 0, *iter, 0, &box); device->CopySubresourceRegion(mD3D10Texture, 0, 0, 0, 0, *iter, 0, &box);