xephyr: Remove DRI1

This only worked if the backend server supported DRI1, which is
stunningly unlikely these days.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
This commit is contained in:
Adam Jackson 2015-12-08 17:41:38 -05:00
parent 953b71270c
commit 623ff251dd
13 changed files with 0 additions and 3490 deletions

View File

@ -46,19 +46,6 @@ GLAMOR_SRCS = \
$()
endif
if DRI
DRI_SRCS = \
ephyrdriext.c \
ephyrdriext.h \
ephyrdri.c \
ephyrdri.h \
ephyrglxext.c \
ephyrglxext.h \
ephyrhostglx.c \
ephyrhostglx.h \
$()
endif
bin_PROGRAMS = Xephyr
Xephyr_SOURCES = \
@ -72,7 +59,6 @@ Xephyr_SOURCES = \
hostx.c \
hostx.h \
$(XV_SRCS) \
$(DRI_SRCS) \
$(GLAMOR_SRCS) \
$()

View File

@ -36,13 +36,6 @@
#include "scrnintstr.h"
#include "ephyrlog.h"
#ifdef XF86DRI
#include <xcb/xf86dri.h>
#include "ephyrdri.h"
#include "ephyrdriext.h"
#include "ephyrglxext.h"
#endif /* XF86DRI */
#ifdef GLAMOR
#include "glamor.h"
#endif
@ -658,16 +651,6 @@ ephyrInitScreen(ScreenPtr pScreen)
}
}
#endif /*XV*/
#ifdef XF86DRI
if (!ephyrNoDRI && !hostx_has_extension(&xcb_xf86dri_id)) {
EPHYR_LOG("host x does not support DRI. Disabling DRI forwarding\n");
ephyrNoDRI = TRUE;
}
if (!ephyrNoDRI) {
ephyrDRIExtensionInit(pScreen);
ephyrHijackGLXExtension();
}
#endif
return TRUE;
}
@ -849,40 +832,6 @@ miPointerScreenFuncRec ephyrPointerScreenFuncs = {
ephyrWarpCursor,
};
#ifdef XF86DRI
/**
* find if the remote window denoted by a_remote
* is paired with an internal Window within the Xephyr server.
* If the remove window is paired with an internal window, send an
* expose event to the client insterested in the internal window expose event.
*
* Pairing happens when a drawable inside Xephyr is associated with
* a GL surface in a DRI environment.
* Look at the function ProcXF86DRICreateDrawable in ephyrdriext.c to
* know a paired window is created.
*
* This is useful to make GL drawables (only windows for now) handle
* expose events and send those events to clients.
*/
static void
ephyrExposePairedWindow(int a_remote)
{
EphyrWindowPair *pair = NULL;
RegionRec reg;
ScreenPtr screen;
if (!findWindowPairFromRemote(a_remote, &pair)) {
EPHYR_LOG("did not find a pair for this window\n");
return;
}
screen = pair->local->drawable.pScreen;
RegionNull(&reg);
RegionCopy(&reg, &pair->local->clipList);
screen->WindowExposures(pair->local, &reg);
RegionUninit(&reg);
}
#endif /* XF86DRI */
static KdScreenInfo *
screen_from_window(Window w)
{
@ -939,16 +888,6 @@ ephyrProcessExpose(xcb_generic_event_t *xev)
scrpriv->win_height);
} else {
EPHYR_LOG_ERROR("failed to get host screen\n");
#ifdef XF86DRI
/*
* We only receive expose events when the expose event
* have be generated for a drawable that is a host X
* window managed by Xephyr. Host X windows managed by
* Xephyr exists for instance when Xephyr is asked to
* create a GL drawable in a DRI environment.
*/
ephyrExposePairedWindow(expose->window);
#endif /* XF86DRI */
}
}
@ -974,25 +913,10 @@ ephyrProcessMouseMotion(xcb_generic_event_t *xev)
else {
int x = 0, y = 0;
#ifdef XF86DRI
EphyrWindowPair *pair = NULL;
#endif
EPHYR_LOG("enqueuing mouse motion:%d\n", screen->pScreen->myNum);
x = motion->event_x;
y = motion->event_y;
EPHYR_LOG("initial (x,y):(%d,%d)\n", x, y);
#ifdef XF86DRI
EPHYR_LOG("is this window peered by a gl drawable ?\n");
if (findWindowPairFromRemote(motion->event, &pair)) {
EPHYR_LOG("yes, it is peered\n");
x += pair->local->drawable.x;
y += pair->local->drawable.y;
}
else {
EPHYR_LOG("no, it is not peered\n");
}
EPHYR_LOG("final (x,y):(%d,%d)\n", x, y);
#endif
/* convert coords into desktop-wide coordinates.
* fill_pointer_events will convert that back to

View File

@ -1,356 +0,0 @@
/*
* Xephyr - A kdrive X server thats runs in a host X window.
* Authored by Matthew Allum <mallum@openedhand.com>
*
* Copyright © 2007 OpenedHand Ltd
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of OpenedHand Ltd not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. OpenedHand Ltd makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* Authors:
* Dodji Seketeli <dodji@openedhand.com>
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include <X11/Xdefs.h>
#include <xcb/xf86dri.h>
#include "hostx.h"
#include "ephyrdri.h"
#define _HAVE_XALLOC_DECLS
#include "ephyrlog.h"
#include "dixstruct.h"
#include "pixmapstr.h"
#ifndef TRUE
#define TRUE 1
#endif /*TRUE*/
#ifndef FALSE
#define FALSE 0
#endif /*FALSE*/
Bool
ephyrDRIQueryDirectRenderingCapable(int a_screen, Bool *a_is_capable)
{
xcb_connection_t *conn = hostx_get_xcbconn();
Bool is_ok = FALSE;
xcb_xf86dri_query_direct_rendering_capable_cookie_t cookie;
xcb_xf86dri_query_direct_rendering_capable_reply_t *reply;
EPHYR_RETURN_VAL_IF_FAIL(a_is_capable, FALSE);
EPHYR_LOG("enter\n");
cookie = xcb_xf86dri_query_direct_rendering_capable(conn,
hostx_get_screen());
reply = xcb_xf86dri_query_direct_rendering_capable_reply(conn, cookie, NULL);
if (reply) {
is_ok = TRUE;
*a_is_capable = reply->is_capable;
free(reply);
}
EPHYR_LOG("leave. is_capable:%d, is_ok=%d\n", *a_is_capable, is_ok);
return is_ok;
}
Bool
ephyrDRIOpenConnection(int a_screen,
drm_handle_t * a_sarea, char **a_bus_id_string)
{
xcb_connection_t *conn = hostx_get_xcbconn();
Bool is_ok = FALSE;
xcb_xf86dri_open_connection_cookie_t cookie;
xcb_xf86dri_open_connection_reply_t *reply;
EPHYR_RETURN_VAL_IF_FAIL(a_bus_id_string, FALSE);
EPHYR_LOG("enter. screen:%d\n", a_screen);
cookie = xcb_xf86dri_open_connection(conn, hostx_get_screen());
reply = xcb_xf86dri_open_connection_reply(conn, cookie, NULL);
if (!reply)
goto out;
*a_sarea = reply->sarea_handle_low;
if (sizeof(drm_handle_t) == 8) {
int shift = 32;
*a_sarea |= ((drm_handle_t) reply->sarea_handle_high) << shift;
}
*a_bus_id_string = malloc(reply->bus_id_len + 1);
if (!*a_bus_id_string)
goto out;
memcpy(*a_bus_id_string, xcb_xf86dri_open_connection_bus_id(reply), reply->bus_id_len);
*a_bus_id_string[reply->bus_id_len] = '\0';
is_ok = TRUE;
out:
free(reply);
EPHYR_LOG("leave. bus_id_string:%s, is_ok:%d\n", *a_bus_id_string, is_ok);
return is_ok;
}
Bool
ephyrDRIAuthConnection(int a_screen, drm_magic_t a_magic)
{
xcb_connection_t *conn = hostx_get_xcbconn();
int screen = hostx_get_screen();
xcb_xf86dri_auth_connection_cookie_t cookie;
xcb_xf86dri_auth_connection_reply_t *reply;
Bool is_ok = FALSE;
EPHYR_LOG("enter\n");
cookie = xcb_xf86dri_auth_connection(conn, screen, a_magic);
reply = xcb_xf86dri_auth_connection_reply(conn, cookie, NULL);
is_ok = reply->authenticated;
free(reply);
EPHYR_LOG("leave. is_ok:%d\n", is_ok);
return is_ok;
}
Bool
ephyrDRICloseConnection(int a_screen)
{
xcb_connection_t *conn = hostx_get_xcbconn();
int screen = hostx_get_screen();
EPHYR_LOG("enter\n");
xcb_xf86dri_close_connection(conn, screen);
EPHYR_LOG("leave\n");
return TRUE;
}
Bool
ephyrDRIGetClientDriverName(int a_screen,
int *a_ddx_driver_major_version,
int *a_ddx_driver_minor_version,
int *a_ddx_driver_patch_version,
char **a_client_driver_name)
{
xcb_connection_t *conn = hostx_get_xcbconn();
int screen = hostx_get_screen();
xcb_xf86dri_get_client_driver_name_cookie_t cookie;
xcb_xf86dri_get_client_driver_name_reply_t *reply;
Bool is_ok = FALSE;
EPHYR_RETURN_VAL_IF_FAIL(a_ddx_driver_major_version
&& a_ddx_driver_minor_version
&& a_ddx_driver_patch_version
&& a_client_driver_name, FALSE);
EPHYR_LOG("enter\n");
cookie = xcb_xf86dri_get_client_driver_name(conn, screen);
reply = xcb_xf86dri_get_client_driver_name_reply(conn, cookie, NULL);
if (!reply)
goto out;
*a_ddx_driver_major_version = reply->client_driver_major_version;
*a_ddx_driver_minor_version = reply->client_driver_minor_version;
*a_ddx_driver_patch_version = reply->client_driver_patch_version;
*a_client_driver_name = malloc(reply->client_driver_name_len + 1);
if (!*a_client_driver_name)
goto out;
memcpy(*a_client_driver_name,
xcb_xf86dri_get_client_driver_name_client_driver_name(reply),
reply->client_driver_name_len);
(*a_client_driver_name)[reply->client_driver_name_len] = '\0';
is_ok = TRUE;
EPHYR_LOG("major:%d, minor:%d, patch:%d, name:%s\n",
*a_ddx_driver_major_version,
*a_ddx_driver_minor_version,
*a_ddx_driver_patch_version, *a_client_driver_name);
out:
free(reply);
EPHYR_LOG("leave:%d\n", is_ok);
return is_ok;
}
Bool
ephyrDRICreateContext(int a_screen,
int a_visual_id,
CARD32 ctxt_id, drm_context_t * a_hw_ctxt)
{
xcb_connection_t *conn = hostx_get_xcbconn();
int screen = hostx_get_screen();
Bool is_ok = FALSE;
xcb_xf86dri_create_context_cookie_t cookie;
xcb_xf86dri_create_context_reply_t *reply;
ctxt_id = xcb_generate_id(conn);
EPHYR_LOG("enter. screen:%d, visual:%d\n", a_screen, a_visual_id);
cookie = xcb_xf86dri_create_context(conn, screen, a_visual_id, ctxt_id);
reply = xcb_xf86dri_create_context_reply(conn, cookie, NULL);
if (!reply)
goto out;
*a_hw_ctxt = reply->hw_context;
is_ok = TRUE;
out:
free(reply);
EPHYR_LOG("leave:%d\n", is_ok);
return is_ok;
}
Bool
ephyrDRIDestroyContext(int a_screen, int a_context_id)
{
xcb_connection_t *conn = hostx_get_xcbconn ();
int screen = hostx_get_screen();
EPHYR_LOG("enter\n");
xcb_xf86dri_destroy_context(conn, screen, a_context_id);
EPHYR_LOG("leave\n");
return TRUE;
}
Bool
ephyrDRICreateDrawable(int a_screen,
int a_drawable, drm_drawable_t * a_hw_drawable)
{
Bool is_ok = FALSE;
xcb_connection_t *conn = hostx_get_xcbconn();
int screen = hostx_get_screen();
xcb_xf86dri_create_drawable_cookie_t cookie;
xcb_xf86dri_create_drawable_reply_t *reply;
EPHYR_LOG("enter\n");
cookie = xcb_xf86dri_create_drawable(conn, screen, a_drawable);
reply = xcb_xf86dri_create_drawable_reply(conn, cookie, NULL);
if (!reply)
goto out;
*a_hw_drawable = reply->hw_drawable_handle;
is_ok = TRUE;
out:
free(reply);
EPHYR_LOG("leave. is_ok:%d\n", is_ok);
return is_ok;
}
Bool
ephyrDRIDestroyDrawable(int a_screen, int a_drawable)
{
EPHYR_LOG("enter\n");
EPHYR_LOG_ERROR("not implemented yet\n");
EPHYR_LOG("leave\n");
return FALSE;
}
Bool
ephyrDRIGetDrawableInfo(int a_screen,
int a_drawable,
unsigned int *a_index,
unsigned int *a_stamp,
int *a_x,
int *a_y,
int *a_w,
int *a_h,
int *a_num_clip_rects,
drm_clip_rect_t ** a_clip_rects,
int *a_back_x,
int *a_back_y,
int *a_num_back_clip_rects,
drm_clip_rect_t ** a_back_clip_rects)
{
Bool is_ok = FALSE;
xcb_connection_t *conn = hostx_get_xcbconn();
int screen = hostx_get_screen();
xcb_xf86dri_get_drawable_info_cookie_t cookie;
xcb_xf86dri_get_drawable_info_reply_t *reply = NULL;
EphyrHostWindowAttributes attrs;
EPHYR_RETURN_VAL_IF_FAIL(a_x && a_y && a_w && a_h
&& a_num_clip_rects, FALSE);
EPHYR_LOG("enter\n");
memset(&attrs, 0, sizeof(attrs));
if (!hostx_get_window_attributes(a_drawable, &attrs)) {
EPHYR_LOG_ERROR("failed to query host window attributes\n");
goto out;
}
cookie = xcb_xf86dri_get_drawable_info(conn, screen, a_drawable);
reply = xcb_xf86dri_get_drawable_info_reply(conn, cookie, NULL);
if (!reply) {
EPHYR_LOG_ERROR ("XF86DRIGetDrawableInfo ()\n");
goto out;
}
*a_index = reply->drawable_table_index;
*a_stamp = reply->drawable_table_stamp;
*a_x = reply->drawable_origin_X;
*a_y = reply->drawable_origin_Y;
*a_w = reply->drawable_size_W;
*a_h = reply->drawable_size_H;
*a_num_clip_rects = reply->num_clip_rects;
*a_clip_rects = calloc(*a_num_clip_rects, sizeof(drm_clip_rect_t));
memcpy(*a_clip_rects, xcb_xf86dri_get_drawable_info_clip_rects(reply),
*a_num_clip_rects * sizeof(drm_clip_rect_t));
EPHYR_LOG("host x,y,w,h: (%d,%d,%d,%d)\n", *a_x, *a_y, *a_w, *a_h);
if (*a_num_clip_rects) {
free(*a_back_clip_rects);
*a_back_clip_rects = calloc(*a_num_clip_rects, sizeof(drm_clip_rect_t));
memmove(*a_back_clip_rects,
*a_clip_rects, *a_num_clip_rects * sizeof(drm_clip_rect_t));
*a_num_back_clip_rects = *a_num_clip_rects;
}
EPHYR_LOG("num back clip rects:%d, num clip rects:%d\n",
*a_num_clip_rects, *a_num_back_clip_rects);
*a_back_x = *a_x;
*a_back_y = *a_y;
*a_w = attrs.width;
*a_h = attrs.height;
is_ok = TRUE;
out:
EPHYR_LOG("leave. index:%d, stamp:%d, x,y:(%d,%d), w,y:(%d,%d)\n",
*a_index, *a_stamp, *a_x, *a_y, *a_w, *a_h);
free(reply);
return is_ok;
}
Bool
ephyrDRIGetDeviceInfo(int a_screen,
drm_handle_t * a_frame_buffer,
int *a_fb_origin,
int *a_fb_size,
int *a_fb_stride,
int *a_dev_private_size, void **a_dev_private)
{
Bool is_ok = FALSE;
xcb_connection_t *conn = hostx_get_xcbconn ();
int screen = hostx_get_screen();
xcb_xf86dri_get_device_info_cookie_t cookie;
xcb_xf86dri_get_device_info_reply_t *reply;
EPHYR_RETURN_VAL_IF_FAIL(conn, FALSE);
EPHYR_LOG("enter\n");
cookie = xcb_xf86dri_get_device_info(conn, screen);
reply = xcb_xf86dri_get_device_info_reply(conn, cookie, NULL);
if (!reply)
goto out;
*a_frame_buffer = reply->framebuffer_handle_low;
if (sizeof(drm_handle_t) == 8) {
int shift = 32;
*a_frame_buffer |= ((drm_handle_t)reply->framebuffer_handle_high) << shift;
}
*a_fb_origin = reply->framebuffer_origin_offset;
*a_fb_size = reply->framebuffer_size;
*a_fb_stride = reply->framebuffer_stride;
*a_dev_private_size = reply->device_private_size;
*a_dev_private = calloc(reply->device_private_size, 1);
if (!*a_dev_private)
goto out;
memcpy(*a_dev_private,
xcb_xf86dri_get_device_info_device_private(reply),
reply->device_private_size);
is_ok = TRUE;
out:
free(reply);
EPHYR_LOG("leave:%d\n", is_ok);
return is_ok;
}

View File

@ -1,70 +0,0 @@
/*
* Xephyr - A kdrive X server thats runs in a host X window.
* Authored by Matthew Allum <mallum@openedhand.com>
*
* Copyright © 2007 OpenedHand Ltd
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of OpenedHand Ltd not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. OpenedHand Ltd makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* Authors:
* Dodji Seketeli <dodji@openedhand.com>
*/
#ifndef __EPHYRDRI_H__
#define __EPHYRDRI_H__
#include <xf86drm.h>
Bool ephyrDRIQueryDirectRenderingCapable(int a_screen, Bool *a_is_capable);
Bool ephyrDRIOpenConnection(int screen, drm_handle_t * a_sarea,
char **a_bus_id_string);
Bool ephyrDRIAuthConnection(int a_screen, drm_magic_t a_magic);
Bool ephyrDRICloseConnection(int a_screen);
Bool ephyrDRIGetClientDriverName(int a_screen,
int *a_ddx_driver_major_version,
int *a_ddx_driver_minor_version,
int *a_ddx_driver_patch_version,
char **a_client_driver_name);
Bool ephyrDRICreateContext(int a_screen,
int a_visual_id,
CARD32 ctx_id, drm_context_t * a_hw_ctx);
Bool ephyrDRIDestroyContext(int a_screen, int a_context_id);
Bool ephyrDRICreateDrawable(int a_screen,
int a_drawable, drm_drawable_t * a_hw_drawable);
Bool ephyrDRIDestroyDrawable(int a_screen, int a_drawable);
Bool ephyrDRIGetDrawableInfo(int a_screen, int /*Drawable */ a_drawable,
unsigned int *a_index,
unsigned int *a_stamp,
int *a_x,
int *a_y,
int *a_w,
int *a_h,
int *a_num_clip_rects,
drm_clip_rect_t ** a_clip_rects,
int *a_back_x,
int *a_back_y,
int *num_back_clip_rects,
drm_clip_rect_t ** a_back_clip_rects);
Bool ephyrDRIGetDeviceInfo(int a_screen,
drm_handle_t * a_frame_buffer,
int *a_fb_origin,
int *a_fb_size,
int *a_fb_stride,
int *a_dev_private_size, void **a_dev_private);
#endif /*__EPHYRDRI_H__*/

File diff suppressed because it is too large Load Diff

View File

@ -1,40 +0,0 @@
/*
* Xephyr - A kdrive X server thats runs in a host X window.
* Authored by Matthew Allum <mallum@openedhand.com>
*
* Copyright © 2007 OpenedHand Ltd
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of OpenedHand Ltd not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. OpenedHand Ltd makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* Authors:
* Dodji Seketeli <dodji@openedhand.com>
*/
#ifndef __EPHYRDRIEXT_H__
#define __EPHYRDRIEXT_H__
typedef struct {
WindowPtr local;
int remote;
} EphyrWindowPair;
Bool ephyrDRIExtensionInit(ScreenPtr a_screen);
Bool findWindowPairFromRemote(int a_remote, EphyrWindowPair ** a_pair);
#endif /*__EPHYRDRIEXT_H__*/

View File

@ -1,854 +0,0 @@
/*
* Xephyr - A kdrive X server thats runs in a host X window.
* Authored by Matthew Allum <mallum@openedhand.com>
*
* Copyright © 2007 OpenedHand Ltd
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of OpenedHand Ltd not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. OpenedHand Ltd makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* Authors:
* Dodji Seketeli <dodji@openedhand.com>
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include <xcb/glx.h>
#include "extnsionst.h"
#include "ephyrglxext.h"
#include "ephyrhostglx.h"
#define _HAVE_XALLOC_DECLS
#include "ephyrlog.h"
#include <GL/glxproto.h>
#include "glx/glxserver.h"
#include "glx/indirect_table.h"
#include "glx/indirect_util.h"
#include "glx/unpack.h"
#include "hostx.h"
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
int ephyrGLXQueryVersion(__GLXclientState * cl, GLbyte * pc);
int ephyrGLXQueryVersionSwap(__GLXclientState * cl, GLbyte * pc);
int ephyrGLXGetVisualConfigs(__GLXclientState * cl, GLbyte * pc);
int ephyrGLXGetVisualConfigsSwap(__GLXclientState * cl, GLbyte * pc);
int ephyrGLXClientInfo(__GLXclientState * cl, GLbyte * pc);
int ephyrGLXClientInfoSwap(__GLXclientState * cl, GLbyte * pc);
int ephyrGLXQueryServerString(__GLXclientState * a_cl, GLbyte * a_pc);
int ephyrGLXQueryServerStringSwap(__GLXclientState * a_cl, GLbyte * a_pc);
int ephyrGLXGetFBConfigsSGIX(__GLXclientState * a_cl, GLbyte * a_pc);
int ephyrGLXGetFBConfigsSGIXSwap(__GLXclientState * a_cl, GLbyte * a_pc);
int ephyrGLXCreateContext(__GLXclientState * a_cl, GLbyte * a_pc);
int ephyrGLXCreateContextSwap(__GLXclientState * a_cl, GLbyte * a_pc);
int ephyrGLXCreateNewContext(__GLXclientState * a_cl, GLbyte * a_pc);
int ephyrGLXCreateNewContextSwap(__GLXclientState * a_cl, GLbyte * a_pc);
int ephyrGLXDestroyContext(__GLXclientState * a_cl, GLbyte * a_pc);
int ephyrGLXDestroyContextSwap(__GLXclientState * a_cl, GLbyte * a_pc);
int ephyrGLXMakeCurrent(__GLXclientState * a_cl, GLbyte * a_pc);
int ephyrGLXMakeCurrentSwap(__GLXclientState * a_cl, GLbyte * a_pc);
int ephyrGLXMakeCurrentReadSGI(__GLXclientState * a_cl, GLbyte * a_pc);
int ephyrGLXMakeCurrentReadSGISwap(__GLXclientState * a_cl, GLbyte * a_pc);
int ephyrGLXMakeContextCurrent(__GLXclientState * a_cl, GLbyte * a_pc);
int ephyrGLXMakeContextCurrentSwap(__GLXclientState * a_cl, GLbyte * a_pc);
int ephyrGLXGetString(__GLXclientState * a_cl, GLbyte * a_pc);
int ephyrGLXGetStringSwap(__GLXclientState * a_cl, GLbyte * a_pc);
int ephyrGLXGetIntegerv(__GLXclientState * a_cl, GLbyte * a_pc);
int ephyrGLXGetIntegervSwap(__GLXclientState * a_cl, GLbyte * a_pc);
int ephyrGLXIsDirect(__GLXclientState * a_cl, GLbyte * a_pc);
int ephyrGLXIsDirectSwap(__GLXclientState * a_cl, GLbyte * a_pc);
Bool
ephyrHijackGLXExtension(void)
{
const void *(*dispatch_functions)[2];
if (!hostx_has_extension(&xcb_glx_id)) {
EPHYR_LOG("host X does not have GLX\n");
return FALSE;
}
EPHYR_LOG("host X does have GLX\n");
if (!Single_dispatch_info.dispatch_functions) {
EPHYR_LOG_ERROR("could not get dispatch functions table\n");
return FALSE;
}
/*
* hijack some single entry point dispatch functions
*/
dispatch_functions = Single_dispatch_info.dispatch_functions;
EPHYR_RETURN_VAL_IF_FAIL(dispatch_functions, FALSE);
dispatch_functions[X_GLXQueryVersion][0] = ephyrGLXQueryVersion;
dispatch_functions[X_GLXQueryVersion][1] = ephyrGLXQueryVersionSwap;
dispatch_functions[X_GLXGetVisualConfigs][0] = ephyrGLXGetVisualConfigs;
dispatch_functions[X_GLXGetVisualConfigs][1] = ephyrGLXGetVisualConfigsSwap;
dispatch_functions[X_GLXClientInfo][0] = ephyrGLXClientInfo;
dispatch_functions[X_GLXClientInfo][1] = ephyrGLXClientInfoSwap;
dispatch_functions[X_GLXQueryServerString][0] = ephyrGLXQueryServerString;
dispatch_functions[X_GLXQueryServerString][1] =
ephyrGLXQueryServerStringSwap;
dispatch_functions[X_GLXCreateContext][0] = ephyrGLXCreateContext;
dispatch_functions[X_GLXCreateContext][1] = ephyrGLXCreateContextSwap;
dispatch_functions[X_GLXCreateNewContext][0] = ephyrGLXCreateNewContext;
dispatch_functions[X_GLXCreateNewContext][1] = ephyrGLXCreateNewContextSwap;
dispatch_functions[X_GLXDestroyContext][0] = ephyrGLXDestroyContext;
dispatch_functions[X_GLXDestroyContext][1] = ephyrGLXDestroyContextSwap;
dispatch_functions[X_GLXMakeCurrent][0] = ephyrGLXMakeCurrent;
dispatch_functions[X_GLXMakeCurrent][1] = ephyrGLXMakeCurrentSwap;
dispatch_functions[X_GLXIsDirect][0] = ephyrGLXIsDirect;
dispatch_functions[X_GLXIsDirect][1] = ephyrGLXIsDirectSwap;
dispatch_functions[73][0] = ephyrGLXGetString;
dispatch_functions[73][1] = ephyrGLXGetStringSwap;
dispatch_functions[61][0] = ephyrGLXGetIntegerv;
dispatch_functions[61][1] = ephyrGLXGetIntegervSwap;
dispatch_functions[X_GLXMakeContextCurrent][0] =
ephyrGLXMakeContextCurrent;
dispatch_functions[X_GLXMakeContextCurrent][1] =
ephyrGLXMakeContextCurrentSwap;
/*
* hijack some vendor priv entry point dispatch functions
*/
dispatch_functions = VendorPriv_dispatch_info.dispatch_functions;
dispatch_functions[92][0] = ephyrGLXGetFBConfigsSGIX;
dispatch_functions[92][1] = ephyrGLXGetFBConfigsSGIXSwap;
dispatch_functions[89][0] = ephyrGLXMakeCurrentReadSGI;
dispatch_functions[89][1] = ephyrGLXMakeCurrentReadSGISwap;
EPHYR_LOG("hijacked glx entry points to forward requests to host X\n");
return TRUE;
}
/*********************
* implementation of
* hijacked GLX entry
* points
********************/
int
ephyrGLXQueryVersion(__GLXclientState * a_cl, GLbyte * a_pc)
{
ClientPtr client = a_cl->client;
xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) a_pc;
xGLXQueryVersionReply reply;
int major, minor;
int res = BadImplementation;
EPHYR_LOG("enter\n");
major = req->majorVersion;
minor = req->minorVersion;
if (!ephyrHostGLXQueryVersion(&major, &minor)) {
EPHYR_LOG_ERROR("ephyrHostGLXQueryVersion() failed\n");
goto out;
}
EPHYR_LOG("major:%d, minor:%d\n", major, minor);
reply = (xGLXQueryVersionReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.majorVersion = major,
.minorVersion = minor
};
if (client->swapped) {
__glXSwapQueryVersionReply(client, &reply);
}
else {
WriteToClient(client, sz_xGLXQueryVersionReply, &reply);
}
res = Success;
out:
EPHYR_LOG("leave\n");
return res;
}
int
ephyrGLXQueryVersionSwap(__GLXclientState * a_cl, GLbyte * a_pc)
{
xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) a_pc;
__GLX_DECLARE_SWAP_VARIABLES;
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->majorVersion);
__GLX_SWAP_INT(&req->minorVersion);
return ephyrGLXQueryVersion(a_cl, a_pc);
}
static int
ephyrGLXGetVisualConfigsReal(__GLXclientState * a_cl,
GLbyte * a_pc, Bool a_do_swap)
{
xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) a_pc;
ClientPtr client = a_cl->client;
xGLXGetVisualConfigsReply reply;
int32_t *props_buf = NULL, num_visuals = 0,
num_props = 0, res = BadImplementation, i = 0,
props_per_visual_size = 0, props_buf_size = 0;
__GLX_DECLARE_SWAP_VARIABLES;
__GLX_DECLARE_SWAP_ARRAY_VARIABLES;
EPHYR_LOG("enter\n");
if (!ephyrHostGLXGetVisualConfigs(req->screen,
&num_visuals,
&num_props,
&props_buf_size, &props_buf)) {
EPHYR_LOG_ERROR("ephyrHostGLXGetVisualConfigs() failed\n");
goto out;
}
EPHYR_LOG("num_visuals:%d, num_props:%d\n", num_visuals, num_props);
reply = (xGLXGetVisualConfigsReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = (num_visuals * __GLX_SIZE_CARD32 * num_props) >> 2,
.numVisuals = num_visuals,
.numProps = num_props
};
if (a_do_swap) {
__GLX_SWAP_SHORT(&reply.sequenceNumber);
__GLX_SWAP_INT(&reply.length);
__GLX_SWAP_INT(&reply.numVisuals);
__GLX_SWAP_INT(&reply.numProps);
__GLX_SWAP_INT_ARRAY(props_buf, num_props);
}
WriteToClient(client, sz_xGLXGetVisualConfigsReply, &reply);
props_per_visual_size = props_buf_size / num_visuals;
for (i = 0; i < num_visuals; i++) {
WriteToClient(client,
props_per_visual_size,
(char *) props_buf + i * props_per_visual_size);
}
res = Success;
out:
EPHYR_LOG("leave\n");
free(props_buf);
props_buf = NULL;
return res;
}
static int
ephyrGLXGetFBConfigsSGIXReal(__GLXclientState * a_cl,
GLbyte * a_pc, Bool a_do_swap)
{
xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *) a_pc;
ClientPtr client = a_cl->client;
xGLXGetVisualConfigsReply reply;
int32_t *props_buf = NULL, num_visuals = 0,
num_props = 0, res = BadImplementation, i = 0,
props_per_visual_size = 0, props_buf_size = 0;
__GLX_DECLARE_SWAP_VARIABLES;
__GLX_DECLARE_SWAP_ARRAY_VARIABLES;
EPHYR_LOG("enter\n");
if (!ephyrHostGLXVendorPrivGetFBConfigsSGIX(req->screen,
&num_visuals,
&num_props,
&props_buf_size, &props_buf)) {
EPHYR_LOG_ERROR("ephyrHostGLXGetVisualConfigs() failed\n");
goto out;
}
EPHYR_LOG("num_visuals:%d, num_props:%d\n", num_visuals, num_props);
reply = (xGLXGetVisualConfigsReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = props_buf_size >> 2,
.numVisuals = num_visuals,
.numProps = num_props
};
if (a_do_swap) {
__GLX_SWAP_SHORT(&reply.sequenceNumber);
__GLX_SWAP_INT(&reply.length);
__GLX_SWAP_INT(&reply.numVisuals);
__GLX_SWAP_INT(&reply.numProps);
__GLX_SWAP_INT_ARRAY(props_buf, num_props);
}
WriteToClient(client, sz_xGLXGetVisualConfigsReply, &reply);
props_per_visual_size = props_buf_size / num_visuals;
for (i = 0; i < num_visuals; i++) {
WriteToClient(client,
props_per_visual_size,
&((char *) props_buf)[i * props_per_visual_size]);
}
res = Success;
out:
EPHYR_LOG("leave\n");
free(props_buf);
props_buf = NULL;
return res;
}
int
ephyrGLXGetVisualConfigs(__GLXclientState * a_cl, GLbyte * a_pc)
{
return ephyrGLXGetVisualConfigsReal(a_cl, a_pc, FALSE);
}
int
ephyrGLXGetVisualConfigsSwap(__GLXclientState * a_cl, GLbyte * a_pc)
{
return ephyrGLXGetVisualConfigsReal(a_cl, a_pc, TRUE);
}
int
ephyrGLXClientInfo(__GLXclientState * a_cl, GLbyte * a_pc)
{
int res = BadImplementation;
xGLXClientInfoReq *req = (xGLXClientInfoReq *) a_pc;
EPHYR_LOG("enter\n");
if (!ephyrHostGLXSendClientInfo(req->major, req->minor, (char *) req + 1)) {
EPHYR_LOG_ERROR("failed to send client info to host\n");
goto out;
}
res = Success;
out:
EPHYR_LOG("leave\n");
return res;
}
int
ephyrGLXClientInfoSwap(__GLXclientState * a_cl, GLbyte * a_pc)
{
xGLXClientInfoReq *req = (xGLXClientInfoReq *) a_pc;
__GLX_DECLARE_SWAP_VARIABLES;
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->major);
__GLX_SWAP_INT(&req->minor);
__GLX_SWAP_INT(&req->numbytes);
return ephyrGLXClientInfo(a_cl, a_pc);
}
int
ephyrGLXQueryServerString(__GLXclientState * a_cl, GLbyte * a_pc)
{
int res = BadImplementation;
ClientPtr client = a_cl->client;
xGLXQueryServerStringReq *req = (xGLXQueryServerStringReq *) a_pc;
xGLXQueryServerStringReply reply;
char *server_string = NULL;
int length = 0;
EPHYR_LOG("enter\n");
if (!ephyrHostGLXQueryServerString(req->screen,
req->name,
&server_string)) {
EPHYR_LOG_ERROR("failed to query string from host\n");
goto out;
}
EPHYR_LOG("string: %s\n", server_string);
length = strlen(server_string) + 1;
reply = (xGLXQueryServerStringReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = __GLX_PAD(length) >> 2,
.n = length
};
WriteToClient(client, sz_xGLXQueryServerStringReply, &reply);
WriteToClient(client, (int) (reply.length << 2), server_string);
res = Success;
out:
EPHYR_LOG("leave\n");
free(server_string);
server_string = NULL;
return res;
}
int
ephyrGLXQueryServerStringSwap(__GLXclientState * a_cl, GLbyte * a_pc)
{
EPHYR_LOG_ERROR("not yet implemented\n");
return BadImplementation;
}
int
ephyrGLXGetFBConfigsSGIX(__GLXclientState * a_cl, GLbyte * a_pc)
{
return ephyrGLXGetFBConfigsSGIXReal(a_cl, a_pc, FALSE);
}
int
ephyrGLXGetFBConfigsSGIXSwap(__GLXclientState * a_cl, GLbyte * a_pc)
{
return ephyrGLXGetFBConfigsSGIXReal(a_cl, a_pc, TRUE);
}
static int
ephyrGLXCreateContextReal(xGLXCreateContextReq * a_req, Bool a_do_swap)
{
int res = BadImplementation;
EphyrHostWindowAttributes host_w_attrs;
__GLX_DECLARE_SWAP_VARIABLES;
EPHYR_RETURN_VAL_IF_FAIL(a_req, BadValue);
EPHYR_LOG("enter\n");
if (a_do_swap) {
__GLX_SWAP_SHORT(&a_req->length);
__GLX_SWAP_INT(&a_req->context);
__GLX_SWAP_INT(&a_req->visual);
__GLX_SWAP_INT(&a_req->screen);
__GLX_SWAP_INT(&a_req->shareList);
}
EPHYR_LOG("context creation requested. localid:%d, "
"screen:%d, visual:%d, direct:%d\n",
(int) a_req->context, (int) a_req->screen,
(int) a_req->visual, (int) a_req->isDirect);
memset(&host_w_attrs, 0, sizeof(host_w_attrs));
if (!hostx_get_window_attributes(hostx_get_window(a_req->screen),
&host_w_attrs)) {
EPHYR_LOG_ERROR("failed to get host window attrs\n");
goto out;
}
EPHYR_LOG("host window visual id: %d\n", host_w_attrs.visualid);
if (!ephyrHostGLXCreateContext(a_req->screen,
host_w_attrs.visualid,
a_req->context,
a_req->shareList, 0,
a_req->isDirect, X_GLXCreateContext)) {
EPHYR_LOG_ERROR("ephyrHostGLXCreateContext() failed\n");
goto out;
}
res = Success;
out:
EPHYR_LOG("leave\n");
return res;
}
static int
ephyrGLXCreateNewContextReal(xGLXCreateNewContextReq * a_req, Bool a_do_swap)
{
int res = BadImplementation;
__GLX_DECLARE_SWAP_VARIABLES;
EPHYR_RETURN_VAL_IF_FAIL(a_req, BadValue);
EPHYR_LOG("enter\n");
if (a_do_swap) {
__GLX_SWAP_SHORT(&a_req->length);
__GLX_SWAP_INT(&a_req->context);
__GLX_SWAP_INT(&a_req->fbconfig);
__GLX_SWAP_INT(&a_req->screen);
__GLX_SWAP_INT(&a_req->renderType);
__GLX_SWAP_INT(&a_req->shareList);
}
EPHYR_LOG("context creation requested. localid:%d, "
"screen:%d, fbconfig:%d, renderType:%d, direct:%d\n",
(int) a_req->context, (int) a_req->screen,
(int) a_req->fbconfig, (int) a_req->renderType,
(int) a_req->isDirect);
if (!ephyrHostGLXCreateContext(a_req->screen,
a_req->fbconfig,
a_req->context,
a_req->shareList, a_req->renderType,
a_req->isDirect, X_GLXCreateNewContext)) {
EPHYR_LOG_ERROR("ephyrHostGLXCreateNewContext() failed\n");
goto out;
}
res = Success;
out:
EPHYR_LOG("leave\n");
return res;
}
int
ephyrGLXCreateContext(__GLXclientState * cl, GLbyte * pc)
{
xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc;
return ephyrGLXCreateContextReal(req, FALSE);
}
int
ephyrGLXCreateContextSwap(__GLXclientState * cl, GLbyte * pc)
{
xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc;
return ephyrGLXCreateContextReal(req, TRUE);
}
int
ephyrGLXCreateNewContext(__GLXclientState * cl, GLbyte * pc)
{
xGLXCreateNewContextReq *req = (xGLXCreateNewContextReq *) pc;
return ephyrGLXCreateNewContextReal(req, FALSE);
}
int
ephyrGLXCreateNewContextSwap(__GLXclientState * cl, GLbyte * pc)
{
xGLXCreateNewContextReq *req = (xGLXCreateNewContextReq *) pc;
return ephyrGLXCreateNewContextReal(req, TRUE);
}
static int
ephyrGLXDestroyContextReal(__GLXclientState * a_cl,
GLbyte * a_pc, Bool a_do_swap)
{
int res = BadImplementation;
ClientPtr client = a_cl->client;
xGLXDestroyContextReq *req = (xGLXDestroyContextReq *) a_pc;
EPHYR_LOG("enter. id:%d\n", (int) req->context);
if (!ephyrHostDestroyContext(req->context)) {
EPHYR_LOG_ERROR("ephyrHostDestroyContext() failed\n");
client->errorValue = req->context;
goto out;
}
res = Success;
out:
EPHYR_LOG("leave\n");
return res;
}
int
ephyrGLXDestroyContext(__GLXclientState * a_cl, GLbyte * a_pc)
{
return ephyrGLXDestroyContextReal(a_cl, a_pc, FALSE);
}
int
ephyrGLXDestroyContextSwap(__GLXclientState * a_cl, GLbyte * a_pc)
{
return ephyrGLXDestroyContextReal(a_cl, a_pc, TRUE);
}
static int
ephyrGLXMakeCurrentReal(__GLXclientState * a_cl, GLXDrawable write,
GLXDrawable read, GLXContextTag ctx,
GLXContextTag old_ctx, Bool a_do_swap)
{
int res = BadImplementation;
xGLXMakeCurrentReply reply;
DrawablePtr drawableR = NULL, drawableW = NULL;
GLXContextTag new_ctx = 0;
EPHYR_LOG("enter\n");
res = dixLookupDrawable(&drawableW, write, a_cl->client, 0, DixReadAccess);
EPHYR_RETURN_VAL_IF_FAIL(drawableW, BadValue);
EPHYR_RETURN_VAL_IF_FAIL(drawableW->pScreen, BadValue);
EPHYR_LOG("screen nummber requested:%d\n", drawableW->pScreen->myNum);
if (read != write) {
res = dixLookupDrawable(&drawableR, read, a_cl->client, 0,
DixReadAccess);
EPHYR_RETURN_VAL_IF_FAIL(drawableR, BadValue);
EPHYR_RETURN_VAL_IF_FAIL(drawableR->pScreen, BadValue);
}
else {
drawableR = drawableW;
}
if (!ephyrHostGLXMakeCurrent(hostx_get_window(drawableW->pScreen->myNum),
hostx_get_window(drawableR->pScreen->myNum),
ctx, old_ctx, (int *) &new_ctx)) {
EPHYR_LOG_ERROR("ephyrHostGLXMakeCurrent() failed\n");
goto out;
}
reply = (xGLXMakeCurrentReply) {
.type = X_Reply,
.sequenceNumber = a_cl->client->sequence,
.length = 0,
.contextTag = new_ctx
};
if (a_do_swap) {
__GLX_DECLARE_SWAP_VARIABLES;
__GLX_SWAP_SHORT(&reply.sequenceNumber);
__GLX_SWAP_INT(&reply.length);
__GLX_SWAP_INT(&reply.contextTag);
}
WriteToClient(a_cl->client, sz_xGLXMakeCurrentReply, &reply);
res = Success;
out:
EPHYR_LOG("leave\n");
return res;
}
int
ephyrGLXMakeCurrent(__GLXclientState * a_cl, GLbyte * a_pc)
{
xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) a_pc;
return ephyrGLXMakeCurrentReal(a_cl, req->drawable, req->drawable,
req->context, req->oldContextTag, FALSE);
}
int
ephyrGLXMakeCurrentSwap(__GLXclientState * a_cl, GLbyte * a_pc)
{
xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) a_pc;
__GLX_DECLARE_SWAP_VARIABLES;
__GLX_SWAP_INT(&req->drawable);
__GLX_SWAP_INT(&req->context);
__GLX_SWAP_INT(&req->oldContextTag);
return ephyrGLXMakeCurrentReal(a_cl, req->drawable, req->drawable,
req->context, req->oldContextTag, TRUE);
}
int
ephyrGLXMakeCurrentReadSGI(__GLXclientState * a_cl, GLbyte * a_pc)
{
xGLXMakeCurrentReadSGIReq *req = (xGLXMakeCurrentReadSGIReq *) a_pc;
return ephyrGLXMakeCurrentReal(a_cl, req->drawable, req->readable,
req->context, req->oldContextTag, FALSE);
}
int
ephyrGLXMakeCurrentReadSGISwap(__GLXclientState * a_cl, GLbyte * a_pc)
{
xGLXMakeCurrentReadSGIReq *req = (xGLXMakeCurrentReadSGIReq *) a_pc;
__GLX_DECLARE_SWAP_VARIABLES;
__GLX_SWAP_INT(&req->drawable);
__GLX_SWAP_INT(&req->readable);
__GLX_SWAP_INT(&req->context);
__GLX_SWAP_INT(&req->oldContextTag);
return ephyrGLXMakeCurrentReal(a_cl, req->drawable, req->readable,
req->context, req->oldContextTag, TRUE);
}
int
ephyrGLXMakeContextCurrent(__GLXclientState * a_cl, GLbyte * a_pc)
{
xGLXMakeContextCurrentReq *req = (xGLXMakeContextCurrentReq *) a_pc;
return ephyrGLXMakeCurrentReal(a_cl, req->drawable, req->readdrawable,
req->context, req->oldContextTag, FALSE);
}
int
ephyrGLXMakeContextCurrentSwap(__GLXclientState * a_cl, GLbyte * a_pc)
{
xGLXMakeContextCurrentReq *req = (xGLXMakeContextCurrentReq *) a_pc;
__GLX_DECLARE_SWAP_VARIABLES;
__GLX_SWAP_INT(&req->drawable);
__GLX_SWAP_INT(&req->readdrawable);
__GLX_SWAP_INT(&req->context);
__GLX_SWAP_INT(&req->oldContextTag);
return ephyrGLXMakeCurrentReal(a_cl, req->drawable, req->readdrawable,
req->context, req->oldContextTag, TRUE);
}
static int
ephyrGLXGetStringReal(__GLXclientState * a_cl, GLbyte * a_pc, Bool a_do_swap)
{
ClientPtr client = NULL;
int context_tag = 0, name = 0, res = BadImplementation, length = 0;
char *string = NULL;
__GLX_DECLARE_SWAP_VARIABLES;
EPHYR_RETURN_VAL_IF_FAIL(a_cl && a_pc, BadValue);
EPHYR_LOG("enter\n");
client = a_cl->client;
if (a_do_swap) {
__GLX_SWAP_INT(a_pc + 4);
__GLX_SWAP_INT(a_pc + __GLX_SINGLE_HDR_SIZE);
}
context_tag = __GLX_GET_SINGLE_CONTEXT_TAG(a_pc);
a_pc += __GLX_SINGLE_HDR_SIZE;
name = *(GLenum *) (a_pc + 0);
EPHYR_LOG("context_tag:%d, name:%d\n", context_tag, name);
if (!ephyrHostGLXGetString(context_tag, name, &string)) {
EPHYR_LOG_ERROR("failed to get string from server\n");
goto out;
}
if (string) {
length = strlen(string) + 1;
EPHYR_LOG("got string:'%s', size:%d\n", string, length);
}
else {
EPHYR_LOG("got string: string (null)\n");
}
__GLX_BEGIN_REPLY(length);
__GLX_PUT_SIZE(length);
__GLX_SEND_HEADER();
if (a_do_swap) {
__GLX_SWAP_REPLY_SIZE();
__GLX_SWAP_REPLY_HEADER();
}
WriteToClient(client, length, string);
res = Success;
out:
EPHYR_LOG("leave\n");
return res;
}
int
ephyrGLXGetString(__GLXclientState * a_cl, GLbyte * a_pc)
{
return ephyrGLXGetStringReal(a_cl, a_pc, FALSE);
}
int
ephyrGLXGetStringSwap(__GLXclientState * a_cl, GLbyte * a_pc)
{
return ephyrGLXGetStringReal(a_cl, a_pc, TRUE);
}
static int
ephyrGLXGetIntegervReal(__GLXclientState * a_cl, GLbyte * a_pc, Bool a_do_swap)
{
int res = BadImplementation;
xGLXSingleReq *const req = (xGLXSingleReq *) a_pc;
GLenum int_name;
int value = 0;
GLint answer_buf_room[200];
GLint *buf = NULL;
EPHYR_LOG("enter\n");
a_pc += __GLX_SINGLE_HDR_SIZE;
int_name = *(GLenum *) (a_pc + 0);
if (!ephyrHostGetIntegerValue(req->contextTag, int_name, &value)) {
EPHYR_LOG_ERROR("ephyrHostGetIntegerValue() failed\n");
goto out;
}
buf = __glXGetAnswerBuffer(a_cl, sizeof(value),
answer_buf_room, sizeof(answer_buf_room), 4);
if (!buf) {
EPHYR_LOG_ERROR("failed to allocate reply buffer\n");
res = BadAlloc;
goto out;
}
__glXSendReply(a_cl->client, buf, 1, sizeof(value), GL_FALSE, 0);
res = Success;
out:
EPHYR_LOG("leave\n");
return res;
}
int
ephyrGLXGetIntegerv(__GLXclientState * a_cl, GLbyte * a_pc)
{
return ephyrGLXGetIntegervReal(a_cl, a_pc, FALSE);
}
int
ephyrGLXGetIntegervSwap(__GLXclientState * a_cl, GLbyte * a_pc)
{
return ephyrGLXGetIntegervReal(a_cl, a_pc, TRUE);
}
static int
ephyrGLXIsDirectReal(__GLXclientState * a_cl, GLbyte * a_pc, Bool a_do_swap)
{
int res = BadImplementation;
ClientPtr client = a_cl->client;
xGLXIsDirectReq *req = (xGLXIsDirectReq *) a_pc;
xGLXIsDirectReply reply;
int is_direct = 0;
EPHYR_RETURN_VAL_IF_FAIL(a_cl && a_pc, FALSE);
EPHYR_LOG("enter\n");
if (!ephyrHostIsContextDirect(req->context, (int *) &is_direct)) {
EPHYR_LOG_ERROR("ephyrHostIsContextDirect() failed\n");
goto out;
}
reply = (xGLXIsDirectReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.isDirect = is_direct
};
WriteToClient(client, sz_xGLXIsDirectReply, &reply);
res = Success;
out:
EPHYR_LOG("leave\n");
return res;
}
int
ephyrGLXIsDirect(__GLXclientState * a_cl, GLbyte * a_pc)
{
return ephyrGLXIsDirectReal(a_cl, a_pc, FALSE);
}
int
ephyrGLXIsDirectSwap(__GLXclientState * a_cl, GLbyte * a_pc)
{
return ephyrGLXIsDirectReal(a_cl, a_pc, TRUE);
}

