Updated xgl code drop from Novell + xserver tree changes

This commit is contained in:
Dave Airlie 2006-01-18 07:15:55 +00:00
parent b5356e0afa
commit e70b64b930
42 changed files with 11214 additions and 2747 deletions

View File

@ -1,3 +1,10 @@
2006-01-18 Dave Airlie <airlied@linux.ie>
Update XGL server from the xserver tree, and fix to work
in X.org tree (look out for a branch appearing RSN),
Most of the changes are from David Reveman @ Novell
and the rest are from either myself or Eric Anholt.
2006-01-18 Dave Airlie <airlied@linux.ie> 2006-01-18 Dave Airlie <airlied@linux.ie>
* Xext/Makefile.am: * Xext/Makefile.am:

View File

@ -22,12 +22,18 @@ AM_CFLAGS = \
@SERVER_DEFINES@ \ @SERVER_DEFINES@ \
-DHAVE_XGL_CONFIG_H \ -DHAVE_XGL_CONFIG_H \
-DHAVE_DIX_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) $(XGLMODULES_CFLAGS)
noinst_LIBRARIES = libxgl.a noinst_LIBRARIES = libxgl.a
libxgl_a_SOURCES = \ libxgl_a_SOURCES = \
xgl.h \ xgl.h \
xglmodule.h \
xglglx.h \
xglinput.c \ xglinput.c \
xgloutput.c \ xgloutput.c \
xglcmap.c \ xglcmap.c \
@ -46,13 +52,14 @@ libxgl_a_SOURCES = \
xglget.c \ xglget.c \
xglgc.c \ xglgc.c \
xglshm.c \ xglshm.c \
xglcomp.c \ xglcompose.c \
xglpict.c \ xglpict.c \
xglglyph.c \ xglglyph.c \
xgltrap.c \ xgltrap.c \
xglloader.c \
xglhash.c \ xglhash.c \
xglloader.c \ xglglx.c \
xglglx.c xglxv.c
EXTRA_DIST = \ EXTRA_DIST = \
xglmodule.h xglmodule.h
@ -69,8 +76,7 @@ Xgl_LDADD = \
$(XORG_CORE_LIBS) \ $(XORG_CORE_LIBS) \
$(XGL_LIBS) \ $(XGL_LIBS) \
$(XSERVER_LIBS) \ $(XSERVER_LIBS) \
$(EXTENSION_LIBS) \ $(EXTENSION_LIBS) -lglitz -ldl
$(XGLMODULES_LIBS)
Xgl_programs = Xgl Xgl_programs = Xgl
bin_PROGRAMS = $(Xgl_programs) bin_PROGRAMS = $(Xgl_programs)

View File

@ -10,6 +10,11 @@ SUBDIRS = \
AM_CFLAGS = \ AM_CFLAGS = \
-I$(srcdir)/.. \ -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@ \ @SERVER_DEFINES@ \
-DHAVE_XGL_CONFIG_H \ -DHAVE_XGL_CONFIG_H \
-DHAVE_DIX_CONFIG_H \ -DHAVE_DIX_CONFIG_H \
@ -19,24 +24,25 @@ noinst_LTLIBRARIES = libxglx.la
libxglx_la_SOURCES = \ libxglx_la_SOURCES = \
xglx.h \ xglx.h \
xglx.c xglx.c \
xglxorg.c
Xglx_DEPENDENCIES = @XGLX_LIBS@ # Xglx_DEPENDENCIES = @XGLX_LIBS@
Xglx_LDFLAGS = -export-dynamic # Xglx_LDFLAGS = -export-dynamic
Xglx_SOURCES = \ # Xglx_SOURCES = \
xglxinit.c \ # xglxinit.c \
$(top_srcdir)/mi/miinitext.c \ # $(top_srcdir)/mi/miinitext.c \
$(top_srcdir)/Xext/dpmsstubs.c \ # $(top_srcdir)/Xext/dpmsstubs.c \
$(top_srcdir)/Xi/stubs.c \ # $(top_srcdir)/Xi/stubs.c \
$(top_srcdir)/fb/fbcmap.c # $(top_srcdir)/fb/fbcmap.c
Xglx_LDADD = \ #Xglx_LDADD = \
libxglx.la \ # libxglx.la \
../libxgl.a \ # ../libxgl.a \
$(XORG_CORE_LIBS) \ # $(XORG_CORE_LIBS) \
$(XGLX_LIBS) \ # $(XGLX_LIBS) \
$(XSERVER_LIBS) \ # $(EXTENSION_LIBS) \
$(EXTENSION_LIBS) \ # $(XGLXMODULES_LIBS) \
$(XGLXMODULES_LIBS) # -lXrandr
Xglx_programs = Xglx #Xglx_programs = Xglx
bin_PROGRAMS = $(Xglx_programs) bin_PROGRAMS = $(Xglx_programs)

View File

@ -1,13 +1,20 @@
if GLX
GLX_LIB = $(top_builddir)/hw/xgl/glxext/libxglglxext.la
endif
AM_CFLAGS = \ AM_CFLAGS = \
-I$(srcdir)/.. \ -I$(srcdir)/.. \
-I$(srcdir)/../.. \ -I$(srcdir)/../.. \
$(XGLXMODULES_CFLAGS) $(XGLXMODULES_CFLAGS)
libxglx_la_DEPENDENCIES = $(GLX_LIB)
libxglx_la_LDFLAGS = -avoid-version libxglx_la_LDFLAGS = -avoid-version
libxglx_la_SOURCES = xglxmodule.c libxglx_la_SOURCES = xglxmodule.c
libxglx_la_LIBADD = \ libxglx_la_LIBADD = \
$(top_builddir)/hw/xgl/glx/libxglx.la \ $(top_builddir)/hw/xgl/glx/libxglx.la \
$(XGLXMODULES_LIBS) $(GLX_LIB) \
$(XGLXMODULES_LIBS) \
-lXrandr
moduledir = @xglmoduledir@ moduledir = @xglmoduledir@

File diff suppressed because it is too large Load Diff

View File

