update to 1.10.4
[profile/ivi/clutter.git] / clutter / x11 / clutter-glx-texture-pixmap.c
1 /*
2  * Clutter.
3  *
4  * An OpenGL based 'interactive canvas' library.
5  *
6  * Authored By Johan Bilien  <johan.bilien@nokia.com>
7  *             Matthew Allum <mallum@o-hand.com>
8  *             Robert Bragg  <bob@o-hand.com>
9  *             Neil Roberts <neil@linux.intel.com>
10  *
11  * Copyright (C) 2007 OpenedHand
12  * Copyright (C) 2010 Intel Corporation.
13  *
14  * This library is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU Lesser General Public
16  * License as published by the Free Software Foundation; either
17  * version 2 of the License, or (at your option) any later version.
18  *
19  * This library is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22  * Lesser General Public License for more details.
23  *
24  * You should have received a copy of the GNU Lesser General Public
25  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
26  *
27  *
28  */
29
30 /**
31  * SECTION:clutter-glx-texture-pixmap
32  * @Title: ClutterGLXTexturePixmap
33  * @short_description: A texture which displays the content of an X Pixmap
34  * @Deprecated: 1.4: Use #ClutterX11TexturePixmap instead.
35  *
36  * #ClutterGLXTexturePixmap is a class for displaying the content of an
37  * X Pixmap as a ClutterActor. Used together with the X Composite extension,
38  * it allows to display the content of X Windows inside Clutter.
39  *
40  * This class used to be necessary to use the
41  * GLX_EXT_texture_from_pixmap extension to get fast texture
42  * updates. However since Clutter 1.4 the handling of this extension
43  * has moved down to Cogl. ClutterX11TexturePixmap and
44  * ClutterGLXTexturePixmap are now equivalent and either one of them
45  * may use the extension if it is possible.
46  */
47
48 #include "config.h"
49
50 #include <string.h>
51
52 #include "x11/clutter-x11-texture-pixmap.h"
53
54 #include <cogl/cogl-texture-pixmap-x11.h>
55
56 #include "clutter-glx-texture-pixmap.h"
57
58 G_DEFINE_TYPE (ClutterGLXTexturePixmap,    \
59                clutter_glx_texture_pixmap, \
60                CLUTTER_X11_TYPE_TEXTURE_PIXMAP);
61
62 static void
63 clutter_glx_texture_pixmap_init (ClutterGLXTexturePixmap *self)
64 {
65 }
66
67 static void
68 clutter_glx_texture_pixmap_class_init (ClutterGLXTexturePixmapClass *klass)
69 {
70 }
71
72 /**
73  * clutter_glx_texture_pixmap_using_extension:
74  * @texture: A #ClutterGLXTexturePixmap
75  *
76  * Checks whether @texture is using the GLX_EXT_texture_from_pixmap
77  * extension; this extension can be optionally (though it is strongly
78  * encouraged) implemented as a zero-copy between a GLX pixmap and
79  * a GL texture.
80  *
81  * Return value: %TRUE if the texture is using the
82  *   GLX_EXT_texture_from_pixmap OpenGL extension or falling back to the
83  *   slower software mechanism.
84  *
85  * Deprecated: 1.6: Use cogl_texture_pixmap_x11_is_using_tfp_extension()
86  *   on the texture handle instead.
87  *
88  * Since: 0.8
89  */
90 gboolean
91 clutter_glx_texture_pixmap_using_extension (ClutterGLXTexturePixmap *texture)
92 {
93   CoglHandle cogl_texture;
94
95   g_return_val_if_fail (CLUTTER_GLX_IS_TEXTURE_PIXMAP (texture), FALSE);
96
97   cogl_texture = clutter_texture_get_cogl_texture (CLUTTER_TEXTURE (texture));
98
99   return (cogl_is_texture_pixmap_x11 (cogl_texture) &&
100           cogl_texture_pixmap_x11_is_using_tfp_extension (cogl_texture));
101 }
102
103 /**
104  * clutter_glx_texture_pixmap_new_with_pixmap:
105  * @pixmap: the X Pixmap to which this texture should be bound
106  *
107  * Creates a new #ClutterGLXTexturePixmap for @pixmap
108  *
109  * Return value: A new #ClutterGLXTexturePixmap bound to the given X Pixmap
110  *
111  * Since: 0.8
112  *
113  * Deprecated: 1.6: Use clutter_x11_texture_pixmap_new_with_pixmap() instead
114  */
115 ClutterActor *
116 clutter_glx_texture_pixmap_new_with_pixmap (Pixmap pixmap)
117 {
118   return g_object_new (CLUTTER_GLX_TYPE_TEXTURE_PIXMAP,
119                        "pixmap", pixmap,
120                        NULL);
121 }
122
123 /**
124  * clutter_glx_texture_pixmap_new_with_window:
125  * @window: the X window to which this texture should be bound
126  *
127  * Creates a new #ClutterGLXTexturePixmap for @window
128  *
129  * Return value: A new #ClutterGLXTexturePixmap bound to the given X window
130  *
131  * Since: 0.8
132  *
133  * Deprecated: 1.6: Use clutter_x11_texture_pixmap_new_with_window() instead
134  */
135 ClutterActor *
136 clutter_glx_texture_pixmap_new_with_window (Window window)
137 {
138   return g_object_new (CLUTTER_GLX_TYPE_TEXTURE_PIXMAP,
139                        "window", window,
140                        NULL);
141 }
142
143 /**
144  * clutter_glx_texture_pixmap_new:
145  *
146  * Creates a new, empty #ClutterGLXTexturePixmap
147  *
148  * Return value: A new #ClutterGLXTexturePixmap
149  *
150  * Since: 0.8
151  *
152  * Deprecated: 1.6: Use clutter_x11_texture_pixmap_new() instead
153  */
154 ClutterActor *
155 clutter_glx_texture_pixmap_new (void)
156 {
157   return g_object_new (CLUTTER_GLX_TYPE_TEXTURE_PIXMAP, NULL);
158 }