[clutter/master-next: 1/43] Deprecate ClutterCairoTexture



commit 1ec5d55f0ac95d99bc2d646aa21a8afc3b0a1a55
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Tue Apr 17 18:40:43 2012 +0100

    Deprecate ClutterCairoTexture
    
    The ClutterCanvas content implementation should be used instead, to
    avoid stringing along the ClutterTexture API and implementation.
    
    This change requires some minor surgery, as the deprecated section
    already contains an header for the previously deprecated methods; plus,
    we don't want to deprecate clutter_cairo_set_source_color(). This means
    creating a new header to be used for Cairo-related API.

 clutter/Makefile.am                              |    5 +-
 clutter/clutter-cairo-texture.h                  |  119 ----------------------
 clutter/clutter-cairo.c                          |   63 ++++++++++++
 clutter/clutter-cairo.h                          |   59 +++++++++++
 clutter/clutter-canvas.c                         |    1 +
 clutter/clutter-macros.h                         |   20 ----
 clutter/clutter-stage.c                          |    2 +-
 clutter/clutter.h                                |    2 +-
 clutter/clutter.symbols                          |    1 +
 clutter/{ => deprecated}/clutter-cairo-texture.c |   69 +++++--------
 clutter/deprecated/clutter-cairo-texture.h       |   94 +++++++++++++++++-
 11 files changed, 248 insertions(+), 187 deletions(-)
---
diff --git a/clutter/Makefile.am b/clutter/Makefile.am
index 5a19556..8679249 100644
--- a/clutter/Makefile.am
+++ b/clutter/Makefile.am
@@ -64,7 +64,7 @@ source_h =					\
 	$(srcdir)/clutter-blur-effect.h		\
 	$(srcdir)/clutter-box-layout.h		\
 	$(srcdir)/clutter-brightness-contrast-effect.h	\
-	$(srcdir)/clutter-cairo-texture.h	\
+	$(srcdir)/clutter-cairo.h		\
 	$(srcdir)/clutter-canvas.h		\
 	$(srcdir)/clutter-child-meta.h		\
 	$(srcdir)/clutter-click-action.h	\
@@ -145,7 +145,7 @@ source_c = \
 	$(srcdir)/clutter-blur-effect.c		\
 	$(srcdir)/clutter-box-layout.c		\
 	$(srcdir)/clutter-brightness-contrast-effect.c	\
-	$(srcdir)/clutter-cairo-texture.c       \
+	$(srcdir)/clutter-cairo.c		\
 	$(srcdir)/clutter-canvas.c		\
 	$(srcdir)/clutter-child-meta.c		\
 	$(srcdir)/clutter-click-action.c	\
@@ -288,6 +288,7 @@ deprecated_c = \
 	$(srcdir)/deprecated/clutter-behaviour-rotate.c		\
 	$(srcdir)/deprecated/clutter-behaviour-scale.c		\
 	$(srcdir)/deprecated/clutter-box.c			\
+	$(srcdir)/deprecated/clutter-cairo-texture.c		\
 	$(srcdir)/deprecated/clutter-fixed.c			\
 	$(srcdir)/deprecated/clutter-frame-source.c		\
 	$(srcdir)/deprecated/clutter-group.c 			\