@ -28,6 +28,62 @@
#include "xgl.h" #include "xgl.h"
#ifdef _XSERVER64
#define _XSERVER64_tmp
#undef _XSERVER64
typedef unsigned long XID64;
typedef unsigned long Mask64;
typedef unsigned long Atom64;
typedef unsigned long VisualID64;
typedef unsigned long Time64;
#define XID XID64
#define Mask Mask64
#define Atom Atom64
#define VisualID VisualID64
#define Time Time64
typedef XID Window64;
typedef XID Drawable64;
typedef XID Font64;
typedef XID Pixmap64;
typedef XID Cursor64;
typedef XID Colormap64;
typedef XID GContext64;
typedef XID KeySym64;
#define Window Window64
#define Drawable Drawable64
#define Font Font64
#define Pixmap Pixmap64
#define Cursor Cursor64
#define Colormap Colormap64
#define GContext GContext64
#define KeySym KeySym64
#endif
#define GC XlibGC
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#undef GC
#ifdef _XSERVER64_tmp
#ifndef _XSERVER64
#define _XSERVER64
#endif
#undef _XSERVER64_tmp
#undef XID
#undef Mask
#undef Atom
#undef VisualID
#undef Time
#undef Window
#undef Drawable
#undef Font
#undef Pixmap
#undef Cursor
#undef Colormap
#undef GContext
#undef KeySym
#endif
void void
xglxInitOutput (ScreenInfo *pScreenInfo, xglxInitOutput (ScreenInfo *pScreenInfo,
int argc, int argc,
@ -61,4 +117,22 @@ xglxGiveUp (void);
void void
xglxOsVendorInit (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_ */ #endif /* _XGLX_H_ */

View File

@ -24,19 +24,30 @@
*/ */
#include "xglx.h" #include "xglx.h"
#include "xglglx.h"
xglScreenInfoRec xglScreenInfo = { xglScreenInfoRec xglScreenInfo = {
NULL, 0, 0, 0, 0, NULL, 0, 0, 0, 0, 0,
DEFAULT_GEOMETRY_DATA_TYPE, DEFAULT_GEOMETRY_DATA_TYPE,
DEFAULT_GEOMETRY_USAGE, DEFAULT_GEOMETRY_USAGE,
FALSE, FALSE,
XGL_DEFAULT_PBO_MASK, XGL_DEFAULT_PBO_MASK,
FALSE, 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 #ifdef GLXEXT
static Bool loadGlx = TRUE; static Bool loadGlx = TRUE;
#ifndef NGLXEXTLOG
static char *glxExtLogFile = 0;
#endif
#endif #endif
void void
@ -50,6 +61,18 @@ InitOutput (ScreenInfo *pScreenInfo,
{ {
if (!xglLoadGLXModules ()) if (!xglLoadGLXModules ())
FatalError ("No GLX modules loaded"); FatalError ("No GLX modules loaded");
#ifndef NGLXEXTLOG
if (glxExtLogFile)
{
__xglGLXLogFp = fopen (glxExtLogFile, "w");
if (!__xglGLXLogFp)
perror ("InitOutput");
}
else
__xglGLXLogFp = 0;
#endif
} }
#endif #endif
@ -83,6 +106,11 @@ ddxUseMsg (void)
#ifdef GLXEXT #ifdef GLXEXT
ErrorF ("-noglx don't load glx extension\n"); ErrorF ("-noglx don't load glx extension\n");
#ifndef NGLXEXTLOG
ErrorF ("-glxlog file glx extension log file\n");
#endif
#endif #endif
xglUseMsg (); xglUseMsg ();
@ -103,6 +131,15 @@ ddxProcessArgument (int argc,
loadGlx = FALSE; loadGlx = FALSE;
return 1; return 1;
} }
#ifndef NGLXEXTLOG
else if (!strcmp (argv[i], "-glxlog"))
{
if (++i < argc)
glxExtLogFile = argv[i];
}
#endif
#endif #endif
skip = xglProcessArgument (argc, argv, i); skip = xglProcessArgument (argc, argv, i);
@ -130,6 +167,6 @@ OsVendorInit (void)
xglxOsVendorInit (); xglxOsVendorInit ();
} }
void ddxInitGlobals(void) void ddxInitGlobals()
{ {
} }

676
hw/xgl/glx/xglxorg.c Normal file
View File

@ -0,0 +1,676 @@
/*
* Copyright © 2005 Novell, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies
* and that both that copyright notice and this permission notice
* appear in supporting documentation, and that the name of
* Novell, Inc. not be used in advertising or publicity pertaining to
* distribution of the software without specific, written prior permission.
* Novell, Inc. makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Authors: David Reveman <davidr@novell.com>
* Matthias Hopf <mhopf@suse.de>
*/
#include "xglx.h"
#ifndef NXGLXORG
#include <X11/Xauth.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <ctype.h>
#include <signal.h>
#include <setjmp.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <libgen.h>
typedef void (*sighandler_t) (int);
#define XORG_DIE_TIMEOUT 3
#define XORG_DEV_RANDOM "/dev/urandom"
static char xorgAuthBuf[256];
static char *xorgAuthTempl = "/tmp/.Xgl-auth-XXXXXX";
static char *xorgAuth = NULL;
static char *xorgProgs[] = { "/usr/bin/Xorg", "/usr/X11R6/bin/Xorg" };
static char *xorgProg = NULL;
static char *xorgDisplay = ":93";
static char *xorgTerminate = "-terminate";
static pid_t xorgPid = 0;
static int receivedUsr1 = 0;
static jmp_buf jumpbuf;
static Bool waitAndExit = FALSE;
static char **xorgArgv = 0;
static int nXorgArgv = 0;
typedef struct _xglxArg *xglxArgPtr;
typedef int (*xglxProcessArgumentProc) (xglxArgPtr, int, char **, int);
typedef struct _xglxArg {
xglxProcessArgumentProc processArgument;
const char *name;
const char *usage;
} xglxArgRec;
static int
xglxAddXorgArguments (char **argv,
int n)
{
char **newArgv;
int i;
newArgv = xrealloc (xorgArgv, sizeof (char *) * (nXorgArgv + n));
if (!newArgv)
return 0;
for (i = 0; i < n; i++)
newArgv[nXorgArgv + i] = argv[i];
xorgArgv = newArgv;
nXorgArgv += n;
return n;
}
static int
xglxProcessCommonXorgArgument (xglxArgPtr pArg,
int n,
int argc,
char **argv,
int i)
{
if (strcmp (argv[i], pArg->name) == 0)
{
if (i + n - 1 < argc)
return xglxAddXorgArguments (&argv[i], n);
}
return 0;
}
#define PROCESS_COMMON_XORG_ARGUMENT_IMP(args) \
static int \
xglxProcess ## args ## CommonXorgArgument (xglxArgPtr pArg, \
int argc, \
char **argv, \
int i) \
{ \
return xglxProcessCommonXorgArgument (pArg, args, argc, argv, i); \
}
PROCESS_COMMON_XORG_ARGUMENT_IMP (1)
PROCESS_COMMON_XORG_ARGUMENT_IMP (2)
static int
xglxProcessXorgVTArgument (xglxArgPtr pArg,
int argc,
char **argv,
int i)
{
if (argv[i][0] == 'v' && argv[i][1] == 't' &&
strspn (&argv[i][2], "0123456789") == strlen (&argv[i][2]))
return xglxAddXorgArguments (&argv[i], 1);
return 0;
}
static int
xglxProcessXorgAcArgument (xglxArgPtr pArg,
int argc,
char **argv,
int i)
{
static char *ac = "-ac";
if (strcmp (argv[i], pArg->name) == 0)
{
if (xglxAddXorgArguments (&ac, 1))
return 1;
}
return 0;
}
static int
xglxProcessXorgVersionArgument (xglxArgPtr pArg,
int argc,
char **argv,
int i)
{
static char *version = "-version";
if (strcmp (argv[i], pArg->name) == 0)
{
if (xglxAddXorgArguments (&version, 1))
{
waitAndExit = TRUE;
return 1;
}
}
return 0;
}
static int
xglxProcessXorgProgArgument (xglxArgPtr pArg,
int argc,
char **argv,
int i)
{
if (strcmp (argv[i], pArg->name) == 0)
{
if (i + 1 < argc)
{
xorgProg = argv[i + 1];
return 2;
}
}
return 0;
}
static int
xglxProcessXorgDisplayArgument (xglxArgPtr pArg,
int argc,
char **argv,
int i)
{
if (strcmp (argv[i], pArg->name) == 0)
{
if (i + 1 < argc)
{
xorgDisplay = argv[i + 1];
return 2;
}
}
return 0;
}
static int
xglxProcessXorgWaitExitArgument (xglxArgPtr pArg,
int argc,
char **argv,
int i)
{
if (xglxProcessCommonXorgArgument (pArg, 1, argc, argv, i))
{
waitAndExit = TRUE;
return 1;
}
return 0;
}
#define ARG(processArgument, name, usage) \
{ processArgument, name, usage }
#define XORG_ARG(name, args) \
ARG (xglxProcess ## args ## CommonXorgArgument, name, 0)
#define XORG_UARG(name, usage, args) \
ARG (xglxProcess ## args ## CommonXorgArgument, name, usage)
xglxArgRec xorgUid0Args[] = {
XORG_UARG ("-modulepath", " paths specify the module search path", 2),
XORG_UARG ("-logfile", " file specify a log file name", 2),
ARG (xglxProcessXorgWaitExitArgument, "-configure",
" probe for devices and write an Xorg config")
};
xglxArgRec xorgUidArgs[] = {
XORG_UARG ("-config",
" file specify configuration file, relative to the\n"
" Xorg config search path, "
"only root can use absolute", 2)
};
xglxArgRec xorgArgs[] = {
ARG (xglxProcessXorgWaitExitArgument, "-probeonly",
" probe for devices, then exit"),
ARG (xglxProcessXorgWaitExitArgument, "-scanpci",
" execute the scanpci module and exit"),
XORG_UARG ("-verbose", " [n] verbose startup messages", 2),
XORG_UARG ("-logverbose", " [n] verbose log messages", 2),
XORG_UARG ("-quiet", " minimal startup messages", 1),
XORG_UARG ("-depth", " n set colour depth. Default: 8", 2),
XORG_UARG ("-gamma",
" f set gamma value (0.1 < f < 10.0) "
"Default: 1.0", 2),
XORG_UARG ("-rgamma", " f set gamma value for red phase", 2),
XORG_UARG ("-ggamma", " f set gamma value for green phase",
2),
XORG_UARG ("-bgamma", " f set gamma value for blue phase", 2),
XORG_UARG ("-layout",
" name specify the ServerLayout section name", 2),
XORG_UARG ("-screen",
" name specify the Screen section name", 2),
XORG_UARG ("-keyboard",
" name specify the core keyboard InputDevice name", 2),
XORG_UARG ("-pointer",
" name specify the core pointer InputDevice name", 2),
XORG_UARG ("-nosilk", " disable Silken Mouse", 1),
XORG_UARG ("-disableModInDev",
" disable dynamic modification of input device settings",
1),
XORG_UARG ("-allowMouseOpenFail",
" start server even if the mouse can't be initialized", 1),
XORG_UARG ("-bestRefresh",
" choose modes with the best refresh rate", 1),
XORG_UARG ("-ignoreABI",
" make module ABI mismatches non-fatal", 1),
XORG_UARG ("-isolateDevice",
" bus_id restrict device resets to bus_id (PCI only)", 2),
ARG (xglxProcessXorgVTArgument, "vtXX",
" use the specified VT number"),
XORG_UARG ("-keeptty",
" don't detach controlling tty "
"(for debugging only)", 1),
XORG_UARG ("-novtswitch", " don't immediately switch to new VT",
1),
XORG_UARG ("-sharevts", " share VTs with another X server",
1),
ARG (xglxProcessXorgAcArgument, "-xorgAc",
" disable access control restrictions"),
ARG (xglxProcessXorgProgArgument, "-xorgProgram",
" server program"),
ARG (xglxProcessXorgDisplayArgument, "-xorgDisplay",
" server display"),
ARG (xglxProcessXorgVersionArgument, "-xorgVersion",
" show the server version")
};
xglxArgRec sharedArgs[] = {
XORG_ARG ("-br", 1)
};
void
xglxUseXorgMsg (void)
{
int i;
ErrorF ("\nXorg usage:\n");
if (getuid () == 0)
{
for (i = 0; i < sizeof (xorgUid0Args) / sizeof (xglxArgRec); i++)
ErrorF ("%s%s\n", xorgUid0Args[i].name, xorgUid0Args[i].usage);
}
else
{
for (i = 0; i < sizeof (xorgUidArgs) / sizeof (xglxArgRec); i++)
ErrorF ("%s%s\n", xorgUidArgs[i].name, xorgUidArgs[i].usage);
}
for (i = 0; i < sizeof (xorgArgs) / sizeof (xglxArgRec); i++)
ErrorF ("%s%s\n", xorgArgs[i].name, xorgArgs[i].usage);
}
int
xglxProcessXorgArgument (int argc,
char **argv,
int i)
{
int skip, j;
if (nXorgArgv == 0)
{
if (!xglxAddXorgArguments (&xorgProg, 1))
return 0;
}
if (getuid () == 0)
{
for (j = 0; j < sizeof (xorgUid0Args) / sizeof (xglxArgRec); j++)
{
skip = (*xorgUid0Args[j].processArgument) (&xorgUid0Args[j],
argc, argv, i);
if (skip)
return skip;
}
}
else
{
for (j = 0; j < sizeof (xorgUidArgs) / sizeof (xglxArgRec); j++)
{
skip = (*xorgUidArgs[j].processArgument) (&xorgUidArgs[j],
argc, argv, i);
if (skip)
return skip;
}
}
for (j = 0; j < sizeof (xorgArgs) / sizeof (xorgArgs[0]); j++)
{
skip = (*xorgArgs[j].processArgument) (&xorgArgs[j], argc, argv, i);
if (skip)
return skip;
}
for (j = 0; j < sizeof (sharedArgs) / sizeof (sharedArgs[0]); j++)
{
skip = (*sharedArgs[j].processArgument) (&sharedArgs[j], argc, argv, i);
if (skip)
return 0;
}
return 0;
}
static void
sigAlarm (int sig)
{
ErrorF ("%s won't die, killing it\n", basename (xorgProg));
kill (xorgPid, SIGKILL);
if (xorgPid)
while (waitpid (xorgPid, NULL, 0) == -1 && errno == EINTR);
}
void
xglxAbortXorg (void)
{
sighandler_t oldSigAlarm;
unsigned int oldAlarm;
int status = 0;
char *name;
if (!xorgPid)
return;
name = basename (xorgProg);
oldAlarm = alarm (0);
oldSigAlarm = signal (SIGALRM, sigAlarm);
kill (xorgPid, SIGTERM);
alarm (XORG_DIE_TIMEOUT);
while (waitpid (xorgPid, &status, 0) == -1 && errno == EINTR);
alarm (0);
signal (SIGALRM, oldSigAlarm);
alarm (oldAlarm);
if (WIFEXITED (status))
{
if (WEXITSTATUS (status))
ErrorF ("%s died, exit status %d\n", name, WEXITSTATUS (status));
}
else if (WIFSIGNALED (status))
ErrorF ("%s died, signal %d\n", name, WTERMSIG (status));
else
ErrorF ("%s died, dubious exit\n", name);
if (xorgAuth)
unlink (xorgAuth);
}
static void
sigUsr1Waiting (int sig)
{
signal (sig, sigUsr1Waiting);
receivedUsr1++;
}
static void
sigUsr1Jump (int sig)
{
#ifdef HAVE_SIGPROCMASK
sigset_t set;
#endif
signal (sig, sigUsr1Waiting);
#ifdef HAVE_SIGPROCMASK
sigemptyset (&set);
sigaddset (&set, SIGUSR1);
sigprocmask (SIG_UNBLOCK, &set, NULL);
#endif
longjmp (jumpbuf, 1);
}
#define AUTH_DATA_LEN 16 /* bytes of authorization data */
static Bool
xglxSetupAuth (char *name, int authFd)
{
Xauth auth;
int randomFd;
ssize_t bytes, size;
char authHost[256];
char authData[AUTH_DATA_LEN];
FILE *file;
auth.family = FamilyLocal;
gethostname (authHost, sizeof (authHost));
auth.address = authHost;
auth.address_length = strlen (authHost);
auth.number = strrchr (xorgDisplay, ':');
if (!auth.number)
{
ErrorF ("Bad Xorg display name: %s\n", xorgDisplay);
return FALSE;
}
auth.number++;
auth.number_length = strlen (auth.number);
if (!auth.number_length)
{
ErrorF ("Bad Xorg display name: %s\n", xorgDisplay);
return FALSE;
}
auth.name = "MIT-MAGIC-COOKIE-1";
auth.name_length = strlen (auth.name);
randomFd = open (XORG_DEV_RANDOM, O_RDONLY);
if (randomFd == -1)
{
ErrorF ("Failed to open " XORG_DEV_RANDOM "\n");
return FALSE;
}
bytes = 0;
do {
size = read (randomFd, authData + bytes, AUTH_DATA_LEN - bytes);
if (size <= 0)
break;
bytes += size;
} while (bytes != AUTH_DATA_LEN);
close (randomFd);
if (bytes != AUTH_DATA_LEN)
{
ErrorF ("Failed to read %d random bytes from " XORG_DEV_RANDOM "\n",
AUTH_DATA_LEN);
return FALSE;
}
auth.data = authData;
auth.data_length = AUTH_DATA_LEN;
file = fdopen (authFd, "w");
if (!file)
{
ErrorF ("Failed to open authorization file: %s\n", name);
close (authFd);
return FALSE;
}
XauWriteAuth (file, &auth);
fclose (file);
return TRUE;
}
char *
xglxInitXorg (void)
{
sighandler_t oldSigUsr1;
pid_t pid;
char *name;
char *auth[] = { "-auth", xorgAuthBuf, "-nolisten", "tcp" };
char *saver[] = { "-dpms", "-v", "-s", "0" };
char *endArg = NULL;
int authFd;
int mask;
if (xorgPid)
return xorgDisplay;
if (!xorgProg)
{
struct stat buf;
int i;
for (i = 0; i < sizeof (xorgProgs) / sizeof (char *); i++)
{
if (stat (xorgProgs[i], &buf) == 0)
{
xorgProg = xorgProgs[i];
break;
}
}
if (!xorgProg)
FatalError ("Can't find Xorg executable\n");
}
strcpy (xorgAuthBuf, xorgAuthTempl);
mask = umask (0077);
authFd = mkstemp (xorgAuthBuf);
umask (mask);
if (authFd == -1)
FatalError ("Failed to generate unique authorization file\n");
xorgAuth = xorgAuthBuf;
if (nXorgArgv == 0)
{
if (!xglxAddXorgArguments (&xorgProg, 1))
return 0;
}
else
{
xorgArgv[0] = xorgProg;
}
if (!xglxAddXorgArguments (auth, sizeof (auth) / sizeof (char *)))
return 0;
if (!xglxAddXorgArguments (saver, sizeof (saver) / sizeof (char *)))
return 0;
if (!xglxAddXorgArguments (&xorgDisplay, 1))
return 0;
if (!xglxAddXorgArguments (&xorgTerminate, 1))
return 0;
if (!xglxAddXorgArguments (&endArg, 1))
return 0;
name = basename (xorgProg);
if (!xglxSetupAuth (xorgAuth, authFd))
FatalError ("Failed to set up authorization: %s\n", xorgAuth);
oldSigUsr1 = signal (SIGUSR1, sigUsr1Waiting);
pid = fork ();
switch (pid) {
case -1:
perror ("fork");
FatalError ("fork");
break;
case 0:
signal (SIGUSR1, SIG_IGN);
execv (xorgArgv[0], xorgArgv);
perror (xorgArgv[0]);
exit (2);
break;
default:
xorgPid = pid;
break;
}
for (;;)
{
int status;
signal (SIGUSR1, sigUsr1Waiting);
if (setjmp (jumpbuf) && !waitAndExit)
break;
signal (SIGUSR1, sigUsr1Jump);
if (receivedUsr1 && !waitAndExit)
break;
if (waitpid (xorgPid, &status, 0) != -1)
{
if (WIFEXITED (status))
{
if (waitAndExit)
{
if (WEXITSTATUS (status))
FatalError ("%s died, exit status %d\n", name,
WEXITSTATUS (status));
exit (WEXITSTATUS (status));
}
else
{
FatalError ("%s died, exit status %d\n", name,
WEXITSTATUS (status));
}
}
else if (WIFSIGNALED (status))
FatalError ("%s died, signal %d\n", name, WTERMSIG (status));
else
FatalError ("%s died, dubious exit\n", name);
}
}
signal (SIGUSR1, oldSigUsr1);
setenv ("XAUTHORITY", xorgAuth, 1);
return xorgDisplay;
}
#endif

View File

@ -1,13 +1,21 @@
SUBDIRS = module SUBDIRS = module
INCLUDES = \ AM_CFLAGS = \
@XGL_INCS@ \ @SERVER_DEFINES@ \
@XSERVER_CFLAGS@ -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_libraries = libxglglxext.la
libxglglxext_la_SOURCES = \ libxglglxext_la_SOURCES = \
xglglxext.h \ xglglxext.h \
xglglxext.c xglglxext.c \
xglglxlog.c
noinst_LTLIBRARIES = $(libxglglxext_libraries) noinst_LTLIBRARIES = $(libxglglxext_libraries)

View File

@ -1,6 +1,9 @@
INCLUDES = \ AM_CFLAGS = \
@XGLX_INCS@ \ @SERVER_DEFINES@ \
@XSERVER_CFLAGS@ -DHAVE_XGL_CONFIG_H \
-DHAVE_DIX_CONFIG_H \
$(XGLMODULES_CFLAGS) \
-I$(top_srcdir)/hw/xgl
libglx_la_LDFLAGS = -avoid-version libglx_la_LDFLAGS = -avoid-version
libglx_la_SOURCES = glxmodule.c libglx_la_SOURCES = glxmodule.c
@ -9,11 +12,11 @@ libglx_modules = libglx.la
libglcore_la_LDFLAGS = -avoid-version libglcore_la_LDFLAGS = -avoid-version
libglcore_la_SOURCES = glcoremodule.c 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 libglcore_modules = libglcore.la
moduledir = @MODULEPATH@/xgl moduledir = @XGL_MODULE_PATH@
module_LTLIBRARIES = \ module_LTLIBRARIES = \
$(libglcore_modules) \ $(libglcore_modules) \
$(libglx_modules) $(libglx_modules)

File diff suppressed because it is too large Load Diff

View File

@ -12,11 +12,11 @@
* software for any purpose. It is provided "as is" without express or * software for any purpose. It is provided "as is" without express or
* implied warranty. * 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 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * 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 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
@ -26,11 +26,16 @@
#ifndef _XGL_GLXEXT_H_ #ifndef _XGL_GLXEXT_H_
#define _XGL_GLXEXT_H_ #define _XGL_GLXEXT_H_
#include <xgl-config.h>
#include "scrnintstr.h" #include "scrnintstr.h"
Bool Bool
xglInitVisualConfigs (ScreenPtr pScreen); xglInitVisualConfigs (ScreenPtr pScreen);
#ifndef NGLXEXTLOG
void
xglInitGlxLog (void);
#endif
#endif /* _XGL_GLXEXT_H_ */ #endif /* _XGL_GLXEXT_H_ */

4519
hw/xgl/glxext/xglglxlog.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
/* /*
* Copyright © 2004 David Reveman * Copyright © 2004 David Reveman
* *
* Permission to use, copy, modify, distribute, and sell this software * Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without * and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies * 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 * software for any purpose. It is provided "as is" without express or
* implied warranty. * 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 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * 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 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
@ -28,8 +28,6 @@
#include <xgl-config.h> #include <xgl-config.h>
#include <stdint.h>
#include <stdio.h>
#include <X11/X.h> #include <X11/X.h>
#define NEED_EVENTS #define NEED_EVENTS
#include <X11/Xproto.h> #include <X11/Xproto.h>
@ -44,11 +42,23 @@
#include "dix.h" #include "dix.h"
#include "damage.h" #include "damage.h"
#include "gc.h" #include "gc.h"
#include "micmap.h"
/* I'd like gc.h to provide this */ /* I'd like gc.h to provide this */
typedef struct _GCFuncs *GCFuncsPtr; typedef struct _GCFuncs *GCFuncsPtr;
#ifdef RENDER #ifdef RENDER
#include "mipict.h" #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 #endif
/* For the modules. We should decide what the actual version numbering should /* 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 #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 { typedef struct _xglScreenInfo {
glitz_drawable_t *drawable; glitz_drawable_t *drawable;
unsigned int width; unsigned int depth;
unsigned int height; unsigned int width;
unsigned int widthMm; unsigned int height;
unsigned int heightMm; unsigned int widthMm;
int geometryDataType; unsigned int heightMm;
int geometryUsage; int geometryDataType;
Bool yInverted; int geometryUsage;
int pboMask; Bool yInverted;
Bool lines; int pboMask;
Bool fbo; Bool lines;
xglScreenAccelInfoRec accel;
} xglScreenInfoRec, *xglScreenInfoPtr; } xglScreenInfoRec, *xglScreenInfoPtr;
extern xglScreenInfoRec xglScreenInfo; extern xglScreenInfoRec xglScreenInfo;
@ -82,18 +113,17 @@ typedef struct _xglPixelFormat {
} xglPixelFormatRec, *xglPixelFormatPtr; } xglPixelFormatRec, *xglPixelFormatPtr;
typedef struct _xglVisual { typedef struct _xglVisual {
glitz_drawable_format_t *format; struct _xglVisual *next;
xglPixelFormatPtr pPixel; VisualID vid;
unsigned long visuals; xglPixelFormatPtr pPixel;
Bool pbuffer;
struct {
glitz_drawable_format_t *drawable;
glitz_format_t *surface;
} format;
} xglVisualRec, *xglVisualPtr; } xglVisualRec, *xglVisualPtr;
typedef struct _xglPixmapFormat {
glitz_format_t *format;
xglPixelFormatPtr pPixel;
} xglPixmapFormatRec, *xglPixmapFormatPtr;
extern xglVisualPtr xglVisuals; extern xglVisualPtr xglVisuals;
extern int nxglVisuals;
#define xglAreaAvailable 0 #define xglAreaAvailable 0
#define xglAreaDivided 1 #define xglAreaDivided 1
@ -114,7 +144,7 @@ typedef struct _xglArea {
typedef struct _xglAreaFuncs { typedef struct _xglAreaFuncs {
Bool (*Create) (xglAreaPtr pArea); Bool (*Create) (xglAreaPtr pArea);
Bool (*MoveIn) (xglAreaPtr pArea, Bool (*MoveIn) (xglAreaPtr pArea,
pointer closure); pointer closure);
@ -124,7 +154,7 @@ typedef struct _xglAreaFuncs {
int (*CompareScore) (xglAreaPtr pArea, int (*CompareScore) (xglAreaPtr pArea,
pointer closure1, pointer closure1,
pointer closure2); pointer closure2);
} xglAreaFuncsRec, *xglAreaFuncsPtr; } xglAreaFuncsRec, *xglAreaFuncsPtr;
typedef struct _xglRootArea { typedef struct _xglRootArea {
@ -166,7 +196,7 @@ typedef struct _xglRange {
} xglRangeRec, *xglRangePtr; } xglRangeRec, *xglRangePtr;
typedef struct _xglGlyphTexture { typedef struct _xglGlyphTexture {
glitz_surface_t *mask; PicturePtr pMask;
glitz_pixel_format_t pixel; glitz_pixel_format_t pixel;
glitz_geometry_format_t format; glitz_geometry_format_t format;
int geometryDataType; int geometryDataType;
@ -206,11 +236,18 @@ extern int xglGlyphPrivateIndex;
typedef struct _xglScreen { typedef struct _xglScreen {
xglVisualPtr pVisual; 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_drawable_t *drawable;
glitz_surface_t *surface; glitz_surface_t *surface;
glitz_surface_t *backSurface;
glitz_surface_t *solid;
PixmapPtr pScreenPixmap; PixmapPtr pScreenPixmap;
unsigned long features; unsigned long features;
int geometryUsage; int geometryUsage;
@ -218,22 +255,22 @@ typedef struct _xglScreen {
Bool yInverted; Bool yInverted;
int pboMask; int pboMask;
Bool lines; Bool lines;
Bool fbo;
xglGeometryRec scratchGeometry; xglGeometryRec scratchGeometry;
xglScreenAccelInfoRec accel;
#ifdef RENDER #ifdef RENDER
xglGlyphCacheRec glyphCache[33]; xglGlyphCacheRec glyphCache[33];
PicturePtr pSolidAlpha; PicturePtr pSolidAlpha;
struct _trapInfo { struct _trapInfo {
PicturePtr pMask; PicturePtr pMask;
glitz_surface_t *mask;
glitz_geometry_format_t format; glitz_geometry_format_t format;
} trapInfo; } trapInfo;
#endif #endif
GetImageProcPtr GetImage; GetImageProcPtr GetImage;
GetSpansProcPtr GetSpans; GetSpansProcPtr GetSpans;
CreateWindowProcPtr CreateWindow; CreateWindowProcPtr CreateWindow;
DestroyWindowProcPtr DestroyWindow;
ChangeWindowAttributesProcPtr ChangeWindowAttributes; ChangeWindowAttributesProcPtr ChangeWindowAttributes;
PaintWindowBackgroundProcPtr PaintWindowBackground; PaintWindowBackgroundProcPtr PaintWindowBackground;
PaintWindowBorderProcPtr PaintWindowBorder; PaintWindowBorderProcPtr PaintWindowBorder;
@ -258,16 +295,11 @@ typedef struct _xglScreen {
#endif #endif
BSFuncRec BackingStoreFuncs; BSFuncRec BackingStoreFuncs;
#ifdef GLXEXT
DestroyWindowProcPtr DestroyWindow;
#endif
} xglScreenRec, *xglScreenPtr; } xglScreenRec, *xglScreenPtr;
extern int xglScreenPrivateIndex; extern int xglScreenPrivateIndex;
#define XGL_GET_SCREEN_PRIV(pScreen) \ #define XGL_GET_SCREEN_PRIV(pScreen) \
((xglScreenPtr) (pScreen)->devPrivates[xglScreenPrivateIndex].ptr) ((xglScreenPtr) (pScreen)->devPrivates[xglScreenPrivateIndex].ptr)
#define XGL_SET_SCREEN_PRIV(pScreen, v) \ #define XGL_SET_SCREEN_PRIV(pScreen, v) \
@ -293,17 +325,17 @@ extern int xglScreenPrivateIndex;
#endif #endif
#define xglGCSoftwareDrawableFlag (1L << 0) #define xglGCSoftwareDrawableFlag (1L << 0)
#define xglGCReadOnlyDrawableFlag (1L << 1) #define xglGCBadFunctionFlag (1L << 1)
#define xglGCBadFunctionFlag (1L << 2) #define xglGCPlaneMaskFlag (1L << 2)
#define xglGCPlaneMaskFlag (1L << 3)
typedef struct _xglGC { typedef struct _xglGC {
glitz_color_t fg; glitz_surface_t *fg;
glitz_color_t bg; glitz_surface_t *bg;
glitz_operator_t op; glitz_format_id_t id;
unsigned long flags; glitz_operator_t op;
GCFuncsPtr funcs; unsigned long flags;
GCOpsPtr ops; GCFuncsPtr funcs;
GCOpsPtr ops;
} xglGCRec, *xglGCPtr; } xglGCRec, *xglGCPtr;
extern int xglGCPrivateIndex; extern int xglGCPrivateIndex;
@ -324,7 +356,7 @@ extern int xglGCPrivateIndex;
#define xglPCFillMask (1L << 0) #define xglPCFillMask (1L << 0)
#define xglPCFilterMask (1L << 1) #define xglPCFilterMask (1L << 1)
#define xglPCTransformMask (1L << 2) #define xglPCTransformMask (1L << 2)
#define xglPCComponentAlphaMask (1L << 3) #define xglPCComponentAlphaMask (1L << 3)
#define xglPCDitherMask (1L << 4) #define xglPCDitherMask (1L << 4)
@ -334,22 +366,36 @@ extern int xglGCPrivateIndex;
#define xglPixmapTargetOut 1 #define xglPixmapTargetOut 1
#define xglPixmapTargetIn 2 #define xglPixmapTargetIn 2
#ifdef XV
typedef struct _xglXvPort {
PixmapPtr pPixmap;
PicturePtr pSrc;
PicturePtr pDst;
} xglXvPortRec, *xglXvPortPtr;
#endif
typedef struct _xglPixmap { typedef struct _xglPixmap {
xglPixelFormatPtr pPixel; xglVisualPtr pVisual;
glitz_format_t *format; glitz_surface_t *surface;
glitz_surface_t *surface; glitz_drawable_t *drawable;
glitz_buffer_t *buffer; glitz_buffer_t *buffer;
int target; int target;
Bool acceleratedTile; Bool acceleratedTile;
pointer bits; pointer bits;
int stride; int stride;
DamagePtr pDamage; DamagePtr pDamage;
BoxRec damageBox; BoxRec damageBox;
BoxRec bitBox; RegionRec bitRegion;
Bool allBits; Bool allBits;
unsigned long pictureMask; unsigned long pictureMask;
xglGeometryPtr pGeometry; xglGeometryPtr pGeometry;
int lock;
#ifdef XV
xglXvPortPtr pPortPriv;
#endif
} xglPixmapRec, *xglPixmapPtr; } xglPixmapRec, *xglPixmapPtr;
extern int xglPixmapPrivateIndex; extern int xglPixmapPrivateIndex;
@ -364,7 +410,7 @@ extern int xglPixmapPrivateIndex;
#define XGL_PICTURE_FAILURES(pictureMask) (pictureMask & 0xffff0000) #define XGL_PICTURE_FAILURES(pictureMask) (pictureMask & 0xffff0000)
typedef struct _xglWin { typedef struct _xglWin {
PixmapPtr pPixmap; PixmapPtr pPixmap;
} xglWinRec, *xglWinPtr; } xglWinRec, *xglWinPtr;
extern int xglWinPrivateIndex; extern int xglWinPrivateIndex;
@ -463,28 +509,42 @@ xglInitInput (int argc, char **argv);
void void
xglSetPixmapFormats (ScreenInfo *pScreenInfo); xglSetPixmapFormats (ScreenInfo *pScreenInfo);
void
xglSetRootClip (ScreenPtr pScreen,
Bool enable);
/* xglcmap.c */ /* xglcmap.c */
void void
xglSetVisualTypesAndMasks (ScreenInfo *pScreenInfo, xglSetVisualTypes (int depth,
glitz_drawable_format_t *format, int visuals,
unsigned long visuals); int redSize,
int greenSize,
int blueSize);
Bool
xglHasVisualTypes (xglVisualPtr pVisual,
int depth);
glitz_format_t *
xglFindBestSurfaceFormat (ScreenPtr pScreen,
xglPixelFormatPtr pPixel);
void void
xglInitVisuals (ScreenInfo *pScreenInfo); xglInitVisuals (ScreenPtr pScreen);
xglVisualPtr
xglFindVisualWithDepth (ScreenPtr pScreen,
int depth);
xglVisualPtr
xglFindVisualWithId (ScreenPtr pScreen,
int vid);
void void
xglClearVisualTypes (void); xglClearVisualTypes (void);
void
xglInitPixmapFormats (ScreenPtr pScreen);
void
xglPixelToColor (xglPixelFormatPtr pFormat,
CARD32 pixel,
glitz_color_t *color);
/* xglparse.c */ /* xglparse.c */
@ -680,7 +740,7 @@ extern xglDataTypeInfoRec xglGeometryDataTypes[2];
#define GEOMETRY_ADD_REGION_AT(pScreen, pGeometry, pRegion, offset) \ #define GEOMETRY_ADD_REGION_AT(pScreen, pGeometry, pRegion, offset) \
xglGeometryAddBox (pScreen, pGeometry, \ xglGeometryAddBox (pScreen, pGeometry, \
REGION_RECTS (pRegion), \ REGION_RECTS (pRegion), \
REGION_NUM_RECTS (pRegion), \ REGION_NUM_RECTS (pRegion), \
offset) offset)
#define GEOMETRY_ADD_REGION(pScreen, pGeometry, pRegion) \ #define GEOMETRY_ADD_REGION(pScreen, pGeometry, pRegion) \
@ -792,7 +852,7 @@ xglGetScratchVertexGeometry (ScreenPtr pScreen,
int count); int count);
Bool Bool
xglSetGeometry (xglGeometryPtr pGeometry, xglSetGeometry (xglGeometryPtr pGeometry,
glitz_surface_t *surface); glitz_surface_t *surface);
@ -813,7 +873,7 @@ xglSetGeometry (xglGeometryPtr pGeometry,
PixmapPtr PixmapPtr
xglCreatePixmap (ScreenPtr pScreen, xglCreatePixmap (ScreenPtr pScreen,
int width, int width,
int height, int height,
int depth); int depth);
void void
@ -831,6 +891,10 @@ xglModifyPixmapHeader (PixmapPtr pPixmap,
int devKind, int devKind,
pointer pPixData); pointer pPixData);
void
xglSetPixmapVisual (PixmapPtr pPixmap,
xglVisualPtr pVisual);
RegionPtr RegionPtr
xglPixmapToRegion (PixmapPtr pPixmap); xglPixmapToRegion (PixmapPtr pPixmap);
@ -851,6 +915,14 @@ xglMapPixmapBits (PixmapPtr pPixmap);
Bool Bool
xglUnmapPixmapBits (PixmapPtr pPixmap); xglUnmapPixmapBits (PixmapPtr pPixmap);
Bool
xglCheckPixmapSize (PixmapPtr pPixmap,
xglSizeConstraintPtr pSize);
void
xglEnablePixmapAccel (PixmapPtr pPixmap,
xglAccelInfoPtr pAccel);
/* xglsync.c */ /* xglsync.c */
@ -887,7 +959,7 @@ xglAddCurrentBitDamage (DrawablePtr pDrawable);
Bool Bool
xglSolid (DrawablePtr pDrawable, xglSolid (DrawablePtr pDrawable,
glitz_operator_t op, glitz_operator_t op,
glitz_color_t *color, glitz_surface_t *solid,
xglGeometryPtr pGeometry, xglGeometryPtr pGeometry,
int x, int x,
int y, int y,
@ -960,7 +1032,7 @@ Bool
xglFill (DrawablePtr pDrawable, xglFill (DrawablePtr pDrawable,
GCPtr pGC, GCPtr pGC,
xglGeometryPtr pGeometry, xglGeometryPtr pGeometry,
int x, int x,
int y, int y,
int width, int width,
int height, int height,
@ -975,8 +1047,8 @@ xglFillSpan (DrawablePtr pDrawable,
int *pwidth); int *pwidth);
void void
xglFillRect (DrawablePtr pDrawable, xglFillRect (DrawablePtr pDrawable,
GCPtr pGC, GCPtr pGC,
int nrect, int nrect,
xRectangle *prect); xRectangle *prect);
@ -989,7 +1061,7 @@ xglFillLine (DrawablePtr pDrawable,
Bool Bool
xglFillSegment (DrawablePtr pDrawable, xglFillSegment (DrawablePtr pDrawable,
GCPtr pGC, GCPtr pGC,
int nsegInit, int nsegInit,
xSegment *pSegInit); xSegment *pSegInit);
@ -1008,13 +1080,16 @@ xglFillGlyph (DrawablePtr pDrawable,
Bool Bool
xglCreateWindow (WindowPtr pWin); xglCreateWindow (WindowPtr pWin);
Bool
xglDestroyWindow (WindowPtr pWin);
Bool Bool
xglChangeWindowAttributes (WindowPtr pWin, xglChangeWindowAttributes (WindowPtr pWin,
unsigned long mask); unsigned long mask);
void void
xglCopyWindow (WindowPtr pWin, xglCopyWindow (WindowPtr pWin,
DDXPointRec ptOldOrg, DDXPointRec ptOldOrg,
RegionPtr prgnSrc); RegionPtr prgnSrc);
void void
@ -1027,6 +1102,13 @@ xglPaintWindowBorder (WindowPtr pWin,
RegionPtr pRegion, RegionPtr pRegion,
int what); int what);
PixmapPtr
xglGetWindowPixmap (WindowPtr pWin);
void
xglSetWindowPixmap (WindowPtr pWin,
PixmapPtr pPixmap);
/* xglbstore.c */ /* xglbstore.c */
@ -1058,11 +1140,11 @@ xglGetImage (DrawablePtr pDrawable,
char *d); char *d);
void void
xglGetSpans (DrawablePtr pDrawable, xglGetSpans (DrawablePtr pDrawable,
int wMax, int wMax,
DDXPointPtr ppt, DDXPointPtr ppt,
int *pwidth, int *pwidth,
int nspans, int nspans,
char *pchardstStart); char *pchardstStart);
@ -1071,6 +1153,9 @@ xglGetSpans (DrawablePtr pDrawable,
Bool Bool
xglCreateGC (GCPtr pGC); xglCreateGC (GCPtr pGC);
void
xglDestroyGC (GCPtr pGC);
void void
xglValidateGC (GCPtr pGC, xglValidateGC (GCPtr pGC,
unsigned long changes, unsigned long changes,
@ -1144,13 +1229,13 @@ xglPolylines (DrawablePtr pDrawable,
void void
xglPolySegment (DrawablePtr pDrawable, xglPolySegment (DrawablePtr pDrawable,
GCPtr pGC, GCPtr pGC,
int nsegInit, int nsegInit,
xSegment *pSegInit); xSegment *pSegInit);
void void
xglPolyArc (DrawablePtr pDrawable, xglPolyArc (DrawablePtr pDrawable,
GCPtr pGC, GCPtr pGC,
int narcs, int narcs,
xArc *pArcs); xArc *pArcs);
@ -1162,7 +1247,7 @@ xglPolyFillRect (DrawablePtr pDrawable,
void void
xglPolyFillArc (DrawablePtr pDrawable, xglPolyFillArc (DrawablePtr pDrawable,
GCPtr pGC, GCPtr pGC,
int narcs, int narcs,
xArc *pArcs); xArc *pArcs);
@ -1217,25 +1302,6 @@ xglShmPutImage (DrawablePtr pDrawable,
#ifdef RENDER #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 */ /* xglpict.c */
void void
@ -1273,8 +1339,18 @@ xglChangePictureFilter (PicturePtr pPicture,
xFixed *params, xFixed *params,
int nparams); int nparams);
void PicturePtr
xglUpdatePicture (PicturePtr pPicture); xglCreateDevicePicture (pointer data);
Bool
xglSyncPicture (ScreenPtr pScreen,
PicturePtr pPicture,
INT16 x,
INT16 y,
CARD16 width,
CARD16 height,
INT16 *xOff,
INT16 *yOff);
Bool Bool
xglPictureInit (ScreenPtr pScreen); xglPictureInit (ScreenPtr pScreen);
@ -1283,6 +1359,25 @@ void
xglPictureClipExtents (PicturePtr pPicture, xglPictureClipExtents (PicturePtr pPicture,
BoxPtr extents); 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 */ /* xglglyph.c */
Bool Bool
@ -1344,7 +1439,8 @@ typedef struct _xglSymbol {
} xglSymbolRec, *xglSymbolPtr; } xglSymbolRec, *xglSymbolPtr;
void * void *
xglLoadModule (const char *name); xglLoadModule (const char *name,
int flag);
void void
xglUnloadModule (void *handle); xglUnloadModule (void *handle);
@ -1356,18 +1452,17 @@ xglLookupSymbols (void *handle,
#endif #endif
#ifdef GLXEXT
/* xglglx.c */ /* xglxv.c */
#ifdef XV
Bool Bool
xglLoadGLXModules (void); xglXvScreenInit (ScreenPtr pScreen);
void
xglUnloadGLXModules (void);
#endif #endif
/* xglhash.c */ /* xglhash.c */
typedef struct _xglHashTable *xglHashTablePtr; typedef struct _xglHashTable *xglHashTablePtr;

View File

@ -1,6 +1,6 @@
/* /*
* Copyright © 2005 Novell, Inc. * Copyright © 2005 Novell, Inc.
* *
* Permission to use, copy, modify, distribute, and sell this software * Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without * and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies * 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 * software for any purpose. It is provided "as is" without express or
* implied warranty. * 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 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * 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 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
@ -31,7 +31,7 @@ xglAreaMoveIn (xglAreaPtr pArea,
{ {
pArea->closure = closure; pArea->closure = closure;
pArea->state = xglAreaOccupied; pArea->state = xglAreaOccupied;
return (*pArea->pRoot->funcs->MoveIn) (pArea, closure); return (*pArea->pRoot->funcs->MoveIn) (pArea, closure);
} }
@ -54,7 +54,7 @@ xglAreaCreate (xglRootAreaPtr pRoot,
{ {
xglAreaPtr pArea; xglAreaPtr pArea;
int n = 4; int n = 4;
pArea = xalloc (sizeof (xglAreaRec) + pRoot->devPrivateSize); pArea = xalloc (sizeof (xglAreaRec) + pRoot->devPrivateSize);
if (!pArea) if (!pArea)
return NULL; return NULL;
@ -67,7 +67,7 @@ xglAreaCreate (xglRootAreaPtr pRoot,
pArea->pRoot = pRoot; pArea->pRoot = pRoot;
pArea->closure = (pointer) 0; pArea->closure = (pointer) 0;
pArea->state = xglAreaAvailable; pArea->state = xglAreaAvailable;
while (n--) while (n--)
pArea->pArea[n] = NULL; pArea->pArea[n] = NULL;
@ -81,13 +81,13 @@ xglAreaCreate (xglRootAreaPtr pRoot,
free (pArea); free (pArea);
return NULL; return NULL;
} }
return pArea; return pArea;
} }
static void static void
xglAreaDestroy (xglAreaPtr pArea) xglAreaDestroy (xglAreaPtr pArea)
{ {
if (!pArea) if (!pArea)
return; return;
@ -98,11 +98,11 @@ xglAreaDestroy (xglAreaPtr pArea)
else else
{ {
int n = 4; int n = 4;
while (n--) while (n--)
xglAreaDestroy (pArea->pArea[n]); xglAreaDestroy (pArea->pArea[n]);
} }
xfree (pArea); xfree (pArea);
} }
@ -111,7 +111,7 @@ xglAreaGetTopScoredSubArea (xglAreaPtr pArea)
{ {
if (!pArea) if (!pArea)
return NULL; return NULL;
switch (pArea->state) { switch (pArea->state) {
case xglAreaOccupied: case xglAreaOccupied:
return pArea; return pArea;
@ -120,7 +120,7 @@ xglAreaGetTopScoredSubArea (xglAreaPtr pArea)
case xglAreaDivided: { case xglAreaDivided: {
xglAreaPtr tmp, top = NULL; xglAreaPtr tmp, top = NULL;
int i; int i;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
tmp = xglAreaGetTopScoredSubArea (pArea->pArea[i]); tmp = xglAreaGetTopScoredSubArea (pArea->pArea[i]);
@ -139,7 +139,7 @@ xglAreaGetTopScoredSubArea (xglAreaPtr pArea)
return top; return top;
} }
} }
return NULL; return NULL;
} }
@ -161,11 +161,11 @@ xglAreaFind (xglAreaPtr pArea,
pArea->closure, pArea->closure,
closure) >= 0) closure) >= 0)
return FALSE; return FALSE;
xglAreaMoveOut (pArea); xglAreaMoveOut (pArea);
} else } else
return FALSE; return FALSE;
/* fall-through */ /* fall-through */
case xglAreaAvailable: case xglAreaAvailable:
{ {
@ -178,15 +178,15 @@ xglAreaFind (xglAreaPtr pArea,
else else
{ {
int dx[4], dy[4], w[4], h[4], i; int dx[4], dy[4], w[4], h[4], i;
dx[0] = dx[2] = dy[0] = dy[1] = 0; dx[0] = dx[2] = dy[0] = dy[1] = 0;
w[0] = w[2] = dx[1] = dx[3] = width; w[0] = w[2] = dx[1] = dx[3] = width;
h[0] = h[1] = dy[2] = dy[3] = height; h[0] = h[1] = dy[2] = dy[3] = height;
w[1] = w[3] = pArea->width - width; w[1] = w[3] = pArea->width - width;
h[2] = h[3] = pArea->height - height; h[2] = h[3] = pArea->height - height;
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
{ {
if (w[i]) if (w[i])
@ -210,7 +210,7 @@ xglAreaFind (xglAreaPtr pArea,
} }
pArea->state = xglAreaDivided; pArea->state = xglAreaDivided;
if (xglAreaFind (pArea->pArea[0], width, height, kickOut, closure)) if (xglAreaFind (pArea->pArea[0], width, height, kickOut, closure))
return TRUE; return TRUE;
} }
@ -230,7 +230,7 @@ xglAreaFind (xglAreaPtr pArea,
if (xglFindArea (pArea->pArea[i], width, height, kickOut, if (xglFindArea (pArea->pArea[i], width, height, kickOut,
closure)) closure))
return TRUE; return TRUE;
rejected = TRUE; rejected = TRUE;
} }
} }
@ -257,12 +257,12 @@ xglAreaFind (xglAreaPtr pArea,
xglAreaDestroy (pArea->pArea[i]); xglAreaDestroy (pArea->pArea[i]);
pArea->pArea[i] = NULL; pArea->pArea[i] = NULL;
} }
pArea->closure = (pointer) 0; pArea->closure = (pointer) 0;
pArea->state = xglAreaAvailable; pArea->state = xglAreaAvailable;
if (xglFindArea (pArea, width, height, TRUE, closure)) if (xglFindArea (pArea, width, height, TRUE, closure))
return TRUE; return TRUE;
} break; } break;
} }
@ -286,7 +286,7 @@ xglRootAreaInit (xglRootAreaPtr pRoot,
pRoot->pArea = xglAreaCreate (pRoot, 0, 0, 0, width, height); pRoot->pArea = xglAreaCreate (pRoot, 0, 0, 0, width, height);
if (!pRoot->pArea) if (!pRoot->pArea)
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
@ -298,7 +298,7 @@ xglRootAreaFini (xglRootAreaPtr pRoot)
void void
xglLeaveArea (xglAreaPtr pArea) xglLeaveArea (xglAreaPtr pArea)
{ {
xglAreaMoveOut (pArea); xglAreaMoveOut (pArea);
} }

View File

@ -1,6 +1,6 @@
/* /*
* Copyright © 2004 David Reveman * Copyright © 2004 David Reveman
* *
* Permission to use, copy, modify, distribute, and sell this software * Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without * and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies * 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 * software for any purpose. It is provided "as is" without express or
* implied warranty. * 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 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * 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 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
@ -69,12 +69,12 @@ xglSaveAreas (PixmapPtr pPixmap,
box.y1 += yorg; box.y1 += yorg;
box.x2 += xorg; box.x2 += xorg;
box.y2 += yorg; box.y2 += yorg;
if (!xglSyncBits (&pWin->drawable, &box)) if (!xglSyncBits (&pWin->drawable, &box))
FatalError (XGL_SW_FAILURE_STRING); FatalError (XGL_SW_FAILURE_STRING);
XGL_BSTORE_FALLBACK_PROLOGUE (&pPixmap->drawable, XGL_BSTORE_FALLBACK_PROLOGUE (&pPixmap->drawable,
BackingStoreFuncs.RestoreAreas); BackingStoreFuncs.SaveAreas);
(*pScreen->BackingStoreFuncs.SaveAreas) (pPixmap, prgnSave, (*pScreen->BackingStoreFuncs.SaveAreas) (pPixmap, prgnSave,
xorg, yorg, pWin); xorg, yorg, pWin);
XGL_BSTORE_FALLBACK_EPILOGUE (&pPixmap->drawable, XGL_BSTORE_FALLBACK_EPILOGUE (&pPixmap->drawable,
@ -111,10 +111,10 @@ xglRestoreAreas (PixmapPtr pPixmap,
box.y1 = pExt->y1 - yorg; box.y1 = pExt->y1 - yorg;
box.x2 = pExt->x2 - xorg; box.x2 = pExt->x2 - xorg;
box.y2 = pExt->y2 - yorg; box.y2 = pExt->y2 - yorg;
if (!xglSyncBits (&pPixmap->drawable, &box)) if (!xglSyncBits (&pPixmap->drawable, &box))
FatalError (XGL_SW_FAILURE_STRING); FatalError (XGL_SW_FAILURE_STRING);
XGL_BSTORE_FALLBACK_PROLOGUE (&pWin->drawable, XGL_BSTORE_FALLBACK_PROLOGUE (&pWin->drawable,
BackingStoreFuncs.RestoreAreas); BackingStoreFuncs.RestoreAreas);
(*pScreen->BackingStoreFuncs.RestoreAreas) (pPixmap, prgnRestore, (*pScreen->BackingStoreFuncs.RestoreAreas) (pPixmap, prgnRestore,

View File

@ -1,6 +1,6 @@
/* /*
* Copyright © 2004 David Reveman * Copyright © 2004 David Reveman
* *
* Permission to use, copy, modify, distribute, and sell this software * Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without * and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies * 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 * software for any purpose. It is provided "as is" without express or
* implied warranty. * 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 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * 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 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
* Author: David Reveman <davidr@novell.com> * Author: David Reveman <davidr@novell.com>
*/ */
#include <stdint.h>
#include "xgl.h" #include "xgl.h"
#include "colormapst.h" #include "colormapst.h"
#include "micmap.h" #include "micmap.h"
@ -81,225 +80,387 @@ static xglPixelFormatRec xglPixelFormats[] = {
#define NUM_XGL_PIXEL_FORMATS \ #define NUM_XGL_PIXEL_FORMATS \
(sizeof (xglPixelFormats) / sizeof (xglPixelFormats[0])) (sizeof (xglPixelFormats) / sizeof (xglPixelFormats[0]))
xglVisualPtr xglVisuals = NULL; xglVisualPtr xglVisuals = NULL;
int nxglVisuals = 0;
xglVisualPtr xglPbufferVisuals = NULL; void
int nxglPbufferVisuals = 0; xglSetVisualTypes (int depth,
int visuals,
static xglPixelFormatPtr int redSize,
xglFindPixelFormat (glitz_drawable_format_t *format, int greenSize,
int visuals) int blueSize)
{ {
glitz_color_format_t *color; xglPixelFormatPtr pBestFormat = 0;
int depth, i; int i, rs, gs, bs, diff, bestDiff = 0;
color = &format->color;
depth = color->red_size + color->green_size + color->blue_size;
if (!visuals)
depth += color->alpha_size;
for (i = 0; i < NUM_XGL_PIXEL_FORMATS; i++) for (i = 0; i < NUM_XGL_PIXEL_FORMATS; i++)
{ {
if (xglPixelFormats[i].depth == depth) if (xglPixelFormats[i].depth == depth)
{ {
xglPixelFormatPtr pPixel; if (visuals)
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)
{ {
rs = Ones (xglPixelFormats[i].masks.red_mask);
if (visuals) gs = Ones (xglPixelFormats[i].masks.green_mask);
return pPixel; bs = Ones (xglPixelFormats[i].masks.blue_mask);
if (Ones (pPixel->masks.alpha_mask) == color->alpha_size) if (redSize >= rs &&
return pPixel; greenSize >= gs &&
} blueSize >= bs)
}
}
return NULL;
}
void
xglSetVisualTypesAndMasks (ScreenInfo *pScreenInfo,
glitz_drawable_format_t *format,
unsigned long visuals)
{
xglPixelFormatPtr pPixelFormat;
pPixelFormat = xglFindPixelFormat (format, visuals);
if (pPixelFormat)
{
if (visuals)
{
xglVisuals = xrealloc (xglVisuals,
(nxglVisuals + 1) * sizeof (xglVisualRec));
if (xglVisuals)
{
xglVisuals[nxglVisuals].format = format;
xglVisuals[nxglVisuals].pPixel = pPixelFormat;
xglVisuals[nxglVisuals].visuals = visuals;
nxglVisuals++;
}
}
}
}
void
xglInitVisuals (ScreenInfo *pScreenInfo)
{
int i, j;
for (i = 0; i < pScreenInfo->numPixmapFormats; 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++)
{
if (pScreenInfo->formats[i].depth == xglVisuals[j].pPixel->depth)
{
visuals = xglVisuals[j].visuals;
bitsPerRGB = xglVisuals[j].pPixel->bitsPerRGB;
rm = xglVisuals[j].pPixel->masks.red_mask;
gm = xglVisuals[j].pPixel->masks.green_mask;
bm = xglVisuals[j].pPixel->masks.blue_mask;
fbSetVisualTypesAndMasks (pScreenInfo->formats[i].depth,
visuals, bitsPerRGB,
rm, gm, bm);
}
}
if (!visuals)
{
for (j = 0; j < NUM_XGL_PIXEL_FORMATS; j++)
{
if (pScreenInfo->formats[i].depth == xglPixelFormats[j].depth)
{ {
bitsPerRGB = xglPixelFormats[j].bitsPerRGB; diff = (redSize - rs) + (greenSize - gs) + (blueSize - bs);
if (pBestFormat)
rm = xglPixelFormats[j].masks.red_mask; {
gm = xglPixelFormats[j].masks.green_mask; if (diff < bestDiff)
bm = xglPixelFormats[j].masks.blue_mask; {
break; pBestFormat = &xglPixelFormats[i];
bestDiff = diff;
}
}
else
{
pBestFormat = &xglPixelFormats[i];
bestDiff = diff;
}
} }
} }
else
fbSetVisualTypesAndMasks (pScreenInfo->formats[i].depth, {
visuals, bitsPerRGB, pBestFormat = &xglPixelFormats[i];
rm, gm, bm); break;
}
} }
} }
if (pBestFormat)
{
xglVisualPtr new, *prev, v;
unsigned int bitsPerRGB;
Pixel rm, gm, bm;
new = xalloc (sizeof (xglVisualRec));
if (!new)
return;
new->next = 0;
new->format.surface = 0;
new->format.drawable = 0;
new->pPixel = pBestFormat;
new->vid = 0;
bitsPerRGB = pBestFormat->bitsPerRGB;
rm = pBestFormat->masks.red_mask;
gm = pBestFormat->masks.green_mask;
bm = pBestFormat->masks.blue_mask;
fbSetVisualTypesAndMasks (depth, visuals, bitsPerRGB, rm, gm, bm);
for (prev = &xglVisuals; (v = *prev); prev = &v->next);
*prev = new;
}
else
{
fbSetVisualTypesAndMasks (depth, 0, 0, 0, 0, 0);
}
}
Bool
xglHasVisualTypes (xglVisualPtr pVisual,
int depth)
{
xglVisualPtr v;
for (v = pVisual; v; v = v->next)
if (v->pPixel->depth == depth)
return TRUE;
return FALSE;
}
glitz_format_t *
xglFindBestSurfaceFormat (ScreenPtr pScreen,
xglPixelFormatPtr pPixel)
{
glitz_format_t templ, *format, *best = 0;
unsigned int mask;
unsigned short rs, gs, bs, as;
int i = 0;
XGL_SCREEN_PRIV (pScreen);
rs = Ones (pPixel->masks.red_mask);
gs = Ones (pPixel->masks.green_mask);
bs = Ones (pPixel->masks.blue_mask);
as = Ones (pPixel->masks.alpha_mask);
templ.color.fourcc = GLITZ_FOURCC_RGB;
mask = GLITZ_FORMAT_FOURCC_MASK;
do {
format = glitz_find_format (pScreenPriv->drawable, mask, &templ, i++);
if (format)
{
if (format->color.red_size >= rs &&
format->color.green_size >= gs &&
format->color.blue_size >= bs &&
format->color.alpha_size >= as)
{
if (best)
{
if (((format->color.red_size - rs) +
(format->color.green_size - gs) +
(format->color.blue_size - bs)) <
((best->color.red_size - rs) +
(best->color.green_size - gs) +
(best->color.blue_size - bs)))
best = format;
}
else
{
best = format;
}
}
}
} while (format);
return best;
}
static Bool
xglInitVisual (ScreenPtr pScreen,
xglVisualPtr pVisual,
xglPixelFormatPtr pPixel,
VisualID vid)
{
glitz_format_t *format;
XGL_SCREEN_PRIV (pScreen);
format = xglFindBestSurfaceFormat (pScreen, pPixel);
if (format)
{
glitz_drawable_format_t templ;
unsigned long mask;
templ.color = format->color;
templ.depth_size = 0;
templ.stencil_size = 0;
templ.doublebuffer = 0;
templ.samples = 1;
mask =
GLITZ_FORMAT_FOURCC_MASK |
GLITZ_FORMAT_RED_SIZE_MASK |
GLITZ_FORMAT_GREEN_SIZE_MASK |
GLITZ_FORMAT_BLUE_SIZE_MASK |
GLITZ_FORMAT_ALPHA_SIZE_MASK |
GLITZ_FORMAT_DEPTH_SIZE_MASK |
GLITZ_FORMAT_STENCIL_SIZE_MASK |
GLITZ_FORMAT_DOUBLEBUFFER_MASK |
GLITZ_FORMAT_SAMPLES_MASK;
pVisual->next = 0;
pVisual->vid = vid;
pVisual->pPixel = pPixel;
pVisual->pbuffer = FALSE;
pVisual->format.surface = format;
pVisual->format.drawable =
glitz_find_drawable_format (pScreenPriv->drawable,
mask, &templ, 0);
return TRUE;
}
return FALSE;
}
static Bool
xglInitPbufferVisual (ScreenPtr pScreen,
xglVisualPtr pVisual,
xglPixelFormatPtr pPixel,
VisualID vid)
{
glitz_format_t *format;
XGL_SCREEN_PRIV (pScreen);
format = xglFindBestSurfaceFormat (pScreen, pPixel);
if (format)
{
glitz_drawable_format_t templ, *screenFormat;
unsigned long mask;
/* use same drawable format as screen for pbuffers */
screenFormat = glitz_drawable_get_format (pScreenPriv->drawable);
templ.id = screenFormat->id;
templ.color = format->color;
templ.samples = 1;
mask =
GLITZ_FORMAT_ID_MASK |
GLITZ_FORMAT_FOURCC_MASK |
GLITZ_FORMAT_RED_SIZE_MASK |
GLITZ_FORMAT_GREEN_SIZE_MASK |
GLITZ_FORMAT_BLUE_SIZE_MASK |
GLITZ_FORMAT_SAMPLES_MASK;
pVisual->next = 0;
pVisual->vid = vid;
pVisual->pPixel = pPixel;
pVisual->pbuffer = TRUE;
pVisual->format.surface = format;
pVisual->format.drawable =
glitz_find_pbuffer_format (pScreenPriv->drawable,
mask, &templ, 0);
if (pVisual->format.drawable)
return TRUE;
}
return FALSE;
}
void
xglInitVisuals (ScreenPtr pScreen)
{
xglVisualPtr pVisual, v, new, *prev;
int i;
XGL_SCREEN_PRIV (pScreen);
for (i = 0; i < pScreen->numVisuals; i++)
{
for (pVisual = xglVisuals; pVisual; pVisual = pVisual->next)
if (pVisual->pPixel->depth == pScreen->visuals[i].nplanes)
break;
if (pVisual)
{
new = xalloc (sizeof (xglVisualRec));
if (new)
{
if (xglInitVisual (pScreen, new, pVisual->pPixel,
pScreen->visuals[i].vid))
{
new->next = 0;
prev = &pScreenPriv->pVisual;
while ((v = *prev))
prev = &v->next;
*prev = new;
}
else
{
xfree (new);
}
}
new = xalloc (sizeof (xglVisualRec));
if (new)
{
if (xglInitPbufferVisual (pScreen, new, pVisual->pPixel,
pScreen->visuals[i].vid))
{
new->next = 0;
prev = &pScreenPriv->pVisual;
while ((v = *prev))
prev = &v->next;
*prev = new;
}
else
{
xfree (new);
}
}
}
}
/* Add additional Xgl visuals for pixmap formats */
for (i = 0; i < screenInfo.numPixmapFormats; i++)
{
if (!xglHasVisualTypes (pScreenPriv->pVisual,
screenInfo.formats[i].depth))
{
for (v = xglVisuals; v; v = v->next)
if (v->pPixel->depth == screenInfo.formats[i].depth)
break;
if (v)
{
new = xalloc (sizeof (xglVisualRec));
if (new)
{
if (xglInitVisual (pScreen, new, v->pPixel, 0))
{
new->next = 0;
prev = &pScreenPriv->pVisual;
while ((v = *prev))
prev = &v->next;
*prev = new;
}
else
{
xfree (new);
}
}
}
}
}
}
xglVisualPtr
xglFindVisualWithDepth (ScreenPtr pScreen,
int depth)
{
xglVisualPtr v;
XGL_SCREEN_PRIV (pScreen);
for (v = pScreenPriv->pVisual; v; v = v->next)
{
if (v->pPixel->depth == depth)
return v;
}
return 0;
}
xglVisualPtr
xglFindVisualWithId (ScreenPtr pScreen,
int vid)
{
xglVisualPtr v;
XGL_SCREEN_PRIV (pScreen);
for (v = pScreenPriv->pVisual; v; v = v->next)
{
if (v->vid == vid)
return v;
}
return 0;
} }
void void
xglClearVisualTypes (void) xglClearVisualTypes (void)
{ {
nxglVisuals = 0; xglVisualPtr v;
nxglPbufferVisuals = 0;
if (xglVisuals) while (xglVisuals)
xfree (xglVisuals); {
v = xglVisuals;
if (xglPbufferVisuals) xglVisuals = v->next;
xfree (xglPbufferVisuals); xfree (v);
}
xglVisuals = NULL;
xglPbufferVisuals = NULL;
miClearVisualTypes (); miClearVisualTypes ();
} }
void
xglInitPixmapFormats (ScreenPtr pScreen)
{
glitz_format_t *format, **best;
int i, j;
XGL_SCREEN_PRIV (pScreen);
for (i = 0; i < 33; i++)
{
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);
}
}
}
}
#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)
void
xglPixelToColor (xglPixelFormatPtr pFormat,
CARD32 pixel,
glitz_color_t *color)
{
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;
}

View File

@ -1,6 +1,6 @@
/* /*
* Copyright © 2004 David Reveman * Copyright © 2004 David Reveman
* *
* Permission to use, copy, modify, distribute, and sell this software * Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without * and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies * 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 * software for any purpose. It is provided "as is" without express or
* implied warranty. * 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 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * 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 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * 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_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 Bool
xglComp (CARD8 op, xglCompositeGeneral (CARD8 op,
PicturePtr pSrc, PicturePtr pSrc,
PicturePtr pMask, PicturePtr pMask,
PicturePtr pDst, PicturePtr pDst,
INT16 xSrc, xglGeometryPtr pGeometry,
INT16 ySrc, INT16 xSrc,
INT16 xMask, INT16 ySrc,
INT16 yMask, INT16 xMask,
INT16 xDst, INT16 yMask,
INT16 yDst, INT16 xDst,
CARD16 width, INT16 yDst,
CARD16 height, CARD16 width,
xglGeometryPtr pGeometry, CARD16 height)
glitz_surface_t *mask)
{ {
ScreenPtr pScreen = pDst->pDrawable->pScreen; ScreenPtr pScreen = pDst->pDrawable->pScreen;
xglPixmapPtr pSrcPriv; INT16 xOff, yOff;
glitz_surface_t *src, *dst; glitz_surface_t *src, *mask = NULL, *dst;
int dstXoff, dstYoff; int dstXoff, dstYoff;
RegionRec region; RegionRec region;
BoxPtr pBox; BoxPtr pBox, pExt;
int nBox; int nBox;
if (pDst->alphaMap) if (pDst->alphaMap)
return FALSE; return FALSE;
if (op >= NUM_XGL_OPERATORS) if (op >= NUM_XGL_OPERATORS)
return FALSE; return FALSE;
if (pSrc->pSourcePict) if (pSrc->pDrawable)
return FALSE; {
if (pSrc->pDrawable->type != DRAWABLE_PIXMAP)
return FALSE;
if (pSrc->pDrawable->type != DRAWABLE_PIXMAP) if (pSrc->pDrawable->bitsPerPixel == 1)
return FALSE; return FALSE;
}
if (pSrc->pDrawable->bitsPerPixel == 1)
return FALSE;
if (pMask) if (pMask)
{ {
if (pMask->pSourcePict) if (pMask->pDrawable)
return FALSE; {
if (pMask->pDrawable->type != DRAWABLE_PIXMAP) if (pMask->pDrawable->type != DRAWABLE_PIXMAP)
return FALSE; return FALSE;
if (pSrc->pDrawable == pMask->pDrawable && pSrc != pMask) if (pSrc->pDrawable == pMask->pDrawable && pSrc != pMask)
return FALSE; return FALSE;
}
} }
if (!xglPrepareTarget (pDst->pDrawable))
return FALSE;
if (!miComputeCompositeRegion (&region, pSrc, pMask, pDst, if (!miComputeCompositeRegion (&region, pSrc, pMask, pDst,
xSrc, ySrc, xMask, yMask, xSrc, ySrc, xMask, yMask,
xDst, yDst, width, height)) xDst, yDst, width, height))
@ -105,33 +113,30 @@ xglComp (CARD8 op,
pBox = REGION_RECTS (&region); pBox = REGION_RECTS (&region);
nBox = REGION_NUM_RECTS (&region); nBox = REGION_NUM_RECTS (&region);
pExt = REGION_EXTENTS (pScreen, &region);
if (!xglPrepareTarget (pDst->pDrawable))
{
REGION_UNINIT (pScreen, &region);
return FALSE;
}
XGL_GET_DRAWABLE (pDst->pDrawable, dst, dstXoff, dstYoff); 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, &region); REGION_UNINIT (pScreen, &region);
return FALSE; 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) if (pMask)
{ {
xglPixmapPtr pMaskPriv;
/* bitmap as mask */ /* bitmap as mask */
if (pMask->pDrawable->bitsPerPixel == 1) if (pMask->pDrawable && pMask->pDrawable->bitsPerPixel == 1)
{ {
if (pGeometry) if (pGeometry)
{ {
@ -139,10 +144,9 @@ xglComp (CARD8 op,
return FALSE; return FALSE;
} }
pGeometry = pGeometry = xglPixmapToGeometry ((PixmapPtr) pMask->pDrawable,
xglPixmapToGeometry ((PixmapPtr) pMask->pDrawable, xDst - xMask,
xDst - xMask, yDst - yMask);
yDst - yMask);
if (!pGeometry) if (!pGeometry)
{ {
REGION_UNINIT (pScreen, &region); REGION_UNINIT (pScreen, &region);
@ -151,17 +155,21 @@ xglComp (CARD8 op,
} }
else 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, &region); REGION_UNINIT (pScreen, &region);
return FALSE; return FALSE;
} }
pMaskPriv = XGL_GET_PIXMAP_PRIV ((PixmapPtr) pMask->pDrawable); xMask -= xOff;
if (XGL_PICTURE_CHANGES (pMaskPriv->pictureMask)) yMask -= yOff;
xglUpdatePicture (pMask);
XGL_GET_SOURCE_PICTURE (pMask, mask);
mask = pMaskPriv->surface;
} }
} }
@ -169,10 +177,12 @@ xglComp (CARD8 op,
{ {
if (!pSrc->transform && pSrc->filter != PictFilterConvolution) if (!pSrc->transform && pSrc->filter != PictFilterConvolution)
{ {
if (pSrc->repeat) if (pSrc->pDrawable && pSrc->repeat == RepeatNormal)
{ {
XGL_PIXMAP_PRIV ((PixmapPtr) pSrc->pDrawable);
/* tile */ /* tile */
if (!pSrcPriv->acceleratedTile) if (!pPixmapPriv->acceleratedTile)
{ {
pGeometry = pGeometry =
xglTiledBoxGeometry ((PixmapPtr) pSrc->pDrawable, xglTiledBoxGeometry ((PixmapPtr) pSrc->pDrawable,
@ -183,8 +193,8 @@ xglComp (CARD8 op,
REGION_UNINIT (pScreen, &region); REGION_UNINIT (pScreen, &region);
return FALSE; return FALSE;
} }
pBox = REGION_EXTENTS (pScreen, &region); pBox = pExt;
nBox = 1; nBox = 1;
} }
} }
@ -210,10 +220,10 @@ xglComp (CARD8 op,
if (nBox > 1) if (nBox > 1)
{ {
pGeometry = xglGetScratchVertexGeometry (pScreen, 4 * nBox); pGeometry = xglGetScratchVertexGeometry (pScreen, 4 * nBox);
GEOMETRY_ADD_BOX (pScreen, pGeometry, pBox, nBox); GEOMETRY_ADD_BOX (pScreen, pGeometry, pBox, nBox);
pBox = REGION_EXTENTS (pScreen, &region); pBox = pExt;
} }
xSrc += pBox->x1 - xDst; xSrc += pBox->x1 - xDst;
@ -224,10 +234,10 @@ xglComp (CARD8 op,
xMask += pBox->x1 - xDst; xMask += pBox->x1 - xDst;
yMask += pBox->y1 - yDst; yMask += pBox->y1 - yDst;
} }
xDst = pBox->x1; xDst = pBox->x1;
yDst = pBox->y1; yDst = pBox->y1;
width = pBox->x2 - pBox->x1; width = pBox->x2 - pBox->x1;
height = pBox->y2 - pBox->y1; height = pBox->y2 - pBox->y1;
} }
@ -244,10 +254,11 @@ xglComp (CARD8 op,
if (!GEOMETRY_ENABLE (pGeometry, dst)) if (!GEOMETRY_ENABLE (pGeometry, dst))
{ {
REGION_UNINIT (pScreen, &region); REGION_UNINIT (pScreen, &region);
return FALSE; return FALSE;
} }
} else }
else
GEOMETRY_DISABLE (dst); GEOMETRY_DISABLE (dst);
glitz_composite (XGL_OPERATOR (op), glitz_composite (XGL_OPERATOR (op),
@ -260,10 +271,10 @@ xglComp (CARD8 op,
glitz_surface_set_clip_region (dst, 0, 0, NULL, 0); glitz_surface_set_clip_region (dst, 0, 0, NULL, 0);
REGION_UNINIT (pScreen, &region); REGION_UNINIT (pScreen, &region);
if (glitz_surface_get_status (dst)) if (glitz_surface_get_status (dst))
return FALSE; return FALSE;
return TRUE; return TRUE;
} }

View File

@ -1,6 +1,6 @@
/* /*
* Copyright © 2004 David Reveman * Copyright © 2004 David Reveman
* *
* Permission to use, copy, modify, distribute, and sell this software * Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without * and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies * 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 * software for any purpose. It is provided "as is" without express or
* implied warranty. * 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 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * 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 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
@ -38,6 +38,8 @@ xglCopy (DrawablePtr pSrc,
int srcXoff, srcYoff; int srcXoff, srcYoff;
int dstXoff, dstYoff; int dstXoff, dstYoff;
XGL_DRAWABLE_PIXMAP (pDst);
if (!nBox) if (!nBox)
return TRUE; return TRUE;
@ -50,11 +52,11 @@ xglCopy (DrawablePtr pSrc,
{ {
if (!xglPrepareTarget (pSrc)) if (!xglPrepareTarget (pSrc))
return FALSE; return FALSE;
if (!xglSyncSurface (pDst)) if (!xglSyncSurface (pDst))
return FALSE; return FALSE;
} }
XGL_GET_DRAWABLE (pSrc, src, srcXoff, srcYoff); XGL_GET_DRAWABLE (pSrc, src, srcXoff, srcYoff);
XGL_GET_DRAWABLE (pDst, dst, dstXoff, dstYoff); XGL_GET_DRAWABLE (pDst, dst, dstXoff, dstYoff);
@ -64,18 +66,18 @@ xglCopy (DrawablePtr pSrc,
glitz_copy_area (src, glitz_copy_area (src,
dst, dst,
pDst->x + srcXoff + dx, srcXoff + dx,
pDst->y + srcYoff + dy, srcYoff + dy,
pDst->width, pPixmap->drawable.width - dstXoff,
pDst->height, pPixmap->drawable.height - dstYoff,
pDst->x + dstXoff, dstXoff,
pDst->y + dstYoff); dstYoff);
glitz_surface_set_clip_region (dst, 0, 0, NULL, 0); glitz_surface_set_clip_region (dst, 0, 0, NULL, 0);
if (glitz_surface_get_status (dst)) if (glitz_surface_get_status (dst))
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
@ -96,24 +98,16 @@ xglCopyProc (DrawablePtr pSrc,
if (!xglCopy (pSrc, pDst, dx, dy, pBox, nBox)) if (!xglCopy (pSrc, pDst, dx, dy, pBox, nBox))
{ {
RegionPtr pDamageRegion; RegionRec region;
glitz_surface_t *dst;
int dstXoff, dstYoff;
RegionRec region;
BoxRec box;
XGL_DRAWABLE_PIXMAP (pDst); XGL_DRAWABLE_PIXMAP (pDst);
XGL_PIXMAP_PRIV (pPixmap); XGL_PIXMAP_PRIV (pPixmap);
XGL_GET_DRAWABLE (pDst, dst, dstXoff, dstYoff); if (!xglSyncBits (pSrc, pSrcBox))
FatalError (XGL_SW_FAILURE_STRING);
pDamageRegion = DamageRegion (pPixmapPriv->pDamage);
if (!xglMapPixmapBits (pPixmap)) if (!xglMapPixmapBits (pPixmap))
FatalError (XGL_SW_FAILURE_STRING); FatalError (XGL_SW_FAILURE_STRING);
if (!xglSyncBits (pSrc, pSrcBox))
FatalError (XGL_SW_FAILURE_STRING);
fbCopyNtoN (pSrc, pDst, pGC, fbCopyNtoN (pSrc, pDst, pGC,
pBox, nBox, pBox, nBox,
@ -122,19 +116,11 @@ xglCopyProc (DrawablePtr pSrc,
(void *) 0); (void *) 0);
pPixmapPriv->damageBox = miEmptyBox; pPixmapPriv->damageBox = miEmptyBox;
if (!pPixmapPriv->format)
return;
while (nBox--) while (nBox--)
{ {
box.x1 = pBox->x1 + dstXoff; REGION_INIT (pDst->pScreen, &region, pBox, 1);
box.y1 = pBox->y1 + dstYoff; xglAddSurfaceDamage (pDst, &region);
box.x2 = pBox->x2 + dstXoff;
box.y2 = pBox->y2 + dstYoff;
REGION_INIT (pDst->pScreen, &region, &box, 1);
REGION_UNION (pDst->pScreen,
pDamageRegion, pDamageRegion, &region);
REGION_UNINIT (pDst->pScreen, &region); REGION_UNINIT (pDst->pScreen, &region);
pBox++; pBox++;

View File

@ -1,6 +1,6 @@
/* /*
* Copyright © 2004 David Reveman * Copyright © 2004 David Reveman
* *
* Permission to use, copy, modify, distribute, and sell this software * Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without * and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies * 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 * software for any purpose. It is provided "as is" without express or
* implied warranty. * 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 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * 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 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
@ -31,7 +31,7 @@ Bool
xglFill (DrawablePtr pDrawable, xglFill (DrawablePtr pDrawable,
GCPtr pGC, GCPtr pGC,
xglGeometryPtr pGeometry, xglGeometryPtr pGeometry,
int x, int x,
int y, int y,
int width, int width,
int height, int height,
@ -43,7 +43,7 @@ xglFill (DrawablePtr pDrawable,
switch (pGC->fillStyle) { switch (pGC->fillStyle) {
case FillSolid: case FillSolid:
if (xglSolid (pDrawable, if (xglSolid (pDrawable,
pGCPriv->op, &pGCPriv->fg, pGCPriv->op, pGCPriv->fg,
pGeometry, pGeometry,
x, y, x, y,
width, height, width, height,
@ -70,26 +70,21 @@ xglFill (DrawablePtr pDrawable,
} }
static void static void
xglFillBox (DrawablePtr pDrawable, xglFillBox (DrawablePtr pDrawable,
GCPtr pGC, GCPtr pGC,
int x, int x,
int y, int y,
int width, int width,
int height, int height,
BoxPtr pBox, BoxPtr pBox,
int nBox) int nBox)
{ {
BoxRec box;
if (!nBox) if (!nBox)
return; return;
if (!xglFill (pDrawable, pGC, NULL, x, y, width, height, pBox, nBox)) if (!xglFill (pDrawable, pGC, NULL, x, y, width, height, pBox, nBox))
{ {
RegionRec region; RegionRec region;
RegionPtr pDamageRegion;
glitz_surface_t *surface;
int xOff, yOff;
XGL_DRAWABLE_PIXMAP (pDrawable); XGL_DRAWABLE_PIXMAP (pDrawable);
XGL_PIXMAP_PRIV (pPixmap); XGL_PIXMAP_PRIV (pPixmap);
@ -111,31 +106,18 @@ xglFillBox (DrawablePtr pDrawable,
break; break;
} }
pDamageRegion = DamageRegion (pPixmapPriv->pDamage);
XGL_GET_DRAWABLE (pDrawable, surface, xOff, yOff);
pPixmapPriv->damageBox = miEmptyBox; pPixmapPriv->damageBox = miEmptyBox;
while (nBox--) while (nBox--)
{ {
fbFill (pDrawable, pGC, fbFill (pDrawable, pGC,
pBox->x1, pBox->y1, pBox->x1, pBox->y1,
pBox->x2 - pBox->x1, pBox->y2 - pBox->y1); pBox->x2 - pBox->x1, pBox->y2 - pBox->y1);
if (pPixmapPriv->format) REGION_INIT (pDrawable->pScreen, &region, pBox, 1);
{ xglAddSurfaceDamage (pDrawable, &region);
box.x1 = pBox->x1 + xOff; REGION_UNINIT (pDrawable->pScreen, &region);
box.y1 = pBox->y1 + yOff;
box.x2 = pBox->x2 + xOff;
box.y2 = pBox->y2 + yOff;
REGION_INIT (pDrawable->pScreen, &region, &box, 1);
REGION_UNION (pDrawable->pScreen,
pDamageRegion, pDamageRegion, &region);
REGION_UNINIT (pDrawable->pScreen, &region);
}
pBox++; pBox++;
} }
} else } else
@ -150,11 +132,11 @@ xglMoreBoxes (BoxPtr stackBox,
int nBoxes) int nBoxes)
{ {
Bool stack = !heapBox; Bool stack = !heapBox;
heapBox = xrealloc (heapBox, sizeof (BoxRec) * nBoxes); heapBox = xrealloc (heapBox, sizeof (BoxRec) * nBoxes);
if (!heapBox) if (!heapBox)
return NULL; return NULL;
if (stack) if (stack)
memcpy (heapBox, stackBox, sizeof (BoxRec) * N_STACK_BOX); memcpy (heapBox, stackBox, sizeof (BoxRec) * N_STACK_BOX);
@ -182,8 +164,8 @@ xglMoreBoxes (BoxPtr stackBox,
} }
void void
xglFillRect (DrawablePtr pDrawable, xglFillRect (DrawablePtr pDrawable,
GCPtr pGC, GCPtr pGC,
int nrect, int nrect,
xRectangle *prect) xRectangle *prect)
{ {
@ -205,19 +187,19 @@ xglFillRect (DrawablePtr pDrawable,
full.y2 = full.y1 + (int) prect->height; full.y2 = full.y1 + (int) prect->height;
prect++; prect++;
if (full.x1 < pExtent->x1) if (full.x1 < pExtent->x1)
full.x1 = pExtent->x1; full.x1 = pExtent->x1;
if (full.y1 < pExtent->y1) if (full.y1 < pExtent->y1)
full.y1 = pExtent->y1; full.y1 = pExtent->y1;
if (full.x2 > pExtent->x2) if (full.x2 > pExtent->x2)
full.x2 = pExtent->x2; full.x2 = pExtent->x2;
if (full.y2 > pExtent->y2) if (full.y2 > pExtent->y2)
full.y2 = pExtent->y2; full.y2 = pExtent->y2;
if (full.x1 >= full.x2 || full.y1 >= full.y2) if (full.x1 >= full.x2 || full.y1 >= full.y2)
continue; continue;
nClip = REGION_NUM_RECTS (pClip); nClip = REGION_NUM_RECTS (pClip);
if (nClip == 1) if (nClip == 1)
{ {
@ -238,7 +220,7 @@ xglFillRect (DrawablePtr pDrawable,
part.x2 = full.x2; part.x2 = full.x2;
if (part.y2 > full.y2) if (part.y2 > full.y2)
part.y2 = full.y2; part.y2 = full.y2;
if (part.x1 < part.x2 && part.y1 < part.y2) if (part.x1 < part.x2 && part.y1 < part.y2)
ADD_BOX (pBox, nBox, stackBox, heapBox, size, part); ADD_BOX (pBox, nBox, stackBox, heapBox, size, part);
} }
@ -249,7 +231,7 @@ xglFillRect (DrawablePtr pDrawable,
pExtent->x1, pExtent->y1, pExtent->x1, pExtent->y1,
pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1, pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
(heapBox) ? heapBox : stackBox, nBox); (heapBox) ? heapBox : stackBox, nBox);
if (heapBox) if (heapBox)
xfree (heapBox); xfree (heapBox);
} }
@ -280,19 +262,19 @@ xglFillSpan (DrawablePtr pDrawable,
pwidth++; pwidth++;
ppt++; ppt++;
if (full.x1 < pExtent->x1) if (full.x1 < pExtent->x1)
full.x1 = pExtent->x1; full.x1 = pExtent->x1;
if (full.y1 < pExtent->y1) if (full.y1 < pExtent->y1)
full.y1 = pExtent->y1; full.y1 = pExtent->y1;
if (full.x2 > pExtent->x2) if (full.x2 > pExtent->x2)
full.x2 = pExtent->x2; full.x2 = pExtent->x2;
if (full.y2 > pExtent->y2) if (full.y2 > pExtent->y2)
full.y2 = pExtent->y2; full.y2 = pExtent->y2;
if (full.x1 >= full.x2 || full.y1 >= full.y2) if (full.x1 >= full.x2 || full.y1 >= full.y2)
continue; continue;
nClip = REGION_NUM_RECTS (pClip); nClip = REGION_NUM_RECTS (pClip);
if (nClip == 1) if (nClip == 1)
{ {
@ -313,7 +295,7 @@ xglFillSpan (DrawablePtr pDrawable,
part.x2 = full.x2; part.x2 = full.x2;
if (part.y2 > full.y2) if (part.y2 > full.y2)
part.y2 = full.y2; part.y2 = full.y2;
if (part.x1 < part.x2 && part.y1 < part.y2) if (part.x1 < part.x2 && part.y1 < part.y2)
ADD_BOX (pBox, nBox, stackBox, heapBox, size, part); ADD_BOX (pBox, nBox, stackBox, heapBox, size, part);
} }
@ -324,7 +306,7 @@ xglFillSpan (DrawablePtr pDrawable,
pExtent->x1, pExtent->y1, pExtent->x1, pExtent->y1,
pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1, pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
(heapBox) ? heapBox : stackBox, nBox); (heapBox) ? heapBox : stackBox, nBox);
if (heapBox) if (heapBox)
xfree (heapBox); xfree (heapBox);
} }
@ -346,28 +328,28 @@ xglFillLine (DrawablePtr pDrawable,
xglGeometryPtr pGeometry; xglGeometryPtr pGeometry;
XGL_SCREEN_PRIV (pGC->pScreen); XGL_SCREEN_PRIV (pGC->pScreen);
if (npt < 2) if (npt < 2)
return TRUE; return TRUE;
pt = *ppt; pt = *ppt;
nptTmp = npt - 1; nptTmp = npt - 1;
pptTmp = ppt + 1; pptTmp = ppt + 1;
if (mode == CoordModePrevious) if (mode == CoordModePrevious)
{ {
while (nptTmp--) while (nptTmp--)
{ {
if (pptTmp->x && pptTmp->y) if (pptTmp->x && pptTmp->y)
horizontalAndVertical = FALSE; horizontalAndVertical = FALSE;
pt.x += pptTmp->x; pt.x += pptTmp->x;
pt.y += pptTmp->y; pt.y += pptTmp->y;
pptTmp++; pptTmp++;
} }
if (pt.x == ppt->x && pt.y == ppt->y) if (pt.x == ppt->x && pt.y == ppt->y)
coincidentEndpoints = TRUE; coincidentEndpoints = TRUE;
} }
@ -383,7 +365,7 @@ xglFillLine (DrawablePtr pDrawable,
pt = *pptTmp++; pt = *pptTmp++;
} }
if (ppt[npt - 1].x == ppt->x && ppt[npt - 1].y == ppt->y) if (ppt[npt - 1].x == ppt->x && ppt[npt - 1].y == ppt->y)
coincidentEndpoints = TRUE; coincidentEndpoints = TRUE;
} }
@ -403,7 +385,7 @@ xglFillLine (DrawablePtr pDrawable,
ppt++; ppt++;
npt--; npt--;
while (npt--) while (npt--)
{ {
if (mode == CoordModePrevious) if (mode == CoordModePrevious)
@ -416,13 +398,13 @@ xglFillLine (DrawablePtr pDrawable,
dx = ppt->x - pt.x; dx = ppt->x - pt.x;
dy = ppt->y - pt.y; dy = ppt->y - pt.y;
} }
if (dx) if (dx)
{ {
if (dx > 0) if (dx > 0)
{ {
full.x1 = pt.x + pDrawable->x; full.x1 = pt.x + pDrawable->x;
if (npt || coincidentEndpoints) if (npt || coincidentEndpoints)
full.x2 = full.x1 + dx; full.x2 = full.x1 + dx;
else else
@ -437,7 +419,7 @@ xglFillLine (DrawablePtr pDrawable,
else else
full.x1 = full.x2 + dx - 1; full.x1 = full.x2 + dx - 1;
} }
full.y1 = pt.y + pDrawable->y; full.y1 = pt.y + pDrawable->y;
full.y2 = full.y1 + 1; full.y2 = full.y1 + 1;
} }
@ -446,7 +428,7 @@ xglFillLine (DrawablePtr pDrawable,
if (dy > 0) if (dy > 0)
{ {
full.y1 = pt.y + pDrawable->y; full.y1 = pt.y + pDrawable->y;
if (npt || coincidentEndpoints) if (npt || coincidentEndpoints)
full.y2 = full.y1 + dy; full.y2 = full.y1 + dy;
else else
@ -461,28 +443,28 @@ xglFillLine (DrawablePtr pDrawable,
else else
full.y1 = full.y2 + dy - 1; full.y1 = full.y2 + dy - 1;
} }
full.x1 = pt.x + pDrawable->x; full.x1 = pt.x + pDrawable->x;
full.x2 = full.x1 + 1; full.x2 = full.x1 + 1;
} }
pt.x += dx; pt.x += dx;
pt.y += dy; pt.y += dy;
ppt++; ppt++;
if (full.x1 < pExtent->x1) if (full.x1 < pExtent->x1)
full.x1 = pExtent->x1; full.x1 = pExtent->x1;
if (full.y1 < pExtent->y1) if (full.y1 < pExtent->y1)
full.y1 = pExtent->y1; full.y1 = pExtent->y1;
if (full.x2 > pExtent->x2) if (full.x2 > pExtent->x2)
full.x2 = pExtent->x2; full.x2 = pExtent->x2;
if (full.y2 > pExtent->y2) if (full.y2 > pExtent->y2)
full.y2 = pExtent->y2; full.y2 = pExtent->y2;
if (full.x1 >= full.x2 || full.y1 >= full.y2) if (full.x1 >= full.x2 || full.y1 >= full.y2)
continue; continue;
nClip = REGION_NUM_RECTS (pClip); nClip = REGION_NUM_RECTS (pClip);
if (nClip == 1) if (nClip == 1)
{ {
@ -503,7 +485,7 @@ xglFillLine (DrawablePtr pDrawable,
part.x2 = full.x2; part.x2 = full.x2;
if (part.y2 > full.y2) if (part.y2 > full.y2)
part.y2 = full.y2; part.y2 = full.y2;
if (part.x1 < part.x2 && part.y1 < part.y2) if (part.x1 < part.x2 && part.y1 < part.y2)
ADD_BOX (pBox, nBox, stackBox, heapBox, size, part); ADD_BOX (pBox, nBox, stackBox, heapBox, size, part);
} }
@ -514,7 +496,7 @@ xglFillLine (DrawablePtr pDrawable,
pExtent->x1, pExtent->y1, pExtent->x1, pExtent->y1,
pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1, pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
(heapBox) ? heapBox : stackBox, nBox); (heapBox) ? heapBox : stackBox, nBox);
if (heapBox) if (heapBox)
xfree (heapBox); xfree (heapBox);
@ -526,9 +508,9 @@ xglFillLine (DrawablePtr pDrawable,
if (coincidentEndpoints) if (coincidentEndpoints)
npt--; npt--;
pGeometry = xglGetScratchVertexGeometry (pGC->pScreen, npt); pGeometry = xglGetScratchVertexGeometry (pGC->pScreen, npt);
GEOMETRY_ADD_LINE (pGC->pScreen, pGeometry, GEOMETRY_ADD_LINE (pGC->pScreen, pGeometry,
coincidentEndpoints, mode, npt, ppt); coincidentEndpoints, mode, npt, ppt);
@ -539,24 +521,27 @@ xglFillLine (DrawablePtr pDrawable,
/* Lines need a 0.5 translate */ /* Lines need a 0.5 translate */
GEOMETRY_TRANSLATE_FIXED (pGeometry, 1 << 15, 1 << 15); GEOMETRY_TRANSLATE_FIXED (pGeometry, 1 << 15, 1 << 15);
GEOMETRY_TRANSLATE (pGeometry, pDrawable->x, pDrawable->y); GEOMETRY_TRANSLATE (pGeometry, pDrawable->x, pDrawable->y);
pExtent = REGION_EXTENTS (pDrawable->pScreen, pGC->pCompositeClip); pExtent = REGION_EXTENTS (pDrawable->pScreen, pGC->pCompositeClip);
if (xglFill (pDrawable, pGC, pGeometry, if (xglFill (pDrawable, pGC, pGeometry,
pExtent->x1, pExtent->y1, pExtent->x1, pExtent->y1,
pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1, pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
REGION_RECTS (pGC->pCompositeClip), REGION_RECTS (pGC->pCompositeClip),
REGION_NUM_RECTS (pGC->pCompositeClip))) REGION_NUM_RECTS (pGC->pCompositeClip)))
{
xglAddCurrentBitDamage (pDrawable);
return TRUE; return TRUE;
}
return FALSE; return FALSE;
} }
Bool Bool
xglFillSegment (DrawablePtr pDrawable, xglFillSegment (DrawablePtr pDrawable,
GCPtr pGC, GCPtr pGC,
int nSegInit, int nSegInit,
xSegment *pSegInit) xSegment *pSegInit)
{ {
@ -632,19 +617,19 @@ xglFillSegment (DrawablePtr pDrawable,
} }
pSegInit++; pSegInit++;
if (full.x1 < pExtent->x1) if (full.x1 < pExtent->x1)
full.x1 = pExtent->x1; full.x1 = pExtent->x1;
if (full.y1 < pExtent->y1) if (full.y1 < pExtent->y1)
full.y1 = pExtent->y1; full.y1 = pExtent->y1;
if (full.x2 > pExtent->x2) if (full.x2 > pExtent->x2)
full.x2 = pExtent->x2; full.x2 = pExtent->x2;
if (full.y2 > pExtent->y2) if (full.y2 > pExtent->y2)
full.y2 = pExtent->y2; full.y2 = pExtent->y2;
if (full.x1 >= full.x2 || full.y1 >= full.y2) if (full.x1 >= full.x2 || full.y1 >= full.y2)
continue; continue;
nClip = REGION_NUM_RECTS (pClip); nClip = REGION_NUM_RECTS (pClip);
if (nClip == 1) if (nClip == 1)
{ {
@ -665,7 +650,7 @@ xglFillSegment (DrawablePtr pDrawable,
part.x2 = full.x2; part.x2 = full.x2;
if (part.y2 > full.y2) if (part.y2 > full.y2)
part.y2 = full.y2; part.y2 = full.y2;
if (part.x1 < part.x2 && part.y1 < part.y2) if (part.x1 < part.x2 && part.y1 < part.y2)
ADD_BOX (pBox, nBox, stackBox, heapBox, size, part); ADD_BOX (pBox, nBox, stackBox, heapBox, size, part);
} }
@ -676,7 +661,7 @@ xglFillSegment (DrawablePtr pDrawable,
pExtent->x1, pExtent->y1, pExtent->x1, pExtent->y1,
pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1, pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
(heapBox) ? heapBox : stackBox, nBox); (heapBox) ? heapBox : stackBox, nBox);
if (heapBox) if (heapBox)
xfree (heapBox); xfree (heapBox);
@ -685,24 +670,27 @@ xglFillSegment (DrawablePtr pDrawable,
if (!pScreenPriv->lines) if (!pScreenPriv->lines)
return FALSE; return FALSE;
pGeometry = xglGetScratchVertexGeometry (pGC->pScreen, 2 * nSegInit); pGeometry = xglGetScratchVertexGeometry (pGC->pScreen, 2 * nSegInit);
GEOMETRY_ADD_SEGMENT (pGC->pScreen, pGeometry, nSegInit, pSegInit); GEOMETRY_ADD_SEGMENT (pGC->pScreen, pGeometry, nSegInit, pSegInit);
/* Line segments need 0.5 translate */ /* Line segments need 0.5 translate */
GEOMETRY_TRANSLATE_FIXED (pGeometry, 1 << 15, 1 << 15); GEOMETRY_TRANSLATE_FIXED (pGeometry, 1 << 15, 1 << 15);
GEOMETRY_SET_VERTEX_PRIMITIVE (pGeometry, GLITZ_PRIMITIVE_LINES); GEOMETRY_SET_VERTEX_PRIMITIVE (pGeometry, GLITZ_PRIMITIVE_LINES);
GEOMETRY_TRANSLATE (pGeometry, pDrawable->x, pDrawable->y); GEOMETRY_TRANSLATE (pGeometry, pDrawable->x, pDrawable->y);
if (xglFill (pDrawable, pGC, pGeometry, if (xglFill (pDrawable, pGC, pGeometry,
pExtent->x1, pExtent->y1, pExtent->x1, pExtent->y1,
pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1, pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
REGION_RECTS (pGC->pCompositeClip), REGION_RECTS (pGC->pCompositeClip),
REGION_NUM_RECTS (pGC->pCompositeClip))) REGION_NUM_RECTS (pGC->pCompositeClip)))
{
xglAddCurrentBitDamage (pDrawable);
return TRUE; return TRUE;
}
return FALSE; return FALSE;
} }
@ -745,9 +733,10 @@ xglFillGlyph (DrawablePtr pDrawable,
REGION_NUM_RECTS (pGC->pCompositeClip))) REGION_NUM_RECTS (pGC->pCompositeClip)))
{ {
GEOMETRY_UNINIT (&geometry); GEOMETRY_UNINIT (&geometry);
xglAddCurrentBitDamage (pDrawable);
return TRUE; return TRUE;
} }
GEOMETRY_UNINIT (&geometry); GEOMETRY_UNINIT (&geometry);
return FALSE; return FALSE;
} }

