Bug 946532. Fix crash on startup with basic compositor and d2d. r=

This commit is contained in:
Nicholas Cameron 2013-12-09 09:47:57 +13:00
parent 1d635642ef
commit 71f949fbcc

View File

@ -3514,19 +3514,36 @@ mozilla::TemporaryRef<mozilla::gfx::DrawTarget>
nsWindow::StartRemoteDrawing()
{
MOZ_ASSERT(!mCompositeDC);
NS_ASSERTION(IsRenderMode(gfxWindowsPlatform::RENDER_DIRECT2D)) ||
IsRenderMode(gfxWindowsPlatform::RENDER_GDI)),
"Unexpected render mode for remote drawing");
HDC dc = (HDC)GetNativeData(NS_NATIVE_GRAPHIC);
if (!dc) {
return nullptr;
}
nsRefPtr<gfxASurface> surf;
uint32_t flags = (mTransparencyMode == eTransparencyOpaque) ? 0 :
gfxWindowsSurface::FLAG_IS_TRANSPARENT;
nsRefPtr<gfxASurface> surf = new gfxWindowsSurface(dc, flags);
if (mTransparencyMode == eTransparencyTransparent) {
if (!mTransparentSurface) {
SetupTranslucentWindowMemoryBitmap(mTransparencyMode);
}
if (mTransparentSurface) {
surf = mTransparentSurface;
}
}
if (!surf) {
if (!dc) {
return nullptr;
}
uint32_t flags = (mTransparencyMode == eTransparencyOpaque) ? 0 :
gfxWindowsSurface::FLAG_IS_TRANSPARENT;
surf = new gfxWindowsSurface(dc, flags);
}
mozilla::gfx::IntSize size(surf->GetSize().width, surf->GetSize().height);
if (size.width <= 0 || size.height <= 0) {
FreeNativeData(dc, NS_NATIVE_GRAPHIC);
if (dc) {
FreeNativeData(dc, NS_NATIVE_GRAPHIC);
}
return nullptr;
}
@ -3539,9 +3556,14 @@ nsWindow::StartRemoteDrawing()
void
nsWindow::EndRemoteDrawing()
{
MOZ_ASSERT(mCompositeDC);
UpdateTranslucentWindow();
FreeNativeData(mCompositeDC, NS_NATIVE_GRAPHIC);
if (mTransparencyMode == eTransparencyTransparent) {
MOZ_ASSERT(IsRenderMode(gfxWindowsPlatform::RENDER_DIRECT2D))
|| mTransparentSurface);
UpdateTranslucentWindow();
}
if (mCompositeDC) {
FreeNativeData(mCompositeDC, NS_NATIVE_GRAPHIC);
}
mCompositeDC = nullptr;
}