diff options
author | Benjamin Otte <otte@gnome.org> | 2006-05-18 22:38:05 +0000 |
---|---|---|
committer | Benjamin Otte <otte@gnome.org> | 2006-05-18 22:38:05 +0000 |
commit | 86259e9cc1ae001e58ff096c7504a331e87400d5 (patch) | |
tree | 9b842a4f9dd7c35d2cae07bdf24418beece1b961 | |
parent | fff434e15c269363fd03b55017d850764f262c77 (diff) |
* games/pacman/game-custom-graphic.c: (game_custom_graphic_draw),
(game_custom_graphic_class_init):
* games/pacman/game-custom-graphic.h:
remove caching code, now that GameGraphic does it itself
* games/pacman/pacman-graphic.c: (pacman_graphic_set_property):
set caching policy based on wether the graphic is animated
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | games/pacman/game-custom-graphic.c | 44 | ||||
-rw-r--r-- | games/pacman/game-custom-graphic.h | 5 | ||||
-rw-r--r-- | games/pacman/pacman-graphic.c | 2 |
4 files changed, 12 insertions, 48 deletions
@@ -1,5 +1,14 @@ 2006-05-19 Benjamin Otte <in7y118@public.uni-hamburg.de> + * games/pacman/game-custom-graphic.c: (game_custom_graphic_draw), + (game_custom_graphic_class_init): + * games/pacman/game-custom-graphic.h: + remove caching code, now that GameGraphic does it itself + * games/pacman/pacman-graphic.c: (pacman_graphic_set_property): + set caching policy based on wether the graphic is animated + +2006-05-19 Benjamin Otte <in7y118@public.uni-hamburg.de> + * libgame/game-graphic.c: (game_graphic_invalidate_area), (game_graphic_invalidate_cache), (game_graphic_do_draw_area), (game_graphic_draw), (game_graphic_draw_area), diff --git a/games/pacman/game-custom-graphic.c b/games/pacman/game-custom-graphic.c index 8225052..5c81824 100644 --- a/games/pacman/game-custom-graphic.c +++ b/games/pacman/game-custom-graphic.c @@ -25,62 +25,20 @@ static GameGraphicClass *parent_class = NULL; static void -game_custom_graphic_finalize (GObject *object) -{ - GameCustomGraphic *custom_graphic = GAME_CUSTOM_GRAPHIC (object); - - if (custom_graphic->surface) - cairo_surface_destroy (custom_graphic->surface); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static void game_custom_graphic_draw (GameGraphic *graphic, cairo_t *cr, const GameRectangle *area) { GameCustomGraphic *custom = GAME_CUSTOM_GRAPHIC (graphic); - double width = 1.0, height = 1.0; - cairo_matrix_t matrix; - /* FIXME: this is wrong for rotated stuff */ - cairo_get_matrix (cr, &matrix); - cairo_matrix_transform_distance (&matrix, &width, &height); - width = ceil (width); - height = ceil (height); - if (!custom->surface || - (guint) width != custom->width || - (guint) height != custom->height) { - cairo_t *crs; - g_return_if_fail (custom->draw); - - if (custom->surface) - cairo_surface_destroy (custom->surface); - custom->surface = cairo_surface_create_similar (cairo_get_target (cr), - CAIRO_CONTENT_COLOR_ALPHA, width, height); - crs = cairo_create (custom->surface); - cairo_scale (crs, width, height); - custom->draw (custom, crs); - cairo_destroy (crs); - custom->width = width; - custom->height = height; - } - cairo_scale (cr, 1.0 / custom->width, 1.0 / custom->height); - cairo_set_source_surface (cr, custom->surface, 0, 0); - cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT); - cairo_rectangle (cr, 0, 0, custom->width, custom->height); - cairo_fill (cr); + custom->draw (custom, cr); } static void game_custom_graphic_class_init (gpointer g_class, gpointer class_data) { - GObjectClass *object_class = G_OBJECT_CLASS (g_class); GameGraphicClass *graphic_class = GAME_GRAPHIC_CLASS (g_class); parent_class = g_type_class_peek_parent (g_class); - object_class->finalize = game_custom_graphic_finalize; - graphic_class->draw = game_custom_graphic_draw; } diff --git a/games/pacman/game-custom-graphic.h b/games/pacman/game-custom-graphic.h index f0aecc6..790ca16 100644 --- a/games/pacman/game-custom-graphic.h +++ b/games/pacman/game-custom-graphic.h @@ -41,11 +41,6 @@ struct _GameCustomGraphic { void (* draw) (GameCustomGraphic * graphic, cairo_t * cr); - - /*< private >*/ - cairo_surface_t * surface; - guint width; - guint height; }; struct _GameCustomGraphicClass { diff --git a/games/pacman/pacman-graphic.c b/games/pacman/pacman-graphic.c index 29bc13f..c785ae0 100644 --- a/games/pacman/pacman-graphic.c +++ b/games/pacman/pacman-graphic.c @@ -114,6 +114,8 @@ pacman_graphic_set_property (GObject *object, guint param_id, break; case PROP_ANIMATE: graphic->animate = g_value_get_boolean (value); + GAME_GRAPHIC (graphic)->cache_policy = graphic->animate ? + GAME_GRAPHIC_CACHE_NEVER : GAME_GRAPHIC_CACHE_ALWAYS; break; case PROP_COLOR: graphic->color = *((GameColor *) g_value_get_boxed (value)); |