Remove xgl.
This code hasn't been updated with anything even resembling what anyone is shipping in nearly thirty months. It hasn't built out of the box since 7.1. Most of its features over AIGLX are accomplished with DRI2 and friends.
This commit is contained in:
parent
c37a93b485
commit
d15b379030
70
configure.ac
70
configure.ac
|
@ -40,8 +40,6 @@ AC_CONFIG_HEADERS(include/xorg-server.h)
|
|||
dnl dix-config.h covers most of the DIX (i.e. everything but the DDX, not just
|
||||
dnl dix/).
|
||||
AC_CONFIG_HEADERS(include/dix-config.h)
|
||||
dnl xgl-config.h covers the Xgl DDX.
|
||||
AC_CONFIG_HEADERS(include/xgl-config.h)
|
||||
dnl xorg-config.h covers the Xorg DDX.
|
||||
AC_CONFIG_HEADERS(include/xorg-config.h)
|
||||
dnl xkb-config.h covers XKB for the Xorg and Xnest DDXs.
|
||||
|
@ -567,9 +565,6 @@ AC_ARG_ENABLE(xvfb, AS_HELP_STRING([--enable-xvfb], [Build Xvfb server
|
|||
AC_ARG_ENABLE(xnest, AS_HELP_STRING([--enable-xnest], [Build Xnest server (default: auto)]), [XNEST=$enableval], [XNEST=auto])
|
||||
AC_ARG_ENABLE(xquartz, AS_HELP_STRING([--enable-xquartz], [Build Xquartz server for OS-X (default: auto)]), [XQUARTZ=$enableval], [XQUARTZ=auto])
|
||||
AC_ARG_ENABLE(xwin, AS_HELP_STRING([--enable-xwin], [Build XWin server (default: auto)]), [XWIN=$enableval], [XWIN=auto])
|
||||
AC_ARG_ENABLE(xgl, AS_HELP_STRING([--enable-xgl], [Build Xgl server (default: no)]), [XGL=$enableval], [XGL=no])
|
||||
AC_ARG_ENABLE(xglx, AS_HELP_STRING([--enable-xglx], [Build Xglx xgl module (default: no)]), [XGLX=$enableval], [XGLX=no])
|
||||
AC_ARG_ENABLE(xegl, AS_HELP_STRING([--enable-xegl], [Build Xegl xgl module (default: no)]), [XEGL=$enableval], [XEGL=no])
|
||||
dnl legacy fb support
|
||||
AC_ARG_ENABLE(mfb, AS_HELP_STRING([--enable-mfb], [Build legacy mono framebuffer support (default: disable)]), [MFB=$enableval], [MFB=no])
|
||||
dnl kdrive and its subsystems
|
||||
|
@ -1252,62 +1247,6 @@ if test "x$XORG" = xauto; then
|
|||
fi
|
||||
AC_MSG_RESULT([$XORG])
|
||||
|
||||
dnl Xgl DDX
|
||||
|
||||
AC_MSG_CHECKING([whether to build Xgl DDX])
|
||||
if test "x$XGL" != xno; then
|
||||
PKG_CHECK_MODULES([XGLMODULES], [glitz-glx >= 0.4.3], [XGL=yes], [XGL=no])
|
||||
AC_SUBST(XGLMODULES_CFLAGS)
|
||||
fi
|
||||
AC_MSG_RESULT([$XGL])
|
||||
AM_CONDITIONAL(XGL, [test "x$XGL" = xyes])
|
||||
|
||||
if test "x$XGL" = xyes; then
|
||||
XGL_LIBS="$FB_LIB $COMPOSITE_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $MIEXT_LAYER_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB"
|
||||
XGL_SYS_LIBS="$XGLMODULES_LIBS $GLX_SYS_LIBS $DLOPEN_LIBS"
|
||||
AC_SUBST([XGL_LIBS])
|
||||
AC_SUBST([XGL_SYS_LIBS])
|
||||
AC_DEFINE(XGL_MODULAR, 1, [Use loadable XGL modules])
|
||||
|
||||
xglmoduledir="$moduledir/xgl"
|
||||
AC_SUBST([xglmoduledir])
|
||||
AC_DEFINE_DIR(XGL_MODULE_PATH, xglmoduledir, [Default XGL module search path])
|
||||
fi
|
||||
|
||||
dnl Xegl DDX
|
||||
|
||||
AC_MSG_CHECKING([whether to build Xegl DDX])
|
||||
if test "x$XEGL" != xno; then
|
||||
PKG_CHECK_MODULES([XGLMODULES], [glitz-glx >= 0.4.3], [XEGL=yes], [XEGL=no])
|
||||
AC_SUBST(XEGLMODULES_CFLAGS)
|
||||
fi
|
||||
AC_MSG_RESULT([$XEGL])
|
||||
AM_CONDITIONAL(XEGL, [test "x$XEGL" = xyes])
|
||||
|
||||
if test "x$XEGL" = xyes; then
|
||||
XEGL_LIBS="$FB_LIB $COMPOSITE_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $MIEXT_LAYER_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB"
|
||||
XEGL_SYS_LIBS = "$XEGL_SYS_LIBS $XEGLMODULES_LIBS $GLX_SYS_LIBS"
|
||||
AC_SUBST([XEGL_LIBS])
|
||||
AC_SUBST([XEGL_SYS_LIBS])
|
||||
fi
|
||||
|
||||
dnl Xglx DDX
|
||||
|
||||
AC_MSG_CHECKING([whether to build Xglx DDX])
|
||||
if test "x$XGLX" != xno; then
|
||||
PKG_CHECK_MODULES([XGLXMODULES], [glitz-glx >= 0.4.3 xrender], [XGLX=yes], [XGLX=no])
|
||||
AC_SUBST(XGLXMODULES_CFLAGS)
|
||||
fi
|
||||
AC_MSG_RESULT([$XGLX])
|
||||
AM_CONDITIONAL(XGLX, [test "x$XGLX" = xyes])
|
||||
|
||||
if test "x$XGLX" = xyes; then
|
||||
XGLX_LIBS="$FB_LIB $COMPOSITE_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $MIEXT_LAYER_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB"
|
||||
XGLX_SYS_LIBS="$XGLX_SYS_LIBS $XGLXMODULES_LIBS $GLX_SYS_LIBS"
|
||||
AC_SUBST([XGLX_LIBS])
|
||||
AC_SUBST([XGLX_SYS_LIBS])
|
||||
fi
|
||||
|
||||
xorg_bus_linuxpci=no
|
||||
xorg_bus_bsdpci=no
|
||||
xorg_bus_ix86pci=no
|
||||
|
@ -1315,7 +1254,7 @@ xorg_bus_ppcpci=no
|
|||
xorg_bus_sparcpci=no
|
||||
xorg_bus_sparc=no
|
||||
|
||||
if test "x$XORG" = xyes -o "x$XGL" = xyes; then
|
||||
if test "x$XORG" = xyes; then
|
||||
XORG_DDXINCS='-I$(top_srcdir)/hw/xfree86 -I$(top_srcdir)/hw/xfree86/include -I$(top_srcdir)/hw/xfree86/common'
|
||||
XORG_OSINCS='-I$(top_srcdir)/hw/xfree86/os-support -I$(top_srcdir)/hw/xfree86/os-support/bus -I$(top_srcdir)/os'
|
||||
XORG_INCS="$XORG_DDXINCS $XORG_OSINCS"
|
||||
|
@ -2054,13 +1993,6 @@ hw/dmx/input/Makefile
|
|||
hw/dmx/glxProxy/Makefile
|
||||
hw/dmx/Makefile
|
||||
hw/vfb/Makefile
|
||||
hw/xgl/Makefile
|
||||
hw/xgl/egl/Makefile
|
||||
hw/xgl/egl/module/Makefile
|
||||
hw/xgl/glx/Makefile
|
||||
hw/xgl/glx/module/Makefile
|
||||
hw/xgl/glxext/Makefile
|
||||
hw/xgl/glxext/module/Makefile
|
||||
hw/xnest/Makefile
|
||||
hw/xwin/Makefile
|
||||
hw/xquartz/Makefile
|
||||
|
|
|
@ -18,10 +18,6 @@ if XWIN
|
|||
XWIN_SUBDIRS = xwin
|
||||
endif
|
||||
|
||||
if XGL
|
||||
XGL_SUBDIRS = xgl
|
||||
endif
|
||||
|
||||
if KDRIVE
|
||||
KDRIVE_SUBDIRS = kdrive
|
||||
endif
|
||||
|
@ -32,7 +28,6 @@ endif
|
|||
|
||||
SUBDIRS = \
|
||||
$(XORG_SUBDIRS) \
|
||||
$(XGL_SUBDIRS) \
|
||||
$(XWIN_SUBDIRS) \
|
||||
$(XVFB_SUBDIRS) \
|
||||
$(XNEST_SUBDIRS) \
|
||||
|
@ -40,7 +35,7 @@ SUBDIRS = \
|
|||
$(KDRIVE_SUBDIRS) \
|
||||
$(XQUARTZ_SUBDIRS)
|
||||
|
||||
DIST_SUBDIRS = dmx xfree86 vfb xnest xwin xquartz kdrive xgl
|
||||
DIST_SUBDIRS = dmx xfree86 vfb xnest xwin xquartz kdrive
|
||||
|
||||
relink:
|
||||
for i in $(SUBDIRS) ; do $(MAKE) -C $$i relink ; done
|
||||
|
|
|
@ -1,83 +0,0 @@
|
|||
if GLX
|
||||
GLX_SUBDIRS = glxext
|
||||
endif
|
||||
|
||||
if XGLX
|
||||
XGLX_SUBDIRS = glx
|
||||
endif
|
||||
|
||||
if XEGL
|
||||
XEGL_SUBDIRS = egl
|
||||
endif
|
||||
|
||||
DIST_SUBDIRS = glxext glx egl
|
||||
|
||||
SUBDIRS = \
|
||||
. \
|
||||
$(GLX_SUBDIRS) \
|
||||
$(XGLX_SUBDIRS) \
|
||||
$(XEGL_SUBDIRS)
|
||||
|
||||
AM_CFLAGS = \
|
||||
$(DIX_CFLAGS) \
|
||||
-DHAVE_XGL_CONFIG_H \
|
||||
-DHAVE_DIX_CONFIG_H \
|
||||
-I$(top_srcdir)/glx \
|
||||
-I$(top_srcdir)/GL/include \
|
||||
-I@MESA_SOURCE@/include \
|
||||
-I@MESA_SOURCE@/src/mesa/glapi \
|
||||
$(XGLMODULES_CFLAGS)
|
||||
|
||||
noinst_LIBRARIES = libxgl.a
|
||||
|
||||
libxgl_a_SOURCES = \
|
||||
xgl.h \
|
||||
xglmodule.h \
|
||||
xglglx.h \
|
||||
xglinput.c \
|
||||
xgloutput.c \
|
||||
xglcmap.c \
|
||||
xglparse.c \
|
||||
xglscreen.c \
|
||||
xglarea.c \
|
||||
xglgeometry.c \
|
||||
xglpixmap.c \
|
||||
xglsync.c \
|
||||
xglsolid.c \
|
||||
xgltile.c \
|
||||
xglcopy.c \
|
||||
xglfill.c \
|
||||
xglwindow.c \
|
||||
xglget.c \
|
||||
xglgc.c \
|
||||
xglshm.c \
|
||||
xglcompose.c \
|
||||
xglpict.c \
|
||||
xglglyph.c \
|
||||
xgltrap.c \
|
||||
xglloader.c \
|
||||
xglhash.c \
|
||||
xglglx.c \
|
||||
xglxv.c
|
||||
|
||||
EXTRA_DIST = \
|
||||
xglmodule.h
|
||||
|
||||
Xgl_LDFLAGS = -export-dynamic
|
||||
Xgl_SOURCES = \
|
||||
xglinit.c \
|
||||
$(top_srcdir)/mi/miinitext.c \
|
||||
$(top_srcdir)/Xext/dpmsstubs.c \
|
||||
$(top_srcdir)/Xi/stubs.c \
|
||||
$(top_srcdir)/fb/fbcmap.c
|
||||
|
||||
XGL_LIBS = \
|
||||
libxgl.a \
|
||||
@XGL_LIBS@ \
|
||||
$(XSERVER_LIBS)
|
||||
|
||||
Xgl_DEPENDENCIES = $(XGL_LIBS)
|
||||
Xgl_LDADD = $(XGL_LIBS) $(XSERVER_SYS_LIBS) $(XGL_SYS_LIBS)
|
||||
Xgl_programs = Xgl
|
||||
|
||||
bin_PROGRAMS = $(Xgl_programs)
|
|
@ -1,44 +0,0 @@
|
|||
if XGL
|
||||
XGL_MODULE_DIRS = module
|
||||
endif
|
||||
|
||||
DIST_SUBDIRS = module
|
||||
|
||||
SUBDIRS = \
|
||||
. \
|
||||
$(XGL_MODULE_DIRS)
|
||||
|
||||
AM_CFLAGS = \
|
||||
$(DIX_CFLAGS) \
|
||||
-DHAVE_XGL_CONFIG_H \
|
||||
-DHAVE_DIX_CONFIG_H \
|
||||
$(XEGLMODULES_CFLAGS)
|
||||
|
||||
noinst_LTLIBRARIES = libxegl.la
|
||||
|
||||
libxegl_la_SOURCES = \
|
||||
xegl.h \
|
||||
xegl.c \
|
||||
xeglinput.c \
|
||||
kkeymap.h \
|
||||
kinput.c \
|
||||
evdev.c
|
||||
|
||||
XEGL_LIBS = \
|
||||
@XEGL_LIBS@ \
|
||||
libxegl.la \
|
||||
../libxgl.a \
|
||||
$XSERVER_LIBS
|
||||
|
||||
Xegl_LDFLAGS = -export-dynamic
|
||||
Xegl_SOURCES = \
|
||||
xeglinit.c \
|
||||
$(top_srcdir)/mi/miinitext.c \
|
||||
$(top_srcdir)/Xext/dpmsstubs.c \
|
||||
$(top_srcdir)/Xi/stubs.c \
|
||||
$(top_srcdir)/fb/fbcmap.c
|
||||
|
||||
Xegl_DEPENDENCIES = $(XEGL_LIBS)
|
||||
Xegl_LDADD = $(XEGL_LIBS) $(XSERVER_SYS_LIBS) $(XEGL_SYS_LIBS)
|
||||
|
||||
bin_PROGRAMS = Xegl
|
|
@ -1,646 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2004 Keith Packard
|
||||
*
|
||||
* 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 Keith Packard not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Keith Packard makes no
|
||||
* representations about the suitability of this software for any purpose. It
|
||||
* is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL KEITH PACKARD 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.
|
||||
*/
|
||||
|
||||
#include <xgl-config.h>
|
||||
#define NEED_EVENTS
|
||||
#include <errno.h>
|
||||
#include <linux/input.h>
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xproto.h>
|
||||
#include <X11/Xpoll.h>
|
||||
#define XK_PUBLISHING
|
||||
#include <X11/keysym.h>
|
||||
#include "inputstr.h"
|
||||
#include "kkeymap.h"
|
||||
#include "scrnintstr.h"
|
||||
#include "xegl.h"
|
||||
|
||||
#define NUM_EVENTS 128
|
||||
#define ABS_UNSET -65535
|
||||
|
||||
#define BITS_PER_LONG (sizeof(long) * 8)
|
||||
#define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1)
|
||||
#define ISBITSET(x,y) ((x)[LONG(y)] & BIT(y))
|
||||
#define OFF(x) ((x)%BITS_PER_LONG)
|
||||
#define LONG(x) ((x)/BITS_PER_LONG)
|
||||
#define BIT(x) (1 << OFF(x))
|
||||
#define SETBIT(x,y) ((x)[LONG(y)] |= BIT(y))
|
||||
#define CLRBIT(x,y) ((x)[LONG(y)] &= ~BIT(y))
|
||||
#define ASSIGNBIT(x,y,z) ((x)[LONG(y)] = ((x)[LONG(y)] & ~BIT(y)) | (z << OFF(y)))
|
||||
|
||||
typedef struct _kevdevMouse {
|
||||
/* current device state */
|
||||
int rel[REL_MAX + 1];
|
||||
int abs[ABS_MAX + 1];
|
||||
int prevabs[ABS_MAX + 1];
|
||||
long key[NBITS(KEY_MAX + 1)];
|
||||
|
||||
/* supported device info */
|
||||
long relbits[NBITS(REL_MAX + 1)];
|
||||
long absbits[NBITS(ABS_MAX + 1)];
|
||||
long keybits[NBITS(KEY_MAX + 1)];
|
||||
struct input_absinfo absinfo[ABS_MAX + 1];
|
||||
int max_rel;
|
||||
int max_abs;
|
||||
} Kevdev;
|
||||
|
||||
static int flags = 0;
|
||||
|
||||
static void
|
||||
EvdevMotion (KdMouseInfo *mi)
|
||||
{
|
||||
Kevdev *ke = mi->driver;
|
||||
int i;
|
||||
|
||||
for (i = 0; i <= ke->max_rel; i++)
|
||||
if (ke->rel[i])
|
||||
{
|
||||
KdEnqueueMouseEvent (mi, flags | KD_MOUSE_DELTA, ke->rel[0], ke->rel[1]);
|
||||
int a;
|
||||
// ErrorF ("rel");
|
||||
for (a = 0; a <= ke->max_rel; a++)
|
||||
{
|
||||
// if (ISBITSET (ke->relbits, a))
|
||||
// ErrorF (" %d=%d", a, ke->rel[a]);
|
||||
ke->rel[a] = 0;
|
||||
}
|
||||
// ErrorF ("\n");
|
||||
break;
|
||||
}
|
||||
for (i = 0; i < ke->max_abs; i++)
|
||||
if (ke->abs[i] != ke->prevabs[i])
|
||||
{
|
||||
KdEnqueueMouseEvent (mi, flags, ke->abs[0], ke->abs[1]);
|
||||
int a;
|
||||
// ErrorF ("abs");
|
||||
for (a = 0; a <= ke->max_abs; a++)
|
||||
{
|
||||
// if (ISBITSET (ke->absbits, a))
|
||||
// ErrorF (" %d=%d", a, ke->abs[a]);
|
||||
ke->prevabs[a] = ke->abs[a];
|
||||
}
|
||||
// ErrorF ("\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
EvdevRead (int evdevPort, void *closure)
|
||||
{
|
||||
KdMouseInfo *mi = closure;
|
||||
Kevdev *ke = mi->driver;
|
||||
int i, n;
|
||||
struct input_event events[NUM_EVENTS];
|
||||
|
||||
n = read (evdevPort, &events, NUM_EVENTS * sizeof (struct input_event));
|
||||
if (n <= 0)
|
||||
return;
|
||||
n /= sizeof (struct input_event);
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
switch (events[i].type) {
|
||||
case EV_SYN:
|
||||
break;
|
||||
case EV_KEY:
|
||||
EvdevMotion (mi);
|
||||
ASSIGNBIT(ke->key,events[i].code, events[i].value);
|
||||
if (events[i].code < 0x100)
|
||||
ErrorF ("key %d %d\n", events[i].code, events[i].value);
|
||||
else
|
||||
ErrorF ("key 0x%x %d\n", events[i].code, events[i].value);
|
||||
|
||||
if (events[i].value==1) {
|
||||
switch (events[i].code) {
|
||||
case BTN_LEFT:
|
||||
flags |= KD_BUTTON_1;
|
||||
break;
|
||||
case BTN_RIGHT:
|
||||
flags |= KD_BUTTON_3;
|
||||
break;
|
||||
case BTN_MIDDLE:
|
||||
flags |= KD_BUTTON_2;
|
||||
break;
|
||||
case BTN_FORWARD:
|
||||
flags |= KD_BUTTON_4;
|
||||
break;
|
||||
case BTN_BACK:
|
||||
flags |= KD_BUTTON_5;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (events[i].value==0) {
|
||||
switch (events[i].code) {
|
||||
case BTN_LEFT:
|
||||
flags &= ~KD_BUTTON_1;
|
||||
break;
|
||||
case BTN_RIGHT:
|
||||
flags &= ~KD_BUTTON_3;
|
||||
break;
|
||||
case BTN_MIDDLE:
|
||||
flags &= ~KD_BUTTON_2;
|
||||
break;
|
||||
case BTN_FORWARD:
|
||||
flags &= ~KD_BUTTON_4;
|
||||
break;
|
||||
case BTN_BACK:
|
||||
flags &= ~KD_BUTTON_5;
|
||||
break;
|
||||
}
|
||||
}
|
||||
KdEnqueueMouseEvent (mi, KD_MOUSE_DELTA | flags, 0, 0);
|
||||
break;
|
||||
case EV_REL:
|
||||
ke->rel[events[i].code] += events[i].value;
|
||||
break;
|
||||
case EV_ABS:
|
||||
ke->abs[events[i].code] = events[i].value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
EvdevMotion (mi);
|
||||
}
|
||||
|
||||
int EvdevInputType;
|
||||
|
||||
char *kdefaultEvdev[] = {
|
||||
// "/dev/input/event0",
|
||||
"/dev/input/event1",
|
||||
// "/dev/input/event2",
|
||||
// "/dev/input/event3",
|
||||
// "/dev/input/event4",
|
||||
// "/dev/input/event5",
|
||||
};
|
||||
|
||||
#define NUM_DEFAULT_EVDEV (sizeof (kdefaultEvdev) / sizeof (kdefaultEvdev[0]))
|
||||
|
||||
static Bool
|
||||
EvdevInit (void)
|
||||
{
|
||||
int i;
|
||||
int fd;
|
||||
KdMouseInfo *mi, *next;
|
||||
int n = 0;
|
||||
char *prot;
|
||||
char name[100];
|
||||
|
||||
if (!EvdevInputType)
|
||||
EvdevInputType = KdAllocInputType ();
|
||||
|
||||
for (mi = kdMouseInfo; mi; mi = next)
|
||||
{
|
||||
next = mi->next;
|
||||
prot = mi->prot;
|
||||
if (mi->inputType)
|
||||
continue;
|
||||
if (!mi->name)
|
||||
{
|
||||
for (i = 0; i < NUM_DEFAULT_EVDEV; i++)
|
||||
{
|
||||
fd = open (kdefaultEvdev[i], 2);
|
||||
if (fd >= 0)
|
||||
{
|
||||
ioctl(fd, EVIOCGRAB, 1);
|
||||
|
||||
ioctl(fd, EVIOCGNAME(sizeof(name)), name);
|
||||
ErrorF("Name is %s\n", name);
|
||||
ioctl(fd, EVIOCGPHYS(sizeof(name)), name);
|
||||
ErrorF("Phys Loc is %s\n", name);
|
||||
ioctl(fd, EVIOCGUNIQ(sizeof(name)), name);
|
||||
ErrorF("Unique is %s\n", name);
|
||||
|
||||
mi->name = KdSaveString (kdefaultEvdev[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
fd = open (mi->name, 2);
|
||||
|
||||
if (fd >= 0)
|
||||
{
|
||||
unsigned long ev[NBITS(EV_MAX)];
|
||||
Kevdev *ke;
|
||||
|
||||
if (ioctl (fd, EVIOCGBIT(0 /*EV*/, sizeof (ev)), ev) < 0)
|
||||
{
|
||||
perror ("EVIOCGBIT 0");
|
||||
close (fd);
|
||||
continue;
|
||||
}
|
||||
ke = xalloc (sizeof (Kevdev));
|
||||
if (!ke)
|
||||
{
|
||||
close (fd);
|
||||
continue;
|
||||
}
|
||||
memset (ke, '\0', sizeof (Kevdev));
|
||||
if (ISBITSET (ev, EV_KEY))
|
||||
{
|
||||
if (ioctl (fd, EVIOCGBIT (EV_KEY, sizeof (ke->keybits)),
|
||||
ke->keybits) < 0)
|
||||
{
|
||||
perror ("EVIOCGBIT EV_KEY");
|
||||
xfree (ke);
|
||||
close (fd);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (ISBITSET (ev, EV_REL))
|
||||
{
|
||||
if (ioctl (fd, EVIOCGBIT (EV_REL, sizeof (ke->relbits)),
|
||||
ke->relbits) < 0)
|
||||
{
|
||||
perror ("EVIOCGBIT EV_REL");
|
||||
xfree (ke);
|
||||
close (fd);
|
||||
continue;
|
||||
}
|
||||
for (ke->max_rel = REL_MAX; ke->max_rel >= 0; ke->max_rel--)
|
||||
if (ISBITSET(ke->relbits, ke->max_rel))
|
||||
break;
|
||||
}
|
||||
if (ISBITSET (ev, EV_ABS))
|
||||
{
|
||||
int i;
|
||||
|
||||
if (ioctl (fd, EVIOCGBIT (EV_ABS, sizeof (ke->absbits)),
|
||||
ke->absbits) < 0)
|
||||
{
|
||||
perror ("EVIOCGBIT EV_ABS");
|
||||
xfree (ke);
|
||||
close (fd);
|
||||
continue;
|
||||
}
|
||||
for (ke->max_abs = ABS_MAX; ke->max_abs >= 0; ke->max_abs--)
|
||||
if (ISBITSET(ke->absbits, ke->max_abs))
|
||||
break;
|
||||
for (i = 0; i <= ke->max_abs; i++)
|
||||
{
|
||||
if (ISBITSET (ke->absbits, i))
|
||||
if (ioctl (fd, EVIOCGABS(i), &ke->absinfo[i]) < 0)
|
||||
{
|
||||
perror ("EVIOCGABS");
|
||||
break;
|
||||
}
|
||||
ke->prevabs[i] = ABS_UNSET;
|
||||
}
|
||||
if (i <= ke->max_abs)
|
||||
{
|
||||
xfree (ke);
|
||||
close (fd);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
mi->driver = ke;
|
||||
mi->inputType = EvdevInputType;
|
||||
if (KdRegisterFd (EvdevInputType, fd, EvdevRead, (void *) mi))
|
||||
n++;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
EvdevFini (void)
|
||||
{
|
||||
KdMouseInfo *mi;
|
||||
|
||||
KdUnregisterFds (EvdevInputType, TRUE);
|
||||
for (mi = kdMouseInfo; mi; mi = mi->next)
|
||||
{
|
||||
if (mi->inputType == EvdevInputType)
|
||||
{
|
||||
xfree (mi->driver);
|
||||
mi->driver = 0;
|
||||
mi->inputType = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
KdMouseFuncs LinuxEvdevMouseFuncs = {
|
||||
EvdevInit,
|
||||
EvdevFini,
|
||||
};
|
||||
|
||||
|
||||
KeySym evdevKeymap[(112 - 1 + 1) * 2] = {
|
||||
/* These are directly mapped from DOS scanset 0 */
|
||||
/* 1 8 */ XK_Escape, NoSymbol,
|
||||
/* 2 9 */ XK_1, XK_exclam,
|
||||
/* 3 10 */ XK_2, XK_at,
|
||||
/* 4 11 */ XK_3, XK_numbersign,
|
||||
/* 5 12 */ XK_4, XK_dollar,
|
||||
/* 6 13 */ XK_5, XK_percent,
|
||||
/* 7 14 */ XK_6, XK_asciicircum,
|
||||
/* 8 15 */ XK_7, XK_ampersand,
|
||||
/* 9 16 */ XK_8, XK_asterisk,
|
||||
/* 10 17 */ XK_9, XK_parenleft,
|
||||
/* 11 18 */ XK_0, XK_parenright,
|
||||
/* 12 19 */ XK_minus, XK_underscore,
|
||||
/* 13 20 */ XK_equal, XK_plus,
|
||||
/* 14 21 */ XK_BackSpace, NoSymbol,
|
||||
/* 15 22 */ XK_Tab, NoSymbol,
|
||||
/* 16 23 */ XK_Q, NoSymbol,
|
||||
/* 17 24 */ XK_W, NoSymbol,
|
||||
/* 18 25 */ XK_E, NoSymbol,
|
||||
/* 19 26 */ XK_R, NoSymbol,
|
||||
/* 20 27 */ XK_T, NoSymbol,
|
||||
/* 21 28 */ XK_Y, NoSymbol,
|
||||
/* 22 29 */ XK_U, NoSymbol,
|
||||
/* 23 30 */ XK_I, NoSymbol,
|
||||
/* 24 31 */ XK_O, NoSymbol,
|
||||
/* 25 32 */ XK_P, NoSymbol,
|
||||
/* 26 33 */ XK_bracketleft, XK_braceleft,
|
||||
/* 27 34 */ XK_bracketright, XK_braceright,
|
||||
/* 28 35 */ XK_Return, NoSymbol,
|
||||
/* 29 36 */ XK_Control_L, NoSymbol,
|
||||
/* 30 37 */ XK_A, NoSymbol,
|
||||
/* 31 38 */ XK_S, NoSymbol,
|
||||
/* 32 39 */ XK_D, NoSymbol,
|
||||
/* 33 40 */ XK_F, NoSymbol,
|
||||
/* 34 41 */ XK_G, NoSymbol,
|
||||
/* 35 42 */ XK_H, NoSymbol,
|
||||
/* 36 43 */ XK_J, NoSymbol,
|
||||
/* 37 44 */ XK_K, NoSymbol,
|
||||
/* 38 45 */ XK_L, NoSymbol,
|
||||
/* 39 46 */ XK_semicolon, XK_colon,
|
||||
/* 40 47 */ XK_apostrophe, XK_quotedbl,
|
||||
/* 41 48 */ XK_grave, XK_asciitilde,
|
||||
/* 42 49 */ XK_Shift_L, NoSymbol,
|
||||
/* 43 50 */ XK_backslash, XK_bar,
|
||||
/* 44 51 */ XK_Z, NoSymbol,
|
||||
/* 45 52 */ XK_X, NoSymbol,
|
||||
/* 46 53 */ XK_C, NoSymbol,
|
||||
/* 47 54 */ XK_V, NoSymbol,
|
||||
/* 48 55 */ XK_B, NoSymbol,
|
||||
/* 49 56 */ XK_N, NoSymbol,
|
||||
/* 50 57 */ XK_M, NoSymbol,
|
||||
/* 51 58 */ XK_comma, XK_less,
|
||||
/* 52 59 */ XK_period, XK_greater,
|
||||
/* 53 60 */ XK_slash, XK_question,
|
||||
/* 54 61 */ XK_Shift_R, NoSymbol,
|
||||
/* 55 62 */ XK_KP_Multiply, NoSymbol,
|
||||
/* 56 63 */ XK_Alt_L, XK_Meta_L,
|
||||
/* 57 64 */ XK_space, NoSymbol,
|
||||
/* 58 65 */ XK_Caps_Lock, NoSymbol,
|
||||
/* 59 66 */ XK_F1, NoSymbol,
|
||||
/* 60 67 */ XK_F2, NoSymbol,
|
||||
/* 61 68 */ XK_F3, NoSymbol,
|
||||
/* 62 69 */ XK_F4, NoSymbol,
|
||||
/* 63 70 */ XK_F5, NoSymbol,
|
||||
/* 64 71 */ XK_F6, NoSymbol,
|
||||
/* 65 72 */ XK_F7, NoSymbol,
|
||||
/* 66 73 */ XK_F8, NoSymbol,
|
||||
/* 67 74 */ XK_F9, NoSymbol,
|
||||
/* 68 75 */ XK_F10, NoSymbol,
|
||||
/* 69 76 */ XK_Break, XK_Pause,
|
||||
/* 70 77 */ XK_Scroll_Lock, NoSymbol,
|
||||
/* 71 78 */ XK_KP_Home, XK_KP_7,
|
||||
/* 72 79 */ XK_KP_Up, XK_KP_8,
|
||||
/* 73 80 */ XK_KP_Page_Up, XK_KP_9,
|
||||
/* 74 81 */ XK_KP_Subtract, NoSymbol,
|
||||
/* 75 82 */ XK_KP_Left, XK_KP_4,
|
||||
/* 76 83 */ XK_KP_5, NoSymbol,
|
||||
/* 77 84 */ XK_KP_Right, XK_KP_6,
|
||||
/* 78 85 */ XK_KP_Add, NoSymbol,
|
||||
/* 79 86 */ XK_KP_End, XK_KP_1,
|
||||
/* 80 87 */ XK_KP_Down, XK_KP_2,
|
||||
/* 81 88 */ XK_KP_Page_Down, XK_KP_3,
|
||||
/* 82 89 */ XK_KP_Insert, XK_KP_0,
|
||||
/* 83 90 */ XK_KP_Delete, XK_KP_Decimal,
|
||||
/* 84 91 */ NoSymbol, NoSymbol,
|
||||
/* 85 92 */ NoSymbol, NoSymbol,
|
||||
/* 86 93 */ NoSymbol, NoSymbol,
|
||||
/* 87 94 */ XK_F11, NoSymbol,
|
||||
/* 88 95 */ XK_F12, NoSymbol,
|
||||
|
||||
/* These are remapped from the extended set (using ExtendMap) */
|
||||
|
||||
/* 89 96 */ XK_Control_R, NoSymbol,
|
||||
/* 90 97 */ XK_KP_Enter, NoSymbol,
|
||||
/* 91 98 */ XK_KP_Divide, NoSymbol,
|
||||
/* 92 99 */ XK_Sys_Req, XK_Print,
|
||||
/* 93 100 */ XK_Alt_R, XK_Meta_R,
|
||||
/* 94 101 */ XK_Num_Lock, NoSymbol,
|
||||
/* 95 102 */ XK_Home, NoSymbol,
|
||||
/* 96 103 */ XK_Up, NoSymbol,
|
||||
/* 97 104 */ XK_Page_Up, NoSymbol,
|
||||
/* 98 105 */ XK_Left, NoSymbol,
|
||||
/* 99 106 */ XK_Right, NoSymbol,
|
||||
/* 100 107 */ XK_End, NoSymbol,
|
||||
/* 101 108 */ XK_Down, NoSymbol,
|
||||
/* 102 109 */ XK_Page_Down, NoSymbol,
|
||||
/* 103 110 */ XK_Insert, NoSymbol,
|
||||
/* 104 111 */ XK_Delete, NoSymbol,
|
||||
/* 105 112 */ XK_Super_L, NoSymbol,
|
||||
/* 106 113 */ XK_Super_R, NoSymbol,
|
||||
/* 107 114 */ XK_Menu, NoSymbol,
|
||||
/* 108 115 */ NoSymbol, NoSymbol,
|
||||
/* 109 116 */ NoSymbol, NoSymbol,
|
||||
/* 110 117 */ NoSymbol, NoSymbol,
|
||||
/* 111 118 */ NoSymbol, NoSymbol,
|
||||
/* 112 119 */ NoSymbol, NoSymbol,
|
||||
};
|
||||
|
||||
static void
|
||||
EvdevRead1 (int evdevPort, void *closure)
|
||||
{
|
||||
int i, n, xk;
|
||||
struct input_event events[NUM_EVENTS];
|
||||
|
||||
n = read (evdevPort, &events, NUM_EVENTS * sizeof (struct input_event));
|
||||
if (n <= 0)
|
||||
return;
|
||||
n /= sizeof (struct input_event);
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
switch (events[i].type) {
|
||||
case EV_SYN:
|
||||
break;
|
||||
case EV_KEY:
|
||||
xk = events[i].code;
|
||||
if (events[i].code < 0x100)
|
||||
ErrorF ("key %d %d xk %d\n", events[i].code, events[i].value, xk);
|
||||
else
|
||||
ErrorF ("key 0x%x %d xk %d\n", events[i].code, events[i].value, xk);
|
||||
if (events[i].value == 2) {
|
||||
//KdEnqueueKeyboardEvent (xk, 0);
|
||||
KdEnqueueKeyboardEvent (xk, 0);
|
||||
} else
|
||||
KdEnqueueKeyboardEvent (xk, !events[i].value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
char *kdefaultEvdev1[] = {
|
||||
"/dev/input/event0",
|
||||
// "/dev/input/event1",
|
||||
// "/dev/input/event2",
|
||||
// "/dev/input/event3",
|
||||
// "/dev/input/event4",
|
||||
// "/dev/input/event5",
|
||||
};
|
||||
|
||||
#define NUM_DEFAULT_EVDEV1 (sizeof (kdefaultEvdev1) / sizeof (kdefaultEvdev1[0]))
|
||||
|
||||
static Bool
|
||||
EvdevKbdInit (void)
|
||||
{
|
||||
int i;
|
||||
int fd;
|
||||
int n = 0;
|
||||
char name[100];
|
||||
|
||||
if (!EvdevInputType)
|
||||
EvdevInputType = KdAllocInputType ();
|
||||
|
||||
for (i = 0; i < NUM_DEFAULT_EVDEV; i++)
|
||||
{
|
||||
fd = open (kdefaultEvdev1[i], 2);
|
||||
if (fd >= 0)
|
||||
{
|
||||
ioctl(fd, EVIOCGRAB, 1);
|
||||
|
||||
ioctl(fd, EVIOCGNAME(sizeof(name)), name);
|
||||
ErrorF("Name is %s\n", name);
|
||||
ioctl(fd, EVIOCGPHYS(sizeof(name)), name);
|
||||
ErrorF("Phys Loc is %s\n", name);
|
||||
ioctl(fd, EVIOCGUNIQ(sizeof(name)), name);
|
||||
ErrorF("Unique is %s\n", name);
|
||||
|
||||
}
|
||||
|
||||
if (fd >= 0)
|
||||
{
|
||||
unsigned long ev[NBITS(EV_MAX)];
|
||||
Kevdev *ke;
|
||||
|
||||
if (ioctl (fd, EVIOCGBIT(0 /*EV*/, sizeof (ev)), ev) < 0)
|
||||
{
|
||||
perror ("EVIOCGBIT 0");
|
||||
close (fd);
|
||||
continue;
|
||||
}
|
||||
ke = xalloc (sizeof (Kevdev));
|
||||
if (!ke)
|
||||
{
|
||||
close (fd);
|
||||
continue;
|
||||
}
|
||||
memset (ke, '\0', sizeof (Kevdev));
|
||||
if (ISBITSET (ev, EV_KEY))
|
||||
{
|
||||
if (ioctl (fd, EVIOCGBIT (EV_KEY, sizeof (ke->keybits)),
|
||||
ke->keybits) < 0)
|
||||
{
|
||||
perror ("EVIOCGBIT EV_KEY");
|
||||
xfree (ke);
|
||||
close (fd);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (ISBITSET (ev, EV_REL))
|
||||
{
|
||||
if (ioctl (fd, EVIOCGBIT (EV_REL, sizeof (ke->relbits)),
|
||||
ke->relbits) < 0)
|
||||
{
|
||||
perror ("EVIOCGBIT EV_REL");
|
||||
xfree (ke);
|
||||
close (fd);
|
||||
continue;
|
||||
}
|
||||
for (ke->max_rel = REL_MAX; ke->max_rel >= 0; ke->max_rel--)
|
||||
if (ISBITSET(ke->relbits, ke->max_rel))
|
||||
break;
|
||||
}
|
||||
if (ISBITSET (ev, EV_ABS))
|
||||
{
|
||||
int i;
|
||||
|
||||
if (ioctl (fd, EVIOCGBIT (EV_ABS, sizeof (ke->absbits)),
|
||||
ke->absbits) < 0)
|
||||
{
|
||||
perror ("EVIOCGBIT EV_ABS");
|
||||
xfree (ke);
|
||||
close (fd);
|
||||
continue;
|
||||
}
|
||||
for (ke->max_abs = ABS_MAX; ke->max_abs >= 0; ke->max_abs--)
|
||||
if (ISBITSET(ke->absbits, ke->max_abs))
|
||||
break;
|
||||
for (i = 0; i <= ke->max_abs; i++)
|
||||
{
|
||||
if (ISBITSET (ke->absbits, i))
|
||||
if (ioctl (fd, EVIOCGABS(i), &ke->absinfo[i]) < 0)
|
||||
{
|
||||
perror ("EVIOCGABS");
|
||||
break;
|
||||
}
|
||||
ke->prevabs[i] = ABS_UNSET;
|
||||
}
|
||||
if (i <= ke->max_abs)
|
||||
{
|
||||
xfree (ke);
|
||||
close (fd);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (KdRegisterFd (EvdevInputType, fd, EvdevRead1, NULL))
|
||||
n++;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void EvdevKbdLoad(void)
|
||||
{
|
||||
kdMinScanCode = 1;
|
||||
kdMaxScanCode = 112;
|
||||
kdKeymapWidth = 2;
|
||||
memcpy (kdKeymap, evdevKeymap, sizeof (evdevKeymap));
|
||||
}
|
||||
|
||||
static void
|
||||
EvdevKbdFini (void)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
EvdevKbdLeds (int leds)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static void EvdevKbdBell(int volume, int pitch, int duration)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
KdKeyboardFuncs LinuxEvdevKeyboardFuncs = {
|
||||
EvdevKbdLoad,
|
||||
EvdevKbdInit,
|
||||
EvdevKbdLeds,
|
||||
EvdevKbdBell,
|
||||
EvdevKbdFini,
|
||||
0,
|
||||
};
|
1670
hw/xgl/egl/kinput.c
1670
hw/xgl/egl/kinput.c
File diff suppressed because it is too large
Load Diff
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
* Copyright 1999 Keith Packard
|
||||
*
|
||||
* 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 Keith Packard not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Keith Packard makes no
|
||||
* representations about the suitability of this software for any purpose. It
|
||||
* is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL KEITH PACKARD 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.
|
||||
*/
|
||||
/*
|
||||
* All global variables and functions pertaining to keyboard key mapping
|
||||
* live in this header file.
|
||||
*/
|
||||
|
||||
#ifndef _KKEYMAP_H
|
||||
#define _KKEYMAP_H
|
||||
|
||||
/* Offset of MIN_SCANCODE to 8 (X minimum scancode value) */
|
||||
#define KD_KEY_OFFSET (8 - kdMinScanCode)
|
||||
|
||||
#define KD_MIN_KEYCODE 8
|
||||
#define KD_MAX_KEYCODE 254
|
||||
#define KD_MAX_WIDTH 4
|
||||
#define KD_MAX_LENGTH (KD_MAX_KEYCODE - KD_MIN_KEYCODE + 1)
|
||||
|
||||
extern int kdMinScanCode;
|
||||
extern int kdMaxScanCode;
|
||||
extern int kdMinKeyCode;
|
||||
extern int kdMaxKeyCode;
|
||||
extern int kdKeymapWidth;
|
||||
|
||||
extern KeySym kdKeymap[KD_MAX_LENGTH * KD_MAX_WIDTH];
|
||||
|
||||
extern CARD8 kdModMap[MAP_LENGTH];
|
||||
|
||||
extern KeySymsRec kdKeySyms;
|
||||
|
||||
typedef struct {
|
||||
KeySym modsym;
|
||||
int modbit;
|
||||
} KdKeySymModsRec;
|
||||
|
||||
#endif /* _KKEYMAP_H */
|
|
@ -1,15 +0,0 @@
|
|||
AM_CFLAGS = \
|
||||
$(DIX_CFLAGS) \
|
||||
-I$(srcdir)/.. \
|
||||
-I$(srcdir)/../.. \
|
||||
$(XEGLMODULES_CFLAGS)
|
||||
|
||||
libxegl_la_LDFLAGS = -avoid-version
|
||||
libxegl_la_SOURCES = xeglmodule.c
|
||||
libxegl_la_LIBADD = \
|
||||
$(top_builddir)/hw/xgl/glx/libxegl.la \
|
||||
$(XEGLMODULES_LIBS)
|
||||
|
||||
moduledir = @xglmoduledir@
|
||||
|
||||
module_LTLIBRARIES = libxegl.la
|
|
@ -1,104 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2005 Novell, Inc.
|
||||
*
|
||||
* 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
|
||||
* Novell, Inc. not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* Novell, Inc. makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL NOVELL, INC. 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include "xglmodule.h"
|
||||
#include "xegl.h"
|
||||
|
||||
#include <glitz-egl.h>
|
||||
|
||||
char *
|
||||
moduleVersion (void)
|
||||
{
|
||||
return VERSION;
|
||||
}
|
||||
|
||||
Bool
|
||||
moduleInit (const char *module)
|
||||
{
|
||||
glitz_egl_init (module);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
InitOutput (ScreenInfo *pScreenInfo,
|
||||
int argc,
|
||||
char **argv)
|
||||
{
|
||||
xeglInitOutput (pScreenInfo, argc, argv);
|
||||
}
|
||||
|
||||
Bool
|
||||
LegalModifier (unsigned int key,
|
||||
DeviceIntPtr pDev)
|
||||
{
|
||||
return xeglLegalModifier (key, pDev);
|
||||
}
|
||||
|
||||
void
|
||||
ProcessInputEvents (void)
|
||||
{
|
||||
xeglProcessInputEvents ();
|
||||
}
|
||||
|
||||
void
|
||||
InitInput (int argc,
|
||||
char **argv)
|
||||
{
|
||||
xeglInitInput (argc, argv);
|
||||
}
|
||||
|
||||
void
|
||||
ddxUseMsg (void)
|
||||
{
|
||||
ErrorF ("\nXegl usage:\n");
|
||||
xeglUseMsg ();
|
||||
}
|
||||
|
||||
int
|
||||
ddxProcessArgument (int argc,
|
||||
char **argv,
|
||||
int i)
|
||||
{
|
||||
return xeglProcessArgument (argc, argv, i);
|
||||
}
|
||||
|
||||
void
|
||||
AbortDDX (void)
|
||||
{
|
||||
xeglAbort ();
|
||||
}
|
||||
|
||||
void
|
||||
ddxGiveUp (void)
|
||||
{
|
||||
xeglGiveUp ();
|
||||
}
|
||||
|
||||
void
|
||||
OsVendorInit (void)
|
||||
{
|
||||
xeglOsVendorInit ();
|
||||
}
|
|
@ -1,303 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* 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
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <glitz-egl.h>
|
||||
|
||||
#include "inputstr.h"
|
||||
#include "cursorstr.h"
|
||||
#include "mipointer.h"
|
||||
|
||||
#include "xegl.h"
|
||||
|
||||
#define XEGL_DEFAULT_SCREEN_WIDTH 800
|
||||
#define XEGL_DEFAULT_SCREEN_HEIGHT 600
|
||||
|
||||
DevPrivateKey xeglScreenPrivateKey = &xeglScreenPrivateKey;
|
||||
|
||||
#define XEGL_GET_SCREEN_PRIV(pScreen) ((xeglScreenPtr) \
|
||||
dixLookupPrivate(&(pScreen)->devPrivates, xeglScreenPrivateKey))
|
||||
|
||||
#define XEGL_SET_SCREEN_PRIV(pScreen, v) \
|
||||
dixSetPrivate(&(pScreen)->devPrivates, xeglScreenPrivateKey, v)
|
||||
|
||||
#define XEGL_SCREEN_PRIV(pScreen) \
|
||||
xeglScreenPtr pScreenPriv = XEGL_GET_SCREEN_PRIV (pScreen)
|
||||
|
||||
static EGLDisplay eDisplay;
|
||||
static EGLScreenMESA eScreen;
|
||||
static ScreenPtr currentScreen = 0;
|
||||
static Bool softCursor = TRUE;
|
||||
|
||||
extern miPointerScreenFuncRec kdPointerScreenFuncs;
|
||||
|
||||
static Bool
|
||||
xeglAllocatePrivates (ScreenPtr pScreen)
|
||||
{
|
||||
xeglScreenPtr pScreenPriv;
|
||||
|
||||
pScreenPriv = xalloc (sizeof (xeglScreenRec));
|
||||
if (!pScreenPriv)
|
||||
return FALSE;
|
||||
|
||||
XEGL_SET_SCREEN_PRIV (pScreen, pScreenPriv);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Bool
|
||||
xeglCloseScreen (int index,
|
||||
ScreenPtr pScreen)
|
||||
{
|
||||
glitz_drawable_t *drawable;
|
||||
|
||||
XEGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
drawable = XGL_GET_SCREEN_PRIV (pScreen)->drawable;
|
||||
if (drawable)
|
||||
glitz_drawable_destroy (drawable);
|
||||
|
||||
xglClearVisualTypes ();
|
||||
|
||||
XGL_SCREEN_UNWRAP (CloseScreen);
|
||||
xfree (pScreenPriv);
|
||||
|
||||
return (*pScreen->CloseScreen) (index, pScreen);
|
||||
}
|
||||
|
||||
static Bool
|
||||
xeglScreenInit (int index,
|
||||
ScreenPtr pScreen,
|
||||
int argc,
|
||||
char **argv)
|
||||
{
|
||||
EGLSurface eSurface;
|
||||
EGLModeMESA mode;
|
||||
int count;
|
||||
xeglScreenPtr pScreenPriv;
|
||||
glitz_drawable_format_t *format;
|
||||
glitz_drawable_t *drawable;
|
||||
EGLint screenAttribs[] = {
|
||||
EGL_WIDTH, 1024,
|
||||
EGL_HEIGHT, 768,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
if (xglScreenInfo.width == 0 || xglScreenInfo.height == 0)
|
||||
{
|
||||
xglScreenInfo.width = XEGL_DEFAULT_SCREEN_WIDTH;
|
||||
xglScreenInfo.height = XEGL_DEFAULT_SCREEN_HEIGHT;
|
||||
|
||||
}
|
||||
|
||||
screenAttribs[1] = xglScreenInfo.width;
|
||||
screenAttribs[3] = xglScreenInfo.height;
|
||||
|
||||
format = xglVisuals[0].format;
|
||||
|
||||
if (!xeglAllocatePrivates (pScreen))
|
||||
return FALSE;
|
||||
|
||||
currentScreen = pScreen;
|
||||
|
||||
pScreenPriv = XEGL_GET_SCREEN_PRIV (pScreen);
|
||||
|
||||
if (xglScreenInfo.width == 0 || xglScreenInfo.height == 0)
|
||||
{
|
||||
xglScreenInfo.width = XEGL_DEFAULT_SCREEN_WIDTH;
|
||||
xglScreenInfo.height = XEGL_DEFAULT_SCREEN_HEIGHT;
|
||||
}
|
||||
|
||||
eglGetModesMESA (eDisplay, eScreen, &mode, 1, &count);
|
||||
|
||||
eSurface = eglCreateScreenSurfaceMESA (eDisplay, format->id, screenAttribs);
|
||||
if (eSurface == EGL_NO_SURFACE)
|
||||
{
|
||||
ErrorF ("failed to create screen surface\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
eglShowScreenSurfaceMESA (eDisplay, eScreen, eSurface, mode);
|
||||
|
||||
drawable = glitz_egl_create_surface (eDisplay, eScreen, format, eSurface,
|
||||
xglScreenInfo.width,
|
||||
xglScreenInfo.height);
|
||||
if (!drawable)
|
||||
{
|
||||
ErrorF ("[%d] couldn't create glitz drawable for window\n", index);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
xglScreenInfo.drawable = drawable;
|
||||
|
||||
if (!xglScreenInit (pScreen))
|
||||
return FALSE;
|
||||
|
||||
#ifdef GLXEXT
|
||||
if (!xglInitVisualConfigs (pScreen))
|
||||
return FALSE;
|
||||
#endif
|
||||
|
||||
XGL_SCREEN_WRAP (CloseScreen, xeglCloseScreen);
|
||||
|
||||
miDCInitialize (pScreen, &kdPointerScreenFuncs);
|
||||
miCreateDefColormap(pScreen);
|
||||
|
||||
if (!xglFinishScreenInit (pScreen))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
xeglInitOutput (ScreenInfo *pScreenInfo,
|
||||
int argc,
|
||||
char **argv)
|
||||
{
|
||||
glitz_drawable_format_t *format, templ;
|
||||
int i, maj, min, count;
|
||||
unsigned long mask;
|
||||
|
||||
xglSetPixmapFormats (pScreenInfo);
|
||||
|
||||
if (!eDisplay)
|
||||
{
|
||||
eDisplay = eglGetDisplay (":0");
|
||||
|
||||
if (!eglInitialize (eDisplay, &maj, &min))
|
||||
FatalError ("can't open display");
|
||||
|
||||
eglGetScreensMESA (eDisplay, &eScreen, 1, &count);
|
||||
}
|
||||
|
||||
templ.samples = 1;
|
||||
templ.doublebuffer = 1;
|
||||
templ.color.alpha_size = 8;
|
||||
|
||||
mask = GLITZ_FORMAT_SAMPLES_MASK;
|
||||
|
||||
format = glitz_egl_find_window_config (eDisplay, eScreen,
|
||||
mask, &templ, 0);
|
||||
|
||||
if (!format)
|
||||
FatalError ("no visual format found");
|
||||
|
||||
xglSetVisualTypesAndMasks (pScreenInfo, format, (1 << TrueColor));
|
||||
|
||||
xglInitVisuals (pScreenInfo);
|
||||
|
||||
AddScreen (xeglScreenInit, argc, argv);
|
||||
}
|
||||
|
||||
static void
|
||||
xeglBlockHandler (pointer blockData,
|
||||
OSTimePtr pTimeout,
|
||||
pointer pReadMask)
|
||||
{
|
||||
XGL_SCREEN_PRIV (currentScreen);
|
||||
|
||||
if (!xglSyncSurface (&pScreenPriv->pScreenPixmap->drawable))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
|
||||
glitz_surface_flush (pScreenPriv->surface);
|
||||
glitz_drawable_finish (pScreenPriv->drawable);
|
||||
}
|
||||
|
||||
void
|
||||
xeglInitInput (int argc,
|
||||
char **argv)
|
||||
{
|
||||
eglInitInput (&LinuxEvdevMouseFuncs, &LinuxEvdevKeyboardFuncs);
|
||||
RegisterBlockAndWakeupHandlers (xeglBlockHandler, KdWakeupHandler, NULL);
|
||||
}
|
||||
|
||||
Bool
|
||||
xeglLegalModifier (unsigned int key,
|
||||
DeviceIntPtr pDev)
|
||||
{
|
||||
return KdLegalModifier (key, pDev);
|
||||
}
|
||||
|
||||
void
|
||||
xeglProcessInputEvents (void)
|
||||
{
|
||||
KdProcessInputEvents ();
|
||||
}
|
||||
|
||||
void
|
||||
xeglUseMsg (void)
|
||||
{
|
||||
ErrorF ("-screen WIDTH[/WIDTHMM]xHEIGHT[/HEIGHTMM] "
|
||||
"specify screen characteristics\n");
|
||||
ErrorF ("-softcursor force software cursor\n");
|
||||
}
|
||||
|
||||
int
|
||||
xeglProcessArgument (int argc,
|
||||
char **argv,
|
||||
int i)
|
||||
{
|
||||
if (!strcmp (argv[i], "-screen"))
|
||||
{
|
||||
if ((i + 1) < argc)
|
||||
{
|
||||
xglParseScreen (argv[i + 1]);
|
||||
}
|
||||
else
|
||||
return 1;
|
||||
|
||||
return 2;
|
||||
}
|
||||
else if (!strcmp (argv[i], "-softcursor"))
|
||||
{
|
||||
softCursor = TRUE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
xeglAbort (void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
xeglGiveUp (void)
|
||||
{
|
||||
AbortDDX ();
|
||||
}
|
||||
|
||||
void
|
||||
xeglOsVendorInit (void)
|
||||
{
|
||||
}
|
|
@ -1,214 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2005 Novell, Inc.
|
||||
*
|
||||
* 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
|
||||
* Novell, Inc. not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* Novell, Inc. makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL NOVELL, INC. 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#ifndef _XEGL_H_
|
||||
#define _XEGL_H_
|
||||
|
||||
#include "xgl.h"
|
||||
|
||||
#include "randrstr.h"
|
||||
|
||||
#define KD_BUTTON_1 0x01
|
||||
#define KD_BUTTON_2 0x02
|
||||
#define KD_BUTTON_3 0x04
|
||||
#define KD_BUTTON_4 0x08
|
||||
#define KD_BUTTON_5 0x10
|
||||
#define KD_MOUSE_DELTA 0x80000000
|
||||
|
||||
typedef struct _KdMouseFuncs {
|
||||
Bool (*Init) (void);
|
||||
void (*Fini) (void);
|
||||
} KdMouseFuncs;
|
||||
|
||||
typedef struct _KdKeyboardFuncs {
|
||||
void (*Load) (void);
|
||||
int (*Init) (void);
|
||||
void (*Leds) (int);
|
||||
void (*Bell) (int, int, int);
|
||||
void (*Fini) (void);
|
||||
int LockLed;
|
||||
} KdKeyboardFuncs;
|
||||
|
||||
typedef struct _KdOsFuncs {
|
||||
int (*Init) (void);
|
||||
void (*Enable) (void);
|
||||
Bool (*SpecialKey) (KeySym);
|
||||
void (*Disable) (void);
|
||||
void (*Fini) (void);
|
||||
void (*pollEvents) (void);
|
||||
} KdOsFuncs;
|
||||
|
||||
typedef struct _KdMouseMatrix {
|
||||
int matrix[2][3];
|
||||
} KdMouseMatrix;
|
||||
|
||||
typedef enum _KdMouseState {
|
||||
start,
|
||||
button_1_pend,
|
||||
button_1_down,
|
||||
button_2_down,
|
||||
button_3_pend,
|
||||
button_3_down,
|
||||
synth_2_down_13,
|
||||
synth_2_down_3,
|
||||
synth_2_down_1,
|
||||
num_input_states
|
||||
} KdMouseState;
|
||||
|
||||
#define KD_MAX_BUTTON 7
|
||||
|
||||
typedef struct _KdMouseInfo {
|
||||
struct _KdMouseInfo *next;
|
||||
void *driver;
|
||||
void *closure;
|
||||
char *name;
|
||||
char *prot;
|
||||
char map[KD_MAX_BUTTON];
|
||||
int nbutton;
|
||||
Bool emulateMiddleButton;
|
||||
unsigned long emulationTimeout;
|
||||
Bool timeoutPending;
|
||||
KdMouseState mouseState;
|
||||
Bool eventHeld;
|
||||
xEvent heldEvent;
|
||||
unsigned char buttonState;
|
||||
int emulationDx, emulationDy;
|
||||
int inputType;
|
||||
Bool transformCoordinates;
|
||||
} KdMouseInfo;
|
||||
|
||||
typedef struct _xeglScreen {
|
||||
CloseScreenProcPtr CloseScreen;
|
||||
ScreenPtr pScreen;
|
||||
DDXPointRec origin;
|
||||
} xeglScreenRec, *xeglScreenPtr;
|
||||
|
||||
extern KdMouseInfo *kdMouseInfo;
|
||||
extern KdOsFuncs *kdOsFuncs;
|
||||
extern Bool kdDontZap;
|
||||
extern Bool kdDisableZaphod;
|
||||
extern DevPrivateKey xeglScreenPrivateKey;
|
||||
extern KdMouseFuncs LinuxEvdevMouseFuncs;
|
||||
extern KdKeyboardFuncs LinuxEvdevKeyboardFuncs;
|
||||
|
||||
#define RR_Rotate_All \
|
||||
(RR_Rotate_0 | RR_Rotate_90 | RR_Rotate_180 | RR_Rotate_270)
|
||||
#define RR_Reflect_All (RR_Reflect_X | RR_Reflect_Y)
|
||||
|
||||
#define KdGetScreenPriv(pScreen) ((xeglScreenPtr) \
|
||||
dixLookupPrivate(&(pScreen)->devPrivates, xeglScreenPrivateKey))
|
||||
#define KdScreenPriv(pScreen) \
|
||||
xeglScreenPtr pScreenPriv = KdGetScreenPriv (pScreen)
|
||||
|
||||
void
|
||||
eglInitInput (KdMouseFuncs *pMouseFuncs,
|
||||
KdKeyboardFuncs *pKeyboardFuncs);
|
||||
|
||||
void
|
||||
KdParseMouse (char *arg);
|
||||
|
||||
KdMouseInfo *
|
||||
KdMouseInfoAdd (void);
|
||||
|
||||
void
|
||||
KdMouseInfoDispose (KdMouseInfo *mi);
|
||||
|
||||
int
|
||||
KdAllocInputType (void);
|
||||
|
||||
char *
|
||||
KdSaveString (char *str);
|
||||
|
||||
Bool
|
||||
KdRegisterFd (int type,
|
||||
int fd,
|
||||
void (*read) (int fd, void *closure),
|
||||
void *closure);
|
||||
|
||||
void
|
||||
KdUnregisterFds (int type,
|
||||
Bool do_close);
|
||||
|
||||
void
|
||||
KdEnqueueKeyboardEvent (unsigned char scan_code,
|
||||
unsigned char is_up);
|
||||
|
||||
void
|
||||
KdEnqueueMouseEvent (KdMouseInfo *mi,
|
||||
unsigned long flags,
|
||||
int rx,
|
||||
int ry);
|
||||
|
||||
void
|
||||
KdRegisterFdEnableDisable (int fd,
|
||||
int (*enable) (int fd, void *closure),
|
||||
void (*disable) (int fd, void *closure));
|
||||
|
||||
void
|
||||
KdWakeupHandler (pointer data,
|
||||
int result,
|
||||
pointer readmask);
|
||||
|
||||
Bool
|
||||
KdLegalModifier (unsigned int key,
|
||||
DeviceIntPtr pDev);
|
||||
|
||||
void
|
||||
KdProcessInputEvents (void);
|
||||
|
||||
void
|
||||
xeglInitOutput (ScreenInfo *pScreenInfo,
|
||||
int argc,
|
||||
char **argv);
|
||||
|
||||
Bool
|
||||
xeglLegalModifier (unsigned int key,
|
||||
DevicePtr pDev);
|
||||
|
||||
void
|
||||
xeglProcessInputEvents (void);
|
||||
|
||||
void
|
||||
xeglInitInput (int argc,
|
||||
char **argv);
|
||||
|
||||
void
|
||||
xeglUseMsg (void);
|
||||
|
||||
int
|
||||
xeglProcessArgument (int argc,
|
||||
char **argv,
|
||||
int i);
|
||||
|
||||
void
|
||||
xeglAbort (void);
|
||||
|
||||
void
|
||||
xeglGiveUp (void);
|
||||
|
||||
void
|
||||
xeglOsVendorInit (void);
|
||||
|
||||
#endif /* _XEGL_H_ */
|
|
@ -1,131 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* 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
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include "xegl.h"
|
||||
|
||||
static xglScreenInfoRec xglScreenInfo = {
|
||||
NULL, 0, 0, 0, 0,
|
||||
DEFAULT_GEOMETRY_DATA_TYPE,
|
||||
DEFAULT_GEOMETRY_USAGE,
|
||||
FALSE,
|
||||
XGL_DEFAULT_PBO_MASK,
|
||||
FALSE,
|
||||
FALSE
|
||||
};
|
||||
|
||||
#ifdef GLXEXT
|
||||
static Bool loadGlx = TRUE;
|
||||
#endif
|
||||
|
||||
void
|
||||
InitOutput (ScreenInfo *pScreenInfo,
|
||||
int argc,
|
||||
char **argv)
|
||||
{
|
||||
|
||||
#ifdef GLXEXT
|
||||
if (loadGlx)
|
||||
{
|
||||
if (!xglLoadGLXModules ())
|
||||
FatalError ("No GLX modules loaded");
|
||||
}
|
||||
#endif
|
||||
|
||||
xeglInitOutput (pScreenInfo, argc, argv);
|
||||
}
|
||||
|
||||
Bool
|
||||
LegalModifier (unsigned int key,
|
||||
DeviceIntPtr pDev)
|
||||
{
|
||||
return xeglLegalModifier (key, pDev);
|
||||
}
|
||||
|
||||
void
|
||||
ProcessInputEvents (void)
|
||||
{
|
||||
xeglProcessInputEvents ();
|
||||
}
|
||||
|
||||
void
|
||||
InitInput (int argc,
|
||||
char **argv)
|
||||
{
|
||||
xeglInitInput (argc, argv);
|
||||
}
|
||||
|
||||
void
|
||||
ddxUseMsg (void)
|
||||
{
|
||||
ErrorF ("\nXgl usage:\n");
|
||||
|
||||
#ifdef GLXEXT
|
||||
ErrorF ("-noglx don't load glx extension\n");
|
||||
#endif
|
||||
|
||||
xglUseMsg ();
|
||||
ErrorF ("\nXegl usage:\n");
|
||||
xeglUseMsg ();
|
||||
}
|
||||
|
||||
int
|
||||
ddxProcessArgument (int argc,
|
||||
char **argv,
|
||||
int i)
|
||||
{
|
||||
int skip;
|
||||
|
||||
#ifdef GLXEXT
|
||||
if (!strcmp (argv[i], "-noglx"))
|
||||
{
|
||||
loadGlx = FALSE;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
skip = xglProcessArgument (argc, argv, i);
|
||||
if (skip)
|
||||
return skip;
|
||||
|
||||
return xeglProcessArgument (argc, argv, i);
|
||||
}
|
||||
|
||||
void
|
||||
AbortDDX (void)
|
||||
{
|
||||
xeglAbort ();
|
||||
}
|
||||
|
||||
void
|
||||
ddxGiveUp (void)
|
||||
{
|
||||
xeglGiveUp ();
|
||||
}
|
||||
|
||||
void
|
||||
OsVendorInit (void)
|
||||
{
|
||||
xeglOsVendorInit ();
|
||||
}
|
|
@ -1,168 +0,0 @@
|
|||
#include "xgl.h"
|
||||
#include "xegl.h"
|
||||
|
||||
KdOsFuncs *kdOsFuncs;
|
||||
Bool kdEmulateMiddleButton;
|
||||
Bool kdRawPointerCoordinates;
|
||||
Bool kdDontZap;
|
||||
Bool kdDisableZaphod;
|
||||
int kdScreenPrivateIndex;
|
||||
|
||||
static char *
|
||||
KdParseFindNext (char *cur, char *delim, char *save, char *last)
|
||||
{
|
||||
while (*cur && !strchr (delim, *cur))
|
||||
{
|
||||
*save++ = *cur++;
|
||||
}
|
||||
*save = 0;
|
||||
*last = *cur;
|
||||
if (*cur)
|
||||
cur++;
|
||||
return cur;
|
||||
}
|
||||
|
||||
/*
|
||||
* Mouse argument syntax:
|
||||
*
|
||||
* device,protocol,options...
|
||||
*
|
||||
* Options are any of:
|
||||
* 1-5 n button mouse
|
||||
* 2button emulate middle button
|
||||
* {NMO} Reorder buttons
|
||||
*/
|
||||
char *
|
||||
KdSaveString (char *str)
|
||||
{
|
||||
char *n = (char *) xalloc (strlen (str) + 1);
|
||||
|
||||
if (!n)
|
||||
return 0;
|
||||
strcpy (n, str);
|
||||
return n;
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse mouse information. Syntax:
|
||||
*
|
||||
* <device>,<nbutton>,<protocol>{,<option>}...
|
||||
*
|
||||
* options: {nmo} pointer mapping (e.g. {321})
|
||||
* 2button emulate middle button
|
||||
* 3button dont emulate middle button
|
||||
*/
|
||||
void
|
||||
KdParseMouse (char *arg)
|
||||
{
|
||||
char save[1024];
|
||||
char delim;
|
||||
KdMouseInfo *mi;
|
||||
int i;
|
||||
|
||||
mi = KdMouseInfoAdd ();
|
||||
if (!mi)
|
||||
return;
|
||||
mi->name = 0;
|
||||
mi->prot = 0;
|
||||
mi->emulateMiddleButton = kdEmulateMiddleButton;
|
||||
mi->transformCoordinates = !kdRawPointerCoordinates;
|
||||
mi->nbutton = 3;
|
||||
for (i = 0; i < KD_MAX_BUTTON; i++)
|
||||
mi->map[i] = i + 1;
|
||||
|
||||
if (!arg)
|
||||
return;
|
||||
if (strlen (arg) >= sizeof (save))
|
||||
return;
|
||||
arg = KdParseFindNext (arg, ",", save, &delim);
|
||||
if (!save[0])
|
||||
return;
|
||||
mi->name = KdSaveString (save);
|
||||
if (delim != ',')
|
||||
return;
|
||||
|
||||
arg = KdParseFindNext (arg, ",", save, &delim);
|
||||
if (!save[0])
|
||||
return;
|
||||
|
||||
if ('1' <= save[0] && save[0] <= '0' + KD_MAX_BUTTON && save[1] == '\0')
|
||||
{
|
||||
mi->nbutton = save[0] - '0';
|
||||
if (mi->nbutton > KD_MAX_BUTTON)
|
||||
{
|
||||
UseMsg ();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!delim != ',')
|
||||
return;
|
||||
|
||||
arg = KdParseFindNext (arg, ",", save, &delim);
|
||||
|
||||
if (save[0])
|
||||
mi->prot = KdSaveString (save);
|
||||
|
||||
while (delim == ',')
|
||||
{
|
||||
arg = KdParseFindNext (arg, ",", save, &delim);
|
||||
if (save[0] == '{')
|
||||
{
|
||||
char *s = save + 1;
|
||||
i = 0;
|
||||
while (*s && *s != '}')
|
||||
{
|
||||
if ('1' <= *s && *s <= '0' + mi->nbutton)
|
||||
mi->map[i] = *s - '0';
|
||||
else
|
||||
UseMsg ();
|
||||
s++;
|
||||
}
|
||||
}
|
||||
else if (!strcmp (save, "2button"))
|
||||
mi->emulateMiddleButton = TRUE;
|
||||
else if (!strcmp (save, "3button"))
|
||||
mi->emulateMiddleButton = FALSE;
|
||||
else if (!strcmp (save, "rawcoord"))
|
||||
mi->transformCoordinates = FALSE;
|
||||
else if (!strcmp (save, "transform"))
|
||||
mi->transformCoordinates = TRUE;
|
||||
else
|
||||
UseMsg ();
|
||||
}
|
||||
}
|
||||
|
||||
KdMouseInfo *kdMouseInfo;
|
||||
|
||||
KdMouseInfo *
|
||||
KdMouseInfoAdd (void)
|
||||
{
|
||||
KdMouseInfo *mi, **prev;
|
||||
|
||||
mi = (KdMouseInfo *) xalloc (sizeof (KdMouseInfo));
|
||||
if (!mi)
|
||||
return 0;
|
||||
bzero (mi, sizeof (KdMouseInfo));
|
||||
for (prev = &kdMouseInfo; *prev; prev = &(*prev)->next);
|
||||
*prev = mi;
|
||||
return mi;
|
||||
}
|
||||
|
||||
void
|
||||
KdMouseInfoDispose (KdMouseInfo *mi)
|
||||
{
|
||||
KdMouseInfo **prev;
|
||||
|
||||
for (prev = &kdMouseInfo; *prev; prev = &(*prev)->next)
|
||||
if (*prev == mi)
|
||||
{
|
||||
*prev = mi->next;
|
||||
if (mi->name)
|
||||
xfree (mi->name);
|
||||
if (mi->prot)
|
||||
xfree (mi->prot);
|
||||
xfree (mi);
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
if XGL
|
||||
XGL_MODULE_DIRS = module
|
||||
endif
|
||||
|
||||
DIST_SUBDIRS = module
|
||||
|
||||
SUBDIRS = \
|
||||
. \
|
||||
$(XGL_MODULE_DIRS)
|
||||
|
||||
AM_CFLAGS = \
|
||||
-I$(srcdir)/.. \
|
||||
-I$(srcdir)/../glxext \
|
||||
-I$(top_srcdir)/glx \
|
||||
-I$(top_srcdir)/GL/include \
|
||||
-I@MESA_SOURCE@/include \
|
||||
-I@MESA_SOURCE@/src/mesa/glapi \
|
||||
$(DIX_CFLAGS) \
|
||||
-DHAVE_XGL_CONFIG_H \
|
||||
-DHAVE_DIX_CONFIG_H \
|
||||
$(XGLXMODULES_CFLAGS)
|
||||
|
||||
noinst_LTLIBRARIES = libxglx.la
|
||||
|
||||
libxglx_la_SOURCES = \
|
||||
xglx.h \
|
||||
xglx.c \
|
||||
xglxorg.c
|
||||
|
||||
# Xglx_DEPENDENCIES = @XGLX_LIBS@
|
||||
# Xglx_LDFLAGS = -export-dynamic
|
||||
# Xglx_SOURCES = \
|
||||
# xglxinit.c \
|
||||
# $(top_srcdir)/mi/miinitext.c \
|
||||
# $(top_srcdir)/Xext/dpmsstubs.c \
|
||||
# $(top_srcdir)/Xi/stubs.c \
|
||||
# $(top_srcdir)/fb/fbcmap.c
|
||||
#Xglx_LDADD = \
|
||||
# libxglx.la \
|
||||
# ../libxgl.a \
|
||||
# $(XORG_CORE_LIBS) \
|
||||
# $(XGLX_LIBS) \
|
||||
# $(EXTENSION_LIBS) \
|
||||
# $(XGLXMODULES_LIBS) \
|
||||
# -lXrandr
|
||||
#Xglx_programs = Xglx
|
||||
#
|
||||
#bin_PROGRAMS = $(Xglx_programs)
|
|
@ -1,21 +0,0 @@
|
|||
if GLX
|
||||
GLX_LIB = $(top_builddir)/hw/xgl/glxext/libxglglxext.la
|
||||
endif
|
||||
|
||||
AM_CFLAGS = $(DIX_CFLAGS) \
|
||||
-I$(srcdir)/.. \
|
||||
-I$(srcdir)/../.. \
|
||||
$(XGLXMODULES_CFLAGS)
|
||||
|
||||
libxglx_la_DEPENDENCIES = $(GLX_LIB)
|
||||
libxglx_la_LDFLAGS = -avoid-version
|
||||
libxglx_la_SOURCES = xglxmodule.c
|
||||
libxglx_la_LIBADD = \
|
||||
$(top_builddir)/hw/xgl/glx/libxglx.la \
|
||||
$(GLX_LIB) \
|
||||
$(XGLXMODULES_LIBS) \
|
||||
-lXrandr
|
||||
|
||||
moduledir = @xglmoduledir@
|
||||
|
||||
module_LTLIBRARIES = libxglx.la
|
|
@ -1,104 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2005 Novell, Inc.
|
||||
*
|
||||
* 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
|
||||
* Novell, Inc. not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* Novell, Inc. makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL NOVELL, INC. 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include "xglx.h"
|
||||
#include "xglmodule.h"
|
||||
|
||||
#include <glitz-glx.h>
|
||||
|
||||
char *
|
||||
moduleVersion (void)
|
||||
{
|
||||
return VERSION;
|
||||
}
|
||||
|
||||
Bool
|
||||
moduleInit (const char *module)
|
||||
{
|
||||
glitz_glx_init (module);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
InitOutput (ScreenInfo *pScreenInfo,
|
||||
int argc,
|
||||
char **argv)
|
||||
{
|
||||
xglxInitOutput (pScreenInfo, argc, argv);
|
||||
}
|
||||
|
||||
Bool
|
||||
LegalModifier (unsigned int key,
|
||||
DeviceIntPtr pDev)
|
||||
{
|
||||
return xglxLegalModifier (key, pDev);
|
||||
}
|
||||
|
||||
void
|
||||
ProcessInputEvents (void)
|
||||
{
|
||||
xglxProcessInputEvents ();
|
||||
}
|
||||
|
||||
void
|
||||
InitInput (int argc,
|
||||
char **argv)
|
||||
{
|
||||
xglxInitInput (argc, argv);
|
||||
}
|
||||
|
||||
void
|
||||
ddxUseMsg (void)
|
||||
{
|
||||
ErrorF ("\nXglx usage:\n");
|
||||
xglxUseMsg ();
|
||||
}
|
||||
|
||||
int
|
||||
ddxProcessArgument (int argc,
|
||||
char **argv,
|
||||
int i)
|
||||
{
|
||||
return xglxProcessArgument (argc, argv, i);
|
||||
}
|
||||
|
||||
void
|
||||
AbortDDX (void)
|
||||
{
|
||||
xglxAbort ();
|
||||
}
|
||||
|
||||
void
|
||||
ddxGiveUp (void)
|
||||
{
|
||||
xglxGiveUp ();
|
||||
}
|
||||
|
||||
void
|
||||
OsVendorInit (void)
|
||||
{
|
||||
xglxOsVendorInit ();
|
||||
}
|
1444
hw/xgl/glx/xglx.c
1444
hw/xgl/glx/xglx.c
File diff suppressed because it is too large
Load Diff
|
@ -1,138 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2005 Novell, Inc.
|
||||
*
|
||||
* 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
|
||||
* Novell, Inc. not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* Novell, Inc. makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL NOVELL, INC. 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#ifndef _XGLX_H_
|
||||
#define _XGLX_H_
|
||||
|
||||
#include "xgl.h"
|
||||
|
||||
#ifdef _XSERVER64
|
||||
#define _XSERVER64_tmp
|
||||
#undef _XSERVER64
|
||||
typedef unsigned long XID64;
|
||||
typedef unsigned long Mask64;
|
||||
typedef unsigned long Atom64;
|
||||
typedef unsigned long VisualID64;
|
||||
typedef unsigned long Time64;
|
||||
#define XID XID64
|
||||
#define Mask Mask64
|
||||
#define Atom Atom64
|
||||
#define VisualID VisualID64
|
||||
#define Time Time64
|
||||
typedef XID Window64;
|
||||
typedef XID Drawable64;
|
||||
typedef XID Font64;
|
||||
typedef XID Pixmap64;
|
||||
typedef XID Cursor64;
|
||||
typedef XID Colormap64;
|
||||
typedef XID GContext64;
|
||||
typedef XID KeySym64;
|
||||
#define Window Window64
|
||||
#define Drawable Drawable64
|
||||
#define Font Font64
|
||||
#define Pixmap Pixmap64
|
||||
#define Cursor Cursor64
|
||||
#define Colormap Colormap64
|
||||
#define GContext GContext64
|
||||
#define KeySym KeySym64
|
||||
#endif
|
||||
|
||||
#define GC XlibGC
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#undef GC
|
||||
|
||||
#ifdef _XSERVER64_tmp
|
||||
#ifndef _XSERVER64
|
||||
#define _XSERVER64
|
||||
#endif
|
||||
#undef _XSERVER64_tmp
|
||||
#undef XID
|
||||
#undef Mask
|
||||
#undef Atom
|
||||
#undef VisualID
|
||||
#undef Time
|
||||
#undef Window
|
||||
#undef Drawable
|
||||
#undef Font
|
||||
#undef Pixmap
|
||||
#undef Cursor
|
||||
#undef Colormap
|
||||
#undef GContext
|
||||
#undef KeySym
|
||||
#endif
|
||||
|
||||
void
|
||||
xglxInitOutput (ScreenInfo *pScreenInfo,
|
||||
int argc,
|
||||
char **argv);
|
||||
|
||||
Bool
|
||||
xglxLegalModifier (unsigned int key,
|
||||
DeviceIntPtr pDev);
|
||||
|
||||
void
|
||||
xglxProcessInputEvents (void);
|
||||
|
||||
void
|
||||
xglxInitInput (int argc,
|
||||
char **argv);
|
||||
|
||||
void
|
||||
xglxUseMsg (void);
|
||||
|
||||
int
|
||||
xglxProcessArgument (int argc,
|
||||
char **argv,
|
||||
int i);
|
||||
|
||||
void
|
||||
xglxAbort (void);
|
||||
|
||||
void
|
||||
xglxGiveUp (void);
|
||||
|
||||
void
|
||||
xglxOsVendorInit (void);
|
||||
|
||||
#ifndef NXGLXORG
|
||||
|
||||
void
|
||||
xglxUseXorgMsg (void);
|
||||
|
||||
int
|
||||
xglxProcessXorgArgument (int argc,
|
||||
char **argv,
|
||||
int i);
|
||||
|
||||
void
|
||||
xglxAbortXorg (void);
|
||||
|
||||
char *
|
||||
xglxInitXorg (void);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _XGLX_H_ */
|
|
@ -1,168 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* 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
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include "xglx.h"
|
||||
#include "xglglx.h"
|
||||
|
||||
xglScreenInfoRec xglScreenInfo = {
|
||||
NULL, 0, 0, 0, 0, 0,
|
||||
DEFAULT_GEOMETRY_DATA_TYPE,
|
||||
DEFAULT_GEOMETRY_USAGE,
|
||||
FALSE,
|
||||
XGL_DEFAULT_PBO_MASK,
|
||||
FALSE,
|
||||
{
|
||||
{ FALSE, FALSE, { 0, 0, 0, 0 } },
|
||||
{ FALSE, FALSE, { 0, 0, 0, 0 } },
|
||||
{ FALSE, FALSE, { 0, 0, 0, 0 } },
|
||||
{ FALSE, FALSE, { 0, 0, 0, 0 } }
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef GLXEXT
|
||||
static Bool loadGlx = TRUE;
|
||||
|
||||
#ifndef NGLXEXTLOG
|
||||
static char *glxExtLogFile = 0;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
void
|
||||
InitOutput (ScreenInfo *pScreenInfo,
|
||||
int argc,
|
||||
char **argv)
|
||||
{
|
||||
|
||||
#ifdef GLXEXT
|
||||
if (loadGlx)
|
||||
{
|
||||
if (!xglLoadGLXModules ())
|
||||
FatalError ("No GLX modules loaded");
|
||||
|
||||
#ifndef NGLXEXTLOG
|
||||
if (glxExtLogFile)
|
||||
{
|
||||
__xglGLXLogFp = fopen (glxExtLogFile, "w");
|
||||
if (!__xglGLXLogFp)
|
||||
perror ("InitOutput");
|
||||
}
|
||||
else
|
||||
__xglGLXLogFp = 0;
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
xglxInitOutput (pScreenInfo, argc, argv);
|
||||
}
|
||||
|
||||
Bool
|
||||
LegalModifier (unsigned int key,
|
||||
DeviceIntPtr pDev)
|
||||
{
|
||||
return xglxLegalModifier (key, pDev);
|
||||
}
|
||||
|
||||
void
|
||||
ProcessInputEvents (void)
|
||||
{
|
||||
xglxProcessInputEvents ();
|
||||
}
|
||||
|
||||
void
|
||||
InitInput (int argc,
|
||||
char **argv)
|
||||
{
|
||||
xglxInitInput (argc, argv);
|
||||
}
|
||||
|
||||
void
|
||||
ddxUseMsg (void)
|
||||
{
|
||||
ErrorF ("\nXgl usage:\n");
|
||||
|
||||
#ifdef GLXEXT
|
||||
ErrorF ("-noglx don't load glx extension\n");
|
||||
|
||||
#ifndef NGLXEXTLOG
|
||||
ErrorF ("-glxlog file glx extension log file\n");
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
xglUseMsg ();
|
||||
ErrorF ("\nXglx usage:\n");
|
||||
xglxUseMsg ();
|
||||
}
|
||||
|
||||
int
|
||||
ddxProcessArgument (int argc,
|
||||
char **argv,
|
||||
int i)
|
||||
{
|
||||
int skip;
|
||||
|
||||
#ifdef GLXEXT
|
||||
if (!strcmp (argv[i], "-noglx"))
|
||||
{
|
||||
loadGlx = FALSE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef NGLXEXTLOG
|
||||
else if (!strcmp (argv[i], "-glxlog"))
|
||||
{
|
||||
if (++i < argc)
|
||||
glxExtLogFile = argv[i];
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
skip = xglProcessArgument (argc, argv, i);
|
||||
if (skip)
|
||||
return skip;
|
||||
|
||||
return xglxProcessArgument (argc, argv, i);
|
||||
}
|
||||
|
||||
void
|
||||
AbortDDX (void)
|
||||
{
|
||||
xglxAbort ();
|
||||
}
|
||||
|
||||
void
|
||||
ddxGiveUp (void)
|
||||
{
|
||||
xglxGiveUp ();
|
||||
}
|
||||
|
||||
void
|
||||
OsVendorInit (void)
|
||||
{
|
||||
xglxOsVendorInit ();
|
||||
}
|
|
@ -1,674 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2005 Novell, Inc.
|
||||
*
|
||||
* 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
|
||||
* Novell, Inc. not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* Novell, Inc. makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL NOVELL, INC. 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: David Reveman <davidr@novell.com>
|
||||
* Matthias Hopf <mhopf@suse.de>
|
||||
*/
|
||||
|
||||
#include "xglx.h"
|
||||
|
||||
#ifndef NXGLXORG
|
||||
|
||||
#include <X11/Xauth.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <signal.h>
|
||||
#include <setjmp.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/stat.h>
|
||||
#include <libgen.h>
|
||||
|
||||
typedef void (*sighandler_t) (int);
|
||||
|
||||
#define XORG_DIE_TIMEOUT 3
|
||||
#define XORG_DEV_RANDOM "/dev/urandom"
|
||||
|
||||
static char xorgAuthBuf[256];
|
||||
static char *xorgAuthTempl = "/tmp/.Xgl-auth-XXXXXX";
|
||||
static char *xorgAuth = NULL;
|
||||
|
||||
static char *xorgProgs[] = { "/usr/bin/Xorg", "/usr/X11R6/bin/Xorg" };
|
||||
static char *xorgProg = NULL;
|
||||
|
||||
static char *xorgDisplay = ":93";
|
||||
static char *xorgTerminate = "-terminate";
|
||||
|
||||
static pid_t xorgPid = 0;
|
||||
static int receivedUsr1 = 0;
|
||||
static jmp_buf jumpbuf;
|
||||
|
||||
static Bool waitAndExit = FALSE;
|
||||
|
||||
static char **xorgArgv = 0;
|
||||
static int nXorgArgv = 0;
|
||||
|
||||
typedef struct _xglxArg *xglxArgPtr;
|
||||
|
||||
typedef int (*xglxProcessArgumentProc) (xglxArgPtr, int, char **, int);
|
||||
|
||||
typedef struct _xglxArg {
|
||||
xglxProcessArgumentProc processArgument;
|
||||
const char *name;
|
||||
const char *usage;
|
||||
} xglxArgRec;
|
||||
|
||||
static int
|
||||
xglxAddXorgArguments (char **argv,
|
||||
int n)
|
||||
{
|
||||
char **newArgv;
|
||||
int i;
|
||||
|
||||
newArgv = xrealloc (xorgArgv, sizeof (char *) * (nXorgArgv + n));
|
||||
if (!newArgv)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
newArgv[nXorgArgv + i] = argv[i];
|
||||
|
||||
xorgArgv = newArgv;
|
||||
nXorgArgv += n;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
static int
|
||||
xglxProcessCommonXorgArgument (xglxArgPtr pArg,
|
||||
int n,
|
||||
int argc,
|
||||
char **argv,
|
||||
int i)
|
||||
{
|
||||
if (strcmp (argv[i], pArg->name) == 0)
|
||||
{
|
||||
if (i + n - 1 < argc)
|
||||
return xglxAddXorgArguments (&argv[i], n);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define PROCESS_COMMON_XORG_ARGUMENT_IMP(args) \
|
||||
static int \
|
||||
xglxProcess ## args ## CommonXorgArgument (xglxArgPtr pArg, \
|
||||
int argc, \
|
||||
char **argv, \
|
||||
int i) \
|
||||
{ \
|
||||
return xglxProcessCommonXorgArgument (pArg, args, argc, argv, i); \
|
||||
}
|
||||
|
||||
PROCESS_COMMON_XORG_ARGUMENT_IMP (1)
|
||||
PROCESS_COMMON_XORG_ARGUMENT_IMP (2)
|
||||
|
||||
static int
|
||||
xglxProcessXorgVTArgument (xglxArgPtr pArg,
|
||||
int argc,
|
||||
char **argv,
|
||||
int i)
|
||||
{
|
||||
if (argv[i][0] == 'v' && argv[i][1] == 't' &&
|
||||
strspn (&argv[i][2], "0123456789") == strlen (&argv[i][2]))
|
||||
return xglxAddXorgArguments (&argv[i], 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
xglxProcessXorgAcArgument (xglxArgPtr pArg,
|
||||
int argc,
|
||||
char **argv,
|
||||
int i)
|
||||
{
|
||||
static char *ac = "-ac";
|
||||
|
||||
if (strcmp (argv[i], pArg->name) == 0)
|
||||
{
|
||||
if (xglxAddXorgArguments (&ac, 1))
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
xglxProcessXorgVersionArgument (xglxArgPtr pArg,
|
||||
int argc,
|
||||
char **argv,
|
||||
int i)
|
||||
{
|
||||
static char *version = "-version";
|
||||
|
||||
if (strcmp (argv[i], pArg->name) == 0)
|
||||
{
|
||||
if (xglxAddXorgArguments (&version, 1))
|
||||
{
|
||||
waitAndExit = TRUE;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
xglxProcessXorgProgArgument (xglxArgPtr pArg,
|
||||
int argc,
|
||||
char **argv,
|
||||
int i)
|
||||
{
|
||||
if (strcmp (argv[i], pArg->name) == 0)
|
||||
{
|
||||
if (i + 1 < argc)
|
||||
{
|
||||
xorgProg = argv[i + 1];
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
xglxProcessXorgDisplayArgument (xglxArgPtr pArg,
|
||||
int argc,
|
||||
char **argv,
|
||||
int i)
|
||||
{
|
||||
if (strcmp (argv[i], pArg->name) == 0)
|
||||
{
|
||||
if (i + 1 < argc)
|
||||
{
|
||||
xorgDisplay = argv[i + 1];
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
xglxProcessXorgWaitExitArgument (xglxArgPtr pArg,
|
||||
int argc,
|
||||
char **argv,
|
||||
int i)
|
||||
{
|
||||
if (xglxProcessCommonXorgArgument (pArg, 1, argc, argv, i))
|
||||
{
|
||||
waitAndExit = TRUE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define ARG(processArgument, name, usage) \
|
||||
{ processArgument, name, usage }
|
||||
|
||||
#define XORG_ARG(name, args) \
|
||||
ARG (xglxProcess ## args ## CommonXorgArgument, name, 0)
|
||||
|
||||
#define XORG_UARG(name, usage, args) \
|
||||
ARG (xglxProcess ## args ## CommonXorgArgument, name, usage)
|
||||
|
||||
xglxArgRec xorgUid0Args[] = {
|
||||
XORG_UARG ("-modulepath", " paths specify the module search path", 2),
|
||||
XORG_UARG ("-logfile", " file specify a log file name", 2),
|
||||
ARG (xglxProcessXorgWaitExitArgument, "-configure",
|
||||
" probe for devices and write an Xorg config")
|
||||
};
|
||||
|
||||
xglxArgRec xorgUidArgs[] = {
|
||||
XORG_UARG ("-config",
|
||||
" file specify configuration file, relative to the\n"
|
||||
" Xorg config search path, "
|
||||
"only root can use absolute", 2)
|
||||
};
|
||||
|
||||
xglxArgRec xorgArgs[] = {
|
||||
ARG (xglxProcessXorgWaitExitArgument, "-probeonly",
|
||||
" probe for devices, then exit"),
|
||||
XORG_UARG ("-verbose", " [n] verbose startup messages", 2),
|
||||
XORG_UARG ("-logverbose", " [n] verbose log messages", 2),
|
||||
XORG_UARG ("-quiet", " minimal startup messages", 1),
|
||||
XORG_UARG ("-depth", " n set colour depth. Default: 8", 2),
|
||||
XORG_UARG ("-gamma",
|
||||
" f set gamma value (0.1 < f < 10.0) "
|
||||
"Default: 1.0", 2),
|
||||
XORG_UARG ("-rgamma", " f set gamma value for red phase", 2),
|
||||
XORG_UARG ("-ggamma", " f set gamma value for green phase",
|
||||
2),
|
||||
XORG_UARG ("-bgamma", " f set gamma value for blue phase", 2),
|
||||
XORG_UARG ("-layout",
|
||||
" name specify the ServerLayout section name", 2),
|
||||
XORG_UARG ("-screen",
|
||||
" name specify the Screen section name", 2),
|
||||
XORG_UARG ("-keyboard",
|
||||
" name specify the core keyboard InputDevice name", 2),
|
||||
XORG_UARG ("-pointer",
|
||||
" name specify the core pointer InputDevice name", 2),
|
||||
XORG_UARG ("-nosilk", " disable Silken Mouse", 1),
|
||||
XORG_UARG ("-disableModInDev",
|
||||
" disable dynamic modification of input device settings",
|
||||
1),
|
||||
XORG_UARG ("-allowMouseOpenFail",
|
||||
" start server even if the mouse can't be initialized", 1),
|
||||
XORG_UARG ("-bestRefresh",
|
||||
" choose modes with the best refresh rate", 1),
|
||||
XORG_UARG ("-ignoreABI",
|
||||
" make module ABI mismatches non-fatal", 1),
|
||||
XORG_UARG ("-isolateDevice",
|
||||
" bus_id restrict device resets to bus_id (PCI only)", 2),
|
||||
ARG (xglxProcessXorgVTArgument, "vtXX",
|
||||
" use the specified VT number"),
|
||||
XORG_UARG ("-keeptty",
|
||||
" don't detach controlling tty "
|
||||
"(for debugging only)", 1),
|
||||
XORG_UARG ("-novtswitch", " don't immediately switch to new VT",
|
||||
1),
|
||||
XORG_UARG ("-sharevts", " share VTs with another X server",
|
||||
1),
|
||||
ARG (xglxProcessXorgAcArgument, "-xorgAc",
|
||||
" disable access control restrictions"),
|
||||
ARG (xglxProcessXorgProgArgument, "-xorgProgram",
|
||||
" server program"),
|
||||
ARG (xglxProcessXorgDisplayArgument, "-xorgDisplay",
|
||||
" server display"),
|
||||
ARG (xglxProcessXorgVersionArgument, "-xorgVersion",
|
||||
" show the server version")
|
||||
};
|
||||
|
||||
xglxArgRec sharedArgs[] = {
|
||||
XORG_ARG ("-br", 1)
|
||||
};
|
||||
|
||||
void
|
||||
xglxUseXorgMsg (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
ErrorF ("\nXorg usage:\n");
|
||||
|
||||
if (getuid () == 0)
|
||||
{
|
||||
for (i = 0; i < sizeof (xorgUid0Args) / sizeof (xglxArgRec); i++)
|
||||
ErrorF ("%s%s\n", xorgUid0Args[i].name, xorgUid0Args[i].usage);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < sizeof (xorgUidArgs) / sizeof (xglxArgRec); i++)
|
||||
ErrorF ("%s%s\n", xorgUidArgs[i].name, xorgUidArgs[i].usage);
|
||||
}
|
||||
|
||||
for (i = 0; i < sizeof (xorgArgs) / sizeof (xglxArgRec); i++)
|
||||
ErrorF ("%s%s\n", xorgArgs[i].name, xorgArgs[i].usage);
|
||||
}
|
||||
|
||||
int
|
||||
xglxProcessXorgArgument (int argc,
|
||||
char **argv,
|
||||
int i)
|
||||
{
|
||||
int skip, j;
|
||||
|
||||
if (nXorgArgv == 0)
|
||||
{
|
||||
if (!xglxAddXorgArguments (&xorgProg, 1))
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (getuid () == 0)
|
||||
{
|
||||
for (j = 0; j < sizeof (xorgUid0Args) / sizeof (xglxArgRec); j++)
|
||||
{
|
||||
skip = (*xorgUid0Args[j].processArgument) (&xorgUid0Args[j],
|
||||
argc, argv, i);
|
||||
if (skip)
|
||||
return skip;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (j = 0; j < sizeof (xorgUidArgs) / sizeof (xglxArgRec); j++)
|
||||
{
|
||||
skip = (*xorgUidArgs[j].processArgument) (&xorgUidArgs[j],
|
||||
argc, argv, i);
|
||||
if (skip)
|
||||
return skip;
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < sizeof (xorgArgs) / sizeof (xorgArgs[0]); j++)
|
||||
{
|
||||
skip = (*xorgArgs[j].processArgument) (&xorgArgs[j], argc, argv, i);
|
||||
if (skip)
|
||||
return skip;
|
||||
}
|
||||
|
||||
for (j = 0; j < sizeof (sharedArgs) / sizeof (sharedArgs[0]); j++)
|
||||
{
|
||||
skip = (*sharedArgs[j].processArgument) (&sharedArgs[j], argc, argv, i);
|
||||
if (skip)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
sigAlarm (int sig)
|
||||
{
|
||||
ErrorF ("%s won't die, killing it\n", basename (xorgProg));
|
||||
|
||||
kill (xorgPid, SIGKILL);
|
||||
if (xorgPid)
|
||||
while (waitpid (xorgPid, NULL, 0) == -1 && errno == EINTR);
|
||||
}
|
||||
|
||||
void
|
||||
xglxAbortXorg (void)
|
||||
{
|
||||
sighandler_t oldSigAlarm;
|
||||
unsigned int oldAlarm;
|
||||
int status = 0;
|
||||
char *name;
|
||||
|
||||
if (!xorgPid)
|
||||
return;
|
||||
|
||||
name = basename (xorgProg);
|
||||
|
||||
oldAlarm = alarm (0);
|
||||
oldSigAlarm = signal (SIGALRM, sigAlarm);
|
||||
|
||||
kill (xorgPid, SIGTERM);
|
||||
|
||||
alarm (XORG_DIE_TIMEOUT);
|
||||
while (waitpid (xorgPid, &status, 0) == -1 && errno == EINTR);
|
||||
alarm (0);
|
||||
|
||||
signal (SIGALRM, oldSigAlarm);
|
||||
alarm (oldAlarm);
|
||||
|
||||
if (WIFEXITED (status))
|
||||
{
|
||||
if (WEXITSTATUS (status))
|
||||
ErrorF ("%s died, exit status %d\n", name, WEXITSTATUS (status));
|
||||
}
|
||||
else if (WIFSIGNALED (status))
|
||||
ErrorF ("%s died, signal %d\n", name, WTERMSIG (status));
|
||||
else
|
||||
ErrorF ("%s died, dubious exit\n", name);
|
||||
|
||||
if (xorgAuth)
|
||||
unlink (xorgAuth);
|
||||
}
|
||||
|
||||
static void
|
||||
sigUsr1Waiting (int sig)
|
||||
{
|
||||
signal (sig, sigUsr1Waiting);
|
||||
receivedUsr1++;
|
||||
}
|
||||
|
||||
static void
|
||||
sigUsr1Jump (int sig)
|
||||
{
|
||||
|
||||
#ifdef HAVE_SIGPROCMASK
|
||||
sigset_t set;
|
||||
#endif
|
||||
|
||||
signal (sig, sigUsr1Waiting);
|
||||
|
||||
#ifdef HAVE_SIGPROCMASK
|
||||
sigemptyset (&set);
|
||||
sigaddset (&set, SIGUSR1);
|
||||
sigprocmask (SIG_UNBLOCK, &set, NULL);
|
||||
#endif
|
||||
|
||||
longjmp (jumpbuf, 1);
|
||||
}
|
||||
|
||||
#define AUTH_DATA_LEN 16 /* bytes of authorization data */
|
||||
|
||||
static Bool
|
||||
xglxSetupAuth (char *name, int authFd)
|
||||
{
|
||||
Xauth auth;
|
||||
int randomFd;
|
||||
ssize_t bytes, size;
|
||||
char authHost[256];
|
||||
char authData[AUTH_DATA_LEN];
|
||||
FILE *file;
|
||||
|
||||
auth.family = FamilyLocal;
|
||||
|
||||
gethostname (authHost, sizeof (authHost));
|
||||
|
||||
auth.address = authHost;
|
||||
auth.address_length = strlen (authHost);
|
||||
|
||||
auth.number = strrchr (xorgDisplay, ':');
|
||||
if (!auth.number)
|
||||
{
|
||||
ErrorF ("Bad Xorg display name: %s\n", xorgDisplay);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
auth.number++;
|
||||
|
||||
auth.number_length = strlen (auth.number);
|
||||
if (!auth.number_length)
|
||||
{
|
||||
ErrorF ("Bad Xorg display name: %s\n", xorgDisplay);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
auth.name = "MIT-MAGIC-COOKIE-1";
|
||||
auth.name_length = strlen (auth.name);
|
||||
|
||||
randomFd = open (XORG_DEV_RANDOM, O_RDONLY);
|
||||
if (randomFd == -1)
|
||||
{
|
||||
ErrorF ("Failed to open " XORG_DEV_RANDOM "\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bytes = 0;
|
||||
do {
|
||||
size = read (randomFd, authData + bytes, AUTH_DATA_LEN - bytes);
|
||||
if (size <= 0)
|
||||
break;
|
||||
|
||||
bytes += size;
|
||||
} while (bytes != AUTH_DATA_LEN);
|
||||
|
||||
close (randomFd);
|
||||
|
||||
if (bytes != AUTH_DATA_LEN)
|
||||
{
|
||||
ErrorF ("Failed to read %d random bytes from " XORG_DEV_RANDOM "\n",
|
||||
AUTH_DATA_LEN);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
auth.data = authData;
|
||||
auth.data_length = AUTH_DATA_LEN;
|
||||
|
||||
file = fdopen (authFd, "w");
|
||||
if (!file)
|
||||
{
|
||||
ErrorF ("Failed to open authorization file: %s\n", name);
|
||||
close (authFd);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
XauWriteAuth (file, &auth);
|
||||
fclose (file);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
char *
|
||||
xglxInitXorg (void)
|
||||
{
|
||||
sighandler_t oldSigUsr1;
|
||||
pid_t pid;
|
||||
char *name;
|
||||
char *auth[] = { "-auth", xorgAuthBuf, "-nolisten", "tcp" };
|
||||
char *saver[] = { "-dpms", "-v", "-s", "0" };
|
||||
char *endArg = NULL;
|
||||
int authFd;
|
||||
int mask;
|
||||
|
||||
if (xorgPid)
|
||||
return xorgDisplay;
|
||||
|
||||
if (!xorgProg)
|
||||
{
|
||||
struct stat buf;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < sizeof (xorgProgs) / sizeof (char *); i++)
|
||||
{
|
||||
if (stat (xorgProgs[i], &buf) == 0)
|
||||
{
|
||||
xorgProg = xorgProgs[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!xorgProg)
|
||||
FatalError ("Can't find Xorg executable\n");
|
||||
}
|
||||
|
||||
strcpy (xorgAuthBuf, xorgAuthTempl);
|
||||
mask = umask (0077);
|
||||
authFd = mkstemp (xorgAuthBuf);
|
||||
umask (mask);
|
||||
if (authFd == -1)
|
||||
FatalError ("Failed to generate unique authorization file\n");
|
||||
|
||||
xorgAuth = xorgAuthBuf;
|
||||
|
||||
if (nXorgArgv == 0)
|
||||
{
|
||||
if (!xglxAddXorgArguments (&xorgProg, 1))
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
xorgArgv[0] = xorgProg;
|
||||
}
|
||||
|
||||
if (!xglxAddXorgArguments (auth, sizeof (auth) / sizeof (char *)))
|
||||
return 0;
|
||||
|
||||
if (!xglxAddXorgArguments (saver, sizeof (saver) / sizeof (char *)))
|
||||
return 0;
|
||||
|
||||
if (!xglxAddXorgArguments (&xorgDisplay, 1))
|
||||
return 0;
|
||||
|
||||
if (!xglxAddXorgArguments (&xorgTerminate, 1))
|
||||
return 0;
|
||||
|
||||
if (!xglxAddXorgArguments (&endArg, 1))
|
||||
return 0;
|
||||
|
||||
name = basename (xorgProg);
|
||||
|
||||
if (!xglxSetupAuth (xorgAuth, authFd))
|
||||
FatalError ("Failed to set up authorization: %s\n", xorgAuth);
|
||||
|
||||
oldSigUsr1 = signal (SIGUSR1, sigUsr1Waiting);
|
||||
|
||||
pid = fork ();
|
||||
|
||||
switch (pid) {
|
||||
case -1:
|
||||
perror ("fork");
|
||||
FatalError ("fork");
|
||||
break;
|
||||
case 0:
|
||||
signal (SIGUSR1, SIG_IGN);
|
||||
execv (xorgArgv[0], xorgArgv);
|
||||
perror (xorgArgv[0]);
|
||||
exit (2);
|
||||
break;
|
||||
default:
|
||||
xorgPid = pid;
|
||||
break;
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
int status;
|
||||
|
||||
signal (SIGUSR1, sigUsr1Waiting);
|
||||
if (setjmp (jumpbuf) && !waitAndExit)
|
||||
break;
|
||||
|
||||
signal (SIGUSR1, sigUsr1Jump);
|
||||
if (receivedUsr1 && !waitAndExit)
|
||||
break;
|
||||
|
||||
if (waitpid (xorgPid, &status, 0) != -1)
|
||||
{
|
||||
if (WIFEXITED (status))
|
||||
{
|
||||
if (waitAndExit)
|
||||
{
|
||||
if (WEXITSTATUS (status))
|
||||
FatalError ("%s died, exit status %d\n", name,
|
||||
WEXITSTATUS (status));
|
||||
|
||||
exit (WEXITSTATUS (status));
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalError ("%s died, exit status %d\n", name,
|
||||
WEXITSTATUS (status));
|
||||
}
|
||||
}
|
||||
else if (WIFSIGNALED (status))
|
||||
FatalError ("%s died, signal %d\n", name, WTERMSIG (status));
|
||||
else
|
||||
FatalError ("%s died, dubious exit\n", name);
|
||||
}
|
||||
}
|
||||
|
||||
signal (SIGUSR1, oldSigUsr1);
|
||||
|
||||
setenv ("XAUTHORITY", xorgAuth, 1);
|
||||
|
||||
return xorgDisplay;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,21 +0,0 @@
|
|||
SUBDIRS = module
|
||||
|
||||
AM_CFLAGS = \
|
||||
$(DIX_CFLAGS) \
|
||||
-DHAVE_XGL_CONFIG_H \
|
||||
-DHAVE_DIX_CONFIG_H \
|
||||
$(XGLMODULES_CFLAGS) \
|
||||
-I$(top_srcdir)/glx \
|
||||
-I$(top_srcdir)/GL/include \
|
||||
-I$(top_srcdir)/hw/xgl \
|
||||
-I@MESA_SOURCE@/include \
|
||||
-I@MESA_SOURCE@/src/mesa/glapi
|
||||
|
||||
libxglglxext_libraries = libxglglxext.la
|
||||
libxglglxext_la_SOURCES = \
|
||||
xglglxext.h \
|
||||
xglglxext.c \
|
||||
xglglxlog.c
|
||||
|
||||
noinst_LTLIBRARIES = $(libxglglxext_libraries)
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
AM_CFLAGS = \
|
||||
$(DIX_CFLAGS) \
|
||||
-DHAVE_XGL_CONFIG_H \
|
||||
-DHAVE_DIX_CONFIG_H \
|
||||
$(XGLMODULES_CFLAGS) \
|
||||
-I$(top_srcdir)/hw/xgl
|
||||
|
||||
libglx_la_LDFLAGS = -avoid-version
|
||||
libglx_la_SOURCES = glxmodule.c
|
||||
libglx_la_LIBADD = $(top_builddir)/glx/libglx.la
|
||||
libglx_modules = libglx.la
|
||||
|
||||
libglcore_la_LDFLAGS = -avoid-version
|
||||
libglcore_la_SOURCES = glcoremodule.c
|
||||
libglcore_la_LIBADD = $(top_builddir)/GL/mesa/libGLcore.la
|
||||
libglcore_modules = libglcore.la
|
||||
|
||||
moduledir = @XGL_MODULE_PATH@
|
||||
|
||||
module_LTLIBRARIES = \
|
||||
$(libglcore_modules) \
|
||||
$(libglx_modules)
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2005 Novell, Inc.
|
||||
*
|
||||
* 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
|
||||
* Novell, Inc. not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* Novell, Inc. makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL NOVELL, INC. 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include "xglmodule.h"
|
||||
|
||||
char *
|
||||
moduleVersion (void)
|
||||
{
|
||||
return VERSION;
|
||||
}
|
||||
|
||||
Bool
|
||||
moduleInit (const char *module)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2005 Novell, Inc.
|
||||
*
|
||||
* 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
|
||||
* Novell, Inc. not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* Novell, Inc. makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL NOVELL, INC. 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include "xglmodule.h"
|
||||
|
||||
char *
|
||||
moduleVersion (void)
|
||||
{
|
||||
return VERSION;
|
||||
}
|
||||
|
||||
Bool
|
||||
moduleInit (const char *module)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,41 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2005 Novell, Inc.
|
||||
*
|
||||
* 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
|
||||
* Novell, Inc. not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* Novell, Inc. makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL NOVELL, INC. 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#ifndef _XGL_GLXEXT_H_
|
||||
#define _XGL_GLXEXT_H_
|
||||
|
||||
#include "scrnintstr.h"
|
||||
|
||||
Bool
|
||||
xglInitVisualConfigs (ScreenPtr pScreen);
|
||||
|
||||
#ifndef NGLXEXTLOG
|
||||
|
||||
void
|
||||
xglInitGlxLog (void);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _XGL_GLXEXT_H_ */
|
File diff suppressed because it is too large
Load Diff
1474
hw/xgl/xgl.h
1474
hw/xgl/xgl.h
File diff suppressed because it is too large
Load Diff
323
hw/xgl/xglarea.c
323
hw/xgl/xglarea.c
|
@ -1,323 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2005 Novell, Inc.
|
||||
*
|
||||
* 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
|
||||
* Novell, Inc. not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* Novell, Inc. makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL NOVELL, INC. 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
|
||||
static Bool
|
||||
xglAreaMoveIn (xglAreaPtr pArea,
|
||||
pointer closure)
|
||||
{
|
||||
pArea->closure = closure;
|
||||
pArea->state = xglAreaOccupied;
|
||||
|
||||
return (*pArea->pRoot->funcs->MoveIn) (pArea, closure);
|
||||
}
|
||||
|
||||
static void
|
||||
xglAreaMoveOut (xglAreaPtr pArea)
|
||||
{
|
||||
(*pArea->pRoot->funcs->MoveOut) (pArea, pArea->closure);
|
||||
|
||||
pArea->closure = (pointer) 0;
|
||||
pArea->state = xglAreaAvailable;
|
||||
}
|
||||
|
||||
static xglAreaPtr
|
||||
xglAreaCreate (xglRootAreaPtr pRoot,
|
||||
int level,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
xglAreaPtr pArea;
|
||||
int n = 4;
|
||||
|
||||
pArea = xalloc (sizeof (xglAreaRec) + pRoot->devPrivateSize);
|
||||
if (!pArea)
|
||||
return NULL;
|
||||
|
||||
pArea->level = level;
|
||||
pArea->x = x;
|
||||
pArea->y = y;
|
||||
pArea->width = width;
|
||||
pArea->height = height;
|
||||
pArea->pRoot = pRoot;
|
||||
pArea->closure = (pointer) 0;
|
||||
pArea->state = xglAreaAvailable;
|
||||
|
||||
while (n--)
|
||||
pArea->pArea[n] = NULL;
|
||||
|
||||
if (pRoot->devPrivateSize)
|
||||
pArea->devPrivate.ptr = pArea + 1;
|
||||
else
|
||||
pArea->devPrivate.ptr = (pointer) 0;
|
||||
|
||||
if (!(*pArea->pRoot->funcs->Create) (pArea))
|
||||
{
|
||||
free (pArea);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return pArea;
|
||||
}
|
||||
|
||||
static void
|
||||
xglAreaDestroy (xglAreaPtr pArea)
|
||||
{
|
||||
if (!pArea)
|
||||
return;
|
||||
|
||||
if (pArea->state == xglAreaOccupied)
|
||||
{
|
||||
xglAreaMoveOut (pArea);
|
||||
}
|
||||
else
|
||||
{
|
||||
int n = 4;
|
||||
|
||||
while (n--)
|
||||
xglAreaDestroy (pArea->pArea[n]);
|
||||
}
|
||||
|
||||
xfree (pArea);
|
||||
}
|
||||
|
||||
static xglAreaPtr
|
||||
xglAreaGetTopScoredSubArea (xglAreaPtr pArea)
|
||||
{
|
||||
if (!pArea)
|
||||
return NULL;
|
||||
|
||||
switch (pArea->state) {
|
||||
case xglAreaOccupied:
|
||||
return pArea;
|
||||
case xglAreaAvailable:
|
||||
break;
|
||||
case xglAreaDivided: {
|
||||
xglAreaPtr tmp, top = NULL;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
tmp = xglAreaGetTopScoredSubArea (pArea->pArea[i]);
|
||||
if (tmp && top)
|
||||
{
|
||||
if ((*pArea->pRoot->funcs->CompareScore) (tmp,
|
||||
tmp->closure,
|
||||
top->closure) > 0)
|
||||
top = tmp;
|
||||
}
|
||||
else if (tmp)
|
||||
{
|
||||
top = tmp;
|
||||
}
|
||||
}
|
||||
return top;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static Bool
|
||||
xglAreaFind (xglAreaPtr pArea,
|
||||
int width,
|
||||
int height,
|
||||
Bool kickOut,
|
||||
pointer closure)
|
||||
{
|
||||
if (pArea->width < width || pArea->height < height)
|
||||
return FALSE;
|
||||
|
||||
switch (pArea->state) {
|
||||
case xglAreaOccupied:
|
||||
if (kickOut)
|
||||
{
|
||||
if ((*pArea->pRoot->funcs->CompareScore) (pArea,
|
||||
pArea->closure,
|
||||
closure) >= 0)
|
||||
return FALSE;
|
||||
|
||||
xglAreaMoveOut (pArea);
|
||||
} else
|
||||
return FALSE;
|
||||
|
||||
/* fall-through */
|
||||
case xglAreaAvailable:
|
||||
{
|
||||
if (pArea->level == pArea->pRoot->maxLevel ||
|
||||
(pArea->width == width && pArea->height == height))
|
||||
{
|
||||
if (xglAreaMoveIn (pArea, closure))
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
int dx[4], dy[4], w[4], h[4], i;
|
||||
|
||||
dx[0] = dx[2] = dy[0] = dy[1] = 0;
|
||||
|
||||
w[0] = w[2] = dx[1] = dx[3] = width;
|
||||
h[0] = h[1] = dy[2] = dy[3] = height;
|
||||
|
||||
w[1] = w[3] = pArea->width - width;
|
||||
h[2] = h[3] = pArea->height - height;
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
if (w[i])
|
||||
pArea->pArea[i] =
|
||||
xglAreaCreate (pArea->pRoot,
|
||||
pArea->level + 1,
|
||||
pArea->x + dx[i],
|
||||
pArea->y + dy[i],
|
||||
w[i], h[i]);
|
||||
}
|
||||
|
||||
for (; i < 4; i++)
|
||||
{
|
||||
if (w[i] && h[i])
|
||||
pArea->pArea[i] =
|
||||
xglAreaCreate (pArea->pRoot,
|
||||
pArea->level + 1,
|
||||
pArea->x + dx[i],
|
||||
pArea->y + dy[i],
|
||||
w[i], h[i]);
|
||||
}
|
||||
|
||||
pArea->state = xglAreaDivided;
|
||||
|
||||
if (xglAreaFind (pArea->pArea[0], width, height, kickOut, closure))
|
||||
return TRUE;
|
||||
}
|
||||
} break;
|
||||
case xglAreaDivided:
|
||||
{
|
||||
xglAreaPtr topArea;
|
||||
int i, rejected = FALSE;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (pArea->pArea[i])
|
||||
{
|
||||
if (pArea->pArea[i]->width >= width &&
|
||||
pArea->pArea[i]->height >= height)
|
||||
{
|
||||
if (xglFindArea (pArea->pArea[i], width, height, kickOut,
|
||||
closure))
|
||||
return TRUE;
|
||||
|
||||
rejected = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rejected)
|
||||
return FALSE;
|
||||
|
||||
topArea = xglAreaGetTopScoredSubArea (pArea);
|
||||
if (topArea)
|
||||
{
|
||||
if (kickOut)
|
||||
{
|
||||
if ((*pArea->pRoot->funcs->CompareScore) (topArea,
|
||||
topArea->closure,
|
||||
closure) >= 0)
|
||||
return FALSE;
|
||||
} else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
xglAreaDestroy (pArea->pArea[i]);
|
||||
pArea->pArea[i] = NULL;
|
||||
}
|
||||
|
||||
pArea->closure = (pointer) 0;
|
||||
pArea->state = xglAreaAvailable;
|
||||
if (xglFindArea (pArea, width, height, TRUE, closure))
|
||||
return TRUE;
|
||||
|
||||
} break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglRootAreaInit (xglRootAreaPtr pRoot,
|
||||
int maxLevel,
|
||||
int width,
|
||||
int height,
|
||||
int devPrivateSize,
|
||||
xglAreaFuncsPtr funcs,
|
||||
pointer closure)
|
||||
{
|
||||
pRoot->maxLevel = maxLevel;
|
||||
pRoot->funcs = funcs;
|
||||
pRoot->devPrivateSize = devPrivateSize;
|
||||
pRoot->closure = closure;
|
||||
|
||||
pRoot->pArea = xglAreaCreate (pRoot, 0, 0, 0, width, height);
|
||||
if (!pRoot->pArea)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
xglRootAreaFini (xglRootAreaPtr pRoot)
|
||||
{
|
||||
xglAreaDestroy (pRoot->pArea);
|
||||
}
|
||||
|
||||
void
|
||||
xglLeaveArea (xglAreaPtr pArea)
|
||||
{
|
||||
xglAreaMoveOut (pArea);
|
||||
}
|
||||
|
||||
void
|
||||
xglWithdrawArea (xglAreaPtr pArea)
|
||||
{
|
||||
pArea->closure = NULL;
|
||||
pArea->state = xglAreaAvailable;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglFindArea (xglAreaPtr pArea,
|
||||
int width,
|
||||
int height,
|
||||
Bool kickOut,
|
||||
pointer closure)
|
||||
{
|
||||
if (width < 1 || height < 0)
|
||||
return FALSE;
|
||||
|
||||
return xglAreaFind (pArea, width, height, kickOut, closure);
|
||||
}
|
466
hw/xgl/xglcmap.c
466
hw/xgl/xglcmap.c
|
@ -1,466 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* 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
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
#include "colormapst.h"
|
||||
#include "micmap.h"
|
||||
#include "fb.h"
|
||||
|
||||
static xglPixelFormatRec xglPixelFormats[] = {
|
||||
{
|
||||
8, 8,
|
||||
{
|
||||
8,
|
||||
0x000000ff,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0x00000000
|
||||
}
|
||||
}, {
|
||||
15, 5,
|
||||
{
|
||||
16,
|
||||
0x00000000,
|
||||
0x00007c00,
|
||||
0x000003e0,
|
||||
0x0000001f
|
||||
}
|
||||
}, {
|
||||
16, 6,
|
||||
{
|
||||
16,
|
||||
0x00000000,
|
||||
0x0000f800,
|
||||
0x000007e0,
|
||||
0x0000001f
|
||||
}
|
||||
}, {
|
||||
24, 8,
|
||||
{
|
||||
32,
|
||||
0x00000000,
|
||||
0x00ff0000,
|
||||
0x0000ff00,
|
||||
0x000000ff
|
||||
}
|
||||
}, {
|
||||
32, 8,
|
||||
{
|
||||
32,
|
||||
0xff000000,
|
||||
0x00ff0000,
|
||||
0x0000ff00,
|
||||
0x000000ff
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#define NUM_XGL_PIXEL_FORMATS \
|
||||
(sizeof (xglPixelFormats) / sizeof (xglPixelFormats[0]))
|
||||
|
||||
xglVisualPtr xglVisuals = NULL;
|
||||
|
||||
void
|
||||
xglSetVisualTypes (int depth,
|
||||
int visuals,
|
||||
int redSize,
|
||||
int greenSize,
|
||||
int blueSize)
|
||||
{
|
||||
xglPixelFormatPtr pBestFormat = 0;
|
||||
int i, rs, gs, bs, diff, bestDiff = 0;
|
||||
|
||||
for (i = 0; i < NUM_XGL_PIXEL_FORMATS; i++)
|
||||
{
|
||||
if (xglPixelFormats[i].depth == depth)
|
||||
{
|
||||
if (visuals)
|
||||
{
|
||||
rs = Ones (xglPixelFormats[i].masks.red_mask);
|
||||
gs = Ones (xglPixelFormats[i].masks.green_mask);
|
||||
bs = Ones (xglPixelFormats[i].masks.blue_mask);
|
||||
|
||||
if (redSize >= rs &&
|
||||
greenSize >= gs &&
|
||||
blueSize >= bs)
|
||||
{
|
||||
diff = (redSize - rs) + (greenSize - gs) + (blueSize - bs);
|
||||
if (pBestFormat)
|
||||
{
|
||||
if (diff < bestDiff)
|
||||
{
|
||||
pBestFormat = &xglPixelFormats[i];
|
||||
bestDiff = diff;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pBestFormat = &xglPixelFormats[i];
|
||||
bestDiff = diff;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pBestFormat = &xglPixelFormats[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pBestFormat)
|
||||
{
|
||||
xglVisualPtr new, *prev, v;
|
||||
unsigned int bitsPerRGB;
|
||||
Pixel rm, gm, bm;
|
||||
|
||||
new = xalloc (sizeof (xglVisualRec));
|
||||
if (!new)
|
||||
return;
|
||||
|
||||
new->next = 0;
|
||||
|
||||
new->format.surface = 0;
|
||||
new->format.drawable = 0;
|
||||
new->pPixel = pBestFormat;
|
||||
new->vid = 0;
|
||||
|
||||
bitsPerRGB = pBestFormat->bitsPerRGB;
|
||||
|
||||
rm = pBestFormat->masks.red_mask;
|
||||
gm = pBestFormat->masks.green_mask;
|
||||
bm = pBestFormat->masks.blue_mask;
|
||||
|
||||
fbSetVisualTypesAndMasks (depth, visuals, bitsPerRGB, rm, gm, bm);
|
||||
|
||||
for (prev = &xglVisuals; (v = *prev); prev = &v->next);
|
||||
*prev = new;
|
||||
}
|
||||
else
|
||||
{
|
||||
fbSetVisualTypesAndMasks (depth, 0, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
Bool
|
||||
xglHasVisualTypes (xglVisualPtr pVisual,
|
||||
int depth)
|
||||
{
|
||||
xglVisualPtr v;
|
||||
|
||||
for (v = pVisual; v; v = v->next)
|
||||
if (v->pPixel->depth == depth)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
glitz_format_t *
|
||||
xglFindBestSurfaceFormat (ScreenPtr pScreen,
|
||||
xglPixelFormatPtr pPixel)
|
||||
{
|
||||
glitz_format_t templ, *format, *best = 0;
|
||||
unsigned int mask;
|
||||
unsigned short rs, gs, bs, as;
|
||||
int i = 0;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
rs = Ones (pPixel->masks.red_mask);
|
||||
gs = Ones (pPixel->masks.green_mask);
|
||||
bs = Ones (pPixel->masks.blue_mask);
|
||||
as = Ones (pPixel->masks.alpha_mask);
|
||||
|
||||
templ.color.fourcc = GLITZ_FOURCC_RGB;
|
||||
mask = GLITZ_FORMAT_FOURCC_MASK;
|
||||
|
||||
do {
|
||||
format = glitz_find_format (pScreenPriv->drawable, mask, &templ, i++);
|
||||
if (format)
|
||||
{
|
||||
if (format->color.red_size >= rs &&
|
||||
format->color.green_size >= gs &&
|
||||
format->color.blue_size >= bs &&
|
||||
format->color.alpha_size >= as)
|
||||
{
|
||||
if (best)
|
||||
{
|
||||
if (((format->color.red_size - rs) +
|
||||
(format->color.green_size - gs) +
|
||||
(format->color.blue_size - bs)) <
|
||||
((best->color.red_size - rs) +
|
||||
(best->color.green_size - gs) +
|
||||
(best->color.blue_size - bs)))
|
||||
best = format;
|
||||
}
|
||||
else
|
||||
{
|
||||
best = format;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (format);
|
||||
|
||||
return best;
|
||||
}
|
||||
|
||||
static Bool
|
||||
xglInitVisual (ScreenPtr pScreen,
|
||||
xglVisualPtr pVisual,
|
||||
xglPixelFormatPtr pPixel,
|
||||
VisualID vid)
|
||||
{
|
||||
glitz_format_t *format;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
format = xglFindBestSurfaceFormat (pScreen, pPixel);
|
||||
if (format)
|
||||
{
|
||||
glitz_drawable_format_t templ;
|
||||
unsigned long mask;
|
||||
|
||||
templ.color = format->color;
|
||||
templ.depth_size = 0;
|
||||
templ.stencil_size = 0;
|
||||
templ.doublebuffer = 0;
|
||||
templ.samples = 1;
|
||||
|
||||
mask =
|
||||
GLITZ_FORMAT_FOURCC_MASK |
|
||||
GLITZ_FORMAT_RED_SIZE_MASK |
|
||||
GLITZ_FORMAT_GREEN_SIZE_MASK |
|
||||
GLITZ_FORMAT_BLUE_SIZE_MASK |
|
||||
GLITZ_FORMAT_ALPHA_SIZE_MASK |
|
||||
GLITZ_FORMAT_DEPTH_SIZE_MASK |
|
||||
GLITZ_FORMAT_STENCIL_SIZE_MASK |
|
||||
GLITZ_FORMAT_DOUBLEBUFFER_MASK |
|
||||
GLITZ_FORMAT_SAMPLES_MASK;
|
||||
|
||||
pVisual->next = 0;
|
||||
pVisual->vid = vid;
|
||||
pVisual->pPixel = pPixel;
|
||||
pVisual->pbuffer = FALSE;
|
||||
|
||||
pVisual->format.surface = format;
|
||||
pVisual->format.drawable =
|
||||
glitz_find_drawable_format (pScreenPriv->drawable,
|
||||
mask, &templ, 0);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static Bool
|
||||
xglInitPbufferVisual (ScreenPtr pScreen,
|
||||
xglVisualPtr pVisual,
|
||||
xglPixelFormatPtr pPixel,
|
||||
VisualID vid)
|
||||
{
|
||||
glitz_format_t *format;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
format = xglFindBestSurfaceFormat (pScreen, pPixel);
|
||||
if (format)
|
||||
{
|
||||
glitz_drawable_format_t templ, *screenFormat;
|
||||
unsigned long mask;
|
||||
|
||||
/* use same drawable format as screen for pbuffers */
|
||||
screenFormat = glitz_drawable_get_format (pScreenPriv->drawable);
|
||||
templ.id = screenFormat->id;
|
||||
|
||||
templ.color = format->color;
|
||||
templ.samples = 1;
|
||||
|
||||
mask =
|
||||
GLITZ_FORMAT_ID_MASK |
|
||||
GLITZ_FORMAT_FOURCC_MASK |
|
||||
GLITZ_FORMAT_RED_SIZE_MASK |
|
||||
GLITZ_FORMAT_GREEN_SIZE_MASK |
|
||||
GLITZ_FORMAT_BLUE_SIZE_MASK |
|
||||
GLITZ_FORMAT_SAMPLES_MASK;
|
||||
|
||||
pVisual->next = 0;
|
||||
pVisual->vid = vid;
|
||||
pVisual->pPixel = pPixel;
|
||||
pVisual->pbuffer = TRUE;
|
||||
|
||||
pVisual->format.surface = format;
|
||||
pVisual->format.drawable =
|
||||
glitz_find_pbuffer_format (pScreenPriv->drawable,
|
||||
mask, &templ, 0);
|
||||
|
||||
if (pVisual->format.drawable)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
xglInitVisuals (ScreenPtr pScreen)
|
||||
{
|
||||
xglVisualPtr pVisual, v, new, *prev;
|
||||
int i;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
for (i = 0; i < pScreen->numVisuals; i++)
|
||||
{
|
||||
for (pVisual = xglVisuals; pVisual; pVisual = pVisual->next)
|
||||
if (pVisual->pPixel->depth == pScreen->visuals[i].nplanes)
|
||||
break;
|
||||
|
||||
if (pVisual)
|
||||
{
|
||||
new = xalloc (sizeof (xglVisualRec));
|
||||
if (new)
|
||||
{
|
||||
if (xglInitVisual (pScreen, new, pVisual->pPixel,
|
||||
pScreen->visuals[i].vid))
|
||||
{
|
||||
new->next = 0;
|
||||
|
||||
prev = &pScreenPriv->pVisual;
|
||||
while ((v = *prev))
|
||||
prev = &v->next;
|
||||
|
||||
*prev = new;
|
||||
}
|
||||
else
|
||||
{
|
||||
xfree (new);
|
||||
}
|
||||
}
|
||||
|
||||
new = xalloc (sizeof (xglVisualRec));
|
||||
if (new)
|
||||
{
|
||||
if (xglInitPbufferVisual (pScreen, new, pVisual->pPixel,
|
||||
pScreen->visuals[i].vid))
|
||||
{
|
||||
new->next = 0;
|
||||
|
||||
prev = &pScreenPriv->pVisual;
|
||||
while ((v = *prev))
|
||||
prev = &v->next;
|
||||
|
||||
*prev = new;
|
||||
}
|
||||
else
|
||||
{
|
||||
xfree (new);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Add additional Xgl visuals for pixmap formats */
|
||||
for (i = 0; i < screenInfo.numPixmapFormats; i++)
|
||||
{
|
||||
if (!xglHasVisualTypes (pScreenPriv->pVisual,
|
||||
screenInfo.formats[i].depth))
|
||||
{
|
||||
for (v = xglVisuals; v; v = v->next)
|
||||
if (v->pPixel->depth == screenInfo.formats[i].depth)
|
||||
break;
|
||||
|
||||
if (v)
|
||||
{
|
||||
new = xalloc (sizeof (xglVisualRec));
|
||||
if (new)
|
||||
{
|
||||
if (xglInitVisual (pScreen, new, v->pPixel, 0))
|
||||
{
|
||||
new->next = 0;
|
||||
|
||||
prev = &pScreenPriv->pVisual;
|
||||
while ((v = *prev))
|
||||
prev = &v->next;
|
||||
|
||||
*prev = new;
|
||||
}
|
||||
else
|
||||
{
|
||||
xfree (new);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
xglVisualPtr
|
||||
xglFindVisualWithDepth (ScreenPtr pScreen,
|
||||
int depth)
|
||||
{
|
||||
xglVisualPtr v;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
for (v = pScreenPriv->pVisual; v; v = v->next)
|
||||
{
|
||||
if (v->pPixel->depth == depth)
|
||||
return v;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
xglVisualPtr
|
||||
xglFindVisualWithId (ScreenPtr pScreen,
|
||||
int vid)
|
||||
{
|
||||
xglVisualPtr v;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
for (v = pScreenPriv->pVisual; v; v = v->next)
|
||||
{
|
||||
if (v->vid == vid)
|
||||
return v;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
xglClearVisualTypes (void)
|
||||
{
|
||||
xglVisualPtr v;
|
||||
|
||||
while (xglVisuals)
|
||||
{
|
||||
v = xglVisuals;
|
||||
xglVisuals = v->next;
|
||||
xfree (v);
|
||||
}
|
||||
|
||||
miClearVisualTypes ();
|
||||
}
|
|
@ -1,281 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* 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
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
|
||||
#ifdef RENDER
|
||||
|
||||
static glitz_operator_t xglOperators[] = {
|
||||
GLITZ_OPERATOR_CLEAR,
|
||||
GLITZ_OPERATOR_SRC,
|
||||
GLITZ_OPERATOR_DST,
|
||||
GLITZ_OPERATOR_OVER,
|
||||
GLITZ_OPERATOR_OVER_REVERSE,
|
||||
GLITZ_OPERATOR_IN,
|
||||
GLITZ_OPERATOR_IN_REVERSE,
|
||||
GLITZ_OPERATOR_OUT,
|
||||
GLITZ_OPERATOR_OUT_REVERSE,
|
||||
GLITZ_OPERATOR_ATOP,
|
||||
GLITZ_OPERATOR_ATOP_REVERSE,
|
||||
GLITZ_OPERATOR_XOR,
|
||||
GLITZ_OPERATOR_ADD
|
||||
};
|
||||
|
||||
#define NUM_XGL_OPERATORS \
|
||||
(sizeof (xglOperators) / sizeof (xglOperators[0]))
|
||||
|
||||
#define XGL_OPERATOR(op) (xglOperators[op])
|
||||
|
||||
#define XGL_GET_SOURCE_PICTURE(pPicture, outSurface) \
|
||||
(outSurface) = ((pPicture)->pDrawable) ? \
|
||||
XGL_GET_PIXMAP_PRIV ((PixmapPtr) (pPicture)->pDrawable)->surface : \
|
||||
(glitz_surface_t *) (pPicture)->pSourcePict->source.devPrivate.ptr
|
||||
|
||||
Bool
|
||||
xglCompositeGeneral (CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pMask,
|
||||
PicturePtr pDst,
|
||||
xglGeometryPtr pGeometry,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
INT16 xMask,
|
||||
INT16 yMask,
|
||||
INT16 xDst,
|
||||
INT16 yDst,
|
||||
CARD16 width,
|
||||
CARD16 height)
|
||||
{
|
||||
ScreenPtr pScreen = pDst->pDrawable->pScreen;
|
||||
INT16 xOff, yOff;
|
||||
glitz_surface_t *src, *mask = NULL, *dst;
|
||||
int dstXoff, dstYoff;
|
||||
RegionRec region;
|
||||
BoxPtr pBox, pExt;
|
||||
int nBox;
|
||||
|
||||
if (pDst->alphaMap)
|
||||
return FALSE;
|
||||
|
||||
if (op >= NUM_XGL_OPERATORS)
|
||||
return FALSE;
|
||||
|
||||
if (pSrc->pDrawable)
|
||||
{
|
||||
if (pSrc->pDrawable->type != DRAWABLE_PIXMAP)
|
||||
return FALSE;
|
||||
|
||||
if (pSrc->pDrawable->bitsPerPixel == 1)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (pMask)
|
||||
{
|
||||
if (pMask->pDrawable)
|
||||
{
|
||||
if (pMask->pDrawable->type != DRAWABLE_PIXMAP)
|
||||
return FALSE;
|
||||
|
||||
if (pSrc->pDrawable == pMask->pDrawable && pSrc != pMask)
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!xglPrepareTarget (pDst->pDrawable))
|
||||
return FALSE;
|
||||
|
||||
if (!miComputeCompositeRegion (®ion, pSrc, pMask, pDst,
|
||||
xSrc, ySrc, xMask, yMask,
|
||||
xDst, yDst, width, height))
|
||||
return TRUE;
|
||||
|
||||
pBox = REGION_RECTS (®ion);
|
||||
nBox = REGION_NUM_RECTS (®ion);
|
||||
pExt = REGION_EXTENTS (pScreen, ®ion);
|
||||
|
||||
XGL_GET_DRAWABLE (pDst->pDrawable, dst, dstXoff, dstYoff);
|
||||
|
||||
if (!xglSyncPicture (pScreen, pSrc,
|
||||
pExt->x1 + xSrc - xDst,
|
||||
pExt->y1 + ySrc - yDst,
|
||||
pExt->x2 - pExt->x1,
|
||||
pExt->y2 - pExt->y1,
|
||||
&xOff, &yOff))
|
||||
{
|
||||
REGION_UNINIT (pScreen, ®ion);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
xSrc -= xOff;
|
||||
ySrc -= yOff;
|
||||
|
||||
XGL_GET_SOURCE_PICTURE (pSrc, src);
|
||||
|
||||
if (pMask)
|
||||
{
|
||||
/* bitmap as mask */
|
||||
if (pMask->pDrawable && pMask->pDrawable->bitsPerPixel == 1)
|
||||
{
|
||||
if (pGeometry)
|
||||
{
|
||||
REGION_UNINIT (pScreen, ®ion);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pGeometry = xglPixmapToGeometry ((PixmapPtr) pMask->pDrawable,
|
||||
xDst - xMask,
|
||||
yDst - yMask);
|
||||
if (!pGeometry)
|
||||
{
|
||||
REGION_UNINIT (pScreen, ®ion);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!xglSyncPicture (pScreen, pMask,
|
||||
pExt->x1 + xMask - xDst,
|
||||
pExt->y1 + yMask - yDst,
|
||||
pExt->x2 - pExt->x1,
|
||||
pExt->y2 - pExt->y1,
|
||||
&xOff, &yOff))
|
||||
{
|
||||
REGION_UNINIT (pScreen, ®ion);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
xMask -= xOff;
|
||||
yMask -= yOff;
|
||||
|
||||
XGL_GET_SOURCE_PICTURE (pMask, mask);
|
||||
}
|
||||
}
|
||||
|
||||
if (!pGeometry)
|
||||
{
|
||||
if (!pSrc->transform && pSrc->filter != PictFilterConvolution)
|
||||
{
|
||||
if (pSrc->pDrawable && pSrc->repeatType == RepeatNormal)
|
||||
{
|
||||
XGL_PIXMAP_PRIV ((PixmapPtr) pSrc->pDrawable);
|
||||
|
||||
/* tile */
|
||||
if (!pPixmapPriv->acceleratedTile)
|
||||
{
|
||||
pGeometry =
|
||||
xglTiledBoxGeometry ((PixmapPtr) pSrc->pDrawable,
|
||||
xSrc - xDst, ySrc - yDst,
|
||||
pBox, nBox);
|
||||
if (!pGeometry)
|
||||
{
|
||||
REGION_UNINIT (pScreen, ®ion);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pBox = pExt;
|
||||
nBox = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* copy */
|
||||
if (op == PictOpSrc && !mask)
|
||||
{
|
||||
if (xglCopy (pSrc->pDrawable,
|
||||
pDst->pDrawable,
|
||||
xSrc - xDst,
|
||||
ySrc - yDst,
|
||||
pBox,
|
||||
nBox))
|
||||
{
|
||||
REGION_UNINIT (pScreen, ®ion);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nBox > 1)
|
||||
{
|
||||
pGeometry = xglGetScratchVertexGeometry (pScreen, 4 * nBox);
|
||||
|
||||
GEOMETRY_ADD_BOX (pScreen, pGeometry, pBox, nBox);
|
||||
|
||||
pBox = pExt;
|
||||
}
|
||||
|
||||
xSrc += pBox->x1 - xDst;
|
||||
ySrc += pBox->y1 - yDst;
|
||||
|
||||
if (pMask)
|
||||
{
|
||||
xMask += pBox->x1 - xDst;
|
||||
yMask += pBox->y1 - yDst;
|
||||
}
|
||||
|
||||
xDst = pBox->x1;
|
||||
yDst = pBox->y1;
|
||||
|
||||
width = pBox->x2 - pBox->x1;
|
||||
height = pBox->y2 - pBox->y1;
|
||||
}
|
||||
else
|
||||
{
|
||||
glitz_surface_set_clip_region (dst,
|
||||
dstXoff, dstYoff,
|
||||
(glitz_box_t *) pBox, nBox);
|
||||
}
|
||||
|
||||
if (pGeometry)
|
||||
{
|
||||
GEOMETRY_TRANSLATE (pGeometry, dstXoff, dstYoff);
|
||||
|
||||
if (!GEOMETRY_ENABLE (pGeometry, dst))
|
||||
{
|
||||
REGION_UNINIT (pScreen, ®ion);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
GEOMETRY_DISABLE (dst);
|
||||
|
||||
glitz_composite (XGL_OPERATOR (op),
|
||||
src, mask, dst,
|
||||
xSrc, ySrc,
|
||||
xMask, yMask,
|
||||
xDst + dstXoff, yDst + dstYoff,
|
||||
width, height);
|
||||
|
||||
glitz_surface_set_clip_region (dst, 0, 0, NULL, 0);
|
||||
|
||||
REGION_UNINIT (pScreen, ®ion);
|
||||
|
||||
if (glitz_surface_get_status (dst))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif
|
130
hw/xgl/xglcopy.c
130
hw/xgl/xglcopy.c
|
@ -1,130 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* 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
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
#include "fb.h"
|
||||
|
||||
Bool
|
||||
xglCopy (DrawablePtr pSrc,
|
||||
DrawablePtr pDst,
|
||||
int dx,
|
||||
int dy,
|
||||
BoxPtr pBox,
|
||||
int nBox)
|
||||
{
|
||||
glitz_surface_t *src, *dst;
|
||||
int srcXoff, srcYoff;
|
||||
int dstXoff, dstYoff;
|
||||
|
||||
XGL_DRAWABLE_PIXMAP (pDst);
|
||||
|
||||
if (!nBox)
|
||||
return TRUE;
|
||||
|
||||
if (xglPrepareTarget (pDst))
|
||||
{
|
||||
if (!xglSyncSurface (pSrc))
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!xglPrepareTarget (pSrc))
|
||||
return FALSE;
|
||||
|
||||
if (!xglSyncSurface (pDst))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
XGL_GET_DRAWABLE (pSrc, src, srcXoff, srcYoff);
|
||||
XGL_GET_DRAWABLE (pDst, dst, dstXoff, dstYoff);
|
||||
|
||||
glitz_surface_set_clip_region (dst,
|
||||
dstXoff, dstYoff,
|
||||
(glitz_box_t *) pBox, nBox);
|
||||
|
||||
glitz_copy_area (src,
|
||||
dst,
|
||||
srcXoff + dx,
|
||||
srcYoff + dy,
|
||||
pPixmap->drawable.width - dstXoff,
|
||||
pPixmap->drawable.height - dstYoff,
|
||||
dstXoff,
|
||||
dstYoff);
|
||||
|
||||
glitz_surface_set_clip_region (dst, 0, 0, NULL, 0);
|
||||
|
||||
if (glitz_surface_get_status (dst))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
xglCopyProc (DrawablePtr pSrc,
|
||||
DrawablePtr pDst,
|
||||
GCPtr pGC,
|
||||
BoxPtr pBox,
|
||||
int nBox,
|
||||
int dx,
|
||||
int dy,
|
||||
Bool reverse,
|
||||
Bool upsidedown,
|
||||
Pixel bitplane,
|
||||
void *closure)
|
||||
{
|
||||
BoxPtr pSrcBox = (BoxPtr) closure;
|
||||
|
||||
if (!xglCopy (pSrc, pDst, dx, dy, pBox, nBox))
|
||||
{
|
||||
RegionRec region;
|
||||
|
||||
XGL_DRAWABLE_PIXMAP (pDst);
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
if (!xglSyncBits (pSrc, pSrcBox))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
|
||||
if (!xglMapPixmapBits (pPixmap))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
|
||||
fbCopyNtoN (pSrc, pDst, pGC,
|
||||
pBox, nBox,
|
||||
dx, dy,
|
||||
reverse, upsidedown, bitplane,
|
||||
(void *) 0);
|
||||
|
||||
pPixmapPriv->damageBox = miEmptyBox;
|
||||
|
||||
while (nBox--)
|
||||
{
|
||||
REGION_INIT (pDst->pScreen, ®ion, pBox, 1);
|
||||
xglAddSurfaceDamage (pDst, ®ion);
|
||||
REGION_UNINIT (pDst->pScreen, ®ion);
|
||||
|
||||
pBox++;
|
||||
}
|
||||
} else
|
||||
xglAddCurrentBitDamage (pDst);
|
||||
}
|
742
hw/xgl/xglfill.c
742
hw/xgl/xglfill.c
|
@ -1,742 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* 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
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
#include "gcstruct.h"
|
||||
#include "fb.h"
|
||||
|
||||
Bool
|
||||
xglFill (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
xglGeometryPtr pGeometry,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
BoxPtr pBox,
|
||||
int nBox)
|
||||
{
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
switch (pGC->fillStyle) {
|
||||
case FillSolid:
|
||||
if (xglSolid (pDrawable,
|
||||
pGCPriv->op, pGCPriv->fg,
|
||||
pGeometry,
|
||||
x, y,
|
||||
width, height,
|
||||
pBox, nBox))
|
||||
return TRUE;
|
||||
break;
|
||||
case FillStippled:
|
||||
case FillOpaqueStippled:
|
||||
break;
|
||||
case FillTiled:
|
||||
if (xglTile (pDrawable,
|
||||
pGCPriv->op, pGC->tile.pixmap,
|
||||
-(pGC->patOrg.x + pDrawable->x),
|
||||
-(pGC->patOrg.y + pDrawable->y),
|
||||
pGeometry,
|
||||
x, y,
|
||||
width, height,
|
||||
pBox, nBox))
|
||||
return TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
xglFillBox (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
BoxPtr pBox,
|
||||
int nBox)
|
||||
{
|
||||
if (!nBox)
|
||||
return;
|
||||
|
||||
if (!xglFill (pDrawable, pGC, NULL, x, y, width, height, pBox, nBox))
|
||||
{
|
||||
RegionRec region;
|
||||
|
||||
XGL_DRAWABLE_PIXMAP (pDrawable);
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
if (!xglMapPixmapBits (pPixmap))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
|
||||
switch (pGC->fillStyle) {
|
||||
case FillSolid:
|
||||
break;
|
||||
case FillStippled:
|
||||
case FillOpaqueStippled:
|
||||
if (!xglSyncBits (&pGC->stipple->drawable, NullBox))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
break;
|
||||
case FillTiled:
|
||||
if (!xglSyncBits (&pGC->tile.pixmap->drawable, NullBox))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
break;
|
||||
}
|
||||
|
||||
pPixmapPriv->damageBox = miEmptyBox;
|
||||
|
||||
while (nBox--)
|
||||
{
|
||||
fbFill (pDrawable, pGC,
|
||||
pBox->x1, pBox->y1,
|
||||
pBox->x2 - pBox->x1, pBox->y2 - pBox->y1);
|
||||
|
||||
REGION_INIT (pDrawable->pScreen, ®ion, pBox, 1);
|
||||
xglAddSurfaceDamage (pDrawable, ®ion);
|
||||
REGION_UNINIT (pDrawable->pScreen, ®ion);
|
||||
|
||||
pBox++;
|
||||
}
|
||||
} else
|
||||
xglAddCurrentBitDamage (pDrawable);
|
||||
}
|
||||
|
||||
#define N_STACK_BOX 1024
|
||||
|
||||
static BoxPtr
|
||||
xglMoreBoxes (BoxPtr stackBox,
|
||||
BoxPtr heapBox,
|
||||
int nBoxes)
|
||||
{
|
||||
Bool stack = !heapBox;
|
||||
|
||||
heapBox = xrealloc (heapBox, sizeof (BoxRec) * nBoxes);
|
||||
if (!heapBox)
|
||||
return NULL;
|
||||
|
||||
if (stack)
|
||||
memcpy (heapBox, stackBox, sizeof (BoxRec) * N_STACK_BOX);
|
||||
|
||||
return heapBox;
|
||||
}
|
||||
|
||||
#define ADD_BOX(pBox, nBox, stackBox, heapBox, size, box) \
|
||||
{ \
|
||||
if ((nBox) == (size)) \
|
||||
{ \
|
||||
(size) *= 2; \
|
||||
(heapBox) = xglMoreBoxes (stackBox, heapBox, size); \
|
||||
if (heapBox) \
|
||||
{ \
|
||||
(pBox) = (heapBox) + (nBox); \
|
||||
*(pBox)++ = (box); \
|
||||
(nBox)++; \
|
||||
} \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
*(pBox)++ = (box); \
|
||||
(nBox)++; \
|
||||
} \
|
||||
}
|
||||
|
||||
void
|
||||
xglFillRect (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int nrect,
|
||||
xRectangle *prect)
|
||||
{
|
||||
RegionPtr pClip = pGC->pCompositeClip;
|
||||
BoxPtr pClipBox;
|
||||
BoxPtr pExtent = REGION_EXTENTS (pGC->pScreen, pClip);
|
||||
BoxRec part, full;
|
||||
BoxPtr heapBox = NULL;
|
||||
BoxRec stackBox[N_STACK_BOX];
|
||||
int size = N_STACK_BOX;
|
||||
BoxPtr pBox = stackBox;
|
||||
int nClip, nBox = 0;
|
||||
|
||||
while (nrect--)
|
||||
{
|
||||
full.x1 = prect->x + pDrawable->x;
|
||||
full.y1 = prect->y + pDrawable->y;
|
||||
full.x2 = full.x1 + (int) prect->width;
|
||||
full.y2 = full.y1 + (int) prect->height;
|
||||
|
||||
prect++;
|
||||
|
||||
if (full.x1 < pExtent->x1)
|
||||
full.x1 = pExtent->x1;
|
||||
if (full.y1 < pExtent->y1)
|
||||
full.y1 = pExtent->y1;
|
||||
if (full.x2 > pExtent->x2)
|
||||
full.x2 = pExtent->x2;
|
||||
if (full.y2 > pExtent->y2)
|
||||
full.y2 = pExtent->y2;
|
||||
|
||||
if (full.x1 >= full.x2 || full.y1 >= full.y2)
|
||||
continue;
|
||||
|
||||
nClip = REGION_NUM_RECTS (pClip);
|
||||
if (nClip == 1)
|
||||
{
|
||||
ADD_BOX (pBox, nBox, stackBox, heapBox, size, full);
|
||||
}
|
||||
else
|
||||
{
|
||||
pClipBox = REGION_RECTS (pClip);
|
||||
while (nClip--)
|
||||
{
|
||||
part = *pClipBox++;
|
||||
|
||||
if (part.x1 < full.x1)
|
||||
part.x1 = full.x1;
|
||||
if (part.y1 < full.y1)
|
||||
part.y1 = full.y1;
|
||||
if (part.x2 > full.x2)
|
||||
part.x2 = full.x2;
|
||||
if (part.y2 > full.y2)
|
||||
part.y2 = full.y2;
|
||||
|
||||
if (part.x1 < part.x2 && part.y1 < part.y2)
|
||||
ADD_BOX (pBox, nBox, stackBox, heapBox, size, part);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
xglFillBox (pDrawable, pGC,
|
||||
pExtent->x1, pExtent->y1,
|
||||
pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
|
||||
(heapBox) ? heapBox : stackBox, nBox);
|
||||
|
||||
if (heapBox)
|
||||
xfree (heapBox);
|
||||
}
|
||||
|
||||
void
|
||||
xglFillSpan (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int n,
|
||||
DDXPointPtr ppt,
|
||||
int *pwidth)
|
||||
{
|
||||
RegionPtr pClip = pGC->pCompositeClip;
|
||||
BoxPtr pClipBox;
|
||||
BoxPtr pExtent = REGION_EXTENTS (pGC->pScreen, pClip);
|
||||
BoxRec part, full;
|
||||
BoxPtr heapBox = NULL;
|
||||
BoxRec stackBox[N_STACK_BOX];
|
||||
int size = N_STACK_BOX;
|
||||
BoxPtr pBox = stackBox;
|
||||
int nClip, nBox = 0;
|
||||
|
||||
while (n--)
|
||||
{
|
||||
full.x1 = ppt->x;
|
||||
full.y1 = ppt->y;
|
||||
full.x2 = full.x1 + *pwidth;
|
||||
full.y2 = full.y1 + 1;
|
||||
|
||||
pwidth++;
|
||||
ppt++;
|
||||
|
||||
if (full.x1 < pExtent->x1)
|
||||
full.x1 = pExtent->x1;
|
||||
if (full.y1 < pExtent->y1)
|
||||
full.y1 = pExtent->y1;
|
||||
if (full.x2 > pExtent->x2)
|
||||
full.x2 = pExtent->x2;
|
||||
if (full.y2 > pExtent->y2)
|
||||
full.y2 = pExtent->y2;
|
||||
|
||||
if (full.x1 >= full.x2 || full.y1 >= full.y2)
|
||||
continue;
|
||||
|
||||
nClip = REGION_NUM_RECTS (pClip);
|
||||
if (nClip == 1)
|
||||
{
|
||||
ADD_BOX (pBox, nBox, stackBox, heapBox, size, full);
|
||||
}
|
||||
else
|
||||
{
|
||||
pClipBox = REGION_RECTS (pClip);
|
||||
while (nClip--)
|
||||
{
|
||||
part = *pClipBox++;
|
||||
|
||||
if (part.x1 < full.x1)
|
||||
part.x1 = full.x1;
|
||||
if (part.y1 < full.y1)
|
||||
part.y1 = full.y1;
|
||||
if (part.x2 > full.x2)
|
||||
part.x2 = full.x2;
|
||||
if (part.y2 > full.y2)
|
||||
part.y2 = full.y2;
|
||||
|
||||
if (part.x1 < part.x2 && part.y1 < part.y2)
|
||||
ADD_BOX (pBox, nBox, stackBox, heapBox, size, part);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
xglFillBox (pDrawable, pGC,
|
||||
pExtent->x1, pExtent->y1,
|
||||
pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
|
||||
(heapBox) ? heapBox : stackBox, nBox);
|
||||
|
||||
if (heapBox)
|
||||
xfree (heapBox);
|
||||
}
|
||||
|
||||
Bool
|
||||
xglFillLine (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int mode,
|
||||
int npt,
|
||||
DDXPointPtr ppt)
|
||||
{
|
||||
RegionPtr pClip = pGC->pCompositeClip;
|
||||
BoxPtr pExtent = REGION_EXTENTS (pGC->pScreen, pClip);
|
||||
Bool coincidentEndpoints = FALSE;
|
||||
Bool horizontalAndVertical = TRUE;
|
||||
DDXPointPtr pptTmp;
|
||||
int nptTmp;
|
||||
DDXPointRec pt;
|
||||
xglGeometryPtr pGeometry;
|
||||
|
||||
XGL_SCREEN_PRIV (pGC->pScreen);
|
||||
|
||||
if (npt < 2)
|
||||
return TRUE;
|
||||
|
||||
pt = *ppt;
|
||||
|
||||
nptTmp = npt - 1;
|
||||
pptTmp = ppt + 1;
|
||||
|
||||
if (mode == CoordModePrevious)
|
||||
{
|
||||
while (nptTmp--)
|
||||
{
|
||||
if (pptTmp->x && pptTmp->y)
|
||||
horizontalAndVertical = FALSE;
|
||||
|
||||
pt.x += pptTmp->x;
|
||||
pt.y += pptTmp->y;
|
||||
|
||||
pptTmp++;
|
||||
}
|
||||
|
||||
if (pt.x == ppt->x && pt.y == ppt->y)
|
||||
coincidentEndpoints = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (nptTmp--)
|
||||
{
|
||||
if (pptTmp->x != pt.x && pptTmp->y != pt.y)
|
||||
{
|
||||
horizontalAndVertical = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
pt = *pptTmp++;
|
||||
}
|
||||
|
||||
if (ppt[npt - 1].x == ppt->x && ppt[npt - 1].y == ppt->y)
|
||||
coincidentEndpoints = TRUE;
|
||||
}
|
||||
|
||||
if (horizontalAndVertical)
|
||||
{
|
||||
BoxPtr pClipBox;
|
||||
BoxRec part, full;
|
||||
BoxPtr heapBox = NULL;
|
||||
BoxRec stackBox[N_STACK_BOX];
|
||||
int size = N_STACK_BOX;
|
||||
BoxPtr pBox = stackBox;
|
||||
int nClip, nBox = 0;
|
||||
int dx, dy;
|
||||
|
||||
pt = *ppt;
|
||||
|
||||
ppt++;
|
||||
npt--;
|
||||
|
||||
while (npt--)
|
||||
{
|
||||
if (mode == CoordModePrevious)
|
||||
{
|
||||
dx = ppt->x;
|
||||
dy = ppt->y;
|
||||
}
|
||||
else
|
||||
{
|
||||
dx = ppt->x - pt.x;
|
||||
dy = ppt->y - pt.y;
|
||||
}
|
||||
|
||||
if (dx)
|
||||
{
|
||||
if (dx > 0)
|
||||
{
|
||||
full.x1 = pt.x + pDrawable->x;
|
||||
|
||||
if (npt || coincidentEndpoints)
|
||||
full.x2 = full.x1 + dx;
|
||||
else
|
||||
full.x2 = full.x1 + dx + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
full.x2 = pt.x + pDrawable->x + 1;
|
||||
|
||||
if (npt || coincidentEndpoints)
|
||||
full.x1 = full.x2 + dx;
|
||||
else
|
||||
full.x1 = full.x2 + dx - 1;
|
||||
}
|
||||
|
||||
full.y1 = pt.y + pDrawable->y;
|
||||
full.y2 = full.y1 + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dy > 0)
|
||||
{
|
||||
full.y1 = pt.y + pDrawable->y;
|
||||
|
||||
if (npt || coincidentEndpoints)
|
||||
full.y2 = full.y1 + dy;
|
||||
else
|
||||
full.y2 = full.y1 + dy + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
full.y2 = pt.y + pDrawable->y + 1;
|
||||
|
||||
if (npt || coincidentEndpoints)
|
||||
full.y1 = full.y2 + dy;
|
||||
else
|
||||
full.y1 = full.y2 + dy - 1;
|
||||
}
|
||||
|
||||
full.x1 = pt.x + pDrawable->x;
|
||||
full.x2 = full.x1 + 1;
|
||||
}
|
||||
|
||||
pt.x += dx;
|
||||
pt.y += dy;
|
||||
|
||||
ppt++;
|
||||
|
||||
if (full.x1 < pExtent->x1)
|
||||
full.x1 = pExtent->x1;
|
||||
if (full.y1 < pExtent->y1)
|
||||
full.y1 = pExtent->y1;
|
||||
if (full.x2 > pExtent->x2)
|
||||
full.x2 = pExtent->x2;
|
||||
if (full.y2 > pExtent->y2)
|
||||
full.y2 = pExtent->y2;
|
||||
|
||||
if (full.x1 >= full.x2 || full.y1 >= full.y2)
|
||||
continue;
|
||||
|
||||
nClip = REGION_NUM_RECTS (pClip);
|
||||
if (nClip == 1)
|
||||
{
|
||||
ADD_BOX (pBox, nBox, stackBox, heapBox, size, full);
|
||||
}
|
||||
else
|
||||
{
|
||||
pClipBox = REGION_RECTS (pClip);
|
||||
while (nClip--)
|
||||
{
|
||||
part = *pClipBox++;
|
||||
|
||||
if (part.x1 < full.x1)
|
||||
part.x1 = full.x1;
|
||||
if (part.y1 < full.y1)
|
||||
part.y1 = full.y1;
|
||||
if (part.x2 > full.x2)
|
||||
part.x2 = full.x2;
|
||||
if (part.y2 > full.y2)
|
||||
part.y2 = full.y2;
|
||||
|
||||
if (part.x1 < part.x2 && part.y1 < part.y2)
|
||||
ADD_BOX (pBox, nBox, stackBox, heapBox, size, part);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
xglFillBox (pDrawable, pGC,
|
||||
pExtent->x1, pExtent->y1,
|
||||
pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
|
||||
(heapBox) ? heapBox : stackBox, nBox);
|
||||
|
||||
if (heapBox)
|
||||
xfree (heapBox);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!pScreenPriv->lines)
|
||||
return FALSE;
|
||||
|
||||
if (coincidentEndpoints)
|
||||
npt--;
|
||||
|
||||
pGeometry = xglGetScratchVertexGeometry (pGC->pScreen, npt);
|
||||
|
||||
GEOMETRY_ADD_LINE (pGC->pScreen, pGeometry,
|
||||
coincidentEndpoints, mode, npt, ppt);
|
||||
|
||||
if (coincidentEndpoints)
|
||||
GEOMETRY_SET_VERTEX_PRIMITIVE (pGeometry, GLITZ_PRIMITIVE_LINE_LOOP);
|
||||
else
|
||||
GEOMETRY_SET_VERTEX_PRIMITIVE (pGeometry, GLITZ_PRIMITIVE_LINE_STRIP);
|
||||
|
||||
/* Lines need a 0.5 translate */
|
||||
GEOMETRY_TRANSLATE_FIXED (pGeometry, 1 << 15, 1 << 15);
|
||||
|
||||
GEOMETRY_TRANSLATE (pGeometry, pDrawable->x, pDrawable->y);
|
||||
|
||||
pExtent = REGION_EXTENTS (pDrawable->pScreen, pGC->pCompositeClip);
|
||||
|
||||
if (xglFill (pDrawable, pGC, pGeometry,
|
||||
pExtent->x1, pExtent->y1,
|
||||
pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
|
||||
REGION_RECTS (pGC->pCompositeClip),
|
||||
REGION_NUM_RECTS (pGC->pCompositeClip)))
|
||||
{
|
||||
xglAddCurrentBitDamage (pDrawable);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglFillSegment (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int nSegInit,
|
||||
xSegment *pSegInit)
|
||||
{
|
||||
RegionPtr pClip = pGC->pCompositeClip;
|
||||
BoxPtr pExtent = REGION_EXTENTS (pGC->pScreen, pClip);
|
||||
Bool horizontalAndVertical = TRUE;
|
||||
xglGeometryPtr pGeometry;
|
||||
xSegment *pSeg;
|
||||
int nSeg;
|
||||
|
||||
XGL_SCREEN_PRIV (pGC->pScreen);
|
||||
|
||||
if (nSegInit < 1)
|
||||
return TRUE;
|
||||
|
||||
pSeg = pSegInit;
|
||||
nSeg = nSegInit;
|
||||
while (nSeg--)
|
||||
{
|
||||
if (pSeg->x1 != pSeg->x2 && pSeg->y1 != pSeg->y2)
|
||||
horizontalAndVertical = FALSE;
|
||||
|
||||
pSeg++;
|
||||
}
|
||||
|
||||
if (horizontalAndVertical)
|
||||
{
|
||||
BoxPtr pClipBox;
|
||||
BoxRec part, full;
|
||||
BoxPtr heapBox = NULL;
|
||||
BoxRec stackBox[N_STACK_BOX];
|
||||
int size = N_STACK_BOX;
|
||||
BoxPtr pBox = stackBox;
|
||||
int nClip, nBox = 0;
|
||||
|
||||
while (nSegInit--)
|
||||
{
|
||||
if (pSegInit->x1 != pSegInit->x2)
|
||||
{
|
||||
if (pSegInit->x1 < pSegInit->x2)
|
||||
{
|
||||
full.x1 = pSegInit->x1;
|
||||
full.x2 = pSegInit->x2;
|
||||
}
|
||||
else
|
||||
{
|
||||
full.x1 = pSegInit->x2;
|
||||
full.x2 = pSegInit->x1;
|
||||
}
|
||||
|
||||
full.x1 += pDrawable->x;
|
||||
full.x2 += pDrawable->x + 1;
|
||||
full.y1 = pSegInit->y1 + pDrawable->y;
|
||||
full.y2 = full.y1 + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pSegInit->y1 < pSegInit->y2)
|
||||
{
|
||||
full.y1 = pSegInit->y1;
|
||||
full.y2 = pSegInit->y2;
|
||||
}
|
||||
else
|
||||
{
|
||||
full.y1 = pSegInit->y2;
|
||||
full.y2 = pSegInit->y1;
|
||||
}
|
||||
|
||||
full.y1 += pDrawable->y;
|
||||
full.y2 += pDrawable->y + 1;
|
||||
full.x1 = pSegInit->x1 + pDrawable->x;
|
||||
full.x2 = full.x1 + 1;
|
||||
}
|
||||
|
||||
pSegInit++;
|
||||
|
||||
if (full.x1 < pExtent->x1)
|
||||
full.x1 = pExtent->x1;
|
||||
if (full.y1 < pExtent->y1)
|
||||
full.y1 = pExtent->y1;
|
||||
if (full.x2 > pExtent->x2)
|
||||
full.x2 = pExtent->x2;
|
||||
if (full.y2 > pExtent->y2)
|
||||
full.y2 = pExtent->y2;
|
||||
|
||||
if (full.x1 >= full.x2 || full.y1 >= full.y2)
|
||||
continue;
|
||||
|
||||
nClip = REGION_NUM_RECTS (pClip);
|
||||
if (nClip == 1)
|
||||
{
|
||||
ADD_BOX (pBox, nBox, stackBox, heapBox, size, full);
|
||||
}
|
||||
else
|
||||
{
|
||||
pClipBox = REGION_RECTS (pClip);
|
||||
while (nClip--)
|
||||
{
|
||||
part = *pClipBox++;
|
||||
|
||||
if (part.x1 < full.x1)
|
||||
part.x1 = full.x1;
|
||||
if (part.y1 < full.y1)
|
||||
part.y1 = full.y1;
|
||||
if (part.x2 > full.x2)
|
||||
part.x2 = full.x2;
|
||||
if (part.y2 > full.y2)
|
||||
part.y2 = full.y2;
|
||||
|
||||
if (part.x1 < part.x2 && part.y1 < part.y2)
|
||||
ADD_BOX (pBox, nBox, stackBox, heapBox, size, part);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
xglFillBox (pDrawable, pGC,
|
||||
pExtent->x1, pExtent->y1,
|
||||
pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
|
||||
(heapBox) ? heapBox : stackBox, nBox);
|
||||
|
||||
if (heapBox)
|
||||
xfree (heapBox);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!pScreenPriv->lines)
|
||||
return FALSE;
|
||||
|
||||
pGeometry = xglGetScratchVertexGeometry (pGC->pScreen, 2 * nSegInit);
|
||||
|
||||
GEOMETRY_ADD_SEGMENT (pGC->pScreen, pGeometry, nSegInit, pSegInit);
|
||||
|
||||
/* Line segments need 0.5 translate */
|
||||
GEOMETRY_TRANSLATE_FIXED (pGeometry, 1 << 15, 1 << 15);
|
||||
GEOMETRY_SET_VERTEX_PRIMITIVE (pGeometry, GLITZ_PRIMITIVE_LINES);
|
||||
|
||||
GEOMETRY_TRANSLATE (pGeometry, pDrawable->x, pDrawable->y);
|
||||
|
||||
if (xglFill (pDrawable, pGC, pGeometry,
|
||||
pExtent->x1, pExtent->y1,
|
||||
pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
|
||||
REGION_RECTS (pGC->pCompositeClip),
|
||||
REGION_NUM_RECTS (pGC->pCompositeClip)))
|
||||
{
|
||||
xglAddCurrentBitDamage (pDrawable);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglFillGlyph (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int x,
|
||||
int y,
|
||||
unsigned int nGlyph,
|
||||
CharInfoPtr *ppci,
|
||||
pointer pglyphBase)
|
||||
{
|
||||
BoxPtr pExtent;
|
||||
xglGeometryRec geometry;
|
||||
|
||||
if (nGlyph < 1)
|
||||
return TRUE;
|
||||
|
||||
pExtent = REGION_EXTENTS (pDrawable->pScreen, pGC->pCompositeClip);
|
||||
|
||||
x += pDrawable->x;
|
||||
y += pDrawable->y;
|
||||
|
||||
GEOMETRY_INIT (pDrawable->pScreen, &geometry,
|
||||
GLITZ_GEOMETRY_TYPE_BITMAP,
|
||||
GEOMETRY_USAGE_SYSMEM, 0);
|
||||
|
||||
GEOMETRY_FOR_GLYPH (pDrawable->pScreen,
|
||||
&geometry,
|
||||
nGlyph,
|
||||
ppci,
|
||||
pglyphBase);
|
||||
|
||||
GEOMETRY_TRANSLATE (&geometry, x, y);
|
||||
|
||||
if (xglFill (pDrawable, pGC, &geometry,
|
||||
pExtent->x1, pExtent->y1,
|
||||
pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
|
||||
REGION_RECTS (pGC->pCompositeClip),
|
||||
REGION_NUM_RECTS (pGC->pCompositeClip)))
|
||||
{
|
||||
GEOMETRY_UNINIT (&geometry);
|
||||
xglAddCurrentBitDamage (pDrawable);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GEOMETRY_UNINIT (&geometry);
|
||||
return FALSE;
|
||||
}
|
645
hw/xgl/xglgc.c
645
hw/xgl/xglgc.c
|
@ -1,645 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* 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
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
#include "fb.h"
|
||||
#include "gcstruct.h"
|
||||
#include "migc.h"
|
||||
|
||||
#define XGL_GC_OP_FALLBACK_PROLOGUE(pDrawable) \
|
||||
xglSyncDamageBoxBits (pDrawable); \
|
||||
XGL_GC_UNWRAP (funcs); \
|
||||
XGL_GC_UNWRAP (ops)
|
||||
|
||||
#define XGL_GC_OP_FALLBACK_EPILOGUE(pDrawable) \
|
||||
XGL_GC_WRAP (funcs, (GCFuncs *) &xglGCFuncs); \
|
||||
XGL_GC_WRAP (ops, (GCOps *) &xglGCOps); \
|
||||
xglAddCurrentSurfaceDamage (pDrawable)
|
||||
|
||||
#define XGL_GC_FILL_OP_FALLBACK_PROLOGUE(pDrawable) \
|
||||
switch (pGC->fillStyle) { \
|
||||
case FillSolid: \
|
||||
break; \
|
||||
case FillStippled: \
|
||||
case FillOpaqueStippled: \
|
||||
if (!xglSyncBits (&pGC->stipple->drawable, NullBox)) \
|
||||
FatalError (XGL_SW_FAILURE_STRING); \
|
||||
break; \
|
||||
case FillTiled: \
|
||||
if (!xglSyncBits (&pGC->tile.pixmap->drawable, NullBox)) \
|
||||
FatalError (XGL_SW_FAILURE_STRING); \
|
||||
break; \
|
||||
} \
|
||||
XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable)
|
||||
|
||||
static const GCFuncs xglGCFuncs = {
|
||||
xglValidateGC,
|
||||
miChangeGC,
|
||||
miCopyGC,
|
||||
xglDestroyGC,
|
||||
miChangeClip,
|
||||
miDestroyClip,
|
||||
miCopyClip
|
||||
};
|
||||
|
||||
static const GCOps xglGCOps = {
|
||||
xglFillSpans,
|
||||
xglSetSpans,
|
||||
xglPutImage,
|
||||
xglCopyArea,
|
||||
xglCopyPlane,
|
||||
xglPolyPoint,
|
||||
xglPolylines,
|
||||
xglPolySegment,
|
||||
miPolyRectangle,
|
||||
xglPolyArc,
|
||||
miFillPolygon,
|
||||
xglPolyFillRect,
|
||||
xglPolyFillArc,
|
||||
miPolyText8,
|
||||
miPolyText16,
|
||||
miImageText8,
|
||||
miImageText16,
|
||||
xglImageGlyphBlt,
|
||||
xglPolyGlyphBlt,
|
||||
xglPushPixels
|
||||
};
|
||||
|
||||
void
|
||||
xglFillSpans (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int nspans,
|
||||
DDXPointPtr ppt,
|
||||
int *pwidth,
|
||||
int fSorted)
|
||||
{
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
if (pGCPriv->flags || pGC->fillStyle == FillStippled)
|
||||
{
|
||||
XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
|
||||
(*pGC->ops->FillSpans) (pDrawable, pGC, nspans, ppt, pwidth, fSorted);
|
||||
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* xglFillSpan handles fall-back */
|
||||
xglFillSpan (pDrawable, pGC, nspans, ppt, pwidth);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
xglSetSpans (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
char *psrc,
|
||||
DDXPointPtr ppt,
|
||||
int *pwidth,
|
||||
int nspans,
|
||||
int fSorted)
|
||||
{
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable);
|
||||
(*pGC->ops->SetSpans) (pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted);
|
||||
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
|
||||
}
|
||||
|
||||
void
|
||||
xglPutImage (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int depth,
|
||||
int x,
|
||||
int y,
|
||||
int w,
|
||||
int h,
|
||||
int leftPad,
|
||||
int format,
|
||||
char *bits)
|
||||
{
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
if (pGC->alu != GXcopy || (pGCPriv->flags & xglGCPlaneMaskFlag))
|
||||
{
|
||||
XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable);
|
||||
(*pGC->ops->PutImage) (pDrawable, pGC, depth,
|
||||
x, y, w, h, leftPad, format, bits);
|
||||
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
|
||||
}
|
||||
else
|
||||
{
|
||||
RegionPtr pClip = pGC->pCompositeClip;
|
||||
RegionRec region;
|
||||
BoxRec box;
|
||||
|
||||
XGL_DRAWABLE_PIXMAP (pDrawable);
|
||||
|
||||
if (!xglMapPixmapBits (pPixmap))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
|
||||
XGL_GC_UNWRAP (funcs);
|
||||
XGL_GC_UNWRAP (ops);
|
||||
|
||||
(*pGC->ops->PutImage) (pDrawable, pGC, depth,
|
||||
x, y, w, h, leftPad, format, bits);
|
||||
|
||||
XGL_GC_WRAP (funcs, (GCFuncs *) &xglGCFuncs);
|
||||
XGL_GC_WRAP (ops, (GCOps *) &xglGCOps);
|
||||
|
||||
box.x1 = pDrawable->x + x;
|
||||
box.y1 = pDrawable->y + y;
|
||||
box.x2 = box.x1 + w;
|
||||
box.y2 = box.y1 + h;
|
||||
|
||||
REGION_INIT (pDrawable->pScreen, ®ion, &box, 1);
|
||||
REGION_INTERSECT (pDrawable->pScreen, ®ion, pClip, ®ion);
|
||||
|
||||
xglAddSurfaceDamage (pDrawable, ®ion);
|
||||
|
||||
REGION_UNINIT (pDrawable->pScreen, ®ion);
|
||||
}
|
||||
}
|
||||
|
||||
RegionPtr
|
||||
xglCopyArea (DrawablePtr pSrc,
|
||||
DrawablePtr pDst,
|
||||
GCPtr pGC,
|
||||
int srcX,
|
||||
int srcY,
|
||||
int w,
|
||||
int h,
|
||||
int dstX,
|
||||
int dstY)
|
||||
{
|
||||
RegionPtr pRegion;
|
||||
BoxRec box;
|
||||
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
box.x1 = pSrc->x + srcX;
|
||||
box.y1 = pSrc->y + srcY;
|
||||
box.x2 = box.x1 + w;
|
||||
box.y2 = box.y1 + h;
|
||||
|
||||
if (pGC->alu != GXcopy || pGCPriv->flags)
|
||||
{
|
||||
if (!xglSyncBits (pSrc, &box))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
|
||||
XGL_GC_OP_FALLBACK_PROLOGUE (pDst);
|
||||
pRegion = (*pGC->ops->CopyArea) (pSrc, pDst, pGC,
|
||||
srcX, srcY, w, h, dstX, dstY);
|
||||
XGL_GC_OP_FALLBACK_EPILOGUE (pDst);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* xglCopyProc handles fall-back */
|
||||
pRegion = fbDoCopy (pSrc, pDst, pGC,
|
||||
srcX, srcY,
|
||||
w, h,
|
||||
dstX, dstY,
|
||||
xglCopyProc, 0,
|
||||
(void *) &box);
|
||||
}
|
||||
|
||||
return pRegion;
|
||||
}
|
||||
|
||||
RegionPtr
|
||||
xglCopyPlane (DrawablePtr pSrc,
|
||||
DrawablePtr pDst,
|
||||
GCPtr pGC,
|
||||
int srcX,
|
||||
int srcY,
|
||||
int w,
|
||||
int h,
|
||||
int dstX,
|
||||
int dstY,
|
||||
unsigned long bitPlane)
|
||||
{
|
||||
RegionPtr pRegion;
|
||||
BoxRec box;
|
||||
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
box.x1 = pSrc->x + srcX;
|
||||
box.y1 = pSrc->y + srcY;
|
||||
box.x2 = box.x1 + w;
|
||||
box.y2 = box.y1 + h;
|
||||
|
||||
if (!xglSyncBits (pSrc, &box))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
|
||||
XGL_GC_OP_FALLBACK_PROLOGUE (pDst);
|
||||
pRegion = (*pGC->ops->CopyPlane) (pSrc, pDst, pGC,
|
||||
srcX, srcY, w, h, dstX, dstY,
|
||||
bitPlane);
|
||||
XGL_GC_OP_FALLBACK_EPILOGUE (pDst);
|
||||
|
||||
return pRegion;
|
||||
}
|
||||
|
||||
void
|
||||
xglPolyPoint (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int mode,
|
||||
int npt,
|
||||
DDXPointPtr pptInit)
|
||||
{
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable);
|
||||
(*pGC->ops->PolyPoint) (pDrawable, pGC, mode, npt, pptInit);
|
||||
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
|
||||
}
|
||||
|
||||
void
|
||||
xglPolylines (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int mode,
|
||||
int npt,
|
||||
DDXPointPtr ppt)
|
||||
{
|
||||
if (pGC->lineWidth == 0)
|
||||
{
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
if (!pGCPriv->flags)
|
||||
{
|
||||
if (pGC->lineStyle == LineSolid)
|
||||
{
|
||||
if (xglFillLine (pDrawable, pGC, mode, npt, ppt))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
|
||||
(*pGC->ops->Polylines) (pDrawable, pGC, mode, npt, ppt);
|
||||
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pGC->lineStyle != LineSolid)
|
||||
miWideDash (pDrawable, pGC, mode, npt, ppt);
|
||||
else
|
||||
miWideLine (pDrawable, pGC, mode, npt, ppt);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
xglPolySegment (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int nsegInit,
|
||||
xSegment *pSegInit)
|
||||
{
|
||||
if (pGC->lineWidth == 0)
|
||||
{
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
if (!pGCPriv->flags)
|
||||
{
|
||||
if (pGC->lineStyle == LineSolid)
|
||||
{
|
||||
if (xglFillSegment (pDrawable, pGC, nsegInit, pSegInit))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
|
||||
(*pGC->ops->PolySegment) (pDrawable, pGC, nsegInit, pSegInit);
|
||||
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
|
||||
} else
|
||||
miPolySegment (pDrawable, pGC, nsegInit, pSegInit);
|
||||
}
|
||||
|
||||
void
|
||||
xglPolyArc (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int narcs,
|
||||
xArc *pArcs)
|
||||
{
|
||||
if (pGC->lineWidth == 0)
|
||||
{
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
|
||||
(*pGC->ops->PolyArc) (pDrawable, pGC, narcs, pArcs);
|
||||
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
|
||||
} else
|
||||
miPolyArc (pDrawable, pGC, narcs, pArcs);
|
||||
}
|
||||
|
||||
void
|
||||
xglPolyFillRect (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int nrect,
|
||||
xRectangle *prect)
|
||||
{
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
if (pGC->fillStyle == FillStippled || pGCPriv->flags)
|
||||
{
|
||||
XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
|
||||
(*pGC->ops->PolyFillRect) (pDrawable, pGC, nrect, prect);
|
||||
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* xglFillRect handles fall-back */
|
||||
xglFillRect (pDrawable, pGC, nrect, prect);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
xglPolyFillArc (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int narcs,
|
||||
xArc *pArcs)
|
||||
{
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
|
||||
(*pGC->ops->PolyFillArc) (pDrawable, pGC, narcs, pArcs);
|
||||
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
|
||||
}
|
||||
|
||||
void
|
||||
xglImageGlyphBlt (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int x,
|
||||
int y,
|
||||
unsigned int nglyph,
|
||||
CharInfoPtr *ppci,
|
||||
pointer pglyphBase)
|
||||
{
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
if (!pGCPriv->flags)
|
||||
{
|
||||
if (xglSolidGlyph (pDrawable,
|
||||
pGC,
|
||||
x,
|
||||
y,
|
||||
nglyph,
|
||||
ppci,
|
||||
pglyphBase))
|
||||
return;
|
||||
}
|
||||
|
||||
XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable);
|
||||
(*pGC->ops->ImageGlyphBlt) (pDrawable, pGC, x, y, nglyph, ppci,
|
||||
pglyphBase);
|
||||
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
|
||||
}
|
||||
|
||||
void
|
||||
xglPolyGlyphBlt (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int x,
|
||||
int y,
|
||||
unsigned int nglyph,
|
||||
CharInfoPtr *ppci,
|
||||
pointer pglyphBase)
|
||||
{
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
if (!pGCPriv->flags)
|
||||
{
|
||||
if (xglFillGlyph (pDrawable,
|
||||
pGC,
|
||||
x,
|
||||
y,
|
||||
nglyph,
|
||||
ppci,
|
||||
pglyphBase))
|
||||
return;
|
||||
}
|
||||
|
||||
XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
|
||||
(*pGC->ops->PolyGlyphBlt) (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
|
||||
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
|
||||
}
|
||||
|
||||
void
|
||||
xglPushPixels (GCPtr pGC,
|
||||
PixmapPtr pBitmap,
|
||||
DrawablePtr pDrawable,
|
||||
int w,
|
||||
int h,
|
||||
int x,
|
||||
int y)
|
||||
{
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
if (!xglSyncBits (&pBitmap->drawable, NullBox))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
|
||||
XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable);
|
||||
(*pGC->ops->PushPixels) (pGC, pBitmap, pDrawable, w, h, x, y);
|
||||
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
|
||||
}
|
||||
|
||||
Bool
|
||||
xglCreateGC (GCPtr pGC)
|
||||
{
|
||||
ScreenPtr pScreen = pGC->pScreen;
|
||||
Bool ret;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
XGL_SCREEN_UNWRAP (CreateGC);
|
||||
ret = (*pScreen->CreateGC) (pGC);
|
||||
XGL_SCREEN_WRAP (CreateGC, xglCreateGC);
|
||||
|
||||
XGL_GC_WRAP (funcs, (GCFuncs *) &xglGCFuncs);
|
||||
XGL_GC_WRAP (ops, (GCOps *) &xglGCOps);
|
||||
|
||||
pGCPriv->flags = 0;
|
||||
pGCPriv->op = GLITZ_OPERATOR_SRC;
|
||||
|
||||
pGCPriv->fg = NULL;
|
||||
pGCPriv->bg = NULL;
|
||||
pGCPriv->id = ~0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
xglDestroyGC (GCPtr pGC)
|
||||
{
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
if (pGCPriv->fg)
|
||||
glitz_surface_destroy (pGCPriv->fg);
|
||||
|
||||
if (pGCPriv->bg)
|
||||
glitz_surface_destroy (pGCPriv->bg);
|
||||
|
||||
XGL_GC_UNWRAP (funcs);
|
||||
XGL_GC_UNWRAP (ops);
|
||||
(*pGC->funcs->DestroyGC) (pGC);
|
||||
XGL_GC_WRAP (funcs, (GCFuncs *) &xglGCFuncs);
|
||||
XGL_GC_WRAP (ops, (GCOps *) &xglGCOps);
|
||||
}
|
||||
|
||||
void
|
||||
xglValidateGC (GCPtr pGC,
|
||||
unsigned long changes,
|
||||
DrawablePtr pDrawable)
|
||||
{
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
if (changes & GCTile)
|
||||
{
|
||||
if (!pGC->tileIsPixel &&
|
||||
FbEvenTile (pGC->tile.pixmap->drawable.width *
|
||||
pDrawable->bitsPerPixel))
|
||||
xglSyncBits (&pGC->tile.pixmap->drawable, NULL);
|
||||
}
|
||||
|
||||
if (changes & GCStipple)
|
||||
{
|
||||
if (pGC->stipple)
|
||||
xglSyncBits (&pGC->stipple->drawable, NULL);
|
||||
}
|
||||
|
||||
XGL_GC_UNWRAP (funcs);
|
||||
XGL_GC_UNWRAP (ops);
|
||||
(*pGC->funcs->ValidateGC) (pGC, changes, pDrawable);
|
||||
XGL_GC_WRAP (funcs, (GCFuncs *) &xglGCFuncs);
|
||||
XGL_GC_WRAP (ops, (GCOps *) &xglGCOps);
|
||||
|
||||
if (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS))
|
||||
{
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
|
||||
|
||||
if (pPixmapPriv->pVisual && pPixmapPriv->pVisual->format.surface)
|
||||
{
|
||||
glitz_format_t *format;
|
||||
|
||||
format = pPixmapPriv->pVisual->format.surface;
|
||||
if (format->id != pGCPriv->id)
|
||||
{
|
||||
XGL_SCREEN_PRIV (pDrawable->pScreen);
|
||||
|
||||
pGCPriv->flags |= xglGCSoftwareDrawableFlag;
|
||||
|
||||
if (pGCPriv->fg)
|
||||
glitz_surface_destroy (pGCPriv->fg);
|
||||
|
||||
pGCPriv->fg = glitz_surface_create (pScreenPriv->drawable,
|
||||
format, 1, 1, 0, NULL);
|
||||
if (pGCPriv->fg)
|
||||
glitz_surface_set_fill (pGCPriv->fg, GLITZ_FILL_REPEAT);
|
||||
|
||||
if (pGCPriv->bg)
|
||||
glitz_surface_destroy (pGCPriv->bg);
|
||||
|
||||
pGCPriv->bg = glitz_surface_create (pScreenPriv->drawable,
|
||||
format, 1, 1, 0, NULL);
|
||||
if (pGCPriv->bg)
|
||||
glitz_surface_set_fill (pGCPriv->bg, GLITZ_FILL_REPEAT);
|
||||
|
||||
pGCPriv->id = format->id;
|
||||
|
||||
if (pGCPriv->fg && pGCPriv->bg)
|
||||
{
|
||||
changes |= (GCForeground | GCBackground);
|
||||
pGCPriv->flags &= ~xglGCSoftwareDrawableFlag;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
pGCPriv->flags |= xglGCSoftwareDrawableFlag;
|
||||
}
|
||||
|
||||
if (changes & GCFunction)
|
||||
{
|
||||
switch (pGC->alu) {
|
||||
case GXclear:
|
||||
pGCPriv->op = GLITZ_OPERATOR_CLEAR;
|
||||
pGCPriv->flags &= ~xglGCBadFunctionFlag;
|
||||
break;
|
||||
case GXcopy:
|
||||
pGCPriv->op = GLITZ_OPERATOR_SRC;
|
||||
pGCPriv->flags &= ~xglGCBadFunctionFlag;
|
||||
break;
|
||||
case GXnoop:
|
||||
pGCPriv->op = GLITZ_OPERATOR_DST;
|
||||
pGCPriv->flags &= ~xglGCBadFunctionFlag;
|
||||
break;
|
||||
default:
|
||||
pGCPriv->flags |= xglGCBadFunctionFlag;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (changes & GCPlaneMask)
|
||||
{
|
||||
FbBits mask;
|
||||
|
||||
mask = FbFullMask (pDrawable->depth);
|
||||
|
||||
if ((pGC->planemask & mask) != mask)
|
||||
pGCPriv->flags |= xglGCPlaneMaskFlag;
|
||||
else
|
||||
pGCPriv->flags &= ~xglGCPlaneMaskFlag;
|
||||
}
|
||||
|
||||
if (!(pGCPriv->flags & xglGCSoftwareDrawableFlag))
|
||||
{
|
||||
if (changes & (GCForeground | GCBackground))
|
||||
{
|
||||
glitz_pixel_format_t format;
|
||||
glitz_buffer_t *buffer;
|
||||
CARD32 pixel;
|
||||
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
|
||||
|
||||
format.fourcc = GLITZ_FOURCC_RGB;
|
||||
format.masks = pPixmapPriv->pVisual->pPixel->masks;
|
||||
format.xoffset = 0;
|
||||
format.skip_lines = 0;
|
||||
format.bytes_per_line = sizeof (CARD32);
|
||||
format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP;
|
||||
|
||||
buffer = glitz_buffer_create_for_data (&pixel);
|
||||
|
||||
if (changes & GCForeground)
|
||||
{
|
||||
pixel = pGC->fgPixel;
|
||||
glitz_set_pixels (pGCPriv->fg, 0, 0, 1, 1, &format, buffer);
|
||||
}
|
||||
|
||||
if (changes & GCBackground)
|
||||
{
|
||||
pixel = pGC->bgPixel;
|
||||
glitz_set_pixels (pGCPriv->bg, 0, 0, 1, 1, &format, buffer);
|
||||
}
|
||||
|
||||
glitz_buffer_destroy (buffer);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,724 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* 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
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
#include <X11/fonts/fontstruct.h>
|
||||
#include "dixfontstr.h"
|
||||
|
||||
xglDataTypeInfoRec xglGeometryDataTypes[2] = {
|
||||
{ GLITZ_DATA_TYPE_SHORT, sizeof (glitz_short_t) },
|
||||
{ GLITZ_DATA_TYPE_FLOAT, sizeof (glitz_float_t) }
|
||||
};
|
||||
|
||||
glitz_buffer_hint_t usageTypes[] = {
|
||||
GLITZ_BUFFER_HINT_STREAM_DRAW,
|
||||
GLITZ_BUFFER_HINT_STATIC_DRAW,
|
||||
GLITZ_BUFFER_HINT_DYNAMIC_DRAW
|
||||
};
|
||||
|
||||
void
|
||||
xglGeometryResize (ScreenPtr pScreen,
|
||||
xglGeometryPtr pGeometry,
|
||||
int size)
|
||||
{
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
if (size == pGeometry->size)
|
||||
return;
|
||||
|
||||
if (pGeometry->broken)
|
||||
return;
|
||||
|
||||
if (pGeometry->usage == GEOMETRY_USAGE_SYSMEM)
|
||||
{
|
||||
pGeometry->data = xrealloc (pGeometry->data, size);
|
||||
|
||||
if (pGeometry->buffer)
|
||||
glitz_buffer_destroy (pGeometry->buffer);
|
||||
|
||||
pGeometry->buffer = NULL;
|
||||
|
||||
if (pGeometry->data)
|
||||
{
|
||||
pGeometry->buffer = glitz_buffer_create_for_data (pGeometry->data);
|
||||
if (!pGeometry->buffer)
|
||||
{
|
||||
pGeometry->broken = TRUE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (size)
|
||||
{
|
||||
pGeometry->broken = TRUE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
glitz_buffer_t *newBuffer;
|
||||
|
||||
if (size)
|
||||
{
|
||||
newBuffer =
|
||||
glitz_vertex_buffer_create (pScreenPriv->drawable, NULL, size,
|
||||
usageTypes[pGeometry->usage]);
|
||||
if (!newBuffer)
|
||||
{
|
||||
pGeometry->broken = TRUE;
|
||||
return;
|
||||
}
|
||||
} else
|
||||
newBuffer = NULL;
|
||||
|
||||
if (pGeometry->buffer && newBuffer)
|
||||
{
|
||||
void *oldData, *newData;
|
||||
|
||||
oldData = glitz_buffer_map (pGeometry->buffer,
|
||||
GLITZ_BUFFER_ACCESS_READ_ONLY);
|
||||
newData = glitz_buffer_map (newBuffer,
|
||||
GLITZ_BUFFER_ACCESS_WRITE_ONLY);
|
||||
|
||||
if (oldData && newData)
|
||||
memcpy (newData, oldData, MIN (size, pGeometry->size));
|
||||
|
||||
glitz_buffer_unmap (pGeometry->buffer);
|
||||
glitz_buffer_unmap (newBuffer);
|
||||
|
||||
glitz_buffer_destroy (pGeometry->buffer);
|
||||
}
|
||||
pGeometry->buffer = newBuffer;
|
||||
}
|
||||
|
||||
pGeometry->size = size;
|
||||
|
||||
if (pGeometry->endOffset > size)
|
||||
pGeometry->endOffset = size;
|
||||
}
|
||||
|
||||
#define MAP_GEOMETRY(pScreen, pGeometry, offset, units, ptr, _size) \
|
||||
if ((pGeometry)->broken) \
|
||||
return; \
|
||||
(_size) = (units) * xglGeometryDataTypes[(pGeometry)->dataType].size; \
|
||||
if (((pGeometry)->size - (offset)) < (_size)) \
|
||||
{ \
|
||||
xglGeometryResize (pScreen, pGeometry, \
|
||||
(pGeometry)->endOffset + (_size) + 500); \
|
||||
if ((pGeometry)->broken) \
|
||||
return; \
|
||||
} \
|
||||
(ptr) = glitz_buffer_map ((pGeometry)->buffer, \
|
||||
GLITZ_BUFFER_ACCESS_WRITE_ONLY); \
|
||||
if (!(ptr)) \
|
||||
{ \
|
||||
(pGeometry)->broken = TRUE; \
|
||||
return; \
|
||||
} \
|
||||
(ptr) += (offset)
|
||||
|
||||
#define UNMAP_GEOMETRY(pGeometry, offset, _size) \
|
||||
if (glitz_buffer_unmap ((pGeometry)->buffer)) \
|
||||
{ \
|
||||
(pGeometry)->broken = TRUE; \
|
||||
return; \
|
||||
} \
|
||||
if (((offset) + (_size)) > (pGeometry)->endOffset) \
|
||||
{ \
|
||||
(pGeometry)->endOffset = (offset) + (_size); \
|
||||
(pGeometry)->count = (pGeometry)->endOffset / \
|
||||
(2 * xglGeometryDataTypes[(pGeometry)->dataType].size); \
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds a number of boxes as GL_QUAD primitives
|
||||
*/
|
||||
void
|
||||
xglGeometryAddBox (ScreenPtr pScreen,
|
||||
xglGeometryPtr pGeometry,
|
||||
BoxPtr pBox,
|
||||
int nBox,
|
||||
int offset)
|
||||
{
|
||||
int size;
|
||||
char *ptr;
|
||||
|
||||
if (nBox < 1)
|
||||
return;
|
||||
|
||||
MAP_GEOMETRY (pScreen, pGeometry, offset, nBox * 8, ptr, size);
|
||||
|
||||
switch (pGeometry->dataType) {
|
||||
case GEOMETRY_DATA_TYPE_SHORT:
|
||||
{
|
||||
glitz_short_t *data = (glitz_short_t *) ptr;
|
||||
|
||||
while (nBox--)
|
||||
{
|
||||
*data++ = (glitz_short_t) pBox->x1;
|
||||
*data++ = (glitz_short_t) pBox->y1;
|
||||
*data++ = (glitz_short_t) pBox->x2;
|
||||
*data++ = (glitz_short_t) pBox->y1;
|
||||
*data++ = (glitz_short_t) pBox->x2;
|
||||
*data++ = (glitz_short_t) pBox->y2;
|
||||
*data++ = (glitz_short_t) pBox->x1;
|
||||
*data++ = (glitz_short_t) pBox->y2;
|
||||
|
||||
pBox++;
|
||||
}
|
||||
} break;
|
||||
case GEOMETRY_DATA_TYPE_FLOAT:
|
||||
{
|
||||
glitz_float_t *data = (glitz_float_t *) ptr;
|
||||
|
||||
while (nBox--)
|
||||
{
|
||||
*data++ = (glitz_float_t) pBox->x1;
|
||||
*data++ = (glitz_float_t) pBox->y1;
|
||||
*data++ = (glitz_float_t) pBox->x2;
|
||||
*data++ = (glitz_float_t) pBox->y1;
|
||||
*data++ = (glitz_float_t) pBox->x2;
|
||||
*data++ = (glitz_float_t) pBox->y2;
|
||||
*data++ = (glitz_float_t) pBox->x1;
|
||||
*data++ = (glitz_float_t) pBox->y2;
|
||||
|
||||
pBox++;
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
||||
UNMAP_GEOMETRY (pGeometry, offset, size);
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds a number of spans as GL_LINE primitives
|
||||
*/
|
||||
void
|
||||
xglGeometryAddSpan (ScreenPtr pScreen,
|
||||
xglGeometryPtr pGeometry,
|
||||
DDXPointPtr ppt,
|
||||
int *pwidth,
|
||||
int n,
|
||||
int offset)
|
||||
{
|
||||
int size;
|
||||
char *ptr;
|
||||
|
||||
if (n < 1)
|
||||
return;
|
||||
|
||||
MAP_GEOMETRY (pScreen, pGeometry, offset, n * 4, ptr, size);
|
||||
|
||||
switch (pGeometry->dataType) {
|
||||
case GEOMETRY_DATA_TYPE_SHORT:
|
||||
{
|
||||
glitz_short_t *data = (glitz_short_t *) ptr;
|
||||
|
||||
while (n--)
|
||||
{
|
||||
*data++ = (glitz_short_t) ppt->x;
|
||||
*data++ = (glitz_short_t) ppt->y;
|
||||
*data++ = (glitz_short_t) (ppt->x + *pwidth);
|
||||
*data++ = (glitz_short_t) ppt->y;
|
||||
|
||||
ppt++;
|
||||
pwidth++;
|
||||
}
|
||||
} break;
|
||||
case GEOMETRY_DATA_TYPE_FLOAT:
|
||||
{
|
||||
glitz_float_t *data = (glitz_float_t *) ptr;
|
||||
|
||||
while (n--)
|
||||
{
|
||||
*data++ = (glitz_float_t) ppt->x;
|
||||
*data++ = (glitz_float_t) ppt->y;
|
||||
*data++ = (glitz_float_t) (ppt->x + *pwidth);
|
||||
*data++ = (glitz_float_t) ppt->y;
|
||||
|
||||
ppt++;
|
||||
pwidth++;
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
||||
UNMAP_GEOMETRY (pGeometry, offset, size);
|
||||
}
|
||||
|
||||
/*
|
||||
* This macro is needed for end pixels to be rasterized correctly using
|
||||
* OpenGL as OpenGL line segments are half-opened.
|
||||
*/
|
||||
#define ADJUST_END_POINT(start, end, isPoint) \
|
||||
(((end) > (start)) ? (end) + 1: \
|
||||
((end) < (start)) ? (end) - 1: \
|
||||
(isPoint) ? (end) + 1: \
|
||||
(end))
|
||||
|
||||
/*
|
||||
* Adds a number of connected lines as GL_LINE_STRIP primitives
|
||||
*/
|
||||
void
|
||||
xglGeometryAddLine (ScreenPtr pScreen,
|
||||
xglGeometryPtr pGeometry,
|
||||
int loop,
|
||||
int mode,
|
||||
int npt,
|
||||
DDXPointPtr ppt,
|
||||
int offset)
|
||||
{
|
||||
DDXPointRec pt;
|
||||
int size;
|
||||
char *ptr;
|
||||
|
||||
if (npt < 2)
|
||||
return;
|
||||
|
||||
MAP_GEOMETRY (pScreen, pGeometry, offset, npt * 2, ptr, size);
|
||||
|
||||
pt.x = 0;
|
||||
pt.y = 0;
|
||||
|
||||
switch (pGeometry->dataType) {
|
||||
case GEOMETRY_DATA_TYPE_SHORT:
|
||||
{
|
||||
glitz_short_t *data = (glitz_short_t *) ptr;
|
||||
|
||||
while (npt--)
|
||||
{
|
||||
if (mode == CoordModePrevious)
|
||||
{
|
||||
pt.x += ppt->x;
|
||||
pt.y += ppt->y;
|
||||
}
|
||||
else
|
||||
{
|
||||
pt.x = ppt->x;
|
||||
pt.y = ppt->y;
|
||||
}
|
||||
|
||||
if (npt || loop)
|
||||
{
|
||||
*data++ = (glitz_short_t) pt.x;
|
||||
*data++ = (glitz_short_t) pt.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
ppt--;
|
||||
*data++ = (glitz_short_t)
|
||||
ADJUST_END_POINT (ppt->x, pt.x, ppt->y == pt.y);
|
||||
*data++ = (glitz_short_t) ADJUST_END_POINT (ppt->y, pt.y, 0);
|
||||
}
|
||||
|
||||
ppt++;
|
||||
}
|
||||
} break;
|
||||
case GEOMETRY_DATA_TYPE_FLOAT:
|
||||
{
|
||||
glitz_float_t *data = (glitz_float_t *) ptr;
|
||||
|
||||
while (npt--)
|
||||
{
|
||||
if (mode == CoordModePrevious)
|
||||
{
|
||||
pt.x += ppt->x;
|
||||
pt.y += ppt->y;
|
||||
}
|
||||
else
|
||||
{
|
||||
pt.x = ppt->x;
|
||||
pt.y = ppt->y;
|
||||
}
|
||||
|
||||
if (npt || loop)
|
||||
{
|
||||
*data++ = (glitz_float_t) pt.x;
|
||||
*data++ = (glitz_float_t) pt.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
ppt--;
|
||||
*data++ = (glitz_float_t)
|
||||
ADJUST_END_POINT (ppt->x, pt.x, ppt->y == pt.y);
|
||||
*data++ = (glitz_float_t) ADJUST_END_POINT (ppt->y, pt.y, 0);
|
||||
}
|
||||
|
||||
ppt++;
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
||||
UNMAP_GEOMETRY (pGeometry, offset, size);
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds a number of line segments as GL_LINE primitives
|
||||
*/
|
||||
void
|
||||
xglGeometryAddSegment (ScreenPtr pScreen,
|
||||
xglGeometryPtr pGeometry,
|
||||
int nsegInit,
|
||||
xSegment *pSegInit,
|
||||
int offset)
|
||||
{
|
||||
int size;
|
||||
char *ptr;
|
||||
|
||||
if (nsegInit < 1)
|
||||
return;
|
||||
|
||||
MAP_GEOMETRY (pScreen, pGeometry, offset, nsegInit * 4, ptr, size);
|
||||
|
||||
switch (pGeometry->dataType) {
|
||||
case GEOMETRY_DATA_TYPE_SHORT:
|
||||
{
|
||||
glitz_short_t *data = (glitz_short_t *) ptr;
|
||||
|
||||
while (nsegInit--)
|
||||
{
|
||||
*data++ = (glitz_short_t) pSegInit->x1;
|
||||
*data++ = (glitz_short_t) pSegInit->y1;
|
||||
*data++ = (glitz_short_t)
|
||||
ADJUST_END_POINT (pSegInit->x1, pSegInit->x2,
|
||||
pSegInit->y1 == pSegInit->y2);
|
||||
*data++ = (glitz_short_t)
|
||||
ADJUST_END_POINT (pSegInit->y1, pSegInit->y2, 0);
|
||||
|
||||
pSegInit++;
|
||||
}
|
||||
} break;
|
||||
case GEOMETRY_DATA_TYPE_FLOAT:
|
||||
{
|
||||
glitz_float_t *data = (glitz_float_t *) ptr;
|
||||
|
||||
while (nsegInit--)
|
||||
{
|
||||
*data++ = (glitz_float_t) pSegInit->x1;
|
||||
*data++ = (glitz_float_t) pSegInit->y1;
|
||||
*data++ = (glitz_float_t)
|
||||
ADJUST_END_POINT (pSegInit->x1, pSegInit->x2,
|
||||
pSegInit->y1 == pSegInit->y2);
|
||||
*data++ = (glitz_float_t)
|
||||
ADJUST_END_POINT (pSegInit->y1, pSegInit->y2, 0);
|
||||
|
||||
pSegInit++;
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
||||
UNMAP_GEOMETRY (pGeometry, offset, size);
|
||||
}
|
||||
|
||||
void
|
||||
xglGeometryForGlyph (ScreenPtr pScreen,
|
||||
xglGeometryPtr pGeometry,
|
||||
unsigned int nGlyph,
|
||||
CharInfoPtr *ppciInit,
|
||||
pointer pglyphBase)
|
||||
{
|
||||
CharInfoPtr *ppci;
|
||||
CharInfoPtr pci;
|
||||
unsigned char *glyphbase = (pointer) ~0;
|
||||
unsigned char *pglyph;
|
||||
int x = 0;
|
||||
int gx, gy;
|
||||
int gWidth, gHeight;
|
||||
int n, lastX = 0, lastY = 0;
|
||||
glitz_multi_array_t *array;
|
||||
glitz_buffer_t *buffer;
|
||||
|
||||
ppci = ppciInit;
|
||||
n = nGlyph;
|
||||
|
||||
while (n--)
|
||||
{
|
||||
pglyph = FONTGLYPHBITS (pglyphBase, *ppci++);
|
||||
if (pglyph < glyphbase)
|
||||
glyphbase = pglyph;
|
||||
}
|
||||
|
||||
buffer = glitz_buffer_create_for_data (glyphbase);
|
||||
if (!buffer)
|
||||
{
|
||||
pGeometry->broken = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
GEOMETRY_SET_BUFFER (pGeometry, buffer);
|
||||
|
||||
array = glitz_multi_array_create (nGlyph);
|
||||
if (!array)
|
||||
{
|
||||
pGeometry->broken = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
GEOMETRY_SET_MULTI_ARRAY (pGeometry, array);
|
||||
|
||||
ppci = ppciInit;
|
||||
while (nGlyph--)
|
||||
{
|
||||
pci = *ppci++;
|
||||
pglyph = FONTGLYPHBITS (pglyphBase, pci);
|
||||
gWidth = GLYPHWIDTHPIXELS (pci);
|
||||
gHeight = GLYPHHEIGHTPIXELS (pci);
|
||||
|
||||
if (gWidth && gHeight)
|
||||
{
|
||||
gx = x + pci->metrics.leftSideBearing;
|
||||
gy = -pci->metrics.ascent;
|
||||
|
||||
glitz_multi_array_add (array,
|
||||
(pglyph - glyphbase) * 8,
|
||||
gWidth, gHeight,
|
||||
(gx - lastX) << 16, (gy - lastY) << 16);
|
||||
lastX = gx;
|
||||
lastY = gy;
|
||||
}
|
||||
x += pci->metrics.characterWidth;
|
||||
}
|
||||
|
||||
glitz_buffer_destroy (buffer);
|
||||
glitz_multi_array_destroy (array);
|
||||
}
|
||||
|
||||
#define FIXED_LINE_X_TO_FLOAT(line, v) \
|
||||
(((glitz_float_t) \
|
||||
((line).p1.x + (xFixed_16_16) \
|
||||
(((xFixed_32_32) ((v) - (line).p1.y) * \
|
||||
((line).p2.x - (line).p1.x)) / \
|
||||
((line).p2.y - (line).p1.y)))) / 65536)
|
||||
|
||||
#define FIXED_LINE_X_CEIL_TO_FLOAT(line, v) \
|
||||
(((glitz_float_t) \
|
||||
((line).p1.x + (xFixed_16_16) \
|
||||
(((((line).p2.y - (line).p1.y) - 1) + \
|
||||
((xFixed_32_32) ((v) - (line).p1.y) * \
|
||||
((line).p2.x - (line).p1.x))) / \
|
||||
((line).p2.y - (line).p1.y)))) / 65536)
|
||||
|
||||
/*
|
||||
* Adds a number of trapezoids as GL_QUAD primitives
|
||||
*/
|
||||
void
|
||||
xglGeometryAddTrapezoid (ScreenPtr pScreen,
|
||||
xglGeometryPtr pGeometry,
|
||||
xTrapezoid *pTrap,
|
||||
int nTrap,
|
||||
int offset)
|
||||
{
|
||||
int size;
|
||||
char *ptr;
|
||||
|
||||
if (nTrap < 1)
|
||||
return;
|
||||
|
||||
MAP_GEOMETRY (pScreen, pGeometry, offset, nTrap * 8, ptr, size);
|
||||
|
||||
switch (pGeometry->dataType) {
|
||||
case GEOMETRY_DATA_TYPE_SHORT:
|
||||
/* not supported */
|
||||
pGeometry->broken = TRUE;
|
||||
break;
|
||||
case GEOMETRY_DATA_TYPE_FLOAT:
|
||||
{
|
||||
glitz_float_t *data = (glitz_float_t *) ptr;
|
||||
glitz_float_t top, bottom;
|
||||
|
||||
while (nTrap--)
|
||||
{
|
||||
top = FIXED_TO_FLOAT (pTrap->top);
|
||||
bottom = FIXED_TO_FLOAT (pTrap->bottom);
|
||||
|
||||
*data++ = FIXED_LINE_X_TO_FLOAT (pTrap->left, pTrap->top);
|
||||
*data++ = top;
|
||||
*data++ = FIXED_LINE_X_CEIL_TO_FLOAT (pTrap->right, pTrap->top);
|
||||
*data++ = top;
|
||||
*data++ = FIXED_LINE_X_CEIL_TO_FLOAT (pTrap->right, pTrap->bottom);
|
||||
*data++ = bottom;
|
||||
*data++ = FIXED_LINE_X_TO_FLOAT (pTrap->left, pTrap->bottom);
|
||||
*data++ = bottom;
|
||||
|
||||
pTrap++;
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
||||
UNMAP_GEOMETRY (pGeometry, offset, size);
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds a number of traps as GL_QUAD primitives
|
||||
*/
|
||||
void
|
||||
xglGeometryAddTrap (ScreenPtr pScreen,
|
||||
xglGeometryPtr pGeometry,
|
||||
xTrap *pTrap,
|
||||
int nTrap,
|
||||
int offset)
|
||||
{
|
||||
int size;
|
||||
char *ptr;
|
||||
|
||||
if (nTrap < 1)
|
||||
return;
|
||||
|
||||
MAP_GEOMETRY (pScreen, pGeometry, offset, nTrap * 8, ptr, size);
|
||||
|
||||
switch (pGeometry->dataType) {
|
||||
case GEOMETRY_DATA_TYPE_SHORT:
|
||||
/* not supported */
|
||||
pGeometry->broken = TRUE;
|
||||
break;
|
||||
case GEOMETRY_DATA_TYPE_FLOAT:
|
||||
{
|
||||
glitz_float_t *data = (glitz_float_t *) ptr;
|
||||
glitz_float_t top, bottom;
|
||||
|
||||
while (nTrap--)
|
||||
{
|
||||
top = FIXED_TO_FLOAT (pTrap->top.y);
|
||||
bottom = FIXED_TO_FLOAT (pTrap->bot.y);
|
||||
|
||||
*data++ = FIXED_TO_FLOAT (pTrap->top.l);
|
||||
*data++ = top;
|
||||
*data++ = FIXED_TO_FLOAT (pTrap->top.r);
|
||||
*data++ = top;
|
||||
*data++ = FIXED_TO_FLOAT (pTrap->bot.r);
|
||||
*data++ = bottom;
|
||||
*data++ = FIXED_TO_FLOAT (pTrap->bot.l);
|
||||
*data++ = bottom;
|
||||
|
||||
pTrap++;
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
||||
UNMAP_GEOMETRY (pGeometry, offset, size);
|
||||
}
|
||||
|
||||
/* XXX: scratch geometry size never shrinks, it just gets larger when
|
||||
required. this is not acceptable. */
|
||||
xglGeometryPtr
|
||||
xglGetScratchGeometryWithSize (ScreenPtr pScreen,
|
||||
int size)
|
||||
{
|
||||
xglGeometryPtr pGeometry;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
pGeometry = &pScreenPriv->scratchGeometry;
|
||||
|
||||
if (pGeometry->broken || pGeometry->size < size)
|
||||
{
|
||||
GEOMETRY_UNINIT (pGeometry);
|
||||
GEOMETRY_INIT (pScreen, pGeometry, pGeometry->type,
|
||||
pScreenPriv->geometryUsage, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pGeometry->array)
|
||||
{
|
||||
glitz_multi_array_destroy (pGeometry->array);
|
||||
pGeometry->array = NULL;
|
||||
}
|
||||
pGeometry->endOffset = 0;
|
||||
pGeometry->xOff = 0;
|
||||
pGeometry->yOff = 0;
|
||||
pGeometry->first = 0;
|
||||
pGeometry->count = 0;
|
||||
pGeometry->width = 2;
|
||||
}
|
||||
|
||||
return pGeometry;
|
||||
}
|
||||
|
||||
xglGeometryPtr
|
||||
xglGetScratchVertexGeometryWithType (ScreenPtr pScreen,
|
||||
int type,
|
||||
int count)
|
||||
{
|
||||
xglGeometryPtr pGeometry;
|
||||
int stride;
|
||||
|
||||
stride = 2 * xglGeometryDataTypes[type].size;
|
||||
|
||||
pGeometry = xglGetScratchGeometryWithSize (pScreen, count * stride);
|
||||
|
||||
pGeometry->type = GLITZ_GEOMETRY_TYPE_VERTEX;
|
||||
pGeometry->dataType = type;
|
||||
|
||||
pGeometry->f.vertex.primitive = GLITZ_PRIMITIVE_QUADS;
|
||||
pGeometry->f.vertex.type = xglGeometryDataTypes[type].type;
|
||||
pGeometry->f.vertex.bytes_per_vertex = stride;
|
||||
pGeometry->f.vertex.attributes = 0;
|
||||
|
||||
return pGeometry;
|
||||
}
|
||||
|
||||
xglGeometryPtr
|
||||
xglGetScratchVertexGeometry (ScreenPtr pScreen,
|
||||
int count)
|
||||
{
|
||||
xglGeometryPtr pGeometry;
|
||||
int type, stride;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
type = pScreenPriv->geometryDataType;
|
||||
stride = 2 * xglGeometryDataTypes[type].size;
|
||||
|
||||
pGeometry = xglGetScratchGeometryWithSize (pScreen, count * stride);
|
||||
|
||||
pGeometry->type = GLITZ_GEOMETRY_TYPE_VERTEX;
|
||||
pGeometry->dataType = type;
|
||||
|
||||
pGeometry->f.vertex.primitive = GLITZ_PRIMITIVE_QUADS;
|
||||
pGeometry->f.vertex.type = xglGeometryDataTypes[type].type;
|
||||
pGeometry->f.vertex.bytes_per_vertex = stride;
|
||||
pGeometry->f.vertex.attributes = 0;
|
||||
|
||||
return pGeometry;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglSetGeometry (xglGeometryPtr pGeometry,
|
||||
glitz_surface_t *surface)
|
||||
{
|
||||
if (pGeometry->broken)
|
||||
return FALSE;
|
||||
|
||||
glitz_set_geometry (surface, pGeometry->type, &pGeometry->f,
|
||||
pGeometry->buffer);
|
||||
|
||||
if (pGeometry->array)
|
||||
glitz_set_multi_array (surface, pGeometry->array,
|
||||
pGeometry->xOff, pGeometry->yOff);
|
||||
else
|
||||
glitz_set_array (surface,
|
||||
pGeometry->first, pGeometry->width, pGeometry->count,
|
||||
pGeometry->xOff, pGeometry->yOff);
|
||||
|
||||
return TRUE;
|
||||
}
|
|
@ -1,88 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* 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
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
|
||||
void
|
||||
xglGetImage (DrawablePtr pDrawable,
|
||||
int x,
|
||||
int y,
|
||||
int w,
|
||||
int h,
|
||||
unsigned int format,
|
||||
unsigned long planeMask,
|
||||
char *d)
|
||||
{
|
||||
ScreenPtr pScreen = pDrawable->pScreen;
|
||||
glitz_surface_t *surface;
|
||||
int xOff, yOff;
|
||||
BoxRec box;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
/* Many apps use GetImage to sync with the visible frame buffer */
|
||||
if (pDrawable->type == DRAWABLE_WINDOW)
|
||||
{
|
||||
if (!xglSyncSurface (&pScreenPriv->pScreenPixmap->drawable))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
|
||||
glitz_surface_flush (pScreenPriv->surface);
|
||||
glitz_drawable_finish (pScreenPriv->drawable);
|
||||
}
|
||||
|
||||
XGL_GET_DRAWABLE (pDrawable, surface, xOff, yOff);
|
||||
|
||||
box.x1 = pDrawable->x + xOff + x;
|
||||
box.y1 = pDrawable->y + yOff + y;
|
||||
box.x2 = box.x1 + w;
|
||||
box.y2 = box.y1 + h;
|
||||
|
||||
if (!xglSyncBits (pDrawable, &box))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
|
||||
XGL_SCREEN_UNWRAP (GetImage);
|
||||
(*pScreen->GetImage) (pDrawable, x, y, w, h, format, planeMask, d);
|
||||
XGL_SCREEN_WRAP (GetImage, xglGetImage);
|
||||
}
|
||||
|
||||
void
|
||||
xglGetSpans (DrawablePtr pDrawable,
|
||||
int wMax,
|
||||
DDXPointPtr ppt,
|
||||
int *pwidth,
|
||||
int nspans,
|
||||
char *pchardstStart)
|
||||
{
|
||||
ScreenPtr pScreen = pDrawable->pScreen;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
if (!xglSyncBits (pDrawable, NullBox))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
|
||||
XGL_SCREEN_UNWRAP (GetSpans);
|
||||
(*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pchardstStart);
|
||||
XGL_SCREEN_WRAP (GetSpans, xglGetSpans);
|
||||
}
|
260
hw/xgl/xglglx.c
260
hw/xgl/xglglx.c
|
@ -1,260 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2005 Novell, Inc.
|
||||
*
|
||||
* 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
|
||||
* Novell, Inc. not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* Novell, Inc. makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL NOVELL, INC. 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include "xglglx.h"
|
||||
|
||||
#ifdef GLXEXT
|
||||
|
||||
#ifdef XGL_MODULAR
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
xglGLXFuncRec __xglGLXFunc;
|
||||
|
||||
#ifndef NGLXEXTLOG
|
||||
FILE *__xglGLXLogFp;
|
||||
#endif
|
||||
|
||||
static void *glXHandle = 0;
|
||||
static void *glCoreHandle = 0;
|
||||
|
||||
#define SYM(ptr, name) { (void **) &(ptr), (name) }
|
||||
|
||||
__GLXextensionInfo *__xglExtensionInfo;
|
||||
__GLXscreenInfo *__xglScreenInfoPtr;
|
||||
|
||||
void
|
||||
GlxSetVisualConfigs (int nconfigs,
|
||||
__GLXvisualConfig *configs,
|
||||
void **privates)
|
||||
{
|
||||
if (glXHandle && glCoreHandle)
|
||||
(*__xglGLXFunc.setVisualConfigs) (nconfigs, configs, privates);
|
||||
}
|
||||
|
||||
void
|
||||
GlxExtensionInit (void)
|
||||
{
|
||||
if (glXHandle && glCoreHandle)
|
||||
(*__xglGLXFunc.extensionInit) ();
|
||||
}
|
||||
|
||||
void
|
||||
GlxWrapInitVisuals (miInitVisualsProcPtr *initVisuals)
|
||||
{
|
||||
if (glXHandle && glCoreHandle)
|
||||
(*__xglGLXFunc.wrapInitVisuals) (initVisuals);
|
||||
}
|
||||
|
||||
int
|
||||
GlxInitVisuals (VisualPtr *visualp,
|
||||
DepthPtr *depthp,
|
||||
int *nvisualp,
|
||||
int *ndepthp,
|
||||
int *rootDepthp,
|
||||
VisualID *defaultVisp,
|
||||
unsigned long sizes,
|
||||
int bitsPerRGB,
|
||||
int preferredVis)
|
||||
{
|
||||
if (glXHandle && glCoreHandle)
|
||||
return (*__xglGLXFunc.initVisuals) (visualp, depthp, nvisualp, ndepthp,
|
||||
rootDepthp, defaultVisp, sizes,
|
||||
bitsPerRGB, preferredVis);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
GlxFlushContextCache (void)
|
||||
{
|
||||
(*__xglGLXFunc.flushContextCache) ();
|
||||
}
|
||||
|
||||
void
|
||||
GlxSetRenderTables (struct _glapi_table *table)
|
||||
{
|
||||
(*__xglGLXFunc.setRenderTables) (table);
|
||||
}
|
||||
|
||||
struct _glapi_table *_mglapi_Dispatch;
|
||||
|
||||
void *(*__glcore_DDXScreenInfo)(void);
|
||||
|
||||
void *__glXglDDXScreenInfo(void)
|
||||
{
|
||||
return __xglScreenInfoPtr;
|
||||
}
|
||||
|
||||
void *(*__glcore_DDXExtensionInfo)(void);
|
||||
|
||||
void *__glXglDDXExtensionInfo(void)
|
||||
{
|
||||
return __xglExtensionInfo;
|
||||
}
|
||||
|
||||
void _gl_copy_visual_to_context_mode( __GLcontextModes * mode,
|
||||
const __GLXvisualConfig * config )
|
||||
{
|
||||
(*__xglGLXFunc.copy_visual_to_context_mode)(mode, config);
|
||||
}
|
||||
|
||||
__GLcontextModes *_gl_context_modes_create( unsigned count, size_t minimum_size )
|
||||
{
|
||||
return (*__xglGLXFunc.context_modes_create)(count, minimum_size);
|
||||
}
|
||||
|
||||
void _gl_context_modes_destroy( __GLcontextModes * modes )
|
||||
{
|
||||
(*__xglGLXFunc.context_modes_destroy)(modes);
|
||||
}
|
||||
|
||||
GLint _gl_convert_from_x_visual_type( int visualType )
|
||||
{
|
||||
return (*__xglGLXFunc.convert_from_x_visual_type)(visualType);
|
||||
}
|
||||
|
||||
GLint _gl_convert_to_x_visual_type( int visualType )
|
||||
{
|
||||
return (*__xglGLXFunc.convert_to_x_visual_type)(visualType);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Bool
|
||||
xglLoadGLXModules (void)
|
||||
{
|
||||
|
||||
#ifdef XGL_MODULAR
|
||||
if (!glXHandle)
|
||||
{
|
||||
xglSymbolRec sym[] = {
|
||||
SYM (__xglGLXFunc.extensionInit, "GlxExtensionInit"),
|
||||
SYM (__xglGLXFunc.setVisualConfigs, "GlxSetVisualConfigs"),
|
||||
SYM (__xglGLXFunc.wrapInitVisuals, "GlxWrapInitVisuals"),
|
||||
SYM (__xglGLXFunc.initVisuals, "GlxInitVisuals"),
|
||||
SYM (__xglGLXFunc.flushContextCache, "__glXFlushContextCache"),
|
||||
SYM (__xglGLXFunc.setRenderTables, "GlxSetRenderTables"),
|
||||
SYM (__xglGLXFunc.copy_visual_to_context_mode, "_gl_copy_visual_to_context_mode"),
|
||||
SYM (__xglGLXFunc.context_modes_create, "_gl_context_modes_create"),
|
||||
SYM (__xglGLXFunc.context_modes_destroy, "_gl_context_modes_destroy"),
|
||||
SYM (__xglGLXFunc.convert_from_x_visual_type, "_gl_convert_from_x_visual_type"),
|
||||
SYM (__xglGLXFunc.convert_to_x_visual_type, "_gl_convert_to_x_visual_type"),
|
||||
};
|
||||
|
||||
glXHandle = xglLoadModule ("glx", RTLD_NOW | RTLD_LOCAL);
|
||||
if (!glXHandle)
|
||||
return FALSE;
|
||||
|
||||
if (!xglLookupSymbols (glXHandle, sym, sizeof (sym) / sizeof (sym[0])))
|
||||
{
|
||||
xglUnloadModule (glXHandle);
|
||||
glXHandle = 0;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!glCoreHandle)
|
||||
{
|
||||
xglSymbolRec ddxsym[] = {
|
||||
SYM (__glcore_DDXExtensionInfo, "__glXglDDXExtensionInfo"),
|
||||
SYM (__glcore_DDXScreenInfo, "__glXglDDXScreenInfo")
|
||||
};
|
||||
|
||||
glCoreHandle = xglLoadModule ("glcore", RTLD_NOW | RTLD_LOCAL);
|
||||
if (!glCoreHandle)
|
||||
return FALSE;
|
||||
|
||||
if (!xglLookupSymbols (glCoreHandle, ddxsym,
|
||||
sizeof (ddxsym) / sizeof(ddxsym[0])))
|
||||
{
|
||||
xglUnloadModule (glCoreHandle);
|
||||
glCoreHandle = 0;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
__xglScreenInfoPtr = __glcore_DDXScreenInfo();
|
||||
__xglExtensionInfo = __glcore_DDXExtensionInfo();
|
||||
{
|
||||
xglSymbolRec sym[] = {
|
||||
SYM (__xglScreenInfoPtr->screenProbe, "__MESA_screenProbe"),
|
||||
SYM (__xglScreenInfoPtr->createContext, "__MESA_createContext"),
|
||||
SYM (__xglScreenInfoPtr->createBuffer, "__MESA_createBuffer"),
|
||||
SYM (__xglExtensionInfo->resetExtension,
|
||||
"__MESA_resetExtension"),
|
||||
SYM (__xglExtensionInfo->initVisuals, "__MESA_initVisuals"),
|
||||
SYM (__xglExtensionInfo->setVisualConfigs,
|
||||
"__MESA_setVisualConfigs"),
|
||||
|
||||
};
|
||||
|
||||
|
||||
if (!xglLookupSymbols (glCoreHandle, sym,
|
||||
sizeof (sym) / sizeof (sym[0])))
|
||||
{
|
||||
xglUnloadModule (glCoreHandle);
|
||||
glCoreHandle = 0;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!xglLoadHashFuncs (glCoreHandle))
|
||||
{
|
||||
xglUnloadModule (glCoreHandle);
|
||||
glCoreHandle = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
#else
|
||||
return FALSE;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
xglUnloadGLXModules (void)
|
||||
{
|
||||
|
||||
#ifdef XGL_MODULAR
|
||||
if (glXHandle)
|
||||
{
|
||||
xglUnloadModule (glXHandle);
|
||||
glXHandle = 0;
|
||||
}
|
||||
|
||||
if (glCoreHandle)
|
||||
{
|
||||
xglUnloadModule (glCoreHandle);
|
||||
glCoreHandle = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,79 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2005 Novell, Inc.
|
||||
*
|
||||
* 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
|
||||
* Novell, Inc. not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* Novell, Inc. makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL NOVELL, INC. 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
|
||||
#ifdef GLXEXT
|
||||
|
||||
#include "glxserver.h"
|
||||
#include "glxscreens.h"
|
||||
#include "glxext.h"
|
||||
#include "glapitable.h"
|
||||
|
||||
|
||||
typedef struct _xglGLXFunc {
|
||||
void (*extensionInit) (void);
|
||||
void (*setVisualConfigs) (int nconfigs,
|
||||
__GLXvisualConfig *configs,
|
||||
void **privates);
|
||||
void (*wrapInitVisuals) (miInitVisualsProcPtr *initVisuals);
|
||||
int (*initVisuals) (VisualPtr *visualp,
|
||||
DepthPtr *depthp,
|
||||
int *nvisualp,
|
||||
int *ndepthp,
|
||||
int *rootDepthp,
|
||||
VisualID *defaultVisp,
|
||||
unsigned long sizes,
|
||||
int bitsPerRGB,
|
||||
int preferredVis);
|
||||
|
||||
void (*flushContextCache) (void);
|
||||
void *(*DDXExtensionInfo) (void);
|
||||
void *(*DDXScreenInfo) (void);
|
||||
void (*setRenderTables) (struct _glapi_table *table);
|
||||
void (*copy_visual_to_context_mode)( __GLcontextModes *mode, const __GLXvisualConfig *config );
|
||||
__GLcontextModes *(*context_modes_create)( unsigned count, size_t minimum_size );
|
||||
void (*context_modes_destroy)( __GLcontextModes * modes );
|
||||
GLint (*convert_from_x_visual_type)( int visualType );
|
||||
GLint (*convert_to_x_visual_type)( int visualType );
|
||||
} xglGLXFuncRec, *xglGLXFuncPtr;
|
||||
|
||||
extern xglGLXFuncRec __xglGLXFunc;
|
||||
|
||||
#ifndef NGLXEXTLOG
|
||||
|
||||
extern FILE *__xglGLXLogFp;
|
||||
|
||||
#endif
|
||||
|
||||
/* xglglx.c */
|
||||
|
||||
Bool
|
||||
xglLoadGLXModules (void);
|
||||
|
||||
void
|
||||
xglUnloadGLXModules (void);
|
||||
|
||||
#endif
|
1170
hw/xgl/xglglyph.c
1170
hw/xgl/xglglyph.c
File diff suppressed because it is too large
Load Diff
134
hw/xgl/xglhash.c
134
hw/xgl/xglhash.c
|
@ -1,134 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2005 Novell, Inc.
|
||||
*
|
||||
* 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
|
||||
* Novell, Inc. not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* Novell, Inc. makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL NOVELL, INC. 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
|
||||
#define SYM(ptr, name) { (void **) &(ptr), (name) }
|
||||
|
||||
typedef struct _xglHashFunc {
|
||||
xglHashTablePtr (*NewHashTable) (void);
|
||||
void (*DeleteHashTable) (xglHashTablePtr pTable);
|
||||
void *(*HashLookup) (const xglHashTablePtr pTable,
|
||||
unsigned int key);
|
||||
void (*HashInsert) (xglHashTablePtr pTable,
|
||||
unsigned int key,
|
||||
void *data);
|
||||
void (*HashRemove) (xglHashTablePtr pTable,
|
||||
unsigned int key);
|
||||
unsigned int (*HashFirstEntry) (xglHashTablePtr pTable);
|
||||
unsigned int (*HashNextEntry) (const xglHashTablePtr pTable,
|
||||
unsigned int key);
|
||||
unsigned int (*HashFindFreeKeyBlock) (xglHashTablePtr pTable,
|
||||
unsigned int numKeys);
|
||||
} xglHashFuncRec;
|
||||
|
||||
static xglHashFuncRec __hashFunc;
|
||||
|
||||
static void *hashHandle = 0;
|
||||
|
||||
Bool
|
||||
xglLoadHashFuncs (void *handle)
|
||||
{
|
||||
|
||||
#ifdef XGL_MODULAR
|
||||
xglSymbolRec sym[] = {
|
||||
SYM (__hashFunc.NewHashTable, "_mesa_NewHashTable"),
|
||||
SYM (__hashFunc.DeleteHashTable, "_mesa_DeleteHashTable"),
|
||||
SYM (__hashFunc.HashLookup, "_mesa_HashLookup"),
|
||||
SYM (__hashFunc.HashInsert, "_mesa_HashInsert"),
|
||||
SYM (__hashFunc.HashRemove, "_mesa_HashRemove"),
|
||||
SYM (__hashFunc.HashFirstEntry, "_mesa_HashFirstEntry"),
|
||||
SYM (__hashFunc.HashNextEntry, "_mesa_HashNextEntry"),
|
||||
SYM (__hashFunc.HashFindFreeKeyBlock, "_mesa_HashFindFreeKeyBlock")
|
||||
};
|
||||
|
||||
if (!xglLookupSymbols (handle, sym, sizeof (sym) / sizeof (sym[0])))
|
||||
return FALSE;
|
||||
|
||||
hashHandle = handle;
|
||||
|
||||
return TRUE;
|
||||
#else
|
||||
return FALSE;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
xglHashTablePtr
|
||||
xglNewHashTable (void)
|
||||
{
|
||||
if (!hashHandle)
|
||||
return 0;
|
||||
|
||||
return (*__hashFunc.NewHashTable) ();
|
||||
}
|
||||
|
||||
void
|
||||
xglDeleteHashTable (xglHashTablePtr pTable)
|
||||
{
|
||||
(*__hashFunc.DeleteHashTable) (pTable);
|
||||
}
|
||||
|
||||
void *
|
||||
xglHashLookup (const xglHashTablePtr pTable,
|
||||
unsigned int key)
|
||||
{
|
||||
return (*__hashFunc.HashLookup) (pTable, key);
|
||||
}
|
||||
|
||||
void
|
||||
xglHashInsert (xglHashTablePtr pTable,
|
||||
unsigned int key,
|
||||
void *data)
|
||||
{
|
||||
(*__hashFunc.HashInsert) (pTable, key, data);
|
||||
}
|
||||
|
||||
void
|
||||
xglHashRemove (xglHashTablePtr pTable,
|
||||
unsigned int key)
|
||||
{
|
||||
(*__hashFunc.HashRemove) (pTable, key);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
xglHashFirstEntry (xglHashTablePtr pTable)
|
||||
{
|
||||
return (*__hashFunc.HashFirstEntry) (pTable);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
xglHashNextEntry (const xglHashTablePtr pTable,
|
||||
unsigned int key)
|
||||
{
|
||||
return (*__hashFunc.HashNextEntry) (pTable, key);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
xglHashFindFreeKeyBlock (xglHashTablePtr pTable,
|
||||
unsigned int numKeys)
|
||||
{
|
||||
return (*__hashFunc.HashFindFreeKeyBlock) (pTable, numKeys);
|
||||
}
|
332
hw/xgl/xglinit.c
332
hw/xgl/xglinit.c
|
@ -1,332 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2005 Novell, Inc.
|
||||
*
|
||||
* 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
|
||||
* Novell, Inc. not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* Novell, Inc. makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL NOVELL, INC. 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
#include "xglglx.h"
|
||||
#include "micmap.h"
|
||||
#include "mipointer.h"
|
||||
#include "fb.h"
|
||||
|
||||
#ifdef XGL_MODULAR
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#define DEFAULT_DDX_MODULE_NAME "xglx"
|
||||
|
||||
static char *ddxModuleName = DEFAULT_DDX_MODULE_NAME;
|
||||
|
||||
xglScreenInfoRec xglScreenInfo = {
|
||||
NULL, 0, 0, 0, 0, 0,
|
||||
DEFAULT_GEOMETRY_DATA_TYPE,
|
||||
DEFAULT_GEOMETRY_USAGE,
|
||||
FALSE,
|
||||
XGL_DEFAULT_PBO_MASK,
|
||||
FALSE,
|
||||
{
|
||||
{ FALSE, FALSE, { 0, 0, 0, 0 } },
|
||||
{ FALSE, FALSE, { 0, 0, 0, 0 } },
|
||||
{ FALSE, FALSE, { 0, 0, 0, 0 } },
|
||||
{ FALSE, FALSE, { 0, 0, 0, 0 } }
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef GLXEXT
|
||||
static Bool loadGlx = TRUE;
|
||||
|
||||
#ifndef NGLXEXTLOG
|
||||
static char *glxExtLogFile = 0;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
typedef struct _xglDDXFunc {
|
||||
void (*initOutput) (ScreenInfo *pScreenInfo,
|
||||
int argc,
|
||||
char **argv);
|
||||
void (*initInput) (int argc,
|
||||
char **argv);
|
||||
Bool (*legalModifier) (unsigned int key,
|
||||
DevicePtr pDev);
|
||||
void (*processInputEvents) (void);
|
||||
void (*useMsg) (void);
|
||||
int (*processArgument) (int argc,
|
||||
char **argv,
|
||||
int i);
|
||||
void (*abort) (void);
|
||||
void (*giveUp) (void);
|
||||
void (*osVendorInit) (void);
|
||||
} xglDDXFuncRec;
|
||||
|
||||
static xglDDXFuncRec __ddxFunc;
|
||||
|
||||
#define SYMFUNC(name) ((void *) (name))
|
||||
#define SYMVAR(name) ((void *) &(name))
|
||||
|
||||
/*
|
||||
* The following table is used to make sure that all symbols required by
|
||||
* dynamically loaded modules are present in the main program. Add more symbols
|
||||
* as needed.
|
||||
*/
|
||||
|
||||
void *symTab[] = {
|
||||
SYMFUNC (xglKbdCtrl),
|
||||
SYMFUNC (xglSetPixmapFormats),
|
||||
SYMVAR (xglVisuals),
|
||||
|
||||
SYMFUNC (mieqEnqueue),
|
||||
SYMFUNC (mieqInit),
|
||||
SYMFUNC (mieqProcessInputEvents),
|
||||
SYMFUNC (miPointerAbsoluteCursor),
|
||||
SYMFUNC (miRegisterPointerDevice),
|
||||
SYMFUNC (miPointerWarpCursor),
|
||||
SYMFUNC (miDCInitialize),
|
||||
SYMFUNC (miPointerAbsoluteCursor),
|
||||
SYMFUNC (miPointerUpdate),
|
||||
SYMFUNC (miRegisterRedirectBorderClipProc)
|
||||
};
|
||||
|
||||
#define SYM(ptr, name) { (void **) &(ptr), (name) }
|
||||
|
||||
static Bool
|
||||
xglEnsureDDXModule (void)
|
||||
{
|
||||
|
||||
#ifdef XGL_MODULAR
|
||||
static void *ddxHandle = 0;
|
||||
static Bool status = TRUE;
|
||||
|
||||
if (!status)
|
||||
return FALSE;
|
||||
|
||||
#ifdef GLXEXT
|
||||
/* GLX and GLcore modules must be loaded with RTLD_NOW and RTLD_LOCAL
|
||||
flags before DDX module which is linked to libGL and should be
|
||||
loaded with RTLD_GLOBAL. */
|
||||
if (loadGlx)
|
||||
{
|
||||
if (!xglLoadGLXModules ())
|
||||
FatalError ("No GLX modules loaded");
|
||||
|
||||
#ifndef NGLXEXTLOG
|
||||
if (glxExtLogFile)
|
||||
{
|
||||
__xglGLXLogFp = fopen (glxExtLogFile, "w");
|
||||
if (!__xglGLXLogFp)
|
||||
perror ("InitOutput");
|
||||
}
|
||||
else
|
||||
__xglGLXLogFp = 0;
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!ddxHandle)
|
||||
{
|
||||
xglSymbolRec sym[] = {
|
||||
SYM (__ddxFunc.initOutput, "InitOutput"),
|
||||
SYM (__ddxFunc.initInput, "InitInput"),
|
||||
SYM (__ddxFunc.legalModifier, "LegalModifier"),
|
||||
SYM (__ddxFunc.processInputEvents, "ProcessInputEvents"),
|
||||
SYM (__ddxFunc.useMsg, "ddxUseMsg"),
|
||||
SYM (__ddxFunc.processArgument, "ddxProcessArgument"),
|
||||
SYM (__ddxFunc.abort, "AbortDDX"),
|
||||
SYM (__ddxFunc.giveUp, "ddxGiveUp"),
|
||||
SYM (__ddxFunc.osVendorInit, "OsVendorInit")
|
||||
};
|
||||
|
||||
ddxHandle = xglLoadModule (ddxModuleName, RTLD_NOW | RTLD_GLOBAL);
|
||||
if (!ddxHandle)
|
||||
return (status = FALSE);
|
||||
|
||||
if (!xglLookupSymbols (ddxHandle, sym, sizeof (sym) / sizeof (sym[0])))
|
||||
{
|
||||
xglUnloadModule (ddxHandle);
|
||||
ddxHandle = 0;
|
||||
|
||||
return (status = FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
#else
|
||||
return FALSE;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
InitOutput (ScreenInfo *pScreenInfo,
|
||||
int argc,
|
||||
char **argv)
|
||||
{
|
||||
(void) symTab;
|
||||
|
||||
if (!xglEnsureDDXModule ())
|
||||
FatalError ("No DDX module loaded");
|
||||
|
||||
(*__ddxFunc.initOutput) (pScreenInfo, argc, argv);
|
||||
}
|
||||
|
||||
Bool
|
||||
LegalModifier (unsigned int key,
|
||||
DeviceIntPtr pDev)
|
||||
{
|
||||
return (*__ddxFunc.legalModifier) (key, pDev);
|
||||
}
|
||||
|
||||
void
|
||||
ProcessInputEvents (void)
|
||||
{
|
||||
(*__ddxFunc.processInputEvents) ();
|
||||
}
|
||||
|
||||
void
|
||||
InitInput (int argc,
|
||||
char **argv)
|
||||
{
|
||||
if (!xglEnsureDDXModule ())
|
||||
FatalError ("No DDX module loaded");
|
||||
|
||||
(*__ddxFunc.initInput) (argc, argv);
|
||||
}
|
||||
|
||||
void
|
||||
ddxUseMsg (void)
|
||||
{
|
||||
ErrorF ("\nXgl usage:\n");
|
||||
ErrorF ("-ddx module specify ddx module\n");
|
||||
|
||||
#ifdef GLXEXT
|
||||
ErrorF ("-noglx don't load glx extension\n");
|
||||
|
||||
#ifndef NGLXEXTLOG
|
||||
ErrorF ("-glxlog file glx extension log file\n");
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
xglUseMsg ();
|
||||
|
||||
if (xglEnsureDDXModule ())
|
||||
(*__ddxFunc.useMsg) ();
|
||||
}
|
||||
|
||||
int
|
||||
ddxProcessArgument (int argc,
|
||||
char **argv,
|
||||
int i)
|
||||
{
|
||||
static Bool checkDDX = FALSE;
|
||||
int skip;
|
||||
|
||||
if (!checkDDX)
|
||||
{
|
||||
int j;
|
||||
|
||||
for (j = i; j < argc; j++)
|
||||
{
|
||||
if (!strcmp (argv[j], "-ddx"))
|
||||
{
|
||||
if (++j < argc)
|
||||
ddxModuleName = argv[j];
|
||||
}
|
||||
|
||||
#ifdef GLXEXT
|
||||
else if (!strcmp (argv[j], "-noglx"))
|
||||
{
|
||||
loadGlx = FALSE;
|
||||
}
|
||||
|
||||
#ifndef NGLXEXTLOG
|
||||
else if (!strcmp (argv[j], "-glxlog"))
|
||||
{
|
||||
if (++j < argc)
|
||||
glxExtLogFile = argv[j];
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
checkDDX = TRUE;
|
||||
}
|
||||
|
||||
if (!strcmp (argv[i], "-ddx"))
|
||||
{
|
||||
if ((i + 1) < argc)
|
||||
return 2;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef GLXEXT
|
||||
else if (!strcmp (argv[i], "-noglx"))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef NGLXEXTLOG
|
||||
else if (!strcmp (argv[i], "-glxlog"))
|
||||
{
|
||||
if ((i + 1) < argc)
|
||||
return 2;
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
skip = xglProcessArgument (argc, argv, i);
|
||||
if (skip)
|
||||
return skip;
|
||||
|
||||
if (xglEnsureDDXModule ())
|
||||
return (*__ddxFunc.processArgument) (argc, argv, i);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
AbortDDX (void)
|
||||
{
|
||||
if (xglEnsureDDXModule ())
|
||||
(*__ddxFunc.abort) ();
|
||||
}
|
||||
|
||||
void
|
||||
ddxGiveUp (void)
|
||||
{
|
||||
if (xglEnsureDDXModule ())
|
||||
(*__ddxFunc.giveUp) ();
|
||||
}
|
||||
|
||||
void
|
||||
OsVendorInit (void)
|
||||
{
|
||||
if (xglEnsureDDXModule ())
|
||||
(*__ddxFunc.osVendorInit) ();
|
||||
}
|
|
@ -1,263 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* 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
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
#include "inputstr.h"
|
||||
#include "mipointer.h"
|
||||
|
||||
#define XK_PUBLISHING
|
||||
#include <X11/keysym.h>
|
||||
#if HAVE_X11_XF86KEYSYM_H
|
||||
#include <X11/XF86keysym.h>
|
||||
#endif
|
||||
|
||||
#define NUM_BUTTONS 7
|
||||
|
||||
int
|
||||
xglMouseProc (DeviceIntPtr pDevice,
|
||||
int onoff)
|
||||
{
|
||||
BYTE map[NUM_BUTTONS + 1];
|
||||
DevicePtr pDev = (DevicePtr) pDevice;
|
||||
int i;
|
||||
|
||||
switch (onoff) {
|
||||
case DEVICE_INIT:
|
||||
for (i = 1; i <= NUM_BUTTONS; i++)
|
||||
map[i] = i;
|
||||
|
||||
InitPointerDeviceStruct (pDev,
|
||||
map,
|
||||
NUM_BUTTONS,
|
||||
miPointerGetMotionEvents,
|
||||
(PtrCtrlProcPtr) NoopDDA,
|
||||
miPointerGetMotionBufferSize ());
|
||||
break;
|
||||
case DEVICE_ON:
|
||||
pDev->on = TRUE;
|
||||
break;
|
||||
case DEVICE_OFF:
|
||||
case DEVICE_CLOSE:
|
||||
pDev->on = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
void
|
||||
xglBell (int volume,
|
||||
DeviceIntPtr pDev,
|
||||
pointer ctrl,
|
||||
int something)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
xglKbdCtrl (DeviceIntPtr pDevice,
|
||||
KeybdCtrl *ctrl)
|
||||
{
|
||||
}
|
||||
|
||||
#define XGL_KEYMAP_WIDTH 2
|
||||
|
||||
KeySym xglKeymap[] = {
|
||||
/* 1 8 */ XK_Escape, NoSymbol,
|
||||
/* 2 9 */ XK_1, XK_exclam,
|
||||
/* 3 10 */ XK_2, XK_at,
|
||||
/* 4 11 */ XK_3, XK_numbersign,
|
||||
/* 5 12 */ XK_4, XK_dollar,
|
||||
/* 6 13 */ XK_5, XK_percent,
|
||||
/* 7 14 */ XK_6, XK_asciicircum,
|
||||
/* 8 15 */ XK_7, XK_ampersand,
|
||||
/* 9 16 */ XK_8, XK_asterisk,
|
||||
/* 10 17 */ XK_9, XK_parenleft,
|
||||
/* 11 18 */ XK_0, XK_parenright,
|
||||
/* 12 19 */ XK_minus, XK_underscore,
|
||||
/* 13 20 */ XK_equal, XK_plus,
|
||||
/* 14 21 */ XK_BackSpace, NoSymbol,
|
||||
/* 15 22 */ XK_Tab, NoSymbol,
|
||||
/* 16 23 */ XK_Q, NoSymbol,
|
||||
/* 17 24 */ XK_W, NoSymbol,
|
||||
/* 18 25 */ XK_E, NoSymbol,
|
||||
/* 19 26 */ XK_R, NoSymbol,
|
||||
/* 20 27 */ XK_T, NoSymbol,
|
||||
/* 21 28 */ XK_Y, NoSymbol,
|
||||
/* 22 29 */ XK_U, NoSymbol,
|
||||
/* 23 30 */ XK_I, NoSymbol,
|
||||
/* 24 31 */ XK_O, NoSymbol,
|
||||
/* 25 32 */ XK_P, NoSymbol,
|
||||
/* 26 33 */ XK_bracketleft, XK_braceleft,
|
||||
/* 27 34 */ XK_bracketright, XK_braceright,
|
||||
/* 28 35 */ XK_Return, NoSymbol,
|
||||
/* 29 36 */ XK_Control_L, NoSymbol,
|
||||
/* 30 37 */ XK_A, NoSymbol,
|
||||
/* 31 38 */ XK_S, NoSymbol,
|
||||
/* 32 39 */ XK_D, NoSymbol,
|
||||
/* 33 40 */ XK_F, NoSymbol,
|
||||
/* 34 41 */ XK_G, NoSymbol,
|
||||
/* 35 42 */ XK_H, NoSymbol,
|
||||
/* 36 43 */ XK_J, NoSymbol,
|
||||
/* 37 44 */ XK_K, NoSymbol,
|
||||
/* 38 45 */ XK_L, NoSymbol,
|
||||
/* 39 46 */ XK_semicolon, XK_colon,
|
||||
/* 40 47 */ XK_apostrophe, XK_quotedbl,
|
||||
/* 41 48 */ XK_grave, XK_asciitilde,
|
||||
/* 42 49 */ XK_Shift_L, NoSymbol,
|
||||
/* 43 50 */ XK_backslash, XK_bar,
|
||||
/* 44 51 */ XK_Z, NoSymbol,
|
||||
/* 45 52 */ XK_X, NoSymbol,
|
||||
/* 46 53 */ XK_C, NoSymbol,
|
||||
/* 47 54 */ XK_V, NoSymbol,
|
||||
/* 48 55 */ XK_B, NoSymbol,
|
||||
/* 49 56 */ XK_N, NoSymbol,
|
||||
/* 50 57 */ XK_M, NoSymbol,
|
||||
/* 51 58 */ XK_comma, XK_less,
|
||||
/* 52 59 */ XK_period, XK_greater,
|
||||
/* 53 60 */ XK_slash, XK_question,
|
||||
/* 54 61 */ XK_Shift_R, NoSymbol,
|
||||
/* 55 62 */ XK_KP_Multiply, NoSymbol,
|
||||
/* 56 63 */ XK_Alt_L, XK_Meta_L,
|
||||
/* 57 64 */ XK_space, NoSymbol,
|
||||
/* 58 65 */ XK_Caps_Lock, NoSymbol,
|
||||
/* 59 66 */ XK_F1, NoSymbol,
|
||||
/* 60 67 */ XK_F2, NoSymbol,
|
||||
/* 61 68 */ XK_F3, NoSymbol,
|
||||
/* 62 69 */ XK_F4, NoSymbol,
|
||||
/* 63 70 */ XK_F5, NoSymbol,
|
||||
/* 64 71 */ XK_F6, NoSymbol,
|
||||
/* 65 72 */ XK_F7, NoSymbol,
|
||||
/* 66 73 */ XK_F8, NoSymbol,
|
||||
/* 67 74 */ XK_F9, NoSymbol,
|
||||
/* 68 75 */ XK_F10, NoSymbol,
|
||||
/* 69 76 */ XK_Break, XK_Pause,
|
||||
/* 70 77 */ XK_Scroll_Lock, NoSymbol,
|
||||
/* 71 78 */ XK_KP_Home, XK_KP_7,
|
||||
/* 72 79 */ XK_KP_Up, XK_KP_8,
|
||||
/* 73 80 */ XK_KP_Page_Up, XK_KP_9,
|
||||
/* 74 81 */ XK_KP_Subtract, NoSymbol,
|
||||
/* 75 82 */ XK_KP_Left, XK_KP_4,
|
||||
/* 76 83 */ XK_KP_5, NoSymbol,
|
||||
/* 77 84 */ XK_KP_Right, XK_KP_6,
|
||||
/* 78 85 */ XK_KP_Add, NoSymbol,
|
||||
/* 79 86 */ XK_KP_End, XK_KP_1,
|
||||
/* 80 87 */ XK_KP_Down, XK_KP_2,
|
||||
/* 81 88 */ XK_KP_Page_Down, XK_KP_3,
|
||||
/* 82 89 */ XK_KP_Insert, XK_KP_0,
|
||||
/* 83 90 */ XK_KP_Delete, XK_KP_Decimal,
|
||||
/* 84 91 */ NoSymbol, NoSymbol,
|
||||
/* 85 92 */ NoSymbol, NoSymbol,
|
||||
/* 86 93 */ NoSymbol, NoSymbol,
|
||||
/* 87 94 */ XK_F11, NoSymbol,
|
||||
/* 88 95 */ XK_F12, NoSymbol,
|
||||
/* 89 96 */ XK_Control_R, NoSymbol,
|
||||
/* 90 97 */ XK_KP_Enter, NoSymbol,
|
||||
/* 91 98 */ XK_KP_Divide, NoSymbol,
|
||||
/* 92 99 */ XK_Sys_Req, XK_Print,
|
||||
/* 93 100 */ XK_Alt_R, XK_Meta_R,
|
||||
/* 94 101 */ XK_Num_Lock, NoSymbol,
|
||||
/* 95 102 */ XK_Home, NoSymbol,
|
||||
/* 96 103 */ XK_Up, NoSymbol,
|
||||
/* 97 104 */ XK_Page_Up, NoSymbol,
|
||||
/* 98 105 */ XK_Left, NoSymbol,
|
||||
/* 99 106 */ XK_Right, NoSymbol,
|
||||
/* 100 107 */ XK_End, NoSymbol,
|
||||
/* 101 108 */ XK_Down, NoSymbol,
|
||||
/* 102 109 */ XK_Page_Down, NoSymbol,
|
||||
/* 103 110 */ XK_Insert, NoSymbol,
|
||||
/* 104 111 */ XK_Delete, NoSymbol,
|
||||
/* 105 112 */ XK_Super_L, NoSymbol,
|
||||
/* 106 113 */ XK_Super_R, NoSymbol,
|
||||
/* 107 114 */ XK_Menu, NoSymbol,
|
||||
|
||||
/* 108 115 */ XK_Next, NoSymbol, /* right button on side */
|
||||
/* 109 116 */ XK_Prior, NoSymbol, /* left button on side */
|
||||
/* 110 117 */ XK_Up, NoSymbol, /* joypad */
|
||||
/* 111 118 */ XK_Down, NoSymbol,
|
||||
/* 112 119 */ XK_Left, NoSymbol,
|
||||
/* 113 120 */ XK_Right, NoSymbol,
|
||||
/* 114 121 */ NoSymbol, NoSymbol, /* left near speaker */
|
||||
/* 115 122 */ NoSymbol, NoSymbol, /* right near speaker */
|
||||
/* 116 123 */ NoSymbol, NoSymbol, /* tiny button */
|
||||
};
|
||||
|
||||
CARD8 xglModMap[MAP_LENGTH];
|
||||
|
||||
KeySymsRec xglKeySyms = {
|
||||
xglKeymap,
|
||||
8,
|
||||
8 + (sizeof (xglKeymap) / sizeof (xglKeymap[0]) / XGL_KEYMAP_WIDTH) - 1,
|
||||
XGL_KEYMAP_WIDTH
|
||||
};
|
||||
|
||||
int
|
||||
xglKeybdProc (DeviceIntPtr pDevice,
|
||||
int onoff)
|
||||
{
|
||||
Bool ret;
|
||||
DevicePtr pDev = (DevicePtr) pDevice;
|
||||
|
||||
if (!pDev)
|
||||
return BadImplementation;
|
||||
|
||||
switch (onoff) {
|
||||
case DEVICE_INIT:
|
||||
if (pDev != (DevicePtr)inputInfo.keyboard)
|
||||
return !Success;
|
||||
|
||||
ret = InitKeyboardDeviceStruct (pDev,
|
||||
&xglKeySyms,
|
||||
xglModMap,
|
||||
xglBell,
|
||||
xglKbdCtrl);
|
||||
if (!ret)
|
||||
return BadImplementation;
|
||||
break;
|
||||
case DEVICE_ON:
|
||||
pDev->on = TRUE;
|
||||
break;
|
||||
case DEVICE_OFF:
|
||||
case DEVICE_CLOSE:
|
||||
pDev->on = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
void
|
||||
xglInitInput (int argc, char **argv)
|
||||
{
|
||||
DeviceIntPtr pKeyboard, pPointer;
|
||||
|
||||
pPointer = AddInputDevice (xglMouseProc, TRUE);
|
||||
pKeyboard = AddInputDevice (xglKeybdProc, TRUE);
|
||||
|
||||
RegisterPointerDevice (pPointer);
|
||||
RegisterKeyboardDevice (pKeyboard);
|
||||
|
||||
miRegisterPointerDevice (screenInfo.screens[0], pPointer);
|
||||
mieqInit (&pKeyboard->public, &pPointer->public);
|
||||
}
|
|
@ -1,130 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2005 Novell, Inc.
|
||||
*
|
||||
* 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
|
||||
* Novell, Inc. not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* Novell, Inc. makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL NOVELL, INC. 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
#include "xglmodule.h"
|
||||
|
||||
#ifdef XGL_MODULAR
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
#define SYM(ptr, name) { (void **) &(ptr), (name) }
|
||||
|
||||
void *
|
||||
xglLoadModule (const char *name,
|
||||
int flag)
|
||||
{
|
||||
ModuleVersionProcPtr moduleVersion;
|
||||
ModuleInitProcPtr moduleInit;
|
||||
void *handle = 0;
|
||||
char *module;
|
||||
xglSymbolRec mSym[] = {
|
||||
SYM (moduleVersion, "moduleVersion"),
|
||||
SYM (moduleInit, "moduleInit")
|
||||
};
|
||||
|
||||
module = malloc (strlen (XGL_MODULE_PATH "/lib.so") + strlen (name) + 1);
|
||||
if (!module)
|
||||
return 0;
|
||||
|
||||
sprintf (module, XGL_MODULE_PATH "/lib%s.so", name);
|
||||
|
||||
handle = dlopen (module, flag);
|
||||
if (handle)
|
||||
{
|
||||
if (xglLookupSymbols (handle, mSym, sizeof (mSym) / sizeof (mSym[0])))
|
||||
{
|
||||
const char *version;
|
||||
|
||||
version = (*moduleVersion) ();
|
||||
if (strcmp (VERSION, version) == 0)
|
||||
{
|
||||
if (!(*moduleInit) (module))
|
||||
{
|
||||
dlclose (handle);
|
||||
handle = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorF ("Module version mismatch. "
|
||||
"%s is %s Xserver is" VERSION "\n",
|
||||
module, version);
|
||||
|
||||
dlclose (handle);
|
||||
handle = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dlclose (handle);
|
||||
handle = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
ErrorF ("dlopen: %s\n", dlerror ());
|
||||
|
||||
free (module);
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
void
|
||||
xglUnloadModule (void *handle)
|
||||
{
|
||||
dlclose (handle);
|
||||
}
|
||||
|
||||
Bool
|
||||
xglLookupSymbols (void *handle,
|
||||
xglSymbolPtr sym,
|
||||
int nSym)
|
||||
{
|
||||
void *symbol;
|
||||
char *error;
|
||||
int i;
|
||||
|
||||
/* avoid previous error */
|
||||
dlerror ();
|
||||
|
||||
for (i = 0; i < nSym; i++)
|
||||
{
|
||||
symbol = dlsym (handle, sym[i].name);
|
||||
if (!symbol)
|
||||
{
|
||||
error = dlerror ();
|
||||
if (error != 0)
|
||||
ErrorF ("dlsym: %s: %s\n", sym[i].name, error);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*(sym[i].ptr) = symbol;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2005 Novell, Inc.
|
||||
*
|
||||
* 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
|
||||
* Novell, Inc. not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* Novell, Inc. makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL NOVELL, INC. 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#ifndef _XGL_MODULE_H_
|
||||
#define _XGL_MODULE_H_
|
||||
|
||||
#include <xgl-config.h>
|
||||
|
||||
#include <X11/Xdefs.h>
|
||||
#include "misc.h"
|
||||
|
||||
#define VERSION "0.0.1"
|
||||
|
||||
typedef const char *(*ModuleVersionProcPtr) (void);
|
||||
typedef Bool (*ModuleInitProcPtr) (const char *module);
|
||||
|
||||
char *
|
||||
moduleVersion (void);
|
||||
|
||||
Bool
|
||||
moduleInit (const char *module);
|
||||
|
||||
#endif /* _XGL_MODULE_H_ */
|
|
@ -1,181 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* 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
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
|
||||
#include <mivalidate.h>
|
||||
#include <dixstruct.h>
|
||||
|
||||
typedef struct _xglDepth {
|
||||
CARD8 depth;
|
||||
CARD8 bpp;
|
||||
} xglDepthRec, *xglDepthPtr;
|
||||
|
||||
static xglDepthRec xglDepths[] = {
|
||||
{ 1, 1 },
|
||||
{ 4, 4 },
|
||||
{ 8, 8 },
|
||||
{ 15, 16 },
|
||||
{ 16, 16 },
|
||||
{ 24, 32 },
|
||||
{ 32, 32 }
|
||||
};
|
||||
|
||||
#define NUM_XGL_DEPTHS (sizeof (xglDepths) / sizeof (xglDepths[0]))
|
||||
|
||||
void
|
||||
xglSetPixmapFormats (ScreenInfo *pScreenInfo)
|
||||
{
|
||||
int i;
|
||||
|
||||
pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
|
||||
pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
|
||||
pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
|
||||
pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
|
||||
pScreenInfo->numPixmapFormats = 0;
|
||||
|
||||
for (i = 0; i < NUM_XGL_DEPTHS; i++)
|
||||
{
|
||||
PixmapFormatRec *format;
|
||||
|
||||
format = &pScreenInfo->formats[pScreenInfo->numPixmapFormats++];
|
||||
|
||||
format->depth = xglDepths[i].depth;
|
||||
format->bitsPerPixel = xglDepths[i].bpp;
|
||||
format->scanlinePad = BITMAP_SCANLINE_PAD;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
xglSetRootClip (ScreenPtr pScreen,
|
||||
Bool enable)
|
||||
{
|
||||
WindowPtr pWin = WindowTable[pScreen->myNum];
|
||||
WindowPtr pChild;
|
||||
Bool wasViewable;
|
||||
Bool anyMarked = FALSE;
|
||||
RegionPtr pOldClip = 0;
|
||||
|
||||
#ifdef DO_SAVE_UNDERS
|
||||
Bool dosave = FALSE;
|
||||
#endif
|
||||
|
||||
WindowPtr pLayerWin;
|
||||
BoxRec box;
|
||||
|
||||
if (!pWin)
|
||||
return;
|
||||
|
||||
wasViewable = (Bool) (pWin->viewable);
|
||||
if (wasViewable)
|
||||
{
|
||||
for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib)
|
||||
{
|
||||
(void) (*pScreen->MarkOverlappedWindows) (pChild,
|
||||
pChild,
|
||||
&pLayerWin);
|
||||
}
|
||||
|
||||
(*pScreen->MarkWindow) (pWin);
|
||||
anyMarked = TRUE;
|
||||
|
||||
if (pWin->valdata)
|
||||
{
|
||||
if (HasBorder (pWin))
|
||||
{
|
||||
RegionPtr borderVisible;
|
||||
|
||||
borderVisible = REGION_CREATE (pScreen, NullBox, 1);
|
||||
REGION_SUBTRACT (pScreen, borderVisible,
|
||||
&pWin->borderClip, &pWin->winSize);
|
||||
pWin->valdata->before.borderVisible = borderVisible;
|
||||
}
|
||||
pWin->valdata->before.resized = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (enable)
|
||||
{
|
||||
box.x1 = 0;
|
||||
box.y1 = 0;
|
||||
box.x2 = pScreen->width;
|
||||
box.y2 = pScreen->height;
|
||||
|
||||
pWin->drawable.width = pScreen->width;
|
||||
pWin->drawable.height = pScreen->height;
|
||||
|
||||
REGION_INIT (pScreen, &pWin->winSize, &box, 1);
|
||||
REGION_INIT (pScreen, &pWin->borderSize, &box, 1);
|
||||
REGION_RESET (pScreen, &pWin->borderClip, &box);
|
||||
REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
|
||||
}
|
||||
else
|
||||
{
|
||||
REGION_EMPTY (pScreen, &pWin->borderClip);
|
||||
REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
|
||||
}
|
||||
|
||||
ResizeChildrenWinSize (pWin, 0, 0, 0, 0);
|
||||
|
||||
if (wasViewable)
|
||||
{
|
||||
if (pWin->firstChild)
|
||||
{
|
||||
anyMarked |= (*pScreen->MarkOverlappedWindows) (pWin->firstChild,
|
||||
pWin->firstChild,
|
||||
(WindowPtr *) 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
(*pScreen->MarkWindow) (pWin);
|
||||
anyMarked = TRUE;
|
||||
}
|
||||
|
||||
#ifdef DO_SAVE_UNDERS
|
||||
if (DO_SAVE_UNDERS (pWin))
|
||||
dosave = (*pScreen->ChangeSaveUnder) (pLayerWin, pLayerWin);
|
||||
#endif
|
||||
|
||||
if (anyMarked)
|
||||
(*pScreen->ValidateTree)(pWin, NullWindow, VTOther);
|
||||
}
|
||||
|
||||
if (wasViewable)
|
||||
{
|
||||
if (anyMarked)
|
||||
(*pScreen->HandleExposures) (pWin);
|
||||
|
||||
#ifdef DO_SAVE_UNDERS
|
||||
if (dosave)
|
||||
(*pScreen->PostChangeSaveUnder) (pLayerWin, pLayerWin);
|
||||
#endif
|
||||
|
||||
if (anyMarked && pScreen->PostValidateTree)
|
||||
(*pScreen->PostValidateTree) (pWin, NullWindow, VTOther);
|
||||
}
|
||||
|
||||
if (pWin->realized)
|
||||
WindowsRestructured ();
|
||||
}
|
|
@ -1,257 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* 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
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
|
||||
char *
|
||||
xglParseFindNext (char *cur,
|
||||
char *delim,
|
||||
char *save,
|
||||
char *last)
|
||||
{
|
||||
while (*cur && !strchr (delim, *cur))
|
||||
*save++ = *cur++;
|
||||
|
||||
*save = 0;
|
||||
*last = *cur;
|
||||
|
||||
if (*cur)
|
||||
cur++;
|
||||
|
||||
return cur;
|
||||
}
|
||||
|
||||
void
|
||||
xglParseScreen (char *arg)
|
||||
{
|
||||
char delim;
|
||||
char save[1024];
|
||||
int i, pixels, mm;
|
||||
|
||||
xglScreenInfo.width = 0;
|
||||
xglScreenInfo.height = 0;
|
||||
xglScreenInfo.widthMm = 0;
|
||||
xglScreenInfo.heightMm = 0;
|
||||
|
||||
if (!arg)
|
||||
return;
|
||||
|
||||
if (strlen (arg) >= sizeof (save))
|
||||
return;
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
arg = xglParseFindNext (arg, "x/", save, &delim);
|
||||
if (!save[0])
|
||||
return;
|
||||
|
||||
pixels = atoi (save);
|
||||
mm = 0;
|
||||
|
||||
if (delim == '/')
|
||||
{
|
||||
arg = xglParseFindNext (arg, "x", save, &delim);
|
||||
if (!save[0])
|
||||
return;
|
||||
|
||||
mm = atoi (save);
|
||||
}
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
xglScreenInfo.width = pixels;
|
||||
xglScreenInfo.widthMm = mm;
|
||||
}
|
||||
else
|
||||
{
|
||||
xglScreenInfo.height = pixels;
|
||||
xglScreenInfo.heightMm = mm;
|
||||
}
|
||||
|
||||
if (delim != 'x')
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
xglParseAccel (char *arg)
|
||||
{
|
||||
xglAccelInfoPtr pAccel;
|
||||
char delim;
|
||||
char save[1024];
|
||||
|
||||
if (!arg)
|
||||
return;
|
||||
|
||||
if (strlen (arg) >= sizeof (save))
|
||||
return;
|
||||
|
||||
arg = xglParseFindNext (arg, "@:", save, &delim);
|
||||
if (!save[0])
|
||||
return;
|
||||
|
||||
if (strcasecmp (save, "pixmap") == 0)
|
||||
pAccel = &xglScreenInfo.accel.pixmap;
|
||||
else if (strcasecmp (save, "window") == 0)
|
||||
pAccel = &xglScreenInfo.accel.window;
|
||||
else if (strcasecmp (save, "glx") == 0)
|
||||
pAccel = &xglScreenInfo.accel.glx;
|
||||
else if (strcasecmp (save, "xv") == 0)
|
||||
pAccel = &xglScreenInfo.accel.xv;
|
||||
else
|
||||
return;
|
||||
|
||||
if (delim == '@')
|
||||
{
|
||||
arg = xglParseFindNext (arg, "/x:", save, &delim);
|
||||
if (!save[0])
|
||||
return;
|
||||
|
||||
pAccel->size.aboveWidth = pAccel->size.minWidth = atoi (save);
|
||||
|
||||
if (delim == '/')
|
||||
{
|
||||
arg = xglParseFindNext (arg, "x:", save, &delim);
|
||||
if (!save[0])
|
||||
return;
|
||||
|
||||
pAccel->size.aboveWidth = atoi (save);
|
||||
}
|
||||
|
||||
if (delim == 'x')
|
||||
{
|
||||
arg = xglParseFindNext (arg, "/:", save, &delim);
|
||||
if (!save[0])
|
||||
return;
|
||||
|
||||
pAccel->size.aboveHeight = pAccel->size.minHeight = atoi (save);
|
||||
|
||||
if (delim == '/')
|
||||
{
|
||||
arg = xglParseFindNext (arg, ":", save, &delim);
|
||||
if (!save[0])
|
||||
return;
|
||||
|
||||
pAccel->size.aboveHeight = atoi (save);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pAccel->enabled = TRUE;
|
||||
pAccel->pbuffer = FALSE;
|
||||
|
||||
if (delim == ':')
|
||||
{
|
||||
if (strcasecmp (arg, "fbo") == 0)
|
||||
;
|
||||
else if (strcasecmp (arg, "off") == 0 ||
|
||||
strncasecmp (arg, "0", 1) == 0 ||
|
||||
strncasecmp (arg, "f", 1) == 0 ||
|
||||
strncasecmp (arg, "n", 1) == 0)
|
||||
{
|
||||
pAccel->enabled = FALSE;
|
||||
pAccel->pbuffer = FALSE;
|
||||
}
|
||||
else if (strcasecmp (arg, "pbuffer") == 0)
|
||||
{
|
||||
pAccel->pbuffer = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
xglUseMsg (void)
|
||||
{
|
||||
ErrorF ("-vertextype [short|float] set vertex data type\n");
|
||||
ErrorF ("-yinverted Y is upside-down\n");
|
||||
ErrorF ("-lines "
|
||||
"accelerate lines that are not vertical or horizontal\n");
|
||||
ErrorF ("-vbo "
|
||||
"use vertex buffer objects for streaming of vertex data\n");
|
||||
ErrorF ("-pbomask [1|4|8|16|32] "
|
||||
"set bpp's to use with pixel buffer objects\n");
|
||||
ErrorF ("-accel TYPE[@WIDTH[/MIN]xHEIGHT[/MIN]][:METHOD] "
|
||||
"offscreen acceleration\n");
|
||||
}
|
||||
|
||||
int
|
||||
xglProcessArgument (int argc,
|
||||
char **argv,
|
||||
int i)
|
||||
{
|
||||
if (!strcmp (argv[i], "-vertextype"))
|
||||
{
|
||||
if ((i + 1) < argc)
|
||||
{
|
||||
if (!strcasecmp (argv[i + 1], "short"))
|
||||
xglScreenInfo.geometryDataType = GEOMETRY_DATA_TYPE_SHORT;
|
||||
else if (!strcasecmp (argv[i + 1], "float"))
|
||||
xglScreenInfo.geometryDataType = GEOMETRY_DATA_TYPE_FLOAT;
|
||||
}
|
||||
else
|
||||
return 1;
|
||||
|
||||
return 2;
|
||||
}
|
||||
else if (!strcmp (argv[i], "-yinverted"))
|
||||
{
|
||||
xglScreenInfo.yInverted = TRUE;
|
||||
return 1;
|
||||
}
|
||||
else if (!strcmp (argv[i], "-lines"))
|
||||
{
|
||||
xglScreenInfo.lines = TRUE;
|
||||
return 1;
|
||||
}
|
||||
else if (!strcmp (argv[i], "-vbo"))
|
||||
{
|
||||
xglScreenInfo.geometryUsage = GEOMETRY_USAGE_STREAM;
|
||||
return 1;
|
||||
}
|
||||
else if (!strcmp (argv[i], "-pbomask"))
|
||||
{
|
||||
if ((i + 1) < argc)
|
||||
{
|
||||
xglScreenInfo.pboMask = atoi (argv[i + 1]);
|
||||
}
|
||||
else
|
||||
return 1;
|
||||
|
||||
return 2;
|
||||
}
|
||||
else if (!strcmp (argv[i], "-accel"))
|
||||
{
|
||||
if ((i + 1) < argc)
|
||||
{
|
||||
xglParseAccel (argv[i + 1]);
|
||||
}
|
||||
else
|
||||
return 1;
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
787
hw/xgl/xglpict.c
787
hw/xgl/xglpict.c
|
@ -1,787 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* 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
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
#include "fb.h"
|
||||
|
||||
#ifdef RENDER
|
||||
|
||||
#include "fbpict.h"
|
||||
|
||||
#define XGL_PICTURE_FALLBACK_PROLOGUE(pPicture, func) \
|
||||
xglSyncDamageBoxBits (pPicture->pDrawable); \
|
||||
XGL_PICTURE_SCREEN_UNWRAP (func)
|
||||
|
||||
#define XGL_PICTURE_FALLBACK_EPILOGUE(pPicture, func, xglfunc) \
|
||||
XGL_PICTURE_SCREEN_WRAP (func, xglfunc); \
|
||||
xglAddCurrentSurfaceDamage (pPicture->pDrawable)
|
||||
|
||||
void
|
||||
xglComposite (CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pMask,
|
||||
PicturePtr pDst,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
INT16 xMask,
|
||||
INT16 yMask,
|
||||
INT16 xDst,
|
||||
INT16 yDst,
|
||||
CARD16 width,
|
||||
CARD16 height)
|
||||
{
|
||||
PictureScreenPtr pPictureScreen;
|
||||
ScreenPtr pScreen = pDst->pDrawable->pScreen;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
if (xglCompositeGeneral (op,
|
||||
pSrc, pMask, pDst, NULL,
|
||||
xSrc, ySrc,
|
||||
xMask, yMask,
|
||||
xDst + pDst->pDrawable->x,
|
||||
yDst + pDst->pDrawable->y,
|
||||
width, height))
|
||||
{
|
||||
xglAddCurrentBitDamage (pDst->pDrawable);
|
||||
return;
|
||||
}
|
||||
|
||||
pPictureScreen = GetPictureScreen (pScreen);
|
||||
|
||||
if (pSrc->pDrawable)
|
||||
{
|
||||
if (!xglSyncBits (pSrc->pDrawable, NullBox))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
}
|
||||
|
||||
if (pMask && pMask->pDrawable)
|
||||
{
|
||||
if (!xglSyncBits (pMask->pDrawable, NullBox))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
}
|
||||
|
||||
if (op == PictOpSrc)
|
||||
{
|
||||
XGL_DRAWABLE_PIXMAP (pDst->pDrawable);
|
||||
|
||||
if (!xglMapPixmapBits (pPixmap))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
} else
|
||||
xglSyncDamageBoxBits (pDst->pDrawable);
|
||||
|
||||
XGL_PICTURE_SCREEN_UNWRAP (Composite);
|
||||
(*pPictureScreen->Composite) (op, pSrc, pMask, pDst,
|
||||
xSrc, ySrc, xMask, yMask, xDst, yDst,
|
||||
width, height);
|
||||
XGL_PICTURE_SCREEN_WRAP (Composite, xglComposite);
|
||||
|
||||
if (op == PictOpSrc)
|
||||
{
|
||||
RegionRec region;
|
||||
|
||||
xDst += pDst->pDrawable->x;
|
||||
yDst += pDst->pDrawable->y;
|
||||
|
||||
if (pSrc->pDrawable)
|
||||
{
|
||||
xSrc += pSrc->pDrawable->x;
|
||||
ySrc += pSrc->pDrawable->y;
|
||||
}
|
||||
|
||||
if (pMask && pMask->pDrawable)
|
||||
{
|
||||
xMask += pMask->pDrawable->x;
|
||||
yMask += pMask->pDrawable->y;
|
||||
}
|
||||
|
||||
if (!miComputeCompositeRegion (®ion, pSrc, pMask, pDst,
|
||||
xSrc, ySrc, xMask, yMask, xDst, yDst,
|
||||
width, height))
|
||||
return;
|
||||
|
||||
xglAddSurfaceDamage (pDst->pDrawable, ®ion);
|
||||
REGION_UNINIT (pDst->pDrawable->pScreen, ®ion);
|
||||
} else
|
||||
xglAddCurrentSurfaceDamage (pDst->pDrawable);
|
||||
}
|
||||
|
||||
void
|
||||
xglAddTriangles (PicturePtr pDst,
|
||||
INT16 xOff,
|
||||
INT16 yOff,
|
||||
int ntri,
|
||||
xTriangle *tris)
|
||||
{
|
||||
PictureScreenPtr pPictureScreen;
|
||||
ScreenPtr pScreen = pDst->pDrawable->pScreen;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pDst->pDrawable);
|
||||
|
||||
pPictureScreen = GetPictureScreen (pScreen);
|
||||
|
||||
pPixmapPriv->damageBox.x1 = 0;
|
||||
pPixmapPriv->damageBox.y1 = 0;
|
||||
pPixmapPriv->damageBox.x2 = pDst->pDrawable->width;
|
||||
pPixmapPriv->damageBox.y2 = pDst->pDrawable->height;
|
||||
|
||||
XGL_PICTURE_FALLBACK_PROLOGUE (pDst, AddTriangles);
|
||||
(*pPictureScreen->AddTriangles) (pDst, xOff, yOff, ntri, tris);
|
||||
XGL_PICTURE_FALLBACK_EPILOGUE (pDst, AddTriangles, xglAddTriangles);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
xglChangePicture (PicturePtr pPicture,
|
||||
Mask mask)
|
||||
{
|
||||
PictureScreenPtr pPictureScreen;
|
||||
ScreenPtr pScreen = pPicture->pDrawable->pScreen;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pPicture->pDrawable);
|
||||
|
||||
pPictureScreen = GetPictureScreen (pScreen);
|
||||
|
||||
if (pPicture->stateChanges & CPRepeat)
|
||||
pPixmapPriv->pictureMask |= xglPCFillMask;
|
||||
|
||||
if (pPicture->stateChanges & CPComponentAlpha)
|
||||
pPixmapPriv->pictureMask |= xglPCComponentAlphaMask;
|
||||
|
||||
if (pPicture->stateChanges & CPDither)
|
||||
pPixmapPriv->pictureMask |= xglPCDitherMask;
|
||||
|
||||
XGL_PICTURE_SCREEN_UNWRAP (ChangePicture);
|
||||
(*pPictureScreen->ChangePicture) (pPicture, mask);
|
||||
XGL_PICTURE_SCREEN_WRAP (ChangePicture, xglChangePicture);
|
||||
}
|
||||
|
||||
int
|
||||
xglChangePictureTransform (PicturePtr pPicture,
|
||||
PictTransform *transform)
|
||||
{
|
||||
PictureScreenPtr pPictureScreen;
|
||||
ScreenPtr pScreen = pPicture->pDrawable->pScreen;
|
||||
int ret;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pPicture->pDrawable);
|
||||
|
||||
pPictureScreen = GetPictureScreen (pScreen);
|
||||
|
||||
if (transform != pPicture->transform ||
|
||||
(transform && memcmp (transform, &pPicture->transform,
|
||||
sizeof (PictTransform))))
|
||||
pPixmapPriv->pictureMask |= xglPCTransformMask;
|
||||
|
||||
XGL_PICTURE_SCREEN_UNWRAP (ChangePictureTransform);
|
||||
ret = (*pPictureScreen->ChangePictureTransform) (pPicture, transform);
|
||||
XGL_PICTURE_SCREEN_WRAP (ChangePictureTransform,
|
||||
xglChangePictureTransform);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
xglChangePictureFilter (PicturePtr pPicture,
|
||||
int filter,
|
||||
xFixed *params,
|
||||
int nparams)
|
||||
{
|
||||
PictureScreenPtr pPictureScreen;
|
||||
ScreenPtr pScreen = pPicture->pDrawable->pScreen;
|
||||
int ret;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pPicture->pDrawable);
|
||||
|
||||
pPictureScreen = GetPictureScreen (pScreen);
|
||||
|
||||
pPixmapPriv->pictureMask |= xglPCFilterMask;
|
||||
|
||||
XGL_PICTURE_SCREEN_UNWRAP (ChangePictureFilter);
|
||||
ret = (*pPictureScreen->ChangePictureFilter) (pPicture, filter,
|
||||
params, nparams);
|
||||
XGL_PICTURE_SCREEN_WRAP (ChangePictureFilter, xglChangePictureFilter);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
xglDestroyDevicePicture (PicturePtr pPicture)
|
||||
{
|
||||
if (pPicture->pSourcePict->source.devPrivate.ptr)
|
||||
glitz_surface_destroy (pPicture->pSourcePict->source.devPrivate.ptr);
|
||||
}
|
||||
|
||||
PicturePtr
|
||||
xglCreateDevicePicture (pointer data)
|
||||
{
|
||||
PicturePtr pPicture;
|
||||
int error;
|
||||
|
||||
pPicture = CreateDevicePicture (0, &error);
|
||||
if (!pPicture)
|
||||
return 0;
|
||||
|
||||
pPicture->pSourcePict->source.devPrivate.ptr = data;
|
||||
pPicture->pSourcePict->source.Destroy = xglDestroyDevicePicture;
|
||||
|
||||
return pPicture;
|
||||
}
|
||||
|
||||
static int fillMode[] = {
|
||||
GLITZ_FILL_TRANSPARENT, /* RepeatNone */
|
||||
GLITZ_FILL_REPEAT, /* RepeatNormal */
|
||||
GLITZ_FILL_NEAREST, /* RepeatPad */
|
||||
GLITZ_FILL_REFLECT /* RepeatReflect */
|
||||
};
|
||||
|
||||
static void
|
||||
xglUpdatePicture (PicturePtr pPicture)
|
||||
{
|
||||
glitz_surface_t *surface;
|
||||
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pPicture->pDrawable);
|
||||
|
||||
surface = pPixmapPriv->surface;
|
||||
|
||||
if (pPixmapPriv->pictureMask & xglPCFillMask)
|
||||
{
|
||||
glitz_surface_set_fill (surface, fillMode[pPicture->repeat]);
|
||||
}
|
||||
|
||||
if (pPixmapPriv->pictureMask & xglPCFilterMask)
|
||||
{
|
||||
switch (pPicture->filter) {
|
||||
case PictFilterNearest:
|
||||
case PictFilterFast:
|
||||
glitz_surface_set_filter (surface, GLITZ_FILTER_NEAREST, NULL, 0);
|
||||
break;
|
||||
case PictFilterGood:
|
||||
case PictFilterBest:
|
||||
case PictFilterBilinear:
|
||||
glitz_surface_set_filter (surface, GLITZ_FILTER_BILINEAR, NULL, 0);
|
||||
break;
|
||||
case PictFilterConvolution:
|
||||
glitz_surface_set_filter (surface, GLITZ_FILTER_CONVOLUTION,
|
||||
(glitz_fixed16_16_t *)
|
||||
pPicture->filter_params,
|
||||
pPicture->filter_nparams);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pPixmapPriv->pictureMask & xglPCTransformMask)
|
||||
{
|
||||
glitz_surface_set_transform (surface, (glitz_transform_t *)
|
||||
pPicture->transform);
|
||||
}
|
||||
|
||||
if (pPixmapPriv->pictureMask & xglPCComponentAlphaMask)
|
||||
{
|
||||
glitz_surface_set_component_alpha (surface, pPicture->componentAlpha);
|
||||
}
|
||||
|
||||
if (pPixmapPriv->pictureMask & xglPCDitherMask)
|
||||
{
|
||||
glitz_surface_set_dither (surface, pPicture->dither);
|
||||
}
|
||||
|
||||
pPixmapPriv->pictureMask &= ~XGL_PICTURE_CHANGES (~0);
|
||||
}
|
||||
|
||||
#define N_STACK_PARAM 256
|
||||
|
||||
static int gradientNParam[] = {
|
||||
0, /* SourcePictTypeSolidFill */
|
||||
4, /* SourcePictTypeLinear */
|
||||
6, /* SourcePictTypeRadial */
|
||||
4, /* SourcePictTypeConical */
|
||||
};
|
||||
|
||||
Bool
|
||||
xglSyncPicture (ScreenPtr pScreen,
|
||||
PicturePtr pPicture,
|
||||
INT16 x,
|
||||
INT16 y,
|
||||
CARD16 width,
|
||||
CARD16 height,
|
||||
INT16 *xOff,
|
||||
INT16 *yOff)
|
||||
{
|
||||
xglPixmapPtr pPixmapPriv;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
*xOff = *yOff = 0;
|
||||
|
||||
if (pPicture->pSourcePict)
|
||||
{
|
||||
if (pPicture->pSourcePict->source.devPrivate.ptr)
|
||||
return TRUE;
|
||||
|
||||
if (pPicture->pDrawable)
|
||||
{
|
||||
(*pScreen->DestroyPixmap) ((PixmapPtr) pPicture->pDrawable);
|
||||
pPicture->pDrawable = (DrawablePtr) 0;
|
||||
}
|
||||
|
||||
switch (pPicture->pSourcePict->source.type) {
|
||||
case SourcePictTypeSolidFill:
|
||||
x = y = 0;
|
||||
width = height = 1;
|
||||
break;
|
||||
case SourcePictTypeLinear:
|
||||
case SourcePictTypeRadial: {
|
||||
glitz_fixed16_16_t stackParam[N_STACK_PARAM];
|
||||
glitz_fixed16_16_t *param;
|
||||
int nParam, nStop, size, i;
|
||||
CARD32 *pixel;
|
||||
PictGradientStopPtr pStop;
|
||||
glitz_buffer_t *buffer;
|
||||
glitz_format_t *format;
|
||||
glitz_surface_t *surface;
|
||||
static glitz_pixel_format_t pixelFormat = {
|
||||
GLITZ_FOURCC_RGB,
|
||||
{
|
||||
32,
|
||||
0xff000000,
|
||||
0x00ff0000,
|
||||
0x0000ff00,
|
||||
0x000000ff
|
||||
},
|
||||
0, 0, 0,
|
||||
GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP
|
||||
};
|
||||
|
||||
if (!(pScreenPriv->features & GLITZ_FEATURE_FRAGMENT_PROGRAM_MASK))
|
||||
break;
|
||||
|
||||
format = glitz_find_standard_format (pScreenPriv->drawable,
|
||||
GLITZ_STANDARD_ARGB32);
|
||||
if (!format)
|
||||
break;
|
||||
|
||||
nParam = gradientNParam[pPicture->pSourcePict->gradient.type];
|
||||
pStop = pPicture->pSourcePict->gradient.stops;
|
||||
nStop = pPicture->pSourcePict->gradient.nstops;
|
||||
|
||||
size = nParam + nStop * 4;
|
||||
if (size > N_STACK_PARAM)
|
||||
{
|
||||
param = malloc (sizeof (xFixed) * size);
|
||||
if (!param)
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
param = stackParam;
|
||||
}
|
||||
|
||||
pixel = (CARD32 *) (param + nParam + nStop * 3);
|
||||
|
||||
buffer = glitz_buffer_create_for_data (pixel);
|
||||
if (!buffer)
|
||||
{
|
||||
if (size > N_STACK_PARAM)
|
||||
free (param);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
surface = glitz_surface_create (pScreenPriv->drawable,
|
||||
format, nStop, 1, 0, NULL);
|
||||
if (!surface)
|
||||
{
|
||||
glitz_buffer_destroy (buffer);
|
||||
if (size > N_STACK_PARAM)
|
||||
free (param);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; i < nStop; i++)
|
||||
{
|
||||
pixel[i] = pStop[i].color;
|
||||
|
||||
param[nParam + 3 * i + 0] = pStop[i].x;
|
||||
param[nParam + 3 * i + 1] = i << 16;
|
||||
param[nParam + 3 * i + 2] = 0;
|
||||
}
|
||||
|
||||
glitz_set_pixels (surface, 0, 0, nStop, 1, &pixelFormat, buffer);
|
||||
|
||||
glitz_buffer_destroy (buffer);
|
||||
|
||||
switch (pPicture->pSourcePict->source.type) {
|
||||
case SourcePictTypeLinear:
|
||||
param[0] = pPicture->pSourcePict->linear.p1.x;
|
||||
param[1] = pPicture->pSourcePict->linear.p1.y;
|
||||
param[2] = pPicture->pSourcePict->linear.p2.x;
|
||||
param[3] = pPicture->pSourcePict->linear.p2.y;
|
||||
|
||||
glitz_surface_set_filter (surface,
|
||||
GLITZ_FILTER_LINEAR_GRADIENT,
|
||||
param, nParam + nStop * 3);
|
||||
break;
|
||||
case SourcePictTypeRadial:
|
||||
param[0] = pPicture->pSourcePict->radial.inner.x;
|
||||
param[1] = pPicture->pSourcePict->radial.inner.y;
|
||||
param[2] = pPicture->pSourcePict->radial.inner_radius;
|
||||
param[3] = pPicture->pSourcePict->radial.outer.x;
|
||||
param[4] = pPicture->pSourcePict->radial.outer.y;
|
||||
param[5] = pPicture->pSourcePict->radial.outer_radius;
|
||||
|
||||
glitz_surface_set_filter (surface,
|
||||
GLITZ_FILTER_RADIAL_GRADIENT,
|
||||
param, nParam + nStop * 3);
|
||||
break;
|
||||
}
|
||||
|
||||
glitz_surface_set_fill (surface, fillMode[pPicture->repeat]);
|
||||
glitz_surface_set_transform (surface, (glitz_transform_t *)
|
||||
pPicture->transform);
|
||||
|
||||
pPicture->pSourcePict->gradient.devPrivate.ptr = surface;
|
||||
pPicture->pSourcePict->gradient.Destroy = xglDestroyDevicePicture;
|
||||
|
||||
if (size > N_STACK_PARAM)
|
||||
free (param);
|
||||
|
||||
return TRUE;
|
||||
} break;
|
||||
case SourcePictTypeConical:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!pPicture->pDrawable)
|
||||
{
|
||||
PictFormatPtr pFormat;
|
||||
PixmapPtr pPixmap;
|
||||
PicturePtr pTmp;
|
||||
RegionRec region;
|
||||
BoxRec box;
|
||||
int error;
|
||||
|
||||
pFormat = PictureMatchFormat (pScreen, 32, PICT_a8r8g8b8);
|
||||
if (!pFormat)
|
||||
return FALSE;
|
||||
|
||||
pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height,
|
||||
pFormat->depth, 0);
|
||||
if (!pPixmap)
|
||||
return FALSE;
|
||||
|
||||
pTmp = CreatePicture (0, &pPixmap->drawable, pFormat, 0, NULL,
|
||||
serverClient, &error);
|
||||
if (!pTmp)
|
||||
{
|
||||
(*pScreen->DestroyPixmap) (pPixmap);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ValidatePicture (pTmp);
|
||||
|
||||
if (!xglSyncBits (pTmp->pDrawable, NullBox))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
|
||||
fbCompositeGeneral (PictOpSrc,
|
||||
pPicture, 0, pTmp,
|
||||
x, y, 0, 0, 0, 0,
|
||||
width, height);
|
||||
|
||||
FreePicture ((pointer) pTmp, (XID) 0);
|
||||
|
||||
box.x1 = 0;
|
||||
box.y1 = 0;
|
||||
box.x2 = width;
|
||||
box.y2 = height;
|
||||
|
||||
REGION_INIT (pScreen, ®ion, &box, 1);
|
||||
xglAddSurfaceDamage (&pPixmap->drawable, ®ion);
|
||||
REGION_UNINIT (pDrawable->pScreen, ®ion);
|
||||
|
||||
pPicture->pDrawable = &pPixmap->drawable;
|
||||
|
||||
*xOff = x;
|
||||
*yOff = y;
|
||||
|
||||
XGL_GET_PIXMAP_PRIV (pPixmap)->pictureMask &=
|
||||
~(xglPCFillMask | xglPCFilterMask | xglPCTransformMask);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef XV
|
||||
switch (pPicture->format) {
|
||||
case PICT_yuy2:
|
||||
xglSetPixmapVisual ((PixmapPtr) pPicture->pDrawable,
|
||||
&pScreenPriv->pXvVisual[XGL_XV_FORMAT_YUY2]);
|
||||
break;
|
||||
case PICT_yv12:
|
||||
xglSetPixmapVisual ((PixmapPtr) pPicture->pDrawable,
|
||||
&pScreenPriv->pXvVisual[XGL_XV_FORMAT_YV12]);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!xglSyncSurface (pPicture->pDrawable))
|
||||
return FALSE;
|
||||
|
||||
pPixmapPriv = XGL_GET_PIXMAP_PRIV ((PixmapPtr) pPicture->pDrawable);
|
||||
if (XGL_PICTURE_CHANGES (pPixmapPriv->pictureMask))
|
||||
xglUpdatePicture (pPicture);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
xglVisualDepth (ScreenPtr pScreen, VisualPtr pVisual)
|
||||
{
|
||||
DepthPtr pDepth;
|
||||
int d, v;
|
||||
|
||||
for (d = 0; d < pScreen->numDepths; d++)
|
||||
{
|
||||
pDepth = &pScreen->allowedDepths[d];
|
||||
for (v = 0; v < pDepth->numVids; v++)
|
||||
if (pDepth->vids[v] == pVisual->vid)
|
||||
return pDepth->depth;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
typedef struct _xglformatInit {
|
||||
CARD32 format;
|
||||
CARD8 depth;
|
||||
} xglFormatInitRec, *xglFormatInitPtr;
|
||||
|
||||
static int
|
||||
xglAddFormat (xglFormatInitPtr formats,
|
||||
int nformat,
|
||||
CARD32 format,
|
||||
CARD8 depth)
|
||||
{
|
||||
int n;
|
||||
|
||||
for (n = 0; n < nformat; n++)
|
||||
if (formats[n].format == format && formats[n].depth == depth)
|
||||
return nformat;
|
||||
|
||||
formats[nformat].format = format;
|
||||
formats[nformat].depth = depth;
|
||||
|
||||
return ++nformat;
|
||||
}
|
||||
|
||||
#define Mask(n) ((n) == 32 ? 0xffffffff : ((1 << (n)) - 1))
|
||||
|
||||
Bool
|
||||
xglPictureInit (ScreenPtr pScreen)
|
||||
{
|
||||
int f, nformats = 0;
|
||||
PictFormatPtr pFormats;
|
||||
xglFormatInitRec formats[64];
|
||||
CARD32 format;
|
||||
CARD8 depth;
|
||||
VisualPtr pVisual;
|
||||
int v;
|
||||
int bpp;
|
||||
int r, g, b;
|
||||
int d;
|
||||
DepthPtr pDepth;
|
||||
|
||||
/* formats required by protocol */
|
||||
formats[nformats].format = PICT_a1;
|
||||
formats[nformats].depth = 1;
|
||||
nformats++;
|
||||
formats[nformats].format = PICT_a4;
|
||||
formats[nformats].depth = 4;
|
||||
nformats++;
|
||||
formats[nformats].format = PICT_a8;
|
||||
formats[nformats].depth = 8;
|
||||
nformats++;
|
||||
formats[nformats].format = PICT_a8r8g8b8;
|
||||
formats[nformats].depth = 32;
|
||||
nformats++;
|
||||
|
||||
/* now look through the depths and visuals adding other formats */
|
||||
for (v = 0; v < pScreen->numVisuals; v++)
|
||||
{
|
||||
pVisual = &pScreen->visuals[v];
|
||||
depth = xglVisualDepth (pScreen, pVisual);
|
||||
if (!depth)
|
||||
continue;
|
||||
|
||||
bpp = BitsPerPixel (depth);
|
||||
switch (pVisual->class) {
|
||||
case DirectColor:
|
||||
case TrueColor:
|
||||
r = Ones (pVisual->redMask);
|
||||
g = Ones (pVisual->greenMask);
|
||||
b = Ones (pVisual->blueMask);
|
||||
if (pVisual->offsetBlue == 0 &&
|
||||
pVisual->offsetGreen == b &&
|
||||
pVisual->offsetRed == b + g)
|
||||
{
|
||||
format = PICT_FORMAT (bpp, PICT_TYPE_ARGB, 0, r, g, b);
|
||||
nformats = xglAddFormat (formats, nformats, format, depth);
|
||||
}
|
||||
break;
|
||||
case StaticColor:
|
||||
case PseudoColor:
|
||||
case StaticGray:
|
||||
case GrayScale:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* walk supported depths and add missing Direct formats */
|
||||
for (d = 0; d < pScreen->numDepths; d++)
|
||||
{
|
||||
pDepth = &pScreen->allowedDepths[d];
|
||||
bpp = BitsPerPixel (pDepth->depth);
|
||||
format = 0;
|
||||
switch (bpp) {
|
||||
case 16:
|
||||
if (pDepth->depth == 15)
|
||||
nformats = xglAddFormat (formats, nformats,
|
||||
PICT_x1r5g5b5, pDepth->depth);
|
||||
if (pDepth->depth == 16)
|
||||
nformats = xglAddFormat (formats, nformats,
|
||||
PICT_r5g6b5, pDepth->depth);
|
||||
break;
|
||||
case 24:
|
||||
if (pDepth->depth == 24)
|
||||
nformats = xglAddFormat (formats, nformats,
|
||||
PICT_r8g8b8, pDepth->depth);
|
||||
break;
|
||||
case 32:
|
||||
if (pDepth->depth == 24)
|
||||
nformats = xglAddFormat (formats, nformats,
|
||||
PICT_x8r8g8b8, pDepth->depth);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* add YUV formats */
|
||||
nformats = xglAddFormat (formats, nformats, PICT_yuy2, 16);
|
||||
nformats = xglAddFormat (formats, nformats, PICT_yv12, 12);
|
||||
|
||||
pFormats = (PictFormatPtr) xalloc (nformats * sizeof (PictFormatRec));
|
||||
if (!pFormats)
|
||||
return 0;
|
||||
|
||||
memset (pFormats, '\0', nformats * sizeof (PictFormatRec));
|
||||
for (f = 0; f < nformats; f++)
|
||||
{
|
||||
pFormats[f].id = FakeClientID (0);
|
||||
pFormats[f].depth = formats[f].depth;
|
||||
format = formats[f].format;
|
||||
pFormats[f].format = format;
|
||||
switch (PICT_FORMAT_TYPE (format)) {
|
||||
case PICT_TYPE_ARGB:
|
||||
pFormats[f].type = PictTypeDirect;
|
||||
pFormats[f].direct.alphaMask = Mask (PICT_FORMAT_A (format));
|
||||
if (pFormats[f].direct.alphaMask)
|
||||
pFormats[f].direct.alpha = (PICT_FORMAT_R (format) +
|
||||
PICT_FORMAT_G (format) +
|
||||
PICT_FORMAT_B (format));
|
||||
|
||||
pFormats[f].direct.redMask = Mask (PICT_FORMAT_R (format));
|
||||
pFormats[f].direct.red = (PICT_FORMAT_G (format) +
|
||||
PICT_FORMAT_B (format));
|
||||
|
||||
pFormats[f].direct.greenMask = Mask (PICT_FORMAT_G (format));
|
||||
pFormats[f].direct.green = PICT_FORMAT_B (format);
|
||||
|
||||
pFormats[f].direct.blueMask = Mask (PICT_FORMAT_B (format));
|
||||
pFormats[f].direct.blue = 0;
|
||||
break;
|
||||
case PICT_TYPE_A:
|
||||
pFormats[f].type = PictTypeDirect;
|
||||
pFormats[f].direct.alpha = 0;
|
||||
pFormats[f].direct.alphaMask = Mask (PICT_FORMAT_A (format));
|
||||
break;
|
||||
case PICT_TYPE_COLOR:
|
||||
case PICT_TYPE_GRAY:
|
||||
pFormats[f].type = PictTypeDirect;
|
||||
break;
|
||||
case PICT_TYPE_YUY2:
|
||||
case PICT_TYPE_YV12:
|
||||
pFormats[f].type = PictTypeOther;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!fbPictureInit (pScreen, pFormats, nformats))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
xglPictureClipExtents (PicturePtr pPicture,
|
||||
BoxPtr extents)
|
||||
{
|
||||
if (pPicture->clientClipType != CT_NONE)
|
||||
{
|
||||
BoxPtr clip = REGION_EXTENTS (pPicture->pDrawable->pScreen,
|
||||
(RegionPtr) pPicture->clientClip);
|
||||
|
||||
if (extents->x1 < pPicture->clipOrigin.x + clip->x1)
|
||||
extents->x1 = pPicture->clipOrigin.x + clip->x1;
|
||||
|
||||
if (extents->y1 < pPicture->clipOrigin.y + clip->y1)
|
||||
extents->y1 = pPicture->clipOrigin.y + clip->y1;
|
||||
|
||||
if (extents->x2 > pPicture->clipOrigin.x + clip->x2)
|
||||
extents->x2 = pPicture->clipOrigin.x + clip->x2;
|
||||
|
||||
if (extents->y2 > pPicture->clipOrigin.y + clip->y2)
|
||||
extents->y2 = pPicture->clipOrigin.y + clip->y2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (extents->x1 < 0)
|
||||
extents->x1 = 0;
|
||||
|
||||
if (extents->y1 < 0)
|
||||
extents->y1 = 0;
|
||||
|
||||
if (extents->x2 > pPicture->pDrawable->width)
|
||||
extents->x2 = pPicture->pDrawable->width;
|
||||
|
||||
if (extents->y2 > pPicture->pDrawable->height)
|
||||
extents->y2 = pPicture->pDrawable->height;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,744 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* 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
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
#include "fb.h"
|
||||
|
||||
static glitz_buffer_hint_t xglPixmapUsageHints[] = {
|
||||
(glitz_buffer_hint_t) 0, /* reserved for system memory */
|
||||
GLITZ_BUFFER_HINT_STREAM_DRAW,
|
||||
GLITZ_BUFFER_HINT_STREAM_READ,
|
||||
GLITZ_BUFFER_HINT_STREAM_COPY,
|
||||
GLITZ_BUFFER_HINT_STATIC_DRAW,
|
||||
GLITZ_BUFFER_HINT_STATIC_READ,
|
||||
GLITZ_BUFFER_HINT_STATIC_COPY,
|
||||
GLITZ_BUFFER_HINT_DYNAMIC_DRAW,
|
||||
GLITZ_BUFFER_HINT_DYNAMIC_READ,
|
||||
GLITZ_BUFFER_HINT_DYNAMIC_COPY
|
||||
};
|
||||
|
||||
#define NUM_XGL_PIXMAP_USAGE_HINTS \
|
||||
(sizeof (xglPixmapUsageHints) / sizeof (xglPixmapUsageHints[0]))
|
||||
|
||||
#define XGL_PIXMAP_USAGE_HINT(hint) (xglPixmapUsageHints[hint])
|
||||
|
||||
static void
|
||||
xglPixmapDamageReport (DamagePtr pDamage,
|
||||
RegionPtr pRegion,
|
||||
void *closure)
|
||||
{
|
||||
PixmapPtr pPixmap = (PixmapPtr) closure;
|
||||
BoxPtr pExt;
|
||||
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
pExt = REGION_EXTENTS (pPixmap->drawable.pScreen, pRegion);
|
||||
|
||||
if (BOX_NOTEMPTY (&pPixmapPriv->damageBox))
|
||||
{
|
||||
if (pExt->x1 < pPixmapPriv->damageBox.x1)
|
||||
pPixmapPriv->damageBox.x1 = pExt->x1;
|
||||
|
||||
if (pExt->y1 < pPixmapPriv->damageBox.y1)
|
||||
pPixmapPriv->damageBox.y1 = pExt->y1;
|
||||
|
||||
if (pExt->x2 > pPixmapPriv->damageBox.x2)
|
||||
pPixmapPriv->damageBox.x2 = pExt->x2;
|
||||
|
||||
if (pExt->y2 > pPixmapPriv->damageBox.y2)
|
||||
pPixmapPriv->damageBox.y2 = pExt->y2;
|
||||
}
|
||||
else
|
||||
pPixmapPriv->damageBox = *pExt;
|
||||
}
|
||||
|
||||
|
||||
static Bool
|
||||
xglPixmapCreateDamage (PixmapPtr pPixmap)
|
||||
{
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
pPixmapPriv->pDamage =
|
||||
DamageCreate (xglPixmapDamageReport, (DamageDestroyFunc) 0,
|
||||
DamageReportRawRegion, TRUE,
|
||||
pPixmap->drawable.pScreen,
|
||||
(void *) pPixmap);
|
||||
if (!pPixmapPriv->pDamage)
|
||||
return FALSE;
|
||||
|
||||
DamageRegister (&pPixmap->drawable, pPixmapPriv->pDamage);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
xglSetPixmapVisual (PixmapPtr pPixmap,
|
||||
xglVisualPtr pVisual)
|
||||
{
|
||||
xglVisualPtr pOldVisual;
|
||||
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
pOldVisual = pPixmapPriv->pVisual;
|
||||
if (pOldVisual && pVisual)
|
||||
{
|
||||
glitz_surface_t *surface;
|
||||
|
||||
if (pOldVisual->vid != pVisual->vid)
|
||||
{
|
||||
surface = pPixmapPriv->surface;
|
||||
if (surface)
|
||||
{
|
||||
glitz_drawable_t *drawable;
|
||||
|
||||
drawable = glitz_surface_get_attached_drawable (surface);
|
||||
if (drawable)
|
||||
{
|
||||
if (pOldVisual->format.drawable->id !=
|
||||
pVisual->format.drawable->id)
|
||||
{
|
||||
glitz_surface_detach (pPixmapPriv->surface);
|
||||
pPixmapPriv->target = xglPixmapTargetOut;
|
||||
}
|
||||
}
|
||||
|
||||
if (pOldVisual->format.surface->id != pVisual->format.surface->id)
|
||||
{
|
||||
xglSyncBits (&pPixmap->drawable, NULL);
|
||||
glitz_surface_destroy (pPixmapPriv->surface);
|
||||
pPixmapPriv->surface = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (pOldVisual)
|
||||
{
|
||||
if (pPixmapPriv->surface)
|
||||
{
|
||||
xglSyncBits (&pPixmap->drawable, NULL);
|
||||
glitz_surface_destroy (pPixmapPriv->surface);
|
||||
pPixmapPriv->surface = 0;
|
||||
}
|
||||
pPixmapPriv->target = xglPixmapTargetNo;
|
||||
}
|
||||
|
||||
pPixmapPriv->pVisual = pVisual;
|
||||
|
||||
if (pPixmapPriv->pVisual && pPixmapPriv->pVisual->format.surface)
|
||||
{
|
||||
if (!pPixmapPriv->pDamage)
|
||||
{
|
||||
if (!xglPixmapCreateDamage (pPixmap))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static Bool
|
||||
xglPixmapSurfaceInit (PixmapPtr pPixmap,
|
||||
unsigned long features,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
BoxRec box;
|
||||
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
pPixmapPriv->surface = NULL;
|
||||
pPixmapPriv->drawable = NULL;
|
||||
pPixmapPriv->acceleratedTile = FALSE;
|
||||
pPixmapPriv->pictureMask = ~0;
|
||||
pPixmapPriv->target = xglPixmapTargetNo;
|
||||
|
||||
box.x1 = 0;
|
||||
box.y1 = 0;
|
||||
box.x2 = width;
|
||||
box.y2 = height;
|
||||
|
||||
REGION_INIT (pScreen, &pPixmapPriv->bitRegion, &box, 1);
|
||||
|
||||
pPixmapPriv->pVisual = xglFindVisualWithDepth (pPixmap->drawable.pScreen,
|
||||
pPixmap->drawable.depth);
|
||||
if (pPixmapPriv->pVisual)
|
||||
{
|
||||
XGL_SCREEN_PRIV (pPixmap->drawable.pScreen);
|
||||
|
||||
/* general pixmap acceleration */
|
||||
if (pPixmapPriv->pVisual->format.drawable &&
|
||||
pScreenPriv->accel.pixmap.enabled &&
|
||||
xglCheckPixmapSize (pPixmap, &pScreenPriv->accel.pixmap.size))
|
||||
pPixmapPriv->target = xglPixmapTargetOut;
|
||||
}
|
||||
|
||||
if (pPixmapPriv->pVisual && pPixmapPriv->pVisual->format.surface)
|
||||
{
|
||||
if (!pPixmapPriv->pDamage)
|
||||
{
|
||||
if (!xglPixmapCreateDamage (pPixmap))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
}
|
||||
|
||||
if (width && height)
|
||||
{
|
||||
if (width == 1 && height == 1)
|
||||
{
|
||||
pPixmapPriv->acceleratedTile = TRUE;
|
||||
}
|
||||
else if (features & GLITZ_FEATURE_TEXTURE_BORDER_CLAMP_MASK)
|
||||
{
|
||||
if ((features & GLITZ_FEATURE_TEXTURE_NON_POWER_OF_TWO_MASK) ||
|
||||
(POWER_OF_TWO (width) && POWER_OF_TWO (height)))
|
||||
pPixmapPriv->acceleratedTile = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
PixmapPtr
|
||||
xglCreatePixmap (ScreenPtr pScreen,
|
||||
int width,
|
||||
int height,
|
||||
int depth,
|
||||
unsigned usage_hint)
|
||||
{
|
||||
xglPixmapPtr pPixmapPriv;
|
||||
PixmapPtr pPixmap;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
pPixmap = AllocatePixmap (pScreen, 0);
|
||||
if (!pPixmap)
|
||||
return NullPixmap;
|
||||
|
||||
pPixmap->drawable.type = DRAWABLE_PIXMAP;
|
||||
pPixmap->drawable.class = 0;
|
||||
pPixmap->drawable.pScreen = pScreen;
|
||||
pPixmap->drawable.depth = depth;
|
||||
pPixmap->drawable.bitsPerPixel = BitsPerPixel (depth);
|
||||
pPixmap->drawable.id = 0;
|
||||
pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
|
||||
pPixmap->drawable.x = 0;
|
||||
pPixmap->drawable.y = 0;
|
||||
pPixmap->drawable.width = width;
|
||||
pPixmap->drawable.height = height;
|
||||
|
||||
#ifdef COMPOSITE
|
||||
pPixmap->screen_x = 0;
|
||||
pPixmap->screen_y = 0;
|
||||
#endif
|
||||
|
||||
pPixmap->devKind = 0;
|
||||
pPixmap->refcnt = 1;
|
||||
pPixmap->devPrivate.ptr = 0;
|
||||
pPixmap->usage_hint = usage_hint;
|
||||
|
||||
pPixmapPriv = XGL_GET_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
pPixmapPriv->pVisual = NULL;
|
||||
pPixmapPriv->pDamage = NULL;
|
||||
|
||||
if (!xglPixmapSurfaceInit (pPixmap, pScreenPriv->features, width, height))
|
||||
return NullPixmap;
|
||||
|
||||
pPixmapPriv->buffer = NULL;
|
||||
pPixmapPriv->bits = (pointer) 0;
|
||||
pPixmapPriv->stride = 0;
|
||||
pPixmapPriv->pGeometry = NULL;
|
||||
pPixmapPriv->allBits = TRUE;
|
||||
|
||||
pPixmapPriv->damageBox = miEmptyBox;
|
||||
|
||||
return pPixmap;
|
||||
}
|
||||
|
||||
void
|
||||
xglFiniPixmap (PixmapPtr pPixmap)
|
||||
{
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
if (pPixmap->devPrivate.ptr)
|
||||
{
|
||||
if (pPixmapPriv->buffer)
|
||||
glitz_buffer_unmap (pPixmapPriv->buffer);
|
||||
}
|
||||
|
||||
if (pPixmapPriv->pGeometry)
|
||||
GEOMETRY_UNINIT (pPixmapPriv->pGeometry);
|
||||
|
||||
if (pPixmapPriv->buffer)
|
||||
glitz_buffer_destroy (pPixmapPriv->buffer);
|
||||
|
||||
if (pPixmapPriv->bits)
|
||||
xfree (pPixmapPriv->bits);
|
||||
|
||||
REGION_UNINIT (pPixmap->drawable.pScreen, &pPixmapPriv->bitRegion);
|
||||
|
||||
if (pPixmapPriv->drawable)
|
||||
glitz_drawable_destroy (pPixmapPriv->drawable);
|
||||
|
||||
if (pPixmapPriv->surface)
|
||||
glitz_surface_destroy (pPixmapPriv->surface);
|
||||
}
|
||||
|
||||
Bool
|
||||
xglDestroyPixmap (PixmapPtr pPixmap)
|
||||
{
|
||||
if (--pPixmap->refcnt)
|
||||
return TRUE;
|
||||
|
||||
xglFiniPixmap (pPixmap);
|
||||
|
||||
dixFreePrivates(pPixmap->devPrivates);
|
||||
xfree (pPixmap);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglModifyPixmapHeader (PixmapPtr pPixmap,
|
||||
int width,
|
||||
int height,
|
||||
int depth,
|
||||
int bitsPerPixel,
|
||||
int devKind,
|
||||
pointer pPixData)
|
||||
{
|
||||
xglScreenPtr pScreenPriv;
|
||||
xglPixmapPtr pPixmapPriv;
|
||||
int oldWidth, oldHeight;
|
||||
|
||||
if (!pPixmap)
|
||||
return FALSE;
|
||||
|
||||
pScreenPriv = XGL_GET_SCREEN_PRIV (pPixmap->drawable.pScreen);
|
||||
pPixmapPriv = XGL_GET_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
oldWidth = pPixmap->drawable.width;
|
||||
oldHeight = pPixmap->drawable.height;
|
||||
|
||||
if ((width > 0) && (height > 0) && (depth > 0) && (bitsPerPixel > 0) &&
|
||||
(devKind > 0) && pPixData)
|
||||
{
|
||||
pPixmap->drawable.depth = depth;
|
||||
pPixmap->drawable.bitsPerPixel = bitsPerPixel;
|
||||
pPixmap->drawable.id = 0;
|
||||
pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
|
||||
pPixmap->drawable.x = 0;
|
||||
pPixmap->drawable.y = 0;
|
||||
pPixmap->drawable.width = width;
|
||||
pPixmap->drawable.height = height;
|
||||
pPixmapPriv->stride = devKind;
|
||||
pPixmap->refcnt = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (width > 0)
|
||||
pPixmap->drawable.width = width;
|
||||
|
||||
if (height > 0)
|
||||
pPixmap->drawable.height = height;
|
||||
|
||||
if (depth > 0)
|
||||
pPixmap->drawable.depth = depth;
|
||||
|
||||
if (bitsPerPixel > 0)
|
||||
pPixmap->drawable.bitsPerPixel = bitsPerPixel;
|
||||
else if ((bitsPerPixel < 0) && (depth > 0))
|
||||
pPixmap->drawable.bitsPerPixel = BitsPerPixel (depth);
|
||||
|
||||
if (devKind > 0)
|
||||
pPixmapPriv->stride = devKind;
|
||||
else if ((devKind < 0) && ((width > 0) || (depth > 0)))
|
||||
pPixmapPriv->stride = PixmapBytePad (pPixmap->drawable.width,
|
||||
pPixmap->drawable.depth);
|
||||
}
|
||||
|
||||
if (pPixmap->drawable.width != oldWidth ||
|
||||
pPixmap->drawable.height != oldHeight)
|
||||
{
|
||||
pPixmapPriv->pVisual = NULL;
|
||||
pPixmapPriv->target = xglPixmapTargetNo;
|
||||
|
||||
if (pPixmapPriv->drawable)
|
||||
glitz_drawable_destroy (pPixmapPriv->drawable);
|
||||
|
||||
if (pPixmapPriv->surface)
|
||||
glitz_surface_destroy (pPixmapPriv->surface);
|
||||
|
||||
REGION_UNINIT (pPixmap->drawable.pScreen, &pPixmapPriv->bitRegion);
|
||||
|
||||
if (!xglPixmapSurfaceInit (pPixmap,
|
||||
pScreenPriv->features,
|
||||
pPixmap->drawable.width,
|
||||
pPixmap->drawable.height))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (pPixData)
|
||||
{
|
||||
BoxRec box;
|
||||
|
||||
if (pPixmap->devPrivate.ptr)
|
||||
{
|
||||
if (pPixmapPriv->buffer)
|
||||
glitz_buffer_unmap (pPixmapPriv->buffer);
|
||||
|
||||
pPixmap->devPrivate.ptr = 0;
|
||||
}
|
||||
|
||||
if (pPixmapPriv->pGeometry)
|
||||
{
|
||||
GEOMETRY_UNINIT (pPixmapPriv->pGeometry);
|
||||
pPixmapPriv->pGeometry = NULL;
|
||||
}
|
||||
|
||||
if (pPixmapPriv->buffer)
|
||||
glitz_buffer_destroy (pPixmapPriv->buffer);
|
||||
|
||||
if (pPixmapPriv->bits)
|
||||
xfree (pPixmapPriv->bits);
|
||||
|
||||
pPixmapPriv->bits = (pointer) 0;
|
||||
pPixmapPriv->buffer = glitz_buffer_create_for_data (pPixData);
|
||||
if (!pPixmapPriv->buffer)
|
||||
return FALSE;
|
||||
|
||||
pPixmapPriv->allBits = TRUE;
|
||||
|
||||
box.x1 = 0;
|
||||
box.y1 = 0;
|
||||
box.x2 = pPixmap->drawable.width;
|
||||
box.y2 = pPixmap->drawable.height;
|
||||
|
||||
REGION_UNINIT (pPixmap->drawable.pScreen, &pPixmapPriv->bitRegion);
|
||||
REGION_INIT (pPixmap->drawable.pScreen, &pPixmapPriv->bitRegion,
|
||||
&box, 1);
|
||||
|
||||
if (pPixmapPriv->pDamage)
|
||||
{
|
||||
RegionPtr pRegion;
|
||||
|
||||
pRegion = DamageRegion (pPixmapPriv->pDamage);
|
||||
|
||||
REGION_UNINIT (pPixmap->drawable.pScreen, pRegion);
|
||||
REGION_INIT (pPixmap->drawable.pScreen, pRegion, NullBox, 0);
|
||||
REGION_SUBTRACT (pPixmap->drawable.pScreen, pRegion,
|
||||
&pPixmapPriv->bitRegion, pRegion);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Screen pixmap
|
||||
*/
|
||||
if (!pScreenPriv->pScreenPixmap || pScreenPriv->pScreenPixmap == pPixmap)
|
||||
{
|
||||
if (!pPixmapPriv->drawable)
|
||||
{
|
||||
glitz_drawable_reference (pScreenPriv->drawable);
|
||||
pPixmapPriv->drawable = pScreenPriv->drawable;
|
||||
}
|
||||
|
||||
if (!pPixmapPriv->surface)
|
||||
{
|
||||
glitz_surface_reference (pScreenPriv->surface);
|
||||
pPixmapPriv->surface = pScreenPriv->surface;
|
||||
}
|
||||
|
||||
pPixmapPriv->pVisual = pScreenPriv->rootVisual;
|
||||
pPixmapPriv->target = xglPixmapTargetIn;
|
||||
|
||||
if (!pScreenPriv->pScreenPixmap)
|
||||
pScreenPriv->pScreenPixmap = pPixmap;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
RegionPtr
|
||||
xglPixmapToRegion (PixmapPtr pPixmap)
|
||||
{
|
||||
ScreenPtr pScreen = pPixmap->drawable.pScreen;
|
||||
RegionPtr pRegion;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
if (!xglSyncBits (&pPixmap->drawable, NullBox))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
|
||||
XGL_SCREEN_UNWRAP (BitmapToRegion);
|
||||
pRegion = (*pScreen->BitmapToRegion) (pPixmap);
|
||||
XGL_SCREEN_WRAP (BitmapToRegion, xglPixmapToRegion);
|
||||
|
||||
return pRegion;
|
||||
}
|
||||
|
||||
xglGeometryPtr
|
||||
xglPixmapToGeometry (PixmapPtr pPixmap,
|
||||
int xOff,
|
||||
int yOff)
|
||||
{
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
if (pPixmap->devPrivate.ptr)
|
||||
xglUnmapPixmapBits (pPixmap);
|
||||
|
||||
if (!pPixmapPriv->pGeometry)
|
||||
{
|
||||
xglGeometryPtr pGeometry;
|
||||
|
||||
if (!pPixmapPriv->buffer)
|
||||
{
|
||||
if (!xglAllocatePixmapBits (pPixmap,
|
||||
XGL_PIXMAP_USAGE_HINT_DEFAULT))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pGeometry = xalloc (sizeof (xglGeometryRec));
|
||||
if (!pGeometry)
|
||||
return NULL;
|
||||
|
||||
GEOMETRY_INIT (pPixmap->drawable.pScreen, pGeometry,
|
||||
GLITZ_GEOMETRY_TYPE_BITMAP,
|
||||
GEOMETRY_USAGE_DYNAMIC, 0);
|
||||
|
||||
GEOMETRY_SET_BUFFER (pGeometry, pPixmapPriv->buffer);
|
||||
|
||||
if (pPixmapPriv->stride < 0)
|
||||
{
|
||||
pGeometry->f.bitmap.bytes_per_line = -pPixmapPriv->stride;
|
||||
pGeometry->f.bitmap.scanline_order =
|
||||
GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP;
|
||||
}
|
||||
else
|
||||
{
|
||||
pGeometry->f.bitmap.bytes_per_line = pPixmapPriv->stride;
|
||||
pGeometry->f.bitmap.scanline_order =
|
||||
GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN;
|
||||
}
|
||||
|
||||
pGeometry->f.bitmap.pad = ((1 + FB_MASK) >> FB_SHIFT) *
|
||||
sizeof (FbBits);
|
||||
pGeometry->width = pPixmap->drawable.width;
|
||||
pGeometry->count = pPixmap->drawable.height;
|
||||
|
||||
pPixmapPriv->pGeometry = pGeometry;
|
||||
}
|
||||
|
||||
pPixmapPriv->pGeometry->xOff = xOff << 16;
|
||||
pPixmapPriv->pGeometry->yOff = yOff << 16;
|
||||
|
||||
return pPixmapPriv->pGeometry;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglCreatePixmapSurface (PixmapPtr pPixmap)
|
||||
{
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
if (!pPixmapPriv->surface)
|
||||
{
|
||||
XGL_SCREEN_PRIV (pPixmap->drawable.pScreen);
|
||||
|
||||
if (!pPixmapPriv->pVisual || !pPixmapPriv->pVisual->format.surface)
|
||||
return FALSE;
|
||||
|
||||
pPixmapPriv->surface =
|
||||
glitz_surface_create (pScreenPriv->drawable,
|
||||
pPixmapPriv->pVisual->format.surface,
|
||||
pPixmap->drawable.width,
|
||||
pPixmap->drawable.height,
|
||||
0, NULL);
|
||||
if (!pPixmapPriv->surface)
|
||||
{
|
||||
pPixmapPriv->pVisual = NULL;
|
||||
pPixmapPriv->target = xglPixmapTargetNo;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglAllocatePixmapBits (PixmapPtr pPixmap, int hint)
|
||||
{
|
||||
int width, height, bpp, stride;
|
||||
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
XGL_SCREEN_PRIV (pPixmap->drawable.pScreen);
|
||||
|
||||
width = pPixmap->drawable.width;
|
||||
height = pPixmap->drawable.height;
|
||||
bpp = pPixmap->drawable.bitsPerPixel;
|
||||
|
||||
stride = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof (FbBits);
|
||||
|
||||
if (stride)
|
||||
{
|
||||
glitz_buffer_t *buffer;
|
||||
|
||||
if ((pScreenPriv->pboMask & bpp) && hint)
|
||||
{
|
||||
buffer = glitz_pixel_buffer_create (pScreenPriv->drawable,
|
||||
NULL, height * stride,
|
||||
XGL_PIXMAP_USAGE_HINT (hint));
|
||||
}
|
||||
else
|
||||
{
|
||||
pPixmapPriv->bits = xalloc (height * stride);
|
||||
if (!pPixmapPriv->bits)
|
||||
return FALSE;
|
||||
|
||||
buffer = glitz_buffer_create_for_data (pPixmapPriv->bits);
|
||||
}
|
||||
|
||||
if (!buffer)
|
||||
{
|
||||
if (pPixmapPriv->bits)
|
||||
xfree (pPixmapPriv->bits);
|
||||
pPixmapPriv->bits = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
pPixmapPriv->buffer = buffer;
|
||||
}
|
||||
|
||||
if (pScreenPriv->yInverted)
|
||||
pPixmapPriv->stride = stride;
|
||||
else
|
||||
pPixmapPriv->stride = -stride;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglMapPixmapBits (PixmapPtr pPixmap)
|
||||
{
|
||||
if (!pPixmap->devPrivate.ptr)
|
||||
{
|
||||
CARD8 *bits;
|
||||
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
if (!pPixmapPriv->buffer)
|
||||
if (!xglAllocatePixmapBits (pPixmap,
|
||||
XGL_PIXMAP_USAGE_HINT_DEFAULT))
|
||||
return FALSE;
|
||||
|
||||
bits = glitz_buffer_map (pPixmapPriv->buffer,
|
||||
GLITZ_BUFFER_ACCESS_READ_WRITE);
|
||||
if (!bits)
|
||||
return FALSE;
|
||||
|
||||
pPixmap->devKind = pPixmapPriv->stride;
|
||||
if (pPixmapPriv->stride < 0)
|
||||
{
|
||||
pPixmap->devPrivate.ptr = bits +
|
||||
(pPixmap->drawable.height - 1) * -pPixmapPriv->stride;
|
||||
}
|
||||
else
|
||||
{
|
||||
pPixmap->devPrivate.ptr = bits;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglUnmapPixmapBits (PixmapPtr pPixmap)
|
||||
{
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
pPixmap->devKind = 0;
|
||||
pPixmap->devPrivate.ptr = 0;
|
||||
|
||||
if (pPixmapPriv->buffer)
|
||||
if (glitz_buffer_unmap (pPixmapPriv->buffer))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglCheckPixmapSize (PixmapPtr pPixmap,
|
||||
xglSizeConstraintPtr pSize)
|
||||
{
|
||||
if (pPixmap->drawable.width < pSize->minWidth ||
|
||||
pPixmap->drawable.height < pSize->minHeight)
|
||||
return FALSE;
|
||||
|
||||
if (pPixmap->drawable.width > pSize->aboveWidth ||
|
||||
pPixmap->drawable.height > pSize->aboveHeight)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
xglEnablePixmapAccel (PixmapPtr pPixmap,
|
||||
xglAccelInfoPtr pAccel)
|
||||
{
|
||||
XGL_SCREEN_PRIV (pPixmap->drawable.pScreen);
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
if (pAccel->enabled && xglCheckPixmapSize (pPixmap, &pAccel->size))
|
||||
{
|
||||
xglVisualPtr v;
|
||||
|
||||
if (pAccel->pbuffer)
|
||||
{
|
||||
for (v = pScreenPriv->pVisual; v; v = v->next)
|
||||
{
|
||||
if (v->pPixel->depth != pPixmap->drawable.depth)
|
||||
continue;
|
||||
|
||||
if (v->format.drawable && v->pbuffer)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (v = pScreenPriv->pVisual; v; v = v->next)
|
||||
{
|
||||
if (v->pPixel->depth != pPixmap->drawable.depth)
|
||||
continue;
|
||||
|
||||
if (v->format.drawable && !v->pbuffer)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (v)
|
||||
{
|
||||
xglSetPixmapVisual (pPixmap, v);
|
||||
if (!pPixmapPriv->target)
|
||||
pPixmapPriv->target = xglPixmapTargetOut;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,473 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* 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
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
#include "inputstr.h"
|
||||
#include "mipointer.h"
|
||||
#include "damage.h"
|
||||
#include "fb.h"
|
||||
#ifdef MITSHM
|
||||
#include "shmint.h"
|
||||
static ShmFuncs shmFuncs = { NULL, xglShmPutImage };
|
||||
#endif
|
||||
#ifdef RENDER
|
||||
#include "glyphstr.h"
|
||||
#endif
|
||||
#ifdef COMPOSITE
|
||||
#include "compint.h"
|
||||
#endif
|
||||
|
||||
int xglScreenGeneration = -1;
|
||||
int xglScreenPrivateIndex;
|
||||
int xglGCPrivateIndex;
|
||||
int xglPixmapPrivateIndex;
|
||||
int xglWinPrivateIndex;
|
||||
|
||||
#ifdef RENDER
|
||||
int xglGlyphPrivateIndex;
|
||||
#endif
|
||||
|
||||
#define xglQueryBestSize (void *) NoopDDA
|
||||
#define xglSaveScreen (void *) NoopDDA
|
||||
|
||||
#define xglConstrainCursor (void *) NoopDDA
|
||||
#define xglCursorLimits (void *) NoopDDA
|
||||
#define xglDisplayCursor (void *) NoopDDA
|
||||
#define xglRealizeCursor (void *) NoopDDA
|
||||
#define xglUnrealizeCursor (void *) NoopDDA
|
||||
#define xglRecolorCursor (void *) NoopDDA
|
||||
#define xglSetCursorPosition (void *) NoopDDA
|
||||
|
||||
static Bool
|
||||
xglAllocatePrivates (ScreenPtr pScreen)
|
||||
{
|
||||
xglScreenPtr pScreenPriv;
|
||||
|
||||
if (xglScreenGeneration != serverGeneration)
|
||||
{
|
||||
xglScreenPrivateIndex = AllocateScreenPrivateIndex ();
|
||||
if (xglScreenPrivateIndex < 0)
|
||||
return FALSE;
|
||||
|
||||
xglGCPrivateIndex = AllocateGCPrivateIndex ();
|
||||
if (xglGCPrivateIndex < 0)
|
||||
return FALSE;
|
||||
|
||||
xglPixmapPrivateIndex = AllocatePixmapPrivateIndex ();
|
||||
if (xglPixmapPrivateIndex < 0)
|
||||
return FALSE;
|
||||
|
||||
xglWinPrivateIndex = AllocateWindowPrivateIndex ();
|
||||
if (xglWinPrivateIndex < 0)
|
||||
return FALSE;
|
||||
|
||||
#ifdef RENDER
|
||||
xglGlyphPrivateIndex = AllocateGlyphPrivateIndex ();
|
||||
if (xglGlyphPrivateIndex < 0)
|
||||
return FALSE;
|
||||
#endif
|
||||
|
||||
xglScreenGeneration = serverGeneration;
|
||||
}
|
||||
|
||||
if (!AllocateGCPrivate (pScreen, xglGCPrivateIndex, sizeof (xglGCRec)))
|
||||
return FALSE;
|
||||
|
||||
if (!AllocatePixmapPrivate (pScreen, xglPixmapPrivateIndex,
|
||||
sizeof (xglPixmapRec)))
|
||||
return FALSE;
|
||||
|
||||
if (!AllocateWindowPrivate (pScreen, xglWinPrivateIndex,
|
||||
sizeof (xglWinRec)))
|
||||
return FALSE;
|
||||
|
||||
pScreenPriv = xalloc (sizeof (xglScreenRec));
|
||||
if (!pScreenPriv)
|
||||
return FALSE;
|
||||
|
||||
XGL_SET_SCREEN_PRIV (pScreen, pScreenPriv);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglScreenInit (ScreenPtr pScreen)
|
||||
{
|
||||
xglScreenPtr pScreenPriv;
|
||||
xglVisualPtr v;
|
||||
int i, depth, bpp = 0;
|
||||
|
||||
#ifdef RENDER
|
||||
PictureScreenPtr pPictureScreen;
|
||||
#endif
|
||||
|
||||
depth = xglScreenInfo.depth;
|
||||
|
||||
for (v = xglVisuals; v; v = v->next)
|
||||
{
|
||||
if (v->pPixel->depth == depth)
|
||||
{
|
||||
bpp = v->pPixel->masks.bpp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bpp)
|
||||
return FALSE;
|
||||
|
||||
if (!xglAllocatePrivates (pScreen))
|
||||
return FALSE;
|
||||
|
||||
pScreenPriv = XGL_GET_SCREEN_PRIV (pScreen);
|
||||
|
||||
pScreenPriv->pScreenPixmap = NULL;
|
||||
|
||||
/* Add any unlisted depths from the pixmap formats */
|
||||
for (i = 0; i < screenInfo.numPixmapFormats; i++)
|
||||
{
|
||||
if (!xglHasVisualTypes (xglVisuals, screenInfo.formats[i].depth))
|
||||
xglSetVisualTypes (screenInfo.formats[i].depth, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
pScreenPriv->pVisual = 0;
|
||||
|
||||
#ifdef GLXEXT
|
||||
pScreenPriv->pGlxVisual = 0;
|
||||
#endif
|
||||
|
||||
pScreenPriv->rootVisual = 0;
|
||||
|
||||
pScreenPriv->drawable = xglScreenInfo.drawable;
|
||||
pScreenPriv->features =
|
||||
glitz_drawable_get_features (xglScreenInfo.drawable);
|
||||
|
||||
GEOMETRY_INIT (pScreen, &pScreenPriv->scratchGeometry,
|
||||
GLITZ_GEOMETRY_TYPE_VERTEX,
|
||||
pScreenPriv->geometryUsage, 0);
|
||||
|
||||
pScreenPriv->geometryDataType = xglScreenInfo.geometryDataType;
|
||||
pScreenPriv->geometryUsage = xglScreenInfo.geometryUsage;
|
||||
pScreenPriv->yInverted = xglScreenInfo.yInverted;
|
||||
pScreenPriv->pboMask = xglScreenInfo.pboMask;
|
||||
pScreenPriv->lines = xglScreenInfo.lines;
|
||||
pScreenPriv->accel = xglScreenInfo.accel;
|
||||
|
||||
if (monitorResolution == 0)
|
||||
monitorResolution = XGL_DEFAULT_DPI;
|
||||
|
||||
if (!fbSetupScreen (pScreen, NULL,
|
||||
xglScreenInfo.width, xglScreenInfo.height,
|
||||
monitorResolution, monitorResolution,
|
||||
xglScreenInfo.width, bpp))
|
||||
return FALSE;
|
||||
|
||||
pScreen->SaveScreen = xglSaveScreen;
|
||||
|
||||
pScreen->CreatePixmap = xglCreatePixmap;
|
||||
pScreen->DestroyPixmap = xglDestroyPixmap;
|
||||
|
||||
if (!fbFinishScreenInit (pScreen, NULL,
|
||||
xglScreenInfo.width, xglScreenInfo.height,
|
||||
monitorResolution, monitorResolution,
|
||||
xglScreenInfo.width, bpp))
|
||||
return FALSE;
|
||||
|
||||
#ifdef MITSHM
|
||||
ShmRegisterFuncs (pScreen, &shmFuncs);
|
||||
#endif
|
||||
|
||||
#ifdef RENDER
|
||||
if (!xglPictureInit (pScreen))
|
||||
return FALSE;
|
||||
#endif
|
||||
|
||||
XGL_SCREEN_WRAP (GetImage, xglGetImage);
|
||||
XGL_SCREEN_WRAP (GetSpans, xglGetSpans);
|
||||
|
||||
XGL_SCREEN_WRAP (CopyWindow, xglCopyWindow);
|
||||
XGL_SCREEN_WRAP (CreateWindow, xglCreateWindow);
|
||||
XGL_SCREEN_WRAP (DestroyWindow, xglDestroyWindow);
|
||||
XGL_SCREEN_WRAP (ChangeWindowAttributes, xglChangeWindowAttributes);
|
||||
|
||||
XGL_SCREEN_WRAP (CreateGC, xglCreateGC);
|
||||
|
||||
pScreen->ConstrainCursor = xglConstrainCursor;
|
||||
pScreen->CursorLimits = xglCursorLimits;
|
||||
pScreen->DisplayCursor = xglDisplayCursor;
|
||||
pScreen->RealizeCursor = xglRealizeCursor;
|
||||
pScreen->UnrealizeCursor = xglUnrealizeCursor;
|
||||
pScreen->RecolorCursor = xglRecolorCursor;
|
||||
pScreen->SetCursorPosition = xglSetCursorPosition;
|
||||
|
||||
pScreen->ModifyPixmapHeader = xglModifyPixmapHeader;
|
||||
|
||||
XGL_SCREEN_WRAP (BitmapToRegion, xglPixmapToRegion);
|
||||
|
||||
pScreen->GetWindowPixmap = xglGetWindowPixmap;
|
||||
|
||||
XGL_SCREEN_WRAP (SetWindowPixmap, xglSetWindowPixmap);
|
||||
|
||||
#ifdef RENDER
|
||||
pPictureScreen = GetPictureScreenIfSet (pScreen);
|
||||
if (pPictureScreen)
|
||||
{
|
||||
if (!AllocateGlyphPrivate (pScreen, xglGlyphPrivateIndex,
|
||||
sizeof (xglGlyphRec)))
|
||||
return FALSE;
|
||||
|
||||
XGL_PICTURE_SCREEN_WRAP (RealizeGlyph, xglRealizeGlyph);
|
||||
XGL_PICTURE_SCREEN_WRAP (UnrealizeGlyph, xglUnrealizeGlyph);
|
||||
XGL_PICTURE_SCREEN_WRAP (Composite, xglComposite);
|
||||
XGL_PICTURE_SCREEN_WRAP (Glyphs, xglGlyphs);
|
||||
XGL_PICTURE_SCREEN_WRAP (Trapezoids, xglTrapezoids);
|
||||
XGL_PICTURE_SCREEN_WRAP (AddTraps, xglAddTraps);
|
||||
XGL_PICTURE_SCREEN_WRAP (AddTriangles, xglAddTriangles);
|
||||
XGL_PICTURE_SCREEN_WRAP (ChangePicture, xglChangePicture);
|
||||
XGL_PICTURE_SCREEN_WRAP (ChangePictureTransform,
|
||||
xglChangePictureTransform);
|
||||
XGL_PICTURE_SCREEN_WRAP (ChangePictureFilter, xglChangePictureFilter);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!fbCreateDefColormap (pScreen))
|
||||
return FALSE;
|
||||
|
||||
#ifdef COMPOSITE
|
||||
#warning "composite building"
|
||||
if (!compScreenInit (pScreen))
|
||||
return FALSE;
|
||||
#endif
|
||||
|
||||
/* Damage is required */
|
||||
DamageSetup (pScreen);
|
||||
|
||||
XGL_SCREEN_WRAP (CloseScreen, xglCloseScreen);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglFinishScreenInit (ScreenPtr pScreen)
|
||||
{
|
||||
xglVisualPtr v;
|
||||
|
||||
#ifdef RENDER
|
||||
glitz_vertex_format_t *format;
|
||||
static glitz_color_t clearBlack = { 0x0, 0x0, 0x0, 0x0 };
|
||||
static glitz_color_t solidWhite = { 0xffff, 0xffff, 0xffff, 0xffff };
|
||||
int i;
|
||||
#endif
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
xglInitVisuals (pScreen);
|
||||
|
||||
for (v = pScreenPriv->pVisual; v; v = v->next)
|
||||
{
|
||||
if (v->vid == pScreen->rootVisual)
|
||||
pScreenPriv->rootVisual = v;
|
||||
}
|
||||
|
||||
if (!pScreenPriv->rootVisual || !pScreenPriv->rootVisual->format.surface)
|
||||
return FALSE;
|
||||
|
||||
pScreenPriv->surface =
|
||||
glitz_surface_create (pScreenPriv->drawable,
|
||||
pScreenPriv->rootVisual->format.surface,
|
||||
xglScreenInfo.width, xglScreenInfo.height,
|
||||
0, NULL);
|
||||
if (!pScreenPriv->surface)
|
||||
return FALSE;
|
||||
|
||||
glitz_surface_attach (pScreenPriv->surface,
|
||||
pScreenPriv->drawable,
|
||||
GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
|
||||
|
||||
#ifdef RENDER
|
||||
for (i = 0; i < 33; i++)
|
||||
pScreenPriv->glyphCache[i].pScreen = NULL;
|
||||
|
||||
for (v = pScreenPriv->pVisual; v; v = v->next)
|
||||
{
|
||||
if (v->pPixel->depth == 8)
|
||||
break;
|
||||
}
|
||||
|
||||
pScreenPriv->pSolidAlpha = 0;
|
||||
pScreenPriv->trapInfo.pMask = 0;
|
||||
|
||||
/* An accelerated alpha only Xgl visual is required for trapezoid
|
||||
acceleration */
|
||||
if (v && v->format.surface)
|
||||
{
|
||||
glitz_surface_t *mask;
|
||||
|
||||
mask = glitz_surface_create (pScreenPriv->drawable,
|
||||
v->format.surface,
|
||||
2, 1, 0, NULL);
|
||||
if (mask)
|
||||
{
|
||||
glitz_set_rectangle (mask, &clearBlack, 0, 0, 1, 1);
|
||||
glitz_set_rectangle (mask, &solidWhite, 1, 0, 1, 1);
|
||||
|
||||
glitz_surface_set_fill (mask, GLITZ_FILL_NEAREST);
|
||||
glitz_surface_set_filter (mask, GLITZ_FILTER_BILINEAR, NULL, 0);
|
||||
|
||||
pScreenPriv->trapInfo.pMask = xglCreateDevicePicture (mask);
|
||||
if (!pScreenPriv->trapInfo.pMask)
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
format = &pScreenPriv->trapInfo.format.vertex;
|
||||
format->primitive = GLITZ_PRIMITIVE_QUADS;
|
||||
format->attributes = GLITZ_VERTEX_ATTRIBUTE_MASK_COORD_MASK;
|
||||
|
||||
format->mask.type = GLITZ_DATA_TYPE_FLOAT;
|
||||
format->mask.size = GLITZ_COORDINATE_SIZE_X;
|
||||
format->bytes_per_vertex = sizeof (glitz_float_t);
|
||||
|
||||
if (pScreenPriv->geometryDataType)
|
||||
{
|
||||
format->type = GLITZ_DATA_TYPE_FLOAT;
|
||||
format->bytes_per_vertex += 2 * sizeof (glitz_float_t);
|
||||
format->mask.offset = 2 * sizeof (glitz_float_t);
|
||||
}
|
||||
else
|
||||
{
|
||||
format->type = GLITZ_DATA_TYPE_SHORT;
|
||||
format->bytes_per_vertex += 2 * sizeof (glitz_short_t);
|
||||
format->mask.offset = 2 * sizeof (glitz_short_t);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef XV
|
||||
if (!xglXvScreenInit (pScreen))
|
||||
return FALSE;
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglCloseScreen (int index,
|
||||
ScreenPtr pScreen)
|
||||
{
|
||||
xglVisualPtr v;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
XGL_PIXMAP_PRIV (pScreenPriv->pScreenPixmap);
|
||||
|
||||
#ifdef RENDER
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 33; i++)
|
||||
xglFiniGlyphCache (&pScreenPriv->glyphCache[i]);
|
||||
|
||||
if (pScreenPriv->pSolidAlpha)
|
||||
FreePicture ((pointer) pScreenPriv->pSolidAlpha, 0);
|
||||
|
||||
if (pScreenPriv->trapInfo.pMask)
|
||||
FreePicture ((pointer) pScreenPriv->trapInfo.pMask, 0);
|
||||
#endif
|
||||
|
||||
xglFiniPixmap (pScreenPriv->pScreenPixmap);
|
||||
if (pPixmapPriv->pDamage)
|
||||
DamageDestroy (pPixmapPriv->pDamage);
|
||||
|
||||
if (pScreenPriv->surface)
|
||||
glitz_surface_destroy (pScreenPriv->surface);
|
||||
|
||||
GEOMETRY_UNINIT (&pScreenPriv->scratchGeometry);
|
||||
|
||||
while (pScreenPriv->pVisual)
|
||||
{
|
||||
v = pScreenPriv->pVisual;
|
||||
pScreenPriv->pVisual = v->next;
|
||||
xfree (v);
|
||||
}
|
||||
|
||||
#ifdef GLXEXT
|
||||
while (pScreenPriv->pGlxVisual)
|
||||
{
|
||||
v = pScreenPriv->pGlxVisual;
|
||||
pScreenPriv->pGlxVisual = v->next;
|
||||
xfree (v);
|
||||
}
|
||||
#endif
|
||||
|
||||
XGL_SCREEN_UNWRAP (CloseScreen);
|
||||
xfree (pScreenPriv);
|
||||
|
||||
return (*pScreen->CloseScreen) (index, pScreen);
|
||||
}
|
||||
|
||||
#ifdef RENDER
|
||||
void
|
||||
xglCreateSolidAlphaPicture (ScreenPtr pScreen)
|
||||
{
|
||||
static xRenderColor solidWhite = { 0xffff, 0xffff, 0xffff, 0xffff };
|
||||
static xRectangle one = { 0, 0, 1, 1 };
|
||||
PixmapPtr pPixmap;
|
||||
PictFormatPtr pFormat;
|
||||
int error;
|
||||
Pixel pixel;
|
||||
GCPtr pGC;
|
||||
XID tmpval[2];
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
pFormat = PictureMatchFormat (pScreen, 32, PICT_a8r8g8b8);
|
||||
if (!pFormat)
|
||||
return;
|
||||
|
||||
pGC = GetScratchGC (pFormat->depth, pScreen);
|
||||
if (!pGC)
|
||||
return;
|
||||
|
||||
pPixmap = (*pScreen->CreatePixmap) (pScreen, 1, 1, pFormat->depth, 0);
|
||||
if (!pPixmap)
|
||||
return;
|
||||
|
||||
miRenderColorToPixel (pFormat, &solidWhite, &pixel);
|
||||
|
||||
tmpval[0] = GXcopy;
|
||||
tmpval[1] = pixel;
|
||||
|
||||
ChangeGC (pGC, GCFunction | GCForeground, tmpval);
|
||||
ValidateGC (&pPixmap->drawable, pGC);
|
||||
(*pGC->ops->PolyFillRect) (&pPixmap->drawable, pGC, 1, &one);
|
||||
FreeScratchGC (pGC);
|
||||
|
||||
tmpval[0] = xTrue;
|
||||
pScreenPriv->pSolidAlpha = CreatePicture (0, &pPixmap->drawable, pFormat,
|
||||
CPRepeat, tmpval,
|
||||
serverClient, &error);
|
||||
(*pScreen->DestroyPixmap) (pPixmap);
|
||||
|
||||
if (pScreenPriv->pSolidAlpha)
|
||||
ValidatePicture (pScreenPriv->pSolidAlpha);
|
||||
}
|
||||
#endif
|
123
hw/xgl/xglshm.c
123
hw/xgl/xglshm.c
|
@ -1,123 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2005 Novell, Inc.
|
||||
*
|
||||
* 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
|
||||
* Novell, Inc. not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* Novell, Inc. makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL NOVELL, INC. 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
#include "gcstruct.h"
|
||||
|
||||
#ifdef MITSHM
|
||||
|
||||
void
|
||||
xglShmPutImage (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int depth,
|
||||
unsigned int format,
|
||||
int w,
|
||||
int h,
|
||||
int sx,
|
||||
int sy,
|
||||
int sw,
|
||||
int sh,
|
||||
int dx,
|
||||
int dy,
|
||||
char *data)
|
||||
{
|
||||
ScreenPtr pScreen = pDrawable->pScreen;
|
||||
PixmapPtr pPixmapHeader = NULL;
|
||||
PixmapPtr pPixmap;
|
||||
int saveTarget;
|
||||
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
|
||||
|
||||
if ((format == ZPixmap) || (depth == 1))
|
||||
{
|
||||
pPixmap = pPixmapHeader =
|
||||
GetScratchPixmapHeader (pScreen, w, h, depth,
|
||||
BitsPerPixel (depth),
|
||||
PixmapBytePad (w, depth),
|
||||
(pointer) data);
|
||||
|
||||
/* disable any possible acceleration of this pixmap */
|
||||
if (pPixmap)
|
||||
xglSetPixmapVisual (pPixmap, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
pPixmap = (*pScreen->CreatePixmap) (pScreen, sw, sh, depth,
|
||||
CREATE_PIXMAP_USAGE_SCRATCH);
|
||||
if (pPixmap)
|
||||
{
|
||||
GCPtr pScratchGC;
|
||||
|
||||
if (!xglAllocatePixmapBits (pPixmap,
|
||||
XGL_PIXMAP_USAGE_HINT_DEFAULT))
|
||||
{
|
||||
(*pScreen->DestroyPixmap) (pPixmap);
|
||||
return;
|
||||
}
|
||||
|
||||
xglSetPixmapVisual (pPixmap, 0);
|
||||
|
||||
pScratchGC = GetScratchGC (depth, pScreen);
|
||||
if (!pScratchGC)
|
||||
{
|
||||
(*pScreen->DestroyPixmap) (pPixmap);
|
||||
return;
|
||||
}
|
||||
|
||||
ValidateGC ((DrawablePtr) pPixmap, pScratchGC);
|
||||
(*pGC->ops->PutImage) ((DrawablePtr) pPixmap, pScratchGC, depth,
|
||||
-sx, -sy, w, h, 0,
|
||||
(format == XYPixmap) ? XYPixmap : ZPixmap,
|
||||
data);
|
||||
|
||||
FreeScratchGC (pScratchGC);
|
||||
|
||||
sx = sy = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!pPixmap)
|
||||
return;
|
||||
|
||||
/* CopyArea should always be done in software */
|
||||
saveTarget = pPixmapPriv->target;
|
||||
pPixmapPriv->target = xglPixmapTargetNo;
|
||||
|
||||
if (format == XYBitmap)
|
||||
(*pGC->ops->CopyPlane) ((DrawablePtr) pPixmap, pDrawable, pGC,
|
||||
sx, sy, sw, sh, dx, dy, 1L);
|
||||
else
|
||||
(*pGC->ops->CopyArea) ((DrawablePtr) pPixmap, pDrawable, pGC,
|
||||
sx, sy, sw, sh, dx, dy);
|
||||
|
||||
pPixmapPriv->target = saveTarget;
|
||||
|
||||
if (pPixmapHeader)
|
||||
FreeScratchPixmapHeader (pPixmapHeader);
|
||||
else
|
||||
(*pScreen->DestroyPixmap) (pPixmap);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,159 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* 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
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
#include "gcstruct.h"
|
||||
#include <X11/fonts/fontstruct.h>
|
||||
#include "dixfontstr.h"
|
||||
|
||||
Bool
|
||||
xglSolid (DrawablePtr pDrawable,
|
||||
glitz_operator_t op,
|
||||
glitz_surface_t *solid,
|
||||
xglGeometryPtr pGeometry,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
BoxPtr pBox,
|
||||
int nBox)
|
||||
{
|
||||
glitz_surface_t *surface;
|
||||
int xOff, yOff;
|
||||
|
||||
if (nBox < 1)
|
||||
return TRUE;
|
||||
|
||||
if (!xglPrepareTarget (pDrawable))
|
||||
return FALSE;
|
||||
|
||||
XGL_GET_DRAWABLE (pDrawable, surface, xOff, yOff);
|
||||
|
||||
if (pGeometry)
|
||||
{
|
||||
glitz_surface_set_clip_region (surface, xOff, yOff,
|
||||
(glitz_box_t *) pBox, nBox);
|
||||
}
|
||||
else
|
||||
{
|
||||
pGeometry = xglGetScratchVertexGeometry (pDrawable->pScreen, 4 * nBox);
|
||||
GEOMETRY_ADD_BOX (pDrawable->pScreen, pGeometry, pBox, nBox);
|
||||
}
|
||||
|
||||
GEOMETRY_TRANSLATE (pGeometry, xOff, yOff);
|
||||
|
||||
if (!GEOMETRY_ENABLE (pGeometry, surface))
|
||||
return FALSE;
|
||||
|
||||
glitz_composite (op,
|
||||
solid, NULL, surface,
|
||||
0, 0,
|
||||
0, 0,
|
||||
x + xOff,
|
||||
y + yOff,
|
||||
width, height);
|
||||
|
||||
glitz_surface_set_clip_region (surface, 0, 0, NULL, 0);
|
||||
|
||||
if (glitz_surface_get_status (surface))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglSolidGlyph (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int x,
|
||||
int y,
|
||||
unsigned int nGlyph,
|
||||
CharInfoPtr *ppci,
|
||||
pointer pglyphBase)
|
||||
{
|
||||
xglGeometryRec geometry;
|
||||
int xBack, widthBack;
|
||||
int yBack, heightBack;
|
||||
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
x += pDrawable->x;
|
||||
y += pDrawable->y;
|
||||
|
||||
GEOMETRY_INIT (pDrawable->pScreen, &geometry,
|
||||
GLITZ_GEOMETRY_TYPE_BITMAP,
|
||||
GEOMETRY_USAGE_SYSMEM, 0);
|
||||
|
||||
GEOMETRY_FOR_GLYPH (pDrawable->pScreen,
|
||||
&geometry,
|
||||
nGlyph,
|
||||
ppci,
|
||||
pglyphBase);
|
||||
|
||||
GEOMETRY_TRANSLATE (&geometry, x, y);
|
||||
|
||||
widthBack = 0;
|
||||
while (nGlyph--)
|
||||
widthBack += (*ppci++)->metrics.characterWidth;
|
||||
|
||||
xBack = x;
|
||||
if (widthBack < 0)
|
||||
{
|
||||
xBack += widthBack;
|
||||
widthBack = -widthBack;
|
||||
}
|
||||
yBack = y - FONTASCENT (pGC->font);
|
||||
heightBack = FONTASCENT (pGC->font) + FONTDESCENT (pGC->font);
|
||||
|
||||
if (xglSolid (pDrawable,
|
||||
pGCPriv->op,
|
||||
pGCPriv->bg,
|
||||
NULL,
|
||||
xBack,
|
||||
yBack,
|
||||
widthBack,
|
||||
heightBack,
|
||||
REGION_RECTS (pGC->pCompositeClip),
|
||||
REGION_NUM_RECTS (pGC->pCompositeClip)))
|
||||
{
|
||||
if (xglSolid (pDrawable,
|
||||
pGCPriv->op,
|
||||
pGCPriv->fg,
|
||||
&geometry,
|
||||
xBack,
|
||||
yBack,
|
||||
widthBack,
|
||||
heightBack,
|
||||
REGION_RECTS (pGC->pCompositeClip),
|
||||
REGION_NUM_RECTS (pGC->pCompositeClip)))
|
||||
{
|
||||
GEOMETRY_UNINIT (&geometry);
|
||||
xglAddCurrentBitDamage (pDrawable);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
GEOMETRY_UNINIT (&geometry);
|
||||
return FALSE;
|
||||
}
|
453
hw/xgl/xglsync.c
453
hw/xgl/xglsync.c
|
@ -1,453 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* 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
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
|
||||
Bool
|
||||
xglSyncBits (DrawablePtr pDrawable,
|
||||
BoxPtr pExtents)
|
||||
{
|
||||
RegionRec region;
|
||||
BoxRec box;
|
||||
|
||||
XGL_DRAWABLE_PIXMAP (pDrawable);
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
if (pPixmapPriv->allBits)
|
||||
return xglMapPixmapBits (pPixmap);
|
||||
|
||||
if (pPixmapPriv->target == xglPixmapTargetIn && pExtents)
|
||||
{
|
||||
box.x1 = 0;
|
||||
box.y1 = 0;
|
||||
box.x2 = pPixmap->drawable.width;
|
||||
box.y2 = pPixmap->drawable.height;
|
||||
if (pExtents->x1 > box.x1)
|
||||
box.x1 = pExtents->x1;
|
||||
if (pExtents->y1 > box.y1)
|
||||
box.y1 = pExtents->y1;
|
||||
if (pExtents->x2 < box.x2)
|
||||
box.x2 = pExtents->x2;
|
||||
if (pExtents->y2 < box.y2)
|
||||
box.y2 = pExtents->y2;
|
||||
|
||||
if (box.x2 <= box.x1 || box.y2 <= box.y1)
|
||||
return xglMapPixmapBits (pPixmap);
|
||||
|
||||
if (REGION_NOTEMPTY (pDrawable->pScreen, &pPixmapPriv->bitRegion))
|
||||
{
|
||||
switch (RECT_IN_REGION (pDrawable->pScreen,
|
||||
&pPixmapPriv->bitRegion,
|
||||
&box)) {
|
||||
case rgnIN:
|
||||
REGION_INIT (pDrawable->pScreen, ®ion, NullBox, 0);
|
||||
break;
|
||||
case rgnOUT:
|
||||
REGION_INIT (pDrawable->pScreen, ®ion, &box, 1);
|
||||
REGION_UNION (pDrawable->pScreen,
|
||||
&pPixmapPriv->bitRegion, &pPixmapPriv->bitRegion,
|
||||
®ion);
|
||||
break;
|
||||
case rgnPART:
|
||||
REGION_INIT (pDrawable->pScreen, ®ion, &box, 1);
|
||||
REGION_SUBTRACT (pDrawable->pScreen, ®ion, ®ion,
|
||||
&pPixmapPriv->bitRegion);
|
||||
REGION_UNION (pDrawable->pScreen,
|
||||
&pPixmapPriv->bitRegion, &pPixmapPriv->bitRegion,
|
||||
®ion);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
REGION_INIT (pDrawable->pScreen, ®ion, &box, 1);
|
||||
REGION_SUBTRACT (pDrawable->pScreen, &pPixmapPriv->bitRegion,
|
||||
®ion, &pPixmapPriv->bitRegion);
|
||||
}
|
||||
|
||||
if (REGION_NUM_RECTS (&pPixmapPriv->bitRegion) == 1)
|
||||
{
|
||||
BoxPtr pBox;
|
||||
|
||||
pBox = REGION_RECTS (&pPixmapPriv->bitRegion);
|
||||
|
||||
if (pBox->x1 <= 0 &&
|
||||
pBox->y1 <= 0 &&
|
||||
pBox->x2 >= pPixmap->drawable.width &&
|
||||
pBox->y2 >= pPixmap->drawable.height)
|
||||
pPixmapPriv->allBits = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
box.x1 = 0;
|
||||
box.y1 = 0;
|
||||
box.x2 = pPixmap->drawable.width;
|
||||
box.y2 = pPixmap->drawable.height;
|
||||
|
||||
REGION_INIT (pDrawable->pScreen, ®ion, &box, 1);
|
||||
REGION_SUBTRACT (pDrawable->pScreen, ®ion, ®ion,
|
||||
&pPixmapPriv->bitRegion);
|
||||
|
||||
pPixmapPriv->allBits = TRUE;
|
||||
}
|
||||
|
||||
if (!pPixmapPriv->buffer)
|
||||
if (!xglAllocatePixmapBits (pPixmap, XGL_PIXMAP_USAGE_HINT_DEFAULT))
|
||||
return FALSE;
|
||||
|
||||
if (REGION_NOTEMPTY (pDrawable->pScreen, ®ion) && pPixmapPriv->surface)
|
||||
{
|
||||
glitz_pixel_format_t format;
|
||||
BoxPtr pBox;
|
||||
BoxPtr pExt;
|
||||
int nBox;
|
||||
|
||||
if (!xglSyncSurface (pDrawable))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
|
||||
xglUnmapPixmapBits (pPixmap);
|
||||
|
||||
pBox = REGION_RECTS (®ion);
|
||||
nBox = REGION_NUM_RECTS (®ion);
|
||||
pExt = REGION_EXTENTS (pDrawable->pScreen, ®ion);
|
||||
|
||||
format.fourcc = GLITZ_FOURCC_RGB;
|
||||
format.masks = pPixmapPriv->pVisual->pPixel->masks;
|
||||
format.xoffset = pExt->x1;
|
||||
|
||||
if (pPixmapPriv->stride < 0)
|
||||
{
|
||||
format.skip_lines = pPixmap->drawable.height - pExt->y2;
|
||||
format.bytes_per_line = -pPixmapPriv->stride;
|
||||
format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP;
|
||||
}
|
||||
else
|
||||
{
|
||||
format.skip_lines = pExt->y1;
|
||||
format.bytes_per_line = pPixmapPriv->stride;
|
||||
format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN;
|
||||
}
|
||||
|
||||
glitz_surface_set_clip_region (pPixmapPriv->surface,
|
||||
0, 0, (glitz_box_t *) pBox, nBox);
|
||||
|
||||
glitz_get_pixels (pPixmapPriv->surface,
|
||||
pExt->x1,
|
||||
pExt->y1,
|
||||
pExt->x2 - pExt->x1,
|
||||
pExt->y2 - pExt->y1,
|
||||
&format,
|
||||
pPixmapPriv->buffer);
|
||||
|
||||
glitz_surface_set_clip_region (pPixmapPriv->surface, 0, 0, NULL, 0);
|
||||
}
|
||||
|
||||
REGION_UNINIT (pDrawable->pScreen, ®ion);
|
||||
|
||||
if (pPixmapPriv->allBits)
|
||||
{
|
||||
box.x1 = 0;
|
||||
box.y1 = 0;
|
||||
box.x2 = pPixmap->drawable.width;
|
||||
box.y2 = pPixmap->drawable.height;
|
||||
|
||||
REGION_UNINIT (pDrawable->pScreen, &pPixmapPriv->bitRegion);
|
||||
REGION_INIT (pDrawable->pScreen, &pPixmapPriv->bitRegion, &box, 1);
|
||||
}
|
||||
|
||||
return xglMapPixmapBits (pPixmap);
|
||||
}
|
||||
|
||||
void
|
||||
xglSyncDamageBoxBits (DrawablePtr pDrawable)
|
||||
{
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
|
||||
|
||||
if (!xglSyncBits (pDrawable, &pPixmapPriv->damageBox))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
}
|
||||
|
||||
Bool
|
||||
xglSyncSurface (DrawablePtr pDrawable)
|
||||
{
|
||||
RegionPtr pRegion;
|
||||
|
||||
XGL_DRAWABLE_PIXMAP (pDrawable);
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
if (!pPixmapPriv->surface)
|
||||
{
|
||||
if (!xglCreatePixmapSurface (pPixmap))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pRegion = DamageRegion (pPixmapPriv->pDamage);
|
||||
|
||||
if (REGION_NOTEMPTY (pDrawable->pScreen, pRegion))
|
||||
{
|
||||
glitz_pixel_format_t format;
|
||||
BoxPtr pBox;
|
||||
BoxPtr pExt;
|
||||
int nBox;
|
||||
|
||||
xglUnmapPixmapBits (pPixmap);
|
||||
|
||||
nBox = REGION_NUM_RECTS (pRegion);
|
||||
pBox = REGION_RECTS (pRegion);
|
||||
pExt = REGION_EXTENTS (pDrawable->pScreen, pRegion);
|
||||
|
||||
format.fourcc = pPixmapPriv->pVisual->format.surface->color.fourcc;
|
||||
format.masks = pPixmapPriv->pVisual->pPixel->masks;
|
||||
format.xoffset = pExt->x1;
|
||||
|
||||
if (pPixmapPriv->stride < 0)
|
||||
{
|
||||
format.skip_lines = pPixmap->drawable.height - pExt->y2;
|
||||
format.bytes_per_line = -pPixmapPriv->stride;
|
||||
format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP;
|
||||
}
|
||||
else
|
||||
{
|
||||
format.skip_lines = pExt->y1;
|
||||
format.bytes_per_line = pPixmapPriv->stride;
|
||||
format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN;
|
||||
}
|
||||
|
||||
glitz_surface_set_clip_region (pPixmapPriv->surface,
|
||||
0, 0, (glitz_box_t *) pBox, nBox);
|
||||
|
||||
glitz_set_pixels (pPixmapPriv->surface,
|
||||
pExt->x1,
|
||||
pExt->y1,
|
||||
pExt->x2 - pExt->x1,
|
||||
pExt->y2 - pExt->y1,
|
||||
&format,
|
||||
pPixmapPriv->buffer);
|
||||
|
||||
glitz_surface_set_clip_region (pPixmapPriv->surface, 0, 0, NULL, 0);
|
||||
|
||||
REGION_EMPTY (pDrawable->pScreen, pRegion);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglPrepareTarget (DrawablePtr pDrawable)
|
||||
{
|
||||
XGL_DRAWABLE_PIXMAP (pDrawable);
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
switch (pPixmapPriv->target) {
|
||||
case xglPixmapTargetNo:
|
||||
break;
|
||||
case xglPixmapTargetOut:
|
||||
if (xglSyncSurface (pDrawable))
|
||||
{
|
||||
glitz_drawable_format_t *format;
|
||||
|
||||
XGL_SCREEN_PRIV (pDrawable->pScreen);
|
||||
|
||||
if (!pPixmapPriv->drawable)
|
||||
{
|
||||
unsigned int width, height;
|
||||
|
||||
format = pPixmapPriv->pVisual->format.drawable;
|
||||
width = pPixmap->drawable.width;
|
||||
height = pPixmap->drawable.height;
|
||||
|
||||
if (pPixmapPriv->pVisual->pbuffer)
|
||||
{
|
||||
pPixmapPriv->drawable =
|
||||
glitz_create_pbuffer_drawable (pScreenPriv->drawable,
|
||||
format, width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
pPixmapPriv->drawable =
|
||||
glitz_create_drawable (pScreenPriv->drawable,
|
||||
format, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
if (pPixmapPriv->drawable)
|
||||
{
|
||||
glitz_surface_attach (pPixmapPriv->surface,
|
||||
pPixmapPriv->drawable,
|
||||
GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
|
||||
|
||||
pPixmapPriv->target = xglPixmapTargetIn;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
pPixmapPriv->target = xglPixmapTargetNo;
|
||||
break;
|
||||
case xglPixmapTargetIn:
|
||||
if (xglSyncSurface (pDrawable))
|
||||
return TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
xglAddSurfaceDamage (DrawablePtr pDrawable,
|
||||
RegionPtr pRegion)
|
||||
{
|
||||
glitz_surface_t *surface;
|
||||
int xOff, yOff;
|
||||
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
|
||||
|
||||
pPixmapPriv->damageBox = miEmptyBox;
|
||||
|
||||
XGL_GET_DRAWABLE (pDrawable, surface, xOff, yOff);
|
||||
|
||||
if (xOff || yOff)
|
||||
REGION_TRANSLATE (pDrawable->pScreen, pRegion, xOff, yOff);
|
||||
|
||||
if (pPixmapPriv->pDamage)
|
||||
{
|
||||
RegionPtr pDamageRegion;
|
||||
|
||||
pDamageRegion = DamageRegion (pPixmapPriv->pDamage);
|
||||
|
||||
REGION_UNION (pDrawable->pScreen,
|
||||
pDamageRegion, pDamageRegion,
|
||||
pRegion);
|
||||
}
|
||||
|
||||
REGION_UNION (pDrawable->pScreen,
|
||||
&pPixmapPriv->bitRegion, &pPixmapPriv->bitRegion,
|
||||
pRegion);
|
||||
|
||||
if (xOff || yOff)
|
||||
REGION_TRANSLATE (pDrawable->pScreen, pRegion, -xOff, -yOff);
|
||||
}
|
||||
|
||||
void
|
||||
xglAddCurrentSurfaceDamage (DrawablePtr pDrawable)
|
||||
{
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
|
||||
|
||||
if (BOX_NOTEMPTY (&pPixmapPriv->damageBox))
|
||||
{
|
||||
RegionRec region;
|
||||
|
||||
REGION_INIT (pDrawable->pScreen, ®ion, &pPixmapPriv->damageBox, 1);
|
||||
|
||||
if (pPixmapPriv->pDamage)
|
||||
{
|
||||
RegionPtr pDamageRegion;
|
||||
|
||||
pDamageRegion = DamageRegion (pPixmapPriv->pDamage);
|
||||
|
||||
REGION_UNION (pDrawable->pScreen,
|
||||
pDamageRegion, pDamageRegion,
|
||||
®ion);
|
||||
}
|
||||
|
||||
REGION_UNION (pDrawable->pScreen,
|
||||
&pPixmapPriv->bitRegion, &pPixmapPriv->bitRegion,
|
||||
®ion);
|
||||
|
||||
REGION_UNINIT (pDrawable->pScreen, ®ion);
|
||||
|
||||
pPixmapPriv->damageBox = miEmptyBox;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
xglAddBitDamage (DrawablePtr pDrawable,
|
||||
RegionPtr pRegion)
|
||||
{
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
|
||||
|
||||
if (REGION_NOTEMPTY (pDrawable->pScreen, &pPixmapPriv->bitRegion))
|
||||
{
|
||||
BoxPtr pBox;
|
||||
BoxPtr pExt, pBitExt;
|
||||
int nBox;
|
||||
|
||||
pBox = REGION_RECTS (pRegion);
|
||||
pExt = REGION_EXTENTS (pDrawable->pScreen, pRegion);
|
||||
nBox = REGION_NUM_RECTS (pRegion);
|
||||
|
||||
pBitExt = REGION_EXTENTS (pDrawable->pScreen, &pPixmapPriv->bitRegion);
|
||||
|
||||
if (pExt->x1 < pBitExt->x2 &&
|
||||
pExt->y1 < pBitExt->y2 &&
|
||||
pExt->x2 > pBitExt->x1 &&
|
||||
pExt->y2 > pBitExt->y1)
|
||||
{
|
||||
while (nBox--)
|
||||
{
|
||||
if (pBox->x1 < pBitExt->x2 &&
|
||||
pBox->y1 < pBitExt->y2 &&
|
||||
pBox->x2 > pBitExt->x1 &&
|
||||
pBox->y2 > pBitExt->y1)
|
||||
{
|
||||
REGION_UNINIT (pDrawable->pScreen,
|
||||
&pPixmapPriv->bitRegion);
|
||||
REGION_INIT (pDrawable->pScreen, &pPixmapPriv->bitRegion,
|
||||
NullBox, 0);
|
||||
pPixmapPriv->allBits = FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
pBox++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
xglAddCurrentBitDamage (DrawablePtr pDrawable)
|
||||
{
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
|
||||
|
||||
if (REGION_NOTEMPTY (pDrawable->pScreen, &pPixmapPriv->bitRegion))
|
||||
{
|
||||
BoxPtr pBitExt;
|
||||
|
||||
pBitExt = REGION_EXTENTS (pDrawable->pScreen, &pPixmapPriv->bitRegion);
|
||||
|
||||
if (pPixmapPriv->damageBox.x1 < pBitExt->x2 &&
|
||||
pPixmapPriv->damageBox.y1 < pBitExt->y2 &&
|
||||
pPixmapPriv->damageBox.x2 > pBitExt->x1 &&
|
||||
pPixmapPriv->damageBox.y2 > pBitExt->y1)
|
||||
{
|
||||
REGION_UNINIT (pDrawable->pScreen, &pPixmapPriv->bitRegion);
|
||||
REGION_INIT (pDrawable->pScreen, &pPixmapPriv->bitRegion,
|
||||
NullBox, 0);
|
||||
pPixmapPriv->allBits = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
pPixmapPriv->damageBox = miEmptyBox;
|
||||
}
|
268
hw/xgl/xgltile.c
268
hw/xgl/xgltile.c
|
@ -1,268 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* 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
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
|
||||
static glitz_geometry_format_t tileGeometryFormat = {
|
||||
{
|
||||
GLITZ_PRIMITIVE_QUADS,
|
||||
GLITZ_DATA_TYPE_FLOAT,
|
||||
sizeof (glitz_float_t) * 4,
|
||||
GLITZ_VERTEX_ATTRIBUTE_SRC_COORD_MASK, {
|
||||
GLITZ_DATA_TYPE_FLOAT,
|
||||
GLITZ_COORDINATE_SIZE_XY,
|
||||
sizeof (glitz_float_t) * 2,
|
||||
}, {
|
||||
0, 0, 0
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
xglGeometryPtr
|
||||
xglTiledBoxGeometry (PixmapPtr pTile,
|
||||
int tileX,
|
||||
int tileY,
|
||||
BoxPtr pBox,
|
||||
int nBox)
|
||||
{
|
||||
ScreenPtr pScreen = pTile->drawable.pScreen;
|
||||
glitz_point_fixed_t p1, p2;
|
||||
xglGeometryPtr pGeometry;
|
||||
glitz_float_t x1, x2, y1, y2;
|
||||
int x, y, width, height, i;
|
||||
int xTile, yTile;
|
||||
int widthTile, heightTile;
|
||||
int widthTmp, xTmp, yTmp, xTileTmp;
|
||||
int tileWidth, tileHeight;
|
||||
int size = 0;
|
||||
glitz_float_t *data;
|
||||
|
||||
XGL_PIXMAP_PRIV (pTile);
|
||||
|
||||
tileWidth = pTile->drawable.width;
|
||||
tileHeight = pTile->drawable.height;
|
||||
|
||||
for (i = 0; i < nBox; i++)
|
||||
size +=
|
||||
(((pBox[i].x2 - pBox[i].x1) / tileWidth) + 2) *
|
||||
(((pBox[i].y2 - pBox[i].y1) / tileHeight) + 2);
|
||||
|
||||
pGeometry = xglGetScratchVertexGeometryWithType (pScreen,
|
||||
GEOMETRY_DATA_TYPE_FLOAT,
|
||||
8 * size);
|
||||
|
||||
data = glitz_buffer_map (pGeometry->buffer,
|
||||
GLITZ_BUFFER_ACCESS_WRITE_ONLY);
|
||||
|
||||
while (nBox--)
|
||||
{
|
||||
x = pBox->x1;
|
||||
y = pBox->y1;
|
||||
width = pBox->x2 - pBox->x1;
|
||||
height = pBox->y2 - pBox->y1;
|
||||
|
||||
xTile = MOD (tileX + x, tileWidth);
|
||||
yTile = MOD (tileY + y, tileHeight);
|
||||
|
||||
yTmp = y;
|
||||
|
||||
while (height)
|
||||
{
|
||||
heightTile = MIN (tileHeight - yTile, height);
|
||||
|
||||
xTileTmp = xTile;
|
||||
widthTmp = width;
|
||||
xTmp = x;
|
||||
|
||||
while (widthTmp)
|
||||
{
|
||||
widthTile = MIN (tileWidth - xTileTmp, widthTmp);
|
||||
|
||||
p1.x = xTileTmp << 16;
|
||||
p1.y = yTile << 16;
|
||||
p2.x = (xTileTmp + widthTile) << 16;
|
||||
p2.y = (yTile + heightTile) << 16;
|
||||
|
||||
glitz_surface_translate_point (pPixmapPriv->surface, &p1, &p1);
|
||||
glitz_surface_translate_point (pPixmapPriv->surface, &p2, &p2);
|
||||
|
||||
x1 = FIXED_TO_FLOAT (p1.x);
|
||||
y1 = FIXED_TO_FLOAT (p1.y);
|
||||
x2 = FIXED_TO_FLOAT (p2.x);
|
||||
y2 = FIXED_TO_FLOAT (p2.y);
|
||||
|
||||
*data++ = (glitz_float_t) xTmp;
|
||||
*data++ = (glitz_float_t) yTmp;
|
||||
*data++ = x1;
|
||||
*data++ = y1;
|
||||
|
||||
*data++ = (glitz_float_t) (xTmp + widthTile);
|
||||
*data++ = (glitz_float_t) yTmp;
|
||||
*data++ = x2;
|
||||
*data++ = y1;
|
||||
|
||||
*data++ = (glitz_float_t) (xTmp + widthTile);
|
||||
*data++ = (glitz_float_t) (yTmp + heightTile);
|
||||
*data++ = x2;
|
||||
*data++ = y2;
|
||||
|
||||
*data++ = (glitz_float_t) xTmp;
|
||||
*data++ = (glitz_float_t) (yTmp + heightTile);
|
||||
*data++ = x1;
|
||||
*data++ = y2;
|
||||
|
||||
pGeometry->endOffset += sizeof (glitz_float_t) * 16;
|
||||
|
||||
xTileTmp = 0;
|
||||
xTmp += widthTile;
|
||||
widthTmp -= widthTile;
|
||||
}
|
||||
|
||||
yTile = 0;
|
||||
yTmp += heightTile;
|
||||
height -= heightTile;
|
||||
}
|
||||
|
||||
pBox++;
|
||||
}
|
||||
|
||||
if (glitz_buffer_unmap (pGeometry->buffer))
|
||||
return NULL;
|
||||
|
||||
pGeometry->f = tileGeometryFormat;
|
||||
pGeometry->count =
|
||||
pGeometry->endOffset / tileGeometryFormat.vertex.bytes_per_vertex;
|
||||
|
||||
pPixmapPriv->pictureMask |= xglPCFillMask;
|
||||
glitz_surface_set_fill (pPixmapPriv->surface, GLITZ_FILL_TRANSPARENT);
|
||||
|
||||
return pGeometry;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglTile (DrawablePtr pDrawable,
|
||||
glitz_operator_t op,
|
||||
PixmapPtr pTile,
|
||||
int tileX,
|
||||
int tileY,
|
||||
xglGeometryPtr pGeometry,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
BoxPtr pBox,
|
||||
int nBox)
|
||||
{
|
||||
xglPixmapPtr pTilePriv;
|
||||
glitz_surface_t *surface;
|
||||
int xOff, yOff;
|
||||
|
||||
if (nBox < 1)
|
||||
return TRUE;
|
||||
|
||||
if (!xglPrepareTarget (pDrawable))
|
||||
return FALSE;
|
||||
|
||||
if (!xglSyncSurface (&pTile->drawable))
|
||||
return FALSE;
|
||||
|
||||
XGL_GET_DRAWABLE (pDrawable, surface, xOff, yOff);
|
||||
|
||||
pTilePriv = XGL_GET_PIXMAP_PRIV (pTile);
|
||||
|
||||
pTilePriv->pictureMask |= xglPCFilterMask | xglPCTransformMask;
|
||||
glitz_surface_set_filter (pTilePriv->surface,
|
||||
GLITZ_FILTER_NEAREST,
|
||||
NULL, 0);
|
||||
glitz_surface_set_transform (pTilePriv->surface, NULL);
|
||||
|
||||
if (pTilePriv->acceleratedTile)
|
||||
{
|
||||
if (pGeometry)
|
||||
{
|
||||
glitz_surface_set_clip_region (surface, xOff, yOff,
|
||||
(glitz_box_t *) pBox, nBox);
|
||||
nBox = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pGeometry = xglGetScratchVertexGeometry (pDrawable->pScreen,
|
||||
4 * nBox);
|
||||
GEOMETRY_ADD_BOX (pDrawable->pScreen, pGeometry, pBox, nBox);
|
||||
}
|
||||
|
||||
GEOMETRY_TRANSLATE (pGeometry, xOff, yOff);
|
||||
|
||||
if (!GEOMETRY_ENABLE (pGeometry, surface))
|
||||
return FALSE;
|
||||
|
||||
pTilePriv->pictureMask |= xglPCFillMask;
|
||||
glitz_surface_set_fill (pTilePriv->surface, GLITZ_FILL_REPEAT);
|
||||
|
||||
glitz_composite (op,
|
||||
pTilePriv->surface, NULL, surface,
|
||||
x + tileX,
|
||||
y + tileY,
|
||||
0, 0,
|
||||
x + xOff,
|
||||
y + yOff,
|
||||
width, height);
|
||||
|
||||
glitz_surface_set_clip_region (surface, 0, 0, NULL, 0);
|
||||
|
||||
if (!glitz_surface_get_status (surface))
|
||||
return TRUE;
|
||||
|
||||
if (!nBox)
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pGeometry)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pGeometry = xglTiledBoxGeometry (pTile, tileX, tileY, pBox, nBox);
|
||||
if (!pGeometry)
|
||||
return FALSE;
|
||||
|
||||
GEOMETRY_TRANSLATE (pGeometry, xOff, yOff);
|
||||
|
||||
if (!GEOMETRY_ENABLE (pGeometry, surface))
|
||||
return FALSE;
|
||||
|
||||
glitz_composite (op,
|
||||
pTilePriv->surface, NULL, surface,
|
||||
0, 0,
|
||||
0, 0,
|
||||
x + xOff,
|
||||
y + yOff,
|
||||
width, height);
|
||||
|
||||
if (glitz_surface_get_status (surface))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
481
hw/xgl/xgltrap.c
481
hw/xgl/xgltrap.c
|
@ -1,481 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2005 Novell, Inc.
|
||||
*
|
||||
* 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
|
||||
* Novell, Inc. not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* Novell, Inc. makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL NOVELL, INC. 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
#include "gcstruct.h"
|
||||
#include "damage.h"
|
||||
|
||||
#ifdef RENDER
|
||||
|
||||
#define XGL_TRAP_FALLBACK_PROLOGUE(pPicture, func) \
|
||||
xglSyncDamageBoxBits (pPicture->pDrawable); \
|
||||
XGL_PICTURE_SCREEN_UNWRAP (func)
|
||||
|
||||
#define XGL_TRAP_FALLBACK_EPILOGUE(pPicture, func, xglfunc) \
|
||||
XGL_PICTURE_SCREEN_WRAP (func, xglfunc); \
|
||||
xglAddCurrentSurfaceDamage (pPicture->pDrawable)
|
||||
|
||||
/* just a guess */
|
||||
#define SMOOTH_TRAPS_ESTIMATE_RECTS(nTrap) (30 * nTrap)
|
||||
|
||||
#define LINE_FIXED_X(l, _y, v) \
|
||||
dx = (l)->p2.x - (l)->p1.x; \
|
||||
ex = (xFixed_32_32) ((_y) - (l)->p1.y) * dx; \
|
||||
dy = (l)->p2.y - (l)->p1.y; \
|
||||
(v) = (l)->p1.x + (xFixed) (ex / dy)
|
||||
|
||||
#define LINE_FIXED_X_CEIL(l, _y, v) \
|
||||
dx = (l)->p2.x - (l)->p1.x; \
|
||||
ex = (xFixed_32_32) ((_y) - (l)->p1.y) * dx; \
|
||||
dy = (l)->p2.y - (l)->p1.y; \
|
||||
(v) = (l)->p1.x + (xFixed) ((ex + (dy - 1)) / dy)
|
||||
|
||||
static Bool
|
||||
xglTrapezoidExtents (PicturePtr pDst,
|
||||
int ntrap,
|
||||
xTrapezoid *traps,
|
||||
BoxPtr extents)
|
||||
{
|
||||
Bool x_overlap, overlap = FALSE;
|
||||
xFixed dx, dy, top, bottom;
|
||||
xFixed_32_32 ex;
|
||||
|
||||
if (!ntrap)
|
||||
{
|
||||
extents->x1 = MAXSHORT;
|
||||
extents->x2 = MINSHORT;
|
||||
extents->y1 = MAXSHORT;
|
||||
extents->y2 = MINSHORT;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
extents->y1 = xFixedToInt (traps->top);
|
||||
extents->y2 = xFixedToInt (xFixedCeil (traps->bottom));
|
||||
|
||||
LINE_FIXED_X (&traps->left, traps->top, top);
|
||||
LINE_FIXED_X (&traps->left, traps->bottom, bottom);
|
||||
extents->x1 = xFixedToInt (MIN (top, bottom));
|
||||
|
||||
LINE_FIXED_X_CEIL (&traps->right, traps->top, top);
|
||||
LINE_FIXED_X_CEIL (&traps->right, traps->bottom, bottom);
|
||||
extents->x2 = xFixedToInt (xFixedCeil (MAX (top, bottom)));
|
||||
|
||||
ntrap--;
|
||||
traps++;
|
||||
|
||||
for (; ntrap; ntrap--, traps++)
|
||||
{
|
||||
INT16 x1, y1, x2, y2;
|
||||
|
||||
if (!xTrapezoidValid (traps))
|
||||
continue;
|
||||
|
||||
y1 = xFixedToInt (traps->top);
|
||||
y2 = xFixedToInt (xFixedCeil (traps->bottom));
|
||||
|
||||
LINE_FIXED_X (&traps->left, traps->top, top);
|
||||
LINE_FIXED_X (&traps->left, traps->bottom, bottom);
|
||||
x1 = xFixedToInt (MIN (top, bottom));
|
||||
|
||||
LINE_FIXED_X_CEIL (&traps->right, traps->top, top);
|
||||
LINE_FIXED_X_CEIL (&traps->right, traps->bottom, bottom);
|
||||
x2 = xFixedToInt (xFixedCeil (MAX (top, bottom)));
|
||||
|
||||
x_overlap = FALSE;
|
||||
if (x1 >= extents->x2)
|
||||
extents->x2 = x2;
|
||||
else if (x2 <= extents->x1)
|
||||
extents->x1 = x1;
|
||||
else
|
||||
{
|
||||
x_overlap = TRUE;
|
||||
if (x1 < extents->x1)
|
||||
extents->x1 = x1;
|
||||
if (x2 > extents->x2)
|
||||
extents->x2 = x2;
|
||||
}
|
||||
|
||||
if (y1 >= extents->y2)
|
||||
extents->y2 = y2;
|
||||
else if (y2 <= extents->y1)
|
||||
extents->y1 = y1;
|
||||
else
|
||||
{
|
||||
if (y1 < extents->y1)
|
||||
extents->y1 = y1;
|
||||
if (y2 > extents->y2)
|
||||
extents->y2 = y2;
|
||||
|
||||
if (x_overlap)
|
||||
overlap = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
xglPictureClipExtents (pDst, extents);
|
||||
|
||||
return overlap;
|
||||
}
|
||||
|
||||
void
|
||||
xglTrapezoids (CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
int nTrap,
|
||||
xTrapezoid *traps)
|
||||
{
|
||||
ScreenPtr pScreen = pDst->pDrawable->pScreen;
|
||||
PicturePtr pMask = NULL, pSrcPicture, pDstPicture;
|
||||
PicturePtr pMaskPicture = NULL;
|
||||
xglGeometryPtr pGeometry = NULL;
|
||||
unsigned int polyEdge = pDst->polyEdge;
|
||||
INT16 xDst, yDst;
|
||||
INT16 xOff, yOff;
|
||||
BoxRec extents;
|
||||
Bool overlap;
|
||||
Bool target;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
xDst = traps[0].left.p1.x >> 16;
|
||||
yDst = traps[0].left.p1.y >> 16;
|
||||
|
||||
overlap = xglTrapezoidExtents (pDst, nTrap, traps, &extents);
|
||||
if (extents.y1 >= extents.y2 || extents.x1 >= extents.x2)
|
||||
return;
|
||||
|
||||
target = xglPrepareTarget (pDst->pDrawable);
|
||||
|
||||
if (nTrap > 1 && op != PictOpAdd && maskFormat &&
|
||||
(!target || overlap || op != PictOpOver))
|
||||
{
|
||||
PixmapPtr pPixmap;
|
||||
GCPtr pGC;
|
||||
xRectangle rect;
|
||||
int error;
|
||||
int area;
|
||||
|
||||
if (!pScreenPriv->pSolidAlpha)
|
||||
{
|
||||
xglCreateSolidAlphaPicture (pScreen);
|
||||
if (!pScreenPriv->pSolidAlpha)
|
||||
return;
|
||||
}
|
||||
|
||||
rect.x = 0;
|
||||
rect.y = 0;
|
||||
rect.width = extents.x2 - extents.x1;
|
||||
rect.height = extents.y2 - extents.y1;
|
||||
|
||||
pPixmap = (*pScreen->CreatePixmap) (pScreen,
|
||||
rect.width, rect.height,
|
||||
maskFormat->depth,
|
||||
CREATE_PIXMAP_USAGE_SCRATCH);
|
||||
if (!pPixmap)
|
||||
return;
|
||||
|
||||
pMask = CreatePicture (0, &pPixmap->drawable, maskFormat,
|
||||
0, 0, serverClient, &error);
|
||||
if (!pMask)
|
||||
{
|
||||
(*pScreen->DestroyPixmap) (pPixmap);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!target)
|
||||
{
|
||||
/* make sure we don't do accelerated drawing to mask */
|
||||
xglSetPixmapVisual (pPixmap, NULL);
|
||||
}
|
||||
|
||||
area = rect.width * rect.height;
|
||||
if ((SMOOTH_TRAPS_ESTIMATE_RECTS (nTrap) * 4) > area)
|
||||
XGL_GET_PIXMAP_PRIV (pPixmap)->target = xglPixmapTargetNo;
|
||||
|
||||
ValidatePicture (pMask);
|
||||
pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
|
||||
ValidateGC (&pPixmap->drawable, pGC);
|
||||
(*pGC->ops->PolyFillRect) (&pPixmap->drawable, pGC, 1, &rect);
|
||||
FreeScratchGC (pGC);
|
||||
|
||||
(*pScreen->DestroyPixmap) (pPixmap);
|
||||
|
||||
target = xglPrepareTarget (pMask->pDrawable);
|
||||
|
||||
xOff = -extents.x1;
|
||||
yOff = -extents.y1;
|
||||
pSrcPicture = pScreenPriv->pSolidAlpha;
|
||||
pDstPicture = pMask;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (maskFormat)
|
||||
{
|
||||
if (maskFormat->depth == 1)
|
||||
polyEdge = PolyEdgeSharp;
|
||||
else
|
||||
polyEdge = PolyEdgeSmooth;
|
||||
}
|
||||
|
||||
xOff = 0;
|
||||
yOff = 0;
|
||||
pSrcPicture = pSrc;
|
||||
pDstPicture = pDst;
|
||||
}
|
||||
|
||||
if (target)
|
||||
{
|
||||
if (maskFormat || polyEdge == PolyEdgeSmooth)
|
||||
{
|
||||
glitz_vertex_format_t *format;
|
||||
glitz_surface_t *mask;
|
||||
xTrapezoid *pTrap = traps;
|
||||
int nAddedTrap, n = nTrap;
|
||||
int offset = 0;
|
||||
int size = SMOOTH_TRAPS_ESTIMATE_RECTS (n);
|
||||
|
||||
pMaskPicture = pScreenPriv->trapInfo.pMask;
|
||||
format = &pScreenPriv->trapInfo.format.vertex;
|
||||
mask = pMaskPicture->pSourcePict->source.devPrivate.ptr;
|
||||
|
||||
size *= format->bytes_per_vertex;
|
||||
pGeometry = xglGetScratchGeometryWithSize (pScreen, size);
|
||||
|
||||
while (n)
|
||||
{
|
||||
if (pGeometry->size < size)
|
||||
GEOMETRY_RESIZE (pScreen, pGeometry, size);
|
||||
|
||||
if (!pGeometry->buffer)
|
||||
{
|
||||
if (pMask)
|
||||
FreePicture (pMask, 0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
offset +=
|
||||
glitz_add_trapezoids (pGeometry->buffer,
|
||||
offset, size - offset, format->type,
|
||||
mask, (glitz_trapezoid_t *) pTrap, n,
|
||||
&nAddedTrap);
|
||||
|
||||
n -= nAddedTrap;
|
||||
pTrap += nAddedTrap;
|
||||
size *= 2;
|
||||
}
|
||||
|
||||
pGeometry->f = pScreenPriv->trapInfo.format;
|
||||
pGeometry->count = offset / format->bytes_per_vertex;
|
||||
}
|
||||
else
|
||||
{
|
||||
pGeometry =
|
||||
xglGetScratchVertexGeometryWithType (pScreen,
|
||||
GEOMETRY_DATA_TYPE_FLOAT,
|
||||
4 * nTrap);
|
||||
if (!pGeometry->buffer)
|
||||
{
|
||||
if (pMask)
|
||||
FreePicture (pMask, 0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
GEOMETRY_ADD_TRAPEZOID (pScreen, pGeometry, traps, nTrap);
|
||||
}
|
||||
|
||||
GEOMETRY_TRANSLATE (pGeometry,
|
||||
pDstPicture->pDrawable->x + xOff,
|
||||
pDstPicture->pDrawable->y + yOff);
|
||||
}
|
||||
|
||||
if (pGeometry &&
|
||||
xglCompositeGeneral (pMask ? PictOpAdd : op,
|
||||
pSrcPicture,
|
||||
pMaskPicture,
|
||||
pDstPicture,
|
||||
pGeometry,
|
||||
extents.x1 + xOff + xSrc - xDst,
|
||||
extents.y1 + yOff + ySrc - yDst,
|
||||
0, 0,
|
||||
pDstPicture->pDrawable->x + extents.x1 + xOff,
|
||||
pDstPicture->pDrawable->y + extents.y1 + yOff,
|
||||
extents.x2 - extents.x1,
|
||||
extents.y2 - extents.y1))
|
||||
{
|
||||
/* no intermediate mask? we need to register damage from here as
|
||||
CompositePicture will never be called. */
|
||||
if (!pMask)
|
||||
{
|
||||
RegionRec region;
|
||||
|
||||
REGION_INIT (pScreen, ®ion, &extents, 1);
|
||||
REGION_TRANSLATE (pScreen, ®ion,
|
||||
pDst->pDrawable->x, pDst->pDrawable->y);
|
||||
|
||||
DamageDamageRegion (pDst->pDrawable, ®ion);
|
||||
|
||||
REGION_UNINIT (pScreen, ®ion);
|
||||
}
|
||||
|
||||
xglAddCurrentBitDamage (pDstPicture->pDrawable);
|
||||
}
|
||||
else
|
||||
{
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pDstPicture->pDrawable);
|
||||
|
||||
pPixmapPriv->damageBox.x1 = extents.x1 + xOff;
|
||||
pPixmapPriv->damageBox.y1 = extents.y1 + yOff;
|
||||
pPixmapPriv->damageBox.x2 = extents.x2 + xOff;
|
||||
pPixmapPriv->damageBox.y2 = extents.y2 + yOff;
|
||||
|
||||
xglSyncDamageBoxBits (pDstPicture->pDrawable);
|
||||
|
||||
if (pMask || (polyEdge == PolyEdgeSmooth &&
|
||||
op == PictOpAdd && miIsSolidAlpha (pSrc)))
|
||||
{
|
||||
PictureScreenPtr ps = GetPictureScreen (pScreen);
|
||||
|
||||
for (; nTrap; nTrap--, traps++)
|
||||
(*ps->RasterizeTrapezoid) (pDstPicture, traps, xOff, yOff);
|
||||
|
||||
xglAddCurrentSurfaceDamage (pDstPicture->pDrawable);
|
||||
}
|
||||
else
|
||||
miTrapezoids (op, pSrc, pDstPicture, maskFormat,
|
||||
xSrc, ySrc, nTrap, traps);
|
||||
}
|
||||
|
||||
if (pMask)
|
||||
{
|
||||
CompositePicture (op, pSrc, pMask, pDst,
|
||||
extents.x1 + xSrc - xDst,
|
||||
extents.y1 + ySrc - yDst,
|
||||
0, 0,
|
||||
extents.x1, extents.y1,
|
||||
extents.x2 - extents.x1,
|
||||
extents.y2 - extents.y1);
|
||||
|
||||
FreePicture (pMask, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
xglAddTraps (PicturePtr pDst,
|
||||
INT16 xOff,
|
||||
INT16 yOff,
|
||||
int nTrap,
|
||||
xTrap *traps)
|
||||
{
|
||||
PictureScreenPtr pPictureScreen;
|
||||
ScreenPtr pScreen = pDst->pDrawable->pScreen;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pDst->pDrawable);
|
||||
|
||||
if (!pScreenPriv->pSolidAlpha)
|
||||
{
|
||||
xglCreateSolidAlphaPicture (pScreen);
|
||||
if (!pScreenPriv->pSolidAlpha)
|
||||
return;
|
||||
}
|
||||
|
||||
pPixmapPriv->damageBox.x1 = 0;
|
||||
pPixmapPriv->damageBox.y1 = 0;
|
||||
pPixmapPriv->damageBox.x2 = pDst->pDrawable->width;
|
||||
pPixmapPriv->damageBox.y2 = pDst->pDrawable->height;
|
||||
|
||||
if (xglPrepareTarget (pDst->pDrawable))
|
||||
{
|
||||
PicturePtr pMask;
|
||||
glitz_vertex_format_t *format;
|
||||
glitz_surface_t *mask;
|
||||
xglGeometryPtr pGeometry;
|
||||
xTrap *pTrap = traps;
|
||||
int nAddedTrap, n = nTrap;
|
||||
int offset = 0;
|
||||
int size = SMOOTH_TRAPS_ESTIMATE_RECTS (n);
|
||||
|
||||
pMask = pScreenPriv->trapInfo.pMask;
|
||||
format = &pScreenPriv->trapInfo.format.vertex;
|
||||
mask = pMask->pSourcePict->source.devPrivate.ptr;
|
||||
|
||||
size *= format->bytes_per_vertex;
|
||||
pGeometry = xglGetScratchGeometryWithSize (pScreen, size);
|
||||
|
||||
while (n)
|
||||
{
|
||||
if (pGeometry->size < size)
|
||||
GEOMETRY_RESIZE (pScreen, pGeometry, size);
|
||||
|
||||
if (!pGeometry->buffer)
|
||||
return;
|
||||
|
||||
offset +=
|
||||
glitz_add_traps (pGeometry->buffer,
|
||||
offset, size - offset, format->type, mask,
|
||||
(glitz_trap_t *) pTrap, n,
|
||||
&nAddedTrap);
|
||||
|
||||
n -= nAddedTrap;
|
||||
pTrap += nAddedTrap;
|
||||
size *= 2;
|
||||
}
|
||||
|
||||
pGeometry->f = pScreenPriv->trapInfo.format;
|
||||
pGeometry->count = offset / format->bytes_per_vertex;
|
||||
|
||||
GEOMETRY_TRANSLATE (pGeometry,
|
||||
pDst->pDrawable->x + xOff,
|
||||
pDst->pDrawable->y + yOff);
|
||||
|
||||
if (xglCompositeGeneral (PictOpAdd,
|
||||
pScreenPriv->pSolidAlpha,
|
||||
pMask,
|
||||
pDst,
|
||||
pGeometry,
|
||||
0, 0,
|
||||
0, 0,
|
||||
pDst->pDrawable->x, pDst->pDrawable->y,
|
||||
pDst->pDrawable->width,
|
||||
pDst->pDrawable->height))
|
||||
{
|
||||
xglAddCurrentBitDamage (pDst->pDrawable);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
pPictureScreen = GetPictureScreen (pScreen);
|
||||
|
||||
XGL_TRAP_FALLBACK_PROLOGUE (pDst, AddTraps);
|
||||
(*pPictureScreen->AddTraps) (pDst, xOff, yOff, nTrap, traps);
|
||||
XGL_TRAP_FALLBACK_EPILOGUE (pDst, AddTraps, xglAddTraps);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,166 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* 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
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN 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.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
#include "fb.h"
|
||||
|
||||
#define XGL_WINDOW_FALLBACK_PROLOGUE(pWin, func) \
|
||||
if (!xglMapPixmapBits (XGL_GET_DRAWABLE_PIXMAP (&pWin->drawable))) \
|
||||
FatalError (XGL_SW_FAILURE_STRING); \
|
||||
XGL_SCREEN_UNWRAP (func)
|
||||
|
||||
#define XGL_WINDOW_FALLBACK_EPILOGUE(pWin, pRegion, func, xglfunc) \
|
||||
XGL_SCREEN_WRAP (func, xglfunc); \
|
||||
xglAddSurfaceDamage (&pWin->drawable, pRegion)
|
||||
|
||||
Bool
|
||||
xglCreateWindow (WindowPtr pWin)
|
||||
{
|
||||
ScreenPtr pScreen = pWin->drawable.pScreen;
|
||||
Bool ret;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
XGL_WINDOW_PRIV (pWin);
|
||||
|
||||
XGL_SCREEN_UNWRAP (CreateWindow);
|
||||
ret = (*pScreen->CreateWindow) (pWin);
|
||||
XGL_SCREEN_WRAP (CreateWindow, xglCreateWindow);
|
||||
|
||||
pWinPriv->pPixmap = pWin->drawable.pScreen->devPrivate;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglDestroyWindow (WindowPtr pWin)
|
||||
{
|
||||
ScreenPtr pScreen = pWin->drawable.pScreen;
|
||||
Bool ret;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
XGL_SCREEN_UNWRAP (DestroyWindow);
|
||||
ret = (*pScreen->DestroyWindow) (pWin);
|
||||
XGL_SCREEN_WRAP (DestroyWindow, xglDestroyWindow);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglChangeWindowAttributes (WindowPtr pWin,
|
||||
unsigned long mask)
|
||||
{
|
||||
ScreenPtr pScreen = pWin->drawable.pScreen;
|
||||
PixmapPtr pPixmap;
|
||||
Bool ret;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
if (mask & CWBackPixmap)
|
||||
{
|
||||
if (pWin->backgroundState == BackgroundPixmap)
|
||||
{
|
||||
pPixmap = pWin->background.pixmap;
|
||||
|
||||
if (FbEvenTile (pPixmap->drawable.width *
|
||||
pPixmap->drawable.bitsPerPixel))
|
||||
xglSyncBits (&pPixmap->drawable, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (mask & CWBorderPixmap)
|
||||
{
|
||||
if (pWin->borderIsPixel == FALSE)
|
||||
{
|
||||
pPixmap = pWin->border.pixmap;
|
||||
|
||||
if (FbEvenTile (pPixmap->drawable.width *
|
||||
pPixmap->drawable.bitsPerPixel))
|
||||
xglSyncBits (&pPixmap->drawable, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
XGL_SCREEN_UNWRAP (ChangeWindowAttributes);
|
||||
ret = (*pScreen->ChangeWindowAttributes) (pWin, mask);
|
||||
XGL_SCREEN_WRAP (ChangeWindowAttributes, xglChangeWindowAttributes);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
xglCopyWindow (WindowPtr pWin,
|
||||
DDXPointRec ptOldOrg,
|
||||
RegionPtr prgnSrc)
|
||||
{
|
||||
PixmapPtr pPixmap;
|
||||
RegionRec rgnDst;
|
||||
int dx, dy;
|
||||
BoxPtr pExtent = REGION_EXTENTS (pWin->drawable.pScreen, prgnSrc);
|
||||
BoxRec box;
|
||||
|
||||
pPixmap = XGL_GET_WINDOW_PIXMAP (pWin);
|
||||
|
||||
box.x1 = pExtent->x1;
|
||||
box.y1 = pExtent->y1;
|
||||
box.x2 = pExtent->x2;
|
||||
box.y2 = pExtent->y2;
|
||||
|
||||
dx = ptOldOrg.x - pWin->drawable.x;
|
||||
dy = ptOldOrg.y - pWin->drawable.y;
|
||||
|
||||
REGION_TRANSLATE (pWin->drawable.pScreen, prgnSrc, -dx, -dy);
|
||||
REGION_INIT (pWin->drawable.pScreen, &rgnDst, NullBox, 0);
|
||||
REGION_INTERSECT (pWin->drawable.pScreen,
|
||||
&rgnDst, &pWin->borderClip, prgnSrc);
|
||||
|
||||
fbCopyRegion (&pWin->drawable, &pWin->drawable,
|
||||
0, &rgnDst, dx, dy, xglCopyProc, 0, (void *) &box);
|
||||
|
||||
REGION_UNINIT (pWin->drawable.pScreen, &rgnDst);
|
||||
}
|
||||
|
||||
PixmapPtr
|
||||
xglGetWindowPixmap (WindowPtr pWin)
|
||||
{
|
||||
return XGL_GET_WINDOW_PIXMAP (pWin);
|
||||
}
|
||||
|
||||
void
|
||||
xglSetWindowPixmap (WindowPtr pWin,
|
||||
PixmapPtr pPixmap)
|
||||
{
|
||||
ScreenPtr pScreen = pWin->drawable.pScreen;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
XGL_SCREEN_UNWRAP (SetWindowPixmap);
|
||||
(*pScreen->SetWindowPixmap) (pWin, pPixmap);
|
||||
XGL_SCREEN_WRAP (SetWindowPixmap, xglSetWindowPixmap);
|
||||
|
||||
XGL_GET_WINDOW_PRIV (pWin)->pPixmap = pPixmap;
|
||||
|
||||
if (pPixmap != pScreenPriv->pScreenPixmap)
|
||||
xglEnablePixmapAccel (pPixmap, &pScreenPriv->accel.window);
|
||||
}
|
634
hw/xgl/xglxv.c
634
hw/xgl/xglxv.c
|
@ -1,634 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2005 Novell, Inc.
|
||||
*
|
||||
* 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
|
||||
* Novell, Inc. not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* Novell, Inc. makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL NOVELL, INC. 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: David Reveman <davidr@novell.com>
|
||||
* Matthias Hopf <mhopf@suse.de>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
|
||||
#ifdef XV
|
||||
|
||||
#include "xvdix.h"
|
||||
#include "gcstruct.h"
|
||||
#include "dixstruct.h"
|
||||
|
||||
#include <X11/extensions/Xv.h>
|
||||
#include <X11/extensions/Xvproto.h>
|
||||
|
||||
static DevPrivateKey xglXvScreenKey;
|
||||
static unsigned long portResource = 0;
|
||||
|
||||
#define XGL_GET_XV_SCREEN(pScreen) ((XvScreenPtr) \
|
||||
dixLookupPrivate(&(pScreen)->devPrivates, xglXvScreenKey))
|
||||
|
||||
#define XGL_XV_SCREEN(pScreen) \
|
||||
XvScreenPtr pXvScreen = XGL_GET_XV_SCREEN (pScreen)
|
||||
|
||||
#define XGL_GET_XV_SCREEN_PRIV(pScreen) \
|
||||
((xglXvScreenPtr) (GET_XV_SCREEN (pScreen)->devPriv.ptr))
|
||||
|
||||
#define XGL_XV_SCREEN_PRIV(pScreen) \
|
||||
xglXvScreenPtr pXvScreenPriv = XGL_GET_XV_SCREEN_PRIV (pScreen)
|
||||
|
||||
#define XGL_GET_XV_PORT_PRIV(pPort) \
|
||||
((xglXvPortPtr) ((pPort)->devPriv.ptr))
|
||||
|
||||
#define XGL_XV_PORT_PRIV(pPort) \
|
||||
xglXvPortPtr pPortPriv = XGL_GET_XV_PORT_PRIV (pPort)
|
||||
|
||||
#define XGL_XV_NUM_PORTS 32
|
||||
|
||||
#define XGL_XV_IMAGE_MAX_WIDTH 2048
|
||||
#define XGL_XV_IMAGE_MAX_HEIGHT 2048
|
||||
|
||||
static XvImageRec xvImages[] = {
|
||||
{
|
||||
GLITZ_FOURCC_YUY2, XvYUV, BITMAP_BIT_ORDER,
|
||||
{
|
||||
'Y','U','Y','2',
|
||||
0x00, 0x00, 0x00, 0x10, 0x80, 0x00,
|
||||
0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71
|
||||
},
|
||||
16, XvPacked, 1,
|
||||
0, 0, 0, 0,
|
||||
8, 8, 8, 1, 2, 2, 1, 1, 1,
|
||||
{
|
||||
'Y', 'U', 'Y', 'V',
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
},
|
||||
XvTopToBottom
|
||||
}, {
|
||||
GLITZ_FOURCC_YV12, XvYUV, BITMAP_BIT_ORDER,
|
||||
{
|
||||
'Y', 'V', '1', '2',
|
||||
0x00, 0x00, 0x00, 0x10, 0x80, 0x00,
|
||||
0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71
|
||||
},
|
||||
12, XvPlanar, 3,
|
||||
0, 0, 0, 0,
|
||||
8, 8, 8, 1, 2, 2, 1, 2, 2,
|
||||
{
|
||||
'Y', 'V', 'U', 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
},
|
||||
XvTopToBottom
|
||||
}, {
|
||||
GLITZ_FOURCC_RGB, XvRGB, BITMAP_BIT_ORDER,
|
||||
{
|
||||
0x03, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x10, 0x80, 0x00,
|
||||
0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71
|
||||
},
|
||||
32, XvPacked, 1,
|
||||
24, 0xff0000, 0xff00, 0xff,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
{
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
},
|
||||
XvTopToBottom
|
||||
}
|
||||
};
|
||||
|
||||
static struct _xglXvFormat {
|
||||
CARD32 format;
|
||||
glitz_fourcc_t fourcc;
|
||||
xglPixelFormatRec pixel;
|
||||
} xglXvFormat[XGL_XV_FORMAT_NUM] = {
|
||||
{
|
||||
PICT_yuy2,
|
||||
GLITZ_FOURCC_YUY2,
|
||||
{
|
||||
16, 6,
|
||||
{
|
||||
16,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
}
|
||||
}
|
||||
}, {
|
||||
PICT_yv12,
|
||||
GLITZ_FOURCC_YV12,
|
||||
{
|
||||
12, 4,
|
||||
{
|
||||
12,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
}
|
||||
}
|
||||
}, {
|
||||
PICT_x8r8g8b8,
|
||||
GLITZ_FOURCC_RGB,
|
||||
{
|
||||
24, 8,
|
||||
{
|
||||
32,
|
||||
0x00000000,
|
||||
0x00ff0000,
|
||||
0x0000ff00,
|
||||
0x000000ff,
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static int
|
||||
xglXvQueryAdaptors (ScreenPtr pScreen,
|
||||
XvAdaptorPtr *pAdaptors,
|
||||
int *nAdaptors)
|
||||
{
|
||||
XGL_XV_SCREEN (pScreen);
|
||||
|
||||
*nAdaptors = pXvScreen->nAdaptors;
|
||||
*pAdaptors = pXvScreen->pAdaptors;
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
static int
|
||||
xglXvAllocatePort (unsigned long port,
|
||||
XvPortPtr pPort,
|
||||
XvPortPtr *ppPort)
|
||||
{
|
||||
*ppPort = pPort;
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
static int
|
||||
xglXvFreePort (XvPortPtr pPort)
|
||||
{
|
||||
XGL_XV_PORT_PRIV (pPort);
|
||||
|
||||
if (pPortPriv->pDst)
|
||||
{
|
||||
FreePicture ((pointer) pPortPriv->pDst, 0);
|
||||
pPortPriv->pDst = (PicturePtr) 0;
|
||||
}
|
||||
|
||||
if (pPortPriv->pSrc)
|
||||
{
|
||||
FreePicture ((pointer) pPortPriv->pSrc, 0);
|
||||
pPortPriv->pSrc = (PicturePtr) 0;
|
||||
}
|
||||
|
||||
if (pPortPriv->pPixmap)
|
||||
{
|
||||
ScreenPtr pScreen;
|
||||
|
||||
pScreen = pPortPriv->pPixmap->drawable.pScreen;
|
||||
(*pScreen->DestroyPixmap) (pPortPriv->pPixmap);
|
||||
pPortPriv->pPixmap = (PixmapPtr) 0;
|
||||
}
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
static int
|
||||
xglXvQueryBestSize (ClientPtr client,
|
||||
XvPortPtr pPort,
|
||||
CARD8 motion,
|
||||
CARD16 srcWidth,
|
||||
CARD16 srcHeight,
|
||||
CARD16 dstWidth,
|
||||
CARD16 dstHeight,
|
||||
unsigned int *pWidth,
|
||||
unsigned int *pHeight)
|
||||
{
|
||||
*pWidth = dstWidth;
|
||||
*pHeight = dstHeight;
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
static int
|
||||
xglXvStopVideo (ClientPtr client,
|
||||
XvPortPtr pPort,
|
||||
DrawablePtr pDrawable)
|
||||
{
|
||||
xglXvFreePort (pPort);
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
static int
|
||||
xglXvPutImage (ClientPtr client,
|
||||
DrawablePtr pDrawable,
|
||||
XvPortPtr pPort,
|
||||
GCPtr pGC,
|
||||
INT16 srcX,
|
||||
INT16 srcY,
|
||||
CARD16 srcWidth,
|
||||
CARD16 srcHeight,
|
||||
INT16 dstX,
|
||||
INT16 dstY,
|
||||
CARD16 dstWidth,
|
||||
CARD16 dstHeight,
|
||||
XvImagePtr pImage,
|
||||
unsigned char *data,
|
||||
Bool sync,
|
||||
CARD16 width,
|
||||
CARD16 height)
|
||||
{
|
||||
ScreenPtr pScreen = pDrawable->pScreen;
|
||||
PictTransform transform;
|
||||
int depth, bpp;
|
||||
CARD32 format;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
XGL_XV_PORT_PRIV (pPort);
|
||||
XGL_DRAWABLE_PIXMAP (pDrawable);
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
switch (pImage->id) {
|
||||
case GLITZ_FOURCC_YUY2:
|
||||
bpp = depth = 16;
|
||||
format = PICT_yuy2;
|
||||
break;
|
||||
case GLITZ_FOURCC_YV12:
|
||||
depth = bpp = 12;
|
||||
format = PICT_yv12;
|
||||
break;
|
||||
case GLITZ_FOURCC_RGB:
|
||||
depth = 24;
|
||||
bpp = 32;
|
||||
format = PICT_x8r8g8b8;
|
||||
break;
|
||||
default:
|
||||
return BadImplementation;
|
||||
}
|
||||
|
||||
pPort->pDraw = pDrawable;
|
||||
|
||||
if (!pPortPriv->pPixmap)
|
||||
{
|
||||
pPortPriv->pPixmap = (*pScreen->CreatePixmap) (pScreen, 0, 0, depth, 0);
|
||||
if (!pPortPriv->pPixmap)
|
||||
return BadAlloc;
|
||||
}
|
||||
|
||||
(*pScreen->ModifyPixmapHeader) (pPortPriv->pPixmap,
|
||||
srcWidth, srcHeight,
|
||||
depth, bpp, -1, (pointer) data);
|
||||
|
||||
XGL_GET_PIXMAP_PRIV (pPortPriv->pPixmap)->stride = -srcWidth;
|
||||
|
||||
pPortPriv->pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
|
||||
|
||||
if (!pPortPriv->pSrc || pPortPriv->pSrc->format != format)
|
||||
{
|
||||
PictFormatPtr pFormat;
|
||||
int error;
|
||||
static XID value = RepeatPad;
|
||||
|
||||
pFormat = PictureMatchFormat (pScreen, depth, format);
|
||||
if (!pFormat)
|
||||
return BadImplementation;
|
||||
|
||||
if (pPortPriv->pSrc)
|
||||
FreePicture ((pointer) pPortPriv->pSrc, 0);
|
||||
|
||||
pPortPriv->pSrc = CreatePicture (0, &pPortPriv->pPixmap->drawable,
|
||||
pFormat, CPRepeat, &value,
|
||||
serverClient, &error);
|
||||
if (!pPortPriv->pSrc)
|
||||
{
|
||||
xglXvFreePort (pPort);
|
||||
return error;
|
||||
}
|
||||
|
||||
SetPictureFilter (pPortPriv->pSrc,
|
||||
FilterBilinear, strlen (FilterBilinear),
|
||||
0, 0);
|
||||
}
|
||||
|
||||
if (!pPortPriv->pDst || pPortPriv->pDst->pDrawable != pDrawable)
|
||||
{
|
||||
PictFormatPtr pFormat = 0;
|
||||
int i, error;
|
||||
|
||||
for (i = 0; i < pScreen->numVisuals; i++)
|
||||
{
|
||||
if (pScreen->visuals[i].nplanes == pDrawable->depth)
|
||||
{
|
||||
pFormat = PictureMatchVisual (pScreen, pDrawable->depth,
|
||||
&pScreen->visuals[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!pFormat)
|
||||
return BadImplementation;
|
||||
|
||||
if (pPortPriv->pDst)
|
||||
FreePicture ((pointer) pPortPriv->pDst, 0);
|
||||
|
||||
pPortPriv->pDst = CreatePicture (0, pDrawable,
|
||||
pFormat, 0, 0, serverClient,
|
||||
&error);
|
||||
if (!pPortPriv->pDst)
|
||||
{
|
||||
xglXvFreePort (pPort);
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
transform.matrix[0][0] = ((srcWidth << 16) + (dstWidth >> 1))
|
||||
/ dstWidth;
|
||||
transform.matrix[0][1] = 0;
|
||||
transform.matrix[0][2] = 0;
|
||||
|
||||
/* flip Y */
|
||||
transform.matrix[1][0] = 0;
|
||||
transform.matrix[1][1] = -((srcHeight << 16) + (dstHeight >> 1))
|
||||
/ dstHeight;
|
||||
transform.matrix[1][2] = (srcHeight << 16);
|
||||
|
||||
transform.matrix[2][0] = 0;
|
||||
transform.matrix[2][1] = 0;
|
||||
transform.matrix[2][2] = 1 << 16;
|
||||
|
||||
SetPictureTransform (pPortPriv->pSrc, &transform);
|
||||
|
||||
if (pPixmap != pScreenPriv->pScreenPixmap && !pPixmapPriv->target)
|
||||
xglEnablePixmapAccel (pPixmap, &pScreenPriv->accel.xv);
|
||||
|
||||
CompositePicture (PictOpSrc,
|
||||
pPortPriv->pSrc,
|
||||
(PicturePtr) 0,
|
||||
pPortPriv->pDst,
|
||||
srcX, srcY,
|
||||
0, 0,
|
||||
dstX, dstY,
|
||||
dstWidth, dstHeight);
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
static int
|
||||
xglXvQueryImageAttributes (ClientPtr client,
|
||||
XvPortPtr pPort,
|
||||
XvImagePtr pImage,
|
||||
CARD16 *width,
|
||||
CARD16 *height,
|
||||
int *pitches,
|
||||
int *offsets)
|
||||
{
|
||||
if (*width > XGL_XV_IMAGE_MAX_WIDTH)
|
||||
*width = XGL_XV_IMAGE_MAX_WIDTH;
|
||||
|
||||
if (*height > XGL_XV_IMAGE_MAX_HEIGHT)
|
||||
*height = XGL_XV_IMAGE_MAX_HEIGHT;
|
||||
|
||||
*width = (*width + 7) & ~7;
|
||||
|
||||
switch (pImage->id) {
|
||||
case GLITZ_FOURCC_YUY2:
|
||||
if (offsets)
|
||||
offsets[0] = 0;
|
||||
|
||||
if (pitches)
|
||||
pitches[0] = *width * 2;
|
||||
|
||||
return *width * *height * 2;
|
||||
case GLITZ_FOURCC_YV12:
|
||||
*height = (*height + 1) & ~1;
|
||||
|
||||
if (offsets)
|
||||
{
|
||||
offsets[0] = 0;
|
||||
offsets[1] = *width * *height;
|
||||
offsets[2] = *width * *height + (*width >> 1) * (*height >> 1);
|
||||
}
|
||||
|
||||
if (pitches)
|
||||
{
|
||||
pitches[0] = *width;
|
||||
pitches[1] = pitches[2] = *width >> 1;
|
||||
}
|
||||
|
||||
return *width * *height + (*width >> 1) * *height;
|
||||
case GLITZ_FOURCC_RGB:
|
||||
if (offsets)
|
||||
offsets[0] = 0;
|
||||
|
||||
if (pitches)
|
||||
pitches[0] = *width * 4;
|
||||
|
||||
return *width * *height * 4;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
xglXvFreeAdaptor (XvAdaptorPtr pAdaptor)
|
||||
{
|
||||
xfree (pAdaptor->pEncodings);
|
||||
xfree (pAdaptor->pFormats);
|
||||
|
||||
if (pAdaptor->pPorts)
|
||||
xfree (pAdaptor->pPorts);
|
||||
}
|
||||
|
||||
static Bool
|
||||
xglXvInitAdaptors (ScreenPtr pScreen)
|
||||
{
|
||||
XvAdaptorPtr pAdaptor;
|
||||
xglXvPortPtr pPortPriv;
|
||||
XvPortPtr pPort;
|
||||
XvFormatPtr pFormat;
|
||||
XvEncodingPtr pEncoding;
|
||||
int i;
|
||||
|
||||
XGL_XV_SCREEN (pScreen);
|
||||
|
||||
pXvScreen->nAdaptors = 0;
|
||||
pXvScreen->pAdaptors = NULL;
|
||||
|
||||
pAdaptor = xcalloc (1, sizeof (XvAdaptorRec));
|
||||
if (!pAdaptor)
|
||||
return FALSE;
|
||||
|
||||
pAdaptor->type = XvInputMask | XvImageMask;
|
||||
pAdaptor->pScreen = pScreen;
|
||||
|
||||
pAdaptor->ddAllocatePort = xglXvAllocatePort;
|
||||
pAdaptor->ddFreePort = xglXvFreePort;
|
||||
pAdaptor->ddStopVideo = xglXvStopVideo;
|
||||
pAdaptor->ddPutImage = xglXvPutImage;
|
||||
pAdaptor->ddQueryBestSize = xglXvQueryBestSize;
|
||||
pAdaptor->ddQueryImageAttributes = xglXvQueryImageAttributes;
|
||||
|
||||
pAdaptor->name = "Xgl Generic Texture Video";
|
||||
|
||||
pEncoding = xcalloc (1, sizeof (XvEncodingRec));
|
||||
if (!pEncoding)
|
||||
return FALSE;
|
||||
|
||||
pEncoding->id = 0;
|
||||
pEncoding->pScreen = pScreen;
|
||||
pEncoding->name = "XV_IMAGE";
|
||||
|
||||
pEncoding->width = XGL_XV_IMAGE_MAX_WIDTH;
|
||||
pEncoding->height = XGL_XV_IMAGE_MAX_HEIGHT;
|
||||
|
||||
pEncoding->rate.numerator = 1;
|
||||
pEncoding->rate.denominator = 1;
|
||||
|
||||
pAdaptor->nEncodings = 1;
|
||||
pAdaptor->pEncodings = pEncoding;
|
||||
|
||||
pAdaptor->nImages = sizeof (xvImages) / sizeof (XvImageRec);
|
||||
pAdaptor->pImages = xvImages;
|
||||
|
||||
/* TODO: Currently no attributes */
|
||||
pAdaptor->nAttributes = 0;
|
||||
pAdaptor->pAttributes = 0;
|
||||
|
||||
pFormat = xcalloc (pScreen->numVisuals, sizeof (XvFormatRec));
|
||||
if (!pFormat)
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < pScreen->numVisuals; i++)
|
||||
{
|
||||
pFormat[i].depth = pScreen->visuals[i].nplanes;
|
||||
pFormat[i].visual = pScreen->visuals[i].vid;
|
||||
}
|
||||
|
||||
/* All visuals allowed */
|
||||
pAdaptor->nFormats = pScreen->numVisuals;
|
||||
pAdaptor->pFormats = pFormat;
|
||||
|
||||
pPort = xcalloc (XGL_XV_NUM_PORTS,
|
||||
sizeof (XvPortRec) + sizeof (xglXvPortRec));
|
||||
pPortPriv = (xglXvPortPtr) (pPort + XGL_XV_NUM_PORTS);
|
||||
if (!pPort)
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < XGL_XV_NUM_PORTS; i++)
|
||||
{
|
||||
pPort[i].id = FakeClientID (0);
|
||||
if (!pPort[i].id)
|
||||
return FALSE;
|
||||
|
||||
if (!AddResource (pPort[i].id, portResource, &pPort[i]))
|
||||
return FALSE;
|
||||
|
||||
pPort[i].pAdaptor = pAdaptor;
|
||||
pPort[i].pNotify = (XvPortNotifyPtr) 0;
|
||||
pPort[i].pDraw = (DrawablePtr) 0;
|
||||
pPort[i].client = (ClientPtr) 0;
|
||||
pPort[i].grab.client = (ClientPtr) 0;
|
||||
pPort[i].time = currentTime;
|
||||
pPort[i].devPriv.ptr = pPortPriv + i;
|
||||
}
|
||||
|
||||
pAdaptor->nPorts = XGL_XV_NUM_PORTS;
|
||||
pAdaptor->pPorts = pPort;
|
||||
pAdaptor->base_id = pPort->id;
|
||||
|
||||
pXvScreen->pAdaptors = pAdaptor;
|
||||
pXvScreen->nAdaptors = 1;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Bool
|
||||
xglXvCloseScreen (int i, ScreenPtr pScreen)
|
||||
{
|
||||
int j;
|
||||
|
||||
XGL_XV_SCREEN (pScreen);
|
||||
|
||||
for (j = 0; j < pXvScreen->nAdaptors; j++)
|
||||
xglXvFreeAdaptor (&pXvScreen->pAdaptors[j]);
|
||||
|
||||
if (pXvScreen->pAdaptors)
|
||||
xfree (pXvScreen->pAdaptors);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglXvScreenInit (ScreenPtr pScreen)
|
||||
{
|
||||
XvScreenPtr pXvScreen;
|
||||
xglVisualPtr v;
|
||||
int i, status, vid = 0;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
status = XvScreenInit (pScreen);
|
||||
if (status != Success)
|
||||
return FALSE;
|
||||
|
||||
xglXvScreenKey = XvGetScreenKey ();
|
||||
portResource = XvGetRTPort ();
|
||||
|
||||
pXvScreen = XGL_GET_XV_SCREEN (pScreen);
|
||||
|
||||
/* Anyone initializing the Xv layer must provide these two.
|
||||
The Xv di layer calls them without even checking if they exist! */
|
||||
pXvScreen->ddCloseScreen = xglXvCloseScreen;
|
||||
pXvScreen->ddQueryAdaptors = xglXvQueryAdaptors;
|
||||
|
||||
pXvScreen->devPriv.ptr = (pointer) 0;
|
||||
|
||||
if (!xglXvInitAdaptors (pScreen))
|
||||
return FALSE;
|
||||
|
||||
for (v = pScreenPriv->pVisual; v; v = v->next)
|
||||
{
|
||||
if (v->vid > vid)
|
||||
vid = v->vid;
|
||||
}
|
||||
|
||||
memset (pScreenPriv->pXvVisual, 0, sizeof (pScreenPriv->pXvVisual));
|
||||
|
||||
for (i = 0; i < XGL_XV_FORMAT_NUM; i++)
|
||||
{
|
||||
glitz_format_t templ;
|
||||
|
||||
templ.color.fourcc = xglXvFormat[i].fourcc;
|
||||
|
||||
pScreenPriv->pXvVisual[i].vid = ++vid;
|
||||
pScreenPriv->pXvVisual[i].pPixel = &xglXvFormat[i].pixel;
|
||||
pScreenPriv->pXvVisual[i].format.surface =
|
||||
glitz_find_format (pScreenPriv->drawable,
|
||||
GLITZ_FORMAT_FOURCC_MASK,
|
||||
&templ, 0);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,14 +0,0 @@
|
|||
/*
|
||||
* xgl-config.h.in
|
||||
*
|
||||
* This file has defines used in the xgl ddx
|
||||
*
|
||||
*/
|
||||
|
||||
#include <dix-config.h>
|
||||
|
||||
/* Use loadable XGL modules. */
|
||||
#undef XGL_MODULAR
|
||||
|
||||
/* Default XGL module search path */
|
||||
#undef XGL_MODULE_PATH
|
Loading…
Reference in New Issue
Block a user