diff options
author | Dave Airlie <airlied@linux.ie> | 2006-01-18 07:15:55 +0000 |
---|---|---|
committer | Dave Airlie <airlied@linux.ie> | 2006-01-18 07:15:55 +0000 |
commit | e70b64b93024d05519014fb1b76fe26bd9f3a496 (patch) | |
tree | adde5d80999ebeed1bf361eafbae114a9d65dc93 /hw/xgl | |
parent | b5356e0afaf2b660c8905f63d5fdcb03402b81c5 (diff) |
Updated xgl code drop from Novell + xserver tree changes
Diffstat (limited to 'hw/xgl')
41 files changed, 11154 insertions, 2694 deletions
diff --git a/hw/xgl/Makefile.am b/hw/xgl/Makefile.am index 8e32a26c7..0aa94f9a5 100644 --- a/hw/xgl/Makefile.am +++ b/hw/xgl/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 \ + xglloader.c \ xglhash.c \ - xglloader.c \ - xglglx.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) diff --git a/hw/xgl/glx/Makefile.am b/hw/xgl/glx/Makefile.am index 0198d0906..4bc0189a4 100644 --- a/hw/xgl/glx/Makefile.am +++ b/hw/xgl/glx/Makefile.am @@ -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) diff --git a/hw/xgl/glx/module/Makefile.am b/hw/xgl/glx/module/Makefile.am index e2d1de74e..846942a43 100644 --- a/hw/xgl/glx/module/Makefile.am +++ b/hw/xgl/glx/module/Makefile.am @@ -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@ diff --git a/hw/xgl/glx/xglx.c b/hw/xgl/glx/xglx.c index 842ab19ec..cff3821dd 100644 --- a/hw/xgl/glx/xglx.c +++ b/hw/xgl/glx/xglx.c @@ -1,6 +1,6 @@ /* * Copyright © 2004 David Reveman - * + * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without * fee, provided that the above copyright notice appear in all copies @@ -12,23 +12,24 @@ * software for any purpose. It is provided "as is" without express or * implied warranty. * - * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * 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 <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,25 +38,77 @@ #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; int xglxScreenGeneration = -1; int xglxScreenPrivateIndex; -#define XGLX_GET_SCREEN_PRIV(pScreen) \ +#define XGLX_GET_SCREEN_PRIV(pScreen) \ ((xglxScreenPtr) (pScreen)->devPrivates[xglxScreenPrivateIndex].ptr) #define XGLX_SET_SCREEN_PRIV(pScreen, v) \ @@ -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) @@ -95,19 +153,232 @@ xglxAllocatePrivates (ScreenPtr pScreen) xglxScreenPrivateIndex = AllocateScreenPrivateIndex (); if (xglxScreenPrivateIndex < 0) return FALSE; - - xglxScreenGeneration = serverGeneration; + + xglxScreenGeneration = serverGeneration; } pScreenPriv = xalloc (sizeof (xglxScreenRec)); if (!pScreenPriv) return FALSE; - + XGLX_SET_SCREEN_PRIV (pScreen, pScreenPriv); - + + 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) @@ -120,7 +391,7 @@ xglxCursorLimits (ScreenPtr pScreen, BoxPtr pHotBox, BoxPtr pTopLeftBox) { - *pTopLeftBox = *pHotBox; + *pTopLeftBox = *pHotBox; } static Bool @@ -129,9 +400,9 @@ xglxDisplayCursor (ScreenPtr pScreen, { XGLX_SCREEN_PRIV (pScreen); XGLX_CURSOR_PRIV (pCursor, pScreen); - + XDefineCursor (xdisplay, pScreenPriv->win, pCursorPriv->cursor); - + return TRUE; } @@ -154,7 +425,7 @@ xglxRealizeCursor (ScreenPtr pScreen, XImage *ximage; Pixmap source, mask; XColor fgColor, bgColor; - GC xgc; + XlibGC xgc; unsigned long valuemask; XGCValues values; @@ -180,20 +451,20 @@ xglxRealizeCursor (ScreenPtr pScreen, } #endif - source = XCreatePixmap (xdisplay, + source = XCreatePixmap (xdisplay, pScreenPriv->win, pCursor->bits->width, pCursor->bits->height, 1); - - mask = XCreatePixmap (xdisplay, + + mask = XCreatePixmap (xdisplay, pScreenPriv->win, pCursor->bits->width, pCursor->bits->height, 1); - + xgc = XCreateGC (xdisplay, source, valuemask, &values); - + ximage = XCreateImage (xdisplay, DefaultVisual (xdisplay, xscreen), 1, XYBitmap, 0, @@ -201,41 +472,41 @@ xglxRealizeCursor (ScreenPtr pScreen, pCursor->bits->width, pCursor->bits->height, BitmapPad (xdisplay), 0); - + XPutImage (xdisplay, source, xgc, ximage, 0, 0, 0, 0, pCursor->bits->width, pCursor->bits->height); - + XFree (ximage); - - ximage = XCreateImage (xdisplay, + + ximage = XCreateImage (xdisplay, DefaultVisual (xdisplay, xscreen), - 1, XYBitmap, 0, + 1, XYBitmap, 0, (char *) pCursor->bits->mask, pCursor->bits->width, pCursor->bits->height, BitmapPad (xdisplay), 0); - + XPutImage (xdisplay, mask, xgc, ximage, 0, 0, 0, 0, pCursor->bits->width, pCursor->bits->height); - + XFree (ximage); XFreeGC (xdisplay, xgc); - + fgColor.red = pCursor->foreRed; fgColor.green = pCursor->foreGreen; fgColor.blue = pCursor->foreBlue; - + bgColor.red = pCursor->backRed; bgColor.green = pCursor->backGreen; bgColor.blue = pCursor->backBlue; - - pCursorPriv->cursor = + + pCursorPriv->cursor = XCreatePixmapCursor (xdisplay, source, mask, &fgColor, &bgColor, pCursor->bits->xhot, pCursor->bits->yhot); XFreePixmap (xdisplay, mask); XFreePixmap (xdisplay, source); - + return TRUE; } @@ -244,10 +515,10 @@ xglxUnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor) { XGLX_CURSOR_PRIV (pCursor, pScreen); - + XFreeCursor (xdisplay, pCursorPriv->cursor); xfree (pCursorPriv); - + return TRUE; } @@ -259,15 +530,15 @@ xglxRecolorCursor (ScreenPtr pScreen, XColor fgColor, bgColor; XGLX_CURSOR_PRIV (pCursor, pScreen); - + fgColor.red = pCursor->foreRed; fgColor.green = pCursor->foreGreen; fgColor.blue = pCursor->foreBlue; - + bgColor.red = pCursor->backRed; bgColor.green = pCursor->backGreen; bgColor.blue = pCursor->backBlue; - + XRecolorCursor (xdisplay, pCursorPriv->cursor, &fgColor, &bgColor); } @@ -278,10 +549,10 @@ xglxSetCursorPosition (ScreenPtr pScreen, Bool generateEvent) { XGLX_SCREEN_PRIV (pScreen); - + XWarpPointer (xdisplay, pScreenPriv->win, pScreenPriv->win, 0, 0, 0, 0, x, y); - + return TRUE; } @@ -290,7 +561,7 @@ xglxCloseScreen (int index, ScreenPtr pScreen) { glitz_drawable_t *drawable; - + XGLX_SCREEN_PRIV (pScreen); drawable = XGL_GET_SCREEN_PRIV (pScreen)->drawable; @@ -304,10 +575,10 @@ xglxCloseScreen (int index, if (pScreenPriv->colormap) XFreeColormap (xdisplay, pScreenPriv->colormap); - + XGL_SCREEN_UNWRAP (CloseScreen); xfree (pScreenPriv); - + return (*pScreen->CloseScreen) (index, pScreen); } @@ -345,14 +616,13 @@ 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) { @@ -386,13 +680,13 @@ 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); - + XFree (vinfo); normalHints = XAllocSizeHints (); @@ -412,14 +706,14 @@ xglxScreenInit (int index, classHint = XAllocClassHint (); classHint->res_name = "xglx"; classHint->res_class = "Xglx"; - + wmHints = XAllocWMHints (); wmHints->flags = InputHint; wmHints->input = TRUE; - - Xutf8SetWMProperties (xdisplay, pScreenPriv->win, "Xglx", "Xglx", 0, 0, + + Xutf8SetWMProperties (xdisplay, pScreenPriv->win, "Xglx", "Xglx", 0, 0, normalHints, wmHints, classHint); - + XFree (wmHints); XFree (classHint); XFree (normalHints); @@ -438,15 +732,15 @@ xglxScreenInit (int index, ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask | EnterWindowMask | PointerMotionMask | ExposureMask); - + XMapWindow (xdisplay, pScreenPriv->win); if (fullscreen) { XClientMessageEvent xev; - + memset (&xev, 0, sizeof (xev)); - + xev.type = ClientMessage; xev.message_type = XInternAtom (xdisplay, "_NET_WM_STATE", FALSE); xev.display = xdisplay; @@ -455,13 +749,13 @@ xglxScreenInit (int index, xev.data.l[0] = 1; 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; - + if (!xglScreenInit (pScreen)) return FALSE; @@ -476,28 +770,28 @@ xglxScreenInit (int index, if (!xglxARGBCursorSupport ()) softCursor = TRUE; #endif - + if (softCursor) { static char data = 0; XColor black, dummy; Pixmap bitmap; Cursor cursor; - + if (!XAllocNamedColor (xdisplay, pScreenPriv->colormap, "black", &black, &dummy)) return FALSE; - + bitmap = XCreateBitmapFromData (xdisplay, pScreenPriv->win, &data, 1, 1); if (!bitmap) return FALSE; - + cursor = XCreatePixmapCursor (xdisplay, bitmap, bitmap, &black, &black, 0, 0); if (!cursor) return FALSE; - + XDefineCursor (xdisplay, pScreenPriv->win, cursor); XFreeCursor (xdisplay, cursor); @@ -519,7 +813,12 @@ 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,34 +834,67 @@ 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; - format = glitz_glx_find_window_format (xdisplay, xscreen, - mask, &templ, 0); - + 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 | extraMask[i], + &templ, 0); + if (format) + break; + } + if (!format) FatalError ("no visual format found"); - xglSetVisualTypesAndMasks (pScreenInfo, format, (1 << TrueColor)); - - xglInitVisuals (pScreenInfo); - + xglScreenInfo.depth = + format->color.red_size + + format->color.green_size + + format->color.blue_size; + + xglSetVisualTypes (xglScreenInfo.depth, + (1 << TrueColor), + format->color.red_size, + format->color.green_size, + format->color.blue_size); + + xglxScreenFormat = format; + AddScreen (xglxScreenInit, argc, argv); } @@ -591,15 +923,15 @@ 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); (*pScreen->PaintWindowBorder) (pWin, &ClipList, PW_BORDER); 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); @@ -621,25 +953,25 @@ xglxBlockHandler (pointer blockData, while (XCheckIfEvent (xdisplay, &X, xglxExposurePredicate, NULL)) { ScreenPtr pScreen = currentScreen; - + box.x1 = X.xexpose.x; box.y1 = X.xexpose.y; box.x2 = box.x1 + X.xexpose.width; box.y2 = box.y1 + X.xexpose.height; - + REGION_INIT (currentScreen, ®ion, &box, 1); WalkTree (pScreen, xglxWindowExposures, ®ion); - + REGION_UNINIT (pScreen, ®ion); } - + if (!xglSyncSurface (&pScreenPriv->pScreenPixmap->drawable)) FatalError (XGL_SW_FAILURE_STRING); - + glitz_surface_flush (pScreenPriv->surface); glitz_drawable_flush (pScreenPriv->drawable); - + XFlush (xdisplay); } @@ -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 = @@ -699,7 +1033,7 @@ xglxWakeupHandler (pointer blockData, mieqEnqueue (&x); } } - break; + break; default: break; } @@ -715,16 +1049,48 @@ 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) return BadImplementation; - + switch (onoff) { case DEVICE_INIT: { XModifierKeymap *xmodMap; @@ -734,18 +1100,44 @@ 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; - + return !Success; + xmodMap = XGetModifierMapping (xdisplay); + XDisplayKeycodes (xdisplay, &minKeyCode, &maxKeyCode); - xkeyMap = XGetKeyboardMapping (xdisplay, + +#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); - + for (j = 0; j < 8; j++) { for (i = 0; i < xmodMap->max_keypermod; i++) @@ -757,39 +1149,124 @@ xglxKeybdProc (DeviceIntPtr pDevice, xglxModMap[keyCode] |= 1 << j; } } - + XFreeModifiermap (xmodMap); - + xglxKeySyms.minKeyCode = minKeyCode; xglxKeySyms.maxKeyCode = maxKeyCode; xglxKeySyms.mapWidth = mapWidth; xglxKeySyms.map = xkeyMap; - XGetKeyboardControl (xdisplay, &values); +#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 - memmove (defaultKeyboardControl.autoRepeats, - values.auto_repeats, sizeof (values.auto_repeats)); + if (!ret) + { + XGetKeyboardControl (xdisplay, &values); - ret = InitKeyboardDeviceStruct (pDev, - &xglxKeySyms, - xglxModMap, - xglxBell, - xglKbdCtrl); + memmove (defaultKeyboardControl.autoRepeats, + values.auto_repeats, sizeof (values.auto_repeats)); + + ret = InitKeyboardDeviceStruct (pDev, + &xglxKeySyms, + xglxModMap, + xglxBell, + xglxKbdCtrl); + } +#ifdef _XSERVER64 + xfree (xkeyMap); +#else XFree (xkeyMap); +#endif if (!ret) return BadImplementation; + } break; - case DEVICE_ON: + case DEVICE_ON: pDev->on = TRUE; break; - case DEVICE_OFF: + case DEVICE_OFF: case DEVICE_CLOSE: pDev->on = FALSE; break; } - + return Success; } @@ -812,16 +1289,16 @@ xglxInitInput (int argc, char **argv) { DeviceIntPtr pKeyboard, pPointer; - + pPointer = AddInputDevice (xglMouseProc, TRUE); pKeyboard = AddInputDevice (xglxKeybdProc, TRUE); - + RegisterPointerDevice (pPointer); RegisterKeyboardDevice (pKeyboard); - + miRegisterPointerDevice (screenInfo.screens[0], pPointer); mieqInit (&pKeyboard->public, &pPointer->public); - + AddEnabledDevice (XConnectionNumber (xdisplay)); RegisterBlockAndWakeupHandlers (xglxBlockHandler, @@ -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 (); } @@ -901,34 +1425,34 @@ static Bool xglxARGBCursorSupport (void) { int renderMajor, renderMinor; - + if (!XRenderQueryVersion (xdisplay, &renderMajor, &renderMinor)) renderMajor = renderMinor = -1; return (renderMajor > 0 || renderMinor > 4); -} +} static Cursor xglxCreateARGBCursor (ScreenPtr pScreen, CursorPtr pCursor) { Pixmap xpixmap; - GC xgc; + XlibGC xgc; XImage *ximage; XRenderPictFormat *xformat; Picture xpicture; Cursor cursor; XGLX_SCREEN_PRIV (pScreen); - - xpixmap = XCreatePixmap (xdisplay, + + xpixmap = XCreatePixmap (xdisplay, pScreenPriv->win, pCursor->bits->width, pCursor->bits->height, 32); - + xgc = XCreateGC (xdisplay, xpixmap, 0, NULL); - + ximage = XCreateImage (xdisplay, DefaultVisual (xdisplay, xscreen), 32, ZPixmap, 0, @@ -936,23 +1460,23 @@ xglxCreateARGBCursor (ScreenPtr pScreen, pCursor->bits->width, pCursor->bits->height, 32, pCursor->bits->width * 4); - + XPutImage (xdisplay, xpixmap, xgc, ximage, 0, 0, 0, 0, pCursor->bits->width, pCursor->bits->height); - + XFree (ximage); XFreeGC (xdisplay, xgc); - + xformat = XRenderFindStandardFormat (xdisplay, PictStandardARGB32); xpicture = XRenderCreatePicture (xdisplay, xpixmap, xformat, 0, 0); cursor = XRenderCreateCursor (xdisplay, xpicture, pCursor->bits->xhot, pCursor->bits->yhot); - + XRenderFreePicture (xdisplay, xpicture); XFreePixmap (xdisplay, xpixmap); - + return cursor; } diff --git a/hw/xgl/glx/xglx.h b/hw/xgl/glx/xglx.h index cb2ea2af1..b0c5d3d70 100644 --- a/hw/xgl/glx/xglx.h +++ b/hw/xgl/glx/xglx.h @@ -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_ */ diff --git a/hw/xgl/glx/xglxinit.c b/hw/xgl/glx/xglxinit.c index 0376133bb..50bbca52b 100644 --- a/hw/xgl/glx/xglxinit.c +++ b/hw/xgl/glx/xglxinit.c @@ -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() { } diff --git a/hw/xgl/glx/xglxorg.c b/hw/xgl/glx/xglxorg.c new file mode 100644 index 000000000..984c50ee2 --- /dev/null +++ b/hw/xgl/glx/xglxorg.c @@ -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 diff --git a/hw/xgl/glxext/Makefile.am b/hw/xgl/glxext/Makefile.am index 53d5fe841..f9b9c0d68 100644 --- a/hw/xgl/glxext/Makefile.am +++ b/hw/xgl/glxext/Makefile.am @@ -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) diff --git a/hw/xgl/glxext/module/Makefile.am b/hw/xgl/glxext/module/Makefile.am index 8272ae514..660838dd9 100644 --- a/hw/xgl/glxext/module/Makefile.am +++ b/hw/xgl/glxext/module/Makefile.am @@ -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,11 +12,11 @@ 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) \ - $(libglx_modules)
\ No newline at end of file + $(libglx_modules) diff --git a/hw/xgl/glxext/xglglxext.c b/hw/xgl/glxext/xglglxext.c index 3a9c4cc14..c260d8e2d 100644 --- a/hw/xgl/glxext/xglglxext.c +++ b/hw/xgl/glxext/xglglxext.c @@ -12,11 +12,11 @@ * software for any purpose. It is provided "as is" without express or * implied warranty. * - * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * 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, + * 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. * @@ -24,6 +24,7 @@ */ #include "xgl.h" +#include "xglglx.h" #include "xglglxext.h" #include <GL/gl.h> @@ -36,10 +37,12 @@ #include "glxutil.h" #include "unpack.h" #include "g_disptab.h" +#include "glapitable.h" #include "glxext.h" #include "micmap.h" -#define XGL_MAX_TEXTURE_UNITS 8 +#define XGL_MAX_TEXTURE_UNITS 8 +#define XGL_MAX_ATTRIB_STACK_DEPTH 16 #define XGL_TEXTURE_1D_BIT (1 << 0) #define XGL_TEXTURE_2D_BIT (1 << 1) @@ -64,15 +67,17 @@ typedef struct _xglGLXScreenInfo { GLXCreateBufferProc createBuffer; } xglGLXScreenInfoRec, *xglGLXScreenInfoPtr; +extern __GLXscreenInfo *__xglScreenInfoPtr; + static xglGLXScreenInfoRec screenInfoPriv; -extern __GLXscreenInfo __glDDXScreenInfo; +//extern __GLXscreenInfo __glDDXScreenInfo; typedef GLboolean (*GLResizeBuffersProc) (__GLdrawableBuffer *buffer, GLint x, GLint y, GLuint width, - GLuint height, + GLuint height, __GLdrawablePrivate *glPriv, GLuint bufferMask); typedef void (*GLFreeBuffersProc) (__GLdrawablePrivate *glPriv); @@ -85,11 +90,14 @@ typedef struct _xglGLBuffer { GLFreeBuffersProc freeBuffers; ScreenPtr pScreen; DrawablePtr pDrawable; + xglVisualPtr pVisual; + glitz_drawable_t *drawable; glitz_surface_t *backSurface; PixmapPtr pPixmap; GCPtr pGC; RegionRec damage; void *private; + int screenX, screenY; int xOff, yOff; int yFlip; } xglGLBufferRec, *xglGLBufferPtr; @@ -137,7 +145,7 @@ typedef struct _xglGLOp { GLint x; GLint y; GLsizei width; - GLint border; + GLint border; } copy_tex_image_1d; struct { GLenum target; @@ -147,7 +155,7 @@ typedef struct _xglGLOp { GLint y; GLsizei width; GLsizei height; - GLint border; + GLint border; } copy_tex_image_2d; struct { GLenum target; @@ -155,7 +163,7 @@ typedef struct _xglGLOp { GLint xoffset; GLint x; GLint y; - GLsizei width; + GLsizei width; } copy_tex_sub_image_1d; struct { GLenum target; @@ -165,7 +173,7 @@ typedef struct _xglGLOp { GLint x; GLint y; GLsizei width; - GLsizei height; + GLsizei height; } copy_tex_sub_image_2d; struct { GLenum target; @@ -262,14 +270,15 @@ typedef struct _xglGLContext { int refcnt; struct _xglGLContext *shared; glitz_context_t *context; - __glProcTableEXT glRenderTableEXT; + struct _glapi_table glRenderTable; PFNGLACTIVETEXTUREARBPROC ActiveTextureARB; PFNGLWINDOWPOS3FMESAPROC WindowPos3fMESA; Bool needInit; xglGLBufferPtr pDrawBuffer; xglGLBufferPtr pReadBuffer; - GLuint fbo; int drawXoff, drawYoff; + __GLdrawablePrivate *readPriv; + __GLdrawablePrivate *drawPriv; char *versionString; GLenum errorValue; GLboolean doubleBuffer; @@ -279,33 +288,52 @@ typedef struct _xglGLContext { xglHashTablePtr displayLists; GLuint list; GLenum listMode; + GLuint beginCnt; xglDisplayListPtr pList; GLuint groupList; xglGLAttributesRec attrib; - xglGLAttributesPtr pAttribStack; + xglGLAttributesRec attribStack[XGL_MAX_ATTRIB_STACK_DEPTH]; int nAttribStack; int activeTexUnit; GLint maxTexUnits; GLint maxListNesting; + GLint maxAttribStackDepth; } xglGLContextRec, *xglGLContextPtr; static xglGLContextPtr cctx = NULL; -//static void -//xglSetCurrentContext (xglGLContextPtr pContext, glitz_drawable_t *drawable); static void xglSetCurrentContext (xglGLContextPtr pContext); +#define XGL_GLX_DRAW_PROLOGUE_WITHOUT_TEXTURES(pBox, nBox, pScissorBox) \ + (pBox) = REGION_RECTS (cctx->pDrawBuffer->pGC->pCompositeClip); \ + (nBox) = REGION_NUM_RECTS (cctx->pDrawBuffer->pGC->pCompositeClip); \ + (pScissorBox)->x1 = cctx->attrib.scissor.x + cctx->pDrawBuffer->xOff; \ + (pScissorBox)->x2 = (pScissorBox)->x1 + cctx->attrib.scissor.width; \ + (pScissorBox)->y2 = cctx->attrib.scissor.y + cctx->pDrawBuffer->yOff; \ + (pScissorBox)->y2 = cctx->pDrawBuffer->yFlip - (pScissorBox)->y2; \ + (pScissorBox)->y1 = (pScissorBox)->y2 - cctx->attrib.scissor.height + +#define XGL_GLX_DRAW_PROLOGUE(pBox, nBox, pScissorBox) \ + XGL_GLX_DRAW_PROLOGUE_WITHOUT_TEXTURES (pBox, nBox, pScissorBox); \ + xglSetupTextures () + +#define XGL_GLX_DRAW_BOX(pBox1, pBox2) \ + (pBox1)->x1 = cctx->pDrawBuffer->screenX + (pBox2)->x1; \ + (pBox1)->y1 = cctx->pDrawBuffer->screenY + (pBox2)->y1; \ + (pBox1)->x2 = cctx->pDrawBuffer->screenX + (pBox2)->x2; \ + (pBox1)->y2 = cctx->pDrawBuffer->screenY + (pBox2)->y2 + #define XGL_GLX_INTERSECT_BOX(pBox1, pBox2) \ { \ - if ((pBox1)->x1 < (pBox2)->x1) \ - (pBox1)->x1 = (pBox2)->x1; \ - if ((pBox1)->y1 < (pBox2)->y1) \ - (pBox1)->y1 = (pBox2)->y1; \ - if ((pBox1)->x2 > (pBox2)->x2) \ - (pBox1)->x2 = (pBox2)->x2; \ - if ((pBox1)->y2 > (pBox2)->y2) \ - (pBox1)->y2 = (pBox2)->y2; \ + if ((pBox1)->x1 < (pBox2)->x1) \ + (pBox1)->x1 = (pBox2)->x1; \ + if ((pBox1)->y1 < (pBox2)->y1) \ + (pBox1)->y1 = (pBox2)->y1; \ + if ((pBox1)->x2 > (pBox2)->x2) \ + (pBox1)->x2 = (pBox2)->x2; \ + if ((pBox1)->y2 > (pBox2)->y2) \ + (pBox1)->y2 = (pBox2)->y2; \ } #define XGL_GLX_SET_SCISSOR_BOX(pBox) \ @@ -314,27 +342,19 @@ xglSetCurrentContext (xglGLContextPtr pContext); (pBox)->x2 - (pBox)->x1, \ (pBox)->y2 - (pBox)->y1) -#define XGL_GLX_DRAW_PROLOGUE(pBox, nBox, pScissorBox) \ - (pBox) = REGION_RECTS (cctx->pDrawBuffer->pGC->pCompositeClip); \ - (nBox) = REGION_NUM_RECTS (cctx->pDrawBuffer->pGC->pCompositeClip); \ - (pScissorBox)->x1 = cctx->attrib.scissor.x + cctx->pDrawBuffer->xOff; \ - (pScissorBox)->x2 = (pScissorBox)->x1 + cctx->attrib.scissor.width; \ - (pScissorBox)->y2 = cctx->attrib.scissor.y + cctx->pDrawBuffer->yOff; \ - (pScissorBox)->y2 = cctx->pDrawBuffer->yFlip - (pScissorBox)->y2; \ - (pScissorBox)->y1 = (pScissorBox)->y2 - cctx->attrib.scissor.height; \ - xglSetupTextures () - #define XGL_GLX_DRAW_DAMAGE(pBox, pRegion) \ - if (cctx->attrib.drawBuffer != GL_BACK && \ - cctx->pDrawBuffer->pDrawable && \ - cctx->pDrawBuffer->pDrawable->type != DRAWABLE_PIXMAP) \ + if (cctx->attrib.drawBuffer != GL_BACK) \ { \ - REGION_INIT (cctx->pDrawBuffer->pGC->pScreen, pRegion, pBox, 1); \ + (pRegion)->extents.x1 = (pBox)->x1 - cctx->pDrawBuffer->screenX; \ + (pRegion)->extents.y1 = (pBox)->y1 - cctx->pDrawBuffer->screenY; \ + (pRegion)->extents.x2 = (pBox)->x2 - cctx->pDrawBuffer->screenX; \ + (pRegion)->extents.y2 = (pBox)->y2 - cctx->pDrawBuffer->screenY; \ + (pRegion)->data = (RegDataPtr) NULL; \ REGION_UNION (cctx->pDrawBuffer->pGC->pScreen, \ &cctx->pDrawBuffer->damage, \ &cctx->pDrawBuffer->damage, \ pRegion); \ - REGION_UNINIT (cctx->pDrawBuffer->pGC->pScreen, pRegion); \ + xglAddBitDamage (cctx->pDrawBuffer->pDrawable, pRegion); \ } static void @@ -348,14 +368,14 @@ static xglDisplayListPtr xglCreateList (void) { xglDisplayListPtr pDisplayList; - + pDisplayList = xalloc (sizeof (xglDisplayListRec)); if (!pDisplayList) return NULL; - - pDisplayList->pOp = NULL; - pDisplayList->nOp = 0; - pDisplayList->size = 0; + + pDisplayList->pOp = NULL; + pDisplayList->nOp = 0; + pDisplayList->size = 0; return pDisplayList; } @@ -372,17 +392,17 @@ xglDestroyList (xglDisplayListPtr pDisplayList) case XGL_LIST_OP_CALLS: case XGL_LIST_OP_DRAW: glDeleteLists (pOp->u.list, 1); - break; + break; case XGL_LIST_OP_GL: xfree (pOp->u.gl); break; case XGL_LIST_OP_LIST: break; } - + pOp++; } - + if (pDisplayList->pOp) xfree (pDisplayList->pOp); @@ -399,12 +419,12 @@ xglResizeList (xglDisplayListPtr pDisplayList, while (size < nOp) size <<= 1; - + pDisplayList->pOp = xrealloc (pDisplayList->pOp, sizeof (xglListOpRec) * size); if (!pDisplayList->pOp) return FALSE; - + pDisplayList->size = size; } @@ -420,7 +440,7 @@ xglStartList (int type, xglRecordError (GL_OUT_OF_MEMORY); return; } - + cctx->pList->pOp[cctx->pList->nOp].type = type; cctx->pList->pOp[cctx->pList->nOp].u.list = glGenLists (1); @@ -442,7 +462,7 @@ xglGLOp (xglGLOpPtr pOp) xglRecordError (GL_OUT_OF_MEMORY); return; } - + if (!xglResizeList (cctx->pList, cctx->pList->nOp + 1)) { xfree (pGLOp); @@ -453,7 +473,7 @@ xglGLOp (xglGLOpPtr pOp) glEndList (); *pGLOp = *pOp; - + cctx->pList->pOp[cctx->pList->nOp].type = XGL_LIST_OP_GL; cctx->pList->pOp[cctx->pList->nOp].u.gl = pGLOp; cctx->pList->nOp++; @@ -464,7 +484,7 @@ xglGLOp (xglGLOpPtr pOp) xglStartList (XGL_LIST_OP_CALLS, cctx->listMode); } else - (*pOp->glProc) (pOp); + (*pOp->glProc) (pOp); } static void @@ -488,7 +508,7 @@ xglViewport (GLint x, GLsizei height) { xglGLOpRec gl; - + gl.glProc = xglViewportProc; gl.u.rect.x = x; @@ -515,7 +535,7 @@ xglScissor (GLint x, GLsizei height) { xglGLOpRec gl; - + gl.glProc = xglScissorProc; gl.u.rect.x = x; @@ -529,9 +549,22 @@ xglScissor (GLint x, static void xglDrawBufferProc (xglGLOpPtr pOp) { + glitz_drawable_buffer_t buffers[2]; + switch (pOp->u.enumeration) { case GL_FRONT: + buffers[0] = GLITZ_DRAWABLE_BUFFER_FRONT_COLOR; + glitz_context_draw_buffers (cctx->context, buffers, 1); + break; case GL_FRONT_AND_BACK: + buffers[0] = GLITZ_DRAWABLE_BUFFER_FRONT_COLOR; + if (cctx->doubleBuffer) + { + buffers[1] = GLITZ_DRAWABLE_BUFFER_BACK_COLOR; + glitz_context_draw_buffers (cctx->context, buffers, 2); + } + else + glitz_context_draw_buffers (cctx->context, buffers, 1); break; case GL_BACK: if (!cctx->doubleBuffer) @@ -539,22 +572,22 @@ xglDrawBufferProc (xglGLOpPtr pOp) xglRecordError (GL_INVALID_OPERATION); return; } + buffers[0] = GLITZ_DRAWABLE_BUFFER_BACK_COLOR; + glitz_context_draw_buffers (cctx->context, buffers, 1); break; default: xglRecordError (GL_INVALID_ENUM); return; } - + cctx->attrib.drawBuffer = pOp->u.enumeration; - - glDrawBuffer (pOp->u.enumeration); } static void xglDrawBuffer (GLenum mode) { xglGLOpRec gl; - + gl.glProc = xglDrawBufferProc; gl.u.enumeration = mode; @@ -567,6 +600,8 @@ xglReadBufferProc (xglGLOpPtr pOp) { switch (pOp->u.enumeration) { case GL_FRONT: + glitz_context_read_buffer (cctx->context, + GLITZ_DRAWABLE_BUFFER_FRONT_COLOR); break; case GL_BACK: if (!cctx->doubleBuffer) @@ -574,22 +609,22 @@ xglReadBufferProc (xglGLOpPtr pOp) xglRecordError (GL_INVALID_OPERATION); return; } + glitz_context_read_buffer (cctx->context, + GLITZ_DRAWABLE_BUFFER_BACK_COLOR); break; default: xglRecordError (GL_INVALID_ENUM); return; } - + cctx->attrib.readBuffer = pOp->u.enumeration; - - glReadBuffer (pOp->u.enumeration); } static void xglReadBuffer (GLenum mode) { xglGLOpRec gl; - + gl.glProc = xglReadBufferProc; gl.u.enumeration = mode; @@ -601,7 +636,7 @@ static void xglDisableProc (xglGLOpPtr pOp) { xglTexUnitPtr pTexUnit = &cctx->attrib.texUnits[cctx->activeTexUnit]; - + switch (pOp->u.enumeration) { case GL_SCISSOR_TEST: cctx->attrib.scissorTest = GL_FALSE; @@ -632,7 +667,7 @@ static void xglDisable (GLenum cap) { xglGLOpRec gl; - + gl.glProc = xglDisableProc; gl.u.enumeration = cap; @@ -644,7 +679,7 @@ static void xglEnableProc (xglGLOpPtr pOp) { xglTexUnitPtr pTexUnit = &cctx->attrib.texUnits[cctx->activeTexUnit]; - + switch (pOp->u.enumeration) { case GL_SCISSOR_TEST: cctx->attrib.scissorTest = GL_TRUE; @@ -681,7 +716,7 @@ static void xglEnable (GLenum cap) { xglGLOpRec gl; - + gl.glProc = xglEnableProc; gl.u.enumeration = cap; @@ -697,7 +732,7 @@ xglDeleteTexObj (xglTexObjPtr pTexObj) ScreenPtr pScreen = pTexObj->pPixmap->drawable.pScreen; (*pScreen->DestroyPixmap) (pTexObj->pPixmap); - + glitz_texture_object_destroy (pTexObj->object); } @@ -717,7 +752,7 @@ xglRefTexObj (xglTexObjPtr pTexObj) { if (!pTexObj) return; - + pTexObj->refcnt++; } @@ -726,7 +761,7 @@ xglUnrefTexObj (xglTexObjPtr pTexObj) { if (!pTexObj) return; - + pTexObj->refcnt--; if (pTexObj->refcnt) return; @@ -740,35 +775,22 @@ static void xglPushAttribProc (xglGLOpPtr pOp) { xglGLAttributesPtr pAttrib; - GLint depth; - - glGetIntegerv (GL_MAX_ATTRIB_STACK_DEPTH, &depth); - - if (cctx->nAttribStack == depth) + + if (cctx->nAttribStack == cctx->maxAttribStackDepth) { xglRecordError (GL_STACK_OVERFLOW); return; } - - cctx->pAttribStack = - realloc (cctx->pAttribStack, - sizeof (xglGLAttributesRec) * (cctx->nAttribStack + 1)); - - if (!cctx->pAttribStack) - { - xglRecordError (GL_OUT_OF_MEMORY); - return; - } - pAttrib = &cctx->pAttribStack[cctx->nAttribStack]; - pAttrib->mask = pOp->u.bitfield; - + pAttrib = &cctx->attribStack[cctx->nAttribStack]; + *pAttrib = cctx->attrib; - + pAttrib->mask = pOp->u.bitfield; + if (pOp->u.bitfield & GL_TEXTURE_BIT) { int i; - + for (i = 0; i < cctx->maxTexUnits; i++) { xglRefTexObj (pAttrib->texUnits[i].p1D); @@ -778,9 +800,9 @@ xglPushAttribProc (xglGLOpPtr pOp) xglRefTexObj (pAttrib->texUnits[i].pCubeMap); } } - + cctx->nAttribStack++; - + glPushAttrib (pOp->u.bitfield); } @@ -788,7 +810,7 @@ static void xglPushAttrib (GLbitfield mask) { xglGLOpRec gl; - + gl.glProc = xglPushAttribProc; gl.u.bitfield = mask; @@ -801,7 +823,7 @@ xglPopAttribProc (xglGLOpPtr pOp) { xglGLAttributesPtr pAttrib; GLbitfield mask; - + if (!cctx->nAttribStack) { xglRecordError (GL_STACK_UNDERFLOW); @@ -809,16 +831,16 @@ xglPopAttribProc (xglGLOpPtr pOp) } cctx->nAttribStack--; - - pAttrib = &cctx->pAttribStack[cctx->nAttribStack]; + + pAttrib = &cctx->attribStack[cctx->nAttribStack]; mask = pAttrib->mask; if (mask & GL_COLOR_BUFFER_BIT) xglDrawBuffer (pAttrib->drawBuffer); - + if (mask & GL_PIXEL_MODE_BIT) xglReadBuffer (pAttrib->readBuffer); - + if (mask & GL_SCISSOR_BIT) { xglScissor (pAttrib->scissor.x, @@ -838,7 +860,7 @@ xglPopAttribProc (xglGLOpPtr pOp) else xglDisable (GL_SCISSOR_TEST); } - + if (mask & GL_VIEWPORT_BIT) xglViewport (pAttrib->viewport.x, pAttrib->viewport.y, @@ -848,7 +870,7 @@ xglPopAttribProc (xglGLOpPtr pOp) if (mask & GL_TEXTURE_BIT) { int i; - + for (i = 0; i < cctx->maxTexUnits; i++) { xglUnrefTexObj (cctx->attrib.texUnits[i].p1D); @@ -863,15 +885,11 @@ xglPopAttribProc (xglGLOpPtr pOp) else if (mask & GL_ENABLE_BIT) { int i; - + for (i = 0; i < cctx->maxTexUnits; i++) - cctx->attrib.texUnits[i].enabled = pAttrib->texUnits[i].enabled; + cctx->attrib.texUnits[i].enabled = pAttrib->texUnits[i].enabled; } - - cctx->pAttribStack = - realloc (cctx->pAttribStack, - sizeof (xglGLAttributesRec) * cctx->nAttribStack); - + glPopAttrib (); } @@ -879,7 +897,7 @@ static void xglPopAttrib (void) { xglGLOpRec gl; - + gl.glProc = xglPopAttribProc; xglGLOp (&gl); @@ -889,7 +907,7 @@ static GLuint xglActiveTextureBinding (GLenum target) { xglTexObjPtr pTexObj; - + switch (target) { case GL_TEXTURE_BINDING_1D: pTexObj = cctx->attrib.texUnits[cctx->activeTexUnit].p1D; @@ -912,7 +930,7 @@ xglActiveTextureBinding (GLenum target) if (pTexObj) return pTexObj->key; - + return 0; } @@ -928,7 +946,7 @@ xglGetBooleanv (GLenum pname, case GL_CURRENT_RASTER_POSITION: { GLdouble v[4]; - + glGetDoublev (GL_CURRENT_RASTER_POSITION, v); params[0] = DOUBLE_TO_BOOLEAN (v[0] - (GLdouble) cctx->drawXoff); @@ -955,7 +973,7 @@ xglGetBooleanv (GLenum pname, params[0] = INT_TO_BOOLEAN (cctx->attrib.scissor.x); params[1] = INT_TO_BOOLEAN (cctx->attrib.scissor.y); params[2] = INT_TO_BOOLEAN (cctx->attrib.scissor.width); - params[3] = INT_TO_BOOLEAN (cctx->attrib.scissor.height); + params[3] = INT_TO_BOOLEAN (cctx->attrib.scissor.height); break; case GL_SCISSOR_TEST: params[0] = cctx->attrib.scissorTest; @@ -969,7 +987,8 @@ xglGetBooleanv (GLenum pname, case GL_TEXTURE_BINDING_1D: case GL_TEXTURE_BINDING_2D: case GL_TEXTURE_BINDING_3D: - case GL_TEXTURE_RECTANGLE_NV: + case GL_TEXTURE_BINDING_RECTANGLE_NV: + case GL_TEXTURE_BINDING_CUBE_MAP_ARB: /* should be safe to fall-through here */ default: glGetBooleanv (pname, params); @@ -1010,7 +1029,7 @@ xglGetDoublev (GLenum pname, params[0] = cctx->attrib.scissor.x; params[1] = cctx->attrib.scissor.y; params[2] = cctx->attrib.scissor.width; - params[3] = cctx->attrib.scissor.height; + params[3] = cctx->attrib.scissor.height; break; case GL_SCISSOR_TEST: params[0] = BOOLEAN_TO_DOUBLE (cctx->attrib.scissorTest); @@ -1024,12 +1043,16 @@ xglGetDoublev (GLenum pname, case GL_TEXTURE_BINDING_1D: case GL_TEXTURE_BINDING_2D: case GL_TEXTURE_BINDING_3D: - case GL_TEXTURE_RECTANGLE_NV: + case GL_TEXTURE_BINDING_RECTANGLE_NV: + case GL_TEXTURE_BINDING_CUBE_MAP_ARB: params[0] = xglActiveTextureBinding (pname); break; case GL_MAX_TEXTURE_UNITS_ARB: params[0] = cctx->maxTexUnits; break; + case GL_MAX_ATTRIB_STACK_DEPTH: + params[0] = cctx->maxAttribStackDepth; + break; default: glGetDoublev (pname, params); } @@ -1069,7 +1092,7 @@ xglGetFloatv (GLenum pname, params[0] = cctx->attrib.scissor.x; params[1] = cctx->attrib.scissor.y; params[2] = cctx->attrib.scissor.width; - params[3] = cctx->attrib.scissor.height; + params[3] = cctx->attrib.scissor.height; break; case GL_SCISSOR_TEST: params[0] = BOOLEAN_TO_FLOAT (cctx->attrib.scissorTest); @@ -1083,12 +1106,16 @@ xglGetFloatv (GLenum pname, case GL_TEXTURE_BINDING_1D: case GL_TEXTURE_BINDING_2D: case GL_TEXTURE_BINDING_3D: - case GL_TEXTURE_RECTANGLE_NV: + case GL_TEXTURE_BINDING_RECTANGLE_NV: + case GL_TEXTURE_BINDING_CUBE_MAP_ARB: params[0] = xglActiveTextureBinding (pname); break; case GL_MAX_TEXTURE_UNITS_ARB: params[0] = cctx->maxTexUnits; break; + case GL_MAX_ATTRIB_STACK_DEPTH: + params[0] = cctx->maxAttribStackDepth; + break; default: glGetFloatv (pname, params); } @@ -1104,7 +1131,7 @@ xglGetIntegerv (GLenum pname, switch (pname) { case GL_CURRENT_RASTER_POSITION: glGetIntegerv (GL_CURRENT_RASTER_POSITION, params); - + params[0] -= (GLint) cctx->drawXoff; params[1] -= (GLint) cctx->drawYoff; break; @@ -1127,7 +1154,7 @@ xglGetIntegerv (GLenum pname, params[0] = cctx->attrib.scissor.x; params[1] = cctx->attrib.scissor.y; params[2] = cctx->attrib.scissor.width; - params[3] = cctx->attrib.scissor.height; + params[3] = cctx->attrib.scissor.height; break; case GL_SCISSOR_TEST: params[0] = BOOLEAN_TO_INT (cctx->attrib.scissorTest); @@ -1141,12 +1168,16 @@ xglGetIntegerv (GLenum pname, case GL_TEXTURE_BINDING_1D: case GL_TEXTURE_BINDING_2D: case GL_TEXTURE_BINDING_3D: - case GL_TEXTURE_RECTANGLE_NV: + case GL_TEXTURE_BINDING_RECTANGLE_NV: + case GL_TEXTURE_BINDING_CUBE_MAP_ARB: params[0] = xglActiveTextureBinding (pname); break; case GL_MAX_TEXTURE_UNITS_ARB: params[0] = cctx->maxTexUnits; break; + case GL_MAX_ATTRIB_STACK_DEPTH: + params[0] = cctx->maxAttribStackDepth; + break; default: glGetIntegerv (pname, params); } @@ -1167,7 +1198,7 @@ static GLenum xglGetError (void) { GLenum error = cctx->errorValue; - + if (error != GL_NO_ERROR) { cctx->errorValue = GL_NO_ERROR; @@ -1204,11 +1235,11 @@ xglGenTextures (GLsizei n, { xglTexObjPtr pTexObj; GLuint name; - + name = xglHashFindFreeKeyBlock (cctx->shared->texObjects, n); glGenTextures (n, textures); - + while (n--) { pTexObj = xalloc (sizeof (xglTexObjRec)); @@ -1226,7 +1257,7 @@ xglGenTextures (GLsizei n, { xglRecordError (GL_OUT_OF_MEMORY); } - + *textures++ = name++; } } @@ -1235,7 +1266,7 @@ static void xglBindTextureProc (xglGLOpPtr pOp) { xglTexObjPtr *ppTexObj; - + switch (pOp->u.bind_texture.target) { case GL_TEXTURE_1D: ppTexObj = &cctx->attrib.texUnits[cctx->activeTexUnit].p1D; @@ -1256,45 +1287,49 @@ xglBindTextureProc (xglGLOpPtr pOp) xglRecordError (GL_INVALID_ENUM); return; } - + if (pOp->u.bind_texture.texture) { - xglTexObjPtr pTexObj; - - pTexObj = (xglTexObjPtr) xglHashLookup (cctx->shared->texObjects, - pOp->u.bind_texture.texture); - if (!pTexObj) + if (!*ppTexObj || pOp->u.bind_texture.texture != (*ppTexObj)->key) { - pTexObj = xalloc (sizeof (xglTexObjRec)); + xglTexObjPtr pTexObj; + + pTexObj = (xglTexObjPtr) + xglHashLookup (cctx->shared->texObjects, + pOp->u.bind_texture.texture); if (!pTexObj) { - xglRecordError (GL_OUT_OF_MEMORY); - return; - } + pTexObj = xalloc (sizeof (xglTexObjRec)); + if (!pTexObj) + { + xglRecordError (GL_OUT_OF_MEMORY); + return; + } - pTexObj->key = pOp->u.bind_texture.texture; - pTexObj->pPixmap = NULL; - pTexObj->object = NULL; - pTexObj->refcnt = 1; + pTexObj->key = pOp->u.bind_texture.texture; + pTexObj->pPixmap = NULL; + pTexObj->object = NULL; + pTexObj->refcnt = 1; - glGenTextures (1, &pTexObj->name); - - xglHashInsert (cctx->shared->texObjects, - pOp->u.bind_texture.texture, - pTexObj); - } + glGenTextures (1, &pTexObj->name); - xglRefTexObj (pTexObj); - xglUnrefTexObj (*ppTexObj); - *ppTexObj = pTexObj; + xglHashInsert (cctx->shared->texObjects, + pOp->u.bind_texture.texture, + pTexObj); + } - glBindTexture (pOp->u.bind_texture.target, pTexObj->name); + xglRefTexObj (pTexObj); + xglUnrefTexObj (*ppTexObj); + *ppTexObj = pTexObj; + + glBindTexture (pOp->u.bind_texture.target, pTexObj->name); + } } else { xglUnrefTexObj (*ppTexObj); *ppTexObj = NULL; - + glBindTexture (pOp->u.bind_texture.target, 0); } } @@ -1304,12 +1339,12 @@ xglBindTexture (GLenum target, GLuint texture) { xglGLOpRec gl; - + gl.glProc = xglBindTextureProc; gl.u.bind_texture.target = target; gl.u.bind_texture.texture = texture; - + xglGLOp (&gl); } @@ -1377,13 +1412,13 @@ xglAreTexturesResident (GLsizei n, { GLboolean allResident = GL_TRUE; int i, j; - + if (n < 0) { xglRecordError (GL_INVALID_VALUE); return GL_FALSE; } - + if (!textures || !residences) return GL_FALSE; @@ -1391,8 +1426,8 @@ xglAreTexturesResident (GLsizei n, { xglTexObjPtr pTexObj; GLboolean resident; - - if (textures[i] == 0) + + if (!textures[i]) { xglRecordError (GL_INVALID_VALUE); return GL_FALSE; @@ -1405,7 +1440,7 @@ xglAreTexturesResident (GLsizei n, xglRecordError (GL_INVALID_VALUE); return GL_FALSE; } - + if (pTexObj->name == 0 || glAreTexturesResident (1, &pTexObj->name, &resident)) { @@ -1424,7 +1459,7 @@ xglAreTexturesResident (GLsizei n, residences[i] = GL_FALSE; } } - + return allResident; } @@ -1433,9 +1468,12 @@ xglDeleteTextures (GLsizei n, const GLuint *textures) { xglTexObjPtr pTexObj; - + while (n--) { + if (!*textures) + continue; + pTexObj = (xglTexObjPtr) xglHashLookup (cctx->shared->texObjects, *textures); if (pTexObj) @@ -1455,7 +1493,7 @@ xglIsTexture (GLuint texture) if (!texture) return GL_FALSE; - + pTexObj = (xglTexObjPtr) xglHashLookup (cctx->shared->texObjects, texture); if (pTexObj) return GL_TRUE; @@ -1470,21 +1508,21 @@ xglPrioritizeTextures (GLsizei n, { xglTexObjPtr pTexObj; int i; - + if (n < 0) { xglRecordError (GL_INVALID_VALUE); return; } - + if (!priorities) return; for (i = 0; i < n; i++) { - if (textures[i] <= 0) + if (!textures[i]) continue; - + pTexObj = (xglTexObjPtr) xglHashLookup (cctx->shared->texObjects, textures[i]); if (pTexObj && pTexObj->name) @@ -1720,7 +1758,7 @@ xglGenLists (GLsizei range) { xglDisplayListPtr pDisplayList; GLuint first, name; - + first = xglHashFindFreeKeyBlock (cctx->shared->displayLists, range); name = first; @@ -1802,16 +1840,18 @@ xglDrawList (GLuint list) BoxRec scissor, box; BoxPtr pBox; int nBox; - + XGL_GLX_DRAW_PROLOGUE (pBox, nBox, &scissor); while (nBox--) { - box = *pBox++; + XGL_GLX_DRAW_BOX (&box, pBox); + + pBox++; if (cctx->attrib.scissorTest) XGL_GLX_INTERSECT_BOX (&box, &scissor); - + if (box.x1 < box.x2 && box.y1 < box.y2) { XGL_GLX_SET_SCISSOR_BOX (&box); @@ -1835,7 +1875,7 @@ xglCallDisplayList (GLuint list, xglRecordError (GL_INVALID_VALUE); return; } - + if (cctx->list) { if (!xglResizeList (cctx->pList, cctx->pList->nOp + 1)) @@ -1858,7 +1898,7 @@ xglCallDisplayList (GLuint list, { xglListOpPtr pOp = pDisplayList->pOp; int nOp = pDisplayList->nOp; - + while (nOp--) { switch (pOp->type) { @@ -1946,7 +1986,7 @@ xglCallLists (GLsizei n, xglRecordError (GL_INVALID_ENUM); return; } - + xglCallDisplayList (base + list, 1); } } @@ -1957,20 +1997,23 @@ xglDeleteLists (GLuint list, { xglDisplayListPtr pDisplayList; GLint i; - + if (range < 0) { xglRecordError (GL_INVALID_VALUE); return; } - - for (i = 0; i < range; i++) + + for (i = list; i < list + range; i++) { + if (!i) + continue; + pDisplayList = (xglDisplayListPtr) - xglHashLookup (cctx->shared->displayLists, list + i); + xglHashLookup (cctx->shared->displayLists, i); if (pDisplayList) { - xglHashRemove (cctx->shared->displayLists, list + i); + xglHashRemove (cctx->shared->displayLists, i); xglDestroyList (pDisplayList); } } @@ -1983,7 +2026,7 @@ xglIsList (GLuint list) if (!list) return GL_FALSE; - + pDisplayList = (xglDisplayListPtr) xglHashLookup (cctx->shared->displayLists, list); if (pDisplayList) @@ -1997,15 +2040,18 @@ xglFlush (void) { glFlush (); - if (cctx->pDrawBuffer->pDrawable) + if (cctx && cctx->pDrawBuffer->pDrawable) { xglGLBufferPtr pBuffer = cctx->pDrawBuffer; - + if (REGION_NOTEMPTY (pBuffer->pDrawable->pScreen, &pBuffer->damage)) { - xglAddBitDamage (pBuffer->pDrawable, &pBuffer->damage); + XGL_DRAWABLE_PIXMAP_PRIV (pBuffer->pDrawable); + DamageDamageRegion (pBuffer->pDrawable, &pBuffer->damage); REGION_EMPTY (pBuffer->pDrawable->pScreen, &pBuffer->damage); + + pPixmapPriv->damageBox = miEmptyBox; } } } @@ -2015,15 +2061,18 @@ xglFinish (void) { glFinish (); - if (cctx->pDrawBuffer->pDrawable) + if (cctx && cctx->pDrawBuffer->pDrawable) { xglGLBufferPtr pBuffer = cctx->pDrawBuffer; - + if (REGION_NOTEMPTY (pBuffer->pDrawable->pScreen, &pBuffer->damage)) { - xglAddBitDamage (pBuffer->pDrawable, &pBuffer->damage); + XGL_DRAWABLE_PIXMAP_PRIV (pBuffer->pDrawable); + DamageDamageRegion (pBuffer->pDrawable, &pBuffer->damage); REGION_EMPTY (pBuffer->pDrawable->pScreen, &pBuffer->damage); + + pPixmapPriv->damageBox = miEmptyBox; } } } @@ -2032,14 +2081,14 @@ static void xglClear (GLbitfield mask) { GLenum mode; - + if (cctx->list) { glEndList (); xglStartList (XGL_LIST_OP_DRAW, GL_COMPILE); glClear (mask); glEndList (); - + mode = cctx->listMode; } else @@ -2051,22 +2100,24 @@ xglClear (GLbitfield mask) BoxRec scissor, box; BoxPtr pBox; int nBox; - - XGL_GLX_DRAW_PROLOGUE (pBox, nBox, &scissor); + + XGL_GLX_DRAW_PROLOGUE_WITHOUT_TEXTURES (pBox, nBox, &scissor); while (nBox--) { - box = *pBox++; - + XGL_GLX_DRAW_BOX (&box, pBox); + + pBox++; + if (cctx->attrib.scissorTest) XGL_GLX_INTERSECT_BOX (&box, &scissor); - + if (box.x1 < box.x2 && box.y1 < box.y2) { XGL_GLX_SET_SCISSOR_BOX (&box); glClear (mask); - + if (mask & GL_COLOR_BUFFER_BIT) XGL_GLX_DRAW_DAMAGE (&box, ®ion); } @@ -2084,46 +2135,48 @@ xglAccum (GLenum op, if (op == GL_RETURN) { GLenum listMode; - + if (cctx->list) { glEndList (); xglStartList (XGL_LIST_OP_DRAW, GL_COMPILE); glAccum (GL_RETURN, value); glEndList (); - + listMode = cctx->listMode; } else listMode = GL_COMPILE_AND_EXECUTE; - + if (listMode == GL_COMPILE_AND_EXECUTE) { RegionRec region; BoxRec scissor, box; BoxPtr pBox; int nBox; - - XGL_GLX_DRAW_PROLOGUE (pBox, nBox, &scissor); - + + XGL_GLX_DRAW_PROLOGUE_WITHOUT_TEXTURES (pBox, nBox, &scissor); + while (nBox--) { - box = *pBox++; - + XGL_GLX_DRAW_BOX (&box, pBox); + + pBox++; + if (cctx->attrib.scissorTest) XGL_GLX_INTERSECT_BOX (&box, &scissor); - + if (box.x1 < box.x2 && box.y1 < box.y2) { XGL_GLX_SET_SCISSOR_BOX (&box); glAccum (GL_RETURN, value); - + XGL_GLX_DRAW_DAMAGE (&box, ®ion); } } } - + if (cctx->list) xglStartList (XGL_LIST_OP_CALLS, cctx->listMode); } @@ -2137,41 +2190,43 @@ xglDrawArrays (GLenum mode, GLsizei count) { GLenum listMode; - + if (cctx->list) { glEndList (); xglStartList (XGL_LIST_OP_DRAW, GL_COMPILE); glDrawArrays (mode, first, count); glEndList (); - + listMode = cctx->listMode; } else listMode = GL_COMPILE_AND_EXECUTE; - + if (listMode == GL_COMPILE_AND_EXECUTE) { RegionRec region; BoxRec scissor, box; BoxPtr pBox; int nBox; - + XGL_GLX_DRAW_PROLOGUE (pBox, nBox, &scissor); - + while (nBox--) { - box = *pBox++; - + XGL_GLX_DRAW_BOX (&box, pBox); + + pBox++; + if (cctx->attrib.scissorTest) XGL_GLX_INTERSECT_BOX (&box, &scissor); - + if (box.x1 < box.x2 && box.y1 < box.y2) { XGL_GLX_SET_SCISSOR_BOX (&box); glDrawArrays (mode, first, count); - + XGL_GLX_DRAW_DAMAGE (&box, ®ion); } } @@ -2188,41 +2243,43 @@ xglDrawElements (GLenum mode, const GLvoid *indices) { GLenum listMode; - + if (cctx->list) { glEndList (); xglStartList (XGL_LIST_OP_DRAW, GL_COMPILE); glDrawElements (mode, count, type, indices); glEndList (); - + listMode = cctx->listMode; } else listMode = GL_COMPILE_AND_EXECUTE; - + if (listMode == GL_COMPILE_AND_EXECUTE) { RegionRec region; BoxRec scissor, box; BoxPtr pBox; int nBox; - + XGL_GLX_DRAW_PROLOGUE (pBox, nBox, &scissor); while (nBox--) { - box = *pBox++; - + XGL_GLX_DRAW_BOX (&box, pBox); + + pBox++; + if (cctx->attrib.scissorTest) XGL_GLX_INTERSECT_BOX (&box, &scissor); - + if (box.x1 < box.x2 && box.y1 < box.y2) { XGL_GLX_SET_SCISSOR_BOX (&box); glDrawElements (mode, count, type, indices); - + XGL_GLX_DRAW_DAMAGE (&box, ®ion); } } @@ -2240,35 +2297,37 @@ xglDrawPixels (GLsizei width, const GLvoid *pixels) { GLenum listMode; - + if (cctx->list) { glEndList (); xglStartList (XGL_LIST_OP_DRAW, GL_COMPILE); glDrawPixels (width, height, format, type, pixels); glEndList (); - + listMode = cctx->listMode; } else listMode = GL_COMPILE_AND_EXECUTE; - + if (listMode == GL_COMPILE_AND_EXECUTE) { RegionRec region; BoxRec scissor, box; BoxPtr pBox; int nBox; - + XGL_GLX_DRAW_PROLOGUE (pBox, nBox, &scissor); while (nBox--) { - box = *pBox++; - + XGL_GLX_DRAW_BOX (&box, pBox); + + pBox++; + if (cctx->attrib.scissorTest) XGL_GLX_INTERSECT_BOX (&box, &scissor); - + if (box.x1 < box.x2 && box.y1 < box.y2) { XGL_GLX_SET_SCISSOR_BOX (&box); @@ -2302,39 +2361,41 @@ xglBitmap (GLsizei width, xglStartList (XGL_LIST_OP_DRAW, GL_COMPILE); glBitmap (width, height, xorig, yorig, 0, 0, bitmap); glEndList (); - + listMode = cctx->listMode; } else listMode = GL_COMPILE_AND_EXECUTE; - + if (listMode == GL_COMPILE_AND_EXECUTE && width && height) { RegionRec region; BoxRec scissor, box; BoxPtr pBox; int nBox; - + XGL_GLX_DRAW_PROLOGUE (pBox, nBox, &scissor); - + while (nBox--) { - box = *pBox++; - + XGL_GLX_DRAW_BOX (&box, pBox); + + pBox++; + if (cctx->attrib.scissorTest) XGL_GLX_INTERSECT_BOX (&box, &scissor); - + if (box.x1 < box.x2 && box.y1 < box.y2) { XGL_GLX_SET_SCISSOR_BOX (&box); glBitmap (width, height, xorig, yorig, 0, 0, bitmap); - + XGL_GLX_DRAW_DAMAGE (&box, ®ion); } } } - + if (cctx->list) xglStartList (XGL_LIST_OP_CALLS, cctx->listMode); @@ -2346,41 +2407,43 @@ xglRectdv (const GLdouble *v1, const GLdouble *v2) { GLenum listMode; - + if (cctx->list) { glEndList (); xglStartList (XGL_LIST_OP_DRAW, GL_COMPILE); glRectdv (v1, v2); glEndList (); - + listMode = cctx->listMode; } else listMode = GL_COMPILE_AND_EXECUTE; - + if (listMode == GL_COMPILE_AND_EXECUTE) { RegionRec region; BoxRec scissor, box; BoxPtr pBox; int nBox; - + XGL_GLX_DRAW_PROLOGUE (pBox, nBox, &scissor); - + while (nBox--) { - box = *pBox++; - + XGL_GLX_DRAW_BOX (&box, pBox); + + pBox++; + if (cctx->attrib.scissorTest) XGL_GLX_INTERSECT_BOX (&box, &scissor); - + if (box.x1 < box.x2 && box.y1 < box.y2) { XGL_GLX_SET_SCISSOR_BOX (&box); glRectdv (v1, v2); - + XGL_GLX_DRAW_DAMAGE (&box, ®ion); } } @@ -2438,6 +2501,20 @@ xglRectsv (const GLshort *v1, static void xglBegin (GLenum mode) { + if (mode > GL_POLYGON) + { + xglRecordError (GL_INVALID_ENUM); + return; + } + + if (cctx->beginCnt) + { + xglRecordError (GL_INVALID_OPERATION); + return; + } + + cctx->beginCnt++; + if (cctx->list) { glEndList (); @@ -2445,88 +2522,104 @@ xglBegin (GLenum mode) } else { - BoxRec scissor; - BoxPtr pBox; - int nBox; - - XGL_GLX_DRAW_PROLOGUE (pBox, nBox, &scissor); - - if (nBox == 1) + if (REGION_NUM_RECTS (cctx->pDrawBuffer->pGC->pCompositeClip) == 1) { - BoxRec box = *pBox; + BoxRec scissor, box; + BoxPtr pBox; + int nBox; + + XGL_GLX_DRAW_PROLOGUE (pBox, nBox, &scissor); + + XGL_GLX_DRAW_BOX (&box, pBox); if (cctx->attrib.scissorTest) XGL_GLX_INTERSECT_BOX (&box, &scissor); - + XGL_GLX_SET_SCISSOR_BOX (&box); } else { if (!cctx->groupList) cctx->groupList = glGenLists (1); - + glNewList (cctx->groupList, GL_COMPILE); } } - + glBegin (mode); } static void xglEnd (void) { + if (!cctx->beginCnt) + { + xglRecordError (GL_INVALID_OPERATION); + return; + } + + cctx->beginCnt--; + glEnd (); - + if (!cctx->list || cctx->listMode == GL_COMPILE_AND_EXECUTE) { RegionRec region; BoxRec scissor, box; BoxPtr pBox; int nBox; - GLuint list; - - XGL_GLX_DRAW_PROLOGUE (pBox, nBox, &scissor); - + GLuint list = 0; + if (cctx->list) { + XGL_GLX_DRAW_PROLOGUE (pBox, nBox, &scissor); + list = cctx->pList->pOp[cctx->pList->nOp - 1].u.list; } else { - if (nBox == 1) + if (REGION_NUM_RECTS (cctx->pDrawBuffer->pGC->pCompositeClip) == 1) { - box = *pBox++; - - if (cctx->attrib.scissorTest) - XGL_GLX_INTERSECT_BOX (&box, &scissor); - - XGL_GLX_DRAW_DAMAGE (&box, ®ion); - return; + XGL_GLX_DRAW_PROLOGUE_WITHOUT_TEXTURES (pBox, nBox, &scissor); + } + else + { + XGL_GLX_DRAW_PROLOGUE (pBox, nBox, &scissor); + + list = cctx->groupList; } - - list = cctx->groupList; } - glEndList (); + if (list) + glEndList (); while (nBox--) { - box = *pBox++; - + XGL_GLX_DRAW_BOX (&box, pBox); + + pBox++; + if (cctx->attrib.scissorTest) XGL_GLX_INTERSECT_BOX (&box, &scissor); - + if (box.x1 < box.x2 && box.y1 < box.y2) { - XGL_GLX_SET_SCISSOR_BOX (&box); + if (list) + { + XGL_GLX_SET_SCISSOR_BOX (&box); + + glCallList (list); + } - glCallList (list); - XGL_GLX_DRAW_DAMAGE (&box, ®ion); } } } - + else + { + glEndList (); + } + if (cctx->list) xglStartList (XGL_LIST_OP_CALLS, cctx->listMode); } @@ -2543,11 +2636,13 @@ xglCopyPixelsProc (xglGLOpPtr pOp) while (nBox--) { - box = *pBox++; - + XGL_GLX_DRAW_BOX (&box, pBox); + + pBox++; + if (cctx->attrib.scissorTest) XGL_GLX_INTERSECT_BOX (&box, &scissor); - + if (box.x1 < box.x2 && box.y1 < box.y2) { XGL_GLX_SET_SCISSOR_BOX (&box); @@ -2581,7 +2676,7 @@ xglCopyPixels (GLint x, gl.u.copy_pixels.height = height; gl.u.copy_pixels.type = type; - xglGLOp (&gl); + xglGLOp (&gl); } static void @@ -2620,9 +2715,9 @@ xglCopyTexImage1D (GLenum target, GLint border) { xglGLOpRec gl; - + gl.glProc = xglCopyTexImage1DProc; - + gl.u.copy_tex_image_1d.target = target; gl.u.copy_tex_image_1d.level = level; gl.u.copy_tex_image_1d.internalformat = internalformat; @@ -2658,7 +2753,7 @@ xglCopyTexImage2D (GLenum target, GLint border) { xglGLOpRec gl; - + gl.glProc = xglCopyTexImage2DProc; gl.u.copy_tex_image_2d.target = target; @@ -2695,9 +2790,9 @@ xglCopyTexSubImage1D (GLenum target, GLsizei width) { xglGLOpRec gl; - + gl.glProc = xglCopyTexSubImage1DProc; - + gl.u.copy_tex_sub_image_1d.target = target; gl.u.copy_tex_sub_image_1d.level = level; gl.u.copy_tex_sub_image_1d.xoffset = xoffset; @@ -2734,7 +2829,7 @@ xglCopyTexSubImage2D (GLenum target, GLsizei height) { xglGLOpRec gl; - + gl.glProc = xglCopyTexSubImage2DProc; gl.u.copy_tex_sub_image_2d.target = target; @@ -2747,7 +2842,7 @@ xglCopyTexSubImage2D (GLenum target, gl.u.copy_tex_sub_image_2d.height = height; xglGLOp (&gl); -} +} static void xglCopyColorTableProc (xglGLOpPtr pOp) @@ -2767,15 +2862,15 @@ xglCopyColorTable (GLenum target, GLsizei width) { xglGLOpRec gl; - + gl.glProc = xglCopyColorTableProc; - + gl.u.copy_color_table.target = target; gl.u.copy_color_table.internalformat = internalformat; gl.u.copy_color_table.x = x; gl.u.copy_color_table.y = y; gl.u.copy_color_table.width = width; - + xglGLOp (&gl); } @@ -2797,7 +2892,7 @@ xglCopyColorSubTable (GLenum target, GLsizei width) { xglGLOpRec gl; - + gl.glProc = xglCopyColorSubTableProc; gl.u.copy_color_sub_table.target = target; @@ -2805,7 +2900,7 @@ xglCopyColorSubTable (GLenum target, gl.u.copy_color_sub_table.x = x; gl.u.copy_color_sub_table.y = y; gl.u.copy_color_sub_table.width = width; - + xglGLOp (&gl); } @@ -2813,7 +2908,7 @@ static void xglCopyConvolutionFilter1DProc (xglGLOpPtr pOp) { GLenum internalformat = pOp->u.copy_convolution_filter_1d.internalformat; - + glCopyConvolutionFilter1D (pOp->u.copy_convolution_filter_1d.target, internalformat, pOp->u.copy_convolution_filter_1d.x + @@ -2831,7 +2926,7 @@ xglCopyConvolutionFilter1D (GLenum target, GLsizei width) { xglGLOpRec gl; - + gl.glProc = xglCopyConvolutionFilter1DProc; gl.u.copy_convolution_filter_1d.target = target; @@ -2839,7 +2934,7 @@ xglCopyConvolutionFilter1D (GLenum target, gl.u.copy_convolution_filter_1d.x = x; gl.u.copy_convolution_filter_1d.y = y; gl.u.copy_convolution_filter_1d.width = width; - + xglGLOp (&gl); } @@ -2847,7 +2942,7 @@ static void xglCopyConvolutionFilter2DProc (xglGLOpPtr pOp) { GLenum internalformat = pOp->u.copy_convolution_filter_2d.internalformat; - + glCopyConvolutionFilter2D (pOp->u.copy_convolution_filter_2d.target, internalformat, pOp->u.copy_convolution_filter_2d.x + @@ -2867,16 +2962,16 @@ xglCopyConvolutionFilter2D (GLenum target, GLsizei height) { xglGLOpRec gl; - + gl.glProc = xglCopyConvolutionFilter2DProc; - + gl.u.copy_convolution_filter_2d.target = target; gl.u.copy_convolution_filter_2d.internalformat = internalformat; gl.u.copy_convolution_filter_2d.x = x; gl.u.copy_convolution_filter_2d.y = y; gl.u.copy_convolution_filter_2d.width = width; gl.u.copy_convolution_filter_2d.height = height; - + xglGLOp (&gl); } @@ -2908,9 +3003,9 @@ xglCopyTexSubImage3D (GLenum target, GLsizei height) { xglGLOpRec gl; - + gl.glProc = xglCopyTexSubImage3DProc; - + gl.u.copy_tex_sub_image_3d.target = target; gl.u.copy_tex_sub_image_3d.level = level; gl.u.copy_tex_sub_image_3d.xoffset = xoffset; @@ -2924,86 +3019,380 @@ xglCopyTexSubImage3D (GLenum target, xglGLOp (&gl); } -__glProcTable __glNativeRenderTable = { - xglNewList, /* glNewList */ - xglEndList, /* glEndList */ - xglCallList, /* glCallList */ - xglCallLists, /* glCallLists */ - xglDeleteLists, /* glDeleteLists */ - xglGenLists, /* glGenLists */ +/* GL_ARB_multitexture */ +static void +xglNoOpActiveTextureARB (GLenum texture) {} +static void +xglActiveTextureARBProc (xglGLOpPtr pOp) +{ + GLenum texUnit; + + texUnit = pOp->u.enumeration - GL_TEXTURE0; + if (texUnit < 0 || texUnit >= cctx->maxTexUnits) + { + xglRecordError (GL_INVALID_ENUM); + } + else + { + cctx->activeTexUnit = texUnit; + (*cctx->ActiveTextureARB) (pOp->u.enumeration); + } +} +static void +xglActiveTextureARB (GLenum texture) +{ + xglGLOpRec gl; + + gl.glProc = xglActiveTextureARBProc; + + gl.u.enumeration = texture; + + xglGLOp (&gl); +} +static void +xglNoOpClientActiveTextureARB (GLenum texture) {} +static void +xglNoOpMultiTexCoord1dvARB (GLenum target, const GLdouble *v) {} +static void +xglNoOpMultiTexCoord1fvARB (GLenum target, const GLfloat *v) {} +static void +xglNoOpMultiTexCoord1ivARB (GLenum target, const GLint *v) {} +static void +xglNoOpMultiTexCoord1svARB (GLenum target, const GLshort *v) {} +static void +xglNoOpMultiTexCoord2dvARB (GLenum target, const GLdouble *v) {} +static void +xglNoOpMultiTexCoord2fvARB (GLenum target, const GLfloat *v) {} +static void +xglNoOpMultiTexCoord2ivARB (GLenum target, const GLint *v) {} +static void +xglNoOpMultiTexCoord2svARB (GLenum target, const GLshort *v) {} +static void +xglNoOpMultiTexCoord3dvARB (GLenum target, const GLdouble *v) {} +static void +xglNoOpMultiTexCoord3fvARB (GLenum target, const GLfloat *v) {} +static void +xglNoOpMultiTexCoord3ivARB (GLenum target, const GLint *v) {} +static void +xglNoOpMultiTexCoord3svARB (GLenum target, const GLshort *v) {} +static void +xglNoOpMultiTexCoord4dvARB (GLenum target, const GLdouble *v) {} +static void +xglNoOpMultiTexCoord4fvARB (GLenum target, const GLfloat *v) {} +static void +xglNoOpMultiTexCoord4ivARB (GLenum target, const GLint *v) {} +static void +xglNoOpMultiTexCoord4svARB (GLenum target, const GLshort *v) {} + +/* GL_ARB_multisample */ +static void +xglNoOpSampleCoverageARB (GLclampf value, GLboolean invert) {} + +/* GL_EXT_texture_object */ +static GLboolean +xglNoOpAreTexturesResidentEXT (GLsizei n, + const GLuint *textures, + GLboolean *residences) +{ + return GL_FALSE; +} +static void +xglNoOpGenTexturesEXT (GLsizei n, GLuint *textures) {} +static GLboolean +xglNoOpIsTextureEXT (GLuint texture) +{ + return GL_FALSE; +} + +/* GL_SGIS_multisample */ +static void +xglNoOpSampleMaskSGIS (GLclampf value, GLboolean invert) {} +static void +xglNoOpSamplePatternSGIS (GLenum pattern) {} + +/* GL_EXT_point_parameters */ +static void +xglNoOpPointParameterfEXT (GLenum pname, GLfloat param) {} +static void +xglNoOpPointParameterfvEXT (GLenum pname, const GLfloat *params) {} + +/* GL_MESA_window_pos */ +static void +xglNoOpWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z) {} +static void +xglWindowPos3fMESAProc (xglGLOpPtr pOp) +{ + (*cctx->WindowPos3fMESA) (pOp->u.window_pos_3f.x + cctx->pDrawBuffer->xOff, + pOp->u.window_pos_3f.y + cctx->pDrawBuffer->yOff, + pOp->u.window_pos_3f.z); +} +static void +xglWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z) +{ + xglGLOpRec gl; + + gl.glProc = xglWindowPos3fMESAProc; + + gl.u.window_pos_3f.x = x; + gl.u.window_pos_3f.y = y; + gl.u.window_pos_3f.z = z; + + xglGLOp (&gl); +} + +/* GL_EXT_blend_func_separate */ +static void +xglNoOpBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, + GLenum sfactorAlpha, GLenum dfactorAlpha) {} + +/* GL_EXT_fog_coord */ +static void +xglNoOpFogCoordfvEXT (const GLfloat *coord) {} +static void +xglNoOpFogCoorddvEXT (const GLdouble *coord) {} +static void +xglNoOpFogCoordPointerEXT (GLenum type, GLsizei stride, + const GLvoid *pointer) {} + +/* GL_EXT_secondary_color */ +static void +xglNoOpSecondaryColor3bvEXT (const GLbyte *v) {} +static void +xglNoOpSecondaryColor3dvEXT (const GLdouble *v) {} +static void +xglNoOpSecondaryColor3fvEXT (const GLfloat *v) {} +static void +xglNoOpSecondaryColor3ivEXT (const GLint *v) {} +static void +xglNoOpSecondaryColor3svEXT (const GLshort *v) {} +static void +xglNoOpSecondaryColor3ubvEXT (const GLubyte *v) {} +static void +xglNoOpSecondaryColor3uivEXT (const GLuint *v) {} +static void +xglNoOpSecondaryColor3usvEXT (const GLushort *v) {} +static void +xglNoOpSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei stride, + const GLvoid *pointer) {} + +/* GL_NV_point_sprite */ +static void +xglNoOpPointParameteriNV (GLenum pname, GLint params) {} +static void +xglNoOpPointParameterivNV (GLenum pname, const GLint *params) {} + +/* GL_EXT_stencil_two_side */ +static void +xglNoOpActiveStencilFaceEXT (GLenum face) {} + +/* GL_EXT_framebuffer_object */ +static GLboolean +xglNoOpIsRenderbufferEXT (GLuint renderbuffer) +{ + return FALSE; +} +static void +xglNoOpBindRenderbufferEXT (GLenum target, GLuint renderbuffer) {} +static void +xglNoOpDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers) {} +static void +xglNoOpGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers) {} +static void +xglNoOpRenderbufferStorageEXT (GLenum target, GLenum internalformat, + GLsizei width, GLsizei height) {} +static void +xglNoOpGetRenderbufferParameterivEXT (GLenum target, GLenum pname, + GLint *params) {} +static GLboolean +xglNoOpIsFramebufferEXT (GLuint framebuffer) +{ + return FALSE; +} +static void +xglNoOpBindFramebufferEXT (GLenum target, GLuint framebuffer) {} +static void +xglNoOpDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers) {} +static void +xglNoOpGenFramebuffersEXT (GLsizei n, GLuint *framebuffers) {} +static GLenum +xglNoOpCheckFramebufferStatusEXT (GLenum target) +{ + return GL_FRAMEBUFFER_UNSUPPORTED_EXT; +} +static void +xglNoOpFramebufferTexture1DEXT (GLenum target, GLenum attachment, + GLenum textarget, GLuint texture, + GLint level) {} +static void +xglNoOpFramebufferTexture2DEXT (GLenum target, GLenum attachment, + GLenum textarget, GLuint texture, + GLint level) {} +static void +xglNoOpFramebufferTexture3DEXT (GLenum target, GLenum attachment, + GLenum textarget, GLuint texture, + GLint level, GLint zoffset) {} +static void +xglNoOpFramebufferRenderbufferEXT (GLenum target, GLenum attachment, + GLenum renderbuffertarget, + GLuint renderbuffer) {} +static void +xglNoOpGetFramebufferAttachmentParameterivEXT (GLenum target, + GLenum attachment, + GLenum pname, + GLint *params) {} +static void +xglNoOpGenerateMipmapEXT (GLenum target) {} + +static struct _glapi_table __glNativeRenderTable = { + xglNewList, + xglEndList, + xglCallList, + xglCallLists, + xglDeleteLists, + xglGenLists, glListBase, - xglBegin, /* glBegin */ - xglBitmap, /* glBitmap */ + xglBegin, + xglBitmap, + 0, /* glColor3b */ glColor3bv, + 0, /* glColor3d */ glColor3dv, + 0, /* glColor3f */ glColor3fv, + 0, /* glColor3i */ glColor3iv, + 0, /* glColor3s */ glColor3sv, + 0, /* glColor3ub */ glColor3ubv, + 0, /* glColor3ui */ glColor3uiv, + 0, /* glColor3us */ glColor3usv, + 0, /* glColor4b */ glColor4bv, + 0, /* glColor4d */ glColor4dv, + 0, /* glColor4f */ glColor4fv, + 0, /* glColor4i */ glColor4iv, + 0, /* glColor4s */ glColor4sv, + 0, /* glColor4ub */ glColor4ubv, + 0, /* glColor4ui */ glColor4uiv, + 0, /* glColor4us */ glColor4usv, + 0, /* glEdgeFlag */ glEdgeFlagv, - xglEnd, /* glEnd */ + xglEnd, + 0, /* glIndexd */ glIndexdv, + 0, /* glIndexf */ glIndexfv, + 0, /* glIndexi */ glIndexiv, + 0, /* glIndexs */ glIndexsv, + 0, /* glNormal3b */ glNormal3bv, + 0, /* glNormal3d */ glNormal3dv, + 0, /* glNormal3f */ glNormal3fv, + 0, /* glNormal3i */ glNormal3iv, + 0, /* glNormal3s */ glNormal3sv, + 0, /* glRasterPos2d */ glRasterPos2dv, + 0, /* glRasterPos2f */ glRasterPos2fv, + 0, /* glRasterPos2i */ glRasterPos2iv, + 0, /* glRasterPos2s */ glRasterPos2sv, + 0, /* glRasterPos3d */ glRasterPos3dv, + 0, /* glRasterPos3f */ glRasterPos3fv, + 0, /* glRasterPos3i */ glRasterPos3iv, + 0, /* glRasterPos3s */ glRasterPos3sv, + 0, /* glRasterPos4d */ glRasterPos4dv, + 0, /* glRasterPos4f */ glRasterPos4fv, + 0, /* glRasterPos4i */ glRasterPos4iv, + 0, /* glRasterPos4s */ glRasterPos4sv, - xglRectdv, /* glRectdv */ - xglRectfv, /* glRectfv */ - xglRectiv, /* glRectiv */ - xglRectsv, /* glRectsv */ + 0, /* glRectd */ + xglRectdv, + 0, /* glRectf */ + xglRectfv, + 0, /* glRecti */ + xglRectiv, + 0, /* glRects */ + xglRectsv, + 0, /* glTexCoord1d */ glTexCoord1dv, + 0, /* glTexCoord1f */ glTexCoord1fv, + 0, /* glTexCoord1i */ glTexCoord1iv, + 0, /* glTexCoord1s */ glTexCoord1sv, + 0, /* glTexCoord2d */ glTexCoord2dv, + 0, /* glTexCoord2f */ glTexCoord2fv, + 0, /* glTexCoord2i */ glTexCoord2iv, + 0, /* glTexCoord2s */ glTexCoord2sv, + 0, /* glTexCoord3d */ glTexCoord3dv, + 0, /* glTexCoord3f */ glTexCoord3fv, + 0, /* glTexCoord3i */ glTexCoord3iv, + 0, /* glTexCoord3s */ glTexCoord3sv, + 0, /* glTexCoord4d */ glTexCoord4dv, + 0, /* glTexCoord4f */ glTexCoord4fv, + 0, /* glTexCoord4i */ glTexCoord4iv, + 0, /* glTexCoord4s */ glTexCoord4sv, + 0, /* glVertex2d */ glVertex2dv, + 0, /* glVertex2f */ glVertex2fv, + 0, /* glVertex2i */ glVertex2iv, + 0, /* glVertex2s */ glVertex2sv, + 0, /* glVertex3d */ glVertex3dv, + 0, /* glVertex3f */ glVertex3fv, + 0, /* glVertex3i */ glVertex3iv, + 0, /* glVertex3s */ glVertex3sv, + 0, /* glVertex4d */ glVertex4dv, + 0, /* glVertex4f */ glVertex4fv, + 0, /* glVertex4i */ glVertex4iv, + 0, /* glVertex4s */ glVertex4sv, glClipPlane, glColorMaterial, @@ -3031,12 +3420,12 @@ __glProcTable __glNativeRenderTable = { glPointSize, glPolygonMode, glPolygonStipple, - xglScissor, /* glScissor */ + xglScissor, glShadeModel, - xglTexParameterf, /* glTexParameterf */ - xglTexParameterfv, /* glTexParameterfv */ - xglTexParameteri, /* glTexParameteri */ - xglTexParameteriv, /* glTexParameteriv */ + xglTexParameterf, + xglTexParameterfv, + xglTexParameteri, + xglTexParameteriv, glTexImage1D, glTexImage2D, glTexEnvf, @@ -3057,8 +3446,8 @@ __glProcTable __glNativeRenderTable = { glPassThrough, glPopName, glPushName, - xglDrawBuffer, /* glDrawBuffer */ - xglClear, /* glClear */ + xglDrawBuffer, + xglClear, glClearAccum, glClearIndex, glClearColor, @@ -3068,13 +3457,13 @@ __glProcTable __glNativeRenderTable = { glColorMask, glDepthMask, glIndexMask, - xglAccum, /* glAccum */ - xglDisable, /* glDisable */ - xglEnable, /* glEnable */ - xglFinish, /* glFinish */ - xglFlush, /* glFlush */ - xglPopAttrib, /* glPopAttrib */ - xglPushAttrib, /* glPushAttrib */ + xglAccum, + xglDisable, + xglEnable, + xglFinish, + xglFlush, + xglPopAttrib, + xglPushAttrib, glMap1d, glMap1f, glMap2d, @@ -3083,9 +3472,13 @@ __glProcTable __glNativeRenderTable = { glMapGrid1f, glMapGrid2d, glMapGrid2f, + 0, /* glEvalCoord1d */ glEvalCoord1dv, + 0, /* glEvalCoord1f */ glEvalCoord1fv, + 0, /* glEvalCoord2d */ glEvalCoord2dv, + 0, /* glEvalCoord2f */ glEvalCoord2fv, glEvalMesh1, glEvalPoint1, @@ -3105,16 +3498,16 @@ __glProcTable __glNativeRenderTable = { glPixelMapfv, glPixelMapuiv, glPixelMapusv, - xglReadBuffer, /* glReadBuffer */ - xglCopyPixels, /* glCopyPixels */ - xglReadPixels, /* glReadPixels */ - xglDrawPixels, /* glDrawPixels */ - xglGetBooleanv, /* glGetBooleanv */ + xglReadBuffer, + xglCopyPixels, + xglReadPixels, + xglDrawPixels, + xglGetBooleanv, glGetClipPlane, - xglGetDoublev, /* glGetDoublev */ - xglGetError, /* glGetError */ - xglGetFloatv, /* glGetFloatv */ - xglGetIntegerv, /* glGetIntegerv */ + xglGetDoublev, + xglGetError, + xglGetFloatv, + xglGetIntegerv, glGetLightfv, glGetLightiv, glGetMapdv, @@ -3126,7 +3519,7 @@ __glProcTable __glNativeRenderTable = { glGetPixelMapuiv, glGetPixelMapusv, glGetPolygonStipple, - xglGetString, /* glGetString */ + xglGetString, glGetTexEnvfv, glGetTexEnviv, glGetTexGendv, @@ -3135,10 +3528,10 @@ __glProcTable __glNativeRenderTable = { glGetTexImage, glGetTexParameterfv, glGetTexParameteriv, - xglGetTexLevelParameterfv, /* glGetTexLevelParameterfv */ - xglGetTexLevelParameteriv, /* glGetTexLevelParameteriv */ - xglIsEnabled, /* glIsEnabled */ - xglIsList, /* glIsList */ + xglGetTexLevelParameterfv, + xglGetTexLevelParameteriv, + xglIsEnabled, + xglIsList, glDepthRange, glFrustum, glLoadIdentity, @@ -3156,55 +3549,57 @@ __glProcTable __glNativeRenderTable = { glScalef, glTranslated, glTranslatef, - xglViewport, /* glViewport */ + xglViewport, glArrayElement, - xglBindTexture, /* glBindTexture */ + xglBindTexture, glColorPointer, glDisableClientState, - xglDrawArrays, /* glDrawArrays */ - xglDrawElements, /* glDrawElements */ + xglDrawArrays, + xglDrawElements, glEdgeFlagPointer, glEnableClientState, glIndexPointer, + 0, /* glIndexub */ glIndexubv, glInterleavedArrays, glNormalPointer, glPolygonOffset, glTexCoordPointer, glVertexPointer, - xglAreTexturesResident, /* glAreTexturesResident */ - xglCopyTexImage1D, /* glCopyTexImage1D */ - xglCopyTexImage2D, /* glCopyTexImage2D */ - xglCopyTexSubImage1D, /* glCopyTexSubImage1D */ - xglCopyTexSubImage2D, /* glCopyTexSubImage2D */ - xglDeleteTextures, /* glDeleteTextures */ - xglGenTextures, /* glGenTextures */ + xglAreTexturesResident, + xglCopyTexImage1D, + xglCopyTexImage2D, + xglCopyTexSubImage1D, + xglCopyTexSubImage2D, + xglDeleteTextures, + xglGenTextures, glGetPointerv, - xglIsTexture, /* glIsTexture */ - xglPrioritizeTextures, /* glPrioritizeTextures */ + xglIsTexture, + xglPrioritizeTextures, glTexSubImage1D, glTexSubImage2D, glPopClientAttrib, glPushClientAttrib, glBlendColor, glBlendEquation, + 0, /* glDrawRangeElements */ glColorTable, glColorTableParameterfv, glColorTableParameteriv, - xglCopyColorTable, /* glCopyColorTable */ + xglCopyColorTable, glGetColorTable, glGetColorTableParameterfv, glGetColorTableParameteriv, glColorSubTable, - xglCopyColorSubTable, /* glCopyColorSubTable */ + xglCopyColorSubTable, glConvolutionFilter1D, glConvolutionFilter2D, glConvolutionParameterf, glConvolutionParameterfv, glConvolutionParameteri, glConvolutionParameteriv, - xglCopyConvolutionFilter1D, /* glCopyConvolutionFilter1D */ - xglCopyConvolutionFilter2D, /* glCopyConvolutionFilter2D */ + xglCopyConvolutionFilter1D, + xglCopyConvolutionFilter2D, glGetConvolutionFilter, glGetConvolutionParameterfv, glGetConvolutionParameteriv, @@ -3222,278 +3617,429 @@ __glProcTable __glNativeRenderTable = { glResetMinmax, glTexImage3D, glTexSubImage3D, - xglCopyTexSubImage3D /* glCopyTexSubImage3D */ -}; - -/* GL_ARB_multitexture */ -static void -xglNoOpActiveTextureARB (GLenum texture) {} -static void -xglActiveTextureARBProc (xglGLOpPtr pOp) -{ - GLenum texUnit; - - texUnit = pOp->u.enumeration - GL_TEXTURE0; - if (texUnit < 0 || texUnit >= cctx->maxTexUnits) - { - xglRecordError (GL_INVALID_ENUM); - } - else - { - cctx->activeTexUnit = texUnit; - (*cctx->ActiveTextureARB) (pOp->u.enumeration); - } -} -static void -xglActiveTextureARB (GLenum texture) -{ - xglGLOpRec gl; - - gl.glProc = xglActiveTextureARBProc; - - gl.u.enumeration = texture; - - xglGLOp (&gl); -} -static void -xglNoOpClientActiveTextureARB (GLenum texture) {} -static void -xglNoOpMultiTexCoord1dvARB (GLenum target, const GLdouble *v) {} -static void -xglNoOpMultiTexCoord1fvARB (GLenum target, const GLfloat *v) {} -static void -xglNoOpMultiTexCoord1ivARB (GLenum target, const GLint *v) {} -static void -xglNoOpMultiTexCoord1svARB (GLenum target, const GLshort *v) {} -static void -xglNoOpMultiTexCoord2dvARB (GLenum target, const GLdouble *v) {} -static void -xglNoOpMultiTexCoord2fvARB (GLenum target, const GLfloat *v) {} -static void -xglNoOpMultiTexCoord2ivARB (GLenum target, const GLint *v) {} -static void -xglNoOpMultiTexCoord2svARB (GLenum target, const GLshort *v) {} -static void -xglNoOpMultiTexCoord3dvARB (GLenum target, const GLdouble *v) {} -static void -xglNoOpMultiTexCoord3fvARB (GLenum target, const GLfloat *v) {} -static void -xglNoOpMultiTexCoord3ivARB (GLenum target, const GLint *v) {} -static void -xglNoOpMultiTexCoord3svARB (GLenum target, const GLshort *v) {} -static void -xglNoOpMultiTexCoord4dvARB (GLenum target, const GLdouble *v) {} -static void -xglNoOpMultiTexCoord4fvARB (GLenum target, const GLfloat *v) {} -static void -xglNoOpMultiTexCoord4ivARB (GLenum target, const GLint *v) {} -static void -xglNoOpMultiTexCoord4svARB (GLenum target, const GLshort *v) {} - -/* GL_ARB_multisample */ -static void -xglNoOpSampleCoverageARB (GLclampf value, GLboolean invert) {} - -/* GL_EXT_texture_object */ -static GLboolean -xglNoOpAreTexturesResidentEXT (GLsizei n, - const GLuint *textures, - GLboolean *residences) -{ - return GL_FALSE; -} -static void -xglNoOpGenTexturesEXT (GLsizei n, GLuint *textures) {} -static GLboolean -xglNoOpIsTextureEXT (GLuint texture) -{ - return GL_FALSE; -} - -/* GL_SGIS_multisample */ -static void -xglNoOpSampleMaskSGIS (GLclampf value, GLboolean invert) {} -static void -xglNoOpSamplePatternSGIS (GLenum pattern) {} - -/* GL_EXT_point_parameters */ -static void -xglNoOpPointParameterfEXT (GLenum pname, GLfloat param) {} -static void -xglNoOpPointParameterfvEXT (GLenum pname, const GLfloat *params) {} - -/* GL_MESA_window_pos */ -static void -xglNoOpWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z) {} -static void -xglWindowPos3fMESAProc (xglGLOpPtr pOp) -{ - (*cctx->WindowPos3fMESA) (pOp->u.window_pos_3f.x + cctx->pDrawBuffer->xOff, - pOp->u.window_pos_3f.y + cctx->pDrawBuffer->yOff, - pOp->u.window_pos_3f.z); -} -static void -xglWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z) -{ - xglGLOpRec gl; - - gl.glProc = xglWindowPos3fMESAProc; - - gl.u.window_pos_3f.x = x; - gl.u.window_pos_3f.y = y; - gl.u.window_pos_3f.z = z; - - xglGLOp (&gl); -} - -/* GL_EXT_blend_func_separate */ -static void -xglNoOpBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, - GLenum sfactorAlpha, GLenum dfactorAlpha) {} - -/* GL_EXT_fog_coord */ -static void -xglNoOpFogCoordfvEXT (const GLfloat *coord) {} -static void -xglNoOpFogCoorddvEXT (const GLdouble *coord) {} -static void -xglNoOpFogCoordPointerEXT (GLenum type, GLsizei stride, - const GLvoid *pointer) {} - -/* GL_EXT_secondary_color */ -static void -xglNoOpSecondaryColor3bvEXT (const GLbyte *v) {} -static void -xglNoOpSecondaryColor3dvEXT (const GLdouble *v) {} -static void -xglNoOpSecondaryColor3fvEXT (const GLfloat *v) {} -static void -xglNoOpSecondaryColor3ivEXT (const GLint *v) {} -static void -xglNoOpSecondaryColor3svEXT (const GLshort *v) {} -static void -xglNoOpSecondaryColor3ubvEXT (const GLubyte *v) {} -static void -xglNoOpSecondaryColor3uivEXT (const GLuint *v) {} -static void -xglNoOpSecondaryColor3usvEXT (const GLushort *v) {} -static void -xglNoOpSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei stride, - const GLvoid *pointer) {} - -/* GL_NV_point_sprite */ -static void -xglNoOpPointParameteriNV (GLenum pname, GLint params) {} -static void -xglNoOpPointParameterivNV (GLenum pname, const GLint *params) {} - -/* GL_EXT_stencil_two_side */ -static void -xglNoOpActiveStencilFaceEXT (GLenum face) {} - -/* GL_EXT_framebuffer_object */ -static GLboolean -xglNoOpIsRenderbufferEXT (GLuint renderbuffer) -{ - return FALSE; -} -static void -xglNoOpBindRenderbufferEXT (GLenum target, GLuint renderbuffer) {} -static void -xglNoOpDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers) {} -static void -xglNoOpGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers) {} -static void -xglNoOpRenderbufferStorageEXT (GLenum target, GLenum internalformat, - GLsizei width, GLsizei height) {} -static void -xglNoOpGetRenderbufferParameterivEXT (GLenum target, GLenum pname, - GLint *params) {} -static GLboolean -xglNoOpIsFramebufferEXT (GLuint framebuffer) -{ - return FALSE; -} -static void -xglNoOpBindFramebufferEXT (GLenum target, GLuint framebuffer) {} -static void -xglNoOpDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers) {} -static void -xglNoOpGenFramebuffersEXT (GLsizei n, GLuint *framebuffers) {} -static GLenum -xglNoOpCheckFramebufferStatusEXT (GLenum target) -{ - return GL_FRAMEBUFFER_UNSUPPORTED_EXT; -} -static void -xglNoOpFramebufferTexture1DEXT (GLenum target, GLenum attachment, - GLenum textarget, GLuint texture, - GLint level) {} -static void -xglNoOpFramebufferTexture2DEXT (GLenum target, GLenum attachment, - GLenum textarget, GLuint texture, - GLint level) {} -static void -xglNoOpFramebufferTexture3DEXT (GLenum target, GLenum attachment, - GLenum textarget, GLuint texture, - GLint level, GLint zoffset) {} -static void -xglNoOpFramebufferRenderbufferEXT (GLenum target, GLenum attachment, - GLenum renderbuffertarget, - GLuint renderbuffer) {} -static void -xglNoOpGetFramebufferAttachmentParameterivEXT (GLenum target, - GLenum attachment, - GLenum pname, - GLint *params) {} -static void -xglNoOpGenerateMipmapEXT (GLenum target) {} - - -__glProcTableEXT __glNoOpRenderTableEXT = { + xglCopyTexSubImage3D, xglNoOpActiveTextureARB, xglNoOpClientActiveTextureARB, + 0, /* glMultiTexCoord1dARB */ xglNoOpMultiTexCoord1dvARB, + 0, /* glMultiTexCoord1fARB */ xglNoOpMultiTexCoord1fvARB, + 0, /* glMultiTexCoord1iARB */ xglNoOpMultiTexCoord1ivARB, + 0, /* glMultiTexCoord1sARB */ xglNoOpMultiTexCoord1svARB, + 0, /* glMultiTexCoord2dARB */ xglNoOpMultiTexCoord2dvARB, + 0, /* glMultiTexCoord2fARB */ xglNoOpMultiTexCoord2fvARB, + 0, /* glMultiTexCoord2iARB */ xglNoOpMultiTexCoord2ivARB, + 0, /* glMultiTexCoord2sARB */ xglNoOpMultiTexCoord2svARB, + 0, /* glMultiTexCoord3dARB */ xglNoOpMultiTexCoord3dvARB, + 0, /* glMultiTexCoord3fARB */ xglNoOpMultiTexCoord3fvARB, + 0, /* glMultiTexCoord3iARB */ xglNoOpMultiTexCoord3ivARB, + 0, /* glMultiTexCoord3sARB */ xglNoOpMultiTexCoord3svARB, + 0, /* glMultiTexCoord4dARB */ xglNoOpMultiTexCoord4dvARB, + 0, /* glMultiTexCoord4fARB */ xglNoOpMultiTexCoord4fvARB, + 0, /* glMultiTexCoord4iARB */ xglNoOpMultiTexCoord4ivARB, + 0, /* glMultiTexCoord4sARB */ xglNoOpMultiTexCoord4svARB, + 0, /* glLoadTransposeMatrixfARB */ + 0, /* glLoadTransposeMatrixdARB */ + 0, /* glMultTransposeMatrixfARB */ + 0, /* glMultTransposeMatrixdARB */ xglNoOpSampleCoverageARB, + 0, /* glDrawBuffersARB */ + 0, /* glPolygonOffsetEXT */ + 0, /* glGetTexFilterFuncSGIS */ + 0, /* glTexFilterFuncSGIS */ + 0, /* glGetHistogramEXT */ + 0, /* glGetHistogramParameterfvEXT */ + 0, /* glGetHistogramParameterivEXT */ + 0, /* glGetMinmaxEXT */ + 0, /* glGetMinmaxParameterfvEXT */ + 0, /* glGetMinmaxParameterivEXT */ + 0, /* glGetConvolutionFilterEXT */ + 0, /* glGetConvolutionParameterfvEXT */ + 0, /* glGetConvolutionParameterivEXT */ + 0, /* glGetSeparableFilterEXT */ + 0, /* glGetColorTableSGI */ + 0, /* glGetColorTableParameterfvSGI */ + 0, /* glGetColorTableParameterivSGI */ + 0, /* glPixelTexGenSGIX */ + 0, /* glPixelTexGenParameteriSGIS */ + 0, /* glPixelTexGenParameterivSGIS */ + 0, /* glPixelTexGenParameterfSGIS */ + 0, /* glPixelTexGenParameterfvSGIS */ + 0, /* glGetPixelTexGenParameterivSGIS */ + 0, /* glGetPixelTexGenParameterfvSGIS */ + 0, /* glTexImage4DSGIS */ + 0, /* glTexSubImage4DSGIS */ xglNoOpAreTexturesResidentEXT, xglNoOpGenTexturesEXT, xglNoOpIsTextureEXT, + 0, /* glDetailTexFuncSGIS */ + 0, /* glGetDetailTexFuncSGIS */ + 0, /* glSharpenTexFuncSGIS */ + 0, /* glGetSharpenTexFuncSGIS */ xglNoOpSampleMaskSGIS, xglNoOpSamplePatternSGIS, + 0, /* glColorPointerEXT */ + 0, /* glEdgeFlagPointerEXT */ + 0, /* glIndexPointerEXT */ + 0, /* glNormalPointerEXT */ + 0, /* glTexCoordPointerEXT */ + 0, /* glVertexPointerEXT */ + 0, /* glSpriteParameterfSGIX */ + 0, /* glSpriteParameterfvSGIX */ + 0, /* glSpriteParameteriSGIX */ + 0, /* glSpriteParameterivSGIX */ xglNoOpPointParameterfEXT, xglNoOpPointParameterfvEXT, + 0, /* glGetInstrumentsSGIX */ + 0, /* glInstrumentsBufferSGIX */ + 0, /* glPollInstrumentsSGIX */ + 0, /* glReadInstrumentsSGIX */ + 0, /* glStartInstrumentsSGIX */ + 0, /* glStopInstrumentsSGIX */ + 0, /* glFrameZoomSGIX */ + 0, /* glTagSampleBufferSGIX */ + 0, /* glReferencePlaneSGIX */ + 0, /* glFlushRasterSGIX */ + 0, /* glGetListParameterfvSGIX */ + 0, /* glGetListParameterivSGIX */ + 0, /* glListParameterfSGIX */ + 0, /* glListParameterfvSGIX */ + 0, /* glListParameteriSGIX */ + 0, /* glListParameterivSGIX */ + 0, /* glFragmentColorMaterialSGIX */ + 0, /* glFragmentLightfSGIX */ + 0, /* glFragmentLightfvSGIX */ + 0, /* glFragmentLightiSGIX */ + 0, /* glFragmentLightivSGIX */ + 0, /* glFragmentLightModelfSGIX */ + 0, /* glFragmentLightModelfvSGIX */ + 0, /* glFragmentLightModeliSGIX */ + 0, /* glFragmentLightModelivSGIX */ + 0, /* glFragmentMaterialfSGIX */ + 0, /* glFragmentMaterialfvSGIX */ + 0, /* glFragmentMaterialiSGIX */ + 0, /* glFragmentMaterialivSGIX */ + 0, /* glGetFragmentLightfvSGIX */ + 0, /* glGetFragmentLightivSGIX */ + 0, /* glGetFragmentMaterialfvSGIX */ + 0, /* glGetFragmentMaterialivSGIX */ + 0, /* glLightEnviSGIX */ + 0, /* glVertexWeightfEXT */ + 0, /* glVertexWeightfvEXT */ + 0, /* glVertexWeightPointerEXT */ + 0, /* glFlushVertexArrayRangeNV */ + 0, /* glVertexArrayRangeNV */ + 0, /* glCombinerParameterfvNV */ + 0, /* glCombinerParameterfNV */ + 0, /* glCombinerParameterivNV */ + 0, /* glCombinerParameteriNV */ + 0, /* glCombinerInputNV */ + 0, /* glCombinerOutputNV */ + 0, /* glFinalCombinerInputNV */ + 0, /* glGetCombinerInputParameterfvNV */ + 0, /* glGetCombinerInputParameterivNV */ + 0, /* glGetCombinerOutputParameterfvNV */ + 0, /* glGetCombinerOutputParameterivNV */ + 0, /* glGetFinalCombinerInputParameterfvNV */ + 0, /* glGetFinalCombinerInputParameterivNV */ + 0, /* glResizeBuffersMESA */ + 0, /* glWindowPos2dMESA */ + 0, /* glWindowPos2dvMESA */ + 0, /* glWindowPos2fMESA */ + 0, /* glWindowPos2fvMESA */ + 0, /* glWindowPos2iMESA */ + 0, /* glWindowPos2ivMESA */ + 0, /* glWindowPos2sMESA */ + 0, /* glWindowPos2svMESA */ + 0, /* glWindowPos3dMESA */ + 0, /* glWindowPos3dvMESA */ xglNoOpWindowPos3fMESA, + 0, /* glWindowPos3fvMESA */ + 0, /* glWindowPos3iMESA */ + 0, /* glWindowPos3ivMESA */ + 0, /* glWindowPos3sMESA */ + 0, /* glWindowPos3svMESA */ + 0, /* glWindowPos4dMESA */ + 0, /* glWindowPos4dvMESA */ + 0, /* glWindowPos4fMESA */ + 0, /* glWindowPos4fvMESA */ + 0, /* glWindowPos4iMESA */ + 0, /* glWindowPos4ivMESA */ + 0, /* glWindowPos4sMESA */ + 0, /* glWindowPos4svMESA */ xglNoOpBlendFuncSeparateEXT, + 0, /* glIndexMaterialEXT */ + 0, /* glIndexFuncEXT */ + 0, /* glLockArraysEXT */ + 0, /* glUnlockArraysEXT */ + 0, /* glCullParameterdvEXT */ + 0, /* glCullParameterfvEXT */ + 0, /* glHintPGI */ + 0, /* glFogCoordfEXT */ xglNoOpFogCoordfvEXT, + 0, /* glFogCoorddEXT */ xglNoOpFogCoorddvEXT, xglNoOpFogCoordPointerEXT, + 0, /* glGetColorTableEXT */ + 0, /* glGetColorTableParameterivEXT */ + 0, /* glGetColorTableParameterfvEXT */ + 0, /* glTbufferMask3DFX */ + 0, /* glCompressedTexImage3DARB */ + 0, /* glCompressedTexImage2DARB */ + 0, /* glCompressedTexImage1DARB */ + 0, /* glCompressedTexSubImage3DARB */ + 0, /* glCompressedTexSubImage2DARB */ + 0, /* glCompressedTexSubImage1DARB */ + 0, /* glGetCompressedTexImageARB */ + 0, /* glSecondaryColor3bEXT */ xglNoOpSecondaryColor3bvEXT, + 0, /* glSecondaryColor3dEXT */ xglNoOpSecondaryColor3dvEXT, + 0, /* glSecondaryColor3fEXT */ xglNoOpSecondaryColor3fvEXT, + 0, /* glSecondaryColor3iEXT */ xglNoOpSecondaryColor3ivEXT, + 0, /* glSecondaryColor3sEXT */ xglNoOpSecondaryColor3svEXT, + 0, /* glSecondaryColor3ubEXT */ xglNoOpSecondaryColor3ubvEXT, + 0, /* glSecondaryColor3uiEXT */ xglNoOpSecondaryColor3uivEXT, + 0, /* glSecondaryColor3usEXT */ xglNoOpSecondaryColor3usvEXT, xglNoOpSecondaryColorPointerEXT, + 0, /* glAreProgramsResidentNV */ + 0, /* glBindProgramNV */ + 0, /* glDeleteProgramsNV */ + 0, /* glExecuteProgramNV */ + 0, /* glGenProgramsNV */ + 0, /* glGetProgramParameterdvNV */ + 0, /* glGetProgramParameterfvNV */ + 0, /* glGetProgramivNV */ + 0, /* glGetProgramStringNV */ + 0, /* glGetTrackMatrixivNV */ + 0, /* glGetVertexAttribdvARB */ + 0, /* glGetVertexAttribfvARB */ + 0, /* glGetVertexAttribivARB */ + 0, /* glGetVertexAttribPointervNV */ + 0, /* glIsProgramNV */ + 0, /* glLoadProgramNV */ + 0, /* glProgramParameter4dNV */ + 0, /* glProgramParameter4dvNV */ + 0, /* glProgramParameter4fNV */ + 0, /* glProgramParameter4fvNV */ + 0, /* glProgramParameters4dvNV */ + 0, /* glProgramParameters4fvNV */ + 0, /* glRequestResidentProgramsNV */ + 0, /* glTrackMatrixNV */ + 0, /* glVertexAttribPointerNV */ + 0, /* glVertexAttrib1dARB */ + 0, /* glVertexAttrib1dvARB */ + 0, /* glVertexAttrib1fARB */ + 0, /* glVertexAttrib1fvARB */ + 0, /* glVertexAttrib1sARB */ + 0, /* glVertexAttrib1svARB */ + 0, /* glVertexAttrib2dARB */ + 0, /* glVertexAttrib2dvARB */ + 0, /* glVertexAttrib2fARB */ + 0, /* glVertexAttrib2fvARB */ + 0, /* glVertexAttrib2sARB */ + 0, /* glVertexAttrib2svARB */ + 0, /* glVertexAttrib3dARB */ + 0, /* glVertexAttrib3dvARB */ + 0, /* glVertexAttrib3fARB */ + 0, /* glVertexAttrib3fvARB */ + 0, /* glVertexAttrib3sARB */ + 0, /* glVertexAttrib3svARB */ + 0, /* glVertexAttrib4dARB */ + 0, /* glVertexAttrib4dvARB */ + 0, /* glVertexAttrib4fARB */ + 0, /* glVertexAttrib4fvARB */ + 0, /* glVertexAttrib4sARB */ + 0, /* glVertexAttrib4svARB */ + 0, /* glVertexAttrib4NubARB */ + 0, /* glVertexAttrib4NubvARB */ + 0, /* glVertexAttribs1dvNV */ + 0, /* glVertexAttribs1fvNV */ + 0, /* glVertexAttribs1svNV */ + 0, /* glVertexAttribs2dvNV */ + 0, /* glVertexAttribs2fvNV */ + 0, /* glVertexAttribs2svNV */ + 0, /* glVertexAttribs3dvNV */ + 0, /* glVertexAttribs3fvNV */ + 0, /* glVertexAttribs3svNV */ + 0, /* glVertexAttribs4dvNV */ + 0, /* glVertexAttribs4fvNV */ + 0, /* glVertexAttribs4svNV */ + 0, /* glVertexAttribs4ubvNV */ xglNoOpPointParameteriNV, xglNoOpPointParameterivNV, + 0, /* glMultiDrawArraysEXT */ + 0, /* glMultiDrawElementsEXT */ xglNoOpActiveStencilFaceEXT, + 0, /* glDeleteFencesNV */ + 0, /* glGenFencesNV */ + 0, /* glIsFenceNV */ + 0, /* glTestFenceNV */ + 0, /* glGetFenceivNV */ + 0, /* glFinishFenceNV */ + 0, /* glSetFenceNV */ + 0, /* glVertexAttrib4bvARB */ + 0, /* glVertexAttrib4ivARB */ + 0, /* glVertexAttrib4ubvARB */ + 0, /* glVertexAttrib4usvARB */ + 0, /* glVertexAttrib4uivARB */ + 0, /* glVertexAttrib4NbvARB */ + 0, /* glVertexAttrib4NsvARB */ + 0, /* glVertexAttrib4NivARB */ + 0, /* glVertexAttrib4NusvARB */ + 0, /* glVertexAttrib4NuivARB */ + 0, /* glVertexAttribPointerARB */ + 0, /* glEnableVertexAttribArrayARB */ + 0, /* glDisableVertexAttribArrayARB */ + 0, /* glProgramStringARB */ + 0, /* glProgramEnvParameter4dARB */ + 0, /* glProgramEnvParameter4dvARB */ + 0, /* glProgramEnvParameter4fARB */ + 0, /* glProgramEnvParameter4fvARB */ + 0, /* glProgramLocalParameter4dARB */ + 0, /* glProgramLocalParameter4dvARB */ + 0, /* glProgramLocalParameter4fARB */ + 0, /* glProgramLocalParameter4fvARB */ + 0, /* glGetProgramEnvParameterdvARB */ + 0, /* glGetProgramEnvParameterfvARB */ + 0, /* glGetProgramLocalParameterdvARB */ + 0, /* glGetProgramLocalParameterfvARB */ + 0, /* glGetProgramivARB */ + 0, /* glGetProgramStringARB */ + 0, /* glProgramNamedParameter4fNV */ + 0, /* glProgramNamedParameter4dNV */ + 0, /* glProgramNamedParameter4fvNV */ + 0, /* glProgramNamedParameter4dvNV */ + 0, /* glGetProgramNamedParameterfvNV */ + 0, /* glGetProgramNamedParameterdvNV */ + 0, /* glBindBufferARB */ + 0, /* glBufferDataARB */ + 0, /* glBufferSubDataARB */ + 0, /* glDeleteBuffersARB */ + 0, /* glGenBuffersARB */ + 0, /* glGetBufferParameterivARB */ + 0, /* glGetBufferPointervARB */ + 0, /* glGetBufferSubDataARB */ + 0, /* glIsBufferARB */ + 0, /* glMapBufferARB */ + 0, /* glUnmapBufferARB */ + 0, /* glDepthBoundsEXT */ + 0, /* glGenQueriesARB */ + 0, /* glDeleteQueriesARB */ + 0, /* glIsQueryARB */ + 0, /* glBeginQueryARB */ + 0, /* glEndQueryARB */ + 0, /* glGetQueryivARB */ + 0, /* glGetQueryObjectivARB */ + 0, /* glGetQueryObjectuivARB */ + 0, /* glMultiModeDrawArraysIBM */ + 0, /* glMultiModeDrawElementsIBM */ + 0, /* glBlendEquationSeparateEXT */ + 0, /* glDeleteObjectARB */ + 0, /* glGetHandleARB */ + 0, /* glDetachObjectARB */ + 0, /* glCreateShaderObjectARB */ + 0, /* glShaderSourceARB */ + 0, /* glCompileShaderARB */ + 0, /* glCreateProgramObjectARB */ + 0, /* glAttachObjectARB */ + 0, /* glLinkProgramARB */ + 0, /* glUseProgramObjectARB */ + 0, /* glValidateProgramARB */ + 0, /* glUniform1fARB */ + 0, /* glUniform2fARB */ + 0, /* glUniform3fARB */ + 0, /* glUniform4fARB */ + 0, /* glUniform1iARB */ + 0, /* glUniform2iARB */ + 0, /* glUniform3iARB */ + 0, /* glUniform4iARB */ + 0, /* glUniform1fvARB */ + 0, /* glUniform2fvARB */ + 0, /* glUniform3fvARB */ + 0, /* glUniform4fvARB */ + 0, /* glUniform1ivARB */ + 0, /* glUniform2ivARB */ + 0, /* glUniform3ivARB */ + 0, /* glUniform4ivARB */ + 0, /* glUniformMatrix2fvARB */ + 0, /* glUniformMatrix3fvARB */ + 0, /* glUniformMatrix4fvARB */ + 0, /* glGetObjectParameterfvARB */ + 0, /* glGetObjectParameterivARB */ + 0, /* glGetInfoLogARB */ + 0, /* glGetAttachedObjectsARB */ + 0, /* glGetUniformLocationARB */ + 0, /* glGetActiveUniformARB */ + 0, /* glGetUniformfvARB */ + 0, /* glGetUniformivARB */ + 0, /* glGetShaderSourceARB */ + 0, /* glBindAttribLocationARB */ + 0, /* glGetActiveAttribARB */ + 0, /* glGetAttribLocationARB */ + 0, /* glGetVertexAttribdvNV */ + 0, /* glGetVertexAttribfvNV */ + 0, /* glGetVertexAttribivNV */ + 0, /* glVertexAttrib1dNV */ + 0, /* glVertexAttrib1dvNV */ + 0, /* glVertexAttrib1fNV */ + 0, /* glVertexAttrib1fvNV */ + 0, /* glVertexAttrib1sNV */ + 0, /* glVertexAttrib1svNV */ + 0, /* glVertexAttrib2dNV */ + 0, /* glVertexAttrib2dvNV */ + 0, /* glVertexAttrib2fNV */ + 0, /* glVertexAttrib2fvNV */ + 0, /* glVertexAttrib2sNV */ + 0, /* glVertexAttrib2svNV */ + 0, /* glVertexAttrib3dNV */ + 0, /* glVertexAttrib3dvNV */ + 0, /* glVertexAttrib3fNV */ + 0, /* glVertexAttrib3fvNV */ + 0, /* glVertexAttrib3sNV */ + 0, /* glVertexAttrib3svNV */ + 0, /* glVertexAttrib4dNV */ + 0, /* glVertexAttrib4dvNV */ + 0, /* glVertexAttrib4fNV */ + 0, /* glVertexAttrib4fvNV */ + 0, /* glVertexAttrib4sNV */ + 0, /* glVertexAttrib4svNV */ + 0, /* glVertexAttrib4ubNV */ + 0, /* glVertexAttrib4ubvNV */ + 0, /* glGenFragmentShadersATI */ + 0, /* glBindFragmentShaderATI */ + 0, /* glDeleteFragmentShaderATI */ + 0, /* glBeginFragmentShaderATI */ + 0, /* glEndFragmentShaderATI */ + 0, /* glPassTexCoordATI */ + 0, /* glSampleMapATI */ + 0, /* glColorFragmentOp1ATI */ + 0, /* glColorFragmentOp2ATI */ + 0, /* glColorFragmentOp3ATI */ + 0, /* glAlphaFragmentOp1ATI */ + 0, /* glAlphaFragmentOp2ATI */ + 0, /* glAlphaFragmentOp3ATI */ + 0, /* glSetFragmentShaderConstantATI */ xglNoOpIsRenderbufferEXT, xglNoOpBindRenderbufferEXT, xglNoOpDeleteRenderbuffersEXT, @@ -3510,7 +4056,12 @@ __glProcTableEXT __glNoOpRenderTableEXT = { xglNoOpFramebufferTexture3DEXT, xglNoOpFramebufferRenderbufferEXT, xglNoOpGetFramebufferAttachmentParameterivEXT, - xglNoOpGenerateMipmapEXT + xglNoOpGenerateMipmapEXT, + 0, /* glStencilFuncSeparate */ + 0, /* glStencilOpSeparate */ + 0, /* glStencilMaskSeparate */ + 0, /* glGetQueryObjecti64vEXT */ + 0 /* glGetQueryObjectui64vEXT */ }; static void @@ -3518,8 +4069,6 @@ xglInitExtensions (xglGLContextPtr pContext) { const char *extensions; - pContext->glRenderTableEXT = __glNoOpRenderTableEXT; - extensions = (const char *) glGetString (GL_EXTENSIONS); if (strstr (extensions, "GL_ARB_multitexture")) @@ -3528,88 +4077,87 @@ xglInitExtensions (xglGLContextPtr pContext) (PFNGLACTIVETEXTUREARBPROC) glitz_context_get_proc_address (pContext->context, "glActiveTextureARB"); - pContext->glRenderTableEXT.ClientActiveTextureARB = + pContext->glRenderTable.ClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARBPROC) glitz_context_get_proc_address (pContext->context, "glClientActiveTextureARB"); - pContext->glRenderTableEXT.MultiTexCoord1dvARB = + pContext->glRenderTable.MultiTexCoord1dvARB = (PFNGLMULTITEXCOORD1DVARBPROC) glitz_context_get_proc_address (pContext->context, "glMultiTexCoord1dvARB"); - pContext->glRenderTableEXT.MultiTexCoord1fvARB = + pContext->glRenderTable.MultiTexCoord1fvARB = (PFNGLMULTITEXCOORD1FVARBPROC) glitz_context_get_proc_address (pContext->context, "glMultiTexCoord1fvARB"); - pContext->glRenderTableEXT.MultiTexCoord1ivARB = + pContext->glRenderTable.MultiTexCoord1ivARB = (PFNGLMULTITEXCOORD1IVARBPROC) glitz_context_get_proc_address (pContext->context, "glMultiTexCoord1ivARB"); - pContext->glRenderTableEXT.MultiTexCoord1svARB = + pContext->glRenderTable.MultiTexCoord1svARB = (PFNGLMULTITEXCOORD1SVARBPROC) glitz_context_get_proc_address (pContext->context, "glMultiTexCoord1svARB"); - pContext->glRenderTableEXT.MultiTexCoord2dvARB = + pContext->glRenderTable.MultiTexCoord2dvARB = (PFNGLMULTITEXCOORD2DVARBPROC) glitz_context_get_proc_address (pContext->context, "glMultiTexCoord2dvARB"); - pContext->glRenderTableEXT.MultiTexCoord2fvARB = + pContext->glRenderTable.MultiTexCoord2fvARB = (PFNGLMULTITEXCOORD2FVARBPROC) glitz_context_get_proc_address (pContext->context, "glMultiTexCoord2fvARB"); - pContext->glRenderTableEXT.MultiTexCoord2ivARB = + pContext->glRenderTable.MultiTexCoord2ivARB = (PFNGLMULTITEXCOORD2IVARBPROC) glitz_context_get_proc_address (pContext->context, "glMultiTexCoord2ivARB"); - pContext->glRenderTableEXT.MultiTexCoord2svARB = + pContext->glRenderTable.MultiTexCoord2svARB = (PFNGLMULTITEXCOORD2SVARBPROC) glitz_context_get_proc_address (pContext->context, "glMultiTexCoord2svARB"); - pContext->glRenderTableEXT.MultiTexCoord3dvARB = + pContext->glRenderTable.MultiTexCoord3dvARB = (PFNGLMULTITEXCOORD3DVARBPROC) glitz_context_get_proc_address (pContext->context, "glMultiTexCoord3dvARB"); - pContext->glRenderTableEXT.MultiTexCoord3fvARB = + pContext->glRenderTable.MultiTexCoord3fvARB = (PFNGLMULTITEXCOORD3FVARBPROC) glitz_context_get_proc_address (pContext->context, "glMultiTexCoord3fvARB"); - pContext->glRenderTableEXT.MultiTexCoord3ivARB = + pContext->glRenderTable.MultiTexCoord3ivARB = (PFNGLMULTITEXCOORD3IVARBPROC) glitz_context_get_proc_address (pContext->context, "glMultiTexCoord3ivARB"); - pContext->glRenderTableEXT.MultiTexCoord3svARB = + pContext->glRenderTable.MultiTexCoord3svARB = (PFNGLMULTITEXCOORD3SVARBPROC) glitz_context_get_proc_address (pContext->context, "glMultiTexCoord3svARB"); - pContext->glRenderTableEXT.MultiTexCoord4dvARB = + pContext->glRenderTable.MultiTexCoord4dvARB = (PFNGLMULTITEXCOORD4DVARBPROC) glitz_context_get_proc_address (pContext->context, "glMultiTexCoord4dvARB"); - pContext->glRenderTableEXT.MultiTexCoord4fvARB = + pContext->glRenderTable.MultiTexCoord4fvARB = (PFNGLMULTITEXCOORD4FVARBPROC) glitz_context_get_proc_address (pContext->context, "glMultiTexCoord4fvARB"); - pContext->glRenderTableEXT.MultiTexCoord4ivARB = + pContext->glRenderTable.MultiTexCoord4ivARB = (PFNGLMULTITEXCOORD4IVARBPROC) glitz_context_get_proc_address (pContext->context, "glMultiTexCoord4ivARB"); - pContext->glRenderTableEXT.MultiTexCoord4svARB = + pContext->glRenderTable.MultiTexCoord4svARB = (PFNGLMULTITEXCOORD4SVARBPROC) glitz_context_get_proc_address (pContext->context, "glMultiTexCoord4svARB"); - glGetIntegerv (GL_MAX_LIST_NESTING, &pContext->maxListNesting); glGetIntegerv (GL_MAX_TEXTURE_UNITS_ARB, &pContext->maxTexUnits); if (pContext->maxTexUnits > XGL_MAX_TEXTURE_UNITS) pContext->maxTexUnits = XGL_MAX_TEXTURE_UNITS; - pContext->glRenderTableEXT.ActiveTextureARB = xglActiveTextureARB; + pContext->glRenderTable.ActiveTextureARB = xglActiveTextureARB; } else pContext->maxTexUnits = 1; if (strstr (extensions, "GL_ARB_multisample")) { - pContext->glRenderTableEXT.SampleCoverageARB = + pContext->glRenderTable.SampleCoverageARB = (PFNGLSAMPLECOVERAGEARBPROC) glitz_context_get_proc_address (pContext->context, "glSampleCoverageARB"); @@ -3617,19 +4165,19 @@ xglInitExtensions (xglGLContextPtr pContext) if (strstr (extensions, "GL_EXT_texture_object")) { - pContext->glRenderTableEXT.AreTexturesResidentEXT = + pContext->glRenderTable.AreTexturesResidentEXT = xglAreTexturesResident; - pContext->glRenderTableEXT.GenTexturesEXT = xglGenTextures; - pContext->glRenderTableEXT.IsTextureEXT = xglIsTexture; + pContext->glRenderTable.GenTexturesEXT = xglGenTextures; + pContext->glRenderTable.IsTextureEXT = xglIsTexture; } if (strstr (extensions, "GL_SGIS_multisample")) { - pContext->glRenderTableEXT.SampleMaskSGIS = + pContext->glRenderTable.SampleMaskSGIS = (PFNGLSAMPLEMASKSGISPROC) glitz_context_get_proc_address (pContext->context, "glSampleMaskSGIS"); - pContext->glRenderTableEXT.SamplePatternSGIS = + pContext->glRenderTable.SamplePatternSGIS = (PFNGLSAMPLEPATTERNSGISPROC) glitz_context_get_proc_address (pContext->context, "glSamplePatternSGIS"); @@ -3637,11 +4185,11 @@ xglInitExtensions (xglGLContextPtr pContext) if (strstr (extensions, "GL_EXT_point_parameters")) { - pContext->glRenderTableEXT.PointParameterfEXT = + pContext->glRenderTable.PointParameterfEXT = (PFNGLPOINTPARAMETERFEXTPROC) glitz_context_get_proc_address (pContext->context, "glPointParameterfEXT"); - pContext->glRenderTableEXT.PointParameterfvEXT = + pContext->glRenderTable.PointParameterfvEXT = (PFNGLPOINTPARAMETERFVEXTPROC) glitz_context_get_proc_address (pContext->context, "glPointParameterfvEXT"); @@ -3653,12 +4201,13 @@ xglInitExtensions (xglGLContextPtr pContext) (PFNGLWINDOWPOS3FMESAPROC) glitz_context_get_proc_address (pContext->context, "glWindowPos3fMESA"); - pContext->glRenderTableEXT.WindowPos3fMESA = xglWindowPos3fMESA; + + pContext->glRenderTable.WindowPos3fMESA = xglWindowPos3fMESA; } if (strstr (extensions, "GL_EXT_blend_func_separate")) { - pContext->glRenderTableEXT.BlendFuncSeparateEXT = + pContext->glRenderTable.BlendFuncSeparateEXT = (PFNGLBLENDFUNCSEPARATEEXTPROC) glitz_context_get_proc_address (pContext->context, "glBlendFuncSeparateEXT"); @@ -3666,15 +4215,15 @@ xglInitExtensions (xglGLContextPtr pContext) if (strstr (extensions, "GL_EXT_fog_coord")) { - pContext->glRenderTableEXT.FogCoordfvEXT = + pContext->glRenderTable.FogCoordfvEXT = (PFNGLFOGCOORDFVEXTPROC) glitz_context_get_proc_address (pContext->context, "glFogCoordfvEXT"); - pContext->glRenderTableEXT.FogCoorddvEXT = + pContext->glRenderTable.FogCoorddvEXT = (PFNGLFOGCOORDDVEXTPROC) glitz_context_get_proc_address (pContext->context, "glFogCoorddvEXT"); - pContext->glRenderTableEXT.FogCoordPointerEXT = + pContext->glRenderTable.FogCoordPointerEXT = (PFNGLFOGCOORDPOINTEREXTPROC) glitz_context_get_proc_address (pContext->context, "glFogCoordPointerEXT"); @@ -3682,39 +4231,39 @@ xglInitExtensions (xglGLContextPtr pContext) if (strstr (extensions, "GL_EXT_secondary_color")) { - pContext->glRenderTableEXT.SecondaryColor3bvEXT = + pContext->glRenderTable.SecondaryColor3bvEXT = (PFNGLSECONDARYCOLOR3BVEXTPROC) glitz_context_get_proc_address (pContext->context, "glSecondaryColor3bvEXT"); - pContext->glRenderTableEXT.SecondaryColor3dvEXT = + pContext->glRenderTable.SecondaryColor3dvEXT = (PFNGLSECONDARYCOLOR3DVEXTPROC) glitz_context_get_proc_address (pContext->context, "glSecondaryColor3dvEXT"); - pContext->glRenderTableEXT.SecondaryColor3fvEXT = + pContext->glRenderTable.SecondaryColor3fvEXT = (PFNGLSECONDARYCOLOR3FVEXTPROC) glitz_context_get_proc_address (pContext->context, "glSecondaryColor3fvEXT"); - pContext->glRenderTableEXT.SecondaryColor3ivEXT = + pContext->glRenderTable.SecondaryColor3ivEXT = (PFNGLSECONDARYCOLOR3IVEXTPROC) glitz_context_get_proc_address (pContext->context, "glSecondaryColor3ivEXT"); - pContext->glRenderTableEXT.SecondaryColor3svEXT = + pContext->glRenderTable.SecondaryColor3svEXT = (PFNGLSECONDARYCOLOR3SVEXTPROC) glitz_context_get_proc_address (pContext->context, "glSecondaryColor3svEXT"); - pContext->glRenderTableEXT.SecondaryColor3ubvEXT = + pContext->glRenderTable.SecondaryColor3ubvEXT = (PFNGLSECONDARYCOLOR3UBVEXTPROC) glitz_context_get_proc_address (pContext->context, "glSecondaryColor3ubvEXT"); - pContext->glRenderTableEXT.SecondaryColor3uivEXT = + pContext->glRenderTable.SecondaryColor3uivEXT = (PFNGLSECONDARYCOLOR3UIVEXTPROC) glitz_context_get_proc_address (pContext->context, "glSecondaryColor3uivEXT"); - pContext->glRenderTableEXT.SecondaryColor3usvEXT = + pContext->glRenderTable.SecondaryColor3usvEXT = (PFNGLSECONDARYCOLOR3USVEXTPROC) glitz_context_get_proc_address (pContext->context, "glSecondaryColor3usvEXT"); - pContext->glRenderTableEXT.SecondaryColorPointerEXT = + pContext->glRenderTable.SecondaryColorPointerEXT = (PFNGLSECONDARYCOLORPOINTEREXTPROC) glitz_context_get_proc_address (pContext->context, "glSecondaryColorPointerEXT"); @@ -3722,11 +4271,11 @@ xglInitExtensions (xglGLContextPtr pContext) if (strstr (extensions, "GL_NV_point_sprite")) { - pContext->glRenderTableEXT.PointParameteriNV = + pContext->glRenderTable.PointParameteriNV = (PFNGLPOINTPARAMETERINVPROC) glitz_context_get_proc_address (pContext->context, "glPointParameteriNV"); - pContext->glRenderTableEXT.PointParameterivNV = + pContext->glRenderTable.PointParameterivNV = (PFNGLPOINTPARAMETERIVNVPROC) glitz_context_get_proc_address (pContext->context, "glPointParameterivNV"); @@ -3734,7 +4283,7 @@ xglInitExtensions (xglGLContextPtr pContext) if (strstr (extensions, "GL_EXT_stencil_two_side")) { - pContext->glRenderTableEXT.ActiveStencilFaceEXT = + pContext->glRenderTable.ActiveStencilFaceEXT = (PFNGLACTIVESTENCILFACEEXTPROC) glitz_context_get_proc_address (pContext->context, "glActiveStencilFaceEXT"); @@ -3742,72 +4291,72 @@ xglInitExtensions (xglGLContextPtr pContext) if (strstr (extensions, "GL_EXT_framebuffer_object")) { - pContext->glRenderTableEXT.IsRenderbufferEXT = + pContext->glRenderTable.IsRenderbufferEXT = (PFNGLISRENDERBUFFEREXTPROC) glitz_context_get_proc_address (pContext->context, "glIsRenderbufferEXT"); - pContext->glRenderTableEXT.BindRenderbufferEXT = + pContext->glRenderTable.BindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC) glitz_context_get_proc_address (pContext->context, "glBindRenderbufferEXT"); - pContext->glRenderTableEXT.DeleteRenderbuffersEXT = + pContext->glRenderTable.DeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC) glitz_context_get_proc_address (pContext->context, "glDeleteRenderbuffersEXT"); - pContext->glRenderTableEXT.GenRenderbuffersEXT = + pContext->glRenderTable.GenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC) glitz_context_get_proc_address (pContext->context, "glGenRenderbuffersEXT"); - pContext->glRenderTableEXT.RenderbufferStorageEXT = + pContext->glRenderTable.RenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC) glitz_context_get_proc_address (pContext->context, "glRenderbufferStorageEXT"); - pContext->glRenderTableEXT.GetRenderbufferParameterivEXT = + pContext->glRenderTable.GetRenderbufferParameterivEXT = (PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) glitz_context_get_proc_address (pContext->context, "glGetRenderbufferParameterivEXT"); - pContext->glRenderTableEXT.IsFramebufferEXT = + pContext->glRenderTable.IsFramebufferEXT = (PFNGLISFRAMEBUFFEREXTPROC) glitz_context_get_proc_address (pContext->context, "glIsFramebufferEXT"); - pContext->glRenderTableEXT.BindFramebufferEXT = + pContext->glRenderTable.BindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) glitz_context_get_proc_address (pContext->context, "glBindFramebufferEXT"); - pContext->glRenderTableEXT.DeleteFramebuffersEXT = + pContext->glRenderTable.DeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC) glitz_context_get_proc_address (pContext->context, "glDeleteFramebuffersEXT"); - pContext->glRenderTableEXT.GenFramebuffersEXT = + pContext->glRenderTable.GenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) glitz_context_get_proc_address (pContext->context, "glGenFramebuffersEXT"); - pContext->glRenderTableEXT.CheckFramebufferStatusEXT = + pContext->glRenderTable.CheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) glitz_context_get_proc_address (pContext->context, "glCheckFramebufferStatusEXT"); - pContext->glRenderTableEXT.FramebufferTexture1DEXT = + pContext->glRenderTable.FramebufferTexture1DEXT = (PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) glitz_context_get_proc_address (pContext->context, "glFramebufferTexture1DEXT"); - pContext->glRenderTableEXT.FramebufferTexture2DEXT = + pContext->glRenderTable.FramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) glitz_context_get_proc_address (pContext->context, "glFramebufferTexture2DEXT"); - pContext->glRenderTableEXT.FramebufferTexture3DEXT = + pContext->glRenderTable.FramebufferTexture3DEXT = (PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) glitz_context_get_proc_address (pContext->context, "glFramebufferTexture3DEXT"); - pContext->glRenderTableEXT.FramebufferRenderbufferEXT = + pContext->glRenderTable.FramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) glitz_context_get_proc_address (pContext->context, "glFramebufferRenderbufferEXT"); - pContext->glRenderTableEXT.GetFramebufferAttachmentParameterivEXT = + pContext->glRenderTable.GetFramebufferAttachmentParameterivEXT = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) glitz_context_get_proc_address (pContext->context, "glGetFramebufferAttachment" "ParameterivEXT"); - pContext->glRenderTableEXT.GenerateMipmapEXT = + pContext->glRenderTable.GenerateMipmapEXT = (PFNGLGENERATEMIPMAPEXTPROC) glitz_context_get_proc_address (pContext->context, "glGenerateMipmapEXT"); @@ -3817,23 +4366,22 @@ xglInitExtensions (xglGLContextPtr pContext) static void xglSetCurrentContext (xglGLContextPtr pContext) { - XGL_SCREEN_PRIV (pContext->pDrawBuffer->pGC->pScreen); cctx = pContext; - glitz_context_make_current (cctx->context, pScreenPriv->drawable); + glitz_context_make_current (cctx->context, cctx->pDrawBuffer->drawable); - GlxSetRenderTables (&__glNativeRenderTable, &cctx->glRenderTableEXT); + GlxSetRenderTables (&cctx->glRenderTable); } static void xglFreeContext (xglGLContextPtr pContext) { int i; - + pContext->refcnt--; if (pContext->shared == pContext) pContext->refcnt--; - + if (pContext->refcnt) return; @@ -3853,11 +4401,11 @@ xglFreeContext (xglGLContextPtr pContext) key); if (pTexObj) xglUnrefTexObj (pTexObj); - + xglHashRemove (pContext->texObjects, key); } } while (key); - + xglDeleteHashTable (pContext->texObjects); } @@ -3874,11 +4422,11 @@ xglFreeContext (xglGLContextPtr pContext) xglHashLookup (pContext->displayLists, key); if (pDisplayList) xglDestroyList (pDisplayList); - + xglHashRemove (pContext->displayLists, key); } } while (key); - + xglDeleteHashTable (pContext->displayLists); } @@ -3890,13 +4438,10 @@ xglFreeContext (xglGLContextPtr pContext) xglUnrefTexObj (pContext->attrib.texUnits[i].pRect); xglUnrefTexObj (pContext->attrib.texUnits[i].pCubeMap); } - + if (pContext->groupList) glDeleteLists (pContext->groupList, 1); - if (pContext->pAttribStack) - xfree (pContext->pAttribStack); - if (pContext->context) glitz_context_destroy (pContext->context); @@ -3927,17 +4472,18 @@ xglLoseCurrent (__GLcontext *gc) __GLinterface *iface = pContext->mIface; GlxFlushContextCache (); + GlxSetRenderTables (0); if (!iface) return GL_TRUE; - return (*iface->exports.loseCurrent) ((__GLcontext *) iface); + return (*iface->exports.loseCurrent) ((__GLcontext *) iface); } static GLboolean xglMakeCurrent (__GLcontext *gc) { - xglGLContextPtr pContext = (xglGLContextPtr) gc; + xglGLContextPtr pContext = (xglGLContextPtr) gc; __GLinterface *iface = &pContext->iface; __GLinterface *mIface = pContext->mIface; __GLdrawablePrivate *drawPriv = iface->imports.getDrawablePrivate (gc); @@ -3958,27 +4504,24 @@ xglMakeCurrent (__GLcontext *gc) (!((WindowPtr) (pDrawBufferPriv->pDrawable))->parent)) values[0] = IncludeInferiors; #endif - + /* this happens if client previously used this context with a buffer not supported by the native GL stack */ if (!pContext->context) return GL_FALSE; - + /* XXX: GLX_SGI_make_current_read disabled for now */ if (pDrawBufferPriv != pReadBufferPriv) return GL_FALSE; - pContext->pReadBuffer = pReadBufferPriv; - pContext->pDrawBuffer = pDrawBufferPriv; - if (!pReadBufferPriv->pGC) pReadBufferPriv->pGC = CreateGC (pReadBufferPriv->pDrawable, GCSubwindowMode | GCGraphicsExposures, values, &status); - + ValidateGC (pReadBufferPriv->pDrawable, pReadBufferPriv->pGC); - + if (!pDrawBufferPriv->pGC) pDrawBufferPriv->pGC = CreateGC (pDrawBufferPriv->pDrawable, @@ -3987,11 +4530,14 @@ xglMakeCurrent (__GLcontext *gc) ValidateGC (pDrawBufferPriv->pDrawable, pDrawBufferPriv->pGC); + pReadBufferPriv->pPixmap = (PixmapPtr) 0; + pDrawBufferPriv->pPixmap = (PixmapPtr) 0; + pContext->pReadBuffer = pReadBufferPriv; pContext->pDrawBuffer = pDrawBufferPriv; - pReadBufferPriv->pPixmap = (PixmapPtr) 0; - pDrawBufferPriv->pPixmap = (PixmapPtr) 0; + pContext->readPriv = readPriv; + pContext->drawPriv = drawPriv; /* from now on this context can only be used with native GL stack */ if (mIface) @@ -4011,7 +4557,7 @@ xglMakeCurrent (__GLcontext *gc) readPriv->private = pReadBufferPriv->private; status = (*mIface->exports.makeCurrent) ((__GLcontext *) mIface); - + drawPriv->private = pDrawBufferPriv; readPriv->private = pReadBufferPriv; @@ -4037,7 +4583,7 @@ xglShareContext (__GLcontext *gc, if (!iface || !ifaceShare) return GL_TRUE; - + return (*iface->exports.shareContext) ((__GLcontext *) iface, (__GLcontext *) ifaceShare); } @@ -4052,7 +4598,7 @@ xglCopyContext (__GLcontext *dst, const __GLcontext *srcCtx = (const __GLcontext *) pSrc->mIface; __GLinterface *dstIface = (__GLinterface *) pDst->mIface; GLboolean status = GL_TRUE; - + if (pSrc->context && pDst->context) glitz_context_copy (pSrc->context, pDst->context, mask); else @@ -4081,67 +4627,119 @@ xglResizeBuffer (__GLdrawablePrivate *glPriv, if (pPixmap != pScreenPriv->pScreenPixmap) { - if (glPriv->modes->doubleBufferMode) + if (!xglCreatePixmapSurface (pPixmap)) + return FALSE; + + if (pBufferPriv->drawable == pScreenPriv->drawable) + { + if (pBufferPriv->backSurface) + glitz_surface_destroy (pBufferPriv->backSurface); + + glitz_drawable_destroy (pBufferPriv->drawable); + + pBufferPriv->drawable = NULL; + pBufferPriv->backSurface = NULL; + } + + if (pBufferPriv->drawable) + { + glitz_drawable_update_size (pBufferPriv->drawable, + pPixmap->drawable.width, + pPixmap->drawable.height); + } + else { - glitz_surface_t *surface = pBufferPriv->backSurface; + glitz_drawable_format_t *format; - if (!surface || - (glitz_surface_get_width (surface) != width || - glitz_surface_get_height (surface) != height)) + format = pBufferPriv->pVisual->format.drawable; + if (pBufferPriv->pVisual->pbuffer) { - glitz_format_t *format; - - format = pScreenPriv->pixmapFormats[pDrawable->depth].format; - - if (surface) - glitz_surface_destroy (surface); - - pBufferPriv->backSurface = - glitz_surface_create (pScreenPriv->drawable, format, - width, height, 0, NULL); - if (!pBufferPriv->backSurface) + pBufferPriv->drawable = + glitz_create_pbuffer_drawable (pScreenPriv->drawable, + format, + pPixmap->drawable.width, + pPixmap->drawable.height); + } + else + { + pBufferPriv->drawable = + glitz_create_drawable (pScreenPriv->drawable, format, + pPixmap->drawable.width, + pPixmap->drawable.height); + + if (!pBufferPriv->drawable) return FALSE; + + if (format->doublebuffer) + { + glitz_format_t *backFormat; + + backFormat = pBufferPriv->pVisual->format.surface; + + pBufferPriv->backSurface = + glitz_surface_create (pScreenPriv->drawable, backFormat, + pPixmap->drawable.width, + pPixmap->drawable.height, + 0, NULL); + if (pBufferPriv->backSurface) + glitz_surface_attach (pBufferPriv->backSurface, + pBufferPriv->drawable, + GLITZ_DRAWABLE_BUFFER_BACK_COLOR); + } } } } else { - if (glPriv->modes->doubleBufferMode) - { - if (!pBufferPriv->backSurface) - { - pBufferPriv->backSurface = pScreenPriv->backSurface; - glitz_surface_reference (pScreenPriv->backSurface); - } - } + glitz_drawable_reference (pScreenPriv->drawable); + + if (pBufferPriv->backSurface) + glitz_surface_destroy (pBufferPriv->backSurface); + + if (pBufferPriv->drawable) + glitz_drawable_destroy (pBufferPriv->drawable); + + pBufferPriv->drawable = pScreenPriv->drawable; + pBufferPriv->backSurface = NULL; } - + ValidateGC (pDrawable, pBufferPriv->pGC); return TRUE; } - static GLboolean xglForceCurrent (__GLcontext *gc) { xglGLContextPtr pContext = (xglGLContextPtr) gc; __GLinterface *iface = pContext->mIface; GLboolean status = GL_TRUE; - - if (pContext->context) + + if (pContext && pContext->context) { + __GLdrawablePrivate *readPriv, *drawPriv; + + readPriv = pContext->readPriv; + drawPriv = pContext->drawPriv; + + drawPriv->lockDP (drawPriv, gc); + if (readPriv != drawPriv) + readPriv->lockDP (readPriv, gc); + cctx = pContext; if (cctx->pReadBuffer->pDrawable && cctx->pDrawBuffer->pDrawable) { - DrawablePtr pDrawable; + DrawablePtr pDrawable = cctx->pReadBuffer->pDrawable; PixmapPtr pReadPixmap, pDrawPixmap; - - pDrawable = cctx->pReadBuffer->pDrawable; + + XGL_SCREEN_PRIV (pDrawable->pScreen); + if (pDrawable->type != DRAWABLE_PIXMAP) { pReadPixmap = XGL_GET_WINDOW_PIXMAP (pDrawable); + cctx->pReadBuffer->screenX = __XGL_OFF_X_WIN (pReadPixmap); + cctx->pReadBuffer->screenY = __XGL_OFF_Y_WIN (pReadPixmap); cctx->pReadBuffer->xOff = pDrawable->x + __XGL_OFF_X_WIN (pReadPixmap); cctx->pReadBuffer->yOff = pReadPixmap->drawable.height - @@ -4152,14 +4750,17 @@ xglForceCurrent (__GLcontext *gc) else { pReadPixmap = (PixmapPtr) pDrawable; + cctx->pReadBuffer->screenX = cctx->pReadBuffer->screenY = 0; cctx->pReadBuffer->xOff = cctx->pReadBuffer->yOff = 0; cctx->pReadBuffer->yFlip = pDrawable->height; } - + pDrawable = cctx->pDrawBuffer->pDrawable; if (pDrawable->type != DRAWABLE_PIXMAP) { pDrawPixmap = XGL_GET_WINDOW_PIXMAP (pDrawable); + cctx->pDrawBuffer->screenX = __XGL_OFF_X_WIN (pDrawPixmap); + cctx->pDrawBuffer->screenY = __XGL_OFF_Y_WIN (pDrawPixmap); cctx->pDrawBuffer->xOff = pDrawable->x + __XGL_OFF_X_WIN (pDrawPixmap); cctx->pDrawBuffer->yOff = pDrawPixmap->drawable.height - @@ -4170,94 +4771,135 @@ xglForceCurrent (__GLcontext *gc) else { pDrawPixmap = (PixmapPtr) pDrawable; + cctx->pDrawBuffer->screenX = cctx->pDrawBuffer->screenY = 0; cctx->pDrawBuffer->xOff = cctx->pDrawBuffer->yOff = 0; cctx->pDrawBuffer->yFlip = pDrawable->height; } - - /* draw buffer changed */ + + /* buffer changed */ if (cctx->pDrawBuffer->pPixmap != pDrawPixmap || cctx->pReadBuffer->pPixmap != pReadPixmap) { - __GLinterface *iface = &pContext->iface; - __GLdrawablePrivate *drawPriv, *readPriv; - - if (!xglPrepareTarget (pDrawable)) - return FALSE; - - drawPriv = iface->imports.getDrawablePrivate (gc); - readPriv = iface->imports.getReadablePrivate (gc); - if (!xglResizeBuffer (drawPriv, pDrawable->x, pDrawable->y, pDrawable->width, pDrawable->height)) + { + drawPriv->unlockDP (drawPriv); + if (readPriv != drawPriv) + readPriv->unlockDP (readPriv); + return FALSE; + } if (!xglResizeBuffer (readPriv, cctx->pReadBuffer->pDrawable->x, cctx->pReadBuffer->pDrawable->y, cctx->pReadBuffer->pDrawable->width, cctx->pReadBuffer->pDrawable->height)) + { + drawPriv->unlockDP (drawPriv); + if (readPriv != drawPriv) + readPriv->unlockDP (readPriv); + return FALSE; + } cctx->pReadBuffer->pPixmap = pReadPixmap; cctx->pDrawBuffer->pPixmap = pDrawPixmap; } - } - xglSetCurrentContext (pContext);//, cctx->pDrawBuffer); - - if (cctx->needInit) - { - int i; - - xglInitExtensions (cctx); - - cctx->attrib.scissorTest = GL_FALSE; - cctx->attrib.scissor.x = cctx->attrib.scissor.y = 0; - cctx->attrib.scissor.width = cctx->pDrawBuffer->pDrawable->width; - cctx->attrib.scissor.height = cctx->pDrawBuffer->pDrawable->height; - cctx->attrib.viewport = cctx->attrib.scissor; - - cctx->activeTexUnit = 0; - - for (i = 0; i < cctx->maxTexUnits; i++) + if (!xglSyncSurface (pContext->pDrawBuffer->pDrawable)) { - cctx->attrib.texUnits[i].enabled = 0; - - cctx->attrib.texUnits[i].p1D = NULL; - cctx->attrib.texUnits[i].p2D = NULL; - cctx->attrib.texUnits[i].p3D = NULL; - cctx->attrib.texUnits[i].pRect = NULL; - cctx->attrib.texUnits[i].pCubeMap = NULL; + drawPriv->unlockDP (drawPriv); + if (readPriv != drawPriv) + readPriv->unlockDP (readPriv); + + return FALSE; } - - glEnable (GL_SCISSOR_TEST); - cctx->needInit = FALSE; - } + if (pDrawPixmap != pScreenPriv->pScreenPixmap) + { + XGL_PIXMAP_PRIV (pDrawPixmap); + + glitz_surface_attach (pPixmapPriv->surface, + pContext->pDrawBuffer->drawable, + GLITZ_DRAWABLE_BUFFER_FRONT_COLOR); - /* update viewport and raster position */ - if (cctx->pDrawBuffer->xOff != cctx->drawXoff || - cctx->pDrawBuffer->yOff != cctx->drawYoff) + if (pPixmapPriv->target) + pPixmapPriv->target = xglPixmapTargetOut; + } + + xglSetCurrentContext (pContext); + + if (cctx->needInit) + { + int i; + + xglInitExtensions (cctx); + + glGetIntegerv (GL_MAX_LIST_NESTING, &cctx->maxListNesting); + glGetIntegerv (GL_MAX_ATTRIB_STACK_DEPTH, + &cctx->maxAttribStackDepth); + if (cctx->maxAttribStackDepth > XGL_MAX_ATTRIB_STACK_DEPTH) + cctx->maxAttribStackDepth = XGL_MAX_ATTRIB_STACK_DEPTH; + + cctx->attrib.scissorTest = GL_FALSE; + cctx->attrib.scissor.x = cctx->attrib.scissor.y = 0; + cctx->attrib.scissor.width = + cctx->pDrawBuffer->pDrawable->width; + cctx->attrib.scissor.height = + cctx->pDrawBuffer->pDrawable->height; + cctx->attrib.viewport = cctx->attrib.scissor; + + cctx->activeTexUnit = 0; + + for (i = 0; i < cctx->maxTexUnits; i++) + { + cctx->attrib.texUnits[i].enabled = 0; + + cctx->attrib.texUnits[i].p1D = NULL; + cctx->attrib.texUnits[i].p2D = NULL; + cctx->attrib.texUnits[i].p3D = NULL; + cctx->attrib.texUnits[i].pRect = NULL; + cctx->attrib.texUnits[i].pCubeMap = NULL; + } + + glEnable (GL_SCISSOR_TEST); + + cctx->needInit = FALSE; + } + + /* update viewport and raster position */ + if (cctx->pDrawBuffer->xOff != cctx->drawXoff || + cctx->pDrawBuffer->yOff != cctx->drawYoff) + { + glViewport (cctx->attrib.viewport.x + cctx->pDrawBuffer->xOff, + cctx->attrib.viewport.y + cctx->pDrawBuffer->yOff, + cctx->attrib.viewport.width, + cctx->attrib.viewport.height); + + glBitmap (0, 0, 0, 0, + cctx->pDrawBuffer->xOff - cctx->drawXoff, + cctx->pDrawBuffer->yOff - cctx->drawYoff, + NULL); + + cctx->drawXoff = cctx->pDrawBuffer->xOff; + cctx->drawYoff = cctx->pDrawBuffer->yOff; + } + + xglDrawBuffer (cctx->attrib.drawBuffer); + xglReadBuffer (cctx->attrib.readBuffer); + } + else { - glViewport (cctx->attrib.scissor.x + cctx->pDrawBuffer->xOff, - cctx->attrib.scissor.y + cctx->pDrawBuffer->yOff, - cctx->attrib.scissor.width, - cctx->attrib.scissor.height); - - glBitmap (0, 0, 0, 0, - cctx->pDrawBuffer->xOff - cctx->drawXoff, - cctx->pDrawBuffer->yOff - cctx->drawYoff, - NULL); - - cctx->drawXoff = cctx->pDrawBuffer->xOff; - cctx->drawYoff = cctx->pDrawBuffer->yOff; + xglSetCurrentContext (pContext); } - glDrawBuffer (cctx->attrib.drawBuffer); - glReadBuffer (cctx->attrib.readBuffer); + drawPriv->unlockDP (drawPriv); + if (readPriv != drawPriv) + readPriv->unlockDP (readPriv); } else { @@ -4276,7 +4918,7 @@ xglNotifyResize (__GLcontext *gc) if (!iface) return GL_TRUE; - + return (*iface->exports.notifyResize) ((__GLcontext *) iface); } @@ -4286,6 +4928,9 @@ xglNotifyDestroy (__GLcontext *gc) xglGLContextPtr pContext = (xglGLContextPtr) gc; __GLinterface *iface = pContext->mIface; + pContext->pReadBuffer->pDrawable = 0; + pContext->pDrawBuffer->pDrawable = 0; + if (iface) (*iface->exports.notifyDestroy) ((__GLcontext *) iface); } @@ -4308,7 +4953,7 @@ xglDispatchExec (__GLcontext *gc) if (!iface) return NULL; - + return (*iface->exports.dispatchExec) ((__GLcontext *) iface); } @@ -4335,9 +4980,13 @@ xglEndDispatchOverride (__GLcontext *gc) static void xglLoseCurrentContext (void *closure) { - cctx = NULL; + if (closure == cctx) + { + cctx = NULL; - GlxFlushContextCache (); + GlxFlushContextCache (); + GlxSetRenderTables (0); + } } static __GLinterface * @@ -4354,32 +5003,31 @@ xglCreateContext (__GLimports *imports, XGL_SCREEN_PRIV (glxCtx->pScreen); - format = glitz_drawable_get_format (pScreenPriv->drawable); - pContext = xalloc (sizeof (xglGLContextRec)); if (!pContext) return NULL; + format = glitz_drawable_get_format (pScreenPriv->drawable); pContext->context = glitz_context_create (pScreenPriv->drawable, format); - glitz_context_set_user_data (pContext->context, NULL, + glitz_context_set_user_data (pContext->context, pContext, xglLoseCurrentContext); + pContext->glRenderTable = __glNativeRenderTable; pContext->needInit = TRUE; pContext->versionString = NULL; pContext->errorValue = GL_NO_ERROR; pContext->shared = NULL; pContext->list = 0; pContext->groupList = 0; - pContext->pAttribStack = NULL; + pContext->beginCnt = 0; pContext->nAttribStack = 0; pContext->refcnt = 1; - pContext->doubleBuffer = glxCtx->pGlxVisual->doubleBuffer; - pContext->depthBits = glxCtx->pGlxVisual->depthSize; - pContext->stencilBits = glxCtx->pGlxVisual->stencilSize; + pContext->doubleBuffer = glxCtx->modes->doubleBufferMode; + pContext->depthBits = glxCtx->modes->depthBits; + pContext->stencilBits = glxCtx->modes->stencilBits; pContext->drawXoff = 0; pContext->drawYoff = 0; pContext->maxTexUnits = 0; - pContext->fbo = 0; if (pContext->doubleBuffer) { @@ -4391,14 +5039,14 @@ xglCreateContext (__GLimports *imports, pContext->attrib.drawBuffer = GL_FRONT; pContext->attrib.readBuffer = GL_FRONT; } - + pContext->attrib.scissorTest = GL_FALSE; - + if (shareGC) { pContext->texObjects = NULL; pContext->displayLists = NULL; - + pContext->shared = pShareContext->shared; shareIface = pShareContext->mIface; } @@ -4410,7 +5058,7 @@ xglCreateContext (__GLimports *imports, xglFreeContext (pContext); return NULL; } - + pContext->displayLists = xglNewHashTable (); if (!pContext->displayLists) { @@ -4432,7 +5080,7 @@ xglCreateContext (__GLimports *imports, pContext->mIface = iface; pContext->iface.imports = *imports; - + pContext->iface.exports.destroyContext = xglDestroyContext; pContext->iface.exports.loseCurrent = xglLoseCurrent; pContext->iface.exports.makeCurrent = xglMakeCurrent; @@ -4445,7 +5093,7 @@ xglCreateContext (__GLimports *imports, pContext->iface.exports.dispatchExec = xglDispatchExec; pContext->iface.exports.beginDispatchOverride = xglBeginDispatchOverride; pContext->iface.exports.endDispatchOverride = xglEndDispatchOverride; - + return (__GLinterface *) pContext; } @@ -4456,51 +5104,23 @@ xglSwapBuffers (__GLXdrawablePrivate *glxPriv) xglGLBufferPtr pBufferPriv = glPriv->private; DrawablePtr pDrawable = pBufferPriv->pDrawable; GLboolean status = GL_TRUE; - + if (pDrawable) { if (glPriv->modes->doubleBufferMode) { glitz_surface_t *surface; int xOff, yOff; - GCPtr pGC = pBufferPriv->pGC; + GCPtr pGC = pBufferPriv->pGC; BoxPtr pBox = REGION_RECTS (pGC->pCompositeClip); int nBox = REGION_NUM_RECTS (pGC->pCompositeClip); - XGL_SCREEN_PRIV (pGC->pScreen); - - if (!xglPrepareTarget (pDrawable)) - return GL_FALSE; - XGL_GET_DRAWABLE (pDrawable, surface, xOff, yOff); - /* native swap buffers for fullscreen windows */ - if (surface == pScreenPriv->surface && - nBox == 1 && - pBox->x1 <= 0 && - pBox->y1 <= 0 && - pBox->x2 >= pGC->pScreen->width && - pBox->y2 >= pGC->pScreen->height) - { - glitz_drawable_swap_buffers (pScreenPriv->drawable); - } - else - { - glitz_surface_set_clip_region (surface, xOff, yOff, + glitz_drawable_swap_buffer_region (pBufferPriv->drawable, + xOff, yOff, (glitz_box_t *) pBox, nBox); - glitz_copy_area (pBufferPriv->backSurface, - surface, - pDrawable->x + xOff, - pDrawable->y + yOff, - pDrawable->width, - pDrawable->height, - pDrawable->x + xOff, - pDrawable->y + yOff); - - glitz_surface_set_clip_region (surface, 0, 0, NULL, 0); - } - xglAddBitDamage (pDrawable, pGC->pCompositeClip); DamageDamageRegion (pDrawable, pGC->pCompositeClip); REGION_EMPTY (pGC->pScreen, &pBufferPriv->damage); @@ -4521,18 +5141,18 @@ xglResizeBuffers (__GLdrawableBuffer *buffer, GLint x, GLint y, GLuint width, - GLuint height, + GLuint height, __GLdrawablePrivate *glPriv, GLuint bufferMask) { xglGLBufferPtr pBufferPriv = glPriv->private; DrawablePtr pDrawable = pBufferPriv->pDrawable; GLboolean status = GL_TRUE; - + if (pDrawable) { if (!xglResizeBuffer (glPriv, x, y, width, height)) - return GL_FALSE; + return GL_FALSE; } else if (pBufferPriv->private) { @@ -4559,7 +5179,7 @@ xglBindBuffers (__GLXdrawablePrivate *glxPriv, xglTexUnitPtr pTexUnit = &cctx->attrib.texUnits[cctx->activeTexUnit]; xglTexObjPtr pTexObj = NULL; DrawablePtr pDrawable; - + /* XXX: front left buffer is only supported so far */ if (buffer != GLX_FRONT_LEFT_EXT) return BadMatch; @@ -4585,9 +5205,13 @@ xglBindBuffers (__GLXdrawablePrivate *glxPriv, { glitz_texture_object_t *object; + XGL_SCREEN_PRIV (pDrawable->pScreen); XGL_DRAWABLE_PIXMAP (pDrawable); XGL_PIXMAP_PRIV (pPixmap); + if (pPixmap == pScreenPriv->pScreenPixmap) + return BadDrawable; + object = glitz_texture_object_create (pPixmapPriv->surface); if (object) { @@ -4609,7 +5233,7 @@ xglBindBuffers (__GLXdrawablePrivate *glxPriv, else if (pBufferPriv->private) { int status; - + glPriv->private = pBufferPriv->private; status = (*pBufferPriv->bindBuffers) (glxPriv, buffer); glPriv->private = pBufferPriv; @@ -4630,11 +5254,11 @@ xglReleaseBuffers (__GLXdrawablePrivate *glxPriv, if (cctx) { xglTexObjPtr pTexObj; - + /* XXX: front left buffer is only supported so far */ if (buffer != GLX_FRONT_LEFT_EXT) return BadMatch; - + /* Must be a GLXpixmap */ if (glxPriv->pGlxPixmap) { @@ -4670,22 +5294,21 @@ xglReleaseBuffers (__GLXdrawablePrivate *glxPriv, else if (pBufferPriv->private) { int status; - + glPriv->private = pBufferPriv->private; status = (*pBufferPriv->releaseBuffers) (glxPriv, buffer); glPriv->private = pBufferPriv; return status; } - + return BadDrawable; } - static void xglFreeBuffers (__GLdrawablePrivate *glPriv) { xglGLBufferPtr pBufferPriv = glPriv->private; - + glPriv->private = pBufferPriv->private; if (pBufferPriv->freeBuffers) @@ -4693,10 +5316,13 @@ xglFreeBuffers (__GLdrawablePrivate *glPriv) if (pBufferPriv->pGC) FreeGC (pBufferPriv->pGC, (GContext) 0); - + if (pBufferPriv->backSurface) glitz_surface_destroy (pBufferPriv->backSurface); + if (pBufferPriv->drawable) + glitz_drawable_destroy (pBufferPriv->drawable); + xfree (pBufferPriv); } @@ -4704,87 +5330,107 @@ static void xglCreateBuffer (__GLXdrawablePrivate *glxPriv) { __GLdrawablePrivate *glPriv = &glxPriv->glPriv; - DrawablePtr pDrawable = glxPriv->pDraw; + DrawablePtr pDrawable = glxPriv->pDraw; ScreenPtr pScreen = pDrawable->pScreen; xglGLBufferPtr pBufferPriv; + xglVisualPtr v; XGL_SCREEN_PRIV (pScreen); - + XGL_DRAWABLE_PIXMAP (pDrawable); + pBufferPriv = xalloc (sizeof (xglGLBufferRec)); if (!pBufferPriv) FatalError ("xglCreateBuffer: No memory\n"); - pBufferPriv->pScreen = pScreen; - pBufferPriv->pDrawable = NULL; - pBufferPriv->pPixmap = NULL; - pBufferPriv->pGC = NULL; - pBufferPriv->backSurface = NULL; + pBufferPriv->pScreen = pScreen; + pBufferPriv->pDrawable = NULL; + pBufferPriv->pPixmap = NULL; + pBufferPriv->pGC = NULL; pBufferPriv->swapBuffers = NULL; pBufferPriv->bindBuffers = NULL; pBufferPriv->releaseBuffers = NULL; - + pBufferPriv->resizeBuffers = NULL; pBufferPriv->private = NULL; pBufferPriv->freeBuffers = NULL; - REGION_NULL (pScreen, &pBufferPriv->damage); + pBufferPriv->drawable = NULL; + pBufferPriv->backSurface = NULL; + + REGION_INIT (pScreen, &pBufferPriv->damage, NullBox, 0); + + pBufferPriv->pVisual = 0; + + /* glx acceleration */ + if (pScreenPriv->accel.glx.enabled && + xglCheckPixmapSize (pPixmap, &pScreenPriv->accel.glx.size)) + { + for (v = pScreenPriv->pGlxVisual; v; v = v->next) + { + glitz_drawable_format_t *format; + + if (pScreenPriv->accel.glx.pbuffer != v->pbuffer) + continue; + + format = v->format.drawable; + if (!format) + continue; + + if (format->color.red_size != glxPriv->modes->redBits || + format->color.green_size != glxPriv->modes->greenBits || + format->color.blue_size != glxPriv->modes->blueBits) + continue; + + if (format->color.alpha_size < glxPriv->modes->alphaBits || + format->depth_size < glxPriv->modes->depthBits || + format->stencil_size < glxPriv->modes->stencilBits || + format->doublebuffer < glxPriv->modes->doubleBufferMode) + continue; + + /* this is good enought for pbuffers */ + if (v->pbuffer) + break; + + /* we want an exact match for non-pbuffer formats */ + if (format->color.alpha_size == glxPriv->modes->alphaBits && + format->depth_size == glxPriv->modes->depthBits && + format->stencil_size == glxPriv->modes->stencilBits && + format->doublebuffer == glxPriv->modes->doubleBufferMode) + break; + } + + pBufferPriv->pVisual = v; + } + + if ((pDrawable->type == DRAWABLE_WINDOW) - if (pScreenPriv->fbo || - ((pDrawable->type == DRAWABLE_WINDOW) - #ifdef COMPOSITE - /* this is a root window, can't be redirected */ - && (!((WindowPtr) pDrawable)->parent) + && (pBufferPriv->pVisual + + /* this is a root window, can't be redirected */ + || (!((WindowPtr) pDrawable)->parent)) #endif - - )) + + ) { pBufferPriv->pDrawable = pDrawable; } - -/* else if (pScreenPriv->fbo) - { - if (glxPriv->pGlxVisual->doubleBuffer) - { - int depth = pDrawable->depth; - - pBufferPriv->backSurface = - glitz_surface_create (pScreenPriv->drawable, - pScreenPriv->pixmapFormats[depth].format, - pDrawable->width, pDrawable->height, - 0, NULL); - if (pBufferPriv->backSurface) - { - if (glitz_surface_valid_target (pBufferPriv->backSurface)) - { - pBufferPriv->pDrawable = pDrawable; - ErrorF ("Backbuffer created\n"); - } - else - { - glitz_surface_destroy (pBufferPriv->backSurface); - pBufferPriv->backSurface = NULL; - } - } - } - } - */ else { (*screenInfoPriv.createBuffer) (glxPriv); /* Wrap the swap buffers routine */ pBufferPriv->swapBuffers = glxPriv->swapBuffers; - + /* Wrap the render texture routines */ pBufferPriv->bindBuffers = glxPriv->bindBuffers; pBufferPriv->releaseBuffers = glxPriv->releaseBuffers; /* Wrap the front buffer's resize routine */ pBufferPriv->resizeBuffers = glPriv->frontBuffer.resize; - + /* Save Xgl's private buffer structure */ pBufferPriv->freeBuffers = glPriv->freePrivate; pBufferPriv->private = glPriv->private; @@ -4823,12 +5469,11 @@ xglCreateBuffer (__GLXdrawablePrivate *glxPriv) } glxPriv->swapBuffers = xglSwapBuffers; - + glxPriv->bindBuffers = xglBindBuffers; glxPriv->releaseBuffers = xglReleaseBuffers; - glPriv->frontBuffer.resize = xglResizeBuffers; - + glPriv->private = (void *) pBufferPriv; glPriv->freePrivate = xglFreeBuffers; } @@ -4836,49 +5481,120 @@ xglCreateBuffer (__GLXdrawablePrivate *glxPriv) static Bool xglScreenProbe (int screen) { - Bool status; + ScreenPtr pScreen = screenInfo.screens[screen]; + xglVisualPtr pVisual; + Bool status; + int i; + + XGL_SCREEN_PRIV (pScreen); status = (*screenInfoPriv.screenProbe) (screen); - /* Wrap createBuffer */ - if (__glDDXScreenInfo.createBuffer != xglCreateBuffer) + /* Create Xgl GLX visuals */ + for (i = 0; i < __xglScreenInfoPtr->numVisuals; i++) { - screenInfoPriv.createBuffer = __glDDXScreenInfo.createBuffer; - __glDDXScreenInfo.createBuffer = xglCreateBuffer; + pVisual = xglFindVisualWithId (pScreen, pScreen->visuals[i].vid); + if (pVisual) + { + glitz_drawable_format_t templ, *format, *screenFormat; + unsigned long mask; + + templ.color = pVisual->format.surface->color; + templ.depth_size = __xglScreenInfoPtr->modes[i].depthBits; + templ.stencil_size = __xglScreenInfoPtr->modes[i].stencilBits; + templ.doublebuffer = __xglScreenInfoPtr->modes[i].doubleBufferMode; + 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; + + format = glitz_find_drawable_format (pScreenPriv->drawable, + mask, &templ, 0); + if (format) + { + xglVisualPtr v, new, *prev; + + new = xalloc (sizeof (xglVisualRec)); + if (new) + { + new->next = 0; + new->vid = pVisual->vid; + new->pPixel = pVisual->pPixel; + new->pbuffer = FALSE; + + new->format.surface = pVisual->format.surface; + new->format.drawable = format; + + prev = &pScreenPriv->pGlxVisual; + while ((v = *prev)) + prev = &v->next; + + *prev = new; + } + } + + /* use same drawable format as screen for pbuffers */ + screenFormat = glitz_drawable_get_format (pScreenPriv->drawable); + templ.id = screenFormat->id; + + 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; + + format = glitz_find_pbuffer_format (pScreenPriv->drawable, + mask, &templ, 0); + if (format) + { + xglVisualPtr v, new, *prev; + + new = xalloc (sizeof (xglVisualRec)); + if (new) + { + new->next = 0; + new->vid = pVisual->vid; + new->pPixel = pVisual->pPixel; + new->pbuffer = TRUE; + + new->format.surface = pVisual->format.surface; + new->format.drawable = format; + + prev = &pScreenPriv->pGlxVisual; + while ((v = *prev)) + prev = &v->next; + + *prev = new; + } + } + } } - - /* Wrap createContext */ - if (__glDDXScreenInfo.createContext != xglCreateContext) + + /* Wrap createBuffer */ + if (__xglScreenInfoPtr->createBuffer != xglCreateBuffer) { - screenInfoPriv.createContext = __glDDXScreenInfo.createContext; - __glDDXScreenInfo.createContext = xglCreateContext; + screenInfoPriv.createBuffer = __xglScreenInfoPtr->createBuffer; + __xglScreenInfoPtr->createBuffer = xglCreateBuffer; } - - return status; -} -static Bool -xglDestroyWindow (WindowPtr pWin) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - Bool ret; - - XGL_SCREEN_PRIV (pScreen); - - if (cctx) + /* Wrap createContext */ + if (__xglScreenInfoPtr->createContext != xglCreateContext) { - if (cctx->pDrawBuffer->pDrawable == &pWin->drawable) - cctx->pDrawBuffer->pDrawable = NULL; - - if (cctx->pReadBuffer->pDrawable == &pWin->drawable) - cctx->pReadBuffer->pDrawable = NULL; + screenInfoPriv.createContext = __xglScreenInfoPtr->createContext; + __xglScreenInfoPtr->createContext = xglCreateContext; } - - XGL_SCREEN_UNWRAP (DestroyWindow); - ret = (*pScreen->DestroyWindow) (pWin); - XGL_SCREEN_WRAP (DestroyWindow, xglDestroyWindow); - return ret; + return status; } Bool @@ -4892,40 +5608,34 @@ xglInitVisualConfigs (ScreenPtr pScreen) int rootDepth; VisualID defaultVis; glitz_drawable_format_t *format; - xglPixelFormatPtr pPixel; + xglVisualPtr pVisual; __GLXvisualConfig *pConfig; xglGLXVisualConfigPtr pConfigPriv, *ppConfigPriv; XID *installedCmaps; ColormapPtr installedCmap; int numInstalledCmaps; int numConfig = 1; - int depth, bpp, i; + int bpp, i; XGL_SCREEN_PRIV (pScreen); - XGL_SCREEN_WRAP (DestroyWindow, xglDestroyWindow); - - depth = pScreenPriv->pVisual->pPixel->depth; - bpp = pScreenPriv->pVisual->pPixel->masks.bpp; - format = glitz_drawable_get_format (pScreenPriv->drawable); - pPixel = pScreenPriv->pixmapFormats[depth].pPixel; + if (xglScreenInfo.depth != 16 && xglScreenInfo.depth != 24) + return FALSE; - if (format->doublebuffer) + for (pVisual = xglVisuals; pVisual; pVisual = pVisual->next) { - pScreenPriv->backSurface = - glitz_surface_create (pScreenPriv->drawable, - pScreenPriv->pixmapFormats[depth].format, - pScreen->width, pScreen->height, - 0, NULL); - if (!pScreenPriv->backSurface) - return FALSE; + if (pVisual->pPixel->depth == xglScreenInfo.depth) + break; + } + + if (!pVisual) + return FALSE; - glitz_surface_attach (pScreenPriv->backSurface, - pScreenPriv->drawable, - GLITZ_DRAWABLE_BUFFER_BACK_COLOR); + bpp = pVisual->pPixel->masks.bpp; + format = glitz_drawable_get_format (pScreenPriv->drawable); + if (format->doublebuffer) numConfig *= 2; - } pConfig = xcalloc (sizeof (__GLXvisualConfig), numConfig); if (!pConfig) @@ -4954,40 +5664,30 @@ xglInitVisualConfigs (ScreenPtr pScreen) xfree (pConfig); return FALSE; } - + for (i = 0; i < numConfig; i++) { ppConfigPriv[i] = &pConfigPriv[i]; - + pConfig[i].vid = (VisualID) (-1); pConfig[i].class = -1; pConfig[i].rgba = TRUE; - + pConfig[i].redSize = format->color.red_size; pConfig[i].greenSize = format->color.green_size; pConfig[i].blueSize = format->color.blue_size; + pConfig[i].alphaSize = format->color.alpha_size; - pConfig[i].redMask = pPixel->masks.red_mask; - pConfig[i].greenMask = pPixel->masks.green_mask; - pConfig[i].blueMask = pPixel->masks.blue_mask; - - if (format->color.alpha_size) - { - pConfig[i].alphaSize = format->color.alpha_size; - pConfig[i].alphaMask = pPixel->masks.alpha_mask; - } - else - { - pConfig[i].alphaSize = 0; - pConfig[i].alphaMask = 0; - } + pConfig[i].redMask = pVisual->pPixel->masks.red_mask; + pConfig[i].greenMask = pVisual->pPixel->masks.green_mask; + pConfig[i].blueMask = pVisual->pPixel->masks.blue_mask; + pConfig[i].alphaMask = pVisual->pPixel->masks.alpha_mask; if (i == 1) { pConfig[i].doubleBuffer = FALSE; pConfig[i].depthSize = 0; pConfig[i].stencilSize = 0; - } else { @@ -4995,19 +5695,19 @@ xglInitVisualConfigs (ScreenPtr pScreen) pConfig[i].depthSize = format->depth_size; pConfig[i].stencilSize = format->stencil_size; } - + pConfig[i].stereo = FALSE; - - if (depth == 16) + + if (pScreen->rootDepth == 16) pConfig[i].bufferSize = 16; else pConfig[i].bufferSize = 32; pConfig[i].auxBuffers = 0; pConfig[i].level = 0; - + pConfig[i].visualRating = GLX_NONE; - + pConfig[i].transparentPixel = GLX_NONE; pConfig[i].transparentRed = 0; pConfig[i].transparentGreen = 0; @@ -5019,10 +5719,10 @@ xglInitVisualConfigs (ScreenPtr pScreen) GlxSetVisualConfigs (numConfig, pConfig, (void **) ppConfigPriv); /* Wrap screenProbe */ - if (__glDDXScreenInfo.screenProbe != xglScreenProbe) + if (__xglScreenInfoPtr->screenProbe != xglScreenProbe) { - screenInfoPriv.screenProbe = __glDDXScreenInfo.screenProbe; - __glDDXScreenInfo.screenProbe = xglScreenProbe; + screenInfoPriv.screenProbe = __xglScreenInfoPtr->screenProbe; + __xglScreenInfoPtr->screenProbe = xglScreenProbe; } visuals = pScreen->visuals; @@ -5060,6 +5760,10 @@ xglInitVisualConfigs (ScreenPtr pScreen) pScreen->rootDepth = rootDepth; pScreen->rootVisual = defaultVis; +#ifndef NGLXLOG + xglInitGlxLog (); +#endif + xfree (installedCmaps); xfree (pConfigPriv); xfree (pConfig); diff --git a/hw/xgl/glxext/xglglxext.h b/hw/xgl/glxext/xglglxext.h index 2fe9d742f..c353783af 100644 --- a/hw/xgl/glxext/xglglxext.h +++ b/hw/xgl/glxext/xglglxext.h @@ -12,11 +12,11 @@ * software for any purpose. It is provided "as is" without express or * implied warranty. * - * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * 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, + * 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. * @@ -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_ */ diff --git a/hw/xgl/glxext/xglglxlog.c b/hw/xgl/glxext/xglglxlog.c new file mode 100644 index 000000000..0f194c9ed --- /dev/null +++ b/hw/xgl/glxext/xglglxlog.c @@ -0,0 +1,4519 @@ +/* + * Copyright © 2005 Novell, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of + * Novell, Inc. not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior permission. + * Novell, Inc. makes no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: David Reveman <davidr@novell.com> + */ + +#include "xglglx.h" +#include "xglglxext.h" +#include "glapitable.h" + +#ifndef NGLXEXTLOG + +static struct _glapi_table *nativeRenderTable = 0; + +static FILE *logFp = 0; + +static Bool logVertexAttribs = FALSE; + +static struct VertexAttribCount { + int n; + char *name; +} vCnt[] = { + { 0, "glArrayElement" }, + { 0, "glCallList" }, + { 0, "glCallLists" }, + { 0, "glColor3bv" }, + { 0, "glColor3dv" }, + { 0, "glColor3fv" }, + { 0, "glColor3iv" }, + { 0, "glColor3sv" }, + { 0, "glColor3ubv" }, + { 0, "glColor3uiv" }, + { 0, "glColor3usv" }, + { 0, "glColor4bv" }, + { 0, "glColor4dv" }, + { 0, "glColor4fv" }, + { 0, "glColor4iv" }, + { 0, "glColor4sv" }, + { 0, "glColor4ubv" }, + { 0, "glColor4uiv" }, + { 0, "glColor4usv" }, + { 0, "glEdgeFlagv" }, + { 0, "glEvalCoord1dv" }, + { 0, "glEvalCoord1fv" }, + { 0, "glEvalCoord2dv" }, + { 0, "glEvalCoord2fv" }, + { 0, "glEvalPoint1" }, + { 0, "glEvalPoint2" }, + { 0, "glIndexdv" }, + { 0, "glIndexfv" }, + { 0, "glIndexiv" }, + { 0, "glIndexsv" }, + { 0, "glIndexubv" }, + { 0, "glMaterialf" }, + { 0, "glMaterialfv" }, + { 0, "glMateriali" }, + { 0, "glMaterialiv" }, + { 0, "glNormal3bv" }, + { 0, "glNormal3dv" }, + { 0, "glNormal3fv" }, + { 0, "glNormal3iv" }, + { 0, "glNormal3sv" }, + { 0, "glTexCoord1dv" }, + { 0, "glTexCoord1fv" }, + { 0, "glTexCoord1iv" }, + { 0, "glTexCoord1sv" }, + { 0, "glTexCoord2dv" }, + { 0, "glTexCoord2fv" }, + { 0, "glTexCoord2iv" }, + { 0, "glTexCoord2sv" }, + { 0, "glTexCoord3dv" }, + { 0, "glTexCoord3fv" }, + { 0, "glTexCoord3iv" }, + { 0, "glTexCoord3sv" }, + { 0, "glTexCoord4dv" }, + { 0, "glTexCoord4fv" }, + { 0, "glTexCoord4iv" }, + { 0, "glTexCoord4sv" }, + { 0, "glVertex2dv" }, + { 0, "glVertex2fv" }, + { 0, "glVertex2iv" }, + { 0, "glVertex2sv" }, + { 0, "glVertex3dv" }, + { 0, "glVertex3fv" }, + { 0, "glVertex3iv" }, + { 0, "glVertex3sv" }, + { 0, "glVertex4dv" }, + { 0, "glVertex4fv" }, + { 0, "glVertex4iv" }, + { 0, "glVertex4sv" }, + { 0, "glMultiTexCoord1dv" }, + { 0, "glMultiTexCoord1fv" }, + { 0, "glMultiTexCoord1iv" }, + { 0, "glMultiTexCoord1sv" }, + { 0, "glMultiTexCoord2dv" }, + { 0, "glMultiTexCoord2fv" }, + { 0, "glMultiTexCoord2iv" }, + { 0, "glMultiTexCoord2sv" }, + { 0, "glMultiTexCoord3dv" }, + { 0, "glMultiTexCoord3fv" }, + { 0, "glMultiTexCoord3iv" }, + { 0, "glMultiTexCoord3sv" }, + { 0, "glMultiTexCoord4dv" }, + { 0, "glMultiTexCoord4fv" }, + { 0, "glMultiTexCoord4iv" }, + { 0, "glMultiTexCoord4sv" }, + { 0, "glFogCoordfv" }, + { 0, "glFogCoorddv" }, + { 0, "glSecondaryColor3bv" }, + { 0, "glSecondaryColor3dv" }, + { 0, "glSecondaryColor3fv" }, + { 0, "glSecondaryColor3iv" }, + { 0, "glSecondaryColor3sv" }, + { 0, "glSecondaryColor3ubv" }, + { 0, "glSecondaryColor3uiv" }, + { 0, "glSecondaryColor3usv" } +}; + +#define arrayElementIndex 0 +#define callListIndex 1 +#define callListsIndex 2 +#define color3bvIndex 3 +#define color3dvIndex 4 +#define color3fvIndex 5 +#define color3ivIndex 6 +#define color3svIndex 7 +#define color3ubvIndex 8 +#define color3uivIndex 9 +#define color3usvIndex 10 +#define color4bvIndex 11 +#define color4dvIndex 12 +#define color4fvIndex 13 +#define color4ivIndex 14 +#define color4svIndex 15 +#define color4ubvIndex 16 +#define color4uivIndex 17 +#define color4usvIndex 18 +#define edgeFlagvIndex 19 +#define evalCoord1dvIndex 20 +#define evalCoord1fvIndex 21 +#define evalCoord2dvIndex 22 +#define evalCoord2fvIndex 23 +#define evalPoint1Index 24 +#define evalPoint2Index 25 +#define indexdvIndex 26 +#define indexfvIndex 27 +#define indexivIndex 28 +#define indexsvIndex 29 +#define indexubvIndex 30 +#define materialfIndex 31 +#define materialfvIndex 32 +#define materialiIndex 33 +#define materialivIndex 34 +#define normal3bvIndex 35 +#define normal3dvIndex 36 +#define normal3fvIndex 37 +#define normal3ivIndex 38 +#define normal3svIndex 39 +#define texCoord1dvIndex 40 +#define texCoord1fvIndex 41 +#define texCoord1ivIndex 42 +#define texCoord1svIndex 43 +#define texCoord2dvIndex 44 +#define texCoord2fvIndex 45 +#define texCoord2ivIndex 46 +#define texCoord2svIndex 47 +#define texCoord3dvIndex 48 +#define texCoord3fvIndex 49 +#define texCoord3ivIndex 50 +#define texCoord3svIndex 51 +#define texCoord4dvIndex 52 +#define texCoord4fvIndex 53 +#define texCoord4ivIndex 54 +#define texCoord4svIndex 55 +#define vertex2dvIndex 56 +#define vertex2fvIndex 57 +#define vertex2ivIndex 58 +#define vertex2svIndex 59 +#define vertex3dvIndex 60 +#define vertex3fvIndex 61 +#define vertex3ivIndex 62 +#define vertex3svIndex 63 +#define vertex4dvIndex 64 +#define vertex4fvIndex 65 +#define vertex4ivIndex 66 +#define vertex4svIndex 67 +#define multiTexCoord1dvIndex 68 +#define multiTexCoord1fvIndex 69 +#define multiTexCoord1ivIndex 70 +#define multiTexCoord1svIndex 71 +#define multiTexCoord2dvIndex 72 +#define multiTexCoord2fvIndex 73 +#define multiTexCoord2ivIndex 74 +#define multiTexCoord2svIndex 75 +#define multiTexCoord3dvIndex 76 +#define multiTexCoord3fvIndex 77 +#define multiTexCoord3ivIndex 78 +#define multiTexCoord3svIndex 79 +#define multiTexCoord4dvIndex 80 +#define multiTexCoord4fvIndex 81 +#define multiTexCoord4ivIndex 82 +#define multiTexCoord4svIndex 83 +#define fogCoordfvIndex 84 +#define fogCoorddvIndex 85 +#define secondaryColor3bvIndex 86 +#define secondaryColor3dvIndex 87 +#define secondaryColor3fvIndex 88 +#define secondaryColor3ivIndex 89 +#define secondaryColor3svIndex 90 +#define secondaryColor3ubvIndex 91 +#define secondaryColor3uivIndex 92 +#define secondaryColor3usvIndex 93 + +static void +logAccum (GLenum op, + GLfloat value) +{ + fprintf (logFp, "glAccum (0x%x, %f)\n", op, value); + (*nativeRenderTable->Accum) (op, value); +} + +static void +logAlphaFunc (GLenum func, + GLclampf ref) +{ + fprintf (logFp, "glAlphaFunc (0x%x, %f)\n", func, ref); + (*nativeRenderTable->AlphaFunc) (func, ref); +} + +static GLboolean +logAreTexturesResident (GLsizei n, + const GLuint *textures, + GLboolean *residences) +{ + fprintf (logFp, "glAreTexturesResident (%d, %p, %p)\n", n, textures, + residences); + return (*nativeRenderTable->AreTexturesResident) (n, textures, + residences); +} + +static void +logArrayElement (GLint i) +{ + vCnt[arrayElementIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glArrayElement (%d)\n", i); + (*nativeRenderTable->ArrayElement) (i); +} + +static void +logBegin (GLenum mode) +{ + fprintf (logFp, "glBegin (0x%x)\n", mode); + (*nativeRenderTable->Begin) (mode); +} + +static void +logBindTexture (GLenum target, + GLuint texture) +{ + fprintf (logFp, "glBindTexture (0x%x, %u)\n", target, texture); + (*nativeRenderTable->BindTexture) (target, texture); +} + +static void +logBitmap (GLsizei width, + GLsizei height, + GLfloat xorig, + GLfloat yorig, + GLfloat xmove, + GLfloat ymove, + const GLubyte *bitmap) +{ + fprintf (logFp, "glBitmap (%d, %d, %f, %f, %f, %f, %p)\n", + width, height, xorig, yorig, xmove, ymove, bitmap); + (*nativeRenderTable->Bitmap) (width, height, xorig, yorig, + xmove, ymove, bitmap); +} + +static void +logBlendFunc (GLenum sfactor, + GLenum dfactor) +{ + fprintf (logFp, "glBlendFunc (0x%x, 0x%x)\n", sfactor, dfactor); + (*nativeRenderTable->BlendFunc) (sfactor, dfactor); +} + +static void +logCallList (GLuint list) +{ + vCnt[callListIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glCallList (%u)\n", list); + (*nativeRenderTable->CallList) (list); +} + +static void +logCallLists (GLsizei n, + GLenum type, + const void *lists) +{ + vCnt[callListsIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glCallLists (%d, 0x%x, %p)\n", n, type, lists); + (*nativeRenderTable->CallLists) (n, type, lists); +} + +static void +logClear (GLbitfield mask) +{ + fprintf (logFp, "glClear (0x%x)\n", mask); + (*nativeRenderTable->Clear) (mask); +} + +static void +logClearAccum (GLfloat red, + GLfloat green, + GLfloat blue, + GLfloat alpha) +{ + fprintf (logFp, "glClearAccum (%f, %f, %f, %f)\n", + red, green, blue, alpha); + (*nativeRenderTable->ClearAccum) (red, green, blue, alpha); +} + +static void +logClearColor (GLclampf red, + GLclampf green, + GLclampf blue, + GLclampf alpha) +{ + fprintf (logFp, "glClearColor (%f, %f, %f, %f)\n", + red, green, blue, alpha); + (*nativeRenderTable->ClearColor) (red, green, blue, alpha); +} + +static void +logClearDepth (GLclampd depth) +{ + fprintf (logFp, "glClearDepth (%f)\n", depth); + (*nativeRenderTable->ClearDepth) (depth); +} + +static void +logClearIndex (GLfloat c) +{ + fprintf (logFp, "glClearIndex (%f)\n", c); + (*nativeRenderTable->ClearIndex) (c); +} + +static void +logClearStencil (GLint s) +{ + fprintf (logFp, "glClearStencil (%d)\n", s); + (*nativeRenderTable->ClearStencil) (s); +} + +static void +logClipPlane (GLenum plane, + const GLdouble *equation) +{ + fprintf (logFp, "glClipPlane (0x%x, %p)\n", plane, equation); + (*nativeRenderTable->ClipPlane) (plane, equation); +} + +static void +logColor3bv (const GLbyte *v) +{ + vCnt[color3bvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glColor3bv (%p)\n", v); + (*nativeRenderTable->Color3bv) (v); +} + +static void +logColor3dv (const GLdouble *v) +{ + vCnt[color3dvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glColor3dv (%p)\n", v); + (*nativeRenderTable->Color3dv) (v); +} + +static void +logColor3fv (const GLfloat *v) +{ + vCnt[color3fvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glColor3fv (%p)\n", v); + (*nativeRenderTable->Color3fv) (v); +} + +static void +logColor3iv (const GLint *v) +{ + vCnt[color3ivIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glColor3iv (%p)\n", v); + (*nativeRenderTable->Color3iv) (v); +} + +static void +logColor3sv (const GLshort *v) +{ + vCnt[color3svIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glColor3sv (%p)\n", v); + (*nativeRenderTable->Color3sv) (v); +} + +static void +logColor3ubv (const GLubyte *v) +{ + vCnt[color3ubvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glColor3ubv (%p)\n", v); + (*nativeRenderTable->Color3ubv) (v); +} + +static void +logColor3uiv (const GLuint *v) +{ + vCnt[color3uivIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glColor3uiv (%p)\n", v); + (*nativeRenderTable->Color3uiv) (v); +} + +static void +logColor3usv (const GLushort *v) +{ + vCnt[color3usvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glColor3usv (%p)\n", v); + (*nativeRenderTable->Color3usv) (v); +} + +static void +logColor4bv (const GLbyte *v) +{ + vCnt[color4bvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glColor4bv (%p)\n", v); + (*nativeRenderTable->Color4bv) (v); +} + +static void +logColor4dv (const GLdouble *v) +{ + vCnt[color4dvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glColor4dv (%p)\n", v); + (*nativeRenderTable->Color4dv) (v); +} + +static void +logColor4fv (const GLfloat *v) +{ + vCnt[color4fvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glColor4fv (%p)\n", v); + (*nativeRenderTable->Color4fv) (v); +} + +static void +logColor4iv (const GLint *v) +{ + vCnt[color4ivIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glColor4iv (%p)\n", v); + (*nativeRenderTable->Color4iv) (v); +} + +static void +logColor4sv (const GLshort *v) +{ + vCnt[color4svIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glColor4sv (%p)\n", v); + (*nativeRenderTable->Color4sv) (v); +} + +static void +logColor4ubv (const GLubyte *v) +{ + vCnt[color4ubvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glColor4ubv (%p)\n", v); + (*nativeRenderTable->Color4ubv) (v); +} + +static void +logColor4uiv(const GLuint *v) +{ + vCnt[color4uivIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glColor4uiv (%p)\n", v); + (*nativeRenderTable->Color4uiv) (v); +} + +static void +logColor4usv (const GLushort *v) +{ + vCnt[color4usvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glColor4usv (%p)\n", v); + (*nativeRenderTable->Color4usv) (v); +} + +static void +logColorMask (GLboolean red, + GLboolean green, + GLboolean blue, + GLboolean alpha) +{ + fprintf (logFp, "glColorMask (%d, %d, %d, %d)\n", red, green, blue, alpha); + (*nativeRenderTable->ColorMask) (red, green, blue, alpha); +} + +static void +logColorMaterial (GLenum face, + GLenum mode) +{ + fprintf (logFp, "glColorMaterial (0x%x, 0x%x)\n", face, mode); + (*nativeRenderTable->ColorMaterial) (face, mode); +} + +static void +logColorPointer (GLint size, + GLenum type, + GLsizei stride, + const void *pointer) +{ + fprintf (logFp, "glColorPointer (%d, 0x%x, %d, %p)\n", + size, type, stride, pointer); + (*nativeRenderTable->ColorPointer) (size, type, stride, pointer); +} + +static void +logCopyPixels (GLint x, + GLint y, + GLsizei width, + GLsizei height, + GLenum type) +{ + fprintf (logFp, "glCopyPixels (%d, %d, %d, %d, 0x%x)\n", + x, y, width, height, type); + (*nativeRenderTable->CopyPixels) (x, y, width, height, type); +} + +static void +logCopyTexImage1D (GLenum target, + GLint level, + GLenum internalFormat, + GLint x, + GLint y, + GLsizei width, + GLint border) +{ + fprintf (logFp, "glCopyTexImage1D (0x%x, %d, 0x%x, %d, %d, %d, %d)\n", + target, level, internalFormat, x, y, width, border); + (*nativeRenderTable->CopyTexImage1D) (target, level, internalFormat, + x, y, width, border); +} + +static void +logCopyTexImage2D (GLenum target, + GLint level, + GLenum internalFormat, + GLint x, + GLint y, + GLsizei width, + GLsizei height, + GLint border) +{ + fprintf (logFp, "glCopyTexImage2D (0x%x, %d, 0x%x, %d, %d, %d, %d, %d)\n", + target, level, internalFormat, x, y, width, height, border); + (*nativeRenderTable->CopyTexImage2D) (target, level, internalFormat, + x, y, width, height, border); +} + +static void +logCopyTexSubImage1D (GLenum target, + GLint level, + GLint xoffset, + GLint x, + GLint y, + GLsizei width) +{ + fprintf (logFp, "glCopyTexSubImage1D (0x%x, %d, %d, %d, %d, %d)\n", + target, level, xoffset, x, y, width); + (*nativeRenderTable->CopyTexSubImage1D) (target, level, xoffset, x, y, + width); +} + +static void +logCopyTexSubImage2D (GLenum target, + GLint level, + GLint xoffset, + GLint yoffset, + GLint x, + GLint y, + GLsizei width, + GLsizei height) +{ + fprintf (logFp, "glCopyTexSubImage2D (0x%x, %d, %d, %d, %d, %d, %d, %d)\n", + target, level, xoffset, yoffset, x, y, width, height); + (*nativeRenderTable->CopyTexSubImage2D) (target, level, + xoffset, yoffset, x, y, + width, height); +} + +static void +logCullFace (GLenum mode) +{ + fprintf (logFp, "glCullFace (0x%x)\n", mode); + (*nativeRenderTable->CullFace) (mode); +} + +static void +logDeleteLists (GLuint list, + GLsizei range) +{ + fprintf (logFp, "glDeleteLists (%d, %d)\n", list, range); + (*nativeRenderTable->DeleteLists) (list, range); +} + +static void +logDeleteTextures (GLsizei n, const GLuint *textures) +{ + fprintf (logFp, "glDeleteTextures (%d, %p)\n", n, textures); + (*nativeRenderTable->DeleteTextures) (n, textures); +} + +static void +logDepthFunc (GLenum func) +{ + fprintf (logFp, "glDepthFunc (0x%x)\n", func); + (*nativeRenderTable->DepthFunc) (func); +} + +static void +logDepthMask (GLboolean flag) +{ + fprintf (logFp, "glDepthMask (%d)\n", flag); + (*nativeRenderTable->DepthMask) (flag); +} + +static void +logDepthRange (GLclampd zNear, + GLclampd zFar) +{ + fprintf (logFp, "glDepthRange (%f, %f)\n", zNear, zFar); + (*nativeRenderTable->DepthRange) (zNear, zFar); +} + +static void +logDisable (GLenum cap) +{ + fprintf (logFp, "glDisable (0x%x)\n", cap); + (*nativeRenderTable->Disable) (cap); +} + +static void +logDisableClientState (GLenum array) +{ + fprintf (logFp, "glDisableClientState (0x%x)\n", array); + (*nativeRenderTable->DisableClientState) (array); +} + +static void +logDrawArrays (GLenum mode, + GLint first, + GLsizei count) +{ + fprintf (logFp, "glDrawArrays (0x%x, %d, %d)\n", mode, first, count); + (*nativeRenderTable->DrawArrays) (mode, first, count); +} + +static void +logDrawBuffer (GLenum mode) +{ + fprintf (logFp, "glDrawBuffer (0x%x)\n", mode); + (*nativeRenderTable->DrawBuffer) (mode); +} + +static void +logDrawElements (GLenum mode, + GLsizei count, + GLenum type, + const void *indices) +{ + fprintf (logFp, "glDrawElements (0x%x, %d, 0x%x, %p)\n", + mode, count, type, indices); + (*nativeRenderTable->DrawElements) (mode, count, type, indices); +} + +static void +logDrawPixels (GLsizei width, + GLsizei height, + GLenum format, + GLenum type, + const void *pixels) +{ + fprintf (logFp, "glDrawPixels (%d, %d, 0x%x, 0x%x, %p)\n", + width, height, format, type, pixels); + (*nativeRenderTable->DrawPixels) (width, height, format, type, pixels); +} + +static void +logEdgeFlagPointer (GLsizei stride, + const void *pointer) +{ + fprintf (logFp, "glEdgeFlagPointer (%d, %p)", stride, pointer); + (*nativeRenderTable->EdgeFlagPointer) (stride, pointer); +} + +static void +logEdgeFlagv (const GLboolean *flag) +{ + vCnt[edgeFlagvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glEdgeFlagv (%p)\n", flag); + (*nativeRenderTable->EdgeFlagv) (flag); +} + +static void +logEnable (GLenum cap) +{ + fprintf (logFp, "glEnable (0x%x)\n", cap); + (*nativeRenderTable->Enable) (cap); +} + +static void +logEnableClientState (GLenum array) +{ + fprintf (logFp, "glEnableClientState (0x%x)\n", array); + (*nativeRenderTable->EnableClientState) (array); +} + +static void +logEnd (void) +{ + int i; + + for (i = 0; i < sizeof (vCnt) / sizeof (vCnt[0]); i++) + { + if (vCnt[i].n) + { + fprintf (logFp, " %s: %d\n", vCnt[i].name, vCnt[i].n); + vCnt[i].n = 0; + } + } + + fprintf (logFp, "glEnd ()\n" ); + (*nativeRenderTable->End) (); +} + +static void +logEndList (void) +{ + fprintf (logFp, "glEndList ()\n" ); + (*nativeRenderTable->EndList) (); +} + +static void +logEvalCoord1dv (const GLdouble *u) +{ + vCnt[evalCoord1dvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glEvalCoord1dv (%p)\n", u); + (*nativeRenderTable->EvalCoord1dv) (u); +} + +static void +logEvalCoord1fv (const GLfloat *u) +{ + vCnt[evalCoord1fvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glEvalCoord1fv (%p)\n", u); + (*nativeRenderTable->EvalCoord1fv) (u); +} + +static void +logEvalCoord2dv (const GLdouble *u) +{ + vCnt[evalCoord2dvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glEvalCoord2dv (%p)\n", u); + (*nativeRenderTable->EvalCoord2dv) (u); +} + +static void +logEvalCoord2fv (const GLfloat *u) +{ + vCnt[evalCoord1fvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glEvalCoord2fv (%p)\n", u); + (*nativeRenderTable->EvalCoord2fv) (u); +} + +static void +logEvalMesh1 (GLenum mode, + GLint i1, + GLint i2) +{ + fprintf (logFp, "glEvalMesh1 (0x%x, %d, %d)\n", mode, i1, i2); + (*nativeRenderTable->EvalMesh1) (mode, i1, i2 ); +} + +static void +logEvalMesh2 (GLenum mode, + GLint i1, + GLint i2, + GLint j1, + GLint j2) +{ + fprintf (logFp, "glEvalMesh2 (0x%x, %d, %d, %d, %d)\n", + mode, i1, i2, j1, j2); + (*nativeRenderTable->EvalMesh2) (mode, i1, i2, j1, j2); +} + +static void +logEvalPoint1 (GLint i) +{ + vCnt[evalPoint1Index].n++; + if (logVertexAttribs) + fprintf (logFp, "glEvalPoint1 (%d)\n", i); + (*nativeRenderTable->EvalPoint1) (i); +} + +static void +logEvalPoint2 (GLint i, GLint j) +{ + vCnt[evalPoint2Index].n++; + if (logVertexAttribs) + fprintf (logFp, "glEvalPoint2 (%d, %d)\n", i, j); + (*nativeRenderTable->EvalPoint2) (i, j); +} + +static void +logFeedbackBuffer (GLsizei size, + GLenum type, + GLfloat *buffer) +{ + fprintf (logFp, "glFeedbackBuffer (%d, 0x%x, %p)\n", size, type, buffer); + (*nativeRenderTable->FeedbackBuffer) (size, type, buffer); +} + +static void +logFinish (void) +{ + fprintf (logFp, "glFinish ()\n"); + (*nativeRenderTable->Finish) (); +} + +static void +logFlush (void) +{ + fprintf (logFp, "glFlush ()\n"); + (*nativeRenderTable->Flush) (); +} + +static void +logFogf (GLenum pname, + GLfloat param) +{ + fprintf (logFp, "glFogf (0x%x, %f)\n", pname, param); + (*nativeRenderTable->Fogf) (pname, param); +} + +static void +logFogfv (GLenum pname, + const GLfloat *params) +{ + fprintf (logFp, "glFogfv (0x%x, %p)\n", pname, params); + (*nativeRenderTable->Fogfv) (pname, params); +} + +static void +logFogi (GLenum pname, + GLint param) +{ + fprintf (logFp, "glFogi (0x%x, %d)\n", pname, param); + (*nativeRenderTable->Fogi) (pname, param); +} + +static void +logFogiv (GLenum pname, + const GLint *params) +{ + fprintf (logFp, "glFogiv (0x%x, %p)\n", pname, params); + (*nativeRenderTable->Fogiv) (pname, params); +} + +static void +logFrontFace (GLenum mode) +{ + fprintf (logFp, "glFrontFace (0x%x)\n", mode); + (*nativeRenderTable->FrontFace) (mode); +} + +static void +logFrustum (GLdouble left, + GLdouble right, + GLdouble bottom, + GLdouble top, + GLdouble zNear, + GLdouble zFar) +{ + fprintf (logFp, "glFrustum (%f, %f, %f, %f, %f, %f)\n", + left, right, bottom, top, zNear, zFar); + (*nativeRenderTable->Frustum) (left, right, bottom, top, zNear, zFar); +} + +static GLuint +logGenLists (GLsizei range) +{ + fprintf (logFp, "glGenLists (%d)\n", range); + return (*nativeRenderTable->GenLists) (range); +} + +static void +logGenTextures (GLsizei n, + GLuint *textures) +{ + fprintf (logFp, "glGenTextures (%d, %p)\n", n, textures); + (*nativeRenderTable->GenTextures) (n, textures); +} +static void +logGetBooleanv (GLenum pname, + GLboolean *params) +{ + fprintf (logFp, "glGetBooleanv (0x%x, %p)\n", pname, params); + (*nativeRenderTable->GetBooleanv) (pname, params); +} + +static void +logGetClipPlane (GLenum plane, + GLdouble *equation) +{ + fprintf (logFp, "glGetClipPlane (0x%x, %p)\n", plane, equation); + (*nativeRenderTable->GetClipPlane) (plane, equation); +} + +static void +logGetDoublev (GLenum pname, + GLdouble *params) +{ + fprintf (logFp, "glGetDoublev (0x%x, %p)\n", pname, params); + (*nativeRenderTable->GetDoublev) (pname, params); +} + +static GLenum +logGetError (void) +{ + fprintf (logFp, "glGetError ()\n"); + return (*nativeRenderTable->GetError) (); +} + +static void +logGetFloatv (GLenum pname, + GLfloat *params) +{ + fprintf (logFp, "glGetFloatv (0x%x, %p)\n", pname, params); + (*nativeRenderTable->GetFloatv) (pname, params); +} + +static void +logGetIntegerv (GLenum pname, + GLint *params) +{ + fprintf (logFp, "glGetIntegerv (0x%x, %p)\n", pname, params); + (*nativeRenderTable->GetIntegerv) (pname, params); +} + +static void +logGetLightfv (GLenum light, + GLenum pname, + GLfloat *params) +{ + fprintf (logFp, "glGetLightfv (0x%x, 0x%x, %p)\n", light, pname, params); + (*nativeRenderTable->GetLightfv) (light, pname, params); +} + +static void +logGetLightiv (GLenum light, + GLenum pname, + GLint *params) +{ + fprintf (logFp, "glGetLightiv (0x%x, 0x%x, %p)\n", + light, pname, params); + (*nativeRenderTable->GetLightiv) (light, pname, params); +} + +static void +logGetMapdv (GLenum target, + GLenum query, + GLdouble *v) +{ + fprintf (logFp, "glGetMapdv (0x%x, 0x%x, %p)\n", target, query, v); + (*nativeRenderTable->GetMapdv) (target, query, v); +} + +static void +logGetMapfv (GLenum target, + GLenum query, + GLfloat *v) +{ + fprintf (logFp, "glGetMapfv (0x%x, 0x%x, %p)\n", target, query, v); + (*nativeRenderTable->GetMapfv) (target, query, v); +} + +static void +logGetMapiv (GLenum target, + GLenum query, + GLint *v) +{ + fprintf (logFp, "glGetMapiv (0x%x, 0x%x, %p)\n", target, query, v); + (*nativeRenderTable->GetMapiv) (target, query, v); +} + +static void +logGetMaterialfv (GLenum face, + GLenum pname, + GLfloat *params) +{ + fprintf (logFp, "glGetMaterialfv (0x%x, 0x%x, %p)\n", face, pname, params); + (*nativeRenderTable->GetMaterialfv) (face, pname, params); +} + +static void +logGetMaterialiv (GLenum face, + GLenum pname, + GLint *params) +{ + fprintf (logFp, "glGetMaterialiv (0x%x, 0x%x, %p)\n", face, pname, params); + (*nativeRenderTable->GetMaterialiv) (face, pname, params); +} + +static void +logGetPixelMapfv (GLenum map, + GLfloat *values) +{ + fprintf (logFp, "glGetPixelMapfv (0x%x, %p)\n", map, values); + (*nativeRenderTable->GetPixelMapfv) (map, values); +} + +static void +logGetPixelMapuiv (GLenum map, + GLuint *values) +{ + fprintf (logFp, "glGetPixelMapuiv (0x%x, %p)\n", map, values); + (*nativeRenderTable->GetPixelMapuiv) (map, values); +} + +static void +logGetPixelMapusv (GLenum map, + GLushort *values) +{ + fprintf (logFp, "glGetPixelMapusv (0x%x, %p)\n", map, values); + (*nativeRenderTable->GetPixelMapusv) (map, values); +} + +static void +logGetPointerv (GLenum pname, + GLvoid **params) +{ + fprintf (logFp, "glGetPointerv (0x%x, %p)\n", pname, params); + (*nativeRenderTable->GetPointerv) (pname, params); +} + +static void +logGetPolygonStipple (GLubyte *mask) +{ + fprintf (logFp, "glGetPolygonStipple (%p)\n", mask); + (*nativeRenderTable->GetPolygonStipple) (mask); +} + +static const GLubyte * +logGetString (GLenum name) +{ + fprintf (logFp, "glGetString (0x%x)\n", name); + return (*nativeRenderTable->GetString) (name); +} + +static void +logGetTexEnvfv (GLenum target, + GLenum pname, + GLfloat *params) +{ + fprintf (logFp, "glGetTexEnvfv (0x%x, 0x%x, %p)\n", target, pname, params); + (*nativeRenderTable->GetTexEnvfv) (target, pname, params); +} + +static void +logGetTexEnviv (GLenum target, + GLenum pname, + GLint *params) +{ + fprintf (logFp, "glGetTexEnviv (0x%x, 0x%x, %p)\n", target, pname, params); + (*nativeRenderTable->GetTexEnviv) (target, pname, params); +} + +static void +logGetTexGendv (GLenum coord, + GLenum pname, + GLdouble *params) +{ + fprintf (logFp, "glGetTexGendv (0x%x, 0x%x, %p)\n", coord, pname, params); + (*nativeRenderTable->GetTexGendv) (coord, pname, params); +} + +static void +logGetTexGenfv (GLenum coord, + GLenum pname, + GLfloat *params) +{ + fprintf (logFp, "glGetTexGenfv (0x%x, 0x%x, %p)\n", coord, pname, params); + (*nativeRenderTable->GetTexGenfv) (coord, pname, params); +} + +static void +logGetTexGeniv (GLenum coord, + GLenum pname, + GLint *params) +{ + fprintf (logFp, "glGetTexGeniv (0x%x, 0x%x, %p)\n", coord, pname, params); + (*nativeRenderTable->GetTexGeniv) (coord, pname, params); +} + +static void +logGetTexImage (GLenum target, + GLint level, + GLenum format, + GLenum type, + void *pixels) +{ + fprintf (logFp, "glGetTexImage (0x%x, %d, 0x%x, 0x%x, %p)\n", + target, level, format, type, pixels); + (*nativeRenderTable->GetTexImage) (target, level, format, type, + pixels); +} +static void +logGetTexLevelParameterfv (GLenum target, + GLint level, + GLenum pname, + GLfloat *params) +{ + fprintf (logFp, "glGetTexLevelParameterfv (0x%x, %d, 0x%x, %p)\n", + target, level, pname, params); + (*nativeRenderTable->GetTexLevelParameterfv) (target, level, + pname, params); +} + +static void +logGetTexLevelParameteriv (GLenum target, + GLint level, + GLenum pname, + GLint *params) +{ + fprintf (logFp, "glGetTexLevelParameteriv (0x%x, %d, 0x%x, %p)\n", + target, level, pname, params); + (*nativeRenderTable->GetTexLevelParameteriv) (target, level, + pname, params); +} + +static void +logGetTexParameterfv (GLenum target, + GLenum pname, + GLfloat *params) +{ + fprintf (logFp, "glGetTexParameterfv (0x%x, 0x%x, %p)\n", + target, pname, params); + (*nativeRenderTable->GetTexParameterfv) (target, pname, params); +} + +static void +logGetTexParameteriv (GLenum target, + GLenum pname, + GLint *params) +{ + fprintf (logFp, "glGetTexParameteriv (0x%x, 0x%x, %p)\n", + target, pname, params); + (*nativeRenderTable->GetTexParameteriv) (target, pname, params); +} + +static void +logHint (GLenum target, + GLenum mode) +{ + fprintf (logFp, "glHint (0x%x, 0x%x)\n", target, mode); + (*nativeRenderTable->Hint) (target, mode); +} + +static void +logIndexMask (GLuint mask) +{ + fprintf (logFp, "glIndexMask (%d)\n", mask); + (*nativeRenderTable->IndexMask) (mask); +} + +static void +logIndexPointer (GLenum type, + GLsizei stride, + const void *pointer) +{ + fprintf (logFp, "glIndexPointer (0x%x, %d, %p)\n", type, stride, pointer); + (*nativeRenderTable->IndexPointer) (type, stride, pointer); +} + +static void +logIndexdv (const GLdouble *c) +{ + vCnt[indexdvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glIndexdv (%p)\n", c); + (*nativeRenderTable->Indexdv) (c); +} + +static void +logIndexfv (const GLfloat *c) +{ + vCnt[indexfvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glIndexfv (%p)\n", c); + (*nativeRenderTable->Indexfv) (c); +} + +static void +logIndexiv (const GLint *c) +{ + vCnt[indexivIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glIndexiv (%p)\n", c); + (*nativeRenderTable->Indexiv) (c); +} + +static void +logIndexsv (const GLshort *c) +{ + vCnt[indexsvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glIndexsv (%p)\n", c); + (*nativeRenderTable->Indexsv) (c); +} + +static void +logIndexubv (const GLubyte *c) +{ + vCnt[indexubvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glIndexubv (%p)\n", c); + (*nativeRenderTable->Indexubv) (c); +} + +static void +logInitNames (void) +{ + fprintf (logFp, "glInitNames ()\n" ); + (*nativeRenderTable->InitNames) (); +} + +static void +logInterleavedArrays (GLenum format, + GLsizei stride, + const void *pointer) +{ + fprintf (logFp, "glInterleavedArrays (0x%x, %d, %p)\n", + format, stride, pointer); + (*nativeRenderTable->InterleavedArrays) (format, stride, pointer); +} + +static GLboolean +logIsEnabled (GLenum cap) +{ + fprintf (logFp, "glIsEnabled (0x%x)\n", cap); + return (*nativeRenderTable->IsEnabled) (cap); +} + +static GLboolean +logIsList (GLuint list) +{ + fprintf (logFp, "glIsList (%d)\n", list); + return (*nativeRenderTable->IsList) (list); +} + +static GLboolean +logIsTexture (GLuint texture) +{ + fprintf (logFp, "glIsTexture (%d)\n", texture); + return (*nativeRenderTable->IsTexture) (texture); +} + +static void +logLightModelf (GLenum pname, + GLfloat param) +{ + fprintf (logFp, "glLightModelf (0x%x, %f)\n", pname, param); + (*nativeRenderTable->LightModelf) (pname, param); +} + +static void +logLightModelfv (GLenum pname, + const GLfloat *params) +{ + fprintf (logFp, "glLightModelfv (0x%x, %p)\n", pname, params); + (*nativeRenderTable->LightModelfv) (pname, params); +} + +static void +logLightModeli (GLenum pname, + GLint param) +{ + fprintf (logFp, "glLightModeli (0x%x, %d)\n", pname, param); + (*nativeRenderTable->LightModeli) (pname, param); +} + +static void +logLightModeliv (GLenum pname, + const GLint *params) +{ + fprintf (logFp, "glLightModeliv (0x%x, %p)\n", pname, params); + (*nativeRenderTable->LightModeliv) (pname, params); +} + +static void +logLightf (GLenum light, + GLenum pname, + GLfloat param) +{ + fprintf (logFp, "glLightf (0x%x, 0x%x, %f)\n", light, pname, param); + (*nativeRenderTable->Lightf) (light, pname, param); +} + +static void +logLightfv (GLenum light, + GLenum pname, + const GLfloat *params) +{ + fprintf (logFp, "glLightfv (0x%x, 0x%x, %p)\n", light, pname, params); + (*nativeRenderTable->Lightfv) (light, pname, params); +} + +static void +logLighti (GLenum light, + GLenum pname, + GLint param) +{ + fprintf (logFp, "glLighti (0x%x, 0x%x, %d)\n", light, pname, param); + (*nativeRenderTable->Lighti) (light, pname, param); +} + +static void +logLightiv (GLenum light, + GLenum pname, + const GLint *params) +{ + fprintf (logFp, "glLightiv (0x%x, 0x%x, %p)\n", light, pname, params); + (*nativeRenderTable->Lightiv) (light, pname, params); +} + +static void +logLineStipple (GLint factor, + GLushort pattern) +{ + fprintf (logFp, "glLineStipple (%d, %d)\n", factor, pattern); + (*nativeRenderTable->LineStipple) (factor, pattern); +} + +static void +logLineWidth (GLfloat width) +{ + fprintf (logFp, "glLineWidth (%f)\n", width); + (*nativeRenderTable->LineWidth) (width); +} + +static void +logListBase (GLuint base) +{ + fprintf (logFp, "glListBase (%d)\n", base); + (*nativeRenderTable->ListBase) (base); +} + +static void +logLoadIdentity (void) +{ + fprintf (logFp, "glLoadIdentity ()\n"); + (*nativeRenderTable->LoadIdentity) (); +} + +static void +logLoadMatrixd (const GLdouble *m) +{ + fprintf (logFp, "glLoadMatrixd (%p)\n", m); + (*nativeRenderTable->LoadMatrixd) (m); +} + +static void +logLoadMatrixf (const GLfloat *m) +{ + fprintf (logFp, "glLoadMatrixf (%p)\n", m); + (*nativeRenderTable->LoadMatrixf) (m); +} + +static void +logLoadName (GLuint name) +{ + fprintf (logFp, "glLoadName (%d)\n", name); + (*nativeRenderTable->LoadName) (name); +} + +static void +logLogicOp (GLenum opcode) +{ + fprintf (logFp, "glLogicOp(0x%x)\n", opcode); + (*nativeRenderTable->LogicOp) (opcode); +} + +static void +logMap1d (GLenum target, + GLdouble u1, + GLdouble u2, + GLint stride, + GLint order, + const GLdouble *points) +{ + fprintf (logFp, "glMap1d (0x%x, %f, %f, %d, %d, %p)\n", + target, u1, u2, stride, order, points); + (*nativeRenderTable->Map1d) (target, u1, u2, stride, order, points); +} + +static void +logMap1f (GLenum target, + GLfloat u1, + GLfloat u2, + GLint stride, + GLint order, + const GLfloat *points) +{ + fprintf (logFp, "glMap1f (0x%x, %f, %f, %d, %d, %p)\n", + target, u1, u2, stride, order, points); + (*nativeRenderTable->Map1f) (target, u1, u2, stride, order, points); +} + +static void +logMap2d (GLenum target, + GLdouble u1, + GLdouble u2, + GLint ustride, + GLint uorder, + GLdouble v1, + GLdouble v2, + GLint vstride, + GLint vorder, + const GLdouble *points) +{ + fprintf (logFp, "glMap2d (0x%x, %f, %f, %d, %d, %f, %f, %d, %d, %p)\n", + target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points); + (*nativeRenderTable->Map2d) (target, u1, u2, ustride, uorder, v1, v2, + vstride, vorder, points); +} + +static void +logMap2f (GLenum target, + GLfloat u1, + GLfloat u2, + GLint ustride, + GLint uorder, + GLfloat v1, + GLfloat v2, + GLint vstride, + GLint vorder, + const GLfloat *points) +{ + fprintf (logFp, "glMap2f (0x%x, %f, %f, %d, %d, %f, %f, %d, %d, %p)\n", + target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points); + (*nativeRenderTable->Map2f) (target, u1, u2, ustride, uorder, v1, v2, + vstride, vorder, points); +} + +static void +logMapGrid1d (GLint un, + GLdouble u1, + GLdouble u2) +{ + fprintf (logFp, "glMapGrid1d (%d, %f, %f)\n", un, u1, u2); + (*nativeRenderTable->MapGrid1d) (un, u1, u2); +} + +static void +logMapGrid1f (GLint un, + GLfloat u1, + GLfloat u2) +{ + fprintf (logFp, "glMapGrid1f (%d, %f, %f)\n", un, u1, u2); + (*nativeRenderTable->MapGrid1f) (un, u1, u2); +} + +static void +logMapGrid2d (GLint un, + GLdouble u1, + GLdouble u2, + GLint vn, + GLdouble v1, + GLdouble v2) +{ + fprintf (logFp, "glMapGrid2d (%d, %f, %f, %d, %f, %f)\n", + un, u1, u2, vn, v1, v2); + (*nativeRenderTable->MapGrid2d) (un, u1, u2, vn, v1, v2); +} + +static void +logMapGrid2f (GLint un, + GLfloat u1, + GLfloat u2, + GLint vn, + GLfloat v1, + GLfloat v2) +{ + fprintf (logFp, "glMapGrid2f (%d, %f, %f, %d, %f, %f)\n", + un, u1, u2, vn, v1, v2); + (*nativeRenderTable->MapGrid2f) (un, u1, u2, vn, v1, v2); +} + +static void +logMaterialf (GLenum face, + GLenum pname, + GLfloat param) +{ + vCnt[materialfIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glMaterialf (0x%x, 0x%x, %f)\n", face, pname, param); + (*nativeRenderTable->Materialf) (face, pname, param); +} + +static void +logMaterialfv (GLenum face, + GLenum pname, + const GLfloat *params) +{ + vCnt[materialfvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glMaterialfv (0x%x, 0x%x, %p)\n", + face, pname, params); + (*nativeRenderTable->Materialfv) (face, pname, params); +} + +static void +logMateriali (GLenum face, + GLenum pname, + GLint param) +{ + vCnt[materialiIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glMateriali (0x%x, 0x%x, %d)\n", face, pname, param); + (*nativeRenderTable->Materiali) (face, pname, param); +} + +static void +logMaterialiv (GLenum face, + GLenum pname, + const GLint *params) +{ + vCnt[materialivIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glMaterialiv (0x%x, 0x%x, %p)\n", + face, pname, params); + (*nativeRenderTable->Materialiv) (face, pname, params); +} + +static void +logMatrixMode (GLenum mode) +{ + fprintf (logFp, "glMatrixMode (0x%x)\n", mode); + (*nativeRenderTable->MatrixMode) (mode); +} + +static void +logMultMatrixd (const GLdouble *m) +{ + fprintf (logFp, "glMultMatrixd (%p)\n", m); + (*nativeRenderTable->MultMatrixd) (m); +} + +static void +logMultMatrixf (const GLfloat *m) +{ + fprintf (logFp, "glMultMatrixf (%p)\n", m); + (*nativeRenderTable->MultMatrixf) (m); +} + +static void +logNewList (GLuint list, + GLenum mode) +{ + fprintf (logFp, "glNewList (%d, 0x%x)\n", list, mode); + (*nativeRenderTable->NewList) (list, mode); +} + +static void +logNormal3bv (const GLbyte *v) +{ + vCnt[normal3bvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glNormal3bv (%p)\n", v); + (*nativeRenderTable->Normal3bv) (v); +} + +static void +logNormal3dv (const GLdouble *v) +{ + vCnt[normal3dvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glNormal3dv (%p)\n", v); + (*nativeRenderTable->Normal3dv) (v); +} + +static void +logNormal3fv (const GLfloat *v) +{ + vCnt[normal3fvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glNormal3fv (%p)\n", v); + (*nativeRenderTable->Normal3fv) (v); +} + +static void +logNormal3iv (const GLint *v) +{ + vCnt[normal3ivIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glNormal3iv (%p)\n", v); + (*nativeRenderTable->Normal3iv) (v); +} + +static void +logNormal3sv (const GLshort *v) +{ + vCnt[normal3svIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glNormal3sv (%p)\n", v); + (*nativeRenderTable->Normal3sv) (v); +} + +static void +logNormalPointer (GLenum type, + GLsizei stride, + const void *pointer) +{ + fprintf (logFp, "glNormalPointer (0x%x, %d, %p)\n", type, stride, pointer); + (*nativeRenderTable->NormalPointer) (type, stride, pointer); +} + +static void +logOrtho (GLdouble left, + GLdouble right, + GLdouble bottom, + GLdouble top, + GLdouble zNear, + GLdouble zFar) +{ + fprintf (logFp, "glOrtho (%f, %f, %f, %f, %f, %f)\n", + left, right, bottom, top, zNear, zFar); + (*nativeRenderTable->Ortho) (left, right, bottom, top, zNear, zFar); +} + +static void +logPassThrough (GLfloat token) +{ + fprintf (logFp, "glPassThrough (%f)\n", token); + (*nativeRenderTable->PassThrough) (token); +} + +static void +logPixelMapfv (GLenum map, + GLsizei mapsize, + const GLfloat *values) +{ + fprintf (logFp, "glPixelMapfv (0x%x, %d, %p)\n", map, mapsize, values); + (*nativeRenderTable->PixelMapfv) (map, mapsize, values); +} + +static void +logPixelMapuiv (GLenum map, + GLsizei mapsize, + const GLuint *values) +{ + fprintf (logFp, "glPixelMapuiv (0x%x, %d, %p)\n", map, mapsize, values); + (*nativeRenderTable->PixelMapuiv) (map, mapsize, values); +} + +static void +logPixelMapusv (GLenum map, + GLsizei mapsize, + const GLushort *values) +{ + fprintf (logFp, "glPixelMapusv (0x%x, %d, %p)\n", map, mapsize, values); + (*nativeRenderTable->PixelMapusv) (map, mapsize, values); +} + +static void +logPixelStoref (GLenum pname, + GLfloat param) +{ + fprintf (logFp, "glPixelStoref (0x%x, %f)\n", pname, param); + (*nativeRenderTable->PixelStoref) (pname, param); +} + +static void +logPixelStorei (GLenum pname, + GLint param) +{ + fprintf (logFp, "glPixelStorei (0x%x, %d)\n", pname, param); + (*nativeRenderTable->PixelStorei) (pname, param); +} + +static void +logPixelTransferf (GLenum pname, GLfloat param) +{ + fprintf (logFp, "glPixelTransferf (0x%x, %f)\n", pname, param); + (*nativeRenderTable->PixelTransferf) (pname, param); +} + +static void +logPixelTransferi (GLenum pname, + GLint param) +{ + fprintf (logFp, "glPixelTransferi (0x%x, %d)\n", pname, param); + (*nativeRenderTable->PixelTransferi) (pname, param); +} + +static void +logPixelZoom (GLfloat xfactor, + GLfloat yfactor) +{ + fprintf (logFp, "glPixelZoom (%f, %f)\n", xfactor, yfactor); + (*nativeRenderTable->PixelZoom) (xfactor, yfactor); +} + +static void +logPointSize (GLfloat size) +{ + fprintf (logFp, "glPointSize" ); + (*nativeRenderTable->PointSize) (size); +} + +static void +logPolygonMode (GLenum face, + GLenum mode) +{ + fprintf (logFp, "glPolygonMode (0x%x, 0x%x)\n", face, mode ); + (*nativeRenderTable->PolygonMode) (face, mode); +} + +static void +logPolygonOffset (GLfloat factor, + GLfloat units) +{ + fprintf (logFp, "glPolygonOffset (%f, %f)\n", factor, units); + (*nativeRenderTable->PolygonOffset) (factor, units); +} + +static void +logPolygonStipple (const GLubyte *mask) +{ + fprintf (logFp, "glPolygonStipple (%p)\n", mask); + (*nativeRenderTable->PolygonStipple) (mask); +} + +static void +logPopAttrib (void) +{ + fprintf (logFp, "glPopAttrib ()\n"); + (*nativeRenderTable->PopAttrib) (); +} + +static void +logPopClientAttrib (void) +{ + fprintf (logFp, "glPopClientAttrib ()\n" ); + (*nativeRenderTable->PopClientAttrib) (); +} + +static void +logPopMatrix (void) +{ + fprintf (logFp, "glPopMatrix ()\n" ); + (*nativeRenderTable->PopMatrix) (); +} + +static void +logPopName (void) +{ + fprintf (logFp, "glPopName ()\n"); + (*nativeRenderTable->PopName) (); +} + +static void +logPrioritizeTextures (GLsizei n, + const GLuint *textures, + const GLclampf *priorities) +{ + fprintf (logFp, "glPrioritizeTextures (%d, %p, %p)\n", + n, textures, priorities); + (*nativeRenderTable->PrioritizeTextures) (n, textures, priorities); +} + +static void +logPushAttrib (GLbitfield mask) +{ + fprintf (logFp, "glPushAttrib (0x%x)\n", mask); + (*nativeRenderTable->PushAttrib) (mask); +} + +static void +logPushClientAttrib (GLbitfield mask) +{ + fprintf (logFp, "glPushClientAttrib (0x%x)\n", mask); + (*nativeRenderTable->PushClientAttrib) (mask); +} + +static void +logPushMatrix (void) +{ + fprintf (logFp, "glPushMatrix ()\n" ); + (*nativeRenderTable->PushMatrix) (); +} + +static void +logPushName (GLuint name) +{ + fprintf (logFp, "glPushName (%d)\n", name); + (*nativeRenderTable->PushName) (name); +} + +static void +logRasterPos2dv (const GLdouble *v) +{ + fprintf (logFp, "glRasterPos2dv (%p)\n", v); + (*nativeRenderTable->RasterPos2dv) (v); +} + +static void +logRasterPos2fv (const GLfloat *v) +{ + fprintf (logFp, "glRasterPos2dv (%p)\n", v); + (*nativeRenderTable->RasterPos2fv) (v); +} + +static void +logRasterPos2iv (const GLint *v) +{ + fprintf (logFp, "glRasterPos2iv (%p)\n", v); + (*nativeRenderTable->RasterPos2iv) (v); +} + +static void +logRasterPos2sv (const GLshort *v) +{ + fprintf (logFp, "glRasterPos2sv (%p)\n", v); + (*nativeRenderTable->RasterPos2sv) (v); +} + +static void +logRasterPos3dv (const GLdouble *v) +{ + fprintf (logFp, "glRasterPos3dv (%p)\n", v); + (*nativeRenderTable->RasterPos3dv) (v); +} + +static void +logRasterPos3fv (const GLfloat *v) +{ + fprintf (logFp, "glRasterPos3fv (%p)\n", v); + (*nativeRenderTable->RasterPos3fv) (v); +} + +static void +logRasterPos3iv (const GLint *v) +{ + fprintf (logFp, "glRasterPos3iv (%p)\n", v); + (*nativeRenderTable->RasterPos3iv) (v); +} + +static void +logRasterPos3sv (const GLshort *v) +{ + fprintf (logFp, "glRasterPos3sv (%p)\n", v); + (*nativeRenderTable->RasterPos3sv) (v); +} + +static void +logRasterPos4dv (const GLdouble *v) +{ + fprintf (logFp, "glRasterPos4dv (%p)\n", v); + (*nativeRenderTable->RasterPos4dv) (v); +} + +static void +logRasterPos4fv (const GLfloat *v) +{ + fprintf (logFp, "glRasterPos4fv (%p)\n", v); + (*nativeRenderTable->RasterPos4fv) (v); +} + +static void +logRasterPos4iv (const GLint *v) +{ + fprintf (logFp, "glRasterPos4iv (%p)\n", v); + (*nativeRenderTable->RasterPos4iv) (v); +} + +static void +logRasterPos4sv (const GLshort *v) +{ + fprintf (logFp, "glRasterPos4sv (%p)\n", v); + (*nativeRenderTable->RasterPos4sv) (v); +} + +static void +logReadBuffer (GLenum mode) +{ + fprintf (logFp, "glReadBuffer (0x%x)\n", mode); + (*nativeRenderTable->ReadBuffer) (mode); +} + +static void +logReadPixels (GLint x, + GLint y, + GLsizei width, + GLsizei height, + GLenum format, + GLenum type, + void *pixels) +{ + fprintf (logFp, "glReadPixels (%d, %d, %d, %d, 0x%x, 0x%x, %p)\n", + x, y, width, height, format, type, pixels); + (*nativeRenderTable->ReadPixels) (x, y, width, height, format, type, + pixels); +} + +static void +logRectdv (const GLdouble *v1, + const GLdouble *v2) +{ + fprintf (logFp, "glRectdv (%p, %p)\n", v1, v2); + (*nativeRenderTable->Rectdv) (v1, v2); +} + +static void +logRectfv (const GLfloat *v1, + const GLfloat *v2) +{ + fprintf (logFp, "glRectfv (%p, %p)\n", v1, v2); + (*nativeRenderTable->Rectfv) (v1, v2); +} + +static void +logRectiv (const GLint *v1, + const GLint *v2) +{ + fprintf (logFp, "glRectiv (%p, %p)\n", v1, v2); + (*nativeRenderTable->Rectiv) (v1, v2); +} + +static void +logRectsv (const GLshort *v1, + const GLshort *v2) +{ + fprintf (logFp, "glRectsv (%p, %p)\n", v1, v2); + (*nativeRenderTable->Rectsv) (v1, v2); +} + +static GLint +logRenderMode (GLenum mode) +{ + fprintf (logFp, "glRenderMode (0x%x)\n", mode); + return (*nativeRenderTable->RenderMode) (mode); +} + +static void +logRotated (GLdouble angle, + GLdouble x, + GLdouble y, + GLdouble z) +{ + fprintf (logFp, "glRotated (%f, %f, %f, %f)\n", angle, x, y, z); + (*nativeRenderTable->Rotated) (angle, x, y, z); +} + +static void +logRotatef (GLfloat angle, + GLfloat x, + GLfloat y, + GLfloat z) +{ + fprintf (logFp, "glRotatef (%f, %f, %f, %f)\n", angle, x, y, z); + (*nativeRenderTable->Rotatef) (angle, x, y, z); +} + +static void +logScaled (GLdouble x, + GLdouble y, + GLdouble z) +{ + fprintf (logFp, "glScaled (%f, %f, %f)\n", x, y, z); + (*nativeRenderTable->Scaled) (x, y, z); +} + +static void +logScalef (GLfloat x, + GLfloat y, + GLfloat z) +{ + fprintf (logFp, "glScalef (%f, %f, %f)\n", x, y, z); + (*nativeRenderTable->Scalef) (x, y, z); +} + +static void +logScissor (GLint x, + GLint y, + GLsizei width, + GLsizei height) +{ + fprintf (logFp, "glScissor (%d, %d, %d, %d)\n", x, y, width, height); + (*nativeRenderTable->Scissor) (x, y, width, height); +} + +static void +logSelectBuffer (GLsizei size, + GLuint *buffer) +{ + fprintf (logFp, "glSelectBuffer (%d, %p)\n", size, buffer); + (*nativeRenderTable->SelectBuffer) (size, buffer); +} + +static void +logShadeModel (GLenum mode) +{ + fprintf (logFp, "glShadeModel (0x%x)\n", mode); + (*nativeRenderTable->ShadeModel) (mode); +} + +static void +logStencilFunc (GLenum func, + GLint ref, + GLuint mask) +{ + fprintf (logFp, "glStencilFunc (0x%x, %d, %d)\n", func, ref, mask); + (*nativeRenderTable->StencilFunc) (func, ref, mask); +} + +static void +logStencilMask (GLuint mask) +{ + fprintf (logFp, "glStencilMask (0x%x)\n", mask); + (*nativeRenderTable->StencilMask) (mask); +} + +static void +logStencilOp (GLenum fail, + GLenum zfail, + GLenum zpass) +{ + fprintf (logFp, "glStencilOp (0x%x, 0x%x, 0x%x)\n", fail, zfail, zpass); + (*nativeRenderTable->StencilOp) (fail, zfail, zpass); +} + +static void +logTexCoord1dv (const GLdouble *v) +{ + vCnt[texCoord1dvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glTexCoord1dv (%p)\n", v); + (*nativeRenderTable->TexCoord1dv) (v); +} + +static void +logTexCoord1fv (const GLfloat *v) +{ + vCnt[texCoord1fvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glTexCoord1fv (%p)\n", v); + (*nativeRenderTable->TexCoord1fv) (v); +} + +static void +logTexCoord1iv (const GLint *v) +{ + vCnt[texCoord1ivIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glTexCoord1iv (%p)\n", v); + (*nativeRenderTable->TexCoord1iv) (v); +} + +static void +logTexCoord1sv (const GLshort *v) +{ + vCnt[texCoord1svIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glTexCoord1sv (%p)\n", v); + (*nativeRenderTable->TexCoord1sv) (v); +} + +static void +logTexCoord2dv (const GLdouble *v) +{ + vCnt[texCoord2dvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glTexCoord2dv (%p)\n", v); + (*nativeRenderTable->TexCoord2dv) (v); +} + +static void +logTexCoord2fv (const GLfloat *v) +{ + vCnt[texCoord2fvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glTexCoord2fv (%p)\n", v); + (*nativeRenderTable->TexCoord2fv) (v); +} + +static void +logTexCoord2iv (const GLint *v) +{ + vCnt[texCoord2ivIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glTexCoord2iv (%p)\n", v); + (*nativeRenderTable->TexCoord2iv) (v); +} + +static void +logTexCoord2sv (const GLshort *v) +{ + vCnt[texCoord2svIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glTexCoord2sv (%p)\n", v); + (*nativeRenderTable->TexCoord2sv) (v); +} + + +static void +logTexCoord3dv (const GLdouble *v) +{ + vCnt[texCoord3dvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glTexCoord3dv (%p)\n", v); + (*nativeRenderTable->TexCoord3dv) (v); +} + +static void +logTexCoord3fv (const GLfloat *v) +{ + vCnt[texCoord3fvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glTexCoord3fv (%p)\n", v); + (*nativeRenderTable->TexCoord3fv) (v); +} + +static void +logTexCoord3iv (const GLint *v) +{ + vCnt[texCoord3ivIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glTexCoord3iv (%p)\n", v); + (*nativeRenderTable->TexCoord3iv) (v); +} + +static void +logTexCoord3sv (const GLshort *v) +{ + vCnt[texCoord3svIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glTexCoord3sv (%p)\n", v); + (*nativeRenderTable->TexCoord3sv) (v); +} + +static void +logTexCoord4dv (const GLdouble *v) +{ + vCnt[texCoord4dvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glTexCoord4dv (%p)\n", v); + (*nativeRenderTable->TexCoord4dv) (v); +} + +static void +logTexCoord4fv (const GLfloat *v) +{ + vCnt[texCoord4fvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glTexCoord4fv (%p)\n", v); + (*nativeRenderTable->TexCoord4fv) (v); +} + +static void +logTexCoord4iv (const GLint *v) +{ + vCnt[texCoord4ivIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glTexCoord4iv (%p)\n", v); + (*nativeRenderTable->TexCoord4iv) (v); +} + +static void +logTexCoord4sv (const GLshort *v) +{ + vCnt[texCoord4svIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glTexCoord4sv (%p)\n", v); + (*nativeRenderTable->TexCoord4sv) (v); +} + +static void +logTexCoordPointer (GLint size, + GLenum type, + GLsizei stride, + const void *pointer) +{ + fprintf (logFp, "glTexCoordPointer (%d, 0x%x, %d, %p)\n", + size, type, stride, pointer); + (*nativeRenderTable->TexCoordPointer) (size, type, stride, pointer); +} + +static void +logTexEnvf (GLenum target, + GLenum pname, + GLfloat param) +{ + fprintf (logFp, "glTexEnvf (0x%x, 0x%x, %f)\n", target, pname, param); + (*nativeRenderTable->TexEnvf) (target, pname, param); +} + +static void +logTexEnvfv (GLenum target, + GLenum pname, + const GLfloat *params) +{ + fprintf (logFp, "glTexEnvfv (0x%x, 0x%x, %p)\n", target, pname, params); + (*nativeRenderTable->TexEnvfv) (target, pname, params); +} + +static void +logTexEnvi (GLenum target, + GLenum pname, + GLint param) +{ + fprintf (logFp, "glTexEnvi (0x%x, 0x%x, %d)\n", target, pname, param); + (*nativeRenderTable->TexEnvi) (target, pname, param); +} + +static void +logTexEnviv (GLenum target, + GLenum pname, + const GLint *params) +{ + fprintf (logFp, "glTexEnviv (0x%x, 0x%x, %p)\n", target, pname, params); + (*nativeRenderTable->TexEnviv) (target, pname, params); +} + +static void +logTexGend (GLenum coord, + GLenum pname, + GLdouble param) +{ + fprintf (logFp, "glTexGend (0x%x, 0x%x, %f)\n", coord, pname, param); + (*nativeRenderTable->TexGend) (coord, pname, param); +} + +static void +logTexGendv (GLenum coord, + GLenum pname, + const GLdouble *params) +{ + fprintf (logFp, "glTexGendv (0x%x, 0x%x, %p)\n", coord, pname, params); + (*nativeRenderTable->TexGendv) (coord, pname, params); +} + +static void +logTexGenf (GLenum coord, + GLenum pname, + GLfloat param) +{ + fprintf (logFp, "glTexGenf (0x%x, 0x%x, %f)\n", coord, pname, param); + (*nativeRenderTable->TexGenf) (coord, pname, param); +} + +static void +logTexGenfv (GLenum coord, + GLenum pname, + const GLfloat *params) +{ + fprintf (logFp, "glTexGenfv (0x%x, 0x%x, %p)\n", coord, pname, params); + (*nativeRenderTable->TexGenfv) (coord, pname, params); +} + +static void +logTexGeni (GLenum coord, + GLenum pname, + GLint param) +{ + fprintf (logFp, "glTexGeni (0x%x, 0x%x, %d)\n", coord, pname, param); + (*nativeRenderTable->TexGeni) (coord, pname, param); +} + +static void +logTexGeniv (GLenum coord, + GLenum pname, + const GLint *params) +{ + fprintf (logFp, "glTexGeniv (0x%x, 0x%x, %p)\n", coord, pname, params); + (*nativeRenderTable->TexGeniv) (coord, pname, params); +} + +static void +logTexImage1D (GLenum target, + GLint level, + GLint internalformat, + GLsizei width, + GLint border, + GLenum format, + GLenum type, + const void *pixels) +{ + fprintf (logFp, "glTexImage1D (0x%x, %d, %d, %d, %d, 0x%x, 0x%x, %p)\n", + target, level, internalformat, width, border, format, type, + pixels); + (*nativeRenderTable->TexImage1D) (target, level, internalformat, + width, border, format, type, + pixels); +} + +static void +logTexImage2D (GLenum target, + GLint level, + GLint internalformat, + GLsizei width, + GLsizei height, + GLint border, + GLenum format, + GLenum type, + const void *pixels) +{ + fprintf (logFp, "glTexImage2D (0x%x, %d, %d, %d, %d, %d, " + "0x%x, 0x%x, %p)\n", target, level, internalformat, + width, height, border, format, type, pixels); + (*nativeRenderTable->TexImage2D) (target, level, internalformat, + width, height, border, format, type, + pixels); +} + +static void +logTexParameterf (GLenum target, + GLenum pname, + GLfloat param) +{ + fprintf (logFp, "glTexParameterf (0x%x, 0x%x, %f)\n", + target, pname, param); + (*nativeRenderTable->TexParameterf) (target, pname, param); +} + +static void +logTexParameterfv (GLenum target, + GLenum pname, + const GLfloat *params) +{ + fprintf (logFp, "glTexParameterfv (0x%x, 0x%x, %p)\n", + target, pname, params); + (*nativeRenderTable->TexParameterfv) (target, pname, params); +} + +static void +logTexParameteri (GLenum target, + GLenum pname, + GLint param) +{ + fprintf (logFp, "glTexParameteri (0x%x, 0x%x, 0x%x)\n", + target, pname, param); + (*nativeRenderTable->TexParameteri) (target, pname, param); +} + +static void +logTexParameteriv (GLenum target, + GLenum pname, + const GLint *params) +{ + fprintf (logFp, "glTexParameteriv (0x%x, 0x%x, %p)\n", + target, pname, params); + (*nativeRenderTable->TexParameteriv) (target, pname, params); +} + +static void +logTexSubImage1D (GLenum target, + GLint level, + GLint xoffset, + GLsizei width, + GLenum format, + GLenum type, + const void *pixels) +{ + fprintf (logFp, "glTexSubImage1D (0x%x, %d, %d, %d, 0x%x, 0x%x, %p)\n", + target, level, xoffset, width, format, type, pixels); + (*nativeRenderTable->TexSubImage1D) (target, level, xoffset, width, + format, type, pixels); +} + +static void +logTexSubImage2D (GLenum target, + GLint level, + GLint xoffset, + GLint yoffset, + GLsizei width, + GLsizei height, + GLenum format, + GLenum type, + const void *pixels) +{ + fprintf (logFp, "glTexSubImage2D (0x%x, %d, %d, %d, %d, %d, " + "0x%x, 0x%x, %p)\n", target, level, xoffset, yoffset, + width, height, format, type, pixels); + (*nativeRenderTable->TexSubImage2D) (target, level, xoffset, yoffset, + width, height, format, type, + pixels); +} + +static void +logTranslated (GLdouble x, + GLdouble y, + GLdouble z) +{ + fprintf (logFp, "glTranslated (%f, %f, %f)\n", x, y, z); + (*nativeRenderTable->Translated) (x, y, z); +} + +static void +logTranslatef (GLfloat x, + GLfloat y, + GLfloat z) +{ + fprintf (logFp, "glTranslatef (%f, %f, %f)\n", x, y, z); + (*nativeRenderTable->Translatef) (x, y, z); +} + +static void +logVertex2dv (const GLdouble *v) +{ + vCnt[vertex2dvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glVertex2dv (%p)\n", v); + (*nativeRenderTable->Vertex2dv) (v); +} + +static void +logVertex2fv (const GLfloat *v) +{ + vCnt[vertex2fvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glVertex2dv (%p)\n", v); + (*nativeRenderTable->Vertex2fv) (v); +} + +static void +logVertex2iv (const GLint *v) +{ + vCnt[vertex2ivIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glVertex2iv (%p)\n", v); + (*nativeRenderTable->Vertex2iv) (v); +} + +static void +logVertex2sv (const GLshort *v) +{ + vCnt[vertex2svIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glVertex2sv (%p)\n", v); + (*nativeRenderTable->Vertex2sv) (v); +} + +static void +logVertex3dv (const GLdouble *v) +{ + vCnt[vertex3dvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glVertex3dv (%p)\n", v); + (*nativeRenderTable->Vertex3dv) (v); +} + +static void +logVertex3fv (const GLfloat *v) +{ + vCnt[vertex3fvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glVertex3fv (%p)\n", v); + (*nativeRenderTable->Vertex3fv) (v); +} + +static void +logVertex3iv (const GLint *v) +{ + vCnt[vertex3ivIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glVertex3iv (%p)\n", v); + (*nativeRenderTable->Vertex3iv) (v); +} + +static void +logVertex3sv (const GLshort *v) +{ + vCnt[vertex3svIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glVertex3sv (%p)\n", v); + (*nativeRenderTable->Vertex3sv) (v); +} + +static void +logVertex4dv (const GLdouble *v) +{ + vCnt[vertex4dvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glVertex4dv (%p)\n", v); + (*nativeRenderTable->Vertex4dv) (v); +} + +static void +logVertex4fv (const GLfloat *v) +{ + vCnt[vertex4fvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glVertex4fv (%p)\n", v); + (*nativeRenderTable->Vertex4fv) (v); +} + +static void +logVertex4iv (const GLint *v) +{ + vCnt[vertex4ivIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glVertex4iv (%p)\n", v); + (*nativeRenderTable->Vertex4iv) (v); +} + +static void +logVertex4sv (const GLshort *v) +{ + vCnt[vertex4svIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glVertex4sv (%p)\n", v); + (*nativeRenderTable->Vertex4sv) (v); +} + +static void +logVertexPointer (GLint size, + GLenum type, + GLsizei stride, + const void *pointer) +{ + fprintf (logFp, "glVertexPointer (%d, 0x%x, %d, %p)\n", + size, type, stride, pointer); + (*nativeRenderTable->VertexPointer) (size, type, stride, pointer); +} + +static void +logViewport (GLint x, + GLint y, + GLsizei width, + GLsizei height) +{ + fprintf (logFp, "glViewport (%d %d %d %d)\n", x, y, width, height); + (*nativeRenderTable->Viewport) (x, y, width, height); +} + +static void +logBlendColor (GLclampf red, + GLclampf green, + GLclampf blue, + GLclampf alpha) +{ + fprintf (logFp, "glBlendColor (%f, %f, %f, %f)\n", + red, green, blue, alpha); + (*nativeRenderTable->BlendColor) (red, green, blue, alpha); +} + +static void +logBlendEquation (GLenum mode) +{ + fprintf (logFp, "glBlendEquation (0x%x)\n", mode); + (*nativeRenderTable->BlendEquation) (mode); +} + +static void +logColorTable (GLenum target, + GLenum internalformat, + GLsizei width, + GLenum format, + GLenum type, + const GLvoid *table) +{ + fprintf (logFp, "glColorTable (0x%x, 0x%x, %d, 0x%x, 0x%x, %p)\n", + target, internalformat, width, format, type, table); + (*nativeRenderTable->ColorTable) (target, internalformat, width, + format, type, table); +} + +static void +logColorTableParameterfv (GLenum target, + GLenum pname, + const GLfloat *params) +{ + fprintf (logFp, "glColorTableParameterfv (0x%x, 0x%x, %p)\n", + target, pname, params); + (*nativeRenderTable->ColorTableParameterfv) (target, pname, params); +} + +static void +logColorTableParameteriv (GLenum target, + GLenum pname, + const GLint *params) +{ + fprintf (logFp, "glColorTableParameterfv (0x%x, 0x%x, %p)\n", + target, pname, params); + (*nativeRenderTable->ColorTableParameteriv) (target, pname, params); +} + +static void +logCopyColorTable (GLenum target, + GLenum internalformat, + GLint x, + GLint y, + GLsizei width) +{ + fprintf (logFp, "glCopyColorTable (0x%x, 0x%x, %d, %d, %d)\n", + target, internalformat, x, y, width); + (*nativeRenderTable->CopyColorTable) (target, internalformat, + x, y, width); +} + +static void +logGetColorTable (GLenum target, + GLenum format, + GLenum type, + GLvoid *table) +{ + fprintf (logFp, "glGetColorTable (0x%x, 0x%x, 0x%x, %p)\n", + target, format, type, table); + (*nativeRenderTable->GetColorTable) (target, format, type, table); +} + +static void +logGetColorTableParameterfv (GLenum target, + GLenum pname, + GLfloat *params) +{ + fprintf (logFp, "glGetColorTableParameterfv (0x%x, 0x%x, %p)\n", + target, pname, params); + (*nativeRenderTable->GetColorTableParameterfv) (target, pname, params); +} + +static void +logGetColorTableParameteriv (GLenum target, + GLenum pname, + GLint *params) +{ + fprintf (logFp, "glGetColorTableParameteriv (0x%x, 0x%x, %p)\n", + target, pname, params); + (*nativeRenderTable->GetColorTableParameteriv) (target, pname, params); +} + +static void +logColorSubTable (GLenum target, + GLsizei start, + GLsizei count, + GLenum format, + GLenum type, + const GLvoid *data) +{ + fprintf (logFp, "glColorSubTable (0x%x, %d, %d, 0x%x, 0x%x, %p)\n", + target, start, count, format, type, data); + (*nativeRenderTable->ColorSubTable) (target, start, count, + format, type, data); +} + +static void +logCopyColorSubTable (GLenum target, + GLsizei start, + GLint x, + GLint y, + GLsizei width) +{ + fprintf (logFp, "glCopyColorSubTable (0x%x, %d, %d, %d, %d)\n", + target, start, x, y, width); + (*nativeRenderTable->CopyColorSubTable) (target, start, x, y, width); +} + +static void +logConvolutionFilter1D (GLenum target, + GLenum internalformat, + GLsizei width, + GLenum format, + GLenum type, + const GLvoid *image) +{ + fprintf (logFp, "glConvolutionFilter1D (0x%x, 0x%x, %d, 0x%x, 0x%x, %p)\n", + target, internalformat, width, format, type, image); + (*nativeRenderTable->ConvolutionFilter1D) (target, internalformat, + width, format, type, image); +} + +static void +logConvolutionFilter2D (GLenum target, + GLenum internalformat, + GLsizei width, + GLsizei height, + GLenum format, + GLenum type, + const GLvoid *image) +{ + fprintf (logFp, "glConvolutionFilter2D (0x%x, 0x%x, %d, %d, " + "0x%x, 0x%x, %p)\n", target, internalformat, width, height, + format, type, image); + (*nativeRenderTable->ConvolutionFilter2D) (target, internalformat, + width, height, format, + type, image); +} + +static void +logConvolutionParameterf (GLenum target, + GLenum pname, + GLfloat param) +{ + fprintf (logFp, "glConvolutionParameterf (0x%x, 0x%x, %f)\n", + target, pname, param); + (*nativeRenderTable->ConvolutionParameterf) (target, pname, param); +} + +static void +logConvolutionParameterfv (GLenum target, + GLenum pname, + const GLfloat *params) +{ + fprintf (logFp, "glConvolutionParameterfv (0x%x, 0x%x, %p)\n", + target, pname, params); + (*nativeRenderTable->ConvolutionParameterfv) (target, pname, params); +} + +static void +logConvolutionParameteri (GLenum target, + GLenum pname, + GLint param) +{ + fprintf (logFp, "glConvolutionParameterf (0x%x, 0x%x, %d)\n", + target, pname, param); + (*nativeRenderTable->ConvolutionParameteri) (target, pname, param); +} + +static void +logConvolutionParameteriv (GLenum target, + GLenum pname, + const GLint *params) +{ + fprintf (logFp, "glConvolutionParameteriv (0x%x, 0x%x, %p)\n", + target, pname, params); + (*nativeRenderTable->ConvolutionParameteriv) (target, pname, params); +} + +static void +logCopyConvolutionFilter1D (GLenum target, + GLenum internalformat, + GLint x, + GLint y, + GLsizei width) +{ + fprintf (logFp, "glCopyConvolutionFilter1D (0x%x, 0x%x, %d, %d, %d)\n", + target, internalformat, x, y, width); + (*nativeRenderTable->CopyConvolutionFilter1D) (target, internalformat, + x, y, width); +} + +static void +logCopyConvolutionFilter2D (GLenum target, + GLenum internalformat, + GLint x, + GLint y, + GLsizei width, + GLsizei height) +{ + fprintf (logFp, "glCopyConvolutionFilter2D (0x%x, 0x%x, %d, %d, %d, %d)\n", + target, internalformat, x, y, width, height); + (*nativeRenderTable->CopyConvolutionFilter2D) (target, internalformat, + x, y, width, height); +} + +static void +logGetConvolutionFilter (GLenum target, + GLenum format, + GLenum type, + GLvoid *image) +{ + fprintf (logFp, "glGetConvolutionFilter (0x%x, 0x%x, 0x%x, %p)\n", + target, format, type, image); + (*nativeRenderTable->GetConvolutionFilter) (target, format, type, + image); +} + +static void +logGetConvolutionParameterfv (GLenum target, + GLenum pname, + GLfloat *params) +{ + fprintf (logFp, "glGetConvolutionParameterfv (0x%x, 0x%x, %p)\n", + target, pname, params); + (*nativeRenderTable->GetConvolutionParameterfv) (target, pname, + params); +} + +static void +logGetConvolutionParameteriv (GLenum target, + GLenum pname, + GLint *params) +{ + fprintf (logFp, "glGetConvolutionParameteriv (0x%x, 0x%x, %p)\n", + target, pname, params); + (*nativeRenderTable->GetConvolutionParameteriv) (target, pname, + params); +} + +static void +logGetSeparableFilter (GLenum target, + GLenum format, + GLenum type, + GLvoid *row, + GLvoid *column, + GLvoid *span) +{ + fprintf (logFp, "glGetSeparableFilter (0x%x, 0x%x, 0x%x, %p, %p, %p)\n", + target, format, type, row, column, span); + (*nativeRenderTable->GetSeparableFilter) (target, format, type, + row, column, span); +} + +static void +logSeparableFilter2D (GLenum target, + GLenum internalformat, + GLsizei width, + GLsizei height, + GLenum format, + GLenum type, + const GLvoid *row, + const GLvoid *column) +{ + fprintf (logFp, "glSeparableFilter2D (0x%x, 0x%x, %d, %d, " + "0x%x, 0x%x, %p, %p)\n", target, internalformat, width, height, + format, type, row, column); + (*nativeRenderTable->SeparableFilter2D) (target, internalformat, + width, height, format, + type, row, column); +} + +static void +logGetHistogram (GLenum target, + GLboolean reset, + GLenum format, + GLenum type, + GLvoid *values) +{ + fprintf (logFp, "glGetHistogram (0x%x, %d, 0x%x, 0x%x, %p)\n", + target, reset, format, type, values); + (*nativeRenderTable->GetHistogram) (target, reset, format, type, + values); +} + +static void +logGetHistogramParameterfv (GLenum target, + GLenum pname, + GLfloat *params) +{ + fprintf (logFp, "glGetHistogramParameterfv (0x%x, 0x%x, %p)\n", + target, pname, params); + (*nativeRenderTable->GetHistogramParameterfv) (target, pname, params); +} + +static void +logGetHistogramParameteriv (GLenum target, + GLenum pname, + GLint *params) +{ + fprintf (logFp, "glGetHistogramParameteriv (0x%x, 0x%x, %p)\n", + target, pname, params); + (*nativeRenderTable->GetHistogramParameteriv) (target, pname, params); +} + +static void +logGetMinmax (GLenum target, + GLboolean reset, + GLenum format, + GLenum type, + GLvoid *values) +{ + fprintf (logFp, "glGetMinmax (0x%x, %d, 0x%x, 0x%x, %p)\n", + target, reset, format, type, values); + (*nativeRenderTable->GetMinmax) (target, reset, format, type, values); +} + +static void +logGetMinmaxParameterfv (GLenum target, + GLenum pname, + GLfloat *params) +{ + fprintf (logFp, "GetMinmaxParameterfv (0x%x, 0x%x, %p)\n", + target, pname, params); + (*nativeRenderTable->GetMinmaxParameterfv) (target, pname, params); +} + +static void +logGetMinmaxParameteriv (GLenum target, + GLenum pname, + GLint *params) +{ + fprintf (logFp, "GetMinmaxParameteriv (0x%x, 0x%x, %p)\n", + target, pname, params); + (*nativeRenderTable->GetMinmaxParameteriv) (target, pname, params); +} + +static void +logHistogram (GLenum target, + GLsizei width, + GLenum internalformat, + GLboolean sink) +{ + fprintf (logFp, "glHistogram (0x%x, %d, 0x%x, %d)\n", + target, width, internalformat, sink); + (*nativeRenderTable->Histogram) (target, width, internalformat, sink); +} + +static void +logMinmax (GLenum target, + GLenum internalformat, + GLboolean sink) +{ + fprintf (logFp, "glMinmax (0x%x, 0x%x, %d)\n", + target, internalformat, sink); + (*nativeRenderTable->Minmax) (target, internalformat, sink); +} + +static void +logResetHistogram (GLenum target) +{ + fprintf (logFp, "glResetHistogram (0x%x)\n", target); + (*nativeRenderTable->ResetHistogram) (target); +} + +static void +logResetMinmax (GLenum target) +{ + fprintf (logFp, "glResetMinmax (0x%x)\n", target); + (*nativeRenderTable->ResetMinmax) (target); +} + +static void +logCopyTexSubImage3D (GLenum target, + GLint level, + GLint xoffset, + GLint yoffset, + GLint zoffset, + GLint x, + GLint y, + GLsizei width, + GLsizei height) +{ + fprintf (logFp, "glCopyTexSubImage3D (0x%x, %d, %d, %d, %d, %d, %d, " + "%d, %d)\n", target, level, xoffset, yoffset, zoffset, + x, y, width, height); + (*nativeRenderTable->CopyTexSubImage3D) (target, level, + xoffset, yoffset, zoffset, + x, y, width, height); +} + +static void +logTexImage3D (GLenum target, + GLint level, + GLint internalformat, + GLsizei width, + GLsizei height, + GLsizei depth, + GLint border, + GLenum format, + GLenum type, + const GLvoid *pixels) +{ + fprintf (logFp, "glTexImage3D (0x%x, %d, %d, %d, %d, %d, %d, " + "0x%x, 0x%x, %p)\n", target, level, internalformat, + width, height, depth, border, format, type, pixels); + (*nativeRenderTable->TexImage3D) (target, level, internalformat, + width, height, depth, border, + format, type, pixels); +} + +static void +logTexSubImage3D (GLenum target, + GLint level, + GLint xoffset, + GLint yoffset, + GLint zoffset, + GLsizei width, + GLsizei height, + GLsizei depth, + GLenum format, + GLenum type, + const GLvoid *pixels) +{ + fprintf (logFp, "glTexSubImage3D (0x%x, %d, %d, %d, %d, %d, %d, %d, " + "0x%x, 0x%x, %p)\n", target, level, xoffset, yoffset, zoffset, + width, height, depth, format, type, pixels); + (*nativeRenderTable->TexSubImage3D) (target, level, + xoffset, yoffset, zoffset, + width, height, depth, + format, type, pixels); +} + +/* GL_ARB_multitexture */ + +static void +logActiveTextureARB (GLenum texture) +{ + fprintf (logFp, "glActiveTextureARB (0x%x)\n", texture); + (*nativeRenderTable->ActiveTextureARB) (texture); +} + +static void +logClientActiveTextureARB (GLenum texture) +{ + fprintf (logFp, "glClientActiveTextureARB (0x%x)\n", texture); + (*nativeRenderTable->ClientActiveTextureARB) (texture); +} + +static void +logMultiTexCoord1dvARB (GLenum target, + const GLdouble *v) +{ + vCnt[multiTexCoord1dvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glMultiTexCoord1dvARB (0x%x, %p)\n", target, v); + (*nativeRenderTable->MultiTexCoord1dvARB) (target, v); +} + +static void +logMultiTexCoord1fvARB (GLenum target, + const GLfloat *v) +{ + vCnt[multiTexCoord1fvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glMultiTexCoord1fvARB (0x%x, %p)\n", target, v); + (*nativeRenderTable->MultiTexCoord1fvARB) (target, v); +} + +static void +logMultiTexCoord1ivARB (GLenum target, + const GLint *v) +{ + vCnt[multiTexCoord1ivIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glMultiTexCoord1ivARB (0x%x, %p)\n", target, v); + (*nativeRenderTable->MultiTexCoord1ivARB) (target, v); +} + +static void +logMultiTexCoord1svARB (GLenum target, + const GLshort *v) +{ + vCnt[multiTexCoord1svIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glMultiTexCoord1svARB (0x%x, %p)\n", target, v); + (*nativeRenderTable->MultiTexCoord1svARB) (target, v); +} + +static void +logMultiTexCoord2dvARB (GLenum target, + const GLdouble *v) +{ + vCnt[multiTexCoord2dvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glMultiTexCoord2dvARB (0x%x, %p)\n", target, v); + (*nativeRenderTable->MultiTexCoord2dvARB) (target, v); +} + +static void +logMultiTexCoord2fvARB (GLenum target, + const GLfloat *v) +{ + vCnt[multiTexCoord2fvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glMultiTexCoord2fvARB (0x%x, %p)\n", target, v); + (*nativeRenderTable->MultiTexCoord2fvARB) (target, v); +} + +static void +logMultiTexCoord2ivARB (GLenum target, + const GLint *v) +{ + vCnt[multiTexCoord2ivIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glMultiTexCoord2ivARB (0x%x, %p)\n", target, v); + (*nativeRenderTable->MultiTexCoord2ivARB) (target, v); +} + +static void +logMultiTexCoord2svARB (GLenum target, + const GLshort *v) +{ + vCnt[multiTexCoord2svIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glMultiTexCoord2svARB (0x%x, %p)\n", target, v); + (*nativeRenderTable->MultiTexCoord2svARB) (target, v); +} + +static void +logMultiTexCoord3dvARB (GLenum target, + const GLdouble *v) +{ + vCnt[multiTexCoord3dvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glMultiTexCoord3dvARB (0x%x, %p)\n", target, v); + (*nativeRenderTable->MultiTexCoord3dvARB) (target, v); +} + +static void +logMultiTexCoord3fvARB (GLenum target, + const GLfloat *v) +{ + vCnt[multiTexCoord3fvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glMultiTexCoord3fvARB (0x%x, %p)\n", target, v); + (*nativeRenderTable->MultiTexCoord3fvARB) (target, v); +} + +static void +logMultiTexCoord3ivARB (GLenum target, + const GLint *v) +{ + vCnt[multiTexCoord3ivIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glMultiTexCoord3ivARB (0x%x, %p)\n", target, v); + (*nativeRenderTable->MultiTexCoord3ivARB) (target, v); +} + +static void +logMultiTexCoord3svARB (GLenum target, + const GLshort *v) +{ + vCnt[multiTexCoord3svIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glMultiTexCoord3svARB (0x%x, %p)\n", target, v); + (*nativeRenderTable->MultiTexCoord3svARB) (target, v); +} + +static void +logMultiTexCoord4dvARB (GLenum target, + const GLdouble *v) +{ + vCnt[multiTexCoord4dvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glMultiTexCoord4dvARB (0x%x, %p)\n", target, v); + (*nativeRenderTable->MultiTexCoord4dvARB) (target, v); +} + +static void +logMultiTexCoord4fvARB (GLenum target, + const GLfloat *v) +{ + vCnt[multiTexCoord4fvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glMultiTexCoord4fvARB (0x%x, %p)\n", target, v); + (*nativeRenderTable->MultiTexCoord4fvARB) (target, v); +} + +static void +logMultiTexCoord4ivARB (GLenum target, + const GLint *v) +{ + vCnt[multiTexCoord4ivIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glMultiTexCoord4ivARB (0x%x, %p)\n", target, v); + (*nativeRenderTable->MultiTexCoord4ivARB) (target, v); +} + +static void +logMultiTexCoord4svARB (GLenum target, + const GLshort *v) +{ + vCnt[multiTexCoord4svIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glMultiTexCoord4svARB (0x%x, %p)\n", target, v); + (*nativeRenderTable->MultiTexCoord4svARB) (target, v); +} + + +/* GL_ARB_multisample */ + +static void +logSampleCoverageARB (GLclampf value, + GLboolean invert) +{ + fprintf (logFp, "glSampleCoverageARB (%f, %d)\n", value, invert); + (*nativeRenderTable->SampleCoverageARB) (value, invert); +} + + +/* GL_EXT_texture_object */ + +static GLboolean +logAreTexturesResidentEXT (GLsizei n, + const GLuint *textures, + GLboolean *residences) +{ + fprintf (logFp, "glAreTexturesResidentEXT (%d, %p, %p)\n", + n, textures, residences); + return (*nativeRenderTable->AreTexturesResidentEXT) (n, textures, + residences); +} +static void +logGenTexturesEXT (GLsizei n, + GLuint *textures) +{ + fprintf (logFp, "glGenTexturesEXT (%d, %p)\n", n, textures); + (*nativeRenderTable->GenTexturesEXT) (n, textures); +} + +static GLboolean +logIsTextureEXT (GLuint texture) +{ + fprintf (logFp, "glIsTextureEXT (%d)\n", texture); + return (*nativeRenderTable->IsTextureEXT) (texture); +} + + +/* GL_SGIS_multisample */ + +static void +logSampleMaskSGIS (GLclampf value, + GLboolean invert) +{ + fprintf (logFp, "glSampleMaskSGIS (%f, %d)\n", value, invert); + (*nativeRenderTable->SampleMaskSGIS) (value, invert); +} + +static void +logSamplePatternSGIS (GLenum pattern) +{ + fprintf (logFp, "glSamplePatternSGIS (0x%x)\n", pattern); + (*nativeRenderTable->SamplePatternSGIS) (pattern); +} + + +/* GL_EXT_point_parameters */ + +static void +logPointParameterfEXT (GLenum pname, + GLfloat param) +{ + fprintf (logFp, "glPointParameterfEXT (0x%x, %f)\n", pname, param); + (*nativeRenderTable->PointParameterfEXT) (pname, param); +} + +static void +logPointParameterfvEXT (GLenum pname, + const GLfloat *params) +{ + fprintf (logFp, "glPointParameterfvEXT (0x%x, %p)\n", pname, params); + (*nativeRenderTable->PointParameterfvEXT) (pname, params); +} + + +/* GL_MESA_window_pos */ + +static void +logWindowPos3fMESA (GLfloat x, + GLfloat y, + GLfloat z) +{ + fprintf (logFp, "glWindowPos3fMESA (%f, %f, %f)\n", x, y, z); + (*nativeRenderTable->WindowPos3fMESA) (x, y, z); +} + + +/* GL_EXT_blend_func_separate */ + +static void +logBlendFuncSeparateEXT (GLenum sfactorRGB, + GLenum dfactorRGB, + GLenum sfactorAlpha, + GLenum dfactorAlpha) +{ + fprintf (logFp, "glBlendFuncSeparateEXT (0x%x, 0x%x, 0x%x, 0x%x)\n", + sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha); + (*nativeRenderTable->BlendFuncSeparateEXT) (sfactorRGB, + dfactorRGB, + sfactorAlpha, + dfactorAlpha); +} + + +/* GL_EXT_fog_coord */ + +static void +logFogCoordfvEXT (const GLfloat *coord) +{ + vCnt[fogCoordfvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glFogCoordfvEXT (%p)\n", coord); + (*nativeRenderTable->FogCoordfvEXT) (coord); +} + +static void +logFogCoorddvEXT (const GLdouble *coord) +{ + vCnt[fogCoorddvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glFogCoorddvEXT (%p)\n", coord); + (*nativeRenderTable->FogCoorddvEXT) (coord); +} + +static void +logFogCoordPointerEXT (GLenum type, + GLsizei stride, + const GLvoid *pointer) +{ + fprintf (logFp, "glFogCoordPointerEXT (0x%x, %d, %p)\n", + type, stride, pointer); + (*nativeRenderTable->FogCoordPointerEXT) (type, stride, pointer); +} + + +/* GL_EXT_secondary_color */ + +static void +logSecondaryColor3bvEXT (const GLbyte *v) +{ + vCnt[secondaryColor3bvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glSecondaryColor3bvEXT (%p)\n", v); + (*nativeRenderTable->SecondaryColor3bvEXT) (v); +} + +static void +logSecondaryColor3dvEXT (const GLdouble *v) +{ + vCnt[secondaryColor3dvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glSecondaryColor3dvEXT (%p)\n", v); + (*nativeRenderTable->SecondaryColor3dvEXT) (v); +} + +static void +logSecondaryColor3fvEXT (const GLfloat *v) +{ + vCnt[secondaryColor3fvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glSecondaryColor3fvEXT (%p)\n", v); + (*nativeRenderTable->SecondaryColor3fvEXT) (v); +} + +static void +logSecondaryColor3ivEXT (const GLint *v) +{ + vCnt[secondaryColor3ivIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glSecondaryColor3ivEXT (%p)\n", v); + (*nativeRenderTable->SecondaryColor3ivEXT) (v); +} + +static void +logSecondaryColor3svEXT (const GLshort *v) +{ + vCnt[secondaryColor3svIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glSecondaryColor3svEXT (%p)\n", v); + (*nativeRenderTable->SecondaryColor3svEXT) (v); +} + +static void +logSecondaryColor3ubvEXT (const GLubyte *v) +{ + vCnt[secondaryColor3ubvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glSecondaryColor3ubvEXT (%p)\n", v); + (*nativeRenderTable->SecondaryColor3ubvEXT) (v); +} + +static void +logSecondaryColor3uivEXT (const GLuint *v) +{ + vCnt[secondaryColor3uivIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glSecondaryColor3uivEXT (%p)\n", v); + (*nativeRenderTable->SecondaryColor3uivEXT) (v); +} + +static void +logSecondaryColor3usvEXT (const GLushort *v) +{ + vCnt[secondaryColor3usvIndex].n++; + if (logVertexAttribs) + fprintf (logFp, "glSecondaryColor3usvEXT (%p)\n", v); + (*nativeRenderTable->SecondaryColor3usvEXT) (v); +} + +static void +logSecondaryColorPointerEXT (GLint size, + GLenum type, + GLsizei stride, + const GLvoid *pointer) +{ + fprintf (logFp, "glSecondaryColorPointerEXT (%d, 0x%x, %d, %p)\n", + size, type, stride, pointer); + (*nativeRenderTable->SecondaryColorPointerEXT) (size, type, + stride, pointer); +} + + +/* GL_NV_point_sprite */ + +static void +logPointParameteriNV (GLenum pname, + GLint param) +{ + fprintf (logFp, "glPointParameteriNV (0x%x, %d)\n", pname, param); + (*nativeRenderTable->PointParameteriNV) (pname, param); +} + +static void +logPointParameterivNV (GLenum pname, + const GLint *params) +{ + fprintf (logFp, "glPointParameterivNV (0x%x, %p)\n", pname, params); + (*nativeRenderTable->PointParameterivNV) (pname, params); +} + + +/* GL_EXT_stencil_two_side */ + +static void +logActiveStencilFaceEXT (GLenum face) +{ + fprintf (logFp, "glActiveStencilFaceEXT (0x%x)\n", face); + (*nativeRenderTable->ActiveStencilFaceEXT) (face); +} + + +/* GL_EXT_framebuffer_object */ + +static GLboolean +logIsRenderbufferEXT (GLuint renderbuffer) +{ + fprintf (logFp, "glIsRenderbufferEXT (%d)\n", renderbuffer); + return (*nativeRenderTable->IsRenderbufferEXT) (renderbuffer); +} + +static void +logBindRenderbufferEXT (GLenum target, + GLuint renderbuffer) +{ + fprintf (logFp, "glBindRenderbufferEXT (0x%x, %d)\n", + target, renderbuffer); + (*nativeRenderTable->BindRenderbufferEXT) (target, renderbuffer); +} + +static void +logDeleteRenderbuffersEXT (GLsizei n, + const GLuint *renderbuffers) +{ + fprintf (logFp, "glDeleteRenderbuffersEXT (%d, %p)\n", n, renderbuffers); + (*nativeRenderTable->DeleteRenderbuffersEXT) (n, renderbuffers); +} + +static void +logGenRenderbuffersEXT (GLsizei n, + GLuint *renderbuffers) +{ + fprintf (logFp, "glGenRenderbuffersEXT (%d, %p)\n", n, renderbuffers); + (*nativeRenderTable->GenRenderbuffersEXT) (n, renderbuffers); +} + +static void +logRenderbufferStorageEXT (GLenum target, + GLenum internalformat, + GLsizei width, + GLsizei height) +{ + fprintf (logFp, "glRenderbufferStorageEXT (0x%x, 0x%x, %d, %d)\n", + target, internalformat, width, height); + (*nativeRenderTable->RenderbufferStorageEXT) (target, + internalformat, + width, height); +} + +static void +logGetRenderbufferParameterivEXT (GLenum target, + GLenum pname, + GLint *params) +{ + fprintf (logFp, "glGetRenderbufferParameterivEXT (0x%x, 0x%x, %p)\n", + target, pname, params); + (*nativeRenderTable->GetRenderbufferParameterivEXT) (target, + pname, + params); +} + +static GLboolean +logIsFramebufferEXT (GLuint framebuffer) +{ + fprintf (logFp, "glIsFramebufferEXT (%d)\n", framebuffer); + return (*nativeRenderTable->IsFramebufferEXT) (framebuffer); +} + +static void +logBindFramebufferEXT (GLenum target, + GLuint framebuffer) +{ + fprintf (logFp, "glBindFramebufferEXT (0x%x, %d)\n", target, framebuffer); + (*nativeRenderTable->BindFramebufferEXT) (target, framebuffer); +} + +static void +logDeleteFramebuffersEXT (GLsizei n, + const GLuint *framebuffers) +{ + fprintf (logFp, "glDeleteFramebuffersEXT (%d, %p)\n", n, framebuffers); + (*nativeRenderTable->DeleteFramebuffersEXT) (n, framebuffers); +} + +static void +logGenFramebuffersEXT (GLsizei n, + GLuint *framebuffers) +{ + fprintf (logFp, "glGenFramebuffersEXT (%d, %p)\n", n, framebuffers); + (*nativeRenderTable->GenFramebuffersEXT) (n, framebuffers); +} + +static GLenum +logCheckFramebufferStatusEXT (GLenum target) +{ + fprintf (logFp, "glCheckFramebufferStatusEXT (0x%x)\n", target); + return (*nativeRenderTable->CheckFramebufferStatusEXT) (target); +} + +static void +logFramebufferTexture1DEXT (GLenum target, + GLenum attachment, + GLenum textarget, + GLuint texture, + GLint level) +{ + fprintf (logFp, "glFramebufferTexture1DEXT (0x%x, 0x%x, 0x%x, %d, %d)\n", + target, attachment, textarget, texture, level); + (*nativeRenderTable->FramebufferTexture1DEXT) (target, attachment, + textarget, texture, + level); +} + +static void +logFramebufferTexture2DEXT (GLenum target, + GLenum attachment, + GLenum textarget, + GLuint texture, + GLint level) +{ + fprintf (logFp, "glFramebufferTexture2DEXT (0x%x, 0x%x, 0x%x, %d, %d)\n", + target, attachment, textarget, texture, level); + (*nativeRenderTable->FramebufferTexture2DEXT) (target, attachment, + textarget, texture, + level); +} + +static void +logFramebufferTexture3DEXT (GLenum target, + GLenum attachment, + GLenum textarget, + GLuint texture, + GLint level, + GLint zoffset) +{ + fprintf (logFp, "glFramebufferTexture3DEXT (0x%x, 0x%x, 0x%x, " + "%d, %d, %d)\n", target, attachment, textarget, texture, + level, zoffset); + (*nativeRenderTable->FramebufferTexture3DEXT) (target, attachment, + textarget, texture, + level, zoffset); +} + +static void +logFramebufferRenderbufferEXT (GLenum target, + GLenum attachment, + GLenum buffertarget, + GLuint renderbuffer) +{ + fprintf (logFp, "glFramebufferRenderbufferEXT (0x%x, 0x%x, 0x%x, %d)\n", + target, attachment, buffertarget, renderbuffer); + (*nativeRenderTable->FramebufferRenderbufferEXT) (target, + attachment, + buffertarget, + renderbuffer); +} + +static void +logGetFramebufferAttachmentParameterivEXT (GLenum target, + GLenum attach, + GLenum pname, + GLint *params) +{ + fprintf (logFp, "glGetFramebufferAttachmentParameterivEXT (0x%x, " + "0x%x, 0x%x, %p)\n", target, attach, pname, params); + (*nativeRenderTable->GetFramebufferAttachmentParameterivEXT) (target, + attach, + pname, + params); +} + +static void +logGenerateMipmapEXT (GLenum target) +{ + fprintf (logFp, "glGenerateMipmapEXT (0x%x)\n", target); + (*nativeRenderTable->GenerateMipmapEXT) (target); +} + +static struct _glapi_table __logRenderTable = { + logNewList, + logEndList, + logCallList, + logCallLists, + logDeleteLists, + logGenLists, + logListBase, + logBegin, + logBitmap, + 0, /* glColor3b */ + logColor3bv, + 0, /* glColor3d */ + logColor3dv, + 0, /* glColor3f */ + logColor3fv, + 0, /* glColor3i */ + logColor3iv, + 0, /* glColor3s */ + logColor3sv, + 0, /* glColor3ub */ + logColor3ubv, + 0, /* glColor3ui */ + logColor3uiv, + 0, /* glColor3us */ + logColor3usv, + 0, /* glColor4b */ + logColor4bv, + 0, /* glColor4d */ + logColor4dv, + 0, /* glColor4f */ + logColor4fv, + 0, /* glColor4i */ + logColor4iv, + 0, /* glColor4s */ + logColor4sv, + 0, /* glColor4ub */ + logColor4ubv, + 0, /* glColor4ui */ + logColor4uiv, + 0, /* glColor4us */ + logColor4usv, + 0, /* glEdgeFlag */ + logEdgeFlagv, + logEnd, + 0, /* glIndexd */ + logIndexdv, + 0, /* glIndexf */ + logIndexfv, + 0, /* glIndexi */ + logIndexiv, + 0, /* glIndexs */ + logIndexsv, + 0, /* glNormal3b */ + logNormal3bv, + 0, /* glNormal3d */ + logNormal3dv, + 0, /* glNormal3f */ + logNormal3fv, + 0, /* glNormal3i */ + logNormal3iv, + 0, /* glNormal3s */ + logNormal3sv, + 0, /* glRasterPos2d */ + logRasterPos2dv, + 0, /* glRasterPos2f */ + logRasterPos2fv, + 0, /* glRasterPos2i */ + logRasterPos2iv, + 0, /* glRasterPos2s */ + logRasterPos2sv, + 0, /* glRasterPos3d */ + logRasterPos3dv, + 0, /* glRasterPos3f */ + logRasterPos3fv, + 0, /* glRasterPos3i */ + logRasterPos3iv, + 0, /* glRasterPos3s */ + logRasterPos3sv, + 0, /* glRasterPos4d */ + logRasterPos4dv, + 0, /* glRasterPos4f */ + logRasterPos4fv, + 0, /* glRasterPos4i */ + logRasterPos4iv, + 0, /* glRasterPos4s */ + logRasterPos4sv, + 0, /* glRectd */ + logRectdv, + 0, /* glRectf */ + logRectfv, + 0, /* glRecti */ + logRectiv, + 0, /* glRects */ + logRectsv, + 0, /* glTexCoord1d */ + logTexCoord1dv, + 0, /* glTexCoord1f */ + logTexCoord1fv, + 0, /* glTexCoord1i */ + logTexCoord1iv, + 0, /* glTexCoord1s */ + logTexCoord1sv, + 0, /* glTexCoord2d */ + logTexCoord2dv, + 0, /* glTexCoord2f */ + logTexCoord2fv, + 0, /* glTexCoord2i */ + logTexCoord2iv, + 0, /* glTexCoord2s */ + logTexCoord2sv, + 0, /* glTexCoord3d */ + logTexCoord3dv, + 0, /* glTexCoord3f */ + logTexCoord3fv, + 0, /* glTexCoord3i */ + logTexCoord3iv, + 0, /* glTexCoord3s */ + logTexCoord3sv, + 0, /* glTexCoord4d */ + logTexCoord4dv, + 0, /* glTexCoord4f */ + logTexCoord4fv, + 0, /* glTexCoord4i */ + logTexCoord4iv, + 0, /* glTexCoord4s */ + logTexCoord4sv, + 0, /* glVertex2d */ + logVertex2dv, + 0, /* glVertex2f */ + logVertex2fv, + 0, /* glVertex2i */ + logVertex2iv, + 0, /* glVertex2s */ + logVertex2sv, + 0, /* glVertex3d */ + logVertex3dv, + 0, /* glVertex3f */ + logVertex3fv, + 0, /* glVertex3i */ + logVertex3iv, + 0, /* glVertex3s */ + logVertex3sv, + 0, /* glVertex4d */ + logVertex4dv, + 0, /* glVertex4f */ + logVertex4fv, + 0, /* glVertex4i */ + logVertex4iv, + 0, /* glVertex4s */ + logVertex4sv, + logClipPlane, + logColorMaterial, + logCullFace, + logFogf, + logFogfv, + logFogi, + logFogiv, + logFrontFace, + logHint, + logLightf, + logLightfv, + logLighti, + logLightiv, + logLightModelf, + logLightModelfv, + logLightModeli, + logLightModeliv, + logLineStipple, + logLineWidth, + logMaterialf, + logMaterialfv, + logMateriali, + logMaterialiv, + logPointSize, + logPolygonMode, + logPolygonStipple, + logScissor, + logShadeModel, + logTexParameterf, + logTexParameterfv, + logTexParameteri, + logTexParameteriv, + logTexImage1D, + logTexImage2D, + logTexEnvf, + logTexEnvfv, + logTexEnvi, + logTexEnviv, + logTexGend, + logTexGendv, + logTexGenf, + logTexGenfv, + logTexGeni, + logTexGeniv, + logFeedbackBuffer, + logSelectBuffer, + logRenderMode, + logInitNames, + logLoadName, + logPassThrough, + logPopName, + logPushName, + logDrawBuffer, + logClear, + logClearAccum, + logClearIndex, + logClearColor, + logClearStencil, + logClearDepth, + logStencilMask, + logColorMask, + logDepthMask, + logIndexMask, + logAccum, + logDisable, + logEnable, + logFinish, + logFlush, + logPopAttrib, + logPushAttrib, + logMap1d, + logMap1f, + logMap2d, + logMap2f, + logMapGrid1d, + logMapGrid1f, + logMapGrid2d, + logMapGrid2f, + 0, /* glEvalCoord1d */ + logEvalCoord1dv, + 0, /* glEvalCoord1f */ + logEvalCoord1fv, + 0, /* glEvalCoord2d */ + logEvalCoord2dv, + 0, /* glEvalCoord2f */ + logEvalCoord2fv, + logEvalMesh1, + logEvalPoint1, + logEvalMesh2, + logEvalPoint2, + logAlphaFunc, + logBlendFunc, + logLogicOp, + logStencilFunc, + logStencilOp, + logDepthFunc, + logPixelZoom, + logPixelTransferf, + logPixelTransferi, + logPixelStoref, + logPixelStorei, + logPixelMapfv, + logPixelMapuiv, + logPixelMapusv, + logReadBuffer, + logCopyPixels, + logReadPixels, + logDrawPixels, + logGetBooleanv, + logGetClipPlane, + logGetDoublev, + logGetError, + logGetFloatv, + logGetIntegerv, + logGetLightfv, + logGetLightiv, + logGetMapdv, + logGetMapfv, + logGetMapiv, + logGetMaterialfv, + logGetMaterialiv, + logGetPixelMapfv, + logGetPixelMapuiv, + logGetPixelMapusv, + logGetPolygonStipple, + logGetString, + logGetTexEnvfv, + logGetTexEnviv, + logGetTexGendv, + logGetTexGenfv, + logGetTexGeniv, + logGetTexImage, + logGetTexParameterfv, + logGetTexParameteriv, + logGetTexLevelParameterfv, + logGetTexLevelParameteriv, + logIsEnabled, + logIsList, + logDepthRange, + logFrustum, + logLoadIdentity, + logLoadMatrixf, + logLoadMatrixd, + logMatrixMode, + logMultMatrixf, + logMultMatrixd, + logOrtho, + logPopMatrix, + logPushMatrix, + logRotated, + logRotatef, + logScaled, + logScalef, + logTranslated, + logTranslatef, + logViewport, + logArrayElement, + logBindTexture, + logColorPointer, + logDisableClientState, + logDrawArrays, + logDrawElements, + logEdgeFlagPointer, + logEnableClientState, + logIndexPointer, + 0, /* glIndexub */ + logIndexubv, + logInterleavedArrays, + logNormalPointer, + logPolygonOffset, + logTexCoordPointer, + logVertexPointer, + logAreTexturesResident, + logCopyTexImage1D, + logCopyTexImage2D, + logCopyTexSubImage1D, + logCopyTexSubImage2D, + logDeleteTextures, + logGenTextures, + logGetPointerv, + logIsTexture, + logPrioritizeTextures, + logTexSubImage1D, + logTexSubImage2D, + logPopClientAttrib, + logPushClientAttrib, + logBlendColor, + logBlendEquation, + 0, /* glDrawRangeElements */ + logColorTable, + logColorTableParameterfv, + logColorTableParameteriv, + logCopyColorTable, + logGetColorTable, + logGetColorTableParameterfv, + logGetColorTableParameteriv, + logColorSubTable, + logCopyColorSubTable, + logConvolutionFilter1D, + logConvolutionFilter2D, + logConvolutionParameterf, + logConvolutionParameterfv, + logConvolutionParameteri, + logConvolutionParameteriv, + logCopyConvolutionFilter1D, + logCopyConvolutionFilter2D, + logGetConvolutionFilter, + logGetConvolutionParameterfv, + logGetConvolutionParameteriv, + logGetSeparableFilter, + logSeparableFilter2D, + logGetHistogram, + logGetHistogramParameterfv, + logGetHistogramParameteriv, + logGetMinmax, + logGetMinmaxParameterfv, + logGetMinmaxParameteriv, + logHistogram, + logMinmax, + logResetHistogram, + logResetMinmax, + logTexImage3D, + logTexSubImage3D, + logCopyTexSubImage3D, + logActiveTextureARB, + logClientActiveTextureARB, + 0, /* glMultiTexCoord1dARB */ + logMultiTexCoord1dvARB, + 0, /* glMultiTexCoord1fARB */ + logMultiTexCoord1fvARB, + 0, /* glMultiTexCoord1iARB */ + logMultiTexCoord1ivARB, + 0, /* glMultiTexCoord1sARB */ + logMultiTexCoord1svARB, + 0, /* glMultiTexCoord2dARB */ + logMultiTexCoord2dvARB, + 0, /* glMultiTexCoord2fARB */ + logMultiTexCoord2fvARB, + 0, /* glMultiTexCoord2iARB */ + logMultiTexCoord2ivARB, + 0, /* glMultiTexCoord2sARB */ + logMultiTexCoord2svARB, + 0, /* glMultiTexCoord3dARB */ + logMultiTexCoord3dvARB, + 0, /* glMultiTexCoord3fARB */ + logMultiTexCoord3fvARB, + 0, /* glMultiTexCoord3iARB */ + logMultiTexCoord3ivARB, + 0, /* glMultiTexCoord3sARB */ + logMultiTexCoord3svARB, + 0, /* glMultiTexCoord4dARB */ + logMultiTexCoord4dvARB, + 0, /* glMultiTexCoord4fARB */ + logMultiTexCoord4fvARB, + 0, /* glMultiTexCoord4iARB */ + logMultiTexCoord4ivARB, + 0, /* glMultiTexCoord4sARB */ + logMultiTexCoord4svARB, + 0, /* glLoadTransposeMatrixfARB */ + 0, /* glLoadTransposeMatrixdARB */ + 0, /* glMultTransposeMatrixfARB */ + 0, /* glMultTransposeMatrixdARB */ + logSampleCoverageARB, + 0, /* glDrawBuffersARB */ + 0, /* glPolygonOffsetEXT */ + 0, /* glGetTexFilterFuncSGIS */ + 0, /* glTexFilterFuncSGIS */ + 0, /* glGetHistogramEXT */ + 0, /* glGetHistogramParameterfvEXT */ + 0, /* glGetHistogramParameterivEXT */ + 0, /* glGetMinmaxEXT */ + 0, /* glGetMinmaxParameterfvEXT */ + 0, /* glGetMinmaxParameterivEXT */ + 0, /* glGetConvolutionFilterEXT */ + 0, /* glGetConvolutionParameterfvEXT */ + 0, /* glGetConvolutionParameterivEXT */ + 0, /* glGetSeparableFilterEXT */ + 0, /* glGetColorTableSGI */ + 0, /* glGetColorTableParameterfvSGI */ + 0, /* glGetColorTableParameterivSGI */ + 0, /* glPixelTexGenSGIX */ + 0, /* glPixelTexGenParameteriSGIS */ + 0, /* glPixelTexGenParameterivSGIS */ + 0, /* glPixelTexGenParameterfSGIS */ + 0, /* glPixelTexGenParameterfvSGIS */ + 0, /* glGetPixelTexGenParameterivSGIS */ + 0, /* glGetPixelTexGenParameterfvSGIS */ + 0, /* glTexImage4DSGIS */ + 0, /* glTexSubImage4DSGIS */ + logAreTexturesResidentEXT, + logGenTexturesEXT, + logIsTextureEXT, + 0, /* glDetailTexFuncSGIS */ + 0, /* glGetDetailTexFuncSGIS */ + 0, /* glSharpenTexFuncSGIS */ + 0, /* glGetSharpenTexFuncSGIS */ + logSampleMaskSGIS, + logSamplePatternSGIS, + 0, /* glColorPointerEXT */ + 0, /* glEdgeFlagPointerEXT */ + 0, /* glIndexPointerEXT */ + 0, /* glNormalPointerEXT */ + 0, /* glTexCoordPointerEXT */ + 0, /* glVertexPointerEXT */ + 0, /* glSpriteParameterfSGIX */ + 0, /* glSpriteParameterfvSGIX */ + 0, /* glSpriteParameteriSGIX */ + 0, /* glSpriteParameterivSGIX */ + logPointParameterfEXT, + logPointParameterfvEXT, + 0, /* glGetInstrumentsSGIX */ + 0, /* glInstrumentsBufferSGIX */ + 0, /* glPollInstrumentsSGIX */ + 0, /* glReadInstrumentsSGIX */ + 0, /* glStartInstrumentsSGIX */ + 0, /* glStopInstrumentsSGIX */ + 0, /* glFrameZoomSGIX */ + 0, /* glTagSampleBufferSGIX */ + 0, /* glReferencePlaneSGIX */ + 0, /* glFlushRasterSGIX */ + 0, /* glGetListParameterfvSGIX */ + 0, /* glGetListParameterivSGIX */ + 0, /* glListParameterfSGIX */ + 0, /* glListParameterfvSGIX */ + 0, /* glListParameteriSGIX */ + 0, /* glListParameterivSGIX */ + 0, /* glFragmentColorMaterialSGIX */ + 0, /* glFragmentLightfSGIX */ + 0, /* glFragmentLightfvSGIX */ + 0, /* glFragmentLightiSGIX */ + 0, /* glFragmentLightivSGIX */ + 0, /* glFragmentLightModelfSGIX */ + 0, /* glFragmentLightModelfvSGIX */ + 0, /* glFragmentLightModeliSGIX */ + 0, /* glFragmentLightModelivSGIX */ + 0, /* glFragmentMaterialfSGIX */ + 0, /* glFragmentMaterialfvSGIX */ + 0, /* glFragmentMaterialiSGIX */ + 0, /* glFragmentMaterialivSGIX */ + 0, /* glGetFragmentLightfvSGIX */ + 0, /* glGetFragmentLightivSGIX */ + 0, /* glGetFragmentMaterialfvSGIX */ + 0, /* glGetFragmentMaterialivSGIX */ + 0, /* glLightEnviSGIX */ + 0, /* glVertexWeightfEXT */ + 0, /* glVertexWeightfvEXT */ + 0, /* glVertexWeightPointerEXT */ + 0, /* glFlushVertexArrayRangeNV */ + 0, /* glVertexArrayRangeNV */ + 0, /* glCombinerParameterfvNV */ + 0, /* glCombinerParameterfNV */ + 0, /* glCombinerParameterivNV */ + 0, /* glCombinerParameteriNV */ + 0, /* glCombinerInputNV */ + 0, /* glCombinerOutputNV */ + 0, /* glFinalCombinerInputNV */ + 0, /* glGetCombinerInputParameterfvNV */ + 0, /* glGetCombinerInputParameterivNV */ + 0, /* glGetCombinerOutputParameterfvNV */ + 0, /* glGetCombinerOutputParameterivNV */ + 0, /* glGetFinalCombinerInputParameterfvNV */ + 0, /* glGetFinalCombinerInputParameterivNV */ + 0, /* glResizeBuffersMESA */ + 0, /* glWindowPos2dMESA */ + 0, /* glWindowPos2dvMESA */ + 0, /* glWindowPos2fMESA */ + 0, /* glWindowPos2fvMESA */ + 0, /* glWindowPos2iMESA */ + 0, /* glWindowPos2ivMESA */ + 0, /* glWindowPos2sMESA */ + 0, /* glWindowPos2svMESA */ + 0, /* glWindowPos3dMESA */ + 0, /* glWindowPos3dvMESA */ + logWindowPos3fMESA, + 0, /* glWindowPos3fvMESA */ + 0, /* glWindowPos3iMESA */ + 0, /* glWindowPos3ivMESA */ + 0, /* glWindowPos3sMESA */ + 0, /* glWindowPos3svMESA */ + 0, /* glWindowPos4dMESA */ + 0, /* glWindowPos4dvMESA */ + 0, /* glWindowPos4fMESA */ + 0, /* glWindowPos4fvMESA */ + 0, /* glWindowPos4iMESA */ + 0, /* glWindowPos4ivMESA */ + 0, /* glWindowPos4sMESA */ + 0, /* glWindowPos4svMESA */ + logBlendFuncSeparateEXT, + 0, /* glIndexMaterialEXT */ + 0, /* glIndexFuncEXT */ + 0, /* glLockArraysEXT */ + 0, /* glUnlockArraysEXT */ + 0, /* glCullParameterdvEXT */ + 0, /* glCullParameterfvEXT */ + 0, /* glHintPGI */ + 0, /* glFogCoordfEXT */ + logFogCoordfvEXT, + 0, /* glFogCoorddEXT */ + logFogCoorddvEXT, + logFogCoordPointerEXT, + 0, /* glGetColorTableEXT */ + 0, /* glGetColorTableParameterivEXT */ + 0, /* glGetColorTableParameterfvEXT */ + 0, /* glTbufferMask3DFX */ + 0, /* glCompressedTexImage3DARB */ + 0, /* glCompressedTexImage2DARB */ + 0, /* glCompressedTexImage1DARB */ + 0, /* glCompressedTexSubImage3DARB */ + 0, /* glCompressedTexSubImage2DARB */ + 0, /* glCompressedTexSubImage1DARB */ + 0, /* glGetCompressedTexImageARB */ + 0, /* glSecondaryColor3bEXT */ + logSecondaryColor3bvEXT, + 0, /* glSecondaryColor3dEXT */ + logSecondaryColor3dvEXT, + 0, /* glSecondaryColor3fEXT */ + logSecondaryColor3fvEXT, + 0, /* glSecondaryColor3iEXT */ + logSecondaryColor3ivEXT, + 0, /* glSecondaryColor3sEXT */ + logSecondaryColor3svEXT, + 0, /* glSecondaryColor3ubEXT */ + logSecondaryColor3ubvEXT, + 0, /* glSecondaryColor3uiEXT */ + logSecondaryColor3uivEXT, + 0, /* glSecondaryColor3usEXT */ + logSecondaryColor3usvEXT, + logSecondaryColorPointerEXT, + 0, /* glAreProgramsResidentNV */ + 0, /* glBindProgramNV */ + 0, /* glDeleteProgramsNV */ + 0, /* glExecuteProgramNV */ + 0, /* glGenProgramsNV */ + 0, /* glGetProgramParameterdvNV */ + 0, /* glGetProgramParameterfvNV */ + 0, /* glGetProgramivNV */ + 0, /* glGetProgramStringNV */ + 0, /* glGetTrackMatrixivNV */ + 0, /* glGetVertexAttribdvARB */ + 0, /* glGetVertexAttribfvARB */ + 0, /* glGetVertexAttribivARB */ + 0, /* glGetVertexAttribPointervNV */ + 0, /* glIsProgramNV */ + 0, /* glLoadProgramNV */ + 0, /* glProgramParameter4dNV */ + 0, /* glProgramParameter4dvNV */ + 0, /* glProgramParameter4fNV */ + 0, /* glProgramParameter4fvNV */ + 0, /* glProgramParameters4dvNV */ + 0, /* glProgramParameters4fvNV */ + 0, /* glRequestResidentProgramsNV */ + 0, /* glTrackMatrixNV */ + 0, /* glVertexAttribPointerNV */ + 0, /* glVertexAttrib1dARB */ + 0, /* glVertexAttrib1dvARB */ + 0, /* glVertexAttrib1fARB */ + 0, /* glVertexAttrib1fvARB */ + 0, /* glVertexAttrib1sARB */ + 0, /* glVertexAttrib1svARB */ + 0, /* glVertexAttrib2dARB */ + 0, /* glVertexAttrib2dvARB */ + 0, /* glVertexAttrib2fARB */ + 0, /* glVertexAttrib2fvARB */ + 0, /* glVertexAttrib2sARB */ + 0, /* glVertexAttrib2svARB */ + 0, /* glVertexAttrib3dARB */ + 0, /* glVertexAttrib3dvARB */ + 0, /* glVertexAttrib3fARB */ + 0, /* glVertexAttrib3fvARB */ + 0, /* glVertexAttrib3sARB */ + 0, /* glVertexAttrib3svARB */ + 0, /* glVertexAttrib4dARB */ + 0, /* glVertexAttrib4dvARB */ + 0, /* glVertexAttrib4fARB */ + 0, /* glVertexAttrib4fvARB */ + 0, /* glVertexAttrib4sARB */ + 0, /* glVertexAttrib4svARB */ + 0, /* glVertexAttrib4NubARB */ + 0, /* glVertexAttrib4NubvARB */ + 0, /* glVertexAttribs1dvNV */ + 0, /* glVertexAttribs1fvNV */ + 0, /* glVertexAttribs1svNV */ + 0, /* glVertexAttribs2dvNV */ + 0, /* glVertexAttribs2fvNV */ + 0, /* glVertexAttribs2svNV */ + 0, /* glVertexAttribs3dvNV */ + 0, /* glVertexAttribs3fvNV */ + 0, /* glVertexAttribs3svNV */ + 0, /* glVertexAttribs4dvNV */ + 0, /* glVertexAttribs4fvNV */ + 0, /* glVertexAttribs4svNV */ + 0, /* glVertexAttribs4ubvNV */ + logPointParameteriNV, + logPointParameterivNV, + 0, /* glMultiDrawArraysEXT */ + 0, /* glMultiDrawElementsEXT */ + logActiveStencilFaceEXT, + 0, /* glDeleteFencesNV */ + 0, /* glGenFencesNV */ + 0, /* glIsFenceNV */ + 0, /* glTestFenceNV */ + 0, /* glGetFenceivNV */ + 0, /* glFinishFenceNV */ + 0, /* glSetFenceNV */ + 0, /* glVertexAttrib4bvARB */ + 0, /* glVertexAttrib4ivARB */ + 0, /* glVertexAttrib4ubvARB */ + 0, /* glVertexAttrib4usvARB */ + 0, /* glVertexAttrib4uivARB */ + 0, /* glVertexAttrib4NbvARB */ + 0, /* glVertexAttrib4NsvARB */ + 0, /* glVertexAttrib4NivARB */ + 0, /* glVertexAttrib4NusvARB */ + 0, /* glVertexAttrib4NuivARB */ + 0, /* glVertexAttribPointerARB */ + 0, /* glEnableVertexAttribArrayARB */ + 0, /* glDisableVertexAttribArrayARB */ + 0, /* glProgramStringARB */ + 0, /* glProgramEnvParameter4dARB */ + 0, /* glProgramEnvParameter4dvARB */ + 0, /* glProgramEnvParameter4fARB */ + 0, /* glProgramEnvParameter4fvARB */ + 0, /* glProgramLocalParameter4dARB */ + 0, /* glProgramLocalParameter4dvARB */ + 0, /* glProgramLocalParameter4fARB */ + 0, /* glProgramLocalParameter4fvARB */ + 0, /* glGetProgramEnvParameterdvARB */ + 0, /* glGetProgramEnvParameterfvARB */ + 0, /* glGetProgramLocalParameterdvARB */ + 0, /* glGetProgramLocalParameterfvARB */ + 0, /* glGetProgramivARB */ + 0, /* glGetProgramStringARB */ + 0, /* glProgramNamedParameter4fNV */ + 0, /* glProgramNamedParameter4dNV */ + 0, /* glProgramNamedParameter4fvNV */ + 0, /* glProgramNamedParameter4dvNV */ + 0, /* glGetProgramNamedParameterfvNV */ + 0, /* glGetProgramNamedParameterdvNV */ + 0, /* glBindBufferARB */ + 0, /* glBufferDataARB */ + 0, /* glBufferSubDataARB */ + 0, /* glDeleteBuffersARB */ + 0, /* glGenBuffersARB */ + 0, /* glGetBufferParameterivARB */ + 0, /* glGetBufferPointervARB */ + 0, /* glGetBufferSubDataARB */ + 0, /* glIsBufferARB */ + 0, /* glMapBufferARB */ + 0, /* glUnmapBufferARB */ + 0, /* glDepthBoundsEXT */ + 0, /* glGenQueriesARB */ + 0, /* glDeleteQueriesARB */ + 0, /* glIsQueryARB */ + 0, /* glBeginQueryARB */ + 0, /* glEndQueryARB */ + 0, /* glGetQueryivARB */ + 0, /* glGetQueryObjectivARB */ + 0, /* glGetQueryObjectuivARB */ + 0, /* glMultiModeDrawArraysIBM */ + 0, /* glMultiModeDrawElementsIBM */ + 0, /* glBlendEquationSeparateEXT */ + 0, /* glDeleteObjectARB */ + 0, /* glGetHandleARB */ + 0, /* glDetachObjectARB */ + 0, /* glCreateShaderObjectARB */ + 0, /* glShaderSourceARB */ + 0, /* glCompileShaderARB */ + 0, /* glCreateProgramObjectARB */ + 0, /* glAttachObjectARB */ + 0, /* glLinkProgramARB */ + 0, /* glUseProgramObjectARB */ + 0, /* glValidateProgramARB */ + 0, /* glUniform1fARB */ + 0, /* glUniform2fARB */ + 0, /* glUniform3fARB */ + 0, /* glUniform4fARB */ + 0, /* glUniform1iARB */ + 0, /* glUniform2iARB */ + 0, /* glUniform3iARB */ + 0, /* glUniform4iARB */ + 0, /* glUniform1fvARB */ + 0, /* glUniform2fvARB */ + 0, /* glUniform3fvARB */ + 0, /* glUniform4fvARB */ + 0, /* glUniform1ivARB */ + 0, /* glUniform2ivARB */ + 0, /* glUniform3ivARB */ + 0, /* glUniform4ivARB */ + 0, /* glUniformMatrix2fvARB */ + 0, /* glUniformMatrix3fvARB */ + 0, /* glUniformMatrix4fvARB */ + 0, /* glGetObjectParameterfvARB */ + 0, /* glGetObjectParameterivARB */ + 0, /* glGetInfoLogARB */ + 0, /* glGetAttachedObjectsARB */ + 0, /* glGetUniformLocationARB */ + 0, /* glGetActiveUniformARB */ + 0, /* glGetUniformfvARB */ + 0, /* glGetUniformivARB */ + 0, /* glGetShaderSourceARB */ + 0, /* glBindAttribLocationARB */ + 0, /* glGetActiveAttribARB */ + 0, /* glGetAttribLocationARB */ + 0, /* glGetVertexAttribdvNV */ + 0, /* glGetVertexAttribfvNV */ + 0, /* glGetVertexAttribivNV */ + 0, /* glVertexAttrib1dNV */ + 0, /* glVertexAttrib1dvNV */ + 0, /* glVertexAttrib1fNV */ + 0, /* glVertexAttrib1fvNV */ + 0, /* glVertexAttrib1sNV */ + 0, /* glVertexAttrib1svNV */ + 0, /* glVertexAttrib2dNV */ + 0, /* glVertexAttrib2dvNV */ + 0, /* glVertexAttrib2fNV */ + 0, /* glVertexAttrib2fvNV */ + 0, /* glVertexAttrib2sNV */ + 0, /* glVertexAttrib2svNV */ + 0, /* glVertexAttrib3dNV */ + 0, /* glVertexAttrib3dvNV */ + 0, /* glVertexAttrib3fNV */ + 0, /* glVertexAttrib3fvNV */ + 0, /* glVertexAttrib3sNV */ + 0, /* glVertexAttrib3svNV */ + 0, /* glVertexAttrib4dNV */ + 0, /* glVertexAttrib4dvNV */ + 0, /* glVertexAttrib4fNV */ + 0, /* glVertexAttrib4fvNV */ + 0, /* glVertexAttrib4sNV */ + 0, /* glVertexAttrib4svNV */ + 0, /* glVertexAttrib4ubNV */ + 0, /* glVertexAttrib4ubvNV */ + 0, /* glGenFragmentShadersATI */ + 0, /* glBindFragmentShaderATI */ + 0, /* glDeleteFragmentShaderATI */ + 0, /* glBeginFragmentShaderATI */ + 0, /* glEndFragmentShaderATI */ + 0, /* glPassTexCoordATI */ + 0, /* glSampleMapATI */ + 0, /* glColorFragmentOp1ATI */ + 0, /* glColorFragmentOp2ATI */ + 0, /* glColorFragmentOp3ATI */ + 0, /* glAlphaFragmentOp1ATI */ + 0, /* glAlphaFragmentOp2ATI */ + 0, /* glAlphaFragmentOp3ATI */ + 0, /* glSetFragmentShaderConstantATI */ + logIsRenderbufferEXT, + logBindRenderbufferEXT, + logDeleteRenderbuffersEXT, + logGenRenderbuffersEXT, + logRenderbufferStorageEXT, + logGetRenderbufferParameterivEXT, + logIsFramebufferEXT, + logBindFramebufferEXT, + logDeleteFramebuffersEXT, + logGenFramebuffersEXT, + logCheckFramebufferStatusEXT, + logFramebufferTexture1DEXT, + logFramebufferTexture2DEXT, + logFramebufferTexture3DEXT, + logFramebufferRenderbufferEXT, + logGetFramebufferAttachmentParameterivEXT, + logGenerateMipmapEXT, + 0, /* glStencilFuncSeparate */ + 0, /* glStencilOpSeparate */ + 0, /* glStencilMaskSeparate */ + 0, /* glGetQueryObjecti64vEXT */ + 0 /* glGetQueryObjectui64vEXT */ +}; + +static Bool isCurrent = FALSE; + +static void (*flushContextCache) (void); +static void (*setRenderTables) (struct _glapi_table *table); + +static void +GlxLogFlushContextCache (void) +{ + if (isCurrent) + { + fprintf (logFp, "LOSE CURRENT\n"); + isCurrent = FALSE; + } + + (*flushContextCache) (); +} + +static void +GlxLogSetRenderTables (struct _glapi_table *table) +{ + nativeRenderTable = table; + + if (table) + { + fprintf (logFp, "FORCE CURRENT\n"); + isCurrent = TRUE; + + (*setRenderTables) (&__logRenderTable); + } + else + { + (*setRenderTables) (0); + } +} + +void +xglInitGlxLog (void) +{ + if (logFp) + return; + + if (__xglGLXLogFp) + { + logFp = __xglGLXLogFp; + + flushContextCache = __xglGLXFunc.flushContextCache; + setRenderTables = __xglGLXFunc.setRenderTables; + + __xglGLXFunc.flushContextCache = GlxLogFlushContextCache; + __xglGLXFunc.setRenderTables = GlxLogSetRenderTables; + } +} + +#endif diff --git a/hw/xgl/xgl.h b/hw/xgl/xgl.h index 0ccf936e4..cd4cec162 100644 --- a/hw/xgl/xgl.h +++ b/hw/xgl/xgl.h @@ -1,6 +1,6 @@ /* * Copyright © 2004 David Reveman - * + * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without * fee, provided that the above copyright notice appear in all copies @@ -12,11 +12,11 @@ * software for any purpose. It is provided "as is" without express or * implied warranty. * - * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * 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. * @@ -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,18 +70,39 @@ 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 width; - unsigned int height; - unsigned int widthMm; - unsigned int heightMm; - int geometryDataType; - int geometryUsage; - Bool yInverted; - int pboMask; - Bool lines; - Bool fbo; + glitz_drawable_t *drawable; + unsigned int depth; + unsigned int width; + unsigned int height; + unsigned int widthMm; + unsigned int heightMm; + int geometryDataType; + int geometryUsage; + Bool yInverted; + int pboMask; + Bool lines; + xglScreenAccelInfoRec accel; } xglScreenInfoRec, *xglScreenInfoPtr; extern xglScreenInfoRec xglScreenInfo; @@ -82,18 +113,17 @@ typedef struct _xglPixelFormat { } xglPixelFormatRec, *xglPixelFormatPtr; typedef struct _xglVisual { - glitz_drawable_format_t *format; - xglPixelFormatPtr pPixel; - unsigned long visuals; -} xglVisualRec, *xglVisualPtr; - -typedef struct _xglPixmapFormat { - glitz_format_t *format; + struct _xglVisual *next; + VisualID vid; xglPixelFormatPtr pPixel; -} xglPixmapFormatRec, *xglPixmapFormatPtr; + Bool pbuffer; + struct { + glitz_drawable_format_t *drawable; + glitz_format_t *surface; + } format; +} xglVisualRec, *xglVisualPtr; extern xglVisualPtr xglVisuals; -extern int nxglVisuals; #define xglAreaAvailable 0 #define xglAreaDivided 1 @@ -114,7 +144,7 @@ typedef struct _xglArea { typedef struct _xglAreaFuncs { Bool (*Create) (xglAreaPtr pArea); - + Bool (*MoveIn) (xglAreaPtr pArea, pointer closure); @@ -124,7 +154,7 @@ typedef struct _xglAreaFuncs { int (*CompareScore) (xglAreaPtr pArea, pointer closure1, pointer closure2); - + } xglAreaFuncsRec, *xglAreaFuncsPtr; typedef struct _xglRootArea { @@ -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,22 +255,22 @@ 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 - + GetImageProcPtr GetImage; GetSpansProcPtr GetSpans; CreateWindowProcPtr CreateWindow; + DestroyWindowProcPtr DestroyWindow; ChangeWindowAttributesProcPtr ChangeWindowAttributes; PaintWindowBackgroundProcPtr PaintWindowBackground; PaintWindowBorderProcPtr PaintWindowBorder; @@ -258,16 +295,11 @@ typedef struct _xglScreen { #endif BSFuncRec BackingStoreFuncs; - -#ifdef GLXEXT - DestroyWindowProcPtr DestroyWindow; -#endif - } xglScreenRec, *xglScreenPtr; extern int xglScreenPrivateIndex; -#define XGL_GET_SCREEN_PRIV(pScreen) \ +#define XGL_GET_SCREEN_PRIV(pScreen) \ ((xglScreenPtr) (pScreen)->devPrivates[xglScreenPrivateIndex].ptr) #define XGL_SET_SCREEN_PRIV(pScreen, v) \ @@ -293,17 +325,17 @@ 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_operator_t op; - unsigned long flags; - GCFuncsPtr funcs; - GCOpsPtr ops; + glitz_surface_t *fg; + glitz_surface_t *bg; + glitz_format_id_t id; + glitz_operator_t op; + unsigned long flags; + GCFuncsPtr funcs; + GCOpsPtr ops; } xglGCRec, *xglGCPtr; extern int xglGCPrivateIndex; @@ -324,7 +356,7 @@ extern int xglGCPrivateIndex; #define xglPCFillMask (1L << 0) #define xglPCFilterMask (1L << 1) -#define xglPCTransformMask (1L << 2) +#define xglPCTransformMask (1L << 2) #define xglPCComponentAlphaMask (1L << 3) #define xglPCDitherMask (1L << 4) @@ -334,22 +366,36 @@ 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; - glitz_surface_t *surface; - glitz_buffer_t *buffer; - int target; - Bool acceleratedTile; - pointer bits; - int stride; - DamagePtr pDamage; - BoxRec damageBox; - BoxRec bitBox; - Bool allBits; - unsigned long pictureMask; - xglGeometryPtr pGeometry; - int lock; + xglVisualPtr pVisual; + glitz_surface_t *surface; + glitz_drawable_t *drawable; + glitz_buffer_t *buffer; + int target; + Bool acceleratedTile; + pointer bits; + int stride; + DamagePtr pDamage; + BoxRec damageBox; + RegionRec bitRegion; + Bool allBits; + unsigned long pictureMask; + xglGeometryPtr pGeometry; + +#ifdef XV + xglXvPortPtr pPortPriv; +#endif + } xglPixmapRec, *xglPixmapPtr; extern int xglPixmapPrivateIndex; @@ -364,7 +410,7 @@ extern int xglPixmapPrivateIndex; #define XGL_PICTURE_FAILURES(pictureMask) (pictureMask & 0xffff0000) typedef struct _xglWin { - PixmapPtr pPixmap; + PixmapPtr pPixmap; } xglWinRec, *xglWinPtr; extern int xglWinPrivateIndex; @@ -463,27 +509,41 @@ 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); -void -xglInitVisuals (ScreenInfo *pScreenInfo); +Bool +xglHasVisualTypes (xglVisualPtr pVisual, + int depth); -void -xglClearVisualTypes (void); +glitz_format_t * +xglFindBestSurfaceFormat (ScreenPtr pScreen, + xglPixelFormatPtr pPixel); void -xglInitPixmapFormats (ScreenPtr pScreen); +xglInitVisuals (ScreenPtr pScreen); + +xglVisualPtr +xglFindVisualWithDepth (ScreenPtr pScreen, + int depth); + +xglVisualPtr +xglFindVisualWithId (ScreenPtr pScreen, + int vid); void -xglPixelToColor (xglPixelFormatPtr pFormat, - CARD32 pixel, - glitz_color_t *color); +xglClearVisualTypes (void); /* xglparse.c */ @@ -680,7 +740,7 @@ extern xglDataTypeInfoRec xglGeometryDataTypes[2]; #define GEOMETRY_ADD_REGION_AT(pScreen, pGeometry, pRegion, offset) \ xglGeometryAddBox (pScreen, pGeometry, \ REGION_RECTS (pRegion), \ - REGION_NUM_RECTS (pRegion), \ + REGION_NUM_RECTS (pRegion), \ offset) #define GEOMETRY_ADD_REGION(pScreen, pGeometry, pRegion) \ @@ -792,7 +852,7 @@ xglGetScratchVertexGeometry (ScreenPtr pScreen, int count); Bool -xglSetGeometry (xglGeometryPtr pGeometry, +xglSetGeometry (xglGeometryPtr pGeometry, glitz_surface_t *surface); @@ -813,7 +873,7 @@ xglSetGeometry (xglGeometryPtr pGeometry, PixmapPtr xglCreatePixmap (ScreenPtr pScreen, int width, - int height, + int height, int depth); void @@ -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, @@ -960,7 +1032,7 @@ Bool xglFill (DrawablePtr pDrawable, GCPtr pGC, xglGeometryPtr pGeometry, - int x, + int x, int y, int width, int height, @@ -975,8 +1047,8 @@ xglFillSpan (DrawablePtr pDrawable, int *pwidth); void -xglFillRect (DrawablePtr pDrawable, - GCPtr pGC, +xglFillRect (DrawablePtr pDrawable, + GCPtr pGC, int nrect, xRectangle *prect); @@ -989,7 +1061,7 @@ xglFillLine (DrawablePtr pDrawable, Bool xglFillSegment (DrawablePtr pDrawable, - GCPtr pGC, + GCPtr pGC, int nsegInit, xSegment *pSegInit); @@ -1009,12 +1081,15 @@ Bool xglCreateWindow (WindowPtr pWin); Bool +xglDestroyWindow (WindowPtr pWin); + +Bool xglChangeWindowAttributes (WindowPtr pWin, unsigned long mask); -void -xglCopyWindow (WindowPtr pWin, - DDXPointRec ptOldOrg, +void +xglCopyWindow (WindowPtr pWin, + DDXPointRec ptOldOrg, RegionPtr prgnSrc); void @@ -1027,6 +1102,13 @@ xglPaintWindowBorder (WindowPtr pWin, RegionPtr pRegion, int what); +PixmapPtr +xglGetWindowPixmap (WindowPtr pWin); + +void +xglSetWindowPixmap (WindowPtr pWin, + PixmapPtr pPixmap); + /* xglbstore.c */ @@ -1058,11 +1140,11 @@ xglGetImage (DrawablePtr pDrawable, char *d); void -xglGetSpans (DrawablePtr pDrawable, - int wMax, - DDXPointPtr ppt, - int *pwidth, - int nspans, +xglGetSpans (DrawablePtr pDrawable, + int wMax, + DDXPointPtr ppt, + int *pwidth, + int nspans, char *pchardstStart); @@ -1072,6 +1154,9 @@ Bool xglCreateGC (GCPtr pGC); void +xglDestroyGC (GCPtr pGC); + +void xglValidateGC (GCPtr pGC, unsigned long changes, DrawablePtr pDrawable); @@ -1144,13 +1229,13 @@ xglPolylines (DrawablePtr pDrawable, void xglPolySegment (DrawablePtr pDrawable, - GCPtr pGC, + GCPtr pGC, int nsegInit, xSegment *pSegInit); void xglPolyArc (DrawablePtr pDrawable, - GCPtr pGC, + GCPtr pGC, int narcs, xArc *pArcs); @@ -1162,7 +1247,7 @@ xglPolyFillRect (DrawablePtr pDrawable, void xglPolyFillArc (DrawablePtr pDrawable, - GCPtr pGC, + GCPtr pGC, int narcs, xArc *pArcs); @@ -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 */ -Bool -xglLoadGLXModules (void); +#ifdef XV -void -xglUnloadGLXModules (void); +Bool +xglXvScreenInit (ScreenPtr pScreen); #endif + /* xglhash.c */ typedef struct _xglHashTable *xglHashTablePtr; diff --git a/hw/xgl/xglarea.c b/hw/xgl/xglarea.c index 849f1a72e..cdf652d0f 100644 --- a/hw/xgl/xglarea.c +++ b/hw/xgl/xglarea.c @@ -1,6 +1,6 @@ /* * 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 @@ -12,11 +12,11 @@ * software for any purpose. It is provided "as is" without express or * implied warranty. * - * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * 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, + * 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. * @@ -31,7 +31,7 @@ xglAreaMoveIn (xglAreaPtr pArea, { pArea->closure = closure; pArea->state = xglAreaOccupied; - + return (*pArea->pRoot->funcs->MoveIn) (pArea, closure); } @@ -54,7 +54,7 @@ xglAreaCreate (xglRootAreaPtr pRoot, { xglAreaPtr pArea; int n = 4; - + pArea = xalloc (sizeof (xglAreaRec) + pRoot->devPrivateSize); if (!pArea) return NULL; @@ -67,7 +67,7 @@ xglAreaCreate (xglRootAreaPtr pRoot, pArea->pRoot = pRoot; pArea->closure = (pointer) 0; pArea->state = xglAreaAvailable; - + while (n--) pArea->pArea[n] = NULL; @@ -81,13 +81,13 @@ xglAreaCreate (xglRootAreaPtr pRoot, free (pArea); return NULL; } - + return pArea; } static void xglAreaDestroy (xglAreaPtr pArea) -{ +{ if (!pArea) return; @@ -98,11 +98,11 @@ xglAreaDestroy (xglAreaPtr pArea) else { int n = 4; - + while (n--) xglAreaDestroy (pArea->pArea[n]); } - + xfree (pArea); } @@ -111,7 +111,7 @@ xglAreaGetTopScoredSubArea (xglAreaPtr pArea) { if (!pArea) return NULL; - + switch (pArea->state) { case xglAreaOccupied: return pArea; @@ -120,7 +120,7 @@ xglAreaGetTopScoredSubArea (xglAreaPtr pArea) case xglAreaDivided: { xglAreaPtr tmp, top = NULL; int i; - + for (i = 0; i < 4; i++) { tmp = xglAreaGetTopScoredSubArea (pArea->pArea[i]); @@ -139,7 +139,7 @@ xglAreaGetTopScoredSubArea (xglAreaPtr pArea) return top; } } - + return NULL; } @@ -161,11 +161,11 @@ xglAreaFind (xglAreaPtr pArea, pArea->closure, closure) >= 0) return FALSE; - + xglAreaMoveOut (pArea); } else return FALSE; - + /* fall-through */ case xglAreaAvailable: { @@ -178,15 +178,15 @@ xglAreaFind (xglAreaPtr pArea, else { int dx[4], dy[4], w[4], h[4], i; - + dx[0] = dx[2] = dy[0] = dy[1] = 0; - + w[0] = w[2] = dx[1] = dx[3] = width; h[0] = h[1] = dy[2] = dy[3] = height; w[1] = w[3] = pArea->width - width; h[2] = h[3] = pArea->height - height; - + for (i = 0; i < 2; i++) { if (w[i]) @@ -210,7 +210,7 @@ xglAreaFind (xglAreaPtr pArea, } pArea->state = xglAreaDivided; - + if (xglAreaFind (pArea->pArea[0], width, height, kickOut, closure)) return TRUE; } @@ -230,7 +230,7 @@ xglAreaFind (xglAreaPtr pArea, if (xglFindArea (pArea->pArea[i], width, height, kickOut, closure)) return TRUE; - + rejected = TRUE; } } @@ -257,12 +257,12 @@ xglAreaFind (xglAreaPtr pArea, xglAreaDestroy (pArea->pArea[i]); pArea->pArea[i] = NULL; } - + pArea->closure = (pointer) 0; pArea->state = xglAreaAvailable; if (xglFindArea (pArea, width, height, TRUE, closure)) return TRUE; - + } break; } @@ -286,7 +286,7 @@ xglRootAreaInit (xglRootAreaPtr pRoot, pRoot->pArea = xglAreaCreate (pRoot, 0, 0, 0, width, height); if (!pRoot->pArea) return FALSE; - + return TRUE; } @@ -298,7 +298,7 @@ xglRootAreaFini (xglRootAreaPtr pRoot) void xglLeaveArea (xglAreaPtr pArea) -{ +{ xglAreaMoveOut (pArea); } diff --git a/hw/xgl/xglbstore.c b/hw/xgl/xglbstore.c index 65b4bbf5c..91019e0ce 100644 --- a/hw/xgl/xglbstore.c +++ b/hw/xgl/xglbstore.c @@ -1,6 +1,6 @@ /* * Copyright © 2004 David Reveman - * + * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without * fee, provided that the above copyright notice appear in all copies @@ -12,11 +12,11 @@ * software for any purpose. It is provided "as is" without express or * implied warranty. * - * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * 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. * @@ -69,12 +69,12 @@ xglSaveAreas (PixmapPtr pPixmap, box.y1 += yorg; box.x2 += xorg; box.y2 += yorg; - + if (!xglSyncBits (&pWin->drawable, &box)) 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, @@ -111,10 +111,10 @@ xglRestoreAreas (PixmapPtr pPixmap, box.y1 = pExt->y1 - yorg; box.x2 = pExt->x2 - xorg; box.y2 = pExt->y2 - yorg; - + if (!xglSyncBits (&pPixmap->drawable, &box)) FatalError (XGL_SW_FAILURE_STRING); - + XGL_BSTORE_FALLBACK_PROLOGUE (&pWin->drawable, BackingStoreFuncs.RestoreAreas); (*pScreen->BackingStoreFuncs.RestoreAreas) (pPixmap, prgnRestore, diff --git a/hw/xgl/xglcmap.c b/hw/xgl/xglcmap.c index f0c2ba2e4..b96308ddf 100644 --- a/hw/xgl/xglcmap.c +++ b/hw/xgl/xglcmap.c @@ -1,6 +1,6 @@ /* * Copyright © 2004 David Reveman - * + * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without * fee, provided that the above copyright notice appear in all copies @@ -12,18 +12,17 @@ * software for any purpose. It is provided "as is" without express or * implied warranty. * - * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * 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 <stdint.h> #include "xgl.h" #include "colormapst.h" #include "micmap.h" @@ -81,225 +80,387 @@ static xglPixelFormatRec xglPixelFormats[] = { #define NUM_XGL_PIXEL_FORMATS \ (sizeof (xglPixelFormats) / sizeof (xglPixelFormats[0])) -xglVisualPtr xglVisuals = NULL; -int nxglVisuals = 0; - -xglVisualPtr xglPbufferVisuals = NULL; -int nxglPbufferVisuals = 0; +xglVisualPtr xglVisuals = NULL; -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; + xglPixelFormatPtr pBestFormat = 0; + int i, rs, gs, bs, diff, bestDiff = 0; - if (!visuals) - depth += color->alpha_size; - 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) { - - if (visuals) - return pPixel; + rs = Ones (xglPixelFormats[i].masks.red_mask); + gs = Ones (xglPixelFormats[i].masks.green_mask); + bs = Ones (xglPixelFormats[i].masks.blue_mask); - if (Ones (pPixel->masks.alpha_mask) == color->alpha_size) - return pPixel; + if (redSize >= rs && + greenSize >= gs && + blueSize >= bs) + { + diff = (redSize - rs) + (greenSize - gs) + (blueSize - bs); + if (pBestFormat) + { + if (diff < bestDiff) + { + pBestFormat = &xglPixelFormats[i]; + bestDiff = diff; + } + } + else + { + pBestFormat = &xglPixelFormats[i]; + bestDiff = diff; + } + } + } + else + { + pBestFormat = &xglPixelFormats[i]; + break; } } } - - return NULL; + + 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 -xglSetVisualTypesAndMasks (ScreenInfo *pScreenInfo, - glitz_drawable_format_t *format, - unsigned long visuals) +Bool +xglHasVisualTypes (xglVisualPtr pVisual, + int depth) { - xglPixelFormatPtr pPixelFormat; + xglVisualPtr v; - pPixelFormat = xglFindPixelFormat (format, visuals); - if (pPixelFormat) - { - if (visuals) + for (v = pVisual; v; v = v->next) + if (v->pPixel->depth == depth) + return TRUE; + + return FALSE; +} + +glitz_format_t * +xglFindBestSurfaceFormat (ScreenPtr pScreen, + xglPixelFormatPtr pPixel) +{ + glitz_format_t templ, *format, *best = 0; + unsigned int mask; + unsigned short rs, gs, bs, as; + int i = 0; + + XGL_SCREEN_PRIV (pScreen); + + rs = Ones (pPixel->masks.red_mask); + gs = Ones (pPixel->masks.green_mask); + bs = Ones (pPixel->masks.blue_mask); + as = Ones (pPixel->masks.alpha_mask); + + templ.color.fourcc = GLITZ_FOURCC_RGB; + mask = GLITZ_FORMAT_FOURCC_MASK; + + do { + format = glitz_find_format (pScreenPriv->drawable, mask, &templ, i++); + if (format) { - xglVisuals = xrealloc (xglVisuals, - (nxglVisuals + 1) * sizeof (xglVisualRec)); - - if (xglVisuals) + if (format->color.red_size >= rs && + format->color.green_size >= gs && + format->color.blue_size >= bs && + format->color.alpha_size >= as) { - xglVisuals[nxglVisuals].format = format; - xglVisuals[nxglVisuals].pPixel = pPixelFormat; - xglVisuals[nxglVisuals].visuals = visuals; - nxglVisuals++; + if (best) + { + if (((format->color.red_size - rs) + + (format->color.green_size - gs) + + (format->color.blue_size - bs)) < + ((best->color.red_size - rs) + + (best->color.green_size - gs) + + (best->color.blue_size - bs))) + best = format; + } + else + { + best = format; + } } } + } while (format); + + return best; +} + +static Bool +xglInitVisual (ScreenPtr pScreen, + xglVisualPtr pVisual, + xglPixelFormatPtr pPixel, + VisualID vid) +{ + glitz_format_t *format; + + XGL_SCREEN_PRIV (pScreen); + + format = xglFindBestSurfaceFormat (pScreen, pPixel); + if (format) + { + glitz_drawable_format_t templ; + unsigned long mask; + + templ.color = format->color; + templ.depth_size = 0; + templ.stencil_size = 0; + templ.doublebuffer = 0; + templ.samples = 1; + + mask = + GLITZ_FORMAT_FOURCC_MASK | + GLITZ_FORMAT_RED_SIZE_MASK | + GLITZ_FORMAT_GREEN_SIZE_MASK | + GLITZ_FORMAT_BLUE_SIZE_MASK | + GLITZ_FORMAT_ALPHA_SIZE_MASK | + GLITZ_FORMAT_DEPTH_SIZE_MASK | + GLITZ_FORMAT_STENCIL_SIZE_MASK | + GLITZ_FORMAT_DOUBLEBUFFER_MASK | + GLITZ_FORMAT_SAMPLES_MASK; + + pVisual->next = 0; + pVisual->vid = vid; + pVisual->pPixel = pPixel; + pVisual->pbuffer = FALSE; + + pVisual->format.surface = format; + pVisual->format.drawable = + glitz_find_drawable_format (pScreenPriv->drawable, + mask, &templ, 0); + + return TRUE; + } + + return FALSE; +} + +static Bool +xglInitPbufferVisual (ScreenPtr pScreen, + xglVisualPtr pVisual, + xglPixelFormatPtr pPixel, + VisualID vid) +{ + glitz_format_t *format; + + XGL_SCREEN_PRIV (pScreen); + + format = xglFindBestSurfaceFormat (pScreen, pPixel); + if (format) + { + glitz_drawable_format_t templ, *screenFormat; + unsigned long mask; + + /* use same drawable format as screen for pbuffers */ + screenFormat = glitz_drawable_get_format (pScreenPriv->drawable); + templ.id = screenFormat->id; + + templ.color = format->color; + templ.samples = 1; + + mask = + GLITZ_FORMAT_ID_MASK | + GLITZ_FORMAT_FOURCC_MASK | + GLITZ_FORMAT_RED_SIZE_MASK | + GLITZ_FORMAT_GREEN_SIZE_MASK | + GLITZ_FORMAT_BLUE_SIZE_MASK | + GLITZ_FORMAT_SAMPLES_MASK; + + pVisual->next = 0; + pVisual->vid = vid; + pVisual->pPixel = pPixel; + pVisual->pbuffer = TRUE; + + pVisual->format.surface = format; + pVisual->format.drawable = + glitz_find_pbuffer_format (pScreenPriv->drawable, + mask, &templ, 0); + + if (pVisual->format.drawable) + return TRUE; } + + return FALSE; } void -xglInitVisuals (ScreenInfo *pScreenInfo) +xglInitVisuals (ScreenPtr pScreen) { - int i, j; + xglVisualPtr pVisual, v, new, *prev; + int i; - for (i = 0; i < pScreenInfo->numPixmapFormats; i++) + XGL_SCREEN_PRIV (pScreen); + + for (i = 0; i < pScreen->numVisuals; i++) { - unsigned long visuals; - unsigned int bitsPerRGB; - Pixel rm, gm, bm; - - visuals = 0; - bitsPerRGB = 0; - rm = gm = bm = 0; - - for (j = 0; j < nxglVisuals; j++) + for (pVisual = xglVisuals; pVisual; pVisual = pVisual->next) + if (pVisual->pPixel->depth == pScreen->visuals[i].nplanes) + break; + + if (pVisual) { - if (pScreenInfo->formats[i].depth == xglVisuals[j].pPixel->depth) + new = xalloc (sizeof (xglVisualRec)); + if (new) + { + if (xglInitVisual (pScreen, new, pVisual->pPixel, + pScreen->visuals[i].vid)) + { + new->next = 0; + + prev = &pScreenPriv->pVisual; + while ((v = *prev)) + prev = &v->next; + + *prev = new; + } + else + { + xfree (new); + } + } + + new = xalloc (sizeof (xglVisualRec)); + if (new) { - 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 (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); + } } } + } - if (!visuals) + /* Add additional Xgl visuals for pixmap formats */ + for (i = 0; i < screenInfo.numPixmapFormats; i++) + { + if (!xglHasVisualTypes (pScreenPriv->pVisual, + screenInfo.formats[i].depth)) { - for (j = 0; j < NUM_XGL_PIXEL_FORMATS; j++) + for (v = xglVisuals; v; v = v->next) + if (v->pPixel->depth == screenInfo.formats[i].depth) + break; + + if (v) { - if (pScreenInfo->formats[i].depth == xglPixelFormats[j].depth) + new = xalloc (sizeof (xglVisualRec)); + if (new) { - bitsPerRGB = xglPixelFormats[j].bitsPerRGB; - - rm = xglPixelFormats[j].masks.red_mask; - gm = xglPixelFormats[j].masks.green_mask; - bm = xglPixelFormats[j].masks.blue_mask; - break; + if (xglInitVisual (pScreen, new, v->pPixel, 0)) + { + new->next = 0; + + prev = &pScreenPriv->pVisual; + while ((v = *prev)) + prev = &v->next; + + *prev = new; + } + else + { + xfree (new); + } } } - - fbSetVisualTypesAndMasks (pScreenInfo->formats[i].depth, - visuals, bitsPerRGB, - rm, gm, bm); } } } -void -xglClearVisualTypes (void) +xglVisualPtr +xglFindVisualWithDepth (ScreenPtr pScreen, + int depth) { - nxglVisuals = 0; - nxglPbufferVisuals = 0; - - if (xglVisuals) - xfree (xglVisuals); + xglVisualPtr v; - if (xglPbufferVisuals) - xfree (xglPbufferVisuals); + XGL_SCREEN_PRIV (pScreen); - xglVisuals = NULL; - xglPbufferVisuals = NULL; + for (v = pScreenPriv->pVisual; v; v = v->next) + { + if (v->pPixel->depth == depth) + return v; + } - miClearVisualTypes (); + return 0; } -void -xglInitPixmapFormats (ScreenPtr pScreen) +xglVisualPtr +xglFindVisualWithId (ScreenPtr pScreen, + int vid) { - glitz_format_t *format, **best; - int i, j; - + xglVisualPtr v; + XGL_SCREEN_PRIV (pScreen); - for (i = 0; i < 33; i++) + for (v = pScreenPriv->pVisual; v; v = v->next) { - pScreenPriv->pixmapFormats[i].pPixel = NULL; - pScreenPriv->pixmapFormats[i].format = NULL; - - for (j = 0; j < NUM_XGL_PIXEL_FORMATS; j++) - { - if (xglPixelFormats[j].depth == i) - { - int rs, gs, bs, as, k; - - 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) - { - /* 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 (((format->color.red_size - rs) + - (format->color.green_size - gs) + - (format->color.blue_size - bs)) < - (((*best)->color.red_size - rs) + - ((*best)->color.green_size - gs) + - ((*best)->color.blue_size - bs))) - *best = format; - } else - *best = format; - } - } - } while (format); - } - } + if (v->vid == vid) + return v; } -} - -#define PIXEL_TO_COLOR(p, mask) \ - (((uint32_t) ((((uint64_t) (((uint32_t) (p)) & (mask))) * 0xffffffff) / \ - ((uint64_t) (mask))))) -#define PIXEL_TO_RGB_COLOR(p, mask) \ - ((mask)? PIXEL_TO_COLOR (p, mask): 0) + return 0; +} void -xglPixelToColor (xglPixelFormatPtr pFormat, - CARD32 pixel, - glitz_color_t *color) +xglClearVisualTypes (void) { - 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); - - if (pFormat->masks.alpha_mask) - color->alpha = PIXEL_TO_COLOR (pixel, pFormat->masks.alpha_mask); - else - color->alpha = 0xffff; + xglVisualPtr v; + + while (xglVisuals) + { + v = xglVisuals; + xglVisuals = v->next; + xfree (v); + } + + miClearVisualTypes (); } diff --git a/hw/xgl/xglcomp.c b/hw/xgl/xglcompose.c index a84efa4b6..d2aead05b 100644 --- a/hw/xgl/xglcomp.c +++ b/hw/xgl/xglcompose.c @@ -1,6 +1,6 @@ /* * Copyright © 2004 David Reveman - * + * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without * fee, provided that the above copyright notice appear in all copies @@ -12,11 +12,11 @@ * software for any purpose. It is provided "as is" without express or * implied warranty. * - * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * 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. * @@ -48,56 +48,64 @@ 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, - 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) +xglCompositeGeneral (CARD8 op, + PicturePtr pSrc, + PicturePtr pMask, + PicturePtr pDst, + xglGeometryPtr pGeometry, + INT16 xSrc, + INT16 ySrc, + INT16 xMask, + INT16 yMask, + INT16 xDst, + INT16 yDst, + CARD16 width, + CARD16 height) { ScreenPtr pScreen = pDst->pDrawable->pScreen; - 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) return FALSE; if (op >= NUM_XGL_OPERATORS) return FALSE; - if (pSrc->pSourcePict) - return FALSE; - - if (pSrc->pDrawable->type != DRAWABLE_PIXMAP) - return FALSE; + if (pSrc->pDrawable) + { + if (pSrc->pDrawable->type != DRAWABLE_PIXMAP) + return FALSE; - if (pSrc->pDrawable->bitsPerPixel == 1) - return FALSE; + if (pSrc->pDrawable->bitsPerPixel == 1) + return FALSE; + } if (pMask) { - if (pMask->pSourcePict) - return FALSE; - if (pMask->pDrawable->type != DRAWABLE_PIXMAP) - return FALSE; + if (pMask->pDrawable) + { + if (pMask->pDrawable->type != DRAWABLE_PIXMAP) + return FALSE; - if (pSrc->pDrawable == pMask->pDrawable && pSrc != pMask) - return FALSE; + if (pSrc->pDrawable == pMask->pDrawable && pSrc != pMask) + return FALSE; + } } + if (!xglPrepareTarget (pDst->pDrawable)) + return FALSE; + if (!miComputeCompositeRegion (®ion, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, xDst, yDst, width, height)) @@ -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); - src = pSrcPriv->surface; + xSrc -= xOff; + ySrc -= yOff; + + 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,10 +144,9 @@ xglComp (CARD8 op, return FALSE; } - pGeometry = - xglPixmapToGeometry ((PixmapPtr) pMask->pDrawable, - xDst - xMask, - yDst - yMask); + pGeometry = xglPixmapToGeometry ((PixmapPtr) pMask->pDrawable, + xDst - xMask, + yDst - yMask); if (!pGeometry) { REGION_UNINIT (pScreen, ®ion); @@ -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); - - mask = pMaskPriv->surface; + xMask -= xOff; + yMask -= yOff; + + 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, @@ -183,8 +193,8 @@ xglComp (CARD8 op, REGION_UNINIT (pScreen, ®ion); return FALSE; } - - pBox = REGION_EXTENTS (pScreen, ®ion); + + pBox = pExt; nBox = 1; } } @@ -210,10 +220,10 @@ xglComp (CARD8 op, if (nBox > 1) { pGeometry = xglGetScratchVertexGeometry (pScreen, 4 * nBox); - + GEOMETRY_ADD_BOX (pScreen, pGeometry, pBox, nBox); - - pBox = REGION_EXTENTS (pScreen, ®ion); + + pBox = pExt; } xSrc += pBox->x1 - xDst; @@ -224,10 +234,10 @@ xglComp (CARD8 op, xMask += pBox->x1 - xDst; yMask += pBox->y1 - yDst; } - + xDst = pBox->x1; yDst = pBox->y1; - + width = pBox->x2 - pBox->x1; height = pBox->y2 - pBox->y1; } @@ -244,10 +254,11 @@ xglComp (CARD8 op, if (!GEOMETRY_ENABLE (pGeometry, dst)) { - REGION_UNINIT (pScreen, ®ion); + REGION_UNINIT (pScreen, ®ion); return FALSE; } - } else + } + else GEOMETRY_DISABLE (dst); glitz_composite (XGL_OPERATOR (op), @@ -260,10 +271,10 @@ xglComp (CARD8 op, glitz_surface_set_clip_region (dst, 0, 0, NULL, 0); REGION_UNINIT (pScreen, ®ion); - + if (glitz_surface_get_status (dst)) return FALSE; - + return TRUE; } diff --git a/hw/xgl/xglcopy.c b/hw/xgl/xglcopy.c index c11bb25c1..d612b332a 100644 --- a/hw/xgl/xglcopy.c +++ b/hw/xgl/xglcopy.c @@ -1,6 +1,6 @@ /* * Copyright © 2004 David Reveman - * + * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without * fee, provided that the above copyright notice appear in all copies @@ -12,11 +12,11 @@ * software for any purpose. It is provided "as is" without express or * implied warranty. * - * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * 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. * @@ -38,6 +38,8 @@ xglCopy (DrawablePtr pSrc, int srcXoff, srcYoff; int dstXoff, dstYoff; + XGL_DRAWABLE_PIXMAP (pDst); + if (!nBox) return TRUE; @@ -50,11 +52,11 @@ xglCopy (DrawablePtr pSrc, { if (!xglPrepareTarget (pSrc)) return FALSE; - + if (!xglSyncSurface (pDst)) return FALSE; } - + XGL_GET_DRAWABLE (pSrc, src, srcXoff, srcYoff); XGL_GET_DRAWABLE (pDst, dst, dstXoff, dstYoff); @@ -64,18 +66,18 @@ 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); - + if (glitz_surface_get_status (dst)) return FALSE; - + return TRUE; } @@ -96,24 +98,16 @@ xglCopyProc (DrawablePtr pSrc, if (!xglCopy (pSrc, pDst, dx, dy, pBox, nBox)) { - RegionPtr pDamageRegion; - glitz_surface_t *dst; - int dstXoff, dstYoff; - RegionRec region; - BoxRec box; - + RegionRec region; + XGL_DRAWABLE_PIXMAP (pDst); XGL_PIXMAP_PRIV (pPixmap); - XGL_GET_DRAWABLE (pDst, dst, dstXoff, dstYoff); - - pDamageRegion = DamageRegion (pPixmapPriv->pDamage); + if (!xglSyncBits (pSrc, pSrcBox)) + FatalError (XGL_SW_FAILURE_STRING); if (!xglMapPixmapBits (pPixmap)) FatalError (XGL_SW_FAILURE_STRING); - - if (!xglSyncBits (pSrc, pSrcBox)) - FatalError (XGL_SW_FAILURE_STRING); fbCopyNtoN (pSrc, pDst, pGC, pBox, nBox, @@ -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++; diff --git a/hw/xgl/xglfill.c b/hw/xgl/xglfill.c index 1bcf41daa..64759ab2e 100644 --- a/hw/xgl/xglfill.c +++ b/hw/xgl/xglfill.c @@ -1,6 +1,6 @@ /* * Copyright © 2004 David Reveman - * + * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without * fee, provided that the above copyright notice appear in all copies @@ -12,11 +12,11 @@ * software for any purpose. It is provided "as is" without express or * implied warranty. * - * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * 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. * @@ -31,7 +31,7 @@ Bool xglFill (DrawablePtr pDrawable, GCPtr pGC, xglGeometryPtr pGeometry, - int x, + int x, int y, int width, int height, @@ -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, @@ -70,26 +70,21 @@ xglFill (DrawablePtr pDrawable, } static void -xglFillBox (DrawablePtr pDrawable, +xglFillBox (DrawablePtr pDrawable, GCPtr pGC, - int x, + int x, int y, int width, int height, BoxPtr pBox, int nBox) { - BoxRec box; - if (!nBox) - return; - + return; + if (!xglFill (pDrawable, pGC, NULL, x, y, width, height, pBox, nBox)) { - RegionRec region; - RegionPtr pDamageRegion; - glitz_surface_t *surface; - int xOff, yOff; + RegionRec region; XGL_DRAWABLE_PIXMAP (pDrawable); XGL_PIXMAP_PRIV (pPixmap); @@ -111,31 +106,18 @@ xglFillBox (DrawablePtr pDrawable, break; } - pDamageRegion = DamageRegion (pPixmapPriv->pDamage); - - XGL_GET_DRAWABLE (pDrawable, surface, xOff, yOff); - pPixmapPriv->damageBox = miEmptyBox; - + while (nBox--) { fbFill (pDrawable, pGC, 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_UNINIT (pDrawable->pScreen, ®ion); - } - + REGION_INIT (pDrawable->pScreen, ®ion, pBox, 1); + xglAddSurfaceDamage (pDrawable, ®ion); + REGION_UNINIT (pDrawable->pScreen, ®ion); + pBox++; } } else @@ -150,11 +132,11 @@ xglMoreBoxes (BoxPtr stackBox, int nBoxes) { Bool stack = !heapBox; - + heapBox = xrealloc (heapBox, sizeof (BoxRec) * nBoxes); if (!heapBox) return NULL; - + if (stack) memcpy (heapBox, stackBox, sizeof (BoxRec) * N_STACK_BOX); @@ -182,8 +164,8 @@ xglMoreBoxes (BoxPtr stackBox, } void -xglFillRect (DrawablePtr pDrawable, - GCPtr pGC, +xglFillRect (DrawablePtr pDrawable, + GCPtr pGC, int nrect, xRectangle *prect) { @@ -205,19 +187,19 @@ xglFillRect (DrawablePtr pDrawable, full.y2 = full.y1 + (int) prect->height; prect++; - + if (full.x1 < pExtent->x1) full.x1 = pExtent->x1; if (full.y1 < pExtent->y1) - full.y1 = pExtent->y1; + full.y1 = pExtent->y1; if (full.x2 > pExtent->x2) full.x2 = pExtent->x2; if (full.y2 > pExtent->y2) full.y2 = pExtent->y2; - + if (full.x1 >= full.x2 || full.y1 >= full.y2) continue; - + nClip = REGION_NUM_RECTS (pClip); if (nClip == 1) { @@ -238,7 +220,7 @@ xglFillRect (DrawablePtr pDrawable, part.x2 = full.x2; if (part.y2 > full.y2) part.y2 = full.y2; - + if (part.x1 < part.x2 && part.y1 < part.y2) ADD_BOX (pBox, nBox, stackBox, heapBox, size, part); } @@ -249,7 +231,7 @@ xglFillRect (DrawablePtr pDrawable, pExtent->x1, pExtent->y1, pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1, (heapBox) ? heapBox : stackBox, nBox); - + if (heapBox) xfree (heapBox); } @@ -280,19 +262,19 @@ xglFillSpan (DrawablePtr pDrawable, pwidth++; ppt++; - + if (full.x1 < pExtent->x1) full.x1 = pExtent->x1; if (full.y1 < pExtent->y1) - full.y1 = pExtent->y1; + full.y1 = pExtent->y1; if (full.x2 > pExtent->x2) full.x2 = pExtent->x2; if (full.y2 > pExtent->y2) full.y2 = pExtent->y2; - + if (full.x1 >= full.x2 || full.y1 >= full.y2) continue; - + nClip = REGION_NUM_RECTS (pClip); if (nClip == 1) { @@ -313,7 +295,7 @@ xglFillSpan (DrawablePtr pDrawable, part.x2 = full.x2; if (part.y2 > full.y2) part.y2 = full.y2; - + if (part.x1 < part.x2 && part.y1 < part.y2) ADD_BOX (pBox, nBox, stackBox, heapBox, size, part); } @@ -324,7 +306,7 @@ xglFillSpan (DrawablePtr pDrawable, pExtent->x1, pExtent->y1, pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1, (heapBox) ? heapBox : stackBox, nBox); - + if (heapBox) xfree (heapBox); } @@ -346,28 +328,28 @@ xglFillLine (DrawablePtr pDrawable, xglGeometryPtr pGeometry; XGL_SCREEN_PRIV (pGC->pScreen); - + if (npt < 2) return TRUE; - + pt = *ppt; - + nptTmp = npt - 1; pptTmp = ppt + 1; - + if (mode == CoordModePrevious) { while (nptTmp--) { if (pptTmp->x && pptTmp->y) horizontalAndVertical = FALSE; - + pt.x += pptTmp->x; pt.y += pptTmp->y; - + pptTmp++; } - + if (pt.x == ppt->x && pt.y == ppt->y) coincidentEndpoints = TRUE; } @@ -383,7 +365,7 @@ xglFillLine (DrawablePtr pDrawable, pt = *pptTmp++; } - + if (ppt[npt - 1].x == ppt->x && ppt[npt - 1].y == ppt->y) coincidentEndpoints = TRUE; } @@ -403,7 +385,7 @@ xglFillLine (DrawablePtr pDrawable, ppt++; npt--; - + while (npt--) { if (mode == CoordModePrevious) @@ -416,13 +398,13 @@ xglFillLine (DrawablePtr pDrawable, dx = ppt->x - pt.x; dy = ppt->y - pt.y; } - + if (dx) { if (dx > 0) { full.x1 = pt.x + pDrawable->x; - + if (npt || coincidentEndpoints) full.x2 = full.x1 + dx; else @@ -437,7 +419,7 @@ xglFillLine (DrawablePtr pDrawable, else full.x1 = full.x2 + dx - 1; } - + full.y1 = pt.y + pDrawable->y; full.y2 = full.y1 + 1; } @@ -446,7 +428,7 @@ xglFillLine (DrawablePtr pDrawable, if (dy > 0) { full.y1 = pt.y + pDrawable->y; - + if (npt || coincidentEndpoints) full.y2 = full.y1 + dy; else @@ -461,28 +443,28 @@ xglFillLine (DrawablePtr pDrawable, else full.y1 = full.y2 + dy - 1; } - + full.x1 = pt.x + pDrawable->x; full.x2 = full.x1 + 1; } - + pt.x += dx; pt.y += dy; - + ppt++; - + if (full.x1 < pExtent->x1) full.x1 = pExtent->x1; if (full.y1 < pExtent->y1) - full.y1 = pExtent->y1; + full.y1 = pExtent->y1; if (full.x2 > pExtent->x2) full.x2 = pExtent->x2; if (full.y2 > pExtent->y2) full.y2 = pExtent->y2; - + if (full.x1 >= full.x2 || full.y1 >= full.y2) continue; - + nClip = REGION_NUM_RECTS (pClip); if (nClip == 1) { @@ -503,7 +485,7 @@ xglFillLine (DrawablePtr pDrawable, part.x2 = full.x2; if (part.y2 > full.y2) part.y2 = full.y2; - + if (part.x1 < part.x2 && part.y1 < part.y2) ADD_BOX (pBox, nBox, stackBox, heapBox, size, part); } @@ -514,7 +496,7 @@ xglFillLine (DrawablePtr pDrawable, pExtent->x1, pExtent->y1, pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1, (heapBox) ? heapBox : stackBox, nBox); - + if (heapBox) xfree (heapBox); @@ -526,9 +508,9 @@ xglFillLine (DrawablePtr pDrawable, if (coincidentEndpoints) npt--; - + pGeometry = xglGetScratchVertexGeometry (pGC->pScreen, npt); - + GEOMETRY_ADD_LINE (pGC->pScreen, pGeometry, coincidentEndpoints, mode, npt, ppt); @@ -539,24 +521,27 @@ xglFillLine (DrawablePtr pDrawable, /* Lines need a 0.5 translate */ GEOMETRY_TRANSLATE_FIXED (pGeometry, 1 << 15, 1 << 15); - + GEOMETRY_TRANSLATE (pGeometry, pDrawable->x, pDrawable->y); pExtent = REGION_EXTENTS (pDrawable->pScreen, pGC->pCompositeClip); - + if (xglFill (pDrawable, pGC, pGeometry, pExtent->x1, pExtent->y1, pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1, REGION_RECTS (pGC->pCompositeClip), REGION_NUM_RECTS (pGC->pCompositeClip))) + { + xglAddCurrentBitDamage (pDrawable); return TRUE; - + } + return FALSE; } Bool xglFillSegment (DrawablePtr pDrawable, - GCPtr pGC, + GCPtr pGC, int nSegInit, xSegment *pSegInit) { @@ -632,19 +617,19 @@ xglFillSegment (DrawablePtr pDrawable, } pSegInit++; - + if (full.x1 < pExtent->x1) full.x1 = pExtent->x1; if (full.y1 < pExtent->y1) - full.y1 = pExtent->y1; + full.y1 = pExtent->y1; if (full.x2 > pExtent->x2) full.x2 = pExtent->x2; if (full.y2 > pExtent->y2) full.y2 = pExtent->y2; - + if (full.x1 >= full.x2 || full.y1 >= full.y2) continue; - + nClip = REGION_NUM_RECTS (pClip); if (nClip == 1) { @@ -665,7 +650,7 @@ xglFillSegment (DrawablePtr pDrawable, part.x2 = full.x2; if (part.y2 > full.y2) part.y2 = full.y2; - + if (part.x1 < part.x2 && part.y1 < part.y2) ADD_BOX (pBox, nBox, stackBox, heapBox, size, part); } @@ -676,7 +661,7 @@ xglFillSegment (DrawablePtr pDrawable, pExtent->x1, pExtent->y1, pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1, (heapBox) ? heapBox : stackBox, nBox); - + if (heapBox) xfree (heapBox); @@ -685,24 +670,27 @@ xglFillSegment (DrawablePtr pDrawable, if (!pScreenPriv->lines) return FALSE; - + pGeometry = xglGetScratchVertexGeometry (pGC->pScreen, 2 * nSegInit); - + GEOMETRY_ADD_SEGMENT (pGC->pScreen, pGeometry, nSegInit, pSegInit); /* Line segments need 0.5 translate */ GEOMETRY_TRANSLATE_FIXED (pGeometry, 1 << 15, 1 << 15); GEOMETRY_SET_VERTEX_PRIMITIVE (pGeometry, GLITZ_PRIMITIVE_LINES); - + GEOMETRY_TRANSLATE (pGeometry, pDrawable->x, pDrawable->y); - + if (xglFill (pDrawable, pGC, pGeometry, pExtent->x1, pExtent->y1, pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1, REGION_RECTS (pGC->pCompositeClip), REGION_NUM_RECTS (pGC->pCompositeClip))) + { + xglAddCurrentBitDamage (pDrawable); return TRUE; - + } + return FALSE; } @@ -745,9 +733,10 @@ xglFillGlyph (DrawablePtr pDrawable, REGION_NUM_RECTS (pGC->pCompositeClip))) { GEOMETRY_UNINIT (&geometry); + xglAddCurrentBitDamage (pDrawable); return TRUE; } - + GEOMETRY_UNINIT (&geometry); return FALSE; } diff --git a/hw/xgl/xglgc.c b/hw/xgl/xglgc.c index 5a85ead69..deb3982a5 100644 --- a/hw/xgl/xglgc.c +++ b/hw/xgl/xglgc.c @@ -1,6 +1,6 @@ /* * Copyright © 2004 David Reveman - * + * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without * fee, provided that the above copyright notice appear in all copies @@ -12,11 +12,11 @@ * software for any purpose. It is provided "as is" without express or * implied warranty. * - * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * 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. * @@ -58,7 +58,7 @@ static const GCFuncs xglGCFuncs = { xglValidateGC, miChangeGC, miCopyGC, - miDestroyGC, + xglDestroyGC, miChangeClip, miDestroyClip, miCopyClip @@ -123,7 +123,7 @@ xglSetSpans (DrawablePtr pDrawable, int fSorted) { XGL_GC_PRIV (pGC); - + XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable); (*pGC->ops->SetSpans) (pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted); XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable); @@ -163,7 +163,7 @@ xglPutImage (DrawablePtr pDrawable, XGL_GC_UNWRAP (funcs); XGL_GC_UNWRAP (ops); - + (*pGC->ops->PutImage) (pDrawable, pGC, depth, x, y, w, h, leftPad, format, bits); @@ -174,7 +174,7 @@ xglPutImage (DrawablePtr pDrawable, box.y1 = pDrawable->y + y; box.x2 = box.x1 + w; box.y2 = box.y1 + h; - + REGION_INIT (pDrawable->pScreen, ®ion, &box, 1); REGION_INTERSECT (pDrawable->pScreen, ®ion, pClip, ®ion); @@ -197,7 +197,7 @@ xglCopyArea (DrawablePtr pSrc, { RegionPtr pRegion; BoxRec box; - + XGL_GC_PRIV (pGC); box.x1 = pSrc->x + srcX; @@ -205,11 +205,11 @@ 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); - + XGL_GC_OP_FALLBACK_PROLOGUE (pDst); pRegion = (*pGC->ops->CopyArea) (pSrc, pDst, pGC, srcX, srcY, w, h, dstX, dstY); @@ -243,14 +243,14 @@ xglCopyPlane (DrawablePtr pSrc, { RegionPtr pRegion; BoxRec box; - + XGL_GC_PRIV (pGC); box.x1 = pSrc->x + srcX; box.y1 = pSrc->y + srcY; box.x2 = box.x1 + w; box.y2 = box.y1 + h; - + if (!xglSyncBits (pSrc, &box)) FatalError (XGL_SW_FAILURE_STRING); @@ -293,13 +293,10 @@ 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); XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable); @@ -315,7 +312,7 @@ xglPolylines (DrawablePtr pDrawable, void xglPolySegment (DrawablePtr pDrawable, - GCPtr pGC, + GCPtr pGC, int nsegInit, xSegment *pSegInit) { @@ -328,10 +325,7 @@ xglPolySegment (DrawablePtr pDrawable, if (pGC->lineStyle == LineSolid) { if (xglFillSegment (pDrawable, pGC, nsegInit, pSegInit)) - { - xglAddCurrentBitDamage (pDrawable); return; - } } } @@ -344,14 +338,14 @@ xglPolySegment (DrawablePtr pDrawable, void xglPolyArc (DrawablePtr pDrawable, - GCPtr pGC, + GCPtr pGC, int narcs, xArc *pArcs) { if (pGC->lineWidth == 0) { XGL_GC_PRIV (pGC); - + XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable); (*pGC->ops->PolyArc) (pDrawable, pGC, narcs, pArcs); XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable); @@ -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); @@ -382,12 +376,12 @@ xglPolyFillRect (DrawablePtr pDrawable, void xglPolyFillArc (DrawablePtr pDrawable, - GCPtr pGC, + GCPtr pGC, int narcs, xArc *pArcs) { XGL_GC_PRIV (pGC); - + XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable); (*pGC->ops->PolyFillArc) (pDrawable, pGC, narcs, pArcs); XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable); @@ -404,7 +398,7 @@ xglImageGlyphBlt (DrawablePtr pDrawable, { XGL_GC_PRIV (pGC); - if (!(pGCPriv->flags & ~xglGCBadFunctionFlag)) + if (!pGCPriv->flags) { if (xglSolidGlyph (pDrawable, pGC, @@ -413,10 +407,7 @@ xglImageGlyphBlt (DrawablePtr pDrawable, nglyph, ppci, pglyphBase)) - { - xglAddCurrentBitDamage (pDrawable); return; - } } XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable); @@ -445,12 +436,9 @@ 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); XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable); @@ -469,7 +457,7 @@ xglPushPixels (GCPtr pGC, if (!xglSyncBits (&pBitmap->drawable, NullBox)) FatalError (XGL_SW_FAILURE_STRING); - + XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable); (*pGC->ops->PushPixels) (pGC, pBitmap, pDrawable, w, h, x, y); XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable); @@ -478,10 +466,9 @@ xglPushPixels (GCPtr pGC, Bool xglCreateGC (GCPtr pGC) { - static glitz_color_t black = { 0x0, 0x0, 0x0, 0xffff }; - ScreenPtr pScreen = pGC->pScreen; - Bool ret; - + ScreenPtr pScreen = pGC->pScreen; + Bool ret; + XGL_SCREEN_PRIV (pScreen); XGL_GC_PRIV (pGC); @@ -491,16 +478,36 @@ xglCreateGC (GCPtr pGC) XGL_GC_WRAP (funcs, (GCFuncs *) &xglGCFuncs); XGL_GC_WRAP (ops, (GCOps *) &xglGCOps); - + 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, DrawablePtr pDrawable) @@ -509,12 +516,12 @@ xglValidateGC (GCPtr pGC, if (changes & GCTile) { - if (!pGC->tileIsPixel && + if (!pGC->tileIsPixel && FbEvenTile (pGC->tile.pixmap->drawable.width * pDrawable->bitsPerPixel)) xglSyncBits (&pGC->tile.pixmap->drawable, NULL); } - + if (changes & GCStipple) { if (pGC->stipple) @@ -530,16 +537,45 @@ xglValidateGC (GCPtr pGC, if (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS)) { XGL_DRAWABLE_PIXMAP_PRIV (pDrawable); - - if (pPixmapPriv->format) - pGCPriv->flags &= ~xglGCSoftwareDrawableFlag; - else - pGCPriv->flags |= xglGCSoftwareDrawableFlag; - if (pPixmapPriv->target) - pGCPriv->flags &= ~xglGCReadOnlyDrawableFlag; + if (pPixmapPriv->pVisual && pPixmapPriv->pVisual->format.surface) + { + glitz_format_t *format; + + format = pPixmapPriv->pVisual->format.surface; + if (format->id != pGCPriv->id) + { + XGL_SCREEN_PRIV (pDrawable->pScreen); + + pGCPriv->flags |= xglGCSoftwareDrawableFlag; + + if (pGCPriv->fg) + glitz_surface_destroy (pGCPriv->fg); + + pGCPriv->fg = glitz_surface_create (pScreenPriv->drawable, + format, 1, 1, 0, NULL); + if (pGCPriv->fg) + glitz_surface_set_fill (pGCPriv->fg, GLITZ_FILL_REPEAT); + + if (pGCPriv->bg) + glitz_surface_destroy (pGCPriv->bg); + + pGCPriv->bg = glitz_surface_create (pScreenPriv->drawable, + format, 1, 1, 0, NULL); + if (pGCPriv->bg) + glitz_surface_set_fill (pGCPriv->bg, GLITZ_FILL_REPEAT); + + pGCPriv->id = format->id; + + if (pGCPriv->fg && pGCPriv->bg) + { + changes |= (GCForeground | GCBackground); + pGCPriv->flags &= ~xglGCSoftwareDrawableFlag; + } + } + } else - pGCPriv->flags |= xglGCReadOnlyDrawableFlag; + pGCPriv->flags |= xglGCSoftwareDrawableFlag; } if (changes & GCFunction) @@ -568,21 +604,45 @@ xglValidateGC (GCPtr pGC, FbBits mask; mask = FbFullMask (pDrawable->depth); - + if ((pGC->planemask & mask) != mask) pGCPriv->flags |= xglGCPlaneMaskFlag; else pGCPriv->flags &= ~xglGCPlaneMaskFlag; } - if (changes & (GCForeground | GCBackground)) + if (!(pGCPriv->flags & xglGCSoftwareDrawableFlag)) { - XGL_DRAWABLE_PIXMAP_PRIV (pDrawable); - - if (pPixmapPriv->pPixel) + if (changes & (GCForeground | GCBackground)) { - xglPixelToColor (pPixmapPriv->pPixel, pGC->fgPixel, &pGCPriv->fg); - xglPixelToColor (pPixmapPriv->pPixel, pGC->bgPixel, &pGCPriv->bg); + glitz_pixel_format_t format; + glitz_buffer_t *buffer; + CARD32 pixel; + + XGL_DRAWABLE_PIXMAP_PRIV (pDrawable); + + format.fourcc = GLITZ_FOURCC_RGB; + format.masks = pPixmapPriv->pVisual->pPixel->masks; + format.xoffset = 0; + format.skip_lines = 0; + format.bytes_per_line = sizeof (CARD32); + format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP; + + buffer = glitz_buffer_create_for_data (&pixel); + + if (changes & GCForeground) + { + pixel = pGC->fgPixel; + glitz_set_pixels (pGCPriv->fg, 0, 0, 1, 1, &format, buffer); + } + + if (changes & GCBackground) + { + pixel = pGC->bgPixel; + glitz_set_pixels (pGCPriv->bg, 0, 0, 1, 1, &format, buffer); + } + + glitz_buffer_destroy (buffer); } } } diff --git a/hw/xgl/xglgeometry.c b/hw/xgl/xglgeometry.c index 410c377de..7ab1ba45c 100644 --- a/hw/xgl/xglgeometry.c +++ b/hw/xgl/xglgeometry.c @@ -1,6 +1,6 @@ /* * Copyright © 2004 David Reveman - * + * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without * fee, provided that the above copyright notice appear in all copies @@ -12,11 +12,11 @@ * software for any purpose. It is provided "as is" without express or * implied warranty. * - * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * 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. * @@ -44,7 +44,7 @@ xglGeometryResize (ScreenPtr pScreen, int size) { XGL_SCREEN_PRIV (pScreen); - + if (size == pGeometry->size) return; @@ -54,12 +54,12 @@ xglGeometryResize (ScreenPtr pScreen, if (pGeometry->usage == GEOMETRY_USAGE_SYSMEM) { pGeometry->data = xrealloc (pGeometry->data, size); - + if (pGeometry->buffer) glitz_buffer_destroy (pGeometry->buffer); - + pGeometry->buffer = NULL; - + if (pGeometry->data) { pGeometry->buffer = glitz_buffer_create_for_data (pGeometry->data); @@ -78,6 +78,7 @@ xglGeometryResize (ScreenPtr pScreen, else { glitz_buffer_t *newBuffer; + if (size) { newBuffer = @@ -90,29 +91,29 @@ xglGeometryResize (ScreenPtr pScreen, } } else newBuffer = NULL; - + if (pGeometry->buffer && newBuffer) { void *oldData, *newData; - + oldData = glitz_buffer_map (pGeometry->buffer, GLITZ_BUFFER_ACCESS_READ_ONLY); newData = glitz_buffer_map (newBuffer, GLITZ_BUFFER_ACCESS_WRITE_ONLY); - + if (oldData && newData) memcpy (newData, oldData, MIN (size, pGeometry->size)); - + glitz_buffer_unmap (pGeometry->buffer); glitz_buffer_unmap (newBuffer); - + glitz_buffer_destroy (pGeometry->buffer); } pGeometry->buffer = newBuffer; } - + pGeometry->size = size; - + if (pGeometry->endOffset > size) pGeometry->endOffset = size; } @@ -149,7 +150,7 @@ xglGeometryResize (ScreenPtr pScreen, (pGeometry)->count = (pGeometry)->endOffset / \ (2 * xglGeometryDataTypes[(pGeometry)->dataType].size); \ } - + /* * Adds a number of boxes as GL_QUAD primitives */ @@ -167,7 +168,7 @@ xglGeometryAddBox (ScreenPtr pScreen, return; MAP_GEOMETRY (pScreen, pGeometry, offset, nBox * 8, ptr, size); - + switch (pGeometry->dataType) { case GEOMETRY_DATA_TYPE_SHORT: { @@ -190,7 +191,7 @@ xglGeometryAddBox (ScreenPtr pScreen, case GEOMETRY_DATA_TYPE_FLOAT: { glitz_float_t *data = (glitz_float_t *) ptr; - + while (nBox--) { *data++ = (glitz_float_t) pBox->x1; @@ -228,7 +229,7 @@ xglGeometryAddSpan (ScreenPtr pScreen, return; MAP_GEOMETRY (pScreen, pGeometry, offset, n * 4, ptr, size); - + switch (pGeometry->dataType) { case GEOMETRY_DATA_TYPE_SHORT: { @@ -240,7 +241,7 @@ xglGeometryAddSpan (ScreenPtr pScreen, *data++ = (glitz_short_t) ppt->y; *data++ = (glitz_short_t) (ppt->x + *pwidth); *data++ = (glitz_short_t) ppt->y; - + ppt++; pwidth++; } @@ -255,13 +256,13 @@ xglGeometryAddSpan (ScreenPtr pScreen, *data++ = (glitz_float_t) ppt->y; *data++ = (glitz_float_t) (ppt->x + *pwidth); *data++ = (glitz_float_t) ppt->y; - + ppt++; pwidth++; } } break; } - + UNMAP_GEOMETRY (pGeometry, offset, size); } @@ -298,7 +299,7 @@ xglGeometryAddLine (ScreenPtr pScreen, pt.x = 0; pt.y = 0; - + switch (pGeometry->dataType) { case GEOMETRY_DATA_TYPE_SHORT: { @@ -329,7 +330,7 @@ xglGeometryAddLine (ScreenPtr pScreen, ADJUST_END_POINT (ppt->x, pt.x, ppt->y == pt.y); *data++ = (glitz_short_t) ADJUST_END_POINT (ppt->y, pt.y, 0); } - + ppt++; } } break; @@ -362,7 +363,7 @@ xglGeometryAddLine (ScreenPtr pScreen, ADJUST_END_POINT (ppt->x, pt.x, ppt->y == pt.y); *data++ = (glitz_float_t) ADJUST_END_POINT (ppt->y, pt.y, 0); } - + ppt++; } } break; @@ -403,7 +404,7 @@ xglGeometryAddSegment (ScreenPtr pScreen, pSegInit->y1 == pSegInit->y2); *data++ = (glitz_short_t) ADJUST_END_POINT (pSegInit->y1, pSegInit->y2, 0); - + pSegInit++; } } break; @@ -420,12 +421,12 @@ xglGeometryAddSegment (ScreenPtr pScreen, pSegInit->y1 == pSegInit->y2); *data++ = (glitz_float_t) ADJUST_END_POINT (pSegInit->y1, pSegInit->y2, 0); - + pSegInit++; } } break; } - + UNMAP_GEOMETRY (pGeometry, offset, size); } @@ -449,7 +450,7 @@ xglGeometryForGlyph (ScreenPtr pScreen, ppci = ppciInit; n = nGlyph; - + while (n--) { pglyph = FONTGLYPHBITS (pglyphBase, *ppci++); @@ -482,7 +483,7 @@ xglGeometryForGlyph (ScreenPtr pScreen, pglyph = FONTGLYPHBITS (pglyphBase, pci); gWidth = GLYPHWIDTHPIXELS (pci); gHeight = GLYPHHEIGHTPIXELS (pci); - + if (gWidth && gHeight) { gx = x + pci->metrics.leftSideBearing; @@ -513,8 +514,8 @@ xglGeometryForGlyph (ScreenPtr pScreen, (((glitz_float_t) \ ((line).p1.x + (xFixed_16_16) \ (((((line).p2.y - (line).p1.y) - 1) + \ - ((xFixed_32_32) ((v) - (line).p1.y) * \ - ((line).p2.x - (line).p1.x))) / \ + ((xFixed_32_32) ((v) - (line).p1.y) * \ + ((line).p2.x - (line).p1.x))) / \ ((line).p2.y - (line).p1.y)))) / 65536) /* @@ -549,7 +550,7 @@ xglGeometryAddTrapezoid (ScreenPtr pScreen, { top = FIXED_TO_FLOAT (pTrap->top); bottom = FIXED_TO_FLOAT (pTrap->bottom); - + *data++ = FIXED_LINE_X_TO_FLOAT (pTrap->left, pTrap->top); *data++ = top; *data++ = FIXED_LINE_X_CEIL_TO_FLOAT (pTrap->right, pTrap->top); @@ -599,7 +600,7 @@ xglGeometryAddTrap (ScreenPtr pScreen, { top = FIXED_TO_FLOAT (pTrap->top.y); bottom = FIXED_TO_FLOAT (pTrap->bot.y); - + *data++ = FIXED_TO_FLOAT (pTrap->top.l); *data++ = top; *data++ = FIXED_TO_FLOAT (pTrap->top.r); @@ -626,9 +627,9 @@ xglGetScratchGeometryWithSize (ScreenPtr pScreen, xglGeometryPtr pGeometry; XGL_SCREEN_PRIV (pScreen); - + pGeometry = &pScreenPriv->scratchGeometry; - + if (pGeometry->broken || pGeometry->size < size) { GEOMETRY_UNINIT (pGeometry); @@ -649,7 +650,7 @@ xglGetScratchGeometryWithSize (ScreenPtr pScreen, pGeometry->count = 0; pGeometry->width = 2; } - + return pGeometry; } @@ -662,17 +663,17 @@ xglGetScratchVertexGeometryWithType (ScreenPtr pScreen, int stride; stride = 2 * xglGeometryDataTypes[type].size; - + pGeometry = xglGetScratchGeometryWithSize (pScreen, count * stride); pGeometry->type = GLITZ_GEOMETRY_TYPE_VERTEX; pGeometry->dataType = type; - + pGeometry->f.vertex.primitive = GLITZ_PRIMITIVE_QUADS; pGeometry->f.vertex.type = xglGeometryDataTypes[type].type; pGeometry->f.vertex.bytes_per_vertex = stride; pGeometry->f.vertex.attributes = 0; - + return pGeometry; } @@ -692,22 +693,22 @@ xglGetScratchVertexGeometry (ScreenPtr pScreen, pGeometry->type = GLITZ_GEOMETRY_TYPE_VERTEX; pGeometry->dataType = type; - + pGeometry->f.vertex.primitive = GLITZ_PRIMITIVE_QUADS; pGeometry->f.vertex.type = xglGeometryDataTypes[type].type; pGeometry->f.vertex.bytes_per_vertex = stride; pGeometry->f.vertex.attributes = 0; - + return pGeometry; } Bool -xglSetGeometry (xglGeometryPtr pGeometry, +xglSetGeometry (xglGeometryPtr pGeometry, glitz_surface_t *surface) { if (pGeometry->broken) return FALSE; - + glitz_set_geometry (surface, pGeometry->type, &pGeometry->f, pGeometry->buffer); @@ -718,6 +719,6 @@ xglSetGeometry (xglGeometryPtr pGeometry, glitz_set_array (surface, pGeometry->first, pGeometry->width, pGeometry->count, pGeometry->xOff, pGeometry->yOff); - + return TRUE; } diff --git a/hw/xgl/xglget.c b/hw/xgl/xglget.c index a88e0fe2c..87bcb0508 100644 --- a/hw/xgl/xglget.c +++ b/hw/xgl/xglget.c @@ -1,6 +1,6 @@ /* * Copyright © 2004 David Reveman - * + * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without * fee, provided that the above copyright notice appear in all copies @@ -12,11 +12,11 @@ * software for any purpose. It is provided "as is" without express or * implied warranty. * - * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * 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. * @@ -39,10 +39,10 @@ xglGetImage (DrawablePtr pDrawable, glitz_surface_t *surface; int xOff, yOff; BoxRec box; - + 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)) @@ -61,27 +61,27 @@ xglGetImage (DrawablePtr pDrawable, if (!xglSyncBits (pDrawable, &box)) FatalError (XGL_SW_FAILURE_STRING); - + XGL_SCREEN_UNWRAP (GetImage); (*pScreen->GetImage) (pDrawable, x, y, w, h, format, planeMask, d); XGL_SCREEN_WRAP (GetImage, xglGetImage); } void -xglGetSpans (DrawablePtr pDrawable, - int wMax, - DDXPointPtr ppt, - int *pwidth, - int nspans, +xglGetSpans (DrawablePtr pDrawable, + int wMax, + DDXPointPtr ppt, + int *pwidth, + int nspans, char *pchardstStart) { ScreenPtr pScreen = pDrawable->pScreen; - + XGL_SCREEN_PRIV (pScreen); if (!xglSyncBits (pDrawable, NullBox)) FatalError (XGL_SW_FAILURE_STRING); - + XGL_SCREEN_UNWRAP (GetSpans); (*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pchardstStart); XGL_SCREEN_WRAP (GetSpans, xglGetSpans); diff --git a/hw/xgl/xglglx.c b/hw/xgl/xglglx.c index 99ff72d5c..d92f9659e 100644 --- a/hw/xgl/xglglx.c +++ b/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" - -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 (*setRenderTables) (__glProcTable *table, - __glProcTableEXT *tableEXT); -} xglGLXFuncRec; - -static xglGLXFuncRec __glXFunc; +#ifdef XGL_MODULAR +#include <dlfcn.h> +#endif + +xglGLXFuncRec __xglGLXFunc; + +#ifndef NGLXEXTLOG +FILE *__xglGLXLogFp; +#endif static void *glXHandle = 0; static void *glCoreHandle = 0; #define SYM(ptr, name) { (void **) &(ptr), (name) } -__GLXextensionInfo __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,9 +80,9 @@ GlxInitVisuals (VisualPtr *visualp, int preferredVis) { if (glXHandle && glCoreHandle) - return (*__glXFunc.initVisuals) (visualp, depthp, nvisualp, ndepthp, - rootDepthp, defaultVisp, sizes, - bitsPerRGB, preferredVis); + return (*__xglGLXFunc.initVisuals) (visualp, depthp, nvisualp, ndepthp, + rootDepthp, defaultVisp, sizes, + bitsPerRGB, preferredVis); return 0; } @@ -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) +{ + (*__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 ) { - (*__glXFunc.setRenderTables) (table, tableEXT); + 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,27 +179,48 @@ 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; + + 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)) diff --git a/hw/xgl/xglglx.h b/hw/xgl/xglglx.h new file mode 100644 index 000000000..d895f4262 --- /dev/null +++ b/hw/xgl/xglglx.h @@ -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 diff --git a/hw/xgl/xglglyph.c b/hw/xgl/xglglyph.c index 477a13fb1..7a601889c 100644 --- a/hw/xgl/xglglyph.c +++ b/hw/xgl/xglglyph.c @@ -1,6 +1,6 @@ /* * 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 @@ -12,11 +12,11 @@ * software for any purpose. It is provided "as is" without express or * implied warranty. * - * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * 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, + * 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. * @@ -163,9 +163,9 @@ xglRealizeGlyph (ScreenPtr pScreen, XGL_PICTURE_SCREEN_UNWRAP (RealizeGlyph); ret = (*pPictureScreen->RealizeGlyph) (pScreen, pGlyph); XGL_PICTURE_SCREEN_WRAP (RealizeGlyph, xglRealizeGlyph); - + pGlyphPriv->pArea = NULL; - + return ret; } @@ -205,7 +205,7 @@ xglInitGlyphCache (xglGlyphCachePtr pCache, if (pCache->depth == 1) { int stride; - + GEOMETRY_INIT (pScreen, &pCache->u.geometry, GLITZ_GEOMETRY_TYPE_VERTEX, GEOMETRY_USAGE_STATIC, BITMAP_CACHE_SIZE); @@ -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,39 +245,46 @@ 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; - - if (!pTexture->mask) + mask = glitz_surface_create (pScreenPriv->drawable, + pVisual->format.surface, + TEXTURE_CACHE_SIZE, + TEXTURE_CACHE_SIZE, + GLITZ_SURFACE_UNNORMALIZED_MASK, + &attr); + } + else + mask = NULL; + + if (!mask) { - pTexture->mask = - glitz_surface_create (pScreenPriv->drawable, pFormat->format, - TEXTURE_CACHE_SIZE, TEXTURE_CACHE_SIZE, - 0, NULL); - if (!pTexture->mask) + mask = glitz_surface_create (pScreenPriv->drawable, + pVisual->format.surface, + TEXTURE_CACHE_SIZE, + TEXTURE_CACHE_SIZE, + 0, NULL); + 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; vertex->mask.size = GLITZ_COORDINATE_SIZE_XY; vertex->attributes = GLITZ_VERTEX_ATTRIBUTE_MASK_COORD_MASK; - + if (pTexture->geometryDataType == GEOMETRY_DATA_TYPE_FLOAT) { vertex->type = GLITZ_DATA_TYPE_FLOAT; @@ -288,13 +300,14 @@ 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; pTexture->pixel.skip_lines = 0; } - + pCache->pScreen = pScreen; return TRUE; @@ -306,17 +319,17 @@ xglFiniGlyphCache (xglGlyphCachePtr pCache) if (pCache->pScreen) { xglRootAreaFini (&pCache->rootArea); - + if (pCache->depth == 1) { GEOMETRY_UNINIT (&pCache->u.geometry); } 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; } } @@ -326,24 +339,24 @@ xglCacheGlyph (xglGlyphCachePtr pCache, GlyphPtr pGlyph) { ScreenPtr pScreen = pCache->pScreen; - + XGL_GLYPH_PRIV (pScreen, pGlyph); - + if (pCache->depth == 1) { PixmapPtr pPixmap; RegionPtr pRegion; int nBox; - + pPixmap = GetScratchPixmapHeader (pScreen, pGlyph->info.width, - pGlyph->info.height, + pGlyph->info.height, pCache->depth, pCache->depth, 0, (pointer) (pGlyph + 1)); if (!pPixmap) return NULL; - - (*pScreen->ModifyPixmapHeader) (pPixmap, + + (*pScreen->ModifyPixmapHeader) (pPixmap, pGlyph->info.width, pGlyph->info.height, 0, 0, -1, (pointer) (pGlyph + 1)); @@ -366,7 +379,7 @@ xglCacheGlyph (xglGlyphCachePtr pCache, /* Find available area */ if (!xglFindArea (pCache->rootArea.pArea, nBox, 0, FALSE, (pointer) pGlyph)) - { + { /* Kicking out area with lower score */ xglFindArea (pCache->rootArea.pArea, nBox, 0, TRUE, (pointer) pGlyph); @@ -375,7 +388,7 @@ xglCacheGlyph (xglGlyphCachePtr pCache, if (pGlyphPriv->pArea) { int stride; - + GLYPH_AREA_PRIV (pGlyphPriv->pArea); pAreaPriv->serial = glyphSerialNumber; @@ -388,7 +401,7 @@ xglCacheGlyph (xglGlyphCachePtr pCache, } } else pGlyphPriv->pArea = &zeroSizeArea; - + REGION_DESTROY (pScreen, pRegion); } else @@ -398,11 +411,11 @@ xglCacheGlyph (xglGlyphCachePtr pCache, if (pGlyph->info.width > TEXTURE_CACHE_MAX_WIDTH || pGlyph->info.height > TEXTURE_CACHE_MAX_HEIGHT) return NULL; - + if (pGlyph->info.width > 0 && pGlyph->info.height > 0) { glitz_buffer_t *buffer; - + buffer = glitz_buffer_create_for_data (pGlyph + 1); if (!buffer) return NULL; @@ -417,19 +430,22 @@ xglCacheGlyph (xglGlyphCachePtr pCache, pGlyph->info.width, pGlyph->info.height, TRUE, (pointer) pGlyph); } - + if (pGlyphPriv->pArea) { + glitz_surface_t *surface; glitz_point_fixed_t p1, p2; glitz_pixel_format_t pixel; - + GLYPH_AREA_PRIV (pGlyphPriv->pArea); pixel = pTexture->pixel; 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, @@ -441,10 +457,10 @@ xglCacheGlyph (xglGlyphCachePtr pCache, p1.y = pGlyphPriv->pArea->y << 16; 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) { @@ -465,7 +481,7 @@ xglCacheGlyph (xglGlyphCachePtr pCache, } else pGlyphPriv->pArea = &zeroSizeArea; } - + return pGlyphPriv->pArea; } @@ -499,7 +515,7 @@ xglUncachedGlyphs (CARD8 op, usingCache = FALSE; } } - + while (pOp->nGlyphs) { glyph = *pOp->ppGlyphs; @@ -511,7 +527,7 @@ xglUncachedGlyphs (CARD8 op, pOp->xOff += pOp->pLists->xOff; pOp->yOff += pOp->pLists->yOff; } - + xOff = pOp->xOff; yOff = pOp->yOff; @@ -523,7 +539,7 @@ xglUncachedGlyphs (CARD8 op, { if (!pArea) pArea = xglCacheGlyph (pCache, glyph); - + if (pArea) break; } @@ -533,26 +549,26 @@ xglUncachedGlyphs (CARD8 op, pOp->listLen--; pOp->nGlyphs--; pOp->ppGlyphs++; - + pOp->xOff += glyph->info.xOff; pOp->yOff += glyph->info.yOff; if (pArea) continue; - + if (!pPicture) { - CARD32 componentAlpha; - int error; - + XID componentAlpha; + int error; + pPixmap = GetScratchPixmapHeader (pScreen, glyph->info.width, - glyph->info.height, + glyph->info.height, depth, depth, 0, (pointer) (glyph + 1)); if (!pPixmap) return; - + componentAlpha = NEEDS_COMPONENT (pOp->pLists->format->format); pPicture = CreatePicture (0, &pPixmap->drawable, pOp->pLists->format, @@ -564,8 +580,8 @@ xglUncachedGlyphs (CARD8 op, return; } } - - (*pScreen->ModifyPixmapHeader) (pPixmap, + + (*pScreen->ModifyPixmapHeader) (pPixmap, glyph->info.width, glyph->info.height, 0, 0, -1, (pointer) (glyph + 1)); pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER; @@ -594,7 +610,7 @@ xglUncachedGlyphs (CARD8 op, glyph->info.width, glyph->info.height); } - + if (pPicture) { FreeScratchPixmapHeader (pPixmap); @@ -624,10 +640,10 @@ 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); - + pCache = &pScreenPriv->glyphCache[depth]; if (!pCache->pScreen) { @@ -663,23 +679,23 @@ xglCachedGlyphs (CARD8 op, else if (pSrc) break; } - + if (nGlyph) { if (depth == 1) { glitz_multi_array_t *multiArray; - + pGeometry = &pCache->u.geometry; pGeometry->xOff = pGeometry->yOff = 0; - + multiArray = glitz_multi_array_create (nGlyph); if (!multiArray) return 1; - + GEOMETRY_SET_MULTI_ARRAY (pGeometry, multiArray); glitz_multi_array_destroy (multiArray); - + vData.array.lastX = 0; vData.array.lastY = 0; } @@ -687,11 +703,11 @@ xglCachedGlyphs (CARD8 op, { i = 4 * pCache->u.texture.format.vertex.bytes_per_vertex * nGlyph; pGeometry = xglGetScratchGeometryWithSize (pScreen, i); - + 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); } @@ -714,7 +730,7 @@ xglCachedGlyphs (CARD8 op, pOp->xOff += pOp->pLists->xOff; pOp->yOff += pOp->pLists->yOff; } - + xOff = pOp->xOff; yOff = pOp->yOff; @@ -726,7 +742,7 @@ xglCachedGlyphs (CARD8 op, pOp->listLen--; pOp->nGlyphs--; pOp->ppGlyphs++; - + pOp->xOff += glyph->info.xOff; pOp->yOff += glyph->info.yOff; @@ -739,7 +755,7 @@ xglCachedGlyphs (CARD8 op, extents.x1 = x1; if (x2 > extents.x2) extents.x2 = x2; - + y1 = yOff - glyph->info.y; y2 = y1 + glyph->info.height; if (y1 < extents.y1) @@ -786,7 +802,7 @@ xglCachedGlyphs (CARD8 op, glitz_buffer_unmap (pGeometry->buffer); pGeometry->count = nGlyph * 4; } - + xSrc += extents.x1; ySrc += extents.y1; @@ -794,27 +810,26 @@ xglCachedGlyphs (CARD8 op, { op = PictOpAdd; pSrc = pScreenPriv->pSolidAlpha; - + if (remaining) - *pOp = opSave; + *pOp = opSave; } GEOMETRY_TRANSLATE (pGeometry, pDst->pDrawable->x, pDst->pDrawable->y); - - if (xglComp (op, - pSrc, - NULL, - pDst, - xSrc, ySrc, - 0, 0, - pDst->pDrawable->x + extents.x1, - pDst->pDrawable->y + extents.y1, - extents.x2 - extents.x1, - extents.y2 - extents.y1, - pGeometry, - mask)) + + if (xglCompositeGeneral (op, + pSrc, + 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)) { xglAddCurrentBitDamage (pDst->pDrawable); return remaining; @@ -857,7 +872,7 @@ xglGlyphExtents (PicturePtr pDst, extents->x1 = MAXSHORT; extents->x2 = MINSHORT; extents->y1 = MAXSHORT; - extents->y2 = MINSHORT; + extents->y2 = MINSHORT; while (!list->len) { @@ -892,7 +907,7 @@ xglGlyphExtents (PicturePtr pDst, y += list->yOff; n = list->len; list++; - + while (n--) { glyph = *glyphs++; @@ -945,7 +960,7 @@ xglGlyphExtents (PicturePtr pDst, extents->y1 = line.y1; if (line.y2 > extents->y2) extents->y2 = line.y2; - + overlap = TRUE; } @@ -959,7 +974,7 @@ xglGlyphExtents (PicturePtr pDst, line.x2 = x2; line.y2 = y2; } - + x += glyph->info.xOff; y += glyph->info.yOff; } @@ -983,15 +998,15 @@ xglGlyphExtents (PicturePtr pDst, extents->y1 = line.y1; if (line.y2 > extents->y2) extents->y2 = line.y2; - + overlap = TRUE; } - + if (line.x1 < extents->x1) extents->x1 = line.x1; if (line.x2 > extents->x2) extents->x2 = line.x2; - + xglPictureClipExtents (pDst, extents); return overlap; @@ -1006,7 +1021,7 @@ xglGlyphListFormatId (GlyphListPtr list, nlist--; list++; - + while (nlist--) { if (list->format->id != id) @@ -1037,20 +1052,18 @@ 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; - + 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; @@ -1065,7 +1078,7 @@ xglGlyphs (CARD8 op, maskFormat->depth); if (!pPixmap) return; - + componentAlpha = NEEDS_COMPONENT (maskFormat->format); pMask = CreatePicture (0, &pPixmap->drawable, maskFormat, CPComponentAlpha, &componentAlpha, @@ -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); @@ -1092,7 +1104,7 @@ xglGlyphs (CARD8 op, (*pScreen->DestroyPixmap) (pPixmap); target = xglPrepareTarget (pMask->pDrawable); - + glyphOp.xOff = -extents.x1; glyphOp.yOff = -extents.y1; pSrcPicture = NULL; @@ -1100,9 +1112,6 @@ xglGlyphs (CARD8 op, } else { - /* make sure destination drawable is locked */ - pPixmapPriv->lock++; - glyphOp.xOff = 0; glyphOp.yOff = 0; pSrcPicture = pSrc; @@ -1119,12 +1128,12 @@ xglGlyphs (CARD8 op, glyphOp.listLen = list->len; glyphOp.nGlyphs = list->len; glyphOp.pLists = list++; - + for (; nlist; nlist--, list++) { if (list->format->id != glyphOp.pLists->format->id) break; - + glyphOp.nGlyphs += list->len; } @@ -1142,26 +1151,19 @@ xglGlyphs (CARD8 op, &glyphOp); } } - + if (pMask) { - CompositePicture (op, - pSrc, - pMask, - pDst, + CompositePicture (op, pSrc, pMask, pDst, xSrc + extents.x1 - xDst, ySrc + extents.y1 - yDst, 0, 0, extents.x1, extents.y1, extents.x2 - extents.x1, extents.y2 - extents.y1); - + FreePicture ((pointer) pMask, (XID) 0); } - - /* release destination drawable lock */ - pPixmapPriv->lock--; - } #endif diff --git a/hw/xgl/xglinit.c b/hw/xgl/xglinit.c index a6fcd43c6..3d93c46cc 100644 --- a/hw/xgl/xglinit.c +++ b/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; - - for (j = 0; j < sizeof (commonOption) / sizeof (commonOption[0]); j++) + static Bool checkDDX = FALSE; + int skip; + + if (!checkDDX) { - if (commonOption[j].length) - { - if (!strncmp (argv[i], commonOption[j].name, commonOption[j].length)) - return 0; - } - else + int j; + + for (j = i; j < argc; j++) { - if (!strcmp (argv[i], commonOption[j].name)) - return 0; + if (!strcmp (argv[j], "-ddx")) + { + if (++j < argc) + ddxModuleName = argv[j]; + } + +#ifdef GLXEXT + else if (!strcmp (argv[j], "-noglx")) + { + loadGlx = FALSE; + } + +#ifndef NGLXEXTLOG + else if (!strcmp (argv[j], "-glxlog")) + { + if (++j < argc) + glxExtLogFile = argv[j]; + } +#endif + +#endif + } + checkDDX = TRUE; } if (!strcmp (argv[i], "-ddx")) { if ((i + 1) < argc) - { - ddxModuleName = argv[i + 1]; - } - else - return 1; + return 2; - 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() { } diff --git a/hw/xgl/xglinput.c b/hw/xgl/xglinput.c index 23e44093a..cda21ad49 100644 --- a/hw/xgl/xglinput.c +++ b/hw/xgl/xglinput.c @@ -1,6 +1,6 @@ /* * Copyright © 2004 David Reveman - * + * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without * fee, provided that the above copyright notice appear in all copies @@ -12,11 +12,11 @@ * software for any purpose. It is provided "as is" without express or * implied warranty. * - * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * 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. * @@ -47,7 +47,7 @@ xglMouseProc (DeviceIntPtr pDevice, case DEVICE_INIT: for (i = 1; i <= NUM_BUTTONS; i++) map[i] = i; - + InitPointerDeviceStruct (pDev, map, NUM_BUTTONS, @@ -63,7 +63,7 @@ xglMouseProc (DeviceIntPtr pDevice, pDev->on = FALSE; break; } - + return Success; } @@ -226,7 +226,7 @@ xglKeybdProc (DeviceIntPtr pDevice, case DEVICE_INIT: if (pDev != LookupKeyboardDevice ()) return !Success; - + ret = InitKeyboardDeviceStruct (pDev, &xglKeySyms, xglModMap, @@ -243,7 +243,7 @@ xglKeybdProc (DeviceIntPtr pDevice, pDev->on = FALSE; break; } - + return Success; } @@ -251,13 +251,13 @@ void xglInitInput (int argc, char **argv) { DeviceIntPtr pKeyboard, pPointer; - + pPointer = AddInputDevice (xglMouseProc, TRUE); pKeyboard = AddInputDevice (xglKeybdProc, TRUE); - + RegisterPointerDevice (pPointer); RegisterKeyboardDevice (pKeyboard); - + miRegisterPointerDevice (screenInfo.screens[0], pPointer); mieqInit (&pKeyboard->public, &pPointer->public); } diff --git a/hw/xgl/xglloader.c b/hw/xgl/xglloader.c index c06b9e225..f64acf18d 100644 --- a/hw/xgl/xglloader.c +++ b/hw/xgl/xglloader.c @@ -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]))) diff --git a/hw/xgl/xglmodule.h b/hw/xgl/xglmodule.h index 78c3e44d0..da868e960 100644 --- a/hw/xgl/xglmodule.h +++ b/hw/xgl/xglmodule.h @@ -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); diff --git a/hw/xgl/xgloutput.c b/hw/xgl/xgloutput.c index 788dafb43..7b7ffad5b 100644 --- a/hw/xgl/xgloutput.c +++ b/hw/xgl/xgloutput.c @@ -1,6 +1,6 @@ /* * Copyright © 2004 David Reveman - * + * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without * fee, provided that the above copyright notice appear in all copies @@ -12,11 +12,11 @@ * software for any purpose. It is provided "as is" without express or * implied warranty. * - * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * 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. * @@ -25,6 +25,9 @@ #include "xgl.h" +#include <mivalidate.h> +#include <dixstruct.h> + typedef struct _xglDepth { CARD8 depth; CARD8 bpp; @@ -46,20 +49,167 @@ void xglSetPixmapFormats (ScreenInfo *pScreenInfo) { int i; - + pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER; pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT; pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD; pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER; pScreenInfo->numPixmapFormats = 0; - for (i = 0; i < NUM_XGL_DEPTHS; i++) { + for (i = 0; i < NUM_XGL_DEPTHS; i++) + { PixmapFormatRec *format; format = &pScreenInfo->formats[pScreenInfo->numPixmapFormats++]; - + format->depth = xglDepths[i].depth; format->bitsPerPixel = xglDepths[i].bpp; format->scanlinePad = BITMAP_SCANLINE_PAD; } } + +void +xglSetRootClip (ScreenPtr pScreen, + Bool enable) +{ + WindowPtr pWin = WindowTable[pScreen->myNum]; + WindowPtr pChild; + Bool wasViewable; + Bool anyMarked = FALSE; + RegionPtr pOldClip = 0, 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 (); +} diff --git a/hw/xgl/xglparse.c b/hw/xgl/xglparse.c index c1f7e6527..5292692a4 100644 --- a/hw/xgl/xglparse.c +++ b/hw/xgl/xglparse.c @@ -1,6 +1,6 @@ /* * Copyright © 2004 David Reveman - * + * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without * fee, provided that the above copyright notice appear in all copies @@ -12,11 +12,11 @@ * software for any purpose. It is provided "as is" without express or * implied warranty. * - * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * 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. * @@ -33,13 +33,13 @@ xglParseFindNext (char *cur, { while (*cur && !strchr (delim, *cur)) *save++ = *cur++; - + *save = 0; *last = *cur; - + if (*cur) cur++; - + return cur; } @@ -57,28 +57,28 @@ xglParseScreen (char *arg) if (!arg) return; - + if (strlen (arg) >= sizeof (save)) return; - + for (i = 0; i < 2; i++) { - arg = xglParseFindNext (arg, "x/@XY", save, &delim); + arg = xglParseFindNext (arg, "x/", save, &delim); if (!save[0]) return; - + pixels = atoi (save); mm = 0; - + if (delim == '/') { - arg = xglParseFindNext (arg, "x@XY", save, &delim); + arg = xglParseFindNext (arg, "x", save, &delim); if (!save[0]) return; - + mm = atoi (save); } - + if (i == 0) { xglScreenInfo.width = pixels; @@ -89,12 +89,98 @@ xglParseScreen (char *arg) xglScreenInfo.height = pixels; xglScreenInfo.heightMm = mm; } - + if (delim != 'x') return; } } +static void +xglParseAccel (char *arg) +{ + xglAccelInfoPtr pAccel; + char delim; + char save[1024]; + + if (!arg) + return; + + if (strlen (arg) >= sizeof (save)) + return; + + arg = xglParseFindNext (arg, "@:", save, &delim); + if (!save[0]) + return; + + if (strcasecmp (save, "pixmap") == 0) + pAccel = &xglScreenInfo.accel.pixmap; + else if (strcasecmp (save, "window") == 0) + pAccel = &xglScreenInfo.accel.window; + else if (strcasecmp (save, "glx") == 0) + pAccel = &xglScreenInfo.accel.glx; + else if (strcasecmp (save, "xv") == 0) + pAccel = &xglScreenInfo.accel.xv; + else + return; + + if (delim == '@') + { + arg = xglParseFindNext (arg, "/x:", save, &delim); + if (!save[0]) + return; + + pAccel->size.aboveWidth = pAccel->size.minWidth = atoi (save); + + if (delim == '/') + { + arg = xglParseFindNext (arg, "x:", save, &delim); + if (!save[0]) + return; + + pAccel->size.aboveWidth = atoi (save); + } + + if (delim == 'x') + { + arg = xglParseFindNext (arg, "/:", save, &delim); + if (!save[0]) + return; + + pAccel->size.aboveHeight = pAccel->size.minHeight = atoi (save); + + if (delim == '/') + { + arg = xglParseFindNext (arg, ":", save, &delim); + if (!save[0]) + return; + + pAccel->size.aboveHeight = atoi (save); + } + } + } + + pAccel->enabled = TRUE; + pAccel->pbuffer = FALSE; + + if (delim == ':') + { + if (strcasecmp (arg, "fbo") == 0) + ; + else if (strcasecmp (arg, "off") == 0 || + strncasecmp (arg, "0", 1) == 0 || + strncasecmp (arg, "f", 1) == 0 || + strncasecmp (arg, "n", 1) == 0) + { + pAccel->enabled = FALSE; + pAccel->pbuffer = FALSE; + } + else if (strcasecmp (arg, "pbuffer") == 0) + { + pAccel->pbuffer = TRUE; + } + } +} + void xglUseMsg (void) { @@ -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 @@ -126,7 +212,7 @@ xglProcessArgument (int argc, } else return 1; - + return 2; } else if (!strcmp (argv[i], "-yinverted")) @@ -152,14 +238,20 @@ xglProcessArgument (int argc, } else return 1; - + return 2; } - else if (!strcmp (argv[i], "-fbo")) + else if (!strcmp (argv[i], "-accel")) { - xglScreenInfo.fbo = TRUE; - return 1; + if ((i + 1) < argc) + { + xglParseAccel (argv[i + 1]); + } + else + return 1; + + return 2; } - + return 0; } diff --git a/hw/xgl/xglpict.c b/hw/xgl/xglpict.c index f005de6d7..932d31a33 100644 --- a/hw/xgl/xglpict.c +++ b/hw/xgl/xglpict.c @@ -1,6 +1,6 @@ /* * Copyright © 2004 David Reveman - * + * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without * fee, provided that the above copyright notice appear in all copies @@ -12,11 +12,11 @@ * software for any purpose. It is provided "as is" without express or * implied warranty. * - * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * 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. * @@ -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,18 +57,18 @@ xglComposite (CARD8 op, XGL_SCREEN_PRIV (pScreen); - if (xglComp (op, - pSrc, pMask, pDst, - xSrc, ySrc, - xMask, yMask, - xDst + pDst->pDrawable->x, yDst + pDst->pDrawable->y, - width, height, - NULL, NULL)) + if (xglCompositeGeneral (op, + pSrc, pMask, pDst, NULL, + xSrc, ySrc, + xMask, yMask, + xDst + pDst->pDrawable->x, + yDst + pDst->pDrawable->y, + width, height)) { xglAddCurrentBitDamage (pDst->pDrawable); return; } - + pPictureScreen = GetPictureScreen (pScreen); if (pSrc->pDrawable) @@ -74,7 +76,7 @@ xglComposite (CARD8 op, if (!xglSyncBits (pSrc->pDrawable, NullBox)) FatalError (XGL_SW_FAILURE_STRING); } - + if (pMask && pMask->pDrawable) { if (!xglSyncBits (pMask->pDrawable, NullBox)) @@ -84,12 +86,12 @@ xglComposite (CARD8 op, if (op == PictOpSrc) { XGL_DRAWABLE_PIXMAP (pDst->pDrawable); - + if (!xglMapPixmapBits (pPixmap)) FatalError (XGL_SW_FAILURE_STRING); } else xglSyncDamageBoxBits (pDst->pDrawable); - + XGL_PICTURE_SCREEN_UNWRAP (Composite); (*pPictureScreen->Composite) (op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, xDst, yDst, @@ -103,16 +105,19 @@ xglComposite (CARD8 op, xDst += pDst->pDrawable->x; yDst += pDst->pDrawable->y; - xSrc += pSrc->pDrawable->x; - ySrc += pSrc->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; } - - if (!miComputeCompositeRegion (®ion, pSrc, pMask, pDst, + + if (!miComputeCompositeRegion (®ion, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, xDst, yDst, width, height)) return; @@ -130,7 +135,7 @@ xglAddTriangles (PicturePtr pDst, int ntri, xTriangle *tris) { - PictureScreenPtr pPictureScreen; + PictureScreenPtr pPictureScreen; ScreenPtr pScreen = pDst->pDrawable->pScreen; XGL_SCREEN_PRIV (pScreen); @@ -153,7 +158,7 @@ void xglChangePicture (PicturePtr pPicture, Mask mask) { - PictureScreenPtr pPictureScreen; + PictureScreenPtr pPictureScreen; ScreenPtr pScreen = pPicture->pDrawable->pScreen; XGL_SCREEN_PRIV (pScreen); @@ -179,7 +184,7 @@ int xglChangePictureTransform (PicturePtr pPicture, PictTransform *transform) { - PictureScreenPtr pPictureScreen; + PictureScreenPtr pPictureScreen; ScreenPtr pScreen = pPicture->pDrawable->pScreen; int ret; @@ -187,14 +192,17 @@ xglChangePictureTransform (PicturePtr pPicture, XGL_DRAWABLE_PIXMAP_PRIV (pPicture->pDrawable); pPictureScreen = GetPictureScreen (pScreen); - - pPixmapPriv->pictureMask |= xglPCTransformMask; + + if (transform != pPicture->transform || + (transform && memcmp (transform, &pPicture->transform, + sizeof (PictTransform)))) + pPixmapPriv->pictureMask |= xglPCTransformMask; XGL_PICTURE_SCREEN_UNWRAP (ChangePictureTransform); ret = (*pPictureScreen->ChangePictureTransform) (pPicture, transform); XGL_PICTURE_SCREEN_WRAP (ChangePictureTransform, xglChangePictureTransform); - + return ret; } @@ -204,7 +212,7 @@ xglChangePictureFilter (PicturePtr pPicture, xFixed *params, int nparams) { - PictureScreenPtr pPictureScreen; + PictureScreenPtr pPictureScreen; ScreenPtr pScreen = pPicture->pDrawable->pScreen; int ret; @@ -212,7 +220,7 @@ xglChangePictureFilter (PicturePtr pPicture, XGL_DRAWABLE_PIXMAP_PRIV (pPicture->pDrawable); pPictureScreen = GetPictureScreen (pScreen); - + pPixmapPriv->pictureMask |= xglPCFilterMask; XGL_PICTURE_SCREEN_UNWRAP (ChangePictureFilter); @@ -223,21 +231,48 @@ 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; - + XGL_DRAWABLE_PIXMAP_PRIV (pPicture->pDrawable); surface = pPixmapPriv->surface; 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) { @@ -299,7 +574,7 @@ xglVisualDepth (ScreenPtr pScreen, VisualPtr pVisual) if (pDepth->vids[v] == pVisual->vid) return pDepth->depth; } - + return 0; } @@ -319,10 +594,10 @@ xglAddFormat (xglFormatInitPtr formats, for (n = 0; n < nformat; n++) if (formats[n].format == format && formats[n].depth == depth) return nformat; - + formats[nformat].format = format; formats[nformat].depth = depth; - + return ++nformat; } @@ -342,7 +617,7 @@ xglPictureInit (ScreenPtr pScreen) int r, g, b; int d; DepthPtr pDepth; - + /* formats required by protocol */ formats[nformats].format = PICT_a1; formats[nformats].depth = 1; @@ -364,8 +639,8 @@ xglPictureInit (ScreenPtr pScreen) depth = xglVisualDepth (pScreen, pVisual); if (!depth) continue; - - bpp = BitsPerPixel (depth); + + bpp = BitsPerPixel (depth); switch (pVisual->class) { case DirectColor: case TrueColor: @@ -399,7 +674,7 @@ xglPictureInit (ScreenPtr pScreen) if (pDepth->depth == 15) nformats = xglAddFormat (formats, nformats, PICT_x1r5g5b5, pDepth->depth); - if (pDepth->depth == 16) + if (pDepth->depth == 16) nformats = xglAddFormat (formats, nformats, PICT_r5g6b5, pDepth->depth); break; @@ -416,42 +691,52 @@ 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; - + memset (pFormats, '\0', nformats * sizeof (PictFormatRec)); for (f = 0; f < nformats; f++) { - pFormats[f].id = FakeClientID (0); + pFormats[f].id = FakeClientID (0); 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) + PICT_FORMAT_G (format) + PICT_FORMAT_B (format)); - + pFormats[f].direct.redMask = Mask (PICT_FORMAT_R (format)); - pFormats[f].direct.red = (PICT_FORMAT_G (format) + + pFormats[f].direct.red = (PICT_FORMAT_G (format) + PICT_FORMAT_B (format)); - + pFormats[f].direct.greenMask = Mask (PICT_FORMAT_G (format)); pFormats[f].direct.green = PICT_FORMAT_B (format); - + pFormats[f].direct.blueMask = Mask (PICT_FORMAT_B (format)); pFormats[f].direct.blue = 0; break; case PICT_TYPE_A: + pFormats[f].type = PictTypeDirect; pFormats[f].direct.alpha = 0; pFormats[f].direct.alphaMask = Mask (PICT_FORMAT_A (format)); break; case PICT_TYPE_COLOR: case PICT_TYPE_GRAY: + pFormats[f].type = PictTypeDirect; + break; + case PICT_TYPE_YUY2: + case PICT_TYPE_YV12: + pFormats[f].type = PictTypeOther; break; } } diff --git a/hw/xgl/xglpixmap.c b/hw/xgl/xglpixmap.c index 8f043081e..368c3eaeb 100644 --- a/hw/xgl/xglpixmap.c +++ b/hw/xgl/xglpixmap.c @@ -1,6 +1,6 @@ /* * Copyright © 2004 David Reveman - * + * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without * fee, provided that the above copyright notice appear in all copies @@ -12,11 +12,11 @@ * software for any purpose. It is provided "as is" without express or * implied warranty. * - * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * 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. * @@ -69,7 +69,8 @@ xglPixmapDamageReport (DamagePtr pDamage, if (pExt->y2 > pPixmapPriv->damageBox.y2) pPixmapPriv->damageBox.y2 = pExt->y2; - } else + } + else pPixmapPriv->damageBox = *pExt; } @@ -88,34 +89,119 @@ xglPixmapCreateDamage (PixmapPtr pPixmap) return FALSE; DamageRegister (&pPixmap->drawable, pPixmapPriv->pDamage); - + return TRUE; } +void +xglSetPixmapVisual (PixmapPtr pPixmap, + xglVisualPtr pVisual) +{ + xglVisualPtr pOldVisual; + + XGL_PIXMAP_PRIV (pPixmap); + + pOldVisual = pPixmapPriv->pVisual; + if (pOldVisual && pVisual) + { + glitz_surface_t *surface; + + if (pOldVisual->vid != pVisual->vid) + { + surface = pPixmapPriv->surface; + if (surface) + { + glitz_drawable_t *drawable; + + drawable = glitz_surface_get_attached_drawable (surface); + if (drawable) + { + if (pOldVisual->format.drawable->id != + pVisual->format.drawable->id) + { + glitz_surface_detach (pPixmapPriv->surface); + pPixmapPriv->target = xglPixmapTargetOut; + } + } + + if (pOldVisual->format.surface->id != pVisual->format.surface->id) + { + xglSyncBits (&pPixmap->drawable, NULL); + glitz_surface_destroy (pPixmapPriv->surface); + pPixmapPriv->surface = 0; + } + } + } + } + else if (pOldVisual) + { + if (pPixmapPriv->surface) + { + xglSyncBits (&pPixmap->drawable, NULL); + glitz_surface_destroy (pPixmapPriv->surface); + pPixmapPriv->surface = 0; + } + pPixmapPriv->target = xglPixmapTargetNo; + } + + pPixmapPriv->pVisual = pVisual; + + if (pPixmapPriv->pVisual && pPixmapPriv->pVisual->format.surface) + { + if (!pPixmapPriv->pDamage) + { + if (!xglPixmapCreateDamage (pPixmap)) + FatalError (XGL_SW_FAILURE_STRING); + } + } +} + static Bool xglPixmapSurfaceInit (PixmapPtr pPixmap, unsigned long features, int width, int height) { + BoxRec box; + XGL_PIXMAP_PRIV (pPixmap); - + pPixmapPriv->surface = NULL; + pPixmapPriv->drawable = NULL; pPixmapPriv->acceleratedTile = FALSE; pPixmapPriv->pictureMask = ~0; pPixmapPriv->target = xglPixmapTargetNo; - pPixmapPriv->lock = 0; - if (pPixmapPriv->format) + box.x1 = 0; + box.y1 = 0; + box.x2 = width; + box.y2 = height; + + REGION_INIT (pScreen, &pPixmapPriv->bitRegion, &box, 1); + + pPixmapPriv->pVisual = xglFindVisualWithDepth (pPixmap->drawable.pScreen, + pPixmap->drawable.depth); + if (pPixmapPriv->pVisual) + { + XGL_SCREEN_PRIV (pPixmap->drawable.pScreen); + + /* general pixmap acceleration */ + if (pPixmapPriv->pVisual->format.drawable && + pScreenPriv->accel.pixmap.enabled && + xglCheckPixmapSize (pPixmap, &pScreenPriv->accel.pixmap.size)) + pPixmapPriv->target = xglPixmapTargetOut; + } + + if (pPixmapPriv->pVisual && pPixmapPriv->pVisual->format.surface) { if (!pPixmapPriv->pDamage) + { if (!xglPixmapCreateDamage (pPixmap)) FatalError (XGL_SW_FAILURE_STRING); - + } + if (width && height) { - XGL_SCREEN_PRIV (pPixmap->drawable.pScreen); - 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; } } @@ -157,7 +221,7 @@ xglPixmapSurfaceInit (PixmapPtr pPixmap, PixmapPtr xglCreatePixmap (ScreenPtr pScreen, int width, - int height, + int height, int depth) { xglPixmapPtr pPixmapPriv; @@ -180,37 +244,32 @@ xglCreatePixmap (ScreenPtr pScreen, pPixmap->drawable.y = 0; pPixmap->drawable.width = width; pPixmap->drawable.height = height; - + #ifdef COMPOSITE pPixmap->screen_x = 0; pPixmap->screen_y = 0; #endif - + pPixmap->devKind = 0; pPixmap->refcnt = 1; pPixmap->devPrivate.ptr = 0; 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)) return NullPixmap; - + pPixmapPriv->buffer = NULL; 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; } @@ -218,7 +277,7 @@ void xglFiniPixmap (PixmapPtr pPixmap) { XGL_PIXMAP_PRIV (pPixmap); - + if (pPixmap->devPrivate.ptr) { if (pPixmapPriv->buffer) @@ -230,10 +289,15 @@ xglFiniPixmap (PixmapPtr pPixmap) if (pPixmapPriv->buffer) glitz_buffer_destroy (pPixmapPriv->buffer); - + if (pPixmapPriv->bits) xfree (pPixmapPriv->bits); - + + REGION_UNINIT (pPixmap->drawable.pScreen, &pPixmapPriv->bitRegion); + + if (pPixmapPriv->drawable) + glitz_drawable_destroy (pPixmapPriv->drawable); + if (pPixmapPriv->surface) glitz_surface_destroy (pPixmapPriv->surface); } @@ -247,7 +311,7 @@ xglDestroyPixmap (PixmapPtr pPixmap) xglFiniPixmap (pPixmap); xfree (pPixmap); - + return TRUE; } @@ -260,18 +324,16 @@ xglModifyPixmapHeader (PixmapPtr pPixmap, int devKind, pointer pPixData) { - xglScreenPtr pScreenPriv; - xglPixmapPtr pPixmapPriv; - glitz_format_t *oldFormat; - int oldWidth, oldHeight; - + xglScreenPtr pScreenPriv; + xglPixmapPtr pPixmapPriv; + int oldWidth, oldHeight; + if (!pPixmap) return FALSE; pScreenPriv = XGL_GET_SCREEN_PRIV (pPixmap->drawable.pScreen); pPixmapPriv = XGL_GET_PIXMAP_PRIV (pPixmap); - oldFormat = pPixmapPriv->format; oldWidth = pPixmap->drawable.width; oldHeight = pPixmap->drawable.height; @@ -293,13 +355,13 @@ xglModifyPixmapHeader (PixmapPtr pPixmap, { if (width > 0) pPixmap->drawable.width = width; - + if (height > 0) pPixmap->drawable.height = height; - + if (depth > 0) pPixmap->drawable.depth = depth; - + if (bitsPerPixel > 0) pPixmap->drawable.bitsPerPixel = bitsPerPixel; else if ((bitsPerPixel < 0) && (depth > 0)) @@ -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) @@ -346,10 +412,10 @@ xglModifyPixmapHeader (PixmapPtr pPixmap, GEOMETRY_UNINIT (pPixmapPriv->pGeometry); pPixmapPriv->pGeometry = NULL; } - + if (pPixmapPriv->buffer) glitz_buffer_destroy (pPixmapPriv->buffer); - + if (pPixmapPriv->bits) xfree (pPixmapPriv->bits); @@ -359,36 +425,54 @@ 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) { RegionPtr pRegion; - + 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) { - glitz_surface_reference (pScreenPriv->surface); - - pPixmapPriv->surface = pScreenPriv->surface; + 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; - - pScreenPriv->pScreenPixmap = pPixmap; + + if (!pScreenPriv->pScreenPixmap) + pScreenPriv->pScreenPixmap = pPixmap; } - + return TRUE; } @@ -397,12 +481,12 @@ xglPixmapToRegion (PixmapPtr pPixmap) { ScreenPtr pScreen = pPixmap->drawable.pScreen; RegionPtr pRegion; - + XGL_SCREEN_PRIV (pScreen); - + if (!xglSyncBits (&pPixmap->drawable, NullBox)) FatalError (XGL_SW_FAILURE_STRING); - + XGL_SCREEN_UNWRAP (BitmapToRegion); pRegion = (*pScreen->BitmapToRegion) (pPixmap); XGL_SCREEN_WRAP (BitmapToRegion, xglPixmapToRegion); @@ -423,14 +507,14 @@ xglPixmapToGeometry (PixmapPtr pPixmap, if (!pPixmapPriv->pGeometry) { xglGeometryPtr pGeometry; - + if (!pPixmapPriv->buffer) { if (!xglAllocatePixmapBits (pPixmap, XGL_PIXMAP_USAGE_HINT_DEFAULT)) return NULL; } - + pGeometry = xalloc (sizeof (xglGeometryRec)); if (!pGeometry) return NULL; @@ -453,7 +537,7 @@ xglPixmapToGeometry (PixmapPtr pPixmap, pGeometry->f.bitmap.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN; } - + pGeometry->f.bitmap.pad = ((1 + FB_MASK) >> FB_SHIFT) * sizeof (FbBits); pGeometry->width = pPixmap->drawable.width; @@ -473,27 +557,28 @@ 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->target = xglPixmapTargetNo; + pPixmapPriv->pVisual = NULL; + pPixmapPriv->target = xglPixmapTargetNo; + return FALSE; } } - + return TRUE; } @@ -501,20 +586,20 @@ Bool xglAllocatePixmapBits (PixmapPtr pPixmap, int hint) { int width, height, bpp, stride; - + XGL_PIXMAP_PRIV (pPixmap); XGL_SCREEN_PRIV (pPixmap->drawable.pScreen); width = pPixmap->drawable.width; height = pPixmap->drawable.height; bpp = pPixmap->drawable.bitsPerPixel; - + stride = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof (FbBits); if (stride) { glitz_buffer_t *buffer; - + if ((pScreenPriv->pboMask & bpp) && hint) { buffer = glitz_pixel_buffer_create (pScreenPriv->drawable, @@ -544,7 +629,7 @@ xglAllocatePixmapBits (PixmapPtr pPixmap, int hint) pPixmapPriv->stride = stride; else pPixmapPriv->stride = -stride; - + return TRUE; } @@ -554,14 +639,14 @@ xglMapPixmapBits (PixmapPtr pPixmap) if (!pPixmap->devPrivate.ptr) { CARD8 *bits; - + XGL_PIXMAP_PRIV (pPixmap); - + if (!pPixmapPriv->buffer) if (!xglAllocatePixmapBits (pPixmap, XGL_PIXMAP_USAGE_HINT_DEFAULT)) return FALSE; - + bits = glitz_buffer_map (pPixmapPriv->buffer, GLITZ_BUFFER_ACCESS_READ_WRITE); if (!bits) @@ -578,7 +663,7 @@ xglMapPixmapBits (PixmapPtr pPixmap) pPixmap->devPrivate.ptr = bits; } } - + return TRUE; } @@ -589,10 +674,68 @@ xglUnmapPixmapBits (PixmapPtr pPixmap) pPixmap->devKind = 0; pPixmap->devPrivate.ptr = 0; - + if (pPixmapPriv->buffer) if (glitz_buffer_unmap (pPixmapPriv->buffer)) return FALSE; - + return TRUE; } + +Bool +xglCheckPixmapSize (PixmapPtr pPixmap, + xglSizeConstraintPtr pSize) +{ + if (pPixmap->drawable.width < pSize->minWidth || + pPixmap->drawable.height < pSize->minHeight) + return FALSE; + + if (pPixmap->drawable.width > pSize->aboveWidth || + pPixmap->drawable.height > pSize->aboveHeight) + return TRUE; + + return FALSE; +} + +void +xglEnablePixmapAccel (PixmapPtr pPixmap, + xglAccelInfoPtr pAccel) +{ + XGL_SCREEN_PRIV (pPixmap->drawable.pScreen); + XGL_PIXMAP_PRIV (pPixmap); + + if (pAccel->enabled && xglCheckPixmapSize (pPixmap, &pAccel->size)) + { + xglVisualPtr v; + + if (pAccel->pbuffer) + { + for (v = pScreenPriv->pVisual; v; v = v->next) + { + if (v->pPixel->depth != pPixmap->drawable.depth) + continue; + + if (v->format.drawable && v->pbuffer) + break; + } + } + else + { + for (v = pScreenPriv->pVisual; v; v = v->next) + { + if (v->pPixel->depth != pPixmap->drawable.depth) + continue; + + if (v->format.drawable && !v->pbuffer) + break; + } + } + + if (v) + { + xglSetPixmapVisual (pPixmap, v); + if (!pPixmapPriv->target) + pPixmapPriv->target = xglPixmapTargetOut; + } + } +} diff --git a/hw/xgl/xglscreen.c b/hw/xgl/xglscreen.c index 26f2848c5..5ad9091ca 100644 --- a/hw/xgl/xglscreen.c +++ b/hw/xgl/xglscreen.c @@ -1,6 +1,6 @@ /* * Copyright © 2004 David Reveman - * + * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without * fee, provided that the above copyright notice appear in all copies @@ -12,11 +12,11 @@ * software for any purpose. It is provided "as is" without express or * implied warranty. * - * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * 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. * @@ -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) { @@ -91,7 +70,7 @@ xglAllocatePrivates (ScreenPtr pScreen) xglScreenPrivateIndex = AllocateScreenPrivateIndex (); if (xglScreenPrivateIndex < 0) return FALSE; - + xglGCPrivateIndex = AllocateGCPrivateIndex (); if (xglGCPrivateIndex < 0) return FALSE; @@ -104,13 +83,13 @@ xglAllocatePrivates (ScreenPtr pScreen) if (xglWinPrivateIndex < 0) return FALSE; -#ifdef RENDER +#ifdef RENDER xglGlyphPrivateIndex = AllocateGlyphPrivateIndex (); if (xglGlyphPrivateIndex < 0) return FALSE; -#endif - - xglScreenGeneration = serverGeneration; +#endif + + xglScreenGeneration = serverGeneration; } if (!AllocateGCPrivate (pScreen, xglGCPrivateIndex, sizeof (xglGCRec))) @@ -127,66 +106,74 @@ xglAllocatePrivates (ScreenPtr pScreen) pScreenPriv = xalloc (sizeof (xglScreenRec)); if (!pScreenPriv) return FALSE; - + XGL_SET_SCREEN_PRIV (pScreen, pScreenPriv); - + return TRUE; } Bool -xglScreenInit (ScreenPtr pScreen) +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; pScreenPriv = XGL_GET_SCREEN_PRIV (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); + glitz_drawable_get_features (xglScreenInfo.drawable); - depth = pScreenPriv->pVisual->pPixel->depth; - bpp = pScreenPriv->pVisual->pPixel->masks.bpp; + GEOMETRY_INIT (pScreen, &pScreenPriv->scratchGeometry, + GLITZ_GEOMETRY_TYPE_VERTEX, + pScreenPriv->geometryUsage, 0); - xglInitPixmapFormats (pScreen); - if (!pScreenPriv->pixmapFormats[depth].format) - return FALSE; - 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->accel = xglScreenInfo.accel; - pScreenPriv->backSurface = NULL; - if (monitorResolution == 0) monitorResolution = XGL_DEFAULT_DPI; @@ -197,7 +184,7 @@ xglScreenInit (ScreenPtr pScreen) return FALSE; pScreen->SaveScreen = xglSaveScreen; - + pScreen->CreatePixmap = xglCreatePixmap; pScreen->DestroyPixmap = xglDestroyPixmap; @@ -218,9 +205,10 @@ xglScreenInit (ScreenPtr pScreen) XGL_SCREEN_WRAP (GetImage, xglGetImage); XGL_SCREEN_WRAP (GetSpans, xglGetSpans); - + XGL_SCREEN_WRAP (CopyWindow, xglCopyWindow); XGL_SCREEN_WRAP (CreateWindow, xglCreateWindow); + XGL_SCREEN_WRAP (DestroyWindow, xglDestroyWindow); XGL_SCREEN_WRAP (ChangeWindowAttributes, xglChangeWindowAttributes); XGL_SCREEN_WRAP (PaintWindowBackground, xglPaintWindowBackground); XGL_SCREEN_WRAP (PaintWindowBorder, xglPaintWindowBorder); @@ -234,13 +222,13 @@ xglScreenInit (ScreenPtr pScreen) pScreen->UnrealizeCursor = xglUnrealizeCursor; pScreen->RecolorCursor = xglRecolorCursor; pScreen->SetCursorPosition = xglSetCursorPosition; - + pScreen->ModifyPixmapHeader = xglModifyPixmapHeader; - + XGL_SCREEN_WRAP (BitmapToRegion, xglPixmapToRegion); pScreen->GetWindowPixmap = xglGetWindowPixmap; - + XGL_SCREEN_WRAP (SetWindowPixmap, xglSetWindowPixmap); #ifdef RENDER @@ -250,7 +238,7 @@ xglScreenInit (ScreenPtr pScreen) if (!AllocateGlyphPrivate (pScreen, xglGlyphPrivateIndex, sizeof (xglGlyphRec))) return FALSE; - + XGL_PICTURE_SCREEN_WRAP (RealizeGlyph, xglRealizeGlyph); XGL_PICTURE_SCREEN_WRAP (UnrealizeGlyph, xglUnrealizeGlyph); XGL_PICTURE_SCREEN_WRAP (Composite, xglComposite); @@ -272,6 +260,7 @@ xglScreenInit (ScreenPtr pScreen) return FALSE; #ifdef COMPOSITE +#warning "composite building" if (!compScreenInit (pScreen)) return FALSE; #endif @@ -287,7 +276,8 @@ xglScreenInit (ScreenPtr pScreen) Bool xglFinishScreenInit (ScreenPtr pScreen) { - + xglVisualPtr v; + #ifdef RENDER glitz_vertex_format_t *format; static glitz_color_t clearBlack = { 0x0, 0x0, 0x0, 0x0 }; @@ -296,38 +286,67 @@ xglFinishScreenInit (ScreenPtr pScreen) #endif XGL_SCREEN_PRIV (pScreen); - - 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; + + pScreenPriv->surface = glitz_surface_create (pScreenPriv->drawable, - pScreenPriv->pixmapFormats[32].format, - 1, 1, 0, NULL); - if (!pScreenPriv->solid) + pScreenPriv->rootVisual->format.surface, + xglScreenInfo.width, xglScreenInfo.height, + 0, NULL); + if (!pScreenPriv->surface) return FALSE; - - glitz_surface_set_fill (pScreenPriv->solid, GLITZ_FILL_REPEAT); + + 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, - 2, 1, 0, NULL); - if (!pScreenPriv->trapInfo.mask) - return FALSE; + pScreenPriv->pSolidAlpha = 0; + pScreenPriv->trapInfo.pMask = 0; - 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); + /* An accelerated alpha only Xgl visual is required for trapezoid + acceleration */ + if (v && v->format.surface) + { + glitz_surface_t *mask; + + mask = glitz_surface_create (pScreenPriv->drawable, + v->format.surface, + 2, 1, 0, NULL); + if (mask) + { + glitz_set_rectangle (mask, &clearBlack, 0, 0, 1, 1); + glitz_set_rectangle (mask, &solidWhite, 1, 0, 1, 1); + + glitz_surface_set_fill (mask, GLITZ_FILL_NEAREST); + glitz_surface_set_filter (mask, GLITZ_FILTER_BILINEAR, NULL, 0); + + pScreenPriv->trapInfo.pMask = xglCreateDevicePicture (mask); + if (!pScreenPriv->trapInfo.pMask) + return FALSE; + } + } - format = &pScreenPriv->trapInfo.format.vertex; + format = &pScreenPriv->trapInfo.format.vertex; format->primitive = GLITZ_PRIMITIVE_QUADS; format->attributes = GLITZ_VERTEX_ATTRIBUTE_MASK_COORD_MASK; @@ -348,7 +367,12 @@ xglFinishScreenInit (ScreenPtr pScreen) format->mask.offset = 2 * sizeof (glitz_short_t); } #endif - + +#ifdef XV + if (!xglXvScreenInit (pScreen)) + return FALSE; +#endif + return TRUE; } @@ -356,37 +380,49 @@ Bool xglCloseScreen (int index, ScreenPtr pScreen) { + xglVisualPtr v; + XGL_SCREEN_PRIV (pScreen); XGL_PIXMAP_PRIV (pScreenPriv->pScreenPixmap); #ifdef RENDER int i; - + for (i = 0; i < 33; i++) xglFiniGlyphCache (&pScreenPriv->glyphCache[i]); if (pScreenPriv->pSolidAlpha) FreePicture ((pointer) pScreenPriv->pSolidAlpha, 0); - if (pScreenPriv->trapInfo.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); @@ -415,25 +451,24 @@ xglCreateSolidAlphaPicture (ScreenPtr pScreen) pGC = GetScratchGC (pFormat->depth, pScreen); if (!pGC) return; - + pPixmap = (*pScreen->CreatePixmap) (pScreen, 1, 1, pFormat->depth); if (!pPixmap) return; - + miRenderColorToPixel (pFormat, &solidWhite, &pixel); - + tmpval[0] = GXcopy; tmpval[1] = pixel; ChangeGC (pGC, GCFunction | GCForeground, tmpval); - ValidateGC (&pPixmap->drawable, pGC); + ValidateGC (&pPixmap->drawable, pGC); (*pGC->ops->PolyFillRect) (&pPixmap->drawable, pGC, 1, &one); FreeScratchGC (pGC); - + tmpval[0] = xTrue; - pScreenPriv->pSolidAlpha = - CreatePicture (0, &pPixmap->drawable, pFormat, - CPRepeat, tmpval, 0, &error); + pScreenPriv->pSolidAlpha = CreatePicture (0, &pPixmap->drawable, pFormat, + CPRepeat, tmpval, 0, &error); (*pScreen->DestroyPixmap) (pPixmap); if (pScreenPriv->pSolidAlpha) diff --git a/hw/xgl/xglshm.c b/hw/xgl/xglshm.c index 3ac0c9453..52a8aabb8 100644 --- a/hw/xgl/xglshm.c +++ b/hw/xgl/xglshm.c @@ -1,6 +1,6 @@ /* * 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 @@ -12,11 +12,11 @@ * software for any purpose. It is provided "as is" without express or * implied warranty. * - * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * 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, + * 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. * @@ -56,9 +56,11 @@ xglShmPutImage (DrawablePtr pDrawable, GetScratchPixmapHeader (pScreen, w, h, depth, BitsPerPixel (depth), PixmapBytePad (w, depth), - (pointer) data); + (pointer) data); + + /* disable any possible acceleration of this pixmap */ if (pPixmap) - XGL_GET_PIXMAP_PRIV (pPixmap)->format = NULL; + xglSetPixmapVisual (pPixmap, 0); } else { @@ -67,24 +69,22 @@ 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) { (*pScreen->DestroyPixmap) (pPixmap); return; } - + ValidateGC ((DrawablePtr) pPixmap, pScratchGC); (*pGC->ops->PutImage) ((DrawablePtr) pPixmap, pScratchGC, depth, -sx, -sy, w, h, 0, @@ -96,7 +96,7 @@ xglShmPutImage (DrawablePtr pDrawable, sx = sy = 0; } } - + if (!pPixmap) return; @@ -112,7 +112,7 @@ xglShmPutImage (DrawablePtr pDrawable, sx, sy, sw, sh, dx, dy); pPixmapPriv->target = saveTarget; - + if (pPixmapHeader) FreeScratchPixmapHeader (pPixmapHeader); else diff --git a/hw/xgl/xglsolid.c b/hw/xgl/xglsolid.c index e0cbfc4d8..8657a9a16 100644 --- a/hw/xgl/xglsolid.c +++ b/hw/xgl/xglsolid.c @@ -1,6 +1,6 @@ /* * Copyright © 2004 David Reveman - * + * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without * fee, provided that the above copyright notice appear in all copies @@ -12,11 +12,11 @@ * software for any purpose. It is provided "as is" without express or * implied warranty. * - * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * 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. * @@ -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, @@ -42,18 +42,14 @@ xglSolid (DrawablePtr pDrawable, { glitz_surface_t *surface; int xOff, yOff; - - XGL_SCREEN_PRIV (pDrawable->pScreen); if (nBox < 1) return TRUE; if (!xglPrepareTarget (pDrawable)) return FALSE; - - XGL_GET_DRAWABLE (pDrawable, surface, xOff, yOff); - glitz_set_rectangle (pScreenPriv->solid, color, 0, 0, 1, 1); + XGL_GET_DRAWABLE (pDrawable, surface, xOff, yOff); if (pGeometry) { @@ -67,12 +63,12 @@ xglSolid (DrawablePtr pDrawable, } GEOMETRY_TRANSLATE (pGeometry, xOff, yOff); - + if (!GEOMETRY_ENABLE (pGeometry, surface)) return FALSE; glitz_composite (op, - pScreenPriv->solid, NULL, surface, + solid, NULL, surface, 0, 0, 0, 0, x + xOff, @@ -80,7 +76,7 @@ xglSolid (DrawablePtr pDrawable, width, height); glitz_surface_set_clip_region (surface, 0, 0, NULL, 0); - + if (glitz_surface_get_status (surface)) return FALSE; @@ -104,7 +100,7 @@ xglSolidGlyph (DrawablePtr pDrawable, x += pDrawable->x; y += pDrawable->y; - + GEOMETRY_INIT (pDrawable->pScreen, &geometry, GLITZ_GEOMETRY_TYPE_BITMAP, GEOMETRY_USAGE_SYSMEM, 0); @@ -116,11 +112,11 @@ xglSolidGlyph (DrawablePtr pDrawable, pglyphBase); GEOMETRY_TRANSLATE (&geometry, x, y); - + widthBack = 0; while (nGlyph--) widthBack += (*ppci++)->metrics.characterWidth; - + xBack = x; if (widthBack < 0) { @@ -129,10 +125,10 @@ xglSolidGlyph (DrawablePtr pDrawable, } yBack = y - FONTASCENT (pGC->font); heightBack = FONTASCENT (pGC->font) + FONTDESCENT (pGC->font); - + 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,10 +149,11 @@ xglSolidGlyph (DrawablePtr pDrawable, REGION_NUM_RECTS (pGC->pCompositeClip))) { GEOMETRY_UNINIT (&geometry); + xglAddCurrentBitDamage (pDrawable); return TRUE; } } - + GEOMETRY_UNINIT (&geometry); return FALSE; } diff --git a/hw/xgl/xglsync.c b/hw/xgl/xglsync.c index 7bcff949b..6b5c00b57 100644 --- a/hw/xgl/xglsync.c +++ b/hw/xgl/xglsync.c @@ -1,6 +1,6 @@ /* * Copyright © 2004 David Reveman - * + * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without * fee, provided that the above copyright notice appear in all copies @@ -12,11 +12,11 @@ * software for any purpose. It is provided "as is" without express or * implied warranty. * - * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * 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. * @@ -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)); - - if (!BOX_NOTEMPTY (&box)) + box.x1 = 0; + box.y1 = 0; + box.x2 = pPixmap->drawable.width; + box.y2 = pPixmap->drawable.height; + if (pExtents->x1 > box.x1) + box.x1 = pExtents->x1; + if (pExtents->y1 > box.y1) + box.y1 = pExtents->y1; + if (pExtents->x2 < box.x2) + box.x2 = pExtents->x2; + if (pExtents->y2 < box.y2) + box.y2 = pExtents->y2; + + if (box.x2 <= box.x1 || box.y2 <= box.y1) return xglMapPixmapBits (pPixmap); - - if (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); - - 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; + REGION_SUBTRACT (pDrawable->pScreen, ®ion, ®ion, + &pPixmapPriv->bitRegion); + pPixmapPriv->allBits = TRUE; } @@ -151,62 +118,66 @@ 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)) FatalError (XGL_SW_FAILURE_STRING); xglUnmapPixmapBits (pPixmap); - + pBox = REGION_RECTS (®ion); nBox = REGION_NUM_RECTS (®ion); + pExt = REGION_EXTENTS (pDrawable->pScreen, ®ion); - format.fourcc = GLITZ_FOURCC_RGB; - format.masks = pPixmapPriv->pPixel->masks; - - while (nBox--) + format.fourcc = GLITZ_FOURCC_RGB; + format.masks = pPixmapPriv->pVisual->pPixel->masks; + format.xoffset = pExt->x1; + + if (pPixmapPriv->stride < 0) { - format.xoffset = pBox->x1; + format.skip_lines = pPixmap->drawable.height - pExt->y2; + format.bytes_per_line = -pPixmapPriv->stride; + format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP; + } + else + { + format.skip_lines = pExt->y1; + format.bytes_per_line = pPixmapPriv->stride; + format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN; + } - if (pPixmapPriv->stride < 0) - { - format.skip_lines = pPixmap->drawable.height - pBox->y2; - format.bytes_per_line = -pPixmapPriv->stride; - format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP; - } - else - { - format.skip_lines = pBox->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, - &format, - pPixmapPriv->buffer); - - pBox++; - } + glitz_get_pixels (pPixmapPriv->surface, + pExt->x1, + pExt->y1, + pExt->x2 - pExt->x1, + pExt->y2 - pExt->y1, + &format, + pPixmapPriv->buffer); + + glitz_surface_set_clip_region (pPixmapPriv->surface, 0, 0, NULL, 0); } REGION_UNINIT (pDrawable->pScreen, ®ion); + if (pPixmapPriv->allBits) + { + box.x1 = 0; + box.y1 = 0; + box.x2 = pPixmap->drawable.width; + box.y2 = pPixmap->drawable.height; + + REGION_UNINIT (pDrawable->pScreen, &pPixmapPriv->bitRegion); + REGION_INIT (pDrawable->pScreen, &pPixmapPriv->bitRegion, &box, 1); + } + return xglMapPixmapBits (pPixmap); } @@ -229,9 +200,6 @@ xglSyncSurface (DrawablePtr pDrawable) if (!pPixmapPriv->surface) { - if (!pPixmapPriv->format) - return FALSE; - if (!xglCreatePixmapSurface (pPixmap)) return FALSE; } @@ -239,20 +207,20 @@ xglSyncSurface (DrawablePtr pDrawable) pRegion = DamageRegion (pPixmapPriv->pDamage); if (REGION_NOTEMPTY (pDrawable->pScreen, pRegion)) - { + { glitz_pixel_format_t format; BoxPtr pBox; BoxPtr pExt; int nBox; - + xglUnmapPixmapBits (pPixmap); nBox = REGION_NUM_RECTS (pRegion); pBox = REGION_RECTS (pRegion); pExt = REGION_EXTENTS (pDrawable->pScreen, pRegion); - format.fourcc = 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,16 +267,51 @@ xglPrepareTarget (DrawablePtr pDrawable) case xglPixmapTargetOut: if (xglSyncSurface (pDrawable)) { - pPixmapPriv->target = xglPixmapTargetIn; - return TRUE; + glitz_drawable_format_t *format; + + XGL_SCREEN_PRIV (pDrawable->pScreen); + + if (!pPixmapPriv->drawable) + { + unsigned int width, height; + + format = pPixmapPriv->pVisual->format.drawable; + width = pPixmap->drawable.width; + height = pPixmap->drawable.height; + + if (pPixmapPriv->pVisual->pbuffer) + { + pPixmapPriv->drawable = + glitz_create_pbuffer_drawable (pScreenPriv->drawable, + format, width, height); + } + else + { + pPixmapPriv->drawable = + glitz_create_drawable (pScreenPriv->drawable, + format, width, height); + } + } + + if (pPixmapPriv->drawable) + { + glitz_surface_attach (pPixmapPriv->surface, + pPixmapPriv->drawable, + GLITZ_DRAWABLE_BUFFER_FRONT_COLOR); + + pPixmapPriv->target = xglPixmapTargetIn; + + return TRUE; + } } + pPixmapPriv->target = xglPixmapTargetNo; break; case xglPixmapTargetIn: if (xglSyncSurface (pDrawable)) return TRUE; break; } - + return FALSE; } @@ -316,52 +319,65 @@ 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); - pDamageRegion = DamageRegion (pPixmapPriv->pDamage); + if (pPixmapPriv->pDamage) + { + RegionPtr pDamageRegion; + + pDamageRegion = DamageRegion (pPixmapPriv->pDamage); + + REGION_UNION (pDrawable->pScreen, + pDamageRegion, pDamageRegion, + pRegion); + } + + REGION_UNION (pDrawable->pScreen, + &pPixmapPriv->bitRegion, &pPixmapPriv->bitRegion, + pRegion); - REGION_UNION (pDrawable->pScreen, pDamageRegion, pDamageRegion, pRegion); - if (xOff || yOff) REGION_TRANSLATE (pDrawable->pScreen, pRegion, -xOff, -yOff); } void xglAddCurrentSurfaceDamage (DrawablePtr pDrawable) -{ +{ XGL_DRAWABLE_PIXMAP_PRIV (pDrawable); - if (!pPixmapPriv->format) - { - pPixmapPriv->damageBox = miEmptyBox; - return; - } - if (BOX_NOTEMPTY (&pPixmapPriv->damageBox)) { - RegionPtr pDamageRegion; RegionRec region; - pDamageRegion = DamageRegion (pPixmapPriv->pDamage); - REGION_INIT (pDrawable->pScreen, ®ion, &pPixmapPriv->damageBox, 1); + + if (pPixmapPriv->pDamage) + { + RegionPtr pDamageRegion; + + pDamageRegion = DamageRegion (pPixmapPriv->pDamage); + + REGION_UNION (pDrawable->pScreen, + pDamageRegion, pDamageRegion, + ®ion); + } + REGION_UNION (pDrawable->pScreen, - pDamageRegion, pDamageRegion, ®ion); + &pPixmapPriv->bitRegion, &pPixmapPriv->bitRegion, + ®ion); + REGION_UNINIT (pDrawable->pScreen, ®ion); - + pPixmapPriv->damageBox = miEmptyBox; } } @@ -370,34 +386,42 @@ void xglAddBitDamage (DrawablePtr pDrawable, RegionPtr pRegion) { - BoxPtr pBox; - BoxPtr pExt; - int nBox; - XGL_DRAWABLE_PIXMAP_PRIV (pDrawable); - 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) + if (REGION_NOTEMPTY (pDrawable->pScreen, &pPixmapPriv->bitRegion)) { - while (nBox--) + BoxPtr pBox; + BoxPtr pExt, pBitExt; + int nBox; + + pBox = REGION_RECTS (pRegion); + pExt = REGION_EXTENTS (pDrawable->pScreen, pRegion); + nBox = REGION_NUM_RECTS (pRegion); + + pBitExt = REGION_EXTENTS (pDrawable->pScreen, &pPixmapPriv->bitRegion); + + if (pExt->x1 < pBitExt->x2 && + pExt->y1 < pBitExt->y2 && + pExt->x2 > pBitExt->x1 && + pExt->y2 > pBitExt->y1) { - if (pBox->x1 < pPixmapPriv->bitBox.x2 && - pBox->y1 < pPixmapPriv->bitBox.y2 && - pBox->x2 > pPixmapPriv->bitBox.x1 && - pBox->y2 > pPixmapPriv->bitBox.y1) + while (nBox--) { - pPixmapPriv->bitBox = miEmptyBox; - pPixmapPriv->allBits = FALSE; - return; + if (pBox->x1 < pBitExt->x2 && + pBox->y1 < pBitExt->y2 && + pBox->x2 > pBitExt->x1 && + pBox->y2 > pBitExt->y1) + { + REGION_UNINIT (pDrawable->pScreen, + &pPixmapPriv->bitRegion); + REGION_INIT (pDrawable->pScreen, &pPixmapPriv->bitRegion, + NullBox, 0); + pPixmapPriv->allBits = FALSE; + return; + } + + pBox++; } - - pBox++; } } } @@ -407,13 +431,22 @@ 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; - pPixmapPriv->allBits = FALSE; + 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; diff --git a/hw/xgl/xgltile.c b/hw/xgl/xgltile.c index d2a440f92..25b78c316 100644 --- a/hw/xgl/xgltile.c +++ b/hw/xgl/xgltile.c @@ -1,6 +1,6 @@ /* * Copyright © 2004 David Reveman - * + * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without * fee, provided that the above copyright notice appear in all copies @@ -12,11 +12,11 @@ * software for any purpose. It is provided "as is" without express or * implied warranty. * - * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * 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. * @@ -63,7 +63,7 @@ xglTiledBoxGeometry (PixmapPtr pTile, tileWidth = pTile->drawable.width; tileHeight = pTile->drawable.height; - + for (i = 0; i < nBox; i++) size += (((pBox[i].x2 - pBox[i].x1) / tileWidth) + 2) * @@ -75,7 +75,7 @@ xglTiledBoxGeometry (PixmapPtr pTile, data = glitz_buffer_map (pGeometry->buffer, GLITZ_BUFFER_ACCESS_WRITE_ONLY); - + while (nBox--) { x = pBox->x1; @@ -87,19 +87,19 @@ xglTiledBoxGeometry (PixmapPtr pTile, yTile = MOD (tileY + y, tileHeight); yTmp = y; - + while (height) { heightTile = MIN (tileHeight - yTile, height); - + xTileTmp = xTile; widthTmp = width; xTmp = x; - + while (widthTmp) { widthTile = MIN (tileWidth - xTileTmp, widthTmp); - + p1.x = xTileTmp << 16; p1.y = yTile << 16; p2.x = (xTileTmp + widthTile) << 16; @@ -107,7 +107,7 @@ xglTiledBoxGeometry (PixmapPtr pTile, glitz_surface_translate_point (pPixmapPriv->surface, &p1, &p1); glitz_surface_translate_point (pPixmapPriv->surface, &p2, &p2); - + x1 = FIXED_TO_FLOAT (p1.x); y1 = FIXED_TO_FLOAT (p1.y); x2 = FIXED_TO_FLOAT (p2.x); @@ -122,29 +122,29 @@ xglTiledBoxGeometry (PixmapPtr pTile, *data++ = (glitz_float_t) yTmp; *data++ = x2; *data++ = y1; - + *data++ = (glitz_float_t) (xTmp + widthTile); *data++ = (glitz_float_t) (yTmp + heightTile); *data++ = x2; *data++ = y2; - + *data++ = (glitz_float_t) xTmp; *data++ = (glitz_float_t) (yTmp + heightTile); *data++ = x1; *data++ = y2; pGeometry->endOffset += sizeof (glitz_float_t) * 16; - + xTileTmp = 0; xTmp += widthTile; widthTmp -= widthTile; } - + yTile = 0; yTmp += heightTile; height -= heightTile; } - + pBox++; } @@ -197,7 +197,7 @@ xglTile (DrawablePtr pDrawable, GLITZ_FILTER_NEAREST, NULL, 0); glitz_surface_set_transform (pTilePriv->surface, NULL); - + if (pTilePriv->acceleratedTile) { if (pGeometry) @@ -212,9 +212,9 @@ xglTile (DrawablePtr pDrawable, 4 * nBox); GEOMETRY_ADD_BOX (pDrawable->pScreen, pGeometry, pBox, nBox); } - + GEOMETRY_TRANSLATE (pGeometry, xOff, yOff); - + if (!GEOMETRY_ENABLE (pGeometry, surface)) return FALSE; @@ -231,7 +231,7 @@ xglTile (DrawablePtr pDrawable, width, height); glitz_surface_set_clip_region (surface, 0, 0, NULL, 0); - + if (!glitz_surface_get_status (surface)) return TRUE; @@ -249,10 +249,10 @@ xglTile (DrawablePtr pDrawable, return FALSE; GEOMETRY_TRANSLATE (pGeometry, xOff, yOff); - + if (!GEOMETRY_ENABLE (pGeometry, surface)) return FALSE; - + glitz_composite (op, pTilePriv->surface, NULL, surface, 0, 0, @@ -260,9 +260,9 @@ xglTile (DrawablePtr pDrawable, x + xOff, y + yOff, width, height); - + if (glitz_surface_get_status (surface)) return FALSE; - + return TRUE; } diff --git a/hw/xgl/xgltrap.c b/hw/xgl/xgltrap.c index 8f792a6c5..26e2bc451 100644 --- a/hw/xgl/xgltrap.c +++ b/hw/xgl/xgltrap.c @@ -1,6 +1,6 @@ /* * 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 @@ -12,11 +12,11 @@ * software for any purpose. It is provided "as is" without express or * implied warranty. * - * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * 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, + * 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. * @@ -74,15 +74,15 @@ xglTrapezoidExtents (PicturePtr pDst, extents->y1 = xFixedToInt (traps->top); extents->y2 = xFixedToInt (xFixedCeil (traps->bottom)); - + LINE_FIXED_X (&traps->left, traps->top, top); LINE_FIXED_X (&traps->left, traps->bottom, bottom); extents->x1 = xFixedToInt (MIN (top, bottom)); - + LINE_FIXED_X_CEIL (&traps->right, traps->top, top); LINE_FIXED_X_CEIL (&traps->right, traps->bottom, bottom); extents->x2 = xFixedToInt (xFixedCeil (MAX (top, bottom))); - + ntrap--; traps++; @@ -95,15 +95,15 @@ xglTrapezoidExtents (PicturePtr pDst, y1 = xFixedToInt (traps->top); y2 = xFixedToInt (xFixedCeil (traps->bottom)); - + LINE_FIXED_X (&traps->left, traps->top, top); LINE_FIXED_X (&traps->left, traps->bottom, bottom); x1 = xFixedToInt (MIN (top, bottom)); - + LINE_FIXED_X_CEIL (&traps->right, traps->top, top); LINE_FIXED_X_CEIL (&traps->right, traps->bottom, bottom); x2 = xFixedToInt (xFixedCeil (MAX (top, bottom))); - + x_overlap = FALSE; if (x1 >= extents->x2) extents->x2 = x2; @@ -117,18 +117,18 @@ xglTrapezoidExtents (PicturePtr pDst, if (x2 > extents->x2) extents->x2 = x2; } - + if (y1 >= extents->y2) extents->y2 = y2; else if (y2 <= extents->y1) - extents->y1 = y1; + extents->y1 = y1; else { if (y1 < extents->y1) extents->y1 = y1; if (y2 > extents->y2) extents->y2 = y2; - + if (x_overlap) overlap = TRUE; } @@ -151,21 +151,20 @@ 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; BoxRec extents; Bool overlap; 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; - + overlap = xglTrapezoidExtents (pDst, nTrap, traps, &extents); if (extents.y1 >= extents.y2 || extents.x1 >= extents.x2) return; @@ -180,7 +179,7 @@ xglTrapezoids (CARD8 op, xRectangle rect; int error; int area; - + if (!pScreenPriv->pSolidAlpha) { xglCreateSolidAlphaPicture (pScreen); @@ -194,11 +193,11 @@ xglTrapezoids (CARD8 op, rect.height = extents.y2 - extents.y1; pPixmap = (*pScreen->CreatePixmap) (pScreen, - rect.width, rect.height, + rect.width, rect.height, maskFormat->depth); if (!pPixmap) return; - + pMask = CreatePicture (0, &pPixmap->drawable, maskFormat, 0, 0, serverClient, &error); if (!pMask) @@ -206,15 +205,17 @@ xglTrapezoids (CARD8 op, (*pScreen->DestroyPixmap) (pPixmap); return; } - - /* make sure destination drawable is locked */ - pPixmapPriv->lock++; - /* lock mask if we are not doing accelerated drawing to destination */ + if (!target) + { + /* make sure we don't do accelerated drawing to mask */ + xglSetPixmapVisual (pPixmap, NULL); + } + 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); ValidateGC (&pPixmap->drawable, pGC); @@ -224,7 +225,7 @@ xglTrapezoids (CARD8 op, (*pScreen->DestroyPixmap) (pPixmap); target = xglPrepareTarget (pMask->pDrawable); - + xOff = -extents.x1; yOff = -extents.y1; pSrcPicture = pScreenPriv->pSolidAlpha; @@ -232,9 +233,6 @@ xglTrapezoids (CARD8 op, } else { - /* make sure destination drawable is locked */ - pPixmapPriv->lock++; - if (maskFormat) { if (maskFormat->depth == 1) @@ -242,7 +240,7 @@ xglTrapezoids (CARD8 op, else polyEdge = PolyEdgeSmooth; } - + xOff = 0; yOff = 0; pSrcPicture = pSrc; @@ -254,37 +252,38 @@ 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); - + while (n) { if (pGeometry->size < size) GEOMETRY_RESIZE (pScreen, pGeometry, size); - + if (!pGeometry->buffer) { if (pMask) FreePicture (pMask, 0); - pPixmapPriv->lock--; return; } - + offset += glitz_add_trapezoids (pGeometry->buffer, offset, size - offset, format->type, mask, (glitz_trapezoid_t *) pTrap, n, &nAddedTrap); - + n -= nAddedTrap; pTrap += nAddedTrap; size *= 2; @@ -304,10 +303,9 @@ xglTrapezoids (CARD8 op, if (pMask) FreePicture (pMask, 0); - pPixmapPriv->lock--; return; } - + GEOMETRY_ADD_TRAPEZOID (pScreen, pGeometry, traps, nTrap); } @@ -317,19 +315,18 @@ xglTrapezoids (CARD8 op, } if (pGeometry && - xglComp (pMask ? PictOpAdd : op, - pSrcPicture, - NULL, - pDstPicture, - 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)) + xglCompositeGeneral (pMask ? PictOpAdd : op, + pSrcPicture, + pMaskPicture, + pDstPicture, + pGeometry, + extents.x1 + xOff + xSrc - xDst, + extents.y1 + yOff + ySrc - yDst, + 0, 0, + pDstPicture->pDrawable->x + extents.x1 + xOff, + pDstPicture->pDrawable->y + extents.y1 + yOff, + extents.x2 - extents.x1, + extents.y2 - extents.y1)) { /* no intermediate mask? we need to register damage from here as CompositePicture will never be called. */ @@ -340,12 +337,12 @@ xglTrapezoids (CARD8 op, REGION_INIT (pScreen, ®ion, &extents, 1); REGION_TRANSLATE (pScreen, ®ion, pDst->pDrawable->x, pDst->pDrawable->y); - + DamageDamageRegion (pDst->pDrawable, ®ion); REGION_UNINIT (pScreen, ®ion); } - + xglAddCurrentBitDamage (pDstPicture->pDrawable); } else @@ -363,16 +360,17 @@ xglTrapezoids (CARD8 op, op == PictOpAdd && miIsSolidAlpha (pSrc))) { PictureScreenPtr ps = GetPictureScreen (pScreen); - + for (; nTrap; nTrap--, traps++) (*ps->RasterizeTrapezoid) (pDstPicture, traps, xOff, yOff); xglAddCurrentSurfaceDamage (pDstPicture->pDrawable); - } else - miTrapezoids (op, pSrc, pDstPicture, NULL, + } + else + miTrapezoids (op, pSrc, pDstPicture, maskFormat, xSrc, ySrc, nTrap, traps); } - + if (pMask) { CompositePicture (op, pSrc, pMask, pDst, @@ -382,12 +380,9 @@ xglTrapezoids (CARD8 op, extents.x1, extents.y1, extents.x2 - extents.x1, extents.y2 - extents.y1); - + FreePicture (pMask, 0); } - - /* release destination drawable lock */ - pPixmapPriv->lock--; } void @@ -397,9 +392,9 @@ xglAddTraps (PicturePtr pDst, int nTrap, xTrap *traps) { - PictureScreenPtr pPictureScreen; + PictureScreenPtr pPictureScreen; ScreenPtr pScreen = pDst->pDrawable->pScreen; - + XGL_SCREEN_PRIV (pScreen); XGL_DRAWABLE_PIXMAP_PRIV (pDst->pDrawable); @@ -417,33 +412,36 @@ 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); - + while (n) { if (pGeometry->size < size) GEOMETRY_RESIZE (pScreen, pGeometry, size); - + if (!pGeometry->buffer) return; - + offset += glitz_add_traps (pGeometry->buffer, - offset, size - offset, format->type, - pScreenPriv->trapInfo.mask, + offset, size - offset, format->type, mask, (glitz_trap_t *) pTrap, n, &nAddedTrap); - + n -= nAddedTrap; pTrap += nAddedTrap; size *= 2; @@ -455,17 +453,17 @@ xglAddTraps (PicturePtr pDst, GEOMETRY_TRANSLATE (pGeometry, pDst->pDrawable->x + xOff, pDst->pDrawable->y + yOff); - - if (xglComp (PictOpAdd, - pScreenPriv->pSolidAlpha, - NULL, - pDst, - 0, 0, - 0, 0, - pDst->pDrawable->x, pDst->pDrawable->y, - pDst->pDrawable->width, pDst->pDrawable->height, - pGeometry, - pScreenPriv->trapInfo.mask)) + + if (xglCompositeGeneral (PictOpAdd, + pScreenPriv->pSolidAlpha, + pMask, + pDst, + pGeometry, + 0, 0, + 0, 0, + pDst->pDrawable->x, pDst->pDrawable->y, + pDst->pDrawable->width, + pDst->pDrawable->height)) { xglAddCurrentBitDamage (pDst->pDrawable); return; diff --git a/hw/xgl/xglwindow.c b/hw/xgl/xglwindow.c index 9e4245c93..967d10f77 100644 --- a/hw/xgl/xglwindow.c +++ b/hw/xgl/xglwindow.c @@ -1,6 +1,6 @@ /* * Copyright © 2004 David Reveman - * + * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without * fee, provided that the above copyright notice appear in all copies @@ -12,11 +12,11 @@ * software for any purpose. It is provided "as is" without express or * implied warranty. * - * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * 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. * @@ -40,7 +40,7 @@ xglCreateWindow (WindowPtr pWin) { ScreenPtr pScreen = pWin->drawable.pScreen; Bool ret; - + XGL_SCREEN_PRIV (pScreen); XGL_WINDOW_PRIV (pWin); @@ -54,15 +54,30 @@ xglCreateWindow (WindowPtr pWin) } Bool +xglDestroyWindow (WindowPtr pWin) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + Bool ret; + + XGL_SCREEN_PRIV (pScreen); + + XGL_SCREEN_UNWRAP (DestroyWindow); + ret = (*pScreen->DestroyWindow) (pWin); + XGL_SCREEN_WRAP (DestroyWindow, xglDestroyWindow); + + return ret; +} + +Bool xglChangeWindowAttributes (WindowPtr pWin, unsigned long mask) { ScreenPtr pScreen = pWin->drawable.pScreen; PixmapPtr pPixmap; Bool ret; - + XGL_SCREEN_PRIV (pScreen); - + if (mask & CWBackPixmap) { if (pWin->backgroundState == BackgroundPixmap) @@ -74,7 +89,7 @@ xglChangeWindowAttributes (WindowPtr pWin, xglSyncBits (&pPixmap->drawable, NULL); } } - + if (mask & CWBorderPixmap) { if (pWin->borderIsPixel == FALSE) @@ -90,12 +105,12 @@ xglChangeWindowAttributes (WindowPtr pWin, XGL_SCREEN_UNWRAP (ChangeWindowAttributes); ret = (*pScreen->ChangeWindowAttributes) (pWin, mask); XGL_SCREEN_WRAP (ChangeWindowAttributes, xglChangeWindowAttributes); - + return ret; } -void -xglCopyWindow (WindowPtr pWin, +void +xglCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) { @@ -111,18 +126,18 @@ xglCopyWindow (WindowPtr pWin, box.y1 = pExtent->y1; box.x2 = pExtent->x2; box.y2 = pExtent->y2; - + dx = ptOldOrg.x - pWin->drawable.x; dy = ptOldOrg.y - pWin->drawable.y; - + REGION_TRANSLATE (pWin->drawable.pScreen, prgnSrc, -dx, -dy); - REGION_NULL (pWin->drawable.pScreen, &rgnDst); + REGION_INIT (pWin->drawable.pScreen, &rgnDst, NullBox, 0); REGION_INTERSECT (pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc); fbCopyRegion (&pWin->drawable, &pWin->drawable, 0, &rgnDst, dx, dy, xglCopyProc, 0, (void *) &box); - + REGION_UNINIT (pWin->drawable.pScreen, &rgnDst); } @@ -131,29 +146,53 @@ xglFillRegionSolid (DrawablePtr pDrawable, RegionPtr pRegion, Pixel pixel) { - glitz_color_t color; - BoxPtr pExtent; + 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, - GLITZ_OPERATOR_SRC, - &color, - NULL, - pExtent->x1, pExtent->y1, - pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1, - REGION_RECTS (pRegion), - REGION_NUM_RECTS (pRegion))) - return TRUE; - - return FALSE; + ret = xglSolid (pDrawable, + GLITZ_OPERATOR_SRC, + solid, + NULL, + pExtent->x1, pExtent->y1, + pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1, + REGION_RECTS (pRegion), + REGION_NUM_RECTS (pRegion)); + + glitz_surface_destroy (solid); + + return ret; } static Bool @@ -164,11 +203,6 @@ xglFillRegionTiled (DrawablePtr pDrawable, int tileY) { BoxPtr pExtent; - - XGL_DRAWABLE_PIXMAP_PRIV (pDrawable); - - if (!pPixmapPriv->target) - return FALSE; pExtent = REGION_EXTENTS (pDrawable->pScreen, pRegion); @@ -182,7 +216,7 @@ xglFillRegionTiled (DrawablePtr pDrawable, REGION_RECTS (pRegion), REGION_NUM_RECTS (pRegion))) return TRUE; - + return FALSE; } @@ -194,7 +228,7 @@ xglPaintWindowBackground (WindowPtr pWin, ScreenPtr pScreen = pWin->drawable.pScreen; XGL_SCREEN_PRIV (pScreen); - + switch (pWin->backgroundState) { case None: return; @@ -202,7 +236,7 @@ xglPaintWindowBackground (WindowPtr pWin, do { pWin = pWin->parent; } while (pWin->backgroundState == ParentRelative); - + (*pScreen->PaintWindowBackground) (pWin, pRegion, what); return; case BackgroundPixmap: @@ -215,7 +249,7 @@ xglPaintWindowBackground (WindowPtr pWin, xglAddCurrentBitDamage (&pWin->drawable); return; } - + if (!xglSyncBits (&pWin->background.pixmap->drawable, NullBox)) FatalError (XGL_SW_FAILURE_STRING); break; @@ -258,7 +292,7 @@ xglPaintWindowBorder (WindowPtr pWin, else { WindowPtr pBgWin = pWin; - + while (pBgWin->backgroundState == ParentRelative) pBgWin = pBgWin->parent; @@ -271,7 +305,7 @@ xglPaintWindowBorder (WindowPtr pWin, xglAddCurrentBitDamage (&pWin->drawable); return; } - + if (!xglSyncBits (&pWin->border.pixmap->drawable, NullBox)) FatalError (XGL_SW_FAILURE_STRING); } @@ -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); +} diff --git a/hw/xgl/xglxv.c b/hw/xgl/xglxv.c new file mode 100644 index 000000000..aaa66c738 --- /dev/null +++ b/hw/xgl/xglxv.c @@ -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 |