From 18f33115e6e23ac4da992825625d48814b7a0af8 Mon Sep 17 00:00:00 2001 From: "apatrick@chromium.org" Date: Thu, 4 Nov 2010 01:26:34 +0000 Subject: OSMesa SwapBuffers does not fail if the window handle is invalid on windows. This is because the primary application of this class of GLContext is for testing and we do not want every GL related ui browser test to become flaky if there is a race condition between GL context destruction and window destruction. TEST=try BUG=none Review URL: http://codereview.chromium.org/4458001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65011 0039d316-1c4b-4281-b951-d872f2087c98 --- app/gfx/gl/gl_context_win.cc | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/app/gfx/gl/gl_context_win.cc b/app/gfx/gl/gl_context_win.cc index 80af050..b2c35a7 100644 --- a/app/gfx/gl/gl_context_win.cc +++ b/app/gfx/gl/gl_context_win.cc @@ -495,14 +495,22 @@ bool OSMesaViewGLContext::SwapBuffers() { info.bV4BlueMask = 0x00FF0000; info.bV4AlphaMask = 0xFF000000; - // Copy the back buffer to the window's device context. - return StretchDIBits(device_context_, - 0, 0, size.width(), size.height(), - 0, 0, size.width(), size.height(), - osmesa_context_.buffer(), - reinterpret_cast(&info), - DIB_RGB_COLORS, - SRCCOPY) != 0; + // Copy the back buffer to the window's device context. Do not check whether + // StretchDIBits succeeds or not. It will fail if the window has been + // destroyed but it is preferable to allow rendering to silently fail if the + // window is destroyed. This is because the primary application of this + // class of GLContext is for testing and we do not want every GL related ui / + // browser test to become flaky if there is a race condition between GL + // context destruction and window destruction. + StretchDIBits(device_context_, + 0, 0, size.width(), size.height(), + 0, 0, size.width(), size.height(), + osmesa_context_.buffer(), + reinterpret_cast(&info), + DIB_RGB_COLORS, + SRCCOPY); + + return true; } gfx::Size OSMesaViewGLContext::GetSize() { @@ -520,7 +528,8 @@ void OSMesaViewGLContext::SetSwapInterval(int interval) { } void OSMesaViewGLContext::UpdateSize() { - // Change back buffer size to that of window. + // Change back buffer size to that of window. If window handle is invalid, do + // not change the back buffer size. RECT rect; if (!GetClientRect(window_, &rect)) return; -- cgit v1.1