[cogl/wip/rig: 28/34] texture-pixmap-x11: avoid depending on _GET_CONTEXT
- From: Robert Bragg <rbragg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl/wip/rig: 28/34] texture-pixmap-x11: avoid depending on _GET_CONTEXT
- Date: Thu, 20 Mar 2014 18:04:01 +0000 (UTC)
commit d6928b5c9d0649e12d4131ca351368084884e29b
Author: Robert Bragg <robert bragg intel com>
Date: Mon Mar 17 14:23:57 2014 +0000
texture-pixmap-x11: avoid depending on _GET_CONTEXT
This updates cogl-texture-pixmap-x11.c so it no longer depends on a
global CoglContext. This also avoids depending on the deprecated
cogl_xlib_ api that depends on COGL_GET_CONTEXT() in favour of the
cogl_xlib_renderer_ API.
cogl/cogl-context-private.h | 2 +-
cogl/cogl-xlib-private.h | 12 --------
cogl/cogl-xlib-renderer-private.h | 16 ++++++++++-
cogl/cogl-xlib-renderer.c | 8 +++++
cogl/cogl-xlib.c | 1 +
cogl/winsys/cogl-texture-pixmap-x11.c | 48 +++++++++++++++------------------
6 files changed, 47 insertions(+), 40 deletions(-)
---
diff --git a/cogl/cogl-context-private.h b/cogl/cogl-context-private.h
index 291c680..489eae0 100644
--- a/cogl/cogl-context-private.h
+++ b/cogl/cogl-context-private.h
@@ -36,7 +36,7 @@
#include "cogl-flags.h"
#ifdef COGL_HAS_XLIB_SUPPORT
-#include "cogl-xlib-private.h"
+#include "cogl-xlib-renderer-private.h"
#endif
#include "cogl-display-private.h"
diff --git a/cogl/cogl-xlib-private.h b/cogl/cogl-xlib-private.h
index 4a8472d..fa3fd3d 100644
--- a/cogl/cogl-xlib-private.h
+++ b/cogl/cogl-xlib-private.h
@@ -33,18 +33,6 @@
#include <X11/Xlib.h>
-typedef struct _CoglXlibTrapState CoglXlibTrapState;
-
-struct _CoglXlibTrapState
-{
- /* These values are intended to be internal to
- * _cogl_xlib_{un,}trap_errors but they need to be in the header so
- * that the struct can be allocated on the stack */
- int (* old_error_handler) (Display *, XErrorEvent *);
- int trapped_error_code;
- CoglXlibTrapState *old_state;
-};
-
void
_cogl_xlib_query_damage_extension (void);
diff --git a/cogl/cogl-xlib-renderer-private.h b/cogl/cogl-xlib-renderer-private.h
index 9ec5548..88a8c32 100644
--- a/cogl/cogl-xlib-renderer-private.h
+++ b/cogl/cogl-xlib-renderer-private.h
@@ -32,11 +32,22 @@
#define __COGL_RENDERER_XLIB_PRIVATE_H
#include "cogl-object-private.h"
-#include "cogl-xlib-private.h"
#include "cogl-x11-renderer-private.h"
#include "cogl-context.h"
#include "cogl-output.h"
+typedef struct _CoglXlibTrapState CoglXlibTrapState;
+
+struct _CoglXlibTrapState
+{
+ /* These values are intended to be internal to
+ * _cogl_xlib_{un,}trap_errors but they need to be in the header so
+ * that the struct can be allocated on the stack */
+ int (* old_error_handler) (Display *, XErrorEvent *);
+ int trapped_error_code;
+ CoglXlibTrapState *old_state;
+};
+
typedef struct _CoglXlibRenderer
{
CoglX11Renderer _parent;
@@ -98,4 +109,7 @@ _cogl_xlib_renderer_output_for_rectangle (CoglRenderer *renderer,
int width,
int height);
+int
+_cogl_xlib_renderer_get_damage_base (CoglRenderer *renderer);
+
#endif /* __COGL_RENDERER_XLIB_PRIVATE_H */
diff --git a/cogl/cogl-xlib-renderer.c b/cogl/cogl-xlib-renderer.c
index 9c44a9c..fc0338a 100644
--- a/cogl/cogl-xlib-renderer.c
+++ b/cogl/cogl-xlib-renderer.c
@@ -658,3 +658,11 @@ _cogl_xlib_renderer_output_for_rectangle (CoglRenderer *renderer,
return max_overlapped;
}
+
+int
+_cogl_xlib_renderer_get_damage_base (CoglRenderer *renderer)
+{
+ CoglX11Renderer *x11_renderer =
+ (CoglX11Renderer *)_cogl_xlib_renderer_get_data (renderer);
+ return x11_renderer->damage_base;
+}
diff --git a/cogl/cogl-xlib.c b/cogl/cogl-xlib.c
index 30207a1..f83747e 100644
--- a/cogl/cogl-xlib.c
+++ b/cogl/cogl-xlib.c
@@ -47,6 +47,7 @@
#include <X11/extensions/Xdamage.h>
#include "cogl-xlib.h"
+#include "cogl-xlib-private.h"
/* These three functions are wrappers around the equivalent renderer
functions. They can be removed once all xlib-based backends in
diff --git a/cogl/winsys/cogl-texture-pixmap-x11.c b/cogl/winsys/cogl-texture-pixmap-x11.c
index 9c0fd99..534f717 100644
--- a/cogl/winsys/cogl-texture-pixmap-x11.c
+++ b/cogl/winsys/cogl-texture-pixmap-x11.c
@@ -122,9 +122,8 @@ cogl_damage_rectangle_is_whole (const CoglDamageRectangle *damage_rect,
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);
+ CoglTexture *tex = COGL_TEXTURE (tex_pixmap);
+ CoglContext *ctx = tex->context;
return ctx->display->renderer->winsys_vtable;
}
@@ -134,13 +133,12 @@ process_damage_event (CoglTexturePixmapX11 *tex_pixmap,
XDamageNotifyEvent *damage_event)
{
CoglTexture *tex = COGL_TEXTURE (tex_pixmap);
+ CoglContext *ctx = tex->context;
Display *display;
enum { DO_NOTHING, NEEDS_SUBTRACT, NEED_BOUNDING_BOX } handle_mode;
const CoglWinsysVtable *winsys;
- _COGL_GET_CONTEXT (ctxt, NO_RETVAL);
-
- display = cogl_xlib_renderer_get_display (ctxt->display->renderer);
+ display = cogl_xlib_renderer_get_display (ctx->display->renderer);
COGL_NOTE (TEXTURE_PIXMAP, "Damage event received for %p", tex_pixmap);
@@ -236,11 +234,11 @@ static CoglFilterReturn
_cogl_texture_pixmap_x11_filter (XEvent *event, void *data)
{
CoglTexturePixmapX11 *tex_pixmap = data;
+ CoglTexture *tex = COGL_TEXTURE (tex_pixmap);
+ CoglContext *ctx = tex->context;
int damage_base;
- _COGL_GET_CONTEXT (ctxt, COGL_FILTER_CONTINUE);
-
- damage_base = _cogl_xlib_get_damage_base ();
+ damage_base = _cogl_xlib_renderer_get_damage_base (ctx->display->renderer);
if (event->type == damage_base + XDamageNotify)
{
XDamageNotifyEvent *damage_event = (XDamageNotifyEvent *) event;
@@ -283,13 +281,13 @@ set_damage_object_internal (CoglContext *ctx,
}
CoglTexturePixmapX11 *
-cogl_texture_pixmap_x11_new (CoglContext *ctxt,
+cogl_texture_pixmap_x11_new (CoglContext *ctx,
uint32_t pixmap,
CoglBool automatic_updates,
CoglError **error)
{
CoglTexturePixmapX11 *tex_pixmap = u_new (CoglTexturePixmapX11, 1);
- Display *display = cogl_xlib_renderer_get_display (ctxt->display->renderer);
+ Display *display = cogl_xlib_renderer_get_display (ctx->display->renderer);
Window pixmap_root_window;
int pixmap_x, pixmap_y;
unsigned int pixmap_width, pixmap_height;
@@ -319,7 +317,7 @@ cogl_texture_pixmap_x11_new (CoglContext *ctxt,
? COGL_PIXEL_FORMAT_RGBA_8888_PRE
: COGL_PIXEL_FORMAT_RGB_888);
- _cogl_texture_init (tex, ctxt, pixmap_width, pixmap_height,
+ _cogl_texture_init (tex, ctx, pixmap_width, pixmap_height,
internal_format,
NULL, /* no loader */
&cogl_texture_pixmap_x11_vtable);
@@ -348,13 +346,13 @@ cogl_texture_pixmap_x11_new (CoglContext *ctxt,
/* If automatic updates are requested and the Xlib connection
supports damage events then we'll register a damage object on the
pixmap */
- damage_base = _cogl_xlib_get_damage_base ();
+ damage_base = _cogl_xlib_renderer_get_damage_base (ctx->display->renderer);
if (automatic_updates && damage_base >= 0)
{
Damage damage = XDamageCreate (display,
pixmap,
XDamageReportBoundingBox);
- set_damage_object_internal (ctxt,
+ set_damage_object_internal (ctx,
tex_pixmap,
damage,
COGL_TEXTURE_PIXMAP_X11_DAMAGE_BOUNDING_BOX);
@@ -398,11 +396,10 @@ static void
try_alloc_shm (CoglTexturePixmapX11 *tex_pixmap)
{
CoglTexture *tex = COGL_TEXTURE (tex_pixmap);
+ CoglContext *ctx = tex->context;
XImage *dummy_image;
Display *display;
- _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
display = cogl_xlib_renderer_get_display (ctx->display->renderer);
if (!XShmQueryExtension (display))
@@ -499,13 +496,13 @@ cogl_texture_pixmap_x11_set_damage_object (CoglTexturePixmapX11 *tex_pixmap,
CoglTexturePixmapX11ReportLevel
report_level)
{
+ CoglTexture *tex = COGL_TEXTURE (tex_pixmap);
+ CoglContext *ctx = tex->context;
int damage_base;
- _COGL_GET_CONTEXT (ctxt, NO_RETVAL);
-
- damage_base = _cogl_xlib_get_damage_base ();
+ damage_base = _cogl_xlib_renderer_get_damage_base (ctx->display->renderer);
if (damage_base >= 0)
- set_damage_object_internal (ctxt, tex_pixmap, damage, report_level);
+ set_damage_object_internal (ctx, tex_pixmap, damage, report_level);
}
static CoglTexture *
@@ -560,6 +557,7 @@ static void
_cogl_texture_pixmap_x11_update_image_texture (CoglTexturePixmapX11 *tex_pixmap)
{
CoglTexture *tex = COGL_TEXTURE (tex_pixmap);
+ CoglContext *ctx = tex->context;
Display *display;
Visual *visual;
CoglPixelFormat image_format;
@@ -570,8 +568,6 @@ _cogl_texture_pixmap_x11_update_image_texture (CoglTexturePixmapX11 *tex_pixmap)
int offset;
CoglError *ignore = NULL;
- _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
display = cogl_xlib_renderer_get_display (ctx->display->renderer);
visual = tex_pixmap->visual;
@@ -1033,13 +1029,13 @@ _cogl_texture_pixmap_x11_get_type (CoglTexture *tex)
static void
_cogl_texture_pixmap_x11_free (CoglTexturePixmapX11 *tex_pixmap)
{
+ CoglTexture *tex = COGL_TEXTURE (tex_pixmap);
+ CoglContext *ctx = tex->context;
Display *display;
- _COGL_GET_CONTEXT (ctxt, NO_RETVAL);
-
- display = cogl_xlib_renderer_get_display (ctxt->display->renderer);
+ display = cogl_xlib_renderer_get_display (ctx->display->renderer);
- set_damage_object_internal (ctxt, tex_pixmap, 0, 0);
+ set_damage_object_internal (ctx, tex_pixmap, 0, 0);
if (tex_pixmap->image)
XDestroyImage (tex_pixmap->image);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]