From c4b4500059defee4e74fb355aae698c7dea1e24c Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Wed, 28 Jan 2009 14:47:03 +0000 Subject: [PATCH] Changes cogl_rectangle to take x1, y1, x2, y2 args not x1, y1, width, height This makes it consistent with cogl_rectangle_with_{multi,}texture_coords. Notably the reason cogl_rectangle_with_{multi,}texture_coords wasn't changed instead is that the former approach lets you describe back facing rectangles. (though technically you could pass negative width/height values to achieve this; it doesn't seem as neat.) --- cogl-path.h | 16 ++++++++-------- common/cogl-primitives.c | 13 ++++++------- gl/cogl-primitives.c | 10 ++++++---- gles/cogl-primitives.c | 10 ++++++---- gles/cogl.c | 8 +++++--- 5 files changed, 31 insertions(+), 26 deletions(-) diff --git a/cogl-path.h b/cogl-path.h index d1433fe4d..361c9ef1b 100644 --- a/cogl-path.h +++ b/cogl-path.h @@ -52,17 +52,17 @@ G_BEGIN_DECLS /** * cogl_rectangle: - * @x: X coordinate of the top-left corner - * @y: Y coordinate of the top-left corner - * @width: Width of the rectangle - * @height: Height of the rectangle + * @x1: X coordinate of the top-left corner + * @y1: Y coordinate of the top-left corner + * @x2: X coordinate of the bottom-right corner + * @y2: Y coordinate of the bottom-right corner * * Fills a rectangle at the given coordinates with the current source material **/ -void cogl_rectangle (float x, - float y, - float width, - float height); +void cogl_rectangle (float x1, + float y1, + float x2, + float y2); /** * cogl_path_fill: diff --git a/common/cogl-primitives.c b/common/cogl-primitives.c index 40843fc2b..1454b03c7 100644 --- a/common/cogl-primitives.c +++ b/common/cogl-primitives.c @@ -45,14 +45,13 @@ void _cogl_path_fill_nodes (); void _cogl_path_stroke_nodes (); void -cogl_rectangle (float x, - float y, - float width, - float height) +cogl_rectangle (float x1, + float y1, + float x2, + float y2) { - cogl_rectangle_with_multitexture_coords (x, y, - x+width, - y+height, + cogl_rectangle_with_multitexture_coords (x1, y1, + x2, y2, NULL, 0); } diff --git a/gl/cogl-primitives.c b/gl/cogl-primitives.c index ddb3bcc5e..917e69840 100644 --- a/gl/cogl-primitives.c +++ b/gl/cogl-primitives.c @@ -174,7 +174,8 @@ _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min, significant bit */ GE( glStencilMask (merge ? 6 : 3) ); GE( glStencilOp (GL_ZERO, GL_REPLACE, GL_REPLACE) ); - cogl_rectangle (bounds_x, bounds_y, bounds_w, bounds_h); + cogl_rectangle (bounds_x, bounds_y, + bounds_x + bounds_w, bounds_y + bounds_h); GE( glStencilOp (GL_INVERT, GL_INVERT, GL_INVERT) ); } @@ -200,8 +201,8 @@ _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min, GE( glMatrixMode (GL_PROJECTION) ); GE( glPushMatrix () ); GE( glLoadIdentity () ); - cogl_rectangle (-1.0, -1.0, 2, 2); - cogl_rectangle (-1.0, -1.0, 2, 2); + cogl_rectangle (-1.0, -1.0, 1.0, 1.0); + cogl_rectangle (-1.0, -1.0, 1.0, 1.0); GE( glPopMatrix () ); GE( glMatrixMode (GL_MODELVIEW) ); GE( glPopMatrix () ); @@ -235,7 +236,8 @@ _cogl_path_fill_nodes () CoglPathNode, 0), ctx->clip.stencil_used); - cogl_rectangle (bounds_x, bounds_y, bounds_w, bounds_h); + cogl_rectangle (bounds_x, bounds_y, + bounds_x + bounds_w, bounds_y + bounds_h); /* The stencil buffer now contains garbage so the clip area needs to be rebuilt */ diff --git a/gles/cogl-primitives.c b/gles/cogl-primitives.c index 612237283..0612d0216 100644 --- a/gles/cogl-primitives.c +++ b/gles/cogl-primitives.c @@ -180,7 +180,8 @@ _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min, significant bit */ GE( glStencilMask (merge ? 6 : 3) ); GE( glStencilOp (GL_ZERO, GL_REPLACE, GL_REPLACE) ); - cogl_rectangle (bounds_x, bounds_y, bounds_w, bounds_h); + cogl_rectangle (bounds_x, bounds_y, + bounds_x + bounds_w, bounds_y + bounds_h); GE( glStencilOp (GL_INVERT, GL_INVERT, GL_INVERT) ); } @@ -206,8 +207,8 @@ _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min, GE( glMatrixMode (GL_PROJECTION) ); GE( glPushMatrix () ); GE( glLoadIdentity () ); - cogl_rectangle (-1.0, -1.0, 2, 2); - cogl_rectangle (-1.0, -1.0, 2, 2); + cogl_rectangle (-1.0, -1.0, 1.0, 1.0); + cogl_rectangle (-1.0, -1.0, 1.0, 1.0); GE( glPopMatrix () ); GE( glMatrixMode (GL_MODELVIEW) ); GE( glPopMatrix () ); @@ -412,7 +413,8 @@ _cogl_path_fill_nodes () CoglPathNode, 0), ctx->clip.stencil_used); - cogl_rectangle (bounds_x, bounds_y, bounds_w, bounds_h); + cogl_rectangle (bounds_x, bounds_y, + bounds_x + bounds_w, bounds_y + bounds_h); /* The stencil buffer now contains garbage so the clip area needs to be rebuilt */ diff --git a/gles/cogl.c b/gles/cogl.c index 0b087a161..b0b983d0d 100644 --- a/gles/cogl.c +++ b/gles/cogl.c @@ -404,7 +404,8 @@ _cogl_add_stencil_clip (float x_offset, GE( glStencilFunc (GL_NEVER, 0x1, 0x1) ); GE( glStencilOp (GL_REPLACE, GL_REPLACE, GL_REPLACE) ); - cogl_rectangle (x_offset, y_offset, width, height); + cogl_rectangle (x_offset, y_offset, + x_offset + width, y_offset + height); } else { @@ -412,7 +413,8 @@ _cogl_add_stencil_clip (float x_offset, rectangle */ GE( glStencilFunc (GL_NEVER, 0x1, 0x3) ); GE( glStencilOp (GL_INCR, GL_INCR, GL_INCR) ); - cogl_rectangle (x_offset, y_offset, width, height); + cogl_rectangle (x_offset, y_offset, + x_offset + width, y_offset + height); /* Subtract one from all pixels in the stencil buffer so that only pixels where both the original stencil buffer and the @@ -423,7 +425,7 @@ _cogl_add_stencil_clip (float x_offset, GE( glMatrixMode (GL_PROJECTION) ); GE( glPushMatrix () ); GE( glLoadIdentity () ); - cogl_rectangle (-1.0, -1.0, 2, 2); + cogl_rectangle (-1.0, -1.0, 1.0, 1.0); GE( glPopMatrix () ); GE( glMatrixMode (GL_MODELVIEW) ); GE( glPopMatrix () );