gnome-games r8133 - trunk/aisleriot



Author: jclinton
Date: Tue Oct 21 19:43:39 2008
New Revision: 8133
URL: http://svn.gnome.org/viewvc/gnome-games?rev=8133&view=rev

Log:
Store the textures in the card cache as Cogl textures instead of
Clutter textures.

Modified:
   trunk/aisleriot/card-cache.c
   trunk/aisleriot/card-cache.h

Modified: trunk/aisleriot/card-cache.c
==============================================================================
--- trunk/aisleriot/card-cache.c	(original)
+++ trunk/aisleriot/card-cache.c	Tue Oct 21 19:43:39 2008
@@ -20,7 +20,7 @@
 
 #include <glib-object.h>
 #include <gtk/gtk.h>
-#include <clutter/clutter-texture.h>
+#include <cogl/cogl.h>
 #include <clutter-gtk/gtk-clutter-util.h>
 
 #include <libgames-support/games-card-images.h>
@@ -51,7 +51,7 @@
 
 struct _AisleriotCardCachePrivate
 {
-  ClutterActor **cards;
+  CoglHandle *cards;
   GamesCardImages *card_images;
 
   guint theme_handler;
@@ -199,13 +199,13 @@
   int i;
 
   for (i = 0; i < GAMES_CARDS_TOTAL; i++)
-    if (priv->cards[i]) {
-      g_object_unref (priv->cards[i]);
-      priv->cards[i] = NULL;
+    if (priv->cards[i] != COGL_INVALID_HANDLE) {
+      cogl_texture_unref (priv->cards[i]);
+      priv->cards[i] = COGL_INVALID_HANDLE;
     }
 }
 
-ClutterActor *
+CoglHandle
 aisleriot_card_cache_get_card_texture_by_id (AisleriotCardCache *cache,
                                              guint card_id,
                                              gboolean highlighted)
@@ -224,14 +224,22 @@
   if (highlighted)
     index *= 2;
 
-  if (priv->cards[index] == NULL) {
-    ClutterActor *tex = g_object_ref_sink (clutter_texture_new ());
+  if (priv->cards[index] == COGL_INVALID_HANDLE) {
+    CoglHandle tex;
     GdkPixbuf *pixbuf
       = games_card_images_get_card_pixbuf_by_id (priv->card_images,
                                                  card_id,
                                                  highlighted);
 
-    gtk_clutter_texture_set_from_pixbuf (CLUTTER_TEXTURE (tex), pixbuf);
+    tex = cogl_texture_new_from_data (gdk_pixbuf_get_width (pixbuf),
+                                      gdk_pixbuf_get_height (pixbuf),
+                                      64, FALSE,
+                                      gdk_pixbuf_get_has_alpha (pixbuf)
+                                      ? COGL_PIXEL_FORMAT_RGBA_8888
+                                      : COGL_PIXEL_FORMAT_RGB_888,
+                                      COGL_PIXEL_FORMAT_ANY,
+                                      gdk_pixbuf_get_rowstride (pixbuf),
+                                      gdk_pixbuf_get_pixels (pixbuf));
 
     priv->cards[index] = tex;
   }
@@ -239,7 +247,7 @@
   return priv->cards[index];
 }
 
-ClutterActor *
+CoglHandle
 aisleriot_card_cache_get_card_texture (AisleriotCardCache *cache,
                                        Card card,
                                        gboolean highlighted)

Modified: trunk/aisleriot/card-cache.h
==============================================================================
--- trunk/aisleriot/card-cache.h	(original)
+++ trunk/aisleriot/card-cache.h	Tue Oct 21 19:43:39 2008
@@ -3,6 +3,7 @@
 #define AISLERIOT_CARD_CACHE_H
 
 #include <glib-object.h>
+#include <cogl/cogl.h>
 
 G_BEGIN_DECLS
 
@@ -47,13 +48,13 @@
 
 AisleriotCardCache *aisleriot_card_cache_new (GamesCardImages *images);
 
-ClutterActor *aisleriot_card_cache_get_card_texture (AisleriotCardCache *cache,
-                                                     Card card,
-                                                     gboolean highlighted);
-ClutterActor *aisleriot_card_cache_get_card_texture_by_id
-                                              (AisleriotCardCache *cache,
-                                               guint card_id,
-                                               gboolean highlighted);
+CoglHandle aisleriot_card_cache_get_card_texture (AisleriotCardCache *cache,
+                                                  Card card,
+                                                  gboolean highlighted);
+CoglHandle aisleriot_card_cache_get_card_texture_by_id
+                                                 (AisleriotCardCache *cache,
+                                                  guint card_id,
+                                                  gboolean highlighted);
 
 G_END_DECLS
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]