summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2011-10-13 23:38:10 -0700
committerBenjamin Otte <otte@redhat.com>2011-10-15 00:06:23 -0700
commit3cf855da749e68b5b7e8cde552c79271823db0cd (patch)
tree030a59bbb78c86076bf4822c0f24e33fb844d73d
parent0896c30a81d56cb7216ca51d5547c7eeb766e469 (diff)
graphic: Remove game_graphic_draw_area() function
Use game_graphic_draw() + clipping instead.
-rw-r--r--libgame/game-board.c15
-rw-r--r--libgame/game-colored.c2
-rw-r--r--libgame/game-graphic.c19
-rw-r--r--libgame/game-graphic.h3
-rw-r--r--libgame/game-viewport.c8
5 files changed, 7 insertions, 40 deletions
diff --git a/libgame/game-board.c b/libgame/game-board.c
index 775d8ae..03094a5 100644
--- a/libgame/game-board.c
+++ b/libgame/game-board.c
@@ -40,7 +40,7 @@ GameGraphicClass *parent_class;
static void
game_board_draw_repeated (GameBoard *board, cairo_t *cr, const GameRectangle *areap)
{
- GameRectangle rect, rect2, area = *areap;
+ GameRectangle rect, area = *areap;
GamePoint p, move_x = { - board->repeat.x, 0 }, move_y = { 0, - board->repeat.y };
GSList *walk;
double tmp;
@@ -95,12 +95,10 @@ game_board_draw_repeated (GameBoard *board, cairo_t *cr, const GameRectangle *ar
move_x.y = - (y_start - y_stop) * board->repeat.y;
for (; x_start < x_stop; x_start++) {
for (y = y_start; y < y_stop; y++) {
- if (!game_rectangle_intersect (&rect2, &rect, &sprite->graphic->rect))
- continue;
cairo_save (cr);
cairo_translate (cr, x_start * board->repeat.x + sprite->pos.x,
y * board->repeat.y + sprite->pos.y);
- game_graphic_draw_area (sprite->graphic, cr, &rect2);
+ game_graphic_draw (sprite->graphic, cr);
cairo_restore (cr);
game_rectangle_move (&rect, &rect, &move_y);
}
@@ -113,22 +111,15 @@ static void
game_board_draw_unrepeated (GameBoard *board, cairo_t *cr,
const GameRectangle *area)
{
- GameRectangle rect;
- GamePoint p;
GSList *walk;
for (walk = board->sprites; walk; walk = g_slist_next (walk)) {
GameSprite *sprite = walk->data;
if (!sprite->graphic)
continue;
- game_sprite_get_area (sprite, &rect);
- if (!game_rectangle_intersect (&rect, area, &rect))
- continue;
cairo_save (cr);
cairo_translate (cr, sprite->pos.x, sprite->pos.y);
- game_point_negate (&p, &sprite->pos);
- game_rectangle_move (&rect, &rect, &p);
- game_graphic_draw_area (sprite->graphic, cr, &rect);
+ game_graphic_draw (sprite->graphic, cr);
cairo_restore (cr);
}
}
diff --git a/libgame/game-colored.c b/libgame/game-colored.c
index 106b8cb..fd43460 100644
--- a/libgame/game-colored.c
+++ b/libgame/game-colored.c
@@ -130,7 +130,7 @@ game_colored_draw (GameGraphic *graphic, cairo_t *cr, const GameRectangle *area)
cairo_pattern_t *mask;
if (colored->base)
- game_graphic_draw_area (colored->base, cr, area);
+ game_graphic_draw (colored->base, cr);
game_color_as_cairo_source (cr, &colored->color);
if (colored->mask) {
diff --git a/libgame/game-graphic.c b/libgame/game-graphic.c
index 536bbca..12bcafa 100644
--- a/libgame/game-graphic.c
+++ b/libgame/game-graphic.c
@@ -209,26 +209,11 @@ game_graphic_invalidate_area (GameGraphic *graphic,
gboolean
game_graphic_draw (GameGraphic *graphic, cairo_t *cr)
{
- g_return_val_if_fail (GAME_IS_GRAPHIC (graphic), FALSE);
- g_return_val_if_fail (cr != NULL, FALSE);
-
- return game_graphic_draw_area (graphic, cr, &graphic->rect);
-}
-
-gboolean
-game_graphic_draw_area (GameGraphic *graphic, cairo_t *cr, const
- GameRectangle *rect)
-{
GameGraphicClass *klass;
- GameRectangle inval;
-
+
g_return_val_if_fail (GAME_IS_GRAPHIC (graphic), FALSE);
g_return_val_if_fail (cr != NULL, FALSE);
- g_return_val_if_fail (GAME_RECTANGLE_IS_VALID (rect), FALSE);
- if (!game_rectangle_intersect (&inval, &graphic->rect, rect))
- return TRUE;
-
cairo_save (cr);
game_rectangle_path (cr, &graphic->rect);
@@ -236,7 +221,7 @@ game_graphic_draw_area (GameGraphic *graphic, cairo_t *cr, const
klass = GAME_GRAPHIC_GET_CLASS (graphic);
g_return_val_if_fail (klass->draw, FALSE);
- klass->draw (graphic, cr, rect);
+ klass->draw (graphic, cr, &graphic->rect);
if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) {
gchar *s = game_object_to_string (GAME_OBJECT (graphic));
g_printerr ("Error drawing to %s: %s\n", s, cairo_status_to_string (cairo_status (cr)));
diff --git a/libgame/game-graphic.h b/libgame/game-graphic.h
index d0e9010..0e36f2f 100644
--- a/libgame/game-graphic.h
+++ b/libgame/game-graphic.h
@@ -66,9 +66,6 @@ void game_graphic_invalidate_area (GameGraphic * graphic,
gboolean game_graphic_draw (GameGraphic * graphic,
cairo_t * cr);
-gboolean game_graphic_draw_area (GameGraphic * graphic,
- cairo_t * cr,
- const GameRectangle * rectangle);
G_END_DECLS
diff --git a/libgame/game-viewport.c b/libgame/game-viewport.c
index c5cd24a..03fb025 100644
--- a/libgame/game-viewport.c
+++ b/libgame/game-viewport.c
@@ -123,18 +123,12 @@ static void
game_viewport_draw (GameGraphic *graphic, cairo_t *cr, const GameRectangle *rect)
{
GameViewport *port = GAME_VIEWPORT (graphic);
- GameRectangle rect2;
if (!port->graphic)
return;
cairo_scale (cr, port->scale, port->scale);
cairo_translate (cr, -port->offset.x, -port->offset.y);
- rect2.x1 = rect->x1 / port->scale;
- rect2.y1 = rect->y1 / port->scale;
- rect2.x2 = rect->x2 / port->scale;
- rect2.y2 = rect->y2 / port->scale;
- game_rectangle_move (&rect2, &rect2, &port->offset);
- game_graphic_draw_area (port->graphic, cr, &rect2);
+ game_graphic_draw (port->graphic, cr);
}
static void