diff --git a/clutter/clutter-cairo.c b/clutter/clutter-cairo.c
new file mode 100644
index 0000000..985999b
--- /dev/null
+++ b/clutter/clutter-cairo.c
@@ -0,0 +1,63 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "clutter-cairo.h"
+#include "clutter-color.h"
+
+/**
+ * clutter_cairo_set_source_color:
+ * @cr: a Cairo context
+ * @color: a #ClutterColor
+ *
+ * Utility function for setting the source color of @cr using
+ * a #ClutterColor. This function is the equivalent of:
+ *
+ * |[
+ *   cairo_set_source_rgba (cr,
+ *                          color->red / 255.0,
+ *                          color->green / 255.0,
+ *                          color->blue / 255.0,
+ *                          color->alpha / 255.0);
+ * ]|
+ *
+ * Since: 1.0
+ */
+void
+clutter_cairo_set_source_color (cairo_t            *cr,
+                                const ClutterColor *color)
+{
+  g_return_if_fail (cr != NULL);
+  g_return_if_fail (color != NULL);
+
+  if (color->alpha == 0xff)
+    cairo_set_source_rgb (cr,
+                          color->red / 255.0,
+                          color->green / 255.0,
+                          color->blue / 255.0);
+  else
+    cairo_set_source_rgba (cr,
+                           color->red / 255.0,
+                           color->green / 255.0,
+                           color->blue / 255.0,
+                           color->alpha / 255.0);
+}
+
+/**
+ * clutter_cairo_clear:
+ * @cr: a Cairo context
+ *
+ * Utility function to clear a Cairo context.
+ *
+ * Since: 1.12
+ */
+void
+clutter_cairo_clear (cairo_t *cr)
+{
+  cairo_save (cr);
+
+  cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
+  cairo_paint (cr);
+
+  cairo_restore (cr);
+}
diff --git a/clutter/clutter-cairo.h b/clutter/clutter-cairo.h
new file mode 100644
index 0000000..f6bd9d8
--- /dev/null
+++ b/clutter/clutter-cairo.h
@@ -0,0 +1,59 @@
+/*
+ * Clutter.
+ *
+ * An OpenGL based 'interactive canvas' library.
+ *
+ * Copyright (C) 2012 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
+#error "Only <clutter/clutter.h> can be included directly."
+#endif
+
+#ifndef __CLUTTER_CAIRO_H__
+#define __CLUTTER_CAIRO_H__
+
+#include <clutter/clutter-types.h>
+
+G_BEGIN_DECLS
+
+/**
+ * CLUTTER_CAIRO_FORMAT_ARGB32:
+ *
+ * The #CoglPixelFormat to be used when uploading image data from
+ * and to a Cairo image surface using %CAIRO_FORMAT_ARGB32 and
+ * %CAIRO_FORMAT_RGB24 as #cairo_format_t.
+ *
+ * Since: 1.8
+ */
+
+/* Cairo stores the data in native byte order as ARGB but Cogl's pixel
+ * formats specify the actual byte order. Therefore we need to use a
+ * different format depending on the architecture
+ */
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+#define CLUTTER_CAIRO_FORMAT_ARGB32     (COGL_PIXEL_FORMAT_BGRA_8888_PRE)
+#else
+#define CLUTTER_CAIRO_FORMAT_ARGB32     (COGL_PIXEL_FORMAT_ARGB_8888_PRE)
+#endif
+
+void    clutter_cairo_clear             (cairo_t               *cr);
+void    clutter_cairo_set_source_color  (cairo_t               *cr,
+                                         const ClutterColor    *color);
+
+G_END_DECLS
+
+#endif /* __CLUTTER_CAIRO_H__ */
diff --git a/clutter/clutter-canvas.c b/clutter/clutter-canvas.c
index b77af55..4e6e766 100644
--- a/clutter/clutter-canvas.c
+++ b/clutter/clutter-canvas.c
@@ -59,6 +59,7 @@
 #define CLUTTER_ENABLE_EXPERIMENTAL_API
 
 #include "clutter-backend.h"
+#include "clutter-cairo.h"
 #include "clutter-color.h"
 #include "clutter-content-private.h"
 #include "clutter-marshal.h"
diff --git a/clutter/clutter-macros.h b/clutter/clutter-macros.h
index dd8033d..82a1c9e 100644
--- a/clutter/clutter-macros.h
+++ b/clutter/clutter-macros.h
@@ -262,24 +262,4 @@
 # define CLUTTER_AVAILABLE_IN_1_12
 #endif
 
