mirror of
https://github.com/brl/mutter.git
synced 2024-12-26 21:02:14 +00:00
framebuffer: validate width/height in _set_viewport
This validates that the viewport width and height arguments are positive values in _cogl_framebuffer_set_viewport. In addition, just before calling glViewport we also assert that something else hasn't gone amiss and that the internal viewport width/height values we track are still positive before passing to glViewport which generates an error for negative values.
This commit is contained in:
parent
5a9b92a4a5
commit
1e3f4f62e0
@ -513,6 +513,8 @@ _cogl_framebuffer_set_viewport (CoglFramebuffer *framebuffer,
|
||||
float width,
|
||||
float height)
|
||||
{
|
||||
g_return_if_fail (width > 0 && height > 0);
|
||||
|
||||
if (framebuffer->viewport_x == x &&
|
||||
framebuffer->viewport_y == y &&
|
||||
framebuffer->viewport_width == width &&
|
||||
@ -976,8 +978,10 @@ _cogl_onscreen_new (void)
|
||||
ctx,
|
||||
COGL_FRAMEBUFFER_TYPE_ONSCREEN,
|
||||
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
|
||||
0xdeadbeef, /* width */
|
||||
0xdeadbeef); /* height */
|
||||
0x1eadbeef, /* width */
|
||||
0x1eadbeef); /* height */
|
||||
/* NB: make sure to pass positive width/height numbers here
|
||||
* because otherwise we'll hit input validation assertions!*/
|
||||
|
||||
COGL_FRAMEBUFFER (onscreen)->allocated = TRUE;
|
||||
|
||||
@ -1413,9 +1417,8 @@ _cogl_framebuffer_flush_state (CoglFramebuffer *draw_buffer,
|
||||
{
|
||||
float gl_viewport_y;
|
||||
|
||||
if (draw_buffer->viewport_width < 0
|
||||
|| draw_buffer->viewport_height < 0)
|
||||
return;
|
||||
g_assert (draw_buffer->viewport_width >=0 &&
|
||||
draw_buffer->viewport_height >=0);
|
||||
|
||||
/* Convert the Cogl viewport y offset to an OpenGL viewport y offset
|
||||
* NB: OpenGL defines its window and viewport origins to be bottom
|
||||
|
Loading…
Reference in New Issue
Block a user