View File

@ -1,6 +1,6 @@
/* /*
* Copyright © 2004 David Reveman * Copyright © 2004 David Reveman
* *
* Permission to use, copy, modify, distribute, and sell this software * Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without * and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies * 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 * software for any purpose. It is provided "as is" without express or
* implied warranty. * 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 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * 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 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
@ -58,7 +58,7 @@ static const GCFuncs xglGCFuncs = {
xglValidateGC, xglValidateGC,
miChangeGC, miChangeGC,
miCopyGC, miCopyGC,
miDestroyGC, xglDestroyGC,
miChangeClip, miChangeClip,
miDestroyClip, miDestroyClip,
miCopyClip miCopyClip
@ -123,7 +123,7 @@ xglSetSpans (DrawablePtr pDrawable,
int fSorted) int fSorted)
{ {
XGL_GC_PRIV (pGC); XGL_GC_PRIV (pGC);
XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable); XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable);
(*pGC->ops->SetSpans) (pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted); (*pGC->ops->SetSpans) (pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted);
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable); XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
@ -163,7 +163,7 @@ xglPutImage (DrawablePtr pDrawable,
XGL_GC_UNWRAP (funcs); XGL_GC_UNWRAP (funcs);
XGL_GC_UNWRAP (ops); XGL_GC_UNWRAP (ops);
(*pGC->ops->PutImage) (pDrawable, pGC, depth, (*pGC->ops->PutImage) (pDrawable, pGC, depth,
x, y, w, h, leftPad, format, bits); x, y, w, h, leftPad, format, bits);
@ -174,7 +174,7 @@ xglPutImage (DrawablePtr pDrawable,
box.y1 = pDrawable->y + y; box.y1 = pDrawable->y + y;
box.x2 = box.x1 + w; box.x2 = box.x1 + w;
box.y2 = box.y1 + h; box.y2 = box.y1 + h;
REGION_INIT (pDrawable->pScreen, &region, &box, 1); REGION_INIT (pDrawable->pScreen, &region, &box, 1);
REGION_INTERSECT (pDrawable->pScreen, &region, pClip, &region); REGION_INTERSECT (pDrawable->pScreen, &region, pClip, &region);
@ -197,7 +197,7 @@ xglCopyArea (DrawablePtr pSrc,
{ {
RegionPtr pRegion; RegionPtr pRegion;
BoxRec box; BoxRec box;
XGL_GC_PRIV (pGC); XGL_GC_PRIV (pGC);
box.x1 = pSrc->x + srcX; box.x1 = pSrc->x + srcX;
@ -205,11 +205,11 @@ xglCopyArea (DrawablePtr pSrc,
box.x2 = box.x1 + w; box.x2 = box.x1 + w;
box.y2 = box.y1 + h; box.y2 = box.y1 + h;
if (pGC->alu != GXcopy || (pGCPriv->flags &= ~xglGCReadOnlyDrawableFlag)) if (pGC->alu != GXcopy || pGCPriv->flags)
{ {
if (!xglSyncBits (pSrc, &box)) if (!xglSyncBits (pSrc, &box))
FatalError (XGL_SW_FAILURE_STRING); FatalError (XGL_SW_FAILURE_STRING);
XGL_GC_OP_FALLBACK_PROLOGUE (pDst); XGL_GC_OP_FALLBACK_PROLOGUE (pDst);
pRegion = (*pGC->ops->CopyArea) (pSrc, pDst, pGC, pRegion = (*pGC->ops->CopyArea) (pSrc, pDst, pGC,
srcX, srcY, w, h, dstX, dstY); srcX, srcY, w, h, dstX, dstY);
@ -243,14 +243,14 @@ xglCopyPlane (DrawablePtr pSrc,
{ {
RegionPtr pRegion; RegionPtr pRegion;
BoxRec box; BoxRec box;
XGL_GC_PRIV (pGC); XGL_GC_PRIV (pGC);
box.x1 = pSrc->x + srcX; box.x1 = pSrc->x + srcX;
box.y1 = pSrc->y + srcY; box.y1 = pSrc->y + srcY;
box.x2 = box.x1 + w; box.x2 = box.x1 + w;
box.y2 = box.y1 + h; box.y2 = box.y1 + h;
if (!xglSyncBits (pSrc, &box)) if (!xglSyncBits (pSrc, &box))
FatalError (XGL_SW_FAILURE_STRING); FatalError (XGL_SW_FAILURE_STRING);
@ -293,13 +293,10 @@ xglPolylines (DrawablePtr pDrawable,
if (pGC->lineStyle == LineSolid) if (pGC->lineStyle == LineSolid)
{ {
if (xglFillLine (pDrawable, pGC, mode, npt, ppt)) if (xglFillLine (pDrawable, pGC, mode, npt, ppt))
{
xglAddCurrentBitDamage (pDrawable);
return; return;
}
} }
} }
XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable); XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
(*pGC->ops->Polylines) (pDrawable, pGC, mode, npt, ppt); (*pGC->ops->Polylines) (pDrawable, pGC, mode, npt, ppt);
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable); XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
@ -315,7 +312,7 @@ xglPolylines (DrawablePtr pDrawable,
void void
xglPolySegment (DrawablePtr pDrawable, xglPolySegment (DrawablePtr pDrawable,
GCPtr pGC, GCPtr pGC,
int nsegInit, int nsegInit,
xSegment *pSegInit) xSegment *pSegInit)
{ {
@ -328,10 +325,7 @@ xglPolySegment (DrawablePtr pDrawable,
if (pGC->lineStyle == LineSolid) if (pGC->lineStyle == LineSolid)
{ {
if (xglFillSegment (pDrawable, pGC, nsegInit, pSegInit)) if (xglFillSegment (pDrawable, pGC, nsegInit, pSegInit))
{
xglAddCurrentBitDamage (pDrawable);
return; return;
}
} }
} }
@ -344,14 +338,14 @@ xglPolySegment (DrawablePtr pDrawable,
void void
xglPolyArc (DrawablePtr pDrawable, xglPolyArc (DrawablePtr pDrawable,
GCPtr pGC, GCPtr pGC,
int narcs, int narcs,
xArc *pArcs) xArc *pArcs)
{ {
if (pGC->lineWidth == 0) if (pGC->lineWidth == 0)
{ {
XGL_GC_PRIV (pGC); XGL_GC_PRIV (pGC);
XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable); XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
(*pGC->ops->PolyArc) (pDrawable, pGC, narcs, pArcs); (*pGC->ops->PolyArc) (pDrawable, pGC, narcs, pArcs);
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable); XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
@ -367,7 +361,7 @@ xglPolyFillRect (DrawablePtr pDrawable,
{ {
XGL_GC_PRIV (pGC); XGL_GC_PRIV (pGC);
if (pGCPriv->flags || pGC->fillStyle == FillStippled) if (pGC->fillStyle == FillStippled || pGCPriv->flags)
{ {
XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable); XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
(*pGC->ops->PolyFillRect) (pDrawable, pGC, nrect, prect); (*pGC->ops->PolyFillRect) (pDrawable, pGC, nrect, prect);
@ -382,12 +376,12 @@ xglPolyFillRect (DrawablePtr pDrawable,
void void
xglPolyFillArc (DrawablePtr pDrawable, xglPolyFillArc (DrawablePtr pDrawable,
GCPtr pGC, GCPtr pGC,
int narcs, int narcs,
xArc *pArcs) xArc *pArcs)
{ {
XGL_GC_PRIV (pGC); XGL_GC_PRIV (pGC);
XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable); XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
(*pGC->ops->PolyFillArc) (pDrawable, pGC, narcs, pArcs); (*pGC->ops->PolyFillArc) (pDrawable, pGC, narcs, pArcs);
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable); XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
@ -404,7 +398,7 @@ xglImageGlyphBlt (DrawablePtr pDrawable,
{ {
XGL_GC_PRIV (pGC); XGL_GC_PRIV (pGC);
if (!(pGCPriv->flags & ~xglGCBadFunctionFlag)) if (!pGCPriv->flags)
{ {
if (xglSolidGlyph (pDrawable, if (xglSolidGlyph (pDrawable,
pGC, pGC,
@ -413,10 +407,7 @@ xglImageGlyphBlt (DrawablePtr pDrawable,
nglyph, nglyph,
ppci, ppci,
pglyphBase)) pglyphBase))
{
xglAddCurrentBitDamage (pDrawable);
return; return;
}
} }
XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable); XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable);
@ -445,12 +436,9 @@ xglPolyGlyphBlt (DrawablePtr pDrawable,
nglyph, nglyph,
ppci, ppci,
pglyphBase)) pglyphBase))
{
xglAddCurrentBitDamage (pDrawable);
return; return;
}
} }
XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable); XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
(*pGC->ops->PolyGlyphBlt) (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); (*pGC->ops->PolyGlyphBlt) (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable); XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
@ -469,7 +457,7 @@ xglPushPixels (GCPtr pGC,
if (!xglSyncBits (&pBitmap->drawable, NullBox)) if (!xglSyncBits (&pBitmap->drawable, NullBox))
FatalError (XGL_SW_FAILURE_STRING); FatalError (XGL_SW_FAILURE_STRING);
XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable); XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable);
(*pGC->ops->PushPixels) (pGC, pBitmap, pDrawable, w, h, x, y); (*pGC->ops->PushPixels) (pGC, pBitmap, pDrawable, w, h, x, y);
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable); XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
@ -478,10 +466,9 @@ xglPushPixels (GCPtr pGC,
Bool Bool
xglCreateGC (GCPtr pGC) xglCreateGC (GCPtr pGC)
{ {
static glitz_color_t black = { 0x0, 0x0, 0x0, 0xffff }; ScreenPtr pScreen = pGC->pScreen;
ScreenPtr pScreen = pGC->pScreen; Bool ret;
Bool ret;
XGL_SCREEN_PRIV (pScreen); XGL_SCREEN_PRIV (pScreen);
XGL_GC_PRIV (pGC); XGL_GC_PRIV (pGC);
@ -491,15 +478,35 @@ xglCreateGC (GCPtr pGC)
XGL_GC_WRAP (funcs, (GCFuncs *) &xglGCFuncs); XGL_GC_WRAP (funcs, (GCFuncs *) &xglGCFuncs);
XGL_GC_WRAP (ops, (GCOps *) &xglGCOps); XGL_GC_WRAP (ops, (GCOps *) &xglGCOps);
pGCPriv->flags = 0; pGCPriv->flags = 0;
pGCPriv->op = GLITZ_OPERATOR_SRC; pGCPriv->op = GLITZ_OPERATOR_SRC;
pGCPriv->fg = black;
pGCPriv->bg = black; pGCPriv->fg = NULL;
pGCPriv->bg = NULL;
pGCPriv->id = ~0;
return ret; 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 void
xglValidateGC (GCPtr pGC, xglValidateGC (GCPtr pGC,
unsigned long changes, unsigned long changes,
@ -509,12 +516,12 @@ xglValidateGC (GCPtr pGC,
if (changes & GCTile) if (changes & GCTile)
{ {
if (!pGC->tileIsPixel && if (!pGC->tileIsPixel &&
FbEvenTile (pGC->tile.pixmap->drawable.width * FbEvenTile (pGC->tile.pixmap->drawable.width *
pDrawable->bitsPerPixel)) pDrawable->bitsPerPixel))
xglSyncBits (&pGC->tile.pixmap->drawable, NULL); xglSyncBits (&pGC->tile.pixmap->drawable, NULL);
} }
if (changes & GCStipple) if (changes & GCStipple)
{ {
if (pGC->stipple) if (pGC->stipple)
@ -530,16 +537,45 @@ xglValidateGC (GCPtr pGC,
if (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS)) if (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS))
{ {
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable); XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
if (pPixmapPriv->format) if (pPixmapPriv->pVisual && pPixmapPriv->pVisual->format.surface)
pGCPriv->flags &= ~xglGCSoftwareDrawableFlag; {
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 else
pGCPriv->flags |= xglGCSoftwareDrawableFlag; pGCPriv->flags |= xglGCSoftwareDrawableFlag;
if (pPixmapPriv->target)
pGCPriv->flags &= ~xglGCReadOnlyDrawableFlag;
else
pGCPriv->flags |= xglGCReadOnlyDrawableFlag;
} }
if (changes & GCFunction) if (changes & GCFunction)
@ -568,21 +604,45 @@ xglValidateGC (GCPtr pGC,
FbBits mask; FbBits mask;
mask = FbFullMask (pDrawable->depth); mask = FbFullMask (pDrawable->depth);
if ((pGC->planemask & mask) != mask) if ((pGC->planemask & mask) != mask)
pGCPriv->flags |= xglGCPlaneMaskFlag; pGCPriv->flags |= xglGCPlaneMaskFlag;
else else
pGCPriv->flags &= ~xglGCPlaneMaskFlag; pGCPriv->flags &= ~xglGCPlaneMaskFlag;
} }
if (changes & (GCForeground | GCBackground)) if (!(pGCPriv->flags & xglGCSoftwareDrawableFlag))
{ {
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable); if (changes & (GCForeground | GCBackground))
if (pPixmapPriv->pPixel)
{ {
xglPixelToColor (pPixmapPriv->pPixel, pGC->fgPixel, &pGCPriv->fg); glitz_pixel_format_t format;
xglPixelToColor (pPixmapPriv->pPixel, pGC->bgPixel, &pGCPriv->bg); 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);
} }
} }
} }

View File

@ -1,6 +1,6 @@
/* /*
* Copyright © 2004 David Reveman * Copyright © 2004 David Reveman
* *
* Permission to use, copy, modify, distribute, and sell this software * Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without * and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies * 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 * software for any purpose. It is provided "as is" without express or
* implied warranty. * 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 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * 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 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
@ -44,7 +44,7 @@ xglGeometryResize (ScreenPtr pScreen,
int size) int size)
{ {
XGL_SCREEN_PRIV (pScreen); XGL_SCREEN_PRIV (pScreen);
if (size == pGeometry->size) if (size == pGeometry->size)
return; return;
@ -54,12 +54,12 @@ xglGeometryResize (ScreenPtr pScreen,
if (pGeometry->usage == GEOMETRY_USAGE_SYSMEM) if (pGeometry->usage == GEOMETRY_USAGE_SYSMEM)
{ {
pGeometry->data = xrealloc (pGeometry->data, size); pGeometry->data = xrealloc (pGeometry->data, size);
if (pGeometry->buffer) if (pGeometry->buffer)
glitz_buffer_destroy (pGeometry->buffer); glitz_buffer_destroy (pGeometry->buffer);
pGeometry->buffer = NULL; pGeometry->buffer = NULL;
if (pGeometry->data) if (pGeometry->data)
{ {
pGeometry->buffer = glitz_buffer_create_for_data (pGeometry->data); pGeometry->buffer = glitz_buffer_create_for_data (pGeometry->data);
@ -78,6 +78,7 @@ xglGeometryResize (ScreenPtr pScreen,
else else
{ {
glitz_buffer_t *newBuffer; glitz_buffer_t *newBuffer;
if (size) if (size)
{ {
newBuffer = newBuffer =
@ -90,29 +91,29 @@ xglGeometryResize (ScreenPtr pScreen,
} }
} else } else
newBuffer = NULL; newBuffer = NULL;
if (pGeometry->buffer && newBuffer) if (pGeometry->buffer && newBuffer)
{ {
void *oldData, *newData; void *oldData, *newData;
oldData = glitz_buffer_map (pGeometry->buffer, oldData = glitz_buffer_map (pGeometry->buffer,
GLITZ_BUFFER_ACCESS_READ_ONLY); GLITZ_BUFFER_ACCESS_READ_ONLY);
newData = glitz_buffer_map (newBuffer, newData = glitz_buffer_map (newBuffer,
GLITZ_BUFFER_ACCESS_WRITE_ONLY); GLITZ_BUFFER_ACCESS_WRITE_ONLY);
if (oldData && newData) if (oldData && newData)
memcpy (newData, oldData, MIN (size, pGeometry->size)); memcpy (newData, oldData, MIN (size, pGeometry->size));
glitz_buffer_unmap (pGeometry->buffer); glitz_buffer_unmap (pGeometry->buffer);
glitz_buffer_unmap (newBuffer); glitz_buffer_unmap (newBuffer);
glitz_buffer_destroy (pGeometry->buffer); glitz_buffer_destroy (pGeometry->buffer);
} }
pGeometry->buffer = newBuffer; pGeometry->buffer = newBuffer;
} }
pGeometry->size = size; pGeometry->size = size;
if (pGeometry->endOffset > size) if (pGeometry->endOffset > size)
pGeometry->endOffset = size; pGeometry->endOffset = size;
} }
@ -149,7 +150,7 @@ xglGeometryResize (ScreenPtr pScreen,
(pGeometry)->count = (pGeometry)->endOffset / \ (pGeometry)->count = (pGeometry)->endOffset / \
(2 * xglGeometryDataTypes[(pGeometry)->dataType].size); \ (2 * xglGeometryDataTypes[(pGeometry)->dataType].size); \
} }
/* /*
* Adds a number of boxes as GL_QUAD primitives * Adds a number of boxes as GL_QUAD primitives
*/ */
@ -167,7 +168,7 @@ xglGeometryAddBox (ScreenPtr pScreen,
return; return;
MAP_GEOMETRY (pScreen, pGeometry, offset, nBox * 8, ptr, size); MAP_GEOMETRY (pScreen, pGeometry, offset, nBox * 8, ptr, size);
switch (pGeometry->dataType) { switch (pGeometry->dataType) {
case GEOMETRY_DATA_TYPE_SHORT: case GEOMETRY_DATA_TYPE_SHORT:
{ {
@ -190,7 +191,7 @@ xglGeometryAddBox (ScreenPtr pScreen,
case GEOMETRY_DATA_TYPE_FLOAT: case GEOMETRY_DATA_TYPE_FLOAT:
{ {
glitz_float_t *data = (glitz_float_t *) ptr; glitz_float_t *data = (glitz_float_t *) ptr;
while (nBox--) while (nBox--)
{ {
*data++ = (glitz_float_t) pBox->x1; *data++ = (glitz_float_t) pBox->x1;
@ -228,7 +229,7 @@ xglGeometryAddSpan (ScreenPtr pScreen,
return; return;
MAP_GEOMETRY (pScreen, pGeometry, offset, n * 4, ptr, size); MAP_GEOMETRY (pScreen, pGeometry, offset, n * 4, ptr, size);
switch (pGeometry->dataType) { switch (pGeometry->dataType) {
case GEOMETRY_DATA_TYPE_SHORT: case GEOMETRY_DATA_TYPE_SHORT:
{ {
@ -240,7 +241,7 @@ xglGeometryAddSpan (ScreenPtr pScreen,
*data++ = (glitz_short_t) ppt->y; *data++ = (glitz_short_t) ppt->y;
*data++ = (glitz_short_t) (ppt->x + *pwidth); *data++ = (glitz_short_t) (ppt->x + *pwidth);
*data++ = (glitz_short_t) ppt->y; *data++ = (glitz_short_t) ppt->y;
ppt++; ppt++;
pwidth++; pwidth++;
} }
@ -255,13 +256,13 @@ xglGeometryAddSpan (ScreenPtr pScreen,
*data++ = (glitz_float_t) ppt->y; *data++ = (glitz_float_t) ppt->y;
*data++ = (glitz_float_t) (ppt->x + *pwidth); *data++ = (glitz_float_t) (ppt->x + *pwidth);
*data++ = (glitz_float_t) ppt->y; *data++ = (glitz_float_t) ppt->y;
ppt++; ppt++;
pwidth++; pwidth++;
} }
} break; } break;
} }
UNMAP_GEOMETRY (pGeometry, offset, size); UNMAP_GEOMETRY (pGeometry, offset, size);
} }
@ -298,7 +299,7 @@ xglGeometryAddLine (ScreenPtr pScreen,
pt.x = 0; pt.x = 0;
pt.y = 0; pt.y = 0;
switch (pGeometry->dataType) { switch (pGeometry->dataType) {
case GEOMETRY_DATA_TYPE_SHORT: case GEOMETRY_DATA_TYPE_SHORT:
{ {
@ -329,7 +330,7 @@ xglGeometryAddLine (ScreenPtr pScreen,
ADJUST_END_POINT (ppt->x, pt.x, ppt->y == pt.y); ADJUST_END_POINT (ppt->x, pt.x, ppt->y == pt.y);
*data++ = (glitz_short_t) ADJUST_END_POINT (ppt->y, pt.y, 0); *data++ = (glitz_short_t) ADJUST_END_POINT (ppt->y, pt.y, 0);
} }
ppt++; ppt++;
} }
} break; } break;
@ -362,7 +363,7 @@ xglGeometryAddLine (ScreenPtr pScreen,
ADJUST_END_POINT (ppt->x, pt.x, ppt->y == pt.y); ADJUST_END_POINT (ppt->x, pt.x, ppt->y == pt.y);
*data++ = (glitz_float_t) ADJUST_END_POINT (ppt->y, pt.y, 0); *data++ = (glitz_float_t) ADJUST_END_POINT (ppt->y, pt.y, 0);
} }
ppt++; ppt++;
} }
} break; } break;
@ -403,7 +404,7 @@ xglGeometryAddSegment (ScreenPtr pScreen,
pSegInit->y1 == pSegInit->y2); pSegInit->y1 == pSegInit->y2);
*data++ = (glitz_short_t) *data++ = (glitz_short_t)
ADJUST_END_POINT (pSegInit->y1, pSegInit->y2, 0); ADJUST_END_POINT (pSegInit->y1, pSegInit->y2, 0);
pSegInit++; pSegInit++;
} }
} break; } break;
@ -420,12 +421,12 @@ xglGeometryAddSegment (ScreenPtr pScreen,
pSegInit->y1 == pSegInit->y2); pSegInit->y1 == pSegInit->y2);
*data++ = (glitz_float_t) *data++ = (glitz_float_t)
ADJUST_END_POINT (pSegInit->y1, pSegInit->y2, 0); ADJUST_END_POINT (pSegInit->y1, pSegInit->y2, 0);
pSegInit++; pSegInit++;
} }
} break; } break;
} }
UNMAP_GEOMETRY (pGeometry, offset, size); UNMAP_GEOMETRY (pGeometry, offset, size);
} }
@ -449,7 +450,7 @@ xglGeometryForGlyph (ScreenPtr pScreen,
ppci = ppciInit; ppci = ppciInit;
n = nGlyph; n = nGlyph;
while (n--) while (n--)
{ {
pglyph = FONTGLYPHBITS (pglyphBase, *ppci++); pglyph = FONTGLYPHBITS (pglyphBase, *ppci++);
@ -482,7 +483,7 @@ xglGeometryForGlyph (ScreenPtr pScreen,
pglyph = FONTGLYPHBITS (pglyphBase, pci); pglyph = FONTGLYPHBITS (pglyphBase, pci);
gWidth = GLYPHWIDTHPIXELS (pci); gWidth = GLYPHWIDTHPIXELS (pci);
gHeight = GLYPHHEIGHTPIXELS (pci); gHeight = GLYPHHEIGHTPIXELS (pci);
if (gWidth && gHeight) if (gWidth && gHeight)
{ {
gx = x + pci->metrics.leftSideBearing; gx = x + pci->metrics.leftSideBearing;
@ -513,8 +514,8 @@ xglGeometryForGlyph (ScreenPtr pScreen,
(((glitz_float_t) \ (((glitz_float_t) \
((line).p1.x + (xFixed_16_16) \ ((line).p1.x + (xFixed_16_16) \
(((((line).p2.y - (line).p1.y) - 1) + \ (((((line).p2.y - (line).p1.y) - 1) + \
((xFixed_32_32) ((v) - (line).p1.y) * \ ((xFixed_32_32) ((v) - (line).p1.y) * \
((line).p2.x - (line).p1.x))) / \ ((line).p2.x - (line).p1.x))) / \
((line).p2.y - (line).p1.y)))) / 65536) ((line).p2.y - (line).p1.y)))) / 65536)
/* /*
@ -549,7 +550,7 @@ xglGeometryAddTrapezoid (ScreenPtr pScreen,
{ {
top = FIXED_TO_FLOAT (pTrap->top); top = FIXED_TO_FLOAT (pTrap->top);
bottom = FIXED_TO_FLOAT (pTrap->bottom); bottom = FIXED_TO_FLOAT (pTrap->bottom);
*data++ = FIXED_LINE_X_TO_FLOAT (pTrap->left, pTrap->top); *data++ = FIXED_LINE_X_TO_FLOAT (pTrap->left, pTrap->top);
*data++ = top; *data++ = top;
*data++ = FIXED_LINE_X_CEIL_TO_FLOAT (pTrap->right, pTrap->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); top = FIXED_TO_FLOAT (pTrap->top.y);
bottom = FIXED_TO_FLOAT (pTrap->bot.y); bottom = FIXED_TO_FLOAT (pTrap->bot.y);
*data++ = FIXED_TO_FLOAT (pTrap->top.l); *data++ = FIXED_TO_FLOAT (pTrap->top.l);
*data++ = top; *data++ = top;
*data++ = FIXED_TO_FLOAT (pTrap->top.r); *data++ = FIXED_TO_FLOAT (pTrap->top.r);
@ -626,9 +627,9 @@ xglGetScratchGeometryWithSize (ScreenPtr pScreen,
xglGeometryPtr pGeometry; xglGeometryPtr pGeometry;
XGL_SCREEN_PRIV (pScreen); XGL_SCREEN_PRIV (pScreen);
pGeometry = &pScreenPriv->scratchGeometry; pGeometry = &pScreenPriv->scratchGeometry;
if (pGeometry->broken || pGeometry->size < size) if (pGeometry->broken || pGeometry->size < size)
{ {
GEOMETRY_UNINIT (pGeometry); GEOMETRY_UNINIT (pGeometry);
@ -649,7 +650,7 @@ xglGetScratchGeometryWithSize (ScreenPtr pScreen,
pGeometry->count = 0; pGeometry->count = 0;
pGeometry->width = 2; pGeometry->width = 2;
} }
return pGeometry; return pGeometry;
} }
@ -662,17 +663,17 @@ xglGetScratchVertexGeometryWithType (ScreenPtr pScreen,
int stride; int stride;
stride = 2 * xglGeometryDataTypes[type].size; stride = 2 * xglGeometryDataTypes[type].size;
pGeometry = xglGetScratchGeometryWithSize (pScreen, count * stride); pGeometry = xglGetScratchGeometryWithSize (pScreen, count * stride);
pGeometry->type = GLITZ_GEOMETRY_TYPE_VERTEX; pGeometry->type = GLITZ_GEOMETRY_TYPE_VERTEX;
pGeometry->dataType = type; pGeometry->dataType = type;
pGeometry->f.vertex.primitive = GLITZ_PRIMITIVE_QUADS; pGeometry->f.vertex.primitive = GLITZ_PRIMITIVE_QUADS;
pGeometry->f.vertex.type = xglGeometryDataTypes[type].type; pGeometry->f.vertex.type = xglGeometryDataTypes[type].type;
pGeometry->f.vertex.bytes_per_vertex = stride; pGeometry->f.vertex.bytes_per_vertex = stride;
pGeometry->f.vertex.attributes = 0; pGeometry->f.vertex.attributes = 0;
return pGeometry; return pGeometry;
} }
@ -692,22 +693,22 @@ xglGetScratchVertexGeometry (ScreenPtr pScreen,
pGeometry->type = GLITZ_GEOMETRY_TYPE_VERTEX; pGeometry->type = GLITZ_GEOMETRY_TYPE_VERTEX;
pGeometry->dataType = type; pGeometry->dataType = type;
pGeometry->f.vertex.primitive = GLITZ_PRIMITIVE_QUADS; pGeometry->f.vertex.primitive = GLITZ_PRIMITIVE_QUADS;
pGeometry->f.vertex.type = xglGeometryDataTypes[type].type; pGeometry->f.vertex.type = xglGeometryDataTypes[type].type;
pGeometry->f.vertex.bytes_per_vertex = stride; pGeometry->f.vertex.bytes_per_vertex = stride;
pGeometry->f.vertex.attributes = 0; pGeometry->f.vertex.attributes = 0;
return pGeometry; return pGeometry;
} }
Bool Bool
xglSetGeometry (xglGeometryPtr pGeometry, xglSetGeometry (xglGeometryPtr pGeometry,
glitz_surface_t *surface) glitz_surface_t *surface)
{ {
if (pGeometry->broken) if (pGeometry->broken)
return FALSE; return FALSE;
glitz_set_geometry (surface, pGeometry->type, &pGeometry->f, glitz_set_geometry (surface, pGeometry->type, &pGeometry->f,
pGeometry->buffer); pGeometry->buffer);
@ -718,6 +719,6 @@ xglSetGeometry (xglGeometryPtr pGeometry,
glitz_set_array (surface, glitz_set_array (surface,
pGeometry->first, pGeometry->width, pGeometry->count, pGeometry->first, pGeometry->width, pGeometry->count,
pGeometry->xOff, pGeometry->yOff); pGeometry->xOff, pGeometry->yOff);
return TRUE; return TRUE;
} }

View File

@ -1,6 +1,6 @@
/* /*
* Copyright © 2004 David Reveman * Copyright © 2004 David Reveman
* *
* Permission to use, copy, modify, distribute, and sell this software * Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without * and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies * 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 * software for any purpose. It is provided "as is" without express or
* implied warranty. * 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 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * 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 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
@ -39,10 +39,10 @@ xglGetImage (DrawablePtr pDrawable,
glitz_surface_t *surface; glitz_surface_t *surface;
int xOff, yOff; int xOff, yOff;
BoxRec box; BoxRec box;
XGL_SCREEN_PRIV (pScreen); 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 (pDrawable->type == DRAWABLE_WINDOW)
{ {
if (!xglSyncSurface (&pScreenPriv->pScreenPixmap->drawable)) if (!xglSyncSurface (&pScreenPriv->pScreenPixmap->drawable))
@ -61,27 +61,27 @@ xglGetImage (DrawablePtr pDrawable,
if (!xglSyncBits (pDrawable, &box)) if (!xglSyncBits (pDrawable, &box))
FatalError (XGL_SW_FAILURE_STRING); FatalError (XGL_SW_FAILURE_STRING);
XGL_SCREEN_UNWRAP (GetImage); XGL_SCREEN_UNWRAP (GetImage);
(*pScreen->GetImage) (pDrawable, x, y, w, h, format, planeMask, d); (*pScreen->GetImage) (pDrawable, x, y, w, h, format, planeMask, d);
XGL_SCREEN_WRAP (GetImage, xglGetImage); XGL_SCREEN_WRAP (GetImage, xglGetImage);
} }
void void
xglGetSpans (DrawablePtr pDrawable, xglGetSpans (DrawablePtr pDrawable,
int wMax, int wMax,
DDXPointPtr ppt, DDXPointPtr ppt,
int *pwidth, int *pwidth,
int nspans, int nspans,
char *pchardstStart) char *pchardstStart)
{ {
ScreenPtr pScreen = pDrawable->pScreen; ScreenPtr pScreen = pDrawable->pScreen;
XGL_SCREEN_PRIV (pScreen); XGL_SCREEN_PRIV (pScreen);
if (!xglSyncBits (pDrawable, NullBox)) if (!xglSyncBits (pDrawable, NullBox))
FatalError (XGL_SW_FAILURE_STRING); FatalError (XGL_SW_FAILURE_STRING);
XGL_SCREEN_UNWRAP (GetSpans); XGL_SCREEN_UNWRAP (GetSpans);
(*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pchardstStart); (*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pchardstStart);
XGL_SCREEN_WRAP (GetSpans, xglGetSpans); XGL_SCREEN_WRAP (GetSpans, xglGetSpans);

View File

@ -23,62 +23,27 @@
* Author: David Reveman <davidr@novell.com> * Author: David Reveman <davidr@novell.com>
*/ */
#include "xgl.h" #include "xglglx.h"
#ifdef GLXEXT #ifdef GLXEXT
#include "glxserver.h" #ifdef XGL_MODULAR
#include "glxscreens.h" #include <dlfcn.h>
#include "glxext.h" #endif
typedef struct _xglGLXFunc { xglGLXFuncRec __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); #ifndef NGLXEXTLOG
void (*setRenderTables) (__glProcTable *table, FILE *__xglGLXLogFp;
__glProcTableEXT *tableEXT); #endif
} xglGLXFuncRec;
static xglGLXFuncRec __glXFunc;
static void *glXHandle = 0; static void *glXHandle = 0;
static void *glCoreHandle = 0; static void *glCoreHandle = 0;
#define SYM(ptr, name) { (void **) &(ptr), (name) } #define SYM(ptr, name) { (void **) &(ptr), (name) }
__GLXextensionInfo __glDDXExtensionInfo = { __GLXextensionInfo *__xglExtensionInfo;
GL_CORE_MESA, __GLXscreenInfo *__xglScreenInfoPtr;
NULL,
NULL,
NULL
};
__GLXscreenInfo __glDDXScreenInfo = {
NULL,
NULL,
NULL,
NULL,
NULL,
0,
0,
"Vendor String",
"Version String",
"Extensions String",
NULL
};
void void
GlxSetVisualConfigs (int nconfigs, GlxSetVisualConfigs (int nconfigs,
@ -86,21 +51,21 @@ GlxSetVisualConfigs (int nconfigs,
void **privates) void **privates)
{ {
if (glXHandle && glCoreHandle) if (glXHandle && glCoreHandle)
(*__glXFunc.setVisualConfigs) (nconfigs, configs, privates); (*__xglGLXFunc.setVisualConfigs) (nconfigs, configs, privates);
} }
void void
GlxExtensionInit (void) GlxExtensionInit (void)
{ {
if (glXHandle && glCoreHandle) if (glXHandle && glCoreHandle)
(*__glXFunc.extensionInit) (); (*__xglGLXFunc.extensionInit) ();
} }
void void
GlxWrapInitVisuals (miInitVisualsProcPtr *initVisuals) GlxWrapInitVisuals (miInitVisualsProcPtr *initVisuals)
{ {
if (glXHandle && glCoreHandle) if (glXHandle && glCoreHandle)
(*__glXFunc.wrapInitVisuals) (initVisuals); (*__xglGLXFunc.wrapInitVisuals) (initVisuals);
} }
int int
@ -115,9 +80,9 @@ GlxInitVisuals (VisualPtr *visualp,
int preferredVis) int preferredVis)
{ {
if (glXHandle && glCoreHandle) if (glXHandle && glCoreHandle)
return (*__glXFunc.initVisuals) (visualp, depthp, nvisualp, ndepthp, return (*__xglGLXFunc.initVisuals) (visualp, depthp, nvisualp, ndepthp,
rootDepthp, defaultVisp, sizes, rootDepthp, defaultVisp, sizes,
bitsPerRGB, preferredVis); bitsPerRGB, preferredVis);
return 0; return 0;
} }
@ -125,16 +90,59 @@ GlxInitVisuals (VisualPtr *visualp,
void void
GlxFlushContextCache (void) GlxFlushContextCache (void)
{ {
(*__glXFunc.flushContextCache) (); (*__xglGLXFunc.flushContextCache) ();
} }
void void
GlxSetRenderTables (__glProcTable *table, GlxSetRenderTables (struct _glapi_table *table)
__glProcTableEXT *tableEXT)
{ {
(*__glXFunc.setRenderTables) (table, tableEXT); (*__xglGLXFunc.setRenderTables) (table);
} }
struct _glapi_table *_mglapi_Dispatch;
void *(*__glcore_DDXScreenInfo)(void);
void *__glXglDDXScreenInfo(void)
{
return __xglScreenInfoPtr;
}
void *(*__glcore_DDXExtensionInfo)(void);
void *__glXglDDXExtensionInfo(void)
{
return __xglExtensionInfo;
}
void _gl_copy_visual_to_context_mode( __GLcontextModes * mode,
const __GLXvisualConfig * config )
{
(*__xglGLXFunc.copy_visual_to_context_mode)(mode, config);
}
__GLcontextModes *_gl_context_modes_create( unsigned count, size_t minimum_size )
{
return (*__xglGLXFunc.context_modes_create)(count, minimum_size);
}
void _gl_context_modes_destroy( __GLcontextModes * modes )
{
(*__xglGLXFunc.context_modes_destroy)(modes);
}
GLint _gl_convert_from_x_visual_type( int visualType )
{
return (*__xglGLXFunc.convert_from_x_visual_type)(visualType);
}
GLint _gl_convert_to_x_visual_type( int visualType )
{
return (*__xglGLXFunc.convert_to_x_visual_type)(visualType);
}
Bool Bool
xglLoadGLXModules (void) xglLoadGLXModules (void)
{ {
@ -143,15 +151,20 @@ xglLoadGLXModules (void)
if (!glXHandle) if (!glXHandle)
{ {
xglSymbolRec sym[] = { xglSymbolRec sym[] = {
SYM (__glXFunc.extensionInit, "GlxExtensionInit"), SYM (__xglGLXFunc.extensionInit, "GlxExtensionInit"),
SYM (__glXFunc.setVisualConfigs, "GlxSetVisualConfigs"), SYM (__xglGLXFunc.setVisualConfigs, "GlxSetVisualConfigs"),
SYM (__glXFunc.wrapInitVisuals, "GlxWrapInitVisuals"), SYM (__xglGLXFunc.wrapInitVisuals, "GlxWrapInitVisuals"),
SYM (__glXFunc.initVisuals, "GlxInitVisuals"), SYM (__xglGLXFunc.initVisuals, "GlxInitVisuals"),
SYM (__glXFunc.flushContextCache, "GlxFlushContextCache"), SYM (__xglGLXFunc.flushContextCache, "__glXFlushContextCache"),
SYM (__glXFunc.setRenderTables, "GlxSetRenderTables") 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) if (!glXHandle)
return FALSE; return FALSE;
@ -166,27 +179,48 @@ xglLoadGLXModules (void)
if (!glCoreHandle) if (!glCoreHandle)
{ {
xglSymbolRec sym[] = { xglSymbolRec ddxsym[] = {
SYM (__glDDXScreenInfo.screenProbe, "__MESA_screenProbe"), SYM (__glcore_DDXExtensionInfo, "__glXglDDXExtensionInfo"),
SYM (__glDDXScreenInfo.createContext, "__MESA_createContext"), SYM (__glcore_DDXScreenInfo, "__glXglDDXScreenInfo")
SYM (__glDDXScreenInfo.createBuffer, "__MESA_createBuffer"), };
SYM (__glDDXExtensionInfo.resetExtension, "__MESA_resetExtension"), glCoreHandle = xglLoadModule ("glcore", RTLD_NOW | RTLD_LOCAL);
SYM (__glDDXExtensionInfo.initVisuals, "__MESA_initVisuals"),
SYM (__glDDXExtensionInfo.setVisualConfigs,
"__MESA_setVisualConfigs")
};
glCoreHandle = xglLoadModule ("glcore");
if (!glCoreHandle) if (!glCoreHandle)
return FALSE; 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); xglUnloadModule (glCoreHandle);
glCoreHandle = 0; glCoreHandle = 0;
return FALSE; return FALSE;
}
} }
if (!xglLoadHashFuncs (glCoreHandle)) if (!xglLoadHashFuncs (glCoreHandle))

79
hw/xgl/xglglx.h Normal file
View File

@ -0,0 +1,79 @@
/*
* Copyright © 2005 Novell, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies
* and that both that copyright notice and this permission notice
* appear in supporting documentation, and that the name of
* Novell, Inc. not be used in advertising or publicity pertaining to
* distribution of the software without specific, written prior permission.
* Novell, Inc. makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Author: David Reveman <davidr@novell.com>
*/
#include "xgl.h"
#ifdef GLXEXT
#include "glxserver.h"
#include "glxscreens.h"
#include "glxext.h"
#include "glapitable.h"
typedef struct _xglGLXFunc {
void (*extensionInit) (void);
void (*setVisualConfigs) (int nconfigs,
__GLXvisualConfig *configs,
void **privates);
void (*wrapInitVisuals) (miInitVisualsProcPtr *initVisuals);
int (*initVisuals) (VisualPtr *visualp,
DepthPtr *depthp,
int *nvisualp,
int *ndepthp,
int *rootDepthp,
VisualID *defaultVisp,
unsigned long sizes,
int bitsPerRGB,
int preferredVis);
void (*flushContextCache) (void);
void *(*DDXExtensionInfo) (void);
void *(*DDXScreenInfo) (void);
void (*setRenderTables) (struct _glapi_table *table);
void (*copy_visual_to_context_mode)( __GLcontextModes *mode, const __GLXvisualConfig *config );
__GLcontextModes *(*context_modes_create)( unsigned count, size_t minimum_size );
void (*context_modes_destroy)( __GLcontextModes * modes );
GLint (*convert_from_x_visual_type)( int visualType );
GLint (*convert_to_x_visual_type)( int visualType );
} xglGLXFuncRec, *xglGLXFuncPtr;
extern xglGLXFuncRec __xglGLXFunc;
#ifndef NGLXEXTLOG
extern FILE *__xglGLXLogFp;
#endif
/* xglglx.c */
Bool
xglLoadGLXModules (void);
void
xglUnloadGLXModules (void);
#endif

View File

@ -1,6 +1,6 @@
/* /*
* Copyright © 2005 Novell, Inc. * Copyright © 2005 Novell, Inc.
* *
* Permission to use, copy, modify, distribute, and sell this software * Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without * and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies * 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 * software for any purpose. It is provided "as is" without express or
* implied warranty. * 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 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * 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 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
@ -163,9 +163,9 @@ xglRealizeGlyph (ScreenPtr pScreen,
XGL_PICTURE_SCREEN_UNWRAP (RealizeGlyph); XGL_PICTURE_SCREEN_UNWRAP (RealizeGlyph);
ret = (*pPictureScreen->RealizeGlyph) (pScreen, pGlyph); ret = (*pPictureScreen->RealizeGlyph) (pScreen, pGlyph);
XGL_PICTURE_SCREEN_WRAP (RealizeGlyph, xglRealizeGlyph); XGL_PICTURE_SCREEN_WRAP (RealizeGlyph, xglRealizeGlyph);
pGlyphPriv->pArea = NULL; pGlyphPriv->pArea = NULL;
return ret; return ret;
} }
@ -205,7 +205,7 @@ xglInitGlyphCache (xglGlyphCachePtr pCache,
if (pCache->depth == 1) if (pCache->depth == 1)
{ {
int stride; int stride;
GEOMETRY_INIT (pScreen, &pCache->u.geometry, GEOMETRY_INIT (pScreen, &pCache->u.geometry,
GLITZ_GEOMETRY_TYPE_VERTEX, GLITZ_GEOMETRY_TYPE_VERTEX,
GEOMETRY_USAGE_STATIC, BITMAP_CACHE_SIZE); GEOMETRY_USAGE_STATIC, BITMAP_CACHE_SIZE);
@ -228,9 +228,14 @@ xglInitGlyphCache (xglGlyphCachePtr pCache,
{ {
xglGlyphTexturePtr pTexture = &pCache->u.texture; xglGlyphTexturePtr pTexture = &pCache->u.texture;
glitz_surface_t *mask;
glitz_surface_attributes_t attr; glitz_surface_attributes_t attr;
xglPixmapFormatPtr pFormat;
glitz_vertex_format_t *vertex; glitz_vertex_format_t *vertex;
xglVisualPtr pVisual;
pVisual = xglFindVisualWithDepth (pScreen, format->depth);
if (!pVisual)
return FALSE;
if (!xglRootAreaInit (&pCache->rootArea, if (!xglRootAreaInit (&pCache->rootArea,
TEXTURE_CACHE_MAX_LEVEL, TEXTURE_CACHE_MAX_LEVEL,
@ -240,39 +245,46 @@ xglInitGlyphCache (xglGlyphCachePtr pCache,
(pointer) pCache)) (pointer) pCache))
return FALSE; return FALSE;
pFormat = &pScreenPriv->pixmapFormats[format->depth];
if (pScreenPriv->geometryDataType == GEOMETRY_DATA_TYPE_SHORT) if (pScreenPriv->geometryDataType == GEOMETRY_DATA_TYPE_SHORT)
{ {
attr.unnormalized = 1; attr.unnormalized = 1;
pTexture->mask = mask = glitz_surface_create (pScreenPriv->drawable,
glitz_surface_create (pScreenPriv->drawable, pFormat->format, pVisual->format.surface,
TEXTURE_CACHE_SIZE, TEXTURE_CACHE_SIZE, TEXTURE_CACHE_SIZE,
GLITZ_SURFACE_UNNORMALIZED_MASK, &attr); TEXTURE_CACHE_SIZE,
} else GLITZ_SURFACE_UNNORMALIZED_MASK,
pTexture->mask = NULL; &attr);
}
if (!pTexture->mask) else
mask = NULL;
if (!mask)
{ {
pTexture->mask = mask = glitz_surface_create (pScreenPriv->drawable,
glitz_surface_create (pScreenPriv->drawable, pFormat->format, pVisual->format.surface,
TEXTURE_CACHE_SIZE, TEXTURE_CACHE_SIZE, TEXTURE_CACHE_SIZE,
0, NULL); TEXTURE_CACHE_SIZE,
if (!pTexture->mask) 0, NULL);
if (!mask)
return FALSE; return FALSE;
pTexture->geometryDataType = GEOMETRY_DATA_TYPE_FLOAT; pTexture->geometryDataType = GEOMETRY_DATA_TYPE_FLOAT;
} else }
else
pTexture->geometryDataType = GEOMETRY_DATA_TYPE_SHORT; pTexture->geometryDataType = GEOMETRY_DATA_TYPE_SHORT;
if (NEEDS_COMPONENT (format->format)) 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 = &pCache->u.texture.format.vertex;
vertex->primitive = GLITZ_PRIMITIVE_QUADS; vertex->primitive = GLITZ_PRIMITIVE_QUADS;
vertex->mask.size = GLITZ_COORDINATE_SIZE_XY; vertex->mask.size = GLITZ_COORDINATE_SIZE_XY;
vertex->attributes = GLITZ_VERTEX_ATTRIBUTE_MASK_COORD_MASK; vertex->attributes = GLITZ_VERTEX_ATTRIBUTE_MASK_COORD_MASK;
if (pTexture->geometryDataType == GEOMETRY_DATA_TYPE_FLOAT) if (pTexture->geometryDataType == GEOMETRY_DATA_TYPE_FLOAT)
{ {
vertex->type = GLITZ_DATA_TYPE_FLOAT; vertex->type = GLITZ_DATA_TYPE_FLOAT;
@ -288,13 +300,14 @@ xglInitGlyphCache (xglGlyphCachePtr pCache,
vertex->mask.type = GLITZ_DATA_TYPE_SHORT; 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.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP;
pTexture->pixel.bytes_per_line = 0; pTexture->pixel.bytes_per_line = 0;
pTexture->pixel.xoffset = 0; pTexture->pixel.xoffset = 0;
pTexture->pixel.skip_lines = 0; pTexture->pixel.skip_lines = 0;
} }
pCache->pScreen = pScreen; pCache->pScreen = pScreen;
return TRUE; return TRUE;
@ -306,17 +319,17 @@ xglFiniGlyphCache (xglGlyphCachePtr pCache)
if (pCache->pScreen) if (pCache->pScreen)
{ {
xglRootAreaFini (&pCache->rootArea); xglRootAreaFini (&pCache->rootArea);
if (pCache->depth == 1) if (pCache->depth == 1)
{ {
GEOMETRY_UNINIT (&pCache->u.geometry); GEOMETRY_UNINIT (&pCache->u.geometry);
} }
else else
{ {
if (pCache->u.texture.mask) if (pCache->u.texture.pMask)
glitz_surface_destroy (pCache->u.texture.mask); FreePicture ((pointer) pCache->u.texture.pMask, 0);
} }
pCache->pScreen = NULL; pCache->pScreen = NULL;
} }
} }
@ -326,24 +339,24 @@ xglCacheGlyph (xglGlyphCachePtr pCache,
GlyphPtr pGlyph) GlyphPtr pGlyph)
{ {
ScreenPtr pScreen = pCache->pScreen; ScreenPtr pScreen = pCache->pScreen;
XGL_GLYPH_PRIV (pScreen, pGlyph); XGL_GLYPH_PRIV (pScreen, pGlyph);
if (pCache->depth == 1) if (pCache->depth == 1)
{ {
PixmapPtr pPixmap; PixmapPtr pPixmap;
RegionPtr pRegion; RegionPtr pRegion;
int nBox; int nBox;
pPixmap = GetScratchPixmapHeader (pScreen, pPixmap = GetScratchPixmapHeader (pScreen,
pGlyph->info.width, pGlyph->info.width,
pGlyph->info.height, pGlyph->info.height,
pCache->depth, pCache->depth, 0, pCache->depth, pCache->depth, 0,
(pointer) (pGlyph + 1)); (pointer) (pGlyph + 1));
if (!pPixmap) if (!pPixmap)
return NULL; return NULL;
(*pScreen->ModifyPixmapHeader) (pPixmap, (*pScreen->ModifyPixmapHeader) (pPixmap,
pGlyph->info.width, pGlyph->info.width,
pGlyph->info.height, pGlyph->info.height,
0, 0, -1, (pointer) (pGlyph + 1)); 0, 0, -1, (pointer) (pGlyph + 1));
@ -366,7 +379,7 @@ xglCacheGlyph (xglGlyphCachePtr pCache,
/* Find available area */ /* Find available area */
if (!xglFindArea (pCache->rootArea.pArea, nBox, 0, if (!xglFindArea (pCache->rootArea.pArea, nBox, 0,
FALSE, (pointer) pGlyph)) FALSE, (pointer) pGlyph))
{ {
/* Kicking out area with lower score */ /* Kicking out area with lower score */
xglFindArea (pCache->rootArea.pArea, nBox, 0, xglFindArea (pCache->rootArea.pArea, nBox, 0,
TRUE, (pointer) pGlyph); TRUE, (pointer) pGlyph);
@ -375,7 +388,7 @@ xglCacheGlyph (xglGlyphCachePtr pCache,
if (pGlyphPriv->pArea) if (pGlyphPriv->pArea)
{ {
int stride; int stride;
GLYPH_AREA_PRIV (pGlyphPriv->pArea); GLYPH_AREA_PRIV (pGlyphPriv->pArea);
pAreaPriv->serial = glyphSerialNumber; pAreaPriv->serial = glyphSerialNumber;
@ -388,7 +401,7 @@ xglCacheGlyph (xglGlyphCachePtr pCache,
} }
} else } else
pGlyphPriv->pArea = &zeroSizeArea; pGlyphPriv->pArea = &zeroSizeArea;
REGION_DESTROY (pScreen, pRegion); REGION_DESTROY (pScreen, pRegion);
} }
else else
@ -398,11 +411,11 @@ xglCacheGlyph (xglGlyphCachePtr pCache,
if (pGlyph->info.width > TEXTURE_CACHE_MAX_WIDTH || if (pGlyph->info.width > TEXTURE_CACHE_MAX_WIDTH ||
pGlyph->info.height > TEXTURE_CACHE_MAX_HEIGHT) pGlyph->info.height > TEXTURE_CACHE_MAX_HEIGHT)
return NULL; return NULL;
if (pGlyph->info.width > 0 && pGlyph->info.height > 0) if (pGlyph->info.width > 0 && pGlyph->info.height > 0)
{ {
glitz_buffer_t *buffer; glitz_buffer_t *buffer;
buffer = glitz_buffer_create_for_data (pGlyph + 1); buffer = glitz_buffer_create_for_data (pGlyph + 1);
if (!buffer) if (!buffer)
return NULL; return NULL;
@ -417,19 +430,22 @@ xglCacheGlyph (xglGlyphCachePtr pCache,
pGlyph->info.width, pGlyph->info.height, pGlyph->info.width, pGlyph->info.height,
TRUE, (pointer) pGlyph); TRUE, (pointer) pGlyph);
} }
if (pGlyphPriv->pArea) if (pGlyphPriv->pArea)
{ {
glitz_surface_t *surface;
glitz_point_fixed_t p1, p2; glitz_point_fixed_t p1, p2;
glitz_pixel_format_t pixel; glitz_pixel_format_t pixel;
GLYPH_AREA_PRIV (pGlyphPriv->pArea); GLYPH_AREA_PRIV (pGlyphPriv->pArea);
pixel = pTexture->pixel; pixel = pTexture->pixel;
pixel.bytes_per_line = pixel.bytes_per_line =
PixmapBytePad (pGlyph->info.width, pCache->depth); 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->x,
pGlyphPriv->pArea->y, pGlyphPriv->pArea->y,
pGlyph->info.width, pGlyph->info.width,
@ -441,10 +457,10 @@ xglCacheGlyph (xglGlyphCachePtr pCache,
p1.y = pGlyphPriv->pArea->y << 16; p1.y = pGlyphPriv->pArea->y << 16;
p2.x = (pGlyphPriv->pArea->x + pGlyph->info.width) << 16; p2.x = (pGlyphPriv->pArea->x + pGlyph->info.width) << 16;
p2.y = (pGlyphPriv->pArea->y + pGlyph->info.height) << 16; p2.y = (pGlyphPriv->pArea->y + pGlyph->info.height) << 16;
glitz_surface_translate_point (pTexture->mask, &p1, &p1); glitz_surface_translate_point (surface, &p1, &p1);
glitz_surface_translate_point (pTexture->mask, &p2, &p2); glitz_surface_translate_point (surface, &p2, &p2);
pAreaPriv->serial = glyphSerialNumber; pAreaPriv->serial = glyphSerialNumber;
if (pTexture->geometryDataType) if (pTexture->geometryDataType)
{ {
@ -465,7 +481,7 @@ xglCacheGlyph (xglGlyphCachePtr pCache,
} else } else
pGlyphPriv->pArea = &zeroSizeArea; pGlyphPriv->pArea = &zeroSizeArea;
} }
return pGlyphPriv->pArea; return pGlyphPriv->pArea;
} }
@ -499,7 +515,7 @@ xglUncachedGlyphs (CARD8 op,
usingCache = FALSE; usingCache = FALSE;
} }
} }
while (pOp->nGlyphs) while (pOp->nGlyphs)
{ {
glyph = *pOp->ppGlyphs; glyph = *pOp->ppGlyphs;
@ -511,7 +527,7 @@ xglUncachedGlyphs (CARD8 op,
pOp->xOff += pOp->pLists->xOff; pOp->xOff += pOp->pLists->xOff;
pOp->yOff += pOp->pLists->yOff; pOp->yOff += pOp->pLists->yOff;
} }
xOff = pOp->xOff; xOff = pOp->xOff;
yOff = pOp->yOff; yOff = pOp->yOff;
@ -523,7 +539,7 @@ xglUncachedGlyphs (CARD8 op,
{ {
if (!pArea) if (!pArea)
pArea = xglCacheGlyph (pCache, glyph); pArea = xglCacheGlyph (pCache, glyph);
if (pArea) if (pArea)
break; break;
} }
@ -533,26 +549,26 @@ xglUncachedGlyphs (CARD8 op,
pOp->listLen--; pOp->listLen--;
pOp->nGlyphs--; pOp->nGlyphs--;
pOp->ppGlyphs++; pOp->ppGlyphs++;
pOp->xOff += glyph->info.xOff; pOp->xOff += glyph->info.xOff;
pOp->yOff += glyph->info.yOff; pOp->yOff += glyph->info.yOff;
if (pArea) if (pArea)
continue; continue;
if (!pPicture) if (!pPicture)
{ {
CARD32 componentAlpha; XID componentAlpha;
int error; int error;
pPixmap = GetScratchPixmapHeader (pScreen, pPixmap = GetScratchPixmapHeader (pScreen,
glyph->info.width, glyph->info.width,
glyph->info.height, glyph->info.height,
depth, depth, depth, depth,
0, (pointer) (glyph + 1)); 0, (pointer) (glyph + 1));
if (!pPixmap) if (!pPixmap)
return; return;
componentAlpha = NEEDS_COMPONENT (pOp->pLists->format->format); componentAlpha = NEEDS_COMPONENT (pOp->pLists->format->format);
pPicture = CreatePicture (0, &pPixmap->drawable, pPicture = CreatePicture (0, &pPixmap->drawable,
pOp->pLists->format, pOp->pLists->format,
@ -564,8 +580,8 @@ xglUncachedGlyphs (CARD8 op,
return; return;
} }
} }
(*pScreen->ModifyPixmapHeader) (pPixmap, (*pScreen->ModifyPixmapHeader) (pPixmap,
glyph->info.width, glyph->info.height, glyph->info.width, glyph->info.height,
0, 0, -1, (pointer) (glyph + 1)); 0, 0, -1, (pointer) (glyph + 1));
pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER; pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
@ -594,7 +610,7 @@ xglUncachedGlyphs (CARD8 op,
glyph->info.width, glyph->info.width,
glyph->info.height); glyph->info.height);
} }
if (pPicture) if (pPicture)
{ {
FreeScratchPixmapHeader (pPixmap); FreeScratchPixmapHeader (pPixmap);
@ -624,10 +640,10 @@ xglCachedGlyphs (CARD8 op,
int depth = pOp->pLists->format->depth; int depth = pOp->pLists->format->depth;
int i, remaining = pOp->nGlyphs; int i, remaining = pOp->nGlyphs;
int nGlyph = 0; int nGlyph = 0;
glitz_surface_t *mask = NULL; PicturePtr pMaskPicture = NULL;
XGL_SCREEN_PRIV (pScreen); XGL_SCREEN_PRIV (pScreen);
pCache = &pScreenPriv->glyphCache[depth]; pCache = &pScreenPriv->glyphCache[depth];
if (!pCache->pScreen) if (!pCache->pScreen)
{ {
@ -663,23 +679,23 @@ xglCachedGlyphs (CARD8 op,
else if (pSrc) else if (pSrc)
break; break;
} }
if (nGlyph) if (nGlyph)
{ {
if (depth == 1) if (depth == 1)
{ {
glitz_multi_array_t *multiArray; glitz_multi_array_t *multiArray;
pGeometry = &pCache->u.geometry; pGeometry = &pCache->u.geometry;
pGeometry->xOff = pGeometry->yOff = 0; pGeometry->xOff = pGeometry->yOff = 0;
multiArray = glitz_multi_array_create (nGlyph); multiArray = glitz_multi_array_create (nGlyph);
if (!multiArray) if (!multiArray)
return 1; return 1;
GEOMETRY_SET_MULTI_ARRAY (pGeometry, multiArray); GEOMETRY_SET_MULTI_ARRAY (pGeometry, multiArray);
glitz_multi_array_destroy (multiArray); glitz_multi_array_destroy (multiArray);
vData.array.lastX = 0; vData.array.lastX = 0;
vData.array.lastY = 0; vData.array.lastY = 0;
} }
@ -687,11 +703,11 @@ xglCachedGlyphs (CARD8 op,
{ {
i = 4 * pCache->u.texture.format.vertex.bytes_per_vertex * nGlyph; i = 4 * pCache->u.texture.format.vertex.bytes_per_vertex * nGlyph;
pGeometry = xglGetScratchGeometryWithSize (pScreen, i); pGeometry = xglGetScratchGeometryWithSize (pScreen, i);
pGeometry->f = pCache->u.texture.format; pGeometry->f = pCache->u.texture.format;
pGeometry->type = GLITZ_GEOMETRY_TYPE_VERTEX; pGeometry->type = GLITZ_GEOMETRY_TYPE_VERTEX;
mask = pCache->u.texture.mask; pMaskPicture = pCache->u.texture.pMask;
vData.list.s = glitz_buffer_map (pGeometry->buffer, vData.list.s = glitz_buffer_map (pGeometry->buffer,
GLITZ_BUFFER_ACCESS_WRITE_ONLY); GLITZ_BUFFER_ACCESS_WRITE_ONLY);
} }
@ -714,7 +730,7 @@ xglCachedGlyphs (CARD8 op,
pOp->xOff += pOp->pLists->xOff; pOp->xOff += pOp->pLists->xOff;
pOp->yOff += pOp->pLists->yOff; pOp->yOff += pOp->pLists->yOff;
} }
xOff = pOp->xOff; xOff = pOp->xOff;
yOff = pOp->yOff; yOff = pOp->yOff;
@ -726,7 +742,7 @@ xglCachedGlyphs (CARD8 op,
pOp->listLen--; pOp->listLen--;
pOp->nGlyphs--; pOp->nGlyphs--;
pOp->ppGlyphs++; pOp->ppGlyphs++;
pOp->xOff += glyph->info.xOff; pOp->xOff += glyph->info.xOff;
pOp->yOff += glyph->info.yOff; pOp->yOff += glyph->info.yOff;
@ -739,7 +755,7 @@ xglCachedGlyphs (CARD8 op,
extents.x1 = x1; extents.x1 = x1;
if (x2 > extents.x2) if (x2 > extents.x2)
extents.x2 = x2; extents.x2 = x2;
y1 = yOff - glyph->info.y; y1 = yOff - glyph->info.y;
y2 = y1 + glyph->info.height; y2 = y1 + glyph->info.height;
if (y1 < extents.y1) if (y1 < extents.y1)
@ -786,7 +802,7 @@ xglCachedGlyphs (CARD8 op,
glitz_buffer_unmap (pGeometry->buffer); glitz_buffer_unmap (pGeometry->buffer);
pGeometry->count = nGlyph * 4; pGeometry->count = nGlyph * 4;
} }
xSrc += extents.x1; xSrc += extents.x1;
ySrc += extents.y1; ySrc += extents.y1;
@ -794,27 +810,26 @@ xglCachedGlyphs (CARD8 op,
{ {
op = PictOpAdd; op = PictOpAdd;
pSrc = pScreenPriv->pSolidAlpha; pSrc = pScreenPriv->pSolidAlpha;
if (remaining) if (remaining)
*pOp = opSave; *pOp = opSave;
} }
GEOMETRY_TRANSLATE (pGeometry, GEOMETRY_TRANSLATE (pGeometry,
pDst->pDrawable->x, pDst->pDrawable->x,
pDst->pDrawable->y); pDst->pDrawable->y);
if (xglComp (op, if (xglCompositeGeneral (op,
pSrc, pSrc,
NULL, pMaskPicture,
pDst, pDst,
xSrc, ySrc, pGeometry,
0, 0, xSrc, ySrc,
pDst->pDrawable->x + extents.x1, 0, 0,
pDst->pDrawable->y + extents.y1, pDst->pDrawable->x + extents.x1,
extents.x2 - extents.x1, pDst->pDrawable->y + extents.y1,
extents.y2 - extents.y1, extents.x2 - extents.x1,
pGeometry, extents.y2 - extents.y1))
mask))
{ {
xglAddCurrentBitDamage (pDst->pDrawable); xglAddCurrentBitDamage (pDst->pDrawable);
return remaining; return remaining;
@ -857,7 +872,7 @@ xglGlyphExtents (PicturePtr pDst,
extents->x1 = MAXSHORT; extents->x1 = MAXSHORT;
extents->x2 = MINSHORT; extents->x2 = MINSHORT;
extents->y1 = MAXSHORT; extents->y1 = MAXSHORT;
extents->y2 = MINSHORT; extents->y2 = MINSHORT;
while (!list->len) while (!list->len)
{ {
@ -892,7 +907,7 @@ xglGlyphExtents (PicturePtr pDst,
y += list->yOff; y += list->yOff;
n = list->len; n = list->len;
list++; list++;
while (n--) while (n--)
{ {
glyph = *glyphs++; glyph = *glyphs++;
@ -945,7 +960,7 @@ xglGlyphExtents (PicturePtr pDst,
extents->y1 = line.y1; extents->y1 = line.y1;
if (line.y2 > extents->y2) if (line.y2 > extents->y2)
extents->y2 = line.y2; extents->y2 = line.y2;
overlap = TRUE; overlap = TRUE;
} }
@ -959,7 +974,7 @@ xglGlyphExtents (PicturePtr pDst,
line.x2 = x2; line.x2 = x2;
line.y2 = y2; line.y2 = y2;
} }
x += glyph->info.xOff; x += glyph->info.xOff;
y += glyph->info.yOff; y += glyph->info.yOff;
} }
@ -983,15 +998,15 @@ xglGlyphExtents (PicturePtr pDst,
extents->y1 = line.y1; extents->y1 = line.y1;
if (line.y2 > extents->y2) if (line.y2 > extents->y2)
extents->y2 = line.y2; extents->y2 = line.y2;
overlap = TRUE; overlap = TRUE;
} }
if (line.x1 < extents->x1) if (line.x1 < extents->x1)
extents->x1 = line.x1; extents->x1 = line.x1;
if (line.x2 > extents->x2) if (line.x2 > extents->x2)
extents->x2 = line.x2; extents->x2 = line.x2;
xglPictureClipExtents (pDst, extents); xglPictureClipExtents (pDst, extents);
return overlap; return overlap;
@ -1006,7 +1021,7 @@ xglGlyphListFormatId (GlyphListPtr list,
nlist--; nlist--;
list++; list++;
while (nlist--) while (nlist--)
{ {
if (list->format->id != id) if (list->format->id != id)
@ -1037,20 +1052,18 @@ xglGlyphs (CARD8 op,
int overlap; int overlap;
int target; int target;
XGL_DRAWABLE_PIXMAP_PRIV (pDst->pDrawable);
overlap = xglGlyphExtents (pDst, nlist, list, glyphs, &extents); overlap = xglGlyphExtents (pDst, nlist, list, glyphs, &extents);
if (extents.x2 <= extents.x1 || extents.y2 <= extents.y1) if (extents.x2 <= extents.x1 || extents.y2 <= extents.y1)
return; return;
target = xglPrepareTarget (pDst->pDrawable); target = xglPrepareTarget (pDst->pDrawable);
if (op != PictOpAdd && maskFormat && if (op != PictOpAdd && maskFormat &&
(overlap || op != PictOpOver || (!target || overlap || op != PictOpOver ||
xglGlyphListFormatId (list, nlist) != maskFormat->id)) xglGlyphListFormatId (list, nlist) != maskFormat->id))
{ {
PixmapPtr pPixmap; PixmapPtr pPixmap;
CARD32 componentAlpha; XID componentAlpha;
GCPtr pGC; GCPtr pGC;
xRectangle rect; xRectangle rect;
int error; int error;
@ -1065,7 +1078,7 @@ xglGlyphs (CARD8 op,
maskFormat->depth); maskFormat->depth);
if (!pPixmap) if (!pPixmap)
return; return;
componentAlpha = NEEDS_COMPONENT (maskFormat->format); componentAlpha = NEEDS_COMPONENT (maskFormat->format);
pMask = CreatePicture (0, &pPixmap->drawable, pMask = CreatePicture (0, &pPixmap->drawable,
maskFormat, CPComponentAlpha, &componentAlpha, maskFormat, CPComponentAlpha, &componentAlpha,
@ -1076,12 +1089,11 @@ xglGlyphs (CARD8 op,
return; return;
} }
/* make sure destination drawable is locked */
pPixmapPriv->lock++;
/* lock mask if we are not doing accelerated drawing to destination */
if (!target) if (!target)
XGL_GET_PIXMAP_PRIV (pPixmap)->lock = 1; {
/* make sure we don't do accelerated drawing to mask */
xglSetPixmapVisual (pPixmap, NULL);
}
ValidatePicture (pMask); ValidatePicture (pMask);
pGC = GetScratchGC (pPixmap->drawable.depth, pScreen); pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
@ -1092,7 +1104,7 @@ xglGlyphs (CARD8 op,
(*pScreen->DestroyPixmap) (pPixmap); (*pScreen->DestroyPixmap) (pPixmap);
target = xglPrepareTarget (pMask->pDrawable); target = xglPrepareTarget (pMask->pDrawable);
glyphOp.xOff = -extents.x1; glyphOp.xOff = -extents.x1;
glyphOp.yOff = -extents.y1; glyphOp.yOff = -extents.y1;
pSrcPicture = NULL; pSrcPicture = NULL;
@ -1100,9 +1112,6 @@ xglGlyphs (CARD8 op,
} }
else else
{ {
/* make sure destination drawable is locked */
pPixmapPriv->lock++;
glyphOp.xOff = 0; glyphOp.xOff = 0;
glyphOp.yOff = 0; glyphOp.yOff = 0;
pSrcPicture = pSrc; pSrcPicture = pSrc;
@ -1119,12 +1128,12 @@ xglGlyphs (CARD8 op,
glyphOp.listLen = list->len; glyphOp.listLen = list->len;
glyphOp.nGlyphs = list->len; glyphOp.nGlyphs = list->len;
glyphOp.pLists = list++; glyphOp.pLists = list++;
for (; nlist; nlist--, list++) for (; nlist; nlist--, list++)
{ {
if (list->format->id != glyphOp.pLists->format->id) if (list->format->id != glyphOp.pLists->format->id)
break; break;
glyphOp.nGlyphs += list->len; glyphOp.nGlyphs += list->len;
} }
@ -1142,26 +1151,19 @@ xglGlyphs (CARD8 op,
&glyphOp); &glyphOp);
} }
} }
if (pMask) if (pMask)
{ {
CompositePicture (op, CompositePicture (op, pSrc, pMask, pDst,
pSrc,
pMask,
pDst,
xSrc + extents.x1 - xDst, xSrc + extents.x1 - xDst,
ySrc + extents.y1 - yDst, ySrc + extents.y1 - yDst,
0, 0, 0, 0,
extents.x1, extents.y1, extents.x1, extents.y1,
extents.x2 - extents.x1, extents.x2 - extents.x1,
extents.y2 - extents.y1); extents.y2 - extents.y1);
FreePicture ((pointer) pMask, (XID) 0); FreePicture ((pointer) pMask, (XID) 0);
} }
/* release destination drawable lock */
pPixmapPriv->lock--;
} }
#endif #endif

View File

@ -24,26 +24,41 @@
*/ */
#include "xgl.h" #include "xgl.h"
#include "xglglx.h"
#include "micmap.h" #include "micmap.h"
#include "mipointer.h" #include "mipointer.h"
#include "fb.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 = { xglScreenInfoRec xglScreenInfo = {
NULL, 0, 0, 0, 0, NULL, 0, 0, 0, 0, 0,
DEFAULT_GEOMETRY_DATA_TYPE, DEFAULT_GEOMETRY_DATA_TYPE,
DEFAULT_GEOMETRY_USAGE, DEFAULT_GEOMETRY_USAGE,
FALSE, FALSE,
XGL_DEFAULT_PBO_MASK, XGL_DEFAULT_PBO_MASK,
FALSE, 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 #ifdef GLXEXT
static Bool loadGlx = TRUE; static Bool loadGlx = TRUE;
#ifndef NGLXEXTLOG
static char *glxExtLogFile = 0;
#endif
#endif #endif
typedef struct _xglDDXFunc { typedef struct _xglDDXFunc {
@ -105,6 +120,29 @@ xglEnsureDDXModule (void)
if (!status) if (!status)
return FALSE; 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) if (!ddxHandle)
{ {
xglSymbolRec sym[] = { xglSymbolRec sym[] = {
@ -119,7 +157,7 @@ xglEnsureDDXModule (void)
SYM (__ddxFunc.osVendorInit, "OsVendorInit") SYM (__ddxFunc.osVendorInit, "OsVendorInit")
}; };
ddxHandle = xglLoadModule (ddxModuleName); ddxHandle = xglLoadModule (ddxModuleName, RTLD_NOW | RTLD_GLOBAL);
if (!ddxHandle) if (!ddxHandle)
return (status = FALSE); return (status = FALSE);
@ -149,14 +187,6 @@ InitOutput (ScreenInfo *pScreenInfo,
if (!xglEnsureDDXModule ()) if (!xglEnsureDDXModule ())
FatalError ("No DDX module loaded"); FatalError ("No DDX module loaded");
#ifdef GLXEXT
if (loadGlx)
{
if (!xglLoadGLXModules ())
FatalError ("No GLX modules loaded");
}
#endif
(*__ddxFunc.initOutput) (pScreenInfo, argc, argv); (*__ddxFunc.initOutput) (pScreenInfo, argc, argv);
} }
@ -191,68 +221,83 @@ ddxUseMsg (void)
#ifdef GLXEXT #ifdef GLXEXT
ErrorF ("-noglx don't load glx extension\n"); ErrorF ("-noglx don't load glx extension\n");
#ifndef NGLXEXTLOG
ErrorF ("-glxlog file glx extension log file\n");
#endif #endif
#endif
xglUseMsg ();
if (xglEnsureDDXModule ()) if (xglEnsureDDXModule ())
(*__ddxFunc.useMsg) (); (*__ddxFunc.useMsg) ();
} }
#define LOPT(s, l) { (s), (l) }
#define OPT(s) LOPT (s, 0)
int int
ddxProcessArgument (int argc, ddxProcessArgument (int argc,
char **argv, char **argv,
int i) int i)
{ {
struct _option { static Bool checkDDX = FALSE;
char *name; int skip;
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++) if (!checkDDX)
{ {
if (commonOption[j].length) int j;
for (j = i; j < argc; j++)
{ {
if (!strncmp (argv[i], commonOption[j].name, commonOption[j].length)) if (!strcmp (argv[j], "-ddx"))
return 0; {
} if (++j < argc)
else ddxModuleName = argv[j];
{ }
if (!strcmp (argv[i], commonOption[j].name))
return 0; #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 (!strcmp (argv[i], "-ddx"))
{ {
if ((i + 1) < argc) if ((i + 1) < argc)
{ return 2;
ddxModuleName = argv[i + 1];
}
else
return 1;
return 2; return 1;
} }
#ifdef GLXEXT #ifdef GLXEXT
else if (!strcmp (argv[i], "-noglx")) else if (!strcmp (argv[i], "-noglx"))
{ {
loadGlx = FALSE;
return 1; return 1;
} }
#ifndef NGLXEXTLOG
else if (!strcmp (argv[i], "-glxlog"))
{
if ((i + 1) < argc)
return 2;
return 1;
}
#endif
#endif #endif
skip = xglProcessArgument (argc, argv, i); skip = xglProcessArgument (argc, argv, i);
@ -286,6 +331,6 @@ OsVendorInit (void)
(*__ddxFunc.osVendorInit) (); (*__ddxFunc.osVendorInit) ();
} }
void ddxInitGlobals(void) void ddxInitGlobals()
{ {
} }

View File

@ -1,6 +1,6 @@
/* /*
* Copyright © 2004 David Reveman * Copyright © 2004 David Reveman
* *
* Permission to use, copy, modify, distribute, and sell this software * Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without * and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies * 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 * software for any purpose. It is provided "as is" without express or
* implied warranty. * 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 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * 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 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
@ -47,7 +47,7 @@ xglMouseProc (DeviceIntPtr pDevice,
case DEVICE_INIT: case DEVICE_INIT:
for (i = 1; i <= NUM_BUTTONS; i++) for (i = 1; i <= NUM_BUTTONS; i++)
map[i] = i; map[i] = i;
InitPointerDeviceStruct (pDev, InitPointerDeviceStruct (pDev,
map, map,
NUM_BUTTONS, NUM_BUTTONS,
@ -63,7 +63,7 @@ xglMouseProc (DeviceIntPtr pDevice,
pDev->on = FALSE; pDev->on = FALSE;
break; break;
} }
return Success; return Success;
} }
@ -226,7 +226,7 @@ xglKeybdProc (DeviceIntPtr pDevice,
case DEVICE_INIT: case DEVICE_INIT:
if (pDev != LookupKeyboardDevice ()) if (pDev != LookupKeyboardDevice ())
return !Success; return !Success;
ret = InitKeyboardDeviceStruct (pDev, ret = InitKeyboardDeviceStruct (pDev,
&xglKeySyms, &xglKeySyms,
xglModMap, xglModMap,
@ -243,7 +243,7 @@ xglKeybdProc (DeviceIntPtr pDevice,
pDev->on = FALSE; pDev->on = FALSE;
break; break;
} }
return Success; return Success;
} }
@ -251,13 +251,13 @@ void
xglInitInput (int argc, char **argv) xglInitInput (int argc, char **argv)
{ {
DeviceIntPtr pKeyboard, pPointer; DeviceIntPtr pKeyboard, pPointer;
pPointer = AddInputDevice (xglMouseProc, TRUE); pPointer = AddInputDevice (xglMouseProc, TRUE);
pKeyboard = AddInputDevice (xglKeybdProc, TRUE); pKeyboard = AddInputDevice (xglKeybdProc, TRUE);
RegisterPointerDevice (pPointer); RegisterPointerDevice (pPointer);
RegisterKeyboardDevice (pKeyboard); RegisterKeyboardDevice (pKeyboard);
miRegisterPointerDevice (screenInfo.screens[0], pPointer); miRegisterPointerDevice (screenInfo.screens[0], pPointer);
mieqInit (&pKeyboard->public, &pPointer->public); mieqInit (&pKeyboard->public, &pPointer->public);
} }

View File

@ -33,7 +33,8 @@
#define SYM(ptr, name) { (void **) &(ptr), (name) } #define SYM(ptr, name) { (void **) &(ptr), (name) }
void * void *
xglLoadModule (const char *name) xglLoadModule (const char *name,
int flag)
{ {
ModuleVersionProcPtr moduleVersion; ModuleVersionProcPtr moduleVersion;
ModuleInitProcPtr moduleInit; ModuleInitProcPtr moduleInit;
@ -50,7 +51,7 @@ xglLoadModule (const char *name)
sprintf (module, XGL_MODULE_PATH "/lib%s.so", name); sprintf (module, XGL_MODULE_PATH "/lib%s.so", name);
handle = dlopen (module, RTLD_NOW); handle = dlopen (module, flag);
if (handle) if (handle)
{ {
if (xglLookupSymbols (handle, mSym, sizeof (mSym) / sizeof (mSym[0]))) if (xglLookupSymbols (handle, mSym, sizeof (mSym) / sizeof (mSym[0])))

View File

@ -31,6 +31,8 @@
#include <X11/Xdefs.h> #include <X11/Xdefs.h>
#include "misc.h" #include "misc.h"
#define VERSION "0.0.1"
typedef const char *(*ModuleVersionProcPtr) (void); typedef const char *(*ModuleVersionProcPtr) (void);
typedef Bool (*ModuleInitProcPtr) (const char *module); typedef Bool (*ModuleInitProcPtr) (const char *module);

View File

@ -1,6 +1,6 @@
/* /*
* Copyright © 2004 David Reveman * Copyright © 2004 David Reveman
* *
* Permission to use, copy, modify, distribute, and sell this software * Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without * and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies * 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 * software for any purpose. It is provided "as is" without express or
* implied warranty. * 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 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * 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 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
@ -25,6 +25,9 @@
#include "xgl.h" #include "xgl.h"
#include <mivalidate.h>
#include <dixstruct.h>
typedef struct _xglDepth { typedef struct _xglDepth {
CARD8 depth; CARD8 depth;
CARD8 bpp; CARD8 bpp;
@ -46,20 +49,167 @@ void
xglSetPixmapFormats (ScreenInfo *pScreenInfo) xglSetPixmapFormats (ScreenInfo *pScreenInfo)
{ {
int i; int i;
pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER; pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT; pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD; pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER; pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
pScreenInfo->numPixmapFormats = 0; pScreenInfo->numPixmapFormats = 0;
for (i = 0; i < NUM_XGL_DEPTHS; i++) { for (i = 0; i < NUM_XGL_DEPTHS; i++)
{
PixmapFormatRec *format; PixmapFormatRec *format;
format = &pScreenInfo->formats[pScreenInfo->numPixmapFormats++]; format = &pScreenInfo->formats[pScreenInfo->numPixmapFormats++];
format->depth = xglDepths[i].depth; format->depth = xglDepths[i].depth;
format->bitsPerPixel = xglDepths[i].bpp; format->bitsPerPixel = xglDepths[i].bpp;
format->scanlinePad = BITMAP_SCANLINE_PAD; 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 ();
}

View File

@ -1,6 +1,6 @@
/* /*
* Copyright © 2004 David Reveman * Copyright © 2004 David Reveman
* *
* Permission to use, copy, modify, distribute, and sell this software * Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without * and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies * 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 * software for any purpose. It is provided "as is" without express or
* implied warranty. * 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 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * 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 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
@ -33,13 +33,13 @@ xglParseFindNext (char *cur,
{ {
while (*cur && !strchr (delim, *cur)) while (*cur && !strchr (delim, *cur))
*save++ = *cur++; *save++ = *cur++;
*save = 0; *save = 0;
*last = *cur; *last = *cur;
if (*cur) if (*cur)
cur++; cur++;
return cur; return cur;
} }
@ -57,28 +57,28 @@ xglParseScreen (char *arg)
if (!arg) if (!arg)
return; return;
if (strlen (arg) >= sizeof (save)) if (strlen (arg) >= sizeof (save))
return; return;
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
{ {
arg = xglParseFindNext (arg, "x/@XY", save, &delim); arg = xglParseFindNext (arg, "x/", save, &delim);
if (!save[0]) if (!save[0])
return; return;
pixels = atoi (save); pixels = atoi (save);
mm = 0; mm = 0;
if (delim == '/') if (delim == '/')
{ {
arg = xglParseFindNext (arg, "x@XY", save, &delim); arg = xglParseFindNext (arg, "x", save, &delim);
if (!save[0]) if (!save[0])
return; return;
mm = atoi (save); mm = atoi (save);
} }
if (i == 0) if (i == 0)
{ {
xglScreenInfo.width = pixels; xglScreenInfo.width = pixels;
@ -89,12 +89,98 @@ xglParseScreen (char *arg)
xglScreenInfo.height = pixels; xglScreenInfo.height = pixels;
xglScreenInfo.heightMm = mm; xglScreenInfo.heightMm = mm;
} }
if (delim != 'x') if (delim != 'x')
return; 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 void
xglUseMsg (void) xglUseMsg (void)
{ {
@ -106,8 +192,8 @@ xglUseMsg (void)
"use vertex buffer objects for streaming of vertex data\n"); "use vertex buffer objects for streaming of vertex data\n");
ErrorF ("-pbomask [1|4|8|16|32] " ErrorF ("-pbomask [1|4|8|16|32] "
"set bpp's to use with pixel buffer objects\n"); "set bpp's to use with pixel buffer objects\n");
ErrorF ("-fbo " ErrorF ("-accel TYPE[@WIDTH[/MIN]xHEIGHT[/MIN]][:METHOD] "
"use frame buffer objects for accelerate offscreen drawing\n"); "offscreen acceleration\n");
} }
int int
@ -126,7 +212,7 @@ xglProcessArgument (int argc,
} }
else else
return 1; return 1;
return 2; return 2;
} }
else if (!strcmp (argv[i], "-yinverted")) else if (!strcmp (argv[i], "-yinverted"))
@ -152,14 +238,20 @@ xglProcessArgument (int argc,
} }
else else
return 1; return 1;
return 2; return 2;
} }
else if (!strcmp (argv[i], "-fbo")) else if (!strcmp (argv[i], "-accel"))
{ {
xglScreenInfo.fbo = TRUE; if ((i + 1) < argc)
return 1; {
xglParseAccel (argv[i + 1]);
}
else
return 1;
return 2;
} }
return 0; return 0;
} }

View File

@ -1,6 +1,6 @@
/* /*
* Copyright © 2004 David Reveman * Copyright © 2004 David Reveman
* *
* Permission to use, copy, modify, distribute, and sell this software * Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without * and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies * 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 * software for any purpose. It is provided "as is" without express or
* implied warranty. * 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 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * 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 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
@ -28,6 +28,8 @@
#ifdef RENDER #ifdef RENDER
#include "fbpict.h"
#define XGL_PICTURE_FALLBACK_PROLOGUE(pPicture, func) \ #define XGL_PICTURE_FALLBACK_PROLOGUE(pPicture, func) \
xglSyncDamageBoxBits (pPicture->pDrawable); \ xglSyncDamageBoxBits (pPicture->pDrawable); \
XGL_PICTURE_SCREEN_UNWRAP (func) XGL_PICTURE_SCREEN_UNWRAP (func)
@ -55,18 +57,18 @@ xglComposite (CARD8 op,
XGL_SCREEN_PRIV (pScreen); XGL_SCREEN_PRIV (pScreen);
if (xglComp (op, if (xglCompositeGeneral (op,
pSrc, pMask, pDst, pSrc, pMask, pDst, NULL,
xSrc, ySrc, xSrc, ySrc,
xMask, yMask, xMask, yMask,
xDst + pDst->pDrawable->x, yDst + pDst->pDrawable->y, xDst + pDst->pDrawable->x,
width, height, yDst + pDst->pDrawable->y,
NULL, NULL)) width, height))
{ {
xglAddCurrentBitDamage (pDst->pDrawable); xglAddCurrentBitDamage (pDst->pDrawable);
return; return;
} }
pPictureScreen = GetPictureScreen (pScreen); pPictureScreen = GetPictureScreen (pScreen);
if (pSrc->pDrawable) if (pSrc->pDrawable)
@ -74,7 +76,7 @@ xglComposite (CARD8 op,
if (!xglSyncBits (pSrc->pDrawable, NullBox)) if (!xglSyncBits (pSrc->pDrawable, NullBox))
FatalError (XGL_SW_FAILURE_STRING); FatalError (XGL_SW_FAILURE_STRING);
} }
if (pMask && pMask->pDrawable) if (pMask && pMask->pDrawable)
{ {
if (!xglSyncBits (pMask->pDrawable, NullBox)) if (!xglSyncBits (pMask->pDrawable, NullBox))
@ -84,12 +86,12 @@ xglComposite (CARD8 op,
if (op == PictOpSrc) if (op == PictOpSrc)
{ {
XGL_DRAWABLE_PIXMAP (pDst->pDrawable); XGL_DRAWABLE_PIXMAP (pDst->pDrawable);
if (!xglMapPixmapBits (pPixmap)) if (!xglMapPixmapBits (pPixmap))
FatalError (XGL_SW_FAILURE_STRING); FatalError (XGL_SW_FAILURE_STRING);
} else } else
xglSyncDamageBoxBits (pDst->pDrawable); xglSyncDamageBoxBits (pDst->pDrawable);
XGL_PICTURE_SCREEN_UNWRAP (Composite); XGL_PICTURE_SCREEN_UNWRAP (Composite);
(*pPictureScreen->Composite) (op, pSrc, pMask, pDst, (*pPictureScreen->Composite) (op, pSrc, pMask, pDst,
xSrc, ySrc, xMask, yMask, xDst, yDst, xSrc, ySrc, xMask, yMask, xDst, yDst,
@ -103,16 +105,19 @@ xglComposite (CARD8 op,
xDst += pDst->pDrawable->x; xDst += pDst->pDrawable->x;
yDst += pDst->pDrawable->y; yDst += pDst->pDrawable->y;
xSrc += pSrc->pDrawable->x; if (pSrc->pDrawable)
ySrc += pSrc->pDrawable->y; {
xSrc += pSrc->pDrawable->x;
ySrc += pSrc->pDrawable->y;
}
if (pMask) if (pMask && pMask->pDrawable)
{ {
xMask += pMask->pDrawable->x; xMask += pMask->pDrawable->x;
yMask += pMask->pDrawable->y; yMask += pMask->pDrawable->y;
} }
if (!miComputeCompositeRegion (&region, pSrc, pMask, pDst, if (!miComputeCompositeRegion (&region, pSrc, pMask, pDst,
xSrc, ySrc, xMask, yMask, xDst, yDst, xSrc, ySrc, xMask, yMask, xDst, yDst,
width, height)) width, height))
return; return;
@ -130,7 +135,7 @@ xglAddTriangles (PicturePtr pDst,
int ntri, int ntri,
xTriangle *tris) xTriangle *tris)
{ {
PictureScreenPtr pPictureScreen; PictureScreenPtr pPictureScreen;
ScreenPtr pScreen = pDst->pDrawable->pScreen; ScreenPtr pScreen = pDst->pDrawable->pScreen;
XGL_SCREEN_PRIV (pScreen); XGL_SCREEN_PRIV (pScreen);
@ -153,7 +158,7 @@ void
xglChangePicture (PicturePtr pPicture, xglChangePicture (PicturePtr pPicture,
Mask mask) Mask mask)
{ {
PictureScreenPtr pPictureScreen; PictureScreenPtr pPictureScreen;
ScreenPtr pScreen = pPicture->pDrawable->pScreen; ScreenPtr pScreen = pPicture->pDrawable->pScreen;
XGL_SCREEN_PRIV (pScreen); XGL_SCREEN_PRIV (pScreen);
@ -179,7 +184,7 @@ int
xglChangePictureTransform (PicturePtr pPicture, xglChangePictureTransform (PicturePtr pPicture,
PictTransform *transform) PictTransform *transform)
{ {
PictureScreenPtr pPictureScreen; PictureScreenPtr pPictureScreen;
ScreenPtr pScreen = pPicture->pDrawable->pScreen; ScreenPtr pScreen = pPicture->pDrawable->pScreen;
int ret; int ret;
@ -187,14 +192,17 @@ xglChangePictureTransform (PicturePtr pPicture,
XGL_DRAWABLE_PIXMAP_PRIV (pPicture->pDrawable); XGL_DRAWABLE_PIXMAP_PRIV (pPicture->pDrawable);
pPictureScreen = GetPictureScreen (pScreen); 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); XGL_PICTURE_SCREEN_UNWRAP (ChangePictureTransform);
ret = (*pPictureScreen->ChangePictureTransform) (pPicture, transform); ret = (*pPictureScreen->ChangePictureTransform) (pPicture, transform);
XGL_PICTURE_SCREEN_WRAP (ChangePictureTransform, XGL_PICTURE_SCREEN_WRAP (ChangePictureTransform,
xglChangePictureTransform); xglChangePictureTransform);
return ret; return ret;
} }
@ -204,7 +212,7 @@ xglChangePictureFilter (PicturePtr pPicture,
xFixed *params, xFixed *params,
int nparams) int nparams)
{ {
PictureScreenPtr pPictureScreen; PictureScreenPtr pPictureScreen;
ScreenPtr pScreen = pPicture->pDrawable->pScreen; ScreenPtr pScreen = pPicture->pDrawable->pScreen;
int ret; int ret;
@ -212,7 +220,7 @@ xglChangePictureFilter (PicturePtr pPicture,
XGL_DRAWABLE_PIXMAP_PRIV (pPicture->pDrawable); XGL_DRAWABLE_PIXMAP_PRIV (pPicture->pDrawable);
pPictureScreen = GetPictureScreen (pScreen); pPictureScreen = GetPictureScreen (pScreen);
pPixmapPriv->pictureMask |= xglPCFilterMask; pPixmapPriv->pictureMask |= xglPCFilterMask;
XGL_PICTURE_SCREEN_UNWRAP (ChangePictureFilter); XGL_PICTURE_SCREEN_UNWRAP (ChangePictureFilter);
@ -223,21 +231,48 @@ xglChangePictureFilter (PicturePtr pPicture,
return ret; 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) xglUpdatePicture (PicturePtr pPicture)
{ {
glitz_surface_t *surface; glitz_surface_t *surface;
XGL_DRAWABLE_PIXMAP_PRIV (pPicture->pDrawable); XGL_DRAWABLE_PIXMAP_PRIV (pPicture->pDrawable);
surface = pPixmapPriv->surface; surface = pPixmapPriv->surface;
if (pPixmapPriv->pictureMask & xglPCFillMask) if (pPixmapPriv->pictureMask & xglPCFillMask)
{ {
if (pPicture->repeat) glitz_surface_set_fill (surface, fillMode[pPicture->repeat]);
glitz_surface_set_fill (surface, GLITZ_FILL_REPEAT);
else
glitz_surface_set_fill (surface, GLITZ_FILL_TRANSPARENT);
} }
if (pPixmapPriv->pictureMask & xglPCFilterMask) if (pPixmapPriv->pictureMask & xglPCFilterMask)
@ -269,23 +304,263 @@ xglUpdatePicture (PicturePtr pPicture)
if (pPixmapPriv->pictureMask & xglPCComponentAlphaMask) if (pPixmapPriv->pictureMask & xglPCComponentAlphaMask)
{ {
if (pPicture->componentAlpha) glitz_surface_set_component_alpha (surface, pPicture->componentAlpha);
glitz_surface_set_component_alpha (surface, 1);
else
glitz_surface_set_component_alpha (surface, 0);
} }
if (pPixmapPriv->pictureMask & xglPCDitherMask) if (pPixmapPriv->pictureMask & xglPCDitherMask)
{ {
if (pPicture->dither) glitz_surface_set_dither (surface, pPicture->dither);
glitz_surface_set_dither (surface, 1);
else
glitz_surface_set_dither (surface, 0);
} }
pPixmapPriv->pictureMask &= ~XGL_PICTURE_CHANGES (~0); 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, &region, &box, 1);
xglAddSurfaceDamage (&pPixmap->drawable, &region);
REGION_UNINIT (pDrawable->pScreen, &region);
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 static int
xglVisualDepth (ScreenPtr pScreen, VisualPtr pVisual) xglVisualDepth (ScreenPtr pScreen, VisualPtr pVisual)
{ {
@ -299,7 +574,7 @@ xglVisualDepth (ScreenPtr pScreen, VisualPtr pVisual)
if (pDepth->vids[v] == pVisual->vid) if (pDepth->vids[v] == pVisual->vid)
return pDepth->depth; return pDepth->depth;
} }
return 0; return 0;
} }
@ -319,10 +594,10 @@ xglAddFormat (xglFormatInitPtr formats,
for (n = 0; n < nformat; n++) for (n = 0; n < nformat; n++)
if (formats[n].format == format && formats[n].depth == depth) if (formats[n].format == format && formats[n].depth == depth)
return nformat; return nformat;
formats[nformat].format = format; formats[nformat].format = format;
formats[nformat].depth = depth; formats[nformat].depth = depth;
return ++nformat; return ++nformat;
} }
@ -342,7 +617,7 @@ xglPictureInit (ScreenPtr pScreen)
int r, g, b; int r, g, b;
int d; int d;
DepthPtr pDepth; DepthPtr pDepth;
/* formats required by protocol */ /* formats required by protocol */
formats[nformats].format = PICT_a1; formats[nformats].format = PICT_a1;
formats[nformats].depth = 1; formats[nformats].depth = 1;
@ -364,8 +639,8 @@ xglPictureInit (ScreenPtr pScreen)
depth = xglVisualDepth (pScreen, pVisual); depth = xglVisualDepth (pScreen, pVisual);
if (!depth) if (!depth)
continue; continue;
bpp = BitsPerPixel (depth); bpp = BitsPerPixel (depth);
switch (pVisual->class) { switch (pVisual->class) {
case DirectColor: case DirectColor:
case TrueColor: case TrueColor:
@ -399,7 +674,7 @@ xglPictureInit (ScreenPtr pScreen)
if (pDepth->depth == 15) if (pDepth->depth == 15)
nformats = xglAddFormat (formats, nformats, nformats = xglAddFormat (formats, nformats,
PICT_x1r5g5b5, pDepth->depth); PICT_x1r5g5b5, pDepth->depth);
if (pDepth->depth == 16) if (pDepth->depth == 16)
nformats = xglAddFormat (formats, nformats, nformats = xglAddFormat (formats, nformats,
PICT_r5g6b5, pDepth->depth); PICT_r5g6b5, pDepth->depth);
break; 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)); pFormats = (PictFormatPtr) xalloc (nformats * sizeof (PictFormatRec));
if (!pFormats) if (!pFormats)
return 0; return 0;
memset (pFormats, '\0', nformats * sizeof (PictFormatRec)); memset (pFormats, '\0', nformats * sizeof (PictFormatRec));
for (f = 0; f < nformats; f++) for (f = 0; f < nformats; f++)
{ {
pFormats[f].id = FakeClientID (0); pFormats[f].id = FakeClientID (0);
pFormats[f].depth = formats[f].depth; pFormats[f].depth = formats[f].depth;
format = formats[f].format; format = formats[f].format;
pFormats[f].format = format; pFormats[f].format = format;
pFormats[f].type = PictTypeDirect;
switch (PICT_FORMAT_TYPE (format)) { switch (PICT_FORMAT_TYPE (format)) {
case PICT_TYPE_ARGB: case PICT_TYPE_ARGB:
pFormats[f].type = PictTypeDirect;
pFormats[f].direct.alphaMask = Mask (PICT_FORMAT_A (format)); pFormats[f].direct.alphaMask = Mask (PICT_FORMAT_A (format));
if (pFormats[f].direct.alphaMask) if (pFormats[f].direct.alphaMask)
pFormats[f].direct.alpha = (PICT_FORMAT_R (format) + pFormats[f].direct.alpha = (PICT_FORMAT_R (format) +
PICT_FORMAT_G (format) + PICT_FORMAT_G (format) +
PICT_FORMAT_B (format)); PICT_FORMAT_B (format));
pFormats[f].direct.redMask = Mask (PICT_FORMAT_R (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)); PICT_FORMAT_B (format));
pFormats[f].direct.greenMask = Mask (PICT_FORMAT_G (format)); pFormats[f].direct.greenMask = Mask (PICT_FORMAT_G (format));
pFormats[f].direct.green = PICT_FORMAT_B (format); pFormats[f].direct.green = PICT_FORMAT_B (format);
pFormats[f].direct.blueMask = Mask (PICT_FORMAT_B (format)); pFormats[f].direct.blueMask = Mask (PICT_FORMAT_B (format));
pFormats[f].direct.blue = 0; pFormats[f].direct.blue = 0;
break; break;
case PICT_TYPE_A: case PICT_TYPE_A:
pFormats[f].type = PictTypeDirect;
pFormats[f].direct.alpha = 0; pFormats[f].direct.alpha = 0;
pFormats[f].direct.alphaMask = Mask (PICT_FORMAT_A (format)); pFormats[f].direct.alphaMask = Mask (PICT_FORMAT_A (format));
break; break;
case PICT_TYPE_COLOR: case PICT_TYPE_COLOR:
case PICT_TYPE_GRAY: case PICT_TYPE_GRAY:
pFormats[f].type = PictTypeDirect;
break;
case PICT_TYPE_YUY2:
case PICT_TYPE_YV12:
pFormats[f].type = PictTypeOther;
break; break;
} }
} }

View File

@ -1,6 +1,6 @@
/* /*
* Copyright © 2004 David Reveman * Copyright © 2004 David Reveman
* *
* Permission to use, copy, modify, distribute, and sell this software * Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without * and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies * 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 * software for any purpose. It is provided "as is" without express or
* implied warranty. * 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 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * 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 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
@ -69,7 +69,8 @@ xglPixmapDamageReport (DamagePtr pDamage,
if (pExt->y2 > pPixmapPriv->damageBox.y2) if (pExt->y2 > pPixmapPriv->damageBox.y2)
pPixmapPriv->damageBox.y2 = pExt->y2; pPixmapPriv->damageBox.y2 = pExt->y2;
} else }
else
pPixmapPriv->damageBox = *pExt; pPixmapPriv->damageBox = *pExt;
} }
@ -88,34 +89,119 @@ xglPixmapCreateDamage (PixmapPtr pPixmap)
return FALSE; return FALSE;
DamageRegister (&pPixmap->drawable, pPixmapPriv->pDamage); DamageRegister (&pPixmap->drawable, pPixmapPriv->pDamage);
return TRUE; 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 static Bool
xglPixmapSurfaceInit (PixmapPtr pPixmap, xglPixmapSurfaceInit (PixmapPtr pPixmap,
unsigned long features, unsigned long features,
int width, int width,
int height) int height)
{ {
BoxRec box;
XGL_PIXMAP_PRIV (pPixmap); XGL_PIXMAP_PRIV (pPixmap);
pPixmapPriv->surface = NULL; pPixmapPriv->surface = NULL;
pPixmapPriv->drawable = NULL;
pPixmapPriv->acceleratedTile = FALSE; pPixmapPriv->acceleratedTile = FALSE;
pPixmapPriv->pictureMask = ~0; pPixmapPriv->pictureMask = ~0;
pPixmapPriv->target = xglPixmapTargetNo; 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 (!pPixmapPriv->pDamage)
{
if (!xglPixmapCreateDamage (pPixmap)) if (!xglPixmapCreateDamage (pPixmap))
FatalError (XGL_SW_FAILURE_STRING); FatalError (XGL_SW_FAILURE_STRING);
}
if (width && height) if (width && height)
{ {
XGL_SCREEN_PRIV (pPixmap->drawable.pScreen);
if (width == 1 && height == 1) if (width == 1 && height == 1)
{ {
pPixmapPriv->acceleratedTile = TRUE; pPixmapPriv->acceleratedTile = TRUE;
@ -126,28 +212,6 @@ xglPixmapSurfaceInit (PixmapPtr pPixmap,
(POWER_OF_TWO (width) && POWER_OF_TWO (height))) (POWER_OF_TWO (width) && POWER_OF_TWO (height)))
pPixmapPriv->acceleratedTile = TRUE; 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 PixmapPtr
xglCreatePixmap (ScreenPtr pScreen, xglCreatePixmap (ScreenPtr pScreen,
int width, int width,
int height, int height,
int depth) int depth)
{ {
xglPixmapPtr pPixmapPriv; xglPixmapPtr pPixmapPriv;
@ -180,37 +244,32 @@ xglCreatePixmap (ScreenPtr pScreen,
pPixmap->drawable.y = 0; pPixmap->drawable.y = 0;
pPixmap->drawable.width = width; pPixmap->drawable.width = width;
pPixmap->drawable.height = height; pPixmap->drawable.height = height;
#ifdef COMPOSITE #ifdef COMPOSITE
pPixmap->screen_x = 0; pPixmap->screen_x = 0;
pPixmap->screen_y = 0; pPixmap->screen_y = 0;
#endif #endif
pPixmap->devKind = 0; pPixmap->devKind = 0;
pPixmap->refcnt = 1; pPixmap->refcnt = 1;
pPixmap->devPrivate.ptr = 0; pPixmap->devPrivate.ptr = 0;
pPixmapPriv = XGL_GET_PIXMAP_PRIV (pPixmap); pPixmapPriv = XGL_GET_PIXMAP_PRIV (pPixmap);
pPixmapPriv->format = pScreenPriv->pixmapFormats[depth].format; pPixmapPriv->pVisual = NULL;
pPixmapPriv->pPixel = pScreenPriv->pixmapFormats[depth].pPixel;
pPixmapPriv->pDamage = NULL; pPixmapPriv->pDamage = NULL;
if (!xglPixmapSurfaceInit (pPixmap, pScreenPriv->features, width, height)) if (!xglPixmapSurfaceInit (pPixmap, pScreenPriv->features, width, height))
return NullPixmap; return NullPixmap;
pPixmapPriv->buffer = NULL; pPixmapPriv->buffer = NULL;
pPixmapPriv->bits = (pointer) 0; pPixmapPriv->bits = (pointer) 0;
pPixmapPriv->stride = 0; pPixmapPriv->stride = 0;
pPixmapPriv->pGeometry = NULL; pPixmapPriv->pGeometry = NULL;
pPixmapPriv->allBits = TRUE; pPixmapPriv->allBits = TRUE;
pPixmapPriv->bitBox.x1 = 0;
pPixmapPriv->bitBox.y1 = 0;
pPixmapPriv->bitBox.x2 = 32767;
pPixmapPriv->bitBox.y2 = 32767;
pPixmapPriv->damageBox = miEmptyBox; pPixmapPriv->damageBox = miEmptyBox;
return pPixmap; return pPixmap;
} }
@ -218,7 +277,7 @@ void
xglFiniPixmap (PixmapPtr pPixmap) xglFiniPixmap (PixmapPtr pPixmap)
{ {
XGL_PIXMAP_PRIV (pPixmap); XGL_PIXMAP_PRIV (pPixmap);
if (pPixmap->devPrivate.ptr) if (pPixmap->devPrivate.ptr)
{ {
if (pPixmapPriv->buffer) if (pPixmapPriv->buffer)
@ -230,10 +289,15 @@ xglFiniPixmap (PixmapPtr pPixmap)
if (pPixmapPriv->buffer) if (pPixmapPriv->buffer)
glitz_buffer_destroy (pPixmapPriv->buffer); glitz_buffer_destroy (pPixmapPriv->buffer);
if (pPixmapPriv->bits) if (pPixmapPriv->bits)
xfree (pPixmapPriv->bits); xfree (pPixmapPriv->bits);
REGION_UNINIT (pPixmap->drawable.pScreen, &pPixmapPriv->bitRegion);
if (pPixmapPriv->drawable)
glitz_drawable_destroy (pPixmapPriv->drawable);
if (pPixmapPriv->surface) if (pPixmapPriv->surface)
glitz_surface_destroy (pPixmapPriv->surface); glitz_surface_destroy (pPixmapPriv->surface);
} }
@ -247,7 +311,7 @@ xglDestroyPixmap (PixmapPtr pPixmap)
xglFiniPixmap (pPixmap); xglFiniPixmap (pPixmap);
xfree (pPixmap); xfree (pPixmap);
return TRUE; return TRUE;
} }
@ -260,18 +324,16 @@ xglModifyPixmapHeader (PixmapPtr pPixmap,
int devKind, int devKind,
pointer pPixData) pointer pPixData)
{ {
xglScreenPtr pScreenPriv; xglScreenPtr pScreenPriv;
xglPixmapPtr pPixmapPriv; xglPixmapPtr pPixmapPriv;
glitz_format_t *oldFormat; int oldWidth, oldHeight;
int oldWidth, oldHeight;
if (!pPixmap) if (!pPixmap)
return FALSE; return FALSE;
pScreenPriv = XGL_GET_SCREEN_PRIV (pPixmap->drawable.pScreen); pScreenPriv = XGL_GET_SCREEN_PRIV (pPixmap->drawable.pScreen);
pPixmapPriv = XGL_GET_PIXMAP_PRIV (pPixmap); pPixmapPriv = XGL_GET_PIXMAP_PRIV (pPixmap);
oldFormat = pPixmapPriv->format;
oldWidth = pPixmap->drawable.width; oldWidth = pPixmap->drawable.width;
oldHeight = pPixmap->drawable.height; oldHeight = pPixmap->drawable.height;
@ -293,13 +355,13 @@ xglModifyPixmapHeader (PixmapPtr pPixmap,
{ {
if (width > 0) if (width > 0)
pPixmap->drawable.width = width; pPixmap->drawable.width = width;
if (height > 0) if (height > 0)
pPixmap->drawable.height = height; pPixmap->drawable.height = height;
if (depth > 0) if (depth > 0)
pPixmap->drawable.depth = depth; pPixmap->drawable.depth = depth;
if (bitsPerPixel > 0) if (bitsPerPixel > 0)
pPixmap->drawable.bitsPerPixel = bitsPerPixel; pPixmap->drawable.bitsPerPixel = bitsPerPixel;
else if ((bitsPerPixel < 0) && (depth > 0)) else if ((bitsPerPixel < 0) && (depth > 0))
@ -312,18 +374,20 @@ xglModifyPixmapHeader (PixmapPtr pPixmap,
pPixmap->drawable.depth); pPixmap->drawable.depth);
} }
depth = pPixmap->drawable.depth; if (pPixmap->drawable.width != oldWidth ||
pPixmapPriv->pPixel = pScreenPriv->pixmapFormats[depth].pPixel;
pPixmapPriv->format = pScreenPriv->pixmapFormats[depth].format;
if (pPixmapPriv->format != oldFormat ||
pPixmap->drawable.width != oldWidth ||
pPixmap->drawable.height != oldHeight) pPixmap->drawable.height != oldHeight)
{ {
pPixmapPriv->pVisual = NULL;
pPixmapPriv->target = xglPixmapTargetNo;
if (pPixmapPriv->drawable)
glitz_drawable_destroy (pPixmapPriv->drawable);
if (pPixmapPriv->surface) if (pPixmapPriv->surface)
glitz_surface_destroy (pPixmapPriv->surface); glitz_surface_destroy (pPixmapPriv->surface);
REGION_UNINIT (pPixmap->drawable.pScreen, &pPixmapPriv->bitRegion);
if (!xglPixmapSurfaceInit (pPixmap, if (!xglPixmapSurfaceInit (pPixmap,
pScreenPriv->features, pScreenPriv->features,
pPixmap->drawable.width, pPixmap->drawable.width,
@ -333,6 +397,8 @@ xglModifyPixmapHeader (PixmapPtr pPixmap,
if (pPixData) if (pPixData)
{ {
BoxRec box;
if (pPixmap->devPrivate.ptr) if (pPixmap->devPrivate.ptr)
{ {
if (pPixmapPriv->buffer) if (pPixmapPriv->buffer)
@ -346,10 +412,10 @@ xglModifyPixmapHeader (PixmapPtr pPixmap,
GEOMETRY_UNINIT (pPixmapPriv->pGeometry); GEOMETRY_UNINIT (pPixmapPriv->pGeometry);
pPixmapPriv->pGeometry = NULL; pPixmapPriv->pGeometry = NULL;
} }
if (pPixmapPriv->buffer) if (pPixmapPriv->buffer)
glitz_buffer_destroy (pPixmapPriv->buffer); glitz_buffer_destroy (pPixmapPriv->buffer);
if (pPixmapPriv->bits) if (pPixmapPriv->bits)
xfree (pPixmapPriv->bits); xfree (pPixmapPriv->bits);
@ -359,36 +425,54 @@ xglModifyPixmapHeader (PixmapPtr pPixmap,
return FALSE; return FALSE;
pPixmapPriv->allBits = TRUE; pPixmapPriv->allBits = TRUE;
pPixmapPriv->bitBox.x1 = 0;
pPixmapPriv->bitBox.y1 = 0; box.x1 = 0;
pPixmapPriv->bitBox.x2 = pPixmap->drawable.width; box.y1 = 0;
pPixmapPriv->bitBox.y2 = pPixmap->drawable.height; 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) if (pPixmapPriv->pDamage)
{ {
RegionPtr pRegion; RegionPtr pRegion;
pRegion = DamageRegion (pPixmapPriv->pDamage); pRegion = DamageRegion (pPixmapPriv->pDamage);
REGION_UNINIT (pPixmap->drawable.pScreen, pRegion); REGION_UNINIT (pPixmap->drawable.pScreen, pRegion);
REGION_INIT (pPixmap->drawable.pScreen, pRegion, REGION_INIT (pPixmap->drawable.pScreen, pRegion, NullBox, 0);
&pPixmapPriv->bitBox, 1); 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); if (!pPixmapPriv->drawable)
{
pPixmapPriv->surface = pScreenPriv->surface; 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; pPixmapPriv->target = xglPixmapTargetIn;
pScreenPriv->pScreenPixmap = pPixmap; if (!pScreenPriv->pScreenPixmap)
pScreenPriv->pScreenPixmap = pPixmap;
} }
return TRUE; return TRUE;
} }
@ -397,12 +481,12 @@ xglPixmapToRegion (PixmapPtr pPixmap)
{ {
ScreenPtr pScreen = pPixmap->drawable.pScreen; ScreenPtr pScreen = pPixmap->drawable.pScreen;
RegionPtr pRegion; RegionPtr pRegion;
XGL_SCREEN_PRIV (pScreen); XGL_SCREEN_PRIV (pScreen);
if (!xglSyncBits (&pPixmap->drawable, NullBox)) if (!xglSyncBits (&pPixmap->drawable, NullBox))
FatalError (XGL_SW_FAILURE_STRING); FatalError (XGL_SW_FAILURE_STRING);
XGL_SCREEN_UNWRAP (BitmapToRegion); XGL_SCREEN_UNWRAP (BitmapToRegion);
pRegion = (*pScreen->BitmapToRegion) (pPixmap); pRegion = (*pScreen->BitmapToRegion) (pPixmap);
XGL_SCREEN_WRAP (BitmapToRegion, xglPixmapToRegion); XGL_SCREEN_WRAP (BitmapToRegion, xglPixmapToRegion);
@ -423,14 +507,14 @@ xglPixmapToGeometry (PixmapPtr pPixmap,
if (!pPixmapPriv->pGeometry) if (!pPixmapPriv->pGeometry)
{ {
xglGeometryPtr pGeometry; xglGeometryPtr pGeometry;
if (!pPixmapPriv->buffer) if (!pPixmapPriv->buffer)
{ {
if (!xglAllocatePixmapBits (pPixmap, if (!xglAllocatePixmapBits (pPixmap,
XGL_PIXMAP_USAGE_HINT_DEFAULT)) XGL_PIXMAP_USAGE_HINT_DEFAULT))
return NULL; return NULL;
} }
pGeometry = xalloc (sizeof (xglGeometryRec)); pGeometry = xalloc (sizeof (xglGeometryRec));
if (!pGeometry) if (!pGeometry)
return NULL; return NULL;
@ -453,7 +537,7 @@ xglPixmapToGeometry (PixmapPtr pPixmap,
pGeometry->f.bitmap.scanline_order = pGeometry->f.bitmap.scanline_order =
GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN; GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN;
} }
pGeometry->f.bitmap.pad = ((1 + FB_MASK) >> FB_SHIFT) * pGeometry->f.bitmap.pad = ((1 + FB_MASK) >> FB_SHIFT) *
sizeof (FbBits); sizeof (FbBits);
pGeometry->width = pPixmap->drawable.width; pGeometry->width = pPixmap->drawable.width;
@ -473,27 +557,28 @@ xglCreatePixmapSurface (PixmapPtr pPixmap)
{ {
XGL_PIXMAP_PRIV (pPixmap); XGL_PIXMAP_PRIV (pPixmap);
if (!pPixmapPriv->format)
return FALSE;
if (!pPixmapPriv->surface) if (!pPixmapPriv->surface)
{ {
XGL_SCREEN_PRIV (pPixmap->drawable.pScreen); XGL_SCREEN_PRIV (pPixmap->drawable.pScreen);
if (!pPixmapPriv->pVisual || !pPixmapPriv->pVisual->format.surface)
return FALSE;
pPixmapPriv->surface = pPixmapPriv->surface =
glitz_surface_create (pScreenPriv->drawable, glitz_surface_create (pScreenPriv->drawable,
pPixmapPriv->format, pPixmapPriv->pVisual->format.surface,
pPixmap->drawable.width, pPixmap->drawable.width,
pPixmap->drawable.height, pPixmap->drawable.height,
0, NULL); 0, NULL);
if (!pPixmapPriv->surface) if (!pPixmapPriv->surface)
{ {
pPixmapPriv->format = NULL; pPixmapPriv->pVisual = NULL;
pPixmapPriv->target = xglPixmapTargetNo; pPixmapPriv->target = xglPixmapTargetNo;
return FALSE; return FALSE;
} }
} }
return TRUE; return TRUE;
} }
@ -501,20 +586,20 @@ Bool
xglAllocatePixmapBits (PixmapPtr pPixmap, int hint) xglAllocatePixmapBits (PixmapPtr pPixmap, int hint)
{ {
int width, height, bpp, stride; int width, height, bpp, stride;
XGL_PIXMAP_PRIV (pPixmap); XGL_PIXMAP_PRIV (pPixmap);
XGL_SCREEN_PRIV (pPixmap->drawable.pScreen); XGL_SCREEN_PRIV (pPixmap->drawable.pScreen);
width = pPixmap->drawable.width; width = pPixmap->drawable.width;
height = pPixmap->drawable.height; height = pPixmap->drawable.height;
bpp = pPixmap->drawable.bitsPerPixel; bpp = pPixmap->drawable.bitsPerPixel;
stride = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof (FbBits); stride = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof (FbBits);
if (stride) if (stride)
{ {
glitz_buffer_t *buffer; glitz_buffer_t *buffer;
if ((pScreenPriv->pboMask & bpp) && hint) if ((pScreenPriv->pboMask & bpp) && hint)
{ {
buffer = glitz_pixel_buffer_create (pScreenPriv->drawable, buffer = glitz_pixel_buffer_create (pScreenPriv->drawable,
@ -544,7 +629,7 @@ xglAllocatePixmapBits (PixmapPtr pPixmap, int hint)
pPixmapPriv->stride = stride; pPixmapPriv->stride = stride;
else else
pPixmapPriv->stride = -stride; pPixmapPriv->stride = -stride;
return TRUE; return TRUE;
} }
@ -554,14 +639,14 @@ xglMapPixmapBits (PixmapPtr pPixmap)
if (!pPixmap->devPrivate.ptr) if (!pPixmap->devPrivate.ptr)
{ {
CARD8 *bits; CARD8 *bits;
XGL_PIXMAP_PRIV (pPixmap); XGL_PIXMAP_PRIV (pPixmap);
if (!pPixmapPriv->buffer) if (!pPixmapPriv->buffer)
if (!xglAllocatePixmapBits (pPixmap, if (!xglAllocatePixmapBits (pPixmap,
XGL_PIXMAP_USAGE_HINT_DEFAULT)) XGL_PIXMAP_USAGE_HINT_DEFAULT))
return FALSE; return FALSE;
bits = glitz_buffer_map (pPixmapPriv->buffer, bits = glitz_buffer_map (pPixmapPriv->buffer,
GLITZ_BUFFER_ACCESS_READ_WRITE); GLITZ_BUFFER_ACCESS_READ_WRITE);
if (!bits) if (!bits)
@ -578,7 +663,7 @@ xglMapPixmapBits (PixmapPtr pPixmap)
pPixmap->devPrivate.ptr = bits; pPixmap->devPrivate.ptr = bits;
} }
} }
return TRUE; return TRUE;
} }
@ -589,10 +674,68 @@ xglUnmapPixmapBits (PixmapPtr pPixmap)
pPixmap->devKind = 0; pPixmap->devKind = 0;
pPixmap->devPrivate.ptr = 0; pPixmap->devPrivate.ptr = 0;
if (pPixmapPriv->buffer) if (pPixmapPriv->buffer)
if (glitz_buffer_unmap (pPixmapPriv->buffer)) if (glitz_buffer_unmap (pPixmapPriv->buffer))
return FALSE; return FALSE;
return TRUE; 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;
}
}
}

View File

@ -1,6 +1,6 @@
/* /*
* Copyright © 2004 David Reveman * Copyright © 2004 David Reveman
* *
* Permission to use, copy, modify, distribute, and sell this software * Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without * and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies * 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 * software for any purpose. It is provided "as is" without express or
* implied warranty. * 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 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * 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 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
@ -60,27 +60,6 @@ int xglGlyphPrivateIndex;
#define xglRecolorCursor (void *) NoopDDA #define xglRecolorCursor (void *) NoopDDA
#define xglSetCursorPosition (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 static Bool
xglAllocatePrivates (ScreenPtr pScreen) xglAllocatePrivates (ScreenPtr pScreen)
{ {
@ -91,7 +70,7 @@ xglAllocatePrivates (ScreenPtr pScreen)
xglScreenPrivateIndex = AllocateScreenPrivateIndex (); xglScreenPrivateIndex = AllocateScreenPrivateIndex ();
if (xglScreenPrivateIndex < 0) if (xglScreenPrivateIndex < 0)
return FALSE; return FALSE;
xglGCPrivateIndex = AllocateGCPrivateIndex (); xglGCPrivateIndex = AllocateGCPrivateIndex ();
if (xglGCPrivateIndex < 0) if (xglGCPrivateIndex < 0)
return FALSE; return FALSE;
@ -104,13 +83,13 @@ xglAllocatePrivates (ScreenPtr pScreen)
if (xglWinPrivateIndex < 0) if (xglWinPrivateIndex < 0)
return FALSE; return FALSE;
#ifdef RENDER #ifdef RENDER
xglGlyphPrivateIndex = AllocateGlyphPrivateIndex (); xglGlyphPrivateIndex = AllocateGlyphPrivateIndex ();
if (xglGlyphPrivateIndex < 0) if (xglGlyphPrivateIndex < 0)
return FALSE; return FALSE;
#endif #endif
xglScreenGeneration = serverGeneration; xglScreenGeneration = serverGeneration;
} }
if (!AllocateGCPrivate (pScreen, xglGCPrivateIndex, sizeof (xglGCRec))) if (!AllocateGCPrivate (pScreen, xglGCPrivateIndex, sizeof (xglGCRec)))
@ -127,66 +106,74 @@ xglAllocatePrivates (ScreenPtr pScreen)
pScreenPriv = xalloc (sizeof (xglScreenRec)); pScreenPriv = xalloc (sizeof (xglScreenRec));
if (!pScreenPriv) if (!pScreenPriv)
return FALSE; return FALSE;
XGL_SET_SCREEN_PRIV (pScreen, pScreenPriv); XGL_SET_SCREEN_PRIV (pScreen, pScreenPriv);
return TRUE; return TRUE;
} }
Bool Bool
xglScreenInit (ScreenPtr pScreen) xglScreenInit (ScreenPtr pScreen)
{ {
xglScreenPtr pScreenPriv; xglScreenPtr pScreenPriv;
int depth, bpp; xglVisualPtr v;
int i, depth, bpp = 0;
#ifdef RENDER #ifdef RENDER
PictureScreenPtr pPictureScreen; PictureScreenPtr pPictureScreen;
#endif #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)) if (!xglAllocatePrivates (pScreen))
return FALSE; return FALSE;
pScreenPriv = XGL_GET_SCREEN_PRIV (pScreen); pScreenPriv = XGL_GET_SCREEN_PRIV (pScreen);
pScreenPriv->pScreenPixmap = NULL; 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->drawable = xglScreenInfo.drawable;
pScreenPriv->features = pScreenPriv->features =
glitz_drawable_get_features (xglScreenInfo.drawable); glitz_drawable_get_features (xglScreenInfo.drawable);
depth = pScreenPriv->pVisual->pPixel->depth; GEOMETRY_INIT (pScreen, &pScreenPriv->scratchGeometry,
bpp = pScreenPriv->pVisual->pPixel->masks.bpp; GLITZ_GEOMETRY_TYPE_VERTEX,
pScreenPriv->geometryUsage, 0);
xglInitPixmapFormats (pScreen);
if (!pScreenPriv->pixmapFormats[depth].format)
return FALSE;
pScreenPriv->geometryDataType = xglScreenInfo.geometryDataType; pScreenPriv->geometryDataType = xglScreenInfo.geometryDataType;
pScreenPriv->geometryUsage = xglScreenInfo.geometryUsage; pScreenPriv->geometryUsage = xglScreenInfo.geometryUsage;
pScreenPriv->yInverted = xglScreenInfo.yInverted; pScreenPriv->yInverted = xglScreenInfo.yInverted;
pScreenPriv->pboMask = xglScreenInfo.pboMask; pScreenPriv->pboMask = xglScreenInfo.pboMask;
pScreenPriv->lines = xglScreenInfo.lines; pScreenPriv->lines = xglScreenInfo.lines;
pScreenPriv->fbo = xglScreenInfo.fbo; pScreenPriv->accel = xglScreenInfo.accel;
GEOMETRY_INIT (pScreen, &pScreenPriv->scratchGeometry,
GLITZ_GEOMETRY_TYPE_VERTEX,
pScreenPriv->geometryUsage, 0);
pScreenPriv->surface =
glitz_surface_create (pScreenPriv->drawable,
pScreenPriv->pixmapFormats[depth].format,
xglScreenInfo.width, xglScreenInfo.height,
0, NULL);
if (!pScreenPriv->surface)
return FALSE;
glitz_surface_attach (pScreenPriv->surface,
pScreenPriv->drawable,
GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
pScreenPriv->backSurface = NULL;
if (monitorResolution == 0) if (monitorResolution == 0)
monitorResolution = XGL_DEFAULT_DPI; monitorResolution = XGL_DEFAULT_DPI;
@ -197,7 +184,7 @@ xglScreenInit (ScreenPtr pScreen)
return FALSE; return FALSE;
pScreen->SaveScreen = xglSaveScreen; pScreen->SaveScreen = xglSaveScreen;
pScreen->CreatePixmap = xglCreatePixmap; pScreen->CreatePixmap = xglCreatePixmap;
pScreen->DestroyPixmap = xglDestroyPixmap; pScreen->DestroyPixmap = xglDestroyPixmap;
@ -218,9 +205,10 @@ xglScreenInit (ScreenPtr pScreen)
XGL_SCREEN_WRAP (GetImage, xglGetImage); XGL_SCREEN_WRAP (GetImage, xglGetImage);
XGL_SCREEN_WRAP (GetSpans, xglGetSpans); XGL_SCREEN_WRAP (GetSpans, xglGetSpans);
XGL_SCREEN_WRAP (CopyWindow, xglCopyWindow); XGL_SCREEN_WRAP (CopyWindow, xglCopyWindow);
XGL_SCREEN_WRAP (CreateWindow, xglCreateWindow); XGL_SCREEN_WRAP (CreateWindow, xglCreateWindow);
XGL_SCREEN_WRAP (DestroyWindow, xglDestroyWindow);
XGL_SCREEN_WRAP (ChangeWindowAttributes, xglChangeWindowAttributes); XGL_SCREEN_WRAP (ChangeWindowAttributes, xglChangeWindowAttributes);
XGL_SCREEN_WRAP (PaintWindowBackground, xglPaintWindowBackground); XGL_SCREEN_WRAP (PaintWindowBackground, xglPaintWindowBackground);
XGL_SCREEN_WRAP (PaintWindowBorder, xglPaintWindowBorder); XGL_SCREEN_WRAP (PaintWindowBorder, xglPaintWindowBorder);
@ -234,13 +222,13 @@ xglScreenInit (ScreenPtr pScreen)
pScreen->UnrealizeCursor = xglUnrealizeCursor; pScreen->UnrealizeCursor = xglUnrealizeCursor;
pScreen->RecolorCursor = xglRecolorCursor; pScreen->RecolorCursor = xglRecolorCursor;
pScreen->SetCursorPosition = xglSetCursorPosition; pScreen->SetCursorPosition = xglSetCursorPosition;
pScreen->ModifyPixmapHeader = xglModifyPixmapHeader; pScreen->ModifyPixmapHeader = xglModifyPixmapHeader;
XGL_SCREEN_WRAP (BitmapToRegion, xglPixmapToRegion); XGL_SCREEN_WRAP (BitmapToRegion, xglPixmapToRegion);
pScreen->GetWindowPixmap = xglGetWindowPixmap; pScreen->GetWindowPixmap = xglGetWindowPixmap;
XGL_SCREEN_WRAP (SetWindowPixmap, xglSetWindowPixmap); XGL_SCREEN_WRAP (SetWindowPixmap, xglSetWindowPixmap);
#ifdef RENDER #ifdef RENDER
@ -250,7 +238,7 @@ xglScreenInit (ScreenPtr pScreen)
if (!AllocateGlyphPrivate (pScreen, xglGlyphPrivateIndex, if (!AllocateGlyphPrivate (pScreen, xglGlyphPrivateIndex,
sizeof (xglGlyphRec))) sizeof (xglGlyphRec)))
return FALSE; return FALSE;
XGL_PICTURE_SCREEN_WRAP (RealizeGlyph, xglRealizeGlyph); XGL_PICTURE_SCREEN_WRAP (RealizeGlyph, xglRealizeGlyph);
XGL_PICTURE_SCREEN_WRAP (UnrealizeGlyph, xglUnrealizeGlyph); XGL_PICTURE_SCREEN_WRAP (UnrealizeGlyph, xglUnrealizeGlyph);
XGL_PICTURE_SCREEN_WRAP (Composite, xglComposite); XGL_PICTURE_SCREEN_WRAP (Composite, xglComposite);
@ -272,6 +260,7 @@ xglScreenInit (ScreenPtr pScreen)
return FALSE; return FALSE;
#ifdef COMPOSITE #ifdef COMPOSITE
#warning "composite building"
if (!compScreenInit (pScreen)) if (!compScreenInit (pScreen))
return FALSE; return FALSE;
#endif #endif
@ -287,7 +276,8 @@ xglScreenInit (ScreenPtr pScreen)
Bool Bool
xglFinishScreenInit (ScreenPtr pScreen) xglFinishScreenInit (ScreenPtr pScreen)
{ {
xglVisualPtr v;
#ifdef RENDER #ifdef RENDER
glitz_vertex_format_t *format; glitz_vertex_format_t *format;
static glitz_color_t clearBlack = { 0x0, 0x0, 0x0, 0x0 }; static glitz_color_t clearBlack = { 0x0, 0x0, 0x0, 0x0 };
@ -296,38 +286,67 @@ xglFinishScreenInit (ScreenPtr pScreen)
#endif #endif
XGL_SCREEN_PRIV (pScreen); XGL_SCREEN_PRIV (pScreen);
pScreenPriv->solid = xglInitVisuals (pScreen);
glitz_surface_create (pScreenPriv->drawable,
pScreenPriv->pixmapFormats[32].format, for (v = pScreenPriv->pVisual; v; v = v->next)
1, 1, 0, NULL); {
if (!pScreenPriv->solid) if (v->vid == pScreen->rootVisual)
pScreenPriv->rootVisual = v;
}
if (!pScreenPriv->rootVisual || !pScreenPriv->rootVisual->format.surface)
return FALSE; return FALSE;
glitz_surface_set_fill (pScreenPriv->solid, GLITZ_FILL_REPEAT); pScreenPriv->surface =
glitz_surface_create (pScreenPriv->drawable,
pScreenPriv->rootVisual->format.surface,
xglScreenInfo.width, xglScreenInfo.height,
0, NULL);
if (!pScreenPriv->surface)
return FALSE;
glitz_surface_attach (pScreenPriv->surface,
pScreenPriv->drawable,
GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
#ifdef RENDER #ifdef RENDER
for (i = 0; i < 33; i++) for (i = 0; i < 33; i++)
pScreenPriv->glyphCache[i].pScreen = NULL; 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 = pScreenPriv->pSolidAlpha = 0;
glitz_surface_create (pScreenPriv->drawable, pScreenPriv->trapInfo.pMask = 0;
pScreenPriv->pixmapFormats[8].format,
2, 1, 0, NULL);
if (!pScreenPriv->trapInfo.mask)
return FALSE;
glitz_set_rectangle (pScreenPriv->trapInfo.mask, &clearBlack, 0, 0, 1, 1); /* An accelerated alpha only Xgl visual is required for trapezoid
glitz_set_rectangle (pScreenPriv->trapInfo.mask, &solidWhite, 1, 0, 1, 1); acceleration */
if (v && v->format.surface)
glitz_surface_set_fill (pScreenPriv->trapInfo.mask, GLITZ_FILL_NEAREST); {
glitz_surface_set_filter (pScreenPriv->trapInfo.mask, glitz_surface_t *mask;
GLITZ_FILTER_BILINEAR,
NULL, 0);
format = &pScreenPriv->trapInfo.format.vertex; mask = glitz_surface_create (pScreenPriv->drawable,
v->format.surface,
2, 1, 0, NULL);
if (mask)
{
glitz_set_rectangle (mask, &clearBlack, 0, 0, 1, 1);
glitz_set_rectangle (mask, &solidWhite, 1, 0, 1, 1);
glitz_surface_set_fill (mask, GLITZ_FILL_NEAREST);
glitz_surface_set_filter (mask, GLITZ_FILTER_BILINEAR, NULL, 0);
pScreenPriv->trapInfo.pMask = xglCreateDevicePicture (mask);
if (!pScreenPriv->trapInfo.pMask)
return FALSE;
}
}
format = &pScreenPriv->trapInfo.format.vertex;
format->primitive = GLITZ_PRIMITIVE_QUADS; format->primitive = GLITZ_PRIMITIVE_QUADS;
format->attributes = GLITZ_VERTEX_ATTRIBUTE_MASK_COORD_MASK; format->attributes = GLITZ_VERTEX_ATTRIBUTE_MASK_COORD_MASK;
@ -348,7 +367,12 @@ xglFinishScreenInit (ScreenPtr pScreen)
format->mask.offset = 2 * sizeof (glitz_short_t); format->mask.offset = 2 * sizeof (glitz_short_t);
} }
#endif #endif
#ifdef XV
if (!xglXvScreenInit (pScreen))
return FALSE;
#endif
return TRUE; return TRUE;
} }
@ -356,37 +380,49 @@ Bool
xglCloseScreen (int index, xglCloseScreen (int index,
ScreenPtr pScreen) ScreenPtr pScreen)
{ {
xglVisualPtr v;
XGL_SCREEN_PRIV (pScreen); XGL_SCREEN_PRIV (pScreen);
XGL_PIXMAP_PRIV (pScreenPriv->pScreenPixmap); XGL_PIXMAP_PRIV (pScreenPriv->pScreenPixmap);
#ifdef RENDER #ifdef RENDER
int i; int i;
for (i = 0; i < 33; i++) for (i = 0; i < 33; i++)
xglFiniGlyphCache (&pScreenPriv->glyphCache[i]); xglFiniGlyphCache (&pScreenPriv->glyphCache[i]);
if (pScreenPriv->pSolidAlpha) if (pScreenPriv->pSolidAlpha)
FreePicture ((pointer) pScreenPriv->pSolidAlpha, 0); FreePicture ((pointer) pScreenPriv->pSolidAlpha, 0);
if (pScreenPriv->trapInfo.mask) if (pScreenPriv->trapInfo.pMask)
glitz_surface_destroy (pScreenPriv->trapInfo.mask); FreePicture ((pointer) pScreenPriv->trapInfo.pMask, 0);
#endif #endif
xglFiniPixmap (pScreenPriv->pScreenPixmap); xglFiniPixmap (pScreenPriv->pScreenPixmap);
if (pPixmapPriv->pDamage) if (pPixmapPriv->pDamage)
DamageDestroy (pPixmapPriv->pDamage); DamageDestroy (pPixmapPriv->pDamage);
if (pScreenPriv->solid)
glitz_surface_destroy (pScreenPriv->solid);
if (pScreenPriv->backSurface)
glitz_surface_destroy (pScreenPriv->backSurface);
if (pScreenPriv->surface) if (pScreenPriv->surface)
glitz_surface_destroy (pScreenPriv->surface); glitz_surface_destroy (pScreenPriv->surface);
GEOMETRY_UNINIT (&pScreenPriv->scratchGeometry); 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); XGL_SCREEN_UNWRAP (CloseScreen);
xfree (pScreenPriv); xfree (pScreenPriv);
@ -404,7 +440,7 @@ xglCreateSolidAlphaPicture (ScreenPtr pScreen)
int error; int error;
Pixel pixel; Pixel pixel;
GCPtr pGC; GCPtr pGC;
CARD32 tmpval[2]; XID tmpval[2];
XGL_SCREEN_PRIV (pScreen); XGL_SCREEN_PRIV (pScreen);
@ -415,25 +451,24 @@ xglCreateSolidAlphaPicture (ScreenPtr pScreen)
pGC = GetScratchGC (pFormat->depth, pScreen); pGC = GetScratchGC (pFormat->depth, pScreen);
if (!pGC) if (!pGC)
return; return;
pPixmap = (*pScreen->CreatePixmap) (pScreen, 1, 1, pFormat->depth); pPixmap = (*pScreen->CreatePixmap) (pScreen, 1, 1, pFormat->depth);
if (!pPixmap) if (!pPixmap)
return; return;
miRenderColorToPixel (pFormat, &solidWhite, &pixel); miRenderColorToPixel (pFormat, &solidWhite, &pixel);
tmpval[0] = GXcopy; tmpval[0] = GXcopy;
tmpval[1] = pixel; tmpval[1] = pixel;
ChangeGC (pGC, GCFunction | GCForeground, tmpval); ChangeGC (pGC, GCFunction | GCForeground, tmpval);
ValidateGC (&pPixmap->drawable, pGC); ValidateGC (&pPixmap->drawable, pGC);
(*pGC->ops->PolyFillRect) (&pPixmap->drawable, pGC, 1, &one); (*pGC->ops->PolyFillRect) (&pPixmap->drawable, pGC, 1, &one);
FreeScratchGC (pGC); FreeScratchGC (pGC);
tmpval[0] = xTrue; tmpval[0] = xTrue;
pScreenPriv->pSolidAlpha = pScreenPriv->pSolidAlpha = CreatePicture (0, &pPixmap->drawable, pFormat,
CreatePicture (0, &pPixmap->drawable, pFormat, CPRepeat, tmpval, 0, &error);
CPRepeat, tmpval, 0, &error);
(*pScreen->DestroyPixmap) (pPixmap); (*pScreen->DestroyPixmap) (pPixmap);
if (pScreenPriv->pSolidAlpha) if (pScreenPriv->pSolidAlpha)

View File

@ -1,6 +1,6 @@
/* /*
* Copyright © 2005 Novell, Inc. * Copyright © 2005 Novell, Inc.
* *
* Permission to use, copy, modify, distribute, and sell this software * Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without * and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies * 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 * software for any purpose. It is provided "as is" without express or
* implied warranty. * 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 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * 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 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
@ -56,9 +56,11 @@ xglShmPutImage (DrawablePtr pDrawable,
GetScratchPixmapHeader (pScreen, w, h, depth, GetScratchPixmapHeader (pScreen, w, h, depth,
BitsPerPixel (depth), BitsPerPixel (depth),
PixmapBytePad (w, depth), PixmapBytePad (w, depth),
(pointer) data); (pointer) data);
/* disable any possible acceleration of this pixmap */
if (pPixmap) if (pPixmap)
XGL_GET_PIXMAP_PRIV (pPixmap)->format = NULL; xglSetPixmapVisual (pPixmap, 0);
} }
else else
{ {
@ -67,24 +69,22 @@ xglShmPutImage (DrawablePtr pDrawable,
{ {
GCPtr pScratchGC; GCPtr pScratchGC;
XGL_PIXMAP_PRIV (pPixmap);
if (!xglAllocatePixmapBits (pPixmap, if (!xglAllocatePixmapBits (pPixmap,
XGL_PIXMAP_USAGE_HINT_DEFAULT)) XGL_PIXMAP_USAGE_HINT_DEFAULT))
{ {
(*pScreen->DestroyPixmap) (pPixmap); (*pScreen->DestroyPixmap) (pPixmap);
return; return;
} }
pPixmapPriv->format = NULL;
pPixmapPriv->target = xglPixmapTargetNo; xglSetPixmapVisual (pPixmap, 0);
pScratchGC = GetScratchGC (depth, pScreen); pScratchGC = GetScratchGC (depth, pScreen);
if (!pScratchGC) if (!pScratchGC)
{ {
(*pScreen->DestroyPixmap) (pPixmap); (*pScreen->DestroyPixmap) (pPixmap);
return; return;
} }
ValidateGC ((DrawablePtr) pPixmap, pScratchGC); ValidateGC ((DrawablePtr) pPixmap, pScratchGC);
(*pGC->ops->PutImage) ((DrawablePtr) pPixmap, pScratchGC, depth, (*pGC->ops->PutImage) ((DrawablePtr) pPixmap, pScratchGC, depth,
-sx, -sy, w, h, 0, -sx, -sy, w, h, 0,
@ -96,7 +96,7 @@ xglShmPutImage (DrawablePtr pDrawable,
sx = sy = 0; sx = sy = 0;
} }
} }
if (!pPixmap) if (!pPixmap)
return; return;
@ -112,7 +112,7 @@ xglShmPutImage (DrawablePtr pDrawable,
sx, sy, sw, sh, dx, dy); sx, sy, sw, sh, dx, dy);
pPixmapPriv->target = saveTarget; pPixmapPriv->target = saveTarget;
if (pPixmapHeader) if (pPixmapHeader)
FreeScratchPixmapHeader (pPixmapHeader); FreeScratchPixmapHeader (pPixmapHeader);
else else

View File

@ -1,6 +1,6 @@
/* /*
* Copyright © 2004 David Reveman * Copyright © 2004 David Reveman
* *
* Permission to use, copy, modify, distribute, and sell this software * Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without * and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies * 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 * software for any purpose. It is provided "as is" without express or
* implied warranty. * 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 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * 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 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
@ -31,7 +31,7 @@
Bool Bool
xglSolid (DrawablePtr pDrawable, xglSolid (DrawablePtr pDrawable,
glitz_operator_t op, glitz_operator_t op,
glitz_color_t *color, glitz_surface_t *solid,
xglGeometryPtr pGeometry, xglGeometryPtr pGeometry,
int x, int x,
int y, int y,
@ -42,18 +42,14 @@ xglSolid (DrawablePtr pDrawable,
{ {
glitz_surface_t *surface; glitz_surface_t *surface;
int xOff, yOff; int xOff, yOff;
XGL_SCREEN_PRIV (pDrawable->pScreen);
if (nBox < 1) if (nBox < 1)
return TRUE; return TRUE;
if (!xglPrepareTarget (pDrawable)) if (!xglPrepareTarget (pDrawable))
return FALSE; 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) if (pGeometry)
{ {
@ -67,12 +63,12 @@ xglSolid (DrawablePtr pDrawable,
} }
GEOMETRY_TRANSLATE (pGeometry, xOff, yOff); GEOMETRY_TRANSLATE (pGeometry, xOff, yOff);
if (!GEOMETRY_ENABLE (pGeometry, surface)) if (!GEOMETRY_ENABLE (pGeometry, surface))
return FALSE; return FALSE;
glitz_composite (op, glitz_composite (op,
pScreenPriv->solid, NULL, surface, solid, NULL, surface,
0, 0, 0, 0,
0, 0, 0, 0,
x + xOff, x + xOff,
@ -80,7 +76,7 @@ xglSolid (DrawablePtr pDrawable,
width, height); width, height);
glitz_surface_set_clip_region (surface, 0, 0, NULL, 0); glitz_surface_set_clip_region (surface, 0, 0, NULL, 0);
if (glitz_surface_get_status (surface)) if (glitz_surface_get_status (surface))
return FALSE; return FALSE;
@ -104,7 +100,7 @@ xglSolidGlyph (DrawablePtr pDrawable,
x += pDrawable->x; x += pDrawable->x;
y += pDrawable->y; y += pDrawable->y;
GEOMETRY_INIT (pDrawable->pScreen, &geometry, GEOMETRY_INIT (pDrawable->pScreen, &geometry,
GLITZ_GEOMETRY_TYPE_BITMAP, GLITZ_GEOMETRY_TYPE_BITMAP,
GEOMETRY_USAGE_SYSMEM, 0); GEOMETRY_USAGE_SYSMEM, 0);
@ -116,11 +112,11 @@ xglSolidGlyph (DrawablePtr pDrawable,
pglyphBase); pglyphBase);
GEOMETRY_TRANSLATE (&geometry, x, y); GEOMETRY_TRANSLATE (&geometry, x, y);
widthBack = 0; widthBack = 0;
while (nGlyph--) while (nGlyph--)
widthBack += (*ppci++)->metrics.characterWidth; widthBack += (*ppci++)->metrics.characterWidth;
xBack = x; xBack = x;
if (widthBack < 0) if (widthBack < 0)
{ {
@ -129,10 +125,10 @@ xglSolidGlyph (DrawablePtr pDrawable,
} }
yBack = y - FONTASCENT (pGC->font); yBack = y - FONTASCENT (pGC->font);
heightBack = FONTASCENT (pGC->font) + FONTDESCENT (pGC->font); heightBack = FONTASCENT (pGC->font) + FONTDESCENT (pGC->font);
if (xglSolid (pDrawable, if (xglSolid (pDrawable,
pGCPriv->op, pGCPriv->op,
&pGCPriv->bg, pGCPriv->bg,
NULL, NULL,
xBack, xBack,
yBack, yBack,
@ -143,7 +139,7 @@ xglSolidGlyph (DrawablePtr pDrawable,
{ {
if (xglSolid (pDrawable, if (xglSolid (pDrawable,
pGCPriv->op, pGCPriv->op,
&pGCPriv->fg, pGCPriv->fg,
&geometry, &geometry,
xBack, xBack,
yBack, yBack,
@ -153,10 +149,11 @@ xglSolidGlyph (DrawablePtr pDrawable,
REGION_NUM_RECTS (pGC->pCompositeClip))) REGION_NUM_RECTS (pGC->pCompositeClip)))
{ {
GEOMETRY_UNINIT (&geometry); GEOMETRY_UNINIT (&geometry);
xglAddCurrentBitDamage (pDrawable);
return TRUE; return TRUE;
} }
} }
GEOMETRY_UNINIT (&geometry); GEOMETRY_UNINIT (&geometry);
return FALSE; return FALSE;
} }

View File

@ -1,6 +1,6 @@
/* /*
* Copyright © 2004 David Reveman * Copyright © 2004 David Reveman
* *
* Permission to use, copy, modify, distribute, and sell this software * Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without * and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies * 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 * software for any purpose. It is provided "as is" without express or
* implied warranty. * 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 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * 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 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
@ -25,49 +25,11 @@
#include "xgl.h" #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 Bool
xglSyncBits (DrawablePtr pDrawable, xglSyncBits (DrawablePtr pDrawable,
BoxPtr pExtents) BoxPtr pExtents)
{ {
RegionRec region; RegionRec region;
BoxPtr pBitBox;
BoxRec box; BoxRec box;
XGL_DRAWABLE_PIXMAP (pDrawable); XGL_DRAWABLE_PIXMAP (pDrawable);
@ -76,53 +38,66 @@ xglSyncBits (DrawablePtr pDrawable,
if (pPixmapPriv->allBits) if (pPixmapPriv->allBits)
return xglMapPixmapBits (pPixmap); return xglMapPixmapBits (pPixmap);
pBitBox = &pPixmapPriv->bitBox;
if (pPixmapPriv->target == xglPixmapTargetIn && pExtents) if (pPixmapPriv->target == xglPixmapTargetIn && pExtents)
{ {
box.x1 = MAX (0, pExtents->x1); box.x1 = 0;
box.y1 = MAX (0, pExtents->y1); box.y1 = 0;
box.x2 = MAX (0, MIN (pPixmap->drawable.width, pExtents->x2)); box.x2 = pPixmap->drawable.width;
box.y2 = MAX (0, MIN (pPixmap->drawable.height, pExtents->y2)); box.y2 = pPixmap->drawable.height;
if (pExtents->x1 > box.x1)
box.x1 = pExtents->x1;
if (pExtents->y1 > box.y1)
box.y1 = pExtents->y1;
if (pExtents->x2 < box.x2)
box.x2 = pExtents->x2;
if (pExtents->y2 < box.y2)
box.y2 = pExtents->y2;
if (!BOX_NOTEMPTY (&box)) if (box.x2 <= box.x1 || box.y2 <= box.y1)
return xglMapPixmapBits (pPixmap); return xglMapPixmapBits (pPixmap);
if (BOX_NOTEMPTY (pBitBox)) if (REGION_NOTEMPTY (pDrawable->pScreen, &pPixmapPriv->bitRegion))
{ {
RegionRec bitRegion; switch (RECT_IN_REGION (pDrawable->pScreen,
&pPixmapPriv->bitRegion,
REGION_INIT (pDrawable->pScreen, &bitRegion, pBitBox, 1); &box)) {
switch (RECT_IN_REGION (pDrawable->pScreen, &bitRegion, &box)) {
case rgnIN: case rgnIN:
REGION_NULL (pDrawable->pScreen, &region); REGION_INIT (pDrawable->pScreen, &region, NullBox, 0);
break; break;
case rgnOUT: case rgnOUT:
REGION_INIT (pDrawable->pScreen, &region, &box, 1); REGION_INIT (pDrawable->pScreen, &region, &box, 1);
*pBitBox = box; REGION_UNION (pDrawable->pScreen,
pPixmapPriv->allBits = ALL_BITS (pPixmap, pBitBox); &pPixmapPriv->bitRegion, &pPixmapPriv->bitRegion,
&region);
break; break;
case rgnPART: case rgnPART:
pBitBox->x1 = MIN (pBitBox->x1, box.x1); REGION_INIT (pDrawable->pScreen, &region, &box, 1);
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, &region, pBitBox, 1);
REGION_SUBTRACT (pDrawable->pScreen, &region, &region, REGION_SUBTRACT (pDrawable->pScreen, &region, &region,
&bitRegion); &pPixmapPriv->bitRegion);
REGION_UNION (pDrawable->pScreen,
&pPixmapPriv->bitRegion, &pPixmapPriv->bitRegion,
&region);
break; break;
} }
REGION_UNINIT (pDrawable->pScreen, &bitRegion);
} }
else else
{ {
REGION_INIT (pDrawable->pScreen, &region, &box, 1); REGION_INIT (pDrawable->pScreen, &region, &box, 1);
*pBitBox = box; REGION_SUBTRACT (pDrawable->pScreen, &pPixmapPriv->bitRegion,
pPixmapPriv->allBits = ALL_BITS (pPixmap, pBitBox); &region, &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 else
@ -133,17 +108,9 @@ xglSyncBits (DrawablePtr pDrawable,
box.y2 = pPixmap->drawable.height; box.y2 = pPixmap->drawable.height;
REGION_INIT (pDrawable->pScreen, &region, &box, 1); REGION_INIT (pDrawable->pScreen, &region, &box, 1);
REGION_SUBTRACT (pDrawable->pScreen, &region, &region,
if (BOX_NOTEMPTY (pBitBox)) &pPixmapPriv->bitRegion);
{
RegionRec bitRegion;
REGION_INIT (pDrawable->pScreen, &bitRegion, pBitBox, 1);
REGION_SUBTRACT (pDrawable->pScreen, &region, &region, &bitRegion);
REGION_UNINIT (pDrawable->pScreen, &bitRegion);
}
*pBitBox = box;
pPixmapPriv->allBits = TRUE; pPixmapPriv->allBits = TRUE;
} }
@ -151,62 +118,66 @@ xglSyncBits (DrawablePtr pDrawable,
if (!xglAllocatePixmapBits (pPixmap, XGL_PIXMAP_USAGE_HINT_DEFAULT)) if (!xglAllocatePixmapBits (pPixmap, XGL_PIXMAP_USAGE_HINT_DEFAULT))
return FALSE; return FALSE;
if (pPixmapPriv->pDamage)
{
RegionPtr pRegion;
pRegion = DamageRegion (pPixmapPriv->pDamage);
REGION_SUBTRACT (pDrawable->pScreen, &region, &region, pRegion);
}
if (REGION_NOTEMPTY (pDrawable->pScreen, &region) && pPixmapPriv->surface) if (REGION_NOTEMPTY (pDrawable->pScreen, &region) && pPixmapPriv->surface)
{ {
glitz_pixel_format_t format; glitz_pixel_format_t format;
BoxPtr pBox; BoxPtr pBox;
BoxPtr pExt;
int nBox; int nBox;
if (!xglSyncSurface (pDrawable)) if (!xglSyncSurface (pDrawable))
FatalError (XGL_SW_FAILURE_STRING); FatalError (XGL_SW_FAILURE_STRING);
xglUnmapPixmapBits (pPixmap); xglUnmapPixmapBits (pPixmap);
pBox = REGION_RECTS (&region); pBox = REGION_RECTS (&region);
nBox = REGION_NUM_RECTS (&region); nBox = REGION_NUM_RECTS (&region);
pExt = REGION_EXTENTS (pDrawable->pScreen, &region);
format.fourcc = GLITZ_FOURCC_RGB; format.fourcc = GLITZ_FOURCC_RGB;
format.masks = pPixmapPriv->pPixel->masks; format.masks = pPixmapPriv->pVisual->pPixel->masks;
format.xoffset = pExt->x1;
while (nBox--)
if (pPixmapPriv->stride < 0)
{ {
format.xoffset = pBox->x1; format.skip_lines = pPixmap->drawable.height - pExt->y2;
format.bytes_per_line = -pPixmapPriv->stride;
if (pPixmapPriv->stride < 0) format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP;
{
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_get_pixels (pPixmapPriv->surface,
pBox->x1,
pBox->y1,
pBox->x2 - pBox->x1,
pBox->y2 - pBox->y1,
&format,
pPixmapPriv->buffer);
pBox++;
} }
else
{
format.skip_lines = pExt->y1;
format.bytes_per_line = pPixmapPriv->stride;
format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_TOP_DOWN;
}
glitz_surface_set_clip_region (pPixmapPriv->surface,
0, 0, (glitz_box_t *) pBox, nBox);
glitz_get_pixels (pPixmapPriv->surface,
pExt->x1,
pExt->y1,
pExt->x2 - pExt->x1,
pExt->y2 - pExt->y1,
&format,
pPixmapPriv->buffer);
glitz_surface_set_clip_region (pPixmapPriv->surface, 0, 0, NULL, 0);
} }
REGION_UNINIT (pDrawable->pScreen, &region); REGION_UNINIT (pDrawable->pScreen, &region);
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); return xglMapPixmapBits (pPixmap);
} }
@ -229,9 +200,6 @@ xglSyncSurface (DrawablePtr pDrawable)
if (!pPixmapPriv->surface) if (!pPixmapPriv->surface)
{ {
if (!pPixmapPriv->format)
return FALSE;
if (!xglCreatePixmapSurface (pPixmap)) if (!xglCreatePixmapSurface (pPixmap))
return FALSE; return FALSE;
} }
@ -239,20 +207,20 @@ xglSyncSurface (DrawablePtr pDrawable)
pRegion = DamageRegion (pPixmapPriv->pDamage); pRegion = DamageRegion (pPixmapPriv->pDamage);
if (REGION_NOTEMPTY (pDrawable->pScreen, pRegion)) if (REGION_NOTEMPTY (pDrawable->pScreen, pRegion))
{ {
glitz_pixel_format_t format; glitz_pixel_format_t format;
BoxPtr pBox; BoxPtr pBox;
BoxPtr pExt; BoxPtr pExt;
int nBox; int nBox;
xglUnmapPixmapBits (pPixmap); xglUnmapPixmapBits (pPixmap);
nBox = REGION_NUM_RECTS (pRegion); nBox = REGION_NUM_RECTS (pRegion);
pBox = REGION_RECTS (pRegion); pBox = REGION_RECTS (pRegion);
pExt = REGION_EXTENTS (pDrawable->pScreen, pRegion); pExt = REGION_EXTENTS (pDrawable->pScreen, pRegion);
format.fourcc = GLITZ_FOURCC_RGB; format.fourcc = pPixmapPriv->pVisual->format.surface->color.fourcc;
format.masks = pPixmapPriv->pPixel->masks; format.masks = pPixmapPriv->pVisual->pPixel->masks;
format.xoffset = pExt->x1; format.xoffset = pExt->x1;
if (pPixmapPriv->stride < 0) if (pPixmapPriv->stride < 0)
@ -299,16 +267,51 @@ xglPrepareTarget (DrawablePtr pDrawable)
case xglPixmapTargetOut: case xglPixmapTargetOut:
if (xglSyncSurface (pDrawable)) if (xglSyncSurface (pDrawable))
{ {
pPixmapPriv->target = xglPixmapTargetIn; glitz_drawable_format_t *format;
return TRUE;
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; break;
case xglPixmapTargetIn: case xglPixmapTargetIn:
if (xglSyncSurface (pDrawable)) if (xglSyncSurface (pDrawable))
return TRUE; return TRUE;
break; break;
} }
return FALSE; return FALSE;
} }
@ -316,52 +319,65 @@ void
xglAddSurfaceDamage (DrawablePtr pDrawable, xglAddSurfaceDamage (DrawablePtr pDrawable,
RegionPtr pRegion) RegionPtr pRegion)
{ {
RegionPtr pDamageRegion;
glitz_surface_t *surface; glitz_surface_t *surface;
int xOff, yOff; int xOff, yOff;
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable); XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
pPixmapPriv->damageBox = miEmptyBox; pPixmapPriv->damageBox = miEmptyBox;
if (!pPixmapPriv->format)
return;
XGL_GET_DRAWABLE (pDrawable, surface, xOff, yOff); XGL_GET_DRAWABLE (pDrawable, surface, xOff, yOff);
if (xOff || yOff) if (xOff || yOff)
REGION_TRANSLATE (pDrawable->pScreen, pRegion, 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) if (xOff || yOff)
REGION_TRANSLATE (pDrawable->pScreen, pRegion, -xOff, -yOff); REGION_TRANSLATE (pDrawable->pScreen, pRegion, -xOff, -yOff);
} }
void void
xglAddCurrentSurfaceDamage (DrawablePtr pDrawable) xglAddCurrentSurfaceDamage (DrawablePtr pDrawable)
{ {
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable); XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
if (!pPixmapPriv->format)
{
pPixmapPriv->damageBox = miEmptyBox;
return;
}
if (BOX_NOTEMPTY (&pPixmapPriv->damageBox)) if (BOX_NOTEMPTY (&pPixmapPriv->damageBox))
{ {
RegionPtr pDamageRegion;
RegionRec region; RegionRec region;
pDamageRegion = DamageRegion (pPixmapPriv->pDamage);
REGION_INIT (pDrawable->pScreen, &region, &pPixmapPriv->damageBox, 1); REGION_INIT (pDrawable->pScreen, &region, &pPixmapPriv->damageBox, 1);
if (pPixmapPriv->pDamage)
{
RegionPtr pDamageRegion;
pDamageRegion = DamageRegion (pPixmapPriv->pDamage);
REGION_UNION (pDrawable->pScreen,
pDamageRegion, pDamageRegion,
&region);
}
REGION_UNION (pDrawable->pScreen, REGION_UNION (pDrawable->pScreen,
pDamageRegion, pDamageRegion, &region); &pPixmapPriv->bitRegion, &pPixmapPriv->bitRegion,
&region);
REGION_UNINIT (pDrawable->pScreen, &region); REGION_UNINIT (pDrawable->pScreen, &region);
pPixmapPriv->damageBox = miEmptyBox; pPixmapPriv->damageBox = miEmptyBox;
} }
} }
@ -370,34 +386,42 @@ void
xglAddBitDamage (DrawablePtr pDrawable, xglAddBitDamage (DrawablePtr pDrawable,
RegionPtr pRegion) RegionPtr pRegion)
{ {
BoxPtr pBox;
BoxPtr pExt;
int nBox;
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable); XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
pBox = REGION_RECTS (pRegion); if (REGION_NOTEMPTY (pDrawable->pScreen, &pPixmapPriv->bitRegion))
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)
{ {
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 && while (nBox--)
pBox->y1 < pPixmapPriv->bitBox.y2 &&
pBox->x2 > pPixmapPriv->bitBox.x1 &&
pBox->y2 > pPixmapPriv->bitBox.y1)
{ {
pPixmapPriv->bitBox = miEmptyBox; if (pBox->x1 < pBitExt->x2 &&
pPixmapPriv->allBits = FALSE; pBox->y1 < pBitExt->y2 &&
return; 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); XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
if (pPixmapPriv->damageBox.x1 < pPixmapPriv->bitBox.x2 && if (REGION_NOTEMPTY (pDrawable->pScreen, &pPixmapPriv->bitRegion))
pPixmapPriv->damageBox.y1 < pPixmapPriv->bitBox.y2 &&
pPixmapPriv->damageBox.x2 > pPixmapPriv->bitBox.x1 &&
pPixmapPriv->damageBox.y2 > pPixmapPriv->bitBox.y1)
{ {
pPixmapPriv->bitBox = miEmptyBox; BoxPtr pBitExt;
pPixmapPriv->allBits = FALSE;
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; pPixmapPriv->damageBox = miEmptyBox;

View File

@ -1,6 +1,6 @@
/* /*
* Copyright © 2004 David Reveman * Copyright © 2004 David Reveman
* *
* Permission to use, copy, modify, distribute, and sell this software * Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without * and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies * 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 * software for any purpose. It is provided "as is" without express or
* implied warranty. * 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 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * 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 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
@ -63,7 +63,7 @@ xglTiledBoxGeometry (PixmapPtr pTile,
tileWidth = pTile->drawable.width; tileWidth = pTile->drawable.width;
tileHeight = pTile->drawable.height; tileHeight = pTile->drawable.height;
for (i = 0; i < nBox; i++) for (i = 0; i < nBox; i++)
size += size +=
(((pBox[i].x2 - pBox[i].x1) / tileWidth) + 2) * (((pBox[i].x2 - pBox[i].x1) / tileWidth) + 2) *
@ -75,7 +75,7 @@ xglTiledBoxGeometry (PixmapPtr pTile,
data = glitz_buffer_map (pGeometry->buffer, data = glitz_buffer_map (pGeometry->buffer,
GLITZ_BUFFER_ACCESS_WRITE_ONLY); GLITZ_BUFFER_ACCESS_WRITE_ONLY);
while (nBox--) while (nBox--)
{ {
x = pBox->x1; x = pBox->x1;
@ -87,19 +87,19 @@ xglTiledBoxGeometry (PixmapPtr pTile,
yTile = MOD (tileY + y, tileHeight); yTile = MOD (tileY + y, tileHeight);
yTmp = y; yTmp = y;
while (height) while (height)
{ {
heightTile = MIN (tileHeight - yTile, height); heightTile = MIN (tileHeight - yTile, height);
xTileTmp = xTile; xTileTmp = xTile;
widthTmp = width; widthTmp = width;
xTmp = x; xTmp = x;
while (widthTmp) while (widthTmp)
{ {
widthTile = MIN (tileWidth - xTileTmp, widthTmp); widthTile = MIN (tileWidth - xTileTmp, widthTmp);
p1.x = xTileTmp << 16; p1.x = xTileTmp << 16;
p1.y = yTile << 16; p1.y = yTile << 16;
p2.x = (xTileTmp + widthTile) << 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, &p1, &p1);
glitz_surface_translate_point (pPixmapPriv->surface, &p2, &p2); glitz_surface_translate_point (pPixmapPriv->surface, &p2, &p2);
x1 = FIXED_TO_FLOAT (p1.x); x1 = FIXED_TO_FLOAT (p1.x);
y1 = FIXED_TO_FLOAT (p1.y); y1 = FIXED_TO_FLOAT (p1.y);
x2 = FIXED_TO_FLOAT (p2.x); x2 = FIXED_TO_FLOAT (p2.x);
@ -122,29 +122,29 @@ xglTiledBoxGeometry (PixmapPtr pTile,
*data++ = (glitz_float_t) yTmp; *data++ = (glitz_float_t) yTmp;
*data++ = x2; *data++ = x2;
*data++ = y1; *data++ = y1;
*data++ = (glitz_float_t) (xTmp + widthTile); *data++ = (glitz_float_t) (xTmp + widthTile);
*data++ = (glitz_float_t) (yTmp + heightTile); *data++ = (glitz_float_t) (yTmp + heightTile);
*data++ = x2; *data++ = x2;
*data++ = y2; *data++ = y2;
*data++ = (glitz_float_t) xTmp; *data++ = (glitz_float_t) xTmp;
*data++ = (glitz_float_t) (yTmp + heightTile); *data++ = (glitz_float_t) (yTmp + heightTile);
*data++ = x1; *data++ = x1;
*data++ = y2; *data++ = y2;
pGeometry->endOffset += sizeof (glitz_float_t) * 16; pGeometry->endOffset += sizeof (glitz_float_t) * 16;
xTileTmp = 0; xTileTmp = 0;
xTmp += widthTile; xTmp += widthTile;
widthTmp -= widthTile; widthTmp -= widthTile;
} }
yTile = 0; yTile = 0;
yTmp += heightTile; yTmp += heightTile;
height -= heightTile; height -= heightTile;
} }
pBox++; pBox++;
} }
@ -197,7 +197,7 @@ xglTile (DrawablePtr pDrawable,
GLITZ_FILTER_NEAREST, GLITZ_FILTER_NEAREST,
NULL, 0); NULL, 0);
glitz_surface_set_transform (pTilePriv->surface, NULL); glitz_surface_set_transform (pTilePriv->surface, NULL);
if (pTilePriv->acceleratedTile) if (pTilePriv->acceleratedTile)
{ {
if (pGeometry) if (pGeometry)
@ -212,9 +212,9 @@ xglTile (DrawablePtr pDrawable,
4 * nBox); 4 * nBox);
GEOMETRY_ADD_BOX (pDrawable->pScreen, pGeometry, pBox, nBox); GEOMETRY_ADD_BOX (pDrawable->pScreen, pGeometry, pBox, nBox);
} }
GEOMETRY_TRANSLATE (pGeometry, xOff, yOff); GEOMETRY_TRANSLATE (pGeometry, xOff, yOff);
if (!GEOMETRY_ENABLE (pGeometry, surface)) if (!GEOMETRY_ENABLE (pGeometry, surface))
return FALSE; return FALSE;
@ -231,7 +231,7 @@ xglTile (DrawablePtr pDrawable,
width, height); width, height);
glitz_surface_set_clip_region (surface, 0, 0, NULL, 0); glitz_surface_set_clip_region (surface, 0, 0, NULL, 0);
if (!glitz_surface_get_status (surface)) if (!glitz_surface_get_status (surface))
return TRUE; return TRUE;
@ -249,10 +249,10 @@ xglTile (DrawablePtr pDrawable,
return FALSE; return FALSE;
GEOMETRY_TRANSLATE (pGeometry, xOff, yOff); GEOMETRY_TRANSLATE (pGeometry, xOff, yOff);
if (!GEOMETRY_ENABLE (pGeometry, surface)) if (!GEOMETRY_ENABLE (pGeometry, surface))
return FALSE; return FALSE;
glitz_composite (op, glitz_composite (op,
pTilePriv->surface, NULL, surface, pTilePriv->surface, NULL, surface,
0, 0, 0, 0,
@ -260,9 +260,9 @@ xglTile (DrawablePtr pDrawable,
x + xOff, x + xOff,
y + yOff, y + yOff,
width, height); width, height);
if (glitz_surface_get_status (surface)) if (glitz_surface_get_status (surface))
return FALSE; return FALSE;
return TRUE; return TRUE;
} }

View File

@ -1,6 +1,6 @@
/* /*
* Copyright © 2005 Novell, Inc. * Copyright © 2005 Novell, Inc.
* *
* Permission to use, copy, modify, distribute, and sell this software * Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without * and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies * 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 * software for any purpose. It is provided "as is" without express or
* implied warranty. * 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 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * 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 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
@ -74,15 +74,15 @@ xglTrapezoidExtents (PicturePtr pDst,
extents->y1 = xFixedToInt (traps->top); extents->y1 = xFixedToInt (traps->top);
extents->y2 = xFixedToInt (xFixedCeil (traps->bottom)); extents->y2 = xFixedToInt (xFixedCeil (traps->bottom));
LINE_FIXED_X (&traps->left, traps->top, top); LINE_FIXED_X (&traps->left, traps->top, top);
LINE_FIXED_X (&traps->left, traps->bottom, bottom); LINE_FIXED_X (&traps->left, traps->bottom, bottom);
extents->x1 = xFixedToInt (MIN (top, bottom)); extents->x1 = xFixedToInt (MIN (top, bottom));
LINE_FIXED_X_CEIL (&traps->right, traps->top, top); LINE_FIXED_X_CEIL (&traps->right, traps->top, top);
LINE_FIXED_X_CEIL (&traps->right, traps->bottom, bottom); LINE_FIXED_X_CEIL (&traps->right, traps->bottom, bottom);
extents->x2 = xFixedToInt (xFixedCeil (MAX (top, bottom))); extents->x2 = xFixedToInt (xFixedCeil (MAX (top, bottom)));
ntrap--; ntrap--;
traps++; traps++;
@ -95,15 +95,15 @@ xglTrapezoidExtents (PicturePtr pDst,
y1 = xFixedToInt (traps->top); y1 = xFixedToInt (traps->top);
y2 = xFixedToInt (xFixedCeil (traps->bottom)); y2 = xFixedToInt (xFixedCeil (traps->bottom));
LINE_FIXED_X (&traps->left, traps->top, top); LINE_FIXED_X (&traps->left, traps->top, top);
LINE_FIXED_X (&traps->left, traps->bottom, bottom); LINE_FIXED_X (&traps->left, traps->bottom, bottom);
x1 = xFixedToInt (MIN (top, bottom)); x1 = xFixedToInt (MIN (top, bottom));
LINE_FIXED_X_CEIL (&traps->right, traps->top, top); LINE_FIXED_X_CEIL (&traps->right, traps->top, top);
LINE_FIXED_X_CEIL (&traps->right, traps->bottom, bottom); LINE_FIXED_X_CEIL (&traps->right, traps->bottom, bottom);
x2 = xFixedToInt (xFixedCeil (MAX (top, bottom))); x2 = xFixedToInt (xFixedCeil (MAX (top, bottom)));
x_overlap = FALSE; x_overlap = FALSE;
if (x1 >= extents->x2) if (x1 >= extents->x2)
extents->x2 = x2; extents->x2 = x2;
@ -117,18 +117,18 @@ xglTrapezoidExtents (PicturePtr pDst,
if (x2 > extents->x2) if (x2 > extents->x2)
extents->x2 = x2; extents->x2 = x2;
} }
if (y1 >= extents->y2) if (y1 >= extents->y2)
extents->y2 = y2; extents->y2 = y2;
else if (y2 <= extents->y1) else if (y2 <= extents->y1)
extents->y1 = y1; extents->y1 = y1;
else else
{ {
if (y1 < extents->y1) if (y1 < extents->y1)
extents->y1 = y1; extents->y1 = y1;
if (y2 > extents->y2) if (y2 > extents->y2)
extents->y2 = y2; extents->y2 = y2;
if (x_overlap) if (x_overlap)
overlap = TRUE; overlap = TRUE;
} }
@ -151,21 +151,20 @@ xglTrapezoids (CARD8 op,
{ {
ScreenPtr pScreen = pDst->pDrawable->pScreen; ScreenPtr pScreen = pDst->pDrawable->pScreen;
PicturePtr pMask = NULL, pSrcPicture, pDstPicture; PicturePtr pMask = NULL, pSrcPicture, pDstPicture;
PicturePtr pMaskPicture = NULL;
xglGeometryPtr pGeometry = NULL; xglGeometryPtr pGeometry = NULL;
glitz_surface_t *mask = NULL;
unsigned int polyEdge = pDst->polyEdge; unsigned int polyEdge = pDst->polyEdge;
INT16 xDst, yDst; INT16 xDst, yDst;
INT16 xOff, yOff; INT16 xOff, yOff;
BoxRec extents; BoxRec extents;
Bool overlap; Bool overlap;
Bool target; Bool target;
XGL_SCREEN_PRIV (pScreen); XGL_SCREEN_PRIV (pScreen);
XGL_DRAWABLE_PIXMAP_PRIV (pDst->pDrawable);
xDst = traps[0].left.p1.x >> 16; xDst = traps[0].left.p1.x >> 16;
yDst = traps[0].left.p1.y >> 16; yDst = traps[0].left.p1.y >> 16;
overlap = xglTrapezoidExtents (pDst, nTrap, traps, &extents); overlap = xglTrapezoidExtents (pDst, nTrap, traps, &extents);
if (extents.y1 >= extents.y2 || extents.x1 >= extents.x2) if (extents.y1 >= extents.y2 || extents.x1 >= extents.x2)
return; return;
@ -180,7 +179,7 @@ xglTrapezoids (CARD8 op,
xRectangle rect; xRectangle rect;
int error; int error;
int area; int area;
if (!pScreenPriv->pSolidAlpha) if (!pScreenPriv->pSolidAlpha)
{ {
xglCreateSolidAlphaPicture (pScreen); xglCreateSolidAlphaPicture (pScreen);
@ -194,11 +193,11 @@ xglTrapezoids (CARD8 op,
rect.height = extents.y2 - extents.y1; rect.height = extents.y2 - extents.y1;
pPixmap = (*pScreen->CreatePixmap) (pScreen, pPixmap = (*pScreen->CreatePixmap) (pScreen,
rect.width, rect.height, rect.width, rect.height,
maskFormat->depth); maskFormat->depth);
if (!pPixmap) if (!pPixmap)
return; return;
pMask = CreatePicture (0, &pPixmap->drawable, maskFormat, pMask = CreatePicture (0, &pPixmap->drawable, maskFormat,
0, 0, serverClient, &error); 0, 0, serverClient, &error);
if (!pMask) if (!pMask)
@ -206,15 +205,17 @@ xglTrapezoids (CARD8 op,
(*pScreen->DestroyPixmap) (pPixmap); (*pScreen->DestroyPixmap) (pPixmap);
return; 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; area = rect.width * rect.height;
if (!target || (SMOOTH_TRAPS_ESTIMATE_RECTS (nTrap) * 4) > area) if ((SMOOTH_TRAPS_ESTIMATE_RECTS (nTrap) * 4) > area)
XGL_GET_PIXMAP_PRIV (pPixmap)->lock = 1; XGL_GET_PIXMAP_PRIV (pPixmap)->target = xglPixmapTargetNo;
ValidatePicture (pMask); ValidatePicture (pMask);
pGC = GetScratchGC (pPixmap->drawable.depth, pScreen); pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
ValidateGC (&pPixmap->drawable, pGC); ValidateGC (&pPixmap->drawable, pGC);
@ -224,7 +225,7 @@ xglTrapezoids (CARD8 op,
(*pScreen->DestroyPixmap) (pPixmap); (*pScreen->DestroyPixmap) (pPixmap);
target = xglPrepareTarget (pMask->pDrawable); target = xglPrepareTarget (pMask->pDrawable);
xOff = -extents.x1; xOff = -extents.x1;
yOff = -extents.y1; yOff = -extents.y1;
pSrcPicture = pScreenPriv->pSolidAlpha; pSrcPicture = pScreenPriv->pSolidAlpha;
@ -232,9 +233,6 @@ xglTrapezoids (CARD8 op,
} }
else else
{ {
/* make sure destination drawable is locked */
pPixmapPriv->lock++;
if (maskFormat) if (maskFormat)
{ {
if (maskFormat->depth == 1) if (maskFormat->depth == 1)
@ -242,7 +240,7 @@ xglTrapezoids (CARD8 op,
else else
polyEdge = PolyEdgeSmooth; polyEdge = PolyEdgeSmooth;
} }
xOff = 0; xOff = 0;
yOff = 0; yOff = 0;
pSrcPicture = pSrc; pSrcPicture = pSrc;
@ -254,37 +252,38 @@ xglTrapezoids (CARD8 op,
if (maskFormat || polyEdge == PolyEdgeSmooth) if (maskFormat || polyEdge == PolyEdgeSmooth)
{ {
glitz_vertex_format_t *format; glitz_vertex_format_t *format;
glitz_surface_t *mask;
xTrapezoid *pTrap = traps; xTrapezoid *pTrap = traps;
int nAddedTrap, n = nTrap; int nAddedTrap, n = nTrap;
int offset = 0; int offset = 0;
int size = SMOOTH_TRAPS_ESTIMATE_RECTS (n); int size = SMOOTH_TRAPS_ESTIMATE_RECTS (n);
mask = pScreenPriv->trapInfo.mask; pMaskPicture = pScreenPriv->trapInfo.pMask;
format = &pScreenPriv->trapInfo.format.vertex; format = &pScreenPriv->trapInfo.format.vertex;
mask = pMaskPicture->pSourcePict->source.devPrivate.ptr;
size *= format->bytes_per_vertex; size *= format->bytes_per_vertex;
pGeometry = xglGetScratchGeometryWithSize (pScreen, size); pGeometry = xglGetScratchGeometryWithSize (pScreen, size);
while (n) while (n)
{ {
if (pGeometry->size < size) if (pGeometry->size < size)
GEOMETRY_RESIZE (pScreen, pGeometry, size); GEOMETRY_RESIZE (pScreen, pGeometry, size);
if (!pGeometry->buffer) if (!pGeometry->buffer)
{ {
if (pMask) if (pMask)
FreePicture (pMask, 0); FreePicture (pMask, 0);
pPixmapPriv->lock--;
return; return;
} }
offset += offset +=
glitz_add_trapezoids (pGeometry->buffer, glitz_add_trapezoids (pGeometry->buffer,
offset, size - offset, format->type, offset, size - offset, format->type,
mask, (glitz_trapezoid_t *) pTrap, n, mask, (glitz_trapezoid_t *) pTrap, n,
&nAddedTrap); &nAddedTrap);
n -= nAddedTrap; n -= nAddedTrap;
pTrap += nAddedTrap; pTrap += nAddedTrap;
size *= 2; size *= 2;
@ -304,10 +303,9 @@ xglTrapezoids (CARD8 op,
if (pMask) if (pMask)
FreePicture (pMask, 0); FreePicture (pMask, 0);
pPixmapPriv->lock--;
return; return;
} }
GEOMETRY_ADD_TRAPEZOID (pScreen, pGeometry, traps, nTrap); GEOMETRY_ADD_TRAPEZOID (pScreen, pGeometry, traps, nTrap);
} }
@ -317,19 +315,18 @@ xglTrapezoids (CARD8 op,
} }
if (pGeometry && if (pGeometry &&
xglComp (pMask ? PictOpAdd : op, xglCompositeGeneral (pMask ? PictOpAdd : op,
pSrcPicture, pSrcPicture,
NULL, pMaskPicture,
pDstPicture, pDstPicture,
extents.x1 + xOff + xSrc - xDst, pGeometry,
extents.y1 + yOff + ySrc - yDst, extents.x1 + xOff + xSrc - xDst,
0, 0, extents.y1 + yOff + ySrc - yDst,
pDstPicture->pDrawable->x + extents.x1 + xOff, 0, 0,
pDstPicture->pDrawable->y + extents.y1 + yOff, pDstPicture->pDrawable->x + extents.x1 + xOff,
extents.x2 - extents.x1, pDstPicture->pDrawable->y + extents.y1 + yOff,
extents.y2 - extents.y1, extents.x2 - extents.x1,
pGeometry, extents.y2 - extents.y1))
mask))
{ {
/* no intermediate mask? we need to register damage from here as /* no intermediate mask? we need to register damage from here as
CompositePicture will never be called. */ CompositePicture will never be called. */
@ -340,12 +337,12 @@ xglTrapezoids (CARD8 op,
REGION_INIT (pScreen, &region, &extents, 1); REGION_INIT (pScreen, &region, &extents, 1);
REGION_TRANSLATE (pScreen, &region, REGION_TRANSLATE (pScreen, &region,
pDst->pDrawable->x, pDst->pDrawable->y); pDst->pDrawable->x, pDst->pDrawable->y);
DamageDamageRegion (pDst->pDrawable, &region); DamageDamageRegion (pDst->pDrawable, &region);
REGION_UNINIT (pScreen, &region); REGION_UNINIT (pScreen, &region);
} }
xglAddCurrentBitDamage (pDstPicture->pDrawable); xglAddCurrentBitDamage (pDstPicture->pDrawable);
} }
else else
@ -363,16 +360,17 @@ xglTrapezoids (CARD8 op,
op == PictOpAdd && miIsSolidAlpha (pSrc))) op == PictOpAdd && miIsSolidAlpha (pSrc)))
{ {
PictureScreenPtr ps = GetPictureScreen (pScreen); PictureScreenPtr ps = GetPictureScreen (pScreen);
for (; nTrap; nTrap--, traps++) for (; nTrap; nTrap--, traps++)
(*ps->RasterizeTrapezoid) (pDstPicture, traps, xOff, yOff); (*ps->RasterizeTrapezoid) (pDstPicture, traps, xOff, yOff);
xglAddCurrentSurfaceDamage (pDstPicture->pDrawable); xglAddCurrentSurfaceDamage (pDstPicture->pDrawable);
} else }
miTrapezoids (op, pSrc, pDstPicture, NULL, else
miTrapezoids (op, pSrc, pDstPicture, maskFormat,
xSrc, ySrc, nTrap, traps); xSrc, ySrc, nTrap, traps);
} }
if (pMask) if (pMask)
{ {
CompositePicture (op, pSrc, pMask, pDst, CompositePicture (op, pSrc, pMask, pDst,
@ -382,12 +380,9 @@ xglTrapezoids (CARD8 op,
extents.x1, extents.y1, extents.x1, extents.y1,
extents.x2 - extents.x1, extents.x2 - extents.x1,
extents.y2 - extents.y1); extents.y2 - extents.y1);
FreePicture (pMask, 0); FreePicture (pMask, 0);
} }
/* release destination drawable lock */
pPixmapPriv->lock--;
} }
void void
@ -397,9 +392,9 @@ xglAddTraps (PicturePtr pDst,
int nTrap, int nTrap,
xTrap *traps) xTrap *traps)
{ {
PictureScreenPtr pPictureScreen; PictureScreenPtr pPictureScreen;
ScreenPtr pScreen = pDst->pDrawable->pScreen; ScreenPtr pScreen = pDst->pDrawable->pScreen;
XGL_SCREEN_PRIV (pScreen); XGL_SCREEN_PRIV (pScreen);
XGL_DRAWABLE_PIXMAP_PRIV (pDst->pDrawable); XGL_DRAWABLE_PIXMAP_PRIV (pDst->pDrawable);
@ -417,33 +412,36 @@ xglAddTraps (PicturePtr pDst,
if (xglPrepareTarget (pDst->pDrawable)) if (xglPrepareTarget (pDst->pDrawable))
{ {
PicturePtr pMask;
glitz_vertex_format_t *format; glitz_vertex_format_t *format;
glitz_surface_t *mask;
xglGeometryPtr pGeometry; xglGeometryPtr pGeometry;
xTrap *pTrap = traps; xTrap *pTrap = traps;
int nAddedTrap, n = nTrap; int nAddedTrap, n = nTrap;
int offset = 0; int offset = 0;
int size = SMOOTH_TRAPS_ESTIMATE_RECTS (n); int size = SMOOTH_TRAPS_ESTIMATE_RECTS (n);
pMask = pScreenPriv->trapInfo.pMask;
format = &pScreenPriv->trapInfo.format.vertex; format = &pScreenPriv->trapInfo.format.vertex;
mask = pMask->pSourcePict->source.devPrivate.ptr;
size *= format->bytes_per_vertex; size *= format->bytes_per_vertex;
pGeometry = xglGetScratchGeometryWithSize (pScreen, size); pGeometry = xglGetScratchGeometryWithSize (pScreen, size);
while (n) while (n)
{ {
if (pGeometry->size < size) if (pGeometry->size < size)
GEOMETRY_RESIZE (pScreen, pGeometry, size); GEOMETRY_RESIZE (pScreen, pGeometry, size);
if (!pGeometry->buffer) if (!pGeometry->buffer)
return; return;
offset += offset +=
glitz_add_traps (pGeometry->buffer, glitz_add_traps (pGeometry->buffer,
offset, size - offset, format->type, offset, size - offset, format->type, mask,
pScreenPriv->trapInfo.mask,
(glitz_trap_t *) pTrap, n, (glitz_trap_t *) pTrap, n,
&nAddedTrap); &nAddedTrap);
n -= nAddedTrap; n -= nAddedTrap;
pTrap += nAddedTrap; pTrap += nAddedTrap;
size *= 2; size *= 2;
@ -455,17 +453,17 @@ xglAddTraps (PicturePtr pDst,
GEOMETRY_TRANSLATE (pGeometry, GEOMETRY_TRANSLATE (pGeometry,
pDst->pDrawable->x + xOff, pDst->pDrawable->x + xOff,
pDst->pDrawable->y + yOff); pDst->pDrawable->y + yOff);
if (xglComp (PictOpAdd, if (xglCompositeGeneral (PictOpAdd,
pScreenPriv->pSolidAlpha, pScreenPriv->pSolidAlpha,
NULL, pMask,
pDst, pDst,
0, 0, pGeometry,
0, 0, 0, 0,
pDst->pDrawable->x, pDst->pDrawable->y, 0, 0,
pDst->pDrawable->width, pDst->pDrawable->height, pDst->pDrawable->x, pDst->pDrawable->y,
pGeometry, pDst->pDrawable->width,
pScreenPriv->trapInfo.mask)) pDst->pDrawable->height))
{ {
xglAddCurrentBitDamage (pDst->pDrawable); xglAddCurrentBitDamage (pDst->pDrawable);
return; return;

View File

@ -1,6 +1,6 @@
/* /*
* Copyright © 2004 David Reveman * Copyright © 2004 David Reveman
* *
* Permission to use, copy, modify, distribute, and sell this software * Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without * and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies * 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 * software for any purpose. It is provided "as is" without express or
* implied warranty. * 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 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR * NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * 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 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
@ -40,7 +40,7 @@ xglCreateWindow (WindowPtr pWin)
{ {
ScreenPtr pScreen = pWin->drawable.pScreen; ScreenPtr pScreen = pWin->drawable.pScreen;
Bool ret; Bool ret;
XGL_SCREEN_PRIV (pScreen); XGL_SCREEN_PRIV (pScreen);
XGL_WINDOW_PRIV (pWin); XGL_WINDOW_PRIV (pWin);
@ -53,6 +53,21 @@ xglCreateWindow (WindowPtr pWin)
return ret; return ret;
} }
Bool
xglDestroyWindow (WindowPtr pWin)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
Bool ret;
XGL_SCREEN_PRIV (pScreen);
XGL_SCREEN_UNWRAP (DestroyWindow);
ret = (*pScreen->DestroyWindow) (pWin);
XGL_SCREEN_WRAP (DestroyWindow, xglDestroyWindow);
return ret;
}
Bool Bool
xglChangeWindowAttributes (WindowPtr pWin, xglChangeWindowAttributes (WindowPtr pWin,
unsigned long mask) unsigned long mask)
@ -60,9 +75,9 @@ xglChangeWindowAttributes (WindowPtr pWin,
ScreenPtr pScreen = pWin->drawable.pScreen; ScreenPtr pScreen = pWin->drawable.pScreen;
PixmapPtr pPixmap; PixmapPtr pPixmap;
Bool ret; Bool ret;
XGL_SCREEN_PRIV (pScreen); XGL_SCREEN_PRIV (pScreen);
if (mask & CWBackPixmap) if (mask & CWBackPixmap)
{ {
if (pWin->backgroundState == BackgroundPixmap) if (pWin->backgroundState == BackgroundPixmap)
@ -74,7 +89,7 @@ xglChangeWindowAttributes (WindowPtr pWin,
xglSyncBits (&pPixmap->drawable, NULL); xglSyncBits (&pPixmap->drawable, NULL);
} }
} }
if (mask & CWBorderPixmap) if (mask & CWBorderPixmap)
{ {
if (pWin->borderIsPixel == FALSE) if (pWin->borderIsPixel == FALSE)
@ -90,12 +105,12 @@ xglChangeWindowAttributes (WindowPtr pWin,
XGL_SCREEN_UNWRAP (ChangeWindowAttributes); XGL_SCREEN_UNWRAP (ChangeWindowAttributes);
ret = (*pScreen->ChangeWindowAttributes) (pWin, mask); ret = (*pScreen->ChangeWindowAttributes) (pWin, mask);
XGL_SCREEN_WRAP (ChangeWindowAttributes, xglChangeWindowAttributes); XGL_SCREEN_WRAP (ChangeWindowAttributes, xglChangeWindowAttributes);
return ret; return ret;
} }
void void
xglCopyWindow (WindowPtr pWin, xglCopyWindow (WindowPtr pWin,
DDXPointRec ptOldOrg, DDXPointRec ptOldOrg,
RegionPtr prgnSrc) RegionPtr prgnSrc)
{ {
@ -111,18 +126,18 @@ xglCopyWindow (WindowPtr pWin,
box.y1 = pExtent->y1; box.y1 = pExtent->y1;
box.x2 = pExtent->x2; box.x2 = pExtent->x2;
box.y2 = pExtent->y2; box.y2 = pExtent->y2;
dx = ptOldOrg.x - pWin->drawable.x; dx = ptOldOrg.x - pWin->drawable.x;
dy = ptOldOrg.y - pWin->drawable.y; dy = ptOldOrg.y - pWin->drawable.y;
REGION_TRANSLATE (pWin->drawable.pScreen, prgnSrc, -dx, -dy); 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, REGION_INTERSECT (pWin->drawable.pScreen,
&rgnDst, &pWin->borderClip, prgnSrc); &rgnDst, &pWin->borderClip, prgnSrc);
fbCopyRegion (&pWin->drawable, &pWin->drawable, fbCopyRegion (&pWin->drawable, &pWin->drawable,
0, &rgnDst, dx, dy, xglCopyProc, 0, (void *) &box); 0, &rgnDst, dx, dy, xglCopyProc, 0, (void *) &box);
REGION_UNINIT (pWin->drawable.pScreen, &rgnDst); REGION_UNINIT (pWin->drawable.pScreen, &rgnDst);
} }
@ -131,29 +146,53 @@ xglFillRegionSolid (DrawablePtr pDrawable,
RegionPtr pRegion, RegionPtr pRegion,
Pixel pixel) Pixel pixel)
{ {
glitz_color_t color; glitz_pixel_format_t format;
BoxPtr pExtent; glitz_surface_t *solid;
glitz_buffer_t *buffer;
BoxPtr pExtent;
Bool ret;
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable); XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
XGL_SCREEN_PRIV (pDrawable->pScreen);
if (!pPixmapPriv->target) if (!xglPrepareTarget (pDrawable))
return FALSE; 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); pExtent = REGION_EXTENTS (pDrawable->pScreen, pRegion);
xglPixelToColor (pPixmapPriv->pPixel, pixel, &color); ret = xglSolid (pDrawable,
GLITZ_OPERATOR_SRC,
if (xglSolid (pDrawable, solid,
GLITZ_OPERATOR_SRC, NULL,
&color, pExtent->x1, pExtent->y1,
NULL, pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
pExtent->x1, pExtent->y1, REGION_RECTS (pRegion),
pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1, REGION_NUM_RECTS (pRegion));
REGION_RECTS (pRegion),
REGION_NUM_RECTS (pRegion))) glitz_surface_destroy (solid);
return TRUE;
return ret;
return FALSE;
} }
static Bool static Bool
@ -164,11 +203,6 @@ xglFillRegionTiled (DrawablePtr pDrawable,
int tileY) int tileY)
{ {
BoxPtr pExtent; BoxPtr pExtent;
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
if (!pPixmapPriv->target)
return FALSE;
pExtent = REGION_EXTENTS (pDrawable->pScreen, pRegion); pExtent = REGION_EXTENTS (pDrawable->pScreen, pRegion);
@ -182,7 +216,7 @@ xglFillRegionTiled (DrawablePtr pDrawable,
REGION_RECTS (pRegion), REGION_RECTS (pRegion),
REGION_NUM_RECTS (pRegion))) REGION_NUM_RECTS (pRegion)))
return TRUE; return TRUE;
return FALSE; return FALSE;
} }
@ -194,7 +228,7 @@ xglPaintWindowBackground (WindowPtr pWin,
ScreenPtr pScreen = pWin->drawable.pScreen; ScreenPtr pScreen = pWin->drawable.pScreen;
XGL_SCREEN_PRIV (pScreen); XGL_SCREEN_PRIV (pScreen);
switch (pWin->backgroundState) { switch (pWin->backgroundState) {
case None: case None:
return; return;
@ -202,7 +236,7 @@ xglPaintWindowBackground (WindowPtr pWin,
do { do {
pWin = pWin->parent; pWin = pWin->parent;
} while (pWin->backgroundState == ParentRelative); } while (pWin->backgroundState == ParentRelative);
(*pScreen->PaintWindowBackground) (pWin, pRegion, what); (*pScreen->PaintWindowBackground) (pWin, pRegion, what);
return; return;
case BackgroundPixmap: case BackgroundPixmap:
@ -215,7 +249,7 @@ xglPaintWindowBackground (WindowPtr pWin,
xglAddCurrentBitDamage (&pWin->drawable); xglAddCurrentBitDamage (&pWin->drawable);
return; return;
} }
if (!xglSyncBits (&pWin->background.pixmap->drawable, NullBox)) if (!xglSyncBits (&pWin->background.pixmap->drawable, NullBox))
FatalError (XGL_SW_FAILURE_STRING); FatalError (XGL_SW_FAILURE_STRING);
break; break;
@ -258,7 +292,7 @@ xglPaintWindowBorder (WindowPtr pWin,
else else
{ {
WindowPtr pBgWin = pWin; WindowPtr pBgWin = pWin;
while (pBgWin->backgroundState == ParentRelative) while (pBgWin->backgroundState == ParentRelative)
pBgWin = pBgWin->parent; pBgWin = pBgWin->parent;
@ -271,7 +305,7 @@ xglPaintWindowBorder (WindowPtr pWin,
xglAddCurrentBitDamage (&pWin->drawable); xglAddCurrentBitDamage (&pWin->drawable);
return; return;
} }
if (!xglSyncBits (&pWin->border.pixmap->drawable, NullBox)) if (!xglSyncBits (&pWin->border.pixmap->drawable, NullBox))
FatalError (XGL_SW_FAILURE_STRING); FatalError (XGL_SW_FAILURE_STRING);
} }
@ -281,3 +315,27 @@ xglPaintWindowBorder (WindowPtr pWin,
XGL_WINDOW_FALLBACK_EPILOGUE (pWin, pRegion, PaintWindowBorder, XGL_WINDOW_FALLBACK_EPILOGUE (pWin, pRegion, PaintWindowBorder,
xglPaintWindowBorder); xglPaintWindowBorder);
} }
PixmapPtr
xglGetWindowPixmap (WindowPtr pWin)
{
return XGL_GET_WINDOW_PIXMAP (pWin);
}
void
xglSetWindowPixmap (WindowPtr pWin,
PixmapPtr pPixmap)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
XGL_SCREEN_PRIV (pScreen);
XGL_SCREEN_UNWRAP (SetWindowPixmap);
(*pScreen->SetWindowPixmap) (pWin, pPixmap);
XGL_SCREEN_WRAP (SetWindowPixmap, xglSetWindowPixmap);
XGL_GET_WINDOW_PRIV (pWin)->pPixmap = pPixmap;
if (pPixmap != pScreenPriv->pScreenPixmap)
xglEnablePixmapAccel (pPixmap, &pScreenPriv->accel.window);
}

634
hw/xgl/xglxv.c Normal file
View File

@ -0,0 +1,634 @@
/*
* Copyright © 2005 Novell, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies
* and that both that copyright notice and this permission notice
* appear in supporting documentation, and that the name of
* Novell, Inc. not be used in advertising or publicity pertaining to
* distribution of the software without specific, written prior permission.
* Novell, Inc. makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
* NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Authors: David Reveman <davidr@novell.com>
* Matthias Hopf <mhopf@suse.de>
*/
#include "xgl.h"
#ifdef XV
#include "xvdix.h"
#include "gcstruct.h"
#include "dixstruct.h"
#include <X11/extensions/Xv.h>
#include <X11/extensions/Xvproto.h>
static unsigned int xglXvScreenIndex = 0;
static unsigned long portResource = 0;
#define XGL_GET_XV_SCREEN(pScreen) \
((XvScreenPtr) ((pScreen)->devPrivates[xglXvScreenIndex].ptr))
#define XGL_XV_SCREEN(pScreen) \
XvScreenPtr pXvScreen = XGL_GET_XV_SCREEN (pScreen)
#define XGL_GET_XV_SCREEN_PRIV(pScreen) \
((xglXvScreenPtr) (GET_XV_SCREEN (pScreen)->devPriv.ptr))
#define XGL_XV_SCREEN_PRIV(pScreen) \
xglXvScreenPtr pXvScreenPriv = XGL_GET_XV_SCREEN_PRIV (pScreen)
#define XGL_GET_XV_PORT_PRIV(pPort) \
((xglXvPortPtr) ((pPort)->devPriv.ptr))
#define XGL_XV_PORT_PRIV(pPort) \
xglXvPortPtr pPortPriv = XGL_GET_XV_PORT_PRIV (pPort)
#define XGL_XV_NUM_PORTS 32
#define XGL_XV_IMAGE_MAX_WIDTH 2048
#define XGL_XV_IMAGE_MAX_HEIGHT 2048
static XvImageRec xvImages[] = {
{
GLITZ_FOURCC_YUY2, XvYUV, BITMAP_BIT_ORDER,
{
'Y','U','Y','2',
0x00, 0x00, 0x00, 0x10, 0x80, 0x00,
0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71
},
16, XvPacked, 1,
0, 0, 0, 0,
8, 8, 8, 1, 2, 2, 1, 1, 1,
{
'Y', 'U', 'Y', 'V',
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
},
XvTopToBottom
}, {
GLITZ_FOURCC_YV12, XvYUV, BITMAP_BIT_ORDER,
{
'Y', 'V', '1', '2',
0x00, 0x00, 0x00, 0x10, 0x80, 0x00,
0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71
},
12, XvPlanar, 3,
0, 0, 0, 0,
8, 8, 8, 1, 2, 2, 1, 2, 2,
{
'Y', 'V', 'U', 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
},
XvTopToBottom
}, {
GLITZ_FOURCC_RGB, XvRGB, BITMAP_BIT_ORDER,
{
0x03, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x10, 0x80, 0x00,
0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71
},
32, XvPacked, 1,
24, 0xff0000, 0xff00, 0xff,
0, 0, 0, 0, 0, 0, 0, 0, 0,
{
0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
},
XvTopToBottom
}
};
static struct _xglXvFormat {
CARD32 format;
glitz_fourcc_t fourcc;
xglPixelFormatRec pixel;
} xglXvFormat[XGL_XV_FORMAT_NUM] = {
{
PICT_yuy2,
GLITZ_FOURCC_YUY2,
{
16, 6,
{
16,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
}
}
}, {
PICT_yv12,
GLITZ_FOURCC_YV12,
{
12, 4,
{
12,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
}
}
}, {
PICT_x8r8g8b8,
GLITZ_FOURCC_RGB,
{
24, 8,
{
32,
0x00000000,
0x00ff0000,
0x0000ff00,
0x000000ff,
}
}
}
};
static int
xglXvQueryAdaptors (ScreenPtr pScreen,
XvAdaptorPtr *pAdaptors,
int *nAdaptors)
{
XGL_XV_SCREEN (pScreen);
*nAdaptors = pXvScreen->nAdaptors;
*pAdaptors = pXvScreen->pAdaptors;
return Success;
}
static int
xglXvAllocatePort (unsigned long port,
XvPortPtr pPort,
XvPortPtr *ppPort)
{
*ppPort = pPort;
return Success;
}
static int
xglXvFreePort (XvPortPtr pPort)
{
XGL_XV_PORT_PRIV (pPort);
if (pPortPriv->pDst)
{
FreePicture ((pointer) pPortPriv->pDst, 0);
pPortPriv->pDst = (PicturePtr) 0;
}
if (pPortPriv->pSrc)
{
FreePicture ((pointer) pPortPriv->pSrc, 0);
pPortPriv->pSrc = (PicturePtr) 0;
}
if (pPortPriv->pPixmap)
{
ScreenPtr pScreen;
pScreen = pPortPriv->pPixmap->drawable.pScreen;
(*pScreen->DestroyPixmap) (pPortPriv->pPixmap);
pPortPriv->pPixmap = (PixmapPtr) 0;
}
return Success;
}
static int
xglXvQueryBestSize (ClientPtr client,
XvPortPtr pPort,
CARD8 motion,
CARD16 srcWidth,
CARD16 srcHeight,
CARD16 dstWidth,
CARD16 dstHeight,
unsigned int *pWidth,
unsigned int *pHeight)
{
*pWidth = dstWidth;
*pHeight = dstHeight;
return Success;
}
static int
xglXvStopVideo (ClientPtr client,
XvPortPtr pPort,
DrawablePtr pDrawable)
{
xglXvFreePort (pPort);
return Success;
}
static int
xglXvPutImage (ClientPtr client,
DrawablePtr pDrawable,
XvPortPtr pPort,
GCPtr pGC,
INT16 srcX,
INT16 srcY,
CARD16 srcWidth,
CARD16 srcHeight,
INT16 dstX,
INT16 dstY,
CARD16 dstWidth,
CARD16 dstHeight,
XvImagePtr pImage,
unsigned char *data,
Bool sync,
CARD16 width,
CARD16 height)
{
ScreenPtr pScreen = pDrawable->pScreen;
PictTransform transform;
int depth, bpp;
CARD32 format;
XGL_SCREEN_PRIV (pScreen);
XGL_XV_PORT_PRIV (pPort);
XGL_DRAWABLE_PIXMAP (pDrawable);
XGL_PIXMAP_PRIV (pPixmap);
switch (pImage->id) {
case GLITZ_FOURCC_YUY2:
bpp = depth = 16;
format = PICT_yuy2;
break;
case GLITZ_FOURCC_YV12:
depth = bpp = 12;
format = PICT_yv12;
break;
case GLITZ_FOURCC_RGB:
depth = 24;
bpp = 32;
format = PICT_x8r8g8b8;
break;
default:
return BadImplementation;
}
pPort->pDraw = pDrawable;
if (!pPortPriv->pPixmap)
{
pPortPriv->pPixmap = (*pScreen->CreatePixmap) (pScreen, 0, 0, depth);
if (!pPortPriv->pPixmap)
return BadAlloc;
}
(*pScreen->ModifyPixmapHeader) (pPortPriv->pPixmap,
srcWidth, srcHeight,
depth, bpp, -1, (pointer) data);
XGL_GET_PIXMAP_PRIV (pPortPriv->pPixmap)->stride = -srcWidth;
pPortPriv->pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
if (!pPortPriv->pSrc || pPortPriv->pSrc->format != format)
{
PictFormatPtr pFormat;
int error;
static XID value = RepeatPad;
pFormat = PictureMatchFormat (pScreen, depth, format);
if (!pFormat)
return BadImplementation;
if (pPortPriv->pSrc)
FreePicture ((pointer) pPortPriv->pSrc, 0);
pPortPriv->pSrc = CreatePicture (0, &pPortPriv->pPixmap->drawable,
pFormat, CPRepeat, &value,
serverClient, &error);
if (!pPortPriv->pSrc)
{
xglXvFreePort (pPort);
return error;
}
SetPictureFilter (pPortPriv->pSrc,
FilterBilinear, strlen (FilterBilinear),
0, 0);
}
if (!pPortPriv->pDst || pPortPriv->pDst->pDrawable != pDrawable)
{
PictFormatPtr pFormat = 0;
int i, error;
for (i = 0; i < pScreen->numVisuals; i++)
{
if (pScreen->visuals[i].nplanes == pDrawable->depth)
{
pFormat = PictureMatchVisual (pScreen, pDrawable->depth,
&pScreen->visuals[i]);
break;
}
}
if (!pFormat)
return BadImplementation;
if (pPortPriv->pDst)
FreePicture ((pointer) pPortPriv->pDst, 0);
pPortPriv->pDst = CreatePicture (0, pDrawable,
pFormat, 0, 0, serverClient,
&error);
if (!pPortPriv->pDst)
{
xglXvFreePort (pPort);
return error;
}
}
transform.matrix[0][0] = ((srcWidth << 16) + (dstWidth >> 1))
/ dstWidth;
transform.matrix[0][1] = 0;
transform.matrix[0][2] = 0;
/* flip Y */
transform.matrix[1][0] = 0;
transform.matrix[1][1] = -((srcHeight << 16) + (dstHeight >> 1))
/ dstHeight;
transform.matrix[1][2] = (srcHeight << 16);
transform.matrix[2][0] = 0;
transform.matrix[2][1] = 0;
transform.matrix[2][2] = 1 << 16;
SetPictureTransform (pPortPriv->pSrc, &transform);
if (pPixmap != pScreenPriv->pScreenPixmap && !pPixmapPriv->target)
xglEnablePixmapAccel (pPixmap, &pScreenPriv->accel.xv);
CompositePicture (PictOpSrc,
pPortPriv->pSrc,
(PicturePtr) 0,
pPortPriv->pDst,
srcX, srcY,
0, 0,
dstX, dstY,
dstWidth, dstHeight);
return Success;
}
static int
xglXvQueryImageAttributes (ClientPtr client,
XvPortPtr pPort,
XvImagePtr pImage,
CARD16 *width,
CARD16 *height,
int *pitches,
int *offsets)
{
if (*width > XGL_XV_IMAGE_MAX_WIDTH)
*width = XGL_XV_IMAGE_MAX_WIDTH;
if (*height > XGL_XV_IMAGE_MAX_HEIGHT)
*height = XGL_XV_IMAGE_MAX_HEIGHT;
*width = (*width + 7) & ~7;
switch (pImage->id) {
case GLITZ_FOURCC_YUY2:
if (offsets)
offsets[0] = 0;
if (pitches)
pitches[0] = *width * 2;
return *width * *height * 2;
case GLITZ_FOURCC_YV12:
*height = (*height + 1) & ~1;
if (offsets)
{
offsets[0] = 0;
offsets[1] = *width * *height;
offsets[2] = *width * *height + (*width >> 1) * (*height >> 1);
}
if (pitches)
{
pitches[0] = *width;
pitches[1] = pitches[2] = *width >> 1;
}
return *width * *height + (*width >> 1) * *height;
case GLITZ_FOURCC_RGB:
if (offsets)
offsets[0] = 0;
if (pitches)
pitches[0] = *width * 4;
return *width * *height * 4;
default:
return 0;
}
}
static void
xglXvFreeAdaptor (XvAdaptorPtr pAdaptor)
{
xfree (pAdaptor->pEncodings);
xfree (pAdaptor->pFormats);
if (pAdaptor->pPorts)
xfree (pAdaptor->pPorts);
}
static Bool
xglXvInitAdaptors (ScreenPtr pScreen)
{
XvAdaptorPtr pAdaptor;
xglXvPortPtr pPortPriv;
XvPortPtr pPort;
XvFormatPtr pFormat;
XvEncodingPtr pEncoding;
int i;
XGL_XV_SCREEN (pScreen);
pXvScreen->nAdaptors = 0;
pXvScreen->pAdaptors = NULL;
pAdaptor = xcalloc (1, sizeof (XvAdaptorRec));
if (!pAdaptor)
return FALSE;
pAdaptor->type = XvInputMask | XvImageMask;
pAdaptor->pScreen = pScreen;
pAdaptor->ddAllocatePort = xglXvAllocatePort;
pAdaptor->ddFreePort = xglXvFreePort;
pAdaptor->ddStopVideo = xglXvStopVideo;
pAdaptor->ddPutImage = xglXvPutImage;
pAdaptor->ddQueryBestSize = xglXvQueryBestSize;
pAdaptor->ddQueryImageAttributes = xglXvQueryImageAttributes;
pAdaptor->name = "Xgl Generic Texture Video";
pEncoding = xcalloc (1, sizeof (XvEncodingRec));
if (!pEncoding)
return FALSE;
pEncoding->id = 0;
pEncoding->pScreen = pScreen;
pEncoding->name = "XV_IMAGE";
pEncoding->width = XGL_XV_IMAGE_MAX_WIDTH;
pEncoding->height = XGL_XV_IMAGE_MAX_HEIGHT;
pEncoding->rate.numerator = 1;
pEncoding->rate.denominator = 1;
pAdaptor->nEncodings = 1;
pAdaptor->pEncodings = pEncoding;
pAdaptor->nImages = sizeof (xvImages) / sizeof (XvImageRec);
pAdaptor->pImages = xvImages;
/* TODO: Currently no attributes */
pAdaptor->nAttributes = 0;
pAdaptor->pAttributes = 0;
pFormat = xcalloc (pScreen->numVisuals, sizeof (XvFormatRec));
if (!pFormat)
return FALSE;
for (i = 0; i < pScreen->numVisuals; i++)
{
pFormat[i].depth = pScreen->visuals[i].nplanes;
pFormat[i].visual = pScreen->visuals[i].vid;
}
/* All visuals allowed */
pAdaptor->nFormats = pScreen->numVisuals;
pAdaptor->pFormats = pFormat;
pPort = xcalloc (XGL_XV_NUM_PORTS,
sizeof (XvPortRec) + sizeof (xglXvPortRec));
pPortPriv = (xglXvPortPtr) (pPort + XGL_XV_NUM_PORTS);
if (!pPort)
return FALSE;
for (i = 0; i < XGL_XV_NUM_PORTS; i++)
{
pPort[i].id = FakeClientID (0);
if (!pPort[i].id)
return FALSE;
if (!AddResource (pPort[i].id, portResource, &pPort[i]))
return FALSE;
pPort[i].pAdaptor = pAdaptor;
pPort[i].pNotify = (XvPortNotifyPtr) 0;
pPort[i].pDraw = (DrawablePtr) 0;
pPort[i].client = (ClientPtr) 0;
pPort[i].grab.client = (ClientPtr) 0;
pPort[i].time = currentTime;
pPort[i].devPriv.ptr = pPortPriv + i;
}
pAdaptor->nPorts = XGL_XV_NUM_PORTS;
pAdaptor->pPorts = pPort;
pAdaptor->base_id = pPort->id;
pXvScreen->pAdaptors = pAdaptor;
pXvScreen->nAdaptors = 1;
return TRUE;
}
static Bool
xglXvCloseScreen (int i, ScreenPtr pScreen)
{
int j;
XGL_XV_SCREEN (pScreen);
for (j = 0; j < pXvScreen->nAdaptors; j++)
xglXvFreeAdaptor (&pXvScreen->pAdaptors[j]);
if (pXvScreen->pAdaptors)
xfree (pXvScreen->pAdaptors);
return TRUE;
}
Bool
xglXvScreenInit (ScreenPtr pScreen)
{
XvScreenPtr pXvScreen;
xglVisualPtr v;
int i, status, vid = 0;
XGL_SCREEN_PRIV (pScreen);
status = XvScreenInit (pScreen);
if (status != Success)
return FALSE;
xglXvScreenIndex = XvGetScreenIndex ();
portResource = XvGetRTPort ();
pXvScreen = XGL_GET_XV_SCREEN (pScreen);
/* Anyone initializing the Xv layer must provide these two.
The Xv di layer calls them without even checking if they exist! */
pXvScreen->ddCloseScreen = xglXvCloseScreen;
pXvScreen->ddQueryAdaptors = xglXvQueryAdaptors;
pXvScreen->devPriv.ptr = (pointer) 0;
if (!xglXvInitAdaptors (pScreen))
return FALSE;
for (v = pScreenPriv->pVisual; v; v = v->next)
{
if (v->vid > vid)
vid = v->vid;
}
memset (pScreenPriv->pXvVisual, 0, sizeof (pScreenPriv->pXvVisual));
for (i = 0; i < XGL_XV_FORMAT_NUM; i++)
{
glitz_format_t templ;
templ.color.fourcc = xglXvFormat[i].fourcc;
pScreenPriv->pXvVisual[i].vid = ++vid;
pScreenPriv->pXvVisual[i].pPixel = &xglXvFormat[i].pixel;
pScreenPriv->pXvVisual[i].format.surface =
glitz_find_format (pScreenPriv->drawable,
GLITZ_FORMAT_FOURCC_MASK,
&templ, 0);
}
return TRUE;
}
#endif