-/**
- * CLUTTER_CAIRO_FORMAT_ARGB32:
- *
- * The #CoglPixelFormat to be used when uploading image data from
- * and to a Cairo image surface using %CAIRO_FORMAT_ARGB32 and
- * %CAIRO_FORMAT_RGB24 as #cairo_format_t.
- *
- * Since: 1.8
- */
-
-/* Cairo stores the data in native byte order as ARGB but Cogl's pixel
- * formats specify the actual byte order. Therefore we need to use a
- * different format depending on the architecture
- */
-#if G_BYTE_ORDER == G_LITTLE_ENDIAN
-#define CLUTTER_CAIRO_FORMAT_ARGB32     (COGL_PIXEL_FORMAT_BGRA_8888_PRE)
-#else
-#define CLUTTER_CAIRO_FORMAT_ARGB32     (COGL_PIXEL_FORMAT_ARGB_8888_PRE)
-#endif
-
 #endif /* __CLUTTER_MACROS_H__ */
diff --git a/clutter/clutter-stage.c b/clutter/clutter-stage.c
index 7ea13b5..ae63be0 100644
--- a/clutter/clutter-stage.c
+++ b/clutter/clutter-stage.c
@@ -59,7 +59,7 @@
 
 #include "clutter-actor-private.h"
 #include "clutter-backend-private.h"
-#include "clutter-cairo-texture.h"
+#include "clutter-cairo.h"
 #include "clutter-color.h"
 #include "clutter-container.h"
 #include "clutter-debug.h"
diff --git a/clutter/clutter.h b/clutter/clutter.h
index 1419df9..32a3739 100644
--- a/clutter/clutter.h
+++ b/clutter/clutter.h
@@ -46,7 +46,7 @@
 #include "clutter-blur-effect.h"
 #include "clutter-box-layout.h"
 #include "clutter-brightness-contrast-effect.h"
-#include "clutter-cairo-texture.h"
+#include "clutter-cairo.h"
 #include "clutter-canvas.h"
 #include "clutter-child-meta.h"
 #include "clutter-click-action.h"
diff --git a/clutter/clutter.symbols b/clutter/clutter.symbols
index 6da9a4b..418db41 100644
--- a/clutter/clutter.symbols
+++ b/clutter/clutter.symbols
@@ -494,6 +494,7 @@ clutter_brightness_contrast_effect_set_contrast
 clutter_canvas_get_type
 clutter_canvas_new
 clutter_canvas_set_size
+clutter_cairo_clear
 clutter_cairo_set_source_color
 clutter_cairo_texture_clear
 clutter_cairo_texture_create
diff --git a/clutter/clutter-cairo-texture.c b/clutter/deprecated/clutter-cairo-texture.c
similarity index 96%
rename from clutter/clutter-cairo-texture.c
rename to clutter/deprecated/clutter-cairo-texture.c
index c1c31e7..deacf77 100644
--- a/clutter/clutter-cairo-texture.c
+++ b/clutter/deprecated/clutter-cairo-texture.c
@@ -61,6 +61,8 @@
  * </example>
  *
  * #ClutterCairoTexture is available since Clutter 1.0.
+ *
+ * #ClutterCairoTexture is deprecated since Clutter 1.12.
  */
 
 #ifdef HAVE_CONFIG_H
@@ -74,6 +76,7 @@
 #include "clutter-cairo-texture.h"
 
 #include "clutter-actor-private.h"
+#include "clutter-cairo.h"
 #include "clutter-color.h"
 #include "clutter-debug.h"
 #include "clutter-marshal.h"
@@ -585,6 +588,8 @@ clutter_cairo_texture_class_init (ClutterCairoTextureClass *klass)
    * actor, in pixels.
    *
    * Since: 1.0
