[cogl/wip/wayland-compositor: 1/18] framebuffer: validate width/height in _set_viewport



commit 6469b5b71e13ee9d6afb433f4cef2aba81551e58
Author: Robert Bragg <robert linux intel com>
Date:   Fri May 27 12:21:26 2011 +0100

    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.

 cogl/cogl-framebuffer.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c
index efe010e..73e8b5b 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -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 &&
@@ -1413,9 +1415,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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]