[gnome-games] aisleriot: Use gdk_window_create_similar_surface
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] aisleriot: Use gdk_window_create_similar_surface
- Date: Fri, 13 Aug 2010 11:42:23 +0000 (UTC)
commit 539f80aed981d1b6b7efe83bec771739db973d24
Author: Christian Persch <chpe gnome org>
Date: Fri Aug 13 13:38:26 2010 +0200
aisleriot: Use gdk_window_create_similar_surface
... when creating the card surface.
aisleriot/board-noclutter.c | 18 ++++++++--------
aisleriot/lib/ar-card-surface-cache.c | 34 +++++++++++++++++++++++++++++++-
aisleriot/lib/ar-card-surface-cache.h | 3 ++
3 files changed, 44 insertions(+), 11 deletions(-)
---
diff --git a/aisleriot/board-noclutter.c b/aisleriot/board-noclutter.c
index 6a31703..6482d89 100644
--- a/aisleriot/board-noclutter.c
+++ b/aisleriot/board-noclutter.c
@@ -2413,17 +2413,19 @@ static void
aisleriot_board_realize (GtkWidget *widget)
{
AisleriotBoard *board = AISLERIOT_BOARD (widget);
+ AisleriotBoardPrivate *priv = board->priv;
+ GdkWindow *window;
GTK_WIDGET_CLASS (aisleriot_board_parent_class)->realize (widget);
-#ifndef CAIRO_DRAWING
+ window = gtk_widget_get_window (widget);
+
+#ifdef CAIRO_DRAWING
+ ar_card_surface_cache_set_drawable (priv->card_cache, window);
+#else
{
- AisleriotBoardPrivate *priv = board->priv;
- GdkWindow *window;
GdkColor baize_color;
- window = gtk_widget_get_window (widget);
-
ar_card_images_set_drawable (priv->images, window);
priv->draw_gc = gdk_gc_new (window);
@@ -2439,11 +2441,8 @@ aisleriot_board_realize (GtkWidget *widget)
#ifndef HAVE_HILDON
{
- AisleriotBoardPrivate *priv = board->priv;
- GdkWindow *window;
GdkDisplay *display;
- window = gtk_widget_get_window (widget);
display = gtk_widget_get_display (widget);
/* Create cursors */
@@ -2469,6 +2468,7 @@ aisleriot_board_unrealize (GtkWidget *widget)
priv->geometry_set = FALSE;
#ifdef CAIRO_DRAWING
+ ar_card_surface_cache_set_drawable (priv->card_cache, NULL);
priv->slot_surface = NULL;
#else
g_object_unref (priv->draw_gc);
@@ -2478,7 +2478,7 @@ aisleriot_board_unrealize (GtkWidget *widget)
g_object_unref (priv->slot_gc);
priv->slot_gc = NULL;
- ar_card_images_set_drawable (priv, NULL);
+ ar_card_images_set_drawable (priv->images, NULL);
priv->slot_image = NULL;
#endif
diff --git a/aisleriot/lib/ar-card-surface-cache.c b/aisleriot/lib/ar-card-surface-cache.c
index bfb666a..22d0c36 100644
--- a/aisleriot/lib/ar-card-surface-cache.c
+++ b/aisleriot/lib/ar-card-surface-cache.c
@@ -19,6 +19,7 @@
#include <config.h>
#include <libgames-support/games-debug.h>
+#include <gdk/gdk.h>
#include "ar-card-surface-cache.h"
#include "ar-card-private.h"
@@ -28,6 +29,7 @@ struct _ArCardSurfaceCachePrivate
ArCardTheme *theme;
guint theme_changed_id;
+ GdkWindow *drawable;
cairo_surface_t **cards;
#ifdef GNOME_ENABLE_DEBUG
@@ -216,6 +218,24 @@ ar_card_surface_cache_new (void)
}
/**
+ * ar_card_surface_cache_set_drawable:
+ * @cache:
+ * @drawable:
+ *
+ */
+void
+ar_card_surface_cache_set_drawable (ArCardSurfaceCache *cache,
+ /* GdkWindow* */ gpointer drawable)
+{
+ ArCardSurfaceCachePrivate * priv = cache->priv;
+
+ if (priv->drawable != drawable)
+ ar_card_surface_cache_drop (cache);
+
+ priv->drawable = drawable;
+}
+
+/**
* ar_card_surface_cache_drop:
* @images: a #ArCardImages
*
@@ -309,8 +329,18 @@ ar_card_surface_cache_get_card_surface_by_id (ArCardSurfaceCache *cache,
ar_card_theme_get_size (priv->theme, &card_size);
- surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
- card_size.width, card_size.height);
+#if GTK_CHECK_VERSION (2, 21, 6)
+ if (priv->drawable) {
+ surface = gdk_window_create_similar_surface (priv->drawable, CAIRO_CONTENT_COLOR_ALPHA,
+ card_size.width, card_size.height);
+ } else
+#else
+ {
+ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
+ card_size.width, card_size.height);
+ }
+#endif /* GTK 2.21.6 */
+
cr = cairo_create (surface);
ar_card_theme_paint_card (priv->theme, cr, card_id);
cairo_destroy (cr);
diff --git a/aisleriot/lib/ar-card-surface-cache.h b/aisleriot/lib/ar-card-surface-cache.h
index 3e14f6d..95b4b3b 100644
--- a/aisleriot/lib/ar-card-surface-cache.h
+++ b/aisleriot/lib/ar-card-surface-cache.h
@@ -54,6 +54,9 @@ GType ar_card_surface_cache_get_type (void);
ArCardSurfaceCache *ar_card_surface_cache_new (void);
+void ar_card_surface_cache_set_drawable (ArCardSurfaceCache *cache,
+ /* GdkWindow* */ gpointer drawable);
+
void ar_card_surface_cache_drop (ArCardSurfaceCache *cache);
void ar_card_surface_cache_set_theme (ArCardSurfaceCache *cache,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]