diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index a4c5a03deb8..98dfa81adbe 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -338,6 +338,15 @@ static WindowsDllInterceptor sUser32Intercept; // the size of the default window border Windows paints. static const PRInt32 kGlassMarginAdjustment = 2; + +// We should never really try to accelerate windows bigger than this. In some +// cases this might lead to no D3D9 acceleration where we could have had it +// but D3D9 does not reliably report when it supports bigger windows. 8192 +// is as safe as we can get, we know at least D3D10 hardware always supports +// this, other hardware we expect to report correctly in D3D9. +#define MAX_ACCELERATED_DIMENSION 8192 + + /************************************************************** ************************************************************** ** @@ -3230,6 +3239,9 @@ nsWindow::GetLayerManager(PLayersChild* aShadowManager, } #endif + RECT windowRect; + ::GetClientRect(mWnd, &windowRect); + if (!mLayerManager || (!sAllowD3D9 && aPersistence == LAYER_MANAGER_PERSISTENT && mLayerManager->GetBackendType() == @@ -3243,7 +3255,9 @@ nsWindow::GetLayerManager(PLayersChild* aShadowManager, * transparent windows so don't even try. I'm also not sure if we even * want to support this case. See bug #593471 */ if (eTransparencyTransparent == mTransparencyMode || - prefs.mDisableAcceleration) + prefs.mDisableAcceleration || + windowRect.right - windowRect.left > MAX_ACCELERATED_DIMENSION || + windowRect.bottom - windowRect.top > MAX_ACCELERATED_DIMENSION) mUseAcceleratedRendering = false; else if (prefs.mAccelerateByDefault) mUseAcceleratedRendering = true; diff --git a/widget/src/windows/nsWindowGfx.cpp b/widget/src/windows/nsWindowGfx.cpp index 6d788f3d662..3b63270c584 100644 --- a/widget/src/windows/nsWindowGfx.cpp +++ b/widget/src/windows/nsWindowGfx.cpp @@ -339,15 +339,6 @@ bool nsWindow::OnPaint(HDC aDC, PRUint32 aNestingLevel) } #endif - nsRefPtr targetSurfaceWin; - if (!targetSurface && - IsRenderMode(gfxWindowsPlatform::RENDER_GDI)) - { - PRUint32 flags = (mTransparencyMode == eTransparencyOpaque) ? 0 : - gfxWindowsSurface::FLAG_IS_TRANSPARENT; - targetSurfaceWin = new gfxWindowsSurface(hDC, flags); - targetSurface = targetSurfaceWin; - } #ifdef CAIRO_HAS_D2D_SURFACE if (!targetSurface && IsRenderMode(gfxWindowsPlatform::RENDER_DIRECT2D)) @@ -361,9 +352,25 @@ bool nsWindow::OnPaint(HDC aDC, PRUint32 aNestingLevel) #endif mD2DWindowSurface = new gfxD2DSurface(mWnd, content); } - targetSurface = mD2DWindowSurface; + if (!mD2DWindowSurface->CairoStatus()) { + targetSurface = mD2DWindowSurface; + } else { + mD2DWindowSurface = nsnull; + } } #endif + + nsRefPtr targetSurfaceWin; + if (!targetSurface && + (IsRenderMode(gfxWindowsPlatform::RENDER_GDI) || + IsRenderMode(gfxWindowsPlatform::RENDER_DIRECT2D))) + { + PRUint32 flags = (mTransparencyMode == eTransparencyOpaque) ? 0 : + gfxWindowsSurface::FLAG_IS_TRANSPARENT; + targetSurfaceWin = new gfxWindowsSurface(hDC, flags); + targetSurface = targetSurfaceWin; + } + nsRefPtr targetSurfaceImage; if (!targetSurface && (IsRenderMode(gfxWindowsPlatform::RENDER_IMAGE_STRETCH32) ||