+   *
+   * Deprecated: 1.12
    */
   obj_props[PROP_SURFACE_WIDTH] =
     g_param_spec_uint ("surface-width",
@@ -592,7 +597,8 @@ clutter_cairo_texture_class_init (ClutterCairoTextureClass *klass)
                        P_("The width of the Cairo surface"),
                        0, G_MAXUINT,
                        0,
-                       CLUTTER_PARAM_READWRITE);
+                       CLUTTER_PARAM_READWRITE |
+                       G_PARAM_DEPRECATED);
   /**
    * ClutterCairoTexture:surface-height:
    *
@@ -600,6 +606,8 @@ clutter_cairo_texture_class_init (ClutterCairoTextureClass *klass)
    * actor, in pixels.
    *
    * Since: 1.0
+   *
+   * Deprecated: 1.12
    */
   obj_props[PROP_SURFACE_HEIGHT] =
     g_param_spec_uint ("surface-height",
@@ -607,7 +615,8 @@ clutter_cairo_texture_class_init (ClutterCairoTextureClass *klass)
                        P_("The height of the Cairo surface"),
                        0, G_MAXUINT,
                        0,
-                       CLUTTER_PARAM_READWRITE);
+                       CLUTTER_PARAM_READWRITE |
+                       G_PARAM_DEPRECATED);
 
   /**
    * ClutterCairoTexture:auto-resize:
@@ -618,13 +627,16 @@ clutter_cairo_texture_class_init (ClutterCairoTextureClass *klass)
    * be invalidated automatically.
    *
    * Since: 1.8
+   *
+   * Deprecated: 1.12
    */
   obj_props[PROP_AUTO_RESIZE] =
     g_param_spec_boolean ("auto-resize",
                           P_("Auto Resize"),
                           P_("Whether the surface should match the allocation"),
                           FALSE,
-                          CLUTTER_PARAM_READWRITE);
+                          CLUTTER_PARAM_READWRITE |
+                          G_PARAM_DEPRECATED);
 
   g_object_class_install_properties (gobject_class, PROP_LAST, obj_props);
 
@@ -647,6 +659,8 @@ clutter_cairo_texture_class_init (ClutterCairoTextureClass *klass)
    * Return value: the newly created #cairo_surface_t for the texture
    *
    * Since: 1.6
