1
0
Fork 0

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.)
This commit is contained in:
Robert Bragg 2009-01-28 14:47:03 +00:00
parent 6048a0544a
commit ef4052c18d
13 changed files with 75 additions and 69 deletions

View file

@ -108,17 +108,17 @@ clutter_rectangle_paint (ClutterActor *self)
/* this sucks, but it's the only way to make a border */
cogl_rectangle (priv->border_width, 0,
geom.width - priv->border_width,
geom.width,
priv->border_width);
cogl_rectangle (geom.width - priv->border_width,
priv->border_width,
priv->border_width,
geom.height - priv->border_width);
geom.width,
geom.height);
cogl_rectangle (0, geom.height - priv->border_width,
geom.width - priv->border_width,
priv->border_width);
geom.height);
cogl_rectangle (0, 0,
priv->border_width,
@ -135,8 +135,8 @@ clutter_rectangle_paint (ClutterActor *self)
tmp_alpha);
cogl_rectangle (priv->border_width, priv->border_width,
geom.width - priv->border_width * 2,
geom.height - priv->border_width * 2);
geom.width - priv->border_width,
geom.height - priv->border_width);
}
else
{

View file

@ -818,8 +818,8 @@ cursor_paint (ClutterText *self)
{
cogl_rectangle (priv->cursor_pos.x,
priv->cursor_pos.y,
priv->cursor_pos.width,
priv->cursor_pos.height);
priv->cursor_pos.x + priv->cursor_pos.width,
priv->cursor_pos.y + priv->cursor_pos.height);
}
else
{
@ -885,8 +885,9 @@ cursor_paint (ClutterText *self)
cogl_rectangle (range_x,
CLUTTER_UNITS_TO_DEVICE (y),
range_width,
CLUTTER_UNITS_TO_DEVICE (height));
range_x + range_width,
CLUTTER_UNITS_TO_DEVICE (y)
+ CLUTTER_UNITS_TO_DEVICE (height));
}
g_free (ranges);

View file

@ -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:

View file

@ -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);
}

View file

@ -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 */

View file

@ -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 */

View file

@ -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 () );

View file

@ -514,7 +514,7 @@ cogl_pango_renderer_draw_rectangle (PangoRenderer *renderer,
&x2, &y2);
cogl_set_source (priv->solid_material);
cogl_rectangle (x1, y1, x2 - x1, y2 - y1);
cogl_rectangle (x1, y1, x2, y2);
}
static void

View file

@ -128,14 +128,14 @@ on_paint (ClutterActor *actor, TestState *state)
/* Draw a front-facing texture */
cogl_set_source_texture (state->texture);
cogl_rectangle (x1, y1, x2 - x1, y2 - y1);
cogl_rectangle (x1, y1, x2, y2);
x1 = x2;
x2 = x1 + (float)(TEXTURE_SIZE);
/* Draw a back-facing texture */
cogl_set_source_texture (state->texture);
cogl_rectangle (x2, y1, x1 - x2, y2 - y1);
cogl_rectangle (x2, y1, x1, y2);
x1 = x2;
x2 = x1 + (float)(TEXTURE_SIZE);
@ -172,7 +172,7 @@ on_paint (ClutterActor *actor, TestState *state)
/* Draw a regular rectangle (this should always show) */
cogl_set_source_color4f (1.0, 0, 0, 1.0);
cogl_rectangle (x1, y1, x2 - x1, y2 - y1);
cogl_rectangle (x1, y1, x2, y2);
/* The second time round draw beneath the first with backface
culling disabled */

View file

@ -162,8 +162,8 @@ key_group_paint (ClutterActor *actor)
cogl_set_source_color4ub (255, 255, 0, 224);
cogl_rectangle (CLUTTER_UNITS_TO_DEVICE (box.x1),
CLUTTER_UNITS_TO_DEVICE (box.y1),
CLUTTER_UNITS_TO_DEVICE (box.x2 - box.x1),
CLUTTER_UNITS_TO_DEVICE (box.y2 - box.y1));
CLUTTER_UNITS_TO_DEVICE (box.x2),
CLUTTER_UNITS_TO_DEVICE (box.y2));
}
if (CLUTTER_ACTOR_IS_VISIBLE (child))

View file

@ -169,8 +169,8 @@ key_group_paint (ClutterActor *actor)
cogl_set_source_color4ub (255, 255, 0, 224);
cogl_rectangle (CLUTTER_UNITS_TO_DEVICE (box.x1),
CLUTTER_UNITS_TO_DEVICE (box.y1),
CLUTTER_UNITS_TO_DEVICE (box.x2 - box.x1),
CLUTTER_UNITS_TO_DEVICE (box.y2 - box.y1));
CLUTTER_UNITS_TO_DEVICE (box.x2),
CLUTTER_UNITS_TO_DEVICE (box.y2));
}
if (CLUTTER_ACTOR_IS_VISIBLE (child))

