2010-05-25 13:56:14 -04:00
|
|
|
/*
|
|
|
|
* Cogl
|
|
|
|
*
|
2014-02-21 20:28:54 -05:00
|
|
|
* A Low Level GPU Graphics and Utilities API
|
2010-05-25 13:56:14 -04:00
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Intel Corporation.
|
|
|
|
*
|
2014-02-21 20:28:54 -05:00
|
|
|
* Permission is hereby granted, free of charge, to any person
|
|
|
|
* obtaining a copy of this software and associated documentation
|
|
|
|
* files (the "Software"), to deal in the Software without
|
|
|
|
* restriction, including without limitation the rights to use, copy,
|
|
|
|
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
|
|
* of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
* included in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
2010-05-25 13:56:14 -04:00
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Neil Roberts <neil@linux.intel.com>
|
|
|
|
* Johan Bilien <johan.bilien@nokia.com>
|
2011-03-01 09:43:43 -05:00
|
|
|
* Robert Bragg <robert@linux.intel.com>
|
2010-05-25 13:56:14 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2010-07-25 16:36:41 -04:00
|
|
|
#include "cogl-debug.h"
|
2010-05-25 13:56:14 -04:00
|
|
|
#include "cogl-util.h"
|
|
|
|
#include "cogl-texture-pixmap-x11.h"
|
|
|
|
#include "cogl-texture-pixmap-x11-private.h"
|
|
|
|
#include "cogl-bitmap-private.h"
|
|
|
|
#include "cogl-texture-private.h"
|
|
|
|
#include "cogl-texture-driver.h"
|
|
|
|
#include "cogl-texture-2d-private.h"
|
2013-06-08 15:45:08 -04:00
|
|
|
#include "cogl-texture-2d-sliced.h"
|
2010-05-25 13:56:14 -04:00
|
|
|
#include "cogl-texture-rectangle-private.h"
|
2010-11-04 18:25:52 -04:00
|
|
|
#include "cogl-context-private.h"
|
2011-02-25 06:29:08 -05:00
|
|
|
#include "cogl-display-private.h"
|
|
|
|
#include "cogl-renderer-private.h"
|
2012-04-16 09:14:10 -04:00
|
|
|
#include "cogl-object-private.h"
|
2011-03-01 09:43:43 -05:00
|
|
|
#include "cogl-winsys-private.h"
|
2010-10-27 13:54:57 -04:00
|
|
|
#include "cogl-pipeline-opengl-private.h"
|
2011-10-17 12:55:35 -04:00
|
|
|
#include "cogl-xlib.h"
|
2012-08-31 14:28:27 -04:00
|
|
|
#include "cogl-error-private.h"
|
2012-11-08 18:00:49 -05:00
|
|
|
#include "cogl-texture-gl-private.h"
|
2012-11-09 12:55:54 -05:00
|
|
|
#include "cogl-private.h"
|
2010-05-25 13:56:14 -04:00
|
|
|
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
|
|
|
|
#include <sys/ipc.h>
|
|
|
|
#include <sys/shm.h>
|
|
|
|
#include <X11/extensions/XShm.h>
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
static void _cogl_texture_pixmap_x11_free (CoglTexturePixmapX11 *tex_pixmap);
|
|
|
|
|
|
|
|
COGL_TEXTURE_DEFINE (TexturePixmapX11, texture_pixmap_x11);
|
|
|
|
|
|
|
|
static const CoglTextureVtable cogl_texture_pixmap_x11_vtable;
|
|
|
|
|
2012-08-31 14:28:27 -04:00
|
|
|
uint32_t
|
2012-02-18 11:53:07 -05:00
|
|
|
cogl_texture_pixmap_x11_error_quark (void)
|
|
|
|
{
|
|
|
|
return g_quark_from_static_string ("cogl-texture-pixmap-error-quark");
|
|
|
|
}
|
|
|
|
|
2010-05-25 13:56:14 -04:00
|
|
|
static void
|
|
|
|
cogl_damage_rectangle_union (CoglDamageRectangle *damage_rect,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int width,
|
|
|
|
int height)
|
|
|
|
{
|
|
|
|
/* If the damage region is empty then we'll just copy the new
|
|
|
|
rectangle directly */
|
|
|
|
if (damage_rect->x1 == damage_rect->x2 ||
|
|
|
|
damage_rect->y1 == damage_rect->y2)
|
|
|
|
{
|
|
|
|
damage_rect->x1 = x;
|
|
|
|
damage_rect->y1 = y;
|
|
|
|
damage_rect->x2 = x + width;
|
|
|
|
damage_rect->y2 = y + height;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (damage_rect->x1 > x)
|
|
|
|
damage_rect->x1 = x;
|
|
|
|
if (damage_rect->y1 > y)
|
|
|
|
damage_rect->y1 = y;
|
|
|
|
if (damage_rect->x2 < x + width)
|
|
|
|
damage_rect->x2 = x + width;
|
|
|
|
if (damage_rect->y2 < y + height)
|
|
|
|
damage_rect->y2 = y + height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
static CoglBool
|
2010-05-25 13:56:14 -04:00
|
|
|
cogl_damage_rectangle_is_whole (const CoglDamageRectangle *damage_rect,
|
|
|
|
unsigned int width,
|
|
|
|
unsigned int height)
|
|
|
|
{
|
|
|
|
return (damage_rect->x1 == 0 && damage_rect->y1 == 0
|
|
|
|
&& damage_rect->x2 == width && damage_rect->y2 == height);
|
|
|
|
}
|
|
|
|
|
2011-02-25 06:29:08 -05:00
|
|
|
static const CoglWinsysVtable *
|
|
|
|
_cogl_texture_pixmap_x11_get_winsys (CoglTexturePixmapX11 *tex_pixmap)
|
|
|
|
{
|
|
|
|
/* FIXME: A CoglContext should be reachable from a CoglTexture
|
|
|
|
* pointer */
|
|
|
|
_COGL_GET_CONTEXT (ctx, NULL);
|
|
|
|
|
|
|
|
return ctx->display->renderer->winsys_vtable;
|
|
|
|
}
|
|
|
|
|
2010-05-25 13:56:14 -04:00
|
|
|
static void
|
|
|
|
process_damage_event (CoglTexturePixmapX11 *tex_pixmap,
|
|
|
|
XDamageNotifyEvent *damage_event)
|
|
|
|
{
|
2012-11-22 16:46:54 -05:00
|
|
|
CoglTexture *tex = COGL_TEXTURE (tex_pixmap);
|
2010-05-25 13:56:14 -04:00
|
|
|
Display *display;
|
|
|
|
enum { DO_NOTHING, NEEDS_SUBTRACT, NEED_BOUNDING_BOX } handle_mode;
|
2011-02-25 06:29:08 -05:00
|
|
|
const CoglWinsysVtable *winsys;
|
2010-05-25 13:56:14 -04:00
|
|
|
|
|
|
|
_COGL_GET_CONTEXT (ctxt, NO_RETVAL);
|
|
|
|
|
2012-11-05 08:45:40 -05:00
|
|
|
display = cogl_xlib_renderer_get_display (ctxt->display->renderer);
|
2010-05-25 13:56:14 -04:00
|
|
|
|
|
|
|
COGL_NOTE (TEXTURE_PIXMAP, "Damage event received for %p", tex_pixmap);
|
|
|
|
|
|
|
|
switch (tex_pixmap->damage_report_level)
|
|
|
|
{
|
|
|
|
case COGL_TEXTURE_PIXMAP_X11_DAMAGE_RAW_RECTANGLES:
|
|
|
|
/* For raw rectangles we don't need do look at the damage region
|
|
|
|
at all because the damage area is directly given in the event
|
|
|
|
struct and the reporting of events is not affected by
|
|
|
|
clearing the damage region */
|
|
|
|
handle_mode = DO_NOTHING;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COGL_TEXTURE_PIXMAP_X11_DAMAGE_DELTA_RECTANGLES:
|
|
|
|
case COGL_TEXTURE_PIXMAP_X11_DAMAGE_NON_EMPTY:
|
|
|
|
/* For delta rectangles and non empty we'll query the damage
|
|
|
|
region for the bounding box */
|
|
|
|
handle_mode = NEED_BOUNDING_BOX;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COGL_TEXTURE_PIXMAP_X11_DAMAGE_BOUNDING_BOX:
|
|
|
|
/* For bounding box we need to clear the damage region but we
|
|
|
|
don't actually care what it was because the damage event
|
|
|
|
itself contains the bounding box of the region */
|
|
|
|
handle_mode = NEEDS_SUBTRACT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If the damage already covers the whole rectangle then we don't
|
|
|
|
need to request the bounding box of the region because we're
|
|
|
|
going to update the whole texture anyway. */
|
|
|
|
if (cogl_damage_rectangle_is_whole (&tex_pixmap->damage_rect,
|
2012-11-22 16:46:54 -05:00
|
|
|
tex->width,
|
|
|
|
tex->height))
|
2010-05-25 13:56:14 -04:00
|
|
|
{
|
|
|
|
if (handle_mode != DO_NOTHING)
|
|
|
|
XDamageSubtract (display, tex_pixmap->damage, None, None);
|
|
|
|
}
|
|
|
|
else if (handle_mode == NEED_BOUNDING_BOX)
|
|
|
|
{
|
|
|
|
XserverRegion parts;
|
|
|
|
int r_count;
|
|
|
|
XRectangle r_bounds;
|
|
|
|
XRectangle *r_damage;
|
|
|
|
|
|
|
|
/* We need to extract the damage region so we can get the
|
|
|
|
bounding box */
|
|
|
|
|
|
|
|
parts = XFixesCreateRegion (display, 0, 0);
|
|
|
|
XDamageSubtract (display, tex_pixmap->damage, None, parts);
|
|
|
|
r_damage = XFixesFetchRegionAndBounds (display,
|
|
|
|
parts,
|
|
|
|
&r_count,
|
|
|
|
&r_bounds);
|
|
|
|
cogl_damage_rectangle_union (&tex_pixmap->damage_rect,
|
|
|
|
r_bounds.x,
|
|
|
|
r_bounds.y,
|
|
|
|
r_bounds.width,
|
|
|
|
r_bounds.height);
|
|
|
|
if (r_damage)
|
|
|
|
XFree (r_damage);
|
|
|
|
|
|
|
|
XFixesDestroyRegion (display, parts);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (handle_mode == NEEDS_SUBTRACT)
|
|
|
|
/* We still need to subtract from the damage region but we
|
|
|
|
don't care what the region actually was */
|
|
|
|
XDamageSubtract (display, tex_pixmap->damage, None, None);
|
|
|
|
|
|
|
|
cogl_damage_rectangle_union (&tex_pixmap->damage_rect,
|
|
|
|
damage_event->area.x,
|
|
|
|
damage_event->area.y,
|
|
|
|
damage_event->area.width,
|
|
|
|
damage_event->area.height);
|
|
|
|
}
|
|
|
|
|
2011-10-01 11:11:26 -04:00
|
|
|
if (tex_pixmap->winsys)
|
|
|
|
{
|
|
|
|
/* If we're using the texture from pixmap extension then there's no
|
|
|
|
point in getting the region and we can just mark that the texture
|
|
|
|
needs updating */
|
|
|
|
winsys = _cogl_texture_pixmap_x11_get_winsys (tex_pixmap);
|
|
|
|
winsys->texture_pixmap_x11_damage_notify (tex_pixmap);
|
|
|
|
}
|
2010-05-25 13:56:14 -04:00
|
|
|
}
|
|
|
|
|
2011-04-13 11:41:41 -04:00
|
|
|
static CoglFilterReturn
|
2011-06-28 08:38:50 -04:00
|
|
|
_cogl_texture_pixmap_x11_filter (XEvent *event, void *data)
|
2010-05-25 13:56:14 -04:00
|
|
|
{
|
|
|
|
CoglTexturePixmapX11 *tex_pixmap = data;
|
2010-11-05 08:28:33 -04:00
|
|
|
int damage_base;
|
2010-05-25 13:56:14 -04:00
|
|
|
|
2011-04-13 11:41:41 -04:00
|
|
|
_COGL_GET_CONTEXT (ctxt, COGL_FILTER_CONTINUE);
|
2010-05-25 13:56:14 -04:00
|
|
|
|
2010-11-05 08:28:33 -04:00
|
|
|
damage_base = _cogl_xlib_get_damage_base ();
|
|
|
|
if (event->type == damage_base + XDamageNotify)
|
2010-05-25 13:56:14 -04:00
|
|
|
{
|
|
|
|
XDamageNotifyEvent *damage_event = (XDamageNotifyEvent *) event;
|
|
|
|
|
|
|
|
if (damage_event->damage == tex_pixmap->damage)
|
|
|
|
process_damage_event (tex_pixmap, damage_event);
|
|
|
|
}
|
|
|
|
|
2011-04-13 11:41:41 -04:00
|
|
|
return COGL_FILTER_CONTINUE;
|
2010-05-25 13:56:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-05-27 07:30:23 -04:00
|
|
|
set_damage_object_internal (CoglContext *ctx,
|
|
|
|
CoglTexturePixmapX11 *tex_pixmap,
|
2010-05-25 13:56:14 -04:00
|
|
|
Damage damage,
|
|
|
|
CoglTexturePixmapX11ReportLevel report_level)
|
|
|
|
{
|
2012-11-05 08:45:40 -05:00
|
|
|
Display *display = cogl_xlib_renderer_get_display (ctx->display->renderer);
|
|
|
|
|
2010-05-25 13:56:14 -04:00
|
|
|
if (tex_pixmap->damage)
|
|
|
|
{
|
2011-06-28 08:38:50 -04:00
|
|
|
cogl_xlib_renderer_remove_filter (ctx->display->renderer,
|
|
|
|
_cogl_texture_pixmap_x11_filter,
|
|
|
|
tex_pixmap);
|
2010-05-25 13:56:14 -04:00
|
|
|
|
|
|
|
if (tex_pixmap->damage_owned)
|
|
|
|
{
|
2012-11-05 08:45:40 -05:00
|
|
|
XDamageDestroy (display, tex_pixmap->damage);
|
2010-05-25 13:56:14 -04:00
|
|
|
tex_pixmap->damage_owned = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tex_pixmap->damage = damage;
|
|
|
|
tex_pixmap->damage_report_level = report_level;
|
|
|
|
|
|
|
|
if (damage)
|
2011-06-28 08:38:50 -04:00
|
|
|
cogl_xlib_renderer_add_filter (ctx->display->renderer,
|
|
|
|
_cogl_texture_pixmap_x11_filter,
|
|
|
|
tex_pixmap);
|
2010-05-25 13:56:14 -04:00
|
|
|
}
|
|
|
|
|
2012-02-18 11:53:07 -05:00
|
|
|
CoglTexturePixmapX11 *
|
|
|
|
cogl_texture_pixmap_x11_new (CoglContext *ctxt,
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
uint32_t pixmap,
|
|
|
|
CoglBool automatic_updates,
|
2012-08-31 14:28:27 -04:00
|
|
|
CoglError **error)
|
2010-05-25 13:56:14 -04:00
|
|
|
{
|
|
|
|
CoglTexturePixmapX11 *tex_pixmap = g_new (CoglTexturePixmapX11, 1);
|
2012-11-05 08:45:40 -05:00
|
|
|
Display *display = cogl_xlib_renderer_get_display (ctxt->display->renderer);
|
2010-05-25 13:56:14 -04:00
|
|
|
Window pixmap_root_window;
|
|
|
|
int pixmap_x, pixmap_y;
|
2012-11-22 16:46:54 -05:00
|
|
|
unsigned int pixmap_width, pixmap_height;
|
2010-05-25 13:56:14 -04:00
|
|
|
unsigned int pixmap_border_width;
|
2013-06-23 11:18:18 -04:00
|
|
|
CoglPixelFormat internal_format;
|
2010-05-25 13:56:14 -04:00
|
|
|
CoglTexture *tex = COGL_TEXTURE (tex_pixmap);
|
|
|
|
XWindowAttributes window_attributes;
|
2010-11-05 08:28:33 -04:00
|
|
|
int damage_base;
|
2011-02-25 06:29:08 -05:00
|
|
|
const CoglWinsysVtable *winsys;
|
2010-05-25 13:56:14 -04:00
|
|
|
|
|
|
|
if (!XGetGeometry (display, pixmap, &pixmap_root_window,
|
|
|
|
&pixmap_x, &pixmap_y,
|
2012-11-22 16:46:54 -05:00
|
|
|
&pixmap_width, &pixmap_height,
|
2010-05-25 13:56:14 -04:00
|
|
|
&pixmap_border_width, &tex_pixmap->depth))
|
|
|
|
{
|
|
|
|
g_free (tex_pixmap);
|
2012-08-31 14:28:27 -04:00
|
|
|
_cogl_set_error (error,
|
2012-02-18 11:53:07 -05:00
|
|
|
COGL_TEXTURE_PIXMAP_X11_ERROR,
|
|
|
|
COGL_TEXTURE_PIXMAP_X11_ERROR_X11,
|
|
|
|
"Unable to query pixmap size");
|
|
|
|
return NULL;
|
2010-05-25 13:56:14 -04:00
|
|
|
}
|
|
|
|
|
2013-06-23 11:18:18 -04:00
|
|
|
/* Note: the detailed pixel layout doesn't matter here, we are just
|
|
|
|
* interested in RGB vs RGBA... */
|
|
|
|
internal_format = (tex_pixmap->depth >= 32
|
|
|
|
? COGL_PIXEL_FORMAT_RGBA_8888_PRE
|
|
|
|
: COGL_PIXEL_FORMAT_RGB_888);
|
|
|
|
|
2012-11-22 16:46:54 -05:00
|
|
|
_cogl_texture_init (tex, ctxt, pixmap_width, pixmap_height,
|
2013-06-23 11:18:18 -04:00
|
|
|
internal_format,
|
|
|
|
NULL, /* no loader */
|
2012-11-22 16:46:54 -05:00
|
|
|
&cogl_texture_pixmap_x11_vtable);
|
|
|
|
|
|
|
|
tex_pixmap->pixmap = pixmap;
|
|
|
|
tex_pixmap->image = NULL;
|
|
|
|
tex_pixmap->shm_info.shmid = -1;
|
|
|
|
tex_pixmap->tex = NULL;
|
|
|
|
tex_pixmap->damage_owned = FALSE;
|
|
|
|
tex_pixmap->damage = 0;
|
|
|
|
|
2010-05-25 13:56:14 -04:00
|
|
|
/* We need a visual to use for shared memory images so we'll query
|
|
|
|
it from the pixmap's root window */
|
|
|
|
if (!XGetWindowAttributes (display, pixmap_root_window, &window_attributes))
|
|
|
|
{
|
|
|
|
g_free (tex_pixmap);
|
2012-08-31 14:28:27 -04:00
|
|
|
_cogl_set_error (error,
|
2012-02-18 11:53:07 -05:00
|
|
|
COGL_TEXTURE_PIXMAP_X11_ERROR,
|
|
|
|
COGL_TEXTURE_PIXMAP_X11_ERROR_X11,
|
|
|
|
"Unable to query root window attributes");
|
|
|
|
return NULL;
|
2010-05-25 13:56:14 -04:00
|
|
|
}
|
2013-06-23 11:18:18 -04:00
|
|
|
|
2010-05-25 13:56:14 -04:00
|
|
|
tex_pixmap->visual = window_attributes.visual;
|
|
|
|
|
|
|
|
/* If automatic updates are requested and the Xlib connection
|
|
|
|
supports damage events then we'll register a damage object on the
|
|
|
|
pixmap */
|
2010-11-05 08:28:33 -04:00
|
|
|
damage_base = _cogl_xlib_get_damage_base ();
|
|
|
|
if (automatic_updates && damage_base >= 0)
|
2010-05-25 13:56:14 -04:00
|
|
|
{
|
|
|
|
Damage damage = XDamageCreate (display,
|
|
|
|
pixmap,
|
|
|
|
XDamageReportBoundingBox);
|
2011-05-27 07:30:23 -04:00
|
|
|
set_damage_object_internal (ctxt,
|
|
|
|
tex_pixmap,
|
2010-05-25 13:56:14 -04:00
|
|
|
damage,
|
|
|
|
COGL_TEXTURE_PIXMAP_X11_DAMAGE_BOUNDING_BOX);
|
|
|
|
tex_pixmap->damage_owned = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Assume the entire pixmap is damaged to begin with */
|
|
|
|
tex_pixmap->damage_rect.x1 = 0;
|
2013-06-23 11:18:18 -04:00
|
|
|
tex_pixmap->damage_rect.x2 = pixmap_width;
|
2010-05-25 13:56:14 -04:00
|
|
|
tex_pixmap->damage_rect.y1 = 0;
|
2013-06-23 11:18:18 -04:00
|
|
|
tex_pixmap->damage_rect.y2 = pixmap_height;
|
2010-05-25 13:56:14 -04:00
|
|
|
|
2011-02-25 06:29:08 -05:00
|
|
|
winsys = _cogl_texture_pixmap_x11_get_winsys (tex_pixmap);
|
|
|
|
if (winsys->texture_pixmap_x11_create)
|
2011-07-15 14:35:55 -04:00
|
|
|
{
|
|
|
|
tex_pixmap->use_winsys_texture =
|
|
|
|
winsys->texture_pixmap_x11_create (tex_pixmap);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
tex_pixmap->use_winsys_texture = FALSE;
|
2010-05-25 13:56:14 -04:00
|
|
|
|
2011-07-15 14:58:22 -04:00
|
|
|
if (!tex_pixmap->use_winsys_texture)
|
|
|
|
tex_pixmap->winsys = NULL;
|
|
|
|
|
2013-06-23 11:18:18 -04:00
|
|
|
_cogl_texture_set_allocated (tex, internal_format,
|
|
|
|
pixmap_width, pixmap_height);
|
2012-11-22 18:01:08 -05:00
|
|
|
|
2012-04-16 09:14:10 -04:00
|
|
|
return _cogl_texture_pixmap_x11_object_new (tex_pixmap);
|
2010-05-25 13:56:14 -04:00
|
|
|
}
|
|
|
|
|
2012-11-22 18:01:08 -05:00
|
|
|
static CoglBool
|
|
|
|
_cogl_texture_pixmap_x11_allocate (CoglTexture *tex,
|
|
|
|
CoglError **error)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-05-25 13:56:14 -04:00
|
|
|
/* Tries to allocate enough shared mem to handle a full size
|
|
|
|
* update size of the X Pixmap. */
|
|
|
|
static void
|
|
|
|
try_alloc_shm (CoglTexturePixmapX11 *tex_pixmap)
|
|
|
|
{
|
2012-11-22 16:46:54 -05:00
|
|
|
CoglTexture *tex = COGL_TEXTURE (tex_pixmap);
|
2010-05-25 13:56:14 -04:00
|
|
|
XImage *dummy_image;
|
|
|
|
Display *display;
|
|
|
|
|
2012-11-05 08:45:40 -05:00
|
|
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
|
|
|
|
|
|
display = cogl_xlib_renderer_get_display (ctx->display->renderer);
|
2010-05-25 13:56:14 -04:00
|
|
|
|
|
|
|
if (!XShmQueryExtension (display))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* We are creating a dummy_image so we can have Xlib calculate
|
|
|
|
* image->bytes_per_line - including any magic padding it may
|
|
|
|
* want - for the largest possible ximage we might need to use
|
|
|
|
* when handling updates to the texture.
|
|
|
|
*
|
|
|
|
* Note: we pass a NULL shminfo here, but that has no bearing
|
|
|
|
* on the setup of the XImage, except that ximage->obdata will
|
|
|
|
* == NULL.
|
|
|
|
*/
|
|
|
|
dummy_image =
|
|
|
|
XShmCreateImage (display,
|
|
|
|
tex_pixmap->visual,
|
|
|
|
tex_pixmap->depth,
|
|
|
|
ZPixmap,
|
|
|
|
NULL,
|
|
|
|
NULL, /* shminfo, */
|
2012-11-22 16:46:54 -05:00
|
|
|
tex->width,
|
|
|
|
tex->height);
|
2010-05-25 13:56:14 -04:00
|
|
|
if (!dummy_image)
|
|
|
|
goto failed_image_create;
|
|
|
|
|
|
|
|
tex_pixmap->shm_info.shmid = shmget (IPC_PRIVATE,
|
|
|
|
dummy_image->bytes_per_line
|
|
|
|
* dummy_image->height,
|
|
|
|
IPC_CREAT | 0777);
|
|
|
|
if (tex_pixmap->shm_info.shmid == -1)
|
|
|
|
goto failed_shmget;
|
|
|
|
|
|
|
|
tex_pixmap->shm_info.shmaddr = shmat (tex_pixmap->shm_info.shmid, 0, 0);
|
|
|
|
if (tex_pixmap->shm_info.shmaddr == (void *) -1)
|
|
|
|
goto failed_shmat;
|
|
|
|
|
|
|
|
tex_pixmap->shm_info.readOnly = False;
|
|
|
|
|
|
|
|
if (XShmAttach (display, &tex_pixmap->shm_info) == 0)
|
|
|
|
goto failed_xshmattach;
|
|
|
|
|
|
|
|
XDestroyImage (dummy_image);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
failed_xshmattach:
|
|
|
|
g_warning ("XShmAttach failed");
|
|
|
|
shmdt (tex_pixmap->shm_info.shmaddr);
|
|
|
|
|
|
|
|
failed_shmat:
|
|
|
|
g_warning ("shmat failed");
|
|
|
|
shmctl (tex_pixmap->shm_info.shmid, IPC_RMID, 0);
|
|
|
|
|
|
|
|
failed_shmget:
|
|
|
|
g_warning ("shmget failed");
|
|
|
|
XDestroyImage (dummy_image);
|
|
|
|
|
|
|
|
failed_image_create:
|
|
|
|
tex_pixmap->shm_info.shmid = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-02-18 11:53:07 -05:00
|
|
|
cogl_texture_pixmap_x11_update_area (CoglTexturePixmapX11 *tex_pixmap,
|
2010-05-25 13:56:14 -04:00
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int width,
|
|
|
|
int height)
|
|
|
|
{
|
|
|
|
/* We'll queue the update for both the GLX texture and the regular
|
|
|
|
texture because we can't determine which will be needed until we
|
|
|
|
actually render something */
|
|
|
|
|
2011-10-01 11:11:26 -04:00
|
|
|
if (tex_pixmap->winsys)
|
|
|
|
{
|
|
|
|
const CoglWinsysVtable *winsys;
|
|
|
|
winsys = _cogl_texture_pixmap_x11_get_winsys (tex_pixmap);
|
|
|
|
winsys->texture_pixmap_x11_damage_notify (tex_pixmap);
|
|
|
|
}
|
2010-05-25 13:56:14 -04:00
|
|
|
|
|
|
|
cogl_damage_rectangle_union (&tex_pixmap->damage_rect,
|
|
|
|
x, y, width, height);
|
|
|
|
}
|
|
|
|
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
CoglBool
|
2012-02-18 11:53:07 -05:00
|
|
|
cogl_texture_pixmap_x11_is_using_tfp_extension (CoglTexturePixmapX11 *tex_pixmap)
|
2010-05-25 13:56:14 -04:00
|
|
|
{
|
2011-03-01 09:43:43 -05:00
|
|
|
return !!tex_pixmap->winsys;
|
2010-05-25 13:56:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-02-18 11:53:07 -05:00
|
|
|
cogl_texture_pixmap_x11_set_damage_object (CoglTexturePixmapX11 *tex_pixmap,
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
uint32_t damage,
|
2010-05-25 13:56:14 -04:00
|
|
|
CoglTexturePixmapX11ReportLevel
|
|
|
|
report_level)
|
|
|
|
{
|
2010-11-05 08:28:33 -04:00
|
|
|
int damage_base;
|
2010-05-25 13:56:14 -04:00
|
|
|
|
|
|
|
_COGL_GET_CONTEXT (ctxt, NO_RETVAL);
|
|
|
|
|
2010-11-05 08:28:33 -04:00
|
|
|
damage_base = _cogl_xlib_get_damage_base ();
|
|
|
|
if (damage_base >= 0)
|
2011-05-27 07:30:23 -04:00
|
|
|
set_damage_object_internal (ctxt, tex_pixmap, damage, report_level);
|
2010-05-25 13:56:14 -04:00
|
|
|
}
|
|
|
|
|
2013-06-08 15:45:08 -04:00
|
|
|
static CoglTexture *
|
|
|
|
create_fallback_texture (CoglContext *ctx,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
CoglPixelFormat internal_format)
|
|
|
|
{
|
|
|
|
CoglTexture *tex;
|
|
|
|
CoglError *skip_error = NULL;
|
|
|
|
|
|
|
|
if ((_cogl_util_is_pot (width) && _cogl_util_is_pot (height)) ||
|
|
|
|
(cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_BASIC) &&
|
|
|
|
cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP)))
|
|
|
|
{
|
|
|
|
/* First try creating a fast-path non-sliced texture */
|
|
|
|
tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx,
|
2013-07-01 20:48:54 -04:00
|
|
|
width, height));
|
|
|
|
|
|
|
|
_cogl_texture_set_internal_format (tex, internal_format);
|
2013-06-08 15:45:08 -04:00
|
|
|
|
|
|
|
/* TODO: instead of allocating storage here it would be better
|
|
|
|
* if we had some api that let us just check that the size is
|
|
|
|
* supported by the hardware so storage could be allocated
|
|
|
|
* lazily when uploading data. */
|
|
|
|
if (!cogl_texture_allocate (tex, &skip_error))
|
|
|
|
{
|
|
|
|
cogl_error_free (skip_error);
|
|
|
|
cogl_object_unref (tex);
|
|
|
|
tex = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
tex = NULL;
|
|
|
|
|
|
|
|
if (!tex)
|
|
|
|
{
|
|
|
|
CoglTexture2DSliced *tex_2ds =
|
|
|
|
cogl_texture_2d_sliced_new_with_size (ctx,
|
|
|
|
width,
|
|
|
|
height,
|
2013-07-01 20:48:54 -04:00
|
|
|
COGL_TEXTURE_MAX_WASTE);
|
2013-06-08 15:45:08 -04:00
|
|
|
tex = COGL_TEXTURE (tex_2ds);
|
2013-07-01 20:48:54 -04:00
|
|
|
|
|
|
|
_cogl_texture_set_internal_format (tex, internal_format);
|
2013-06-08 15:45:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return tex;
|
|
|
|
}
|
|
|
|
|
2010-05-25 13:56:14 -04:00
|
|
|
static void
|
|
|
|
_cogl_texture_pixmap_x11_update_image_texture (CoglTexturePixmapX11 *tex_pixmap)
|
|
|
|
{
|
2012-11-22 16:46:54 -05:00
|
|
|
CoglTexture *tex = COGL_TEXTURE (tex_pixmap);
|
2010-05-25 13:56:14 -04:00
|
|
|
Display *display;
|
2011-11-21 18:41:13 -05:00
|
|
|
Visual *visual;
|
2010-05-25 13:56:14 -04:00
|
|
|
CoglPixelFormat image_format;
|
|
|
|
XImage *image;
|
|
|
|
int src_x, src_y;
|
|
|
|
int x, y, width, height;
|
2012-11-09 12:55:54 -05:00
|
|
|
int bpp;
|
|
|
|
int offset;
|
|
|
|
CoglError *ignore = NULL;
|
2010-05-25 13:56:14 -04:00
|
|
|
|
2012-11-05 08:45:40 -05:00
|
|
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
|
|
|
|
|
|
display = cogl_xlib_renderer_get_display (ctx->display->renderer);
|
2011-11-21 18:41:13 -05:00
|
|
|
visual = tex_pixmap->visual;
|
2010-05-25 13:56:14 -04:00
|
|
|
|
|
|
|
/* If the damage region is empty then there's nothing to do */
|
|
|
|
if (tex_pixmap->damage_rect.x2 == tex_pixmap->damage_rect.x1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
x = tex_pixmap->damage_rect.x1;
|
|
|
|
y = tex_pixmap->damage_rect.y1;
|
|
|
|
width = tex_pixmap->damage_rect.x2 - x;
|
|
|
|
height = tex_pixmap->damage_rect.y2 - y;
|
|
|
|
|
|
|
|
/* We lazily create the texture the first time it is needed in case
|
|
|
|
this texture can be entirely handled using the GLX texture
|
|
|
|
instead */
|
2012-04-16 09:14:10 -04:00
|
|
|
if (tex_pixmap->tex == NULL)
|
2010-05-25 13:56:14 -04:00
|
|
|
{
|
|
|
|
CoglPixelFormat texture_format;
|
|
|
|
|
|
|
|
texture_format = (tex_pixmap->depth >= 32
|
|
|
|
? COGL_PIXEL_FORMAT_RGBA_8888_PRE
|
|
|
|
: COGL_PIXEL_FORMAT_RGB_888);
|
|
|
|
|
2013-06-08 15:45:08 -04:00
|
|
|
tex_pixmap->tex = create_fallback_texture (ctx,
|
|
|
|
tex->width,
|
|
|
|
tex->height,
|
|
|
|
texture_format);
|
2010-05-25 13:56:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (tex_pixmap->image == NULL)
|
|
|
|
{
|
|
|
|
/* If we also haven't got a shm segment then this must be the
|
|
|
|
first time we've tried to update, so lets try allocating shm
|
|
|
|
first */
|
|
|
|
if (tex_pixmap->shm_info.shmid == -1)
|
|
|
|
try_alloc_shm (tex_pixmap);
|
|
|
|
|
|
|
|
if (tex_pixmap->shm_info.shmid == -1)
|
|
|
|
{
|
|
|
|
COGL_NOTE (TEXTURE_PIXMAP, "Updating %p using XGetImage", tex_pixmap);
|
|
|
|
|
|
|
|
/* We'll fallback to using a regular XImage. We'll download
|
|
|
|
the entire area instead of a sub region because presumably
|
|
|
|
if this is the first update then the entire pixmap is
|
|
|
|
needed anyway and it saves trying to manually allocate an
|
|
|
|
XImage at the right size */
|
|
|
|
tex_pixmap->image = XGetImage (display,
|
|
|
|
tex_pixmap->pixmap,
|
|
|
|
0, 0,
|
2012-11-22 16:46:54 -05:00
|
|
|
tex->width, tex->height,
|
2010-05-25 13:56:14 -04:00
|
|
|
AllPlanes, ZPixmap);
|
|
|
|
image = tex_pixmap->image;
|
|
|
|
src_x = x;
|
|
|
|
src_y = y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
COGL_NOTE (TEXTURE_PIXMAP, "Updating %p using XShmGetImage",
|
|
|
|
tex_pixmap);
|
|
|
|
|
|
|
|
/* Create a temporary image using the beginning of the
|
|
|
|
shared memory segment and the right size for the region
|
|
|
|
we want to update. We need to reallocate the XImage every
|
|
|
|
time because there is no XShmGetSubImage. */
|
|
|
|
image = XShmCreateImage (display,
|
|
|
|
tex_pixmap->visual,
|
|
|
|
tex_pixmap->depth,
|
|
|
|
ZPixmap,
|
|
|
|
NULL,
|
|
|
|
&tex_pixmap->shm_info,
|
|
|
|
width,
|
|
|
|
height);
|
|
|
|
image->data = tex_pixmap->shm_info.shmaddr;
|
|
|
|
src_x = 0;
|
|
|
|
src_y = 0;
|
|
|
|
|
|
|
|
XShmGetImage (display, tex_pixmap->pixmap, image, x, y, AllPlanes);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
COGL_NOTE (TEXTURE_PIXMAP, "Updating %p using XGetSubImage", tex_pixmap);
|
|
|
|
|
|
|
|
image = tex_pixmap->image;
|
|
|
|
src_x = x;
|
|
|
|
src_y = y;
|
|
|
|
|
|
|
|
XGetSubImage (display,
|
|
|
|
tex_pixmap->pixmap,
|
|
|
|
x, y, width, height,
|
|
|
|
AllPlanes, ZPixmap,
|
|
|
|
image,
|
|
|
|
x, y);
|
|
|
|
}
|
|
|
|
|
2011-11-21 18:41:13 -05:00
|
|
|
image_format =
|
|
|
|
_cogl_util_pixel_format_from_masks (visual->red_mask,
|
|
|
|
visual->green_mask,
|
|
|
|
visual->blue_mask,
|
|
|
|
image->depth,
|
|
|
|
image->bits_per_pixel,
|
|
|
|
image->byte_order == LSBFirst);
|
2010-05-25 13:56:14 -04:00
|
|
|
|
2012-11-09 12:55:54 -05:00
|
|
|
bpp = _cogl_pixel_format_get_bytes_per_pixel (image_format);
|
|
|
|
offset = image->bytes_per_line * src_y + bpp * src_x;
|
|
|
|
|
|
|
|
_cogl_texture_set_region (tex_pixmap->tex,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
image_format,
|
|
|
|
image->bytes_per_line,
|
|
|
|
((const uint8_t *) image->data) + offset,
|
|
|
|
x, y,
|
|
|
|
0, /* level */
|
|
|
|
&ignore);
|
2010-05-25 13:56:14 -04:00
|
|
|
|
|
|
|
/* If we have a shared memory segment then the XImage would be a
|
|
|
|
temporary one with no data allocated so we can just XFree it */
|
|
|
|
if (tex_pixmap->shm_info.shmid != -1)
|
|
|
|
XFree (image);
|
|
|
|
|
|
|
|
memset (&tex_pixmap->damage_rect, 0, sizeof (CoglDamageRectangle));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-03-01 09:43:43 -05:00
|
|
|
_cogl_texture_pixmap_x11_set_use_winsys_texture (CoglTexturePixmapX11 *tex_pixmap,
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
CoglBool new_value)
|
2010-05-25 13:56:14 -04:00
|
|
|
{
|
2011-03-01 09:43:43 -05:00
|
|
|
if (tex_pixmap->use_winsys_texture != new_value)
|
2010-05-25 13:56:14 -04:00
|
|
|
{
|
2010-10-27 13:54:57 -04:00
|
|
|
/* Notify cogl-pipeline.c that the texture's underlying GL texture
|
2010-05-25 13:56:14 -04:00
|
|
|
* storage is changing so it knows it may need to bind a new texture
|
|
|
|
* if the CoglTexture is reused with the same texture unit. */
|
2011-08-24 16:30:34 -04:00
|
|
|
_cogl_pipeline_texture_storage_change_notify (COGL_TEXTURE (tex_pixmap));
|
2010-05-25 13:56:14 -04:00
|
|
|
|
2011-03-01 09:43:43 -05:00
|
|
|
tex_pixmap->use_winsys_texture = new_value;
|
2010-05-25 13:56:14 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_cogl_texture_pixmap_x11_update (CoglTexturePixmapX11 *tex_pixmap,
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
CoglBool needs_mipmap)
|
2010-05-25 13:56:14 -04:00
|
|
|
{
|
2011-03-01 09:43:43 -05:00
|
|
|
if (tex_pixmap->winsys)
|
2010-05-25 13:56:14 -04:00
|
|
|
{
|
2011-02-25 06:29:08 -05:00
|
|
|
const CoglWinsysVtable *winsys =
|
|
|
|
_cogl_texture_pixmap_x11_get_winsys (tex_pixmap);
|
|
|
|
|
|
|
|
if (winsys->texture_pixmap_x11_update (tex_pixmap, needs_mipmap))
|
2011-03-01 09:43:43 -05:00
|
|
|
{
|
|
|
|
_cogl_texture_pixmap_x11_set_use_winsys_texture (tex_pixmap, TRUE);
|
|
|
|
return;
|
|
|
|
}
|
2010-05-25 13:56:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If it didn't work then fallback to using XGetImage. This may be
|
|
|
|
temporary */
|
2011-03-01 09:43:43 -05:00
|
|
|
_cogl_texture_pixmap_x11_set_use_winsys_texture (tex_pixmap, FALSE);
|
2010-05-25 13:56:14 -04:00
|
|
|
|
|
|
|
_cogl_texture_pixmap_x11_update_image_texture (tex_pixmap);
|
|
|
|
}
|
|
|
|
|
2012-04-16 09:14:10 -04:00
|
|
|
static CoglTexture *
|
2010-05-25 13:56:14 -04:00
|
|
|
_cogl_texture_pixmap_x11_get_texture (CoglTexturePixmapX11 *tex_pixmap)
|
|
|
|
{
|
2012-04-16 09:14:10 -04:00
|
|
|
CoglTexture *tex;
|
2010-05-25 13:56:14 -04:00
|
|
|
int i;
|
|
|
|
|
|
|
|
/* We try getting the texture twice, once without flushing the
|
|
|
|
updates and once with. If pre_paint has been called already then
|
|
|
|
we should have a good idea of which texture to use so we don't
|
|
|
|
want to mess with that by ensuring the updates. However, if we
|
|
|
|
couldn't find a texture then we'll just make a best guess by
|
|
|
|
flushing without expecting mipmap support and try again. This
|
|
|
|
would happen for example if an application calls
|
|
|
|
get_gl_texture before the first paint */
|
|
|
|
|
|
|
|
for (i = 0; i < 2; i++)
|
|
|
|
{
|
2011-03-01 09:43:43 -05:00
|
|
|
if (tex_pixmap->use_winsys_texture)
|
2011-02-25 06:29:08 -05:00
|
|
|
{
|
|
|
|
const CoglWinsysVtable *winsys =
|
|
|
|
_cogl_texture_pixmap_x11_get_winsys (tex_pixmap);
|
|
|
|
tex = winsys->texture_pixmap_x11_get_texture (tex_pixmap);
|
|
|
|
}
|
2010-05-25 13:56:14 -04:00
|
|
|
else
|
|
|
|
tex = tex_pixmap->tex;
|
|
|
|
|
|
|
|
if (tex)
|
|
|
|
return tex;
|
|
|
|
|
|
|
|
_cogl_texture_pixmap_x11_update (tex_pixmap, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
2012-04-16 09:14:10 -04:00
|
|
|
return NULL;
|
2010-05-25 13:56:14 -04:00
|
|
|
}
|
|
|
|
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
static CoglBool
|
2012-11-08 12:54:10 -05:00
|
|
|
_cogl_texture_pixmap_x11_set_region (CoglTexture *tex,
|
|
|
|
int src_x,
|
|
|
|
int src_y,
|
|
|
|
int dst_x,
|
|
|
|
int dst_y,
|
|
|
|
int dst_width,
|
|
|
|
int dst_height,
|
2012-11-09 12:55:54 -05:00
|
|
|
int level,
|
2012-11-08 12:54:10 -05:00
|
|
|
CoglBitmap *bmp,
|
|
|
|
CoglError **error)
|
2010-05-25 13:56:14 -04:00
|
|
|
{
|
|
|
|
/* This doesn't make much sense for texture from pixmap so it's not
|
|
|
|
supported */
|
2012-11-08 12:54:10 -05:00
|
|
|
_cogl_set_error (error,
|
|
|
|
COGL_SYSTEM_ERROR,
|
|
|
|
COGL_SYSTEM_ERROR_UNSUPPORTED,
|
|
|
|
"Explicitly setting a region of a TFP texture unsupported");
|
2010-05-25 13:56:14 -04:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
static CoglBool
|
|
|
|
_cogl_texture_pixmap_x11_get_data (CoglTexture *tex,
|
|
|
|
CoglPixelFormat format,
|
2012-09-26 12:05:01 -04:00
|
|
|
int rowstride,
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
uint8_t *data)
|
2010-05-25 13:56:14 -04:00
|
|
|
{
|
|
|
|
CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex);
|
2012-04-16 09:14:10 -04:00
|
|
|
CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
|
2010-05-25 13:56:14 -04:00
|
|
|
|
|
|
|
/* Forward on to the child texture */
|
|
|
|
return cogl_texture_get_data (child_tex, format, rowstride, data);
|
|
|
|
}
|
|
|
|
|
2011-10-08 09:13:03 -04:00
|
|
|
typedef struct _NormalizeCoordsWrapperData
|
|
|
|
{
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
CoglMetaTextureCallback callback;
|
|
|
|
void *user_data;
|
|
|
|
} NormalizeCoordsWrapperData;
|
|
|
|
|
|
|
|
static void
|
|
|
|
normalize_coords_wrapper_cb (CoglTexture *child_texture,
|
|
|
|
const float *child_texture_coords,
|
|
|
|
const float *meta_coords,
|
|
|
|
void *user_data)
|
|
|
|
{
|
|
|
|
NormalizeCoordsWrapperData *data = user_data;
|
|
|
|
float normalized_coords[4];
|
|
|
|
|
|
|
|
normalized_coords[0] = meta_coords[0] / data->width;
|
|
|
|
normalized_coords[1] = meta_coords[1] / data->height;
|
|
|
|
normalized_coords[2] = meta_coords[2] / data->width;
|
|
|
|
normalized_coords[3] = meta_coords[3] / data->height;
|
|
|
|
|
|
|
|
data->callback (child_texture,
|
|
|
|
child_texture_coords, normalized_coords,
|
|
|
|
data->user_data);
|
|
|
|
}
|
|
|
|
|
2010-05-25 13:56:14 -04:00
|
|
|
static void
|
|
|
|
_cogl_texture_pixmap_x11_foreach_sub_texture_in_region
|
|
|
|
(CoglTexture *tex,
|
|
|
|
float virtual_tx_1,
|
|
|
|
float virtual_ty_1,
|
|
|
|
float virtual_tx_2,
|
|
|
|
float virtual_ty_2,
|
2011-10-08 09:13:03 -04:00
|
|
|
CoglMetaTextureCallback callback,
|
2010-05-25 13:56:14 -04:00
|
|
|
void *user_data)
|
|
|
|
{
|
|
|
|
CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex);
|
2012-04-16 09:14:10 -04:00
|
|
|
CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
|
2010-05-25 13:56:14 -04:00
|
|
|
|
|
|
|
/* Forward on to the child texture */
|
2011-10-08 09:13:03 -04:00
|
|
|
|
|
|
|
/* tfp textures may be implemented in terms of a
|
|
|
|
* CoglTextureRectangle texture which uses un-normalized texture
|
|
|
|
* coordinates but we want to consistently deal with normalized
|
|
|
|
* texture coordinates with CoglTexturePixmapX11... */
|
2011-10-14 04:25:12 -04:00
|
|
|
if (cogl_is_texture_rectangle (child_tex))
|
2011-10-08 09:13:03 -04:00
|
|
|
{
|
|
|
|
NormalizeCoordsWrapperData data;
|
2012-11-22 16:46:54 -05:00
|
|
|
int width = tex->width;
|
|
|
|
int height = tex->height;
|
2011-10-08 09:13:03 -04:00
|
|
|
|
|
|
|
virtual_tx_1 *= width;
|
|
|
|
virtual_ty_1 *= height;
|
|
|
|
virtual_tx_2 *= width;
|
|
|
|
virtual_ty_2 *= height;
|
|
|
|
|
|
|
|
data.width = width;
|
|
|
|
data.height = height;
|
|
|
|
data.callback = callback;
|
|
|
|
data.user_data = user_data;
|
|
|
|
|
2011-12-19 17:53:31 -05:00
|
|
|
cogl_meta_texture_foreach_in_region (COGL_META_TEXTURE (child_tex),
|
2011-10-08 09:13:03 -04:00
|
|
|
virtual_tx_1,
|
|
|
|
virtual_ty_1,
|
|
|
|
virtual_tx_2,
|
|
|
|
virtual_ty_2,
|
|
|
|
COGL_PIPELINE_WRAP_MODE_REPEAT,
|
|
|
|
COGL_PIPELINE_WRAP_MODE_REPEAT,
|
|
|
|
normalize_coords_wrapper_cb,
|
|
|
|
&data);
|
|
|
|
}
|
|
|
|
else
|
2011-12-19 17:53:31 -05:00
|
|
|
cogl_meta_texture_foreach_in_region (COGL_META_TEXTURE (child_tex),
|
2011-10-08 09:13:03 -04:00
|
|
|
virtual_tx_1,
|
|
|
|
virtual_ty_1,
|
|
|
|
virtual_tx_2,
|
|
|
|
virtual_ty_2,
|
|
|
|
COGL_PIPELINE_WRAP_MODE_REPEAT,
|
|
|
|
COGL_PIPELINE_WRAP_MODE_REPEAT,
|
|
|
|
callback,
|
|
|
|
user_data);
|
2010-05-25 13:56:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_cogl_texture_pixmap_x11_get_max_waste (CoglTexture *tex)
|
|
|
|
{
|
|
|
|
CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex);
|
2012-04-16 09:14:10 -04:00
|
|
|
CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
|
2010-05-25 13:56:14 -04:00
|
|
|
|
|
|
|
return cogl_texture_get_max_waste (child_tex);
|
|
|
|
}
|
|
|
|
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
static CoglBool
|
2010-05-25 13:56:14 -04:00
|
|
|
_cogl_texture_pixmap_x11_is_sliced (CoglTexture *tex)
|
|
|
|
{
|
|
|
|
CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex);
|
2012-04-16 09:14:10 -04:00
|
|
|
CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
|
2010-05-25 13:56:14 -04:00
|
|
|
|
|
|
|
return cogl_texture_is_sliced (child_tex);
|
|
|
|
}
|
|
|
|
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
static CoglBool
|
2010-05-25 13:56:14 -04:00
|
|
|
_cogl_texture_pixmap_x11_can_hardware_repeat (CoglTexture *tex)
|
|
|
|
{
|
|
|
|
CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex);
|
2012-04-16 09:14:10 -04:00
|
|
|
CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
|
2010-05-25 13:56:14 -04:00
|
|
|
|
2011-06-10 13:43:56 -04:00
|
|
|
return _cogl_texture_can_hardware_repeat (child_tex);
|
2010-05-25 13:56:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_cogl_texture_pixmap_x11_transform_coords_to_gl (CoglTexture *tex,
|
|
|
|
float *s,
|
|
|
|
float *t)
|
|
|
|
{
|
|
|
|
CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex);
|
2012-04-16 09:14:10 -04:00
|
|
|
CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
|
2010-05-25 13:56:14 -04:00
|
|
|
|
|
|
|
/* Forward on to the child texture */
|
|
|
|
_cogl_texture_transform_coords_to_gl (child_tex, s, t);
|
|
|
|
}
|
|
|
|
|
|
|
|
static CoglTransformResult
|
|
|
|
_cogl_texture_pixmap_x11_transform_quad_coords_to_gl (CoglTexture *tex,
|
|
|
|
float *coords)
|
|
|
|
{
|
|
|
|
CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex);
|
2012-04-16 09:14:10 -04:00
|
|
|
CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
|
2010-05-25 13:56:14 -04:00
|
|
|
|
|
|
|
/* Forward on to the child texture */
|
|
|
|
return _cogl_texture_transform_quad_coords_to_gl (child_tex, coords);
|
|
|
|
}
|
|
|
|
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
static CoglBool
|
2010-05-25 13:56:14 -04:00
|
|
|
_cogl_texture_pixmap_x11_get_gl_texture (CoglTexture *tex,
|
|
|
|
GLuint *out_gl_handle,
|
|
|
|
GLenum *out_gl_target)
|
|
|
|
{
|
|
|
|
CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex);
|
2012-04-16 09:14:10 -04:00
|
|
|
CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
|
2010-05-25 13:56:14 -04:00
|
|
|
|
|
|
|
/* Forward on to the child texture */
|
|
|
|
return cogl_texture_get_gl_texture (child_tex,
|
|
|
|
out_gl_handle,
|
|
|
|
out_gl_target);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-09-10 15:35:39 -04:00
|
|
|
_cogl_texture_pixmap_x11_gl_flush_legacy_texobj_filters (CoglTexture *tex,
|
|
|
|
GLenum min_filter,
|
|
|
|
GLenum mag_filter)
|
2010-05-25 13:56:14 -04:00
|
|
|
{
|
|
|
|
CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex);
|
2012-04-16 09:14:10 -04:00
|
|
|
CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
|
2010-05-25 13:56:14 -04:00
|
|
|
|
|
|
|
/* Forward on to the child texture */
|
2012-09-10 15:35:39 -04:00
|
|
|
_cogl_texture_gl_flush_legacy_texobj_filters (child_tex,
|
|
|
|
min_filter, mag_filter);
|
2010-05-25 13:56:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_cogl_texture_pixmap_x11_pre_paint (CoglTexture *tex,
|
|
|
|
CoglTexturePrePaintFlags flags)
|
|
|
|
{
|
|
|
|
CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex);
|
2012-04-16 09:14:10 -04:00
|
|
|
CoglTexture *child_tex;
|
2010-05-25 13:56:14 -04:00
|
|
|
|
|
|
|
_cogl_texture_pixmap_x11_update (tex_pixmap,
|
|
|
|
!!(flags & COGL_TEXTURE_NEEDS_MIPMAP));
|
|
|
|
|
|
|
|
child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
|
|
|
|
|
|
|
|
_cogl_texture_pre_paint (child_tex, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_cogl_texture_pixmap_x11_ensure_non_quad_rendering (CoglTexture *tex)
|
|
|
|
{
|
|
|
|
CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex);
|
2012-04-16 09:14:10 -04:00
|
|
|
CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
|
2010-05-25 13:56:14 -04:00
|
|
|
|
|
|
|
/* Forward on to the child texture */
|
|
|
|
_cogl_texture_ensure_non_quad_rendering (child_tex);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-09-10 15:35:39 -04:00
|
|
|
_cogl_texture_pixmap_x11_gl_flush_legacy_texobj_wrap_modes (CoglTexture *tex,
|
|
|
|
GLenum wrap_mode_s,
|
|
|
|
GLenum wrap_mode_t,
|
|
|
|
GLenum wrap_mode_p)
|
2010-05-25 13:56:14 -04:00
|
|
|
{
|
|
|
|
CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex);
|
2012-04-16 09:14:10 -04:00
|
|
|
CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
|
2010-05-25 13:56:14 -04:00
|
|
|
|
|
|
|
/* Forward on to the child texture */
|
2012-09-10 15:35:39 -04:00
|
|
|
_cogl_texture_gl_flush_legacy_texobj_wrap_modes (child_tex,
|
|
|
|
wrap_mode_s,
|
|
|
|
wrap_mode_t,
|
|
|
|
wrap_mode_p);
|
2010-05-25 13:56:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static CoglPixelFormat
|
|
|
|
_cogl_texture_pixmap_x11_get_format (CoglTexture *tex)
|
|
|
|
{
|
|
|
|
CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex);
|
2012-04-16 09:14:10 -04:00
|
|
|
CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
|
2010-05-25 13:56:14 -04:00
|
|
|
|
|
|
|
/* Forward on to the child texture */
|
2013-06-27 13:33:04 -04:00
|
|
|
return _cogl_texture_get_format (child_tex);
|
2010-05-25 13:56:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static GLenum
|
|
|
|
_cogl_texture_pixmap_x11_get_gl_format (CoglTexture *tex)
|
|
|
|
{
|
|
|
|
CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex);
|
2012-04-16 09:14:10 -04:00
|
|
|
CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
|
2010-05-25 13:56:14 -04:00
|
|
|
|
2012-11-22 16:31:25 -05:00
|
|
|
return _cogl_texture_gl_get_format (child_tex);
|
2010-05-25 13:56:14 -04:00
|
|
|
}
|
|
|
|
|
2012-02-09 06:19:04 -05:00
|
|
|
static CoglTextureType
|
|
|
|
_cogl_texture_pixmap_x11_get_type (CoglTexture *tex)
|
|
|
|
{
|
|
|
|
CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex);
|
|
|
|
CoglTexture *child_tex;
|
|
|
|
|
|
|
|
child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
|
|
|
|
|
|
|
|
/* Forward on to the child texture */
|
|
|
|
return _cogl_texture_get_type (child_tex);
|
|
|
|
}
|
|
|
|
|
2010-05-25 13:56:14 -04:00
|
|
|
static void
|
|
|
|
_cogl_texture_pixmap_x11_free (CoglTexturePixmapX11 *tex_pixmap)
|
|
|
|
{
|
2012-11-05 08:45:40 -05:00
|
|
|
Display *display;
|
|
|
|
|
2011-05-27 07:30:23 -04:00
|
|
|
_COGL_GET_CONTEXT (ctxt, NO_RETVAL);
|
|
|
|
|
2012-11-05 08:45:40 -05:00
|
|
|
display = cogl_xlib_renderer_get_display (ctxt->display->renderer);
|
|
|
|
|
2011-05-27 07:30:23 -04:00
|
|
|
set_damage_object_internal (ctxt, tex_pixmap, 0, 0);
|
2010-05-25 13:56:14 -04:00
|
|
|
|
|
|
|
if (tex_pixmap->image)
|
|
|
|
XDestroyImage (tex_pixmap->image);
|
|
|
|
|
|
|
|
if (tex_pixmap->shm_info.shmid != -1)
|
|
|
|
{
|
2012-11-05 08:45:40 -05:00
|
|
|
XShmDetach (display, &tex_pixmap->shm_info);
|
2010-05-25 13:56:14 -04:00
|
|
|
shmdt (tex_pixmap->shm_info.shmaddr);
|
|
|
|
shmctl (tex_pixmap->shm_info.shmid, IPC_RMID, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tex_pixmap->tex)
|
2012-04-16 09:14:10 -04:00
|
|
|
cogl_object_unref (tex_pixmap->tex);
|
2010-05-25 13:56:14 -04:00
|
|
|
|
2011-03-01 09:43:43 -05:00
|
|
|
if (tex_pixmap->winsys)
|
2011-02-25 06:29:08 -05:00
|
|
|
{
|
|
|
|
const CoglWinsysVtable *winsys =
|
|
|
|
_cogl_texture_pixmap_x11_get_winsys (tex_pixmap);
|
|
|
|
winsys->texture_pixmap_x11_free (tex_pixmap);
|
|
|
|
}
|
2010-05-25 13:56:14 -04:00
|
|
|
|
|
|
|
/* Chain up */
|
|
|
|
_cogl_texture_free (COGL_TEXTURE (tex_pixmap));
|
|
|
|
}
|
|
|
|
|
|
|
|
static const CoglTextureVtable
|
|
|
|
cogl_texture_pixmap_x11_vtable =
|
|
|
|
{
|
2012-04-04 10:09:43 -04:00
|
|
|
FALSE, /* not primitive */
|
2012-11-22 18:01:08 -05:00
|
|
|
_cogl_texture_pixmap_x11_allocate,
|
2010-05-25 13:56:14 -04:00
|
|
|
_cogl_texture_pixmap_x11_set_region,
|
|
|
|
_cogl_texture_pixmap_x11_get_data,
|
|
|
|
_cogl_texture_pixmap_x11_foreach_sub_texture_in_region,
|
|
|
|
_cogl_texture_pixmap_x11_get_max_waste,
|
|
|
|
_cogl_texture_pixmap_x11_is_sliced,
|
|
|
|
_cogl_texture_pixmap_x11_can_hardware_repeat,
|
|
|
|
_cogl_texture_pixmap_x11_transform_coords_to_gl,
|
|
|
|
_cogl_texture_pixmap_x11_transform_quad_coords_to_gl,
|
|
|
|
_cogl_texture_pixmap_x11_get_gl_texture,
|
2012-09-10 15:35:39 -04:00
|
|
|
_cogl_texture_pixmap_x11_gl_flush_legacy_texobj_filters,
|
2010-05-25 13:56:14 -04:00
|
|
|
_cogl_texture_pixmap_x11_pre_paint,
|
|
|
|
_cogl_texture_pixmap_x11_ensure_non_quad_rendering,
|
2012-09-10 15:35:39 -04:00
|
|
|
_cogl_texture_pixmap_x11_gl_flush_legacy_texobj_wrap_modes,
|
2010-05-25 13:56:14 -04:00
|
|
|
_cogl_texture_pixmap_x11_get_format,
|
|
|
|
_cogl_texture_pixmap_x11_get_gl_format,
|
2012-02-09 06:19:04 -05:00
|
|
|
_cogl_texture_pixmap_x11_get_type,
|
2012-04-04 10:09:43 -04:00
|
|
|
NULL, /* is_foreign */
|
|
|
|
NULL /* set_auto_mipmap */
|
2010-05-25 13:56:14 -04:00
|
|
|
};
|