2008-02-20 12:43:54 +00:00
|
|
|
/*
|
|
|
|
* Clutter.
|
|
|
|
*
|
|
|
|
* An OpenGL based 'interactive canvas' library.
|
|
|
|
*
|
|
|
|
* Authored By Johan Bilien <johan.bilien@nokia.com>
|
2008-04-29 16:30:47 +00:00
|
|
|
* Matthew Allum <mallum@o-hand.com>
|
|
|
|
* Robert Bragg <bob@o-hand.com>
|
2010-05-26 17:06:39 +00:00
|
|
|
* Neil Roberts <neil@linux.intel.com>
|
2008-02-20 12:43:54 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2007 OpenedHand
|
2010-05-26 17:06:39 +00:00
|
|
|
* Copyright (C) 2010 Intel Corporation.
|
2008-02-20 12:43:54 +00:00
|
|
|
*
|
|
|
|
* 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
|
2010-03-01 12:56:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*
|
2008-02-20 12:43:54 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:clutter-glx-texture-pixmap
|
|
|
|
* @short_description: A texture which displays the content of an X Pixmap.
|
|
|
|
*
|
|
|
|
* #ClutterGLXTexturePixmap is a class for displaying the content of an
|
|
|
|
* X Pixmap as a ClutterActor. Used together with the X Composite extension,
|
|
|
|
* it allows to display the content of X Windows inside Clutter.
|
|
|
|
*
|
2010-05-26 17:06:39 +00:00
|
|
|
* This class used to be necessary to use the
|
|
|
|
* GLX_EXT_texture_from_pixmap extension to get fast texture
|
|
|
|
* updates. However since Clutter 1.4 the handling of this extension
|
|
|
|
* has moved down to Cogl. ClutterX11TexturePixmap and
|
|
|
|
* ClutterGLXTexturePixmap are now equivalent and either one of them
|
|
|
|
* may use the extension if it is possible.
|
2008-02-20 12:43:54 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2011-01-20 13:19:03 +00:00
|
|
|
|
2008-12-04 17:24:33 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2011-01-20 13:19:03 +00:00
|
|
|
#include <GL/glx.h>
|
|
|
|
|
|
|
|
#include "x11/clutter-x11-texture-pixmap.h"
|
2011-02-22 15:51:13 +00:00
|
|
|
|
|
|
|
#include <cogl/cogl-texture-pixmap-x11.h>
|
2008-04-29 16:30:47 +00:00
|
|
|
|
2011-06-09 14:28:39 +00:00
|
|
|
#include "clutter-glx-texture-pixmap.h"
|
|
|
|
|
2008-04-15 21:18:13 +00:00
|
|
|
G_DEFINE_TYPE (ClutterGLXTexturePixmap, \
|
|
|
|
clutter_glx_texture_pixmap, \
|
|
|
|
CLUTTER_X11_TYPE_TEXTURE_PIXMAP);
|
2008-02-20 12:43:54 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_glx_texture_pixmap_init (ClutterGLXTexturePixmap *self)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-04-29 16:30:47 +00:00
|
|
|
static void
|
|
|
|
clutter_glx_texture_pixmap_class_init (ClutterGLXTexturePixmapClass *klass)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-05-06 19:57:05 +00:00
|
|
|
/**
|
|
|
|
* clutter_glx_texture_pixmap_using_extension:
|
|
|
|
* @texture: A #ClutterGLXTexturePixmap
|
|
|
|
*
|
2010-03-02 09:53:55 +00:00
|
|
|
* Checks whether @texture is using the GLX_EXT_texture_from_pixmap
|
|
|
|
* extension; this extension can be optionally (though it is strongly
|
|
|
|
* encouraged) implemented as a zero-copy between a GLX pixmap and
|
|
|
|
* a GL texture.
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if the texture is using the
|
|
|
|
* GLX_EXT_texture_from_pixmap OpenGL extension or falling back to the
|
|
|
|
* slower software mechanism.
|
2008-05-06 19:57:05 +00:00
|
|
|
*
|
2011-01-20 13:19:03 +00:00
|
|
|
* Deprecated: 1.6: Use cogl_texture_pixmap_x11_is_using_tfp_extension()
|
|
|
|
* on the texture handle instead.
|
|
|
|
*
|
2008-05-06 19:57:05 +00:00
|
|
|
* Since: 0.8
|
2010-03-02 09:53:55 +00:00
|
|
|
*/
|
2008-05-06 19:57:05 +00:00
|
|
|
gboolean
|
|
|
|
clutter_glx_texture_pixmap_using_extension (ClutterGLXTexturePixmap *texture)
|
|
|
|
{
|
2010-05-26 17:06:39 +00:00
|
|
|
CoglHandle cogl_texture;
|
|
|
|
|
|
|
|
g_return_val_if_fail (CLUTTER_GLX_IS_TEXTURE_PIXMAP (texture), FALSE);
|
2008-05-06 19:57:05 +00:00
|
|
|
|
2010-05-26 17:06:39 +00:00
|
|
|
cogl_texture = clutter_texture_get_cogl_texture (CLUTTER_TEXTURE (texture));
|
2008-05-06 19:57:05 +00:00
|
|
|
|
2010-05-26 17:06:39 +00:00
|
|
|
return (cogl_is_texture_pixmap_x11 (cogl_texture) &&
|
|
|
|
cogl_texture_pixmap_x11_is_using_tfp_extension (cogl_texture));
|
2008-05-06 19:57:05 +00:00
|
|
|
}
|
2008-04-29 16:30:47 +00:00
|
|
|
|
2008-02-20 12:43:54 +00:00
|
|
|
/**
|
|
|
|
* clutter_glx_texture_pixmap_new_with_pixmap:
|
|
|
|
* @pixmap: the X Pixmap to which this texture should be bound
|
|
|
|
*
|
2010-03-02 09:53:55 +00:00
|
|
|
* Creates a new #ClutterGLXTexturePixmap for @pixmap
|
|
|
|
*
|
2008-02-20 12:43:54 +00:00
|
|
|
* Return value: A new #ClutterGLXTexturePixmap bound to the given X Pixmap
|
|
|
|
*
|
|
|
|
* Since: 0.8
|
2011-01-20 13:19:03 +00:00
|
|
|
*
|
|
|
|
* Deprecated: 1.6: Use clutter_x11_texture_pixmap_new_with_pixmap() instead
|
2010-03-02 09:53:55 +00:00
|
|
|
*/
|
|
|
|
ClutterActor *
|
2008-04-15 21:18:13 +00:00
|
|
|
clutter_glx_texture_pixmap_new_with_pixmap (Pixmap pixmap)
|
2008-02-20 12:43:54 +00:00
|
|
|
{
|
2010-03-02 09:53:55 +00:00
|
|
|
return g_object_new (CLUTTER_GLX_TYPE_TEXTURE_PIXMAP,
|
|
|
|
"pixmap", pixmap,
|
|
|
|
NULL);
|
2008-02-20 12:43:54 +00:00
|
|
|
}
|
|
|
|
|
2008-06-30 14:36:49 +00:00
|
|
|
/**
|
|
|
|
* clutter_glx_texture_pixmap_new_with_window:
|
|
|
|
* @window: the X window to which this texture should be bound
|
|
|
|
*
|
2010-03-02 09:53:55 +00:00
|
|
|
* Creates a new #ClutterGLXTexturePixmap for @window
|
|
|
|
*
|
2008-06-30 14:36:49 +00:00
|
|
|
* Return value: A new #ClutterGLXTexturePixmap bound to the given X window
|
|
|
|
*
|
|
|
|
* Since: 0.8
|
2011-01-20 13:19:03 +00:00
|
|
|
*
|
|
|
|
* Deprecated: 1.6: Use clutter_x11_texture_pixmap_new_with_window() instead
|
|
|
|
*/
|
2010-03-02 09:53:55 +00:00
|
|
|
ClutterActor *
|
2008-06-30 14:36:49 +00:00
|
|
|
clutter_glx_texture_pixmap_new_with_window (Window window)
|
|
|
|
{
|
2010-03-02 09:53:55 +00:00
|
|
|
return g_object_new (CLUTTER_GLX_TYPE_TEXTURE_PIXMAP,
|
|
|
|
"window", window,
|
|
|
|
NULL);
|
2008-06-30 14:36:49 +00:00
|
|
|
}
|
|
|
|
|
2008-02-20 12:43:54 +00:00
|
|
|
/**
|
|
|
|
* clutter_glx_texture_pixmap_new:
|
|
|
|
*
|
2010-03-02 09:53:55 +00:00
|
|
|
* Creates a new, empty #ClutterGLXTexturePixmap
|
|
|
|
*
|
2008-02-20 12:43:54 +00:00
|
|
|
* Return value: A new #ClutterGLXTexturePixmap
|
|
|
|
*
|
|
|
|
* Since: 0.8
|
2011-01-20 13:19:03 +00:00
|
|
|
*
|
|
|
|
* Deprecated: 1.6: Use clutter_x11_texture_pixmap_new() instead
|
2010-03-02 09:53:55 +00:00
|
|
|
*/
|
2008-02-20 12:43:54 +00:00
|
|
|
ClutterActor *
|
|
|
|
clutter_glx_texture_pixmap_new (void)
|
|
|
|
{
|
2010-03-02 09:53:55 +00:00
|
|
|
return g_object_new (CLUTTER_GLX_TYPE_TEXTURE_PIXMAP, NULL);
|
2008-02-20 12:43:54 +00:00
|
|
|
}
|