+   *
+   * Deprecated: 1.12
    */
   cairo_signals[CREATE_SURFACE] =
     g_signal_new (I_("create-surface"),
@@ -679,6 +693,8 @@ clutter_cairo_texture_class_init (ClutterCairoTextureClass *klass)
    *   to continue
    *
    * Since: 1.8
+   *
+   * Deprecated: 1.12
    */
   cairo_signals[DRAW] =
     g_signal_new (I_("draw"),
@@ -726,6 +742,8 @@ clutter_cairo_texture_init (ClutterCairoTexture *self)
  * Return value: the newly created #ClutterCairoTexture actor
  *
  * Since: 1.0
+ *
+ * Deprecated: 1.12: Use #ClutterCanvas instead
  */
 ClutterActor*
 clutter_cairo_texture_new (guint width,
@@ -875,6 +893,7 @@ clutter_cairo_texture_create_region (ClutterCairoTexture *self,
  * See also: clutter_cairo_texture_invalidate()
  *
  * Since: 1.8
+ * Deprecated: 1.12: Use #ClutterCanvas instead
  */
 void
 clutter_cairo_texture_invalidate_rectangle (ClutterCairoTexture   *self,
@@ -934,6 +953,7 @@ clutter_cairo_texture_invalidate_rectangle (ClutterCairoTexture   *self,
  * See also: clutter_cairo_texture_invalidate_rectangle()
  *
  * Since: 1.8
+ * Deprecated: 1.12: Use #ClutterCanvas instead
  */
 void
 clutter_cairo_texture_invalidate (ClutterCairoTexture *self)
@@ -976,44 +996,6 @@ clutter_cairo_texture_create (ClutterCairoTexture *self)
 }
 
 /**
- * clutter_cairo_set_source_color:
- * @cr: a Cairo context
- * @color: a #ClutterColor
- *
- * Utility function for setting the source color of @cr using
- * a #ClutterColor. This function is the equivalent of:
- *
- * |[
- *   cairo_set_source_rgba (cr,
- *                          color->red / 255.0,
- *                          color->green / 255.0,
- *                          color->blue / 255.0,
- *                          color->alpha / 255.0);
- * ]|
- *
- * Since: 1.0
- */
-void
-clutter_cairo_set_source_color (cairo_t            *cr,
-                                const ClutterColor *color)
-{
-  g_return_if_fail (cr != NULL);
-  g_return_if_fail (color != NULL);
-
-  if (color->alpha == 0xff)
-    cairo_set_source_rgb (cr,
-                          color->red / 255.0,
-                          color->green / 255.0,
-                          color->blue / 255.0);
-  else
-    cairo_set_source_rgba (cr,
-                           color->red / 255.0,
-                           color->green / 255.0,
-                           color->blue / 255.0,
-                           color->alpha / 255.0);
-}
-
-/**
  * clutter_cairo_texture_set_surface_size:
  * @self: a #ClutterCairoTexture
  * @width: the new width of the surface
@@ -1027,6 +1009,7 @@ clutter_cairo_set_source_color (cairo_t            *cr,
  * clutter_cairo_texture_invalidate().
  *
  * Since: 1.0
+ * Deprecated: 1.12: Use #ClutterCanvas instead
  */
 void
 clutter_cairo_texture_set_surface_size (ClutterCairoTexture *self,
@@ -1071,6 +1054,7 @@ clutter_cairo_texture_set_surface_size (ClutterCairoTexture *self,
  * Retrieves the surface width and height for @self.
  *
  * Since: 1.0
+ * Deprecated: 1.12: Use #ClutterCanvas instead
  */
 void
 clutter_cairo_texture_get_surface_size (ClutterCairoTexture *self,
@@ -1098,6 +1082,7 @@ clutter_cairo_texture_get_surface_size (ClutterCairoTexture *self,
  * signal handler will clear the invalidated area.
  *
  * Since: 1.0
+ * Deprecated: 1.12: Use #ClutterCanvas instead
  */
 void
 clutter_cairo_texture_clear (ClutterCairoTexture *self)
@@ -1148,6 +1133,7 @@ clutter_cairo_texture_clear (ClutterCairoTexture *self)
  * #ClutterCairoTexture will also be invalidated automatically.
  *
  * Since: 1.8
+ * Deprecated: 1.12: Use #ClutterCanvas instead
  */
 void
 clutter_cairo_texture_set_auto_resize (ClutterCairoTexture *self,
@@ -1181,6 +1167,7 @@ clutter_cairo_texture_set_auto_resize (ClutterCairoTexture *self,
  *   allocation, and %FALSE otherwise
  *
  * Since: 1.8
+ * Deprecated: 1.12: Use #ClutterCanvas instead
  */
 gboolean
 clutter_cairo_texture_get_auto_resize (ClutterCairoTexture *self)
diff --git a/clutter/deprecated/clutter-cairo-texture.h b/clutter/deprecated/clutter-cairo-texture.h
index 46c0f20..63b6158 100644
--- a/clutter/deprecated/clutter-cairo-texture.h
+++ b/clutter/deprecated/clutter-cairo-texture.h
@@ -29,13 +29,101 @@
 #error "Only <clutter/clutter.h> can be included directly."
 #endif
 
-#ifndef __CLUTTER_CAIRO_TEXTURE_DEPRECATED_H__
-#define __CLUTTER_CAIRO_TEXTURE_DEPRECATED_H__
+#ifndef __CLUTTER_CAIRO_TEXTURE_H__
+#define __CLUTTER_CAIRO_TEXTURE_H__
 
-#include <clutter/clutter-cairo-texture.h>
+#include <clutter/clutter-texture.h>
 
 G_BEGIN_DECLS
 
+#define CLUTTER_TYPE_CAIRO_TEXTURE              (clutter_cairo_texture_get_type ())
+#define CLUTTER_CAIRO_TEXTURE(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_CAIRO_TEXTURE, ClutterCairoTexture))
+#define CLUTTER_CAIRO_TEXTURE_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_CAIRO_TEXTURE, ClutterCairoTextureClass))
+#define CLUTTER_IS_CAIRO_TEXTURE(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_CAIRO_TEXTURE))
+#define CLUTTER_IS_CAIRO_TEXTURE_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_CAIRO_TEXTURE))
+#define CLUTTER_CAIRO_TEXTURE_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_CAIRO_TEXTURE, ClutterCairoTextureClass))
+
+typedef struct _ClutterCairoTexture             ClutterCairoTexture;
+typedef struct _ClutterCairoTextureClass        ClutterCairoTextureClass;
+typedef struct _ClutterCairoTexturePrivate      ClutterCairoTexturePrivate;
+
+/**
+ * ClutterCairoTexture:
+ *
+ * The #ClutterCairoTexture struct contains only private data.
+ *
+ * Since: 1.0
+ *
+ * Deprecated: 1.12: Use #ClutterCanvas instead
+ */
+struct _ClutterCairoTexture
+{
+  /*< private >*/
+  ClutterTexture parent_instance;
+
+  ClutterCairoTexturePrivate *priv;
+};
+
+/**
+ * ClutterCairoTextureClass:
+ * @create_surface: class handler for the #ClutterCairoTexture::create-surface
+ *   signal
+ * @draw: class handler for the #ClutterCairoTexture::draw signal
+ *
+ * The #ClutterCairoTextureClass struct contains only private data.
+ *
+ * Since: 1.0
+ *
+ * Deprecated: 1.12: Use #ClutterCanvas instead
+ */
+struct _ClutterCairoTextureClass
+{
+  /*< private >*/
+  ClutterTextureClass parent_class;
+
+  /*< public >*/
+  cairo_surface_t *(* create_surface) (ClutterCairoTexture *texture,
+                                       guint                width,
+                                       guint                height);
+
+  gboolean         (* draw)           (ClutterCairoTexture *texture,
+                                       cairo_t             *cr);
+
+  /*< private >*/
+  void (*_clutter_cairo_3) (void);
+  void (*_clutter_cairo_4) (void);
+};
+
+CLUTTER_DEPRECATED_IN_1_12_FOR(clutter_canvas_get_type)
+GType clutter_cairo_texture_get_type (void) G_GNUC_CONST;
+
+CLUTTER_DEPRECATED_IN_1_12_FOR(clutter_canvas_new)
+ClutterActor *  clutter_cairo_texture_new                       (guint                  width,
+                                                                 guint                  height);
+
+CLUTTER_DEPRECATED_IN_1_12_FOR(clutter_canvas_set_size)
+void            clutter_cairo_texture_set_surface_size          (ClutterCairoTexture   *self,
+                                                                 guint                  width,
+                                                                 guint                  height);
+CLUTTER_DEPRECATED_IN_1_12_FOR(clutter_canvas_get_size)
+void            clutter_cairo_texture_get_surface_size          (ClutterCairoTexture   *self,
+                                                                 guint                 *width,
+                                                                 guint                 *height);
+CLUTTER_DEPRECATED_IN_1_12
+void            clutter_cairo_texture_set_auto_resize           (ClutterCairoTexture   *self,
+                                                                 gboolean               value);
+CLUTTER_DEPRECATED_IN_1_12
+gboolean        clutter_cairo_texture_get_auto_resize           (ClutterCairoTexture   *self);
+
+CLUTTER_DEPRECATED_IN_1_12
+void            clutter_cairo_texture_clear                     (ClutterCairoTexture   *self);
+
+CLUTTER_DEPRECATED_IN_1_12
+void            clutter_cairo_texture_invalidate_rectangle      (ClutterCairoTexture   *self,
+                                                                 cairo_rectangle_int_t *rect);
+CLUTTER_DEPRECATED_IN_1_12
+void            clutter_cairo_texture_invalidate                (ClutterCairoTexture   *self);
+
 CLUTTER_DEPRECATED_IN_1_8_FOR(clutter_cairo_texture_invalidate_rectangle)
 cairo_t *       clutter_cairo_texture_create_region             (ClutterCairoTexture   *self,
                                                                  gint                   x_offset,



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