Updated xgl code drop from Novell + xserver tree changes
This commit is contained in:
parent
b5356e0afa
commit
e70b64b930
|
@ -1,3 +1,10 @@
|
|||
2006-01-18 Dave Airlie <airlied@linux.ie>
|
||||
|
||||
Update XGL server from the xserver tree, and fix to work
|
||||
in X.org tree (look out for a branch appearing RSN),
|
||||
Most of the changes are from David Reveman @ Novell
|
||||
and the rest are from either myself or Eric Anholt.
|
||||
|
||||
2006-01-18 Dave Airlie <airlied@linux.ie>
|
||||
|
||||
* Xext/Makefile.am:
|
||||
|
|
|
@ -22,12 +22,18 @@ AM_CFLAGS = \
|
|||
@SERVER_DEFINES@ \
|
||||
-DHAVE_XGL_CONFIG_H \
|
||||
-DHAVE_DIX_CONFIG_H \
|
||||
-I$(top_srcdir)/GL/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 \
|
||||
|
@ -46,13 +52,14 @@ libxgl_a_SOURCES = \
|
|||
xglget.c \
|
||||
xglgc.c \
|
||||
xglshm.c \
|
||||
xglcomp.c \
|
||||
xglcompose.c \
|
||||
xglpict.c \
|
||||
xglglyph.c \
|
||||
xgltrap.c \
|
||||
xglhash.c \
|
||||
xglloader.c \
|
||||
xglglx.c
|
||||
xglhash.c \
|
||||
xglglx.c \
|
||||
xglxv.c
|
||||
|
||||
EXTRA_DIST = \
|
||||
xglmodule.h
|
||||
|
@ -69,8 +76,7 @@ Xgl_LDADD = \
|
|||
$(XORG_CORE_LIBS) \
|
||||
$(XGL_LIBS) \
|
||||
$(XSERVER_LIBS) \
|
||||
$(EXTENSION_LIBS) \
|
||||
$(XGLMODULES_LIBS)
|
||||
$(EXTENSION_LIBS) -lglitz -ldl
|
||||
Xgl_programs = Xgl
|
||||
|
||||
bin_PROGRAMS = $(Xgl_programs)
|
||||
|
|
|
@ -10,6 +10,11 @@ SUBDIRS = \
|
|||
|
||||
AM_CFLAGS = \
|
||||
-I$(srcdir)/.. \
|
||||
-I$(srcdir)/../glxext \
|
||||
-I$(top_srcdir)/GL/glx \
|
||||
-I$(top_srcdir)/GL/include \
|
||||
-I@MESA_SOURCE@/include \
|
||||
-I@MESA_SOURCE@/src/mesa/glapi \
|
||||
@SERVER_DEFINES@ \
|
||||
-DHAVE_XGL_CONFIG_H \
|
||||
-DHAVE_DIX_CONFIG_H \
|
||||
|
@ -19,24 +24,25 @@ noinst_LTLIBRARIES = libxglx.la
|
|||
|
||||
libxglx_la_SOURCES = \
|
||||
xglx.h \
|
||||
xglx.c
|
||||
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) \
|
||||
$(XSERVER_LIBS) \
|
||||
$(EXTENSION_LIBS) \
|
||||
$(XGLXMODULES_LIBS)
|
||||
Xglx_programs = Xglx
|
||||
# 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,13 +1,20 @@
|
|||
if GLX
|
||||
GLX_LIB = $(top_builddir)/hw/xgl/glxext/libxglglxext.la
|
||||
endif
|
||||
|
||||
AM_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 \
|
||||
$(XGLXMODULES_LIBS)
|
||||
$(GLX_LIB) \
|
||||
$(XGLXMODULES_LIBS) \
|
||||
-lXrandr
|
||||
|
||||
moduledir = @xglmoduledir@
|
||||
|
||||
|
|
|
@ -23,12 +23,13 @@
|
|||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <glitz-glx.h>
|
||||
|
||||
#include "xglx.h"
|
||||
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
#include <X11/cursorfont.h>
|
||||
|
||||
#include <glitz-glx.h>
|
||||
|
||||
#ifdef GLXEXT
|
||||
#include "xglglxext.h"
|
||||
#endif
|
||||
|
@ -37,18 +38,70 @@
|
|||
#include "cursorstr.h"
|
||||
#include "mipointer.h"
|
||||
|
||||
#ifdef RANDR
|
||||
#include "randrstr.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef XKB
|
||||
#include <X11/extensions/XKB.h>
|
||||
#include <X11/extensions/XKBsrv.h>
|
||||
#include <X11/extensions/XKBconfig.h>
|
||||
|
||||
extern Bool
|
||||
XkbQueryExtension (Display *dpy,
|
||||
int *opcodeReturn,
|
||||
int *eventBaseReturn,
|
||||
int *errorBaseReturn,
|
||||
int *majorRtrn,
|
||||
int *minorRtrn);
|
||||
|
||||
extern XkbDescPtr
|
||||
XkbGetKeyboard (Display *dpy,
|
||||
unsigned int which,
|
||||
unsigned int deviceSpec);
|
||||
|
||||
extern Status
|
||||
XkbGetControls (Display *dpy,
|
||||
unsigned long which,
|
||||
XkbDescPtr desc);
|
||||
|
||||
#ifndef XKB_BASE_DIRECTORY
|
||||
#define XKB_BASE_DIRECTORY "/usr/lib/X11/xkb/"
|
||||
#endif
|
||||
#ifndef XKB_CONFIG_FILE
|
||||
#define XKB_CONFIG_FILE "X0-config.keyboard"
|
||||
#endif
|
||||
#ifndef XKB_DFLT_RULES_FILE
|
||||
#define XKB_DFLT_RULES_FILE "xorg"
|
||||
#endif
|
||||
#ifndef XKB_DFLT_KB_LAYOUT
|
||||
#define XKB_DFLT_KB_LAYOUT "us"
|
||||
#endif
|
||||
#ifndef XKB_DFLT_KB_MODEL
|
||||
#define XKB_DFLT_KB_MODEL "pc101"
|
||||
#endif
|
||||
#ifndef XKB_DFLT_KB_VARIANT
|
||||
#define XKB_DFLT_KB_VARIANT NULL
|
||||
#endif
|
||||
#ifndef XKB_DFLT_KB_OPTIONS
|
||||
#define XKB_DFLT_KB_OPTIONS NULL
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#define XGLX_DEFAULT_SCREEN_WIDTH 800
|
||||
#define XGLX_DEFAULT_SCREEN_HEIGHT 600
|
||||
|
||||
typedef struct _xglxScreen {
|
||||
Window win;
|
||||
Window win, root;
|
||||
Colormap colormap;
|
||||
Bool fullscreen;
|
||||
CloseScreenProcPtr CloseScreen;
|
||||
} xglxScreenRec, *xglxScreenPtr;
|
||||
|
||||
|
@ -83,7 +136,12 @@ static int xscreen;
|
|||
static CARD32 lastEventTime = 0;
|
||||
static ScreenPtr currentScreen = 0;
|
||||
static Bool softCursor = FALSE;
|
||||
static Bool fullscreen = FALSE;
|
||||
static Bool fullscreen = TRUE;
|
||||
|
||||
static Bool randrExtension = FALSE;
|
||||
static int randrEvent, randrError;
|
||||
|
||||
static glitz_drawable_format_t *xglxScreenFormat = 0;
|
||||
|
||||
static Bool
|
||||
xglxAllocatePrivates (ScreenPtr pScreen)
|
||||
|
@ -108,6 +166,219 @@ xglxAllocatePrivates (ScreenPtr pScreen)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
#ifdef RANDR
|
||||
|
||||
#define DEFAULT_REFRESH_RATE 50
|
||||
|
||||
static Bool
|
||||
xglxRandRGetInfo (ScreenPtr pScreen,
|
||||
Rotation *rotations)
|
||||
{
|
||||
RRScreenSizePtr pSize;
|
||||
|
||||
*rotations = RR_Rotate_0;
|
||||
|
||||
if (randrExtension)
|
||||
{
|
||||
XRRScreenConfiguration *xconfig;
|
||||
XRRScreenSize *sizes;
|
||||
int nSizes, currentSize = 0;
|
||||
short *rates, currentRate;
|
||||
int nRates, i, j;
|
||||
|
||||
XGLX_SCREEN_PRIV (pScreen);
|
||||
|
||||
xconfig = XRRGetScreenInfo (xdisplay, pScreenPriv->root);
|
||||
sizes = XRRConfigSizes (xconfig, &nSizes);
|
||||
currentRate = XRRConfigCurrentRate (xconfig);
|
||||
|
||||
if (pScreenPriv->fullscreen)
|
||||
{
|
||||
Rotation rotation;
|
||||
|
||||
currentSize = XRRConfigCurrentConfiguration (xconfig, &rotation);
|
||||
|
||||
for (i = 0; i < nSizes; i++)
|
||||
{
|
||||
pSize = RRRegisterSize (pScreen,
|
||||
sizes[i].width,
|
||||
sizes[i].height,
|
||||
sizes[i].mwidth,
|
||||
sizes[i].mheight);
|
||||
|
||||
rates = XRRConfigRates (xconfig, i, &nRates);
|
||||
|
||||
for (j = 0; j < nRates; j++)
|
||||
{
|
||||
RRRegisterRate (pScreen, pSize, rates[j]);
|
||||
|
||||
if (i == currentSize && rates[j] == currentRate)
|
||||
RRSetCurrentConfig (pScreen, RR_Rotate_0, currentRate,
|
||||
pSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pSize = RRRegisterSize (pScreen,
|
||||
pScreen->width,
|
||||
pScreen->height,
|
||||
pScreen->mmWidth,
|
||||
pScreen->mmHeight);
|
||||
|
||||
for (i = 0; i < nSizes; i++)
|
||||
{
|
||||
rates = XRRConfigRates (xconfig, i, &nRates);
|
||||
|
||||
for (j = 0; j < nRates; j++)
|
||||
{
|
||||
RRRegisterRate (pScreen, pSize, rates[j]);
|
||||
|
||||
if (rates[j] == currentRate)
|
||||
RRSetCurrentConfig (pScreen, RR_Rotate_0, currentRate,
|
||||
pSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XRRFreeScreenConfigInfo (xconfig);
|
||||
}
|
||||
else
|
||||
{
|
||||
pSize = RRRegisterSize (pScreen,
|
||||
pScreen->width,
|
||||
pScreen->height,
|
||||
pScreen->mmWidth,
|
||||
pScreen->mmHeight);
|
||||
|
||||
RRRegisterRate (pScreen, pSize, DEFAULT_REFRESH_RATE);
|
||||
RRSetCurrentConfig (pScreen, RR_Rotate_0, DEFAULT_REFRESH_RATE, pSize);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Bool
|
||||
xglxRandRSetConfig (ScreenPtr pScreen,
|
||||
Rotation rotations,
|
||||
int rate,
|
||||
RRScreenSizePtr pSize)
|
||||
{
|
||||
if (randrExtension)
|
||||
{
|
||||
XRRScreenConfiguration *xconfig;
|
||||
XRRScreenSize *sizes;
|
||||
int nSizes, currentSize;
|
||||
int i, size = -1;
|
||||
int status = RRSetConfigFailed;
|
||||
Rotation rotation;
|
||||
|
||||
XGLX_SCREEN_PRIV (pScreen);
|
||||
|
||||
xconfig = XRRGetScreenInfo (xdisplay, pScreenPriv->root);
|
||||
sizes = XRRConfigSizes (xconfig, &nSizes);
|
||||
currentSize = XRRConfigCurrentConfiguration (xconfig, &rotation);
|
||||
|
||||
for (i = 0; i < nSizes; i++)
|
||||
{
|
||||
if (pScreenPriv->fullscreen)
|
||||
{
|
||||
if (sizes[i].width == pSize->width &&
|
||||
sizes[i].height == pSize->height &&
|
||||
sizes[i].mwidth == pSize->mmWidth &&
|
||||
sizes[i].mheight == pSize->mmHeight)
|
||||
{
|
||||
size = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
short *rates;
|
||||
int nRates, j;
|
||||
|
||||
rates = XRRConfigRates (xconfig, i, &nRates);
|
||||
|
||||
for (j = 0; j < nRates; j++)
|
||||
{
|
||||
if (rates[j] == rate)
|
||||
{
|
||||
size = i;
|
||||
if (i >= currentSize)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (size >= 0)
|
||||
status = XRRSetScreenConfigAndRate (xdisplay,
|
||||
xconfig,
|
||||
pScreenPriv->root,
|
||||
size,
|
||||
RR_Rotate_0,
|
||||
rate,
|
||||
CurrentTime);
|
||||
|
||||
XRRFreeScreenConfigInfo (xconfig);
|
||||
|
||||
if (status == RRSetConfigSuccess)
|
||||
{
|
||||
PixmapPtr pPixmap;
|
||||
|
||||
pPixmap = (*pScreen->GetScreenPixmap) (pScreen);
|
||||
|
||||
if (pScreenPriv->fullscreen)
|
||||
{
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
xglSetRootClip (pScreen, FALSE);
|
||||
|
||||
XResizeWindow (xdisplay, pScreenPriv->win,
|
||||
pSize->width, pSize->height);
|
||||
|
||||
glitz_drawable_update_size (pPixmapPriv->drawable,
|
||||
pSize->width, pSize->height);
|
||||
|
||||
pScreen->width = pSize->width;
|
||||
pScreen->height = pSize->height;
|
||||
pScreen->mmWidth = pSize->mmWidth;
|
||||
pScreen->mmHeight = pSize->mmHeight;
|
||||
|
||||
(*pScreen->ModifyPixmapHeader) (pPixmap,
|
||||
pScreen->width,
|
||||
pScreen->height,
|
||||
pPixmap->drawable.depth,
|
||||
pPixmap->drawable.bitsPerPixel,
|
||||
0, 0);
|
||||
|
||||
xglSetRootClip (pScreen, TRUE);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static Bool
|
||||
xglxRandRInit (ScreenPtr pScreen)
|
||||
{
|
||||
rrScrPrivPtr pScrPriv;
|
||||
|
||||
if (!RRScreenInit (pScreen))
|
||||
return FALSE;
|
||||
|
||||
pScrPriv = rrGetScrPriv (pScreen);
|
||||
pScrPriv->rrGetInfo = xglxRandRGetInfo;
|
||||
pScrPriv->rrSetConfig = xglxRandRSetConfig;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static void
|
||||
xglxConstrainCursor (ScreenPtr pScreen,
|
||||
BoxPtr pBox)
|
||||
|
@ -154,7 +425,7 @@ xglxRealizeCursor (ScreenPtr pScreen,
|
|||
XImage *ximage;
|
||||
Pixmap source, mask;
|
||||
XColor fgColor, bgColor;
|
||||
GC xgc;
|
||||
XlibGC xgc;
|
||||
unsigned long valuemask;
|
||||
XGCValues values;
|
||||
|
||||
|
@ -345,13 +616,12 @@ xglxScreenInit (int index,
|
|||
XSizeHints *normalHints;
|
||||
XClassHint *classHint;
|
||||
xglxScreenPtr pScreenPriv;
|
||||
Window root;
|
||||
XVisualInfo *vinfo;
|
||||
XEvent xevent;
|
||||
glitz_drawable_format_t *format;
|
||||
glitz_drawable_t *drawable;
|
||||
|
||||
format = xglVisuals[0].format;
|
||||
format = xglxScreenFormat;
|
||||
|
||||
if (!xglxAllocatePrivates (pScreen))
|
||||
return FALSE;
|
||||
|
@ -360,7 +630,8 @@ xglxScreenInit (int index,
|
|||
|
||||
pScreenPriv = XGLX_GET_SCREEN_PRIV (pScreen);
|
||||
|
||||
root = RootWindow (xdisplay, xscreen);
|
||||
pScreenPriv->root = RootWindow (xdisplay, xscreen);
|
||||
pScreenPriv->fullscreen = fullscreen;
|
||||
|
||||
vinfo = glitz_glx_get_visual_info_from_format (xdisplay, xscreen, format);
|
||||
if (!vinfo)
|
||||
|
@ -370,7 +641,11 @@ xglxScreenInit (int index,
|
|||
}
|
||||
|
||||
pScreenPriv->colormap =
|
||||
XCreateColormap (xdisplay, root, vinfo->visual, AllocNone);
|
||||
XCreateColormap (xdisplay, pScreenPriv->root, vinfo->visual,
|
||||
AllocNone);
|
||||
|
||||
if (XRRQueryExtension (xdisplay, &randrEvent, &randrError))
|
||||
randrExtension = TRUE;
|
||||
|
||||
if (fullscreen)
|
||||
{
|
||||
|
@ -378,6 +653,25 @@ xglxScreenInit (int index,
|
|||
xglScreenInfo.height = DisplayHeight (xdisplay, xscreen);
|
||||
xglScreenInfo.widthMm = DisplayWidthMM (xdisplay, xscreen);
|
||||
xglScreenInfo.heightMm = DisplayHeightMM (xdisplay, xscreen);
|
||||
|
||||
if (randrExtension)
|
||||
{
|
||||
XRRScreenConfiguration *xconfig;
|
||||
Rotation rotation;
|
||||
XRRScreenSize *sizes;
|
||||
int nSizes, currentSize;
|
||||
|
||||
xconfig = XRRGetScreenInfo (xdisplay, pScreenPriv->root);
|
||||
currentSize = XRRConfigCurrentConfiguration (xconfig, &rotation);
|
||||
sizes = XRRConfigSizes (xconfig, &nSizes);
|
||||
|
||||
xglScreenInfo.width = sizes[currentSize].width;
|
||||
xglScreenInfo.height = sizes[currentSize].height;
|
||||
xglScreenInfo.widthMm = sizes[currentSize].mwidth;
|
||||
xglScreenInfo.heightMm = sizes[currentSize].mheight;
|
||||
|
||||
XRRFreeScreenConfigInfo (xconfig);
|
||||
}
|
||||
}
|
||||
else if (xglScreenInfo.width == 0 || xglScreenInfo.height == 0)
|
||||
{
|
||||
|
@ -388,7 +682,7 @@ xglxScreenInit (int index,
|
|||
xswa.colormap = pScreenPriv->colormap;
|
||||
|
||||
pScreenPriv->win =
|
||||
XCreateWindow (xdisplay, root, 0, 0,
|
||||
XCreateWindow (xdisplay, pScreenPriv->root, 0, 0,
|
||||
xglScreenInfo.width, xglScreenInfo.height, 0,
|
||||
vinfo->depth, InputOutput, vinfo->visual,
|
||||
CWColormap, &xswa);
|
||||
|
@ -456,8 +750,8 @@ xglxScreenInit (int index,
|
|||
xev.data.l[1] =
|
||||
XInternAtom (xdisplay, "_NET_WM_STATE_FULLSCREEN", FALSE);
|
||||
|
||||
XSendEvent (xdisplay, root, FALSE, SubstructureRedirectMask,
|
||||
(XEvent *) &xev);
|
||||
XSendEvent (xdisplay, pScreenPriv->root, FALSE,
|
||||
SubstructureRedirectMask, (XEvent *) &xev);
|
||||
}
|
||||
|
||||
xglScreenInfo.drawable = drawable;
|
||||
|
@ -520,6 +814,11 @@ xglxScreenInit (int index,
|
|||
if (!xglFinishScreenInit (pScreen))
|
||||
return FALSE;
|
||||
|
||||
#ifdef RANDR
|
||||
if (!xglxRandRInit (pScreen))
|
||||
return FALSE;
|
||||
#endif
|
||||
|
||||
while (XNextEvent (xdisplay, &xevent))
|
||||
if (xevent.type == Expose)
|
||||
break;
|
||||
|
@ -535,33 +834,66 @@ xglxInitOutput (ScreenInfo *pScreenInfo,
|
|||
glitz_drawable_format_t *format, templ;
|
||||
int i;
|
||||
unsigned long mask;
|
||||
unsigned long extraMask[] = {
|
||||
GLITZ_FORMAT_DOUBLEBUFFER_MASK | GLITZ_FORMAT_ALPHA_SIZE_MASK,
|
||||
GLITZ_FORMAT_DOUBLEBUFFER_MASK,
|
||||
GLITZ_FORMAT_ALPHA_SIZE_MASK,
|
||||
0
|
||||
};
|
||||
|
||||
xglClearVisualTypes ();
|
||||
|
||||
xglSetPixmapFormats (pScreenInfo);
|
||||
|
||||
if (!xdisplay)
|
||||
{
|
||||
xdisplay = XOpenDisplay (xDisplayName);
|
||||
char *name = xDisplayName;
|
||||
|
||||
if (!name)
|
||||
name = xglxInitXorg ();
|
||||
|
||||
xdisplay = XOpenDisplay (name);
|
||||
if (!xdisplay)
|
||||
FatalError ("can't open display");
|
||||
FatalError ("can't open display: %s\n", name ? name : "NULL");
|
||||
|
||||
xscreen = DefaultScreen (xdisplay);
|
||||
|
||||
if (!xDisplayName)
|
||||
XDefineCursor (xdisplay, RootWindow (xdisplay, xscreen),
|
||||
XCreateFontCursor (xdisplay, XC_watch));
|
||||
}
|
||||
|
||||
templ.samples = 1;
|
||||
templ.doublebuffer = 1;
|
||||
templ.color.fourcc = GLITZ_FOURCC_RGB;
|
||||
templ.color.alpha_size = 8;
|
||||
|
||||
mask = GLITZ_FORMAT_SAMPLES_MASK;
|
||||
mask = GLITZ_FORMAT_SAMPLES_MASK | GLITZ_FORMAT_FOURCC_MASK;
|
||||
|
||||
for (i = 0; i < sizeof (extraMask) / sizeof (extraMask[0]); i++)
|
||||
{
|
||||
format = glitz_glx_find_window_format (xdisplay, xscreen,
|
||||
mask, &templ, 0);
|
||||
mask | extraMask[i],
|
||||
&templ, 0);
|
||||
if (format)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!format)
|
||||
FatalError ("no visual format found");
|
||||
|
||||
xglSetVisualTypesAndMasks (pScreenInfo, format, (1 << TrueColor));
|
||||
xglScreenInfo.depth =
|
||||
format->color.red_size +
|
||||
format->color.green_size +
|
||||
format->color.blue_size;
|
||||
|
||||
xglInitVisuals (pScreenInfo);
|
||||
xglSetVisualTypes (xglScreenInfo.depth,
|
||||
(1 << TrueColor),
|
||||
format->color.red_size,
|
||||
format->color.green_size,
|
||||
format->color.blue_size);
|
||||
|
||||
xglxScreenFormat = format;
|
||||
|
||||
AddScreen (xglxScreenInit, argc, argv);
|
||||
}
|
||||
|
@ -591,7 +923,7 @@ xglxWindowExposures (WindowPtr pWin,
|
|||
|
||||
if (HasBorder (pWin))
|
||||
{
|
||||
REGION_NULL (pScreen, &ClipList);
|
||||
REGION_INIT (pScreen, &ClipList, NullBox, 0);
|
||||
REGION_SUBTRACT (pScreen, &ClipList, &pWin->borderClip,
|
||||
&pWin->winSize);
|
||||
REGION_INTERSECT (pScreen, &ClipList, &ClipList, (RegionPtr) pReg);
|
||||
|
@ -599,7 +931,7 @@ xglxWindowExposures (WindowPtr pWin,
|
|||
REGION_UNINIT (pScreen, &ClipList);
|
||||
}
|
||||
|
||||
REGION_NULL (pScreen, &ClipList);
|
||||
REGION_INIT (pScreen, &ClipList, NullBox, 0);
|
||||
REGION_INTERSECT (pScreen, &ClipList, &pWin->clipList, (RegionPtr) pReg);
|
||||
(*pScreen->WindowExposures) (pWin, &ClipList, NullRegion);
|
||||
REGION_UNINIT (pScreen, &ClipList);
|
||||
|
@ -681,6 +1013,7 @@ xglxWakeupHandler (pointer blockData,
|
|||
break;
|
||||
case MotionNotify:
|
||||
x.u.u.type = MotionNotify;
|
||||
x.u.u.detail = 0;
|
||||
x.u.keyButtonPointer.rootX = X.xmotion.x;
|
||||
x.u.keyButtonPointer.rootY = X.xmotion.y;
|
||||
x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis ();
|
||||
|
@ -692,6 +1025,7 @@ xglxWakeupHandler (pointer blockData,
|
|||
if (pScreen) {
|
||||
NewCurrentScreen (pScreen, X.xcrossing.x, X.xcrossing.y);
|
||||
x.u.u.type = MotionNotify;
|
||||
x.u.u.detail = 0;
|
||||
x.u.keyButtonPointer.rootX = X.xcrossing.x;
|
||||
x.u.keyButtonPointer.rootY = X.xcrossing.y;
|
||||
x.u.keyButtonPointer.time = lastEventTime =
|
||||
|
@ -715,11 +1049,43 @@ xglxBell (int volume,
|
|||
XBell (xdisplay, volume);
|
||||
}
|
||||
|
||||
static void
|
||||
xglxKbdCtrl (DeviceIntPtr pDev,
|
||||
KeybdCtrl *ctrl)
|
||||
{
|
||||
unsigned long valueMask;
|
||||
XKeyboardControl values;
|
||||
int i;
|
||||
|
||||
valueMask = KBKeyClickPercent | KBBellPercent | KBBellPitch |
|
||||
KBBellDuration | KBAutoRepeatMode;
|
||||
|
||||
values.key_click_percent = ctrl->click;
|
||||
values.bell_percent = ctrl->bell;
|
||||
values.bell_pitch = ctrl->bell_pitch;
|
||||
values.bell_duration = ctrl->bell_duration;
|
||||
values.auto_repeat_mode = (ctrl->autoRepeat) ? AutoRepeatModeOn :
|
||||
AutoRepeatModeOff;
|
||||
|
||||
XChangeKeyboardControl (xdisplay, valueMask, &values);
|
||||
|
||||
valueMask = KBLed | KBLedMode;
|
||||
|
||||
for (i = 1; i <= 32; i++)
|
||||
{
|
||||
values.led = i;
|
||||
values.led_mode = (ctrl->leds & (1 << (i - 1))) ? LedModeOn :
|
||||
LedModeOff;
|
||||
|
||||
XChangeKeyboardControl (xdisplay, valueMask, &values);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
xglxKeybdProc (DeviceIntPtr pDevice,
|
||||
int onoff)
|
||||
{
|
||||
Bool ret;
|
||||
Bool ret = FALSE;
|
||||
DevicePtr pDev = (DevicePtr) pDevice;
|
||||
|
||||
if (!pDev)
|
||||
|
@ -734,15 +1100,41 @@ xglxKeybdProc (DeviceIntPtr pDevice,
|
|||
CARD8 xglxModMap[256];
|
||||
XKeyboardState values;
|
||||
|
||||
#ifdef _XSERVER64
|
||||
KeySym64 *xkeyMap64;
|
||||
int len;
|
||||
#endif
|
||||
|
||||
#ifdef XKB
|
||||
Bool xkbExtension = FALSE;
|
||||
int xkbOp, xkbEvent, xkbError, xkbMajor, xkbMinor;
|
||||
#endif
|
||||
|
||||
if (pDev != LookupKeyboardDevice ())
|
||||
return !Success;
|
||||
|
||||
xmodMap = XGetModifierMapping (xdisplay);
|
||||
|
||||
XDisplayKeycodes (xdisplay, &minKeyCode, &maxKeyCode);
|
||||
|
||||
#ifdef _XSERVER64
|
||||
xkeyMap64 = XGetKeyboardMapping (xdisplay,
|
||||
minKeyCode,
|
||||
maxKeyCode - minKeyCode + 1,
|
||||
&mapWidth);
|
||||
|
||||
len = (maxKeyCode - minKeyCode + 1) * mapWidth;
|
||||
xkeyMap = (KeySym *) xalloc (len * sizeof (KeySym));
|
||||
for (i = 0; i < len; ++i)
|
||||
xkeyMap[i] = xkeyMap64[i];
|
||||
|
||||
XFree (xkeyMap64);
|
||||
#else
|
||||
xkeyMap = XGetKeyboardMapping (xdisplay,
|
||||
minKeyCode,
|
||||
maxKeyCode - minKeyCode + 1,
|
||||
&mapWidth);
|
||||
#endif
|
||||
|
||||
memset (xglxModMap, 0, 256);
|
||||
|
||||
|
@ -765,6 +1157,85 @@ xglxKeybdProc (DeviceIntPtr pDevice,
|
|||
xglxKeySyms.mapWidth = mapWidth;
|
||||
xglxKeySyms.map = xkeyMap;
|
||||
|
||||
#ifdef XKB
|
||||
if (!noXkbExtension)
|
||||
xkbExtension = XkbQueryExtension (xdisplay,
|
||||
&xkbOp, &xkbEvent, &xkbError,
|
||||
&xkbMajor, &xkbMinor);
|
||||
|
||||
if (xkbExtension)
|
||||
{
|
||||
XkbDescPtr desc;
|
||||
char *rules, *model, *layout, *variants, *options;
|
||||
|
||||
desc = XkbGetKeyboard (xdisplay,
|
||||
XkbGBN_AllComponentsMask,
|
||||
XkbUseCoreKbd);
|
||||
|
||||
if (desc && desc->geom)
|
||||
{
|
||||
XkbComponentNamesRec names;
|
||||
FILE *file;
|
||||
|
||||
rules = XKB_DFLT_RULES_FILE;
|
||||
model = XKB_DFLT_KB_MODEL;
|
||||
layout = XKB_DFLT_KB_LAYOUT;
|
||||
variants = XKB_DFLT_KB_VARIANT;
|
||||
options = XKB_DFLT_KB_OPTIONS;
|
||||
|
||||
XkbGetControls (xdisplay, XkbAllControlsMask, desc);
|
||||
|
||||
memset (&names, 0, sizeof (XkbComponentNamesRec));
|
||||
|
||||
if (XkbInitialMap)
|
||||
{
|
||||
if ((names.keymap = strchr (XkbInitialMap, '/')) != NULL)
|
||||
names.keymap++;
|
||||
else
|
||||
names.keymap = XkbInitialMap;
|
||||
}
|
||||
|
||||
file = fopen (XKB_BASE_DIRECTORY XKB_CONFIG_FILE, "r");
|
||||
if (file)
|
||||
{
|
||||
XkbConfigRtrnRec config;
|
||||
|
||||
if (XkbCFParse (file, XkbCFDflts, desc, &config))
|
||||
{
|
||||
if (config.rules_file)
|
||||
rules = config.rules_file;
|
||||
if (config.model)
|
||||
model = config.model;
|
||||
if (config.layout)
|
||||
layout = config.layout;
|
||||
if (config.variant)
|
||||
variants = config.variant;
|
||||
if (config.options)
|
||||
options = config.options;
|
||||
}
|
||||
fclose (file);
|
||||
}
|
||||
|
||||
XkbSetRulesDflts (rules, model, layout, variants, options);
|
||||
|
||||
ret = XkbInitKeyboardDeviceStruct ((pointer) pDev,
|
||||
&names,
|
||||
&xglxKeySyms,
|
||||
xglxModMap,
|
||||
xglxBell,
|
||||
xglxKbdCtrl);
|
||||
|
||||
if (ret)
|
||||
XkbDDXChangeControls ((pointer) pDev, desc->ctrls,
|
||||
desc->ctrls);
|
||||
|
||||
XkbFreeKeyboard (desc, 0, False);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
XGetKeyboardControl (xdisplay, &values);
|
||||
|
||||
memmove (defaultKeyboardControl.autoRepeats,
|
||||
|
@ -774,12 +1245,18 @@ xglxKeybdProc (DeviceIntPtr pDevice,
|
|||
&xglxKeySyms,
|
||||
xglxModMap,
|
||||
xglxBell,
|
||||
xglKbdCtrl);
|
||||
xglxKbdCtrl);
|
||||
}
|
||||
|
||||
#ifdef _XSERVER64
|
||||
xfree (xkeyMap);
|
||||
#else
|
||||
XFree (xkeyMap);
|
||||
#endif
|
||||
|
||||
if (!ret)
|
||||
return BadImplementation;
|
||||
|
||||
} break;
|
||||
case DEVICE_ON:
|
||||
pDev->on = TRUE;
|
||||
|
@ -837,6 +1314,9 @@ xglxUseMsg (void)
|
|||
ErrorF ("-fullscreen run fullscreen\n");
|
||||
ErrorF ("-display string display name of the real server\n");
|
||||
ErrorF ("-softcursor force software cursor\n");
|
||||
|
||||
if (!xDisplayName)
|
||||
xglxUseXorgMsg ();
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -844,6 +1324,46 @@ xglxProcessArgument (int argc,
|
|||
char **argv,
|
||||
int i)
|
||||
{
|
||||
static Bool checkDisplayName = FALSE;
|
||||
|
||||
if (!checkDisplayName)
|
||||
{
|
||||
char *display = ":0";
|
||||
int j;
|
||||
|
||||
for (j = i; j < argc; j++)
|
||||
{
|
||||
if (!strcmp (argv[j], "-display"))
|
||||
{
|
||||
if (++j < argc)
|
||||
xDisplayName = argv[j];
|
||||
|
||||
break;
|
||||
}
|
||||
else if (argv[j][0] == ':')
|
||||
{
|
||||
display = argv[j];
|
||||
}
|
||||
}
|
||||
|
||||
if (!xDisplayName)
|
||||
xDisplayName = getenv ("DISPLAY");
|
||||
|
||||
if (xDisplayName)
|
||||
{
|
||||
int n;
|
||||
|
||||
n = strspn (xDisplayName, ":0123456789");
|
||||
if (strncmp (xDisplayName, display, n) == 0)
|
||||
xDisplayName = 0;
|
||||
}
|
||||
|
||||
if (xDisplayName)
|
||||
fullscreen = FALSE;
|
||||
|
||||
checkDisplayName = TRUE;
|
||||
}
|
||||
|
||||
if (!strcmp (argv[i], "-screen"))
|
||||
{
|
||||
if ((i + 1) < argc)
|
||||
|
@ -860,12 +1380,11 @@ xglxProcessArgument (int argc,
|
|||
fullscreen = TRUE;
|
||||
return 1;
|
||||
}
|
||||
if (!strcmp (argv[i], "-display"))
|
||||
else if (!strcmp (argv[i], "-display"))
|
||||
{
|
||||
if (++i < argc) {
|
||||
xDisplayName = argv[i];
|
||||
if (++i < argc)
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if (!strcmp (argv[i], "-softcursor"))
|
||||
|
@ -873,6 +1392,10 @@ xglxProcessArgument (int argc,
|
|||
softCursor = TRUE;
|
||||
return 1;
|
||||
}
|
||||
else if (!xDisplayName)
|
||||
{
|
||||
return xglxProcessXorgArgument (argc, argv, i);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -880,10 +1403,11 @@ xglxProcessArgument (int argc,
|
|||
void
|
||||
xglxAbort (void)
|
||||
{
|
||||
xglxAbortXorg ();
|
||||
}
|
||||
|
||||
void
|
||||
xglxGiveUp ()
|
||||
xglxGiveUp (void)
|
||||
{
|
||||
AbortDDX ();
|
||||
}
|
||||
|
@ -913,7 +1437,7 @@ xglxCreateARGBCursor (ScreenPtr pScreen,
|
|||
CursorPtr pCursor)
|
||||
{
|
||||
Pixmap xpixmap;
|
||||
GC xgc;
|
||||
XlibGC xgc;
|
||||
XImage *ximage;
|
||||
XRenderPictFormat *xformat;
|
||||
Picture xpicture;
|
||||
|
|
|
@ -28,6 +28,62 @@
|
|||
|
||||
#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,
|
||||
|
@ -61,4 +117,22 @@ 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_ */
|
||||
|
|
|
@ -24,19 +24,30 @@
|
|||
*/
|
||||
|
||||
#include "xglx.h"
|
||||
#include "xglglx.h"
|
||||
|
||||
xglScreenInfoRec xglScreenInfo = {
|
||||
NULL, 0, 0, 0, 0,
|
||||
NULL, 0, 0, 0, 0, 0,
|
||||
DEFAULT_GEOMETRY_DATA_TYPE,
|
||||
DEFAULT_GEOMETRY_USAGE,
|
||||
FALSE,
|
||||
XGL_DEFAULT_PBO_MASK,
|
||||
FALSE,
|
||||
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
|
||||
|
@ -50,6 +61,18 @@ InitOutput (ScreenInfo *pScreenInfo,
|
|||
{
|
||||
if (!xglLoadGLXModules ())
|
||||
FatalError ("No GLX modules loaded");
|
||||
|
||||
#ifndef NGLXEXTLOG
|
||||
if (glxExtLogFile)
|
||||
{
|
||||
__xglGLXLogFp = fopen (glxExtLogFile, "w");
|
||||
if (!__xglGLXLogFp)
|
||||
perror ("InitOutput");
|
||||
}
|
||||
else
|
||||
__xglGLXLogFp = 0;
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -83,6 +106,11 @@ ddxUseMsg (void)
|
|||
|
||||
#ifdef GLXEXT
|
||||
ErrorF ("-noglx don't load glx extension\n");
|
||||
|
||||
#ifndef NGLXEXTLOG
|
||||
ErrorF ("-glxlog file glx extension log file\n");
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
xglUseMsg ();
|
||||
|
@ -103,6 +131,15 @@ ddxProcessArgument (int argc,
|
|||
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);
|
||||
|
@ -130,6 +167,6 @@ OsVendorInit (void)
|
|||
xglxOsVendorInit ();
|
||||
}
|
||||
|
||||
void ddxInitGlobals(void)
|
||||
void ddxInitGlobals()
|
||||
{
|
||||
}
|
||||
|
|
676
hw/xgl/glx/xglxorg.c
Normal file
676
hw/xgl/glx/xglxorg.c
Normal file
|
@ -0,0 +1,676 @@
|
|||
/*
|
||||
* 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"),
|
||||
ARG (xglxProcessXorgWaitExitArgument, "-scanpci",
|
||||
" execute the scanpci module and 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,13 +1,21 @@
|
|||
SUBDIRS = module
|
||||
|
||||
INCLUDES = \
|
||||
@XGL_INCS@ \
|
||||
@XSERVER_CFLAGS@
|
||||
AM_CFLAGS = \
|
||||
@SERVER_DEFINES@ \
|
||||
-DHAVE_XGL_CONFIG_H \
|
||||
-DHAVE_DIX_CONFIG_H \
|
||||
$(XGLMODULES_CFLAGS) \
|
||||
-I$(top_srcdir)/GL/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
|
||||
xglglxext.c \
|
||||
xglglxlog.c
|
||||
|
||||
noinst_LTLIBRARIES = $(libxglglxext_libraries)
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
INCLUDES = \
|
||||
@XGLX_INCS@ \
|
||||
@XSERVER_CFLAGS@
|
||||
AM_CFLAGS = \
|
||||
@SERVER_DEFINES@ \
|
||||
-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
|
||||
|
@ -9,10 +12,10 @@ libglx_modules = libglx.la
|
|||
|
||||
libglcore_la_LDFLAGS = -avoid-version
|
||||
libglcore_la_SOURCES = glcoremodule.c
|
||||
libglcore_la_LIBADD = $(top_builddir)/GL/mesa/libglcore.la
|
||||
libglcore_la_LIBADD = $(top_builddir)/GL/mesa/libGLcore.la
|
||||
libglcore_modules = libglcore.la
|
||||
|
||||
moduledir = @MODULEPATH@/xgl
|
||||
moduledir = @XGL_MODULE_PATH@
|
||||
|
||||
module_LTLIBRARIES = \
|
||||
$(libglcore_modules) \
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -26,11 +26,16 @@
|
|||
#ifndef _XGL_GLXEXT_H_
|
||||
#define _XGL_GLXEXT_H_
|
||||
|
||||
#include <xgl-config.h>
|
||||
|
||||
#include "scrnintstr.h"
|
||||
|
||||
Bool
|
||||
xglInitVisualConfigs (ScreenPtr pScreen);
|
||||
|
||||
#ifndef NGLXEXTLOG
|
||||
|
||||
void
|
||||
xglInitGlxLog (void);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _XGL_GLXEXT_H_ */
|
||||
|
|
4519
hw/xgl/glxext/xglglxlog.c
Normal file
4519
hw/xgl/glxext/xglglxlog.c
Normal file
File diff suppressed because it is too large
Load Diff
239
hw/xgl/xgl.h
239
hw/xgl/xgl.h
|
@ -28,8 +28,6 @@
|
|||
|
||||
#include <xgl-config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <X11/X.h>
|
||||
#define NEED_EVENTS
|
||||
#include <X11/Xproto.h>
|
||||
|
@ -44,11 +42,23 @@
|
|||
#include "dix.h"
|
||||
#include "damage.h"
|
||||
#include "gc.h"
|
||||
#include "micmap.h"
|
||||
/* I'd like gc.h to provide this */
|
||||
typedef struct _GCFuncs *GCFuncsPtr;
|
||||
|
||||
#ifdef RENDER
|
||||
#include "mipict.h"
|
||||
#else
|
||||
#ifdef XV
|
||||
#undef XV /* Xv implementation require RENDER */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef XV
|
||||
#define XGL_XV_FORMAT_YUY2 0
|
||||
#define XGL_XV_FORMAT_YV12 1
|
||||
#define XGL_XV_FORMAT_RGB 2
|
||||
#define XGL_XV_FORMAT_NUM 3
|
||||
#endif
|
||||
|
||||
/* For the modules. We should decide what the actual version numbering should
|
||||
|
@ -60,8 +70,29 @@ extern WindowPtr *WindowTable;
|
|||
|
||||
#define XGL_DEFAULT_PBO_MASK 0
|
||||
|
||||
typedef struct _xglSizeConstraint {
|
||||
int minWidth;
|
||||
int minHeight;
|
||||
int aboveWidth;
|
||||
int aboveHeight;
|
||||
} xglSizeConstraintRec, *xglSizeConstraintPtr;
|
||||
|
||||
typedef struct _xglAccelInfo {
|
||||
Bool enabled;
|
||||
Bool pbuffer;
|
||||
xglSizeConstraintRec size;
|
||||
} xglAccelInfoRec, *xglAccelInfoPtr;
|
||||
|
||||
typedef struct _xglScreenAccelInfo {
|
||||
xglAccelInfoRec pixmap;
|
||||
xglAccelInfoRec window;
|
||||
xglAccelInfoRec glx;
|
||||
xglAccelInfoRec xv;
|
||||
} xglScreenAccelInfoRec, *xglScreenAccelInfoPtr;
|
||||
|
||||
typedef struct _xglScreenInfo {
|
||||
glitz_drawable_t *drawable;
|
||||
unsigned int depth;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned int widthMm;
|
||||
|
@ -71,7 +102,7 @@ typedef struct _xglScreenInfo {
|
|||
Bool yInverted;
|
||||
int pboMask;
|
||||
Bool lines;
|
||||
Bool fbo;
|
||||
xglScreenAccelInfoRec accel;
|
||||
} xglScreenInfoRec, *xglScreenInfoPtr;
|
||||
|
||||
extern xglScreenInfoRec xglScreenInfo;
|
||||
|
@ -82,18 +113,17 @@ typedef struct _xglPixelFormat {
|
|||
} xglPixelFormatRec, *xglPixelFormatPtr;
|
||||
|
||||
typedef struct _xglVisual {
|
||||
glitz_drawable_format_t *format;
|
||||
struct _xglVisual *next;
|
||||
VisualID vid;
|
||||
xglPixelFormatPtr pPixel;
|
||||
unsigned long visuals;
|
||||
Bool pbuffer;
|
||||
struct {
|
||||
glitz_drawable_format_t *drawable;
|
||||
glitz_format_t *surface;
|
||||
} format;
|
||||
} xglVisualRec, *xglVisualPtr;
|
||||
|
||||
typedef struct _xglPixmapFormat {
|
||||
glitz_format_t *format;
|
||||
xglPixelFormatPtr pPixel;
|
||||
} xglPixmapFormatRec, *xglPixmapFormatPtr;
|
||||
|
||||
extern xglVisualPtr xglVisuals;
|
||||
extern int nxglVisuals;
|
||||
|
||||
#define xglAreaAvailable 0
|
||||
#define xglAreaDivided 1
|
||||
|
@ -166,7 +196,7 @@ typedef struct _xglRange {
|
|||
} xglRangeRec, *xglRangePtr;
|
||||
|
||||
typedef struct _xglGlyphTexture {
|
||||
glitz_surface_t *mask;
|
||||
PicturePtr pMask;
|
||||
glitz_pixel_format_t pixel;
|
||||
glitz_geometry_format_t format;
|
||||
int geometryDataType;
|
||||
|
@ -206,11 +236,18 @@ extern int xglGlyphPrivateIndex;
|
|||
|
||||
typedef struct _xglScreen {
|
||||
xglVisualPtr pVisual;
|
||||
xglPixmapFormatRec pixmapFormats[33];
|
||||
|
||||
#ifdef GLXEXT
|
||||
xglVisualPtr pGlxVisual;
|
||||
#endif
|
||||
|
||||
#ifdef XV
|
||||
xglVisualRec pXvVisual[XGL_XV_FORMAT_NUM];
|
||||
#endif
|
||||
|
||||
xglVisualPtr rootVisual;
|
||||
glitz_drawable_t *drawable;
|
||||
glitz_surface_t *surface;
|
||||
glitz_surface_t *backSurface;
|
||||
glitz_surface_t *solid;
|
||||
PixmapPtr pScreenPixmap;
|
||||
unsigned long features;
|
||||
int geometryUsage;
|
||||
|
@ -218,15 +255,14 @@ typedef struct _xglScreen {
|
|||
Bool yInverted;
|
||||
int pboMask;
|
||||
Bool lines;
|
||||
Bool fbo;
|
||||
xglGeometryRec scratchGeometry;
|
||||
xglScreenAccelInfoRec accel;
|
||||
|
||||
#ifdef RENDER
|
||||
xglGlyphCacheRec glyphCache[33];
|
||||
PicturePtr pSolidAlpha;
|
||||
struct _trapInfo {
|
||||
PicturePtr pMask;
|
||||
glitz_surface_t *mask;
|
||||
glitz_geometry_format_t format;
|
||||
} trapInfo;
|
||||
#endif
|
||||
|
@ -234,6 +270,7 @@ typedef struct _xglScreen {
|
|||
GetImageProcPtr GetImage;
|
||||
GetSpansProcPtr GetSpans;
|
||||
CreateWindowProcPtr CreateWindow;
|
||||
DestroyWindowProcPtr DestroyWindow;
|
||||
ChangeWindowAttributesProcPtr ChangeWindowAttributes;
|
||||
PaintWindowBackgroundProcPtr PaintWindowBackground;
|
||||
PaintWindowBorderProcPtr PaintWindowBorder;
|
||||
|
@ -258,11 +295,6 @@ typedef struct _xglScreen {
|
|||
#endif
|
||||
|
||||
BSFuncRec BackingStoreFuncs;
|
||||
|
||||
#ifdef GLXEXT
|
||||
DestroyWindowProcPtr DestroyWindow;
|
||||
#endif
|
||||
|
||||
} xglScreenRec, *xglScreenPtr;
|
||||
|
||||
extern int xglScreenPrivateIndex;
|
||||
|
@ -293,13 +325,13 @@ extern int xglScreenPrivateIndex;
|
|||
#endif
|
||||
|
||||
#define xglGCSoftwareDrawableFlag (1L << 0)
|
||||
#define xglGCReadOnlyDrawableFlag (1L << 1)
|
||||
#define xglGCBadFunctionFlag (1L << 2)
|
||||
#define xglGCPlaneMaskFlag (1L << 3)
|
||||
#define xglGCBadFunctionFlag (1L << 1)
|
||||
#define xglGCPlaneMaskFlag (1L << 2)
|
||||
|
||||
typedef struct _xglGC {
|
||||
glitz_color_t fg;
|
||||
glitz_color_t bg;
|
||||
glitz_surface_t *fg;
|
||||
glitz_surface_t *bg;
|
||||
glitz_format_id_t id;
|
||||
glitz_operator_t op;
|
||||
unsigned long flags;
|
||||
GCFuncsPtr funcs;
|
||||
|
@ -334,10 +366,20 @@ extern int xglGCPrivateIndex;
|
|||
#define xglPixmapTargetOut 1
|
||||
#define xglPixmapTargetIn 2
|
||||
|
||||
#ifdef XV
|
||||
|
||||
typedef struct _xglXvPort {
|
||||
PixmapPtr pPixmap;
|
||||
PicturePtr pSrc;
|
||||
PicturePtr pDst;
|
||||
} xglXvPortRec, *xglXvPortPtr;
|
||||
|
||||
#endif
|
||||
|
||||
typedef struct _xglPixmap {
|
||||
xglPixelFormatPtr pPixel;
|
||||
glitz_format_t *format;
|
||||
xglVisualPtr pVisual;
|
||||
glitz_surface_t *surface;
|
||||
glitz_drawable_t *drawable;
|
||||
glitz_buffer_t *buffer;
|
||||
int target;
|
||||
Bool acceleratedTile;
|
||||
|
@ -345,11 +387,15 @@ typedef struct _xglPixmap {
|
|||
int stride;
|
||||
DamagePtr pDamage;
|
||||
BoxRec damageBox;
|
||||
BoxRec bitBox;
|
||||
RegionRec bitRegion;
|
||||
Bool allBits;
|
||||
unsigned long pictureMask;
|
||||
xglGeometryPtr pGeometry;
|
||||
int lock;
|
||||
|
||||
#ifdef XV
|
||||
xglXvPortPtr pPortPriv;
|
||||
#endif
|
||||
|
||||
} xglPixmapRec, *xglPixmapPtr;
|
||||
|
||||
extern int xglPixmapPrivateIndex;
|
||||
|
@ -463,28 +509,42 @@ xglInitInput (int argc, char **argv);
|
|||
void
|
||||
xglSetPixmapFormats (ScreenInfo *pScreenInfo);
|
||||
|
||||
void
|
||||
xglSetRootClip (ScreenPtr pScreen,
|
||||
Bool enable);
|
||||
|
||||
|
||||
/* xglcmap.c */
|
||||
|
||||
void
|
||||
xglSetVisualTypesAndMasks (ScreenInfo *pScreenInfo,
|
||||
glitz_drawable_format_t *format,
|
||||
unsigned long visuals);
|
||||
xglSetVisualTypes (int depth,
|
||||
int visuals,
|
||||
int redSize,
|
||||
int greenSize,
|
||||
int blueSize);
|
||||
|
||||
Bool
|
||||
xglHasVisualTypes (xglVisualPtr pVisual,
|
||||
int depth);
|
||||
|
||||
glitz_format_t *
|
||||
xglFindBestSurfaceFormat (ScreenPtr pScreen,
|
||||
xglPixelFormatPtr pPixel);
|
||||
|
||||
void
|
||||
xglInitVisuals (ScreenInfo *pScreenInfo);
|
||||
xglInitVisuals (ScreenPtr pScreen);
|
||||
|
||||
xglVisualPtr
|
||||
xglFindVisualWithDepth (ScreenPtr pScreen,
|
||||
int depth);
|
||||
|
||||
xglVisualPtr
|
||||
xglFindVisualWithId (ScreenPtr pScreen,
|
||||
int vid);
|
||||
|
||||
void
|
||||
xglClearVisualTypes (void);
|
||||
|
||||
void
|
||||
xglInitPixmapFormats (ScreenPtr pScreen);
|
||||
|
||||
void
|
||||
xglPixelToColor (xglPixelFormatPtr pFormat,
|
||||
CARD32 pixel,
|
||||
glitz_color_t *color);
|
||||
|
||||
|
||||
/* xglparse.c */
|
||||
|
||||
|
@ -831,6 +891,10 @@ xglModifyPixmapHeader (PixmapPtr pPixmap,
|
|||
int devKind,
|
||||
pointer pPixData);
|
||||
|
||||
void
|
||||
xglSetPixmapVisual (PixmapPtr pPixmap,
|
||||
xglVisualPtr pVisual);
|
||||
|
||||
RegionPtr
|
||||
xglPixmapToRegion (PixmapPtr pPixmap);
|
||||
|
||||
|
@ -851,6 +915,14 @@ xglMapPixmapBits (PixmapPtr pPixmap);
|
|||
Bool
|
||||
xglUnmapPixmapBits (PixmapPtr pPixmap);
|
||||
|
||||
Bool
|
||||
xglCheckPixmapSize (PixmapPtr pPixmap,
|
||||
xglSizeConstraintPtr pSize);
|
||||
|
||||
void
|
||||
xglEnablePixmapAccel (PixmapPtr pPixmap,
|
||||
xglAccelInfoPtr pAccel);
|
||||
|
||||
|
||||
/* xglsync.c */
|
||||
|
||||
|
@ -887,7 +959,7 @@ xglAddCurrentBitDamage (DrawablePtr pDrawable);
|
|||
Bool
|
||||
xglSolid (DrawablePtr pDrawable,
|
||||
glitz_operator_t op,
|
||||
glitz_color_t *color,
|
||||
glitz_surface_t *solid,
|
||||
xglGeometryPtr pGeometry,
|
||||
int x,
|
||||
int y,
|
||||
|
@ -1008,6 +1080,9 @@ xglFillGlyph (DrawablePtr pDrawable,
|
|||
Bool
|
||||
xglCreateWindow (WindowPtr pWin);
|
||||
|
||||
Bool
|
||||
xglDestroyWindow (WindowPtr pWin);
|
||||
|
||||
Bool
|
||||
xglChangeWindowAttributes (WindowPtr pWin,
|
||||
unsigned long mask);
|
||||
|
@ -1027,6 +1102,13 @@ xglPaintWindowBorder (WindowPtr pWin,
|
|||
RegionPtr pRegion,
|
||||
int what);
|
||||
|
||||
PixmapPtr
|
||||
xglGetWindowPixmap (WindowPtr pWin);
|
||||
|
||||
void
|
||||
xglSetWindowPixmap (WindowPtr pWin,
|
||||
PixmapPtr pPixmap);
|
||||
|
||||
|
||||
/* xglbstore.c */
|
||||
|
||||
|
@ -1071,6 +1153,9 @@ xglGetSpans (DrawablePtr pDrawable,
|
|||
Bool
|
||||
xglCreateGC (GCPtr pGC);
|
||||
|
||||
void
|
||||
xglDestroyGC (GCPtr pGC);
|
||||
|
||||
void
|
||||
xglValidateGC (GCPtr pGC,
|
||||
unsigned long changes,
|
||||
|
@ -1217,25 +1302,6 @@ xglShmPutImage (DrawablePtr pDrawable,
|
|||
|
||||
#ifdef RENDER
|
||||
|
||||
/* xglcomp.c */
|
||||
|
||||
Bool
|
||||
xglComp (CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pMask,
|
||||
PicturePtr pDst,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
INT16 xMask,
|
||||
INT16 yMask,
|
||||
INT16 xDst,
|
||||
INT16 yDst,
|
||||
CARD16 width,
|
||||
CARD16 height,
|
||||
xglGeometryPtr pGeometry,
|
||||
glitz_surface_t *mask);
|
||||
|
||||
|
||||
/* xglpict.c */
|
||||
|
||||
void
|
||||
|
@ -1273,8 +1339,18 @@ xglChangePictureFilter (PicturePtr pPicture,
|
|||
xFixed *params,
|
||||
int nparams);
|
||||
|
||||
void
|
||||
xglUpdatePicture (PicturePtr pPicture);
|
||||
PicturePtr
|
||||
xglCreateDevicePicture (pointer data);
|
||||
|
||||
Bool
|
||||
xglSyncPicture (ScreenPtr pScreen,
|
||||
PicturePtr pPicture,
|
||||
INT16 x,
|
||||
INT16 y,
|
||||
CARD16 width,
|
||||
CARD16 height,
|
||||
INT16 *xOff,
|
||||
INT16 *yOff);
|
||||
|
||||
Bool
|
||||
xglPictureInit (ScreenPtr pScreen);
|
||||
|
@ -1283,6 +1359,25 @@ void
|
|||
xglPictureClipExtents (PicturePtr pPicture,
|
||||
BoxPtr extents);
|
||||
|
||||
|
||||
/* xglcompose.c */
|
||||
|
||||
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);
|
||||
|
||||
|
||||
/* xglglyph.c */
|
||||
|
||||
Bool
|
||||
|
@ -1344,7 +1439,8 @@ typedef struct _xglSymbol {
|
|||
} xglSymbolRec, *xglSymbolPtr;
|
||||
|
||||
void *
|
||||
xglLoadModule (const char *name);
|
||||
xglLoadModule (const char *name,
|
||||
int flag);
|
||||
|
||||
void
|
||||
xglUnloadModule (void *handle);
|
||||
|
@ -1356,18 +1452,17 @@ xglLookupSymbols (void *handle,
|
|||
|
||||
#endif
|
||||
|
||||
#ifdef GLXEXT
|
||||
|
||||
/* xglglx.c */
|
||||
/* xglxv.c */
|
||||
|
||||
#ifdef XV
|
||||
|
||||
Bool
|
||||
xglLoadGLXModules (void);
|
||||
|
||||
void
|
||||
xglUnloadGLXModules (void);
|
||||
xglXvScreenInit (ScreenPtr pScreen);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* xglhash.c */
|
||||
|
||||
typedef struct _xglHashTable *xglHashTablePtr;
|
||||
|
|
|
@ -74,7 +74,7 @@ xglSaveAreas (PixmapPtr pPixmap,
|
|||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
|
||||
XGL_BSTORE_FALLBACK_PROLOGUE (&pPixmap->drawable,
|
||||
BackingStoreFuncs.RestoreAreas);
|
||||
BackingStoreFuncs.SaveAreas);
|
||||
(*pScreen->BackingStoreFuncs.SaveAreas) (pPixmap, prgnSave,
|
||||
xorg, yorg, pWin);
|
||||
XGL_BSTORE_FALLBACK_EPILOGUE (&pPixmap->drawable,
|
||||
|
|
493
hw/xgl/xglcmap.c
493
hw/xgl/xglcmap.c
|
@ -23,7 +23,6 @@
|
|||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "xgl.h"
|
||||
#include "colormapst.h"
|
||||
#include "micmap.h"
|
||||
|
@ -82,224 +81,386 @@ static xglPixelFormatRec xglPixelFormats[] = {
|
|||
(sizeof (xglPixelFormats) / sizeof (xglPixelFormats[0]))
|
||||
|
||||
xglVisualPtr xglVisuals = NULL;
|
||||
int nxglVisuals = 0;
|
||||
|
||||
xglVisualPtr xglPbufferVisuals = NULL;
|
||||
int nxglPbufferVisuals = 0;
|
||||
|
||||
static xglPixelFormatPtr
|
||||
xglFindPixelFormat (glitz_drawable_format_t *format,
|
||||
int visuals)
|
||||
void
|
||||
xglSetVisualTypes (int depth,
|
||||
int visuals,
|
||||
int redSize,
|
||||
int greenSize,
|
||||
int blueSize)
|
||||
{
|
||||
glitz_color_format_t *color;
|
||||
int depth, i;
|
||||
|
||||
color = &format->color;
|
||||
|
||||
depth = color->red_size + color->green_size + color->blue_size;
|
||||
|
||||
if (!visuals)
|
||||
depth += color->alpha_size;
|
||||
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)
|
||||
{
|
||||
xglPixelFormatPtr pPixel;
|
||||
|
||||
pPixel = &xglPixelFormats[i];
|
||||
if (Ones (pPixel->masks.red_mask) == color->red_size &&
|
||||
Ones (pPixel->masks.green_mask) == color->green_size &&
|
||||
Ones (pPixel->masks.blue_mask) == color->blue_size)
|
||||
{
|
||||
|
||||
if (visuals)
|
||||
return pPixel;
|
||||
|
||||
if (Ones (pPixel->masks.alpha_mask) == color->alpha_size)
|
||||
return pPixel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
xglSetVisualTypesAndMasks (ScreenInfo *pScreenInfo,
|
||||
glitz_drawable_format_t *format,
|
||||
unsigned long visuals)
|
||||
{
|
||||
xglPixelFormatPtr pPixelFormat;
|
||||
|
||||
pPixelFormat = xglFindPixelFormat (format, visuals);
|
||||
if (pPixelFormat)
|
||||
{
|
||||
if (visuals)
|
||||
{
|
||||
xglVisuals = xrealloc (xglVisuals,
|
||||
(nxglVisuals + 1) * sizeof (xglVisualRec));
|
||||
rs = Ones (xglPixelFormats[i].masks.red_mask);
|
||||
gs = Ones (xglPixelFormats[i].masks.green_mask);
|
||||
bs = Ones (xglPixelFormats[i].masks.blue_mask);
|
||||
|
||||
if (xglVisuals)
|
||||
if (redSize >= rs &&
|
||||
greenSize >= gs &&
|
||||
blueSize >= bs)
|
||||
{
|
||||
xglVisuals[nxglVisuals].format = format;
|
||||
xglVisuals[nxglVisuals].pPixel = pPixelFormat;
|
||||
xglVisuals[nxglVisuals].visuals = visuals;
|
||||
nxglVisuals++;
|
||||
diff = (redSize - rs) + (greenSize - gs) + (blueSize - bs);
|
||||
if (pBestFormat)
|
||||
{
|
||||
if (diff < bestDiff)
|
||||
{
|
||||
pBestFormat = &xglPixelFormats[i];
|
||||
bestDiff = diff;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pBestFormat = &xglPixelFormats[i];
|
||||
bestDiff = diff;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
xglInitVisuals (ScreenInfo *pScreenInfo)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < pScreenInfo->numPixmapFormats; i++)
|
||||
else
|
||||
{
|
||||
unsigned long visuals;
|
||||
unsigned int bitsPerRGB;
|
||||
Pixel rm, gm, bm;
|
||||
|
||||
visuals = 0;
|
||||
bitsPerRGB = 0;
|
||||
rm = gm = bm = 0;
|
||||
|
||||
for (j = 0; j < nxglVisuals; j++)
|
||||
{
|
||||
if (pScreenInfo->formats[i].depth == xglVisuals[j].pPixel->depth)
|
||||
{
|
||||
visuals = xglVisuals[j].visuals;
|
||||
bitsPerRGB = xglVisuals[j].pPixel->bitsPerRGB;
|
||||
|
||||
rm = xglVisuals[j].pPixel->masks.red_mask;
|
||||
gm = xglVisuals[j].pPixel->masks.green_mask;
|
||||
bm = xglVisuals[j].pPixel->masks.blue_mask;
|
||||
|
||||
fbSetVisualTypesAndMasks (pScreenInfo->formats[i].depth,
|
||||
visuals, bitsPerRGB,
|
||||
rm, gm, bm);
|
||||
}
|
||||
}
|
||||
|
||||
if (!visuals)
|
||||
{
|
||||
for (j = 0; j < NUM_XGL_PIXEL_FORMATS; j++)
|
||||
{
|
||||
if (pScreenInfo->formats[i].depth == xglPixelFormats[j].depth)
|
||||
{
|
||||
bitsPerRGB = xglPixelFormats[j].bitsPerRGB;
|
||||
|
||||
rm = xglPixelFormats[j].masks.red_mask;
|
||||
gm = xglPixelFormats[j].masks.green_mask;
|
||||
bm = xglPixelFormats[j].masks.blue_mask;
|
||||
pBestFormat = &xglPixelFormats[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fbSetVisualTypesAndMasks (pScreenInfo->formats[i].depth,
|
||||
visuals, bitsPerRGB,
|
||||
rm, gm, bm);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
xglClearVisualTypes (void)
|
||||
Bool
|
||||
xglHasVisualTypes (xglVisualPtr pVisual,
|
||||
int depth)
|
||||
{
|
||||
nxglVisuals = 0;
|
||||
nxglPbufferVisuals = 0;
|
||||
xglVisualPtr v;
|
||||
|
||||
if (xglVisuals)
|
||||
xfree (xglVisuals);
|
||||
for (v = pVisual; v; v = v->next)
|
||||
if (v->pPixel->depth == depth)
|
||||
return TRUE;
|
||||
|
||||
if (xglPbufferVisuals)
|
||||
xfree (xglPbufferVisuals);
|
||||
|
||||
xglVisuals = NULL;
|
||||
xglPbufferVisuals = NULL;
|
||||
|
||||
miClearVisualTypes ();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
xglInitPixmapFormats (ScreenPtr pScreen)
|
||||
glitz_format_t *
|
||||
xglFindBestSurfaceFormat (ScreenPtr pScreen,
|
||||
xglPixelFormatPtr pPixel)
|
||||
{
|
||||
glitz_format_t *format, **best;
|
||||
int i, j;
|
||||
glitz_format_t templ, *format, *best = 0;
|
||||
unsigned int mask;
|
||||
unsigned short rs, gs, bs, as;
|
||||
int i = 0;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
for (i = 0; i < 33; i++)
|
||||
{
|
||||
pScreenPriv->pixmapFormats[i].pPixel = NULL;
|
||||
pScreenPriv->pixmapFormats[i].format = NULL;
|
||||
rs = Ones (pPixel->masks.red_mask);
|
||||
gs = Ones (pPixel->masks.green_mask);
|
||||
bs = Ones (pPixel->masks.blue_mask);
|
||||
as = Ones (pPixel->masks.alpha_mask);
|
||||
|
||||
for (j = 0; j < NUM_XGL_PIXEL_FORMATS; j++)
|
||||
{
|
||||
if (xglPixelFormats[j].depth == i)
|
||||
{
|
||||
int rs, gs, bs, as, k;
|
||||
templ.color.fourcc = GLITZ_FOURCC_RGB;
|
||||
mask = GLITZ_FORMAT_FOURCC_MASK;
|
||||
|
||||
pScreenPriv->pixmapFormats[i].pPixel = &xglPixelFormats[j];
|
||||
pScreenPriv->pixmapFormats[i].format = NULL;
|
||||
best = &pScreenPriv->pixmapFormats[i].format;
|
||||
|
||||
rs = Ones (xglPixelFormats[j].masks.red_mask);
|
||||
gs = Ones (xglPixelFormats[j].masks.green_mask);
|
||||
bs = Ones (xglPixelFormats[j].masks.blue_mask);
|
||||
as = Ones (xglPixelFormats[j].masks.alpha_mask);
|
||||
|
||||
k = 0;
|
||||
do {
|
||||
format = glitz_find_format (pScreenPriv->drawable,
|
||||
0, NULL, k++);
|
||||
if (format && format->color.fourcc == GLITZ_FOURCC_RGB)
|
||||
format = glitz_find_format (pScreenPriv->drawable, mask, &templ, i++);
|
||||
if (format)
|
||||
{
|
||||
/* find best matching sufficient 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 (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;
|
||||
((best->color.red_size - rs) +
|
||||
(best->color.green_size - gs) +
|
||||
(best->color.blue_size - bs)))
|
||||
best = format;
|
||||
}
|
||||
else
|
||||
{
|
||||
best = format;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (format);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return best;
|
||||
}
|
||||
|
||||
#define PIXEL_TO_COLOR(p, mask) \
|
||||
(((uint32_t) ((((uint64_t) (((uint32_t) (p)) & (mask))) * 0xffffffff) / \
|
||||
((uint64_t) (mask)))))
|
||||
static Bool
|
||||
xglInitVisual (ScreenPtr pScreen,
|
||||
xglVisualPtr pVisual,
|
||||
xglPixelFormatPtr pPixel,
|
||||
VisualID vid)
|
||||
{
|
||||
glitz_format_t *format;
|
||||
|
||||
#define PIXEL_TO_RGB_COLOR(p, mask) \
|
||||
((mask)? PIXEL_TO_COLOR (p, mask): 0)
|
||||
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
|
||||
xglPixelToColor (xglPixelFormatPtr pFormat,
|
||||
CARD32 pixel,
|
||||
glitz_color_t *color)
|
||||
xglInitVisuals (ScreenPtr pScreen)
|
||||
{
|
||||
color->red = PIXEL_TO_RGB_COLOR (pixel, pFormat->masks.red_mask);
|
||||
color->green = PIXEL_TO_RGB_COLOR (pixel, pFormat->masks.green_mask);
|
||||
color->blue = PIXEL_TO_RGB_COLOR (pixel, pFormat->masks.blue_mask);
|
||||
xglVisualPtr pVisual, v, new, *prev;
|
||||
int i;
|
||||
|
||||
if (pFormat->masks.alpha_mask)
|
||||
color->alpha = PIXEL_TO_COLOR (pixel, pFormat->masks.alpha_mask);
|
||||
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
|
||||
color->alpha = 0xffff;
|
||||
{
|
||||
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 ();
|
||||
}
|
||||
|
|
|
@ -48,11 +48,17 @@ static glitz_operator_t xglOperators[] = {
|
|||
|
||||
#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
|
||||
xglComp (CARD8 op,
|
||||
xglCompositeGeneral (CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pMask,
|
||||
PicturePtr pDst,
|
||||
xglGeometryPtr pGeometry,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
INT16 xMask,
|
||||
|
@ -60,16 +66,14 @@ xglComp (CARD8 op,
|
|||
INT16 xDst,
|
||||
INT16 yDst,
|
||||
CARD16 width,
|
||||
CARD16 height,
|
||||
xglGeometryPtr pGeometry,
|
||||
glitz_surface_t *mask)
|
||||
CARD16 height)
|
||||
{
|
||||
ScreenPtr pScreen = pDst->pDrawable->pScreen;
|
||||
xglPixmapPtr pSrcPriv;
|
||||
glitz_surface_t *src, *dst;
|
||||
INT16 xOff, yOff;
|
||||
glitz_surface_t *src, *mask = NULL, *dst;
|
||||
int dstXoff, dstYoff;
|
||||
RegionRec region;
|
||||
BoxPtr pBox;
|
||||
BoxPtr pBox, pExt;
|
||||
int nBox;
|
||||
|
||||
if (pDst->alphaMap)
|
||||
|
@ -78,25 +82,29 @@ xglComp (CARD8 op,
|
|||
if (op >= NUM_XGL_OPERATORS)
|
||||
return FALSE;
|
||||
|
||||
if (pSrc->pSourcePict)
|
||||
return FALSE;
|
||||
|
||||
if (pSrc->pDrawable)
|
||||
{
|
||||
if (pSrc->pDrawable->type != DRAWABLE_PIXMAP)
|
||||
return FALSE;
|
||||
|
||||
if (pSrc->pDrawable->bitsPerPixel == 1)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (pMask)
|
||||
{
|
||||
if (pMask->pSourcePict)
|
||||
return FALSE;
|
||||
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,
|
||||
|
@ -105,33 +113,30 @@ xglComp (CARD8 op,
|
|||
|
||||
pBox = REGION_RECTS (®ion);
|
||||
nBox = REGION_NUM_RECTS (®ion);
|
||||
|
||||
if (!xglPrepareTarget (pDst->pDrawable))
|
||||
{
|
||||
REGION_UNINIT (pScreen, ®ion);
|
||||
return FALSE;
|
||||
}
|
||||
pExt = REGION_EXTENTS (pScreen, ®ion);
|
||||
|
||||
XGL_GET_DRAWABLE (pDst->pDrawable, dst, dstXoff, dstYoff);
|
||||
|
||||
if (!xglSyncSurface (pSrc->pDrawable))
|
||||
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;
|
||||
}
|
||||
|
||||
pSrcPriv = XGL_GET_PIXMAP_PRIV ((PixmapPtr) pSrc->pDrawable);
|
||||
if (XGL_PICTURE_CHANGES (pSrcPriv->pictureMask))
|
||||
xglUpdatePicture (pSrc);
|
||||
xSrc -= xOff;
|
||||
ySrc -= yOff;
|
||||
|
||||
src = pSrcPriv->surface;
|
||||
XGL_GET_SOURCE_PICTURE (pSrc, src);
|
||||
|
||||
if (pMask)
|
||||
{
|
||||
xglPixmapPtr pMaskPriv;
|
||||
|
||||
/* bitmap as mask */
|
||||
if (pMask->pDrawable->bitsPerPixel == 1)
|
||||
if (pMask->pDrawable && pMask->pDrawable->bitsPerPixel == 1)
|
||||
{
|
||||
if (pGeometry)
|
||||
{
|
||||
|
@ -139,8 +144,7 @@ xglComp (CARD8 op,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
pGeometry =
|
||||
xglPixmapToGeometry ((PixmapPtr) pMask->pDrawable,
|
||||
pGeometry = xglPixmapToGeometry ((PixmapPtr) pMask->pDrawable,
|
||||
xDst - xMask,
|
||||
yDst - yMask);
|
||||
if (!pGeometry)
|
||||
|
@ -151,17 +155,21 @@ xglComp (CARD8 op,
|
|||
}
|
||||
else
|
||||
{
|
||||
if (!xglSyncSurface (pMask->pDrawable))
|
||||
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;
|
||||
}
|
||||
|
||||
pMaskPriv = XGL_GET_PIXMAP_PRIV ((PixmapPtr) pMask->pDrawable);
|
||||
if (XGL_PICTURE_CHANGES (pMaskPriv->pictureMask))
|
||||
xglUpdatePicture (pMask);
|
||||
xMask -= xOff;
|
||||
yMask -= yOff;
|
||||
|
||||
mask = pMaskPriv->surface;
|
||||
XGL_GET_SOURCE_PICTURE (pMask, mask);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -169,10 +177,12 @@ xglComp (CARD8 op,
|
|||
{
|
||||
if (!pSrc->transform && pSrc->filter != PictFilterConvolution)
|
||||
{
|
||||
if (pSrc->repeat)
|
||||
if (pSrc->pDrawable && pSrc->repeat == RepeatNormal)
|
||||
{
|
||||
XGL_PIXMAP_PRIV ((PixmapPtr) pSrc->pDrawable);
|
||||
|
||||
/* tile */
|
||||
if (!pSrcPriv->acceleratedTile)
|
||||
if (!pPixmapPriv->acceleratedTile)
|
||||
{
|
||||
pGeometry =
|
||||
xglTiledBoxGeometry ((PixmapPtr) pSrc->pDrawable,
|
||||
|
@ -184,7 +194,7 @@ xglComp (CARD8 op,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
pBox = REGION_EXTENTS (pScreen, ®ion);
|
||||
pBox = pExt;
|
||||
nBox = 1;
|
||||
}
|
||||
}
|
||||
|
@ -213,7 +223,7 @@ xglComp (CARD8 op,
|
|||
|
||||
GEOMETRY_ADD_BOX (pScreen, pGeometry, pBox, nBox);
|
||||
|
||||
pBox = REGION_EXTENTS (pScreen, ®ion);
|
||||
pBox = pExt;
|
||||
}
|
||||
|
||||
xSrc += pBox->x1 - xDst;
|
||||
|
@ -247,7 +257,8 @@ xglComp (CARD8 op,
|
|||
REGION_UNINIT (pScreen, ®ion);
|
||||
return FALSE;
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
GEOMETRY_DISABLE (dst);
|
||||
|
||||
glitz_composite (XGL_OPERATOR (op),
|
|
@ -38,6 +38,8 @@ xglCopy (DrawablePtr pSrc,
|
|||
int srcXoff, srcYoff;
|
||||
int dstXoff, dstYoff;
|
||||
|
||||
XGL_DRAWABLE_PIXMAP (pDst);
|
||||
|
||||
if (!nBox)
|
||||
return TRUE;
|
||||
|
||||
|
@ -64,12 +66,12 @@ xglCopy (DrawablePtr pSrc,
|
|||
|
||||
glitz_copy_area (src,
|
||||
dst,
|
||||
pDst->x + srcXoff + dx,
|
||||
pDst->y + srcYoff + dy,
|
||||
pDst->width,
|
||||
pDst->height,
|
||||
pDst->x + dstXoff,
|
||||
pDst->y + dstYoff);
|
||||
srcXoff + dx,
|
||||
srcYoff + dy,
|
||||
pPixmap->drawable.width - dstXoff,
|
||||
pPixmap->drawable.height - dstYoff,
|
||||
dstXoff,
|
||||
dstYoff);
|
||||
|
||||
glitz_surface_set_clip_region (dst, 0, 0, NULL, 0);
|
||||
|
||||
|
@ -96,23 +98,15 @@ xglCopyProc (DrawablePtr pSrc,
|
|||
|
||||
if (!xglCopy (pSrc, pDst, dx, dy, pBox, nBox))
|
||||
{
|
||||
RegionPtr pDamageRegion;
|
||||
glitz_surface_t *dst;
|
||||
int dstXoff, dstYoff;
|
||||
RegionRec region;
|
||||
BoxRec box;
|
||||
|
||||
XGL_DRAWABLE_PIXMAP (pDst);
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
XGL_GET_DRAWABLE (pDst, dst, dstXoff, dstYoff);
|
||||
|
||||
pDamageRegion = DamageRegion (pPixmapPriv->pDamage);
|
||||
|
||||
if (!xglMapPixmapBits (pPixmap))
|
||||
if (!xglSyncBits (pSrc, pSrcBox))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
|
||||
if (!xglSyncBits (pSrc, pSrcBox))
|
||||
if (!xglMapPixmapBits (pPixmap))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
|
||||
fbCopyNtoN (pSrc, pDst, pGC,
|
||||
|
@ -122,19 +116,11 @@ xglCopyProc (DrawablePtr pSrc,
|
|||
(void *) 0);
|
||||
|
||||
pPixmapPriv->damageBox = miEmptyBox;
|
||||
if (!pPixmapPriv->format)
|
||||
return;
|
||||
|
||||
while (nBox--)
|
||||
{
|
||||
box.x1 = pBox->x1 + dstXoff;
|
||||
box.y1 = pBox->y1 + dstYoff;
|
||||
box.x2 = pBox->x2 + dstXoff;
|
||||
box.y2 = pBox->y2 + dstYoff;
|
||||
|
||||
REGION_INIT (pDst->pScreen, ®ion, &box, 1);
|
||||
REGION_UNION (pDst->pScreen,
|
||||
pDamageRegion, pDamageRegion, ®ion);
|
||||
REGION_INIT (pDst->pScreen, ®ion, pBox, 1);
|
||||
xglAddSurfaceDamage (pDst, ®ion);
|
||||
REGION_UNINIT (pDst->pScreen, ®ion);
|
||||
|
||||
pBox++;
|
||||
|
|
|
@ -43,7 +43,7 @@ xglFill (DrawablePtr pDrawable,
|
|||
switch (pGC->fillStyle) {
|
||||
case FillSolid:
|
||||
if (xglSolid (pDrawable,
|
||||
pGCPriv->op, &pGCPriv->fg,
|
||||
pGCPriv->op, pGCPriv->fg,
|
||||
pGeometry,
|
||||
x, y,
|
||||
width, height,
|
||||
|
@ -79,17 +79,12 @@ xglFillBox (DrawablePtr pDrawable,
|
|||
BoxPtr pBox,
|
||||
int nBox)
|
||||
{
|
||||
BoxRec box;
|
||||
|
||||
if (!nBox)
|
||||
return;
|
||||
|
||||
if (!xglFill (pDrawable, pGC, NULL, x, y, width, height, pBox, nBox))
|
||||
{
|
||||
RegionRec region;
|
||||
RegionPtr pDamageRegion;
|
||||
glitz_surface_t *surface;
|
||||
int xOff, yOff;
|
||||
|
||||
XGL_DRAWABLE_PIXMAP (pDrawable);
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
@ -111,10 +106,6 @@ xglFillBox (DrawablePtr pDrawable,
|
|||
break;
|
||||
}
|
||||
|
||||
pDamageRegion = DamageRegion (pPixmapPriv->pDamage);
|
||||
|
||||
XGL_GET_DRAWABLE (pDrawable, surface, xOff, yOff);
|
||||
|
||||
pPixmapPriv->damageBox = miEmptyBox;
|
||||
|
||||
while (nBox--)
|
||||
|
@ -123,18 +114,9 @@ xglFillBox (DrawablePtr pDrawable,
|
|||
pBox->x1, pBox->y1,
|
||||
pBox->x2 - pBox->x1, pBox->y2 - pBox->y1);
|
||||
|
||||
if (pPixmapPriv->format)
|
||||
{
|
||||
box.x1 = pBox->x1 + xOff;
|
||||
box.y1 = pBox->y1 + yOff;
|
||||
box.x2 = pBox->x2 + xOff;
|
||||
box.y2 = pBox->y2 + yOff;
|
||||
|
||||
REGION_INIT (pDrawable->pScreen, ®ion, &box, 1);
|
||||
REGION_UNION (pDrawable->pScreen,
|
||||
pDamageRegion, pDamageRegion, ®ion);
|
||||
REGION_INIT (pDrawable->pScreen, ®ion, pBox, 1);
|
||||
xglAddSurfaceDamage (pDrawable, ®ion);
|
||||
REGION_UNINIT (pDrawable->pScreen, ®ion);
|
||||
}
|
||||
|
||||
pBox++;
|
||||
}
|
||||
|
@ -549,7 +531,10 @@ xglFillLine (DrawablePtr pDrawable,
|
|||
pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
|
||||
REGION_RECTS (pGC->pCompositeClip),
|
||||
REGION_NUM_RECTS (pGC->pCompositeClip)))
|
||||
{
|
||||
xglAddCurrentBitDamage (pDrawable);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -701,7 +686,10 @@ xglFillSegment (DrawablePtr pDrawable,
|
|||
pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
|
||||
REGION_RECTS (pGC->pCompositeClip),
|
||||
REGION_NUM_RECTS (pGC->pCompositeClip)))
|
||||
{
|
||||
xglAddCurrentBitDamage (pDrawable);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -745,6 +733,7 @@ xglFillGlyph (DrawablePtr pDrawable,
|
|||
REGION_NUM_RECTS (pGC->pCompositeClip)))
|
||||
{
|
||||
GEOMETRY_UNINIT (&geometry);
|
||||
xglAddCurrentBitDamage (pDrawable);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
116
hw/xgl/xglgc.c
116
hw/xgl/xglgc.c
|
@ -58,7 +58,7 @@ static const GCFuncs xglGCFuncs = {
|
|||
xglValidateGC,
|
||||
miChangeGC,
|
||||
miCopyGC,
|
||||
miDestroyGC,
|
||||
xglDestroyGC,
|
||||
miChangeClip,
|
||||
miDestroyClip,
|
||||
miCopyClip
|
||||
|
@ -205,7 +205,7 @@ xglCopyArea (DrawablePtr pSrc,
|
|||
box.x2 = box.x1 + w;
|
||||
box.y2 = box.y1 + h;
|
||||
|
||||
if (pGC->alu != GXcopy || (pGCPriv->flags &= ~xglGCReadOnlyDrawableFlag))
|
||||
if (pGC->alu != GXcopy || pGCPriv->flags)
|
||||
{
|
||||
if (!xglSyncBits (pSrc, &box))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
|
@ -293,12 +293,9 @@ xglPolylines (DrawablePtr pDrawable,
|
|||
if (pGC->lineStyle == LineSolid)
|
||||
{
|
||||
if (xglFillLine (pDrawable, pGC, mode, npt, ppt))
|
||||
{
|
||||
xglAddCurrentBitDamage (pDrawable);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
|
||||
(*pGC->ops->Polylines) (pDrawable, pGC, mode, npt, ppt);
|
||||
|
@ -328,12 +325,9 @@ xglPolySegment (DrawablePtr pDrawable,
|
|||
if (pGC->lineStyle == LineSolid)
|
||||
{
|
||||
if (xglFillSegment (pDrawable, pGC, nsegInit, pSegInit))
|
||||
{
|
||||
xglAddCurrentBitDamage (pDrawable);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
|
||||
(*pGC->ops->PolySegment) (pDrawable, pGC, nsegInit, pSegInit);
|
||||
|
@ -367,7 +361,7 @@ xglPolyFillRect (DrawablePtr pDrawable,
|
|||
{
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
if (pGCPriv->flags || pGC->fillStyle == FillStippled)
|
||||
if (pGC->fillStyle == FillStippled || pGCPriv->flags)
|
||||
{
|
||||
XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
|
||||
(*pGC->ops->PolyFillRect) (pDrawable, pGC, nrect, prect);
|
||||
|
@ -404,7 +398,7 @@ xglImageGlyphBlt (DrawablePtr pDrawable,
|
|||
{
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
if (!(pGCPriv->flags & ~xglGCBadFunctionFlag))
|
||||
if (!pGCPriv->flags)
|
||||
{
|
||||
if (xglSolidGlyph (pDrawable,
|
||||
pGC,
|
||||
|
@ -413,11 +407,8 @@ xglImageGlyphBlt (DrawablePtr pDrawable,
|
|||
nglyph,
|
||||
ppci,
|
||||
pglyphBase))
|
||||
{
|
||||
xglAddCurrentBitDamage (pDrawable);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable);
|
||||
(*pGC->ops->ImageGlyphBlt) (pDrawable, pGC, x, y, nglyph, ppci,
|
||||
|
@ -445,11 +436,8 @@ xglPolyGlyphBlt (DrawablePtr pDrawable,
|
|||
nglyph,
|
||||
ppci,
|
||||
pglyphBase))
|
||||
{
|
||||
xglAddCurrentBitDamage (pDrawable);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
|
||||
(*pGC->ops->PolyGlyphBlt) (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
|
||||
|
@ -478,7 +466,6 @@ xglPushPixels (GCPtr pGC,
|
|||
Bool
|
||||
xglCreateGC (GCPtr pGC)
|
||||
{
|
||||
static glitz_color_t black = { 0x0, 0x0, 0x0, 0xffff };
|
||||
ScreenPtr pScreen = pGC->pScreen;
|
||||
Bool ret;
|
||||
|
||||
|
@ -494,12 +481,32 @@ xglCreateGC (GCPtr pGC)
|
|||
|
||||
pGCPriv->flags = 0;
|
||||
pGCPriv->op = GLITZ_OPERATOR_SRC;
|
||||
pGCPriv->fg = black;
|
||||
pGCPriv->bg = black;
|
||||
|
||||
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,
|
||||
|
@ -531,15 +538,44 @@ xglValidateGC (GCPtr pGC,
|
|||
{
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
|
||||
|
||||
if (pPixmapPriv->format)
|
||||
pGCPriv->flags &= ~xglGCSoftwareDrawableFlag;
|
||||
else
|
||||
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 (pPixmapPriv->target)
|
||||
pGCPriv->flags &= ~xglGCReadOnlyDrawableFlag;
|
||||
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 |= xglGCReadOnlyDrawableFlag;
|
||||
pGCPriv->flags |= xglGCSoftwareDrawableFlag;
|
||||
}
|
||||
|
||||
if (changes & GCFunction)
|
||||
|
@ -575,14 +611,38 @@ xglValidateGC (GCPtr pGC,
|
|||
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);
|
||||
|
||||
if (pPixmapPriv->pPixel)
|
||||
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)
|
||||
{
|
||||
xglPixelToColor (pPixmapPriv->pPixel, pGC->fgPixel, &pGCPriv->fg);
|
||||
xglPixelToColor (pPixmapPriv->pPixel, pGC->bgPixel, &pGCPriv->bg);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,6 +78,7 @@ xglGeometryResize (ScreenPtr pScreen,
|
|||
else
|
||||
{
|
||||
glitz_buffer_t *newBuffer;
|
||||
|
||||
if (size)
|
||||
{
|
||||
newBuffer =
|
||||
|
|
|
@ -42,7 +42,7 @@ xglGetImage (DrawablePtr pDrawable,
|
|||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
/* Many apps use GetImage to sync with the visable frame buffer */
|
||||
/* Many apps use GetImage to sync with the visible frame buffer */
|
||||
if (pDrawable->type == DRAWABLE_WINDOW)
|
||||
{
|
||||
if (!xglSyncSurface (&pScreenPriv->pScreenPixmap->drawable))
|
||||
|
|
176
hw/xgl/xglglx.c
176
hw/xgl/xglglx.c
|
@ -23,62 +23,27 @@
|
|||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
#include "xglglx.h"
|
||||
|
||||
#ifdef GLXEXT
|
||||
|
||||
#include "glxserver.h"
|
||||
#include "glxscreens.h"
|
||||
#include "glxext.h"
|
||||
#ifdef XGL_MODULAR
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
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);
|
||||
xglGLXFuncRec __xglGLXFunc;
|
||||
|
||||
void (*flushContextCache) (void);
|
||||
void (*setRenderTables) (__glProcTable *table,
|
||||
__glProcTableEXT *tableEXT);
|
||||
} xglGLXFuncRec;
|
||||
|
||||
static xglGLXFuncRec __glXFunc;
|
||||
#ifndef NGLXEXTLOG
|
||||
FILE *__xglGLXLogFp;
|
||||
#endif
|
||||
|
||||
static void *glXHandle = 0;
|
||||
static void *glCoreHandle = 0;
|
||||
|
||||
#define SYM(ptr, name) { (void **) &(ptr), (name) }
|
||||
|
||||
__GLXextensionInfo __glDDXExtensionInfo = {
|
||||
GL_CORE_MESA,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
__GLXscreenInfo __glDDXScreenInfo = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
0,
|
||||
"Vendor String",
|
||||
"Version String",
|
||||
"Extensions String",
|
||||
NULL
|
||||
};
|
||||
__GLXextensionInfo *__xglExtensionInfo;
|
||||
__GLXscreenInfo *__xglScreenInfoPtr;
|
||||
|
||||
void
|
||||
GlxSetVisualConfigs (int nconfigs,
|
||||
|
@ -86,21 +51,21 @@ GlxSetVisualConfigs (int nconfigs,
|
|||
void **privates)
|
||||
{
|
||||
if (glXHandle && glCoreHandle)
|
||||
(*__glXFunc.setVisualConfigs) (nconfigs, configs, privates);
|
||||
(*__xglGLXFunc.setVisualConfigs) (nconfigs, configs, privates);
|
||||
}
|
||||
|
||||
void
|
||||
GlxExtensionInit (void)
|
||||
{
|
||||
if (glXHandle && glCoreHandle)
|
||||
(*__glXFunc.extensionInit) ();
|
||||
(*__xglGLXFunc.extensionInit) ();
|
||||
}
|
||||
|
||||
void
|
||||
GlxWrapInitVisuals (miInitVisualsProcPtr *initVisuals)
|
||||
{
|
||||
if (glXHandle && glCoreHandle)
|
||||
(*__glXFunc.wrapInitVisuals) (initVisuals);
|
||||
(*__xglGLXFunc.wrapInitVisuals) (initVisuals);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -115,7 +80,7 @@ GlxInitVisuals (VisualPtr *visualp,
|
|||
int preferredVis)
|
||||
{
|
||||
if (glXHandle && glCoreHandle)
|
||||
return (*__glXFunc.initVisuals) (visualp, depthp, nvisualp, ndepthp,
|
||||
return (*__xglGLXFunc.initVisuals) (visualp, depthp, nvisualp, ndepthp,
|
||||
rootDepthp, defaultVisp, sizes,
|
||||
bitsPerRGB, preferredVis);
|
||||
|
||||
|
@ -125,16 +90,59 @@ GlxInitVisuals (VisualPtr *visualp,
|
|||
void
|
||||
GlxFlushContextCache (void)
|
||||
{
|
||||
(*__glXFunc.flushContextCache) ();
|
||||
(*__xglGLXFunc.flushContextCache) ();
|
||||
}
|
||||
|
||||
void
|
||||
GlxSetRenderTables (__glProcTable *table,
|
||||
__glProcTableEXT *tableEXT)
|
||||
GlxSetRenderTables (struct _glapi_table *table)
|
||||
{
|
||||
(*__glXFunc.setRenderTables) (table, tableEXT);
|
||||
(*__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)
|
||||
{
|
||||
|
@ -143,15 +151,20 @@ xglLoadGLXModules (void)
|
|||
if (!glXHandle)
|
||||
{
|
||||
xglSymbolRec sym[] = {
|
||||
SYM (__glXFunc.extensionInit, "GlxExtensionInit"),
|
||||
SYM (__glXFunc.setVisualConfigs, "GlxSetVisualConfigs"),
|
||||
SYM (__glXFunc.wrapInitVisuals, "GlxWrapInitVisuals"),
|
||||
SYM (__glXFunc.initVisuals, "GlxInitVisuals"),
|
||||
SYM (__glXFunc.flushContextCache, "GlxFlushContextCache"),
|
||||
SYM (__glXFunc.setRenderTables, "GlxSetRenderTables")
|
||||
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");
|
||||
glXHandle = xglLoadModule ("glx", RTLD_NOW | RTLD_LOCAL);
|
||||
if (!glXHandle)
|
||||
return FALSE;
|
||||
|
||||
|
@ -166,22 +179,17 @@ xglLoadGLXModules (void)
|
|||
|
||||
if (!glCoreHandle)
|
||||
{
|
||||
xglSymbolRec sym[] = {
|
||||
SYM (__glDDXScreenInfo.screenProbe, "__MESA_screenProbe"),
|
||||
SYM (__glDDXScreenInfo.createContext, "__MESA_createContext"),
|
||||
SYM (__glDDXScreenInfo.createBuffer, "__MESA_createBuffer"),
|
||||
|
||||
SYM (__glDDXExtensionInfo.resetExtension, "__MESA_resetExtension"),
|
||||
SYM (__glDDXExtensionInfo.initVisuals, "__MESA_initVisuals"),
|
||||
SYM (__glDDXExtensionInfo.setVisualConfigs,
|
||||
"__MESA_setVisualConfigs")
|
||||
xglSymbolRec ddxsym[] = {
|
||||
SYM (__glcore_DDXExtensionInfo, "__glXglDDXExtensionInfo"),
|
||||
SYM (__glcore_DDXScreenInfo, "__glXglDDXScreenInfo")
|
||||
};
|
||||
|
||||
glCoreHandle = xglLoadModule ("glcore");
|
||||
glCoreHandle = xglLoadModule ("glcore", RTLD_NOW | RTLD_LOCAL);
|
||||
if (!glCoreHandle)
|
||||
return FALSE;
|
||||
|
||||
if (!xglLookupSymbols (glCoreHandle, sym, sizeof (sym) / sizeof (sym[0])))
|
||||
if (!xglLookupSymbols (glCoreHandle, ddxsym,
|
||||
sizeof (ddxsym) / sizeof(ddxsym[0])))
|
||||
{
|
||||
xglUnloadModule (glCoreHandle);
|
||||
glCoreHandle = 0;
|
||||
|
@ -189,6 +197,32 @@ xglLoadGLXModules (void)
|
|||
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);
|
||||
|
|
79
hw/xgl/xglglx.h
Normal file
79
hw/xgl/xglglx.h
Normal file
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* 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
|
|
@ -228,9 +228,14 @@ xglInitGlyphCache (xglGlyphCachePtr pCache,
|
|||
{
|
||||
|
||||
xglGlyphTexturePtr pTexture = &pCache->u.texture;
|
||||
glitz_surface_t *mask;
|
||||
glitz_surface_attributes_t attr;
|
||||
xglPixmapFormatPtr pFormat;
|
||||
glitz_vertex_format_t *vertex;
|
||||
xglVisualPtr pVisual;
|
||||
|
||||
pVisual = xglFindVisualWithDepth (pScreen, format->depth);
|
||||
if (!pVisual)
|
||||
return FALSE;
|
||||
|
||||
if (!xglRootAreaInit (&pCache->rootArea,
|
||||
TEXTURE_CACHE_MAX_LEVEL,
|
||||
|
@ -240,33 +245,40 @@ xglInitGlyphCache (xglGlyphCachePtr pCache,
|
|||
(pointer) pCache))
|
||||
return FALSE;
|
||||
|
||||
pFormat = &pScreenPriv->pixmapFormats[format->depth];
|
||||
|
||||
if (pScreenPriv->geometryDataType == GEOMETRY_DATA_TYPE_SHORT)
|
||||
{
|
||||
attr.unnormalized = 1;
|
||||
pTexture->mask =
|
||||
glitz_surface_create (pScreenPriv->drawable, pFormat->format,
|
||||
TEXTURE_CACHE_SIZE, TEXTURE_CACHE_SIZE,
|
||||
GLITZ_SURFACE_UNNORMALIZED_MASK, &attr);
|
||||
} else
|
||||
pTexture->mask = NULL;
|
||||
mask = glitz_surface_create (pScreenPriv->drawable,
|
||||
pVisual->format.surface,
|
||||
TEXTURE_CACHE_SIZE,
|
||||
TEXTURE_CACHE_SIZE,
|
||||
GLITZ_SURFACE_UNNORMALIZED_MASK,
|
||||
&attr);
|
||||
}
|
||||
else
|
||||
mask = NULL;
|
||||
|
||||
if (!pTexture->mask)
|
||||
if (!mask)
|
||||
{
|
||||
pTexture->mask =
|
||||
glitz_surface_create (pScreenPriv->drawable, pFormat->format,
|
||||
TEXTURE_CACHE_SIZE, TEXTURE_CACHE_SIZE,
|
||||
mask = glitz_surface_create (pScreenPriv->drawable,
|
||||
pVisual->format.surface,
|
||||
TEXTURE_CACHE_SIZE,
|
||||
TEXTURE_CACHE_SIZE,
|
||||
0, NULL);
|
||||
if (!pTexture->mask)
|
||||
if (!mask)
|
||||
return FALSE;
|
||||
|
||||
pTexture->geometryDataType = GEOMETRY_DATA_TYPE_FLOAT;
|
||||
} else
|
||||
}
|
||||
else
|
||||
pTexture->geometryDataType = GEOMETRY_DATA_TYPE_SHORT;
|
||||
|
||||
if (NEEDS_COMPONENT (format->format))
|
||||
glitz_surface_set_component_alpha (pTexture->mask, 1);
|
||||
glitz_surface_set_component_alpha (mask, 1);
|
||||
|
||||
pTexture->pMask = xglCreateDevicePicture (mask);
|
||||
if (!pTexture->pMask)
|
||||
return FALSE;
|
||||
|
||||
vertex = &pCache->u.texture.format.vertex;
|
||||
vertex->primitive = GLITZ_PRIMITIVE_QUADS;
|
||||
|
@ -288,7 +300,8 @@ xglInitGlyphCache (xglGlyphCachePtr pCache,
|
|||
vertex->mask.type = GLITZ_DATA_TYPE_SHORT;
|
||||
}
|
||||
|
||||
pTexture->pixel.masks = pFormat->pPixel->masks;
|
||||
pTexture->pixel.fourcc = GLITZ_FOURCC_RGB;
|
||||
pTexture->pixel.masks = pVisual->pPixel->masks;
|
||||
pTexture->pixel.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP;
|
||||
pTexture->pixel.bytes_per_line = 0;
|
||||
pTexture->pixel.xoffset = 0;
|
||||
|
@ -313,8 +326,8 @@ xglFiniGlyphCache (xglGlyphCachePtr pCache)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (pCache->u.texture.mask)
|
||||
glitz_surface_destroy (pCache->u.texture.mask);
|
||||
if (pCache->u.texture.pMask)
|
||||
FreePicture ((pointer) pCache->u.texture.pMask, 0);
|
||||
}
|
||||
|
||||
pCache->pScreen = NULL;
|
||||
|
@ -420,6 +433,7 @@ xglCacheGlyph (xglGlyphCachePtr pCache,
|
|||
|
||||
if (pGlyphPriv->pArea)
|
||||
{
|
||||
glitz_surface_t *surface;
|
||||
glitz_point_fixed_t p1, p2;
|
||||
glitz_pixel_format_t pixel;
|
||||
|
||||
|
@ -429,7 +443,9 @@ xglCacheGlyph (xglGlyphCachePtr pCache,
|
|||
pixel.bytes_per_line =
|
||||
PixmapBytePad (pGlyph->info.width, pCache->depth);
|
||||
|
||||
glitz_set_pixels (pTexture->mask,
|
||||
surface = pTexture->pMask->pSourcePict->source.devPrivate.ptr;
|
||||
|
||||
glitz_set_pixels (surface,
|
||||
pGlyphPriv->pArea->x,
|
||||
pGlyphPriv->pArea->y,
|
||||
pGlyph->info.width,
|
||||
|
@ -442,8 +458,8 @@ xglCacheGlyph (xglGlyphCachePtr pCache,
|
|||
p2.x = (pGlyphPriv->pArea->x + pGlyph->info.width) << 16;
|
||||
p2.y = (pGlyphPriv->pArea->y + pGlyph->info.height) << 16;
|
||||
|
||||
glitz_surface_translate_point (pTexture->mask, &p1, &p1);
|
||||
glitz_surface_translate_point (pTexture->mask, &p2, &p2);
|
||||
glitz_surface_translate_point (surface, &p1, &p1);
|
||||
glitz_surface_translate_point (surface, &p2, &p2);
|
||||
|
||||
pAreaPriv->serial = glyphSerialNumber;
|
||||
if (pTexture->geometryDataType)
|
||||
|
@ -542,7 +558,7 @@ xglUncachedGlyphs (CARD8 op,
|
|||
|
||||
if (!pPicture)
|
||||
{
|
||||
CARD32 componentAlpha;
|
||||
XID componentAlpha;
|
||||
int error;
|
||||
|
||||
pPixmap = GetScratchPixmapHeader (pScreen,
|
||||
|
@ -624,7 +640,7 @@ xglCachedGlyphs (CARD8 op,
|
|||
int depth = pOp->pLists->format->depth;
|
||||
int i, remaining = pOp->nGlyphs;
|
||||
int nGlyph = 0;
|
||||
glitz_surface_t *mask = NULL;
|
||||
PicturePtr pMaskPicture = NULL;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
|
@ -690,7 +706,7 @@ xglCachedGlyphs (CARD8 op,
|
|||
|
||||
pGeometry->f = pCache->u.texture.format;
|
||||
pGeometry->type = GLITZ_GEOMETRY_TYPE_VERTEX;
|
||||
mask = pCache->u.texture.mask;
|
||||
pMaskPicture = pCache->u.texture.pMask;
|
||||
|
||||
vData.list.s = glitz_buffer_map (pGeometry->buffer,
|
||||
GLITZ_BUFFER_ACCESS_WRITE_ONLY);
|
||||
|
@ -803,18 +819,17 @@ xglCachedGlyphs (CARD8 op,
|
|||
pDst->pDrawable->x,
|
||||
pDst->pDrawable->y);
|
||||
|
||||
if (xglComp (op,
|
||||
if (xglCompositeGeneral (op,
|
||||
pSrc,
|
||||
NULL,
|
||||
pMaskPicture,
|
||||
pDst,
|
||||
pGeometry,
|
||||
xSrc, ySrc,
|
||||
0, 0,
|
||||
pDst->pDrawable->x + extents.x1,
|
||||
pDst->pDrawable->y + extents.y1,
|
||||
extents.x2 - extents.x1,
|
||||
extents.y2 - extents.y1,
|
||||
pGeometry,
|
||||
mask))
|
||||
extents.y2 - extents.y1))
|
||||
{
|
||||
xglAddCurrentBitDamage (pDst->pDrawable);
|
||||
return remaining;
|
||||
|
@ -1037,8 +1052,6 @@ xglGlyphs (CARD8 op,
|
|||
int overlap;
|
||||
int target;
|
||||
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pDst->pDrawable);
|
||||
|
||||
overlap = xglGlyphExtents (pDst, nlist, list, glyphs, &extents);
|
||||
if (extents.x2 <= extents.x1 || extents.y2 <= extents.y1)
|
||||
return;
|
||||
|
@ -1046,11 +1059,11 @@ xglGlyphs (CARD8 op,
|
|||
target = xglPrepareTarget (pDst->pDrawable);
|
||||
|
||||
if (op != PictOpAdd && maskFormat &&
|
||||
(overlap || op != PictOpOver ||
|
||||
(!target || overlap || op != PictOpOver ||
|
||||
xglGlyphListFormatId (list, nlist) != maskFormat->id))
|
||||
{
|
||||
PixmapPtr pPixmap;
|
||||
CARD32 componentAlpha;
|
||||
XID componentAlpha;
|
||||
GCPtr pGC;
|
||||
xRectangle rect;
|
||||
int error;
|
||||
|
@ -1076,12 +1089,11 @@ xglGlyphs (CARD8 op,
|
|||
return;
|
||||
}
|
||||
|
||||
/* make sure destination drawable is locked */
|
||||
pPixmapPriv->lock++;
|
||||
|
||||
/* lock mask if we are not doing accelerated drawing to destination */
|
||||
if (!target)
|
||||
XGL_GET_PIXMAP_PRIV (pPixmap)->lock = 1;
|
||||
{
|
||||
/* make sure we don't do accelerated drawing to mask */
|
||||
xglSetPixmapVisual (pPixmap, NULL);
|
||||
}
|
||||
|
||||
ValidatePicture (pMask);
|
||||
pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
|
||||
|
@ -1100,9 +1112,6 @@ xglGlyphs (CARD8 op,
|
|||
}
|
||||
else
|
||||
{
|
||||
/* make sure destination drawable is locked */
|
||||
pPixmapPriv->lock++;
|
||||
|
||||
glyphOp.xOff = 0;
|
||||
glyphOp.yOff = 0;
|
||||
pSrcPicture = pSrc;
|
||||
|
@ -1145,10 +1154,7 @@ xglGlyphs (CARD8 op,
|
|||
|
||||
if (pMask)
|
||||
{
|
||||
CompositePicture (op,
|
||||
pSrc,
|
||||
pMask,
|
||||
pDst,
|
||||
CompositePicture (op, pSrc, pMask, pDst,
|
||||
xSrc + extents.x1 - xDst,
|
||||
ySrc + extents.y1 - yDst,
|
||||
0, 0,
|
||||
|
@ -1158,10 +1164,6 @@ xglGlyphs (CARD8 op,
|
|||
|
||||
FreePicture ((pointer) pMask, (XID) 0);
|
||||
}
|
||||
|
||||
/* release destination drawable lock */
|
||||
pPixmapPriv->lock--;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
137
hw/xgl/xglinit.c
137
hw/xgl/xglinit.c
|
@ -24,26 +24,41 @@
|
|||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
#include "xglglx.h"
|
||||
#include "micmap.h"
|
||||
#include "mipointer.h"
|
||||
#include "fb.h"
|
||||
|
||||
#define DEAFULT_DDX_MODULE_NAME "xglx"
|
||||
#ifdef XGL_MODULAR
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
static char *ddxModuleName = DEAFULT_DDX_MODULE_NAME;
|
||||
#define DEFAULT_DDX_MODULE_NAME "xglx"
|
||||
|
||||
static char *ddxModuleName = DEFAULT_DDX_MODULE_NAME;
|
||||
|
||||
xglScreenInfoRec xglScreenInfo = {
|
||||
NULL, 0, 0, 0, 0,
|
||||
NULL, 0, 0, 0, 0, 0,
|
||||
DEFAULT_GEOMETRY_DATA_TYPE,
|
||||
DEFAULT_GEOMETRY_USAGE,
|
||||
FALSE,
|
||||
XGL_DEFAULT_PBO_MASK,
|
||||
FALSE,
|
||||
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 {
|
||||
|
@ -105,6 +120,29 @@ xglEnsureDDXModule (void)
|
|||
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[] = {
|
||||
|
@ -119,7 +157,7 @@ xglEnsureDDXModule (void)
|
|||
SYM (__ddxFunc.osVendorInit, "OsVendorInit")
|
||||
};
|
||||
|
||||
ddxHandle = xglLoadModule (ddxModuleName);
|
||||
ddxHandle = xglLoadModule (ddxModuleName, RTLD_NOW | RTLD_GLOBAL);
|
||||
if (!ddxHandle)
|
||||
return (status = FALSE);
|
||||
|
||||
|
@ -149,14 +187,6 @@ InitOutput (ScreenInfo *pScreenInfo,
|
|||
if (!xglEnsureDDXModule ())
|
||||
FatalError ("No DDX module loaded");
|
||||
|
||||
#ifdef GLXEXT
|
||||
if (loadGlx)
|
||||
{
|
||||
if (!xglLoadGLXModules ())
|
||||
FatalError ("No GLX modules loaded");
|
||||
}
|
||||
#endif
|
||||
|
||||
(*__ddxFunc.initOutput) (pScreenInfo, argc, argv);
|
||||
}
|
||||
|
||||
|
@ -191,68 +221,83 @@ ddxUseMsg (void)
|
|||
|
||||
#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) ();
|
||||
}
|
||||
|
||||
#define LOPT(s, l) { (s), (l) }
|
||||
#define OPT(s) LOPT (s, 0)
|
||||
|
||||
int
|
||||
ddxProcessArgument (int argc,
|
||||
char **argv,
|
||||
int i)
|
||||
{
|
||||
struct _option {
|
||||
char *name;
|
||||
int length;
|
||||
} commonOption[] = {
|
||||
LOPT (":", 1), OPT ("-a"), OPT ("-ac"), OPT ("-audit"), OPT ("-auth"),
|
||||
OPT ("bc"), OPT ("-br"), OPT ("+bs"), OPT ("-bs"), OPT ("c"), OPT ("-c"),
|
||||
OPT ("-cc"), OPT ("-co"), OPT ("-core"), OPT ("-dpi"),
|
||||
OPT ("-deferglyphs"), OPT ("-f"), OPT ("-fc"), OPT ("-fn"), OPT ("-fp"),
|
||||
OPT ("-help"), OPT ("-nolisten"), OPT ("-noreset"), OPT ("-p"),
|
||||
OPT ("-pn"), OPT ("-nopn"), OPT ("r"), OPT ("-r"), OPT ("-s"),
|
||||
OPT ("-su"), OPT ("-t"), OPT ("-terminate"), OPT ("-to"), OPT ("-tst"),
|
||||
OPT ("v"), OPT ("-v"), OPT ("-wm"), OPT ("-x"), OPT ("-I"),
|
||||
LOPT ("tty", 3)
|
||||
};
|
||||
int skip, j;
|
||||
static Bool checkDDX = FALSE;
|
||||
int skip;
|
||||
|
||||
for (j = 0; j < sizeof (commonOption) / sizeof (commonOption[0]); j++)
|
||||
if (!checkDDX)
|
||||
{
|
||||
if (commonOption[j].length)
|
||||
int j;
|
||||
|
||||
for (j = i; j < argc; j++)
|
||||
{
|
||||
if (!strncmp (argv[i], commonOption[j].name, commonOption[j].length))
|
||||
return 0;
|
||||
if (!strcmp (argv[j], "-ddx"))
|
||||
{
|
||||
if (++j < argc)
|
||||
ddxModuleName = argv[j];
|
||||
}
|
||||
else
|
||||
|
||||
#ifdef GLXEXT
|
||||
else if (!strcmp (argv[j], "-noglx"))
|
||||
{
|
||||
if (!strcmp (argv[i], commonOption[j].name))
|
||||
return 0;
|
||||
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)
|
||||
{
|
||||
ddxModuleName = argv[i + 1];
|
||||
}
|
||||
else
|
||||
return 1;
|
||||
|
||||
return 2;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef GLXEXT
|
||||
else if (!strcmp (argv[i], "-noglx"))
|
||||
{
|
||||
loadGlx = FALSE;
|
||||
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);
|
||||
|
@ -286,6 +331,6 @@ OsVendorInit (void)
|
|||
(*__ddxFunc.osVendorInit) ();
|
||||
}
|
||||
|
||||
void ddxInitGlobals(void)
|
||||
void ddxInitGlobals()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -33,7 +33,8 @@
|
|||
#define SYM(ptr, name) { (void **) &(ptr), (name) }
|
||||
|
||||
void *
|
||||
xglLoadModule (const char *name)
|
||||
xglLoadModule (const char *name,
|
||||
int flag)
|
||||
{
|
||||
ModuleVersionProcPtr moduleVersion;
|
||||
ModuleInitProcPtr moduleInit;
|
||||
|
@ -50,7 +51,7 @@ xglLoadModule (const char *name)
|
|||
|
||||
sprintf (module, XGL_MODULE_PATH "/lib%s.so", name);
|
||||
|
||||
handle = dlopen (module, RTLD_NOW);
|
||||
handle = dlopen (module, flag);
|
||||
if (handle)
|
||||
{
|
||||
if (xglLookupSymbols (handle, mSym, sizeof (mSym) / sizeof (mSym[0])))
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
#include <X11/Xdefs.h>
|
||||
#include "misc.h"
|
||||
|
||||
#define VERSION "0.0.1"
|
||||
|
||||
typedef const char *(*ModuleVersionProcPtr) (void);
|
||||
typedef Bool (*ModuleInitProcPtr) (const char *module);
|
||||
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
|
||||
#include "xgl.h"
|
||||
|
||||
#include <mivalidate.h>
|
||||
#include <dixstruct.h>
|
||||
|
||||
typedef struct _xglDepth {
|
||||
CARD8 depth;
|
||||
CARD8 bpp;
|
||||
|
@ -53,7 +56,8 @@ xglSetPixmapFormats (ScreenInfo *pScreenInfo)
|
|||
pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
|
||||
pScreenInfo->numPixmapFormats = 0;
|
||||
|
||||
for (i = 0; i < NUM_XGL_DEPTHS; i++) {
|
||||
for (i = 0; i < NUM_XGL_DEPTHS; i++)
|
||||
{
|
||||
PixmapFormatRec *format;
|
||||
|
||||
format = &pScreenInfo->formats[pScreenInfo->numPixmapFormats++];
|
||||
|
@ -63,3 +67,149 @@ xglSetPixmapFormats (ScreenInfo *pScreenInfo)
|
|||
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, bsExposed;
|
||||
|
||||
#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->backStorage)
|
||||
{
|
||||
pOldClip = REGION_CREATE (pScreen, NullBox, 1);
|
||||
REGION_COPY (pScreen, pOldClip, &pWin->clipList);
|
||||
}
|
||||
|
||||
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 (pWin->backStorage && ((pWin->backingStore == Always) || wasViewable))
|
||||
{
|
||||
if (!wasViewable)
|
||||
pOldClip = &pWin->clipList; /* a convenient empty region */
|
||||
|
||||
bsExposed = (*pScreen->TranslateBackingStore) (pWin, 0, 0, pOldClip,
|
||||
pWin->drawable.x,
|
||||
pWin->drawable.y);
|
||||
|
||||
if (wasViewable)
|
||||
REGION_DESTROY(pScreen, pOldClip);
|
||||
|
||||
if (bsExposed)
|
||||
{
|
||||
RegionPtr valExposed = NullRegion;
|
||||
|
||||
if (pWin->valdata)
|
||||
valExposed = &pWin->valdata->after.exposed;
|
||||
|
||||
(*pScreen->WindowExposures) (pWin, valExposed, bsExposed);
|
||||
|
||||
if (valExposed)
|
||||
REGION_EMPTY (pScreen, valExposed);
|
||||
|
||||
REGION_DESTROY (pScreen, bsExposed);
|
||||
}
|
||||
}
|
||||
|
||||
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 ();
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ xglParseScreen (char *arg)
|
|||
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
arg = xglParseFindNext (arg, "x/@XY", save, &delim);
|
||||
arg = xglParseFindNext (arg, "x/", save, &delim);
|
||||
if (!save[0])
|
||||
return;
|
||||
|
||||
|
@ -72,7 +72,7 @@ xglParseScreen (char *arg)
|
|||
|
||||
if (delim == '/')
|
||||
{
|
||||
arg = xglParseFindNext (arg, "x@XY", save, &delim);
|
||||
arg = xglParseFindNext (arg, "x", save, &delim);
|
||||
if (!save[0])
|
||||
return;
|
||||
|
||||
|
@ -95,6 +95,92 @@ xglParseScreen (char *arg)
|
|||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -106,8 +192,8 @@ xglUseMsg (void)
|
|||
"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 ("-fbo "
|
||||
"use frame buffer objects for accelerate offscreen drawing\n");
|
||||
ErrorF ("-accel TYPE[@WIDTH[/MIN]xHEIGHT[/MIN]][:METHOD] "
|
||||
"offscreen acceleration\n");
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -155,10 +241,16 @@ xglProcessArgument (int argc,
|
|||
|
||||
return 2;
|
||||
}
|
||||
else if (!strcmp (argv[i], "-fbo"))
|
||||
else if (!strcmp (argv[i], "-accel"))
|
||||
{
|
||||
xglScreenInfo.fbo = TRUE;
|
||||
if ((i + 1) < argc)
|
||||
{
|
||||
xglParseAccel (argv[i + 1]);
|
||||
}
|
||||
else
|
||||
return 1;
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
325
hw/xgl/xglpict.c
325
hw/xgl/xglpict.c
|
@ -28,6 +28,8 @@
|
|||
|
||||
#ifdef RENDER
|
||||
|
||||
#include "fbpict.h"
|
||||
|
||||
#define XGL_PICTURE_FALLBACK_PROLOGUE(pPicture, func) \
|
||||
xglSyncDamageBoxBits (pPicture->pDrawable); \
|
||||
XGL_PICTURE_SCREEN_UNWRAP (func)
|
||||
|
@ -55,13 +57,13 @@ xglComposite (CARD8 op,
|
|||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
if (xglComp (op,
|
||||
pSrc, pMask, pDst,
|
||||
if (xglCompositeGeneral (op,
|
||||
pSrc, pMask, pDst, NULL,
|
||||
xSrc, ySrc,
|
||||
xMask, yMask,
|
||||
xDst + pDst->pDrawable->x, yDst + pDst->pDrawable->y,
|
||||
width, height,
|
||||
NULL, NULL))
|
||||
xDst + pDst->pDrawable->x,
|
||||
yDst + pDst->pDrawable->y,
|
||||
width, height))
|
||||
{
|
||||
xglAddCurrentBitDamage (pDst->pDrawable);
|
||||
return;
|
||||
|
@ -103,10 +105,13 @@ xglComposite (CARD8 op,
|
|||
xDst += pDst->pDrawable->x;
|
||||
yDst += pDst->pDrawable->y;
|
||||
|
||||
if (pSrc->pDrawable)
|
||||
{
|
||||
xSrc += pSrc->pDrawable->x;
|
||||
ySrc += pSrc->pDrawable->y;
|
||||
}
|
||||
|
||||
if (pMask)
|
||||
if (pMask && pMask->pDrawable)
|
||||
{
|
||||
xMask += pMask->pDrawable->x;
|
||||
yMask += pMask->pDrawable->y;
|
||||
|
@ -188,6 +193,9 @@ xglChangePictureTransform (PicturePtr pPicture,
|
|||
|
||||
pPictureScreen = GetPictureScreen (pScreen);
|
||||
|
||||
if (transform != pPicture->transform ||
|
||||
(transform && memcmp (transform, &pPicture->transform,
|
||||
sizeof (PictTransform))))
|
||||
pPixmapPriv->pictureMask |= xglPCTransformMask;
|
||||
|
||||
XGL_PICTURE_SCREEN_UNWRAP (ChangePictureTransform);
|
||||
|
@ -223,7 +231,37 @@ xglChangePictureFilter (PicturePtr pPicture,
|
|||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
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;
|
||||
|
@ -234,10 +272,7 @@ xglUpdatePicture (PicturePtr pPicture)
|
|||
|
||||
if (pPixmapPriv->pictureMask & xglPCFillMask)
|
||||
{
|
||||
if (pPicture->repeat)
|
||||
glitz_surface_set_fill (surface, GLITZ_FILL_REPEAT);
|
||||
else
|
||||
glitz_surface_set_fill (surface, GLITZ_FILL_TRANSPARENT);
|
||||
glitz_surface_set_fill (surface, fillMode[pPicture->repeat]);
|
||||
}
|
||||
|
||||
if (pPixmapPriv->pictureMask & xglPCFilterMask)
|
||||
|
@ -269,23 +304,263 @@ xglUpdatePicture (PicturePtr pPicture)
|
|||
|
||||
if (pPixmapPriv->pictureMask & xglPCComponentAlphaMask)
|
||||
{
|
||||
if (pPicture->componentAlpha)
|
||||
glitz_surface_set_component_alpha (surface, 1);
|
||||
else
|
||||
glitz_surface_set_component_alpha (surface, 0);
|
||||
glitz_surface_set_component_alpha (surface, pPicture->componentAlpha);
|
||||
}
|
||||
|
||||
if (pPixmapPriv->pictureMask & xglPCDitherMask)
|
||||
{
|
||||
if (pPicture->dither)
|
||||
glitz_surface_set_dither (surface, 1);
|
||||
else
|
||||
glitz_surface_set_dither (surface, 0);
|
||||
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);
|
||||
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)
|
||||
{
|
||||
|
@ -416,6 +691,10 @@ xglPictureInit (ScreenPtr pScreen)
|
|||
}
|
||||
}
|
||||
|
||||
/* 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;
|
||||
|
@ -427,9 +706,9 @@ xglPictureInit (ScreenPtr pScreen)
|
|||
pFormats[f].depth = formats[f].depth;
|
||||
format = formats[f].format;
|
||||
pFormats[f].format = format;
|
||||
pFormats[f].type = PictTypeDirect;
|
||||
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) +
|
||||
|
@ -447,11 +726,17 @@ xglPictureInit (ScreenPtr pScreen)
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,8 @@ xglPixmapDamageReport (DamagePtr pDamage,
|
|||
|
||||
if (pExt->y2 > pPixmapPriv->damageBox.y2)
|
||||
pPixmapPriv->damageBox.y2 = pExt->y2;
|
||||
} else
|
||||
}
|
||||
else
|
||||
pPixmapPriv->damageBox = *pExt;
|
||||
}
|
||||
|
||||
|
@ -92,30 +93,115 @@ xglPixmapCreateDamage (PixmapPtr pPixmap)
|
|||
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;
|
||||
pPixmapPriv->lock = 0;
|
||||
|
||||
if (pPixmapPriv->format)
|
||||
{
|
||||
if (!pPixmapPriv->pDamage)
|
||||
if (!xglPixmapCreateDamage (pPixmap))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
box.x1 = 0;
|
||||
box.y1 = 0;
|
||||
box.x2 = width;
|
||||
box.y2 = height;
|
||||
|
||||
if (width && 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;
|
||||
|
@ -126,28 +212,6 @@ xglPixmapSurfaceInit (PixmapPtr pPixmap,
|
|||
(POWER_OF_TWO (width) && POWER_OF_TWO (height)))
|
||||
pPixmapPriv->acceleratedTile = TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Accelerated drawing to pixmaps when using FBOs
|
||||
*/
|
||||
if (pScreenPriv->fbo)
|
||||
{
|
||||
pPixmapPriv->target = xglPixmapTargetOut;
|
||||
|
||||
/*
|
||||
* Do not allow accelerated drawing to bitmaps.
|
||||
*/
|
||||
if (pPixmap->drawable.depth == 1)
|
||||
pPixmapPriv->target = xglPixmapTargetNo;
|
||||
|
||||
/*
|
||||
* Drawing to really small pixmaps is not worth accelerating.
|
||||
*/
|
||||
if (width < 8 && height < 8)
|
||||
pPixmapPriv->target = xglPixmapTargetNo;
|
||||
}
|
||||
else
|
||||
pPixmapPriv->target = xglPixmapTargetNo;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -192,8 +256,7 @@ xglCreatePixmap (ScreenPtr pScreen,
|
|||
|
||||
pPixmapPriv = XGL_GET_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
pPixmapPriv->format = pScreenPriv->pixmapFormats[depth].format;
|
||||
pPixmapPriv->pPixel = pScreenPriv->pixmapFormats[depth].pPixel;
|
||||
pPixmapPriv->pVisual = NULL;
|
||||
pPixmapPriv->pDamage = NULL;
|
||||
|
||||
if (!xglPixmapSurfaceInit (pPixmap, pScreenPriv->features, width, height))
|
||||
|
@ -203,12 +266,8 @@ xglCreatePixmap (ScreenPtr pScreen,
|
|||
pPixmapPriv->bits = (pointer) 0;
|
||||
pPixmapPriv->stride = 0;
|
||||
pPixmapPriv->pGeometry = NULL;
|
||||
|
||||
pPixmapPriv->allBits = TRUE;
|
||||
pPixmapPriv->bitBox.x1 = 0;
|
||||
pPixmapPriv->bitBox.y1 = 0;
|
||||
pPixmapPriv->bitBox.x2 = 32767;
|
||||
pPixmapPriv->bitBox.y2 = 32767;
|
||||
|
||||
pPixmapPriv->damageBox = miEmptyBox;
|
||||
|
||||
return pPixmap;
|
||||
|
@ -234,6 +293,11 @@ xglFiniPixmap (PixmapPtr pPixmap)
|
|||
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);
|
||||
}
|
||||
|
@ -262,7 +326,6 @@ xglModifyPixmapHeader (PixmapPtr pPixmap,
|
|||
{
|
||||
xglScreenPtr pScreenPriv;
|
||||
xglPixmapPtr pPixmapPriv;
|
||||
glitz_format_t *oldFormat;
|
||||
int oldWidth, oldHeight;
|
||||
|
||||
if (!pPixmap)
|
||||
|
@ -271,7 +334,6 @@ xglModifyPixmapHeader (PixmapPtr pPixmap,
|
|||
pScreenPriv = XGL_GET_SCREEN_PRIV (pPixmap->drawable.pScreen);
|
||||
pPixmapPriv = XGL_GET_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
oldFormat = pPixmapPriv->format;
|
||||
oldWidth = pPixmap->drawable.width;
|
||||
oldHeight = pPixmap->drawable.height;
|
||||
|
||||
|
@ -312,18 +374,20 @@ xglModifyPixmapHeader (PixmapPtr pPixmap,
|
|||
pPixmap->drawable.depth);
|
||||
}
|
||||
|
||||
depth = pPixmap->drawable.depth;
|
||||
|
||||
pPixmapPriv->pPixel = pScreenPriv->pixmapFormats[depth].pPixel;
|
||||
pPixmapPriv->format = pScreenPriv->pixmapFormats[depth].format;
|
||||
|
||||
if (pPixmapPriv->format != oldFormat ||
|
||||
pPixmap->drawable.width != oldWidth ||
|
||||
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,
|
||||
|
@ -333,6 +397,8 @@ xglModifyPixmapHeader (PixmapPtr pPixmap,
|
|||
|
||||
if (pPixData)
|
||||
{
|
||||
BoxRec box;
|
||||
|
||||
if (pPixmap->devPrivate.ptr)
|
||||
{
|
||||
if (pPixmapPriv->buffer)
|
||||
|
@ -359,10 +425,15 @@ xglModifyPixmapHeader (PixmapPtr pPixmap,
|
|||
return FALSE;
|
||||
|
||||
pPixmapPriv->allBits = TRUE;
|
||||
pPixmapPriv->bitBox.x1 = 0;
|
||||
pPixmapPriv->bitBox.y1 = 0;
|
||||
pPixmapPriv->bitBox.x2 = pPixmap->drawable.width;
|
||||
pPixmapPriv->bitBox.y2 = pPixmap->drawable.height;
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -371,21 +442,34 @@ xglModifyPixmapHeader (PixmapPtr pPixmap,
|
|||
pRegion = DamageRegion (pPixmapPriv->pDamage);
|
||||
|
||||
REGION_UNINIT (pPixmap->drawable.pScreen, pRegion);
|
||||
REGION_INIT (pPixmap->drawable.pScreen, pRegion,
|
||||
&pPixmapPriv->bitBox, 1);
|
||||
REGION_INIT (pPixmap->drawable.pScreen, pRegion, NullBox, 0);
|
||||
REGION_SUBTRACT (pPixmap->drawable.pScreen, pRegion,
|
||||
&pPixmapPriv->bitRegion, pRegion);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Maybe there's a nicer way to detect if this is the screen pixmap.
|
||||
* Screen pixmap
|
||||
*/
|
||||
if (!pScreenPriv->pScreenPixmap)
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -473,23 +557,24 @@ xglCreatePixmapSurface (PixmapPtr pPixmap)
|
|||
{
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
if (!pPixmapPriv->format)
|
||||
return FALSE;
|
||||
|
||||
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->format,
|
||||
pPixmapPriv->pVisual->format.surface,
|
||||
pPixmap->drawable.width,
|
||||
pPixmap->drawable.height,
|
||||
0, NULL);
|
||||
if (!pPixmapPriv->surface)
|
||||
{
|
||||
pPixmapPriv->format = NULL;
|
||||
pPixmapPriv->pVisual = NULL;
|
||||
pPixmapPriv->target = xglPixmapTargetNo;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -596,3 +681,61 @@ xglUnmapPixmapBits (PixmapPtr pPixmap)
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,27 +60,6 @@ int xglGlyphPrivateIndex;
|
|||
#define xglRecolorCursor (void *) NoopDDA
|
||||
#define xglSetCursorPosition (void *) NoopDDA
|
||||
|
||||
static PixmapPtr
|
||||
xglGetWindowPixmap (WindowPtr pWin)
|
||||
{
|
||||
return XGL_GET_WINDOW_PIXMAP (pWin);
|
||||
}
|
||||
|
||||
static 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;
|
||||
}
|
||||
|
||||
static Bool
|
||||
xglAllocatePrivates (ScreenPtr pScreen)
|
||||
{
|
||||
|
@ -137,12 +116,27 @@ Bool
|
|||
xglScreenInit (ScreenPtr pScreen)
|
||||
{
|
||||
xglScreenPtr pScreenPriv;
|
||||
int depth, bpp;
|
||||
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;
|
||||
|
||||
|
@ -150,42 +144,35 @@ xglScreenInit (ScreenPtr pScreen)
|
|||
|
||||
pScreenPriv->pScreenPixmap = NULL;
|
||||
|
||||
pScreenPriv->pVisual = &xglVisuals[0];
|
||||
/* 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);
|
||||
|
||||
depth = pScreenPriv->pVisual->pPixel->depth;
|
||||
bpp = pScreenPriv->pVisual->pPixel->masks.bpp;
|
||||
|
||||
xglInitPixmapFormats (pScreen);
|
||||
if (!pScreenPriv->pixmapFormats[depth].format)
|
||||
return FALSE;
|
||||
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->fbo = xglScreenInfo.fbo;
|
||||
|
||||
GEOMETRY_INIT (pScreen, &pScreenPriv->scratchGeometry,
|
||||
GLITZ_GEOMETRY_TYPE_VERTEX,
|
||||
pScreenPriv->geometryUsage, 0);
|
||||
|
||||
pScreenPriv->surface =
|
||||
glitz_surface_create (pScreenPriv->drawable,
|
||||
pScreenPriv->pixmapFormats[depth].format,
|
||||
xglScreenInfo.width, xglScreenInfo.height,
|
||||
0, NULL);
|
||||
if (!pScreenPriv->surface)
|
||||
return FALSE;
|
||||
|
||||
glitz_surface_attach (pScreenPriv->surface,
|
||||
pScreenPriv->drawable,
|
||||
GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
|
||||
|
||||
pScreenPriv->backSurface = NULL;
|
||||
pScreenPriv->accel = xglScreenInfo.accel;
|
||||
|
||||
if (monitorResolution == 0)
|
||||
monitorResolution = XGL_DEFAULT_DPI;
|
||||
|
@ -221,6 +208,7 @@ xglScreenInit (ScreenPtr pScreen)
|
|||
|
||||
XGL_SCREEN_WRAP (CopyWindow, xglCopyWindow);
|
||||
XGL_SCREEN_WRAP (CreateWindow, xglCreateWindow);
|
||||
XGL_SCREEN_WRAP (DestroyWindow, xglDestroyWindow);
|
||||
XGL_SCREEN_WRAP (ChangeWindowAttributes, xglChangeWindowAttributes);
|
||||
XGL_SCREEN_WRAP (PaintWindowBackground, xglPaintWindowBackground);
|
||||
XGL_SCREEN_WRAP (PaintWindowBorder, xglPaintWindowBorder);
|
||||
|
@ -272,6 +260,7 @@ xglScreenInit (ScreenPtr pScreen)
|
|||
return FALSE;
|
||||
|
||||
#ifdef COMPOSITE
|
||||
#warning "composite building"
|
||||
if (!compScreenInit (pScreen))
|
||||
return FALSE;
|
||||
#endif
|
||||
|
@ -287,6 +276,7 @@ xglScreenInit (ScreenPtr pScreen)
|
|||
Bool
|
||||
xglFinishScreenInit (ScreenPtr pScreen)
|
||||
{
|
||||
xglVisualPtr v;
|
||||
|
||||
#ifdef RENDER
|
||||
glitz_vertex_format_t *format;
|
||||
|
@ -297,35 +287,64 @@ xglFinishScreenInit (ScreenPtr pScreen)
|
|||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
pScreenPriv->solid =
|
||||
glitz_surface_create (pScreenPriv->drawable,
|
||||
pScreenPriv->pixmapFormats[32].format,
|
||||
1, 1, 0, NULL);
|
||||
if (!pScreenPriv->solid)
|
||||
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;
|
||||
|
||||
glitz_surface_set_fill (pScreenPriv->solid, GLITZ_FILL_REPEAT);
|
||||
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;
|
||||
|
||||
pScreenPriv->pSolidAlpha = NULL;
|
||||
for (v = pScreenPriv->pVisual; v; v = v->next)
|
||||
{
|
||||
if (v->pPixel->depth == 8)
|
||||
break;
|
||||
}
|
||||
|
||||
pScreenPriv->trapInfo.mask =
|
||||
glitz_surface_create (pScreenPriv->drawable,
|
||||
pScreenPriv->pixmapFormats[8].format,
|
||||
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 (!pScreenPriv->trapInfo.mask)
|
||||
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;
|
||||
|
||||
glitz_set_rectangle (pScreenPriv->trapInfo.mask, &clearBlack, 0, 0, 1, 1);
|
||||
glitz_set_rectangle (pScreenPriv->trapInfo.mask, &solidWhite, 1, 0, 1, 1);
|
||||
|
||||
glitz_surface_set_fill (pScreenPriv->trapInfo.mask, GLITZ_FILL_NEAREST);
|
||||
glitz_surface_set_filter (pScreenPriv->trapInfo.mask,
|
||||
GLITZ_FILTER_BILINEAR,
|
||||
NULL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
format = &pScreenPriv->trapInfo.format.vertex;
|
||||
format->primitive = GLITZ_PRIMITIVE_QUADS;
|
||||
|
@ -349,6 +368,11 @@ xglFinishScreenInit (ScreenPtr pScreen)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef XV
|
||||
if (!xglXvScreenInit (pScreen))
|
||||
return FALSE;
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -356,6 +380,8 @@ Bool
|
|||
xglCloseScreen (int index,
|
||||
ScreenPtr pScreen)
|
||||
{
|
||||
xglVisualPtr v;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
XGL_PIXMAP_PRIV (pScreenPriv->pScreenPixmap);
|
||||
|
||||
|
@ -368,25 +394,35 @@ xglCloseScreen (int index,
|
|||
if (pScreenPriv->pSolidAlpha)
|
||||
FreePicture ((pointer) pScreenPriv->pSolidAlpha, 0);
|
||||
|
||||
if (pScreenPriv->trapInfo.mask)
|
||||
glitz_surface_destroy (pScreenPriv->trapInfo.mask);
|
||||
if (pScreenPriv->trapInfo.pMask)
|
||||
FreePicture ((pointer) pScreenPriv->trapInfo.pMask, 0);
|
||||
#endif
|
||||
|
||||
xglFiniPixmap (pScreenPriv->pScreenPixmap);
|
||||
if (pPixmapPriv->pDamage)
|
||||
DamageDestroy (pPixmapPriv->pDamage);
|
||||
|
||||
if (pScreenPriv->solid)
|
||||
glitz_surface_destroy (pScreenPriv->solid);
|
||||
|
||||
if (pScreenPriv->backSurface)
|
||||
glitz_surface_destroy (pScreenPriv->backSurface);
|
||||
|
||||
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);
|
||||
|
||||
|
@ -404,7 +440,7 @@ xglCreateSolidAlphaPicture (ScreenPtr pScreen)
|
|||
int error;
|
||||
Pixel pixel;
|
||||
GCPtr pGC;
|
||||
CARD32 tmpval[2];
|
||||
XID tmpval[2];
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
|
@ -431,8 +467,7 @@ xglCreateSolidAlphaPicture (ScreenPtr pScreen)
|
|||
FreeScratchGC (pGC);
|
||||
|
||||
tmpval[0] = xTrue;
|
||||
pScreenPriv->pSolidAlpha =
|
||||
CreatePicture (0, &pPixmap->drawable, pFormat,
|
||||
pScreenPriv->pSolidAlpha = CreatePicture (0, &pPixmap->drawable, pFormat,
|
||||
CPRepeat, tmpval, 0, &error);
|
||||
(*pScreen->DestroyPixmap) (pPixmap);
|
||||
|
||||
|
|
|
@ -57,8 +57,10 @@ xglShmPutImage (DrawablePtr pDrawable,
|
|||
BitsPerPixel (depth),
|
||||
PixmapBytePad (w, depth),
|
||||
(pointer) data);
|
||||
|
||||
/* disable any possible acceleration of this pixmap */
|
||||
if (pPixmap)
|
||||
XGL_GET_PIXMAP_PRIV (pPixmap)->format = NULL;
|
||||
xglSetPixmapVisual (pPixmap, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -67,16 +69,14 @@ xglShmPutImage (DrawablePtr pDrawable,
|
|||
{
|
||||
GCPtr pScratchGC;
|
||||
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
if (!xglAllocatePixmapBits (pPixmap,
|
||||
XGL_PIXMAP_USAGE_HINT_DEFAULT))
|
||||
{
|
||||
(*pScreen->DestroyPixmap) (pPixmap);
|
||||
return;
|
||||
}
|
||||
pPixmapPriv->format = NULL;
|
||||
pPixmapPriv->target = xglPixmapTargetNo;
|
||||
|
||||
xglSetPixmapVisual (pPixmap, 0);
|
||||
|
||||
pScratchGC = GetScratchGC (depth, pScreen);
|
||||
if (!pScratchGC)
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
Bool
|
||||
xglSolid (DrawablePtr pDrawable,
|
||||
glitz_operator_t op,
|
||||
glitz_color_t *color,
|
||||
glitz_surface_t *solid,
|
||||
xglGeometryPtr pGeometry,
|
||||
int x,
|
||||
int y,
|
||||
|
@ -43,8 +43,6 @@ xglSolid (DrawablePtr pDrawable,
|
|||
glitz_surface_t *surface;
|
||||
int xOff, yOff;
|
||||
|
||||
XGL_SCREEN_PRIV (pDrawable->pScreen);
|
||||
|
||||
if (nBox < 1)
|
||||
return TRUE;
|
||||
|
||||
|
@ -53,8 +51,6 @@ xglSolid (DrawablePtr pDrawable,
|
|||
|
||||
XGL_GET_DRAWABLE (pDrawable, surface, xOff, yOff);
|
||||
|
||||
glitz_set_rectangle (pScreenPriv->solid, color, 0, 0, 1, 1);
|
||||
|
||||
if (pGeometry)
|
||||
{
|
||||
glitz_surface_set_clip_region (surface, xOff, yOff,
|
||||
|
@ -72,7 +68,7 @@ xglSolid (DrawablePtr pDrawable,
|
|||
return FALSE;
|
||||
|
||||
glitz_composite (op,
|
||||
pScreenPriv->solid, NULL, surface,
|
||||
solid, NULL, surface,
|
||||
0, 0,
|
||||
0, 0,
|
||||
x + xOff,
|
||||
|
@ -132,7 +128,7 @@ xglSolidGlyph (DrawablePtr pDrawable,
|
|||
|
||||
if (xglSolid (pDrawable,
|
||||
pGCPriv->op,
|
||||
&pGCPriv->bg,
|
||||
pGCPriv->bg,
|
||||
NULL,
|
||||
xBack,
|
||||
yBack,
|
||||
|
@ -143,7 +139,7 @@ xglSolidGlyph (DrawablePtr pDrawable,
|
|||
{
|
||||
if (xglSolid (pDrawable,
|
||||
pGCPriv->op,
|
||||
&pGCPriv->fg,
|
||||
pGCPriv->fg,
|
||||
&geometry,
|
||||
xBack,
|
||||
yBack,
|
||||
|
@ -153,6 +149,7 @@ xglSolidGlyph (DrawablePtr pDrawable,
|
|||
REGION_NUM_RECTS (pGC->pCompositeClip)))
|
||||
{
|
||||
GEOMETRY_UNINIT (&geometry);
|
||||
xglAddCurrentBitDamage (pDrawable);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
|
299
hw/xgl/xglsync.c
299
hw/xgl/xglsync.c
|
@ -25,49 +25,11 @@
|
|||
|
||||
#include "xgl.h"
|
||||
|
||||
/*
|
||||
* A pixmap may exist both in hardware and in software. Synchronization
|
||||
* is handled as follows:
|
||||
*
|
||||
* Regions modified by software and hardware needs to be tracked.
|
||||
* A software operation requires that a rectangle of pixels matching the
|
||||
* extents of the operation is synchronized. A hardware operation
|
||||
* requires that all pixels are synchronized. If the bounds of a
|
||||
* hardware operation intersects the bounds of a currently synchronized
|
||||
* software rectangle, the software rectangle will be discarded and the
|
||||
* next software operation will require re-synchronization.
|
||||
*
|
||||
* A software rectangle of pixels is synchronized as follows. If a
|
||||
* previously synchronized rectangle exists, then if this previous
|
||||
* rectangle subsumes our new rectangle no pixels are fetched from
|
||||
* hardware as all pixels that need to be synchronized are already up to
|
||||
* date. If a previously synchronized rectangle exists and it intersects
|
||||
* with our new rectangle, then both these rectangles are merged into a
|
||||
* larger rectangle and pixels not part of the previous rectangle are
|
||||
* fetched form hardware. If a previously synchronized rectangle exists
|
||||
* and it doesn't intersect with our new rectangle, then the previous
|
||||
* rectangle is discarded and pixels are fetched from hardware so that
|
||||
* our new rectangle becomes synchronized.
|
||||
*
|
||||
* If the pixmap exists in hardware and if it can be a target of a
|
||||
* drawing operation, then it is kept synchronized all the time, any
|
||||
* pixels modified by software will be transfered to hardware right
|
||||
* away. If the pixmap exists in hardware but it can only be used as
|
||||
* source of a drawing operation, then synchronization is performed
|
||||
* only when needed.
|
||||
*/
|
||||
|
||||
#define ALL_BITS(pPixmap, pBox) \
|
||||
((pBox)->x1 <= 0 && (pBox)->y1 <= 0 && \
|
||||
(pBox)->x2 >= (pPixmap)->drawable.width && \
|
||||
(pBox)->y2 >= (pPixmap)->drawable.height)
|
||||
|
||||
Bool
|
||||
xglSyncBits (DrawablePtr pDrawable,
|
||||
BoxPtr pExtents)
|
||||
{
|
||||
RegionRec region;
|
||||
BoxPtr pBitBox;
|
||||
BoxRec box;
|
||||
|
||||
XGL_DRAWABLE_PIXMAP (pDrawable);
|
||||
|
@ -76,53 +38,66 @@ xglSyncBits (DrawablePtr pDrawable,
|
|||
if (pPixmapPriv->allBits)
|
||||
return xglMapPixmapBits (pPixmap);
|
||||
|
||||
pBitBox = &pPixmapPriv->bitBox;
|
||||
|
||||
if (pPixmapPriv->target == xglPixmapTargetIn && pExtents)
|
||||
{
|
||||
box.x1 = MAX (0, pExtents->x1);
|
||||
box.y1 = MAX (0, pExtents->y1);
|
||||
box.x2 = MAX (0, MIN (pPixmap->drawable.width, pExtents->x2));
|
||||
box.y2 = MAX (0, MIN (pPixmap->drawable.height, pExtents->y2));
|
||||
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_NOTEMPTY (&box))
|
||||
if (box.x2 <= box.x1 || box.y2 <= box.y1)
|
||||
return xglMapPixmapBits (pPixmap);
|
||||
|
||||
if (BOX_NOTEMPTY (pBitBox))
|
||||
if (REGION_NOTEMPTY (pDrawable->pScreen, &pPixmapPriv->bitRegion))
|
||||
{
|
||||
RegionRec bitRegion;
|
||||
|
||||
REGION_INIT (pDrawable->pScreen, &bitRegion, pBitBox, 1);
|
||||
|
||||
switch (RECT_IN_REGION (pDrawable->pScreen, &bitRegion, &box)) {
|
||||
switch (RECT_IN_REGION (pDrawable->pScreen,
|
||||
&pPixmapPriv->bitRegion,
|
||||
&box)) {
|
||||
case rgnIN:
|
||||
REGION_NULL (pDrawable->pScreen, ®ion);
|
||||
REGION_INIT (pDrawable->pScreen, ®ion, NullBox, 0);
|
||||
break;
|
||||
case rgnOUT:
|
||||
REGION_INIT (pDrawable->pScreen, ®ion, &box, 1);
|
||||
*pBitBox = box;
|
||||
pPixmapPriv->allBits = ALL_BITS (pPixmap, pBitBox);
|
||||
REGION_UNION (pDrawable->pScreen,
|
||||
&pPixmapPriv->bitRegion, &pPixmapPriv->bitRegion,
|
||||
®ion);
|
||||
break;
|
||||
case rgnPART:
|
||||
pBitBox->x1 = MIN (pBitBox->x1, box.x1);
|
||||
pBitBox->y1 = MIN (pBitBox->y1, box.y1);
|
||||
pBitBox->x2 = MAX (pBitBox->x2, box.x2);
|
||||
pBitBox->y2 = MAX (pBitBox->y2, box.y2);
|
||||
pPixmapPriv->allBits = ALL_BITS (pPixmap, pBitBox);
|
||||
|
||||
REGION_INIT (pDrawable->pScreen, ®ion, pBitBox, 1);
|
||||
REGION_INIT (pDrawable->pScreen, ®ion, &box, 1);
|
||||
REGION_SUBTRACT (pDrawable->pScreen, ®ion, ®ion,
|
||||
&bitRegion);
|
||||
|
||||
&pPixmapPriv->bitRegion);
|
||||
REGION_UNION (pDrawable->pScreen,
|
||||
&pPixmapPriv->bitRegion, &pPixmapPriv->bitRegion,
|
||||
®ion);
|
||||
break;
|
||||
}
|
||||
REGION_UNINIT (pDrawable->pScreen, &bitRegion);
|
||||
}
|
||||
else
|
||||
{
|
||||
REGION_INIT (pDrawable->pScreen, ®ion, &box, 1);
|
||||
*pBitBox = box;
|
||||
pPixmapPriv->allBits = ALL_BITS (pPixmap, pBitBox);
|
||||
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
|
||||
|
@ -133,17 +108,9 @@ xglSyncBits (DrawablePtr pDrawable,
|
|||
box.y2 = pPixmap->drawable.height;
|
||||
|
||||
REGION_INIT (pDrawable->pScreen, ®ion, &box, 1);
|
||||
REGION_SUBTRACT (pDrawable->pScreen, ®ion, ®ion,
|
||||
&pPixmapPriv->bitRegion);
|
||||
|
||||
if (BOX_NOTEMPTY (pBitBox))
|
||||
{
|
||||
RegionRec bitRegion;
|
||||
|
||||
REGION_INIT (pDrawable->pScreen, &bitRegion, pBitBox, 1);
|
||||
REGION_SUBTRACT (pDrawable->pScreen, ®ion, ®ion, &bitRegion);
|
||||
REGION_UNINIT (pDrawable->pScreen, &bitRegion);
|
||||
}
|
||||
|
||||
*pBitBox = box;
|
||||
pPixmapPriv->allBits = TRUE;
|
||||
}
|
||||
|
||||
|
@ -151,18 +118,11 @@ xglSyncBits (DrawablePtr pDrawable,
|
|||
if (!xglAllocatePixmapBits (pPixmap, XGL_PIXMAP_USAGE_HINT_DEFAULT))
|
||||
return FALSE;
|
||||
|
||||
if (pPixmapPriv->pDamage)
|
||||
{
|
||||
RegionPtr pRegion;
|
||||
|
||||
pRegion = DamageRegion (pPixmapPriv->pDamage);
|
||||
REGION_SUBTRACT (pDrawable->pScreen, ®ion, ®ion, pRegion);
|
||||
}
|
||||
|
||||
if (REGION_NOTEMPTY (pDrawable->pScreen, ®ion) && pPixmapPriv->surface)
|
||||
{
|
||||
glitz_pixel_format_t format;
|
||||
BoxPtr pBox;
|
||||
BoxPtr pExt;
|
||||
int nBox;
|
||||
|
||||
if (!xglSyncSurface (pDrawable))
|
||||
|
@ -172,41 +132,52 @@ xglSyncBits (DrawablePtr pDrawable,
|
|||
|
||||
pBox = REGION_RECTS (®ion);
|
||||
nBox = REGION_NUM_RECTS (®ion);
|
||||
pExt = REGION_EXTENTS (pDrawable->pScreen, ®ion);
|
||||
|
||||
format.fourcc = GLITZ_FOURCC_RGB;
|
||||
format.masks = pPixmapPriv->pPixel->masks;
|
||||
|
||||
while (nBox--)
|
||||
{
|
||||
format.xoffset = pBox->x1;
|
||||
format.masks = pPixmapPriv->pVisual->pPixel->masks;
|
||||
format.xoffset = pExt->x1;
|
||||
|
||||
if (pPixmapPriv->stride < 0)
|
||||
{
|
||||
format.skip_lines = pPixmap->drawable.height - pBox->y2;
|
||||
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 = pBox->y1;
|
||||
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,
|
||||
pBox->x1,
|
||||
pBox->y1,
|
||||
pBox->x2 - pBox->x1,
|
||||
pBox->y2 - pBox->y1,
|
||||
pExt->x1,
|
||||
pExt->y1,
|
||||
pExt->x2 - pExt->x1,
|
||||
pExt->y2 - pExt->y1,
|
||||
&format,
|
||||
pPixmapPriv->buffer);
|
||||
|
||||
pBox++;
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -229,9 +200,6 @@ xglSyncSurface (DrawablePtr pDrawable)
|
|||
|
||||
if (!pPixmapPriv->surface)
|
||||
{
|
||||
if (!pPixmapPriv->format)
|
||||
return FALSE;
|
||||
|
||||
if (!xglCreatePixmapSurface (pPixmap))
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -251,8 +219,8 @@ xglSyncSurface (DrawablePtr pDrawable)
|
|||
pBox = REGION_RECTS (pRegion);
|
||||
pExt = REGION_EXTENTS (pDrawable->pScreen, pRegion);
|
||||
|
||||
format.fourcc = GLITZ_FOURCC_RGB;
|
||||
format.masks = pPixmapPriv->pPixel->masks;
|
||||
format.fourcc = pPixmapPriv->pVisual->format.surface->color.fourcc;
|
||||
format.masks = pPixmapPriv->pVisual->pPixel->masks;
|
||||
format.xoffset = pExt->x1;
|
||||
|
||||
if (pPixmapPriv->stride < 0)
|
||||
|
@ -299,9 +267,44 @@ xglPrepareTarget (DrawablePtr pDrawable)
|
|||
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))
|
||||
|
@ -316,24 +319,32 @@ void
|
|||
xglAddSurfaceDamage (DrawablePtr pDrawable,
|
||||
RegionPtr pRegion)
|
||||
{
|
||||
RegionPtr pDamageRegion;
|
||||
glitz_surface_t *surface;
|
||||
int xOff, yOff;
|
||||
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
|
||||
|
||||
pPixmapPriv->damageBox = miEmptyBox;
|
||||
if (!pPixmapPriv->format)
|
||||
return;
|
||||
|
||||
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,
|
||||
pDamageRegion, pDamageRegion,
|
||||
pRegion);
|
||||
}
|
||||
|
||||
REGION_UNION (pDrawable->pScreen,
|
||||
&pPixmapPriv->bitRegion, &pPixmapPriv->bitRegion,
|
||||
pRegion);
|
||||
|
||||
if (xOff || yOff)
|
||||
REGION_TRANSLATE (pDrawable->pScreen, pRegion, -xOff, -yOff);
|
||||
|
@ -344,22 +355,27 @@ xglAddCurrentSurfaceDamage (DrawablePtr pDrawable)
|
|||
{
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
|
||||
|
||||
if (!pPixmapPriv->format)
|
||||
{
|
||||
pPixmapPriv->damageBox = miEmptyBox;
|
||||
return;
|
||||
}
|
||||
|
||||
if (BOX_NOTEMPTY (&pPixmapPriv->damageBox))
|
||||
{
|
||||
RegionPtr pDamageRegion;
|
||||
RegionRec region;
|
||||
|
||||
REGION_INIT (pDrawable->pScreen, ®ion, &pPixmapPriv->damageBox, 1);
|
||||
|
||||
if (pPixmapPriv->pDamage)
|
||||
{
|
||||
RegionPtr pDamageRegion;
|
||||
|
||||
pDamageRegion = DamageRegion (pPixmapPriv->pDamage);
|
||||
|
||||
REGION_INIT (pDrawable->pScreen, ®ion, &pPixmapPriv->damageBox, 1);
|
||||
REGION_UNION (pDrawable->pScreen,
|
||||
pDamageRegion, pDamageRegion, ®ion);
|
||||
pDamageRegion, pDamageRegion,
|
||||
®ion);
|
||||
}
|
||||
|
||||
REGION_UNION (pDrawable->pScreen,
|
||||
&pPixmapPriv->bitRegion, &pPixmapPriv->bitRegion,
|
||||
®ion);
|
||||
|
||||
REGION_UNINIT (pDrawable->pScreen, ®ion);
|
||||
|
||||
pPixmapPriv->damageBox = miEmptyBox;
|
||||
|
@ -370,29 +386,36 @@ void
|
|||
xglAddBitDamage (DrawablePtr pDrawable,
|
||||
RegionPtr pRegion)
|
||||
{
|
||||
BoxPtr pBox;
|
||||
BoxPtr pExt;
|
||||
int nBox;
|
||||
|
||||
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);
|
||||
|
||||
if (pExt->x1 < pPixmapPriv->bitBox.x2 &&
|
||||
pExt->y1 < pPixmapPriv->bitBox.y2 &&
|
||||
pExt->x2 > pPixmapPriv->bitBox.x1 &&
|
||||
pExt->y2 > pPixmapPriv->bitBox.y1)
|
||||
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 < pPixmapPriv->bitBox.x2 &&
|
||||
pBox->y1 < pPixmapPriv->bitBox.y2 &&
|
||||
pBox->x2 > pPixmapPriv->bitBox.x1 &&
|
||||
pBox->y2 > pPixmapPriv->bitBox.y1)
|
||||
if (pBox->x1 < pBitExt->x2 &&
|
||||
pBox->y1 < pBitExt->y2 &&
|
||||
pBox->x2 > pBitExt->x1 &&
|
||||
pBox->y2 > pBitExt->y1)
|
||||
{
|
||||
pPixmapPriv->bitBox = miEmptyBox;
|
||||
REGION_UNINIT (pDrawable->pScreen,
|
||||
&pPixmapPriv->bitRegion);
|
||||
REGION_INIT (pDrawable->pScreen, &pPixmapPriv->bitRegion,
|
||||
NullBox, 0);
|
||||
pPixmapPriv->allBits = FALSE;
|
||||
return;
|
||||
}
|
||||
|
@ -400,6 +423,7 @@ xglAddBitDamage (DrawablePtr pDrawable,
|
|||
pBox++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -407,14 +431,23 @@ xglAddCurrentBitDamage (DrawablePtr pDrawable)
|
|||
{
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
|
||||
|
||||
if (pPixmapPriv->damageBox.x1 < pPixmapPriv->bitBox.x2 &&
|
||||
pPixmapPriv->damageBox.y1 < pPixmapPriv->bitBox.y2 &&
|
||||
pPixmapPriv->damageBox.x2 > pPixmapPriv->bitBox.x1 &&
|
||||
pPixmapPriv->damageBox.y2 > pPixmapPriv->bitBox.y1)
|
||||
if (REGION_NOTEMPTY (pDrawable->pScreen, &pPixmapPriv->bitRegion))
|
||||
{
|
||||
pPixmapPriv->bitBox = miEmptyBox;
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -151,8 +151,8 @@ xglTrapezoids (CARD8 op,
|
|||
{
|
||||
ScreenPtr pScreen = pDst->pDrawable->pScreen;
|
||||
PicturePtr pMask = NULL, pSrcPicture, pDstPicture;
|
||||
PicturePtr pMaskPicture = NULL;
|
||||
xglGeometryPtr pGeometry = NULL;
|
||||
glitz_surface_t *mask = NULL;
|
||||
unsigned int polyEdge = pDst->polyEdge;
|
||||
INT16 xDst, yDst;
|
||||
INT16 xOff, yOff;
|
||||
|
@ -161,7 +161,6 @@ xglTrapezoids (CARD8 op,
|
|||
Bool target;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pDst->pDrawable);
|
||||
|
||||
xDst = traps[0].left.p1.x >> 16;
|
||||
yDst = traps[0].left.p1.y >> 16;
|
||||
|
@ -207,13 +206,15 @@ xglTrapezoids (CARD8 op,
|
|||
return;
|
||||
}
|
||||
|
||||
/* make sure destination drawable is locked */
|
||||
pPixmapPriv->lock++;
|
||||
if (!target)
|
||||
{
|
||||
/* make sure we don't do accelerated drawing to mask */
|
||||
xglSetPixmapVisual (pPixmap, NULL);
|
||||
}
|
||||
|
||||
/* lock mask if we are not doing accelerated drawing to destination */
|
||||
area = rect.width * rect.height;
|
||||
if (!target || (SMOOTH_TRAPS_ESTIMATE_RECTS (nTrap) * 4) > area)
|
||||
XGL_GET_PIXMAP_PRIV (pPixmap)->lock = 1;
|
||||
if ((SMOOTH_TRAPS_ESTIMATE_RECTS (nTrap) * 4) > area)
|
||||
XGL_GET_PIXMAP_PRIV (pPixmap)->target = xglPixmapTargetNo;
|
||||
|
||||
ValidatePicture (pMask);
|
||||
pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
|
||||
|
@ -232,9 +233,6 @@ xglTrapezoids (CARD8 op,
|
|||
}
|
||||
else
|
||||
{
|
||||
/* make sure destination drawable is locked */
|
||||
pPixmapPriv->lock++;
|
||||
|
||||
if (maskFormat)
|
||||
{
|
||||
if (maskFormat->depth == 1)
|
||||
|
@ -254,13 +252,15 @@ xglTrapezoids (CARD8 op,
|
|||
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);
|
||||
|
||||
mask = pScreenPriv->trapInfo.mask;
|
||||
pMaskPicture = pScreenPriv->trapInfo.pMask;
|
||||
format = &pScreenPriv->trapInfo.format.vertex;
|
||||
mask = pMaskPicture->pSourcePict->source.devPrivate.ptr;
|
||||
|
||||
size *= format->bytes_per_vertex;
|
||||
pGeometry = xglGetScratchGeometryWithSize (pScreen, size);
|
||||
|
@ -275,7 +275,6 @@ xglTrapezoids (CARD8 op,
|
|||
if (pMask)
|
||||
FreePicture (pMask, 0);
|
||||
|
||||
pPixmapPriv->lock--;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -304,7 +303,6 @@ xglTrapezoids (CARD8 op,
|
|||
if (pMask)
|
||||
FreePicture (pMask, 0);
|
||||
|
||||
pPixmapPriv->lock--;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -317,19 +315,18 @@ xglTrapezoids (CARD8 op,
|
|||
}
|
||||
|
||||
if (pGeometry &&
|
||||
xglComp (pMask ? PictOpAdd : op,
|
||||
xglCompositeGeneral (pMask ? PictOpAdd : op,
|
||||
pSrcPicture,
|
||||
NULL,
|
||||
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,
|
||||
pGeometry,
|
||||
mask))
|
||||
extents.y2 - extents.y1))
|
||||
{
|
||||
/* no intermediate mask? we need to register damage from here as
|
||||
CompositePicture will never be called. */
|
||||
|
@ -368,8 +365,9 @@ xglTrapezoids (CARD8 op,
|
|||
(*ps->RasterizeTrapezoid) (pDstPicture, traps, xOff, yOff);
|
||||
|
||||
xglAddCurrentSurfaceDamage (pDstPicture->pDrawable);
|
||||
} else
|
||||
miTrapezoids (op, pSrc, pDstPicture, NULL,
|
||||
}
|
||||
else
|
||||
miTrapezoids (op, pSrc, pDstPicture, maskFormat,
|
||||
xSrc, ySrc, nTrap, traps);
|
||||
}
|
||||
|
||||
|
@ -385,9 +383,6 @@ xglTrapezoids (CARD8 op,
|
|||
|
||||
FreePicture (pMask, 0);
|
||||
}
|
||||
|
||||
/* release destination drawable lock */
|
||||
pPixmapPriv->lock--;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -417,14 +412,18 @@ xglAddTraps (PicturePtr pDst,
|
|||
|
||||
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);
|
||||
|
@ -439,8 +438,7 @@ xglAddTraps (PicturePtr pDst,
|
|||
|
||||
offset +=
|
||||
glitz_add_traps (pGeometry->buffer,
|
||||
offset, size - offset, format->type,
|
||||
pScreenPriv->trapInfo.mask,
|
||||
offset, size - offset, format->type, mask,
|
||||
(glitz_trap_t *) pTrap, n,
|
||||
&nAddedTrap);
|
||||
|
||||
|
@ -456,16 +454,16 @@ xglAddTraps (PicturePtr pDst,
|
|||
pDst->pDrawable->x + xOff,
|
||||
pDst->pDrawable->y + yOff);
|
||||
|
||||
if (xglComp (PictOpAdd,
|
||||
if (xglCompositeGeneral (PictOpAdd,
|
||||
pScreenPriv->pSolidAlpha,
|
||||
NULL,
|
||||
pMask,
|
||||
pDst,
|
||||
pGeometry,
|
||||
0, 0,
|
||||
0, 0,
|
||||
pDst->pDrawable->x, pDst->pDrawable->y,
|
||||
pDst->pDrawable->width, pDst->pDrawable->height,
|
||||
pGeometry,
|
||||
pScreenPriv->trapInfo.mask))
|
||||
pDst->pDrawable->width,
|
||||
pDst->pDrawable->height))
|
||||
{
|
||||
xglAddCurrentBitDamage (pDst->pDrawable);
|
||||
return;
|
||||
|
|
|
@ -53,6 +53,21 @@ xglCreateWindow (WindowPtr pWin)
|
|||
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)
|
||||
|
@ -116,7 +131,7 @@ xglCopyWindow (WindowPtr pWin,
|
|||
dy = ptOldOrg.y - pWin->drawable.y;
|
||||
|
||||
REGION_TRANSLATE (pWin->drawable.pScreen, prgnSrc, -dx, -dy);
|
||||
REGION_NULL (pWin->drawable.pScreen, &rgnDst);
|
||||
REGION_INIT (pWin->drawable.pScreen, &rgnDst, NullBox, 0);
|
||||
REGION_INTERSECT (pWin->drawable.pScreen,
|
||||
&rgnDst, &pWin->borderClip, prgnSrc);
|
||||
|
||||
|
@ -131,29 +146,53 @@ xglFillRegionSolid (DrawablePtr pDrawable,
|
|||
RegionPtr pRegion,
|
||||
Pixel pixel)
|
||||
{
|
||||
glitz_color_t color;
|
||||
glitz_pixel_format_t format;
|
||||
glitz_surface_t *solid;
|
||||
glitz_buffer_t *buffer;
|
||||
BoxPtr pExtent;
|
||||
Bool ret;
|
||||
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
|
||||
XGL_SCREEN_PRIV (pDrawable->pScreen);
|
||||
|
||||
if (!pPixmapPriv->target)
|
||||
if (!xglPrepareTarget (pDrawable))
|
||||
return FALSE;
|
||||
|
||||
solid = glitz_surface_create (pScreenPriv->drawable,
|
||||
pPixmapPriv->pVisual->format.surface,
|
||||
1, 1, 0, NULL);
|
||||
if (!solid)
|
||||
return FALSE;
|
||||
|
||||
glitz_surface_set_fill (solid, GLITZ_FILL_REPEAT);
|
||||
|
||||
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);
|
||||
|
||||
glitz_set_pixels (solid, 0, 0, 1, 1, &format, buffer);
|
||||
|
||||
glitz_buffer_destroy (buffer);
|
||||
|
||||
pExtent = REGION_EXTENTS (pDrawable->pScreen, pRegion);
|
||||
|
||||
xglPixelToColor (pPixmapPriv->pPixel, pixel, &color);
|
||||
|
||||
if (xglSolid (pDrawable,
|
||||
ret = xglSolid (pDrawable,
|
||||
GLITZ_OPERATOR_SRC,
|
||||
&color,
|
||||
solid,
|
||||
NULL,
|
||||
pExtent->x1, pExtent->y1,
|
||||
pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
|
||||
REGION_RECTS (pRegion),
|
||||
REGION_NUM_RECTS (pRegion)))
|
||||
return TRUE;
|
||||
REGION_NUM_RECTS (pRegion));
|
||||
|
||||
return FALSE;
|
||||
glitz_surface_destroy (solid);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static Bool
|
||||
|
@ -165,11 +204,6 @@ xglFillRegionTiled (DrawablePtr pDrawable,
|
|||
{
|
||||
BoxPtr pExtent;
|
||||
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
|
||||
|
||||
if (!pPixmapPriv->target)
|
||||
return FALSE;
|
||||
|
||||
pExtent = REGION_EXTENTS (pDrawable->pScreen, pRegion);
|
||||
|
||||
if (xglTile (pDrawable,
|
||||
|
@ -281,3 +315,27 @@ xglPaintWindowBorder (WindowPtr pWin,
|
|||
XGL_WINDOW_FALLBACK_EPILOGUE (pWin, pRegion, PaintWindowBorder,
|
||||
xglPaintWindowBorder);
|
||||
}
|
||||
|
||||
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
Normal file
634
hw/xgl/xglxv.c
Normal file
|
@ -0,0 +1,634 @@
|
|||
/*
|
||||
* 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 unsigned int xglXvScreenIndex = 0;
|
||||
static unsigned long portResource = 0;
|
||||
|
||||
#define XGL_GET_XV_SCREEN(pScreen) \
|
||||
((XvScreenPtr) ((pScreen)->devPrivates[xglXvScreenIndex].ptr))
|
||||
|
||||
#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);
|
||||
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;
|
||||
|
||||
xglXvScreenIndex = XvGetScreenIndex ();
|
||||
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
|
Loading…
Reference in New Issue
Block a user