st/wgl: Don't cache HDC anywhere.

Applications may destroy HDC at any time. So always get a HDC as needed.

Fixes lack of presents with Solidworks eDrawings when screen resolution is
changed.

Reviewed-by: Brian Paul <brianp@vmware.com>
This commit is contained in:
José Fonseca 2012-10-08 11:40:58 +01:00
parent 86de501f14
commit 88e417d761
4 changed files with 12 additions and 11 deletions

View file

@ -248,8 +248,6 @@ wglGetPbufferDCARB(HPBUFFERARB hPbuffer)
hDC = GetDC(fb->hWnd);
assert(hDC == fb->hDC);
return hDC;
}

View file

@ -92,8 +92,6 @@ stw_framebuffer_destroy_locked(
stw_st_destroy_framebuffer_locked(fb->stfb);
ReleaseDC(fb->hWnd, fb->hDC);
pipe_mutex_unlock( fb->mutex );
pipe_mutex_destroy( fb->mutex );
@ -254,11 +252,6 @@ stw_framebuffer_create(
if (fb == NULL)
return NULL;
/* Applications use, create, destroy device contexts, so the hdc passed is. We create our own DC
* because we need one for single buffered visuals.
*/
fb->hDC = GetDC(hWnd);
fb->hWnd = hWnd;
fb->iPixelFormat = iPixelFormat;

View file

@ -58,7 +58,6 @@ struct stw_framebuffer
* above, to prevent the framebuffer from being destroyed.
*/
HDC hDC;
HWND hWnd;
int iPixelFormat;

View file

@ -175,10 +175,21 @@ stw_st_framebuffer_flush_front(struct st_framebuffer_iface *stfb,
enum st_attachment_type statt)
{
struct stw_st_framebuffer *stwfb = stw_st_framebuffer(stfb);
boolean ret;
HDC hDC;
pipe_mutex_lock(stwfb->fb->mutex);
return stw_st_framebuffer_present_locked(stwfb->fb->hDC, &stwfb->base, statt);
/* We must not cache HDCs anywhere, as they can be invalidated by the
* application, or screen resolution changes. */
hDC = GetDC(stwfb->fb->hWnd);
ret = stw_st_framebuffer_present_locked(hDC, &stwfb->base, statt);
ReleaseDC(stwfb->fb->hWnd, hDC);
return ret;
}
/**