Add working Xgl server code
This commit is contained in:
parent
1aef106064
commit
2dd76d646c
|
@ -1,17 +1,30 @@
|
|||
INCLUDES = \
|
||||
@XGL_INCS@ \
|
||||
@XSERVER_CFLAGS@
|
||||
SUBDIRS = . $(XGLX_DIRS)
|
||||
|
||||
bin_PROGRAMS = Xgl
|
||||
INCLUDES = \
|
||||
@XGL_INCS@ \
|
||||
@XSERVER_CFLAGS@ \
|
||||
@XGLSERVER_CFLAGS@
|
||||
|
||||
Xgl_SOURCES = \
|
||||
xglgc.c \
|
||||
xglinit.c \
|
||||
xglinput.c \
|
||||
xgloutput.c \
|
||||
xglpixmap.c \
|
||||
xglspans.c
|
||||
noinst_LIBRARIES = libxgl.a
|
||||
|
||||
Xgl_LDADD = \
|
||||
@XGL_LIBS@ \
|
||||
@XSERVER_LIBS@
|
||||
libxgl_a_SOURCES = \
|
||||
xglinput.c \
|
||||
xgloutput.c \
|
||||
xglcmap.c \
|
||||
xglparse.c \
|
||||
xglscreen.c \
|
||||
xgloffscreen.c \
|
||||
xglgeometry.c \
|
||||
xglpixmap.c \
|
||||
xglsync.c \
|
||||
xglsolid.c \
|
||||
xgltile.c \
|
||||
xglpixel.c \
|
||||
xglcopy.c \
|
||||
xglfill.c \
|
||||
xglwindow.c \
|
||||
xglbstore.c \
|
||||
xglget.c \
|
||||
xglgc.c \
|
||||
xglcomp.c \
|
||||
xglpict.c
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
INCLUDES = \
|
||||
@XGL_INCS@ \
|
||||
@XSERVER_CFLAGS@ \
|
||||
@XGLXSERVER_CFLAGS@
|
||||
|
||||
bin_PROGRAMS = Xglx
|
||||
|
||||
Xglx_SOURCES = xglx.c
|
||||
|
||||
Xglx_LDADD = \
|
||||
@XGL_LIBS@ \
|
||||
@XSERVER_LIBS@ \
|
||||
@XGLXSERVER_LIBS@
|
||||
|
||||
Xglx_DEPENDENCIES = @XGL_LIBS@
|
||||
|
|
@ -0,0 +1,615 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
* fee, provided that the above copyright notice appear in all copies
|
||||
* and that both that copyright notice and this permission notice
|
||||
* appear in supporting documentation, and that the names of
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Author: David Reveman <davidr@freedesktop.org>
|
||||
*/
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <glitz-glx.h>
|
||||
|
||||
#include "xgl.h"
|
||||
#include "inputstr.h"
|
||||
#include "mipointer.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <math.h>
|
||||
|
||||
#define XGLX_DEFAULT_SCREEN_WIDTH 800
|
||||
#define XGLX_DEFAULT_SCREEN_HEIGHT 600
|
||||
|
||||
typedef struct _xglxScreen {
|
||||
Window win;
|
||||
Colormap colormap;
|
||||
CloseScreenProcPtr CloseScreen;
|
||||
} xglxScreenRec, *xglxScreenPtr;
|
||||
|
||||
int xglxScreenGeneration = -1;
|
||||
int xglxScreenPrivateIndex;
|
||||
|
||||
#define XGLX_GET_SCREEN_PRIV(pScreen) \
|
||||
((xglxScreenPtr) (pScreen)->devPrivates[xglxScreenPrivateIndex].ptr)
|
||||
|
||||
#define XGLX_SET_SCREEN_PRIV(pScreen, v) \
|
||||
((pScreen)->devPrivates[xglxScreenPrivateIndex].ptr = (pointer) v)
|
||||
|
||||
#define XGLX_SCREEN_PRIV(pScreen) \
|
||||
xglxScreenPtr pScreenPriv = XGLX_GET_SCREEN_PRIV (pScreen)
|
||||
|
||||
char *xDisplayName = NULL;
|
||||
Display *xdisplay = NULL;
|
||||
int xscreen;
|
||||
glitz_format_t *xglxCurrentFormat;
|
||||
CARD32 lastEventTime = 0;
|
||||
ScreenPtr currentScreen = NULL;
|
||||
xglScreenInfoRec xglScreenInfo = { 0, 0, 0, 0, FALSE };
|
||||
|
||||
static Bool
|
||||
xglxAllocatePrivates (ScreenPtr pScreen)
|
||||
{
|
||||
xglxScreenPtr pScreenPriv;
|
||||
|
||||
if (xglxScreenGeneration != serverGeneration)
|
||||
{
|
||||
xglxScreenPrivateIndex = AllocateScreenPrivateIndex ();
|
||||
if (xglxScreenPrivateIndex < 0)
|
||||
return FALSE;
|
||||
|
||||
xglxScreenGeneration = serverGeneration;
|
||||
}
|
||||
|
||||
pScreenPriv = xalloc (sizeof (xglxScreenRec));
|
||||
if (!pScreenPriv)
|
||||
return FALSE;
|
||||
|
||||
XGLX_SET_SCREEN_PRIV (pScreen, pScreenPriv);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
xglxConstrainCursor (ScreenPtr pScreen,
|
||||
BoxPtr pBox)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
xglxCursorLimits (ScreenPtr pScreen,
|
||||
CursorPtr pCursor,
|
||||
BoxPtr pHotBox,
|
||||
BoxPtr pTopLeftBox)
|
||||
{
|
||||
*pTopLeftBox = *pHotBox;
|
||||
}
|
||||
|
||||
static Bool
|
||||
xglxDisplayCursor (ScreenPtr pScreen,
|
||||
CursorPtr pCursor)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Bool
|
||||
xglxRealizeCursor (ScreenPtr pScreen,
|
||||
CursorPtr pCursor)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Bool
|
||||
xglxUnrealizeCursor (ScreenPtr pScreen,
|
||||
CursorPtr pCursor)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
xglxRecolorCursor (ScreenPtr pScreen,
|
||||
CursorPtr pCursor,
|
||||
Bool displayed)
|
||||
{
|
||||
}
|
||||
|
||||
static Bool
|
||||
xglxSetCursorPosition (ScreenPtr pScreen,
|
||||
int x,
|
||||
int y,
|
||||
Bool generateEvent)
|
||||
{
|
||||
XGLX_SCREEN_PRIV (pScreen);
|
||||
|
||||
XWarpPointer (xdisplay, pScreenPriv->win, pScreenPriv->win,
|
||||
0, 0, 0, 0, x, y);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Bool
|
||||
xglxCloseScreen (int index,
|
||||
ScreenPtr pScreen)
|
||||
{
|
||||
glitz_drawable_t *drawable;
|
||||
|
||||
XGLX_SCREEN_PRIV (pScreen);
|
||||
|
||||
drawable = XGL_GET_SCREEN_PRIV (pScreen)->drawable;
|
||||
if (drawable)
|
||||
glitz_drawable_destroy (drawable);
|
||||
|
||||
xglClearVisualTypes ();
|
||||
|
||||
if (pScreenPriv->win)
|
||||
XDestroyWindow (xdisplay, pScreenPriv->win);
|
||||
|
||||
if (pScreenPriv->colormap)
|
||||
XFreeColormap (xdisplay, pScreenPriv->colormap);
|
||||
|
||||
XGL_SCREEN_UNWRAP (CloseScreen);
|
||||
xfree (pScreenPriv);
|
||||
|
||||
return (*pScreen->CloseScreen) (index, pScreen);
|
||||
}
|
||||
|
||||
static Bool
|
||||
xglxScreenInit (int index,
|
||||
ScreenPtr pScreen,
|
||||
int argc,
|
||||
char **argv)
|
||||
{
|
||||
XSetWindowAttributes xswa;
|
||||
XWMHints *wmHints;
|
||||
XSizeHints *normalHints;
|
||||
XClassHint *classHint;
|
||||
xglxScreenPtr pScreenPriv;
|
||||
Window root;
|
||||
XVisualInfo *vinfo;
|
||||
XEvent xevent;
|
||||
glitz_drawable_format_t *format;
|
||||
glitz_drawable_t *drawable;
|
||||
|
||||
format = xglVisuals[0].format;
|
||||
|
||||
if (!xglxAllocatePrivates (pScreen))
|
||||
return FALSE;
|
||||
|
||||
currentScreen = pScreen;
|
||||
|
||||
pScreenPriv = XGLX_GET_SCREEN_PRIV (pScreen);
|
||||
|
||||
root = RootWindow (xdisplay, xscreen);
|
||||
|
||||
vinfo = glitz_glx_get_visual_info_from_format (xdisplay, xscreen, format);
|
||||
if (!vinfo)
|
||||
{
|
||||
ErrorF ("[%d] no visual info from format\n", index);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pScreenPriv->colormap =
|
||||
XCreateColormap (xdisplay, root, vinfo->visual, AllocNone);
|
||||
|
||||
if (xglScreenInfo.fullscreen)
|
||||
{
|
||||
xglScreenInfo.width = DisplayWidth (xdisplay, xscreen);
|
||||
xglScreenInfo.height = DisplayHeight (xdisplay, xscreen);
|
||||
xglScreenInfo.widthMm = DisplayWidthMM (xdisplay, xscreen);
|
||||
xglScreenInfo.heightMm = DisplayHeightMM (xdisplay, xscreen);
|
||||
}
|
||||
else if (xglScreenInfo.width == 0 || xglScreenInfo.height == 0)
|
||||
{
|
||||
xglScreenInfo.width = XGLX_DEFAULT_SCREEN_WIDTH;
|
||||
xglScreenInfo.height = XGLX_DEFAULT_SCREEN_HEIGHT;
|
||||
}
|
||||
|
||||
xswa.colormap = pScreenPriv->colormap;
|
||||
|
||||
pScreenPriv->win =
|
||||
XCreateWindow (xdisplay, root, 0, 0,
|
||||
xglScreenInfo.width, xglScreenInfo.height, 0,
|
||||
vinfo->depth, InputOutput, vinfo->visual,
|
||||
CWColormap, &xswa);
|
||||
|
||||
XFree (vinfo);
|
||||
|
||||
normalHints = XAllocSizeHints ();
|
||||
normalHints->flags = PMinSize | PMaxSize | PSize;
|
||||
normalHints->min_width = xglScreenInfo.width;
|
||||
normalHints->min_height = xglScreenInfo.height;
|
||||
normalHints->max_width = xglScreenInfo.width;
|
||||
normalHints->max_height = xglScreenInfo.height;
|
||||
|
||||
if (xglScreenInfo.fullscreen)
|
||||
{
|
||||
normalHints->x = 0;
|
||||
normalHints->y = 0;
|
||||
normalHints->flags |= PPosition;
|
||||
}
|
||||
|
||||
classHint = XAllocClassHint ();
|
||||
classHint->res_name = "xglx";
|
||||
classHint->res_class = "Xglx";
|
||||
|
||||
wmHints = XAllocWMHints ();
|
||||
wmHints->flags = InputHint;
|
||||
wmHints->input = TRUE;
|
||||
|
||||
Xutf8SetWMProperties (xdisplay, pScreenPriv->win, "Xglx", "Xglx", 0, 0,
|
||||
normalHints, wmHints, classHint);
|
||||
|
||||
XFree (wmHints);
|
||||
XFree (classHint);
|
||||
XFree (normalHints);
|
||||
|
||||
drawable = glitz_glx_create_drawable_for_window (xdisplay, xscreen,
|
||||
format, pScreenPriv->win,
|
||||
xglScreenInfo.width,
|
||||
xglScreenInfo.height);
|
||||
if (!drawable)
|
||||
{
|
||||
ErrorF ("[%d] couldn't create glitz drawable for window\n", index);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
XSelectInput (xdisplay, pScreenPriv->win, ExposureMask);
|
||||
XMapWindow (xdisplay, pScreenPriv->win);
|
||||
|
||||
if (xglScreenInfo.fullscreen)
|
||||
{
|
||||
XClientMessageEvent xev;
|
||||
|
||||
memset (&xev, 0, sizeof (xev));
|
||||
|
||||
xev.type = ClientMessage;
|
||||
xev.message_type = XInternAtom (xdisplay, "_NET_WM_STATE", FALSE);
|
||||
xev.display = xdisplay;
|
||||
xev.window = pScreenPriv->win;
|
||||
xev.format = 32;
|
||||
xev.data.l[0] = 1;
|
||||
xev.data.l[1] =
|
||||
XInternAtom (xdisplay, "_NET_WM_STATE_FULLSCREEN", FALSE);
|
||||
|
||||
XSendEvent (xdisplay, root, FALSE, SubstructureRedirectMask,
|
||||
(XEvent *) &xev);
|
||||
}
|
||||
|
||||
xglScreenInfo.drawable = drawable;
|
||||
|
||||
if (!xglScreenInit (pScreen, &xglScreenInfo))
|
||||
return FALSE;
|
||||
|
||||
pScreen->ConstrainCursor = xglxConstrainCursor;
|
||||
pScreen->CursorLimits = xglxCursorLimits;
|
||||
pScreen->DisplayCursor = xglxDisplayCursor;
|
||||
pScreen->RealizeCursor = xglxRealizeCursor;
|
||||
pScreen->UnrealizeCursor = xglxUnrealizeCursor;
|
||||
pScreen->RecolorCursor = xglxRecolorCursor;
|
||||
pScreen->SetCursorPosition = xglxSetCursorPosition;
|
||||
|
||||
XGL_SCREEN_WRAP (CloseScreen, xglxCloseScreen);
|
||||
|
||||
if (!xglFinishScreenInit (pScreen))
|
||||
return FALSE;
|
||||
|
||||
while (XNextEvent (xdisplay, &xevent))
|
||||
if (xevent.type == Expose)
|
||||
break;
|
||||
|
||||
XSelectInput (xdisplay, pScreenPriv->win,
|
||||
ButtonPressMask | ButtonReleaseMask |
|
||||
KeyPressMask | KeyReleaseMask | EnterWindowMask |
|
||||
PointerMotionMask);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
InitOutput (ScreenInfo *pScreenInfo,
|
||||
int argc,
|
||||
char **argv)
|
||||
{
|
||||
glitz_drawable_format_t *format, templ;
|
||||
int i;
|
||||
unsigned long mask;
|
||||
unsigned long extraMask[] = {
|
||||
GLITZ_FORMAT_PBUFFER_MASK |
|
||||
GLITZ_FORMAT_DOUBLEBUFFER_MASK | GLITZ_FORMAT_ALPHA_SIZE_MASK,
|
||||
GLITZ_FORMAT_DOUBLEBUFFER_MASK | GLITZ_FORMAT_ALPHA_SIZE_MASK,
|
||||
GLITZ_FORMAT_ALPHA_SIZE_MASK,
|
||||
GLITZ_FORMAT_DOUBLEBUFFER_MASK,
|
||||
0
|
||||
};
|
||||
|
||||
xglSetPixmapFormats (pScreenInfo);
|
||||
|
||||
if (!xdisplay)
|
||||
{
|
||||
xdisplay = XOpenDisplay (xDisplayName);
|
||||
if (!xdisplay)
|
||||
FatalError ("can't open display");
|
||||
|
||||
xscreen = DefaultScreen (xdisplay);
|
||||
}
|
||||
|
||||
templ.types.window = 1;
|
||||
templ.types.pbuffer = 1;
|
||||
templ.samples = 1;
|
||||
templ.doublebuffer = 1;
|
||||
templ.color.alpha_size = 8;
|
||||
|
||||
mask =
|
||||
GLITZ_FORMAT_WINDOW_MASK |
|
||||
GLITZ_FORMAT_SAMPLES_MASK;
|
||||
|
||||
for (i = 0; i < sizeof (extraMask) / sizeof (extraMask[0]); i++)
|
||||
{
|
||||
format = glitz_glx_find_drawable_format (xdisplay, xscreen,
|
||||
mask | extraMask[i],
|
||||
&templ, 0);
|
||||
if (format)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!format)
|
||||
FatalError ("no visual format found");
|
||||
|
||||
xglSetVisualTypesAndMasks (pScreenInfo, format, (1 << TrueColor));
|
||||
|
||||
xglInitVisuals (pScreenInfo);
|
||||
|
||||
AddScreen (xglxScreenInit, argc, argv);
|
||||
}
|
||||
|
||||
static void
|
||||
xglxBlockHandler (pointer blockData,
|
||||
OSTimePtr pTimeout,
|
||||
pointer pReadMask)
|
||||
{
|
||||
glitz_surface_flush (XGL_GET_SCREEN_PRIV (currentScreen)->surface);
|
||||
glitz_drawable_flush (XGL_GET_SCREEN_PRIV (currentScreen)->drawable);
|
||||
XFlush (xdisplay);
|
||||
}
|
||||
|
||||
static void
|
||||
xglxWakeupHandler (pointer blockData,
|
||||
int result,
|
||||
pointer pReadMask)
|
||||
{
|
||||
ScreenPtr pScreen = currentScreen;
|
||||
XEvent X;
|
||||
xEvent x;
|
||||
|
||||
while (XPending (xdisplay)) {
|
||||
XNextEvent (xdisplay, &X);
|
||||
|
||||
switch (X.type) {
|
||||
case KeyPress:
|
||||
x.u.u.type = KeyPress;
|
||||
x.u.u.detail = X.xkey.keycode;
|
||||
x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis ();
|
||||
mieqEnqueue (&x);
|
||||
break;
|
||||
case KeyRelease:
|
||||
x.u.u.type = KeyRelease;
|
||||
x.u.u.detail = X.xkey.keycode;
|
||||
x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis ();
|
||||
mieqEnqueue (&x);
|
||||
break;
|
||||
case ButtonPress:
|
||||
x.u.u.type = ButtonPress;
|
||||
x.u.u.detail = X.xbutton.button;
|
||||
x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis ();
|
||||
mieqEnqueue (&x);
|
||||
break;
|
||||
case ButtonRelease:
|
||||
x.u.u.type = ButtonRelease;
|
||||
x.u.u.detail = X.xbutton.button;
|
||||
x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis ();
|
||||
mieqEnqueue (&x);
|
||||
break;
|
||||
case MotionNotify:
|
||||
x.u.u.type = MotionNotify;
|
||||
x.u.keyButtonPointer.rootX = X.xmotion.x;
|
||||
x.u.keyButtonPointer.rootY = X.xmotion.y;
|
||||
x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis ();
|
||||
mieqEnqueue (&x);
|
||||
break;
|
||||
case EnterNotify:
|
||||
if (X.xcrossing.detail != NotifyInferior) {
|
||||
if (pScreen) {
|
||||
NewCurrentScreen (pScreen, X.xcrossing.x, X.xcrossing.y);
|
||||
x.u.u.type = MotionNotify;
|
||||
x.u.keyButtonPointer.rootX = X.xcrossing.x;
|
||||
x.u.keyButtonPointer.rootY = X.xcrossing.y;
|
||||
x.u.keyButtonPointer.time = lastEventTime =
|
||||
GetTimeInMillis ();
|
||||
mieqEnqueue (&x);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
xglxBell (int volume,
|
||||
DeviceIntPtr pDev,
|
||||
pointer ctrl,
|
||||
int cls)
|
||||
{
|
||||
XBell (xdisplay, volume);
|
||||
}
|
||||
|
||||
static int
|
||||
xglxKeybdProc (DeviceIntPtr pDevice,
|
||||
int onoff)
|
||||
{
|
||||
Bool ret;
|
||||
DevicePtr pDev = (DevicePtr) pDevice;
|
||||
|
||||
if (!pDev)
|
||||
return BadImplementation;
|
||||
|
||||
switch (onoff) {
|
||||
case DEVICE_INIT: {
|
||||
XModifierKeymap *xmodMap;
|
||||
KeySym *xkeyMap;
|
||||
int minKeyCode, maxKeyCode, mapWidth, i, j;
|
||||
KeySymsRec xglxKeySyms;
|
||||
CARD8 xglxModMap[256];
|
||||
XKeyboardState values;
|
||||
|
||||
if (pDev != LookupKeyboardDevice ())
|
||||
return !Success;
|
||||
|
||||
xmodMap = XGetModifierMapping (xdisplay);
|
||||
XDisplayKeycodes (xdisplay, &minKeyCode, &maxKeyCode);
|
||||
xkeyMap = XGetKeyboardMapping (xdisplay,
|
||||
minKeyCode,
|
||||
maxKeyCode - minKeyCode + 1,
|
||||
&mapWidth);
|
||||
|
||||
memset (xglxModMap, 0, 256);
|
||||
|
||||
for (j = 0; j < 8; j++)
|
||||
{
|
||||
for (i = 0; i < xmodMap->max_keypermod; i++)
|
||||
{
|
||||
CARD8 keyCode;
|
||||
|
||||
keyCode = xmodMap->modifiermap[j * xmodMap->max_keypermod + i];
|
||||
if (keyCode)
|
||||
xglxModMap[keyCode] |= 1 << j;
|
||||
}
|
||||
}
|
||||
|
||||
XFreeModifiermap (xmodMap);
|
||||
|
||||
xglxKeySyms.minKeyCode = minKeyCode;
|
||||
xglxKeySyms.maxKeyCode = maxKeyCode;
|
||||
xglxKeySyms.mapWidth = mapWidth;
|
||||
xglxKeySyms.map = xkeyMap;
|
||||
|
||||
XGetKeyboardControl (xdisplay, &values);
|
||||
|
||||
memmove (defaultKeyboardControl.autoRepeats,
|
||||
values.auto_repeats, sizeof (values.auto_repeats));
|
||||
|
||||
ret = InitKeyboardDeviceStruct (pDev,
|
||||
&xglxKeySyms,
|
||||
xglxModMap,
|
||||
xglxBell,
|
||||
xglKbdCtrl);
|
||||
|
||||
XFree (xkeyMap);
|
||||
|
||||
if (!ret)
|
||||
return BadImplementation;
|
||||
} break;
|
||||
case DEVICE_ON:
|
||||
pDev->on = TRUE;
|
||||
break;
|
||||
case DEVICE_OFF:
|
||||
case DEVICE_CLOSE:
|
||||
pDev->on = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
Bool
|
||||
LegalModifier (unsigned int key,
|
||||
DevicePtr pDev)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
ProcessInputEvents ()
|
||||
{
|
||||
mieqProcessInputEvents ();
|
||||
}
|
||||
|
||||
void
|
||||
InitInput (int argc, char **argv)
|
||||
{
|
||||
DeviceIntPtr pKeyboard, pPointer;
|
||||
|
||||
pPointer = AddInputDevice (xglMouseProc, TRUE);
|
||||
pKeyboard = AddInputDevice (xglxKeybdProc, TRUE);
|
||||
|
||||
RegisterPointerDevice (pPointer);
|
||||
RegisterKeyboardDevice (pKeyboard);
|
||||
|
||||
miRegisterPointerDevice (screenInfo.screens[0], pPointer);
|
||||
mieqInit (&pKeyboard->public, &pPointer->public);
|
||||
|
||||
AddEnabledDevice (XConnectionNumber (xdisplay));
|
||||
|
||||
RegisterBlockAndWakeupHandlers (xglxBlockHandler,
|
||||
xglxWakeupHandler,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void
|
||||
ddxUseMsg (void)
|
||||
{
|
||||
ErrorF ("\nXglx Usage:\n");
|
||||
ErrorF ("-display string display name of the real server\n");
|
||||
|
||||
xglUseMsg ();
|
||||
}
|
||||
|
||||
int
|
||||
ddxProcessArgument (int argc, char **argv, int i)
|
||||
{
|
||||
if (!strcmp (argv[i], "-display")) {
|
||||
if (++i < argc) {
|
||||
xDisplayName = argv[i];
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
return xglProcessArgument (&xglScreenInfo, argc, argv, i);
|
||||
}
|
||||
|
||||
void
|
||||
AbortDDX (void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
ddxGiveUp ()
|
||||
{
|
||||
AbortDDX ();
|
||||
}
|
||||
|
||||
void
|
||||
OsVendorInit (void)
|
||||
{
|
||||
}
|
195
hw/xgl/kbd.c
195
hw/xgl/kbd.c
|
@ -1,195 +0,0 @@
|
|||
/*
|
||||
* Id: kbd.c,v 1.1 1999/11/02 18:39:28 keithp Exp $
|
||||
*
|
||||
* Copyright © 1999 Keith Packard
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Keith Packard not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Keith Packard makes no
|
||||
* representations about the suitability of this software for any purpose. It
|
||||
* is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
/* $RCSId: xc/programs/Xserver/hw/kdrive/fake/kbd.c,v 1.1 1999/11/19 13:53:53 hohndel Exp $ */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include "fake.h"
|
||||
#include "kkeymap.h"
|
||||
#include <X11/keysym.h>
|
||||
|
||||
#define FAKE_WIDTH 2
|
||||
|
||||
KeySym FakeKeymap[] = {
|
||||
/* 1 8 */ XK_Escape, NoSymbol,
|
||||
/* 2 9 */ XK_1, XK_exclam,
|
||||
/* 3 10 */ XK_2, XK_at,
|
||||
/* 4 11 */ XK_3, XK_numbersign,
|
||||
/* 5 12 */ XK_4, XK_dollar,
|
||||
/* 6 13 */ XK_5, XK_percent,
|
||||
/* 7 14 */ XK_6, XK_asciicircum,
|
||||
/* 8 15 */ XK_7, XK_ampersand,
|
||||
/* 9 16 */ XK_8, XK_asterisk,
|
||||
/* 10 17 */ XK_9, XK_parenleft,
|
||||
/* 11 18 */ XK_0, XK_parenright,
|
||||
/* 12 19 */ XK_minus, XK_underscore,
|
||||
/* 13 20 */ XK_equal, XK_plus,
|
||||
/* 14 21 */ XK_BackSpace, NoSymbol,
|
||||
/* 15 22 */ XK_Tab, NoSymbol,
|
||||
/* 16 23 */ XK_Q, NoSymbol,
|
||||
/* 17 24 */ XK_W, NoSymbol,
|
||||
/* 18 25 */ XK_E, NoSymbol,
|
||||
/* 19 26 */ XK_R, NoSymbol,
|
||||
/* 20 27 */ XK_T, NoSymbol,
|
||||
/* 21 28 */ XK_Y, NoSymbol,
|
||||
/* 22 29 */ XK_U, NoSymbol,
|
||||
/* 23 30 */ XK_I, NoSymbol,
|
||||
/* 24 31 */ XK_O, NoSymbol,
|
||||
/* 25 32 */ XK_P, NoSymbol,
|
||||
/* 26 33 */ XK_bracketleft, XK_braceleft,
|
||||
/* 27 34 */ XK_bracketright, XK_braceright,
|
||||
/* 28 35 */ XK_Return, NoSymbol,
|
||||
/* 29 36 */ XK_Control_L, NoSymbol,
|
||||
/* 30 37 */ XK_A, NoSymbol,
|
||||
/* 31 38 */ XK_S, NoSymbol,
|
||||
/* 32 39 */ XK_D, NoSymbol,
|
||||
/* 33 40 */ XK_F, NoSymbol,
|
||||
/* 34 41 */ XK_G, NoSymbol,
|
||||
/* 35 42 */ XK_H, NoSymbol,
|
||||
/* 36 43 */ XK_J, NoSymbol,
|
||||
/* 37 44 */ XK_K, NoSymbol,
|
||||
/* 38 45 */ XK_L, NoSymbol,
|
||||
/* 39 46 */ XK_semicolon, XK_colon,
|
||||
/* 40 47 */ XK_apostrophe, XK_quotedbl,
|
||||
/* 41 48 */ XK_grave, XK_asciitilde,
|
||||
/* 42 49 */ XK_Shift_L, NoSymbol,
|
||||
/* 43 50 */ XK_backslash, XK_bar,
|
||||
/* 44 51 */ XK_Z, NoSymbol,
|
||||
/* 45 52 */ XK_X, NoSymbol,
|
||||
/* 46 53 */ XK_C, NoSymbol,
|
||||
/* 47 54 */ XK_V, NoSymbol,
|
||||
/* 48 55 */ XK_B, NoSymbol,
|
||||
/* 49 56 */ XK_N, NoSymbol,
|
||||
/* 50 57 */ XK_M, NoSymbol,
|
||||
/* 51 58 */ XK_comma, XK_less,
|
||||
/* 52 59 */ XK_period, XK_greater,
|
||||
/* 53 60 */ XK_slash, XK_question,
|
||||
/* 54 61 */ XK_Shift_R, NoSymbol,
|
||||
/* 55 62 */ XK_KP_Multiply, NoSymbol,
|
||||
/* 56 63 */ XK_Alt_L, XK_Meta_L,
|
||||
/* 57 64 */ XK_space, NoSymbol,
|
||||
/* 58 65 */ XK_Caps_Lock, NoSymbol,
|
||||
/* 59 66 */ XK_F1, NoSymbol,
|
||||
/* 60 67 */ XK_F2, NoSymbol,
|
||||
/* 61 68 */ XK_F3, NoSymbol,
|
||||
/* 62 69 */ XK_F4, NoSymbol,
|
||||
/* 63 70 */ XK_F5, NoSymbol,
|
||||
/* 64 71 */ XK_F6, NoSymbol,
|
||||
/* 65 72 */ XK_F7, NoSymbol,
|
||||
/* 66 73 */ XK_F8, NoSymbol,
|
||||
/* 67 74 */ XK_F9, NoSymbol,
|
||||
/* 68 75 */ XK_F10, NoSymbol,
|
||||
/* 69 76 */ XK_Break, XK_Pause,
|
||||
/* 70 77 */ XK_Scroll_Lock, NoSymbol,
|
||||
/* 71 78 */ XK_KP_Home, XK_KP_7,
|
||||
/* 72 79 */ XK_KP_Up, XK_KP_8,
|
||||
/* 73 80 */ XK_KP_Page_Up, XK_KP_9,
|
||||
/* 74 81 */ XK_KP_Subtract, NoSymbol,
|
||||
/* 75 82 */ XK_KP_Left, XK_KP_4,
|
||||
/* 76 83 */ XK_KP_5, NoSymbol,
|
||||
/* 77 84 */ XK_KP_Right, XK_KP_6,
|
||||
/* 78 85 */ XK_KP_Add, NoSymbol,
|
||||
/* 79 86 */ XK_KP_End, XK_KP_1,
|
||||
/* 80 87 */ XK_KP_Down, XK_KP_2,
|
||||
/* 81 88 */ XK_KP_Page_Down, XK_KP_3,
|
||||
/* 82 89 */ XK_KP_Insert, XK_KP_0,
|
||||
/* 83 90 */ XK_KP_Delete, XK_KP_Decimal,
|
||||
/* 84 91 */ NoSymbol, NoSymbol,
|
||||
/* 85 92 */ NoSymbol, NoSymbol,
|
||||
/* 86 93 */ NoSymbol, NoSymbol,
|
||||
/* 87 94 */ XK_F11, NoSymbol,
|
||||
/* 88 95 */ XK_F12, NoSymbol,
|
||||
|
||||
/* These are remapped from the extended set (using ExtendMap) */
|
||||
|
||||
/* 89 96 */ XK_Control_R, NoSymbol,
|
||||
/* 90 97 */ XK_KP_Enter, NoSymbol,
|
||||
/* 91 98 */ XK_KP_Divide, NoSymbol,
|
||||
/* 92 99 */ XK_Sys_Req, XK_Print,
|
||||
/* 93 100 */ XK_Alt_R, XK_Meta_R,
|
||||
/* 94 101 */ XK_Num_Lock, NoSymbol,
|
||||
/* 95 102 */ XK_Home, NoSymbol,
|
||||
/* 96 103 */ XK_Up, NoSymbol,
|
||||
/* 97 104 */ XK_Page_Up, NoSymbol,
|
||||
/* 98 105 */ XK_Left, NoSymbol,
|
||||
/* 99 106 */ XK_Right, NoSymbol,
|
||||
/* 100 107 */ XK_End, NoSymbol,
|
||||
/* 101 108 */ XK_Down, NoSymbol,
|
||||
/* 102 109 */ XK_Page_Down, NoSymbol,
|
||||
/* 103 110 */ XK_Insert, NoSymbol,
|
||||
/* 104 111 */ XK_Delete, NoSymbol,
|
||||
/* 105 112 */ XK_Super_L, NoSymbol,
|
||||
/* 106 113 */ XK_Super_R, NoSymbol,
|
||||
/* 107 114 */ XK_Menu, NoSymbol,
|
||||
|
||||
/* 108 115 */ XK_Next, NoSymbol, /* right button on side */
|
||||
/* 109 116 */ XK_Prior, NoSymbol, /* left button on side */
|
||||
/* 110 117 */ XK_Up, NoSymbol, /* joypad */
|
||||
/* 111 118 */ XK_Down, NoSymbol,
|
||||
/* 112 119 */ XK_Left, NoSymbol,
|
||||
/* 113 120 */ XK_Right, NoSymbol,
|
||||
/* 114 121 */ NoSymbol, NoSymbol, /* left near speaker */
|
||||
/* 115 122 */ NoSymbol, NoSymbol, /* right near speaker */
|
||||
/* 116 123 */ NoSymbol, NoSymbol, /* tiny button */
|
||||
};
|
||||
|
||||
static void
|
||||
FakeKeyboardLoad (void)
|
||||
{
|
||||
kdMinScanCode = 1;
|
||||
kdKeymapWidth = FAKE_WIDTH;
|
||||
kdMaxScanCode = (sizeof (FakeKeymap) / sizeof (FakeKeymap[0])) / FAKE_WIDTH;
|
||||
memcpy (kdKeymap, FakeKeymap, sizeof (FakeKeymap));
|
||||
}
|
||||
|
||||
static int
|
||||
FakeKeyboardInit (void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
FakeKeyboardFini (void)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
FakeKeyboardLeds (int leds)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
FakeKeyboardBell (int volume, int frequency, int duration)
|
||||
{
|
||||
}
|
||||
|
||||
KdKeyboardFuncs FakeKeyboardFuncs = {
|
||||
FakeKeyboardLoad,
|
||||
FakeKeyboardInit,
|
||||
FakeKeyboardLeds,
|
||||
FakeKeyboardBell,
|
||||
FakeKeyboardFini,
|
||||
0,
|
||||
};
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright © 2004 Keith Packard
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Keith Packard not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Keith Packard makes no
|
||||
* representations about the suitability of this software for any purpose. It
|
||||
* is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
#define NEED_EVENTS
|
||||
#include <errno.h>
|
||||
#include <termios.h>
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xproto.h>
|
||||
#include <X11/Xpoll.h>
|
||||
#include "inputstr.h"
|
||||
#include "scrnintstr.h"
|
||||
#include "kdrive.h"
|
||||
|
||||
static Bool
|
||||
MouseInit (void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
MouseFini (void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
KdMouseFuncs FakeMouseFuncs = {
|
||||
MouseInit,
|
||||
MouseFini,
|
||||
};
|
1040
hw/xgl/xgl.h
1040
hw/xgl/xgl.h
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,125 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
* fee, provided that the above copyright notice appear in all copies
|
||||
* and that both that copyright notice and this permission notice
|
||||
* appear in supporting documentation, and that the names of
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Author: David Reveman <davidr@freedesktop.org>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
|
||||
#define XGL_BSTORE_FALLBACK_PROLOGUE(pDrawable, func) \
|
||||
xglSyncDamageBoxBits (pDrawable); \
|
||||
XGL_SCREEN_UNWRAP (func)
|
||||
|
||||
#define XGL_BSTORE_FALLBACK_EPILOGUE(pDrawable, func, xglfunc) \
|
||||
XGL_SCREEN_WRAP (func, xglfunc); \
|
||||
xglAddSurfaceDamage (pDrawable)
|
||||
|
||||
/*
|
||||
* The follwong functions are not yet tested so we can assume that they
|
||||
* are both broken.
|
||||
*/
|
||||
|
||||
void
|
||||
xglSaveAreas (PixmapPtr pPixmap,
|
||||
RegionPtr prgnSave,
|
||||
int xorg,
|
||||
int yorg,
|
||||
WindowPtr pWin)
|
||||
{
|
||||
ScreenPtr pScreen = pWin->drawable.pScreen;
|
||||
BoxRec box;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
box = *(REGION_EXTENTS (pScreen, prgnSave));
|
||||
|
||||
pPixmapPriv->damageBox = box;
|
||||
|
||||
if (xglCopy (&pWin->drawable,
|
||||
&pPixmap->drawable,
|
||||
xorg, yorg,
|
||||
REGION_RECTS (prgnSave),
|
||||
REGION_NUM_RECTS (prgnSave)))
|
||||
{
|
||||
xglAddBitDamage (&pPixmap->drawable);
|
||||
return;
|
||||
}
|
||||
|
||||
box.x1 += xorg;
|
||||
box.y1 += yorg;
|
||||
box.x2 += xorg;
|
||||
box.y2 += yorg;
|
||||
|
||||
if (!xglSyncBits (&pWin->drawable, &box))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
|
||||
XGL_BSTORE_FALLBACK_PROLOGUE (&pPixmap->drawable,
|
||||
BackingStoreFuncs.RestoreAreas);
|
||||
(*pScreen->BackingStoreFuncs.SaveAreas) (pPixmap, prgnSave,
|
||||
xorg, yorg, pWin);
|
||||
XGL_BSTORE_FALLBACK_EPILOGUE (&pPixmap->drawable,
|
||||
BackingStoreFuncs.SaveAreas,
|
||||
xglSaveAreas);
|
||||
}
|
||||
|
||||
void
|
||||
xglRestoreAreas (PixmapPtr pPixmap,
|
||||
RegionPtr prgnRestore,
|
||||
int xorg,
|
||||
int yorg,
|
||||
WindowPtr pWin)
|
||||
{
|
||||
ScreenPtr pScreen = pWin->drawable.pScreen;
|
||||
BoxPtr pExt;
|
||||
BoxRec box;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
if (xglCopy (&pPixmap->drawable,
|
||||
&pWin->drawable,
|
||||
-xorg, -yorg,
|
||||
REGION_RECTS (prgnRestore),
|
||||
REGION_NUM_RECTS (prgnRestore)))
|
||||
{
|
||||
xglAddBitDamage (&pPixmap->drawable);
|
||||
return;
|
||||
}
|
||||
|
||||
pExt = REGION_EXTENTS (pScreen, prgnRestore);
|
||||
|
||||
box.x1 = pExt->x1 - xorg;
|
||||
box.y1 = pExt->y1 - yorg;
|
||||
box.x2 = pExt->x2 - xorg;
|
||||
box.y2 = pExt->y2 - yorg;
|
||||
|
||||
if (!xglSyncBits (&pPixmap->drawable, &box))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
|
||||
XGL_BSTORE_FALLBACK_PROLOGUE (&pWin->drawable,
|
||||
BackingStoreFuncs.RestoreAreas);
|
||||
(*pScreen->BackingStoreFuncs.RestoreAreas) (pPixmap, prgnRestore,
|
||||
xorg, yorg, pWin);
|
||||
XGL_BSTORE_FALLBACK_EPILOGUE (&pWin->drawable,
|
||||
BackingStoreFuncs.RestoreAreas,
|
||||
xglRestoreAreas);
|
||||
}
|
|
@ -0,0 +1,325 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
* fee, provided that the above copyright notice appear in all copies
|
||||
* and that both that copyright notice and this permission notice
|
||||
* appear in supporting documentation, and that the names of
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Author: David Reveman <davidr@freedesktop.org>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
#include "colormapst.h"
|
||||
#include "micmap.h"
|
||||
#include "fb.h"
|
||||
|
||||
static xglPixelFormatRec xglPixelFormats[] = {
|
||||
{
|
||||
8, 8,
|
||||
{
|
||||
8,
|
||||
0x000000ff,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0x00000000
|
||||
}
|
||||
}, {
|
||||
15, 5,
|
||||
{
|
||||
16,
|
||||
0x00000000,
|
||||
0x00007c00,
|
||||
0x000003e0,
|
||||
0x0000001f
|
||||
}
|
||||
}, {
|
||||
16, 6,
|
||||
{
|
||||
16,
|
||||
0x00000000,
|
||||
0x0000f800,
|
||||
0x000007e0,
|
||||
0x0000001f
|
||||
}
|
||||
}, {
|
||||
24, 8,
|
||||
{
|
||||
32,
|
||||
0x00000000,
|
||||
0x00ff0000,
|
||||
0x0000ff00,
|
||||
0x000000ff
|
||||
}
|
||||
}, {
|
||||
32, 8,
|
||||
{
|
||||
32,
|
||||
0xff000000,
|
||||
0x00ff0000,
|
||||
0x0000ff00,
|
||||
0x000000ff
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#define NUM_XGL_PIXEL_FORMATS \
|
||||
(sizeof (xglPixelFormats) / sizeof (xglPixelFormats[0]))
|
||||
|
||||
xglVisualPtr xglVisuals = NULL;
|
||||
int nxglVisuals = 0;
|
||||
|
||||
xglVisualPtr xglPbufferVisuals = NULL;
|
||||
int nxglPbufferVisuals = 0;
|
||||
|
||||
static xglPixelFormatPtr
|
||||
xglFindPixelFormat (glitz_drawable_format_t *format,
|
||||
int visuals)
|
||||
{
|
||||
glitz_color_format_t *color;
|
||||
int depth, i;
|
||||
|
||||
color = &format->color;
|
||||
|
||||
depth = color->red_size + color->green_size + color->blue_size;
|
||||
|
||||
if (!visuals)
|
||||
depth += color->alpha_size;
|
||||
|
||||
for (i = 0; i < NUM_XGL_PIXEL_FORMATS; i++)
|
||||
{
|
||||
if (xglPixelFormats[i].depth == depth)
|
||||
{
|
||||
xglPixelFormatPtr pPixel;
|
||||
|
||||
pPixel = &xglPixelFormats[i];
|
||||
if (Ones (pPixel->masks.red_mask) == color->red_size &&
|
||||
Ones (pPixel->masks.green_mask) == color->green_size &&
|
||||
Ones (pPixel->masks.blue_mask) == color->blue_size)
|
||||
{
|
||||
|
||||
if (visuals)
|
||||
return pPixel;
|
||||
|
||||
if (Ones (pPixel->masks.alpha_mask) == color->alpha_size)
|
||||
return pPixel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
xglSetVisualTypesAndMasks (ScreenInfo *pScreenInfo,
|
||||
glitz_drawable_format_t *format,
|
||||
unsigned long visuals)
|
||||
{
|
||||
xglPixelFormatPtr pPixelFormat;
|
||||
|
||||
pPixelFormat = xglFindPixelFormat (format, visuals);
|
||||
if (pPixelFormat)
|
||||
{
|
||||
if (visuals && format->types.window)
|
||||
{
|
||||
xglVisuals = xrealloc (xglVisuals,
|
||||
(nxglVisuals + 1) * sizeof (xglVisualRec));
|
||||
|
||||
if (xglVisuals)
|
||||
{
|
||||
xglVisuals[nxglVisuals].format = format;
|
||||
xglVisuals[nxglVisuals].pPixel = pPixelFormat;
|
||||
xglVisuals[nxglVisuals].visuals = visuals;
|
||||
nxglVisuals++;
|
||||
}
|
||||
}
|
||||
|
||||
if (format->types.pbuffer)
|
||||
{
|
||||
xglPbufferVisuals =
|
||||
xrealloc (xglPbufferVisuals,
|
||||
(nxglPbufferVisuals + 1) * sizeof (xglVisualRec));
|
||||
|
||||
if (xglPbufferVisuals)
|
||||
{
|
||||
xglPbufferVisuals[nxglPbufferVisuals].format = format;
|
||||
xglPbufferVisuals[nxglPbufferVisuals].pPixel = pPixelFormat;
|
||||
xglPbufferVisuals[nxglPbufferVisuals].visuals = visuals;
|
||||
nxglPbufferVisuals++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
rm = xglPixelFormats[j].masks.red_mask;
|
||||
gm = xglPixelFormats[j].masks.green_mask;
|
||||
bm = xglPixelFormats[j].masks.blue_mask;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fbSetVisualTypesAndMasks (pScreenInfo->formats[i].depth,
|
||||
visuals, bitsPerRGB,
|
||||
rm, gm, bm);
|
||||
}
|
||||
}
|
||||
|
||||
#if 1
|
||||
{
|
||||
for (j = 0; j < nxglVisuals; j++)
|
||||
{
|
||||
ErrorF ("Visual: 0x%x (%c) - r/g/b/a: %d/%d/%d/%d db: %d\n",
|
||||
(int) xglVisuals[j].format->id,
|
||||
xglVisuals[j].format->types.pbuffer? 'y' : 'n',
|
||||
xglVisuals[j].format->color.red_size,
|
||||
xglVisuals[j].format->color.green_size,
|
||||
xglVisuals[j].format->color.blue_size,
|
||||
xglVisuals[j].format->color.alpha_size,
|
||||
xglVisuals[j].format->doublebuffer);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
xglClearVisualTypes (void)
|
||||
{
|
||||
nxglVisuals = 0;
|
||||
nxglPbufferVisuals = 0;
|
||||
|
||||
if (xglVisuals)
|
||||
xfree (xglVisuals);
|
||||
|
||||
if (xglPbufferVisuals)
|
||||
xfree (xglPbufferVisuals);
|
||||
|
||||
xglVisuals = NULL;
|
||||
xglPbufferVisuals = NULL;
|
||||
|
||||
miClearVisualTypes ();
|
||||
}
|
||||
|
||||
void
|
||||
xglInitPixmapFormats (ScreenPtr pScreen)
|
||||
{
|
||||
glitz_format_t *format;
|
||||
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;
|
||||
|
||||
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->type == GLITZ_FORMAT_TYPE_COLOR)
|
||||
{
|
||||
if (rs == format->color.red_size &&
|
||||
gs == format->color.green_size &&
|
||||
bs == format->color.blue_size &&
|
||||
as == format->color.alpha_size)
|
||||
{
|
||||
pScreenPriv->pixmapFormats[i].format = format;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} 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;
|
||||
}
|
|
@ -0,0 +1,251 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
* fee, provided that the above copyright notice appear in all copies
|
||||
* and that both that copyright notice and this permission notice
|
||||
* appear in supporting documentation, and that the names of
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Author: David Reveman <davidr@freedesktop.org>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
|
||||
#ifdef RENDER
|
||||
|
||||
static glitz_operator_t xglOperators[] = {
|
||||
GLITZ_OPERATOR_CLEAR,
|
||||
GLITZ_OPERATOR_SRC,
|
||||
GLITZ_OPERATOR_DST,
|
||||
GLITZ_OPERATOR_OVER,
|
||||
GLITZ_OPERATOR_OVER_REVERSE,
|
||||
GLITZ_OPERATOR_IN,
|
||||
GLITZ_OPERATOR_IN_REVERSE,
|
||||
GLITZ_OPERATOR_OUT,
|
||||
GLITZ_OPERATOR_OUT_REVERSE,
|
||||
GLITZ_OPERATOR_ATOP,
|
||||
GLITZ_OPERATOR_ATOP_REVERSE,
|
||||
GLITZ_OPERATOR_XOR,
|
||||
GLITZ_OPERATOR_ADD
|
||||
};
|
||||
|
||||
#define NUM_XGL_OPERATORS \
|
||||
(sizeof (xglOperators) / sizeof (xglOperators[0]))
|
||||
|
||||
#define XGL_OPERATOR(op) (xglOperators[op])
|
||||
|
||||
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)
|
||||
{
|
||||
ScreenPtr pScreen = pDst->pDrawable->pScreen;
|
||||
xglPixmapPtr pSrcPriv, pMaskPriv;
|
||||
glitz_surface_t *dst;
|
||||
int dstXoff, dstYoff;
|
||||
RegionRec region;
|
||||
BoxPtr pBox;
|
||||
int nBox;
|
||||
|
||||
if (pDst->dither != None)
|
||||
return FALSE;
|
||||
|
||||
if (pDst->alphaMap)
|
||||
return FALSE;
|
||||
|
||||
if (op >= NUM_XGL_OPERATORS)
|
||||
return FALSE;
|
||||
|
||||
if (pSrc->pDrawable->type != DRAWABLE_PIXMAP)
|
||||
return FALSE;
|
||||
|
||||
if (pMask)
|
||||
{
|
||||
if (pMask->pDrawable->type != DRAWABLE_PIXMAP)
|
||||
return FALSE;
|
||||
|
||||
/*
|
||||
* Why?
|
||||
*/
|
||||
if (pSrc->pDrawable == pMask->pDrawable)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
xDst += pDst->pDrawable->x;
|
||||
yDst += pDst->pDrawable->y;
|
||||
|
||||
if (!miComputeCompositeRegion (®ion, pSrc, pMask, pDst,
|
||||
xSrc, ySrc, xMask, yMask,
|
||||
xDst, yDst, width, height))
|
||||
return TRUE;
|
||||
|
||||
pBox = REGION_RECTS (®ion);
|
||||
nBox = REGION_NUM_RECTS (®ion);
|
||||
|
||||
/*
|
||||
* Simple copy
|
||||
*/
|
||||
if (op == PictOpSrc && !pMask &&
|
||||
!pSrc->transform && !pSrc->repeat && pSrc->filter <= 1)
|
||||
{
|
||||
if (xglCopy (pSrc->pDrawable,
|
||||
pDst->pDrawable,
|
||||
xSrc - xDst,
|
||||
ySrc - yDst,
|
||||
pBox,
|
||||
nBox))
|
||||
{
|
||||
REGION_UNINIT (pScreen, ®ion);
|
||||
xglAddBitDamage (pDst->pDrawable);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
REGION_UNINIT (pScreen, ®ion);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!xglPrepareTarget (pDst->pDrawable))
|
||||
{
|
||||
REGION_UNINIT (pScreen, ®ion);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
XGL_GET_DRAWABLE (pDst->pDrawable, dst, dstXoff, dstYoff);
|
||||
|
||||
if (!xglSyncSurface (pSrc->pDrawable))
|
||||
{
|
||||
REGION_UNINIT (pScreen, ®ion);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pSrcPriv = XGL_GET_PIXMAP_PRIV ((PixmapPtr) pSrc->pDrawable);
|
||||
if (XGL_PICTURE_CHANGES (pSrcPriv->pictureMask))
|
||||
xglUpdatePicture (pSrc);
|
||||
|
||||
if (pMask)
|
||||
{
|
||||
if (!xglSyncSurface (pMask->pDrawable))
|
||||
{
|
||||
REGION_UNINIT (pScreen, ®ion);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pMaskPriv = XGL_GET_PIXMAP_PRIV ((PixmapPtr) pMask->pDrawable);
|
||||
if (XGL_PICTURE_CHANGES (pMaskPriv->pictureMask))
|
||||
xglUpdatePicture (pMask);
|
||||
} else
|
||||
pMaskPriv = NULL;
|
||||
|
||||
if (nBox > 1)
|
||||
{
|
||||
xglGeometryRec geometry;
|
||||
|
||||
GEOMETRY_INIT (pScreen, &geometry, REGION_NUM_RECTS (®ion) << 3);
|
||||
GEOMETRY_ADD_BOX (pScreen, &geometry, pBox, nBox);
|
||||
GEOMETRY_TRANSLATE (&geometry, dstXoff, dstYoff);
|
||||
|
||||
if (!GEOMETRY_ENABLE_ALL_VERTICES (&geometry, dst))
|
||||
{
|
||||
GEOMETRY_UNINIT (&geometry);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pBox = REGION_EXTENTS (pScreen, ®ion);
|
||||
} else
|
||||
GEOMETRY_DISABLE (dst);
|
||||
|
||||
xSrc += pBox->x1 - xDst;
|
||||
ySrc += pBox->y1 - yDst;
|
||||
|
||||
if (pMask)
|
||||
{
|
||||
xMask += pBox->x1 - xDst;
|
||||
yMask += pBox->y1 - yDst;
|
||||
}
|
||||
|
||||
xDst = pBox->x1;
|
||||
yDst = pBox->y1;
|
||||
|
||||
width = pBox->x2 - pBox->x1;
|
||||
height = pBox->y2 - pBox->y1;
|
||||
|
||||
REGION_UNINIT (pScreen, ®ion);
|
||||
|
||||
/*
|
||||
* Do software tile instead if hardware can't do it.
|
||||
*/
|
||||
if (pSrc->repeat && !pSrcPriv->acceleratedTile)
|
||||
{
|
||||
BoxRec box;
|
||||
|
||||
if (pSrc->transform || pSrc->filter > 1)
|
||||
return FALSE;
|
||||
|
||||
/*
|
||||
* Don't allow software tile with really small pixmaps.
|
||||
*/
|
||||
if (pSrc->pDrawable->width < 8 && pSrc->pDrawable->height < 8)
|
||||
return FALSE;
|
||||
|
||||
box.x1 = xDst + dstXoff;
|
||||
box.y1 = yDst + dstYoff;
|
||||
box.x2 = box.x1 + width;
|
||||
box.y2 = box.y1 + height;
|
||||
|
||||
glitz_surface_set_fill (pSrcPriv->surface, GLITZ_FILL_TRANSPARENT);
|
||||
|
||||
xglSwTile (XGL_OPERATOR (op),
|
||||
pSrcPriv->surface,
|
||||
(pMaskPriv)? pMaskPriv->surface: NULL,
|
||||
dst,
|
||||
xSrc - box.x1, ySrc - box.y1,
|
||||
xMask - box.x1, yMask - box.y1,
|
||||
TILE_SOURCE,
|
||||
&box, 1,
|
||||
0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
glitz_composite (XGL_OPERATOR (op),
|
||||
pSrcPriv->surface,
|
||||
(pMaskPriv)? pMaskPriv->surface: NULL,
|
||||
dst,
|
||||
xSrc, ySrc,
|
||||
xMask, yMask,
|
||||
xDst + dstXoff, yDst + dstYoff,
|
||||
width, height);
|
||||
}
|
||||
|
||||
if (glitz_surface_get_status (dst))
|
||||
return FALSE;
|
||||
|
||||
xglAddBitDamage (pDst->pDrawable);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,152 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
* fee, provided that the above copyright notice appear in all copies
|
||||
* and that both that copyright notice and this permission notice
|
||||
* appear in supporting documentation, and that the names of
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Author: David Reveman <davidr@freedesktop.org>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
|
||||
Bool
|
||||
xglCopy (DrawablePtr pSrc,
|
||||
DrawablePtr pDst,
|
||||
int dx,
|
||||
int dy,
|
||||
BoxPtr pBox,
|
||||
int nBox)
|
||||
{
|
||||
glitz_surface_t *srcSurface;
|
||||
glitz_surface_t *dstSurface;
|
||||
int srcXoff, srcYoff;
|
||||
int dstXoff, dstYoff;
|
||||
|
||||
if (xglPrepareTarget (pDst))
|
||||
{
|
||||
glitz_drawable_t *srcDrawable;
|
||||
glitz_drawable_t *dstDrawable;
|
||||
|
||||
XGL_SCREEN_PRIV (pDst->pScreen);
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pSrc);
|
||||
|
||||
if (!xglSyncSurface (pSrc))
|
||||
return FALSE;
|
||||
|
||||
XGL_GET_DRAWABLE (pSrc, srcSurface, srcXoff, srcYoff);
|
||||
XGL_GET_DRAWABLE (pDst, dstSurface, dstXoff, dstYoff);
|
||||
|
||||
/*
|
||||
* Blit to screen.
|
||||
*/
|
||||
if (dstSurface == pScreenPriv->surface)
|
||||
XGL_INCREMENT_PIXMAP_SCORE (pPixmapPriv, 5000);
|
||||
|
||||
srcDrawable = glitz_surface_get_attached_drawable (srcSurface);
|
||||
dstDrawable = glitz_surface_get_attached_drawable (dstSurface);
|
||||
|
||||
if (srcDrawable != dstDrawable && nBox > 1)
|
||||
{
|
||||
xglGeometryRec geometry;
|
||||
BoxRec extents;
|
||||
|
||||
BOX_EXTENTS (pBox, nBox, &extents);
|
||||
|
||||
GEOMETRY_INIT (pDst->pScreen, &geometry, nBox << 3);
|
||||
GEOMETRY_ADD_BOX (pDst->pScreen, &geometry, pBox, nBox);
|
||||
GEOMETRY_TRANSLATE (&geometry, dstXoff, dstYoff);
|
||||
|
||||
if (!GEOMETRY_ENABLE_ALL_VERTICES (&geometry, dstSurface))
|
||||
return FALSE;
|
||||
|
||||
pPixmapPriv->pictureMask |=
|
||||
xglPCFillMask | xglPCFilterMask | xglPCTransformMask;
|
||||
|
||||
glitz_surface_set_fill (srcSurface, GLITZ_FILL_TRANSPARENT);
|
||||
glitz_surface_set_filter (srcSurface, GLITZ_FILTER_NEAREST,
|
||||
NULL, 0);
|
||||
glitz_surface_set_transform (srcSurface, NULL);
|
||||
|
||||
glitz_composite (GLITZ_OPERATOR_SRC,
|
||||
srcSurface, NULL, dstSurface,
|
||||
extents.x1 + dx + srcXoff,
|
||||
extents.y1 + dy + srcYoff,
|
||||
0, 0,
|
||||
extents.x1 + dstXoff,
|
||||
extents.y1 + dstYoff,
|
||||
extents.x2 - extents.x1,
|
||||
extents.y2 - extents.y1);
|
||||
|
||||
GEOMETRY_UNINIT (&geometry);
|
||||
|
||||
if (glitz_surface_get_status (dstSurface))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!xglPrepareTarget (pSrc))
|
||||
return FALSE;
|
||||
|
||||
if (!xglSyncSurface (pDst))
|
||||
return FALSE;
|
||||
|
||||
XGL_GET_DRAWABLE (pSrc, srcSurface, srcXoff, srcYoff);
|
||||
XGL_GET_DRAWABLE (pDst, dstSurface, dstXoff, dstYoff);
|
||||
}
|
||||
|
||||
while (nBox--)
|
||||
{
|
||||
glitz_copy_area (srcSurface,
|
||||
dstSurface,
|
||||
pBox->x1 + dx + srcXoff,
|
||||
pBox->y1 + dy + srcYoff,
|
||||
pBox->x2 - pBox->x1,
|
||||
pBox->y2 - pBox->y1,
|
||||
pBox->x1 + dstXoff,
|
||||
pBox->y1 + dstYoff);
|
||||
|
||||
pBox++;
|
||||
}
|
||||
|
||||
if (glitz_surface_get_status (dstSurface))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
xglCopyProc (DrawablePtr pSrc,
|
||||
DrawablePtr pDst,
|
||||
GCPtr pGC,
|
||||
BoxPtr pBox,
|
||||
int nBox,
|
||||
int dx,
|
||||
int dy,
|
||||
Bool reverse,
|
||||
Bool upsidedown,
|
||||
Pixel bitplane,
|
||||
void *closure)
|
||||
{
|
||||
Bool *pRet = (Bool *) closure;
|
||||
|
||||
*pRet = xglCopy (pSrc, pDst, dx, dy, pBox, nBox);
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright © 2004 Keith Packard
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Keith Packard not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Keith Packard makes no
|
||||
* representations about the suitability of this software for any purpose. It
|
||||
* is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
|
|
@ -0,0 +1,203 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
* fee, provided that the above copyright notice appear in all copies
|
||||
* and that both that copyright notice and this permission notice
|
||||
* appear in supporting documentation, and that the names of
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Author: David Reveman <davidr@freedesktop.org>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
#include "gcstruct.h"
|
||||
|
||||
Bool
|
||||
xglFill (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
xglGeometryPtr pGeometry)
|
||||
{
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
switch (pGC->fillStyle) {
|
||||
case FillSolid:
|
||||
if (xglSolid (pDrawable, pGCPriv->op, &pGCPriv->fg,
|
||||
pGeometry,
|
||||
REGION_RECTS (pGC->pCompositeClip),
|
||||
REGION_NUM_RECTS (pGC->pCompositeClip)))
|
||||
return TRUE;
|
||||
break;
|
||||
case FillStippled:
|
||||
case FillOpaqueStippled:
|
||||
break;
|
||||
case FillTiled:
|
||||
if (xglTile (pDrawable, pGCPriv->op, pGC->tile.pixmap,
|
||||
-pGC->patOrg.x, -pGC->patOrg.y,
|
||||
pGeometry,
|
||||
REGION_RECTS (pGC->pCompositeClip),
|
||||
REGION_NUM_RECTS (pGC->pCompositeClip)))
|
||||
return TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglFillRect (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int nrect,
|
||||
xRectangle *prect)
|
||||
{
|
||||
xglGeometryRec geometry;
|
||||
|
||||
GEOMETRY_INIT (pGC->pScreen, &geometry, nrect << 3);
|
||||
GEOMETRY_ADD_RECT (pGC->pScreen, &geometry, prect, nrect);
|
||||
GEOMETRY_TRANSLATE (&geometry, pDrawable->x, pDrawable->y);
|
||||
|
||||
if (xglFill (pDrawable, pGC, &geometry))
|
||||
{
|
||||
GEOMETRY_UNINIT (&geometry);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GEOMETRY_UNINIT (&geometry);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglFillSpan (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int n,
|
||||
DDXPointPtr ppt,
|
||||
int *pwidth)
|
||||
{
|
||||
xglGeometryRec geometry;
|
||||
|
||||
GEOMETRY_INIT (pGC->pScreen, &geometry, n << 2);
|
||||
GEOMETRY_ADD_SPAN (pGC->pScreen, &geometry, ppt, pwidth, n);
|
||||
|
||||
/* Spans are treated as lines so they need a 0.5 translate */
|
||||
GEOMETRY_TRANSLATE_FIXED (&geometry, 1 << 15, 1 << 15);
|
||||
GEOMETRY_SET_PRIMITIVE (pGC->pScreen, &geometry,
|
||||
GLITZ_GEOMETRY_PRIMITIVE_LINES);
|
||||
|
||||
if (xglFill (pDrawable, pGC, &geometry))
|
||||
{
|
||||
GEOMETRY_UNINIT (&geometry);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GEOMETRY_UNINIT (&geometry);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglFillLine (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int mode,
|
||||
int npt,
|
||||
DDXPointPtr ppt)
|
||||
{
|
||||
xglGeometryRec geometry;
|
||||
Bool coincident_endpoints;
|
||||
|
||||
coincident_endpoints = FALSE;
|
||||
if (mode == CoordModePrevious)
|
||||
{
|
||||
DDXPointPtr pptTmp;
|
||||
int nptTmp;
|
||||
DDXPointRec pt;
|
||||
|
||||
pt = *ppt;
|
||||
|
||||
nptTmp = npt - 1;
|
||||
pptTmp = ppt + 1;
|
||||
|
||||
while (nptTmp--)
|
||||
{
|
||||
pt.x += pptTmp->x;
|
||||
pt.y += pptTmp->y;
|
||||
|
||||
pptTmp++;
|
||||
}
|
||||
|
||||
if (pt.x == ppt->x && pt.y == ppt->y)
|
||||
coincident_endpoints = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ppt[npt - 1].x == ppt->x && ppt[npt - 1].y == ppt->y)
|
||||
coincident_endpoints = TRUE;
|
||||
}
|
||||
|
||||
if (coincident_endpoints)
|
||||
npt--;
|
||||
|
||||
GEOMETRY_INIT (pGC->pScreen, &geometry, npt << 1);
|
||||
GEOMETRY_ADD_LINE (pGC->pScreen, &geometry,
|
||||
coincident_endpoints, mode, npt, ppt);
|
||||
|
||||
if (coincident_endpoints)
|
||||
GEOMETRY_SET_PRIMITIVE (pGC->pScreen, &geometry,
|
||||
GLITZ_GEOMETRY_PRIMITIVE_LINE_LOOP);
|
||||
else
|
||||
GEOMETRY_SET_PRIMITIVE (pGC->pScreen, &geometry,
|
||||
GLITZ_GEOMETRY_PRIMITIVE_LINE_STRIP);
|
||||
|
||||
/* Lines need a 0.5 translate */
|
||||
GEOMETRY_TRANSLATE_FIXED (&geometry, 1 << 15, 1 << 15);
|
||||
|
||||
GEOMETRY_TRANSLATE (&geometry, pDrawable->x, pDrawable->y);
|
||||
|
||||
if (xglFill (pDrawable, pGC, &geometry))
|
||||
{
|
||||
GEOMETRY_UNINIT (&geometry);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GEOMETRY_UNINIT (&geometry);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglFillSegment (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int nsegInit,
|
||||
xSegment *pSegInit)
|
||||
{
|
||||
xglGeometryRec geometry;
|
||||
|
||||
GEOMETRY_INIT (pGC->pScreen, &geometry, nsegInit << 2);
|
||||
GEOMETRY_ADD_SEGMENT (pGC->pScreen, &geometry, nsegInit, pSegInit);
|
||||
|
||||
/* Line segments need 0.5 translate */
|
||||
GEOMETRY_TRANSLATE_FIXED (&geometry, 1 << 15, 1 << 15);
|
||||
GEOMETRY_SET_PRIMITIVE (pGC->pScreen, &geometry,
|
||||
GLITZ_GEOMETRY_PRIMITIVE_LINES);
|
||||
|
||||
GEOMETRY_TRANSLATE (&geometry, pDrawable->x, pDrawable->y);
|
||||
|
||||
if (xglFill (pDrawable, pGC, &geometry))
|
||||
{
|
||||
GEOMETRY_UNINIT (&geometry);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GEOMETRY_UNINIT (&geometry);
|
||||
return FALSE;
|
||||
}
|
597
hw/xgl/xglgc.c
597
hw/xgl/xglgc.c
|
@ -1,113 +1,554 @@
|
|||
/*
|
||||
* $Id$
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
* fee, provided that the above copyright notice appear in all copies
|
||||
* and that both that copyright notice and this permission notice
|
||||
* appear in supporting documentation, and that the names of
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* Copyright © 2004 Keith Packard
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Keith Packard not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Keith Packard makes no
|
||||
* representations about the suitability of this software for any purpose. It
|
||||
* is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
* Author: David Reveman <davidr@freedesktop.org>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
#include "fb.h"
|
||||
#include "gcstruct.h"
|
||||
#include "migc.h"
|
||||
|
||||
static void
|
||||
xglValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
|
||||
{
|
||||
pGC->lastWinOrg.x = pDrawable->x;
|
||||
pGC->lastWinOrg.y = pDrawable->y;
|
||||
#define XGL_GC_OP_FALLBACK_PROLOGUE(pDrawable) \
|
||||
xglSyncDamageBoxBits (pDrawable); \
|
||||
XGL_GC_UNWRAP (funcs); \
|
||||
XGL_GC_UNWRAP (ops)
|
||||
|
||||
if ((changes & (GCClipXOrigin|GCClipYOrigin|GCClipMask|GCSubwindowMode)) ||
|
||||
(pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS))
|
||||
)
|
||||
{
|
||||
miComputeCompositeClip (pGC, pDrawable);
|
||||
}
|
||||
}
|
||||
#define XGL_GC_OP_FALLBACK_EPILOGUE(pDrawable) \
|
||||
XGL_GC_WRAP (funcs, (GCFuncs *) &xglGCFuncs); \
|
||||
XGL_GC_WRAP (ops, (GCOps *) &xglGCOps); \
|
||||
xglAddSurfaceDamage (pDrawable)
|
||||
|
||||
static const GCFuncs xglGCFuncs = {
|
||||
#define XGL_GC_FILL_OP_FALLBACK_PROLOGUE(pDrawable) \
|
||||
switch (pGC->fillStyle) { \
|
||||
case FillSolid: \
|
||||
break; \
|
||||
case FillStippled: \
|
||||
case FillOpaqueStippled: \
|
||||
if (!xglSyncBits (&pGC->stipple->drawable, NullBox)) \
|
||||
FatalError (XGL_SW_FAILURE_STRING); \
|
||||
break; \
|
||||
case FillTiled: \
|
||||
if (!xglSyncBits (&pGC->tile.pixmap->drawable, NullBox)) \
|
||||
FatalError (XGL_SW_FAILURE_STRING); \
|
||||
break; \
|
||||
} \
|
||||
XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable)
|
||||
|
||||
static const GCFuncs xglGCFuncs = {
|
||||
xglValidateGC,
|
||||
miChangeGC,
|
||||
miCopyGC,
|
||||
miDestroyGC,
|
||||
miChangeClip,
|
||||
miDestroyClip,
|
||||
miCopyClip,
|
||||
miCopyClip
|
||||
};
|
||||
|
||||
static void
|
||||
xglPolyLine (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int mode,
|
||||
int npt,
|
||||
DDXPointPtr ppt)
|
||||
{
|
||||
void (*line) (DrawablePtr, GCPtr, int mode, int npt, DDXPointPtr ppt);
|
||||
|
||||
if (pGC->lineWidth == 0)
|
||||
{
|
||||
line = miZeroLine;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pGC->lineStyle != LineSolid)
|
||||
line = miWideDash;
|
||||
else
|
||||
line = miWideLine;
|
||||
}
|
||||
(*line) (pDrawable, pGC, mode, npt, ppt);
|
||||
}
|
||||
|
||||
static const GCOps xglGCOps = {
|
||||
static const GCOps xglGCOps = {
|
||||
xglFillSpans,
|
||||
xglSetSpans,
|
||||
miPutImage,
|
||||
miCopyArea,
|
||||
miCopyPlane,
|
||||
miPolyPoint,
|
||||
xglPolyLine,
|
||||
miPolySegment,
|
||||
xglPutImage,
|
||||
xglCopyArea,
|
||||
xglCopyPlane,
|
||||
xglPolyPoint,
|
||||
xglPolylines,
|
||||
xglPolySegment,
|
||||
miPolyRectangle,
|
||||
miPolyArc,
|
||||
xglPolyArc,
|
||||
miFillPolygon,
|
||||
miPolyFillRect,
|
||||
miPolyFillArc,
|
||||
xglPolyFillRect,
|
||||
xglPolyFillArc,
|
||||
miPolyText8,
|
||||
miPolyText16,
|
||||
miImageText8,
|
||||
miImageText16,
|
||||
miImageGlyphBlt,
|
||||
miPolyGlyphBlt,
|
||||
xglImageGlyphBlt,
|
||||
xglPolyGlyphBlt,
|
||||
xglPushPixels
|
||||
#ifdef NEED_LINEHELPER
|
||||
,NULL
|
||||
, NULL
|
||||
#endif
|
||||
};
|
||||
|
||||
void
|
||||
xglFillSpans (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int nspans,
|
||||
DDXPointPtr ppt,
|
||||
int *pwidth,
|
||||
int fSorted)
|
||||
{
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
if (!pGCPriv->flags)
|
||||
{
|
||||
if (xglFillSpan (pDrawable, pGC, nspans, ppt, pwidth))
|
||||
{
|
||||
xglAddBitDamage (pDrawable);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
|
||||
(*pGC->ops->FillSpans) (pDrawable, pGC, nspans, ppt, pwidth, fSorted);
|
||||
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
|
||||
}
|
||||
|
||||
void
|
||||
xglSetSpans (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
char *psrc,
|
||||
DDXPointPtr ppt,
|
||||
int *pwidth,
|
||||
int nspans,
|
||||
int fSorted)
|
||||
{
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable);
|
||||
(*pGC->ops->SetSpans) (pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted);
|
||||
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
|
||||
}
|
||||
|
||||
void
|
||||
xglPutImage (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int depth,
|
||||
int x,
|
||||
int y,
|
||||
int w,
|
||||
int h,
|
||||
int leftPad,
|
||||
int format,
|
||||
char *bits)
|
||||
{
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
switch (format) {
|
||||
case XYBitmap:
|
||||
break;
|
||||
case XYPixmap:
|
||||
case ZPixmap:
|
||||
if (!pGCPriv->flags)
|
||||
{
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
|
||||
|
||||
if (!pPixmapPriv->allBits &&
|
||||
pPixmapPriv->target == xglPixmapTargetIn)
|
||||
{
|
||||
if (xglSetPixels (pDrawable,
|
||||
bits,
|
||||
PixmapBytePad (w, pDrawable->depth),
|
||||
FALSE,
|
||||
x + pDrawable->x, y + pDrawable->y,
|
||||
w, h,
|
||||
REGION_RECTS (pGC->pCompositeClip),
|
||||
REGION_NUM_RECTS (pGC->pCompositeClip)))
|
||||
{
|
||||
xglAddBitDamage (pDrawable);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable);
|
||||
(*pGC->ops->PutImage) (pDrawable, pGC, depth,
|
||||
x, y, w, h, leftPad, format, bits);
|
||||
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
|
||||
}
|
||||
|
||||
RegionPtr
|
||||
xglCopyArea (DrawablePtr pSrc,
|
||||
DrawablePtr pDst,
|
||||
GCPtr pGC,
|
||||
int srcX,
|
||||
int srcY,
|
||||
int w,
|
||||
int h,
|
||||
int dstX,
|
||||
int dstY)
|
||||
{
|
||||
unsigned long flags;
|
||||
RegionPtr pRegion;
|
||||
BoxRec box;
|
||||
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
flags = pGCPriv->flags;
|
||||
|
||||
if (XGL_GET_DRAWABLE_PIXMAP_PRIV (pSrc)->target == xglPixmapTargetIn)
|
||||
flags &= ~xglGCReadOnlyDrawableFlag;
|
||||
|
||||
if (!flags)
|
||||
{
|
||||
Bool ret;
|
||||
|
||||
ret = TRUE;
|
||||
pRegion = fbDoCopy (pSrc, pDst, pGC,
|
||||
srcX, srcY,
|
||||
w, h,
|
||||
dstX, dstY,
|
||||
xglCopyProc, 0,
|
||||
(void *) &ret);
|
||||
if (ret)
|
||||
{
|
||||
xglAddBitDamage (pDst);
|
||||
return pRegion;
|
||||
}
|
||||
|
||||
if (pRegion)
|
||||
REGION_DESTROY (pDst->pScreen, pRegion);
|
||||
}
|
||||
|
||||
box.x1 = pSrc->x + srcX;
|
||||
box.y1 = pSrc->y + srcY;
|
||||
box.x2 = box.x1 + w;
|
||||
box.y2 = box.y1 + h;
|
||||
|
||||
if (!xglSyncBits (pSrc, &box))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
|
||||
XGL_GC_OP_FALLBACK_PROLOGUE (pDst);
|
||||
pRegion = (*pGC->ops->CopyArea) (pSrc, pDst, pGC,
|
||||
srcX, srcY, w, h, dstX, dstY);
|
||||
XGL_GC_OP_FALLBACK_EPILOGUE (pDst);
|
||||
|
||||
return pRegion;
|
||||
}
|
||||
|
||||
RegionPtr
|
||||
xglCopyPlane (DrawablePtr pSrc,
|
||||
DrawablePtr pDst,
|
||||
GCPtr pGC,
|
||||
int srcX,
|
||||
int srcY,
|
||||
int w,
|
||||
int h,
|
||||
int dstX,
|
||||
int dstY,
|
||||
unsigned long bitPlane)
|
||||
{
|
||||
RegionPtr pRegion;
|
||||
BoxRec box;
|
||||
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
box.x1 = pSrc->x + srcX;
|
||||
box.y1 = pSrc->y + srcY;
|
||||
box.x2 = box.x1 + w;
|
||||
box.y2 = box.y1 + h;
|
||||
|
||||
if (!xglSyncBits (pSrc, &box))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
|
||||
XGL_GC_OP_FALLBACK_PROLOGUE (pDst);
|
||||
pRegion = (*pGC->ops->CopyPlane) (pSrc, pDst, pGC,
|
||||
srcX, srcY, w, h, dstX, dstY,
|
||||
bitPlane);
|
||||
XGL_GC_OP_FALLBACK_EPILOGUE (pDst);
|
||||
|
||||
return pRegion;
|
||||
}
|
||||
|
||||
void
|
||||
xglPolyPoint (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int mode,
|
||||
int npt,
|
||||
DDXPointPtr pptInit)
|
||||
{
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable);
|
||||
(*pGC->ops->PolyPoint) (pDrawable, pGC, mode, npt, pptInit);
|
||||
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
|
||||
}
|
||||
|
||||
void
|
||||
xglPolylines (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int mode,
|
||||
int npt,
|
||||
DDXPointPtr ppt)
|
||||
{
|
||||
if (pGC->lineWidth == 0)
|
||||
{
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
if (!pGCPriv->flags)
|
||||
{
|
||||
if (pGC->lineStyle == LineSolid)
|
||||
{
|
||||
if (xglFillLine (pDrawable, pGC, mode, npt, ppt))
|
||||
{
|
||||
xglAddBitDamage (pDrawable);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable);
|
||||
(*pGC->ops->Polylines) (pDrawable, pGC, mode, npt, ppt);
|
||||
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pGC->lineStyle != LineSolid)
|
||||
miWideDash (pDrawable, pGC, mode, npt, ppt);
|
||||
else
|
||||
miWideLine (pDrawable, pGC, mode, npt, ppt);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
xglPolySegment (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int nsegInit,
|
||||
xSegment *pSegInit)
|
||||
{
|
||||
if (pGC->lineWidth == 0)
|
||||
{
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
if (!pGCPriv->flags)
|
||||
{
|
||||
if (pGC->lineStyle == LineSolid)
|
||||
{
|
||||
if (xglFillSegment (pDrawable, pGC, nsegInit, pSegInit))
|
||||
{
|
||||
xglAddBitDamage (pDrawable);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable);
|
||||
(*pGC->ops->PolySegment) (pDrawable, pGC, nsegInit, pSegInit);
|
||||
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
|
||||
} else
|
||||
miPolySegment (pDrawable, pGC, nsegInit, pSegInit);
|
||||
}
|
||||
|
||||
void
|
||||
xglPolyArc (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int narcs,
|
||||
xArc *pArcs)
|
||||
{
|
||||
if (pGC->lineWidth == 0)
|
||||
{
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable);
|
||||
(*pGC->ops->PolyArc) (pDrawable, pGC, narcs, pArcs);
|
||||
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
|
||||
} else
|
||||
miPolyArc (pDrawable, pGC, narcs, pArcs);
|
||||
}
|
||||
|
||||
void
|
||||
xglPolyFillRect (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int nrect,
|
||||
xRectangle *prect)
|
||||
{
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
if (!pGCPriv->flags)
|
||||
{
|
||||
if (xglFillRect (pDrawable, pGC, nrect, prect))
|
||||
{
|
||||
xglAddBitDamage (pDrawable);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
|
||||
(*pGC->ops->PolyFillRect) (pDrawable, pGC, nrect, prect);
|
||||
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
|
||||
}
|
||||
|
||||
void
|
||||
xglPolyFillArc (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int narcs,
|
||||
xArc *pArcs)
|
||||
{
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
XGL_GC_FILL_OP_FALLBACK_PROLOGUE (pDrawable);
|
||||
(*pGC->ops->PolyFillArc) (pDrawable, pGC, narcs, pArcs);
|
||||
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
|
||||
}
|
||||
|
||||
void
|
||||
xglImageGlyphBlt (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int x,
|
||||
int y,
|
||||
unsigned int nglyph,
|
||||
CharInfoPtr *ppci,
|
||||
pointer pglyphBase)
|
||||
{
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable);
|
||||
(*pGC->ops->ImageGlyphBlt) (pDrawable, pGC, x, y, nglyph, ppci,
|
||||
pglyphBase);
|
||||
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
|
||||
}
|
||||
|
||||
void
|
||||
xglPolyGlyphBlt (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int x,
|
||||
int y,
|
||||
unsigned int nglyph,
|
||||
CharInfoPtr *ppci,
|
||||
pointer pglyphBase)
|
||||
{
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable);
|
||||
(*pGC->ops->PolyGlyphBlt) (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
|
||||
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
|
||||
}
|
||||
|
||||
void
|
||||
xglPushPixels (GCPtr pGC,
|
||||
PixmapPtr pBitmap,
|
||||
DrawablePtr pDrawable,
|
||||
int w,
|
||||
int h,
|
||||
int x,
|
||||
int y)
|
||||
{
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
if (!xglSyncBits (&pBitmap->drawable, NullBox))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
|
||||
XGL_GC_OP_FALLBACK_PROLOGUE (pDrawable);
|
||||
(*pGC->ops->PushPixels) (pGC, pBitmap, pDrawable, w, h, x, y);
|
||||
XGL_GC_OP_FALLBACK_EPILOGUE (pDrawable);
|
||||
}
|
||||
|
||||
Bool
|
||||
xglCreateGC (GCPtr pGC)
|
||||
{
|
||||
pGC->clientClip = NULL;
|
||||
pGC->clientClipType = CT_NONE;
|
||||
static glitz_color_t black = { 0x0, 0x0, 0x0, 0xffff };
|
||||
ScreenPtr pScreen = pGC->pScreen;
|
||||
Bool ret;
|
||||
|
||||
pGC->funcs = (GCFuncs *) &xglGCFuncs;
|
||||
pGC->ops = (GCOps *) &xglGCOps;
|
||||
pGC->pCompositeClip = 0;
|
||||
pGC->fExpose = 1;
|
||||
pGC->freeCompClip = FALSE;
|
||||
pGC->pRotatedPixmap = 0;
|
||||
return TRUE;
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
XGL_SCREEN_UNWRAP (CreateGC);
|
||||
ret = (*pScreen->CreateGC) (pGC);
|
||||
XGL_SCREEN_WRAP (CreateGC, xglCreateGC);
|
||||
|
||||
XGL_GC_WRAP (funcs, (GCFuncs *) &xglGCFuncs);
|
||||
XGL_GC_WRAP (ops, (GCOps *) &xglGCOps);
|
||||
|
||||
pGCPriv->flags = 0;
|
||||
pGCPriv->op = GLITZ_OPERATOR_SRC;
|
||||
pGCPriv->fg = black;
|
||||
pGCPriv->bg = black;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
xglValidateGC (GCPtr pGC,
|
||||
unsigned long changes,
|
||||
DrawablePtr pDrawable)
|
||||
{
|
||||
XGL_GC_PRIV (pGC);
|
||||
|
||||
XGL_GC_UNWRAP (funcs);
|
||||
XGL_GC_UNWRAP (ops);
|
||||
(*pGC->funcs->ValidateGC) (pGC, changes, pDrawable);
|
||||
XGL_GC_WRAP (funcs, (GCFuncs *) &xglGCFuncs);
|
||||
XGL_GC_WRAP (ops, (GCOps *) &xglGCOps);
|
||||
|
||||
if (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS))
|
||||
{
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
|
||||
|
||||
if (pPixmapPriv->format)
|
||||
pGCPriv->flags &= ~xglGCSoftwareDrawableFlag;
|
||||
else
|
||||
pGCPriv->flags |= xglGCSoftwareDrawableFlag;
|
||||
|
||||
if (pPixmapPriv->target)
|
||||
pGCPriv->flags &= ~xglGCReadOnlyDrawableFlag;
|
||||
else
|
||||
pGCPriv->flags |= xglGCReadOnlyDrawableFlag;
|
||||
}
|
||||
|
||||
if (changes & GCFunction)
|
||||
{
|
||||
switch (pGC->alu) {
|
||||
case GXclear:
|
||||
pGCPriv->op = GLITZ_OPERATOR_CLEAR;
|
||||
pGCPriv->flags &= ~xglGCBadFunctionFlag;
|
||||
break;
|
||||
case GXcopy:
|
||||
pGCPriv->op = GLITZ_OPERATOR_SRC;
|
||||
pGCPriv->flags &= ~xglGCBadFunctionFlag;
|
||||
break;
|
||||
case GXnoop:
|
||||
pGCPriv->op = GLITZ_OPERATOR_DST;
|
||||
pGCPriv->flags &= ~xglGCBadFunctionFlag;
|
||||
break;
|
||||
default:
|
||||
pGCPriv->flags |= xglGCBadFunctionFlag;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (changes & GCPlaneMask)
|
||||
{
|
||||
FbBits mask;
|
||||
|
||||
mask = FbFullMask (pDrawable->depth);
|
||||
|
||||
if ((pGC->planemask & mask) != mask)
|
||||
pGCPriv->flags |= xglGCPlaneMaskFlag;
|
||||
else
|
||||
pGCPriv->flags &= ~xglGCPlaneMaskFlag;
|
||||
}
|
||||
|
||||
if (changes & (GCForeground | GCBackground))
|
||||
{
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
|
||||
|
||||
if (pPixmapPriv->pPixel)
|
||||
{
|
||||
xglPixelToColor (pPixmapPriv->pPixel, pGC->fgPixel, &pGCPriv->fg);
|
||||
xglPixelToColor (pPixmapPriv->pPixel, pGC->bgPixel, &pGCPriv->bg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,615 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
* fee, provided that the above copyright notice appear in all copies
|
||||
* and that both that copyright notice and this permission notice
|
||||
* appear in supporting documentation, and that the names of
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Author: David Reveman <davidr@freedesktop.org>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
|
||||
struct xglDataTypeInfo {
|
||||
glitz_data_type_t type;
|
||||
int size;
|
||||
} dataTypes[] = {
|
||||
{ GLITZ_DATA_TYPE_SHORT, sizeof (glitz_short_t) },
|
||||
{ GLITZ_DATA_TYPE_FLOAT, sizeof (glitz_float_t) }
|
||||
};
|
||||
|
||||
glitz_buffer_hint_t usageTypes[] = {
|
||||
GLITZ_BUFFER_HINT_STREAM_DRAW,
|
||||
GLITZ_BUFFER_HINT_STATIC_DRAW,
|
||||
GLITZ_BUFFER_HINT_DYNAMIC_DRAW
|
||||
};
|
||||
|
||||
void
|
||||
xglGeometryResize (ScreenPtr pScreen,
|
||||
xglGeometryPtr pGeometry,
|
||||
int size)
|
||||
{
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
if (pGeometry->broken)
|
||||
return;
|
||||
|
||||
if (size == pGeometry->size)
|
||||
return;
|
||||
|
||||
if (pGeometry->usage == GEOMETRY_USAGE_USERMEM)
|
||||
{
|
||||
pGeometry->data =
|
||||
xrealloc (pGeometry->data,
|
||||
size * dataTypes[pGeometry->dataType].size);
|
||||
|
||||
if (pGeometry->buffer)
|
||||
glitz_buffer_destroy (pGeometry->buffer);
|
||||
|
||||
pGeometry->buffer = NULL;
|
||||
|
||||
if (pGeometry->data)
|
||||
{
|
||||
pGeometry->buffer = glitz_buffer_create_for_data (pGeometry->data);
|
||||
if (!pGeometry->buffer)
|
||||
{
|
||||
pGeometry->broken = TRUE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (size)
|
||||
{
|
||||
pGeometry->broken = TRUE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
glitz_buffer_t *newBuffer;
|
||||
int dataTypeSize;
|
||||
|
||||
dataTypeSize = dataTypes[pGeometry->dataType].size;
|
||||
|
||||
if (size)
|
||||
{
|
||||
newBuffer =
|
||||
glitz_geometry_buffer_create (pScreenPriv->drawable, NULL,
|
||||
size * dataTypeSize,
|
||||
usageTypes[pGeometry->usage]);
|
||||
if (!newBuffer)
|
||||
{
|
||||
pGeometry->broken = TRUE;
|
||||
return;
|
||||
}
|
||||
} else
|
||||
newBuffer = NULL;
|
||||
|
||||
if (pGeometry->buffer && newBuffer)
|
||||
{
|
||||
void *oldData, *newData;
|
||||
|
||||
oldData = glitz_buffer_map (pGeometry->buffer,
|
||||
GLITZ_BUFFER_ACCESS_READ_ONLY);
|
||||
newData = glitz_buffer_map (newBuffer,
|
||||
GLITZ_BUFFER_ACCESS_WRITE_ONLY);
|
||||
|
||||
if (oldData && newData)
|
||||
memcpy (newData, oldData,
|
||||
MIN (size, pGeometry->size) * dataTypeSize);
|
||||
|
||||
glitz_buffer_unmap (pGeometry->buffer);
|
||||
glitz_buffer_unmap (newBuffer);
|
||||
|
||||
glitz_buffer_destroy (pGeometry->buffer);
|
||||
}
|
||||
pGeometry->buffer = newBuffer;
|
||||
}
|
||||
|
||||
pGeometry->size = size;
|
||||
|
||||
if (pGeometry->endOffset > size)
|
||||
pGeometry->endOffset = size;
|
||||
}
|
||||
|
||||
/*
|
||||
* Storage for 100 extra vertices are always allocated if
|
||||
* buffer size is to small. Geometry should be initialized
|
||||
* to desired size prior to calling this function when size
|
||||
* is known.
|
||||
*/
|
||||
#define RESIZE_GEOMETRY_FOR_VERTICES(pScreen, pGeometry, nvertices) \
|
||||
if (((pGeometry)->size - (pGeometry)->endOffset) < ((nvertices) << 1)) \
|
||||
{ \
|
||||
xglGeometryResize (pScreen, pGeometry, \
|
||||
(pGeometry)->endOffset + \
|
||||
((nvertices) << 1) + 200); \
|
||||
if ((pGeometry)->broken) \
|
||||
return; \
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds a number of rectangles as GL_QUAD primitives
|
||||
*/
|
||||
void
|
||||
xglGeometryAddRect (ScreenPtr pScreen,
|
||||
xglGeometryPtr pGeometry,
|
||||
xRectangle *pRect,
|
||||
int nRect)
|
||||
{
|
||||
int nvertices;
|
||||
void *ptr;
|
||||
|
||||
if (pGeometry->broken)
|
||||
return;
|
||||
|
||||
if (nRect < 1)
|
||||
return;
|
||||
|
||||
nvertices = nRect << 2;
|
||||
|
||||
RESIZE_GEOMETRY_FOR_VERTICES (pScreen, pGeometry, nvertices);
|
||||
|
||||
ptr = glitz_buffer_map (pGeometry->buffer, GLITZ_BUFFER_ACCESS_WRITE_ONLY);
|
||||
if (!ptr)
|
||||
{
|
||||
pGeometry->broken = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (pGeometry->dataType) {
|
||||
case GEOMETRY_DATA_TYPE_SHORT:
|
||||
{
|
||||
glitz_short_t *data = (glitz_short_t *) ptr;
|
||||
|
||||
data += pGeometry->endOffset;
|
||||
|
||||
while (nRect--)
|
||||
{
|
||||
*data++ = pRect->x;
|
||||
*data++ = pRect->y;
|
||||
*data++ = pRect->x + pRect->width;
|
||||
*data++ = pRect->y;
|
||||
*data++ = pRect->x + pRect->width;
|
||||
*data++ = pRect->y + pRect->height;
|
||||
*data++ = pRect->x;
|
||||
*data++ = pRect->y + pRect->height;
|
||||
|
||||
pRect++;
|
||||
}
|
||||
} break;
|
||||
case GEOMETRY_DATA_TYPE_FLOAT:
|
||||
{
|
||||
glitz_float_t *data = (glitz_float_t *) ptr;
|
||||
|
||||
data += pGeometry->endOffset;
|
||||
|
||||
while (nRect--)
|
||||
{
|
||||
*data++ = (glitz_float_t) pRect->x;
|
||||
*data++ = (glitz_float_t) pRect->y;
|
||||
*data++ = (glitz_float_t) pRect->x + pRect->width;
|
||||
*data++ = (glitz_float_t) pRect->y;
|
||||
*data++ = (glitz_float_t) pRect->x + pRect->width;
|
||||
*data++ = (glitz_float_t) pRect->y + pRect->height;
|
||||
*data++ = (glitz_float_t) pRect->x;
|
||||
*data++ = (glitz_float_t) pRect->y + pRect->height;
|
||||
|
||||
pRect++;
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
||||
if (glitz_buffer_unmap (pGeometry->buffer))
|
||||
{
|
||||
pGeometry->broken = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
pGeometry->endOffset += (nvertices << 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds a number of boxes as GL_QUAD primitives
|
||||
*/
|
||||
void
|
||||
xglGeometryAddBox (ScreenPtr pScreen,
|
||||
xglGeometryPtr pGeometry,
|
||||
BoxPtr pBox,
|
||||
int nBox)
|
||||
{
|
||||
int nvertices;
|
||||
void *ptr;
|
||||
|
||||
if (pGeometry->broken)
|
||||
return;
|
||||
|
||||
if (nBox < 1)
|
||||
return;
|
||||
|
||||
nvertices = nBox << 2;
|
||||
|
||||
RESIZE_GEOMETRY_FOR_VERTICES (pScreen, pGeometry, nvertices);
|
||||
|
||||
ptr = glitz_buffer_map (pGeometry->buffer, GLITZ_BUFFER_ACCESS_WRITE_ONLY);
|
||||
if (!ptr)
|
||||
{
|
||||
pGeometry->broken = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (pGeometry->dataType) {
|
||||
case GEOMETRY_DATA_TYPE_SHORT:
|
||||
{
|
||||
glitz_short_t *data = (glitz_short_t *) ptr;
|
||||
|
||||
data += pGeometry->endOffset;
|
||||
|
||||
while (nBox--)
|
||||
{
|
||||
*data++ = (glitz_short_t) pBox->x1;
|
||||
*data++ = (glitz_short_t) pBox->y1;
|
||||
*data++ = (glitz_short_t) pBox->x2;
|
||||
*data++ = (glitz_short_t) pBox->y1;
|
||||
*data++ = (glitz_short_t) pBox->x2;
|
||||
*data++ = (glitz_short_t) pBox->y2;
|
||||
*data++ = (glitz_short_t) pBox->x1;
|
||||
*data++ = (glitz_short_t) pBox->y2;
|
||||
|
||||
pBox++;
|
||||
}
|
||||
} break;
|
||||
case GEOMETRY_DATA_TYPE_FLOAT:
|
||||
{
|
||||
glitz_float_t *data = (glitz_float_t *) ptr;
|
||||
|
||||
data += pGeometry->endOffset;
|
||||
|
||||
while (nBox--)
|
||||
{
|
||||
*data++ = (glitz_float_t) pBox->x1;
|
||||
*data++ = (glitz_float_t) pBox->y1;
|
||||
*data++ = (glitz_float_t) pBox->x2;
|
||||
*data++ = (glitz_float_t) pBox->y1;
|
||||
*data++ = (glitz_float_t) pBox->x2;
|
||||
*data++ = (glitz_float_t) pBox->y2;
|
||||
*data++ = (glitz_float_t) pBox->x1;
|
||||
*data++ = (glitz_float_t) pBox->y2;
|
||||
|
||||
pBox++;
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
||||
if (glitz_buffer_unmap (pGeometry->buffer))
|
||||
{
|
||||
pGeometry->broken = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
pGeometry->endOffset += (nvertices << 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds a number of spans as GL_LINE primitives
|
||||
*
|
||||
* An extra 1 is added to *pwidth as OpenGL line segments are half-opened.
|
||||
*/
|
||||
void
|
||||
xglGeometryAddSpan (ScreenPtr pScreen,
|
||||
xglGeometryPtr pGeometry,
|
||||
DDXPointPtr ppt,
|
||||
int *pwidth,
|
||||
int n)
|
||||
{
|
||||
int nvertices;
|
||||
void *ptr;
|
||||
|
||||
if (pGeometry->broken)
|
||||
return;
|
||||
|
||||
if (n < 1)
|
||||
return;
|
||||
|
||||
nvertices = n << 1;
|
||||
|
||||
RESIZE_GEOMETRY_FOR_VERTICES (pScreen, pGeometry, nvertices);
|
||||
|
||||
ptr = glitz_buffer_map (pGeometry->buffer, GLITZ_BUFFER_ACCESS_WRITE_ONLY);
|
||||
if (!ptr)
|
||||
{
|
||||
pGeometry->broken = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (pGeometry->dataType) {
|
||||
case GEOMETRY_DATA_TYPE_SHORT:
|
||||
{
|
||||
glitz_short_t *data = (glitz_short_t *) ptr;
|
||||
|
||||
data += pGeometry->endOffset;
|
||||
|
||||
while (n--)
|
||||
{
|
||||
*data++ = (glitz_short_t) ppt->x;
|
||||
*data++ = (glitz_short_t) ppt->y;
|
||||
*data++ = (glitz_short_t) (ppt->x + *pwidth + 1);
|
||||
*data++ = (glitz_short_t) ppt->y;
|
||||
|
||||
ppt++;
|
||||
pwidth++;
|
||||
}
|
||||
} break;
|
||||
case GEOMETRY_DATA_TYPE_FLOAT:
|
||||
{
|
||||
glitz_float_t *data = (glitz_float_t *) ptr;
|
||||
|
||||
data += pGeometry->endOffset;
|
||||
|
||||
while (n--)
|
||||
{
|
||||
*data++ = (glitz_float_t) ppt->x;
|
||||
*data++ = (glitz_float_t) ppt->y;
|
||||
*data++ = (glitz_float_t) (ppt->x + *pwidth + 1);
|
||||
*data++ = (glitz_float_t) ppt->y;
|
||||
|
||||
ppt++;
|
||||
pwidth++;
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
||||
if (glitz_buffer_unmap (pGeometry->buffer))
|
||||
{
|
||||
pGeometry->broken = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
pGeometry->endOffset += (nvertices << 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* This macro is needed for end pixels to be rasterized correctly using
|
||||
* OpenGL as OpenGL line segments are half-opened.
|
||||
*/
|
||||
#define ADJUST_END_POINT(start, end, isPoint) \
|
||||
(((end) > (start)) ? (end) + 1: \
|
||||
((end) < (start)) ? (end) - 1: \
|
||||
(isPoint) ? (end) + 1: \
|
||||
(end))
|
||||
|
||||
/*
|
||||
* Adds a number of connected lines as GL_LINE_STRIP primitives
|
||||
*/
|
||||
void
|
||||
xglGeometryAddLine (ScreenPtr pScreen,
|
||||
xglGeometryPtr pGeometry,
|
||||
int loop,
|
||||
int mode,
|
||||
int npt,
|
||||
DDXPointPtr ppt)
|
||||
{
|
||||
DDXPointRec pt;
|
||||
int nvertices;
|
||||
void *ptr;
|
||||
|
||||
if (pGeometry->broken)
|
||||
return;
|
||||
|
||||
if (npt < 2)
|
||||
return;
|
||||
|
||||
nvertices = npt;
|
||||
|
||||
RESIZE_GEOMETRY_FOR_VERTICES (pScreen, pGeometry, nvertices);
|
||||
|
||||
ptr = glitz_buffer_map (pGeometry->buffer, GLITZ_BUFFER_ACCESS_WRITE_ONLY);
|
||||
if (!ptr)
|
||||
{
|
||||
pGeometry->broken = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
pt.x = 0;
|
||||
pt.y = 0;
|
||||
|
||||
switch (pGeometry->dataType) {
|
||||
case GEOMETRY_DATA_TYPE_SHORT:
|
||||
{
|
||||
glitz_short_t *data = (glitz_short_t *) ptr;
|
||||
|
||||
data += pGeometry->endOffset;
|
||||
|
||||
while (npt--)
|
||||
{
|
||||
if (mode == CoordModePrevious)
|
||||
{
|
||||
pt.x += ppt->x;
|
||||
pt.y += ppt->y;
|
||||
}
|
||||
else
|
||||
{
|
||||
pt.x = ppt->x;
|
||||
pt.y = ppt->y;
|
||||
}
|
||||
|
||||
*data++ = pt.x;
|
||||
*data++ = pt.y;
|
||||
|
||||
if (npt || loop)
|
||||
{
|
||||
*data++ = pt.x;
|
||||
*data++ = pt.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
ppt--;
|
||||
*data++ = ADJUST_END_POINT (ppt->x, pt.x, ppt->y == pt.y);
|
||||
*data++ = ADJUST_END_POINT (ppt->y, pt.y, 0);
|
||||
}
|
||||
|
||||
ppt++;
|
||||
}
|
||||
} break;
|
||||
case GEOMETRY_DATA_TYPE_FLOAT:
|
||||
{
|
||||
glitz_float_t *data = (glitz_float_t *) ptr;
|
||||
|
||||
data += pGeometry->endOffset;
|
||||
|
||||
while (npt--)
|
||||
{
|
||||
if (mode == CoordModePrevious)
|
||||
{
|
||||
pt.x += ppt->x;
|
||||
pt.y += ppt->y;
|
||||
}
|
||||
else
|
||||
{
|
||||
pt.x = ppt->x;
|
||||
pt.y = ppt->y;
|
||||
}
|
||||
|
||||
if (npt || loop)
|
||||
{
|
||||
*data++ = (glitz_float_t) pt.x;
|
||||
*data++ = (glitz_float_t) pt.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
ppt--;
|
||||
*data++ = (glitz_float_t)
|
||||
ADJUST_END_POINT (ppt->x, pt.x, ppt->y == pt.y);
|
||||
*data++ = (glitz_float_t) ADJUST_END_POINT (ppt->y, pt.y, 0);
|
||||
}
|
||||
|
||||
ppt++;
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
||||
if (glitz_buffer_unmap (pGeometry->buffer))
|
||||
{
|
||||
pGeometry->broken = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
pGeometry->endOffset += (nvertices << 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds a number of line segments as GL_LINE primitives
|
||||
*/
|
||||
void
|
||||
xglGeometryAddSegment (ScreenPtr pScreen,
|
||||
xglGeometryPtr pGeometry,
|
||||
int nsegInit,
|
||||
xSegment *pSegInit)
|
||||
{
|
||||
int nvertices;
|
||||
void *ptr;
|
||||
|
||||
if (pGeometry->broken)
|
||||
return;
|
||||
|
||||
if (nsegInit < 1)
|
||||
return;
|
||||
|
||||
nvertices = nsegInit << 1;
|
||||
|
||||
RESIZE_GEOMETRY_FOR_VERTICES (pScreen, pGeometry, nvertices);
|
||||
|
||||
ptr = glitz_buffer_map (pGeometry->buffer, GLITZ_BUFFER_ACCESS_WRITE_ONLY);
|
||||
if (!ptr)
|
||||
{
|
||||
pGeometry->broken = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (pGeometry->dataType) {
|
||||
case GEOMETRY_DATA_TYPE_SHORT:
|
||||
{
|
||||
glitz_short_t *data = (glitz_short_t *) ptr;
|
||||
|
||||
data += pGeometry->endOffset;
|
||||
|
||||
while (nsegInit--)
|
||||
{
|
||||
*data++ = pSegInit->x1;
|
||||
*data++ = pSegInit->y1;
|
||||
*data++ = ADJUST_END_POINT (pSegInit->x1, pSegInit->x2,
|
||||
pSegInit->y1 == pSegInit->y2);
|
||||
*data++ = ADJUST_END_POINT (pSegInit->y1, pSegInit->y2, 0);
|
||||
|
||||
pSegInit++;
|
||||
}
|
||||
} break;
|
||||
case GEOMETRY_DATA_TYPE_FLOAT:
|
||||
{
|
||||
glitz_float_t *data = (glitz_float_t *) ptr;
|
||||
|
||||
data += pGeometry->endOffset;
|
||||
|
||||
while (nsegInit--)
|
||||
{
|
||||
*data++ = (glitz_float_t) pSegInit->x1;
|
||||
*data++ = (glitz_float_t) pSegInit->y1;
|
||||
*data++ = (glitz_float_t)
|
||||
ADJUST_END_POINT (pSegInit->x1, pSegInit->x2,
|
||||
pSegInit->y1 == pSegInit->y2);
|
||||
*data++ = (glitz_float_t)
|
||||
ADJUST_END_POINT (pSegInit->y1, pSegInit->y2, 0);
|
||||
|
||||
pSegInit++;
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
||||
if (glitz_buffer_unmap (pGeometry->buffer))
|
||||
{
|
||||
pGeometry->broken = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
pGeometry->endOffset += (nvertices << 1);
|
||||
}
|
||||
|
||||
Bool
|
||||
xglSetGeometry (xglGeometryPtr pGeometry,
|
||||
glitz_surface_t *surface,
|
||||
int first,
|
||||
int count)
|
||||
{
|
||||
glitz_geometry_format_t format;
|
||||
|
||||
if (pGeometry->broken)
|
||||
return FALSE;
|
||||
|
||||
format.first = first;
|
||||
format.count = count;
|
||||
format.primitive = pGeometry->primitive;
|
||||
format.type = dataTypes[pGeometry->dataType].type;
|
||||
format.mode = GLITZ_GEOMETRY_MODE_DIRECT;
|
||||
format.edge_hint = GLITZ_GEOMETRY_EDGE_HINT_SHARP;
|
||||
|
||||
glitz_set_geometry (surface,
|
||||
pGeometry->xOff, pGeometry->yOff,
|
||||
&format,
|
||||
pGeometry->buffer);
|
||||
|
||||
return TRUE;
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
* fee, provided that the above copyright notice appear in all copies
|
||||
* and that both that copyright notice and this permission notice
|
||||
* appear in supporting documentation, and that the names of
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Author: David Reveman <davidr@freedesktop.org>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
|
||||
void
|
||||
xglGetImage (DrawablePtr pDrawable,
|
||||
int x,
|
||||
int y,
|
||||
int w,
|
||||
int h,
|
||||
unsigned int format,
|
||||
unsigned long planeMask,
|
||||
char *d)
|
||||
{
|
||||
ScreenPtr pScreen = pDrawable->pScreen;
|
||||
BoxRec box;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
/* Many apps use GetImage to sync with the visable frame buffer */
|
||||
if (pDrawable->type == DRAWABLE_WINDOW)
|
||||
{
|
||||
glitz_surface_flush (pScreenPriv->surface);
|
||||
glitz_drawable_flush (pScreenPriv->drawable);
|
||||
}
|
||||
|
||||
box.x1 = x + pDrawable->x;
|
||||
box.y1 = y + pDrawable->y;
|
||||
box.x2 = box.x1 + w;
|
||||
box.y2 = box.y1 + h;
|
||||
|
||||
if (!xglSyncBits (pDrawable, &box))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
|
||||
XGL_SCREEN_UNWRAP (GetImage);
|
||||
(*pScreen->GetImage) (pDrawable, x, y, w, h, format, planeMask, d);
|
||||
XGL_SCREEN_WRAP (GetImage, xglGetImage);
|
||||
}
|
||||
|
||||
void
|
||||
xglGetSpans (DrawablePtr pDrawable,
|
||||
int wMax,
|
||||
DDXPointPtr ppt,
|
||||
int *pwidth,
|
||||
int nspans,
|
||||
char *pchardstStart)
|
||||
{
|
||||
ScreenPtr pScreen = pDrawable->pScreen;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
if (!xglSyncBits (pDrawable, NullBox))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
|
||||
XGL_SCREEN_UNWRAP (GetSpans);
|
||||
(*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pchardstStart);
|
||||
XGL_SCREEN_WRAP (GetSpans, xglGetSpans);
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright © 2004 Keith Packard
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Keith Packard not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Keith Packard makes no
|
||||
* representations about the suitability of this software for any purpose. It
|
||||
* is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include "xgl.h"
|
||||
|
||||
void
|
||||
ddxUseMsg (void)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
ddxProcessArgument (int argc, char **argv, int i)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
AbortDDX(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
ddxGiveUp ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
OsVendorInit (void)
|
||||
{
|
||||
}
|
|
@ -1,90 +1,89 @@
|
|||
/*
|
||||
* $Id$
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
* fee, provided that the above copyright notice appear in all copies
|
||||
* and that both that copyright notice and this permission notice
|
||||
* appear in supporting documentation, and that the names of
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* Copyright © 2004 Keith Packard
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Keith Packard not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Keith Packard makes no
|
||||
* representations about the suitability of this software for any purpose. It
|
||||
* is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
* Author: David Reveman <davidr@freedesktop.org>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
#include "inputstr.h"
|
||||
#include "mipointer.h"
|
||||
|
||||
#define XK_PUBLISHING
|
||||
#include <X11/keysym.h>
|
||||
#if HAVE_X11_XF86KEYSYM_H
|
||||
#include <X11/XF86keysym.h>
|
||||
#endif
|
||||
|
||||
Bool
|
||||
LegalModifier(unsigned int key, DevicePtr pDev)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
ProcessInputEvents ()
|
||||
{
|
||||
}
|
||||
|
||||
#define NUM_BUTTONS 5
|
||||
|
||||
static int
|
||||
xglMouseProc (DeviceIntPtr pDevice, int onoff)
|
||||
int
|
||||
xglMouseProc (DeviceIntPtr pDevice,
|
||||
int onoff)
|
||||
{
|
||||
BYTE map[NUM_BUTTONS + 1];
|
||||
DevicePtr pDev = (DevicePtr) pDevice;
|
||||
int i;
|
||||
BYTE map[NUM_BUTTONS + 1];
|
||||
DevicePtr pDev = (DevicePtr) pDevice;
|
||||
int i;
|
||||
|
||||
switch (onoff) {
|
||||
case DEVICE_INIT:
|
||||
for (i = 1; i <= NUM_BUTTONS; i++)
|
||||
map[i] = i;
|
||||
InitPointerDeviceStruct(pDev, map, NUM_BUTTONS,
|
||||
miPointerGetMotionEvents,
|
||||
(PtrCtrlProcPtr)NoopDDA,
|
||||
miPointerGetMotionBufferSize());
|
||||
|
||||
InitPointerDeviceStruct (pDev,
|
||||
map,
|
||||
NUM_BUTTONS,
|
||||
miPointerGetMotionEvents,
|
||||
(PtrCtrlProcPtr) NoopDDA,
|
||||
miPointerGetMotionBufferSize ());
|
||||
break;
|
||||
case DEVICE_ON:
|
||||
pDev->on = TRUE;
|
||||
break;
|
||||
case DEVICE_OFF:
|
||||
case DEVICE_CLOSE:
|
||||
if (pDev->on)
|
||||
{
|
||||
pDev->on = FALSE;
|
||||
}
|
||||
pDev->on = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
static void
|
||||
xglBell (int volume, DeviceIntPtr pDev, pointer ctrl, int something)
|
||||
void
|
||||
xglBell (int volume,
|
||||
DeviceIntPtr pDev,
|
||||
pointer ctrl,
|
||||
int something)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
xglKbdCtrl (DeviceIntPtr pDevice, KeybdCtrl *ctrl)
|
||||
void
|
||||
xglKbdCtrl (DeviceIntPtr pDevice,
|
||||
KeybdCtrl *ctrl)
|
||||
{
|
||||
}
|
||||
|
||||
#define XGL_KEYMAP_WIDTH 2
|
||||
|
||||
KeySym xglKeymap[] = {
|
||||
KeySym xglKeymap[] = {
|
||||
/* 1 8 */ XK_Escape, NoSymbol,
|
||||
/* 2 9 */ XK_1, XK_exclam,
|
||||
/* 3 10 */ XK_2, XK_at,
|
||||
|
@ -204,35 +203,35 @@ KeySym xglKeymap[] = {
|
|||
/* 116 123 */ NoSymbol, NoSymbol, /* tiny button */
|
||||
};
|
||||
|
||||
CARD8 xglModMap[MAP_LENGTH];
|
||||
CARD8 xglModMap[MAP_LENGTH];
|
||||
|
||||
KeySymsRec xglKeySyms = {
|
||||
KeySymsRec xglKeySyms = {
|
||||
xglKeymap,
|
||||
8,
|
||||
8 + (sizeof (xglKeymap) / sizeof (xglKeymap[0]) / XGL_KEYMAP_WIDTH) - 1,
|
||||
XGL_KEYMAP_WIDTH
|
||||
};
|
||||
|
||||
static int
|
||||
xglKeybdProc(DeviceIntPtr pDevice, int onoff)
|
||||
int
|
||||
xglKeybdProc (DeviceIntPtr pDevice,
|
||||
int onoff)
|
||||
{
|
||||
Bool ret;
|
||||
DevicePtr pDev = (DevicePtr)pDevice;
|
||||
Bool ret;
|
||||
DevicePtr pDev = (DevicePtr) pDevice;
|
||||
|
||||
if (!pDev)
|
||||
return BadImplementation;
|
||||
|
||||
switch (onoff)
|
||||
{
|
||||
switch (onoff) {
|
||||
case DEVICE_INIT:
|
||||
if (pDev != LookupKeyboardDevice())
|
||||
{
|
||||
if (pDev != LookupKeyboardDevice ())
|
||||
return !Success;
|
||||
}
|
||||
ret = InitKeyboardDeviceStruct(pDev,
|
||||
&xglKeySyms,
|
||||
xglModMap,
|
||||
xglBell, xglKbdCtrl);
|
||||
|
||||
ret = InitKeyboardDeviceStruct (pDev,
|
||||
&xglKeySyms,
|
||||
xglModMap,
|
||||
xglBell,
|
||||
xglKbdCtrl);
|
||||
if (!ret)
|
||||
return BadImplementation;
|
||||
break;
|
||||
|
@ -241,24 +240,24 @@ xglKeybdProc(DeviceIntPtr pDevice, int onoff)
|
|||
break;
|
||||
case DEVICE_OFF:
|
||||
case DEVICE_CLOSE:
|
||||
if (pDev->on)
|
||||
{
|
||||
pDev->on = FALSE;
|
||||
}
|
||||
pDev->on = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
void
|
||||
InitInput (int argc, char **argv)
|
||||
xglInitInput (int argc, char **argv)
|
||||
{
|
||||
DeviceIntPtr pKeyboard, pPointer;
|
||||
DeviceIntPtr pKeyboard, pPointer;
|
||||
|
||||
pPointer = AddInputDevice(xglMouseProc, TRUE);
|
||||
pKeyboard = AddInputDevice(xglKeybdProc, TRUE);
|
||||
RegisterPointerDevice(pPointer);
|
||||
RegisterKeyboardDevice(pKeyboard);
|
||||
miRegisterPointerDevice(screenInfo.screens[0], pPointer);
|
||||
mieqInit(&pKeyboard->public, &pPointer->public);
|
||||
pPointer = AddInputDevice (xglMouseProc, TRUE);
|
||||
pKeyboard = AddInputDevice (xglKeybdProc, TRUE);
|
||||
|
||||
RegisterPointerDevice (pPointer);
|
||||
RegisterKeyboardDevice (pKeyboard);
|
||||
|
||||
miRegisterPointerDevice (screenInfo.screens[0], pPointer);
|
||||
mieqInit (&pKeyboard->public, &pPointer->public);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,472 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
* fee, provided that the above copyright notice appear in all copies
|
||||
* and that both that copyright notice and this permission notice
|
||||
* appear in supporting documentation, and that the names of
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Author: David Reveman <davidr@freedesktop.org>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
|
||||
/*
|
||||
* This offscreen memory manager is horrible and needs some serious work.
|
||||
*
|
||||
* It's a recursive memory manager. It's quite fast but wastes huge
|
||||
* amounts of memory. A simple scoring mechanism is used and pixmaps
|
||||
* that blit to screen get high scores which makes a compositing
|
||||
* manager run fast.
|
||||
*
|
||||
* NOTE: With GL_ARB_uber_buffer or GL_EXT_render_target we probably
|
||||
* wont need this offscreen management at all.
|
||||
*/
|
||||
|
||||
static glitz_drawable_buffer_t _buffers[] = {
|
||||
GLITZ_DRAWABLE_BUFFER_BACK_COLOR,
|
||||
GLITZ_DRAWABLE_BUFFER_FRONT_COLOR
|
||||
};
|
||||
|
||||
#define MAX_LEVEL 6
|
||||
|
||||
static Bool
|
||||
xglOffscreenMoveIn (xglOffscreenAreaPtr pArea,
|
||||
PixmapPtr pPixmap)
|
||||
{
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
if (!xglSyncSurface (&pPixmap->drawable))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
|
||||
pArea->pPixmapPriv = pPixmapPriv;
|
||||
pArea->state = xglOffscreenAreaOccupied;
|
||||
|
||||
pPixmapPriv->pArea = pArea;
|
||||
pPixmapPriv->target = xglPixmapTargetIn;
|
||||
|
||||
glitz_surface_attach (pPixmapPriv->surface,
|
||||
pArea->pOffscreen->drawable,
|
||||
pArea->pOffscreen->buffer,
|
||||
pArea->x, pArea->y);
|
||||
|
||||
XGL_INCREMENT_PIXMAP_SCORE (pPixmapPriv, 500);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
xglOffscreenMoveOut (xglOffscreenAreaPtr pArea)
|
||||
{
|
||||
glitz_surface_detach (pArea->pPixmapPriv->surface);
|
||||
|
||||
pArea->pPixmapPriv->pArea = NULL;
|
||||
pArea->pPixmapPriv->target = xglPixmapTargetOut;
|
||||
pArea->pPixmapPriv = NULL;
|
||||
pArea->state = xglOffscreenAreaAvailable;
|
||||
}
|
||||
|
||||
static xglOffscreenAreaPtr
|
||||
xglCreateOffscreenArea (xglOffscreenPtr pOffscreen,
|
||||
int level,
|
||||
int x,
|
||||
int y)
|
||||
{
|
||||
xglOffscreenAreaPtr pArea;
|
||||
int i;
|
||||
|
||||
pArea = xalloc (sizeof (xglOffscreenAreaRec));
|
||||
if (!pArea)
|
||||
return NULL;
|
||||
|
||||
pArea->level = level;
|
||||
pArea->x = x;
|
||||
pArea->y = y;
|
||||
pArea->pOffscreen = pOffscreen;
|
||||
pArea->pPixmapPriv = NULL;
|
||||
pArea->state = xglOffscreenAreaAvailable;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
pArea->pArea[i] = NULL;
|
||||
|
||||
return pArea;
|
||||
}
|
||||
|
||||
static void
|
||||
xglDestroyOffscreenArea (xglOffscreenAreaPtr pArea)
|
||||
{
|
||||
if (!pArea)
|
||||
return;
|
||||
|
||||
if (pArea->pPixmapPriv)
|
||||
{
|
||||
xglOffscreenMoveOut (pArea);
|
||||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
xglDestroyOffscreenArea (pArea->pArea[i]);
|
||||
}
|
||||
|
||||
xfree (pArea);
|
||||
}
|
||||
|
||||
static Bool
|
||||
xglOffscreenInit (xglOffscreenPtr pOffscreen,
|
||||
glitz_drawable_t *drawable,
|
||||
glitz_drawable_buffer_t buffer,
|
||||
unsigned int width,
|
||||
unsigned int height)
|
||||
{
|
||||
pOffscreen->pArea = xglCreateOffscreenArea (NULL, 0, 0, 0);
|
||||
if (!pOffscreen->pArea)
|
||||
return FALSE;
|
||||
|
||||
glitz_drawable_reference (drawable);
|
||||
|
||||
pOffscreen->drawable = drawable;
|
||||
pOffscreen->format = glitz_drawable_get_format (drawable);
|
||||
pOffscreen->buffer = buffer;
|
||||
pOffscreen->width = width;
|
||||
pOffscreen->height = height;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
xglOffscreenFini (xglOffscreenPtr pOffscreen)
|
||||
{
|
||||
xglDestroyOffscreenArea (pOffscreen->pArea);
|
||||
glitz_drawable_destroy (pOffscreen->drawable);
|
||||
}
|
||||
|
||||
static int
|
||||
xglOffscreenAreaGetTopScore (xglOffscreenAreaPtr pArea)
|
||||
{
|
||||
int topScore;
|
||||
|
||||
if (pArea->pPixmapPriv)
|
||||
{
|
||||
topScore = pArea->pPixmapPriv->score;
|
||||
XGL_DECREMENT_PIXMAP_SCORE (pArea->pPixmapPriv, 5);
|
||||
|
||||
return topScore;
|
||||
}
|
||||
else
|
||||
{
|
||||
int topScore, score, i;
|
||||
|
||||
topScore = 0;
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (pArea->pArea[i])
|
||||
{
|
||||
score = xglOffscreenAreaGetTopScore (pArea->pArea[i]);
|
||||
if (score > topScore)
|
||||
topScore = score;
|
||||
}
|
||||
}
|
||||
return topScore;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static Bool
|
||||
xglOffscreenFindArea (xglOffscreenAreaPtr pArea,
|
||||
PixmapPtr pPixmap,
|
||||
int level)
|
||||
{
|
||||
if (pArea->level > level)
|
||||
return FALSE;
|
||||
|
||||
switch (pArea->state) {
|
||||
case xglOffscreenAreaOccupied:
|
||||
{
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
if (pPixmapPriv->score < pArea->pPixmapPriv->score)
|
||||
{
|
||||
XGL_DECREMENT_PIXMAP_SCORE (pArea->pPixmapPriv, 10);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
xglOffscreenMoveOut (pArea);
|
||||
}
|
||||
/* fall-through */
|
||||
case xglOffscreenAreaAvailable:
|
||||
{
|
||||
if (pArea->level == level || pArea->level == MAX_LEVEL)
|
||||
{
|
||||
if (xglOffscreenMoveIn (pArea, pPixmap))
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
int dx[4], dy[4], i;
|
||||
|
||||
dx[0] = dx[2] = dy[0] = dy[1] = 0;
|
||||
dx[1] = dx[3] = pArea->pOffscreen->width >> (pArea->level + 1);
|
||||
dy[2] = dy[3] = pArea->pOffscreen->height >> (pArea->level + 1);
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
pArea->pArea[i] =
|
||||
xglCreateOffscreenArea (pArea->pOffscreen,
|
||||
pArea->level + 1,
|
||||
pArea->x + dx[i],
|
||||
pArea->y + dy[i]);
|
||||
}
|
||||
|
||||
pArea->state = xglOffscreenAreaDivided;
|
||||
|
||||
if (xglOffscreenFindArea (pArea->pArea[0], pPixmap, level))
|
||||
return TRUE;
|
||||
}
|
||||
} break;
|
||||
case xglOffscreenAreaDivided:
|
||||
{
|
||||
int i;
|
||||
|
||||
if (pArea->level == level)
|
||||
{
|
||||
int topScore;
|
||||
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
topScore = xglOffscreenAreaGetTopScore (pArea);
|
||||
|
||||
if (pPixmapPriv->score >= topScore)
|
||||
{
|
||||
/*
|
||||
* Kick out old pixmaps
|
||||
*/
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
xglDestroyOffscreenArea (pArea->pArea[i]);
|
||||
pArea->pArea[i] = NULL;
|
||||
}
|
||||
|
||||
if (xglOffscreenMoveIn (pArea, pPixmap))
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (xglOffscreenFindArea (pArea->pArea[i], pPixmap, level))
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglInitOffscreen (ScreenPtr pScreen,
|
||||
xglScreenInfoPtr pScreenInfo)
|
||||
{
|
||||
xglOffscreenPtr pOffscreen;
|
||||
int nOffscreen;
|
||||
glitz_drawable_format_t *format;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
pScreenPriv->pOffscreen = NULL;
|
||||
pScreenPriv->nOffscreen = 0;
|
||||
|
||||
format = glitz_drawable_get_format (pScreenPriv->drawable);
|
||||
|
||||
/*
|
||||
* Use back buffer as offscreen area.
|
||||
*/
|
||||
if (format->doublebuffer)
|
||||
{
|
||||
pScreenPriv->pOffscreen =
|
||||
xrealloc (pScreenPriv->pOffscreen,
|
||||
sizeof (xglOffscreenRec) *
|
||||
(pScreenPriv->nOffscreen + 1));
|
||||
if (pScreenPriv->pOffscreen)
|
||||
{
|
||||
pOffscreen = &pScreenPriv->pOffscreen[pScreenPriv->nOffscreen];
|
||||
|
||||
if (xglOffscreenInit (pOffscreen,
|
||||
pScreenPriv->drawable,
|
||||
GLITZ_DRAWABLE_BUFFER_BACK_COLOR,
|
||||
pScreenInfo->width, pScreenInfo->height))
|
||||
{
|
||||
pScreenPriv->nOffscreen++;
|
||||
ErrorF ("Initialized %dx%d back buffer offscreen area\n",
|
||||
pScreenInfo->width, pScreenInfo->height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nxglPbufferVisuals)
|
||||
{
|
||||
glitz_pbuffer_attributes_t attributes;
|
||||
unsigned long mask;
|
||||
glitz_drawable_t *pbuffer;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nxglPbufferVisuals; i++)
|
||||
{
|
||||
/*
|
||||
* This can be a bit tricky. I've noticed that when some OpenGL
|
||||
* drivers can't create an accelerated pbuffer of the size we're
|
||||
* requesting they create a software one with the correct
|
||||
* size, but that's not what we want. So if your OpenGL driver
|
||||
* supports accelerated pbuffers but offscreen drawing is really
|
||||
* slow, try decrementing these values.
|
||||
*/
|
||||
attributes.width = 2048;
|
||||
attributes.height = 2048;
|
||||
|
||||
mask = GLITZ_PBUFFER_WIDTH_MASK | GLITZ_PBUFFER_HEIGHT_MASK;
|
||||
|
||||
pbuffer =
|
||||
glitz_create_pbuffer_drawable (pScreenPriv->drawable,
|
||||
xglPbufferVisuals[i].format,
|
||||
&attributes, mask);
|
||||
|
||||
if (pbuffer)
|
||||
{
|
||||
unsigned long width, height;
|
||||
int j;
|
||||
|
||||
width = glitz_drawable_get_width (pbuffer);
|
||||
height = glitz_drawable_get_height (pbuffer);
|
||||
|
||||
j = 0;
|
||||
|
||||
/*
|
||||
* No back buffer? only add front buffer.
|
||||
*/
|
||||
if (!xglPbufferVisuals[i].format->doublebuffer)
|
||||
j++;
|
||||
|
||||
while (j < 2)
|
||||
{
|
||||
pScreenPriv->pOffscreen =
|
||||
xrealloc (pScreenPriv->pOffscreen,
|
||||
sizeof (xglOffscreenRec) *
|
||||
(pScreenPriv->nOffscreen + 1));
|
||||
if (pScreenPriv->pOffscreen)
|
||||
{
|
||||
pOffscreen =
|
||||
&pScreenPriv->pOffscreen[pScreenPriv->nOffscreen];
|
||||
|
||||
if (xglOffscreenInit (pOffscreen,
|
||||
pbuffer, _buffers[j],
|
||||
width, height))
|
||||
{
|
||||
pScreenPriv->nOffscreen++;
|
||||
ErrorF ("Initialized %dx%d pbuffer offscreen "
|
||||
"area\n", width, height);
|
||||
}
|
||||
}
|
||||
j++;
|
||||
}
|
||||
glitz_drawable_destroy (pbuffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pOffscreen = pScreenPriv->pOffscreen;
|
||||
nOffscreen = pScreenPriv->nOffscreen;
|
||||
|
||||
/*
|
||||
* Update offscreen pointers in root offscreen areas
|
||||
*/
|
||||
while (nOffscreen--)
|
||||
{
|
||||
pOffscreen->pArea->pOffscreen = pOffscreen;
|
||||
pOffscreen++;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
xglFiniOffscreen (ScreenPtr pScreen)
|
||||
{
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
while (pScreenPriv->nOffscreen--)
|
||||
xglOffscreenFini (&pScreenPriv->pOffscreen[pScreenPriv->nOffscreen]);
|
||||
|
||||
if (pScreenPriv->pOffscreen)
|
||||
xfree (pScreenPriv->pOffscreen);
|
||||
}
|
||||
|
||||
Bool
|
||||
xglFindOffscreenArea (ScreenPtr pScreen,
|
||||
PixmapPtr pPixmap)
|
||||
{
|
||||
xglOffscreenPtr pOffscreen;
|
||||
int nOffscreen;
|
||||
glitz_color_format_t *pColor;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
if (pPixmapPriv->score < 0)
|
||||
return FALSE;
|
||||
|
||||
pColor = &pPixmapPriv->format->color;
|
||||
|
||||
pOffscreen = pScreenPriv->pOffscreen;
|
||||
nOffscreen = pScreenPriv->nOffscreen;
|
||||
|
||||
while (nOffscreen--)
|
||||
{
|
||||
int level;
|
||||
|
||||
if (pOffscreen->format->color.red_size >= pColor->red_size &&
|
||||
pOffscreen->format->color.green_size >= pColor->green_size &&
|
||||
pOffscreen->format->color.blue_size >= pColor->blue_size &&
|
||||
pOffscreen->format->color.alpha_size >= pColor->alpha_size)
|
||||
{
|
||||
|
||||
level = 0;
|
||||
while ((pOffscreen->width >> level) >= pPixmap->drawable.width &&
|
||||
(pOffscreen->height >> level) >= pPixmap->drawable.height)
|
||||
level++;
|
||||
|
||||
if (!level)
|
||||
continue;
|
||||
|
||||
if (xglOffscreenFindArea (pOffscreen->pArea, pPixmap, level - 1))
|
||||
return TRUE;
|
||||
}
|
||||
pOffscreen++;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
xglWithdrawOffscreenArea (xglOffscreenAreaPtr pArea)
|
||||
{
|
||||
pArea->pPixmapPriv = NULL;
|
||||
pArea->state = xglOffscreenAreaAvailable;
|
||||
}
|
|
@ -1,38 +1,39 @@
|
|||
/*
|
||||
* $Id$
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
* fee, provided that the above copyright notice appear in all copies
|
||||
* and that both that copyright notice and this permission notice
|
||||
* appear in supporting documentation, and that the names of
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* Copyright © 2004 Keith Packard
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Keith Packard not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Keith Packard makes no
|
||||
* representations about the suitability of this software for any purpose. It
|
||||
* is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
* Author: David Reveman <davidr@freedesktop.org>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
|
||||
typedef struct _xglDepths {
|
||||
CARD8 depth;
|
||||
CARD8 bpp;
|
||||
} XglDepths;
|
||||
typedef struct _xglDepth {
|
||||
CARD8 depth;
|
||||
CARD8 bpp;
|
||||
} xglDepthRec, *xglDepthPtr;
|
||||
|
||||
static XglDepths xglDepths[] = {
|
||||
{ 1, 1 },
|
||||
{ 4, 4 },
|
||||
{ 8, 8 },
|
||||
static xglDepthRec xglDepths[] = {
|
||||
{ 1, 1 },
|
||||
{ 4, 4 },
|
||||
{ 8, 8 },
|
||||
{ 15, 16 },
|
||||
{ 16, 16 },
|
||||
{ 24, 32 },
|
||||
|
@ -41,148 +42,24 @@ static XglDepths xglDepths[] = {
|
|||
|
||||
#define NUM_XGL_DEPTHS (sizeof (xglDepths) / sizeof (xglDepths[0]))
|
||||
|
||||
static void
|
||||
void
|
||||
xglSetPixmapFormats (ScreenInfo *pScreenInfo)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
|
||||
pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
|
||||
pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
|
||||
pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
|
||||
pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
|
||||
|
||||
pScreenInfo->numPixmapFormats = 0;
|
||||
for (i = 0; i < NUM_XGL_DEPTHS; i++)
|
||||
{
|
||||
PixmapFormatRec *format = &pScreenInfo->formats[pScreenInfo->numPixmapFormats++];
|
||||
format->depth = xglDepths[i].depth;
|
||||
pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
|
||||
pScreenInfo->numPixmapFormats = 0;
|
||||
|
||||
for (i = 0; i < NUM_XGL_DEPTHS; i++) {
|
||||
PixmapFormatRec *format;
|
||||
|
||||
format = &pScreenInfo->formats[pScreenInfo->numPixmapFormats++];
|
||||
|
||||
format->depth = xglDepths[i].depth;
|
||||
format->bitsPerPixel = xglDepths[i].bpp;
|
||||
format->scanlinePad = BITMAP_SCANLINE_PAD;
|
||||
format->scanlinePad = BITMAP_SCANLINE_PAD;
|
||||
}
|
||||
}
|
||||
|
||||
#define xglQueryBestSize (void *) NoopDDA
|
||||
#define xglSaveScreen (void *) NoopDDA
|
||||
#define miGetImage (void *) NoopDDA
|
||||
#define xglCreateWindow (void *) NoopDDA
|
||||
#define xglDestroyWindow (void *) NoopDDA
|
||||
#define xglPositionWindow (void *) NoopDDA
|
||||
#define xglChangeWindowAttributes (void *) NoopDDA
|
||||
#define xglRealizeWindow (void *) NoopDDA
|
||||
#define xglUnrealizeWindow (void *) NoopDDA
|
||||
#define xglPaintWindowBackground (void *) NoopDDA
|
||||
#define xglPaintWindowBorder (void *) NoopDDA
|
||||
#define xglCopyWindow (void *) NoopDDA
|
||||
#define xglRealizeFont (void *) NoopDDA
|
||||
#define xglUnrealizeFont (void *) NoopDDA
|
||||
|
||||
#define xglConstrainCursor (void *) NoopDDA
|
||||
#define xglCursorLimits (void *) NoopDDA
|
||||
#define xglDisplayCursor (void *) NoopDDA
|
||||
#define xglRealizeCursor (void *) NoopDDA
|
||||
#define xglUnrealizeCursor (void *) NoopDDA
|
||||
#define xglRecolorCursor (void *) NoopDDA
|
||||
#define xglSetCursorPosition (void *) NoopDDA
|
||||
|
||||
#define xglCreateColormap (void *) NoopDDA
|
||||
#define xglDestroyColormap (void *) NoopDDA
|
||||
#define xglInstallColormap (void *) NoopDDA
|
||||
#define xglUninstallColormap (void *) NoopDDA
|
||||
#define xglListInstalledColormaps (void *) NoopDDA
|
||||
#define xglStoreColors (void *) NoopDDA
|
||||
#define xglResolveColor (void *) NoopDDA
|
||||
#define xglBitmapToRegion (void *) NoopDDA
|
||||
|
||||
static PixmapPtr
|
||||
xglGetWindowPixmap (WindowPtr pWin)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
xglSetWindowPixmap (WindowPtr pWin, PixmapPtr pPixmap)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
xglSetupScreen (ScreenPtr pScreen)
|
||||
{
|
||||
pScreen->defColormap = FakeClientID (0);
|
||||
pScreen->blackPixel = pScreen->whitePixel = (Pixel) 0;
|
||||
|
||||
pScreen->QueryBestSize = xglQueryBestSize;
|
||||
pScreen->SaveScreen = xglSaveScreen;
|
||||
pScreen->GetImage = miGetImage;
|
||||
pScreen->GetSpans = xglGetSpans;
|
||||
|
||||
pScreen->CreateWindow = xglCreateWindow;
|
||||
pScreen->DestroyWindow = xglDestroyWindow;
|
||||
pScreen->PositionWindow = xglPositionWindow;
|
||||
pScreen->ChangeWindowAttributes = xglChangeWindowAttributes;
|
||||
pScreen->RealizeWindow = xglRealizeWindow;
|
||||
pScreen->UnrealizeWindow = xglUnrealizeWindow;
|
||||
pScreen->PaintWindowBackground = xglPaintWindowBackground;
|
||||
pScreen->PaintWindowBorder = xglPaintWindowBorder;
|
||||
pScreen->CopyWindow = xglCopyWindow;
|
||||
|
||||
pScreen->CreatePixmap = xglCreatePixmap;
|
||||
pScreen->DestroyPixmap = xglDestroyPixmap;
|
||||
|
||||
pScreen->RealizeFont = xglRealizeFont;
|
||||
pScreen->UnrealizeFont = xglUnrealizeFont;
|
||||
|
||||
pScreen->ConstrainCursor = xglConstrainCursor;
|
||||
pScreen->CursorLimits = xglCursorLimits;
|
||||
pScreen->DisplayCursor = xglDisplayCursor;
|
||||
pScreen->RealizeCursor = xglRealizeCursor;
|
||||
pScreen->UnrealizeCursor = xglUnrealizeCursor;
|
||||
pScreen->RecolorCursor = xglRecolorCursor;
|
||||
pScreen->SetCursorPosition = xglSetCursorPosition;
|
||||
|
||||
pScreen->CreateGC = xglCreateGC;
|
||||
|
||||
pScreen->CreateColormap = miInitializeColormap;
|
||||
pScreen->DestroyColormap = xglDestroyColormap;
|
||||
pScreen->InstallColormap = miInstallColormap;
|
||||
pScreen->UninstallColormap = miUninstallColormap;
|
||||
pScreen->ListInstalledColormaps = miListInstalledColormaps;
|
||||
pScreen->StoreColors = xglStoreColors;
|
||||
pScreen->ResolveColor = miResolveColor;
|
||||
|
||||
pScreen->BitmapToRegion = xglBitmapToRegion;
|
||||
|
||||
pScreen->GetWindowPixmap = xglGetWindowPixmap;
|
||||
pScreen->SetWindowPixmap = xglSetWindowPixmap;
|
||||
}
|
||||
|
||||
static Bool
|
||||
xglScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
|
||||
{
|
||||
VisualPtr visuals;
|
||||
DepthPtr depths;
|
||||
int nvisuals;
|
||||
int ndepth;
|
||||
int rootDepth;
|
||||
VisualID defaultVisual;
|
||||
|
||||
rootDepth = 24;
|
||||
miInitVisuals (&visuals, &depths, &nvisuals,
|
||||
&ndepth, &rootDepth, &defaultVisual,
|
||||
1 << 31, 8, -1);
|
||||
miScreenInit (pScreen, 0, 800, 600, 96, 96, 800, rootDepth,
|
||||
ndepth, depths, defaultVisual, nvisuals, visuals);
|
||||
xglSetupScreen (pScreen);
|
||||
if (!miCreateDefColormap (pScreen))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
|
||||
{
|
||||
xglSetPixmapFormats (pScreenInfo);
|
||||
|
||||
AddScreen (xglScreenInit, argc, argv);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,132 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
* fee, provided that the above copyright notice appear in all copies
|
||||
* and that both that copyright notice and this permission notice
|
||||
* appear in supporting documentation, and that the names of
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Author: David Reveman <davidr@freedesktop.org>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
|
||||
char *
|
||||
xglParseFindNext (char *cur,
|
||||
char *delim,
|
||||
char *save,
|
||||
char *last)
|
||||
{
|
||||
while (*cur && !strchr (delim, *cur))
|
||||
*save++ = *cur++;
|
||||
|
||||
*save = 0;
|
||||
*last = *cur;
|
||||
|
||||
if (*cur)
|
||||
cur++;
|
||||
|
||||
return cur;
|
||||
}
|
||||
|
||||
void
|
||||
xglParseScreen (xglScreenInfoPtr pScreenInfo,
|
||||
char *arg)
|
||||
{
|
||||
char delim;
|
||||
char save[1024];
|
||||
int i, pixels, mm;
|
||||
|
||||
pScreenInfo->width = 0;
|
||||
pScreenInfo->height = 0;
|
||||
pScreenInfo->widthMm = 0;
|
||||
pScreenInfo->heightMm = 0;
|
||||
|
||||
if (!arg)
|
||||
return;
|
||||
|
||||
if (strlen (arg) >= sizeof (save))
|
||||
return;
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
arg = xglParseFindNext (arg, "x/@XY", save, &delim);
|
||||
if (!save[0])
|
||||
return;
|
||||
|
||||
pixels = atoi (save);
|
||||
mm = 0;
|
||||
|
||||
if (delim == '/')
|
||||
{
|
||||
arg = xglParseFindNext (arg, "x@XY", save, &delim);
|
||||
if (!save[0])
|
||||
return;
|
||||
|
||||
mm = atoi (save);
|
||||
}
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
pScreenInfo->width = pixels;
|
||||
pScreenInfo->widthMm = mm;
|
||||
}
|
||||
else
|
||||
{
|
||||
pScreenInfo->height = pixels;
|
||||
pScreenInfo->heightMm = mm;
|
||||
}
|
||||
|
||||
if (delim != 'x')
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
xglUseMsg (void)
|
||||
{
|
||||
ErrorF ("-screen WIDTH[/WIDTHMM]xHEIGHT[/HEIGHTMM] "
|
||||
"Specify screen characteristics\n");
|
||||
ErrorF ("-fullscreen Run fullscreen\n");
|
||||
}
|
||||
|
||||
int
|
||||
xglProcessArgument (xglScreenInfoPtr pScreenInfo,
|
||||
int argc,
|
||||
char **argv,
|
||||
int i)
|
||||
{
|
||||
if (!strcmp (argv[i], "-screen"))
|
||||
{
|
||||
if ((i + 1) < argc)
|
||||
{
|
||||
xglParseScreen (pScreenInfo, argv[i + 1]);
|
||||
}
|
||||
else
|
||||
return 1;
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (!strcmp (argv[i], "-fullscreen"))
|
||||
{
|
||||
pScreenInfo->fullscreen = TRUE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,240 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
* fee, provided that the above copyright notice appear in all copies
|
||||
* and that both that copyright notice and this permission notice
|
||||
* appear in supporting documentation, and that the names of
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Author: David Reveman <davidr@freedesktop.org>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
|
||||
#ifdef RENDER
|
||||
|
||||
#define XGL_PICTURE_FALLBACK_PROLOGUE(pPicture, func) \
|
||||
xglSyncDamageBoxBits (pPicture->pDrawable); \
|
||||
XGL_PICTURE_SCREEN_UNWRAP (func)
|
||||
|
||||
#define XGL_PICTURE_FALLBACK_EPILOGUE(pPicture, func, xglfunc) \
|
||||
XGL_PICTURE_SCREEN_WRAP (func, xglfunc); \
|
||||
xglAddSurfaceDamage (pPicture->pDrawable)
|
||||
|
||||
void
|
||||
xglComposite (CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pMask,
|
||||
PicturePtr pDst,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
INT16 xMask,
|
||||
INT16 yMask,
|
||||
INT16 xDst,
|
||||
INT16 yDst,
|
||||
CARD16 width,
|
||||
CARD16 height)
|
||||
{
|
||||
PictureScreenPtr pPictureScreen;
|
||||
ScreenPtr pScreen = pDst->pDrawable->pScreen;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
if (xglComp (op,
|
||||
pSrc, pMask, pDst,
|
||||
xSrc, ySrc,
|
||||
xMask, yMask,
|
||||
xDst, yDst,
|
||||
width, height))
|
||||
return;
|
||||
|
||||
pPictureScreen = GetPictureScreen (pScreen);
|
||||
|
||||
if (!xglSyncBits (pSrc->pDrawable, NullBox))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
|
||||
if (pMask)
|
||||
{
|
||||
if (!xglSyncBits (pMask->pDrawable, NullBox))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
}
|
||||
|
||||
XGL_PICTURE_FALLBACK_PROLOGUE (pDst, Composite);
|
||||
(*pPictureScreen->Composite) (op, pSrc, pMask, pDst,
|
||||
xSrc, ySrc, xMask, yMask, xDst, yDst,
|
||||
width, height);
|
||||
XGL_PICTURE_FALLBACK_EPILOGUE (pDst, Composite, xglComposite);
|
||||
}
|
||||
|
||||
void
|
||||
xglGlyphs (CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
int nlist,
|
||||
GlyphListPtr list,
|
||||
GlyphPtr *glyphs)
|
||||
{
|
||||
miGlyphs (op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs);
|
||||
}
|
||||
|
||||
void
|
||||
xglRasterizeTrapezoid (PicturePtr pDst,
|
||||
xTrapezoid *trap,
|
||||
int xOff,
|
||||
int yOff)
|
||||
{
|
||||
PictureScreenPtr pPictureScreen;
|
||||
ScreenPtr pScreen = pDst->pDrawable->pScreen;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
pPictureScreen = GetPictureScreen (pScreen);
|
||||
|
||||
XGL_PICTURE_FALLBACK_PROLOGUE (pDst, RasterizeTrapezoid);
|
||||
(*pPictureScreen->RasterizeTrapezoid) (pDst, trap, xOff, yOff);
|
||||
XGL_PICTURE_FALLBACK_EPILOGUE (pDst, RasterizeTrapezoid,
|
||||
xglRasterizeTrapezoid);
|
||||
}
|
||||
|
||||
void
|
||||
xglChangePicture (PicturePtr pPicture,
|
||||
Mask mask)
|
||||
{
|
||||
PictureScreenPtr pPictureScreen;
|
||||
ScreenPtr pScreen = pPicture->pDrawable->pScreen;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pPicture->pDrawable);
|
||||
|
||||
pPictureScreen = GetPictureScreen (pScreen);
|
||||
|
||||
if (pPicture->stateChanges & CPRepeat)
|
||||
pPixmapPriv->pictureMask |= xglPCFillMask;
|
||||
|
||||
if (pPicture->stateChanges & CPComponentAlpha)
|
||||
pPixmapPriv->pictureMask |= xglPCComponentAlphaMask;
|
||||
|
||||
XGL_PICTURE_SCREEN_UNWRAP (ChangePicture);
|
||||
(*pPictureScreen->ChangePicture) (pPicture, mask);
|
||||
XGL_PICTURE_SCREEN_WRAP (ChangePicture, xglChangePicture);
|
||||
}
|
||||
|
||||
int
|
||||
xglChangePictureTransform (PicturePtr pPicture,
|
||||
PictTransform *transform)
|
||||
{
|
||||
PictureScreenPtr pPictureScreen;
|
||||
ScreenPtr pScreen = pPicture->pDrawable->pScreen;
|
||||
int ret;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pPicture->pDrawable);
|
||||
|
||||
pPictureScreen = GetPictureScreen (pScreen);
|
||||
|
||||
pPixmapPriv->pictureMask |= xglPCTransformMask;
|
||||
|
||||
XGL_PICTURE_SCREEN_UNWRAP (ChangePictureTransform);
|
||||
ret = (*pPictureScreen->ChangePictureTransform) (pPicture, transform);
|
||||
XGL_PICTURE_SCREEN_WRAP (ChangePictureTransform,
|
||||
xglChangePictureTransform);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
xglChangePictureFilter (PicturePtr pPicture,
|
||||
int filter,
|
||||
xFixed *params,
|
||||
int nparams)
|
||||
{
|
||||
PictureScreenPtr pPictureScreen;
|
||||
ScreenPtr pScreen = pPicture->pDrawable->pScreen;
|
||||
int ret;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pPicture->pDrawable);
|
||||
|
||||
pPictureScreen = GetPictureScreen (pScreen);
|
||||
|
||||
pPixmapPriv->pictureMask |= xglPCFilterMask;
|
||||
|
||||
XGL_PICTURE_SCREEN_UNWRAP (ChangePictureFilter);
|
||||
ret = (*pPictureScreen->ChangePictureFilter) (pPicture, filter,
|
||||
params, nparams);
|
||||
XGL_PICTURE_SCREEN_WRAP (ChangePictureFilter, xglChangePictureFilter);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
xglUpdatePicture (PicturePtr pPicture)
|
||||
{
|
||||
glitz_surface_t *surface;
|
||||
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pPicture->pDrawable);
|
||||
|
||||
surface = pPixmapPriv->surface;
|
||||
|
||||
if (pPixmapPriv->pictureMask & xglPCFillMask)
|
||||
{
|
||||
if (pPicture->repeat)
|
||||
glitz_surface_set_fill (surface, GLITZ_FILL_REPEAT);
|
||||
else
|
||||
glitz_surface_set_fill (surface, GLITZ_FILL_TRANSPARENT);
|
||||
}
|
||||
|
||||
if (pPixmapPriv->pictureMask & xglPCFilterMask)
|
||||
{
|
||||
switch (pPicture->filter) {
|
||||
case PictFilterNearest:
|
||||
case PictFilterFast:
|
||||
glitz_surface_set_filter (surface, GLITZ_FILTER_NEAREST, NULL, 0);
|
||||
pPixmapPriv->pictureMask &= ~xglPFFilterMask;
|
||||
break;
|
||||
case PictFilterGood:
|
||||
case PictFilterBest:
|
||||
case PictFilterBilinear:
|
||||
glitz_surface_set_filter (surface, GLITZ_FILTER_BILINEAR, NULL, 0);
|
||||
pPixmapPriv->pictureMask &= ~xglPFFilterMask;
|
||||
break;
|
||||
default:
|
||||
pPixmapPriv->pictureMask |= xglPFFilterMask;
|
||||
}
|
||||
}
|
||||
|
||||
if (pPixmapPriv->pictureMask & xglPCTransformMask)
|
||||
{
|
||||
glitz_surface_set_transform (surface, (glitz_transform_t *)
|
||||
pPicture->transform);
|
||||
}
|
||||
|
||||
if (pPixmapPriv->pictureMask & xglPCComponentAlphaMask)
|
||||
{
|
||||
if (pPicture->componentAlpha)
|
||||
glitz_surface_set_component_alpha (surface, 1);
|
||||
else
|
||||
glitz_surface_set_component_alpha (surface, 0);
|
||||
}
|
||||
|
||||
pPixmapPriv->pictureMask &= ~XGL_PICTURE_CHANGES (~0);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,161 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
* fee, provided that the above copyright notice appear in all copies
|
||||
* and that both that copyright notice and this permission notice
|
||||
* appear in supporting documentation, and that the names of
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Author: David Reveman <davidr@freedesktop.org>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
#include "fb.h"
|
||||
|
||||
Bool
|
||||
xglSetPixels (DrawablePtr pDrawable,
|
||||
char *src,
|
||||
int stride,
|
||||
Bool upsideDown,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
BoxPtr pBox,
|
||||
int nBox)
|
||||
{
|
||||
glitz_pixel_format_t format;
|
||||
glitz_surface_t *surface;
|
||||
FbBits *srcBits, *dstBits;
|
||||
FbStride srcStride, dstStride;
|
||||
BoxPtr pDstBox;
|
||||
int nDstBox;
|
||||
int dstXoff, dstYoff, dstBpp;
|
||||
int dstY, srcY;
|
||||
int x1, y1, x2, y2;
|
||||
|
||||
XGL_DRAWABLE_PIXMAP (pDrawable);
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
if (!nBox)
|
||||
return TRUE;
|
||||
|
||||
if (!xglSyncSurface (pDrawable))
|
||||
return FALSE;
|
||||
|
||||
XGL_GET_DRAWABLE (pDrawable, surface, dstXoff, dstYoff);
|
||||
|
||||
if (!xglMapPixmapBits (pPixmap))
|
||||
return FALSE;
|
||||
|
||||
dstBpp = pDrawable->bitsPerPixel;
|
||||
|
||||
srcBits = (FbBits *) src;
|
||||
dstBits = (FbBits *) pPixmap->devPrivate.ptr;
|
||||
|
||||
srcStride = stride / sizeof (FbBits);
|
||||
dstStride = pPixmapPriv->stride / sizeof (FbBits);
|
||||
|
||||
pDstBox = xalloc (nBox);
|
||||
if (!pDstBox)
|
||||
return FALSE;
|
||||
|
||||
nDstBox = 0;
|
||||
|
||||
while (nBox--)
|
||||
{
|
||||
x1 = x;
|
||||
y1 = y;
|
||||
x2 = x + width;
|
||||
y2 = y + height;
|
||||
|
||||
if (x1 < pBox->x1)
|
||||
x1 = pBox->x1;
|
||||
if (y1 < pBox->y1)
|
||||
y1 = pBox->y1;
|
||||
if (x2 > pBox->x2)
|
||||
x2 = pBox->x2;
|
||||
if (y2 > pBox->y2)
|
||||
y2 = pBox->y2;
|
||||
|
||||
if (x1 < x2 && y1 < y2)
|
||||
{
|
||||
if (XGL_INTERNAL_SCANLINE_ORDER_UPSIDE_DOWN)
|
||||
dstY = pDrawable->height - (y2 + dstYoff);
|
||||
else
|
||||
dstY = y1 + dstYoff;
|
||||
|
||||
if (upsideDown)
|
||||
srcY = height - (y2 - y);
|
||||
else
|
||||
srcY = y1 - y;
|
||||
|
||||
fbBlt (srcBits + srcY * srcStride,
|
||||
srcStride,
|
||||
(x1 - x) * dstBpp,
|
||||
|
||||
dstBits + dstY * dstStride,
|
||||
dstStride,
|
||||
(x1 + dstXoff) * dstBpp,
|
||||
|
||||
(x2 - x1) * dstBpp,
|
||||
y2 - y1,
|
||||
|
||||
GXcopy,
|
||||
FB_ALLONES,
|
||||
dstBpp,
|
||||
FALSE,
|
||||
upsideDown != XGL_INTERNAL_SCANLINE_ORDER_UPSIDE_DOWN);
|
||||
|
||||
pDstBox[nDstBox].x1 = x1;
|
||||
pDstBox[nDstBox].y1 = y1;
|
||||
pDstBox[nDstBox].x2 = x2;
|
||||
pDstBox[nDstBox].y2 = y2;
|
||||
|
||||
nDstBox++;
|
||||
}
|
||||
pBox++;
|
||||
}
|
||||
|
||||
xglUnmapPixmapBits (pPixmap);
|
||||
|
||||
format.masks = pPixmapPriv->pPixel->masks;
|
||||
format.bytes_per_line = pPixmapPriv->stride;
|
||||
format.scanline_order = XGL_INTERNAL_SCANLINE_ORDER;
|
||||
|
||||
pBox = pDstBox;
|
||||
|
||||
while (nDstBox--)
|
||||
{
|
||||
format.xoffset = pBox->x1 + dstXoff;
|
||||
format.skip_lines = pBox->y1 + dstYoff;
|
||||
|
||||
glitz_set_pixels (surface,
|
||||
pBox->x1 + dstXoff,
|
||||
pBox->y1 + dstYoff,
|
||||
pBox->x2 - pBox->x1,
|
||||
pBox->y2 - pBox->y1,
|
||||
&format,
|
||||
pPixmapPriv->buffer);
|
||||
|
||||
pBox++;
|
||||
}
|
||||
|
||||
xfree (pDstBox);
|
||||
|
||||
return TRUE;
|
||||
}
|
|
@ -1,28 +1,125 @@
|
|||
/*
|
||||
* $Id$
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
* fee, provided that the above copyright notice appear in all copies
|
||||
* and that both that copyright notice and this permission notice
|
||||
* appear in supporting documentation, and that the names of
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* Copyright © 2004 Keith Packard
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Keith Packard not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Keith Packard makes no
|
||||
* representations about the suitability of this software for any purpose. It
|
||||
* is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
* Author: David Reveman <davidr@freedesktop.org>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
#include "fb.h"
|
||||
|
||||
static void
|
||||
xglPixmapDamageReport (DamagePtr pDamage,
|
||||
RegionPtr pRegion,
|
||||
void *closure)
|
||||
{
|
||||
PixmapPtr pPixmap = (PixmapPtr) closure;
|
||||
BoxPtr pExt;
|
||||
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
pExt = REGION_EXTENTS (pPixmap->drawable.pScreen, pRegion);
|
||||
|
||||
if (BOX_NOTEMPTY (&pPixmapPriv->damageBox))
|
||||
{
|
||||
if (pExt->x1 < pPixmapPriv->damageBox.x1)
|
||||
pPixmapPriv->damageBox.x1 = pExt->x1;
|
||||
|
||||
if (pExt->y1 < pPixmapPriv->damageBox.y1)
|
||||
pPixmapPriv->damageBox.y1 = pExt->y1;
|
||||
|
||||
if (pExt->x2 > pPixmapPriv->damageBox.x2)
|
||||
pPixmapPriv->damageBox.x2 = pExt->x2;
|
||||
|
||||
if (pExt->y2 > pPixmapPriv->damageBox.y2)
|
||||
pPixmapPriv->damageBox.y2 = pExt->y2;
|
||||
} else
|
||||
pPixmapPriv->damageBox = *pExt;
|
||||
}
|
||||
|
||||
|
||||
static Bool
|
||||
xglPixmapCreateDamage (PixmapPtr pPixmap)
|
||||
{
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
pPixmapPriv->pDamage =
|
||||
DamageCreate (xglPixmapDamageReport, (DamageDestroyFunc) 0,
|
||||
DamageReportRawRegion, TRUE,
|
||||
(void *) pPixmap);
|
||||
if (!pPixmapPriv->pDamage)
|
||||
return FALSE;
|
||||
|
||||
DamageRegister (&pPixmap->drawable, pPixmapPriv->pDamage);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Bool
|
||||
xglPixmapSurfaceInit (PixmapPtr pPixmap,
|
||||
unsigned long features,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
pPixmapPriv->surface = NULL;
|
||||
pPixmapPriv->pArea = NULL;
|
||||
pPixmapPriv->score = 0;
|
||||
pPixmapPriv->acceleratedTile = FALSE;
|
||||
pPixmapPriv->pictureMask = ~0;
|
||||
pPixmapPriv->target = xglPixmapTargetNo;
|
||||
|
||||
if (pPixmapPriv->format)
|
||||
{
|
||||
if (!pPixmapPriv->pDamage)
|
||||
if (!xglPixmapCreateDamage (pPixmap))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
|
||||
if (width && height)
|
||||
{
|
||||
if (features & GLITZ_FEATURE_TEXTURE_BORDER_CLAMP_MASK)
|
||||
if ((features & GLITZ_FEATURE_TEXTURE_NON_POWER_OF_TWO_MASK) ||
|
||||
(POWER_OF_TWO (width) && POWER_OF_TWO (height)))
|
||||
pPixmapPriv->acceleratedTile = TRUE;
|
||||
|
||||
pPixmapPriv->target = xglPixmapTargetOut;
|
||||
|
||||
/*
|
||||
* Don't allow depth 8 pixmaps into offscreen drawables as
|
||||
* no trapezoid acceleration is hooked up yet.
|
||||
*/
|
||||
if (pPixmap->drawable.depth <= 8)
|
||||
pPixmapPriv->target = xglPixmapTargetNo;
|
||||
|
||||
/*
|
||||
* Drawing to really small pixmaps is not worth accelerating.
|
||||
*/
|
||||
if (width < 8 && height < 8)
|
||||
pPixmapPriv->target = xglPixmapTargetNo;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
PixmapPtr
|
||||
xglCreatePixmap (ScreenPtr pScreen,
|
||||
|
@ -30,12 +127,15 @@ xglCreatePixmap (ScreenPtr pScreen,
|
|||
int height,
|
||||
int depth)
|
||||
{
|
||||
PixmapPtr pPixmap;
|
||||
xglPixmapPtr pPixmapPriv;
|
||||
PixmapPtr pPixmap;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
pPixmap = AllocatePixmap (pScreen, 0);
|
||||
if (!pPixmap)
|
||||
return NullPixmap;
|
||||
|
||||
|
||||
pPixmap->drawable.type = DRAWABLE_PIXMAP;
|
||||
pPixmap->drawable.class = 0;
|
||||
pPixmap->drawable.pScreen = pScreen;
|
||||
|
@ -47,22 +147,310 @@ xglCreatePixmap (ScreenPtr pScreen,
|
|||
pPixmap->drawable.y = 0;
|
||||
pPixmap->drawable.width = width;
|
||||
pPixmap->drawable.height = height;
|
||||
|
||||
#ifdef COMPOSITE
|
||||
pPixmap->screen_x = 0;
|
||||
pPixmap->screen_y = 0;
|
||||
#endif
|
||||
|
||||
pPixmap->devKind = 0;
|
||||
pPixmap->refcnt = 1;
|
||||
pPixmap->devPrivate.ptr = 0;
|
||||
|
||||
pPixmapPriv = XGL_GET_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
pPixmapPriv->format = pScreenPriv->pixmapFormats[depth].format;
|
||||
pPixmapPriv->pPixel = pScreenPriv->pixmapFormats[depth].pPixel;
|
||||
pPixmapPriv->pDamage = NULL;
|
||||
|
||||
if (!xglPixmapSurfaceInit (pPixmap, pScreenPriv->features, width, height))
|
||||
return NullPixmap;
|
||||
|
||||
pPixmapPriv->buffer = NULL;
|
||||
pPixmapPriv->bits = (pointer) 0;
|
||||
pPixmapPriv->stride = 0;
|
||||
|
||||
pPixmapPriv->allBits = TRUE;
|
||||
pPixmapPriv->bitBox.x1 = 0;
|
||||
pPixmapPriv->bitBox.y1 = 0;
|
||||
pPixmapPriv->bitBox.x2 = 32767;
|
||||
pPixmapPriv->bitBox.y2 = 32767;
|
||||
pPixmapPriv->damageBox = miEmptyBox;
|
||||
|
||||
return pPixmap;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglDestroyPixmap (PixmapPtr pPixmap)
|
||||
{
|
||||
if(--pPixmap->refcnt)
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
if (--pPixmap->refcnt)
|
||||
return TRUE;
|
||||
xfree(pPixmap);
|
||||
|
||||
if (pPixmapPriv->pArea)
|
||||
xglWithdrawOffscreenArea (pPixmapPriv->pArea);
|
||||
|
||||
if (pPixmap->devPrivate.ptr)
|
||||
{
|
||||
if (pPixmapPriv->buffer)
|
||||
glitz_buffer_unmap (pPixmapPriv->buffer);
|
||||
}
|
||||
|
||||
if (pPixmapPriv->buffer)
|
||||
glitz_buffer_destroy (pPixmapPriv->buffer);
|
||||
|
||||
if (pPixmapPriv->bits)
|
||||
xfree (pPixmapPriv->bits);
|
||||
|
||||
if (pPixmapPriv->surface)
|
||||
glitz_surface_destroy (pPixmapPriv->surface);
|
||||
|
||||
xfree (pPixmap);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglModifyPixmapHeader (PixmapPtr pPixmap,
|
||||
int width,
|
||||
int height,
|
||||
int depth,
|
||||
int bitsPerPixel,
|
||||
int devKind,
|
||||
pointer pPixData)
|
||||
{
|
||||
xglScreenPtr pScreenPriv;
|
||||
xglPixmapPtr pPixmapPriv;
|
||||
glitz_format_t *oldFormat;
|
||||
int oldWidth, oldHeight;
|
||||
|
||||
if (!pPixmap)
|
||||
return FALSE;
|
||||
|
||||
pScreenPriv = XGL_GET_SCREEN_PRIV (pPixmap->drawable.pScreen);
|
||||
pPixmapPriv = XGL_GET_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
oldFormat = pPixmapPriv->format;
|
||||
oldWidth = pPixmap->drawable.width;
|
||||
oldHeight = pPixmap->drawable.height;
|
||||
|
||||
if ((width > 0) && (height > 0) && (depth > 0) && (bitsPerPixel > 0) &&
|
||||
(devKind > 0) && pPixData)
|
||||
{
|
||||
pPixmap->drawable.depth = depth;
|
||||
pPixmap->drawable.bitsPerPixel = bitsPerPixel;
|
||||
pPixmap->drawable.id = 0;
|
||||
pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
|
||||
pPixmap->drawable.x = 0;
|
||||
pPixmap->drawable.y = 0;
|
||||
pPixmap->drawable.width = width;
|
||||
pPixmap->drawable.height = height;
|
||||
pPixmapPriv->stride = devKind;
|
||||
pPixmap->refcnt = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (width > 0)
|
||||
pPixmap->drawable.width = width;
|
||||
|
||||
if (height > 0)
|
||||
pPixmap->drawable.height = height;
|
||||
|
||||
if (depth > 0)
|
||||
pPixmap->drawable.depth = depth;
|
||||
|
||||
if (bitsPerPixel > 0)
|
||||
pPixmap->drawable.bitsPerPixel = bitsPerPixel;
|
||||
else if ((bitsPerPixel < 0) && (depth > 0))
|
||||
pPixmap->drawable.bitsPerPixel = BitsPerPixel (depth);
|
||||
|
||||
|
||||
if (devKind > 0)
|
||||
pPixmapPriv->stride = devKind;
|
||||
else if ((devKind < 0) && ((width > 0) || (depth > 0)))
|
||||
pPixmapPriv->stride = PixmapBytePad (pPixmap->drawable.width,
|
||||
pPixmap->drawable.depth);
|
||||
}
|
||||
|
||||
depth = pPixmap->drawable.depth;
|
||||
|
||||
pPixmapPriv->pPixel = pScreenPriv->pixmapFormats[depth].pPixel;
|
||||
pPixmapPriv->format = pScreenPriv->pixmapFormats[depth].format;
|
||||
|
||||
if (pPixmapPriv->format != oldFormat ||
|
||||
pPixmap->drawable.width != oldWidth ||
|
||||
pPixmap->drawable.height != oldHeight)
|
||||
{
|
||||
if (pPixmapPriv->pArea)
|
||||
xglWithdrawOffscreenArea (pPixmapPriv->pArea);
|
||||
|
||||
if (pPixmapPriv->surface)
|
||||
glitz_surface_destroy (pPixmapPriv->surface);
|
||||
|
||||
if (!xglPixmapSurfaceInit (pPixmap,
|
||||
pScreenPriv->features,
|
||||
pPixmap->drawable.width,
|
||||
pPixmap->drawable.height))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (pPixData)
|
||||
{
|
||||
if (pPixmap->devPrivate.ptr)
|
||||
{
|
||||
if (pPixmapPriv->buffer)
|
||||
glitz_buffer_unmap (pPixmapPriv->buffer);
|
||||
|
||||
pPixmap->devPrivate.ptr = 0;
|
||||
}
|
||||
|
||||
if (pPixmapPriv->buffer)
|
||||
glitz_buffer_destroy (pPixmapPriv->buffer);
|
||||
|
||||
if (pPixmapPriv->bits)
|
||||
xfree (pPixmapPriv->bits);
|
||||
|
||||
pPixmapPriv->bits = (pointer) 0;
|
||||
pPixmapPriv->buffer = glitz_buffer_create_for_data (pPixData);
|
||||
if (!pPixmapPriv->buffer)
|
||||
return FALSE;
|
||||
|
||||
pPixmapPriv->allBits = TRUE;
|
||||
pPixmapPriv->bitBox.x1 = 0;
|
||||
pPixmapPriv->bitBox.y1 = 0;
|
||||
pPixmapPriv->bitBox.x2 = pPixmap->drawable.width;
|
||||
pPixmapPriv->bitBox.y2 = pPixmap->drawable.height;
|
||||
|
||||
if (pPixmapPriv->pDamage)
|
||||
{
|
||||
RegionPtr pRegion;
|
||||
|
||||
pRegion = DamageRegion (pPixmapPriv->pDamage);
|
||||
|
||||
REGION_UNINIT (pPixmap->drawable.pScreen, pRegion);
|
||||
REGION_INIT (pPixmap->drawable.pScreen, pRegion,
|
||||
&pPixmapPriv->bitBox, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* We probably don't want accelerated drawing to this pixmap.
|
||||
*/
|
||||
pPixmapPriv->score = XGL_MIN_PIXMAP_SCORE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Maybe there's a nicer way to detect if this is the screen pixmap.
|
||||
*/
|
||||
if (!pScreenPriv->pScreenPixmap)
|
||||
{
|
||||
glitz_surface_reference (pScreenPriv->surface);
|
||||
|
||||
pPixmapPriv->surface = pScreenPriv->surface;
|
||||
pPixmapPriv->pPixel = pScreenPriv->pVisual[0].pPixel;
|
||||
pPixmapPriv->target = xglPixmapTargetIn;
|
||||
|
||||
pScreenPriv->pScreenPixmap = pPixmap;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglCreatePixmapSurface (PixmapPtr pPixmap)
|
||||
{
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
if (!pPixmapPriv->format)
|
||||
return FALSE;
|
||||
|
||||
if (!pPixmapPriv->surface)
|
||||
{
|
||||
XGL_SCREEN_PRIV (pPixmap->drawable.pScreen);
|
||||
|
||||
pPixmapPriv->surface =
|
||||
glitz_surface_create (pScreenPriv->drawable,
|
||||
pPixmapPriv->format,
|
||||
pPixmap->drawable.width,
|
||||
pPixmap->drawable.height);
|
||||
if (!pPixmapPriv->surface)
|
||||
{
|
||||
pPixmapPriv->format = NULL;
|
||||
pPixmapPriv->target = xglPixmapTargetNo;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglAllocatePixmapBits (PixmapPtr pPixmap)
|
||||
{
|
||||
int width, height, bpp, stride;
|
||||
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
width = pPixmap->drawable.width;
|
||||
height = pPixmap->drawable.height;
|
||||
bpp = pPixmap->drawable.bitsPerPixel;
|
||||
|
||||
stride = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof (FbBits);
|
||||
|
||||
pPixmapPriv->stride = stride;
|
||||
|
||||
if (stride)
|
||||
{
|
||||
pPixmapPriv->bits = xalloc (height * stride);
|
||||
if (!pPixmapPriv->bits)
|
||||
return FALSE;
|
||||
|
||||
pPixmapPriv->buffer =
|
||||
glitz_buffer_create_for_data (pPixmapPriv->bits);
|
||||
if (!pPixmapPriv->buffer)
|
||||
{
|
||||
xfree (pPixmapPriv->bits);
|
||||
pPixmapPriv->bits = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglMapPixmapBits (PixmapPtr pPixmap)
|
||||
{
|
||||
if (!pPixmap->devPrivate.ptr)
|
||||
{
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
if (!pPixmapPriv->buffer)
|
||||
if (!xglAllocatePixmapBits (pPixmap))
|
||||
return FALSE;
|
||||
|
||||
pPixmap->devKind = pPixmapPriv->stride;
|
||||
pPixmap->devPrivate.ptr =
|
||||
glitz_buffer_map (pPixmapPriv->buffer,
|
||||
GLITZ_BUFFER_ACCESS_READ_WRITE);
|
||||
if (!pPixmap->devPrivate.ptr)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglUnmapPixmapBits (PixmapPtr pPixmap)
|
||||
{
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
pPixmap->devKind = 0;
|
||||
pPixmap->devPrivate.ptr = 0;
|
||||
|
||||
if (pPixmapPriv->buffer)
|
||||
if (glitz_buffer_unmap (pPixmapPriv->buffer))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,303 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
* fee, provided that the above copyright notice appear in all copies
|
||||
* and that both that copyright notice and this permission notice
|
||||
* appear in supporting documentation, and that the names of
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Author: David Reveman <davidr@freedesktop.org>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
#include "inputstr.h"
|
||||
#include "mipointer.h"
|
||||
#include "damage.h"
|
||||
#include "fb.h"
|
||||
|
||||
int xglScreenGeneration = -1;
|
||||
int xglScreenPrivateIndex;
|
||||
int xglGCPrivateIndex;
|
||||
int xglPixmapPrivateIndex;
|
||||
int xglWinPrivateIndex;
|
||||
|
||||
#define xglQueryBestSize (void *) NoopDDA
|
||||
#define xglSaveScreen (void *) NoopDDA
|
||||
|
||||
#define xglRealizeFont (void *) NoopDDA
|
||||
#define xglUnrealizeFont (void *) NoopDDA
|
||||
|
||||
#define xglConstrainCursor (void *) NoopDDA
|
||||
#define xglCursorLimits (void *) NoopDDA
|
||||
#define xglDisplayCursor (void *) NoopDDA
|
||||
#define xglRealizeCursor (void *) NoopDDA
|
||||
#define xglUnrealizeCursor (void *) NoopDDA
|
||||
#define xglRecolorCursor (void *) NoopDDA
|
||||
#define xglSetCursorPosition (void *) NoopDDA
|
||||
|
||||
#define xglCreateColormap (void *) NoopDDA
|
||||
#define xglDestroyColormap (void *) NoopDDA
|
||||
#define xglInstallColormap (void *) NoopDDA
|
||||
#define xglUninstallColormap (void *) NoopDDA
|
||||
#define xglListInstalledColormaps (void *) NoopDDA
|
||||
#define xglStoreColors (void *) NoopDDA
|
||||
#define xglResolveColor (void *) NoopDDA
|
||||
#define xglBitmapToRegion (void *) NoopDDA
|
||||
|
||||
static PixmapPtr
|
||||
xglGetWindowPixmap (WindowPtr pWin)
|
||||
{
|
||||
return XGL_GET_WINDOW_PIXMAP (pWin);
|
||||
}
|
||||
|
||||
static void
|
||||
xglSetWindowPixmap (WindowPtr pWin,
|
||||
PixmapPtr pPixmap)
|
||||
{
|
||||
ScreenPtr pScreen = pWin->drawable.pScreen;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
XGL_SCREEN_UNWRAP (SetWindowPixmap);
|
||||
(*pScreen->SetWindowPixmap) (pWin, pPixmap);
|
||||
XGL_SCREEN_WRAP (SetWindowPixmap, xglSetWindowPixmap);
|
||||
|
||||
XGL_GET_WINDOW_PRIV(pWin)->pPixmap = pPixmap;
|
||||
}
|
||||
|
||||
static Bool
|
||||
xglAllocatePrivates (ScreenPtr pScreen)
|
||||
{
|
||||
xglScreenPtr pScreenPriv;
|
||||
|
||||
if (xglScreenGeneration != serverGeneration)
|
||||
{
|
||||
xglScreenPrivateIndex = AllocateScreenPrivateIndex ();
|
||||
if (xglScreenPrivateIndex < 0)
|
||||
return FALSE;
|
||||
|
||||
xglGCPrivateIndex = AllocateGCPrivateIndex ();
|
||||
if (xglGCPrivateIndex < 0)
|
||||
return FALSE;
|
||||
|
||||
xglPixmapPrivateIndex = AllocatePixmapPrivateIndex ();
|
||||
if (xglPixmapPrivateIndex < 0)
|
||||
return FALSE;
|
||||
|
||||
xglWinPrivateIndex = AllocateWindowPrivateIndex ();
|
||||
if (xglWinPrivateIndex < 0)
|
||||
return FALSE;
|
||||
|
||||
xglScreenGeneration = serverGeneration;
|
||||
}
|
||||
|
||||
if (!AllocateGCPrivate (pScreen, xglGCPrivateIndex, sizeof (xglGCRec)))
|
||||
return FALSE;
|
||||
|
||||
if (!AllocatePixmapPrivate (pScreen, xglPixmapPrivateIndex,
|
||||
sizeof (xglPixmapRec)))
|
||||
return FALSE;
|
||||
|
||||
if (!AllocateWindowPrivate (pScreen, xglWinPrivateIndex,
|
||||
sizeof (xglWinRec)))
|
||||
return FALSE;
|
||||
|
||||
pScreenPriv = xalloc (sizeof (xglScreenRec));
|
||||
if (!pScreenPriv)
|
||||
return FALSE;
|
||||
|
||||
XGL_SET_SCREEN_PRIV (pScreen, pScreenPriv);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglScreenInit (ScreenPtr pScreen,
|
||||
xglScreenInfoPtr pScreenInfo)
|
||||
{
|
||||
xglScreenPtr pScreenPriv;
|
||||
|
||||
#ifdef RENDER
|
||||
PictureScreenPtr pPictureScreen;
|
||||
#endif
|
||||
|
||||
if (!xglAllocatePrivates (pScreen))
|
||||
return FALSE;
|
||||
|
||||
pScreenPriv = XGL_GET_SCREEN_PRIV (pScreen);
|
||||
|
||||
pScreenPriv->pScreenPixmap = NULL;
|
||||
|
||||
pScreenPriv->pVisual = &xglVisuals[0];
|
||||
pScreenPriv->drawable = pScreenInfo->drawable;
|
||||
pScreenPriv->features =
|
||||
glitz_drawable_get_features (pScreenInfo->drawable);
|
||||
|
||||
if (!xglInitOffscreen (pScreen, pScreenInfo))
|
||||
return FALSE;
|
||||
|
||||
xglInitPixmapFormats (pScreen);
|
||||
if (!pScreenPriv->pixmapFormats[32].format)
|
||||
return FALSE;
|
||||
|
||||
pScreenPriv->surface =
|
||||
glitz_surface_create (pScreenPriv->drawable,
|
||||
pScreenPriv->pixmapFormats[32].format,
|
||||
pScreenInfo->width, pScreenInfo->height);
|
||||
if (!pScreenPriv->surface)
|
||||
return FALSE;
|
||||
|
||||
glitz_surface_attach (pScreenPriv->surface,
|
||||
pScreenPriv->drawable,
|
||||
GLITZ_DRAWABLE_BUFFER_FRONT_COLOR,
|
||||
0, 0);
|
||||
|
||||
if (monitorResolution == 0)
|
||||
monitorResolution = XGL_DEFAULT_DPI;
|
||||
|
||||
if (!fbSetupScreen (pScreen, NULL,
|
||||
pScreenInfo->width, pScreenInfo->height,
|
||||
monitorResolution, monitorResolution,
|
||||
pScreenInfo->width,
|
||||
pScreenPriv->pVisual->pPixel->masks.bpp))
|
||||
return FALSE;
|
||||
|
||||
pScreen->SaveScreen = xglSaveScreen;
|
||||
|
||||
pScreen->CreatePixmap = xglCreatePixmap;
|
||||
pScreen->DestroyPixmap = xglDestroyPixmap;
|
||||
|
||||
if (!fbFinishScreenInit (pScreen, NULL,
|
||||
pScreenInfo->width, pScreenInfo->height,
|
||||
monitorResolution, monitorResolution,
|
||||
pScreenInfo->width,
|
||||
pScreenPriv->pVisual->pPixel->masks.bpp))
|
||||
return FALSE;
|
||||
|
||||
#ifdef RENDER
|
||||
if (!fbPictureInit (pScreen, 0, 0))
|
||||
return FALSE;
|
||||
#endif
|
||||
|
||||
XGL_SCREEN_WRAP (GetImage, xglGetImage);
|
||||
XGL_SCREEN_WRAP (GetSpans, xglGetSpans);
|
||||
|
||||
XGL_SCREEN_WRAP (CopyWindow, xglCopyWindow);
|
||||
XGL_SCREEN_WRAP (CreateWindow, xglCreateWindow);
|
||||
XGL_SCREEN_WRAP (PaintWindowBackground, xglPaintWindowBackground);
|
||||
XGL_SCREEN_WRAP (PaintWindowBorder, xglPaintWindowBorder);
|
||||
|
||||
/*
|
||||
pScreen->RealizeFont = xglRealizeFont;
|
||||
pScreen->UnrealizeFont = xglUnrealizeFont;
|
||||
*/
|
||||
|
||||
XGL_SCREEN_WRAP (CreateGC, xglCreateGC);
|
||||
|
||||
pScreen->ConstrainCursor = xglConstrainCursor;
|
||||
pScreen->CursorLimits = xglCursorLimits;
|
||||
pScreen->DisplayCursor = xglDisplayCursor;
|
||||
pScreen->RealizeCursor = xglRealizeCursor;
|
||||
pScreen->UnrealizeCursor = xglUnrealizeCursor;
|
||||
pScreen->RecolorCursor = xglRecolorCursor;
|
||||
pScreen->SetCursorPosition = xglSetCursorPosition;
|
||||
|
||||
/*
|
||||
pScreen->CreateColormap = miInitializeColormap;
|
||||
pScreen->DestroyColormap = xglDestroyColormap;
|
||||
pScreen->InstallColormap = miInstallColormap;
|
||||
pScreen->UninstallColormap = miUninstallColormap;
|
||||
pScreen->ListInstalledColormaps = miListInstalledColormaps;
|
||||
pScreen->StoreColors = xglStoreColors;
|
||||
pScreen->ResolveColor = miResolveColor;
|
||||
*/
|
||||
|
||||
/*
|
||||
pScreen->BitmapToRegion = xglBitmapToRegion;
|
||||
*/
|
||||
|
||||
pScreen->ModifyPixmapHeader = xglModifyPixmapHeader;
|
||||
|
||||
pScreen->GetWindowPixmap = xglGetWindowPixmap;
|
||||
|
||||
XGL_SCREEN_WRAP (SetWindowPixmap, xglSetWindowPixmap);
|
||||
|
||||
#ifdef RENDER
|
||||
pPictureScreen = GetPictureScreenIfSet (pScreen);
|
||||
if (pPictureScreen) {
|
||||
XGL_PICTURE_SCREEN_WRAP (Composite, xglComposite);
|
||||
XGL_PICTURE_SCREEN_WRAP (Glyphs, xglGlyphs);
|
||||
XGL_PICTURE_SCREEN_WRAP (RasterizeTrapezoid, xglRasterizeTrapezoid);
|
||||
XGL_PICTURE_SCREEN_WRAP (ChangePicture, xglChangePicture);
|
||||
XGL_PICTURE_SCREEN_WRAP (ChangePictureTransform,
|
||||
xglChangePictureTransform);
|
||||
XGL_PICTURE_SCREEN_WRAP (ChangePictureFilter, xglChangePictureFilter);
|
||||
}
|
||||
#endif
|
||||
|
||||
XGL_SCREEN_WRAP (BackingStoreFuncs.SaveAreas, xglSaveAreas);
|
||||
XGL_SCREEN_WRAP (BackingStoreFuncs.RestoreAreas, xglRestoreAreas);
|
||||
|
||||
/* Damage is required */
|
||||
DamageSetup (pScreen);
|
||||
|
||||
XGL_SCREEN_WRAP (CloseScreen, xglCloseScreen);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglFinishScreenInit (ScreenPtr pScreen)
|
||||
{
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
miInitializeBackingStore (pScreen);
|
||||
|
||||
if (!fbCreateDefColormap (pScreen))
|
||||
return FALSE;
|
||||
|
||||
pScreenPriv->solid =
|
||||
glitz_surface_create (pScreenPriv->drawable,
|
||||
pScreenPriv->pixmapFormats[32].format,
|
||||
1, 1);
|
||||
if (!pScreenPriv->solid)
|
||||
return FALSE;
|
||||
|
||||
glitz_surface_set_fill (pScreenPriv->solid, GLITZ_FILL_REPEAT);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglCloseScreen (int index,
|
||||
ScreenPtr pScreen)
|
||||
{
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
if (pScreenPriv->solid)
|
||||
glitz_surface_destroy (pScreenPriv->solid);
|
||||
|
||||
if (pScreenPriv->surface)
|
||||
glitz_surface_destroy (pScreenPriv->surface);
|
||||
|
||||
xglFiniOffscreen (pScreen);
|
||||
|
||||
XGL_SCREEN_UNWRAP (CloseScreen);
|
||||
xfree (pScreenPriv);
|
||||
|
||||
return (*pScreen->CloseScreen) (index, pScreen);
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
* fee, provided that the above copyright notice appear in all copies
|
||||
* and that both that copyright notice and this permission notice
|
||||
* appear in supporting documentation, and that the names of
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Author: David Reveman <davidr@freedesktop.org>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
|
||||
Bool
|
||||
xglSolid (DrawablePtr pDrawable,
|
||||
glitz_operator_t op,
|
||||
glitz_color_t *color,
|
||||
xglGeometryPtr pGeometry,
|
||||
BoxPtr pBox,
|
||||
int nBox)
|
||||
{
|
||||
glitz_surface_t *surface;
|
||||
int xOff, yOff;
|
||||
|
||||
XGL_SCREEN_PRIV (pDrawable->pScreen);
|
||||
|
||||
if (!xglPrepareTarget (pDrawable))
|
||||
return FALSE;
|
||||
|
||||
XGL_GET_DRAWABLE (pDrawable, surface, xOff, yOff);
|
||||
|
||||
glitz_set_rectangle (pScreenPriv->solid, color, 0, 0, 1, 1);
|
||||
|
||||
GEOMETRY_TRANSLATE (pGeometry, xOff, yOff);
|
||||
|
||||
if (!GEOMETRY_ENABLE_ALL_VERTICES (pGeometry, surface))
|
||||
return FALSE;
|
||||
|
||||
while (nBox--)
|
||||
{
|
||||
glitz_composite (op,
|
||||
pScreenPriv->solid, NULL, surface,
|
||||
0, 0,
|
||||
0, 0,
|
||||
pBox->x1 + xOff,
|
||||
pBox->y1 + yOff,
|
||||
pBox->x2 - pBox->x1, pBox->y2 - pBox->y1);
|
||||
|
||||
pBox++;
|
||||
}
|
||||
|
||||
if (glitz_surface_get_status (surface))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright © 2004 Keith Packard
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Keith Packard not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Keith Packard makes no
|
||||
* representations about the suitability of this software for any purpose. It
|
||||
* is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
|
||||
void
|
||||
xglFillSpans (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
int n,
|
||||
DDXPointPtr ppt,
|
||||
int *pwidth,
|
||||
int fSorted)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
xglSetSpans (DrawablePtr pDrawable,
|
||||
GCPtr pGC,
|
||||
char *src,
|
||||
DDXPointPtr ppt,
|
||||
int *pwidth,
|
||||
int nspans,
|
||||
int fSorted)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
xglGetSpans(DrawablePtr pDrawable,
|
||||
int wMax,
|
||||
DDXPointPtr ppt,
|
||||
int *pwidth,
|
||||
int nspans,
|
||||
char *pchardstStart)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
xglPushPixels (GCPtr pGC,
|
||||
PixmapPtr pBitmap,
|
||||
DrawablePtr pDrawable,
|
||||
int dx,
|
||||
int dy,
|
||||
int xOrg,
|
||||
int yOrg)
|
||||
{
|
||||
}
|
|
@ -0,0 +1,341 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
* fee, provided that the above copyright notice appear in all copies
|
||||
* and that both that copyright notice and this permission notice
|
||||
* appear in supporting documentation, and that the names of
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Author: David Reveman <davidr@freedesktop.org>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
|
||||
/*
|
||||
* A pixmap may exist both in hardware and in software. Synchronization
|
||||
* is handled as follows:
|
||||
*
|
||||
* Regions modified by software and hardware needs to be tracked.
|
||||
* A software operation requires that a rectangle of pixels matching the
|
||||
* extents of the operation is synchronized. A hardware operation
|
||||
* requires that all pixels are synchronized. If the bounds of a
|
||||
* hardware operation intersects the bounds of a currently synchronized
|
||||
* software rectangle, the software rectangle will be discarded and the
|
||||
* next software operation will require re-synchronization.
|
||||
*
|
||||
* A software rectangle of pixels is synchronized as follows. If a
|
||||
* previously synchronized rectangle exists, then if this previous
|
||||
* rectangle subsumes our new rectangle no pixels are fetched from
|
||||
* hardware as all pixels that need to be synchronized are already up to
|
||||
* date. If a previously synchronized rectangle exists and it intersects
|
||||
* with our new rectangle, then both these rectangles are merged into a
|
||||
* larger rectangle and pixels not part of the previous rectangle are
|
||||
* fetched form hardware. If a previously synchronized rectangle exists
|
||||
* and it doesn't intersect with our new rectangle, then the previous
|
||||
* rectangle is discarded and pixels are fetched from hardware so that
|
||||
* our new rectangle becomes synchronized.
|
||||
*
|
||||
* If the pixmap exists in hardware and if it can be a target of a
|
||||
* drawing operation, then it is kept synchronized all the time, any
|
||||
* pixels modified by software will be transfered to hardware right
|
||||
* away. If the pixmap exists in hardware but it can only be used as
|
||||
* source of a drawing operation, then synchronization is performed
|
||||
* only when needed.
|
||||
*/
|
||||
|
||||
#define ALL_BITS(pPixmap, pBox) \
|
||||
((pBox)->x1 <= 0 && (pBox)->y1 <= 0 && \
|
||||
(pBox)->x2 >= (pPixmap)->drawable.width && \
|
||||
(pBox)->y2 >= (pPixmap)->drawable.height)
|
||||
|
||||
Bool
|
||||
xglSyncBits (DrawablePtr pDrawable,
|
||||
BoxPtr pExtents)
|
||||
{
|
||||
RegionRec region;
|
||||
BoxPtr pBitBox;
|
||||
BoxRec box;
|
||||
|
||||
XGL_DRAWABLE_PIXMAP (pDrawable);
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
XGL_DECREMENT_PIXMAP_SCORE (pPixmapPriv, 20);
|
||||
|
||||
if (pPixmapPriv->allBits)
|
||||
return xglMapPixmapBits (pPixmap);
|
||||
|
||||
pBitBox = &pPixmapPriv->bitBox;
|
||||
|
||||
if (pExtents)
|
||||
{
|
||||
box.x1 = MAX (0, pExtents->x1);
|
||||
box.y1 = MAX (0, pExtents->y1);
|
||||
box.x2 = MAX (0, MIN (pPixmap->drawable.width, pExtents->x2));
|
||||
box.y2 = MAX (0, MIN (pPixmap->drawable.height, pExtents->y2));
|
||||
|
||||
if (!BOX_NOTEMPTY (&box))
|
||||
return xglMapPixmapBits (pPixmap);
|
||||
|
||||
if (BOX_NOTEMPTY (pBitBox))
|
||||
{
|
||||
RegionRec bitRegion;
|
||||
|
||||
REGION_INIT (pDrawable->pScreen, &bitRegion, pBitBox, 1);
|
||||
|
||||
switch (RECT_IN_REGION (pDrawable->pScreen, &bitRegion, &box)) {
|
||||
case rgnIN:
|
||||
REGION_INIT (pDrawable->pScreen, ®ion, NullBox, 0);
|
||||
break;
|
||||
case rgnOUT:
|
||||
REGION_INIT (pDrawable->pScreen, ®ion, &box, 1);
|
||||
*pBitBox = box;
|
||||
pPixmapPriv->allBits = ALL_BITS (pPixmap, pBitBox);
|
||||
break;
|
||||
case rgnPART:
|
||||
pBitBox->x1 = MIN (pBitBox->x1, box.x1);
|
||||
pBitBox->y1 = MIN (pBitBox->y1, box.y1);
|
||||
pBitBox->x2 = MAX (pBitBox->x2, box.x2);
|
||||
pBitBox->y2 = MAX (pBitBox->y2, box.y2);
|
||||
pPixmapPriv->allBits = ALL_BITS (pPixmap, pBitBox);
|
||||
|
||||
REGION_INIT (pDrawable->pScreen, ®ion, pBitBox, 1);
|
||||
REGION_SUBTRACT (pDrawable->pScreen, ®ion, ®ion,
|
||||
&bitRegion);
|
||||
|
||||
break;
|
||||
}
|
||||
REGION_UNINIT (pDrawable->pScreen, &bitRegion);
|
||||
}
|
||||
else
|
||||
{
|
||||
REGION_INIT (pDrawable->pScreen, ®ion, &box, 1);
|
||||
*pBitBox = box;
|
||||
pPixmapPriv->allBits = ALL_BITS (pPixmap, pBitBox);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
box.x1 = 0;
|
||||
box.y1 = 0;
|
||||
box.x2 = pPixmap->drawable.width;
|
||||
box.y2 = pPixmap->drawable.height;
|
||||
|
||||
REGION_INIT (pDrawable->pScreen, ®ion, &box, 1);
|
||||
|
||||
if (BOX_NOTEMPTY (pBitBox))
|
||||
{
|
||||
RegionRec bitRegion;
|
||||
|
||||
REGION_INIT (pDrawable->pScreen, &bitRegion, pBitBox, 1);
|
||||
REGION_SUBTRACT (pDrawable->pScreen, ®ion, ®ion, &bitRegion);
|
||||
REGION_UNINIT (pDrawable->pScreen, &bitRegion);
|
||||
}
|
||||
|
||||
*pBitBox = box;
|
||||
pPixmapPriv->allBits = TRUE;
|
||||
}
|
||||
|
||||
if (!pPixmapPriv->buffer)
|
||||
if (!xglAllocatePixmapBits (pPixmap))
|
||||
return FALSE;
|
||||
|
||||
if (REGION_NOTEMPTY (pDrawable->pScreen, ®ion))
|
||||
{
|
||||
if (pPixmapPriv->surface)
|
||||
{
|
||||
glitz_pixel_format_t format;
|
||||
BoxPtr pBox;
|
||||
int nBox;
|
||||
|
||||
xglUnmapPixmapBits (pPixmap);
|
||||
|
||||
pBox = REGION_RECTS (®ion);
|
||||
nBox = REGION_NUM_RECTS (®ion);
|
||||
|
||||
format.masks = pPixmapPriv->pPixel->masks;
|
||||
format.bytes_per_line = pPixmapPriv->stride;
|
||||
format.scanline_order = XGL_INTERNAL_SCANLINE_ORDER;
|
||||
|
||||
while (nBox--)
|
||||
{
|
||||
format.xoffset = pBox->x1;
|
||||
format.skip_lines = pBox->y1;
|
||||
|
||||
glitz_get_pixels (pPixmapPriv->surface,
|
||||
pBox->x1,
|
||||
pBox->y1,
|
||||
pBox->x2 - pBox->x1,
|
||||
pBox->y2 - pBox->y1,
|
||||
&format,
|
||||
pPixmapPriv->buffer);
|
||||
|
||||
pBox++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
REGION_UNINIT (pDrawable->pScreen, ®ion);
|
||||
|
||||
return xglMapPixmapBits (pPixmap);
|
||||
}
|
||||
|
||||
void
|
||||
xglSyncDamageBoxBits (DrawablePtr pDrawable)
|
||||
{
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
|
||||
|
||||
if (!xglSyncBits (pDrawable, &pPixmapPriv->damageBox))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
}
|
||||
|
||||
Bool
|
||||
xglSyncSurface (DrawablePtr pDrawable)
|
||||
{
|
||||
RegionPtr pRegion;
|
||||
|
||||
XGL_DRAWABLE_PIXMAP (pDrawable);
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
if (!pPixmapPriv->surface)
|
||||
{
|
||||
if (!pPixmapPriv->format)
|
||||
return FALSE;
|
||||
|
||||
if (!xglCreatePixmapSurface (pPixmap))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!pPixmapPriv->pDamage)
|
||||
return TRUE;
|
||||
|
||||
pRegion = DamageRegion (pPixmapPriv->pDamage);
|
||||
|
||||
if (REGION_NOTEMPTY (pDrawable->pScreen, pRegion))
|
||||
{
|
||||
glitz_pixel_format_t format;
|
||||
BoxPtr pBox;
|
||||
int nBox;
|
||||
|
||||
xglUnmapPixmapBits (pPixmap);
|
||||
|
||||
nBox = REGION_NUM_RECTS (pRegion);
|
||||
pBox = REGION_RECTS (pRegion);
|
||||
|
||||
format.masks = pPixmapPriv->pPixel->masks;
|
||||
format.bytes_per_line = pPixmapPriv->stride;
|
||||
format.scanline_order = XGL_INTERNAL_SCANLINE_ORDER;
|
||||
|
||||
while (nBox--)
|
||||
{
|
||||
format.xoffset = pBox->x1;
|
||||
format.skip_lines = pBox->y1;
|
||||
|
||||
glitz_set_pixels (pPixmapPriv->surface,
|
||||
pBox->x1,
|
||||
pBox->y1,
|
||||
pBox->x2 - pBox->x1,
|
||||
pBox->y2 - pBox->y1,
|
||||
&format,
|
||||
pPixmapPriv->buffer);
|
||||
|
||||
pBox++;
|
||||
}
|
||||
|
||||
REGION_EMPTY (pDrawable->pScreen, pRegion);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
xglPrepareTarget (DrawablePtr pDrawable)
|
||||
{
|
||||
XGL_DRAWABLE_PIXMAP (pDrawable);
|
||||
XGL_PIXMAP_PRIV (pPixmap);
|
||||
|
||||
switch (pPixmapPriv->target) {
|
||||
case xglPixmapTargetNo:
|
||||
break;
|
||||
case xglPixmapTargetIn:
|
||||
XGL_INCREMENT_PIXMAP_SCORE (pPixmapPriv, 10);
|
||||
|
||||
if (xglSyncSurface (pDrawable))
|
||||
return TRUE;
|
||||
break;
|
||||
case xglPixmapTargetOut:
|
||||
XGL_INCREMENT_PIXMAP_SCORE (pPixmapPriv, 10);
|
||||
|
||||
if (xglFindOffscreenArea (pDrawable->pScreen, pPixmap))
|
||||
return TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
xglAddSurfaceDamage (DrawablePtr pDrawable)
|
||||
{
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
|
||||
|
||||
if (!pPixmapPriv->format)
|
||||
{
|
||||
pPixmapPriv->damageBox = miEmptyBox;
|
||||
return;
|
||||
}
|
||||
|
||||
if (BOX_NOTEMPTY (&pPixmapPriv->damageBox))
|
||||
{
|
||||
RegionPtr pDamageRegion;
|
||||
RegionRec region;
|
||||
|
||||
pDamageRegion = DamageRegion (pPixmapPriv->pDamage);
|
||||
|
||||
REGION_INIT (pDrawable->pScreen, ®ion, &pPixmapPriv->damageBox, 1);
|
||||
REGION_UNION (pDrawable->pScreen,
|
||||
pDamageRegion, pDamageRegion, ®ion);
|
||||
REGION_UNINIT (pDrawable->pScreen, ®ion);
|
||||
|
||||
if (pPixmapPriv->target == xglPixmapTargetIn)
|
||||
{
|
||||
if (!xglSyncSurface (pDrawable))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
}
|
||||
|
||||
pPixmapPriv->damageBox = miEmptyBox;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
xglAddBitDamage (DrawablePtr pDrawable)
|
||||
{
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
|
||||
|
||||
if (BOX_NOTEMPTY (&pPixmapPriv->bitBox))
|
||||
{
|
||||
if (pPixmapPriv->damageBox.x1 > pPixmapPriv->bitBox.x2 ||
|
||||
pPixmapPriv->damageBox.y1 > pPixmapPriv->bitBox.y2 ||
|
||||
pPixmapPriv->damageBox.x2 < pPixmapPriv->bitBox.x1 ||
|
||||
pPixmapPriv->damageBox.y2 < pPixmapPriv->bitBox.y1)
|
||||
return;
|
||||
|
||||
pPixmapPriv->bitBox = miEmptyBox;
|
||||
pPixmapPriv->allBits = FALSE;
|
||||
}
|
||||
|
||||
pPixmapPriv->damageBox = miEmptyBox;
|
||||
}
|
|
@ -0,0 +1,200 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
* fee, provided that the above copyright notice appear in all copies
|
||||
* and that both that copyright notice and this permission notice
|
||||
* appear in supporting documentation, and that the names of
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Author: David Reveman <davidr@freedesktop.org>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
|
||||
|
||||
Bool
|
||||
xglTile (DrawablePtr pDrawable,
|
||||
glitz_operator_t op,
|
||||
PixmapPtr pTile,
|
||||
int tileX,
|
||||
int tileY,
|
||||
xglGeometryPtr pGeometry,
|
||||
BoxPtr pBox,
|
||||
int nBox)
|
||||
{
|
||||
xglPixmapPtr pTilePriv;
|
||||
glitz_surface_t *surface;
|
||||
int xOff, yOff;
|
||||
|
||||
if (!xglSyncSurface (&pTile->drawable))
|
||||
return FALSE;
|
||||
|
||||
if (!xglPrepareTarget (pDrawable))
|
||||
return FALSE;
|
||||
|
||||
XGL_GET_DRAWABLE (pDrawable, surface, xOff, yOff);
|
||||
|
||||
GEOMETRY_TRANSLATE (pGeometry, xOff, yOff);
|
||||
|
||||
if (!GEOMETRY_ENABLE_ALL_VERTICES (pGeometry, surface))
|
||||
return FALSE;
|
||||
|
||||
pTilePriv = XGL_GET_PIXMAP_PRIV (pTile);
|
||||
|
||||
pTilePriv->pictureMask |=
|
||||
xglPCFillMask | xglPCFilterMask | xglPCTransformMask;
|
||||
|
||||
glitz_surface_set_filter (pTilePriv->surface, GLITZ_FILTER_NEAREST,
|
||||
NULL, 0);
|
||||
glitz_surface_set_transform (pTilePriv->surface, NULL);
|
||||
|
||||
if (pTilePriv->acceleratedTile)
|
||||
{
|
||||
glitz_surface_set_fill (pTilePriv->surface, GLITZ_FILL_REPEAT);
|
||||
|
||||
while (nBox--)
|
||||
{
|
||||
glitz_composite (op,
|
||||
pTilePriv->surface, NULL, surface,
|
||||
pBox->x1 + tileX,
|
||||
pBox->y1 + tileY,
|
||||
0, 0,
|
||||
pBox->x1 + xOff,
|
||||
pBox->y1 + yOff,
|
||||
pBox->x2 - pBox->x1, pBox->y2 - pBox->y1);
|
||||
|
||||
pBox++;
|
||||
}
|
||||
|
||||
if (!glitz_surface_get_status (surface))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
glitz_surface_set_fill (pTilePriv->surface, GLITZ_FILL_TRANSPARENT);
|
||||
|
||||
/*
|
||||
* Don't allow software tile with really small pixmaps.
|
||||
*/
|
||||
if (pTile->drawable.width < 8 && pTile->drawable.height < 8)
|
||||
return FALSE;
|
||||
|
||||
xglSwTile (op,
|
||||
pTilePriv->surface, NULL, surface,
|
||||
tileX - xOff, tileY - yOff,
|
||||
0, 0,
|
||||
TILE_SOURCE,
|
||||
pBox, nBox,
|
||||
xOff, yOff);
|
||||
|
||||
if (glitz_surface_get_status (surface))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
xglSwTile (glitz_operator_t op,
|
||||
glitz_surface_t *srcSurface,
|
||||
glitz_surface_t *maskSurface,
|
||||
glitz_surface_t *dstSurface,
|
||||
int xSrc,
|
||||
int ySrc,
|
||||
int xMask,
|
||||
int yMask,
|
||||
int what,
|
||||
BoxPtr pBox,
|
||||
int nBox,
|
||||
int xOff,
|
||||
int yOff)
|
||||
{
|
||||
int tileX, tileY;
|
||||
int tileWidth, tileHeight;
|
||||
|
||||
if (what == TILE_MASK) {
|
||||
tileX = xMask;
|
||||
tileY = yMask;
|
||||
tileWidth = glitz_surface_get_width (maskSurface);
|
||||
tileHeight = glitz_surface_get_height (maskSurface);
|
||||
} else {
|
||||
tileX = xSrc;
|
||||
tileY = ySrc;
|
||||
tileWidth = glitz_surface_get_width (srcSurface);
|
||||
tileHeight = glitz_surface_get_height (srcSurface);
|
||||
}
|
||||
|
||||
while (nBox--)
|
||||
{
|
||||
int x, y, width, height;
|
||||
int xTile, yTile;
|
||||
int widthTile, heightTile;
|
||||
int widthTmp, xTmp, yTmp, xTileTmp;
|
||||
|
||||
x = pBox->x1 + xOff;
|
||||
y = pBox->y1 + yOff;
|
||||
width = pBox->x2 - pBox->x1;
|
||||
height = pBox->y2 - pBox->y1;
|
||||
|
||||
xTile = MOD (tileX + x, tileWidth);
|
||||
yTile = MOD (tileY + y, tileHeight);
|
||||
|
||||
yTmp = y;
|
||||
|
||||
while (height)
|
||||
{
|
||||
heightTile = MIN (tileHeight - yTile, height);
|
||||
|
||||
xTileTmp = xTile;
|
||||
widthTmp = width;
|
||||
xTmp = x;
|
||||
|
||||
while (widthTmp)
|
||||
{
|
||||
widthTile = MIN (tileWidth - xTileTmp, widthTmp);
|
||||
|
||||
if (what == TILE_MASK)
|
||||
{
|
||||
glitz_composite (op,
|
||||
srcSurface, maskSurface, dstSurface,
|
||||
xSrc + xTmp, ySrc + yTmp,
|
||||
xTileTmp, yTile,
|
||||
xTmp, yTmp,
|
||||
widthTile, heightTile);
|
||||
}
|
||||
else
|
||||
{
|
||||
glitz_composite (op,
|
||||
srcSurface, maskSurface, dstSurface,
|
||||
xTileTmp, yTile,
|
||||
xMask + xTmp, yMask + yTmp,
|
||||
xTmp, yTmp,
|
||||
widthTile, heightTile);
|
||||
}
|
||||
|
||||
xTileTmp = 0;
|
||||
xTmp += widthTile;
|
||||
widthTmp -= widthTile;
|
||||
|
||||
}
|
||||
|
||||
yTile = 0;
|
||||
yTmp += heightTile;
|
||||
height -= heightTile;
|
||||
}
|
||||
|
||||
pBox++;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,273 @@
|
|||
/*
|
||||
* Copyright © 2004 David Reveman
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
* fee, provided that the above copyright notice appear in all copies
|
||||
* and that both that copyright notice and this permission notice
|
||||
* appear in supporting documentation, and that the names of
|
||||
* David Reveman not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* David Reveman makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* DAVID REVEMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL DAVID REVEMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Author: David Reveman <davidr@freedesktop.org>
|
||||
*/
|
||||
|
||||
#include "xgl.h"
|
||||
#include "fb.h"
|
||||
|
||||
#define XGL_WINDOW_FALLBACK_PROLOGUE(pWin, func) \
|
||||
xglSyncDamageBoxBits (&pWin->drawable); \
|
||||
XGL_SCREEN_UNWRAP (func)
|
||||
|
||||
#define XGL_WINDOW_FALLBACK_EPILOGUE(pWin, func, xglfunc) \
|
||||
XGL_SCREEN_WRAP (func, xglfunc); \
|
||||
xglAddSurfaceDamage (&pWin->drawable)
|
||||
|
||||
Bool
|
||||
xglCreateWindow (WindowPtr pWin)
|
||||
{
|
||||
ScreenPtr pScreen = pWin->drawable.pScreen;
|
||||
Bool ret;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
XGL_WINDOW_PRIV (pWin);
|
||||
|
||||
XGL_SCREEN_UNWRAP (CreateWindow);
|
||||
ret = (*pScreen->CreateWindow) (pWin);
|
||||
XGL_SCREEN_WRAP (CreateWindow, xglCreateWindow);
|
||||
|
||||
pWinPriv->pPixmap = pWin->drawable.pScreen->devPrivate;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
xglCopyWindow (WindowPtr pWin,
|
||||
DDXPointRec ptOldOrg,
|
||||
RegionPtr prgnSrc)
|
||||
{
|
||||
ScreenPtr pScreen = pWin->drawable.pScreen;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
if (XGL_GET_DRAWABLE_PIXMAP_PRIV (&pWin->drawable)->target)
|
||||
{
|
||||
PixmapPtr pPixmap;
|
||||
RegionRec rgnDst;
|
||||
int dx, dy;
|
||||
Bool ret;
|
||||
|
||||
pPixmap = XGL_GET_WINDOW_PIXMAP (pWin);
|
||||
|
||||
dx = ptOldOrg.x - pWin->drawable.x;
|
||||
dy = ptOldOrg.y - pWin->drawable.y;
|
||||
|
||||
REGION_TRANSLATE (pScreen, prgnSrc, -dx, -dy);
|
||||
REGION_INIT (pScreen, &rgnDst, NullBox, 0);
|
||||
REGION_INTERSECT (pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
|
||||
|
||||
#ifdef COMPOSITE
|
||||
if (pPixmap->screen_x || pPixmap->screen_y)
|
||||
REGION_TRANSLATE (pWin->drawable.pScreen, &rgnDst,
|
||||
-pPixmap->screen_x, -pPixmap->screen_y);
|
||||
#endif
|
||||
|
||||
ret = TRUE;
|
||||
fbCopyRegion (&pWin->drawable, &pWin->drawable,
|
||||
0, &rgnDst, dx, dy, xglCopyProc, 0, (void *) &ret);
|
||||
|
||||
REGION_UNINIT (pScreen, &rgnDst);
|
||||
|
||||
if (ret)
|
||||
{
|
||||
xglAddBitDamage (&pWin->drawable);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef COMPOSITE
|
||||
if (pPixmap->screen_x || pPixmap->screen_y)
|
||||
REGION_TRANSLATE (pWin->drawable.pScreen, &rgnDst,
|
||||
pPixmap->screen_x, pPixmap->screen_y);
|
||||
#endif
|
||||
|
||||
REGION_TRANSLATE (pScreen, prgnSrc, dx, dy);
|
||||
}
|
||||
|
||||
if (!xglSyncBits (&pWin->drawable, NullBox))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
|
||||
XGL_WINDOW_FALLBACK_PROLOGUE (pWin, CopyWindow);
|
||||
(*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc);
|
||||
XGL_WINDOW_FALLBACK_EPILOGUE (pWin, CopyWindow, xglCopyWindow);
|
||||
}
|
||||
|
||||
static Bool
|
||||
xglFillRegionSolid (DrawablePtr pDrawable,
|
||||
RegionPtr pRegion,
|
||||
Pixel pixel)
|
||||
{
|
||||
ScreenPtr pScreen = pDrawable->pScreen;
|
||||
xglGeometryRec geometry;
|
||||
glitz_color_t color;
|
||||
|
||||
XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
|
||||
|
||||
if (!pPixmapPriv->target)
|
||||
return FALSE;
|
||||
|
||||
xglPixelToColor (pPixmapPriv->pPixel, pixel, &color);
|
||||
|
||||
GEOMETRY_INIT (pScreen, &geometry, REGION_NUM_RECTS (pRegion) << 3);
|
||||
GEOMETRY_ADD_REGION (pScreen, &geometry, pRegion);
|
||||
|
||||
if (xglSolid (pDrawable,
|
||||
GLITZ_OPERATOR_SRC,
|
||||
&color,
|
||||
&geometry,
|
||||
REGION_EXTENTS (pScreen, pRegion), 1))
|
||||
{
|
||||
GEOMETRY_UNINIT (&geometry);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GEOMETRY_UNINIT (&geometry);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static Bool
|
||||
xglFillRegionTiled (DrawablePtr pDrawable,
|
||||
RegionPtr pRegion,
|
||||
PixmapPtr pTile,
|
||||
int tileX,
|
||||
int tileY)
|
||||
{
|
||||
ScreenPtr pScreen = pDrawable->pScreen;
|
||||
xglGeometryRec geometry;
|
||||
|
||||
if (!XGL_GET_DRAWABLE_PIXMAP_PRIV (pDrawable)->target)
|
||||
return FALSE;
|
||||
|
||||
GEOMETRY_INIT (pScreen, &geometry, REGION_NUM_RECTS (pRegion) << 3);
|
||||
GEOMETRY_ADD_REGION (pScreen, &geometry, pRegion);
|
||||
|
||||
if (xglTile (pDrawable,
|
||||
GLITZ_OPERATOR_SRC,
|
||||
pTile,
|
||||
tileX, tileY,
|
||||
&geometry,
|
||||
REGION_EXTENTS (pScreen, pRegion), 1))
|
||||
{
|
||||
GEOMETRY_UNINIT (&geometry);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GEOMETRY_UNINIT (&geometry);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
xglPaintWindowBackground (WindowPtr pWin,
|
||||
RegionPtr pRegion,
|
||||
int what)
|
||||
{
|
||||
ScreenPtr pScreen = pWin->drawable.pScreen;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
switch (pWin->backgroundState) {
|
||||
case None:
|
||||
return;
|
||||
case ParentRelative:
|
||||
do {
|
||||
pWin = pWin->parent;
|
||||
} while (pWin->backgroundState == ParentRelative);
|
||||
|
||||
(*pScreen->PaintWindowBackground) (pWin, pRegion, what);
|
||||
return;
|
||||
case BackgroundPixmap:
|
||||
if (xglFillRegionTiled (&pWin->drawable,
|
||||
pRegion,
|
||||
pWin->background.pixmap,
|
||||
-pWin->drawable.x,
|
||||
-pWin->drawable.y))
|
||||
{
|
||||
xglAddBitDamage (&pWin->drawable);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!xglSyncBits (&pWin->background.pixmap->drawable, NullBox))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
break;
|
||||
case BackgroundPixel:
|
||||
if (xglFillRegionSolid (&pWin->drawable,
|
||||
pRegion,
|
||||
pWin->background.pixel))
|
||||
{
|
||||
xglAddBitDamage (&pWin->drawable);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
XGL_WINDOW_FALLBACK_PROLOGUE (pWin, PaintWindowBackground);
|
||||
(*pScreen->PaintWindowBackground) (pWin, pRegion, what);
|
||||
XGL_WINDOW_FALLBACK_EPILOGUE (pWin, PaintWindowBackground,
|
||||
xglPaintWindowBackground);
|
||||
}
|
||||
|
||||
void
|
||||
xglPaintWindowBorder (WindowPtr pWin,
|
||||
RegionPtr pRegion,
|
||||
int what)
|
||||
{
|
||||
ScreenPtr pScreen = pWin->drawable.pScreen;
|
||||
|
||||
XGL_SCREEN_PRIV (pScreen);
|
||||
|
||||
if (pWin->borderIsPixel)
|
||||
{
|
||||
if (xglFillRegionSolid (&pWin->drawable,
|
||||
pRegion,
|
||||
pWin->border.pixel))
|
||||
{
|
||||
xglAddBitDamage (&pWin->drawable);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WindowPtr pBgWin = pWin;
|
||||
|
||||
while (pBgWin->backgroundState == ParentRelative)
|
||||
pBgWin = pBgWin->parent;
|
||||
|
||||
if (xglFillRegionTiled (&pBgWin->drawable,
|
||||
pRegion,
|
||||
pWin->border.pixmap,
|
||||
-pBgWin->drawable.x,
|
||||
-pBgWin->drawable.y))
|
||||
{
|
||||
xglAddBitDamage (&pWin->drawable);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!xglSyncBits (&pWin->border.pixmap->drawable, NullBox))
|
||||
FatalError (XGL_SW_FAILURE_STRING);
|
||||
}
|
||||
|
||||
XGL_WINDOW_FALLBACK_PROLOGUE (pWin, PaintWindowBorder);
|
||||
(*pScreen->PaintWindowBorder) (pWin, pRegion, what);
|
||||
XGL_WINDOW_FALLBACK_EPILOGUE (pWin, PaintWindowBorder,
|
||||
xglPaintWindowBorder);
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright © 2004 Keith Packard
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of Keith Packard not be used in
|
||||
* advertising or publicity pertaining to distribution of the software without
|
||||
* specific, written prior permission. Keith Packard makes no
|
||||
* representations about the suitability of this software for any purpose. It
|
||||
* is provided "as is" without express or implied warranty.
|
||||
*
|
||||
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "xglint.h"
|
||||
|
||||
#ifdef XGL_GLX_BACKEND
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <glitz-glx.h>
|
||||
#include <GL/gl.h>
|
||||
|
||||
typedef struct _
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef XGL_AGL_BACKEND
|
||||
#include <glitz-agl.h>
|
||||
#include <OpenGL/gl.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <math.h>
|
||||
|
Loading…
Reference in New Issue