View file

@ -9,7 +9,7 @@
*--------------------------------------------------*/
G_BEGIN_DECLS
#define TEST_TYPE_COGLBOX test_coglbox_get_type()
#define TEST_COGLBOX(obj) \
@ -44,7 +44,7 @@ struct _TestCoglbox
TestCoglboxPrivate *priv;
};
struct _TestCoglboxClass
struct _TestCoglboxClass
{
ClutterActorClass parent_class;
@ -88,7 +88,7 @@ test_coglbox_paint(ClutterActor *self)
CLUTTER_FLOAT_TO_FIXED (1.0f)
};
CoglHandle material;
priv = TEST_COGLBOX_GET_PRIVATE (self);
cogl_set_source_color4ub (0x66, 0x66, 0xdd, 0xff);
@ -101,15 +101,15 @@ test_coglbox_paint(ClutterActor *self)
0, 0,
CLUTTER_INT_TO_FIXED (6),
CLUTTER_INT_TO_FIXED (6));
cogl_draw_buffer (COGL_OFFSCREEN_BUFFER, priv->offscreen_id);
cogl_set_source_color4ub (0xff, 0, 0, 0xff);
cogl_rectangle (20, 20, 100, 100);
cogl_rectangle (20, 20, 20 + 100, 20 + 100);
cogl_set_source_color4ub (0, 0xff, 0, 0xff);
cogl_rectangle (80, 80, 100, 100);
cogl_rectangle (80, 80, 80 + 100, 80 + 100);
cogl_draw_buffer (COGL_WINDOW_BUFFER, 0);
material = cogl_material_new ();
@ -136,12 +136,12 @@ static void
test_coglbox_dispose (GObject *object)
{
TestCoglboxPrivate *priv;
priv = TEST_COGLBOX_GET_PRIVATE (object);
cogl_texture_unref (priv->texture_id);
cogl_offscreen_unref (priv->offscreen_id);
G_OBJECT_CLASS (test_coglbox_parent_class)->dispose (object);
}
@ -150,24 +150,24 @@ test_coglbox_init (TestCoglbox *self)
{
TestCoglboxPrivate *priv;
self->priv = priv = TEST_COGLBOX_GET_PRIVATE(self);
printf ("Loading redhand.png\n");
priv->texhand_id = cogl_texture_new_from_file ("redhand.png", 0,
COGL_TEXTURE_NONE,
COGL_PIXEL_FORMAT_ANY,
NULL);
printf ("Creating texture with size\n");
priv->texture_id = cogl_texture_new_with_size (200, 200, 0,
COGL_TEXTURE_NONE,
COGL_PIXEL_FORMAT_RGB_888);
if (priv->texture_id == COGL_INVALID_HANDLE)
printf ("Failed creating texture with size!\n");
printf ("Creating offscreen\n");
priv->offscreen_id = cogl_offscreen_new_to_texture (priv->texture_id);
if (priv->offscreen_id == COGL_INVALID_HANDLE)
printf ("Failed creating offscreen to texture!\n");
}
@ -179,9 +179,9 @@ test_coglbox_class_init (TestCoglboxClass *klass)
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
gobject_class->finalize = test_coglbox_finalize;
gobject_class->dispose = test_coglbox_dispose;
gobject_class->dispose = test_coglbox_dispose;
actor_class->paint = test_coglbox_paint;
g_type_class_add_private (gobject_class, sizeof (TestCoglboxPrivate));
}
@ -196,21 +196,21 @@ test_cogl_offscreen_main (int argc, char *argv[])
{
ClutterActor *stage;
ClutterActor *coglbox;
clutter_init(&argc, &argv);
/* Stage */
stage = clutter_stage_get_default ();
clutter_actor_set_size (stage, 400, 400);
clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Test");
/* Cogl Box */
coglbox = test_coglbox_new ();
clutter_container_add_actor (CLUTTER_CONTAINER (stage), coglbox);
clutter_actor_show_all (stage);
clutter_main ();
return 0;
}

View file

@ -155,7 +155,7 @@ hand_post_paint (ClutterActor *actor,
clutter_actor_get_size (actor, &w, &h);
cogl_set_source_color4ub (0, 255, 0, 128);
cogl_rectangle (w / 2, h / 2, w / 2, h / 2);
cogl_rectangle (w / 2, h / 2, w, h);
oh->paint_guards[actor_num] = FALSE;
}