View File

@ -1,34 +0,0 @@
/*
* Xephyr - A kdrive X server thats runs in a host X window.
* Authored by Matthew Allum <mallum@openedhand.com>
*
* Copyright © 2007 OpenedHand Ltd
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of OpenedHand Ltd not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. OpenedHand Ltd makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* Authors:
* Dodji Seketeli <dodji@openedhand.com>
*/
#ifndef __EPHYR_GLXEXT_H__
#define __EPHYR_GLXEXT_H__
#include <X11/Xdefs.h>
Bool ephyrHijackGLXExtension(void);
#endif /*__EPHYR_GLXEXT_H__*/

View File

@ -1,490 +0,0 @@
/*
* Xephyr - A kdrive X server thats runs in a host X window.
* Authored by Matthew Allum <mallum@openedhand.com>
*
* Copyright © 2007 OpenedHand Ltd
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of OpenedHand Ltd not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. OpenedHand Ltd makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* a lots of the content of this file has been adapted from the mesa source
* code.
* Authors:
* Dodji Seketeli <dodji@openedhand.com>
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include <X11/Xdefs.h>
#include <X11/Xmd.h>
#include <GL/glxproto.h>
#include <xcb/glx.h>
#include "ephyrhostglx.h"
#define _HAVE_XALLOC_DECLS
#include "ephyrlog.h"
#include "hostx.h"
static int glx_major, glx_minor;
enum VisualConfRequestType {
EPHYR_GET_FB_CONFIG,
EPHYR_VENDOR_PRIV_GET_FB_CONFIG_SGIX,
EPHYR_GET_VISUAL_CONFIGS
};
static Bool ephyrHostGLXGetVisualConfigsInternal
(enum VisualConfRequestType a_type,
xcb_glx_get_visual_configs_reply_t *reply,
int32_t a_screen,
int32_t *a_num_visuals,
int32_t *a_num_props,
int32_t *a_props_buf_size,
int32_t **a_props_buf);
Bool
ephyrHostGLXQueryVersion(int *a_major, int *a_minor)
{
Bool is_ok = FALSE;
xcb_connection_t *conn = hostx_get_xcbconn();
xcb_glx_query_version_cookie_t cookie;
xcb_glx_query_version_reply_t *reply;
EPHYR_RETURN_VAL_IF_FAIL(a_major && a_minor, FALSE);
EPHYR_LOG("enter\n");
if (glx_major) {
*a_major = glx_major;
*a_minor = glx_minor;
return TRUE;
}
/* Send the glXQueryVersion request */
cookie = xcb_glx_query_version(conn, 2, 1);
reply = xcb_glx_query_version_reply(conn, cookie, NULL);
if (!reply)
goto out;
*a_major = reply->major_version;
*a_minor = reply->minor_version;
free(reply);
EPHYR_LOG("major:%d, minor:%d\n", *a_major, *a_minor);
is_ok = TRUE;
out:
EPHYR_LOG("leave\n");
return is_ok;
}
Bool
ephyrHostGLXGetString(int a_context_tag,
int a_string_name,
char **a_string)
{
Bool is_ok = FALSE;
xcb_connection_t *conn = hostx_get_xcbconn();
xcb_glx_get_string_cookie_t cookie;
xcb_glx_get_string_reply_t *reply;
EPHYR_RETURN_VAL_IF_FAIL(conn && a_string, FALSE);
EPHYR_LOG("enter\n");
cookie = xcb_glx_get_string(conn, a_context_tag, a_string_name);
reply = xcb_glx_get_string_reply(conn, cookie, NULL);
if (!reply)
goto out;
*a_string = malloc(reply->n + 1);
memcpy(*a_string, xcb_glx_get_string_string(reply), reply->n);
(*a_string)[reply->n] = '\0';
free(reply);
is_ok = TRUE;
out:
EPHYR_LOG("leave\n");
return is_ok;
}
Bool ephyrHostGLXQueryServerString(int a_screen_number,
int a_string_name,
char **a_string)
{
Bool is_ok = FALSE;
xcb_connection_t *conn = hostx_get_xcbconn();
int default_screen = hostx_get_screen();
xcb_glx_query_server_string_cookie_t cookie;
xcb_glx_query_server_string_reply_t *reply;
EPHYR_RETURN_VAL_IF_FAIL(conn && a_string, FALSE);
EPHYR_LOG("enter\n");
cookie = xcb_glx_query_server_string(conn, default_screen, a_string_name);
reply = xcb_glx_query_server_string_reply(conn, cookie, NULL);
if (!reply)
goto out;
*a_string = malloc(reply->str_len + 1);
memcpy(*a_string, xcb_glx_query_server_string_string(reply), reply->str_len);
(*a_string)[reply->str_len] = '\0';
free(reply);
is_ok = TRUE;
out:
EPHYR_LOG("leave\n");
return is_ok;
}
static Bool
ephyrHostGLXGetVisualConfigsInternal(enum VisualConfRequestType a_type,
xcb_glx_get_visual_configs_reply_t *reply,
int32_t a_screen,
int32_t * a_num_visuals,
int32_t * a_num_props,
int32_t * a_props_buf_size,
int32_t ** a_props_buf)
{
Bool is_ok = FALSE;
int num_props = 0, num_visuals = 0, props_buf_size = 0;
int props_per_visual_size = 0;
int32_t *props_buf = NULL;
if (!reply->num_visuals) {
EPHYR_LOG_ERROR("screen does not support GL rendering\n");
goto out;
}
num_visuals = reply->num_visuals;
num_props = reply->num_properties;
if (a_type != EPHYR_GET_VISUAL_CONFIGS) {
num_props *= 2;
}
props_per_visual_size = num_props * sizeof(uint32_t);
props_buf_size = props_per_visual_size * reply->num_visuals;
props_buf = malloc(props_buf_size);
if (!props_buf)
goto out;
memcpy(props_buf, xcb_glx_get_visual_configs_property_list(reply),
props_buf_size);
*a_num_visuals = num_visuals;
*a_num_props = reply->num_properties;
*a_props_buf_size = props_buf_size;
*a_props_buf = props_buf;
is_ok = TRUE;
out:
return is_ok;
}
Bool
ephyrHostGLXGetVisualConfigs(int32_t a_screen,
int32_t * a_num_visuals,
int32_t * a_num_props,
int32_t * a_props_buf_size, int32_t ** a_props_buf)
{
Bool is_ok = FALSE;
xcb_glx_get_visual_configs_cookie_t cookie;
xcb_glx_get_visual_configs_reply_t *reply;
xcb_connection_t *conn = hostx_get_xcbconn();
int screen = hostx_get_screen();
EPHYR_LOG("enter\n");
cookie = xcb_glx_get_visual_configs(conn, screen);
reply = xcb_glx_get_visual_configs_reply(conn, cookie, NULL);
if (!reply)
goto out;
is_ok = ephyrHostGLXGetVisualConfigsInternal
(EPHYR_GET_VISUAL_CONFIGS,
reply,
a_screen,
a_num_visuals,
a_num_props,
a_props_buf_size,
a_props_buf);
out:
free(reply);
EPHYR_LOG("leave:%d\n", is_ok);
return is_ok;
}
Bool
ephyrHostGLXVendorPrivGetFBConfigsSGIX(int a_screen,
int32_t * a_num_visuals,
int32_t * a_num_props,
int32_t * a_props_buf_size,
int32_t ** a_props_buf)
{
Bool is_ok=FALSE;
xcb_connection_t *conn = hostx_get_xcbconn();
int screen = hostx_get_screen();
xcb_glx_vendor_private_with_reply_cookie_t cookie;
union {
xcb_glx_vendor_private_with_reply_reply_t *vprep;
xcb_glx_get_visual_configs_reply_t *rep;
} reply;
EPHYR_LOG("enter\n");
cookie = xcb_glx_vendor_private_with_reply(conn,
X_GLXvop_GetFBConfigsSGIX,
0, 4, (uint8_t *)&screen);
reply.vprep = xcb_glx_vendor_private_with_reply_reply(conn, cookie, NULL);
if (!reply.vprep)
goto out;
is_ok = ephyrHostGLXGetVisualConfigsInternal
(EPHYR_VENDOR_PRIV_GET_FB_CONFIG_SGIX,
reply.rep,
a_screen,
a_num_visuals,
a_num_props,
a_props_buf_size,
a_props_buf);
out:
free(reply.vprep);
EPHYR_LOG("leave\n");
return is_ok;
}
Bool
ephyrHostGLXSendClientInfo(int32_t a_major, int32_t a_minor,
const char *a_extension_list)
{
xcb_connection_t *conn = hostx_get_xcbconn();
int size;
EPHYR_RETURN_VAL_IF_FAIL(conn && a_extension_list, FALSE);
size = strlen (a_extension_list) + 1;
xcb_glx_client_info(conn, a_major, a_minor, size, a_extension_list);
return TRUE;
}
Bool
ephyrHostGLXCreateContext(int a_screen,
int a_generic_id,
int a_context_id,
int a_share_list_ctxt_id,
int a_render_type,
Bool a_direct,
int code)
{
xcb_connection_t *conn = hostx_get_xcbconn();
Bool is_ok = FALSE;
int remote_context_id = 0;
EPHYR_LOG("enter. screen:%d, generic_id:%d, contextid:%d, rendertype:%d, "
"direct:%d\n", a_screen, a_generic_id, a_context_id,
a_render_type, a_direct);
if (!hostx_allocate_resource_id_peer(a_context_id, &remote_context_id)) {
EPHYR_LOG_ERROR("failed to peer the context id %d host X",
remote_context_id);
goto out;
}
switch (code) {
case X_GLXCreateContext: {
xcb_glx_create_context(conn,
remote_context_id,
a_generic_id,
hostx_get_screen(),
a_share_list_ctxt_id,
a_direct);
}
case X_GLXCreateNewContext: {
xcb_glx_create_new_context(conn,
remote_context_id,
a_generic_id,
hostx_get_screen(),
a_render_type,
a_share_list_ctxt_id,
a_direct);
}
default:
/* This should never be reached !*/
EPHYR_LOG("Internal error! Invalid CreateContext code!\n");
}
is_ok = TRUE;
out:
EPHYR_LOG("leave\n");
return is_ok;
}
Bool
ephyrHostDestroyContext(int a_ctxt_id)
{
xcb_connection_t *conn = hostx_get_xcbconn();
Bool is_ok = FALSE;
int remote_ctxt_id = 0;
EPHYR_LOG("enter:%d\n", a_ctxt_id);
if (!hostx_get_resource_id_peer(a_ctxt_id, &remote_ctxt_id)) {
EPHYR_LOG_ERROR("failed to get remote glx ctxt id\n");
goto out;
}
EPHYR_LOG("host context id:%d\n", remote_ctxt_id);
xcb_glx_destroy_context(conn, remote_ctxt_id);
is_ok = TRUE;
out:
EPHYR_LOG("leave\n");
return is_ok;
}
Bool
ephyrHostGLXMakeCurrent(int a_drawable, int a_readable,
int a_glx_ctxt_id, int a_old_ctxt_tag, int *a_ctxt_tag)
{
xcb_connection_t *conn = hostx_get_xcbconn();
Bool is_ok = FALSE;
int remote_glx_ctxt_id = 0;
EPHYR_RETURN_VAL_IF_FAIL(a_ctxt_tag, FALSE);
EPHYR_LOG("enter. drawable:%d, read:%d, context:%d, oldtag:%d\n",
a_drawable, a_readable, a_glx_ctxt_id, a_old_ctxt_tag);
if (!hostx_get_resource_id_peer(a_glx_ctxt_id, &remote_glx_ctxt_id)) {
EPHYR_LOG_ERROR("failed to get remote glx ctxt id\n");
goto out;
}
/* If both drawables are the same, use the old MakeCurrent request.
* Otherwise, if we have GLX 1.3 or higher, use the MakeContextCurrent
* request which supports separate read and draw targets. Failing that,
* try the SGI MakeCurrentRead extension. Logic cribbed from Mesa. */
if (a_drawable == a_readable) {
xcb_glx_make_current_cookie_t cookie;
xcb_glx_make_current_reply_t *reply;
cookie = xcb_glx_make_current(conn,
a_drawable,
remote_glx_ctxt_id,
a_old_ctxt_tag);
reply = xcb_glx_make_current_reply(conn, cookie, NULL);
if (!reply)
goto out;
*a_ctxt_tag = reply->context_tag;
free(reply);
}
else if (glx_major > 1 || glx_minor >= 3) {
xcb_glx_make_context_current_cookie_t cookie;
xcb_glx_make_context_current_reply_t *reply;
cookie = xcb_glx_make_context_current(conn,
a_old_ctxt_tag,
a_drawable,
a_readable,
remote_glx_ctxt_id);
reply = xcb_glx_make_context_current_reply(conn, cookie, NULL);
if (!reply)
goto out;
*a_ctxt_tag = reply->context_tag;
free(reply);
}
else {
xcb_glx_vendor_private_with_reply_cookie_t cookie;
xcb_glx_vendor_private_with_reply_reply_t *reply;
uint32_t data[3] = {
a_drawable, a_readable, remote_glx_ctxt_id,
};
EPHYR_LOG("enter\n");
cookie = xcb_glx_vendor_private_with_reply(conn,
X_GLXvop_MakeCurrentReadSGI,
a_old_ctxt_tag,
sizeof(data),
(uint8_t *)data);
reply = xcb_glx_vendor_private_with_reply_reply(conn, cookie, NULL);
*a_ctxt_tag = reply->retval;
free(reply);
}
EPHYR_LOG("context tag:%d\n", *a_ctxt_tag);
is_ok = TRUE;
out:
EPHYR_LOG("leave\n");
return is_ok;
}
Bool
ephyrHostGetIntegerValue(int a_current_context_tag, int a_int, int *a_val)
{
xcb_connection_t *conn = hostx_get_xcbconn();
Bool is_ok = FALSE;
int size = 0;
xcb_glx_get_integerv_cookie_t cookie;
xcb_glx_get_integerv_reply_t *reply;
EPHYR_RETURN_VAL_IF_FAIL(a_val, FALSE);
EPHYR_LOG("enter\n");
cookie = xcb_glx_get_integerv(conn, a_current_context_tag, a_int);
reply = xcb_glx_get_integerv_reply(conn, cookie, NULL);
if (!reply)
goto out;
size = reply->n;
if (!size) {
EPHYR_LOG_ERROR("X_GLsop_GetIngerv failed\n");
goto out;
}
*a_val = reply->datum;
is_ok = TRUE;
out:
free(reply);
EPHYR_LOG("leave\n");
return is_ok;
}
Bool
ephyrHostIsContextDirect(int a_ctxt_id, int *a_is_direct)
{
Bool is_ok = FALSE;
xcb_connection_t *conn = hostx_get_xcbconn();
xcb_glx_is_direct_cookie_t cookie;
xcb_glx_is_direct_reply_t *reply = NULL;
int remote_glx_ctxt_id = 0;
EPHYR_LOG("enter\n");
if (!hostx_get_resource_id_peer (a_ctxt_id, &remote_glx_ctxt_id)) {
EPHYR_LOG_ERROR ("failed to get remote glx ctxt id\n");
goto out;
}
/* Send the glXIsDirect request */
cookie = xcb_glx_is_direct(conn, remote_glx_ctxt_id);
reply = xcb_glx_is_direct_reply(conn, cookie, NULL);
if (!reply) {
EPHYR_LOG_ERROR("fail in reading reply from host\n");
goto out;
}
*a_is_direct = reply->is_direct;
is_ok = TRUE;
out:
free(reply);
EPHYR_LOG("leave\n");
return is_ok;
}

