diff options
author | José Fonseca <[email protected]> | 2011-04-18 16:41:25 +0100 |
---|---|---|
committer | José Fonseca <[email protected]> | 2011-06-12 09:15:49 +0100 |
commit | 3f3d1991219fb9b80da667b42c0ea02e7074202e (patch) | |
tree | 50a0be3dd1ff5339d6bc5b169a712f5a572b12d8 /src | |
parent | ac28843c1ad9cf8aaa57218c2bf3bbe56804df6b (diff) |
st/wgl: Cope with zero width/height windows.
While ensuring the framebuffer area is never zero.
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/state_trackers/wgl/stw_framebuffer.c | 50 |
1 files changed, 38 insertions, 12 deletions
diff --git a/src/gallium/state_trackers/wgl/stw_framebuffer.c b/src/gallium/state_trackers/wgl/stw_framebuffer.c index d8b1440a688..4033365bfbe 100644 --- a/src/gallium/state_trackers/wgl/stw_framebuffer.c +++ b/src/gallium/state_trackers/wgl/stw_framebuffer.c @@ -117,13 +117,26 @@ stw_framebuffer_get_size( struct stw_framebuffer *fb ) RECT window_rect; POINT client_pos; + /* + * Sanity checking. + */ + assert(fb->hWnd); - - /* Get the client area size. */ - GetClientRect( fb->hWnd, &client_rect ); + assert(fb->width && fb->height); + assert(fb->client_rect.right == fb->client_rect.left + fb->width); + assert(fb->client_rect.bottom == fb->client_rect.top + fb->height); + + /* + * Get the client area size. + */ + + if (!GetClientRect(fb->hWnd, &client_rect)) { + return; + } + assert(client_rect.left == 0); assert(client_rect.top == 0); - width = client_rect.right - client_rect.left; + width = client_rect.right - client_rect.left; height = client_rect.bottom - client_rect.top; if (width <= 0 || height <= 0) { @@ -138,7 +151,7 @@ stw_framebuffer_get_size( struct stw_framebuffer *fb ) return; } - if(width != fb->width || height != fb->height) { + if (width != fb->width || height != fb->height) { fb->must_resize = TRUE; fb->width = width; fb->height = height; @@ -146,14 +159,14 @@ stw_framebuffer_get_size( struct stw_framebuffer *fb ) client_pos.x = 0; client_pos.y = 0; - ClientToScreen(fb->hWnd, &client_pos); - - GetWindowRect(fb->hWnd, &window_rect); + if (ClientToScreen(fb->hWnd, &client_pos) && + GetWindowRect(fb->hWnd, &window_rect)) { + fb->client_rect.left = client_pos.x - window_rect.left; + fb->client_rect.top = client_pos.y - window_rect.top; + } - fb->client_rect.left = client_pos.x - window_rect.left; - fb->client_rect.top = client_pos.y - window_rect.top; - fb->client_rect.right = fb->client_rect.left + fb->width; - fb->client_rect.bottom = fb->client_rect.top + fb->height; + fb->client_rect.right = fb->client_rect.left + fb->width; + fb->client_rect.bottom = fb->client_rect.top + fb->height; #if 0 debug_printf("\n"); @@ -253,6 +266,19 @@ stw_framebuffer_create( fb->refcnt = 1; + /* + * Windows can be sometimes have zero width and or height, but we ensure + * a non-zero framebuffer size at all times. + */ + + fb->must_resize = TRUE; + fb->width = 1; + fb->height = 1; + fb->client_rect.left = 0; + fb->client_rect.top = 0; + fb->client_rect.right = fb->client_rect.left + fb->width; + fb->client_rect.bottom = fb->client_rect.top + fb->height; + stw_framebuffer_get_size(fb); pipe_mutex_init( fb->mutex ); |