[clutter] Pass context to cogl_texture_pixmap_x11_new() api



commit eff95eba4a2e15124eb38a3d1984c6725efcbe4d
Author: Robert Bragg <robert linux intel com>
Date:   Tue Feb 21 14:23:44 2012 +0000

    Pass context to cogl_texture_pixmap_x11_new() api
    
    The experimental cogl_texture_pixmap_x11_new() api was recently changed
    to take an explicit context argument and return a GError on failures.
    This updates Clutter's use of the api accordingly.

 clutter/x11/clutter-x11-texture-pixmap.c     |   26 ++++++++++++++++++++------
 tests/conform/test-cogl-texture-pixmap-x11.c |    7 ++++++-
 2 files changed, 26 insertions(+), 7 deletions(-)
---
diff --git a/clutter/x11/clutter-x11-texture-pixmap.c b/clutter/x11/clutter-x11-texture-pixmap.c
index dd41c62..975d1f2 100644
--- a/clutter/x11/clutter-x11-texture-pixmap.c
+++ b/clutter/x11/clutter-x11-texture-pixmap.c
@@ -42,6 +42,8 @@
 #include "config.h"
 #endif
 
+#define CLUTTER_ENABLE_EXPERIMENTAL_API
+
 #include "clutter-x11-texture-pixmap.h"
 #include "clutter-x11.h"
 #include "clutter-backend-x11.h"
@@ -806,7 +808,6 @@ clutter_x11_texture_pixmap_set_pixmap (ClutterX11TexturePixmap *texture,
   gboolean     new_pixmap = FALSE, new_pixmap_width = FALSE;
   gboolean     new_pixmap_height = FALSE, new_pixmap_depth = FALSE;
   CoglHandle   material;
-  CoglHandle   cogl_texture;
 
   ClutterX11TexturePixmapPrivate *priv;
 
@@ -897,11 +898,24 @@ clutter_x11_texture_pixmap_set_pixmap (ClutterX11TexturePixmap *texture,
 
   if (pixmap)
     {
-      cogl_texture = cogl_texture_pixmap_x11_new (pixmap, FALSE);
-      clutter_texture_set_cogl_texture (CLUTTER_TEXTURE (texture),
-                                        cogl_texture);
-      cogl_handle_unref (cogl_texture);
-      update_pixmap_damage_object (texture);
+      CoglContext *ctx =
+        clutter_backend_get_cogl_context (clutter_get_default_backend ());
+      GError *error = NULL;
+      CoglTexturePixmapX11 *texture_pixmap =
+        cogl_texture_pixmap_x11_new (ctx, pixmap, FALSE, &error);
+      if (texture_pixmap)
+        {
+          clutter_texture_set_cogl_texture (CLUTTER_TEXTURE (texture),
+                                            COGL_TEXTURE (texture_pixmap));
+          cogl_object_unref (texture_pixmap);
+          update_pixmap_damage_object (texture);
+        }
+      else
+        {
+          g_warning ("Failed to create CoglTexturePixmapX11: %s",
+                     error->message);
+          g_error_free (error);
+        }
     }
 
   /*
diff --git a/tests/conform/test-cogl-texture-pixmap-x11.c b/tests/conform/test-cogl-texture-pixmap-x11.c
index b04e6bc..1af92d1 100644
--- a/tests/conform/test-cogl-texture-pixmap-x11.c
+++ b/tests/conform/test-cogl-texture-pixmap-x11.c
@@ -1,3 +1,6 @@
+#include <cogl/cogl.h>
+
+#define CLUTTER_ENABLE_EXPERIMENTAL_API
 #include <clutter/clutter.h>
 
 #include "test-conform-common.h"
@@ -207,6 +210,8 @@ test_cogl_texture_pixmap_x11 (TestConformSimpleFixture *fixture,
       TestState state;
       guint idle_handler;
       guint paint_handler;
+      CoglContext *ctx =
+        clutter_backend_get_cogl_context (clutter_get_default_backend ());
 
       state.frame_count = 0;
       state.stage = clutter_stage_new ();
@@ -214,7 +219,7 @@ test_cogl_texture_pixmap_x11 (TestConformSimpleFixture *fixture,
       state.display = clutter_x11_get_default_display ();
 
       state.pixmap = create_pixmap (&state);
-      state.tfp = cogl_texture_pixmap_x11_new (state.pixmap, TRUE);
+      state.tfp = cogl_texture_pixmap_x11_new (ctx, state.pixmap, TRUE, NULL);
 
       clutter_stage_set_color (CLUTTER_STAGE (state.stage), &stage_color);
 



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