View File

@ -1,75 +0,0 @@
/*
* Xephyr - A kdrive X server thats runs in a host X window.
* Authored by Matthew Allum <mallum@openedhand.com>
*
* Copyright © 2007 OpenedHand Ltd
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of OpenedHand Ltd not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. OpenedHand Ltd makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* Authors:
* Dodji Seketeli <dodji@openedhand.com>
*/
#ifndef __EPHYRHOSTGLX_H__
#define __EPHYRHOSTGLX_H__
enum EphyrHostGLXGetStringOps {
EPHYR_HOST_GLX_UNDEF,
EPHYR_HOST_GLX_QueryServerString,
EPHYR_HOST_GLX_GetString,
};
Bool ephyrHostGLXQueryVersion(int *a_maj, int *a_min);
Bool ephyrHostGLXGetString(int a_context_tag,
int a_string_name,
char **a_string);
Bool ephyrHostGLXQueryServerString(int a_screen_number,
int a_string_name,
char **a_string);
Bool ephyrHostGLXGetVisualConfigs(int a_screen,
int32_t * a_num_visuals,
int32_t * a_num_props,
int32_t * a_props_buf_size,
int32_t ** a_props_buf);
Bool
ephyrHostGLXVendorPrivGetFBConfigsSGIX(int a_screen,
int32_t * a_num_visuals,
int32_t * a_num_props,
int32_t * a_props_buf_size,
int32_t ** a_props_buf);
Bool ephyrHostGLXSendClientInfo(int32_t a_major, int32_t a_minor,
const char *a_extension_list);
Bool ephyrHostGLXCreateContext(int a_screen,
int a_generic_id,
int a_context_id,
int a_share_list_ctxt_id,
int a_render_type,
Bool a_direct,
int code);
Bool ephyrHostDestroyContext(int a_ctxt_id);
Bool ephyrHostGLXMakeCurrent(int a_drawable, int a_readable, int a_glx_ctxt_id,
int a_olg_ctxt_tag, int *a_ctxt_tag);
Bool ephyrHostGetIntegerValue(int a_current_context_tag, int a_int, int *a_val);
Bool ephyrHostIsContextDirect(int a_ctxt_id, int *a_is_direct);
#endif /*__EPHYRHOSTGLX_H__*/

View File

@ -38,9 +38,6 @@ extern Bool kdHasPointer;
extern Bool kdHasKbd;
extern Bool ephyr_glamor, ephyr_glamor_gles2;
#ifdef GLXEXT
extern Bool ephyrNoDRI;
#endif
extern Bool ephyrNoXV;
#ifdef KDRIVE_EVDEV
@ -154,9 +151,6 @@ ddxUseMsg(void)
ErrorF
("-fakexa Simulate acceleration using software rendering\n");
ErrorF("-verbosity <level> Set log verbosity level\n");
#ifdef GLXEXT
ErrorF("-nodri do not use DRI\n");
#endif
ErrorF("-noxv do not use XV\n");
ErrorF("-name [name] define the name in the WM_CLASS property\n");
ErrorF
@ -314,13 +308,6 @@ ddxProcessArgument(int argc, char **argv, int i)
exit(1);
}
}
#ifdef GLXEXT
else if (!strcmp(argv[i], "-nodri")) {
ephyrNoDRI = TRUE;
EPHYR_LOG("no direct rendering enabled\n");
return 1;
}
#endif
else if (!strcmp(argv[i], "-noxv")) {
ephyrNoXV = TRUE;
EPHYR_LOG("no XVideo enabled\n");

View File

@ -52,10 +52,6 @@
#include <xcb/shape.h>
#include <xcb/xcb_keysyms.h>
#include <xcb/randr.h>
#ifdef XF86DRI
#include <xcb/xf86dri.h>
#include <xcb/glx.h>
#endif /* XF86DRI */
#ifdef GLAMOR
#include <epoxy/gl.h>
#include "glamor.h"
@ -1345,80 +1341,6 @@ out:
return is_ok;
}
#ifdef XF86DRI
typedef struct {
int is_valid;
int local_id;
int remote_id;
} ResourcePair;
#define RESOURCE_PEERS_SIZE 1024*10
static ResourcePair resource_peers[RESOURCE_PEERS_SIZE];
int
hostx_allocate_resource_id_peer(int a_local_resource_id,
int *a_remote_resource_id)
{
int i = 0;
ResourcePair *peer = NULL;
/*
* first make sure a resource peer
* does not exist already for
* a_local_resource_id
*/
for (i = 0; i < RESOURCE_PEERS_SIZE; i++) {
if (resource_peers[i].is_valid
&& resource_peers[i].local_id == a_local_resource_id) {
peer = &resource_peers[i];
break;
}
}
/*
* find one free peer entry, an feed it with
*/
if (!peer) {
for (i = 0; i < RESOURCE_PEERS_SIZE; i++) {
if (!resource_peers[i].is_valid) {
peer = &resource_peers[i];
break;
}
}
if (peer) {
peer->remote_id = xcb_generate_id(HostX.conn);
peer->local_id = a_local_resource_id;
peer->is_valid = TRUE;
}
}
if (peer) {
*a_remote_resource_id = peer->remote_id;
return TRUE;
}
return FALSE;
}
int
hostx_get_resource_id_peer(int a_local_resource_id, int *a_remote_resource_id)
{
int i = 0;
ResourcePair *peer = NULL;
for (i = 0; i < RESOURCE_PEERS_SIZE; i++) {
if (resource_peers[i].is_valid
&& resource_peers[i].local_id == a_local_resource_id) {
peer = &resource_peers[i];
break;
}
}
if (peer) {
*a_remote_resource_id = peer->remote_id;
return TRUE;
}
return FALSE;
}
#endif /* XF86DRI */
#ifdef GLAMOR
Bool
ephyr_glamor_init(ScreenPtr screen)

View File

@ -184,20 +184,6 @@ int hostx_set_window_bounding_rectangles(int a_window,
int hostx_has_extension(xcb_extension_t *extension);
#ifdef XF86DRI
int hostx_lookup_peer_window(void *a_local_window,
int *a_host_peer /*out parameter */ );
int
hostx_allocate_resource_id_peer(int a_local_resource_id,
int *a_remote_resource_id);
int
hostx_get_resource_id_peer(int a_local_resource_id, int *a_remote_resource_id);
int hostx_has_dri(void);
int hostx_has_glx(void);
#endif /* XF86DRI */
int hostx_get_fd(void);
#endif /*_XLIBS_STUFF_H_*/