diff options
author | Alexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de> | 2004-09-15 16:34:16 +0000 |
---|---|---|
committer | Alexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de> | 2004-09-15 16:34:16 +0000 |
commit | 696b137d5855cdcd0e6b95e16ce2dad00510a41d (patch) | |
tree | 93d38eaf0eb8fd4bb2d9725dc242c5434ceabfa8 | |
parent | 2c971497fc9fc09d342cdb13a985fdde81f82351 (diff) |
Pull XORG-6_8_0 to CYGWIN branchCYGWIN-6_8_0-MERGE
402 files changed, 18760 insertions, 7205 deletions
diff --git a/GL/apple/aglGlx.c b/GL/apple/aglGlx.c index 106a6464d..fa7533e73 100644 --- a/GL/apple/aglGlx.c +++ b/GL/apple/aglGlx.c @@ -1,10 +1,14 @@ /* * GLX implementation that uses Apple's AGL.framework for OpenGL + * + * FIXME: This file and indirect.c are very similar. The two should be + * merged by introducing suitable abstractions. */ /* * Copyright (c) 2002 Greg Parker. All Rights Reserved. + * Copyright (c) 2004 Torrey T. Lyons. All Rights Reserved. * - * Portions of this file are copied from xf86glx.c, + * Large portions of this file are copied from Mesa's xf86glx.c, * which contains the following copyright: * * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. @@ -27,10 +31,6 @@ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name(s) of the above copyright - * holders shall not be used in advertising or otherwise to promote the sale, - * use or other dealings in this Software without prior written authorization. */ /* $XFree86: xc/programs/Xserver/GL/apple/aglGlx.c,v 1.2 2003/09/16 00:36:11 torrey Exp $ */ @@ -58,6 +58,11 @@ #include <GL/internal/glcore.h> #undef BOOL +#include "glcontextmodes.h" + +// ggs: needed to call back to glx with visual configs +extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, void **configprivs); + // Write debugging output, or not #ifdef GLAQUA_DEBUG #define GLAQUA_DEBUG_MSG ErrorF @@ -84,14 +89,14 @@ GLboolean glIsTextureEXT (GLuint h) { // some prototypes static Bool glAquaScreenProbe(int screen); static Bool glAquaInitVisuals(VisualPtr *visualp, DepthPtr *depthp, - int *nvisualp, int *ndepthp, - int *rootDepthp, VisualID *defaultVisp, - unsigned long sizes, int bitsPerRGB); + int *nvisualp, int *ndepthp, + int *rootDepthp, VisualID *defaultVisp, + unsigned long sizes, int bitsPerRGB); static void glAquaSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, - void **privates); + void **privates); static __GLinterface *glAquaCreateContext(__GLimports *imports, - __GLcontextModes *mode, - __GLinterface *shareGC); + __GLcontextModes *mode, + __GLinterface *shareGC); static void glAquaCreateBuffer(__GLXdrawablePrivate *glxPriv); static void glAquaResetExtension(void); @@ -102,14 +107,14 @@ static void glAquaResetExtension(void); * __glXScreenInit to initialize each of the active screens * (__glXActiveScreens[]). Several of the fields must be initialized by * the screenProbe routine before they are copied to the active screens - * struct. In particular, the contextCreate, pGlxVisual, numVisuals, + * struct. In particular, the contextCreate, modes, numVisuals, * and numUsableVisuals fields must be initialized. */ -__GLXscreenInfo __glDDXScreenInfo = { +static __GLXscreenInfo __glDDXScreenInfo = { glAquaScreenProbe, /* Must be generic and handle all screens */ glAquaCreateContext, /* Substitute screen's createContext routine */ glAquaCreateBuffer, /* Substitute screen's createBuffer routine */ - NULL, /* Set up pGlxVisual in probe */ + NULL, /* Set up modes in probe */ NULL, /* Set up pVisualPriv in probe */ 0, /* Set up numVisuals in probe */ 0, /* Set up numUsableVisuals in probe */ @@ -119,13 +124,20 @@ __GLXscreenInfo __glDDXScreenInfo = { NULL /* WrappedPositionWindow is overwritten */ }; -__GLXextensionInfo __glDDXExtensionInfo = { +void *__glXglDDXScreenInfo(void) { + return &__glDDXScreenInfo; +} + +static __GLXextensionInfo __glDDXExtensionInfo = { GL_CORE_APPLE, glAquaResetExtension, glAquaInitVisuals, glAquaSetVisualConfigs }; +void *__glXglDDXExtensionInfo(void) { + return &__glDDXExtensionInfo; +} // prototypes @@ -134,7 +146,7 @@ static GLboolean glAquaLoseCurrent(__GLcontext *gc); static GLboolean glAquaMakeCurrent(__GLcontext *gc); static GLboolean glAquaShareContext(__GLcontext *gc, __GLcontext *gcShare); static GLboolean glAquaCopyContext(__GLcontext *dst, const __GLcontext *src, - GLuint mask); + GLuint mask); static GLboolean glAquaForceCurrent(__GLcontext *gc); /* Drawing surface notification callbacks */ @@ -168,7 +180,7 @@ static __GLexports glAquaExports = { typedef struct { int num_vis; - __GLXvisualConfig *glx_vis; + __GLcontextModes *modes; void **priv; // wrapped screen functions @@ -192,6 +204,7 @@ struct __GLcontextRec { AGLContext ctx; AGLPixelFormat pixelFormat; + Bool isAttached; // TRUE if ctx is really attached to a window }; @@ -206,22 +219,28 @@ static GLboolean glAquaDestroyContext(__GLcontext *gc) if (gc->pixelFormat) aglDestroyPixelFormat(gc->pixelFormat); free(gc); } + return GL_TRUE; } static GLboolean glAquaLoseCurrent(__GLcontext *gc) { - // GLAQUA_DEBUG_MSG("glAquaLoseCurrent (ctx 0x%x)\n", gc->ctx); + GLAQUA_DEBUG_MSG("glAquaLoseCurrent (ctx 0x%x)\n", gc->ctx); + aglSetCurrentContext(NULL); __glXLastContext = NULL; // Mesa does this; why? + gc->isAttached = FALSE; + return GL_TRUE; } -// (x, y, w, h) is global coordinates of view or -1 -// glPriv may be NULL -static void attach(__GLcontext *gc, __GLdrawablePrivate *glPriv, - int x, int y, int w, int h) + +/* + * Attach a GL context to a GL drawable + * If glPriv is NULL, the context is detached. + */ +static void attach(__GLcontext *gc, __GLdrawablePrivate *glPriv) { __GLXdrawablePrivate *glxPriv; @@ -244,7 +263,15 @@ static void attach(__GLcontext *gc, __GLdrawablePrivate *glPriv, CRWindowPtr crWinPtr; AGLDrawable newPort; - crWinPtr = (CRWindowPtr) quartzProcs->FrameForWindow(pWin, TRUE); + if (glPriv->width <= 0 || glPriv->height <= 0) { + // attach to zero size drawable - will really attach later + GLAQUA_DEBUG_MSG("couldn't attach to zero size drawable\n"); + aglSetDrawable(gc->ctx, NULL); + gc->isAttached = FALSE; + return; + } + + crWinPtr = (CRWindowPtr) quartzProcs->FrameForWindow(pWin, FALSE); if (crWinPtr) { newPort = (AGLDrawable) crWinPtr->port; @@ -253,35 +280,43 @@ static void attach(__GLcontext *gc, __GLdrawablePrivate *glPriv, } if (newPort) { - // fixme won't be a CGrafPtr if currently offscreen or fullscreen + // FIXME: won't be a CGrafPtr if currently offscreen or fullscreen AGLDrawable oldPort = aglGetDrawable(gc->ctx); // AGLDrawable newPort = GetWindowPort(window); - GLint frame[4] = {x, y, w, h}; // fixme multi-screen? - // frame is now X11-global + + // Frame is GLdrawable in X11 global coordinates + // FIXME: Does this work for multiple screens? + GLint frame[4] = {glPriv->xOrigin, glPriv->yOrigin, glPriv->width, glPriv->height}; + GLAQUA_DEBUG_MSG("global size %d %d %d %d\n", + frame[0], frame[1], frame[2], frame[3]); + + // Convert to window-local coordinates frame[0] -= topWin->drawable.x - topWin->borderWidth; frame[1] -= topWin->drawable.y - topWin->borderWidth; - // frame is now window-local - // GL uses flipped coordinates + + // AGL uses flipped coordinates frame[1] = topWin->drawable.height + 2*topWin->borderWidth - frame[1] - frame[3]; - // GLAQUA_DEBUG_MSG("local size %d %d %d %d\n", - // frame[0], frame[1], frame[2], frame[3]); + GLAQUA_DEBUG_MSG("local size %d %d %d %d\n", + frame[0], frame[1], frame[2], frame[3]); if (oldPort != newPort) { - // fixme retain/release windows - aglSetDrawable(gc->ctx, newPort); + // FIXME: retain/release windows + if (!aglSetDrawable(gc->ctx, newPort)) return; } - aglSetInteger(gc->ctx, AGL_BUFFER_RECT, frame); - aglEnable(gc->ctx, AGL_BUFFER_RECT); - // aglSetInteger(gc->ctx, AGL_SWAP_RECT, frame); - // aglEnable(gc->ctx, AGL_SWAP_RECT); - aglUpdateContext(gc->ctx); + if (!aglSetInteger(gc->ctx, AGL_BUFFER_RECT, frame)) return; + if (!aglEnable(gc->ctx, AGL_BUFFER_RECT)) return; + if (!aglSetInteger(gc->ctx, AGL_SWAP_RECT, frame)) return; + if (!aglEnable(gc->ctx, AGL_SWAP_RECT)) return; + if (!aglUpdateContext(gc->ctx)) return; + gc->isAttached = TRUE; - GLAQUA_DEBUG_MSG("attached\n"); + GLAQUA_DEBUG_MSG("attached context 0x%x to window 0x%x\n", gc->ctx, + pWin->drawable.id); } else { // attach to not-yet-realized window - will really attach later - GLAQUA_DEBUG_MSG("couldn't attach\n"); + GLAQUA_DEBUG_MSG("couldn't attach to unrealized window\n"); aglSetDrawable(gc->ctx, NULL); gc->isAttached = FALSE; } @@ -294,14 +329,14 @@ static void attach(__GLcontext *gc, __GLdrawablePrivate *glPriv, static GLboolean glAquaMakeCurrent(__GLcontext *gc) { -#if 0 __GLdrawablePrivate *glPriv = gc->interface.imports.getDrawablePrivate(gc); + GLAQUA_DEBUG_MSG("glAquaMakeCurrent (ctx 0x%x)\n", gc->ctx); if (!gc->isAttached) { - attach(gc, glPriv, glPriv->xOrigin, glPriv->yOrigin, glPriv->width, glPriv->height); + attach(gc, glPriv); } -#endif + return aglSetCurrentContext(gc->ctx); } @@ -317,8 +352,8 @@ static GLboolean glAquaCopyContext(__GLcontext *dst, const __GLcontext *src, GLuint mask) { GLAQUA_DEBUG_MSG("glAquaCopyContext\n"); - aglCopyContext(src->ctx, dst->ctx, mask); - return GL_TRUE; + + return aglCopyContext(src->ctx, dst->ctx, mask); } static GLboolean glAquaForceCurrent(__GLcontext *gc) @@ -436,16 +471,15 @@ static AGLPixelFormat makeFormat(__GLcontextModes *mode) } static __GLinterface *glAquaCreateContext(__GLimports *imports, - __GLcontextModes *mode, - __GLinterface *shareGC) + __GLcontextModes *mode, + __GLinterface *shareGC) { __GLcontext *result; __GLcontext *sharectx = (__GLcontext *)shareGC; - GLint value; GLAQUA_DEBUG_MSG("glAquaCreateContext\n"); - result = (__GLcontext *)malloc(sizeof(__GLcontext)); + result = (__GLcontext *)calloc(1, sizeof(__GLcontext)); if (!result) return NULL; result->interface.imports = *imports; @@ -468,10 +502,6 @@ static __GLinterface *glAquaCreateContext(__GLimports *imports, result->isAttached = FALSE; - // Tell aglSwapBuffers to wait for vertical retrace - value = 1; - aglSetInteger(result->ctx, AGL_SWAP_INTERVAL, &value); - GLAQUA_DEBUG_MSG("glAquaCreateContext done\n"); return (__GLinterface *)result; } @@ -505,17 +535,15 @@ glAquaRealizeWindow(WindowPtr pWin) GLAQUA_DEBUG_MSG("glAquaRealizeWindow is GL drawable!\n"); // GL contexts bound to this window for drawing - for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->next) { + for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->nextDrawPriv) { gc = (__GLcontext *)gx->gc; - attach(gc, glPriv, glxPriv->xorigin, glxPriv->yorigin, - glxPriv->width, glxPriv->height); + attach(gc, glPriv); } // GL contexts bound to this window for reading - for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->next) { + for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->nextReadPriv) { gc = (__GLcontext *)gx->gc; - attach(gc, glPriv, glxPriv->xorigin, glxPriv->yorigin, - glxPriv->width, glxPriv->height); + attach(gc, glPriv); } } @@ -544,15 +572,15 @@ glAquaUnrealizeWindow(WindowPtr pWin) GLAQUA_DEBUG_MSG("glAquaUnealizeWindow is GL drawable!\n"); // GL contexts bound to this window for drawing - for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->next) { + for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->nextDrawPriv) { gc = (__GLcontext *)gx->gc; - attach(gc, NULL, 0, 0, 0, 0); + attach(gc, NULL); } // GL contexts bound to this window for reading - for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->next) { + for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->nextReadPriv) { gc = (__GLcontext *)gx->gc; - attach(gc, NULL, 0, 0, 0, 0); + attach(gc, NULL); } } @@ -564,23 +592,21 @@ glAquaUnrealizeWindow(WindowPtr pWin) } - - - - -/* - * In the case the driver has no GLX visuals we'll use these. - * [0] = RGB, double buffered - * [1] = RGB, double buffered, stencil, accum - */ // Originally copied from Mesa static int numConfigs = 0; static __GLXvisualConfig *visualConfigs = NULL; static void **visualPrivates = NULL; -#define NUM_FALLBACK_CONFIGS 2 +/* + * In the case the driver defines no GLX visuals we'll use these. + * Note that for TrueColor and DirectColor visuals, bufferSize is the + * sum of redSize, greenSize, blueSize and alphaSize, which may be larger + * than the nplanes/rootDepth of the server's X11 visuals + */ +#define NUM_FALLBACK_CONFIGS 5 static __GLXvisualConfig FallbackConfigs[NUM_FALLBACK_CONFIGS] = { + /* [0] = RGB, double buffered, Z */ { -1, /* vid */ -1, /* class */ @@ -595,11 +621,12 @@ static __GLXvisualConfig FallbackConfigs[NUM_FALLBACK_CONFIGS] = { 0, /* stencilSize */ 0, /* auxBuffers */ 0, /* level */ - GLX_NONE_EXT, /* visualRating */ - 0, /* transparentPixel */ + GLX_NONE, /* visualRating */ + GLX_NONE, /* transparentPixel */ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ 0 /* transparentIndex */ }, + /* [1] = RGB, double buffered, Z, stencil, accum */ { -1, /* vid */ -1, /* class */ @@ -614,15 +641,94 @@ static __GLXvisualConfig FallbackConfigs[NUM_FALLBACK_CONFIGS] = { 8, /* stencilSize */ 0, /* auxBuffers */ 0, /* level */ + GLX_NONE, /* visualRating */ + GLX_NONE, /* transparentPixel */ + 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ + 0 /* transparentIndex */ + }, + /* [2] = RGB+Alpha, double buffered, Z, stencil, accum */ + { + -1, /* vid */ + -1, /* class */ + True, /* rgba */ + -1, -1, -1, 8, /* rgba sizes */ + -1, -1, -1, -1, /* rgba masks */ + 16, 16, 16, 16, /* rgba accum sizes */ + True, /* doubleBuffer */ + False, /* stereo */ + -1, /* bufferSize */ + 16, /* depthSize */ + 8, /* stencilSize */ + 0, /* auxBuffers */ + 0, /* level */ + GLX_NONE, /* visualRating */ + GLX_NONE, /* transparentPixel */ + 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ + 0 /* transparentIndex */ + }, + /* [3] = RGB+Alpha, single buffered, Z, stencil, accum */ + { + -1, /* vid */ + -1, /* class */ + True, /* rgba */ + -1, -1, -1, 8, /* rgba sizes */ + -1, -1, -1, -1, /* rgba masks */ + 16, 16, 16, 16, /* rgba accum sizes */ + False, /* doubleBuffer */ + False, /* stereo */ + -1, /* bufferSize */ + 16, /* depthSize */ + 8, /* stencilSize */ + 0, /* auxBuffers */ + 0, /* level */ + GLX_NONE, /* visualRating */ + GLX_NONE, /* transparentPixel */ + 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ + 0 /* transparentIndex */ + }, + /* [4] = CI, double buffered, Z */ + { + -1, /* vid */ + -1, /* class */ + False, /* rgba? (false = color index) */ + -1, -1, -1, 0, /* rgba sizes */ + -1, -1, -1, 0, /* rgba masks */ + 0, 0, 0, 0, /* rgba accum sizes */ + True, /* doubleBuffer */ + False, /* stereo */ + -1, /* bufferSize */ + 16, /* depthSize */ + 0, /* stencilSize */ + 0, /* auxBuffers */ + 0, /* level */ + GLX_NONE, /* visualRating */ + GLX_NONE, /* transparentPixel */ + 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ + 0 /* transparentIndex */ + }, +}; + +static __GLXvisualConfig NullConfig = { + -1, /* vid */ + -1, /* class */ + False, /* rgba */ + -1, -1, -1, 0, /* rgba sizes */ + -1, -1, -1, 0, /* rgba masks */ + 0, 0, 0, 0, /* rgba accum sizes */ + False, /* doubleBuffer */ + False, /* stereo */ + -1, /* bufferSize */ + 16, /* depthSize */ + 0, /* stencilSize */ + 0, /* auxBuffers */ + 0, /* level */ GLX_NONE_EXT, /* visualRating */ 0, /* transparentPixel */ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ 0 /* transparentIndex */ - } }; - static int count_bits(unsigned int n) { int bits = 0; @@ -635,11 +741,10 @@ static int count_bits(unsigned int n) } -// Mostly copied from Mesa's xf86glx.c static Bool init_visuals(int *nvisualp, VisualPtr *visualp, - VisualID *defaultVisp, - int ndepth, DepthPtr pdepth, - int rootDepth) + VisualID *defaultVisp, + int ndepth, DepthPtr pdepth, + int rootDepth) { int numRGBconfigs; int numCIconfigs; @@ -649,7 +754,7 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp, VisualPtr pVisual = *visualp; VisualPtr pVisualNew = NULL; VisualID *orig_vid = NULL; - __GLXvisualConfig *glXVisualPtr = NULL; + __GLcontextModes *modes; __GLXvisualConfig *pNewVisualConfigs = NULL; void **glXVisualPriv; void **pNewVisualPriv; @@ -667,14 +772,14 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp, pNewVisualConfigs = (__GLXvisualConfig *) __glXMalloc(numNewConfigs * sizeof(__GLXvisualConfig)); if (!pNewVisualConfigs) { - return FALSE; + return FALSE; } /* Alloc space for the list of new GLX visual privates */ pNewVisualPriv = (void **) __glXMalloc(numNewConfigs * sizeof(void *)); if (!pNewVisualPriv) { - __glXFree(pNewVisualConfigs); - return FALSE; + __glXFree(pNewVisualConfigs); + return FALSE; } /* @@ -682,9 +787,9 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp, ** visual configs. */ if (numConfigs == 0) { - memcpy(pNewVisualConfigs, FallbackConfigs, + memcpy(pNewVisualConfigs, FallbackConfigs, NUM_FALLBACK_CONFIGS * sizeof(__GLXvisualConfig)); - memset(pNewVisualPriv, 0, NUM_FALLBACK_CONFIGS * sizeof(void *)); + memset(pNewVisualPriv, 0, NUM_FALLBACK_CONFIGS * sizeof(void *)); } else { /* copy driver's visual config info */ @@ -698,18 +803,24 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp, numRGBconfigs = 0; numCIconfigs = 0; for (i = 0; i < numNewConfigs; i++) { - if (pNewVisualConfigs[i].rgba) - numRGBconfigs++; - else - numCIconfigs++; + if (pNewVisualConfigs[i].rgba) + numRGBconfigs++; + else + numCIconfigs++; } /* Count the total number of visuals to compute */ numNewVisuals = 0; for (i = 0; i < numVisuals; i++) { - numNewVisuals += - (pVisual[i].class == TrueColor || pVisual[i].class == DirectColor) - ? numRGBconfigs : numCIconfigs; + int count; + + count = ((pVisual[i].class == TrueColor || + pVisual[i].class == DirectColor) + ? numRGBconfigs : numCIconfigs); + if (count == 0) + count = 1; /* preserve the existing visual */ + + numNewVisuals += count; } /* Reset variables for use with the next screen/driver's visual configs */ @@ -719,127 +830,159 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp, /* Alloc temp space for the list of orig VisualIDs for each new visual */ orig_vid = (VisualID *)__glXMalloc(numNewVisuals * sizeof(VisualID)); if (!orig_vid) { - __glXFree(pNewVisualPriv); - __glXFree(pNewVisualConfigs); - return FALSE; + __glXFree(pNewVisualPriv); + __glXFree(pNewVisualConfigs); + return FALSE; } /* Alloc space for the list of glXVisuals */ - glXVisualPtr = (__GLXvisualConfig *)__glXMalloc(numNewVisuals * - sizeof(__GLXvisualConfig)); - if (!glXVisualPtr) { - __glXFree(orig_vid); - __glXFree(pNewVisualPriv); - __glXFree(pNewVisualConfigs); - return FALSE; + modes = _gl_context_modes_create(numNewVisuals, sizeof(__GLcontextModes)); + if (modes == NULL) { + __glXFree(orig_vid); + __glXFree(pNewVisualPriv); + __glXFree(pNewVisualConfigs); + return FALSE; } /* Alloc space for the list of glXVisualPrivates */ glXVisualPriv = (void **)__glXMalloc(numNewVisuals * sizeof(void *)); if (!glXVisualPriv) { - __glXFree(glXVisualPtr); - __glXFree(orig_vid); - __glXFree(pNewVisualPriv); - __glXFree(pNewVisualConfigs); - return FALSE; + _gl_context_modes_destroy( modes ); + __glXFree(orig_vid); + __glXFree(pNewVisualPriv); + __glXFree(pNewVisualConfigs); + return FALSE; } /* Alloc space for the new list of the X server's visuals */ pVisualNew = (VisualPtr)__glXMalloc(numNewVisuals * sizeof(VisualRec)); if (!pVisualNew) { - __glXFree(glXVisualPriv); - __glXFree(glXVisualPtr); - __glXFree(orig_vid); - __glXFree(pNewVisualPriv); - __glXFree(pNewVisualConfigs); - return FALSE; + __glXFree(glXVisualPriv); + _gl_context_modes_destroy( modes ); + __glXFree(orig_vid); + __glXFree(pNewVisualPriv); + __glXFree(pNewVisualConfigs); + return FALSE; } /* Initialize the new visuals */ found_default = FALSE; + glAquaScreens[screenInfo.numScreens-1].modes = modes; for (i = j = 0; i < numVisuals; i++) { int is_rgb = (pVisual[i].class == TrueColor || - pVisual[i].class == DirectColor); - - for (k = 0; k < numNewConfigs; k++) { - if (pNewVisualConfigs[k].rgba != is_rgb) - continue; - - /* Initialize the new visual */ - pVisualNew[j] = pVisual[i]; - pVisualNew[j].vid = FakeClientID(0); - - /* Check for the default visual */ - if (!found_default && pVisual[i].vid == *defaultVisp) { - *defaultVisp = pVisualNew[j].vid; - found_default = TRUE; - } - - /* Save the old VisualID */ - orig_vid[j] = pVisual[i].vid; - - /* Initialize the glXVisual */ - glXVisualPtr[j] = pNewVisualConfigs[k]; - glXVisualPtr[j].vid = pVisualNew[j].vid; - - /* - * If the class is -1, then assume the X visual information - * is identical to what GLX needs, and take them from the X - * visual. NOTE: if class != -1, then all other fields MUST - * be initialized. - */ - if (glXVisualPtr[j].class == -1) { - glXVisualPtr[j].class = pVisual[i].class; - glXVisualPtr[j].redSize = count_bits(pVisual[i].redMask); - glXVisualPtr[j].greenSize = count_bits(pVisual[i].greenMask); - glXVisualPtr[j].blueSize = count_bits(pVisual[i].blueMask); - glXVisualPtr[j].alphaSize = glXVisualPtr[j].alphaSize; - glXVisualPtr[j].redMask = pVisual[i].redMask; - glXVisualPtr[j].greenMask = pVisual[i].greenMask; - glXVisualPtr[j].blueMask = pVisual[i].blueMask; - glXVisualPtr[j].alphaMask = glXVisualPtr[j].alphaMask; - glXVisualPtr[j].bufferSize = rootDepth; - } - - /* Save the device-dependent private for this visual */ - glXVisualPriv[j] = pNewVisualPriv[k]; - - j++; - } + pVisual[i].class == DirectColor); + + if (!is_rgb) + { + /* We don't support non-rgb visuals for GL. But we don't + want to remove them either, so just pass them through + with null glX configs */ + + pVisualNew[j] = pVisual[i]; + pVisualNew[j].vid = FakeClientID(0); + + /* Check for the default visual */ + if (!found_default && pVisual[i].vid == *defaultVisp) { + *defaultVisp = pVisualNew[j].vid; + found_default = TRUE; + } + + /* Save the old VisualID */ + orig_vid[j] = pVisual[i].vid; + + /* Initialize the glXVisual */ + _gl_copy_visual_to_context_mode( modes, & NullConfig ); + modes->visualID = pVisualNew[j].vid; + + j++; + + continue; + } + + for (k = 0; k < numNewConfigs; k++) { + if (pNewVisualConfigs[k].rgba != is_rgb) + continue; + + assert( modes != NULL ); + + /* Initialize the new visual */ + pVisualNew[j] = pVisual[i]; + pVisualNew[j].vid = FakeClientID(0); + + /* Check for the default visual */ + if (!found_default && pVisual[i].vid == *defaultVisp) { + *defaultVisp = pVisualNew[j].vid; + found_default = TRUE; + } + + /* Save the old VisualID */ + orig_vid[j] = pVisual[i].vid; + + /* Initialize the glXVisual */ + _gl_copy_visual_to_context_mode( modes, & pNewVisualConfigs[k] ); + modes->visualID = pVisualNew[j].vid; + + /* + * If the class is -1, then assume the X visual information + * is identical to what GLX needs, and take them from the X + * visual. NOTE: if class != -1, then all other fields MUST + * be initialized. + */ + if (modes->visualType == GLX_NONE) { + modes->visualType = _gl_convert_from_x_visual_type( pVisual[i].class ); + modes->redBits = count_bits(pVisual[i].redMask); + modes->greenBits = count_bits(pVisual[i].greenMask); + modes->blueBits = count_bits(pVisual[i].blueMask); + modes->alphaBits = modes->alphaBits; + modes->redMask = pVisual[i].redMask; + modes->greenMask = pVisual[i].greenMask; + modes->blueMask = pVisual[i].blueMask; + modes->alphaMask = modes->alphaMask; + modes->rgbBits = (is_rgb) + ? (modes->redBits + modes->greenBits + + modes->blueBits + modes->alphaBits) + : rootDepth; + } + + /* Save the device-dependent private for this visual */ + glXVisualPriv[j] = pNewVisualPriv[k]; + + j++; + modes = modes->next; + } } assert(j <= numNewVisuals); /* Save the GLX visuals in the screen structure */ glAquaScreens[screenInfo.numScreens-1].num_vis = numNewVisuals; - glAquaScreens[screenInfo.numScreens-1].glx_vis = glXVisualPtr; glAquaScreens[screenInfo.numScreens-1].priv = glXVisualPriv; /* Set up depth's VisualIDs */ for (i = 0; i < ndepth; i++) { - int numVids = 0; - VisualID *pVids = NULL; - int k, n = 0; - - /* Count the new number of VisualIDs at this depth */ - for (j = 0; j < pdepth[i].numVids; j++) - for (k = 0; k < numNewVisuals; k++) - if (pdepth[i].vids[j] == orig_vid[k]) - numVids++; - - /* Allocate a new list of VisualIDs for this depth */ - pVids = (VisualID *)__glXMalloc(numVids * sizeof(VisualID)); - - /* Initialize the new list of VisualIDs for this depth */ - for (j = 0; j < pdepth[i].numVids; j++) - for (k = 0; k < numNewVisuals; k++) - if (pdepth[i].vids[j] == orig_vid[k]) - pVids[n++] = pVisualNew[k].vid; - - /* Update this depth's list of VisualIDs */ - __glXFree(pdepth[i].vids); - pdepth[i].vids = pVids; - pdepth[i].numVids = numVids; + int numVids = 0; + VisualID *pVids = NULL; + int k, n = 0; + + /* Count the new number of VisualIDs at this depth */ + for (j = 0; j < pdepth[i].numVids; j++) + for (k = 0; k < numNewVisuals; k++) + if (pdepth[i].vids[j] == orig_vid[k]) + numVids++; + + /* Allocate a new list of VisualIDs for this depth */ + pVids = (VisualID *)__glXMalloc(numVids * sizeof(VisualID)); + + /* Initialize the new list of VisualIDs for this depth */ + for (j = 0; j < pdepth[i].numVids; j++) + for (k = 0; k < numNewVisuals; k++) + if (pdepth[i].vids[j] == orig_vid[k]) + pVids[n++] = pVisualNew[k].vid; + + /* Update this depth's list of VisualIDs */ + __glXFree(pdepth[i].vids); + pdepth[i].vids = pVids; + pdepth[i].numVids = numVids; } /* Update the X server's visuals */ @@ -862,9 +1005,96 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp, return TRUE; } -// Copied from Mesa +/* based on code in i830_dri.c + This ends calling glAquaSetVisualConfigs to set the static + numconfigs, etc. */ +static void +glAquaInitVisualConfigs(void) +{ + int lclNumConfigs = 0; + __GLXvisualConfig *lclVisualConfigs = NULL; + void **lclVisualPrivates = NULL; + + int depth, aux, buffers, stencil, accum; + int i = 0; + + GLAQUA_DEBUG_MSG("glAquaInitVisualConfigs "); + + /* count num configs: + 2 Z buffer (0, 24 bit) + 2 AUX buffer (0, 2) + 2 buffers (single, double) + 2 stencil (0, 8 bit) + 2 accum (0, 64 bit) + = 32 configs */ + + lclNumConfigs = 2 * 2 * 2 * 2 * 2; /* 32 */ + + /* alloc */ + lclVisualConfigs = xcalloc(sizeof(__GLXvisualConfig), lclNumConfigs); + lclVisualPrivates = xcalloc(sizeof(void *), lclNumConfigs); + + /* fill in configs */ + if (NULL != lclVisualConfigs) { + i = 0; /* current buffer */ + for (depth = 0; depth < 2; depth++) { + for (aux = 0; aux < 2; aux++) { + for (buffers = 0; buffers < 2; buffers++) { + for (stencil = 0; stencil < 2; stencil++) { + for (accum = 0; accum < 2; accum++) { + lclVisualConfigs[i].vid = -1; + lclVisualConfigs[i].class = -1; + lclVisualConfigs[i].rgba = TRUE; + lclVisualConfigs[i].redSize = -1; + lclVisualConfigs[i].greenSize = -1; + lclVisualConfigs[i].blueSize = -1; + lclVisualConfigs[i].redMask = -1; + lclVisualConfigs[i].greenMask = -1; + lclVisualConfigs[i].blueMask = -1; + lclVisualConfigs[i].alphaMask = 0; + if (accum) { + lclVisualConfigs[i].accumRedSize = 16; + lclVisualConfigs[i].accumGreenSize = 16; + lclVisualConfigs[i].accumBlueSize = 16; + lclVisualConfigs[i].accumAlphaSize = 16; + } + else { + lclVisualConfigs[i].accumRedSize = 0; + lclVisualConfigs[i].accumGreenSize = 0; + lclVisualConfigs[i].accumBlueSize = 0; + lclVisualConfigs[i].accumAlphaSize = 0; + } + lclVisualConfigs[i].doubleBuffer = buffers ? TRUE : FALSE; + lclVisualConfigs[i].stereo = FALSE; + lclVisualConfigs[i].bufferSize = -1; + + lclVisualConfigs[i].depthSize = depth? 24 : 0; + lclVisualConfigs[i].stencilSize = stencil ? 8 : 0; + lclVisualConfigs[i].auxBuffers = aux ? 2 : 0; + lclVisualConfigs[i].level = 0; + lclVisualConfigs[i].visualRating = GLX_NONE_EXT; + lclVisualConfigs[i].transparentPixel = 0; + lclVisualConfigs[i].transparentRed = 0; + lclVisualConfigs[i].transparentGreen = 0; + lclVisualConfigs[i].transparentBlue = 0; + lclVisualConfigs[i].transparentAlpha = 0; + lclVisualConfigs[i].transparentIndex = 0; + i++; + } + } + } + } + } + } + if (i != lclNumConfigs) + GLAQUA_DEBUG_MSG("glAquaInitVisualConfigs failed to alloc visual configs"); + + GlxSetVisualConfigs(lclNumConfigs, lclVisualConfigs, lclVisualPrivates); +} + + static void glAquaSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, - void **privates) + void **privates) { GLAQUA_DEBUG_MSG("glAquaSetVisualConfigs\n"); @@ -873,19 +1103,21 @@ static void glAquaSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, visualPrivates = privates; } -// Copied from Mesa static Bool glAquaInitVisuals(VisualPtr *visualp, DepthPtr *depthp, - int *nvisualp, int *ndepthp, - int *rootDepthp, VisualID *defaultVisp, - unsigned long sizes, int bitsPerRGB) + int *nvisualp, int *ndepthp, + int *rootDepthp, VisualID *defaultVisp, + unsigned long sizes, int bitsPerRGB) { GLAQUA_DEBUG_MSG("glAquaInitVisuals\n"); + if (numConfigs == 0) /* if no configs */ + glAquaInitVisualConfigs(); /* ensure the visual configs are setup */ + /* * Setup the visuals supported by this particular screen. */ return init_visuals(nvisualp, visualp, defaultVisp, - *ndepthp, *depthp, *rootDepthp); + *ndepthp, *depthp, *rootDepthp); } @@ -893,100 +1125,92 @@ static void fixup_visuals(int screen) { ScreenPtr pScreen = screenInfo.screens[screen]; glAquaScreenRec *pScr = &glAquaScreens[screen]; - __GLXvisualConfig *pGLXVis = pScr->glx_vis; - VisualPtr pVis; - int i, j; + int j; + __GLcontextModes *modes; GLAQUA_DEBUG_MSG("fixup_visuals\n"); - for (i = 0; i < pScr->num_vis; i++, pGLXVis++) { - pVis = pScreen->visuals; - - /* Find a visual that matches the GLX visual's class and size */ - for (j = 0; j < pScreen->numVisuals; j++, pVis++) { - if (pVis->class == pGLXVis->class && - pVis->nplanes == pGLXVis->bufferSize) { - - /* Fixup the masks */ - pGLXVis->redMask = pVis->redMask; - pGLXVis->greenMask = pVis->greenMask; - pGLXVis->blueMask = pVis->blueMask; - - /* Recalc the sizes */ - pGLXVis->redSize = count_bits(pGLXVis->redMask); - pGLXVis->greenSize = count_bits(pGLXVis->greenMask); - pGLXVis->blueSize = count_bits(pGLXVis->blueMask); - } - } + for ( modes = pScr->modes ; modes != NULL ; modes = modes->next ) { + const int vis_class = _gl_convert_to_x_visual_type( modes->visualType ); + const int nplanes = (modes->rgbBits - modes->alphaBits); + const VisualPtr pVis = pScreen->visuals; + + /* Find a visual that matches the GLX visual's class and size */ + for (j = 0; j < pScreen->numVisuals; j++) { + if (pVis[j].class == vis_class && + pVis[j].nplanes == nplanes) { + + /* Fixup the masks */ + modes->redMask = pVis[j].redMask; + modes->greenMask = pVis[j].greenMask; + modes->blueMask = pVis[j].blueMask; + + /* Recalc the sizes */ + modes->redBits = count_bits(modes->redMask); + modes->greenBits = count_bits(modes->greenMask); + modes->blueBits = count_bits(modes->blueMask); + } + } } } static void init_screen_visuals(int screen) { ScreenPtr pScreen = screenInfo.screens[screen]; - __GLXvisualConfig *pGLXVis = glAquaScreens[screen].glx_vis; - // XMesaVisual *pXMesaVisual; - VisualPtr pVis; + __GLcontextModes *modes; int *used; int i, j; GLAQUA_DEBUG_MSG("init_screen_visuals\n"); - /* Alloc space for the list of XMesa visuals */ - // pXMesaVisual = (XMesaVisual *)__glXMalloc(MESAScreens[screen].num_vis * - // sizeof(XMesaVisual)); - // __glXMemset(pXMesaVisual, 0, - // MESAScreens[screen].num_vis * sizeof(XMesaVisual)); - + /* FIXME: Change 'used' to be a array of bits (rather than of ints), + * FIXME: create a stack array of 8 or 16 bytes. If 'numVisuals' is less + * FIXME: than 64 or 128 the stack array can be used instead of calling + * FIXME: __glXMalloc / __glXFree. If nothing else, convert 'used' to + * FIXME: array of bytes instead of ints! + */ used = (int *)__glXMalloc(pScreen->numVisuals * sizeof(int)); __glXMemset(used, 0, pScreen->numVisuals * sizeof(int)); - for (i = 0; i < glAquaScreens[screen].num_vis; i++, pGLXVis++) { - pVis = pScreen->visuals; - for (j = 0; j < pScreen->numVisuals; j++, pVis++) { - - if (pVis->class == pGLXVis->class && - pVis->nplanes == pGLXVis->bufferSize && - !used[j]) { - - if (pVis->redMask == pGLXVis->redMask && - pVis->greenMask == pGLXVis->greenMask && - pVis->blueMask == pGLXVis->blueMask) { - - /* Create the XMesa visual */ - /* - pXMesaVisual[i] = - XMesaCreateVisual(pScreen, - pVis, - pGLXVis->rgba, - (pGLXVis->alphaSize > 0), - pGLXVis->doubleBuffer, - pGLXVis->stereo, - GL_TRUE, // ximage_flag - pGLXVis->depthSize, - pGLXVis->stencilSize, - pGLXVis->accumRedSize, - pGLXVis->accumGreenSize, - pGLXVis->accumBlueSize, - pGLXVis->accumAlphaSize, - 0, // numSamples - pGLXVis->level, - pGLXVis->visualRating ); - */ - /* Set the VisualID */ - pGLXVis->vid = pVis->vid; - - /* Mark this visual used */ - used[j] = 1; - break; - } - } - } + i = 0; + for ( modes = glAquaScreens[screen].modes + ; modes != NULL + ; modes = modes->next ) { + const int vis_class = _gl_convert_to_x_visual_type( modes->visualType ); + const int nplanes = (modes->rgbBits - modes->alphaBits); + const VisualPtr pVis = pScreen->visuals; + + for (j = 0; j < pScreen->numVisuals; j++) { + if (pVis[j].class == vis_class && + pVis[j].nplanes == nplanes && + pVis[j].redMask == modes->redMask && + pVis[j].greenMask == modes->greenMask && + pVis[j].blueMask == modes->blueMask && + !used[j]) { + + /* Set the VisualID */ + modes->visualID = pVis[j].vid; + + /* Mark this visual used */ + used[j] = 1; + break; + } + } + if ( j == pScreen->numVisuals ) { + ErrorF("No matching visual for __GLcontextMode with " + "visual class = %d (%d), nplanes = %u\n", + vis_class, + (int)modes->visualType, + (unsigned int)(modes->rgbBits - modes->alphaBits) ); + } + else if ( modes->visualID == -1 ) { + FatalError( "Matching visual found, but visualID still -1!\n" ); + } + + i++; } __glXFree(used); - - // glAquaScreens[screen].xm_vis = pXMesaVisual; } static Bool glAquaScreenProbe(int screen) @@ -999,10 +1223,10 @@ static Bool glAquaScreenProbe(int screen) /* * Set up the current screen's visuals. */ - __glDDXScreenInfo.pGlxVisual = glAquaScreens[screen].glx_vis; + __glDDXScreenInfo.modes = glAquaScreens[screen].modes; __glDDXScreenInfo.pVisualPriv = glAquaScreens[screen].priv; __glDDXScreenInfo.numVisuals = - __glDDXScreenInfo.numUsableVisuals = glAquaScreens[screen].num_vis; + __glDDXScreenInfo.numUsableVisuals = glAquaScreens[screen].num_vis; /* * Set the current screen's createContext routine. This could be @@ -1022,7 +1246,9 @@ static Bool glAquaScreenProbe(int screen) */ init_screen_visuals(screen); - // Wrap RealizeWindow and UnrealizeWindow on this screen + /* + * Wrap RealizeWindow and UnrealizeWindow on this screen + */ pScreen = screenInfo.screens[screen]; screenPriv = &glAquaScreens[screen]; screenPriv->RealizeWindow = pScreen->RealizeWindow; @@ -1035,28 +1261,28 @@ static Bool glAquaScreenProbe(int screen) static GLboolean glAquaResizeBuffers(__GLdrawableBuffer *buffer, - GLint x, GLint y, - GLuint width, GLuint height, - __GLdrawablePrivate *glPriv, - GLuint bufferMask) + GLint x, GLint y, + GLuint width, GLuint height, + __GLdrawablePrivate *glPriv, + GLuint bufferMask) { GLAquaDrawableRec *aquaPriv = (GLAquaDrawableRec *)glPriv->private; + __GLXdrawablePrivate *glxPriv = (__GLXdrawablePrivate *)glPriv->other; __GLXcontext *gx; __GLcontext *gc; - __GLXdrawablePrivate *glxPriv = (__GLXdrawablePrivate *)glPriv->other; GLAQUA_DEBUG_MSG("glAquaResizeBuffers to (%d %d %d %d)\n", x, y, width, height); // update all contexts that point at this drawable for drawing (hack?) - for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->next) { + for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->nextDrawPriv) { gc = (__GLcontext *)gx->gc; - attach(gc, glPriv, x, y, width, height); + attach(gc, glPriv); } // update all contexts that point at this drawable for reading (hack?) - for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->next) { + for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->nextReadPriv) { gc = (__GLcontext *)gx->gc; - attach(gc, glPriv, x, y, width, height); + attach(gc, glPriv); } return aquaPriv->resize(buffer, x, y, width, height, glPriv, bufferMask); @@ -1122,24 +1348,24 @@ GLint __glEvalComputeK(GLenum target) case GL_MAP2_VERTEX_4: case GL_MAP2_COLOR_4: case GL_MAP2_TEXTURE_COORD_4: - return 4; + return 4; case GL_MAP1_VERTEX_3: case GL_MAP1_TEXTURE_COORD_3: case GL_MAP1_NORMAL: case GL_MAP2_VERTEX_3: case GL_MAP2_TEXTURE_COORD_3: case GL_MAP2_NORMAL: - return 3; + return 3; case GL_MAP1_TEXTURE_COORD_2: case GL_MAP2_TEXTURE_COORD_2: - return 2; + return 2; case GL_MAP1_TEXTURE_COORD_1: case GL_MAP2_TEXTURE_COORD_1: case GL_MAP1_INDEX: case GL_MAP2_INDEX: - return 1; + return 1; default: - return 0; + return 0; } } @@ -1148,8 +1374,8 @@ GLuint __glFloorLog2(GLuint val) int c = 0; while (val > 1) { - c++; - val >>= 1; + c++; + val >>= 1; } return c; } diff --git a/GL/apple/indirect.c b/GL/apple/indirect.c index c4d235a47..f885e526e 100644 --- a/GL/apple/indirect.c +++ b/GL/apple/indirect.c @@ -5,8 +5,9 @@ /* * Copyright (c) 2002 Greg Parker. All Rights Reserved. * Copyright (c) 2002 Apple Computer, Inc. + * Copyright (c) 2004 Torrey T. Lyons. All Rights Reserved. * - * Portions of this file are copied from xf86glx.c, + * Portions of this file are copied from Mesa's xf86glx.c, * which contains the following copyright: * * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. @@ -29,10 +30,6 @@ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name(s) of the above copyright - * holders shall not be used in advertising or otherwise to promote the sale, - * use or other dealings in this Software without prior written authorization. */ /* $XFree86: xc/programs/Xserver/GL/apple/indirect.c,v 1.2 2003/09/16 00:36:11 torrey Exp $ */ @@ -61,6 +58,8 @@ #include "x-hash.h" #include "x-list.h" +#include "glcontextmodes.h" + // ggs: needed to call back to glx with visual configs extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, void **configprivs); @@ -89,14 +88,14 @@ GLboolean glIsTextureEXT(GLuint h) { // some prototypes static Bool glAquaScreenProbe(int screen); static Bool glAquaInitVisuals(VisualPtr *visualp, DepthPtr *depthp, - int *nvisualp, int *ndepthp, - int *rootDepthp, VisualID *defaultVisp, - unsigned long sizes, int bitsPerRGB); + int *nvisualp, int *ndepthp, + int *rootDepthp, VisualID *defaultVisp, + unsigned long sizes, int bitsPerRGB); static void glAquaSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, - void **privates); + void **privates); static __GLinterface *glAquaCreateContext(__GLimports *imports, - __GLcontextModes *mode, - __GLinterface *shareGC); + __GLcontextModes *mode, + __GLinterface *shareGC); static void glAquaCreateBuffer(__GLXdrawablePrivate *glxPriv); static void glAquaResetExtension(void); @@ -106,14 +105,14 @@ static void glAquaResetExtension(void); * __glXScreenInit to initialize each of the active screens * (__glXActiveScreens[]). Several of the fields must be initialized by * the screenProbe routine before they are copied to the active screens - * struct. In particular, the contextCreate, pGlxVisual, numVisuals, + * struct. In particular, the contextCreate, modes, numVisuals, * and numUsableVisuals fields must be initialized. */ -__GLXscreenInfo __glDDXScreenInfo = { +static __GLXscreenInfo __glDDXScreenInfo = { glAquaScreenProbe, /* Must be generic and handle all screens */ glAquaCreateContext, /* Substitute screen's createContext routine */ glAquaCreateBuffer, /* Substitute screen's createBuffer routine */ - NULL, /* Set up pGlxVisual in probe */ + NULL, /* Set up modes in probe */ NULL, /* Set up pVisualPriv in probe */ 0, /* Set up numVisuals in probe */ 0, /* Set up numUsableVisuals in probe */ @@ -123,13 +122,21 @@ __GLXscreenInfo __glDDXScreenInfo = { NULL /* WrappedPositionWindow is overwritten */ }; -__GLXextensionInfo __glDDXExtensionInfo = { +void *__glXglDDXScreenInfo(void) { + return &__glDDXScreenInfo; +} + +static __GLXextensionInfo __glDDXExtensionInfo = { GL_CORE_APPLE, glAquaResetExtension, glAquaInitVisuals, glAquaSetVisualConfigs }; +void *__glXglDDXExtensionInfo(void) { + return &__glDDXExtensionInfo; +} + // prototypes static GLboolean glAquaDestroyContext(__GLcontext *gc); @@ -137,7 +144,7 @@ static GLboolean glAquaLoseCurrent(__GLcontext *gc); static GLboolean glAquaMakeCurrent(__GLcontext *gc); static GLboolean glAquaShareContext(__GLcontext *gc, __GLcontext *gcShare); static GLboolean glAquaCopyContext(__GLcontext *dst, const __GLcontext *src, - GLuint mask); + GLuint mask); static GLboolean glAquaForceCurrent(__GLcontext *gc); /* Drawing surface notification callbacks */ @@ -169,7 +176,7 @@ static __GLexports glAquaExports = { typedef struct { int num_vis; - __GLXvisualConfig *glx_vis; + __GLcontextModes *modes; void **priv; // wrapped screen functions @@ -186,15 +193,15 @@ typedef struct { } GLAquaDrawableRec; struct __GLcontextRec { - struct __GLinterfaceRec interface; // required to be first + struct __GLinterfaceRec interface; // required to be first - CGLContextObj ctx; - CGLPixelFormatObj pixelFormat; + CGLContextObj ctx; + CGLPixelFormatObj pixelFormat; - /* set when attached */ - xp_surface_id sid; + /* set when attached */ + xp_surface_id sid; - unsigned isAttached :1; + unsigned isAttached :1; }; /* maps from surface id -> list of __GLcontext */ @@ -210,18 +217,18 @@ static GLboolean glAquaDestroyContext(__GLcontext *gc) if (gc != NULL) { - if (gc->sid != 0 && surface_hash != NULL) - { - lst = x_hash_table_lookup(surface_hash, (void *) gc->sid, NULL); - lst = x_list_remove(lst, gc); - x_hash_table_insert(surface_hash, (void *) gc->sid, lst); - } + if (gc->sid != 0 && surface_hash != NULL) + { + lst = x_hash_table_lookup(surface_hash, (void *) gc->sid, NULL); + lst = x_list_remove(lst, gc); + x_hash_table_insert(surface_hash, (void *) gc->sid, lst); + } if (gc->ctx != NULL) - CGLDestroyContext(gc->ctx); + CGLDestroyContext(gc->ctx); if (gc->pixelFormat != NULL) - CGLDestroyPixelFormat(gc->pixelFormat); + CGLDestroyPixelFormat(gc->pixelFormat); free(gc); } @@ -237,7 +244,7 @@ static GLboolean glAquaLoseCurrent(__GLcontext *gc) gl_err = CGLSetCurrentContext(NULL); if (gl_err != 0) - ErrorF("CGLSetCurrentContext error: %s\n", CGLErrorString(gl_err)); + ErrorF("CGLSetCurrentContext error: %s\n", CGLErrorString(gl_err)); __glXLastContext = NULL; // Mesa does this; why? @@ -256,24 +263,24 @@ static void surface_notify(void *_arg, void *data) switch (arg->kind) { case AppleDRISurfaceNotifyDestroyed: - if (surface_hash != NULL) - x_hash_table_remove(surface_hash, (void *) arg->id); + if (surface_hash != NULL) + x_hash_table_remove(surface_hash, (void *) arg->id); - aquaPriv->pDraw = NULL; - aquaPriv->sid = 0; - break; + aquaPriv->pDraw = NULL; + aquaPriv->sid = 0; + break; case AppleDRISurfaceNotifyChanged: - if (surface_hash != NULL) - { - lst = x_hash_table_lookup(surface_hash, (void *) arg->id, NULL); - for (; lst != NULL; lst = lst->next) - { - gc = lst->data; - xp_update_gl_context(gc->ctx); - } - } - break; + if (surface_hash != NULL) + { + lst = x_hash_table_lookup(surface_hash, (void *) arg->id, NULL); + for (; lst != NULL; lst = lst->next) + { + gc = lst->data; + xp_update_gl_context(gc->ctx); + } + } + break; } } @@ -283,18 +290,18 @@ static void unattach(__GLcontext *gc) if (gc->isAttached) { - GLAQUA_DEBUG_MSG("unattaching\n"); - - if (surface_hash != NULL) - { - lst = x_hash_table_lookup(surface_hash, (void *) gc->sid, NULL); - lst = x_list_remove(lst, gc); - x_hash_table_insert(surface_hash, (void *) gc->sid, lst); - } - - CGLClearDrawable(gc->ctx); - gc->isAttached = FALSE; - gc->sid = 0; + GLAQUA_DEBUG_MSG("unattaching\n"); + + if (surface_hash != NULL) + { + lst = x_hash_table_lookup(surface_hash, (void *) gc->sid, NULL); + lst = x_list_remove(lst, gc); + x_hash_table_insert(surface_hash, (void *) gc->sid, lst); + } + + CGLClearDrawable(gc->ctx); + gc->isAttached = FALSE; + gc->sid = 0; } } @@ -307,52 +314,52 @@ static void attach(__GLcontext *gc, __GLdrawablePrivate *glPriv) if (glxPriv->type == DRAWABLE_WINDOW) { WindowPtr pWin = (WindowPtr) glxPriv->pDraw; - GLAquaDrawableRec *aquaPriv = (GLAquaDrawableRec *)glPriv->private; - x_list *lst; + GLAquaDrawableRec *aquaPriv = (GLAquaDrawableRec *)glPriv->private; + x_list *lst; - if (aquaPriv->sid == 0) - { - if (!quartzProcs->CreateSurface(pWin->drawable.pScreen, + if (aquaPriv->sid == 0) + { + if (!quartzProcs->CreateSurface(pWin->drawable.pScreen, pWin->drawable.id, &pWin->drawable, 0, &aquaPriv->sid, NULL, surface_notify, aquaPriv)) - { - return; - } - aquaPriv->pDraw = &pWin->drawable; - } - - if (!gc->isAttached || gc->sid != aquaPriv->sid) - { - if (xp_attach_gl_context(gc->ctx, aquaPriv->sid) != Success) - { - quartzProcs->DestroySurface(pWin->drawable.pScreen, - pWin->drawable.id, &pWin->drawable, - surface_notify, aquaPriv); - - if (surface_hash != NULL) - x_hash_table_remove(surface_hash, (void *) aquaPriv->sid); - - aquaPriv->sid = 0; - return; - } - - gc->isAttached = TRUE; - gc->sid = aquaPriv->sid; - - if (surface_hash == NULL) - surface_hash = x_hash_table_new(NULL, NULL, NULL, NULL); - - lst = x_hash_table_lookup(surface_hash, (void *) gc->sid, NULL); - if (x_list_find(lst, gc) == NULL) - { - lst = x_list_prepend(lst, gc); - x_hash_table_insert(surface_hash, (void *) gc->sid, lst); - } - - GLAQUA_DEBUG_MSG("attached 0x%x to 0x%x\n", pWin->drawable.id, + { + return; + } + aquaPriv->pDraw = &pWin->drawable; + } + + if (!gc->isAttached || gc->sid != aquaPriv->sid) + { + if (xp_attach_gl_context(gc->ctx, aquaPriv->sid) != Success) + { + quartzProcs->DestroySurface(pWin->drawable.pScreen, + pWin->drawable.id, &pWin->drawable, + surface_notify, aquaPriv); + + if (surface_hash != NULL) + x_hash_table_remove(surface_hash, (void *) aquaPriv->sid); + + aquaPriv->sid = 0; + return; + } + + gc->isAttached = TRUE; + gc->sid = aquaPriv->sid; + + if (surface_hash == NULL) + surface_hash = x_hash_table_new(NULL, NULL, NULL, NULL); + + lst = x_hash_table_lookup(surface_hash, (void *) gc->sid, NULL); + if (x_list_find(lst, gc) == NULL) + { + lst = x_list_prepend(lst, gc); + x_hash_table_insert(surface_hash, (void *) gc->sid, lst); + } + + GLAQUA_DEBUG_MSG("attached 0x%x to 0x%x\n", pWin->drawable.id, aquaPriv->sid); - } + } } else { GLAQUA_DEBUG_MSG("attach: attach to non-window unimplemented\n"); CGLClearDrawable(gc->ctx); @@ -371,7 +378,7 @@ static GLboolean glAquaMakeCurrent(__GLcontext *gc) gl_err = CGLSetCurrentContext(gc->ctx); if (gl_err != 0) - ErrorF("CGLSetCurrentContext error: %s\n", CGLErrorString(gl_err)); + ErrorF("CGLSetCurrentContext error: %s\n", CGLErrorString(gl_err)); return gl_err == 0; } @@ -392,7 +399,7 @@ static GLboolean glAquaCopyContext(__GLcontext *dst, const __GLcontext *src, gl_err = CGLCopyContext(src->ctx, dst->ctx, mask); if (gl_err != 0) - ErrorF("CGLCopyContext error: %s\n", CGLErrorString(gl_err)); + ErrorF("CGLCopyContext error: %s\n", CGLErrorString(gl_err)); return gl_err == 0; } @@ -405,7 +412,7 @@ static GLboolean glAquaForceCurrent(__GLcontext *gc) gl_err = CGLSetCurrentContext(gc->ctx); if (gl_err != 0) - ErrorF("CGLSetCurrentContext error: %s\n", CGLErrorString(gl_err)); + ErrorF("CGLSetCurrentContext error: %s\n", CGLErrorString(gl_err)); return gl_err == 0; } @@ -456,7 +463,7 @@ static CGLPixelFormatObj makeFormat(__GLcontextModes *mode) GLAQUA_DEBUG_MSG("makeFormat\n"); if (!mode->rgbMode) - return NULL; + return NULL; i = 0; @@ -471,14 +478,14 @@ static CGLPixelFormatObj makeFormat(__GLcontextModes *mode) } if (mode->colorIndexMode) { - /* ignored */ + /* ignored */ } if (mode->rgbMode) { attr[i++] = kCGLPFAColorSize; attr[i++] = mode->redBits + mode->greenBits + mode->blueBits; attr[i++] = kCGLPFAAlphaSize; - attr[i++] = 1; /* FIXME: ignoring mode->alphaBits which is always 0 */ + attr[i++] = 1; /* FIXME: ignoring mode->alphaBits which is always 0 */ } if (mode->haveAccumBuffer) { @@ -509,7 +516,7 @@ static CGLPixelFormatObj makeFormat(__GLcontextModes *mode) result = NULL; gl_err = CGLChoosePixelFormat(attr, &result, &n_formats); if (gl_err != 0) - ErrorF("CGLChoosePixelFormat error: %s\n", CGLErrorString(gl_err)); + ErrorF("CGLChoosePixelFormat error: %s\n", CGLErrorString(gl_err)); GLAQUA_DEBUG_MSG("makeFormat done (0x%x)\n", result); @@ -517,8 +524,8 @@ static CGLPixelFormatObj makeFormat(__GLcontextModes *mode) } static __GLinterface *glAquaCreateContext(__GLimports *imports, - __GLcontextModes *mode, - __GLinterface *shareGC) + __GLcontextModes *mode, + __GLinterface *shareGC) { __GLcontext *result; __GLcontext *sharectx = (__GLcontext *)shareGC; @@ -540,11 +547,11 @@ static __GLinterface *glAquaCreateContext(__GLimports *imports, result->ctx = NULL; gl_err = CGLCreateContext(result->pixelFormat, - sharectx ? sharectx->ctx : NULL, - &result->ctx); + sharectx ? sharectx->ctx : NULL, + &result->ctx); if (gl_err != 0) { - ErrorF("CGLCreateContext error: %s\n", CGLErrorString(gl_err)); + ErrorF("CGLCreateContext error: %s\n", CGLErrorString(gl_err)); CGLDestroyPixelFormat(result->pixelFormat); free(result); return NULL; @@ -638,19 +645,22 @@ glAquaUnrealizeWindow(WindowPtr pWin) return result; } -/* - * In the case the driver has no GLX visuals we'll use these. - * [0] = RGB, double buffered - * [1] = RGB, double buffered, stencil, accum - */ + // Originally copied from Mesa static int numConfigs = 0; static __GLXvisualConfig *visualConfigs = NULL; static void **visualPrivates = NULL; -#define NUM_FALLBACK_CONFIGS 2 +/* + * In the case the driver defines no GLX visuals we'll use these. + * Note that for TrueColor and DirectColor visuals, bufferSize is the + * sum of redSize, greenSize, blueSize and alphaSize, which may be larger + * than the nplanes/rootDepth of the server's X11 visuals + */ +#define NUM_FALLBACK_CONFIGS 5 static __GLXvisualConfig FallbackConfigs[NUM_FALLBACK_CONFIGS] = { + /* [0] = RGB, double buffered, Z */ { -1, /* vid */ -1, /* class */ @@ -665,11 +675,12 @@ static __GLXvisualConfig FallbackConfigs[NUM_FALLBACK_CONFIGS] = { 0, /* stencilSize */ 0, /* auxBuffers */ 0, /* level */ - GLX_NONE_EXT, /* visualRating */ - 0, /* transparentPixel */ + GLX_NONE, /* visualRating */ + GLX_NONE, /* transparentPixel */ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ 0 /* transparentIndex */ }, + /* [1] = RGB, double buffered, Z, stencil, accum */ { -1, /* vid */ -1, /* class */ @@ -684,11 +695,71 @@ static __GLXvisualConfig FallbackConfigs[NUM_FALLBACK_CONFIGS] = { 8, /* stencilSize */ 0, /* auxBuffers */ 0, /* level */ - GLX_NONE_EXT, /* visualRating */ - 0, /* transparentPixel */ + GLX_NONE, /* visualRating */ + GLX_NONE, /* transparentPixel */ + 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ + 0 /* transparentIndex */ + }, + /* [2] = RGB+Alpha, double buffered, Z, stencil, accum */ + { + -1, /* vid */ + -1, /* class */ + True, /* rgba */ + -1, -1, -1, 8, /* rgba sizes */ + -1, -1, -1, -1, /* rgba masks */ + 16, 16, 16, 16, /* rgba accum sizes */ + True, /* doubleBuffer */ + False, /* stereo */ + -1, /* bufferSize */ + 16, /* depthSize */ + 8, /* stencilSize */ + 0, /* auxBuffers */ + 0, /* level */ + GLX_NONE, /* visualRating */ + GLX_NONE, /* transparentPixel */ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ 0 /* transparentIndex */ - } + }, + /* [3] = RGB+Alpha, single buffered, Z, stencil, accum */ + { + -1, /* vid */ + -1, /* class */ + True, /* rgba */ + -1, -1, -1, 8, /* rgba sizes */ + -1, -1, -1, -1, /* rgba masks */ + 16, 16, 16, 16, /* rgba accum sizes */ + False, /* doubleBuffer */ + False, /* stereo */ + -1, /* bufferSize */ + 16, /* depthSize */ + 8, /* stencilSize */ + 0, /* auxBuffers */ + 0, /* level */ + GLX_NONE, /* visualRating */ + GLX_NONE, /* transparentPixel */ + 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ + 0 /* transparentIndex */ + }, + /* [4] = CI, double buffered, Z */ + { + -1, /* vid */ + -1, /* class */ + False, /* rgba? (false = color index) */ + -1, -1, -1, 0, /* rgba sizes */ + -1, -1, -1, 0, /* rgba masks */ + 0, 0, 0, 0, /* rgba accum sizes */ + True, /* doubleBuffer */ + False, /* stereo */ + -1, /* bufferSize */ + 16, /* depthSize */ + 0, /* stencilSize */ + 0, /* auxBuffers */ + 0, /* level */ + GLX_NONE, /* visualRating */ + GLX_NONE, /* transparentPixel */ + 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ + 0 /* transparentIndex */ + }, }; static __GLXvisualConfig NullConfig = { @@ -721,11 +792,11 @@ static inline int count_bits(uint32_t x) return x & 63; } -// Mostly copied from Mesa's xf86glx.c + static Bool init_visuals(int *nvisualp, VisualPtr *visualp, - VisualID *defaultVisp, - int ndepth, DepthPtr pdepth, - int rootDepth) + VisualID *defaultVisp, + int ndepth, DepthPtr pdepth, + int rootDepth) { int numRGBconfigs; int numCIconfigs; @@ -735,7 +806,7 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp, VisualPtr pVisual = *visualp; VisualPtr pVisualNew = NULL; VisualID *orig_vid = NULL; - __GLXvisualConfig *glXVisualPtr = NULL; + __GLcontextModes *modes; __GLXvisualConfig *pNewVisualConfigs = NULL; void **glXVisualPriv; void **pNewVisualPriv; @@ -753,14 +824,14 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp, pNewVisualConfigs = (__GLXvisualConfig *) __glXMalloc(numNewConfigs * sizeof(__GLXvisualConfig)); if (!pNewVisualConfigs) { - return FALSE; + return FALSE; } /* Alloc space for the list of new GLX visual privates */ pNewVisualPriv = (void **) __glXMalloc(numNewConfigs * sizeof(void *)); if (!pNewVisualPriv) { - __glXFree(pNewVisualConfigs); - return FALSE; + __glXFree(pNewVisualConfigs); + return FALSE; } /* @@ -768,9 +839,9 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp, ** visual configs. */ if (numConfigs == 0) { - memcpy(pNewVisualConfigs, FallbackConfigs, + memcpy(pNewVisualConfigs, FallbackConfigs, NUM_FALLBACK_CONFIGS * sizeof(__GLXvisualConfig)); - memset(pNewVisualPriv, 0, NUM_FALLBACK_CONFIGS * sizeof(void *)); + memset(pNewVisualPriv, 0, NUM_FALLBACK_CONFIGS * sizeof(void *)); } else { /* copy driver's visual config info */ @@ -784,22 +855,22 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp, numRGBconfigs = 0; numCIconfigs = 0; for (i = 0; i < numNewConfigs; i++) { - if (pNewVisualConfigs[i].rgba) - numRGBconfigs++; - else - numCIconfigs++; + if (pNewVisualConfigs[i].rgba) + numRGBconfigs++; + else + numCIconfigs++; } /* Count the total number of visuals to compute */ numNewVisuals = 0; for (i = 0; i < numVisuals; i++) { - int count; + int count; - count = ((pVisual[i].class == TrueColor - || pVisual[i].class == DirectColor) - ? numRGBconfigs : numCIconfigs); - if (count == 0) - count = 1; /* preserve the existing visual */ + count = ((pVisual[i].class == TrueColor + || pVisual[i].class == DirectColor) + ? numRGBconfigs : numCIconfigs); + if (count == 0) + count = 1; /* preserve the existing visual */ numNewVisuals += count; } @@ -811,154 +882,159 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp, /* Alloc temp space for the list of orig VisualIDs for each new visual */ orig_vid = (VisualID *)__glXMalloc(numNewVisuals * sizeof(VisualID)); if (!orig_vid) { - __glXFree(pNewVisualPriv); - __glXFree(pNewVisualConfigs); - return FALSE; + __glXFree(pNewVisualPriv); + __glXFree(pNewVisualConfigs); + return FALSE; } /* Alloc space for the list of glXVisuals */ - glXVisualPtr = (__GLXvisualConfig *)__glXMalloc(numNewVisuals * - sizeof(__GLXvisualConfig)); - if (!glXVisualPtr) { - __glXFree(orig_vid); - __glXFree(pNewVisualPriv); - __glXFree(pNewVisualConfigs); - return FALSE; + modes = _gl_context_modes_create(numNewVisuals, sizeof(__GLcontextModes)); + if (modes == NULL) { + __glXFree(orig_vid); + __glXFree(pNewVisualPriv); + __glXFree(pNewVisualConfigs); + return FALSE; } /* Alloc space for the list of glXVisualPrivates */ glXVisualPriv = (void **)__glXMalloc(numNewVisuals * sizeof(void *)); if (!glXVisualPriv) { - __glXFree(glXVisualPtr); - __glXFree(orig_vid); - __glXFree(pNewVisualPriv); - __glXFree(pNewVisualConfigs); - return FALSE; + _gl_context_modes_destroy( modes ); + __glXFree(orig_vid); + __glXFree(pNewVisualPriv); + __glXFree(pNewVisualConfigs); + return FALSE; } /* Alloc space for the new list of the X server's visuals */ pVisualNew = (VisualPtr)__glXMalloc(numNewVisuals * sizeof(VisualRec)); if (!pVisualNew) { - __glXFree(glXVisualPriv); - __glXFree(glXVisualPtr); - __glXFree(orig_vid); - __glXFree(pNewVisualPriv); - __glXFree(pNewVisualConfigs); - return FALSE; + __glXFree(glXVisualPriv); + _gl_context_modes_destroy( modes ); + __glXFree(orig_vid); + __glXFree(pNewVisualPriv); + __glXFree(pNewVisualConfigs); + return FALSE; } /* Initialize the new visuals */ found_default = FALSE; + glAquaScreens[screenInfo.numScreens-1].modes = modes; for (i = j = 0; i < numVisuals; i++) { int is_rgb = (pVisual[i].class == TrueColor || - pVisual[i].class == DirectColor); - - if (!is_rgb) - { - /* We don't support non-rgb visuals for GL. But we don't - want to remove them either, so just pass them through - with null glX configs */ - - pVisualNew[j] = pVisual[i]; - pVisualNew[j].vid = FakeClientID(0); - - /* Check for the default visual */ - if (!found_default && pVisual[i].vid == *defaultVisp) { - *defaultVisp = pVisualNew[j].vid; - found_default = TRUE; - } - - /* Save the old VisualID */ - orig_vid[j] = pVisual[i].vid; - - /* Initialize the glXVisual */ - glXVisualPtr[j] = NullConfig; - glXVisualPriv[j] = NULL; - - j++; - - continue; - } - - for (k = 0; k < numNewConfigs; k++) { - if (pNewVisualConfigs[k].rgba != is_rgb) - continue; - - /* Initialize the new visual */ - pVisualNew[j] = pVisual[i]; - pVisualNew[j].vid = FakeClientID(0); - - /* Check for the default visual */ - if (!found_default && pVisual[i].vid == *defaultVisp) { - *defaultVisp = pVisualNew[j].vid; - found_default = TRUE; - } - - /* Save the old VisualID */ - orig_vid[j] = pVisual[i].vid; - - /* Initialize the glXVisual */ - glXVisualPtr[j] = pNewVisualConfigs[k]; - glXVisualPtr[j].vid = pVisualNew[j].vid; - - /* - * If the class is -1, then assume the X visual information - * is identical to what GLX needs, and take them from the X - * visual. NOTE: if class != -1, then all other fields MUST - * be initialized. - */ - if (glXVisualPtr[j].class == -1) { - glXVisualPtr[j].class = pVisual[i].class; - glXVisualPtr[j].redSize = count_bits(pVisual[i].redMask); - glXVisualPtr[j].greenSize = count_bits(pVisual[i].greenMask); - glXVisualPtr[j].blueSize = count_bits(pVisual[i].blueMask); - glXVisualPtr[j].alphaSize = glXVisualPtr[j].alphaSize; - glXVisualPtr[j].redMask = pVisual[i].redMask; - glXVisualPtr[j].greenMask = pVisual[i].greenMask; - glXVisualPtr[j].blueMask = pVisual[i].blueMask; - glXVisualPtr[j].alphaMask = glXVisualPtr[j].alphaMask; - glXVisualPtr[j].bufferSize = rootDepth; - } - - /* Save the device-dependent private for this visual */ - glXVisualPriv[j] = pNewVisualPriv[k]; - - j++; - } + pVisual[i].class == DirectColor); + + if (!is_rgb) + { + /* We don't support non-rgb visuals for GL. But we don't + want to remove them either, so just pass them through + with null glX configs */ + + pVisualNew[j] = pVisual[i]; + pVisualNew[j].vid = FakeClientID(0); + + /* Check for the default visual */ + if (!found_default && pVisual[i].vid == *defaultVisp) { + *defaultVisp = pVisualNew[j].vid; + found_default = TRUE; + } + + /* Save the old VisualID */ + orig_vid[j] = pVisual[i].vid; + + /* Initialize the glXVisual */ + _gl_copy_visual_to_context_mode( modes, & NullConfig ); + modes->visualID = pVisualNew[j].vid; + + j++; + + continue; + } + + for (k = 0; k < numNewConfigs; k++) { + if (pNewVisualConfigs[k].rgba != is_rgb) + continue; + + assert( modes != NULL ); + + /* Initialize the new visual */ + pVisualNew[j] = pVisual[i]; + pVisualNew[j].vid = FakeClientID(0); + + /* Check for the default visual */ + if (!found_default && pVisual[i].vid == *defaultVisp) { + *defaultVisp = pVisualNew[j].vid; + found_default = TRUE; + } + + /* Save the old VisualID */ + orig_vid[j] = pVisual[i].vid; + + /* Initialize the glXVisual */ + _gl_copy_visual_to_context_mode( modes, & pNewVisualConfigs[k] ); + modes->visualID = pVisualNew[j].vid; + + /* + * If the class is -1, then assume the X visual information + * is identical to what GLX needs, and take them from the X + * visual. NOTE: if class != -1, then all other fields MUST + * be initialized. + */ + if (modes->visualType == GLX_NONE) { + modes->visualType = _gl_convert_from_x_visual_type( pVisual[i].class ); + modes->redBits = count_bits(pVisual[i].redMask); + modes->greenBits = count_bits(pVisual[i].greenMask); + modes->blueBits = count_bits(pVisual[i].blueMask); + modes->alphaBits = modes->alphaBits; + modes->redMask = pVisual[i].redMask; + modes->greenMask = pVisual[i].greenMask; + modes->blueMask = pVisual[i].blueMask; + modes->alphaMask = modes->alphaMask; + modes->rgbBits = (is_rgb) + ? (modes->redBits + modes->greenBits + + modes->blueBits + modes->alphaBits) + : rootDepth; + } + + /* Save the device-dependent private for this visual */ + glXVisualPriv[j] = pNewVisualPriv[k]; + + j++; + modes = modes->next; + } } assert(j <= numNewVisuals); /* Save the GLX visuals in the screen structure */ glAquaScreens[screenInfo.numScreens-1].num_vis = numNewVisuals; - glAquaScreens[screenInfo.numScreens-1].glx_vis = glXVisualPtr; glAquaScreens[screenInfo.numScreens-1].priv = glXVisualPriv; /* Set up depth's VisualIDs */ for (i = 0; i < ndepth; i++) { - int numVids = 0; - VisualID *pVids = NULL; - int k, n = 0; - - /* Count the new number of VisualIDs at this depth */ - for (j = 0; j < pdepth[i].numVids; j++) - for (k = 0; k < numNewVisuals; k++) - if (pdepth[i].vids[j] == orig_vid[k]) - numVids++; - - /* Allocate a new list of VisualIDs for this depth */ - pVids = (VisualID *)__glXMalloc(numVids * sizeof(VisualID)); - - /* Initialize the new list of VisualIDs for this depth */ - for (j = 0; j < pdepth[i].numVids; j++) - for (k = 0; k < numNewVisuals; k++) - if (pdepth[i].vids[j] == orig_vid[k]) - pVids[n++] = pVisualNew[k].vid; - - /* Update this depth's list of VisualIDs */ - __glXFree(pdepth[i].vids); - pdepth[i].vids = pVids; - pdepth[i].numVids = numVids; + int numVids = 0; + VisualID *pVids = NULL; + int k, n = 0; + + /* Count the new number of VisualIDs at this depth */ + for (j = 0; j < pdepth[i].numVids; j++) + for (k = 0; k < numNewVisuals; k++) + if (pdepth[i].vids[j] == orig_vid[k]) + numVids++; + + /* Allocate a new list of VisualIDs for this depth */ + pVids = (VisualID *)__glXMalloc(numVids * sizeof(VisualID)); + + /* Initialize the new list of VisualIDs for this depth */ + for (j = 0; j < pdepth[i].numVids; j++) + for (k = 0; k < numNewVisuals; k++) + if (pdepth[i].vids[j] == orig_vid[k]) + pVids[n++] = pVisualNew[k].vid; + + /* Update this depth's list of VisualIDs */ + __glXFree(pdepth[i].vids); + pdepth[i].vids = pVids; + pdepth[i].numVids = numVids; } /* Update the X server's visuals */ @@ -995,14 +1071,14 @@ glAquaInitVisualConfigs(void) int i = 0; GLAQUA_DEBUG_MSG("glAquaInitVisualConfigs "); - + /* count num configs: - 2 Z buffer (0, 24 bit) - 2 AUX buffer (0, 2) - 2 buffers (single, double) - 2 stencil (0, 8 bit) - 2 accum (0, 64 bit) - = 32 configs */ + 2 Z buffer (0, 24 bit) + 2 AUX buffer (0, 2) + 2 buffers (single, double) + 2 stencil (0, 8 bit) + 2 accum (0, 64 bit) + = 32 configs */ lclNumConfigs = 2 * 2 * 2 * 2 * 2; /* 32 */ @@ -1012,66 +1088,65 @@ glAquaInitVisualConfigs(void) /* fill in configs */ if (NULL != lclVisualConfigs) { - i = 0; /* current buffer */ - for (depth = 0; depth < 2; depth++) { - for (aux = 0; aux < 2; aux++) { - for (buffers = 0; buffers < 2; buffers++) { - for (stencil = 0; stencil < 2; stencil++) { - for (accum = 0; accum < 2; accum++) { - lclVisualConfigs[i].vid = -1; - lclVisualConfigs[i].class = -1; - lclVisualConfigs[i].rgba = TRUE; - lclVisualConfigs[i].redSize = -1; - lclVisualConfigs[i].greenSize = -1; - lclVisualConfigs[i].blueSize = -1; - lclVisualConfigs[i].redMask = -1; - lclVisualConfigs[i].greenMask = -1; - lclVisualConfigs[i].blueMask = -1; - lclVisualConfigs[i].alphaMask = 0; - if (accum) { - lclVisualConfigs[i].accumRedSize = 16; - lclVisualConfigs[i].accumGreenSize = 16; - lclVisualConfigs[i].accumBlueSize = 16; - lclVisualConfigs[i].accumAlphaSize = 16; - } - else { - lclVisualConfigs[i].accumRedSize = 0; - lclVisualConfigs[i].accumGreenSize = 0; - lclVisualConfigs[i].accumBlueSize = 0; - lclVisualConfigs[i].accumAlphaSize = 0; - } - lclVisualConfigs[i].doubleBuffer = buffers ? TRUE : FALSE; - lclVisualConfigs[i].stereo = FALSE; - lclVisualConfigs[i].bufferSize = -1; - - lclVisualConfigs[i].depthSize = depth? 24 : 0; - lclVisualConfigs[i].stencilSize = stencil ? 8 : 0; - lclVisualConfigs[i].auxBuffers = aux ? 2 : 0; - lclVisualConfigs[i].level = 0; - lclVisualConfigs[i].visualRating = GLX_NONE_EXT; - lclVisualConfigs[i].transparentPixel = 0; - lclVisualConfigs[i].transparentRed = 0; - lclVisualConfigs[i].transparentGreen = 0; - lclVisualConfigs[i].transparentBlue = 0; - lclVisualConfigs[i].transparentAlpha = 0; - lclVisualConfigs[i].transparentIndex = 0; - i++; - } - } - } - } - } + i = 0; /* current buffer */ + for (depth = 0; depth < 2; depth++) { + for (aux = 0; aux < 2; aux++) { + for (buffers = 0; buffers < 2; buffers++) { + for (stencil = 0; stencil < 2; stencil++) { + for (accum = 0; accum < 2; accum++) { + lclVisualConfigs[i].vid = -1; + lclVisualConfigs[i].class = -1; + lclVisualConfigs[i].rgba = TRUE; + lclVisualConfigs[i].redSize = -1; + lclVisualConfigs[i].greenSize = -1; + lclVisualConfigs[i].blueSize = -1; + lclVisualConfigs[i].redMask = -1; + lclVisualConfigs[i].greenMask = -1; + lclVisualConfigs[i].blueMask = -1; + lclVisualConfigs[i].alphaMask = 0; + if (accum) { + lclVisualConfigs[i].accumRedSize = 16; + lclVisualConfigs[i].accumGreenSize = 16; + lclVisualConfigs[i].accumBlueSize = 16; + lclVisualConfigs[i].accumAlphaSize = 16; + } + else { + lclVisualConfigs[i].accumRedSize = 0; + lclVisualConfigs[i].accumGreenSize = 0; + lclVisualConfigs[i].accumBlueSize = 0; + lclVisualConfigs[i].accumAlphaSize = 0; + } + lclVisualConfigs[i].doubleBuffer = buffers ? TRUE : FALSE; + lclVisualConfigs[i].stereo = FALSE; + lclVisualConfigs[i].bufferSize = -1; + + lclVisualConfigs[i].depthSize = depth? 24 : 0; + lclVisualConfigs[i].stencilSize = stencil ? 8 : 0; + lclVisualConfigs[i].auxBuffers = aux ? 2 : 0; + lclVisualConfigs[i].level = 0; + lclVisualConfigs[i].visualRating = GLX_NONE_EXT; + lclVisualConfigs[i].transparentPixel = 0; + lclVisualConfigs[i].transparentRed = 0; + lclVisualConfigs[i].transparentGreen = 0; + lclVisualConfigs[i].transparentBlue = 0; + lclVisualConfigs[i].transparentAlpha = 0; + lclVisualConfigs[i].transparentIndex = 0; + i++; + } + } + } + } + } } if (i != lclNumConfigs) - GLAQUA_DEBUG_MSG("glAquaInitVisualConfigs failed to alloc visual configs"); + GLAQUA_DEBUG_MSG("glAquaInitVisualConfigs failed to alloc visual configs"); GlxSetVisualConfigs(lclNumConfigs, lclVisualConfigs, lclVisualPrivates); } -// Copied from Mesa static void glAquaSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, - void **privates) + void **privates) { GLAQUA_DEBUG_MSG("glAquaSetVisualConfigs\n"); @@ -1080,122 +1155,114 @@ static void glAquaSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, visualPrivates = privates; } -// Copied from Mesa static Bool glAquaInitVisuals(VisualPtr *visualp, DepthPtr *depthp, - int *nvisualp, int *ndepthp, - int *rootDepthp, VisualID *defaultVisp, - unsigned long sizes, int bitsPerRGB) + int *nvisualp, int *ndepthp, + int *rootDepthp, VisualID *defaultVisp, + unsigned long sizes, int bitsPerRGB) { GLAQUA_DEBUG_MSG("glAquaInitVisuals\n"); if (0 == numConfigs) /* if no configs */ - glAquaInitVisualConfigs(); /* ensure the visula configs are setup */ + glAquaInitVisualConfigs(); /* ensure the visula configs are setup */ /* * Setup the visuals supported by this particular screen. */ return init_visuals(nvisualp, visualp, defaultVisp, - *ndepthp, *depthp, *rootDepthp); + *ndepthp, *depthp, *rootDepthp); } + static void fixup_visuals(int screen) { ScreenPtr pScreen = screenInfo.screens[screen]; glAquaScreenRec *pScr = &glAquaScreens[screen]; - __GLXvisualConfig *pGLXVis = pScr->glx_vis; - VisualPtr pVis; - int i, j; + int j; + __GLcontextModes *modes; GLAQUA_DEBUG_MSG("fixup_visuals\n"); - for (i = 0; i < pScr->num_vis; i++, pGLXVis++) { - pVis = pScreen->visuals; - - /* Find a visual that matches the GLX visual's class and size */ - for (j = 0; j < pScreen->numVisuals; j++, pVis++) { - if (pVis->class == pGLXVis->class && - pVis->nplanes == pGLXVis->bufferSize) { - - /* Fixup the masks */ - pGLXVis->redMask = pVis->redMask; - pGLXVis->greenMask = pVis->greenMask; - pGLXVis->blueMask = pVis->blueMask; - - /* Recalc the sizes */ - pGLXVis->redSize = count_bits(pGLXVis->redMask); - pGLXVis->greenSize = count_bits(pGLXVis->greenMask); - pGLXVis->blueSize = count_bits(pGLXVis->blueMask); - } - } + for ( modes = pScr->modes ; modes != NULL ; modes = modes->next ) { + const int vis_class = _gl_convert_to_x_visual_type( modes->visualType ); + const int nplanes = (modes->rgbBits - modes->alphaBits); + const VisualPtr pVis = pScreen->visuals; + + /* Find a visual that matches the GLX visual's class and size */ + for (j = 0; j < pScreen->numVisuals; j++) { + if (pVis[j].class == vis_class && + pVis[j].nplanes == nplanes) { + + /* Fixup the masks */ + modes->redMask = pVis[j].redMask; + modes->greenMask = pVis[j].greenMask; + modes->blueMask = pVis[j].blueMask; + + /* Recalc the sizes */ + modes->redBits = count_bits(modes->redMask); + modes->greenBits = count_bits(modes->greenMask); + modes->blueBits = count_bits(modes->blueMask); + } + } } } static void init_screen_visuals(int screen) { ScreenPtr pScreen = screenInfo.screens[screen]; - __GLXvisualConfig *pGLXVis = glAquaScreens[screen].glx_vis; - // XMesaVisual *pXMesaVisual; - VisualPtr pVis; + __GLcontextModes *modes; int *used; int i, j; GLAQUA_DEBUG_MSG("init_screen_visuals\n"); - /* Alloc space for the list of XMesa visuals */ - // pXMesaVisual = (XMesaVisual *)__glXMalloc(MESAScreens[screen].num_vis * - // sizeof(XMesaVisual)); - // __glXMemset(pXMesaVisual, 0, - // MESAScreens[screen].num_vis * sizeof(XMesaVisual)); - + /* FIXME: Change 'used' to be a array of bits (rather than of ints), + * FIXME: create a stack array of 8 or 16 bytes. If 'numVisuals' is less + * FIXME: than 64 or 128 the stack array can be used instead of calling + * FIXME: __glXMalloc / __glXFree. If nothing else, convert 'used' to + * FIXME: array of bytes instead of ints! + */ used = (int *)__glXMalloc(pScreen->numVisuals * sizeof(int)); __glXMemset(used, 0, pScreen->numVisuals * sizeof(int)); - for (i = 0; i < glAquaScreens[screen].num_vis; i++, pGLXVis++) { - pVis = pScreen->visuals; - for (j = 0; j < pScreen->numVisuals; j++, pVis++) { - - if (pVis->class == pGLXVis->class && - pVis->nplanes == pGLXVis->bufferSize && - !used[j]) { - - if (pVis->redMask == pGLXVis->redMask && - pVis->greenMask == pGLXVis->greenMask && - pVis->blueMask == pGLXVis->blueMask) { - - /* Create the XMesa visual */ - /* - pXMesaVisual[i] = - XMesaCreateVisual(pScreen, - pVis, - pGLXVis->rgba, - (pGLXVis->alphaSize > 0), - pGLXVis->doubleBuffer, - pGLXVis->stereo, - GL_TRUE, // ximage_flag - pGLXVis->depthSize, - pGLXVis->stencilSize, - pGLXVis->accumRedSize, - pGLXVis->accumGreenSize, - pGLXVis->accumBlueSize, - pGLXVis->accumAlphaSize, - 0, // numSamples - pGLXVis->level, - pGLXVis->visualRating ); - */ - /* Set the VisualID */ - pGLXVis->vid = pVis->vid; - - /* Mark this visual used */ - used[j] = 1; - break; - } - } - } + i = 0; + for ( modes = glAquaScreens[screen].modes + ; modes != NULL + ; modes = modes->next ) { + const int vis_class = _gl_convert_to_x_visual_type( modes->visualType ); + const int nplanes = (modes->rgbBits - modes->alphaBits); + const VisualPtr pVis = pScreen->visuals; + + for (j = 0; j < pScreen->numVisuals; j++) { + if (pVis[j].class == vis_class && + pVis[j].nplanes == nplanes && + pVis[j].redMask == modes->redMask && + pVis[j].greenMask == modes->greenMask && + pVis[j].blueMask == modes->blueMask && + !used[j]) { + + /* Set the VisualID */ + modes->visualID = pVis[j].vid; + + /* Mark this visual used */ + used[j] = 1; + break; + } + } + if ( j == pScreen->numVisuals ) { + ErrorF("No matching visual for __GLcontextMode with " + "visual class = %d (%d), nplanes = %u\n", + vis_class, + (int)modes->visualType, + (unsigned int)(modes->rgbBits - modes->alphaBits) ); + } + else if ( modes->visualID == -1 ) { + FatalError( "Matching visual found, but visualID still -1!\n" ); + } + + i++; } __glXFree(used); - - // glAquaScreens[screen].xm_vis = pXMesaVisual; } static Bool glAquaScreenProbe(int screen) @@ -1208,10 +1275,10 @@ static Bool glAquaScreenProbe(int screen) /* * Set up the current screen's visuals. */ - __glDDXScreenInfo.pGlxVisual = glAquaScreens[screen].glx_vis; + __glDDXScreenInfo.modes = glAquaScreens[screen].modes; __glDDXScreenInfo.pVisualPriv = glAquaScreens[screen].priv; __glDDXScreenInfo.numVisuals = - __glDDXScreenInfo.numUsableVisuals = glAquaScreens[screen].num_vis; + __glDDXScreenInfo.numUsableVisuals = glAquaScreens[screen].num_vis; /* * Set the current screen's createContext routine. This could be @@ -1231,7 +1298,9 @@ static Bool glAquaScreenProbe(int screen) */ init_screen_visuals(screen); - // Wrap RealizeWindow and UnrealizeWindow on this screen + /* + * Wrap RealizeWindow and UnrealizeWindow on this screen + */ pScreen = screenInfo.screens[screen]; screenPriv = &glAquaScreens[screen]; screenPriv->RealizeWindow = pScreen->RealizeWindow; @@ -1253,9 +1322,9 @@ static GLboolean glAquaSwapBuffers(__GLXdrawablePrivate *glxPriv) if (gc != NULL && gc->ctx != NULL) { - gl_err = CGLFlushDrawable(gc->ctx); - if (gl_err != 0) - ErrorF("CGLFlushDrawable error: %s\n", CGLErrorString(gl_err)); + gl_err = CGLFlushDrawable(gc->ctx); + if (gl_err != 0) + ErrorF("CGLFlushDrawable error: %s\n", CGLErrorString(gl_err)); } return GL_TRUE; @@ -1308,24 +1377,24 @@ GLint __glEvalComputeK(GLenum target) case GL_MAP2_VERTEX_4: case GL_MAP2_COLOR_4: case GL_MAP2_TEXTURE_COORD_4: - return 4; + return 4; case GL_MAP1_VERTEX_3: case GL_MAP1_TEXTURE_COORD_3: case GL_MAP1_NORMAL: case GL_MAP2_VERTEX_3: case GL_MAP2_TEXTURE_COORD_3: case GL_MAP2_NORMAL: - return 3; + return 3; case GL_MAP1_TEXTURE_COORD_2: case GL_MAP2_TEXTURE_COORD_2: - return 2; + return 2; case GL_MAP1_TEXTURE_COORD_1: case GL_MAP2_TEXTURE_COORD_1: case GL_MAP1_INDEX: case GL_MAP2_INDEX: - return 1; + return 1; default: - return 0; + return 0; } } @@ -1334,8 +1403,8 @@ GLuint __glFloorLog2(GLuint val) int c = 0; while (val > 1) { - c++; - val >>= 1; + c++; + val >>= 1; } return c; } diff --git a/GL/glx/g_disptab.c b/GL/glx/g_disptab.c index 12d1abe56..8c8dc2ccc 100644 --- a/GL/glx/g_disptab.c +++ b/GL/glx/g_disptab.c @@ -54,18 +54,18 @@ __GLXdispatchSingleProcPtr __glXSingleTable[__GLX_SINGLE_TABLE_SIZE] = { __glXQueryExtensionsString, __glXQueryServerString, __glXClientInfo, - __glXNoSuchSingleOpcode, /* glXGetFBConfigs */ - __glXNoSuchSingleOpcode, /* glXCreatePixmap */ - __glXNoSuchSingleOpcode, /* glXDestroyPixmap */ - __glXNoSuchSingleOpcode, /* glXCreateNewContext */ + __glXGetFBConfigs, + __glXCreatePixmap, + __glXDestroyGLXPixmap, /* glXDestroyPixmap */ + __glXCreateNewContext, __glXNoSuchSingleOpcode, /* glXQueryContext */ __glXMakeContextCurrent, - __glXNoSuchSingleOpcode, - __glXNoSuchSingleOpcode, - __glXNoSuchSingleOpcode, - __glXNoSuchSingleOpcode, - __glXNoSuchSingleOpcode, - __glXNoSuchSingleOpcode, + __glXNoSuchSingleOpcode, /* glXCreatePbuffer */ + __glXNoSuchSingleOpcode, /* glXDestroyPbuffer */ + __glXNoSuchSingleOpcode, /* glXGetDrawableAttributes */ + __glXNoSuchSingleOpcode, /* glXChangeDrawableAttributes */ + __glXNoSuchSingleOpcode, /* glXCreateWindow */ + __glXNoSuchSingleOpcode, /* glXDestroyWindow */ __glXNoSuchSingleOpcode, __glXNoSuchSingleOpcode, __glXNoSuchSingleOpcode, @@ -455,18 +455,18 @@ __GLXdispatchSingleProcPtr __glXSwapSingleTable[__GLX_SINGLE_TABLE_SIZE] = { __glXSwapQueryExtensionsString, __glXSwapQueryServerString, __glXSwapClientInfo, - __glXNoSuchSingleOpcode, /* glXGetFBConfigs */ - __glXNoSuchSingleOpcode, /* glXCreatePixmap */ - __glXNoSuchSingleOpcode, /* glXDestroyPixmap */ - __glXNoSuchSingleOpcode, /* glXCreateNewContext */ + __glXSwapGetFBConfigs, + __glXSwapCreatePixmap, + __glXSwapDestroyGLXPixmap, /* glXDestroyPixmap */ + __glXSwapCreateNewContext, __glXNoSuchSingleOpcode, /* glXQueryContext */ __glXSwapMakeContextCurrent, - __glXNoSuchSingleOpcode, - __glXNoSuchSingleOpcode, - __glXNoSuchSingleOpcode, - __glXNoSuchSingleOpcode, - __glXNoSuchSingleOpcode, - __glXNoSuchSingleOpcode, + __glXNoSuchSingleOpcode, /* glXCreatePbuffer */ + __glXNoSuchSingleOpcode, /* glXDestroyPbuffer */ + __glXNoSuchSingleOpcode, /* glXGetDrawableAttributes */ + __glXNoSuchSingleOpcode, /* glXChangeDrawableAttributes */ + __glXNoSuchSingleOpcode, /* glXCreateWindow */ + __glXNoSuchSingleOpcode, /* glXDestroyWindow */ __glXNoSuchSingleOpcode, __glXNoSuchSingleOpcode, __glXNoSuchSingleOpcode, diff --git a/GL/glx/g_disptab.h b/GL/glx/g_disptab.h index 25c233ac7..566650bf7 100644 --- a/GL/glx/g_disptab.h +++ b/GL/glx/g_disptab.h @@ -52,6 +52,9 @@ extern int __glXQueryExtensionsString(__GLXclientState*, GLbyte*); extern int __glXQueryServerString(__GLXclientState*, GLbyte*); extern int __glXClientInfo(__GLXclientState*, GLbyte*); extern int __glXMakeContextCurrent(__GLXclientState*, GLbyte*); +extern int __glXGetFBConfigs(__GLXclientState*, GLbyte*); +extern int __glXCreateNewContext(__GLXclientState*, GLbyte*); +extern int __glXCreatePixmap(__GLXclientState*, GLbyte*); extern int __glXDisp_NewList(__GLXclientState*, GLbyte*); extern int __glXDisp_EndList(__GLXclientState*, GLbyte*); @@ -349,6 +352,9 @@ extern int __glXSwapQueryExtensionsString(__GLXclientState*, GLbyte*); extern int __glXSwapQueryServerString(__GLXclientState*, GLbyte*); extern int __glXSwapClientInfo(__GLXclientState*, GLbyte*); extern int __glXSwapMakeContextCurrent(__GLXclientState*, GLbyte*); +extern int __glXSwapGetFBConfigs(__GLXclientState*, GLbyte*); +extern int __glXSwapCreateNewContext(__GLXclientState*, GLbyte*); +extern int __glXSwapCreatePixmap(__GLXclientState*, GLbyte*); extern int __glXDispSwap_NewList(__GLXclientState*, GLbyte*); extern int __glXDispSwap_EndList(__GLXclientState*, GLbyte*); diff --git a/GL/glx/g_render.c b/GL/glx/g_render.c index a599423cc..f014e3be5 100644 --- a/GL/glx/g_render.c +++ b/GL/glx/g_render.c @@ -2273,7 +2273,6 @@ void __glXDisp_WindowPos3fARB(GLbyte *pc) *(GLfloat *)(pc + 8) ); } - #endif /* !MISSING_GL_EXTS */ void __glXDisp_SampleCoverageARB(GLbyte *pc) diff --git a/GL/glx/g_renderswap.c b/GL/glx/g_renderswap.c index 2a8d0c02f..5c2ed9f58 100644 --- a/GL/glx/g_renderswap.c +++ b/GL/glx/g_renderswap.c @@ -3368,7 +3368,6 @@ void __glXDispSwap_WindowPos3fARB(GLbyte *pc) *(GLfloat *)(pc + 8) ); } - #endif /* !MISSING_GL_EXTS */ void __glXDispSwap_SampleCoverageARB(GLbyte *pc) diff --git a/GL/glx/glxcmds.c b/GL/glx/glxcmds.c index df4154991..9908e8a2d 100644 --- a/GL/glx/glxcmds.c +++ b/GL/glx/glxcmds.c @@ -47,6 +47,7 @@ #include "glxutil.h" #include "glxext.h" #include "GL/glx_ansic.h" +#include "glcontextmodes.h" /************************************************************************/ @@ -68,29 +69,32 @@ static __GLimports imports = { NULL }; -static int DoMakeCurrent( __GLXclientState *cl, GLXDrawable drawId, - GLXDrawable readId, GLXContextID contextId, GLXContextTag tag ); +static int __glXGetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc); +static int __glXCreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc); +static int __glXCreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc); +static int __glXMakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc); /************************************************************************/ -/* -** Create a GL context with the given properties. -*/ -int __glXCreateContext(__GLXclientState *cl, GLbyte *pc) +/** + * Create a GL context with the given properties. This routine is used + * to implement \c glXCreateContext, \c glXCreateNewContext, and + * \c glXCreateContextWithConfigSGIX. This works becuase of the hack way + * that GLXFBConfigs are implemented. Basically, the FBConfigID is the + * same as the VisualID. + */ + +int DoCreateContext(__GLXclientState *cl, GLXContextID gcId, + GLXContextID shareList, VisualID visual, + GLuint screen, GLboolean isDirect) { ClientPtr client = cl->client; - xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc; VisualPtr pVisual; ScreenPtr pScreen; __GLXcontext *glxc, *shareglxc; - __GLXvisualConfig *pGlxVisual; + __GLcontextModes *modes; __GLXscreenInfo *pGlxScreen; __GLinterface *shareGC; - GLXContextID gcId = req->context; - GLXContextID shareList = req->shareList; - VisualID visual = req->visual; - GLuint screen = req->screen; - GLboolean isDirect = req->isDirect; GLint i; /* @@ -123,13 +127,9 @@ int __glXCreateContext(__GLXclientState *cl, GLbyte *pc) ** subset of Visuals that are supported by this implementation of the ** OpenGL. */ - pGlxVisual = pGlxScreen->pGlxVisual; - for (i = 0; i < pGlxScreen->numVisuals; i++, pGlxVisual++) { - if (pGlxVisual->vid == visual) { - break; - } - } - if (i == pGlxScreen->numVisuals) { + + modes = _gl_context_modes_find_visual( pGlxScreen->modes, visual ); + if (modes == NULL) { /* ** Visual not support on this screen by this OpenGL implementation. */ @@ -192,22 +192,15 @@ int __glXCreateContext(__GLXclientState *cl, GLbyte *pc) glxc->pScreen = pScreen; glxc->pGlxScreen = pGlxScreen; glxc->pVisual = pVisual; - glxc->pGlxVisual = pGlxVisual; + glxc->modes = modes; if (!isDirect) { - __GLcontextModes *modes; - /* - ** first build __GLcontextModes from __GLXvisualConfig - */ - modes = (__GLcontextModes *) __glXMalloc(sizeof(__GLcontextModes)); - glxc->modes = modes; - __glXFormatGLModes(modes, pGlxVisual); /* ** Allocate a GL context */ imports.other = (void *)glxc; - glxc->gc = (*pGlxScreen->createContext)(&imports, modes, shareGC); + glxc->gc = (*pGlxScreen->createContext)(&imports, glxc->modes, shareGC); if (!glxc->gc) { __glXFree(glxc); client->errorValue = gcId; @@ -245,6 +238,31 @@ int __glXCreateContext(__GLXclientState *cl, GLbyte *pc) return Success; } + +int __glXCreateContext(__GLXclientState *cl, GLbyte *pc) +{ + xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc; + return DoCreateContext( cl, req->context, req->shareList, req->visual, + req->screen, req->isDirect ); +} + + +int __glXCreateNewContext(__GLXclientState *cl, GLbyte *pc) +{ + xGLXCreateNewContextReq *req = (xGLXCreateNewContextReq *) pc; + return DoCreateContext( cl, req->context, req->shareList, req->fbconfig, + req->screen, req->isDirect ); +} + + +int __glXCreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc) +{ + xGLXCreateContextWithConfigSGIXReq *req = + (xGLXCreateContextWithConfigSGIXReq *) pc; + return DoCreateContext( cl, req->context, req->shareList, req->fbconfig, + req->screen, req->isDirect ); +} + /* ** Destroy a GL context as an X resource. */ @@ -370,24 +388,24 @@ int __glXMakeCurrent(__GLXclientState *cl, GLbyte *pc) { xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) pc; - return DoMakeCurrent( cl, req->drawable, req->drawable, - req->context, req->oldContextTag ); + return DoMakeCurrent( cl, req->drawable, req->drawable, + req->context, req->oldContextTag ); } int __glXMakeContextCurrent(__GLXclientState *cl, GLbyte *pc) { xGLXMakeContextCurrentReq *req = (xGLXMakeContextCurrentReq *) pc; - return DoMakeCurrent( cl, req->drawable, req->readdrawable, - req->context, req->oldContextTag ); + return DoMakeCurrent( cl, req->drawable, req->readdrawable, + req->context, req->oldContextTag ); } int __glXMakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc) { xGLXMakeCurrentReadSGIReq *req = (xGLXMakeCurrentReadSGIReq *) pc; - return DoMakeCurrent( cl, req->drawable, req->readable, - req->context, req->oldContextTag ); + return DoMakeCurrent( cl, req->drawable, req->readable, + req->context, req->oldContextTag ); } @@ -449,7 +467,7 @@ static int GetDrawableOrPixmap( __GLXcontext *glxc, GLXDrawable drawId, ** Check if pixmap and context are similar. */ if (drawPixmap->pScreen != glxc->pScreen || - drawPixmap->pGlxVisual != glxc->pGlxVisual) { + drawPixmap->modes->visualID != glxc->modes->visualID) { client->errorValue = drawId; return BadMatch; } @@ -471,9 +489,9 @@ static int GetDrawableOrPixmap( __GLXcontext *glxc, GLXDrawable drawId, } -static int DoMakeCurrent( __GLXclientState *cl, - GLXDrawable drawId, GLXDrawable readId, - GLXContextID contextId, GLXContextTag tag ) +int DoMakeCurrent( __GLXclientState *cl, + GLXDrawable drawId, GLXDrawable readId, + GLXContextID contextId, GLXContextTag tag ) { ClientPtr client = cl->client; DrawablePtr pDraw; @@ -639,7 +657,8 @@ static int DoMakeCurrent( __GLXclientState *cl, if (prevglxc) { if (prevglxc->drawPixmap) { - if (prevglxc->drawPixmap != prevglxc->readPixmap) { + if (prevglxc->readPixmap && + prevglxc->drawPixmap != prevglxc->readPixmap) { /* ** The previous drawable was a glx pixmap, release it. */ @@ -881,18 +900,19 @@ int __glXCopyContext(__GLXclientState *cl, GLbyte *pc) return Success; } -int __glXGetVisualConfigs(__GLXclientState *cl, GLbyte *pc) + +int DoGetVisualConfigs(__GLXclientState *cl, unsigned screen, + GLboolean do_swap) { ClientPtr client = cl->client; - xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) pc; xGLXGetVisualConfigsReply reply; __GLXscreenInfo *pGlxScreen; - __GLXvisualConfig *pGlxVisual; + __GLcontextModes *modes; CARD32 buf[__GLX_TOTAL_CONFIG]; - unsigned int screen; - int i, p; + int p; + __GLX_DECLARE_SWAP_VARIABLES; + __GLX_DECLARE_SWAP_ARRAY_VARIABLES; - screen = req->screen; if (screen >= screenInfo.numScreens) { /* The client library must send a valid screen number. */ client->errorValue = screen; @@ -907,77 +927,206 @@ int __glXGetVisualConfigs(__GLXclientState *cl, GLbyte *pc) reply.type = X_Reply; reply.sequenceNumber = client->sequence; + if ( do_swap ) { + __GLX_SWAP_SHORT(&reply.sequenceNumber); + __GLX_SWAP_INT(&reply.length); + __GLX_SWAP_INT(&reply.numVisuals); + __GLX_SWAP_INT(&reply.numProps); + } + WriteToClient(client, sz_xGLXGetVisualConfigsReply, (char *)&reply); - for (i=0; i < pGlxScreen->numVisuals; i++) { - pGlxVisual = &pGlxScreen->pGlxVisual[i]; - if (pGlxVisual->vid == 0) { + for ( modes = pGlxScreen->modes ; modes != NULL ; modes = modes->next ) { + if (modes->visualID == 0) { /* not a usable visual */ continue; } p = 0; - buf[p++] = pGlxVisual->vid; - buf[p++] = pGlxVisual->class; - buf[p++] = pGlxVisual->rgba; - - buf[p++] = pGlxVisual->redSize; - buf[p++] = pGlxVisual->greenSize; - buf[p++] = pGlxVisual->blueSize; - buf[p++] = pGlxVisual->alphaSize; - buf[p++] = pGlxVisual->accumRedSize; - buf[p++] = pGlxVisual->accumGreenSize; - buf[p++] = pGlxVisual->accumBlueSize; - buf[p++] = pGlxVisual->accumAlphaSize; - - buf[p++] = pGlxVisual->doubleBuffer; - buf[p++] = pGlxVisual->stereo; - - buf[p++] = pGlxVisual->bufferSize; - buf[p++] = pGlxVisual->depthSize; - buf[p++] = pGlxVisual->stencilSize; - buf[p++] = pGlxVisual->auxBuffers; - buf[p++] = pGlxVisual->level; + buf[p++] = modes->visualID; + buf[p++] = _gl_convert_to_x_visual_type( modes->visualType ); + buf[p++] = modes->rgbMode; + + buf[p++] = modes->redBits; + buf[p++] = modes->greenBits; + buf[p++] = modes->blueBits; + buf[p++] = modes->alphaBits; + buf[p++] = modes->accumRedBits; + buf[p++] = modes->accumGreenBits; + buf[p++] = modes->accumBlueBits; + buf[p++] = modes->accumAlphaBits; + + buf[p++] = modes->doubleBufferMode; + buf[p++] = modes->stereoMode; + + buf[p++] = modes->rgbBits; + buf[p++] = modes->depthBits; + buf[p++] = modes->stencilBits; + buf[p++] = modes->numAuxBuffers; + buf[p++] = modes->level; /* ** Add token/value pairs for extensions. */ buf[p++] = GLX_VISUAL_CAVEAT_EXT; - buf[p++] = pGlxVisual->visualRating; - buf[p++] = GLX_TRANSPARENT_TYPE_EXT; - buf[p++] = pGlxVisual->transparentPixel; - buf[p++] = GLX_TRANSPARENT_RED_VALUE_EXT; - buf[p++] = pGlxVisual->transparentRed; - buf[p++] = GLX_TRANSPARENT_GREEN_VALUE_EXT; - buf[p++] = pGlxVisual->transparentGreen; - buf[p++] = GLX_TRANSPARENT_BLUE_VALUE_EXT; - buf[p++] = pGlxVisual->transparentBlue; - buf[p++] = GLX_TRANSPARENT_ALPHA_VALUE_EXT; - buf[p++] = pGlxVisual->transparentAlpha; - buf[p++] = GLX_TRANSPARENT_INDEX_VALUE_EXT; - buf[p++] = pGlxVisual->transparentIndex; - + buf[p++] = modes->visualRating; + buf[p++] = GLX_TRANSPARENT_TYPE; + buf[p++] = modes->transparentPixel; + buf[p++] = GLX_TRANSPARENT_RED_VALUE; + buf[p++] = modes->transparentRed; + buf[p++] = GLX_TRANSPARENT_GREEN_VALUE; + buf[p++] = modes->transparentGreen; + buf[p++] = GLX_TRANSPARENT_BLUE_VALUE; + buf[p++] = modes->transparentBlue; + buf[p++] = GLX_TRANSPARENT_ALPHA_VALUE; + buf[p++] = modes->transparentAlpha; + buf[p++] = GLX_TRANSPARENT_INDEX_VALUE; + buf[p++] = modes->transparentIndex; + + if ( do_swap ) { + __GLX_SWAP_INT_ARRAY(buf, __GLX_TOTAL_CONFIG); + } WriteToClient(client, __GLX_SIZE_CARD32 * __GLX_TOTAL_CONFIG, (char *)buf); } return Success; } +int __glXGetVisualConfigs(__GLXclientState *cl, GLbyte *pc) +{ + xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) pc; + return DoGetVisualConfigs( cl, req->screen, GL_FALSE ); +} + + + +#define __GLX_TOTAL_FBCONFIG_ATTRIBS (28) + +/** + * Send the set of GLXFBConfigs to the client. There is not currently + * and interface into the driver on the server-side to get GLXFBConfigs, + * so we "invent" some based on the \c __GLXvisualConfig structures that + * the driver does supply. + * + * The reply format for both \c glXGetFBConfigs and \c glXGetFBConfigsSGIX + * is the same, so this routine pulls double duty. + */ + +int DoGetFBConfigs(__GLXclientState *cl, unsigned screen, GLboolean do_swap) +{ + ClientPtr client = cl->client; + xGLXGetFBConfigsReply reply; + __GLXscreenInfo *pGlxScreen; + CARD32 buf[__GLX_TOTAL_FBCONFIG_ATTRIBS * 2]; + int p; + __GLcontextModes *modes; + __GLX_DECLARE_SWAP_VARIABLES; + __GLX_DECLARE_SWAP_ARRAY_VARIABLES; + + + if (screen >= screenInfo.numScreens) { + /* The client library must send a valid screen number. */ + client->errorValue = screen; + return BadValue; + } + pGlxScreen = &__glXActiveScreens[screen]; + + reply.numFBConfigs = pGlxScreen->numUsableVisuals; + reply.numAttribs = __GLX_TOTAL_FBCONFIG_ATTRIBS; + reply.length = (reply.numAttribs * reply.numFBConfigs); + reply.type = X_Reply; + reply.sequenceNumber = client->sequence; + + if ( do_swap ) { + __GLX_SWAP_SHORT(&reply.sequenceNumber); + __GLX_SWAP_INT(&reply.length); + __GLX_SWAP_INT(&reply.numFBConfigs); + __GLX_SWAP_INT(&reply.numAttribs); + } + + WriteToClient(client, sz_xGLXGetFBConfigsReply, (char *)&reply); + + for ( modes = pGlxScreen->modes ; modes != NULL ; modes = modes->next ) { + if (modes->visualID == 0) { + /* not a usable visual */ + continue; + } + p = 0; + +#define WRITE_PAIR(tag,value) \ + do { buf[p++] = tag ; buf[p++] = value ; } while( 0 ) + + WRITE_PAIR( GLX_VISUAL_ID, modes->visualID ); + WRITE_PAIR( GLX_FBCONFIG_ID, modes->visualID ); + WRITE_PAIR( GLX_X_RENDERABLE, GL_TRUE ); + + WRITE_PAIR( GLX_RGBA, modes->rgbMode ); + WRITE_PAIR( GLX_DOUBLEBUFFER, modes->doubleBufferMode ); + WRITE_PAIR( GLX_STEREO, modes->stereoMode ); + + WRITE_PAIR( GLX_BUFFER_SIZE, modes->rgbBits ); + WRITE_PAIR( GLX_LEVEL, modes->level ); + WRITE_PAIR( GLX_AUX_BUFFERS, modes->numAuxBuffers ); + WRITE_PAIR( GLX_RED_SIZE, modes->redBits ); + WRITE_PAIR( GLX_GREEN_SIZE, modes->greenBits ); + WRITE_PAIR( GLX_BLUE_SIZE, modes->blueBits ); + WRITE_PAIR( GLX_ALPHA_SIZE, modes->alphaBits ); + WRITE_PAIR( GLX_ACCUM_RED_SIZE, modes->accumRedBits ); + WRITE_PAIR( GLX_ACCUM_GREEN_SIZE, modes->accumGreenBits ); + WRITE_PAIR( GLX_ACCUM_BLUE_SIZE, modes->accumBlueBits ); + WRITE_PAIR( GLX_ACCUM_ALPHA_SIZE, modes->accumAlphaBits ); + WRITE_PAIR( GLX_DEPTH_SIZE, modes->depthBits ); + WRITE_PAIR( GLX_STENCIL_SIZE, modes->stencilBits ); + + WRITE_PAIR( GLX_X_VISUAL_TYPE, modes->visualType ); + + /* + ** Add token/value pairs for extensions. + */ + WRITE_PAIR( GLX_CONFIG_CAVEAT, modes->visualRating ); + WRITE_PAIR( GLX_TRANSPARENT_TYPE, modes->transparentPixel ); + WRITE_PAIR( GLX_TRANSPARENT_RED_VALUE, modes->transparentRed ); + WRITE_PAIR( GLX_TRANSPARENT_GREEN_VALUE, modes->transparentGreen ); + WRITE_PAIR( GLX_TRANSPARENT_BLUE_VALUE, modes->transparentBlue ); + WRITE_PAIR( GLX_TRANSPARENT_ALPHA_VALUE, modes->transparentAlpha ); + WRITE_PAIR( GLX_TRANSPARENT_INDEX_VALUE, modes->transparentIndex ); + WRITE_PAIR( GLX_SWAP_METHOD_OML, modes->swapMethod ); + + if ( do_swap ) { + __GLX_SWAP_INT_ARRAY(buf, __GLX_TOTAL_FBCONFIG_ATTRIBS * 2); + } + WriteToClient(client, __GLX_SIZE_CARD32 * __GLX_TOTAL_FBCONFIG_ATTRIBS * 2, + (char *)buf); + } + return Success; +} + + +int __glXGetFBConfigs(__GLXclientState *cl, GLbyte *pc) +{ + xGLXGetFBConfigsReq *req = (xGLXGetFBConfigsReq *) pc; + return DoGetFBConfigs( cl, req->screen, GL_FALSE ); +} + + +int __glXGetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc) +{ + xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *) pc; + return DoGetFBConfigs( cl, req->screen, GL_FALSE ); +} + + /* ** Create a GLX Pixmap from an X Pixmap. */ -int __glXCreateGLXPixmap(__GLXclientState *cl, GLbyte *pc) +int DoCreateGLXPixmap(__GLXclientState *cl, VisualID visual, + GLuint screenNum, XID pixmapId, XID glxpixmapId) { ClientPtr client = cl->client; - xGLXCreateGLXPixmapReq *req = (xGLXCreateGLXPixmapReq *) pc; - VisualID visual = req->visual; - GLuint screenNum = req->screen; - XID pixmapId = req->pixmap; - XID glxpixmapId = req->glxpixmap; DrawablePtr pDraw; ScreenPtr pScreen; VisualPtr pVisual; __GLXpixmap *pGlxPixmap; __GLXscreenInfo *pGlxScreen; - __GLXvisualConfig *pGlxVisual; + __GLcontextModes *modes; int i; pDraw = (DrawablePtr) LookupDrawable(pixmapId, client); @@ -1018,13 +1167,8 @@ int __glXCreateGLXPixmap(__GLXclientState *cl, GLbyte *pc) ** Get configuration of the visual. */ pGlxScreen = &__glXActiveScreens[screenNum]; - pGlxVisual = pGlxScreen->pGlxVisual; - for (i = 0; i < pGlxScreen->numVisuals; i++, pGlxVisual++) { - if (pGlxVisual->vid == visual) { - break; - } - } - if (i == pGlxScreen->numVisuals) { + modes = _gl_context_modes_find_visual( pGlxScreen->modes, visual ); + if (modes == NULL) { /* ** Visual not support on this screen by this OpenGL implementation. */ @@ -1041,11 +1185,12 @@ int __glXCreateGLXPixmap(__GLXclientState *cl, GLbyte *pc) } pGlxPixmap->pDraw = pDraw; pGlxPixmap->pGlxScreen = pGlxScreen; - pGlxPixmap->pGlxVisual = pGlxVisual; pGlxPixmap->pScreen = pScreen; pGlxPixmap->idExists = True; pGlxPixmap->refcnt = 0; + pGlxPixmap->modes = modes; + /* ** Bump the ref count on the X pixmap so it won't disappear. */ @@ -1054,6 +1199,34 @@ int __glXCreateGLXPixmap(__GLXclientState *cl, GLbyte *pc) return Success; } +int __glXCreateGLXPixmap(__GLXclientState *cl, GLbyte *pc) +{ + xGLXCreateGLXPixmapReq *req = (xGLXCreateGLXPixmapReq *) pc; + return DoCreateGLXPixmap( cl, req->visual, req->screen, + req->pixmap, req->glxpixmap ); +} + +int __glXCreatePixmap(__GLXclientState *cl, GLbyte *pc) +{ + xGLXCreatePixmapReq *req = (xGLXCreatePixmapReq *) pc; + return DoCreateGLXPixmap( cl, req->fbconfig, req->screen, + req->pixmap, req->glxpixmap ); +} + +int __glXCreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc) +{ + xGLXCreateGLXPixmapWithConfigSGIXReq *req = + (xGLXCreateGLXPixmapWithConfigSGIXReq *) pc; + return DoCreateGLXPixmap( cl, req->fbconfig, req->screen, + req->pixmap, req->glxpixmap ); +} + + +/** + * Destroy a GLX pixmap. This function is used for both + * \c glXDestroyGLXPixmap and \c glXDestroyPixmap. + */ + int __glXDestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc) { ClientPtr client = cl->client; @@ -1592,6 +1765,12 @@ int __glXVendorPrivateWithReply(__GLXclientState *cl, GLbyte *pc) return __glXQueryContextInfoEXT(cl, pc); case X_GLXvop_MakeCurrentReadSGI: return __glXMakeCurrentReadSGI(cl, pc); + case X_GLXvop_GetFBConfigsSGIX: + return __glXGetFBConfigsSGIX(cl, pc); + case X_GLXvop_CreateContextWithConfigSGIX: + return __glXCreateContextWithConfigSGIX(cl, pc); + case X_GLXvop_CreateGLXPixmapWithConfigSGIX: + return __glXCreateGLXPixmapWithConfigSGIX(cl, pc); default: break; } diff --git a/GL/glx/glxcmdsswap.c b/GL/glx/glxcmdsswap.c index 8c0f1f091..450b8bb9b 100644 --- a/GL/glx/glxcmdsswap.c +++ b/GL/glx/glxcmdsswap.c @@ -47,6 +47,11 @@ #include "glxext.h" #include "GL/glx_ansic.h" +static int __glXSwapGetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc); +static int __glXSwapCreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc); +static int __glXSwapCreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc); +static int __glXSwapMakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc); + /************************************************************************/ /* @@ -67,7 +72,41 @@ int __glXSwapCreateContext(__GLXclientState *cl, GLbyte *pc) __GLX_SWAP_INT(&req->screen); __GLX_SWAP_INT(&req->shareList); - return __glXCreateContext(cl, pc); + return DoCreateContext( cl, req->context, req->shareList, req->visual, + req->screen, req->isDirect ); +} + +int __glXSwapCreateNewContext(__GLXclientState *cl, GLbyte *pc) +{ + xGLXCreateNewContextReq *req = (xGLXCreateNewContextReq *) pc; + __GLX_DECLARE_SWAP_VARIABLES; + + __GLX_SWAP_SHORT(&req->length); + __GLX_SWAP_INT(&req->context); + __GLX_SWAP_INT(&req->fbconfig); + __GLX_SWAP_INT(&req->screen); + __GLX_SWAP_INT(&req->renderType); + __GLX_SWAP_INT(&req->shareList); + + return DoCreateContext( cl, req->context, req->shareList, req->fbconfig, + req->screen, req->isDirect ); +} + +int __glXSwapCreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc) +{ + xGLXCreateContextWithConfigSGIXReq *req = + (xGLXCreateContextWithConfigSGIXReq *) pc; + __GLX_DECLARE_SWAP_VARIABLES; + + __GLX_SWAP_SHORT(&req->length); + __GLX_SWAP_INT(&req->context); + __GLX_SWAP_INT(&req->fbconfig); + __GLX_SWAP_INT(&req->screen); + __GLX_SWAP_INT(&req->renderType); + __GLX_SWAP_INT(&req->shareList); + + return DoCreateContext( cl, req->context, req->shareList, req->fbconfig, + req->screen, req->isDirect ); } int __glXSwapDestroyContext(__GLXclientState *cl, GLbyte *pc) @@ -91,7 +130,8 @@ int __glXSwapMakeCurrent(__GLXclientState *cl, GLbyte *pc) __GLX_SWAP_INT(&req->context); __GLX_SWAP_INT(&req->oldContextTag); - return __glXMakeCurrent(cl, pc); + return DoMakeCurrent( cl, req->drawable, req->drawable, + req->context, req->oldContextTag ); } int __glXSwapMakeContextCurrent(__GLXclientState *cl, GLbyte *pc) @@ -105,7 +145,8 @@ int __glXSwapMakeContextCurrent(__GLXclientState *cl, GLbyte *pc) __GLX_SWAP_INT(&req->context); __GLX_SWAP_INT(&req->oldContextTag); - return __glXMakeContextCurrent(cl, pc); + return DoMakeCurrent( cl, req->drawable, req->readdrawable, + req->context, req->oldContextTag ); } int __glXSwapMakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc) @@ -119,7 +160,8 @@ int __glXSwapMakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc) __GLX_SWAP_INT(&req->context); __GLX_SWAP_INT(&req->oldContextTag); - return __glXMakeCurrentReadSGI(cl, pc); + return DoMakeCurrent( cl, req->drawable, req->readable, + req->context, req->oldContextTag ); } int __glXSwapIsDirect(__GLXclientState *cl, GLbyte *pc) @@ -182,90 +224,29 @@ int __glXSwapCopyContext(__GLXclientState *cl, GLbyte *pc) int __glXSwapGetVisualConfigs(__GLXclientState *cl, GLbyte *pc) { - ClientPtr client = cl->client; xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) pc; - xGLXGetVisualConfigsReply reply; - __GLXscreenInfo *pGlxScreen; - __GLXvisualConfig *pGlxVisual; - CARD32 buf[__GLX_TOTAL_CONFIG]; - unsigned int screen; - int i, p; __GLX_DECLARE_SWAP_VARIABLES; - __GLX_DECLARE_SWAP_ARRAY_VARIABLES; __GLX_SWAP_INT(&req->screen); - screen = req->screen; - if (screen > screenInfo.numScreens) { - /* The client library must send a valid screen number. */ - client->errorValue = screen; - return BadValue; - } - pGlxScreen = &__glXActiveScreens[screen]; - - reply.numVisuals = pGlxScreen->numUsableVisuals; - reply.numProps = __GLX_TOTAL_CONFIG; - reply.length = (pGlxScreen->numUsableVisuals * __GLX_SIZE_CARD32 * - __GLX_TOTAL_CONFIG) >> 2; - reply.type = X_Reply; - reply.sequenceNumber = client->sequence; - - __GLX_SWAP_SHORT(&reply.sequenceNumber); - __GLX_SWAP_INT(&reply.length); - __GLX_SWAP_INT(&reply.numVisuals); - __GLX_SWAP_INT(&reply.numProps); - WriteToClient(client, sz_xGLXGetVisualConfigsReply, (char *)&reply); - - for (i=0; i < pGlxScreen->numVisuals; i++) { - pGlxVisual = &pGlxScreen->pGlxVisual[i]; - if (pGlxVisual->vid == 0) { - /* not a usable visual */ - continue; - } - p = 0; - buf[p++] = pGlxVisual->vid; - buf[p++] = pGlxVisual->class; - buf[p++] = pGlxVisual->rgba; - - buf[p++] = pGlxVisual->redSize; - buf[p++] = pGlxVisual->greenSize; - buf[p++] = pGlxVisual->blueSize; - buf[p++] = pGlxVisual->alphaSize; - buf[p++] = pGlxVisual->accumRedSize; - buf[p++] = pGlxVisual->accumGreenSize; - buf[p++] = pGlxVisual->accumBlueSize; - buf[p++] = pGlxVisual->accumAlphaSize; - - buf[p++] = pGlxVisual->doubleBuffer; - buf[p++] = pGlxVisual->stereo; - - buf[p++] = pGlxVisual->bufferSize; - buf[p++] = pGlxVisual->depthSize; - buf[p++] = pGlxVisual->stencilSize; - buf[p++] = pGlxVisual->auxBuffers; - buf[p++] = pGlxVisual->level; - /* - ** Add token/value pairs for extensions. - */ - buf[p++] = GLX_VISUAL_CAVEAT_EXT; - buf[p++] = pGlxVisual->visualRating; - buf[p++] = GLX_TRANSPARENT_TYPE_EXT; - buf[p++] = pGlxVisual->transparentPixel; - buf[p++] = GLX_TRANSPARENT_RED_VALUE_EXT; - buf[p++] = pGlxVisual->transparentRed; - buf[p++] = GLX_TRANSPARENT_GREEN_VALUE_EXT; - buf[p++] = pGlxVisual->transparentGreen; - buf[p++] = GLX_TRANSPARENT_BLUE_VALUE_EXT; - buf[p++] = pGlxVisual->transparentBlue; - buf[p++] = GLX_TRANSPARENT_ALPHA_VALUE_EXT; - buf[p++] = pGlxVisual->transparentAlpha; - buf[p++] = GLX_TRANSPARENT_INDEX_VALUE_EXT; - buf[p++] = pGlxVisual->transparentIndex; - - __GLX_SWAP_INT_ARRAY(buf, __GLX_TOTAL_CONFIG); - WriteToClient(client, __GLX_SIZE_CARD32 * __GLX_TOTAL_CONFIG, - (char *)buf); - } - return Success; + return DoGetVisualConfigs( cl, req->screen, GL_TRUE ); +} + +int __glXSwapGetFBConfigs(__GLXclientState *cl, GLbyte *pc) +{ + xGLXGetFBConfigsReq *req = (xGLXGetFBConfigsReq *) pc; + __GLX_DECLARE_SWAP_VARIABLES; + + __GLX_SWAP_INT(&req->screen); + return DoGetFBConfigs( cl, req->screen, GL_TRUE ); +} + +int __glXSwapGetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc) +{ + xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *) pc; + __GLX_DECLARE_SWAP_VARIABLES; + + __GLX_SWAP_INT(&req->screen); + return DoGetFBConfigs( cl, req->screen, GL_TRUE ); } int __glXSwapCreateGLXPixmap(__GLXclientState *cl, GLbyte *pc) @@ -279,7 +260,39 @@ int __glXSwapCreateGLXPixmap(__GLXclientState *cl, GLbyte *pc) __GLX_SWAP_INT(&req->pixmap); __GLX_SWAP_INT(&req->glxpixmap); - return __glXCreateGLXPixmap(cl, pc); + return DoCreateGLXPixmap( cl, req->visual, req->screen, + req->pixmap, req->glxpixmap ); +} + +int __glXSwapCreatePixmap(__GLXclientState *cl, GLbyte *pc) +{ + xGLXCreatePixmapReq *req = (xGLXCreatePixmapReq *) pc; + __GLX_DECLARE_SWAP_VARIABLES; + + __GLX_SWAP_SHORT(&req->length); + __GLX_SWAP_INT(&req->screen); + __GLX_SWAP_INT(&req->fbconfig); + __GLX_SWAP_INT(&req->pixmap); + __GLX_SWAP_INT(&req->glxpixmap); + + return DoCreateGLXPixmap( cl, req->fbconfig, req->screen, + req->pixmap, req->glxpixmap ); +} + +int __glXSwapCreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc) +{ + xGLXCreateGLXPixmapWithConfigSGIXReq *req = + (xGLXCreateGLXPixmapWithConfigSGIXReq *) pc; + __GLX_DECLARE_SWAP_VARIABLES; + + __GLX_SWAP_SHORT(&req->length); + __GLX_SWAP_INT(&req->screen); + __GLX_SWAP_INT(&req->fbconfig); + __GLX_SWAP_INT(&req->pixmap); + __GLX_SWAP_INT(&req->glxpixmap); + + return DoCreateGLXPixmap( cl, req->fbconfig, req->screen, + req->pixmap, req->glxpixmap ); } int __glXSwapDestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc) @@ -806,6 +819,7 @@ int __glXSwapVendorPrivate(__GLXclientState *cl, GLbyte *pc) } #endif + if ((vendorcode >= __GLX_MIN_VENDPRIV_OPCODE_EXT) && (vendorcode <= __GLX_MAX_VENDPRIV_OPCODE_EXT)) { (*__glXSwapVendorPrivTable_EXT[vendorcode-__GLX_MIN_VENDPRIV_OPCODE_EXT])(cl, (GLbyte*)req); @@ -833,6 +847,12 @@ int __glXSwapVendorPrivateWithReply(__GLXclientState *cl, GLbyte *pc) return __glXSwapQueryContextInfoEXT(cl, pc); case X_GLXvop_MakeCurrentReadSGI: return __glXSwapMakeCurrentReadSGI(cl, pc); + case X_GLXvop_GetFBConfigsSGIX: + return __glXSwapGetFBConfigsSGIX(cl, pc); + case X_GLXvop_CreateContextWithConfigSGIX: + return __glXSwapCreateContextWithConfigSGIX(cl, pc); + case X_GLXvop_CreateGLXPixmapWithConfigSGIX: + return __glXSwapCreateGLXPixmapWithConfigSGIX(cl, pc); default: break; } diff --git a/GL/glx/glxcontext.h b/GL/glx/glxcontext.h index 5eb72177e..9a16851f0 100644 --- a/GL/glx/glxcontext.h +++ b/GL/glx/glxcontext.h @@ -80,7 +80,6 @@ struct __GLXcontextRec { ** This context is created with respect to this visual. */ VisualRec *pVisual; - __GLXvisualConfig *pGlxVisual; /* ** The XID of this context. diff --git a/GL/glx/glxdrawable.h b/GL/glx/glxdrawable.h index 972a6045f..1d7f44352 100644 --- a/GL/glx/glxdrawable.h +++ b/GL/glx/glxdrawable.h @@ -40,7 +40,7 @@ typedef struct { DrawablePtr pDraw; - __GLXvisualConfig *pGlxVisual; + __GLcontextModes *modes; __GLXscreenInfo *pGlxScreen; ScreenPtr pScreen; Bool idExists; @@ -69,11 +69,12 @@ struct __GLXdrawablePrivateRec { /* ** Configuration of the visual to which this drawable was created. */ - __GLXvisualConfig *pGlxVisual; + __GLcontextModes *modes; /* ** cached drawable size and origin */ + GLint xorigin, yorigin; GLint width, height; diff --git a/GL/glx/glxext.c b/GL/glx/glxext.c index 796663e9b..87c9e1448 100644 --- a/GL/glx/glxext.c +++ b/GL/glx/glxext.c @@ -30,12 +30,11 @@ #include "micmap.h" -extern __GLXextensionInfo __glDDXExtensionInfo; void GlxWrapInitVisuals(miInitVisualsProcPtr *); void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, void **privates); -__GLXextensionInfo *__glXExt = &__glDDXExtensionInfo; +static __GLXextensionInfo *__glXExt /* = &__glDDXExtensionInfo */; /* ** Forward declarations. @@ -314,6 +313,8 @@ GlxWrapInitVisuals(miInitVisualsProcPtr *initVisProc) { saveInitVisualsProc = *initVisProc; *initVisProc = GlxInitVisuals; + /* HACK: this shouldn't be done here but it's the earliest time */ + __glXExt = __glXglDDXExtensionInfo(); /* from GLcore */ } /************************************************************************/ diff --git a/GL/glx/glxext.h b/GL/glx/glxext.h index 210fbb88c..c6cd219c7 100644 --- a/GL/glx/glxext.h +++ b/GL/glx/glxext.h @@ -73,8 +73,16 @@ extern void __glXResetLargeCommandStatus(__GLXclientState*); extern int __glXQueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc); extern int __glXSwapQueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc); -extern int __glXMakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc); -extern int __glXSwapMakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc); +extern int DoMakeCurrent( __GLXclientState *cl, GLXDrawable drawId, + GLXDrawable readId, GLXContextID contextId, GLXContextTag tag ); +extern int DoGetVisualConfigs(__GLXclientState *cl, unsigned screen, + GLboolean do_swap); +extern int DoGetFBConfigs(__GLXclientState *cl, unsigned screen, + GLboolean do_swap); +extern int DoCreateContext(__GLXclientState *cl, GLXContextID gcId, + GLXContextID shareList, VisualID visual, GLuint screen, GLboolean isDirect); +extern int DoCreateGLXPixmap(__GLXclientState *cl, VisualID visual, + GLuint screenNum, XID pixmapId, XID glxpixmapId); extern void GlxExtensionInit(void); diff --git a/GL/glx/glxscreens.c b/GL/glx/glxscreens.c index f78b4a284..6ddbfcbd0 100644 --- a/GL/glx/glxscreens.c +++ b/GL/glx/glxscreens.c @@ -133,104 +133,34 @@ static char GLXServerExtensions[] = "GLX_EXT_visual_info " "GLX_EXT_visual_rating " "GLX_EXT_import_context " + "GLX_OML_swap_method " "GLX_SGI_make_current_read " #ifndef __DARWIN__ "GLX_SGIS_multisample " #endif + "GLX_SGIX_fbconfig " ; /* -** This comes from the GL library that the server will link with. Right -** now, that is the DDX Sample OpenGL. -*/ -extern __GLXscreenInfo __glDDXScreenInfo; - -__GLXscreenInfo *__glXScreens[] = { - &__glDDXScreenInfo, + * __glDDXScreenInfo comes from GLcore, so we can't resolve this symbol at + * module open time. Leave a placeholder, and fill this in when we first + * need it (in __glXScreenInit). XXX Why make this an array? + */ +static __GLXscreenInfo *__glXScreens[] = { + NULL /* &__glDDXScreenInfo */ , }; -GLint __glXNumStaticScreens = (sizeof __glXScreens / sizeof __glXScreens[0]); +static GLint __glXNumStaticScreens = + (sizeof __glXScreens / sizeof __glXScreens[0]); __GLXscreenInfo *__glXActiveScreens; GLint __glXNumActiveScreens; RESTYPE __glXDrawableRes; -#if 0 -static int -CountBits(unsigned long mask) -{ - int count = 0; - - while(mask) { - count += (mask&1); - mask >>= 1; - } - - return count; +__GLXscreenInfo *__glXgetActiveScreen(int num) { + return &__glXActiveScreens[num]; } -#endif - -#if 0 -/* -** A typical implementation would not probably not run through the screen's -** visuals to find ones that match the visual configs supplied by the DDX -** Sample OpenGL as we do here; we have done this to make this code easy to -** drop into an existing X server. -*/ -static int matchVisuals(__GLXvisualConfig *pGlxVisual, int numVisuals, - int screen) -{ - int i, j; - __GLXvisualConfig *pvis = pGlxVisual; - ScreenPtr pScreen = screenInfo.screens[screen]; - VisualPtr pVisual; - int numMatchingVisuals = 0; - int *used; - - used = (int *)__glXMalloc(pScreen->numVisuals*sizeof(int)); - __glXMemset(used, 0, pScreen->numVisuals*sizeof(int)); - - for (i=0; i < numVisuals; i++, pvis++) { - /* - ** Look through all the server's visuals to see which match. - */ - pvis->vid = 0; - pVisual = pScreen->visuals; - for (j=0; j < pScreen->numVisuals; j++, pVisual++) { - if (pvis->class == pVisual->class && - pvis->bufferSize == pVisual->nplanes && - !used[j]) { - int rBits, gBits, bBits, aBits; - - /* count bits per rgb */ - rBits = CountBits(pVisual->redMask); - gBits = CountBits(pVisual->greenMask); - bBits = CountBits(pVisual->blueMask); - aBits = 0; - if ((pvis->redSize == rBits) && - (pvis->greenSize == gBits) && - (pvis->blueSize == bBits) && - (pvis->alphaSize == aBits)) { - /* - ** We'll consider this a match. - */ - pvis->vid = pVisual->vid; - pvis->redMask = pVisual->redMask; - pvis->greenMask = pVisual->greenMask; - pvis->blueMask = pVisual->blueMask; - pvis->alphaMask = 0; - numMatchingVisuals++; - used[j] = 1; - break; - } - } - } - } - __glXFree(used); - return numMatchingVisuals; -} -#endif /* ** Destroy routine that gets called when a drawable is freed. A drawable @@ -346,6 +276,8 @@ void __glXScreenInit(GLint numscreens) { GLint i,j; + __glXScreens[0] = __glXglDDXScreenInfo(); /* from GLcore */ + /* ** This alloc has to work or else the server might as well core dump. */ @@ -360,14 +292,7 @@ void __glXScreenInit(GLint numscreens) if ((*__glXScreens[j]->screenProbe)(i)) { __glXActiveScreens[i] = *__glXScreens[j]; -#if 0 - /* we don't use this since matchVisuals doesn't allow alpha */ - __glXActiveScreens[i].numUsableVisuals = - matchVisuals(__glXActiveScreens[i].pGlxVisual, - __glXActiveScreens[i].numVisuals, i); -#else __glXActiveScreens[i].numUsableVisuals = __glXActiveScreens[i].numVisuals; -#endif __glXActiveScreens[i].GLextensions = __glXStrdup(GLServerExtensions); __glXActiveScreens[i].GLXvendor = __glXStrdup(GLXServerVendorName); __glXActiveScreens[i].GLXversion = __glXStrdup(GLXServerVersion); diff --git a/GL/glx/glxscreens.h b/GL/glx/glxscreens.h index 42dc66e08..c4d237bbc 100644 --- a/GL/glx/glxscreens.h +++ b/GL/glx/glxscreens.h @@ -70,7 +70,11 @@ typedef struct { */ void (*createBuffer)(__GLXdrawablePrivate *glxPriv); - __GLXvisualConfig *pGlxVisual; + /** + * Linked list of valid context modes for this screen. + */ + __GLcontextModes *modes; + void **pVisualPriv; GLint numVisuals; GLint numUsableVisuals; diff --git a/GL/glx/glxserver.h b/GL/glx/glxserver.h index be9e40f5a..66d681d2d 100644 --- a/GL/glx/glxserver.h +++ b/GL/glx/glxserver.h @@ -92,6 +92,7 @@ typedef struct __GLXclientStateRec __GLXclientState; extern __GLXscreenInfo *__glXActiveScreens; extern GLint __glXNumActiveScreens; +extern __GLXscreenInfo *__glXgetActiveScreen(int num); /************************************************************************/ diff --git a/GL/glx/glxutil.c b/GL/glx/glxutil.c index 7aafd0065..4512aa5e9 100644 --- a/GL/glx/glxutil.c +++ b/GL/glx/glxutil.c @@ -44,6 +44,9 @@ #include "glxutil.h" #include "glxbuf.h" #include "GL/glx_ansic.h" +#include "GL/internal/glcore.h" +#include "GL/glxint.h" +#include "glcontextmodes.h" /************************************************************************/ @@ -214,53 +217,6 @@ __glXResizeDrawable(__GLdrawablePrivate *glPriv) } -/************************************************************************/ - -void -__glXFormatGLModes(__GLcontextModes *modes, __GLXvisualConfig *config) -{ - __glXMemset(modes, 0, sizeof(__GLcontextModes)); - - modes->rgbMode = (config->rgba != 0); - modes->colorIndexMode = !(modes->rgbMode); - modes->doubleBufferMode = (config->doubleBuffer != 0); - modes->stereoMode = (config->stereo != 0); - - modes->haveAccumBuffer = ((config->accumRedSize + - config->accumGreenSize + - config->accumBlueSize + - config->accumAlphaSize) > 0); - modes->haveDepthBuffer = (config->depthSize > 0); - modes->haveStencilBuffer = (config->stencilSize > 0); - - modes->redBits = config->redSize; - modes->greenBits = config->greenSize; - modes->blueBits = config->blueSize; - modes->alphaBits = config->alphaSize; - modes->redMask = config->redMask; - modes->greenMask = config->greenMask; - modes->blueMask = config->blueMask; - modes->alphaMask = config->alphaMask; -#if 0 - modes->rgbBits = modes->redBits + modes->greenBits + - modes->blueBits + modes->alphaBits; -#endif - assert( !modes->rgbMode || ((config->bufferSize & 0x7) == 0) ); - modes->rgbBits = config->bufferSize; - modes->indexBits = config->bufferSize; - - modes->accumRedBits = config->accumRedSize; - modes->accumGreenBits = config->accumGreenSize; - modes->accumBlueBits = config->accumBlueSize; - modes->accumAlphaBits = config->accumAlphaSize; - modes->depthBits = config->depthSize; - modes->stencilBits = config->stencilSize; - - modes->numAuxBuffers = 0; /* XXX: should be picked up from the visual */ - - modes->level = config->level; -} - /*****************************************************************************/ /* accessing the drawable private */ @@ -382,21 +338,13 @@ __glXCreateDrawablePrivate(DrawablePtr pDraw, XID drawId, pGlxScreen = &__glXActiveScreens[pDraw->pScreen->myNum]; - /* allocate the buffers */ if (glxPriv->type == DRAWABLE_WINDOW) { - int i; VisualID vid = wVisual((WindowPtr)pDraw); - __GLXvisualConfig *pGlxVisual = pGlxScreen->pGlxVisual; - for (i = 0; i < pGlxScreen->numVisuals; i++, pGlxVisual++) { - if (pGlxVisual->vid == vid) { - glxPriv->pGlxVisual = pGlxVisual; - break; - } - } + glxPriv->modes = _gl_context_modes_find_visual( pGlxScreen->modes, vid ); __glXFBInitDrawable(glxPriv, modes); } else { - glxPriv->pGlxVisual = glxPriv->pGlxPixmap->pGlxVisual; + glxPriv->modes = glxPriv->pGlxPixmap->modes; __glXPixInitDrawable(glxPriv, modes); } diff --git a/GL/glx/glxutil.h b/GL/glx/glxutil.h index 67bfb06f9..dbf7084b5 100644 --- a/GL/glx/glxutil.h +++ b/GL/glx/glxutil.h @@ -55,7 +55,6 @@ extern void __glXGetDrawableSize(__GLdrawablePrivate *glPriv, GLuint *width, GLuint *height); extern GLboolean __glXResizeDrawable(__GLdrawablePrivate *glPriv); extern GLboolean __glXResizeDrawableBuffers(__GLXdrawablePrivate *glxPriv); -extern void __glXFormatGLModes(__GLcontextModes *modes, __GLXvisualConfig *config); /* drawable management */ extern void __glXRefDrawablePrivate(__GLXdrawablePrivate *glxPriv); @@ -73,6 +72,9 @@ extern void __glXCacheDrawableSize(__GLXdrawablePrivate *glxPriv); /* context helper routines */ extern __GLXcontext *__glXLookupContextByTag(__GLXclientState*, GLXContextTag); +/* init helper routines */ +extern void *__glXglDDXScreenInfo(void); +extern void *__glXglDDXExtensionInfo(void); #endif /* _glxcmds_h_ */ diff --git a/GL/glx/render2.c b/GL/glx/render2.c index d4c523fea..2629a7025 100644 --- a/GL/glx/render2.c +++ b/GL/glx/render2.c @@ -234,16 +234,14 @@ void __glXDisp_DrawArrays(GLbyte *pc) glEnableClientState(GL_EDGE_FLAG_ARRAY); glEdgeFlagPointer(stride, (const GLboolean *)pc); break; -#ifndef MISSING_GL_EXTS case GL_SECONDARY_COLOR_ARRAY: glEnableClientState(GL_SECONDARY_COLOR_ARRAY); glSecondaryColorPointer(numVals, datatype, stride, pc); break; - case GL_FOG_COORDINATE_ARRAY: - glEnableClientState(GL_FOG_COORDINATE_ARRAY); + case GL_FOG_COORD_ARRAY: + glEnableClientState(GL_FOG_COORD_ARRAY); glFogCoordPointer(datatype, stride, pc); break; -#endif default: break; } @@ -261,7 +259,7 @@ void __glXDisp_DrawArrays(GLbyte *pc) glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_EDGE_FLAG_ARRAY); glDisableClientState(GL_SECONDARY_COLOR_ARRAY); - glDisableClientState(GL_FOG_COORDINATE_ARRAY); + glDisableClientState(GL_FOG_COORD_ARRAY); } void __glXDisp_DrawArraysEXT(GLbyte *pc) diff --git a/GL/glx/rensize.c b/GL/glx/rensize.c index aa784b5fc..5d7c7b367 100644 --- a/GL/glx/rensize.c +++ b/GL/glx/rensize.c @@ -558,7 +558,7 @@ int __glXDrawArraysSize( GLbyte *pc, Bool swap ) return -1; } break; - case GL_FOG_COORDINATE_ARRAY: + case GL_FOG_COORD_ARRAY: case GL_INDEX_ARRAY: if (numVals != 1) { /* bad size */ diff --git a/GL/glx/singlesize.c b/GL/glx/singlesize.c index 448fa1aef..3baf03517 100644 --- a/GL/glx/singlesize.c +++ b/GL/glx/singlesize.c @@ -81,7 +81,7 @@ GLint __glGetTexEnvfv_size(GLenum pname) case GL_ALPHA_SCALE: /* GL_ARB_point_sprite / GL_NV_point_sprite */ - case GL_COORD_REPLACE_NV: + case GL_COORD_REPLACE_ARB: /* GL_NV_texture_env_combine4 */ case GL_SOURCE3_RGB_NV: @@ -179,6 +179,9 @@ GLint __glGetTexParameterfv_size(GLenum pname) /* GL_EXT_texture_filter_anisotropic */ case GL_TEXTURE_MAX_ANISOTROPY_EXT: + + /* GL_NV_texture_expand_normal */ + case GL_TEXTURE_UNSIGNED_REMAP_MODE_NV: return 1; default: @@ -898,11 +901,11 @@ GLint __glGet_size(GLenum sq) case GL_BLEND_SRC_ALPHA: /* GL_EXT_fog_coord / GL 1.4 */ - case GL_CURRENT_FOG_COORDINATE: - case GL_FOG_COORDINATE_ARRAY_TYPE: - case GL_FOG_COORDINATE_ARRAY_STRIDE: - case GL_FOG_COORDINATE_ARRAY: - case GL_FOG_COORDINATE_SOURCE: + case GL_CURRENT_FOG_COORD: + case GL_FOG_COORD_ARRAY_TYPE: + case GL_FOG_COORD_ARRAY_STRIDE: + case GL_FOG_COORD_ARRAY: + case GL_FOG_COORD_SRC: /* GL_EXT_secondary_color / GL 1.4 */ case GL_COLOR_SUM: @@ -915,7 +918,7 @@ GLint __glGet_size(GLenum sq) case GL_MAX_TEXTURE_LOD_BIAS: /* GL_ARB_point_sprite */ - case GL_POINT_SPRITE_NV: + case GL_POINT_SPRITE_ARB: /* GL_ARB_vertex_blend */ case GL_MAX_VERTEX_UNITS_ARB: @@ -942,6 +945,9 @@ GLint __glGet_size(GLenum sq) /* GL_EXT_clip_volume_hint */ case GL_CLIP_VOLUME_CLIPPING_HINT_EXT: + /* GL_EXT_depth_bounds_test */ + case GL_DEPTH_BOUNDS_TEST_EXT: + /* GL_EXT_stencil_two_size */ case GL_STENCIL_TEST_TWO_SIDE_EXT: case GL_ACTIVE_STENCIL_FACE_EXT: @@ -958,9 +964,38 @@ GLint __glGet_size(GLenum sq) /* case GL_MODELVIEW0_STACK_DEPTH_EXT: */ /* alias */ case GL_MODELVIEW1_STACK_DEPTH_EXT: + /* GL_EXT_blend_equation_separate */ + /* case GL_BLEND_EQUATION_RGB_EXT: */ /* alias */ + case GL_BLEND_EQUATION_ALPHA_EXT: + /* GL_ATI_vertex_streams */ case GL_MAX_VERTEX_STREAMS_ATI: + /* GL_ATI_draw_buffers */ + case GL_MAX_DRAW_BUFFERS_ATI: + case GL_DRAW_BUFFER0_ATI: + case GL_DRAW_BUFFER1_ATI: + case GL_DRAW_BUFFER2_ATI: + case GL_DRAW_BUFFER3_ATI: + case GL_DRAW_BUFFER4_ATI: + case GL_DRAW_BUFFER5_ATI: + case GL_DRAW_BUFFER6_ATI: + case GL_DRAW_BUFFER7_ATI: + case GL_DRAW_BUFFER8_ATI: + case GL_DRAW_BUFFER9_ATI: + case GL_DRAW_BUFFER10_ATI: + case GL_DRAW_BUFFER11_ATI: + case GL_DRAW_BUFFER12_ATI: + case GL_DRAW_BUFFER13_ATI: + case GL_DRAW_BUFFER14_ATI: + case GL_DRAW_BUFFER15_ATI: + + /* GL_ATI_separate_stencil */ + case GL_STENCIL_BACK_FUNC_ATI: + case GL_STENCIL_BACK_FAIL_ATI: + case GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI: + case GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI: + /* GL_NV_depth_clamp */ case GL_DEPTH_CLAMP_NV: @@ -978,6 +1013,10 @@ GLint __glGet_size(GLenum sq) /* case GL_POINT_SPRITE_NV: */ /* alias */ case GL_POINT_SPRITE_R_MODE_NV: + /* GL_NV_primitive_restart */ + case GL_PRIMITIVE_RESTART_NV: + case GL_PRIMITIVE_RESTART_INDEX_NV: + /* GL_NV_register_combiners */ case GL_REGISTER_COMBINERS_NV: case GL_NUM_GENERAL_COMBINERS_NV: @@ -993,6 +1032,10 @@ GLint __glGet_size(GLenum sq) case GL_MAX_RECTANGLE_TEXTURE_SIZE_NV: return 1; + /* GL_EXT_depth_bounds_test */ + case GL_DEPTH_BOUNDS_EXT: + return 2; + /* GL_EXT_secondary_color / GL 1.4 */ case GL_CURRENT_SECONDARY_COLOR: diff --git a/GL/windows/ChangeLog b/GL/windows/ChangeLog index 2b049ee73..9732e8c86 100644 --- a/GL/windows/ChangeLog +++ b/GL/windows/ChangeLog @@ -1,3 +1,11 @@ +2004-08-13 Alexander Gottwald <ago@freedesktop.org> + + * Imakefile: Added $(MESASRCDIR)/src/mesa/glapi to INCLUDES. + Removed $(SERVERSRC)/mi from INCLUDES. + Rearranged INCLUDES for better readability. + * glwindows.h: Removed mipointrst.h and miscstruct.h from #include + since they are not used anymore. + 2004-05-27 Alexander Gottwald <ago@freedesktop.org> * glwindows.h: write current function and line in debug output diff --git a/GL/windows/glwindows.h b/GL/windows/glwindows.h index 1bfdcb715..aa984099c 100644 --- a/GL/windows/glwindows.h +++ b/GL/windows/glwindows.h @@ -4,8 +4,6 @@ #include <glxserver.h> #include <glxext.h> -#include <mipointrst.h> -#include <miscstruct.h> #include <windowstr.h> #include <resource.h> #include <GL/glxint.h> @@ -35,7 +33,7 @@ extern glWinDebugSettingsRec glWinDebugSettings; typedef struct { int num_vis; - __GLXvisualConfig *glx_vis; + __GLcontextModes *modes; void **priv; /* wrapped screen functions */ diff --git a/GL/windows/indirect.c b/GL/windows/indirect.c index 80aec7ee9..11dc0c092 100755 --- a/GL/windows/indirect.c +++ b/GL/windows/indirect.c @@ -43,6 +43,7 @@ #include "glwindows.h" +#include <glcontextmodes.h> #include "../../hw/xwin/winpriv.h" @@ -171,7 +172,7 @@ static void glWinResetExtension(void); * struct. In particular, the contextCreate, pGlxVisual, numVisuals, * and numUsableVisuals fields must be initialized. */ -__GLXscreenInfo __glDDXScreenInfo = { +static __GLXscreenInfo __glDDXScreenInfo = { glWinScreenProbe, /* Must be generic and handle all screens */ glWinCreateContext, /* Substitute screen's createContext routine */ glWinCreateBuffer, /* Substitute screen's createBuffer routine */ @@ -185,13 +186,21 @@ __GLXscreenInfo __glDDXScreenInfo = { NULL /* WrappedPositionWindow is overwritten */ }; -__GLXextensionInfo __glDDXExtensionInfo = { +void *__glXglDDXScreenInfo(void) { + return &__glDDXScreenInfo; +} + +static __GLXextensionInfo __glDDXExtensionInfo = { GL_CORE_WINDOWS, glWinResetExtension, glWinInitVisuals, glWinSetVisualConfigs }; +void *__glXglDDXExtensionInfo(void) { + return &__glDDXExtensionInfo; +} + /* prototypes */ static GLboolean glWinDestroyContext(__GLcontext *gc); @@ -863,27 +872,6 @@ static __GLXvisualConfig FallbackConfigs[NUM_FALLBACK_CONFIGS] = { } }; -static __GLXvisualConfig NullConfig = { - -1, /* vid */ - -1, /* class */ - False, /* rgba */ - -1, -1, -1, 0, /* rgba sizes */ - -1, -1, -1, 0, /* rgba masks */ - 0, 0, 0, 0, /* rgba accum sizes */ - False, /* doubleBuffer */ - False, /* stereo */ - -1, /* bufferSize */ - 16, /* depthSize */ - 0, /* stencilSize */ - 0, /* auxBuffers */ - 0, /* level */ - GLX_NONE_EXT, /* visualRating */ - 0, /* transparentPixel */ - 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ - 0 /* transparentIndex */ -}; - - static inline int count_bits(uint32_t x) { x = x - ((x >> 1) & 0x55555555); @@ -908,7 +896,7 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp, VisualPtr pVisual = *visualp; VisualPtr pVisualNew = NULL; VisualID *orig_vid = NULL; - __GLXvisualConfig *glXVisualPtr = NULL; + __GLcontextModes *modes = NULL; __GLXvisualConfig *pNewVisualConfigs = NULL; void **glXVisualPriv; void **pNewVisualPriv; @@ -990,9 +978,8 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp, } /* Alloc space for the list of glXVisuals */ - glXVisualPtr = (__GLXvisualConfig *)__glXMalloc(numNewVisuals * - sizeof(__GLXvisualConfig)); - if (!glXVisualPtr) { + modes = _gl_context_modes_create(numNewVisuals, sizeof(__GLcontextModes)); + if (modes == NULL) { __glXFree(orig_vid); __glXFree(pNewVisualPriv); __glXFree(pNewVisualConfigs); @@ -1002,7 +989,7 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp, /* Alloc space for the list of glXVisualPrivates */ glXVisualPriv = (void **)__glXMalloc(numNewVisuals * sizeof(void *)); if (!glXVisualPriv) { - __glXFree(glXVisualPtr); + _gl_context_modes_destroy( modes ); __glXFree(orig_vid); __glXFree(pNewVisualPriv); __glXFree(pNewVisualConfigs); @@ -1013,7 +1000,7 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp, pVisualNew = (VisualPtr)__glXMalloc(numNewVisuals * sizeof(VisualRec)); if (!pVisualNew) { __glXFree(glXVisualPriv); - __glXFree(glXVisualPtr); + _gl_context_modes_destroy( modes ); __glXFree(orig_vid); __glXFree(pNewVisualPriv); __glXFree(pNewVisualConfigs); @@ -1022,10 +1009,12 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp, /* Initialize the new visuals */ found_default = FALSE; + glWinScreens[screenInfo.numScreens-1].modes = modes; for (i = j = 0; i < numVisuals; i++) { int is_rgb = (pVisual[i].class == TrueColor || pVisual[i].class == DirectColor); +#if 0 if (!is_rgb) { /* We don't support non-rgb visuals for GL. But we don't @@ -1052,11 +1041,14 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp, continue; } +#endif for (k = 0; k < numNewConfigs; k++) { if (pNewVisualConfigs[k].rgba != is_rgb) continue; + assert( modes != NULL ); + /* Initialize the new visual */ pVisualNew[j] = pVisual[i]; pVisualNew[j].vid = FakeClientID(0); @@ -1071,8 +1063,8 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp, orig_vid[j] = pVisual[i].vid; /* Initialize the glXVisual */ - glXVisualPtr[j] = pNewVisualConfigs[k]; - glXVisualPtr[j].vid = pVisualNew[j].vid; + _gl_copy_visual_to_context_mode( modes, & pNewVisualConfigs[k] ); + modes->visualID = pVisualNew[j].vid; /* * If the class is -1, then assume the X visual information @@ -1080,23 +1072,27 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp, * visual. NOTE: if class != -1, then all other fields MUST * be initialized. */ - if (glXVisualPtr[j].class == -1) { - glXVisualPtr[j].class = pVisual[i].class; - glXVisualPtr[j].redSize = count_bits(pVisual[i].redMask); - glXVisualPtr[j].greenSize = count_bits(pVisual[i].greenMask); - glXVisualPtr[j].blueSize = count_bits(pVisual[i].blueMask); - glXVisualPtr[j].alphaSize = glXVisualPtr[j].alphaSize; - glXVisualPtr[j].redMask = pVisual[i].redMask; - glXVisualPtr[j].greenMask = pVisual[i].greenMask; - glXVisualPtr[j].blueMask = pVisual[i].blueMask; - glXVisualPtr[j].alphaMask = glXVisualPtr[j].alphaMask; - glXVisualPtr[j].bufferSize = rootDepth; + if (modes->visualType == GLX_NONE) { + modes->visualType = _gl_convert_from_x_visual_type( pVisual[i].class ); + modes->redBits = count_bits(pVisual[i].redMask); + modes->greenBits = count_bits(pVisual[i].greenMask); + modes->blueBits = count_bits(pVisual[i].blueMask); + modes->alphaBits = modes->alphaBits; + modes->redMask = pVisual[i].redMask; + modes->greenMask = pVisual[i].greenMask; + modes->blueMask = pVisual[i].blueMask; + modes->alphaMask = modes->alphaMask; + modes->rgbBits = (is_rgb) + ? (modes->redBits + modes->greenBits + + modes->blueBits + modes->alphaBits) + : rootDepth; } /* Save the device-dependent private for this visual */ glXVisualPriv[j] = pNewVisualPriv[k]; j++; + modes = modes->next; } } @@ -1104,7 +1100,6 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp, /* Save the GLX visuals in the screen structure */ glWinScreens[screenInfo.numScreens-1].num_vis = numNewVisuals; - glWinScreens[screenInfo.numScreens-1].glx_vis = glXVisualPtr; glWinScreens[screenInfo.numScreens-1].priv = glXVisualPriv; /* Set up depth's VisualIDs */ @@ -1159,29 +1154,30 @@ static void fixup_visuals(int screen) { ScreenPtr pScreen = screenInfo.screens[screen]; glWinScreenRec *pScr = &glWinScreens[screen]; - __GLXvisualConfig *pGLXVis = pScr->glx_vis; - VisualPtr pVis; - int i, j; + __GLcontextModes *modes; + int j; GLWIN_DEBUG_MSG("fixup_visuals\n"); - for (i = 0; i < pScr->num_vis; i++, pGLXVis++) { - pVis = pScreen->visuals; + for (modes = pScr->modes; modes != NULL; modes = modes->next ) { + const int vis_class = _gl_convert_to_x_visual_type( modes->visualType ); + const int nplanes = (modes->rgbBits - modes->alphaBits); + VisualPtr pVis = pScreen->visuals; /* Find a visual that matches the GLX visual's class and size */ - for (j = 0; j < pScreen->numVisuals; j++, pVis++) { - if (pVis->class == pGLXVis->class && - pVis->nplanes == pGLXVis->bufferSize) { + for (j = 0; j < pScreen->numVisuals; j++) { + if (pVis[j].class == vis_class && + pVis[j].nplanes == nplanes) { /* Fixup the masks */ - pGLXVis->redMask = pVis->redMask; - pGLXVis->greenMask = pVis->greenMask; - pGLXVis->blueMask = pVis->blueMask; + modes->redMask = pVis[j].redMask; + modes->greenMask = pVis[j].greenMask; + modes->blueMask = pVis[j].blueMask; /* Recalc the sizes */ - pGLXVis->redSize = count_bits(pGLXVis->redMask); - pGLXVis->greenSize = count_bits(pGLXVis->greenMask); - pGLXVis->blueSize = count_bits(pGLXVis->blueMask); + modes->redBits = count_bits(modes->redMask); + modes->greenBits = count_bits(modes->greenMask); + modes->blueBits = count_bits(modes->blueMask); } } } @@ -1190,67 +1186,75 @@ static void fixup_visuals(int screen) static void init_screen_visuals(int screen) { ScreenPtr pScreen = screenInfo.screens[screen]; - __GLXvisualConfig *pGLXVis = glWinScreens[screen].glx_vis; - /* XMesaVisual *pXMesaVisual; */ - VisualPtr pVis; + __GLcontextModes *modes; int *used; int i, j; GLWIN_DEBUG_MSG("init_screen_visuals\n"); - /* Alloc space for the list of XMesa visuals */ -#if 0 - pXMesaVisual = (XMesaVisual *)__glXMalloc(MESAScreens[screen].num_vis * - sizeof(XMesaVisual)); - __glXMemset(pXMesaVisual, 0, - MESAScreens[screen].num_vis * sizeof(XMesaVisual)); -#endif - used = (int *)__glXMalloc(pScreen->numVisuals * sizeof(int)); __glXMemset(used, 0, pScreen->numVisuals * sizeof(int)); - for (i = 0; i < glWinScreens[screen].num_vis; i++, pGLXVis++) { - pVis = pScreen->visuals; - for (j = 0; j < pScreen->numVisuals; j++, pVis++) { - - if (pVis->class == pGLXVis->class && - pVis->nplanes == pGLXVis->bufferSize && + i = 0; + for ( modes = glWinScreens[screen].modes + ; modes != NULL + ; modes = modes->next) { + const int vis_class = _gl_convert_to_x_visual_type( modes->visualType ); + const int nplanes = (modes->rgbBits - modes->alphaBits); + const VisualPtr pVis = pScreen->visuals; + + for (j = 0; j < pScreen->numVisuals; j++) { + + if (pVis[j].class == vis_class && + pVis[j].nplanes == nplanes && + pVis[j].redMask == modes->redMask && + pVis[j].greenMask == modes->greenMask && + pVis[j].blueMask == modes->blueMask && !used[j]) { - if (pVis->redMask == pGLXVis->redMask && - pVis->greenMask == pGLXVis->greenMask && - pVis->blueMask == pGLXVis->blueMask) { - - /* Create the XMesa visual */ #if 0 - pXMesaVisual[i] = - XMesaCreateVisual(pScreen, - pVis, - pGLXVis->rgba, - (pGLXVis->alphaSize > 0), - pGLXVis->doubleBuffer, - pGLXVis->stereo, - GL_TRUE, /* ximage_flag */ - pGLXVis->depthSize, - pGLXVis->stencilSize, - pGLXVis->accumRedSize, - pGLXVis->accumGreenSize, - pGLXVis->accumBlueSize, - pGLXVis->accumAlphaSize, - 0, /* numSamples */ - pGLXVis->level, - pGLXVis->visualRating ); + /* Create the XMesa visual */ + pXMesaVisual[i] = + XMesaCreateVisual(pScreen, + pVis, + modes->rgbMode, + (modes->alphaBits > 0), + modes->doubleBufferMode, + modes->stereoMode, + GL_TRUE, /* ximage_flag */ + modes->depthBits, + modes->stencilBits, + modes->accumRedBits, + modes->accumGreenBits, + modes->accumBlueBits, + modes->accumAlphaBits, + modes->samples, + modes->level, + modes->visualRating); #endif + + /* Set the VisualID */ + modes->visualID = pVis[j].vid; - /* Set the VisualID */ - pGLXVis->vid = pVis->vid; + /* Mark this visual used */ + used[j] = 1; + break; + } + } - /* Mark this visual used */ - used[j] = 1; - break; - } - } + if ( j == pScreen->numVisuals ) { + ErrorF("No matching visual for __GLcontextMode with " + "visual class = %d (%d), nplanes = %u\n", + vis_class, + modes->visualType, + (modes->rgbBits - modes->alphaBits) ); + } + else if ( modes->visualID == -1 ) { + FatalError( "Matching visual found, but visualID still -1!\n" ); } + + i++; + } __glXFree(used); @@ -1268,7 +1272,7 @@ static Bool glWinScreenProbe(int screen) /* * Set up the current screen's visuals. */ - __glDDXScreenInfo.pGlxVisual = glWinScreens[screen].glx_vis; + __glDDXScreenInfo.modes = glWinScreens[screen].modes; __glDDXScreenInfo.pVisualPriv = glWinScreens[screen].priv; __glDDXScreenInfo.numVisuals = __glDDXScreenInfo.numUsableVisuals = glWinScreens[screen].num_vis; diff --git a/XTrap/xtrapdi.c b/XTrap/xtrapdi.c index 4fe54e1da..bcd5b8a6e 100644 --- a/XTrap/xtrapdi.c +++ b/XTrap/xtrapdi.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/XTrap/xtrapdi.c,v 1.1.4.3.2.3 2004/03/04 20:15:59 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/XTrap/xtrapdi.c,v 1.2 2004/04/23 18:44:40 eich Exp $ */ /* $XFree86: xc/programs/Xserver/XTrap/xtrapdi.c,v 1.6tsi Exp $ */ /***************************************************************************** Copyright 1987, 1988, 1989, 1990, 1991 by Digital Equipment Corp., Maynard, MA diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c index d9e36d47e..90afc2b3d 100644 --- a/Xext/panoramiX.c +++ b/Xext/panoramiX.c @@ -53,6 +53,12 @@ Equipment Corporation. #include "modinit.h" +#ifdef GLXPROXY +extern VisualPtr glxMatchVisual(ScreenPtr pScreen, + VisualPtr pVisual, + ScreenPtr pMatchScreen); +#endif + #if 0 static unsigned char PanoramiXReqCode = 0; #endif @@ -416,6 +422,56 @@ XineramaRegisterConnectionBlockCallback(void (*func)(void)) return TRUE; } +static void XineramaInitData(ScreenPtr pScreen) +{ + int i, w, h; + + REGION_NULL(pScreen, &PanoramiXScreenRegion) + for (i = 0; i < PanoramiXNumScreens; i++) { + BoxRec TheBox; + + pScreen = screenInfo.screens[i]; + + panoramiXdataPtr[i].x = dixScreenOrigins[i].x; + panoramiXdataPtr[i].y = dixScreenOrigins[i].y; + panoramiXdataPtr[i].width = pScreen->width; + panoramiXdataPtr[i].height = pScreen->height; + + TheBox.x1 = panoramiXdataPtr[i].x; + TheBox.x2 = TheBox.x1 + panoramiXdataPtr[i].width; + TheBox.y1 = panoramiXdataPtr[i].y; + TheBox.y2 = TheBox.y1 + panoramiXdataPtr[i].height; + + REGION_INIT(pScreen, &XineramaScreenRegions[i], &TheBox, 1); + REGION_UNION(pScreen, &PanoramiXScreenRegion, &PanoramiXScreenRegion, + &XineramaScreenRegions[i]); + } + + PanoramiXPixWidth = panoramiXdataPtr[0].x + panoramiXdataPtr[0].width; + PanoramiXPixHeight = panoramiXdataPtr[0].y + panoramiXdataPtr[0].height; + + for (i = 1; i < PanoramiXNumScreens; i++) { + w = panoramiXdataPtr[i].x + panoramiXdataPtr[i].width; + h = panoramiXdataPtr[i].y + panoramiXdataPtr[i].height; + + if (PanoramiXPixWidth < w) + PanoramiXPixWidth = w; + if (PanoramiXPixHeight < h) + PanoramiXPixHeight = h; + } +} + +void XineramaReinitData(ScreenPtr pScreen) +{ + int i; + + REGION_UNINIT(pScreen, &PanoramiXScreenRegion); + for (i = 0; i < PanoramiXNumScreens; i++) + REGION_UNINIT(pScreen, &XineramaScreenRegions[i]); + + XineramaInitData(pScreen); +} + /* * PanoramiXExtensionInit(): * Called from InitExtensions in main(). @@ -430,8 +486,7 @@ void PanoramiXExtensionInit(int argc, char *argv[]) ExtensionEntry *extEntry; ScreenPtr pScreen = screenInfo.screens[0]; PanoramiXScreenPtr pScreenPriv; - int w, h; - + if (noPanoramiXExtension) return; @@ -509,41 +564,7 @@ void PanoramiXExtensionInit(int argc, char *argv[]) return; } - - REGION_NULL(pScreen, &PanoramiXScreenRegion); - for (i = 0; i < PanoramiXNumScreens; i++) { - BoxRec TheBox; - - pScreen = screenInfo.screens[i]; - - panoramiXdataPtr[i].x = dixScreenOrigins[i].x; - panoramiXdataPtr[i].y = dixScreenOrigins[i].y; - panoramiXdataPtr[i].width = pScreen->width; - panoramiXdataPtr[i].height = pScreen->height; - - TheBox.x1 = panoramiXdataPtr[i].x; - TheBox.x2 = TheBox.x1 + panoramiXdataPtr[i].width; - TheBox.y1 = panoramiXdataPtr[i].y; - TheBox.y2 = TheBox.y1 + panoramiXdataPtr[i].height; - - REGION_INIT(pScreen, &XineramaScreenRegions[i], &TheBox, 1); - REGION_UNION(pScreen, &PanoramiXScreenRegion, &PanoramiXScreenRegion, - &XineramaScreenRegions[i]); - } - - - PanoramiXPixWidth = panoramiXdataPtr[0].x + panoramiXdataPtr[0].width; - PanoramiXPixHeight = panoramiXdataPtr[0].y + panoramiXdataPtr[0].height; - - for (i = 1; i < PanoramiXNumScreens; i++) { - w = panoramiXdataPtr[i].x + panoramiXdataPtr[i].width; - h = panoramiXdataPtr[i].y + panoramiXdataPtr[i].height; - - if(PanoramiXPixWidth < w) - PanoramiXPixWidth = w; - if(PanoramiXPixHeight < h) - PanoramiXPixHeight = h; - } + XineramaInitData(pScreen); /* * Put our processes into the ProcVector @@ -789,6 +810,18 @@ void PanoramiXConsolidate(void) /* check if the visual exists on all screens */ for (j = 1; j < PanoramiXNumScreens; j++) { pScreen2 = screenInfo.screens[j]; + +#ifdef GLXPROXY + pVisual2 = glxMatchVisual(pScreen, pVisual, pScreen2); + if (pVisual2) { + PanoramiXVisualTable[(pVisual->vid * MAXSCREENS) + j] = + pVisual2->vid; + continue; + } else if (glxMatchVisual(pScreen, pVisual, pScreen)) { + PanoramiXVisualTable[(pVisual->vid * MAXSCREENS) + j] = 0; + break; + } +#endif pVisual2 = pScreen2->visuals; for (k = 0; k < pScreen2->numVisuals; k++, pVisual2++) { diff --git a/Xext/panoramiX.h b/Xext/panoramiX.h index 65b77948f..ff97e8897 100644 --- a/Xext/panoramiX.h +++ b/Xext/panoramiX.h @@ -1,5 +1,5 @@ /* $TOG: panoramiX.h /main/4 1998/03/17 06:51:02 kaleb $ */ -/* $XdotOrg: xc/programs/Xserver/Xext/panoramiX.h,v 1.1.4.1.4.2 2004/03/08 00:36:56 alanc Exp $ */ +/* $XdotOrg: xc/programs/Xserver/Xext/panoramiX.h,v 1.2 2004/04/23 18:44:41 eich Exp $ */ /***************************************************************** Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts. diff --git a/Xext/panoramiXsrv.h b/Xext/panoramiXsrv.h index 1d187bc27..92800062e 100644 --- a/Xext/panoramiXsrv.h +++ b/Xext/panoramiXsrv.h @@ -20,6 +20,8 @@ extern WindowPtr PanoramiXChangeWindow(int, WindowPtr); extern Bool XineramaRegisterConnectionBlockCallback(void (*func)(void)); extern int XineramaDeleteResource(pointer, XID); +extern void XineramaReinitData(ScreenPtr); + extern RegionRec XineramaScreenRegions[MAXSCREENS]; extern unsigned long XRC_DRAWABLE; diff --git a/Xext/saver.c b/Xext/saver.c index 84eb7f294..33173d3ce 100644 --- a/Xext/saver.c +++ b/Xext/saver.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/Xext/saver.c,v 1.1.4.3.2.2 2004/03/04 17:47:20 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/Xext/saver.c,v 1.2 2004/04/23 18:44:41 eich Exp $ */ /* * $XConsortium: saver.c,v 1.12 94/04/17 20:59:36 dpw Exp $ * diff --git a/Xext/security.c b/Xext/security.c index a5b8e6604..488296f51 100644 --- a/Xext/security.c +++ b/Xext/security.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/Xext/security.c,v 1.1.4.3.4.1 2004/03/04 17:47:20 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/Xext/security.c,v 1.2 2004/04/23 18:44:41 eich Exp $ */ /* $Xorg: security.c,v 1.4 2001/02/09 02:04:32 xorgcvs Exp $ */ /* diff --git a/Xext/shape.c b/Xext/shape.c index eccfabac8..7842a402b 100644 --- a/Xext/shape.c +++ b/Xext/shape.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/Xext/shape.c,v 1.1.4.4.2.3 2004/03/04 20:16:01 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/Xext/shape.c,v 1.4 2004/07/29 23:43:39 kem Exp $ */ /* $XFree86: xc/programs/Xserver/Xext/shape.c,v 3.18 2003/10/28 23:08:43 tsi Exp $ */ /************************************************************ @@ -61,10 +61,6 @@ static int ShapeFreeEvents( pointer /* data */, XID /* id */ ); -static void SendShapeNotify( - WindowPtr /* pWin */, - int /* which */ - ); static void ShapeResetProc( ExtensionEntry * /* extEntry */ ); @@ -85,12 +81,9 @@ RegionOperate ( CreateDftPtr /* create */ ); -#define CREATE_PROC(func) RegionPtr func(WindowPtr /* pWin */) - -static CREATE_PROC(CreateBoundingShape); -static CREATE_PROC(CreateClipShape); - -#undef CREATE_PROC +/* SendShapeNotify, CreateBoundingShape and CreateClipShape are used + * externally by the Xfixes extension and are now defined in window.h + */ static DISPATCH_PROC(ProcShapeCombine); static DISPATCH_PROC(ProcShapeDispatch); @@ -261,7 +254,7 @@ RegionOperate (client, pWin, kind, destRgnp, srcRgn, op, xoff, yoff, create) return Success; } -static RegionPtr +RegionPtr CreateBoundingShape (pWin) WindowPtr pWin; { @@ -274,7 +267,7 @@ CreateBoundingShape (pWin) return REGION_CREATE(pWin->drawable.pScreen, &extents, 1); } -static RegionPtr +RegionPtr CreateClipShape (pWin) WindowPtr pWin; { @@ -880,7 +873,7 @@ ProcShapeSelectInput (client) * deliver the event */ -static void +void SendShapeNotify (pWin, which) WindowPtr pWin; int which; diff --git a/Xext/shm.c b/Xext/shm.c index fb8a66694..29eab06f5 100644 --- a/Xext/shm.c +++ b/Xext/shm.c @@ -1,4 +1,3 @@ -/* $XdotOrg: xc/programs/Xserver/Xext/shm.c,v 1.1.4.5.2.3 2004/03/04 20:16:01 kaleb Exp $ */ /* $XFree86: xc/programs/Xserver/Xext/shm.c,v 3.41 2003/12/17 23:28:56 alanh Exp $ */ /************************************************************ diff --git a/Xext/xres.c b/Xext/xres.c index dd429649d..8558f4731 100644 --- a/Xext/xres.c +++ b/Xext/xres.c @@ -2,7 +2,7 @@ Copyright (c) 2002 XFree86 Inc */ /* $XFree86: xc/programs/Xserver/Xext/xres.c,v 1.7tsi Exp $ */ -/* $XdotOrg: xc/programs/Xserver/Xext/xres.c,v 1.1.4.1.6.2 2004/03/08 23:40:19 alanc Exp $ */ +/* $XdotOrg: xc/programs/Xserver/Xext/xres.c,v 1.2 2004/04/23 18:44:42 eich Exp $ */ #define NEED_EVENTS #define NEED_REPLIES diff --git a/Xext/xtest.c b/Xext/xtest.c index 09d135044..1ba8e3df5 100644 --- a/Xext/xtest.c +++ b/Xext/xtest.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/Xext/xtest.c,v 1.1.4.4.2.2 2004/03/04 17:47:20 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/Xext/xtest.c,v 1.2 2004/04/23 18:44:42 eich Exp $ */ /* $Xorg: xtest.c,v 1.4 2001/02/09 02:04:33 xorgcvs Exp $ */ /* diff --git a/Xext/xtest1di.c b/Xext/xtest1di.c index 47e60f6b6..8248d6078 100644 --- a/Xext/xtest1di.c +++ b/Xext/xtest1di.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/Xext/xtest1di.c,v 1.1.4.3.4.1 2004/03/04 17:47:20 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/Xext/xtest1di.c,v 1.2 2004/04/23 18:44:42 eich Exp $ */ /* $Xorg: xtest1di.c,v 1.4 2001/02/09 02:04:33 xorgcvs Exp $ */ /* * File: xtest1di.c diff --git a/Xext/xvdisp.c b/Xext/xvdisp.c index 8e6ea19b1..f10d157e6 100644 --- a/Xext/xvdisp.c +++ b/Xext/xvdisp.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/Xext/xvdisp.c,v 1.1.4.3.2.2 2004/03/04 17:47:20 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/Xext/xvdisp.c,v 1.2 2004/04/23 18:44:42 eich Exp $ */ /*********************************************************** Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts, and the Massachusetts Institute of Technology, Cambridge, Massachusetts. diff --git a/Xext/xvmain.c b/Xext/xvmain.c index 188eb77be..3de18019d 100644 --- a/Xext/xvmain.c +++ b/Xext/xvmain.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/Xext/xvmain.c,v 1.1.4.3.2.2 2004/03/04 17:47:20 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/Xext/xvmain.c,v 1.2 2004/04/23 18:44:42 eich Exp $ */ /*********************************************************** Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts, and the Massachusetts Institute of Technology, Cambridge, Massachusetts. diff --git a/XpConfig/C/print/Xprinters b/XpConfig/C/print/Xprinters index 9290636fb..a32c02dc2 100644 --- a/XpConfig/C/print/Xprinters +++ b/XpConfig/C/print/Xprinters @@ -29,6 +29,13 @@ #Augment_Printer_List %none% ######################################################################## +# Preconfigured entry for the PSspooldir model +# (which sends jobs to /tmp/Xprintjobs instead to a physical printer) +######################################################################## +#Printer xp_pdf_spooldir_tmp_Xprintjobs +Printer xp_ps_spooldir_tmp_Xprintjobs + +######################################################################## # Add individual printers to the list of printers managed by the # server. These are aliases, determined by driver name. ######################################################################## @@ -40,4 +47,3 @@ # Printer xppclpr # Printer xppclmonopr # Printer xprasterpr - diff --git a/XpConfig/C/print/attributes/document b/XpConfig/C/print/attributes/document index e0be64553..b1651bd94 100644 --- a/XpConfig/C/print/attributes/document +++ b/XpConfig/C/print/attributes/document @@ -20,10 +20,21 @@ *content-orientation: portrait *copy-count: 1 *default-medium: iso-a4 -*default-printer-resolution: 300 -*document-format: {Postscript 2} -*plex: duplex +*default-printer-resolution: 600 +# "PSspooldir" jobs should always be 300 DPI +# (to be compatible to DPS-based PostScript viewers such as sdtimage) +PSspooldir.default-printer-resolution: 300 + +# "PS2PDFspooldir-GS" jobs should always be 600 DPI +PS2PDFspooldir-GS.default-printer-resolution: 600 + +# Some resolution defaults to make applications happy which are too lazy +# to pick an own default in absence of "default-printer-resolution" +HPLJ4050-PS.default-printer-resolution: 600 +SPSPARC2.default-printer-resolution: 300 +CANONBJ10E-GS.default-printer-resolution: 360 +CANONC3200-PS.default-printer-resolution: 600 # EXAMPLES # diff --git a/XpConfig/C/print/attributes/printer b/XpConfig/C/print/attributes/printer index a49afa5f0..41e13b44b 100644 --- a/XpConfig/C/print/attributes/printer +++ b/XpConfig/C/print/attributes/printer @@ -16,8 +16,24 @@ # Set this attribute for all printers. # Example: "*.document-formats-ready: {pcl 5}" +# Remove this line and replace them with per printer settings +# if you want to use more than one DDX!! +*xp-model-identifier: PSdefault -*xp-ddx-identifier: XP-POSTSCRIPT + +# Sample entry for the "PSspooldir" model +# Just add a printer called "xp_ps_spooldir_tmp_Xprintjobs" to "Xprinters" +# and you will get an extra printer which files the PostScript jobs +# in the "/tmp/Xprintjobs/" directory. +xp_ps_spooldir_tmp_Xprintjobs.xp-model-identifier: PSspooldir + +# Sample entry for the "PS2PDFspooldir-GS" model +# Just add a printer called "xp_pdf_spooldir_tmp_Xprintjobs" to "Xprinters" +# and you will get an extra printer which convertes the PostScript jobs +# to PDF using "ps2pdf" and files them into the "/tmp/Xprintjobs/" directory. +# NOTE: Future versions of Xprint will use the PDF DDX instead directly +# instead of relying on GhostScript/ps2pdf... +xp_pdf_spooldir_tmp_Xprintjobs.xp-model-identifier: PS2PDFspooldir-GS # IMPORTANT EXAMPLES diff --git a/XpConfig/C/print/models/HPDJ1600C/fonts/fonts.alias b/XpConfig/C/print/models/HPDJ1600C/fonts/fonts.alias index 1499aa845..e69de29bb 100644 --- a/XpConfig/C/print/models/HPDJ1600C/fonts/fonts.alias +++ b/XpConfig/C/print/models/HPDJ1600C/fonts/fonts.alias @@ -1 +0,0 @@ -! So the file isn't empty diff --git a/XpConfig/C/print/models/HPDJ1600C/model-config b/XpConfig/C/print/models/HPDJ1600C/model-config index f3bd8af3a..5d45d4495 100644 --- a/XpConfig/C/print/models/HPDJ1600C/model-config +++ b/XpConfig/C/print/models/HPDJ1600C/model-config @@ -1,28 +1,16 @@ -# $Xorg: model-config,v 1.3 2000/08/17 19:48:04 cpqbld Exp $ +# $Xprint.org: HPDJ1600C model-config,v 1.4 2002/11/07 19:48:04 gisburn Exp $ # This is the configuration file for the HP DeskJet 1600C printer. # # The CDEnext SI supports two 1600C drivers XP-PCL-MONO and # XP-PCL-COLOR, which work with this configuration file. # -# Attribute IDs must be qualified using either the printer-model -# identifier or an asterisk ('*'). For example, if "HPDJ1600C" is the -# printer-model, then to initialize the 'plexes-supported' attribute -# to 'simplex', use: "HPDJ1600C.plexes-supported: simplex". For the -# asterisk, use: "*.plexes-supported: simplex". If the same attribute -# is specified using each method, the printer-model qualified entry -# takes precedence. - -HPDJ1600C.printer-model: "Hewlett-Packard DeskJet 1600C" -HPDJ1600C.printer-resolutions-supported: 300 -HPDJ1600C.content-orientations-supported: portrait landscape -HPDJ1600C.document-formats-supported: {PCL 5} {PostScript 2} -HPDJ1600C.plexes-supported: simplex duplex -HPDJ1600C.xp-ddx-identifier: XP-PCL-COLOR -HPDJ1600C.xp-embedded-formats-supported: { PCL 5 } { PostScript 2 } -HPDJ1600C.xp-setup-proviso: setup-optional +*content-orientations-supported: portrait landscape +*descriptor: Hewlett-Packard DeskJet 1600C +*document-formats-supported: {PCL 5} {PostScript 2} +*input-trays-supported: # 1/4" unprintable margins -HPDJ1600C.medium-source-sizes-supported:\ +*medium-source-sizes-supported:\ { '' \ {na-letter FALSE {6.35 209.55 6.35 273.05}}\ {executive FALSE {6.35 177.75 6.35 260.35}}\ @@ -41,4 +29,12 @@ HPDJ1600C.medium-source-sizes-supported:\ {hp-japanese-postcard FALSE {6 94 6 142 }}\ {hp-japanese-doublepostcard FALSE {6 142 6 194 }}\ } - +*plexes-supported: simplex duplex +*printer-model: "Hewlett-Packard DeskJet 1600C" +*printer-resolutions-supported: 300 +*xp-ddx-identifier: XP-PCL-COLOR +*xp-listfonts-modes-supported: xp-list-internal-printer-fonts xp-list-glyph-fonts +*xp-embedded-formats-supported: { PCL 5 } { PostScript 2 } +*xp-raw-formats-supported: { PCL 5 } +*xp-setup-proviso: setup-optional +# EOF. diff --git a/XpConfig/C/print/models/HPLJ4family/fonts/fonts.alias b/XpConfig/C/print/models/HPLJ4family/fonts/fonts.alias index 1499aa845..e69de29bb 100644 --- a/XpConfig/C/print/models/HPLJ4family/fonts/fonts.alias +++ b/XpConfig/C/print/models/HPLJ4family/fonts/fonts.alias @@ -1 +0,0 @@ -! So the file isn't empty diff --git a/XpConfig/C/print/models/HPLJ4family/model-config b/XpConfig/C/print/models/HPLJ4family/model-config index f69e25718..1ac997ebe 100644 --- a/XpConfig/C/print/models/HPLJ4family/model-config +++ b/XpConfig/C/print/models/HPLJ4family/model-config @@ -1,28 +1,15 @@ -# $Xorg: model-config,v 1.3 2000/08/17 19:48:04 cpqbld Exp $ +# $Xprint.org: HPLJ4family model-config,v 1.4 2002/11/07 19:48:04 gisburn Exp $ # This is the configuration file for the HP LaserJet 4 Printers. # # Though not a deliverable for the CDEnext SI, the XP-PCL-MONO # driver should be able to support the LaserJet 4 printers. # -# Attribute IDs must be qualified using either the printer-model -# identifier or an asterisk ('*'). For example, if "HPLJ4family" is the -# printer-model, then to initialize the 'plexes-supported' attribute -# to 'simplex', use: "HPLJ4family.plexes-supported: simplex". For the -# asterisk, use: "*.plexes-supported: simplex". If the same attribute -# is specified using each method, the printer-model qualified entry -# takes precedence. - -HPLJ4family.printer-model: "Hewlett-Packard LaserJet 4 Series" -HPLJ4family.printer-resolutions-supported: 300 600 -HPLJ4family.content-orientations-supported: portrait landscape -HPLJ4family.document-formats-supported: {PCL 5} {PostScript 2} -HPLJ4family.plexes-supported: simplex duplex -HPLJ4family.xp-ddx-identifier: XP-PCL-MONO -HPLJ4family.xp-embedded-formats-supported: { PCL 5 } { PostScript 2 } -HPLJ4family.xp-setup-proviso: setup-optional - +*content-orientations-supported: portrait landscape +*descriptor: Hewlett-Packard LaserJet 4 Series +*document-formats-supported: {PCL 5} {PostScript 2} +*input-trays-supported: # 1/4" unprintable margins -HPLJ4family.medium-source-sizes-supported:\ +*medium-source-sizes-supported:\ { '' \ {na-letter FALSE {6.35 209.55 6.35 273.05}}\ {executive FALSE {6.35 177.75 6.35 260.35}}\ @@ -41,4 +28,12 @@ HPLJ4family.medium-source-sizes-supported:\ {hp-japanese-postcard FALSE {6 94 6 142 }}\ {hp-japanese-doublepostcard FALSE {6 142 6 194 }}\ } - +*plexes-supported: simplex duplex +*printer-model: "Hewlett-Packard LaserJet 4 Series" +*printer-resolutions-supported: 300 600 +*xp-ddx-identifier: XP-PCL-MONO +*xp-listfonts-modes-supported: xp-list-internal-printer-fonts xp-list-glyph-fonts +*xp-embedded-formats-supported: { PCL 5 } { PostScript 2 } +*xp-raw-formats-supported: { PCL 5 } +*xp-setup-proviso: setup-optional +# EOF. diff --git a/XpConfig/C/print/models/SPSPARC2/model-config b/XpConfig/C/print/models/SPSPARC2/model-config index 959e9ff7b..9f29b9992 100644 --- a/XpConfig/C/print/models/SPSPARC2/model-config +++ b/XpConfig/C/print/models/SPSPARC2/model-config @@ -1,13 +1,18 @@ -# $Xorg: model-config,v 1.3 2000/08/17 19:48:04 cpqbld Exp $ -SPSPARC2.printer-model: "SunPics SPARCprinter II" -SPSPARC2.printer-resolutions-supported: 300 -SPSPARC2.content-orientations-supported: portrait landscape -SPSPARC2.document-formats-supported: {PostScript 2} -SPSPARC2.plexes-supported: simplex -SPSPARC2.xp-ddx-identifier: XP-POSTSCRIPT -SPSPARC2.xp-embedded-formats-supported: { PostScript 2 } -*xp-setup-proviso: setup-optional -SPSPARC2.medium-source-sizes-supported: \ +# $Xprint.org: SPSPARC2 model-config,v 1.4 2002/11/07 19:48:04 gisburn Exp $ +*content-orientations-supported: portrait landscape +*descriptor: SunPics SPARCprinter II +*document-formats-supported: {POSTSCRIPT 2} +*input-trays-supported: +*medium-source-sizes-supported: \ { '' {na-letter FALSE {6.35 209.55 6.35 273.05}} \ {na-legal FALSE {6.35 209.55 6.35 349.25}} \ {iso-a4 FALSE {6.35 203.65 6.35 290.65}}} +*plexes-supported: simplex +*printer-model: "SunPics SPARCprinter II" +*printer-resolutions-supported: 300 +*xp-ddx-identifier: XP-POSTSCRIPT +*xp-listfonts-modes-supported: xp-list-internal-printer-fonts xp-list-glyph-fonts +*xp-embedded-formats-supported: {POSTSCRIPT 2} +*xp-raw-formats-supported: {POSTSCRIPT 2} +*xp-setup-proviso: setup-optional +# EOF. diff --git a/Xprint/AttrValid.c b/Xprint/AttrValid.c index a3046c159..86bfd14e5 100644 --- a/Xprint/AttrValid.c +++ b/Xprint/AttrValid.c @@ -30,8 +30,6 @@ not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from said copyright holders. */ -/* $XFree86: xc/programs/Xserver/Xprint/AttrValid.c,v 1.4 2001/01/17 22:36:27 dawes Exp $ */ - #include <scrnintstr.h> #include "attributes.h" @@ -46,7 +44,7 @@ static XpOidMediumDiscreteSizeList DefaultMediumSizeList = { &DefaultMediumSize, 1 }; static XpOidMediumSourceSize DefaultMediumSourceSize = { - xpoid_unspecified, XpOidMediumSS_DISCRETE, { &DefaultMediumSizeList } + xpoid_unspecified, XpOidMediumSS_DISCRETE, &DefaultMediumSizeList }; static XpOidMediumSS DefaultMediumSS = { &DefaultMediumSourceSize, 1 @@ -298,7 +296,7 @@ XpPutMediumSSAttr(XpContextPtr pContext, } const XpOidMediumSS* -XpGetDefaultMediumSS(void) +XpGetDefaultMediumSS() { return &DefaultMediumSS; } diff --git a/Xprint/AttrValid.h b/Xprint/AttrValid.h index 8e431c285..8e27ae01a 100644 --- a/Xprint/AttrValid.h +++ b/Xprint/AttrValid.h @@ -30,7 +30,6 @@ not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from said copyright holders. */ -/* $XFree86: xc/programs/Xserver/Xprint/AttrValid.h,v 1.6 2001/10/31 22:50:27 tsi Exp $ */ #ifndef _Xp_AttrValid_h #define _Xp_AttrValid_h @@ -85,7 +84,7 @@ typedef struct #define XpPutStringAttr(pContext, pool, oid, value) \ XpPutOneAttribute(pContext, pool, XpOidString(oid), value) -#ifdef _XP_PRINT_SERVER_ /* needed for XpContextPtr in Printstr.h */ +#ifdef _XP_PRINT_SERVER_ /* needed for XpContextPtr in Printstr.h */ /* * XpOid-valued attribute access @@ -179,7 +178,7 @@ void XpPutMediumSSAttr(XpContextPtr pContext, XPAttributes pool, XpOid oid, const XpOidMediumSS* msss); -const XpOidMediumSS* XpGetDefaultMediumSS(void); +const XpOidMediumSS* XpGetDefaultMediumSS(); /* * XpOidTrayMediumList-valued attribute access @@ -193,15 +192,12 @@ void XpPutTrayMediumListAttr(XpContextPtr pContext, XPAttributes pool, XpOid oid, const XpOidTrayMediumList* tm); -BOOL XpOidTrayMediumListHasTray(const XpOidTrayMediumList* list, XpOid tray); - /* * Attribute pool validation */ void XpValidateAttributePool(XpContextPtr pContext, XPAttributes pool, const XpValidatePoolsRec* vpr); -void XpValidateNotificationProfile(XpContextPtr pContext); void XpValidatePrinterPool(XpContextPtr pContext, const XpValidatePoolsRec* vpr); void XpValidateJobPool(XpContextPtr pContext, @@ -210,9 +206,6 @@ void XpValidateDocumentPool(XpContextPtr pContext, const XpValidatePoolsRec* vpr); void XpValidatePagePool(XpContextPtr pContext, const XpValidatePoolsRec* vpr); -void XpValidatePrinterMediaAttrs(XpContextPtr pContext, - const XpOidList* valid_trays, - const XpOidList* valid_sizes); #endif /* _XP_PRINT_SERVER_ */ diff --git a/Xprint/DiPrint.h b/Xprint/DiPrint.h index d6364af26..0b781f2fc 100644 --- a/Xprint/DiPrint.h +++ b/Xprint/DiPrint.h @@ -30,8 +30,6 @@ not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from said copyright holders. */ -/* $XFree86: xc/programs/Xserver/Xprint/DiPrint.h,v 1.3 1999/12/16 02:26:24 robin Exp $ */ - /* * The XpDiListEntry struct is the type of each element of the array * handed back to the extension code to handle a GetPrinterList request. diff --git a/Xprint/Init.c b/Xprint/Init.c index 0deafda7c..cd16847ee 100644 --- a/Xprint/Init.c +++ b/Xprint/Init.c @@ -2,11 +2,12 @@ /* (c) Copyright 1996 Hewlett-Packard Company (c) Copyright 1996 International Business Machines Corp. -(c) Copyright 1996 Sun Microsystems, Inc. +(c) Copyright 1996-2004 Sun Microsystems, Inc. (c) Copyright 1996 Novell, Inc. (c) Copyright 1996 Digital Equipment Corp. (c) Copyright 1996 Fujitsu Limited (c) Copyright 1996 Hitachi, Ltd. +(c) Copyright 2003-2004 Roland Mainz <roland.mainz@nrubsig.org> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -50,7 +51,6 @@ copyright holders. ** ********************************************************* ** ********************************************************************/ -/* $XFree86: xc/programs/Xserver/Xprint/Init.c,v 1.14tsi Exp $ */ #include <unistd.h> #include <stdlib.h> @@ -91,6 +91,7 @@ typedef char *XPointer; #include "attributes.h" #include "os.h" +#include "spooler.h" static void GenericScreenInit( int index, @@ -116,57 +117,6 @@ static Bool InitPrintDrivers( #define MODELDIRNAME "/models" #define FONTDIRNAME "/fonts" -/* - * The string LIST_QUEUES is fed to a shell to generate an ordered - * list of available printers on the system. These string definitions - * are taken from the file PrintSubSys.C within the code for the - * dtprintinfo program. - */ -#ifdef AIXV4 -const char *LIST_QUEUES = "lsallq | grep -v '^bsh$' | sort"; -#else -#ifdef hpux -const char *LIST_QUEUES = "LANG=C lpstat -v | " - "awk '" - " $2 == \"for\" " - " { " - " x = match($3, /:/); " - " print substr($3, 1, x-1)" - " }' | sort"; -#else -#ifdef __osf__ - const char *LIST_QUEUES = "LANG=C lpstat -v | " - "nawk '" - " $2 == \"for\" " - " { print $4 }' " - " | sort"; -#else -#ifdef __uxp__ -const char *LIST_QUEUES = "LANG=C lpstat -v | " - "nawk '" - " $4 == \"for\" " - " { " - " x = match($5, /:/); " - " print substr($5, 1, x-1)" - " }' | sort"; -#else -#if defined(CSRG_BASED) || defined(linux) || defined(ISC) || defined(__GNUC__) -const char *LIST_QUEUES = "LANG=C lpc status | grep -v '^\t' | " - "sed -e /:/s/// | sort"; -#else -const char *LIST_QUEUES = "LANG=C lpstat -v | " - "nawk '" - " $2 == \"for\" " - " { " - " x = match($3, /:/); " - " print substr($3, 1, x-1)" - " }' | sort"; -#endif -#endif -#endif -#endif -#endif - #ifdef XPRASTERDDX static @@ -183,9 +133,9 @@ PixmapFormatRec RasterPixmapFormats[] = { static PixmapFormatRec ColorPclPixmapFormats[] = { - { 1, 1, BITMAP_SCANLINE_PAD }, - { 8, 8, BITMAP_SCANLINE_PAD }, - { 24,32, BITMAP_SCANLINE_PAD } + { 1, 1, BITMAP_SCANLINE_PAD }, + { 8, 8, BITMAP_SCANLINE_PAD }, + { 24, 32, BITMAP_SCANLINE_PAD } }; #define NUMCPCLFORMATS (sizeof ColorPclPixmapFormats)/(sizeof ColorPclPixmapFormats[0]) @@ -211,9 +161,9 @@ PixmapFormatRec MonoPclPixmapFormats[] = { static PixmapFormatRec PSPixmapFormats[] = { - { 1, 1, BITMAP_SCANLINE_PAD }, - { 8, 8, BITMAP_SCANLINE_PAD }, - { 24,32, BITMAP_SCANLINE_PAD } + { 1, 1, BITMAP_SCANLINE_PAD }, + { 8, 8, BITMAP_SCANLINE_PAD }, + { 24, 32, BITMAP_SCANLINE_PAD } }; #define NUMPSFORMATS (sizeof PSPixmapFormats)/(sizeof PSPixmapFormats[0]) @@ -296,6 +246,7 @@ typedef struct _printerDbEntry { char *qualifier; int screenNum; char *driverName; + char *desc; } PrinterDbEntry, *PrinterDbPtr; static PrinterDbPtr printerDb = (PrinterDbPtr)NULL; @@ -325,10 +276,82 @@ typedef struct _driverMapping { int screenNum; } DriverMapEntry, *DriverMapPtr; +static const char configFilePath[] = +"/etc/dt/config/print:/usr/dt/config/print"; + +static const char printServerConfigDir[] = "XPSERVERCONFIGDIR"; + +static int printScreenPrivIndex, + printWindowPrivIndex, + printGCPrivIndex; +static unsigned long printGeneration = 0; static char *configFileName = (char *)NULL; static Bool freeDefaultFontPath = FALSE; static char *origFontPath = (char *)NULL; +static Bool xprintInitGlobalsCalled = FALSE; +/* + * This function is responsible for doing initalisation of any global + * variables at an very early point of server startup (even before + * |ProcessCommandLine()|. + */ +void XprintInitGlobals(void) +{ + extern char dispatchExceptionAtReset; /* defined in Xserver/dix/dispatch.c */ + + xprintInitGlobalsCalled = TRUE; + +#ifdef SMART_SCHEDULE + /* Somehow the XF86 "smart scheduler" completely kills the Xprint DDX + * (see http://xprint.freedesktop.org/cgi-bin/bugzilla/show_bug.cgi?id=467 + * ("Xfree86's "smart scheduler" breaks Xprt") */ + SmartScheduleDisable = TRUE; +#endif /* SMART_SCHEDULE */ + + /* Disable internal screensaver for Xprint (workaround for + * http://pdx.freedesktop.org/cgi-bin/bugzilla/show_bug.cgi?id=567 ("Xorg + * Xprt starts to consume 100% CPU when being idle for some time")) */ + defaultScreenSaverTime = 0; + + /* Ensure that the maximum request size for the BIGREQUESTS extension + * is at least 8MB (see + * http://xprint.freedesktop.org/cgi-bin/bugzilla/show_bug.cgi?id=622 - "RFE: + * Xprt's default BIGREQUESTS extension buffer size should be 8MB") + */ + maxBigRequestSize = (8*1048576)-1; + + /* Xprt should not reset by default when the last client exists + * (default for Xprt is |0|, video Xservers use |DE_RESET|) */ + dispatchExceptionAtReset = 0; +} + +/* + * XprintUseMsg() prints usage for the Xprint-specific options + */ +void XprintUseMsg() +{ + XpSpoolerTypePtr curr = xpstm; + + /* Option '-XpFile' */ + ErrorF("-XpFile file specifies an alternate `Xprinters' file, rather\n"); + ErrorF(" than the default one (e.g.\n"); + ErrorF(" `${XPCONFIGDIR}/${LANG}/print/Xprinters') or\n"); + ErrorF(" `${XPCONFIGDIR}/C/print/Xprinters'.\n"); + + /* Option '-XpSpoolerType' */ + ErrorF("-XpSpoolerType string specifies a spooler type.\n"); + ErrorF(" Supported values are:\n"); + + while( curr->name != NULL ) + { + ErrorF(" - '%s'\n", curr->name); + curr++; + } + ErrorF(" (multiple values can be specified, seperated by ':',\n"); + ErrorF(" the first active spooler will be chosen).\n"); + ErrorF(" default is '%s'.\n", XPDEFAULTSPOOLERNAMELIST); +} + /* * XprintOptions checks argv[i] to see if it is our command line * option specifying a configuration file name. It returns the index @@ -340,6 +363,7 @@ XprintOptions( char **argv, int i) { + extern void ddxUseMsg(); if(strcmp(argv[i], "-XpFile") == 0) { if ((i + 1) >= argc) { @@ -349,8 +373,19 @@ XprintOptions( configFileName = argv[i + 1]; return i + 2; } + else if(strcmp(argv[i], "-XpSpoolerType") == 0) + { + if ((i + 1) >= argc) { + ddxUseMsg (); + return i + 2; + } + XpSetSpoolerTypeNameList(argv[i + 1]); + return i + 2; + } else + { return i; + } } /************************************************************ @@ -417,19 +452,21 @@ FreePrinterDb(void) { PrinterDbPtr pCurEntry, pNextEntry; - for(pCurEntry = printerDb, pNextEntry = 0; + for(pCurEntry = printerDb, pNextEntry = (PrinterDbPtr)NULL; pCurEntry != (PrinterDbPtr)NULL; pCurEntry = pNextEntry) { pNextEntry = pCurEntry->next; if(pCurEntry->name != (char *)NULL) xfree(pCurEntry->name); + if(pCurEntry->desc != (char *)NULL) + xfree(pCurEntry->desc); /* * We don't free the driver name, because it's expected to simply * be a pointer into the xrm database. */ xfree(pCurEntry); } - printerDb = 0; + printerDb = (PrinterDbPtr)NULL; } /* @@ -439,12 +476,13 @@ FreePrinterDb(void) * XXX AddPrinterDbName needs to check for (and not add) duplicate names. */ static Bool -AddPrinterDbName(char *name) +AddPrinterDbName(char *name, char *desc) { PrinterDbPtr pEntry = (PrinterDbPtr)xalloc(sizeof(PrinterDbEntry)); if(pEntry == (PrinterDbPtr)NULL) return FALSE; - pEntry->name = strdup(name); + pEntry->name = (name != NULL) ? strdup(name) : NULL; + pEntry->desc = (desc != NULL) ? strdup(desc) : NULL; pEntry->qualifier = (char *)NULL; if(printerDb == (PrinterDbPtr)NULL) @@ -460,20 +498,45 @@ AddPrinterDbName(char *name) return TRUE; } -static void +static int AugmentPrinterDb(const char *command) { FILE *fp; char name[256]; + int num_printers = 0; /* Number of printers we found */ + size_t namelen; + char *desc = NULL; fp = popen(command, "r"); /* XXX is a 256 character limit overly restrictive for printer names? */ - while(fgets(name, 256, fp) != (char *)NULL && strlen(name)) + while(fgets(name, 256, fp) != (char *)NULL && (namelen=strlen(name))) { - name[strlen(name) - 1] = (char)'\0'; /* strip the \n */ - AddPrinterDbName(name); + char *option = name; + + name[namelen-1] = (char)'\0'; /* strip the \n */ + +#define XP_DESCRIPTOR "xp-printerattr.descriptor=" +#define XP_DESCRIPTOR_LEN (sizeof(XP_DESCRIPTOR)-1) + while (option = strchr(option, '\t')) { + option++; /* Skip the '\t' */ + if (!strncmp(option, XP_DESCRIPTOR, XP_DESCRIPTOR_LEN)) { + *(option-1) = '\0'; /* Kill the '\t' (only if we found a valid option) */ + option += XP_DESCRIPTOR_LEN; + if (*option != '\0') { + desc = option; + } + } + else + { + /* Unknown option */ + ErrorF("AugmentPrinterDb: Unknown option '%s'\n", option); + } + } + AddPrinterDbName(name, desc); + num_printers++; } pclose(fp); + return num_printers; } /* @@ -592,7 +655,7 @@ StoreDriverNames(void) "xp-ddx-identifier"); if(pEntry->driverName == (char *)NULL || strlen(pEntry->driverName) == 0 || - GetInitFunc(pEntry->driverName) == 0) + GetInitFunc(pEntry->driverName) == (Bool(*)())NULL) { if (pEntry->driverName && (strlen(pEntry->driverName) != 0)) { ErrorF("Xp Extension: Can't load driver %s\n", @@ -609,6 +672,29 @@ StoreDriverNames(void) } } +/* + * StoreDescriptors - queries the attribute store for the descriptor. + * if the descriptor is not in the attribute database, then the descriptor + * from the printerDb is store in the attribute store for the printer. + */ +static void +StoreDescriptors() +{ + PrinterDbPtr pEntry; + + for(pEntry = printerDb; pEntry != (PrinterDbPtr)NULL; + pEntry = pEntry->next) + { + if (pEntry->desc != NULL) + { + XpAddPrinterAttribute(pEntry->name, + (pEntry->qualifier != (char *)NULL)? + pEntry->qualifier : pEntry->name, + "*descriptor", pEntry->desc); + } + } +} + static char * MbStrchr( char *str, @@ -650,7 +736,7 @@ GetConfigFileName(void) /* * Check for a LANG-specific file. */ - if ((dirName = XpGetConfigDir(TRUE)) != 0) + if(dirName = XpGetConfigDir(TRUE)) { filePath = (char *)xalloc(strlen(dirName) + strlen(XPRINTERSFILENAME) + 2); @@ -669,7 +755,7 @@ GetConfigFileName(void) xfree(filePath); } - if ((dirName = XpGetConfigDir(FALSE)) != 0) + if(dirName = XpGetConfigDir(FALSE)) { filePath = (char *)xalloc(strlen(dirName) + strlen(XPRINTERSFILENAME) + 2); @@ -701,6 +787,7 @@ GetConfigFileName(void) static PrinterDbPtr BuildPrinterDb(void) { + char *printerList, *augmentCmd = (char *)NULL; Bool defaultAugment = TRUE, freeConfigFileName; if(configFileName && access(configFileName, R_OK) != 0) @@ -727,9 +814,9 @@ BuildPrinterDb(void) { while((tok = strtok((char *)NULL, " \t")) != (char *)NULL) { - if ((ptr = MbStrchr(tok, '\012')) != 0) + if(ptr = MbStrchr(tok, '\012')) *ptr = (char)'\0'; - AddPrinterDbName(tok); + AddPrinterDbName(tok, NULL); } } else if(strcmp(tok, "Map") == 0) @@ -768,7 +855,43 @@ BuildPrinterDb(void) if(defaultAugment == TRUE) { - AugmentPrinterDb(LIST_QUEUES); + XpSpoolerTypePtr curr_spooler_type; /* spooler we are currently probing for queues */ + int num_printers_found; /* number of printers found by |AugmentPrinterDb()| */ + char *tok_lasts; /* strtok_r() position token */ + char *spnamelist; /* list of spooler names, seperated by ":" */ + char *spname; /* spooler name */ + + spnamelist = strdup(XpGetSpoolerTypeNameList()); /* strtok_r() modifies string so dup' it first */ + + for( spname = strtok_r(spnamelist, ":", &tok_lasts) ; + spname != NULL ; + spname = strtok_r(NULL, ":", &tok_lasts) ) + { + curr_spooler_type = XpSpoolerNameToXpSpoolerType(spname); + if(!curr_spooler_type) + { + FatalError("BuildPrinterDb: No spooler type entry found for '%s'.\n", spname); + } + + if(curr_spooler_type->list_queues_command == NULL || + strlen(curr_spooler_type->list_queues_command) == 0) + { + continue; + } + + num_printers_found = AugmentPrinterDb(curr_spooler_type->list_queues_command); + /* Did we found a spooler which works ? */ + if(num_printers_found > 0) + { + spooler_type = curr_spooler_type; +#ifdef DEBUG_gisburn + fprintf(stderr, "BuildPrinterDb: using '%s'.\n", spooler_type->name); +#endif /* DEBUG_gisburn */ + break; + } + } + + free(spnamelist); } MergeNameMap(); @@ -782,6 +905,7 @@ BuildPrinterDb(void) * in the printerDb */ StoreDriverNames(); + StoreDescriptors(); if(freeConfigFileName) { @@ -951,7 +1075,7 @@ FindFontDir( return (char *)NULL; configDir = XpGetConfigDir(TRUE); - if ((fontDir = ValidateFontDir(configDir, modelName)) != 0) + if(fontDir = ValidateFontDir(configDir, modelName)) { xfree(configDir); return fontDir; @@ -1013,8 +1137,8 @@ AddToFontPath( static void AugmentFontPath(void) { - char *modelID, **allIDs = (char **)NULL; - PrinterDbPtr pDbEntry; + char *newPath, *modelID, **allIDs = (char **)NULL; + PrinterDbPtr pDb, pDbEntry; int numModels, i; if(!origFontPath) @@ -1072,7 +1196,7 @@ AugmentFontPath(void) for(i = 0; allIDs != (char **)NULL && allIDs[i] != (char *)NULL; i ++) { char *fontDir; - if ((fontDir = FindFontDir(allIDs[i])) != 0) + if(fontDir = FindFontDir(allIDs[i])) { AddToFontPath(fontDir); xfree(fontDir); @@ -1162,7 +1286,7 @@ XpClientIsPrintClient( * fpe->name. */ if(fpe->name_length < PATH_PREFIX_LEN || - (strlen(fontDir) != (unsigned)(fpe->name_length - PATH_PREFIX_LEN)) || + (strlen(fontDir) != (fpe->name_length - PATH_PREFIX_LEN)) || strncmp(fontDir, fpe->name + PATH_PREFIX_LEN, fpe->name_length - PATH_PREFIX_LEN)) { @@ -1235,6 +1359,38 @@ PrinterInitOutput( char **driverNames; char *configDir; + /* This should NEVER happen, but... */ + if( !xprintInitGlobalsCalled ) + { + FatalError("Internal error: XprintInitGlobals() not called."); + } +#ifdef SMART_SCHEDULE + /* |XprintInitGlobals| should have set |SmartScheduleDisable| to + * |TRUE| - if not we will trigger this safeguard. */ + if( SmartScheduleDisable != TRUE ) + { + FatalError("Internal error: XF86 smart scheduler incompatible to Xprint DDX."); + } +#endif /* SMART_SCHEDULE */ + /* Safeguard for + * http://pdx.freedesktop.org/cgi-bin/bugzilla/show_bug.cgi?id=567 ("Xorg + * Xprt starts to consume 100% CPU when being idle for some time") + * |XprintInitGlobals| should have set |defaultScreenSaverTime| to + * |0| - if not we will trigger this trap. */ + if( defaultScreenSaverTime != 0 ) + { + FatalError("Internal screen saver must be OFF for printing."); + } + + /* Print a warnung when the maximum request size of the BIGREQUESTS + * extension is smaller than 8MB (see + * http://xprint.freedesktop.org/cgi-bin/bugzilla/show_bug.cgi?id=622) + */ + if (maxBigRequestSize < (8*1048576)-1) { + ErrorF("Xp Extension: BIGREQUESTS max. request is currently %ld bytes " + ", recommemded minimum for Xprint is 8MB.\n", (long)maxBigRequestSize); + } + /* * this little test is just a warning at startup to make sure * that the config directory exists. @@ -1254,10 +1410,9 @@ PrinterInitOutput( xfree(configDir); } else { - ErrorF("Xp Extension: could not find config dir %s\n", - configDir ? configDir : XPRINTDIR); - - if (configDir) xfree(configDir); + /* Refuse to start when we do not have our config dir... */ + FatalError("Xp Extension: could not find config dir %s\n", + configDir ? configDir : XPRINTDIR); } if(printerDb != (PrinterDbPtr)NULL) @@ -1414,7 +1569,7 @@ InitPrintDrivers( } if(callInit == TRUE) { - pBFunc initFunc; + Bool (*initFunc)(); initFunc = GetInitFunc(pDb->driverName); if(initFunc(index, pScreen, argc, argv) == FALSE) { @@ -1451,9 +1606,10 @@ GenericScreenInit( int argc, char **argv) { + int i; float fWidth, fHeight, maxWidth, maxHeight; unsigned short width, height; - PrinterDbPtr pDb; + PrinterDbPtr pDb, pDb2; int res, maxRes; /* @@ -1477,6 +1633,7 @@ GenericScreenInit( { if(pDb->screenNum == index) { + XpValidatePoolsRec *pValRec; pVFunc dimensionsFunc; @@ -1506,6 +1663,57 @@ GenericScreenInit( } /* + * QualifyName - takes an unqualified file name such as X6printers and + * a colon-separated list of directory path names such as + * /etc/opt/dt:/opt/dt/config. + * + * Returns a fully qualified file path name such as /etc/opt/dt/X6printers. + * The returned value is malloc'd, and the caller is responsible for + * freeing the associated memory. + */ +static char * +QualifyName(fileName, searchPath) + char *fileName; + char *searchPath; +{ + char * curPath = searchPath; + char * nextPath; + char * chance; + FILE *pFile; + + if (fileName == NULL || searchPath == NULL) + return NULL; + + while (1) { + if ((nextPath = strchr(curPath, ':')) != NULL) + *nextPath = 0; + + chance = (char *)xalloc(strlen(curPath) + strlen(fileName) + 2); + sprintf(chance,"%s/%s",curPath,fileName); + + /* see if we can read from the file */ + if((pFile = fopen(chance, "r")) != (FILE *)NULL) + { + fclose(pFile); + /* ... restore the colon, .... */ + if (nextPath) + *nextPath = ':'; + + return chance; + } + + xfree(chance); + + if (nextPath == NULL) /* End of path list? */ + break; + + /* try the next path */ + curPath = nextPath + 1; + } + return NULL; +} + +/* * FillPrinterListEntry fills in a single XpDiListEntry element with data * derived from the supplied PrinterDbPtr element. * @@ -1548,12 +1756,11 @@ GetPrinterListInfo( int localeLen, char *locale) { - PrinterDbPtr pDb; + PrinterDbPtr pDb, pDb2; for(pDb = printerDb; pDb != (PrinterDbPtr)NULL; pDb = pDb->next) { - if (strlen(pDb->name) == (unsigned)nameLen - && !strncmp(pDb->name, name, nameLen)) + if(strlen(pDb->name) == nameLen && !strncmp(pDb->name, name, nameLen)) { FillPrinterListEntry(pEntry, pDb, localeLen, locale); return TRUE; @@ -1598,7 +1805,7 @@ XpDiGetPrinterList( if(!nameLen || name == (char *)NULL) { int i; - PrinterDbPtr pDb; + PrinterDbPtr pDb, pDb2; for(pDb = printerDb, i = 0; pDb != (PrinterDbPtr)NULL; pDb = pDb->next, i++) @@ -1648,11 +1855,12 @@ WindowPtr XpDiValidatePrinter(char *printerName, int printerNameLen) { PrinterDbPtr pCurEntry; + WindowPtr pWin; for(pCurEntry = printerDb; pCurEntry != (PrinterDbPtr)NULL; pCurEntry = pCurEntry->next) { - if(strlen(pCurEntry->name) == (unsigned)printerNameLen && + if(strlen(pCurEntry->name) == printerNameLen && !strncmp(pCurEntry->name, printerName, printerNameLen)) return WindowTable[pCurEntry->screenNum]; } @@ -1680,3 +1888,4 @@ XpDiGetDriverName(int index, char *printerName) return (char *)NULL; /* XXX Should we supply a default driverName? */ } + diff --git a/Xprint/Oid.c b/Xprint/Oid.c index 311d177d0..32be3efb1 100644 --- a/Xprint/Oid.c +++ b/Xprint/Oid.c @@ -30,7 +30,6 @@ not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from said copyright holders. */ -/* $XFree86: xc/programs/Xserver/Xprint/Oid.c,v 1.5tsi Exp $ */ #include "attributes.h" @@ -274,7 +273,7 @@ XpOidParse(const char* value_string, */ if(ptr_return != (const char**)NULL) *ptr_return = ptr+length; - return (XpOid)i; + return i; } /* @@ -751,7 +750,7 @@ XpOidLinkedListFirstOid(XpOidLinkedList* me) XpOid XpOidLinkedListNextOid(XpOidLinkedList* me) { - if(me->current ? (me->current = me->current->next) != 0 : xFalse) + if(me->current ? me->current = me->current->next : xFalse) return me->current->oid; else return xpoid_none; @@ -1652,6 +1651,8 @@ TrayMediumListValidate(XpOidTrayMediumList* me, const XpOidMediumSS* msss) { int i_mss, i_ds, i_itm; + XpOidMediumDiscreteSizeList* ds_list; + int tray_count; XpOid current_tray, current_medium; XpOidMediumDiscreteSizeList* unspecified_tray_ds; XpOidMediumDiscreteSizeList* tray_ds; @@ -1711,7 +1712,6 @@ TrayMediumListValidate(XpOidTrayMediumList* me, * list */ if(tray_ds == (XpOidMediumDiscreteSizeList*)NULL) - { if(unspecified_tray_ds == (XpOidMediumDiscreteSizeList*)NULL) { /* @@ -1722,10 +1722,7 @@ TrayMediumListValidate(XpOidTrayMediumList* me, continue; } else - { tray_ds = unspecified_tray_ds; - } - } /* * loop through the discrete sizes list, looking for a size that * matches the medium for the current input tray @@ -2107,13 +2104,15 @@ const char* XpOidNotifyString(XpOidNotify notify) { switch(notify) { - default: case XPOID_NOTIFY_UNSUPPORTED: return (const char*)NULL; + break; case XPOID_NOTIFY_NONE: return NOTIFY_NONE_STR; + break; case XPOID_NOTIFY_EMAIL: return NOTIFY_EMAIL_STR; + break; } } @@ -2238,7 +2237,7 @@ XpOidDocFmtNext(XpOidDocFmt* doc_fmt, const char* first_nonws_ptr; const char* format; const char* variant; - const char* version = 0; + const char* version; int format_len; int variant_len; int version_len; @@ -2551,12 +2550,10 @@ XpOidDocFmtListHasFmt(const XpOidDocFmtList* list, * variants must both be NULL or match */ if(fmt->variant == (char*)NULL) - { if(list->list[i].variant == (char*)NULL) return xTrue; else continue; - } if(list->list[i].variant == (char*)NULL) continue; if(strcmp(fmt->variant, list->list[i].variant) != 0) @@ -2565,12 +2562,10 @@ XpOidDocFmtListHasFmt(const XpOidDocFmtList* list, * versions must both be NULL or match */ if(fmt->version == (char*)NULL) - { if(list->list[i].version == (char*)NULL) return xTrue; else continue; - } if(list->list[i].version == (char*)NULL) continue; if(strcmp(fmt->version, list->list[i].version) == 0) diff --git a/Xprint/Oid.h b/Xprint/Oid.h index e2a97869f..70bd8d3e5 100644 --- a/Xprint/Oid.h +++ b/Xprint/Oid.h @@ -30,7 +30,6 @@ not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from said copyright holders. */ -/* $XFree86: xc/programs/Xserver/Xprint/Oid.h,v 1.3 1999/12/16 02:26:24 robin Exp $ */ #ifndef _Xp_Oid_h #define _Xp_Oid_h @@ -206,7 +205,7 @@ char* XpOidListString(const XpOidList*); /* * XpOidLinkedList public methods */ -XpOidLinkedList* XpOidLinkedListNew(void); +XpOidLinkedList* XpOidLinkedListNew(); void XpOidLinkedListDelete(XpOidLinkedList*); #define XpOidLinkedListCount(l) ((l) ? (l)->count : 0) XpOid XpOidLinkedListGetOid(XpOidLinkedList* list, int i); diff --git a/Xprint/OidDefs.h b/Xprint/OidDefs.h index 03e530cb2..55b6568f0 100644 --- a/Xprint/OidDefs.h +++ b/Xprint/OidDefs.h @@ -133,6 +133,14 @@ typedef enum { xpoid_val_medium_size_jis_b8, xpoid_val_medium_size_jis_b9, xpoid_val_medium_size_jis_b10, + xpoid_val_medium_size_hp_2x_postcard, + xpoid_val_medium_size_hp_european_edp, + xpoid_val_medium_size_hp_mini, + xpoid_val_medium_size_hp_postcard, + xpoid_val_medium_size_hp_tabloid, + xpoid_val_medium_size_hp_us_edp, + xpoid_val_medium_size_hp_us_government_legal, + xpoid_val_medium_size_hp_us_government_letter, xpoid_val_plex_simplex, xpoid_val_plex_duplex, xpoid_val_plex_tumble, diff --git a/Xprint/OidStrs.h b/Xprint/OidStrs.h index 6489ae533..1792a6e16 100644 --- a/Xprint/OidStrs.h +++ b/Xprint/OidStrs.h @@ -30,140 +30,144 @@ not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from said copyright holders. */ -/* $XFree86: xc/programs/Xserver/Xprint/OidStrs.h,v 1.4 2001/01/17 22:36:28 dawes Exp $ */ +/* This is an automatically-generated file. Do not edit. */ static int XpOidStringMapCount = 127; -#define OIDATA(name) { name, sizeof(name)-1, 0, 0, 0 } - static const XpOidStringMapEntry XpOidStringMap[] = { - OIDATA(""), - OIDATA(""), - OIDATA("descriptor"), - OIDATA("content-orientation"), - OIDATA("copy-count"), - OIDATA("default-printer-resolution"), - OIDATA("default-input-tray"), - OIDATA("default-medium"), - OIDATA("document-format"), - OIDATA("plex"), - OIDATA("xp-listfonts-modes"), - OIDATA("job-name"), - OIDATA("job-owner"), - OIDATA("notification-profile"), - OIDATA("xp-setup-state"), - OIDATA("xp-spooler-command-options"), - OIDATA("content-orientations-supported"), - OIDATA("document-formats-supported"), - OIDATA("dt-pdm-command"), - OIDATA("input-trays-medium"), - OIDATA("medium-source-sizes-supported"), - OIDATA("plexes-supported"), - OIDATA("printer-model"), - OIDATA("printer-name"), - OIDATA("printer-resolutions-supported"), - OIDATA("xp-embedded-formats-supported"), - OIDATA("xp-listfonts-modes-supported"), - OIDATA("xp-page-attributes-supported"), - OIDATA("xp-raw-formats-supported"), - OIDATA("xp-setup-proviso"), - OIDATA("document-attributes-supported"), - OIDATA("job-attributes-supported"), - OIDATA("locale"), - OIDATA("multiple-documents-supported"), - OIDATA("available-compression"), - OIDATA("available-compressions-supported"), - OIDATA("portrait"), - OIDATA("landscape"), - OIDATA("reverse-portrait"), - OIDATA("reverse-landscape"), - OIDATA("iso-a0"), - OIDATA("iso-a1"), - OIDATA("iso-a2"), - OIDATA("iso-a3"), - OIDATA("iso-a4"), - OIDATA("iso-a5"), - OIDATA("iso-a6"), - OIDATA("iso-a7"), - OIDATA("iso-a8"), - OIDATA("iso-a9"), - OIDATA("iso-a10"), - OIDATA("iso-b0"), - OIDATA("iso-b1"), - OIDATA("iso-b2"), - OIDATA("iso-b3"), - OIDATA("iso-b4"), - OIDATA("iso-b5"), - OIDATA("iso-b6"), - OIDATA("iso-b7"), - OIDATA("iso-b8"), - OIDATA("iso-b9"), - OIDATA("iso-b10"), - OIDATA("na-letter"), - OIDATA("na-legal"), - OIDATA("executive"), - OIDATA("folio"), - OIDATA("invoice"), - OIDATA("ledger"), - OIDATA("quarto"), - OIDATA("iso-c3"), - OIDATA("iso-c4"), - OIDATA("iso-c5"), - OIDATA("iso-c6"), - OIDATA("iso-designated-long"), - OIDATA("na-10x13-envelope"), - OIDATA("na-9x12-envelope"), - OIDATA("na-number-10-envelope"), - OIDATA("na-7x9-envelope"), - OIDATA("na-9x11-envelope"), - OIDATA("na-10x14-envelope"), - OIDATA("na-number-9-envelope"), - OIDATA("na-6x9-envelope"), - OIDATA("na-10x15-envelope"), - OIDATA("monarch-envelope"), - OIDATA("a"), - OIDATA("b"), - OIDATA("c"), - OIDATA("d"), - OIDATA("e"), - OIDATA("jis-b0"), - OIDATA("jis-b1"), - OIDATA("jis-b2"), - OIDATA("jis-b3"), - OIDATA("jis-b4"), - OIDATA("jis-b5"), - OIDATA("jis-b6"), - OIDATA("jis-b7"), - OIDATA("jis-b8"), - OIDATA("jis-b9"), - OIDATA("jis-b10"), - OIDATA("simplex"), - OIDATA("duplex"), - OIDATA("tumble"), - OIDATA("top"), - OIDATA("middle"), - OIDATA("bottom"), - OIDATA("envelope"), - OIDATA("manual"), - OIDATA("large-capacity"), - OIDATA("main"), - OIDATA("side"), - OIDATA("event-report-job-completed"), - OIDATA("electronic-mail"), - OIDATA("xp-setup-mandatory"), - OIDATA("xp-setup-optional"), - OIDATA("xp-setup-ok"), - OIDATA("xp-setup-incomplete"), - OIDATA("xp-list-glyph-fonts"), - OIDATA("xp-list-internal-printer-fonts"), - OIDATA("0"), - OIDATA("01"), - OIDATA("02"), - OIDATA("03"), - OIDATA("012"), - OIDATA("013"), - OIDATA("023"), - OIDATA("0123") + { "", 0 }, + { "", 0 }, + { "descriptor", 10 }, + { "content-orientation", 19 }, + { "copy-count", 10 }, + { "default-printer-resolution", 26 }, + { "default-input-tray", 18 }, + { "default-medium", 14 }, + { "document-format", 15 }, + { "plex", 4 }, + { "xp-listfonts-modes", 18 }, + { "job-name", 8 }, + { "job-owner", 9 }, + { "notification-profile", 20 }, + { "xp-setup-state", 14 }, + { "xp-spooler-command-options", 26 }, + { "content-orientations-supported", 30 }, + { "document-formats-supported", 26 }, + { "dt-pdm-command", 14 }, + { "input-trays-medium", 18 }, + { "medium-source-sizes-supported", 29 }, + { "plexes-supported", 16 }, + { "printer-model", 13 }, + { "printer-name", 12 }, + { "printer-resolutions-supported", 29 }, + { "xp-embedded-formats-supported", 29 }, + { "xp-listfonts-modes-supported", 28 }, + { "xp-page-attributes-supported", 28 }, + { "xp-raw-formats-supported", 24 }, + { "xp-setup-proviso", 16 }, + { "document-attributes-supported", 29 }, + { "job-attributes-supported", 24 }, + { "locale", 6 }, + { "multiple-documents-supported", 28 }, + { "available-compression", 21 }, + { "available-compressions-supported", 32 }, + { "portrait", 8 }, + { "landscape", 9 }, + { "reverse-portrait", 16 }, + { "reverse-landscape", 17 }, + { "iso-a0", 6 }, + { "iso-a1", 6 }, + { "iso-a2", 6 }, + { "iso-a3", 6 }, + { "iso-a4", 6 }, + { "iso-a5", 6 }, + { "iso-a6", 6 }, + { "iso-a7", 6 }, + { "iso-a8", 6 }, + { "iso-a9", 6 }, + { "iso-a10", 7 }, + { "iso-b0", 6 }, + { "iso-b1", 6 }, + { "iso-b2", 6 }, + { "iso-b3", 6 }, + { "iso-b4", 6 }, + { "iso-b5", 6 }, + { "iso-b6", 6 }, + { "iso-b7", 6 }, + { "iso-b8", 6 }, + { "iso-b9", 6 }, + { "iso-b10", 7 }, + { "na-letter", 9 }, + { "na-legal", 8 }, + { "executive", 9 }, + { "folio", 5 }, + { "invoice", 7 }, + { "ledger", 6 }, + { "quarto", 6 }, + { "iso-c3", 6 }, + { "iso-c4", 6 }, + { "iso-c5", 6 }, + { "iso-c6", 6 }, + { "iso-designated-long", 19 }, + { "na-10x13-envelope", 17 }, + { "na-9x12-envelope", 16 }, + { "na-number-10-envelope", 21 }, + { "na-7x9-envelope", 15 }, + { "na-9x11-envelope", 16 }, + { "na-10x14-envelope", 17 }, + { "na-number-9-envelope", 20 }, + { "na-6x9-envelope", 15 }, + { "na-10x15-envelope", 17 }, + { "monarch-envelope", 16 }, + { "a", 1 }, + { "b", 1 }, + { "c", 1 }, + { "d", 1 }, + { "e", 1 }, + { "jis-b0", 6 }, + { "jis-b1", 6 }, + { "jis-b2", 6 }, + { "jis-b3", 6 }, + { "jis-b4", 6 }, + { "jis-b5", 6 }, + { "jis-b6", 6 }, + { "jis-b7", 6 }, + { "jis-b8", 6 }, + { "jis-b9", 6 }, + { "jis-b10", 7 }, + { "hp-2x-postcard", 14 }, + { "hp-european-edp", 15 }, + { "hp-mini", 7 }, + { "hp-postcard", 11 }, + { "hp-tabloid", 10 }, + { "hp-us-edp", 9 }, + { "hp-us-government-legal", 22 }, + { "hp-us-government-letter", 23 }, + { "simplex", 7 }, + { "duplex", 6 }, + { "tumble", 6 }, + { "top", 3 }, + { "middle", 6 }, + { "bottom", 6 }, + { "envelope", 8 }, + { "manual", 6 }, + { "large-capacity", 14 }, + { "main", 4 }, + { "side", 4 }, + { "event-report-job-completed", 26 }, + { "electronic-mail", 15 }, + { "xp-setup-mandatory", 18 }, + { "xp-setup-optional", 17 }, + { "xp-setup-ok", 11 }, + { "xp-setup-incomplete", 19 }, + { "xp-list-glyph-fonts", 19 }, + { "xp-list-internal-printer-fonts", 30 }, + { "0", 1 }, + { "01", 2 }, + { "02", 2 }, + { "03", 2 }, + { "012", 3 }, + { "013", 3 }, + { "023", 3 }, + { "0123", 4 } }; - -#undef OIDATA diff --git a/Xprint/attributes.c b/Xprint/attributes.c index c75af1a88..8dd1b64cb 100644 --- a/Xprint/attributes.c +++ b/Xprint/attributes.c @@ -1,4 +1,3 @@ -/* $XdotOrg: xc/programs/Xserver/Xprint/attributes.c,v 1.1.4.3.4.1 2004/03/04 17:47:23 eich Exp $ */ /* $Xorg: attributes.c,v 1.3 2000/08/17 19:48:07 cpqbld Exp $ */ /* (c) Copyright 1996 Hewlett-Packard Company @@ -45,18 +44,15 @@ copyright holders. ** ********************************************************* ** ********************************************************************/ -/* $XFree86: xc/programs/Xserver/Xprint/attributes.c,v 1.20 2003/10/29 22:11:54 tsi Exp $ */ -#include <X11/Xproto.h> +#include <Xproto.h> #include <string.h> #include <stdlib.h> -#include <sys/types.h> #include <sys/wait.h> #include <pwd.h> #if (defined(sun) && defined(SVR4)) || (defined(SCO)) #include <wchar.h> #endif - #include "scrnintstr.h" #include <X11/extensions/Printstr.h> @@ -67,11 +63,13 @@ copyright holders. #include "Xresource.h" #include "Xrm.c" +#include "spooler.h" + static XrmDatabase CopyDb(XrmDatabase inDb); extern XrmDatabase XpSpoolerGetServerAttributes(void); -static unsigned long attrGeneration = 0; +static int attrGeneration = 0; typedef struct { XrmDatabase *pDb; @@ -138,6 +136,26 @@ static const char XPMODELDIR[] = "/models"; static char NULL_STRING[] = "\0"; /* + * XpGetConfigDirBase returns a string containing the path name of the base + * where the print server configuration directory is localed. + */ +static +char *XpGetConfigDirBase() +{ + char **configDir; + + /* + * If the XPCONFIGDIR environment variable is not set, then use the + * compile-time constant XPRINTDIR. XPRINTDIR is passed in on the + * compile command line, and is defined in $(TOP)/config/cf/Project.tmpl. + */ + if((configDir = getenv("XPCONFIGDIR")) == (char *)NULL) + configDir = XPRINTDIR; + + return configDir; +} + +/* * XpGetConfigDir returns a string containing the path name of the print * server configuration directory. If the useLocale parameter is False * the it returns the path to the "/C" directory. If the useLocale @@ -153,7 +171,12 @@ XpGetConfigDir(Bool useLocale) if(useLocale == False) langDir = "/C"; else { - if((langName = getenv("LANG")) == (char *)NULL) + langName = getenv("LC_ALL"); + if (langName == NULL) { + langName = getenv("LANG"); + } + + if(langName == (char *)NULL) return (char *)NULL; else { @@ -165,13 +188,7 @@ XpGetConfigDir(Bool useLocale) } } - /* - * If the XPCONFIGDIR environment variable is not set, then use the - * compile-time constant XPRINTDIR. XPRINTDIR is passed in on the - * compile command line, and is defined in $(TOP)/config/cf/Project.tmpl. - */ - if((configDir = getenv("XPCONFIGDIR")) == (char *)NULL) - configDir = XPRINTDIR; + configDir = XpGetConfigDirBase(); dirName = (char *)xalloc(strlen(configDir) + strlen(XPDIR) + strlen(langDir) + 1); @@ -307,7 +324,7 @@ BuildPrinterAttrs( if(systemAttributes.printers != (XrmDatabase)NULL) { - char *fileName; + char *dirName, *fileName; XrmDatabase modelDB = (XrmDatabase)NULL; XrmName xrm_name[5], xrm_class[2]; XrmRepresentation rep_type; @@ -607,6 +624,7 @@ XpGetOneAttribute( { ContextAttrPtr pCtxtAttrs; XrmDatabase db = (XrmDatabase)NULL; + char *retVal; XrmName xrm_name[3]; XrmRepresentation rep_type; XrmValue value; @@ -670,10 +688,10 @@ XpGetOneAttribute( */ void XpPutOneAttribute( - XpContextPtr pContext, - XPAttributes class, - const char* attributeName, - const char* value) + XpContextPtr pContext, + XPAttributes class, + const char* attributeName, + const char* value) { ContextAttrPtr pCtxtAttrs; XrmDatabase db; @@ -798,7 +816,7 @@ AppendEntry( char *s, c; if (*type != XrmQString) - return False; + return; for (firstNameSeen = False; *quarks; bindings++, quarks++) { if (*bindings == XrmBindLoosely) { @@ -857,6 +875,7 @@ XpGetAttributes( { ContextAttrPtr pCtxtAttrs; XrmDatabase db = (XrmDatabase)NULL; + char *retVal; StringDbStruct enumStruct; XrmQuark empty = NULLQUARK; @@ -1065,6 +1084,34 @@ XpSpoolerGetServerAttributes(void) } /* + * ExecuteCommand takes two pointers - the command to execute, + * and the "argv" style NULL-terminated vector of arguments for the command. + * We wait for the command to terminate before continuing to ensure that + * we don't delete the job file before the spooler has made a copy. + */ +static void +ExecCommand(pCommand, argVector) + char *pCommand; + char **argVector; +{ + pid_t childPid; + int status; + + if((childPid = fork()) == 0) + { + /* return BadAlloc? */ + if (execv(pCommand, argVector) == -1) { + FatalError("unable to exec '%s'", pCommand); + } + } + else + { + (void) waitpid(childPid, &status, 0); + } + return; +} + +/* * SendFileToCommand takes three character pointers - the file name, * the command to execute, * and the "argv" style NULL-terminated vector of arguments for the command. @@ -1107,11 +1154,17 @@ SendFileToCommand( if((childPid = fork()) == 0) { - close(pipefd[1]); + close(pipefd[1]); + + /* Replace current stdin with input from the pipe */ close(0); dup(pipefd[0]); close(pipefd[0]); + /* Close current stdout and redirect it to stderr */ + close(1); + dup(2); + /* * If a user name is specified, try to set our uid to match that * user name. This is to allow e.g. a banner page to show the @@ -1120,13 +1173,22 @@ SendFileToCommand( */ if(userName) { - if(geteuid() == (uid_t)0) + uid_t myUid; + + if((myUid = geteuid()) == (uid_t)0) { struct passwd *pPasswd; if((pPasswd = getpwnam(userName))) { - setuid((uid_t)pPasswd->pw_uid); + if (setgid((gid_t)pPasswd->pw_gid) != 0) + perror("SendFileToCommand: setgid() failure."); + + if (initgroups(userName, (gid_t)pPasswd->pw_gid) != 0) + perror("SendFileToCommand: initgroups() failure."); + + if (setuid((uid_t)pPasswd->pw_uid) != 0) + perror("SendFileToCommand: setuid() failure."); } } } @@ -1137,6 +1199,8 @@ SendFileToCommand( } else { + int res; + (void) close(pipefd[0]); outPipe = fdopen(pipefd[1], "w"); @@ -1156,6 +1220,7 @@ SendFileToCommand( * store for the supplied print context. The ReplaceAnyString utility * routine is used to perform the actual replacements. */ +extern char *ReplaceAnyString(char *, char *, char *); static char * ReplaceAllKeywords( @@ -1197,6 +1262,10 @@ ReplaceAllKeywords( else command = ReplaceAnyString(command, "%options%", ""); + /* New in xprint.mozdev.org release 007 - replace "%xpconfigdir%" with + * location of $XPCONFIGDIR */ + command = ReplaceAnyString(command, "%xpconfigdir%", XpGetConfigDirBase()); + return command; } @@ -1367,43 +1436,58 @@ VectorizeCommand( char ***pVector, XpContextPtr pContext) { - char *cmdName; + char *cmdName, *curTok; + int i, numChars; if(command == (char *)NULL) return (char *)NULL; - (void) GetToken(command, &cmdName); + numChars = GetToken(command, &cmdName); if(cmdName == (char *)NULL) return (char *)NULL; - *pVector = BuildArgVector(command, pContext); + /* Mangle the command name, too... */ + cmdName = ReplaceAllKeywords(pContext, cmdName); + + if(cmdName == (char *)NULL) + return (char *)NULL; + *pVector = BuildArgVector(command, pContext); + return cmdName; } -#ifdef hpux -static char DEFAULT_SPOOL_COMMAND[] = "/usr/bin/lp -d %printer-name% -o raw -n %copy-count% -t %job-name% %options%"; -#else -static char DEFAULT_SPOOL_COMMAND[] = "/usr/bin/lp -d %printer-name% -n %copy-count% -t %job-name% %options%"; -#endif - int -XpSubmitJob( - char *fileName, - XpContextPtr pContext) +XpSubmitJob(fileName, pContext) + char *fileName; + XpContextPtr pContext; { - char **vector, *cmdNam, *command, *userName; + char **vector, *cmdNam, *cmdOpt, *command, *userName; int i; command = XpGetOneAttribute(pContext, XPPrinterAttr, "xp-spooler-command"); if(command == (char *)NULL || strlen(command) == 0) - command = strdup(DEFAULT_SPOOL_COMMAND); + { + if( spooler_type ) + { + command = strdup(spooler_type->spool_command); + } + else + { + ErrorF("XpSubmitJob: No default spool command defined.\n"); + } + } else + { command = strdup(command); + } if(command == (char *)NULL) + { + ErrorF("XpSubmitJob: No spooler command found, cannot submit job.\n"); return BadAlloc; - + } + cmdNam = VectorizeCommand(command, &vector, pContext); xfree(command); @@ -1431,7 +1515,6 @@ XpSubmitJob( FreeVector(vector); xfree(cmdNam); - return Success; } /* @@ -1504,6 +1587,7 @@ XpGetTrayMediumFromContext(XpContextPtr pCon, { char *defMedium, *defTray; char *t, *m; + char *pS, *pE, *pLast; defMedium = XpGetOneAttribute( pCon, XPPageAttr, "default-medium" ); diff --git a/Xprint/attributes.h b/Xprint/attributes.h index b43d76af5..c4e30d274 100644 --- a/Xprint/attributes.h +++ b/Xprint/attributes.h @@ -30,7 +30,6 @@ not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from said copyright holders. */ -/* $XFree86: xc/programs/Xserver/Xprint/attributes.h,v 1.5 2001/08/01 00:44:45 tsi Exp $ */ #ifndef _Xp_attributes_h #define _Xp_attributes_h 1 @@ -49,11 +48,11 @@ typedef void (*pVFunc)(VFuncArgs); */ void XpInitAttributes(XpContextPtr pContext); void XpBuildAttributeStore(char *printerName, - char *qualifierName); + char *qualifierName); void XpAddPrinterAttribute(char *printerName, - char *printerQualifier, - char *attributeName, - char *attributeValue); + char *printerQualifier, + char *attributeName, + char *attributeValue); void XpDestroyAttributes(XpContextPtr pContext); char *XpGetConfigDir(Bool useLocale); char *XpGetOneAttribute(XpContextPtr pContext, @@ -98,33 +97,33 @@ void XpGetMediumDimensions(XpContextPtr pContext, void XpGetReproductionArea(XpContextPtr pContext, xRectangle *pRect); void XpGetMaxWidthHeightRes(const char *printer_name, - const XpValidatePoolsRec* vpr, - float *width, - float *height, - int* resolution); + const XpValidatePoolsRec* vpr, + float *width, + float *height, + int* resolution); /* Util.c */ -char * ReplaceAnyString(char *string, - char *target, - char *replacement); -char * ReplaceFileString(char *string, - char *inFileName, - char *outFileName); +char *ReplaceAnyString(char *string, + char *target, + char *replacement); +char *ReplaceFileString(char *string, + char *inFileName, + char *outFileName); void ExecCommand(char *pCommand, - char **argVector); + char **argVector); int TransferBytes(FILE *pSrcFile, - FILE *pDstFile, - int numBytes); + FILE *pDstFile, + int numBytes); Bool CopyContentsAndDelete(FILE **ppSrcFile, - char **pSrcFileName, - FILE *pDstFile); + char **pSrcFileName, + FILE *pDstFile); int XpSendDocumentData(ClientPtr client, - FILE *fp, - int fileLen, - int maxBufSize); + FILE *fp, + int fileLen, + int maxBufSize); int XpFinishDocData(ClientPtr client); Bool XpOpenTmpFile(char *mode, - char **fname, - FILE **stream); + char **fname, + FILE **stream); #endif /* _Xp_attributes_h */ diff --git a/Xprint/ddxInit.c b/Xprint/ddxInit.c index 02e5ea370..54f9b611a 100644 --- a/Xprint/ddxInit.c +++ b/Xprint/ddxInit.c @@ -30,13 +30,12 @@ not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from said copyright holders. */ -/* $XFree86: xc/programs/Xserver/Xprint/ddxInit.c,v 1.13 2001/06/11 16:59:02 dawes Exp $ */ #include "X.h" +#include "Xos.h" #include "Xproto.h" #include "windowstr.h" #include "servermd.h" -#include "Xos.h" #include "DiPrint.h" /*- @@ -68,10 +67,13 @@ copyright holders. void InitOutput( - ScreenInfo *pScreenInfo, - int argc, - char **argv) + ScreenInfo *pScreenInfo, + int argc, + char **argv) + { + int i; + pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER; pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT; pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD; @@ -168,10 +170,10 @@ PointerProc( void InitInput( - int argc, + int argc, char **argv) { - DeviceIntPtr ptr, kbd; + DevicePtr ptr, kbd; ptr = AddInputDevice((DeviceProc)PointerProc, TRUE); kbd = AddInputDevice((DeviceProc)KeyboardProc, TRUE); @@ -195,10 +197,26 @@ ProcessInputEvents(void) } #ifdef __DARWIN__ +#include "micmap.h" + +void GlxExtensionInit(void); +void GlxWrapInitVisuals(miInitVisualsProcPtr *procPtr); + void DarwinHandleGUI(int argc, char *argv[]) { } + +void DarwinGlxExtensionInit(void) +{ + GlxExtensionInit(); +} + +void DarwinGlxWrapInitVisuals( + miInitVisualsProcPtr *procPtr) +{ + GlxWrapInitVisuals(procPtr); +} #endif #ifdef DDXOSINIT @@ -232,6 +250,12 @@ GetTimeInMillis(void) } #endif +/* ddxInitGlobals - called by |InitGlobals| from os/util.c */ +void ddxInitGlobals(void) +{ + XprintInitGlobals(); +} + /**************************************** * ddxUseMsg() * @@ -241,7 +265,11 @@ GetTimeInMillis(void) void ddxUseMsg(void) { - /* Right now, let's just do nothing */ +/* Enable |XprintUseMsg()| only if |XprintOptions()| is called + * by |ddxProcessArgument|, too (see below...) */ +#ifdef PRINT_ONLY_SERVER + XprintUseMsg(); +#endif /* PRINT_ONLY_SERVER */ } void AbortDDX (void) @@ -275,12 +303,12 @@ extern int BadDevice; int ChangePointerDevice ( - DeviceIntPtr old_dev, - DeviceIntPtr new_dev, - unsigned char x, - unsigned char y) + DeviceIntPtr old_dev, + DeviceIntPtr new_dev, + unsigned char x, + unsigned char y) { - return (BadDevice); + return (BadDevice); } int diff --git a/Xprint/etc/init.d/xprint.cpp b/Xprint/etc/init.d/xprint.cpp new file mode 100644 index 000000000..40ab6fbae --- /dev/null +++ b/Xprint/etc/init.d/xprint.cpp @@ -0,0 +1,1274 @@ +XCOMM!/bin/sh +XCOMM +XCOMM Copyright 2002-2004 by Roland Mainz <roland.mainz@nrubsig.org>. +XCOMM +XCOMM This script manages the Xprint server side + +XCOMM Basic support for IRIX-style "chkconfig" +XCOMM chkconfig: 2345 61 61 +XCOMM description: Startup/shutdown script for Xprint server(s) + +XCOMM Basic support for the Linux Standard Base Specification 1.0.0 +XCOMM (Note: The Should-Start/Stop lines are there so that this works in the +XCOMM future, when the LSB adopts these. The X-UnitedLinux lines are there +XCOMM so that it works right now.) +XCOMM## BEGIN INIT INFO +XCOMM Provides: xprint +XCOMM Required-Start: $local_fs $remote_fs $syslog $network +XCOMM Required-Stop: $local_fs $remote_fs $syslog +XCOMM Should-Start: cups lpd xfs +XCOMM Should-Stop: cups lpd xfs +XCOMM X-UnitedLinux-Should-Start: cups lpd xfs +XCOMM X-UnitedLinux-Should-Stop: cups lpd xfs +XCOMM Default-Start: 3 5 +XCOMM Default-Stop: 0 1 2 6 +XCOMM Description: Startup/shutdown script for Xprint server(s) +XCOMM## END INIT INFO + +#undef sun +#undef unix + +XCOMM########################################################################### +XCOMM +XCOMM This script has three main tasks: +XCOMM 1. Start Xprint servers ("Xprt") at boot time. +XCOMM 2. Shutdown Xprint servers when the machine is being shut down. +XCOMM 3. Query the list of available printers. +XCOMM +XCOMM Additional tasks are: +XCOMM 4. Restart ('restart'|'force-reload') and conditional restart +XCOMM ('condrestart'/'try-restart') for Linux support +XCOMM 5. Wrapping of application call with setting XPSERVERLIST ('wrapper') +XCOMM +XCOMM Usage: +XCOMM - Start Xprint server(s) manually: +XCOMM % /etc/init.d/xprint start +XCOMM +XCOMM - Stop Xprint server(s) manually: +XCOMM % /etc/init.d/xprint stop +XCOMM +XCOMM - Populate $XPSERVERLIST env var (for example as part of a global +XCOMM login script like /etc/profile or per-user login scripts like +XCOMM $HOME/.profile (sh/ksh/bash)) +XCOMM % XPSERVERLIST="`/etc/init.d/xprint get_xpserverlist`" +XCOMM % export XPSERVERLIST +XCOMM +XCOMM Installation: +XCOMM Copy this script to /etc/init.d/xprint and make sure that it is +XCOMM executable. If your installation is LSB-compliant, then run +XCOMM % /usr/lib/lsb/install_initd /etc/init.d/xprint +XCOMM to start the service on startup. Otherwise, manually create links +XCOMM to the matching run levels. +XCOMM Examples: +XCOMM - Solaris 2.7/2.8/2.9: +XCOMM % cp xprint /etc/init.d/xprint +XCOMM % chmod a+rx /etc/init.d/xprint +XCOMM % ln /etc/init.d/xprint /etc/rc0.d/K38xprint +XCOMM % ln /etc/init.d/xprint /etc/rc1.d/K38xprint +XCOMM % ln /etc/init.d/xprint /etc/rc2.d/S81xprint +XCOMM % ln /etc/init.d/xprint /etc/rcS.d/K38xprint +XCOMM +XCOMM - SuSE Linux 7.3 +XCOMM % cp xprint /etc/init.d/xprint +XCOMM % chmod a+rx /etc/init.d/xprint +XCOMM % ln -s ../xprint /etc/init.d/rc3.d/K13xprint +XCOMM % ln -s ../xprint /etc/init.d/rc3.d/S12xprint +XCOMM % ln -s ../xprint /etc/init.d/rc5.d/K13xprint +XCOMM % ln -s ../xprint /etc/init.d/rc5.d/S12xprint +XCOMM % ln -s ../xprint /etc/init.d/rc2.d/K13xprint +XCOMM % ln -s ../xprint /etc/init.d/rc2.d/S12xprint +XCOMM +XCOMM - SuSE Linux 6.4: +XCOMM % cp xprint /sbin/init.d/xprint +XCOMM % chmod a+rx /sbin/init.d/xprint +XCOMM % ln -s ../xprint /sbin/init.d/rc2.d/K20xprint +XCOMM % ln -s ../xprint /sbin/init.d/rc2.d/S20xprint +XCOMM % ln -s ../xprint /sbin/init.d/rc3.d/K20xprint +XCOMM % ln -s ../xprint /sbin/init.d/rc3.d/S20xprint +XCOMM +XCOMM Notes: +XCOMM - The Xprint servers must be started _after_ the print +XCOMM spooler or the server(s) may refuse to start +XCOMM - The script should be readable by all users to ensure that they +XCOMM can use the "get_xpserverlist"-option +XCOMM +XCOMM Custom configuration: +XCOMM - Edit the function setup_config() in this script to match your needs +XCOMM +XCOMM Known bugs/ToDo/Notes: +XCOMM - The shell script assumes that a Xserver can be reached via +XCOMM "hostname:displaynum" where "hostname" is obtained from +XCOMM "/usr/bin/hostname". It may happen that a kernel firewall +XCOMM blocks an X connection on the same host (e.g. client && Xserver +XCOMM are running on the same host). +XCOMM Suggested fix: Fix the firewall config. +XCOMM Suggested workaround: Edit this script and replace the use of +XCOMM /usr/bin/hostname with "echo 'localhost'". +XCOMM +XCOMM########################################################################### +XCOMM + + +XCOMM########################################################################### + +fatal_error() +{ + echo "${0}: ## FATAL ERROR: ${1}" 1>&2 + exit 1 +} + +error_echo() +{ + echo "${0}: ## ERROR: ${1}" 1>&2 +} + +warning_echo() +{ + echo "${0}: ## WARNING: ${1}" 1>&2 +} + +verbose_echo() +{ + echo "${0}: ${1}" +} + +msg() +{ + echo "${1}" +} + +XCOMM########################################################################### + +#ifndef OS_LINUX +XCOMM Force use of a POSIX conformant sh +XCOMM (Solaris /sbin/sh is plain Bourne shell) +[ "$1" != "posix_sh_forced" -a -x /bin/ksh ] && exec /bin/ksh "$0" posix_sh_forced "$@" +[ "$1" != "posix_sh_forced" -a -x /bin/bash ] && exec /bin/bash --norc --noprofile "$0" posix_sh_forced "$@" +[ "$1" != "posix_sh_forced" -a -x /usr/local/bin/ksh ] && exec /usr/local/bin/ksh "$0" posix_sh_forced "$@" +[ "$1" != "posix_sh_forced" -a -x /usr/local/bin/bash ] && exec /usr/local/bin/bash --norc --noprofile "$0" posix_sh_forced "$@" +if [ "$1" != "posix_sh_forced" ] ; then + echo "${0}: ## FATAL ERROR: No POSIX-shell found." 1>&2 + exit 1 +fi + +shift # Drop "posix_sh_forced" +#endif /* !OS_LINUX */ + +XCOMM#debug +XCOMM set -x + +XCOMM Change current dir to a location which is writeable by everyone +cd /tmp + +XCOMM Clear some environment variables +unset TEMP TMPDIR SCREENDIR + +XCOMM Set search path for commands +export PATH=/usr/bin:/bin:/usr/sbin:/sbin +#ifdef OS_SOLARIS +export PATH=/usr/xpg4/bin:${PATH} +#endif + +XCOMM# Try to figure-out where X11 was installed +#if defined(OS_SOLARIS) +XPROJECTROOT=/usr/openwin +export OPENWINHOME=/usr/openwin +#elif defined(OS_AIX) +XPROJECTROOT=/usr/lpp/X11 +#else +[ -d /usr/X11/bin ] && XPROJECTROOT=/usr/X11 +[ -d /usr/X11R6/bin ] && XPROJECTROOT=/usr/X11R6 +#endif +XPCUSTOMGLUE=DEF_XPCUSTOMGLUE # This is used for customizing this script +export XPROJECTROOT XPCUSTOMGLUE + +if [ -z "${XPROJECTROOT}" ] ; then + fatal_error "Unknown XProjectRoot." +fi + +XCOMM Set the location of the Xprt binary we want to use. +XPRT_BIN="${XPROJECTROOT}/bin/Xprt" + +XCOMM Set the location of the global file where we store the locations +XCOMM of the system-wide servers +if [ -d /var/run ] ; then + XP_GLOBAL_SERVERS=/var/run/Xprint_servers +else + XP_GLOBAL_SERVERS=/tmp/.Xprint_servers +fi + +XCOMM ${LOGNAME} will not work if user su'ed into another account +export CURRLOGNAME="$(id -u -n)" + +XCOMM Set location where we want to store the list of Xprint servers managed +XCOMM by this user +XCOMM - If we start as "root" use the global file +XCOMM - If we start as normal user use a per-user file + +if [ "${CURRLOGNAME}" != "root" -a "${CURRLOGNAME}" != "" ] ; then + XP_PER_USER_SERVERS="/tmp/.Xprint_servers_${CURRLOGNAME}" + XP_SERVERS="${XP_PER_USER_SERVERS}" +else + XP_SERVERS="${XP_GLOBAL_SERVERS}" +fi + +XCOMM Set umask that owner can r/w all files and everyone else can read them +umask 022 + +XCOMM Bump limit for per-process open files to ensure that Xprt can open many many fonts +ulimit -n 1024 + +XCOMM########################################################################### + +XCOMM Get list of fonts for a given display +get_fontlist_from_display() +{ + ${XPROJECTROOT}/bin/xset -display "${1}" q | + awk "/Font Path:/ { i=1 ; next } i==1 { print \$0 ; i=0 }" | + fontpath2fontlist +} + +XCOMM Get list from a fontserver config +get_fontlist_from_xfs_config() +{ + if [ ! -r "${1}" ] ; then + return 0 + fi + + ( + cat "${1}" | + while read -r i ; do + for val in $i; do + case $val in + \#*) break ;; + ?*=*) key="${val%%=*}" ;; + =*) key="${tok}" ;; + *) [ "${key}" = "catalogue" -a "${tok}" != "" ] && echo "${tok}" ;; + esac + tok="${val#*=}" + done + done + ) | tr "," "[\n]" | fontpath2fontlist +} + +get_fontlist_from_all_xfs_configs() +{ + get_fontlist_from_xfs_config "/etc/openwin/fs/fontserver.cfg" + get_fontlist_from_xfs_config "/usr/openwin/lib/X11/fontserver.cfg" + get_fontlist_from_xfs_config "/etc/X11/fs-xtt/config" + get_fontlist_from_xfs_config "/etc/X11/fs/config" + get_fontlist_from_xfs_config "/etc/X11/xfs/config" + get_fontlist_from_xfs_config "${XPROJECTROOT}/lib/X11/fs/config" +} + +get_fontlist_from_xf86config() +{ + srcxconf="" + + XCOMM see xorg.conf(5x) manual page for the list of locations used here + [ "${srcxconf}" = "" -a -f "/etc/X11/xorg.conf" ] && srcxconf="/etc/X11/xorg.conf" + [ "${srcxconf}" = "" -a -f "/usr/X11R6/etc/X11/xorg.conf" ] && srcxconf="/usr/X11R6/etc/X11/xorg.conf" + [ "${srcxconf}" = "" -a -f "/etc/X11/xorg.conf-4" ] && srcxconf="/etc/X11/xorg.conf-4" + [ "${srcxconf}" = "" -a -f "/etc/X11/xorg.conf" ] && srcxconf="/etc/X11/xorg.conf" + [ "${srcxconf}" = "" -a -f "/etc/xorg.conf" ] && srcxconf="/etc/xorg.conf" + [ "${srcxconf}" = "" -a -f "/usr/X11R6/etc/X11/xorg.conf.${hostname}" ] && srcxconf="/usr/X11R6/etc/X11/xorg.conf.${hostname}" + [ "${srcxconf}" = "" -a -f "/usr/X11R6/etc/X11/xorg.conf-4" ] && srcxconf="/usr/X11R6/etc/X11/xorg.conf-4" + [ "${srcxconf}" = "" -a -f "/usr/X11R6/etc/X11/xorg.conf" ] && srcxconf="/usr/X11R6/etc/X11/xorg.conf" + [ "${srcxconf}" = "" -a -f "/usr/X11R6/lib/X11/xorg.conf.${hostname}" ] && srcxconf="/usr/X11R6/lib/X11/xorg.conf.${hostname}" + [ "${srcxconf}" = "" -a -f "/usr/X11R6/lib/X11/xorg.conf-4" ] && srcxconf="/usr/X11R6/lib/X11/xorg.conf-4" + [ "${srcxconf}" = "" -a -f "/usr/X11R6/lib/X11/xorg.conf" ] && srcxconf="/usr/X11R6/lib/X11/xorg.conf" + + XCOMM Xfree86 locations + [ "${srcxconf}" = "" -a -f "/etc/X11/XF86Config-4" ] && srcxconf="/etc/X11/XF86Config-4" + [ "${srcxconf}" = "" -a -f "/etc/X11/XF86Config" ] && srcxconf="/etc/X11/XF86Config" + + + if [ "${srcxconf}" = "" ] ; then + return 0 + fi + + currsection="" + cat "${srcxconf}" | + while read i1 i2 i3 i4 ; do + # Strip "\"" from I2 + i2="${i2#\"}" ; i2="${i2%\"}" + + case "${i1}" in + \#*) + continue + ;; + 'Section') + currsection="${i2}" + ;; + 'EndSection') + currsection="" + ;; + 'FontPath') + [ "$currsection" = "Files" ] && echo "${i2%:unscaled}" + ;; + esac + done | egrep -v -i "tcp/|tcp4/|tcp6/|unix/" + + return 0 +} + +get_fontlist_from_defoma() +{ + # Include Debian defoma font directory where relevant + if [ -d "/var/lib/defoma/x-ttcidfont-conf.d/dirs" ] ; then + find "/var/lib/defoma/x-ttcidfont-conf.d/dirs" -name fonts.dir | + while read i ; do echo "${i%/fonts.dir}" ; done + fi +} + +XCOMM Get list of system fonts +get_system_fontlist() +{ +#if defined(OS_SOLARIS) + ## List the standard X11 fonts + # echo "${XPROJECTROOT}/lib/X11/fonts/F3/" + # echo "${XPROJECTROOT}/lib/X11/fonts/F3bitmaps/" + echo "${XPROJECTROOT}/lib/X11/fonts/Type1/" + echo "${XPROJECTROOT}/lib/X11/fonts/Type1/outline/" + # We cannot use /usr/openwin/lib/X11/fonts/Type1/sun/ - see + # http://xprint.mozdev.org/bugs/show_bug.cgi?id=5726 + # ("Xprint doesn't start under Solaris 2.9 due *.ps files in /usr/openwin/lib/X11/fonts/Type1/sun/fonts.dir") + #echo "${XPROJECTROOT}/lib/X11/fonts/Type1/sun/" + echo "${XPROJECTROOT}/lib/X11/fonts/TrueType/" + echo "${XPROJECTROOT}/lib/X11/fonts/Speedo/" + echo "${XPROJECTROOT}/lib/X11/fonts/misc/" + echo "${XPROJECTROOT}/lib/X11/fonts/75dpi/" + echo "${XPROJECTROOT}/lib/X11/fonts/100dpi/" + + ## List all fonts in all locales installed on this machine + cat /usr/openwin/lib/locale/''*/OWfontpath | tr "," "\n" | sort -u +#elif defined(OS_LINUX) + ( + get_fontlist_from_defoma + + get_fontlist_from_xf86config + + # Getting font paths from XFS is mainly required for compatibilty to RedHat + get_fontlist_from_all_xfs_configs + + ## List all fonts in all locales installed on this machine + ( + [ -d "/usr/share/fonts" ] && find /usr/share/fonts -name fonts.dir + find "${XPROJECTROOT}/lib/X11/fonts" -name fonts.dir + ) | + while read i ; do echo "${i%/fonts.dir}" ; done + ) | sort -u +#else + ## List the standard X11 fonts + # (AIX should be handled like Solaris but I did not found a way to + # enumerate all fonts in all installed locales without scanning the + # dirs manually) + echo "${XPROJECTROOT}/lib/X11/fonts/Type1/" + echo "${XPROJECTROOT}/lib/X11/fonts/TrueType/" + echo "${XPROJECTROOT}/lib/X11/fonts/TTF/" + echo "${XPROJECTROOT}/lib/X11/fonts/Speedo/" + echo "${XPROJECTROOT}/lib/X11/fonts/misc/" + echo "${XPROJECTROOT}/lib/X11/fonts/75dpi/" + echo "${XPROJECTROOT}/lib/X11/fonts/100dpi/" + echo "${XPROJECTROOT}/lib/X11/fonts/" +#endif +} + +XCOMM Filter fonts per given extended regular expressions +XCOMM (and make sure we filter any model-config fonts - they are managed by Xprt internally) +filter_fontlist() +{ + egrep -- "${1}" | fgrep -v "/models/" | egrep -v -- "${2}" +} + +XCOMM Filter font paths with unsupported font types +XCOMM (such as CID fonts) +filter_unsupported_fonts() +{ + egrep -v -i "/cid(/$|$)|/csl(/$|$)" +} + +XCOMM Validate fontpath +XCOMM Only return valid font path entries (note that these entries may +XCOMM include non-file stuff like font server references) +validate_fontlist() +{ + while read i ; do + case "${i}" in + # Check if font path entry is a font server... + tcp/''*|tcp4/''*|tcp6/''*|unix/''*) + echo "${i}" + ;; + # ... if not check if the path is accessible + # and has a valid "fonts.dir" index + *) + [ -f "${i}/fonts.dir" ] && echo "${i}" + ;; + esac + done +} + +XCOMM Build a comma-seperated list of fonts (font path) from a list of fonts +fontlist2fontpath() +{ + fp="" + read fp; + while read i ; do + fp="${fp},${i}" + done + + echo "$fp" +} + +XCOMM Build a list (one item per line) of fonts from a font path +fontpath2fontlist() +{ + while read i ; do + echo "${i}" | tr "," "\n" + done +} + +XCOMM Sort scaleable fonts (PS Type1 and TrueType) first in a font list +sort_scaleable_fonts_first() +{ + i="$(fontlist2fontpath)" + # First list PS Type1 fonts... + echo "${i}" | fontpath2fontlist | fgrep "/Type1" + # ... then TrueType fonts ... + echo "${i}" | fontpath2fontlist | egrep -i "/TrueType|/TT(/$|$)|/TTF(/$|$)" + # ... then all others + echo "${i}" | fontpath2fontlist | egrep -v -i "/Type1|/TrueType|/TT(/$|$)|/TTF(/$|$)" +} + +XCOMM Check if a X display is used by a Xserver or not +XCOMM Known bugs: +XCOMM - there is no way in plain bourne shell or bash (see comment about ksh93 +XCOMM below) to test if a Xserver sits only on a socket and not on a pipe +XCOMM - some Xserver's don't cleanup their stuff in /tmp on exit which may end +XCOMM in the problem that we don't detect possible free display numbers +XCOMM (one problem is that only ksh93 can do stuff like +XCOMM "cat </dev/tcp/0.0.0.0/6001") +CheckIfDisplayIsInUse() +{ + id=$1 + + [ -r "/tmp/.X${id}-lock" ] && return 0; + [ -r "/tmp/.X11-unix/X${id}" ] && return 0; + [ -r "/tmp/.X11-pipe/X${id}" ] && return 0; + + return 1; +} + +lastdisplaynumreturned_store=/tmp/.Xp_last_display_returned_by_findfreexdisplaynum_${RANDOM}_${RANDOM} + +XCOMM Try to find a free display number +FindFreeXDisplayNum() +{ + if [ -r "${lastdisplaynumreturned_store}" ] ; then + i="$(cat "${lastdisplaynumreturned_store}")" + else + i=32 # start at display 32 + fi + + while [ $i -lt 127 ] ; do + i=$(($i + 1)) + + if CheckIfDisplayIsInUse $i ; then + true + else + echo "$i" + echo "$i" >"${lastdisplaynumreturned_store}" + return 0 + fi + done + + # Using "magic" value of 189 here due lack of a better solution + echo "189" + echo "189" >"${lastdisplaynumreturned_store}" + return 0 +} + +XCOMM Check if a process exists or not +pexists() +{ + [ "$1" = "" ] && return 1; + + # Use of /proc would be better but not all platforms (like AIX) have procfs + [ "$(ps -p $1 | fgrep $1)" != "" ] && return 0; + return 1 +} + +XCOMM Check if there is a spooler running... +is_spooler_running() +{ + # This covers Linux lpd, CUPS, Solaris and AIX 4.x - but what about + # AIX 5.x, HP-UX and IRIX ? + + [ "$(ps -A | egrep 'lpd|lpsched|cupsd|qdaemon' | fgrep -v 'grep')" != "" ] && return 0; + return 1 +} + +XCOMM Wait until the spooler system has been started (but not more than 30secs) +wait_for_print_spooler() +{ + for i in 1 2 3 4 5 6 7 8 9 10 ; do + is_spooler_running && return 0; + sleep 3 + done + + return 0 +} + +lock_server_registry() +{ + lock_counter=0 # counts in 1/100s + waiting_for_lock_msg_send="false" + while ! mkdir "${XP_SERVERS}.lock" 2>/dev/null ; do + # print notice after 2 seconds + if [ ${lock_counter} -gt 200 -a "${waiting_for_lock_msg_send}" != "true" ] ; then + echo "${0}: waiting for lock(=${XP_SERVERS}.lock)..." + waiting_for_lock_msg_send="true" + fi + + # tread the lock as "broken" after 20 seconds + if [ ${lock_counter} -gt 2000 ] ; then + echo "${0}: WARNING: lock timeout for lock(=${XP_SERVERS}.lock)." + return 0 + fi + + if [ -x /bin/usleep ] ; then + /bin/usleep 200000 + lock_counter=$((${lock_counter} + 20)) # 20/100s + else + sleep 1 + lock_counter=$((${lock_counter} + 100)) # 100/100s + fi + done +} + +unlock_server_registry() +{ + rmdir "${XP_SERVERS}.lock" +} + +XCOMM Kill dead registry locks (silently!) +kill_dead_registry_locks() +{ + rm -Rf "${XP_SERVERS}.lock" +} + +XCOMM Start Xprint servers +start_servers() +{ + # Write registry "intro" ... + lock_server_registry + echo "# Xprint server list" >>"${XP_SERVERS}" + echo "# File is for private use for ${0}." >>"${XP_SERVERS}" + echo "# Do not edit, rely on the content or file format." >>"${XP_SERVERS}" + unlock_server_registry + + hostname="$(hostname)" + + default_fontpath="$(get_system_fontlist | fontlist2fontpath)" + default_fontpath_acceptpattern=".*"; + default_fontpath_rejectpattern="_No_Match_"; # Match nothing + + curr=0 + while [ $curr -lt $num_xpstart ] ; do + if [ "${xpstart_remote_server[$curr]}" != "" ] ; then + # Remote Xprt, just put the entry into the registry + lock_server_registry + echo "display=${xpstart_remote_server[$curr]}" >>"${XP_SERVERS}" + unlock_server_registry + else + # Run block in seperate process to avoid that changes to the + # xpstart_* variables affect the next cycle + ( + # Use defaults if there are no special options + [ "${xpstart_fontpath[$curr]}" = "" ] && xpstart_fontpath[$curr]="${default_fontpath}"; + [ "${xpstart_fontpath_acceptpattern[$curr]}" = "" ] && xpstart_fontpath_acceptpattern[$curr]="$default_fontpath_acceptpattern"; + [ "${xpstart_fontpath_rejectpattern[$curr]}" = "" ] && xpstart_fontpath_rejectpattern[$curr]="$default_fontpath_rejectpattern"; + [ "${xpstart_displayid[$curr]}" = "" ] && xpstart_displayid[$curr]="$(FindFreeXDisplayNum)" + [ "${xpstart_logger[$curr]}" = "" ] && xpstart_logger[$curr]="logger -p lpr.notice -t Xprt_${xpstart_displayid[$curr]}"; + [ "${xpstart_logfile[$curr]}" = "" ] && xpstart_logfile[$curr]="/dev/null"; + [ "${xpstart_xprt_binary[$curr]}" = "" ] && xpstart_xprt_binary[$curr]="${XPRT_BIN}"; + if [ "${xpstart_xprt_binary[$curr]}" = "/usr/openwin/bin/Xprt" -o "$(uname -s)" = "SunOS" ] ; then + # Solaris /usr/openwin/bin/Xprt does not support "-nolisten tcp" + # yet nor is it possible to run a Xserver on a unix socket only + # in Solaris since access to the unix domain sockets in + # /tmp/.X11-pipe and /tmp/.X11-unix is restricted to applications + # with group-id "root" (e.g. the Xprt server would need to be + # setgid "root" that plain users can start it listening on a unix + # socket only) + [ "${xpstart_options[$curr]}" = "" ] && xpstart_options[$curr]="-ac -pn" + else + [ "${xpstart_options[$curr]}" = "" ] && xpstart_options[$curr]="-ac -pn -nolisten tcp" + fi + + # Check if the Xprt binary is available + if [ ! -x "${xpstart_xprt_binary[$curr]}" ] ; then + error_echo "Can't find \"${xpstart_xprt_binary[$curr]}\"." + exit 1 # exit block + fi + + # Verify and set location of font encodings directory file + if [ "${xpstart_font_encodings_dir[$curr]}" = "" ] ; then + if [ -f "${XPROJECTROOT}/lib/X11/fonts/xf86encodings/encodings.dir" ] ; then + xpstart_font_encodings_dir[$curr]="${XPROJECTROOT}/lib/X11/fonts/xf86encodings/encodings.dir" + else + xpstart_font_encodings_dir[$curr]="${XPROJECTROOT}/lib/X11/fonts/encodings/encodings.dir"; + fi + fi + + unset FONT_ENCODINGS_DIRECTORY + if [ ! -f "${xpstart_font_encodings_dir[$curr]}" ] ; then + warning_echo "Can't find \"${xpstart_font_encodings_dir[$curr]}\", TrueType font support may not work." + fi + + export FONT_ENCODINGS_DIRECTORY="${xpstart_font_encodings_dir[$curr]}" + + # Generate font path (containing only valid font path elements) + # from input font path and filter expressions + curr_fp=$(echo "${xpstart_fontpath[$curr]}" | + fontpath2fontlist | + filter_fontlist "${xpstart_fontpath_acceptpattern[$curr]}" "${xpstart_fontpath_rejectpattern[$curr]}" | + filter_unsupported_fonts | + sort_scaleable_fonts_first | + validate_fontlist | + fontlist2fontpath) + + # Set Xserver auditing level option + unset curr_audit + if [ "${xpstart_auditlevel[$curr]}" != "" ] ; then + curr_audit="-audit ${xpstart_auditlevel[$curr]}" + fi + + # Set Xprt -XpFile option + unset curr_xpfile + if [ "${xpstart_xpfile[$curr]}" != "" ] ; then + curr_xpfile="-XpFile ${xpstart_xpfile[$curr]}" + fi + + # Set custom XPCONFIGDIR (if there is one) + unset XPCONFIGDIR + if [ "${xpstart_xpconfigdir[$curr]}" != "" ] ; then + export XPCONFIGDIR="${xpstart_xpconfigdir[$curr]}" + fi + + # If someone uses "-nolisten tcp" make sure we do not add a hostname to force local transport + if [ "$(echo "${xpstart_options[$curr]}" | egrep "nolisten.*tcp")" != "" ] ; then + xp_display=":${xpstart_displayid[$curr]}" + else + xp_display="${hostname}:${xpstart_displayid[$curr]}" + fi + + ( + ( + "${xpstart_xprt_binary[$curr]}" \ + ${xpstart_options[$curr]} \ + ${curr_xpfile} ${curr_audit} \ + -fp ${curr_fp} \ + :${xpstart_displayid[$curr]} & + server_pid="$!" + + # Append the new server to the registry + lock_server_registry + echo "display=${xp_display} display_id=${xpstart_displayid[$curr]} pid=${server_pid}" >>"${XP_SERVERS}" + unlock_server_registry + + wait + echo "Xprint server pid=${server_pid} done, exitcode=$?." + + # Remove the dead server from the registry + # (only if the registry still exists - if /etc/init.d/xprint stop" gets called the registry + # will be removed - and we should not re-create it afterwards...) + lock_server_registry + if [ -f "${XP_SERVERS}" ] ; then + x="$(cat "${XP_SERVERS}")" # Store content of file "${XP_SERVERS}" in var "x" + echo "${x}" | fgrep -v "display_id=${xpstart_displayid[$curr]} pid=${server_pid}" >"${XP_SERVERS}" + fi + unlock_server_registry + ) 2>&1 | while read i ; do echo "$i" | tee -a "${xpstart_logfile[$curr]}" | ${xpstart_logger[$curr]} ; done + ) & + ) + fi + + curr=$(($curr + 1)) + done + + # Remove tmp. file created by |FindFreeXDisplayNum()| + rm -f "${lastdisplaynumreturned_store}" + + # Done. + lock_server_registry + echo "# EOF." >>"${XP_SERVERS}" + unlock_server_registry + return 0 +} + + +XCOMM Convenience function to check setup and start Xprt server(s) +do_start() +{ + if [ -f "${XP_SERVERS}" ] ; then + numservers="$(do_get_xpserverlist | wc -l)" + if [ ${numservers} -gt 0 ] ; then + verbose_echo "Xprint servers are already running." + return 0 + else + verbose_echo "Old server registry found, cleaning-up..." + do_stop + fi + fi + + # Check if we can write the registry file + touch "${XP_SERVERS}" 2>/dev/null + if [ ! -f "${XP_SERVERS}" ] ; then + error_echo "Cannot create \"${XP_SERVERS}\"." + # exit code 4 = user had insufficient privilege (LSB) + exit 4 + fi + + if ! setup_config ; then + error_echo "setup_config failed." + exit 1 + fi + + # Provide two paths here - one which simply starts the Xprt servers, + # assuming that there is a print spooler already running (or that + # ${XPCONFIG}/C/print/Xprinters provides static print queue entries + # (like for the PSspooldir print model)) and a 2nd path which + # explicitly checks if the print queue daemons are running + if true ; then + msg "Starting Xprint servers: Xprt." + start_servers + else + # Continue in the background if there is no spooler running yet (that + # we don't hold off the boot process nor run in a possible race-condition + # when /etc/init.d/lpd was not called yet but the runlevel script waits + # for us to finish first ... + if is_spooler_running ; then + msg "Starting Xprint servers: Xprt." + start_servers + else + msg "Starting Xprint servers (in the background): Xprt." + (wait_for_print_spooler ; start_servers) & + sleep 5 + fi + fi + + if [ "${CURRLOGNAME}" = "root" -a -d /var/lock/subsys/ ] ; then + touch /var/lock/subsys/xprint + fi +} + +XCOMM Convenience function to stop Xprt server(s) +do_stop() +{ + msg "Stopping Xprint servers: Xprt." + + lock_server_registry + if [ -f "${XP_SERVERS}" ] ; then + reglist="$(cat "${XP_SERVERS}")" + rm -f "${XP_SERVERS}" + fi + unlock_server_registry + + if [ "${reglist}" != "" ] ; then + echo "${reglist}" | + grep "^display=.*:.* pid=[0-9]*$" | + while read i ; do + ( + eval ${i} + if pexists ${pid} ; then + kill ${pid} + fi + + # Remove the X sockets/pipes which are not in use anymore + # (It would be better if the Xservers would cleanup this + # automatically, but most Xservers do not do that... ;-( + # Note that this will not work on Solaris where applications + # must run with groupid="root" if they want to write into + # /tmp/.X11-unix/ and/or /tmp/.X11-pipe/) + if [ "${display_id}" != "" ] ; then + rm -f "/tmp/.X${display_id}-lock" 2>/dev/null + rm -f "/tmp/.X11-unix/X${display_id}" 2>/dev/null + rm -f "/tmp/.X11-pipe/X${display_id}" 2>/dev/null + fi + ) + done + fi + + if [ "${CURRLOGNAME}" = "root" -a -d /var/lock/subsys/ ] ; then + rm -f /var/lock/subsys/xprint + fi + + # Remove any outstanding (dead) locks and cleanup + rm -f "${XP_SERVERS}" + kill_dead_registry_locks +} + +XCOMM Convenience function to obtain a list of available Xprint servers +do_get_xpserverlist() +{ + if [ -f "${XP_PER_USER_SERVERS}" -o -f "${XP_GLOBAL_SERVERS}" ] ; then + xpserverlist=$( + # Enumerate both per-user and global servers (in that order) + ( + [ -f "${XP_PER_USER_SERVERS}" ] && cat "${XP_PER_USER_SERVERS}" + [ -f "${XP_GLOBAL_SERVERS}" ] && cat "${XP_GLOBAL_SERVERS}" + ) | + egrep "^display=.*:.* pid=[0-9]*$|^display=.*:[0-9]*$" | + while read i ; do + ( + pid="none" + eval ${i} + # Check if the Xprt process exists (if possible) + if [ "$pid" != "none" ] ; then + if pexists ${pid} ; then + echo ${display} + fi + else + echo ${display} + fi + ) + done | tr "[\n]" " " + ) + # Only produce output if we have some entries... + [ "${xpserverlist}" != "" ] && echo "${xpserverlist}" + fi +} + +do_restart() +{ + msg "Restarting Xprint server(s): Xprt." + do_stop + sleep 1 + do_start +} + +do_diag() +{ + echo "##### Diag start $(date)." + + # General info + echo "## General info start." + ( + echo "PATH=\"${PATH}\"" + echo "TZ=\"${TZ}\"" + echo "LANG=\"${LANG}\"" + echo "uname -a=\"$(uname -a)\"" + echo "uname -s=\"$(uname -s)\"" + echo "uname -p=\"$(uname -p)\"" + echo "uname -i=\"$(uname -i)\"" + echo "uname -m=\"$(uname -m)\"" + echo "has /etc/SuSE-release ... $([ -f "/etc/SuSE-release" ] && echo "yes" || echo "no")" + echo "has /etc/redhat-release ... $([ -f "/etc/redhat-release" ] && echo "yes" || echo "no")" + echo "has /etc/debian_version ... $([ -f "/etc/debian_version" ] && echo "yes" || echo "no")" + echo "how many Xprt servers are running ...$(ps -ef | fgrep Xprt | fgrep -v "grep" | wc -l)" + ) 2>&1 | while read i ; do echo " $i" ; done + echo "## General info end." + + # Testing font paths + echo "## Testing font paths start." + ( + get_system_fontlist | + filter_unsupported_fonts | + sort_scaleable_fonts_first | + validate_fontlist | while read d ; do + echo "#### Testing \"${d}\" ..." + if [ ! -d "$d" ] ; then + echo "# Error: $d does not exists." + continue + fi + if [ ! -r "$d" ] ; then + echo "# Error: $d not readable." + continue + fi + if [ ! -f "${d}/fonts.dir" ] ; then + echo "# Error: ${d}/fonts.dir not found." + continue + else + if [ ! -r "${d}/fonts.dir" ] ; then + echo "# Error: ${d}/fonts.dir not readable." + continue + fi + fi + if [ -f "${d}/fonts.alias" ] ; then + if [ ! -r "${d}/fonts.alias" ] ; then + echo "# Error: ${d}/fonts.alias not readable." + fi + fi + + if [ "$(cat "${d}/fonts.dir" | fgrep 'cursor')" != "" ] ; then + echo "${d}/fonts.dir has cursor font." + fi + if [ "$(cat "${d}/fonts.dir" | fgrep 'fixed')" != "" ] ; then + echo "${d}/fonts.dir has fixed font." + fi + + if [ -r "${d}/fonts.alias" ] ; then + if [ "$(cat "${d}/fonts.alias" | fgrep 'cursor')" != "" ] ; then + echo "${d}/fonts.alias has cursor font." + fi + if [ "$(cat "${d}/fonts.alias" | fgrep 'fixed')" != "" ] ; then + echo "${d}/fonts.alias has fixed font." + fi + fi + + linenum=0 + cat "${d}/fonts.dir" | while read i1 i2 i3 i4 ; do + linenum=$((${linenum} + 1)) + [ ${linenum} -eq 1 ] && continue + + if [ ! -f "${d}/${i1}" ] ; then + echo "ERROR: ${d}/fonts.dir line ${linenum} has non-exististant font \"${i1}\" (=\"${i1} ${i2} ${i3} ${i4}\")" + fi + done + done + ) 2>&1 | while read i ; do echo " $i" ; done + echo "## Testing font paths end." + + echo "##### Diag End $(date)." +} + +XCOMM Set platform-defaults for setup_config() +setup_config_defaults() +{ + curr_num_xpstart="${1}" + + #### Defaults for Linux/Solaris + # Start Xprt using builtin XPCONFIGDIR at a free display numer + # (Solaris(=SunOS5.x)'s /usr/openwin/bin/Xprt supports TrueType fonts, + # therefore we don't need to filter them) + xpstart_fontpath[${curr_num_xpstart}]=""; + xpstart_fontpath_acceptpattern[${curr_num_xpstart}]=".*"; + xpstart_fontpath_rejectpattern[${curr_num_xpstart}]="/Speedo|/F3bitmaps|/F3"; + xpstart_displayid[${curr_num_xpstart}]=""; + xpstart_xpconfigdir[${curr_num_xpstart}]=""; + xpstart_xpfile[${curr_num_xpstart}]=""; + xpstart_auditlevel[${curr_num_xpstart}]="4"; + xpstart_options[${curr_num_xpstart}]=""; + xpstart_logger[${curr_num_xpstart}]=""; + # Check whether we have /dev/stderr (needed for old AIX + old Debian) + if [ -w "/dev/stderr" ] ; then + xpstart_logfile[${curr_num_xpstart}]="/dev/stderr"; + else + xpstart_logfile[${curr_num_xpstart}]="/dev/tty"; + fi + xpstart_xprt_binary[${curr_num_xpstart}]=""; + + # Custom rules for the GISWxprintglue package on Solaris + # (which uses Solaris's /usr/openwin/bin/Xprt but a custom config) + if [ "${XPCUSTOMGLUE}" = "GISWxprintglue" ] ; then + xpstart_xpconfigdir[${curr_num_xpstart}]="/opt/GISWxprintglue/server/etc/XpConfig" + xpstart_xprt_binary[${curr_num_xpstart}]="/usr/openwin/bin/Xprt" + fi + # Custom rules for the GISWxprint package on Solaris + # (which uses both it's own Xprt and a custom config) + if [ "${XPCUSTOMGLUE}" = "GISWxprint" ] ; then + xpstart_xpconfigdir[${curr_num_xpstart}]="/opt/GISWxprint/server/etc/XpConfig" + xpstart_xprt_binary[${curr_num_xpstart}]="/opt/GISWxprint/bin/Xprt" + xpstart_font_encodings_dir[${curr_num_xpstart}]="/opt/GISWxprint/lib/X11/fonts/encodings/encodings.dir" + fi + + ####################################################### + ### + ### Debian Xprint package default configuration + ### + if [ "${XPCUSTOMGLUE}" = "DebianGlue" ] ; then + # Set XPCONFIGDIR=/usr/share/Xprint/xserver + xpstart_xpconfigdir[${curr_num_xpstart}]="/usr/share/Xprint/xserver"; + + # Use fixed display ID (":64"), or else all client programs will have to be + # restarted simply to update XPSERVERLIST to the latest ID when upgrading, + # which would be a nightmare. + xpstart_displayid[${curr_num_xpstart}]=64; + + # Do not send any messages to console + xpstart_logfile[${curr_num_xpstart}]="/dev/null"; + + # By default use binary provided by Debian's "xprt-xprintorg" package + # (=/usr/bin/Xprt), otherwise leave blank (e.g. use script's default + # (=/usr/X11R6/bin/Xprt)) + if [ -x "/usr/bin/Xprt" ] ; then + xpstart_xprt_binary[${curr_num_xpstart}]="/usr/bin/Xprt"; + fi + fi + ### + ### End Debian default configuration + ### + ####################################################### +} + +fetch_etc_initd_xprint_envvars() +{ + curr_num_xpstart="${1}" + + ## Process some $ETC_INITD_XPRINT_* vars after all which may be used by + # a user to override the hardcoded values here when starting Xprt per-user + # (a more flexible way is to provide an own setup config script in + # "~./Xprint_per_user_startup" - see above) + if [ "${ETC_INITD_XPRINT_XPRT_PATH}" != "" ] ; then + xpstart_xprt_binary[${curr_num_xpstart}]="${ETC_INITD_XPRINT_XPRT_PATH}" + fi + if [ "${ETC_INITD_XPRINT_XPCONFIGDIR}" != "" ] ; then + xpstart_xpconfigdir[${curr_num_xpstart}]="${ETC_INITD_XPRINT_XPCONFIGDIR}" + fi + if [ "${ETC_INITD_XPRINT_XPFILE}" != "" ] ; then + xpstart_xpfile[${curr_num_xpstart}]="${ETC_INITD_XPRINT_XPFILE}" + fi + if [ "${ETC_INITD_XPRINT_LOGFILE}" != "" ] ; then + xpstart_logfile[${curr_num_xpstart}]="${ETC_INITD_XPRINT_LOGFILE}" + fi + if [ "${ETC_INITD_XPRINT_DISPLAYID}" != "" ] ; then + xpstart_displayid[${curr_num_xpstart}]="${ETC_INITD_XPRINT_DISPLAYID}" + fi + if [ "${ETC_INITD_XPRINT_FONTPATH}" != "" ] ; then + xpstart_fontpath[${curr_num_xpstart}]="${ETC_INITD_XPRINT_FONTPATH}" + fi + if [ "${ETC_INITD_XPRINT_XPRT_OPTIONS}" != "" ] ; then + xpstart_options[${curr_num_xpstart}]="${ETC_INITD_XPRINT_XPRT_OPTIONS}" + fi + if [ "${ETC_INITD_XPRINT_AUDITLEVEL}" != "" ] ; then + xpstart_auditlevel[${curr_num_xpstart}]="${ETC_INITD_XPRINT_AUDITLEVEL}" + fi + if [ "${ETC_INITD_XPRINT_XF86ENCODINGSDIR}" != "" ] ; then + xpstart_font_encodings_dir[${curr_num_xpstart}]="${ETC_INITD_XPRINT_XF86ENCODINGSDIR}" + fi +} + +XCOMM########################################################################### +XCOMM setup_config() sets the configuration parameters used to start one +XCOMM or more Xprint servers ("Xprt"). +XCOMM The following variables are used: +XCOMM - "num_xpstart" - number of servers to start +XCOMM - "xpstart_fontpath[index]" - custom font path. Leave blank if you want +XCOMM the platform-specific default +XCOMM - "xpstart_fontpath_acceptpattern[index]" - extended regular expression +XCOMM (see egrep(1)) used to filter the font path - items only pass this +XCOMM filter if they match the pattern (leave blank if you want to filter +XCOMM nothing) +XCOMM - "xpstart_fontpath_rejectpattern[index]" - extended regular expression +XCOMM (see egrep(1)) used to filter the font path - items only pass this +XCOMM filter if they do not match the pattern (leave blank if you want to +XCOMM filter nothing) +XCOMM - "xpstart_font_encodings_dir[index]" - location of "encodings.dir". +XCOMM Leave blank to use the default. +XCOMM - "xpstart_displayid[index]" - display id to use for the Xprint server +XCOMM (leave blank to choose the next available free display id) +XCOMM - "xpstart_xpconfigdir[index]" - value for custom XPCONFIGDIR (leave blank +XCOMM if you don not want that that XPCONFIGDIR is set at Xprt startup) +XCOMM - "xpstart_xpfile[index]" - value used for Xprt's "-XpFile" option (leave +XCOMM blank if you do not want to set this option) +XCOMM - "xpstart_auditlevel[index]" - set Xserver auditing level (leave blank to +XCOMM use no auditing) +XCOMM - "xpstart_options[index]" - set further Xprt options (leave blank to set +XCOMM no further options) +XCOMM - "xpstart_logger[index]" - utility which gets stderr/stdout messages from +XCOMM Xprt and sends them to a logging daemon. Leave blank to use /usr/bin/logger +XCOMM to send such messages to the lpr.notice syslog) +XCOMM - "xpstart_logfile[index]" - log file to append stderr/stdout messages from +XCOMM Xprt to. Leave blank to send messages to /dev/null +XCOMM - "xpstart_xprt_binary[index]" - set custom Xprt binary (leave blank to use +XCOMM the platform-specifc default) +setup_config() +{ + num_xpstart=0; + + if [ "${ETC_INITD_XPRINT_CUSTOM_SETUP_CONFIG}" != "" ] ; then + user_cfg="${ETC_INITD_XPRINT_CUSTOM_SETUP_CONFIG}" + else + user_cfg="${HOME}/.Xprint_per_user_startup" + fi + + # Source per-user ~/.Xprint_per_user_startup file if there is one + # (and do not use the script's defaults below) + if [ -r "${user_cfg}" ] ; then + # Define API version which should be checked by ${HOME}/.Xprint_per_user_startup + # ${HOME}/.Xprint_per_user_startup should bail-out if the version differ + etc_initd_xprint_api_version=2 + + # Source per-user settings script + . "${user_cfg}" + + # done with setting the config for per-user Xprt instances + return 0; + else + # Use /etc/init.d/xprint's builtin config + # Each entry should start with |setup_config_defaults| to pull the + # platform defaults and finish with |num_xpstart=$(($num_xpstart + 1))| + # to end the entry + + # Set platform-defaults + setup_config_defaults "${num_xpstart}" + + ## -- snip -- + + # Admins can put their stuff "in" here... + + ## -- snip -- + + # Override script's builtin values with those a user may set via the + # $ETC_INIITD_XPRINT_* env vars + fetch_etc_initd_xprint_envvars "${num_xpstart}" + + num_xpstart=$((${num_xpstart} + 1)) + + return 0; + fi + + #### Sample 1: + # # Start Xprt on a free display ID with custom XPCONFIGDIR and without + # # Speedo and TrueType fonts + # xpstart_fontpath_rejectpattern[$num_xpstart]="/Speedo|/TrueType|/TT(/$|$)|/TTF(/$|$)"; + # xpstart_xpconfigdir[$num_xpstart]="/home/gisburn/cwork/Xprint/Xprt_config/XpConfig"; + # xpstart_auditlevel[$num_xpstart]="4"; + # xpstart_options[$num_xpstart]="-ac -pn"; + #num_xpstart=$(($num_xpstart + 1)) + + + #### Sample 2: + # # Start Xprt without TrueType fonts on a display 55 with custom + # # XPCONFIGDIR + # xpstart_fontpath_rejectpattern[$num_xpstart]="/TrueType|/TT(/$|$)|/TTF(/$|$)"; + # xpstart_displayid[$num_xpstart]=55; + # xpstart_xpconfigdir[$num_xpstart]="/home/gisburn/cwork/Xprint/Xprt_config/XpConfig"; + # xpstart_auditlevel[$num_xpstart]=4; + # xpstart_options[$num_xpstart]="-ac -pn"; + #num_xpstart=$(($num_xpstart + 1)) + + #### Sample 3: + # # Start Xprt without TrueType fonts on a display 56 with custom + # # XPCONFIGDIR and alternate "Xprinters" file + # xpstart_fontpath_rejectpattern[$num_xpstart]="/TrueType|/TT(/$|$)|/TTF(/$|$)"; + # xpstart_displayid[$num_xpstart]=56; + # xpstart_xpconfigdir[$num_xpstart]="/etc/XpConfig/default"; + # xpstart_xpfile[$num_xpstart]="/etc/XpConfig/default/Xprinters_test2" + # xpstart_auditlevel[$num_xpstart]="4"; + # xpstart_options[$num_xpstart]="-ac -pn"; + # xpstart_xprt_binary[$num_xpstart]=""; + #num_xpstart=$(($num_xpstart + 1)) + + #### Sample 4: + # # Start Xprt with Solaris ISO-8859-7 (greek(="el") locale) fonts on + # # display 57 + # xpstart_fontpath[$num_xpstart]="/usr/openwin/lib/locale/iso_8859_7/X11/fonts/75dpi,/usr/openwin/lib/locale/iso_8859_7/X11/fonts/Type1,/usr/openwin/lib/X11/fonts/misc/"; + # xpstart_fontpath_acceptpattern[$num_xpstart]=""; + # xpstart_fontpath_rejectpattern[$num_xpstart]="_No_Match_"; + # xpstart_displayid[$num_xpstart]="57"; + # xpstart_auditlevel[$num_xpstart]="4"; + # xpstart_options[$num_xpstart]="-ac -pn"; + #num_xpstart=$(($num_xpstart + 1)) + + #### Sample 5: + # # Start Xprt with the font list of an existing Xserver (excluding Speedo fonts) on + # # display 58 + # # Note that this only works within a X session. At system boot time + # # there will be no $DISPLAY to fetch the information from!! + # xpstart_fontpath[$num_xpstart]="$(get_fontlist_from_display ${DISPLAY} | fontlist2fontpath)"; + # xpstart_fontpath_acceptpattern[$num_xpstart]=""; + # xpstart_fontpath_rejectpattern[$num_xpstart]=""; + # xpstart_displayid[$num_xpstart]="58"; + # xpstart_xpconfigdir[$num_xpstart]=""; + # xpstart_auditlevel[$num_xpstart]="4"; + # xpstart_options[$num_xpstart]="-ac -pn"; + # xpstart_xprt_binary[$num_xpstart]=""; + #num_xpstart=$(($num_xpstart + 1)) + + #### Sample 6: + # # List remote Xprt's here + # # (note that there is no test to check whether these DISPLAYs are valid!) + # xpstart_remote_server[$num_xpstart]="sera:12" ; num_xpstart=$(($num_xpstart + 1)) + # xpstart_remote_server[$num_xpstart]="gandalf:19" ; num_xpstart=$(($num_xpstart + 1)) +} + +XCOMM########################################################################### + +XCOMM Main +case "$1" in + ## Start Xprint servers + 'start') + do_start + ;; + + ## Stop Xprint servers + # Note that this does _not_ kill Xprt instances started using this script + # by non-root users + 'stop') + do_stop + ;; + + ## Restart Xprint servers + 'restart'|'force-reload') + do_restart + ;; + + ## Reload configuration without stopping and restarting + 'reload') + # not supported + msg "reload not supported, use 'restart' or 'force-reload'" + exit 3 + ;; + + ## Restart Xprint only if it is already running + 'condrestart'|'try-restart') + # only restart if it is already running + [ -f /var/lock/subsys/xprint ] && do_restart || : + ;; + + ## Get list of all Xprint servers for this user + # (incl. per-user and system-wide instances) + 'get_xpserverlist') + do_get_xpserverlist + ;; + + ## Get status of Xprint servers, RedHat-style + 'status') + x="$(do_get_xpserverlist)" + if [ "${x}" != "" ] ; then + msg "Xprint (${x}) is running..." + exit 0 + else + msg "Xprint is stopped" + exit 3 + fi + ;; + + ## Wrapper + 'wrapper') + cmd="${2}" + [ "${cmd}" = "" ] && fatal_error "No command given." + shift ; shift + export XPSERVERLIST="$(do_get_xpserverlist)" + [ "${XPSERVERLIST}" = "" ] && fatal_error "No Xprint servers found." + exec "${cmd}" "$@" + ;; + + ## Wrapper for "xplsprinters" + 'lsprinters') + [ "${ETC_INITD_XPRINT_XPLSPRINTERS_PATH}" != "" ] && cmd="${ETC_INITD_XPRINT_XPLSPRINTERS_PATH}" + [ "${cmd}" = "" -a "${XPCUSTOMGLUE}" = "GISWxprintglue" ] && cmd="/opt/GISWxprintglue/bin/xplsprinters" + [ "${cmd}" = "" -a "${XPCUSTOMGLUE}" = "GISWxprint" ] && cmd="/opt/GISWxprint/bin/xplsprinters" + [ "${cmd}" = "" -a "${XPROJECTROOT}" != "" ] && cmd="${XPROJECTROOT}/bin/xplsprinters" + [ "${cmd}" = "" ] && cmd="xplsprinters" + + shift + export XPSERVERLIST="$(do_get_xpserverlist)" + [ "${XPSERVERLIST}" = "" ] && fatal_error "No Xprint servers found." + exec "${cmd}" "$@" + ;; + + ## Diagnostics + 'diag') + do_diag + ;; + + ## Print usage + *) + msg "Usage: $0 { start | stop | restart | reload | force-reload | status | condrestart | try-restart | wrapper | lsprinters | get_xpserverlist | diag }" + exit 2 +esac +exit 0 + +XCOMM EOF. diff --git a/Xprint/mediaSizes.c b/Xprint/mediaSizes.c index b24f5c6c0..12482b281 100644 --- a/Xprint/mediaSizes.c +++ b/Xprint/mediaSizes.c @@ -30,8 +30,6 @@ not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from said copyright holders. */ -/* $XFree86: xc/programs/Xserver/Xprint/mediaSizes.c,v 1.4 2001/01/17 22:36:28 dawes Exp $ */ - /******************************************************************* ** ** ********************************************************* @@ -130,6 +128,14 @@ static PageDimensionsRec PageDimensions[] = {xpoid_val_medium_size_jis_b8, 64, 91}, {xpoid_val_medium_size_jis_b9, 45, 64}, {xpoid_val_medium_size_jis_b10, 32, 45}, + {xpoid_val_medium_size_hp_2x_postcard, 148, 200}, + {xpoid_val_medium_size_hp_european_edp, 304.8, 355.6}, + {xpoid_val_medium_size_hp_mini, 139.7, 215.9}, + {xpoid_val_medium_size_hp_postcard, 100, 148}, + {xpoid_val_medium_size_hp_tabloid, 279.4, 431.8}, + {xpoid_val_medium_size_hp_us_edp, 279.4, 355.6}, + {xpoid_val_medium_size_hp_us_government_legal, 203.2, 330.2}, + {xpoid_val_medium_size_hp_us_government_letter, 203.2, 254}, {xpoid_val_medium_size_iso_c3, 324, 458}, {xpoid_val_medium_size_iso_c4, 229, 324}, {xpoid_val_medium_size_iso_c5, 162, 229}, @@ -145,7 +151,8 @@ static PageDimensionsRec PageDimensions[] = * attributes pools have been validated. */ int -XpGetResolution(XpContextPtr pContext) +XpGetResolution( + XpContextPtr pContext) { unsigned long resolution; @@ -185,7 +192,8 @@ XpGetResolution(XpContextPtr pContext) * attributes pools have been validated. */ XpOid -XpGetContentOrientation(XpContextPtr pContext) +XpGetContentOrientation( + XpContextPtr pContext) { XpOid orientation; @@ -415,7 +423,7 @@ XpGetMediumMillimeters( float *width, /* return */ float *height) /* return */ { - unsigned i; + int i; *width = *height = 0; for(i = 0; i < XpNumber(PageDimensions); i++) @@ -739,7 +747,9 @@ XpGetMaxWidthHeightRes( } FontResolutionPtr -XpGetClientResolutions(ClientPtr client, int *num) +XpGetClientResolutions(client, num) + ClientPtr client; + int *num; { static struct _FontResolution res; int resolution = XpGetResolution(XpContextOfClient(client)); @@ -755,13 +765,15 @@ XpGetClientResolutions(ClientPtr client, int *num) } -void XpSetFontResFunc(ClientPtr client) +void XpSetFontResFunc(client) + ClientPtr client; { client->fontResFunc = XpGetClientResolutions; } -void XpUnsetFontResFunc(ClientPtr client) +void XpUnsetFontResFunc(client) + ClientPtr client; { client->fontResFunc = NULL; } diff --git a/Xprint/ps/Ps.h b/Xprint/ps/Ps.h index d33f301fa..6bde70f47 100644 --- a/Xprint/ps/Ps.h +++ b/Xprint/ps/Ps.h @@ -7,6 +7,7 @@ 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. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -73,7 +74,6 @@ in this Software without prior written authorization from The Open Group. ** ********************************************************* ** ********************************************************************/ -/* $XFree86: xc/programs/Xserver/Xprint/ps/Ps.h,v 1.13 2001/12/21 21:02:05 dawes Exp $ */ #ifndef _PS_H_ #define _PS_H_ @@ -113,6 +113,7 @@ typedef char *XPointer; #include <X11/Xresource.h> #include "attributes.h" + /* * Public index variables from PsInit.c */ @@ -245,10 +246,66 @@ typedef DisplayListRec *DisplayListPtr; typedef struct { XrmDatabase resDB; - ColormapPtr CMap; Bool (*DestroyWindow)(WindowPtr); } PsScreenPrivRec, *PsScreenPrivPtr; +typedef struct PsFontTypeInfoRec PsFontTypeInfoRec; + +/* Structure to hold information about one font on disk + * Notes: + * - multiple XLFD names can refer to the same |PsFontTypeInfoRec| (if + * they all use the same font on the disk) + * - the FreeType font download code uses multiple |PsFontTypeInfoRec| + * records for one font on disk if they differ in the encoding being + * used (this is an exception from the + * 'one-|PsFontTypeInfoRec|-per-font-on-disk'-design; maybe it it is better + * to rework that in a later step and add a new per-encoding structure). + */ +struct PsFontTypeInfoRec +{ + PsFontTypeInfoRec *next; /* Next record in list... */ + char *adobe_ps_name; /* PostScript font name (from the + * "_ADOBE_POSTSCRIPT_FONTNAME" atom) */ + char *download_ps_name; /* PostScript font name used for font download */ + char *filename; /* File name of font */ +#ifdef XP_USE_FREETYPE + char *ft_download_encoding; /* encoding used for download */ + PsFTDownloadFontType ft_download_font_type; /* PS font type used for download (e.g. Type1/Type3/CID/etc.) */ +#endif /* XP_USE_FREETYPE */ + int is_iso_encoding; /* Is this font encoded in ISO Latin 1 ? */ + int font_type; /* See PSFTI_FONT_TYPE_* below... */ + Bool downloadableFont; /* Font can be downloaded */ + Bool alreadyDownloaded[256]; /* Font has been downloaded (for 256 8bit "sub"-font) */ +}; + +#define PSFTI_FONT_TYPE_OTHER (0) +#define PSFTI_FONT_TYPE_PMF (1) +#define PSFTI_FONT_TYPE_PS_TYPE1_PFA (2) +#define PSFTI_FONT_TYPE_PS_TYPE1_PFB (3) +#define PSFTI_FONT_TYPE_TRUETYPE (4) +/* PSFTI_FONT_TYPE_FREETYPE is means the font is handled by the freetype engine */ +#define PSFTI_FONT_TYPE_FREETYPE (5) + +typedef struct PsFontInfoRec PsFontInfoRec; + +/* Structure which represents our context info for a single XLFD font + * Note that multiple |PsFontInfoRec| records can share the same + * |PsFontTypeInfoRec| record - the |PsFontInfoRec| records represent + * different appearances of the same font on disk(=|PsFontTypeInfoRec|)). + */ +struct PsFontInfoRec +{ + PsFontInfoRec *next; /* Next record in list... */ + /* |font| and |font_fontPrivate| are used by |PsFindFontInfoRec()| to + * identify a font */ + FontPtr font; /* The font this record is for */ + pointer font_fontPrivate; + PsFontTypeInfoRec *ftir; /* Record about the font file on disk */ + const char *dfl_name; /* XLFD for this font */ + int size; /* Font size. Use |mtx| if |size==0| */ + float mtx[4]; /* Transformation matrix (see |size|) */ +}; + typedef struct { char *jobFileName; @@ -259,6 +316,8 @@ typedef struct ClientPtr getDocClient; int getDocBufSize; PsOutPtr pPsOut; + PsFontTypeInfoRec *fontTypeInfoRecords; + PsFontInfoRec *fontInfoRecords; } PsContextPrivRec, *PsContextPrivPtr; typedef struct @@ -291,6 +350,7 @@ typedef struct extern Bool InitializePsDriver(int ndx, ScreenPtr pScreen, int argc, char **argv); +static Bool PsDestroyContext(XpContextPtr pCon); extern XpContextPtr PsGetContextFromWindow(WindowPtr win); /* @@ -314,6 +374,10 @@ extern int PsGetDocumentData(XpContextPtr pCon, ClientPtr client, */ extern Bool PsCreateGC(GCPtr pGC); +static int PsGetDrawablePrivateStuff(DrawablePtr pDrawable, GC *gc, + unsigned long *valid, PsOutPtr *psOut, + ColormapPtr *cMap); +extern PsContextPrivPtr PsGetPsContextPriv( DrawablePtr pDrawable ); extern int PsUpdateDrawableGC(GCPtr pGC, DrawablePtr pDrawable, PsOutPtr *psOut, ColormapPtr *cMap); extern void PsValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable); @@ -366,9 +430,8 @@ extern void PsPutScaledImage(DrawablePtr pDrawable, GCPtr pGC, int depth, extern void PsPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y, int w, int h, int leftPad, int format, char *pImage); -extern void PsPutImageMask(DrawablePtr pDrawable, GCPtr pGC, int depth, - int x, int y, int w, int h, int leftPad, int format, - char *pImage); +extern void PsPutImageMask(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y, + int w, int h, int leftPad, int format, char *pImage); extern RegionPtr PsCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, int srcx, int srcy, int width, int height, int dstx, int dsty); @@ -456,7 +519,19 @@ extern Bool PsUnrealizeFont(ScreenPtr pscr, FontPtr pFont); extern char *PsGetFontName(FontPtr pFont); extern int PsGetFontSize(FontPtr pFont, float *mtx); extern char *PsGetPSFontName(FontPtr pFont); +extern char *PsGetPSFaceOrFontName(FontPtr pFont); extern int PsIsISOLatin1Encoding(FontPtr pFont); +extern char *PsGetEncodingName(FontPtr pFont); +extern PsFontInfoRec *PsGetFontInfoRec(DrawablePtr pDrawable, FontPtr pFont); +extern void PsFreeFontInfoRecords(PsContextPrivPtr priv); +extern PsFTDownloadFontType PsGetFTDownloadFontType(void); + +/* + * Functions in PsFTFonts.c + */ + +extern char *PsGetFTFontFileName(FontPtr pFont); +extern Bool PsIsFreeTypeFont(FontPtr pFont); /* * Functions in PsAttr.c @@ -503,14 +578,4 @@ extern PsElmPtr PsCreateFillElementList(PixmapPtr pix, int *nElms); extern PsElmPtr PsCloneFillElementList(int nElms, PsElmPtr elms); extern void PsDestroyFillElementList(int nElms, PsElmPtr elms); -/* - * Functions in PsCache.c - */ - -#ifdef BM_CACHE -extern int PsBmIsImageCached(int gWidth, int gHeight, char *pBuffer); -extern int PsBmPutImageInCache(int gWidth, int gHeight, char *pBuffer); -extern void PsBmClearImageCache(void); -#endif - #endif /* _PS_H_ */ diff --git a/Xprint/ps/PsArea.c b/Xprint/ps/PsArea.c index eed650ada..134686a87 100644 --- a/Xprint/ps/PsArea.c +++ b/Xprint/ps/PsArea.c @@ -228,7 +228,7 @@ error: return; } -static void +void PsPutScaledImageIM(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y, int w, int h, int leftPad, int format, int imageRes, char *pImage) { @@ -269,9 +269,9 @@ PsPutScaledImageIM(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y, ColormapPtr cMap; int pageRes, sw, sh; #ifdef BM_CACHE - long cache_id = 0; + long cache_id = 0; #endif - + if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return; if (!imageRes) { sw = w; @@ -296,100 +296,100 @@ PsPutScaledImageIM(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y, PsOut_BeginImageCache(psOut, cache_id); #endif - if( depth==24 ) - { - PsOut_BeginImageIM(psOut, 0, 0, x, y, w, h, sw, sh, 3); - if( format==XYPixmap ) + if( depth==24 ) { - int rowsiz = PixmapBytePad(w, depth); - char *planes[3]; - planes[0] = pImage; - planes[1] = &pImage[rowsiz*h]; - planes[2] = &pImage[rowsiz*h*2]; - for( r=0 ; r<h ; r++ ) + PsOut_BeginImageIM(psOut, 0, 0, x, y, w, h, sw, sh, 3); + if( format==XYPixmap ) { - char *pt[3]; - for( i=0 ; i<3 ; i++ ) pt[i] = &planes[i][rowsiz*r]; - for( c=0 ; c<w ; c++ ) + int rowsiz = PixmapBytePad(w, depth); + char *planes[3]; + planes[0] = pImage; + planes[1] = &pImage[rowsiz*h]; + planes[2] = &pImage[rowsiz*h*2]; + for( r=0 ; r<h ; r++ ) { - for( i=0 ; i<3 ; i++ ) - { PsOut_OutImageBytes(psOut, 1, &pt[i][c]); pt[i]++; } + char *pt[3]; + for( i=0 ; i<3 ; i++ ) pt[i] = &planes[i][rowsiz*r]; + for( c=0 ; c<w ; c++ ) + { + for( i=0 ; i<3 ; i++ ) + { PsOut_OutImageBytes(psOut, 1, &pt[i][c]); pt[i]++; } + } + } + } + else if( format==ZPixmap ) + { + int rowsiz = PixmapBytePad(w, depth); + for( r=0 ; r<h ; r++ ) + { + char *pt = &pImage[rowsiz*r]; + for( c=0 ; c<w ; c++,pt+=4 ) + { + if( swap ) + { + char tmp[4]; + tmp[0] = pt[3]; tmp[1] = pt[2]; tmp[2] = pt[1]; tmp[3] = pt[0]; + PsOut_OutImageBytes(psOut, 3, &tmp[1]); + } + else + PsOut_OutImageBytes(psOut, 3, &pt[1]); + } } } + else goto error; + PsOut_EndImage(psOut); } - else if( format==ZPixmap ) + else if( depth==8 ) { int rowsiz = PixmapBytePad(w, depth); + PsOut_BeginImageIM(psOut, 0, 0, x, y, w, h, sw, sh, 3); for( r=0 ; r<h ; r++ ) { char *pt = &pImage[rowsiz*r]; - for( c=0 ; c<w ; c++,pt+=4 ) + for( c=0 ; c<w ; c++,pt++ ) { + int val = PsGetPixelColor(cMap, (int)(*pt)&0xFF); + char *ipt = (char *)&val; if( swap ) { char tmp[4]; - tmp[0] = pt[3]; tmp[1] = pt[2]; tmp[2] = pt[1]; tmp[3] = pt[0]; + tmp[0] = ipt[3]; tmp[1] = ipt[2]; tmp[2] = ipt[1]; tmp[3] = ipt[0]; PsOut_OutImageBytes(psOut, 3, &tmp[1]); } else - PsOut_OutImageBytes(psOut, 3, &pt[1]); + PsOut_OutImageBytes(psOut, 3, &ipt[1]); } } + PsOut_EndImage(psOut); } - else goto error; - PsOut_EndImage(psOut); - } - else if( depth==8 ) - { - int rowsiz = PixmapBytePad(w, depth); - PsOut_BeginImageIM(psOut, 0, 0, x, y, w, h, sw, sh, 3); - for( r=0 ; r<h ; r++ ) - { - char *pt = &pImage[rowsiz*r]; - for( c=0 ; c<w ; c++,pt++ ) - { - int val = PsGetPixelColor(cMap, (int)(*pt)&0xFF); - char *ipt = (char *)&val; - if( swap ) - { - char tmp[4]; - tmp[0] = ipt[3]; tmp[1] = ipt[2]; tmp[2] = ipt[1]; tmp[3] = ipt[0]; - PsOut_OutImageBytes(psOut, 3, &tmp[1]); - } - else - PsOut_OutImageBytes(psOut, 3, &ipt[1]); - } - } - PsOut_EndImage(psOut); - } - else if( depth==1 ) - { + else if( depth==1 ) { - int rowsiz = BitmapBytePad(w); - int psrsiz = (w+7)/8; - PsOut_BeginImageIM(psOut, PsGetPixelColor(cMap, pGC->bgPixel), - PsGetPixelColor(cMap, pGC->fgPixel), - x, y, w, h, sw, sh, 1); - for( r=0 ; r<h ; r++ ) { - char *pt = &pImage[rowsiz*r]; - for( i=0 ; i<psrsiz ; i++ ) + int rowsiz = BitmapBytePad(w); + int psrsiz = (w+7)/8; + PsOut_BeginImageIM(psOut, PsGetPixelColor(cMap, pGC->bgPixel), + PsGetPixelColor(cMap, pGC->fgPixel), + x, y, w, h, sw, sh, 1); + for( r=0 ; r<h ; r++ ) { - int iv_, iv = (int)pt[i]&0xFF; - char c; - if( swap ) - { for( j=0,iv_=0 ; j<8 ; j++ ) iv_ |= (((iv>>j)&1)<<(7-j)); } - else - iv_ = iv; - c = iv_; - PsOut_OutImageBytes(psOut, 1, &c); + char *pt = &pImage[rowsiz*r]; + for( i=0 ; i<psrsiz ; i++ ) + { + int iv_, iv = (int)pt[i]&0xFF; + char c; + if( swap ) + { for( j=0,iv_=0 ; j<8 ; j++ ) iv_ |= (((iv>>j)&1)<<(7-j)); } + else + iv_ = iv; + c = iv_; + PsOut_OutImageBytes(psOut, 1, &c); + } } + PsOut_EndImage(psOut); } - PsOut_EndImage(psOut); } - } #ifdef BM_CACHE - PsOut_EndImageCache(psOut); + PsOut_EndImageCache(psOut); } PsOut_ImageCache(psOut, x, y, cache_id, PsGetPixelColor(cMap, pGC->bgPixel), PsGetPixelColor(cMap, pGC->fgPixel)); diff --git a/Xprint/ps/PsAttVal.c b/Xprint/ps/PsAttVal.c index 4a7865af6..5ebd0d3b9 100644 --- a/Xprint/ps/PsAttVal.c +++ b/Xprint/ps/PsAttVal.c @@ -32,7 +32,6 @@ not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from said copyright holders. */ -/* $XFree86: xc/programs/Xserver/Xprint/ps/PsAttVal.c,v 1.4 2001/01/17 22:36:31 dawes Exp $ */ #include "Ps.h" #include "AttrValid.h" @@ -73,7 +72,16 @@ static XpOidList DefaultPlexes = { }; static unsigned long ValidPrinterResolutionsCards[] = { + 75, + 100, + 120, + 150, + 180, + 200, + 240, 300, + 360, + 400, 600, 720, 940, @@ -86,7 +94,20 @@ static XpOidCardList ValidPrinterResolutions = { }; static unsigned long DefaultPrinterResolutionsCards[] = { - 300 + 75, + 100, + 120, + 150, + 180, + 200, + 240, + 300, + 360, + 400, + 600, + 720, + 940, + 1200 }; static XpOidCardList DefaultPrinterResolutions = { DefaultPrinterResolutionsCards, XpNumber(DefaultPrinterResolutionsCards) @@ -143,13 +164,6 @@ static XpOidDocFmtList DefaultEmbeddedFormatsSupported = { DefaultEmbeddedFormatsSupportedFmts, XpNumber(DefaultEmbeddedFormatsSupportedFmts) }; -/* -** So filtered printers that accept other raw formats can be -** used with this driver. -** -** Noah Roberts (jik-) -*/ -#if 0 static XpOidDocFmt ValidRawFormatsSupportedFmts[] = { { "Postscript", "2", NULL } @@ -157,7 +171,6 @@ static XpOidDocFmt ValidRawFormatsSupportedFmts[] = { static XpOidDocFmtList ValidRawFormatsSupported = { ValidRawFormatsSupportedFmts, XpNumber(ValidRawFormatsSupportedFmts) }; -#endif static XpOidDocFmt DefaultRawFormatsSupportedFmts[] = { { "Postscript", "2", NULL } @@ -178,12 +191,74 @@ static XpOidList ValidInputTrays = { }; static XpOid ValidMediumSizesOids[] = { + xpoid_val_medium_size_iso_a0, + xpoid_val_medium_size_iso_a1, + xpoid_val_medium_size_iso_a2, + xpoid_val_medium_size_iso_a3, xpoid_val_medium_size_iso_a4, + xpoid_val_medium_size_iso_a5, + xpoid_val_medium_size_iso_a6, + xpoid_val_medium_size_iso_a7, + xpoid_val_medium_size_iso_a8, + xpoid_val_medium_size_iso_a9, + xpoid_val_medium_size_iso_a10, + xpoid_val_medium_size_iso_b0, + xpoid_val_medium_size_iso_b1, + xpoid_val_medium_size_iso_b2, + xpoid_val_medium_size_iso_b3, + xpoid_val_medium_size_iso_b4, + xpoid_val_medium_size_iso_b5, + xpoid_val_medium_size_iso_b6, + xpoid_val_medium_size_iso_b7, + xpoid_val_medium_size_iso_b8, + xpoid_val_medium_size_iso_b9, + xpoid_val_medium_size_iso_b10, xpoid_val_medium_size_na_letter, xpoid_val_medium_size_na_legal, xpoid_val_medium_size_executive, + xpoid_val_medium_size_folio, + xpoid_val_medium_size_invoice, + xpoid_val_medium_size_ledger, + xpoid_val_medium_size_quarto, + xpoid_val_medium_size_iso_c3, + xpoid_val_medium_size_iso_c4, + xpoid_val_medium_size_iso_c5, + xpoid_val_medium_size_iso_c6, xpoid_val_medium_size_iso_designated_long, - xpoid_val_medium_size_na_number_10_envelope + xpoid_val_medium_size_na_10x13_envelope, + xpoid_val_medium_size_na_9x12_envelope, + xpoid_val_medium_size_na_number_10_envelope, + xpoid_val_medium_size_na_7x9_envelope, + xpoid_val_medium_size_na_9x11_envelope, + xpoid_val_medium_size_na_10x14_envelope, + xpoid_val_medium_size_na_number_9_envelope, + xpoid_val_medium_size_na_6x9_envelope, + xpoid_val_medium_size_na_10x15_envelope, + xpoid_val_medium_size_monarch_envelope, + xpoid_val_medium_size_a, + xpoid_val_medium_size_b, + xpoid_val_medium_size_c, + xpoid_val_medium_size_d, + xpoid_val_medium_size_e, + xpoid_val_medium_size_jis_b0, + xpoid_val_medium_size_jis_b1, + xpoid_val_medium_size_jis_b2, + xpoid_val_medium_size_jis_b3, + xpoid_val_medium_size_jis_b4, + xpoid_val_medium_size_jis_b5, + xpoid_val_medium_size_jis_b6, + xpoid_val_medium_size_jis_b7, + xpoid_val_medium_size_jis_b8, + xpoid_val_medium_size_jis_b9, + xpoid_val_medium_size_jis_b10, + xpoid_val_medium_size_hp_2x_postcard, + xpoid_val_medium_size_hp_european_edp, + xpoid_val_medium_size_hp_mini, + xpoid_val_medium_size_hp_postcard, + xpoid_val_medium_size_hp_tabloid, + xpoid_val_medium_size_hp_us_edp, + xpoid_val_medium_size_hp_us_government_legal, + xpoid_val_medium_size_hp_us_government_letter, }; static XpOidList ValidMediumSizes = { ValidMediumSizesOids, XpNumber(ValidMediumSizesOids) @@ -205,7 +280,7 @@ XpValidatePoolsRec PsValidatePoolsRec = { &ValidPrinterResolutions, &DefaultPrinterResolutions, &ValidEmbeddedFormatsSupported, &DefaultEmbeddedFormatsSupported, &ValidListfontsModes, &DefaultListfontsModes, - NULL /* Any raw format specified (NR)*/, &DefaultRawFormatsSupported, + &ValidRawFormatsSupported, &DefaultRawFormatsSupported, &ValidSetupProviso, &DefaultDocumentFormat }; diff --git a/Xprint/ps/PsAttr.c b/Xprint/ps/PsAttr.c index f276c180f..8a5bee9e3 100644 --- a/Xprint/ps/PsAttr.c +++ b/Xprint/ps/PsAttr.c @@ -57,7 +57,6 @@ in this Software without prior written authorization from The Open Group. * or other dealings in this Software without prior written authorization * from said copyright holders. */ -/* $XFree86: xc/programs/Xserver/Xprint/ps/PsAttr.c,v 1.4 2001/01/17 22:36:32 dawes Exp $ */ /******************************************************************* ** @@ -76,6 +75,7 @@ in this Software without prior written authorization from The Open Group. ********************************************************************/ #include "Ps.h" +#include "attributes.h" char * PsGetAttributes( diff --git a/Xprint/ps/PsCache.c b/Xprint/ps/PsCache.c index b688fbba1..8c9f4a926 100644 --- a/Xprint/ps/PsCache.c +++ b/Xprint/ps/PsCache.c @@ -79,21 +79,21 @@ in this Software without prior written authorization from The Open Group. #include "fntfil.h" #include "fntfilst.h" -#define GET 0 -#define RESET 1 +#define GET 0 +#define RESET 1 struct bm_cache_list { - struct bm_cache_list *next; - struct bm_cache_list *prev; + struct bm_cache_list *next; + struct bm_cache_list *prev; int height; - long id; + long id; char *pBuffer; }; struct bm_cache_head { - struct bm_cache_list *head; - int width; - struct bm_cache_head *next; + struct bm_cache_list *head; + int width; + struct bm_cache_head *next; struct bm_cache_head *prev; }; @@ -106,14 +106,14 @@ PsBmUniqueId(int func) if(func == RESET) { - unique_id = 0; - return 0; + unique_id = 0; + return 0; } else - return ++unique_id; + return ++unique_id; } -int +int PsBmIsImageCached( int gWidth, int gHeight, @@ -126,28 +126,28 @@ PsBmIsImageCached( { if(pList->width == gWidth) { - struct bm_cache_list *pItem = pList->head; - - while(pItem != NULL) - { - if(pItem->height == gHeight) - { - int length = 4*(gWidth/32+(gWidth%32!=0))*gHeight; - - if(!memcmp(pItem->pBuffer, pBuffer, sizeof(char)*length)) - { - return_val = pItem->id; - break; - } - } - else if(pItem->height > gHeight) - break; - - pItem = pItem->next; - } + struct bm_cache_list *pItem = pList->head; + + while(pItem != NULL) + { + if(pItem->height == gHeight) + { + int length = 4*(gWidth/32+(gWidth%32!=0))*gHeight; + + if(!memcmp(pItem->pBuffer, pBuffer, sizeof(char)*length)) + { + return_val = pItem->id; + break; + } + } + else if(pItem->height > gHeight) + break; + + pItem = pItem->next; + } } - else if(pList->width > gWidth) - break; + else if(pList->width > gWidth) + break; pList = pList->next; } @@ -180,39 +180,39 @@ PsBmPutImageInCache( while(pList != NULL) { if(pList->width == gWidth) - { - struct bm_cache_list *pItem = pList->head; - - while(pItem != NULL) - { - if(pItem->height >= gHeight) - { - pNew->next = pItem; - pNew->prev = pItem->prev; - if(pItem->prev != NULL) - pItem->prev->next = pNew; + { + struct bm_cache_list *pItem = pList->head; + + while(pItem != NULL) + { + if(pItem->height >= gHeight) + { + pNew->next = pItem; + pNew->prev = pItem->prev; + if(pItem->prev != NULL) + pItem->prev->next = pNew; else - pList->head = pNew; + pList->head = pNew; pItem->prev = pNew; - return_val = pNew->id; + return_val = pNew->id; - break; - } - else if(pItem->next == NULL) - { - pNew->prev = pItem; - pItem->next = pNew; + break; + } + else if(pItem->next == NULL) + { + pNew->prev = pItem; + pItem->next = pNew; - return_val = pNew->id; + return_val = pNew->id; - break; - } + break; + } - pItem = pItem->next; - } + pItem = pItem->next; + } - break; + break; } pList = pList->next; @@ -223,50 +223,50 @@ PsBmPutImageInCache( struct bm_cache_head *pNewList; pNewList = (struct bm_cache_head *)malloc(sizeof(struct bm_cache_head)); - + pNewList->next = NULL; pNewList->prev = NULL; pNewList->width = gWidth; pNewList->head = pNew; - + if(bm_cache == NULL) { - bm_cache = pNewList; - return_val = pNew->id; + bm_cache = pNewList; + return_val = pNew->id; } else { - pList = bm_cache; + pList = bm_cache; - while(pList != NULL) - { - if(pList->width > gWidth) - { - pNewList->next = pList; - pNewList->prev = pList->prev; + while(pList != NULL) + { + if(pList->width > gWidth) + { + pNewList->next = pList; + pNewList->prev = pList->prev; - if(pList->prev != NULL) - pList->prev->next = pNewList; + if(pList->prev != NULL) + pList->prev->next = pNewList; else - bm_cache = pNewList; - pList->prev = pNewList; + bm_cache = pNewList; + pList->prev = pNewList; - return_val = pNew->id; + return_val = pNew->id; - break; - } - else if(pList->next == NULL) + break; + } + else if(pList->next == NULL) { - pNewList->prev = pList; - pList->next = pNewList; + pNewList->prev = pList; + pList->next = pNewList; - return_val = pNew->id; + return_val = pNew->id; - break; - } + break; + } - pList = pList->next; - } + pList = pList->next; + } } } @@ -280,35 +280,35 @@ PsBmClearImageCacheItem( { if(pItem != NULL) { - if(pItem->pBuffer != NULL) - free(pItem->pBuffer); + if(pItem->pBuffer != NULL) + free(pItem->pBuffer); pItem->pBuffer = NULL; - if(pItem->next) - PsBmClearImageCacheItem(pItem->next); + if(pItem->next) + PsBmClearImageCacheItem(pItem->next); pItem->next = NULL; - free(pItem); - pItem = NULL; + free(pItem); + pItem = NULL; } } -static void +static void PsBmClearImageCacheList( struct bm_cache_head *pList) { if(pList != NULL) { - if(pList->head) - PsBmClearImageCacheItem(pList->head); + if(pList->head) + PsBmClearImageCacheItem(pList->head); pList->head = NULL; - if(pList->next) - PsBmClearImageCacheList(pList->next); + if(pList->next) + PsBmClearImageCacheList(pList->next); pList->next = NULL; - free(pList); - pList = NULL; + free(pList); + pList = NULL; } } diff --git a/Xprint/ps/PsColor.c b/Xprint/ps/PsColor.c index 6417410ee..da6c82c1d 100644 --- a/Xprint/ps/PsColor.c +++ b/Xprint/ps/PsColor.c @@ -73,7 +73,6 @@ in this Software without prior written authorization from The Open Group. ** ********************************************************* ** ********************************************************************/ -/* $XFree86: xc/programs/Xserver/Xprint/ps/PsColor.c,v 1.2 2001/10/28 03:32:56 tsi Exp $ */ #include "Ps.h" #include "gcstruct.h" @@ -86,6 +85,7 @@ PsCreateColormap(ColormapPtr pColor) int i; unsigned short rgb; VisualPtr pVisual = pColor->pVisual; + Pixel pix; if( pVisual->class==TrueColor ) { @@ -120,9 +120,6 @@ PsDestroyColormap(ColormapPtr pColor) void PsInstallColormap(ColormapPtr pColor) { - PsScreenPrivPtr pPriv = - (PsScreenPrivPtr)pColor->pScreen->devPrivates[PsScreenPrivateIndex].ptr; - pPriv->CMap = pColor; } void diff --git a/Xprint/ps/PsFonts.c b/Xprint/ps/PsFonts.c index 1f87f7e76..6d0ba1a61 100644 --- a/Xprint/ps/PsFonts.c +++ b/Xprint/ps/PsFonts.c @@ -57,7 +57,6 @@ in this Software without prior written authorization from The Open Group. * or other dealings in this Software without prior written authorization * from said copyright holders. */ -/* $XFree86: xc/programs/Xserver/Xprint/ps/PsFonts.c,v 1.6 2001/12/19 21:55:59 dawes Exp $ */ /******************************************************************* ** @@ -80,9 +79,15 @@ in this Software without prior written authorization from The Open Group. #include "dixfontstr.h" #include "scrnintstr.h" #include "fontxlfd.h" +#include "fntfil.h" +#include "fntfilst.h" #include "Ps.h" +#include <ctype.h> +#include <limits.h> +#include <sys/stat.h> + Bool PsRealizeFont( ScreenPtr pscr, @@ -110,7 +115,7 @@ PsGetFontName(FontPtr pFont) for( i=0 ; i<nprops ; i++ ) { - if( (Atom)props[i].name == name ) + if( (Atom)props[i].name==name ) { value = props[i].value; break; } } if( !value ) return (char *)0; @@ -145,12 +150,14 @@ PsGetPSFontName(FontPtr pFont) int i; int nprops = pFont->info.nprops; FontPropPtr props = pFont->info.props; - Atom name = MakeAtom("PRINTER_RESIDENT_FONT", 21, True); + /* "_ADOBE_POSTSCRIPT_FONTNAME" maps directly to a PMF OBJ_NAME attribute + * name - changing the name will break printer-builtin fonts. */ + Atom name = MakeAtom("_ADOBE_POSTSCRIPT_FONTNAME", 26, True); Atom value = (Atom)0; for( i=0 ; i<nprops ; i++ ) { - if( (Atom)props[i].name == name ) + if( (Atom)props[i].name==name ) { value = props[i].value; break; } } if( !value ) return (char *)0; @@ -171,8 +178,8 @@ PsIsISOLatin1Encoding(FontPtr pFont) for( i=0 ; i<nprops ; i++ ) { - if( (Atom)props[i].name == reg ) rv = props[i].value; - if( (Atom)props[i].name == enc ) ev = props[i].value; + if( (Atom)props[i].name==reg ) rv = props[i].value; + if( (Atom)props[i].name==enc ) ev = props[i].value; } if( rv ) rp = NameForAtom(rv); if( ev ) ep = NameForAtom(ev); @@ -184,3 +191,682 @@ PsIsISOLatin1Encoding(FontPtr pFont) ep[0]!='1' ) return(0); return(1); } + +/* Return the encoding part of the XLFD (e.g. "*-iso8859-6.8x" etc.)*/ +char *PsGetEncodingName(FontPtr pFont) +{ + int i; + int nprops = pFont->info.nprops; + FontPropPtr props = pFont->info.props; + Atom fnt = MakeAtom("FONT", 4, True); + Atom reg = MakeAtom("CHARSET_REGISTRY", 16, True); + Atom enc = MakeAtom("CHARSET_ENCODING", 16, True); + Atom fv = 0, rv = 0, ev = 0; + char *fp = 0; + char *rp = 0; + char *ep = 0; + char *encname; + + for( i=0 ; i<nprops ; i++ ) + { + if( props[i].name==fnt ) fv = props[i].value; + if( props[i].name==reg ) rv = props[i].value; + if( props[i].name==enc ) ev = props[i].value; + } + if( fv ) fp = NameForAtom(fv); + if( rv ) rp = NameForAtom(rv); + if( ev ) ep = NameForAtom(ev); + + if( (!rp) || (!ep) || (!fp)) + return(0); + + encname = fp; + encname += strlen(encname) - (strlen(rp) + strlen(ep) + 1); + + return encname; +} + +/* strstr(), case-insensitive */ +static +char *str_case_str(const char *s, const char *find) +{ + size_t len; + char c, + sc; + + if ((c = tolower(*find++)) != '\0') + { + len = strlen(find); + do + { + do + { + if ((sc = tolower(*s++)) == '\0') + return NULL; + } while (sc != c); + } while (strncasecmp(s, find, len) != 0); + s--; + } + return ((char *)s); +} + +/* Check if the font path element is a directory which can be examined + * (for example the font may be from a font server + * (e.g. pFont->fpe->name == "tcp/:7100")) + */ +static +Bool IsFPEaReadableDir(FontPtr pFont) +{ + const char *fpe_name = pFont->fpe->name; + if (!fpe_name) + return False; + +#define MODEL_FONTPATH_PREFIX "PRINTER:" +#define MODEL_FONTPATH_PREFIX_LEN 8 + /* Strip model-specific font path prefix if there is one... */ + if (!strncmp(fpe_name, MODEL_FONTPATH_PREFIX, MODEL_FONTPATH_PREFIX_LEN)) + fpe_name += MODEL_FONTPATH_PREFIX_LEN; + + if (access(fpe_name, F_OK) == 0) + { + return True; + } + + return False; +} + +static +char *getFontFilename(FontPtr pFont) +{ + FontDirectoryPtr dir; + const char *dlfnam; + FILE *file; + struct stat statb; + int count, i, status; + char buf[512]; + char *front, *end, *fn; + char font_dir_fname[PATH_MAX], /* Full path of fonts.dir */ + font_file_fname[PATH_MAX]; /* Name of font file (excluding path) */ + +#ifdef XP_USE_FREETYPE + if( PsIsFreeTypeFont(pFont) ) + { + const char *fontname = PsGetFTFontFileName(pFont); + +#ifdef DEBUG_gisburn + fprintf(stderr, "getFontFilename: freetype font, file='%s'\n", fontname?fontname:"<NULL>"); +#endif /* DEBUG_gisburn */ + + if( !fontname ) + return NULL; + + return strdup(fontname); + } +#endif /* XP_USE_FREETYPE */ + + if (!IsFPEaReadableDir(pFont)) + { +#ifdef DEBUG_gisburn + fprintf(stderr, "getFontFilename: '%s' no valid font path on disk\n", pFont->fpe->name); +#endif /* DEBUG_gisburn */ + return NULL; + } + + dir = pFont->fpe->private; + sprintf(font_dir_fname, "%s%s", dir->directory, "fonts.dir"); + + if (!(dlfnam = PsGetFontName(pFont))) + return NULL; + + file = fopen(font_dir_fname, "r"); + if (file) + { + if (fstat (fileno(file), &statb) == -1) + return NULL; + + while( fgets(buf, sizeof(buf)-1, file) ) + { + if ((fn = strstr(buf, " -"))) + { + strcpy(font_file_fname, buf); + font_file_fname[fn - buf] = '\0'; + fn++; + if ((front = str_case_str(fn, "normal-"))) + { + fn[front - fn] = '\0'; + if (str_case_str(dlfnam, fn)) + { + char full_font_file_path[PATH_MAX]; + + fclose(file); + + sprintf(full_font_file_path, "%s%s", dir->directory, font_file_fname); + +#ifdef xDEBUG_gisburn + fprintf(stderr, "getFontFilename: returning '%s'\n", full_font_file_path); +#endif /* DEBUG_gisburn */ + return strdup(full_font_file_path); + } + } + } + } + } + font_file_fname[0] = '\0'; + fclose(file); + +#ifdef DEBUG_gisburn + fprintf(stderr, "getFontFilename: returning NULL\n"); +#endif /* DEBUG_gisburn */ + + return NULL; +} + +static +PsFontTypeInfoRec *PsFindFontTypeInfoRec(DrawablePtr pDrawable, FontPtr pFont) +{ + PsContextPrivRec *cPriv = PsGetPsContextPriv(pDrawable); + PsFontTypeInfoRec *rec; + const char *psname; + char *font_filename; + char *encname; +#ifdef XP_USE_FREETYPE + Bool is_freetypefont; +#endif /* XP_USE_FREETYPE */ + +#ifdef XP_USE_FREETYPE + is_freetypefont = PsIsFreeTypeFont(pFont); +#endif /* XP_USE_FREETYPE */ + encname = PsGetEncodingName(pFont); + + /* First try: Search by PostScript font name */ + psname = PsGetPSFontName(pFont); + if (psname) + { + for( rec = cPriv->fontTypeInfoRecords ; rec != NULL ; rec = rec->next ) + { +#ifdef XP_USE_FREETYPE + if (is_freetypefont) + { + if (rec->adobe_ps_name) + { + if ((rec->font_type == PSFTI_FONT_TYPE_FREETYPE) && + (!strcmp(rec->adobe_ps_name, psname)) && + (!strcmp(rec->ft_download_encoding, encname))) + { + return rec; + } + } + } + else +#endif /* XP_USE_FREETYPE */ + { + if (rec->adobe_ps_name) + { + if ((rec->font_type != PSFTI_FONT_TYPE_FREETYPE) && + (!strcmp(rec->adobe_ps_name, psname))) + { + return rec; + } + } + } + } + } + + /* Last attempt: Search by filename */ + font_filename = getFontFilename(pFont); + if (font_filename) + { + for( rec = cPriv->fontTypeInfoRecords ; rec != NULL ; rec = rec->next ) + { + if (rec->filename) + { +#ifdef XP_USE_FREETYPE + if (is_freetypefont) + { + if ( (rec->font_type == PSFTI_FONT_TYPE_FREETYPE) && + (!strcasecmp(rec->filename, font_filename)) && + (!strcasecmp(rec->ft_download_encoding, encname)) ) + { + free(font_filename); + return rec; + } + } + else +#endif /* XP_USE_FREETYPE */ + { + if ( (rec->font_type != PSFTI_FONT_TYPE_FREETYPE) && + (!strcasecmp(rec->filename, font_filename)) ) + { + free(font_filename); + return rec; + } + } + } + } + + free(font_filename); + } + + return NULL; +} + +static +void PsAddFontTypeInfoRec(DrawablePtr pDrawable, PsFontTypeInfoRec *add_rec) +{ + PsContextPrivRec *cPriv = PsGetPsContextPriv(pDrawable); + + /* ToDO: Always move the last used entry to the top that the list get's + * sorted in an efficient order... :-) */ + add_rec->next = cPriv->fontTypeInfoRecords; + cPriv->fontTypeInfoRecords = add_rec; +} + +static +Bool strcaseendswith(const char *str, const char *suffix) +{ + const char *s; + + s = str + strlen(str) - strlen(suffix); + + if (!strcasecmp(s, suffix)) + return True; + + return False; +} + + +static +int getFontFileType( const char *filename ) +{ + int type; + + /* Is this a Adobe PostScript Type 1 binary font (PFB) ? */ + if( strcaseendswith(filename, ".pfb") ) + { + type = PSFTI_FONT_TYPE_PS_TYPE1_PFB; + } + /* Is this a Adobe PostScript ASCII font (PFA) ? */ + else if( strcaseendswith(filename, ".pfa") ) + { + type = PSFTI_FONT_TYPE_PS_TYPE1_PFA; + } + /* Is this a PMF(=Printer Metrics File) ? */ + else if( strcaseendswith(filename, ".pmf") ) + { + type = PSFTI_FONT_TYPE_PMF; + } + /* Is this a TrueType font file ? */ + else if( strcaseendswith(filename, ".ttf") || + strcaseendswith(filename, ".ttc") || + strcaseendswith(filename, ".otf") || + strcaseendswith(filename, ".otc") ) + { + type = PSFTI_FONT_TYPE_TRUETYPE; + } + else + { + type = PSFTI_FONT_TYPE_OTHER; + } + +#ifdef XP_USE_FREETYPE + { + XpContextPtr pCon; + char *downloadfonts; + pCon = XpGetPrintContext(requestingClient); + downloadfonts = XpGetOneAttribute(pCon, XPPrinterAttr, "xp-psddx-download-fonts"); + if( downloadfonts ) + { + /* Should we download PS Type1 fonts as PS Type1||Type3 ? */ + if( (type == PSFTI_FONT_TYPE_PS_TYPE1_PFA) && + (strstr(downloadfonts, "pfa") != NULL) ) + { + type = PSFTI_FONT_TYPE_FREETYPE; + } + + if( (type == PSFTI_FONT_TYPE_PS_TYPE1_PFB) && + (strstr(downloadfonts, "pfb") != NULL) ) + { + type = PSFTI_FONT_TYPE_FREETYPE; + } + + /* Should we download TrueType fonts as PS Type1||Type3 ? */ + if( (type == PSFTI_FONT_TYPE_TRUETYPE) && + ((strstr(downloadfonts, "ttf") != NULL) || + (strstr(downloadfonts, "ttc") != NULL) || + (strstr(downloadfonts, "otf") != NULL) || + (strstr(downloadfonts, "otc") != NULL)) ) + { + type = PSFTI_FONT_TYPE_FREETYPE; + } + } + } +#endif /* XP_USE_FREETYPE */ + +#ifdef DEBUG_gisburn + fprintf(stderr, "getFontFileType: '%s' is %d\n", filename, (int)type); +#endif /* DEBUG_gisburn */ + return type; +} + +PsFTDownloadFontType PsGetFTDownloadFontType(void) +{ + PsFTDownloadFontType downloadfonttype; + XpContextPtr pCon; + char *psfonttype; + + pCon = XpGetPrintContext(requestingClient); + psfonttype = XpGetOneAttribute(pCon, XPPrinterAttr, "xp-psddx-download-font-type"); + + if( !psfonttype || !strlen(psfonttype) ) + { + return PsFontType1; /* Default download font type is PS Type1 */ + } + + if( !strcmp(psfonttype, "bitmap") ) + { + downloadfonttype = PsFontBitmap; + } + else if( !strcmp(psfonttype, "pstype3") ) + { + downloadfonttype = PsFontType3; + } + else if( !strcmp(psfonttype, "pstype1") ) + { + downloadfonttype = PsFontType1; + } + else + { + FatalError("PS DDX: XPPrinterAttr/xp-psddx-download-freetype-font-type='%s' not implemented\n", psfonttype); + return 0; /* NO-OP, FatalError() will call |exit()| */ + } + + return downloadfonttype; +} + +static +PsFontTypeInfoRec *PsCreateFontTypeInfoRec(DrawablePtr pDrawable, FontPtr pFont) +{ + char *dlfnam; + PsFontTypeInfoRec *rec; + char *psname; + + if (!(dlfnam = PsGetFontName(pFont))) + return NULL; + + if (!(rec = (PsFontTypeInfoRec *)xalloc(sizeof(PsFontTypeInfoRec)))) + return NULL; + memset(rec, 0, sizeof(PsFontTypeInfoRec)); + + rec->next = NULL; + + if (rec->filename = getFontFilename(pFont)) + { + rec->font_type = getFontFileType(rec->filename); + } + else + { + rec->filename = NULL; + rec->font_type = PSFTI_FONT_TYPE_OTHER; + } + + rec->adobe_ps_name = PsGetPSFontName(pFont); +#ifdef XP_USE_FREETYPE + rec->ft_download_encoding = PsGetEncodingName(pFont); + rec->ft_download_font_type = PsGetFTDownloadFontType(); +#endif /* XP_USE_FREETYPE */ + rec->download_ps_name = NULL; + +#define SET_FONT_DOWNLOAD_STATUS(rec, downloaded) { int i; for (i = 0 ; i < 256 ; i++) { (rec)->alreadyDownloaded[i]=(downloaded); } } + + /* Set some flags based on the font type */ + switch( rec->font_type ) + { + case PSFTI_FONT_TYPE_PS_TYPE1_PFA: + case PSFTI_FONT_TYPE_PS_TYPE1_PFB: + rec->downloadableFont = True; + SET_FONT_DOWNLOAD_STATUS(rec, False); + rec->is_iso_encoding = PsIsISOLatin1Encoding(pFont); + break; + + case PSFTI_FONT_TYPE_PMF: + rec->downloadableFont = True; /* This font is in printer's ROM */ + SET_FONT_DOWNLOAD_STATUS(rec, True); + rec->is_iso_encoding = PsIsISOLatin1Encoding(pFont); + break; + + case PSFTI_FONT_TYPE_TRUETYPE: + /* Note: TrueType font download not implemented */ + rec->downloadableFont = False; + SET_FONT_DOWNLOAD_STATUS(rec, False); + rec->is_iso_encoding = PsIsISOLatin1Encoding(pFont); + break; + +#ifdef XP_USE_FREETYPE + case PSFTI_FONT_TYPE_FREETYPE: + if( rec->ft_download_font_type == PsFontType1 || + rec->ft_download_font_type == PsFontType3 ) + { + rec->downloadableFont = True; + } + else + { + rec->downloadableFont = False; + } + + SET_FONT_DOWNLOAD_STATUS(rec, False); + rec->is_iso_encoding = False; /* Freetype--->PS Type1/Type3 uses always non-iso PS encoding for now */ + break; +#endif /* XP_USE_FREETYPE */ + + case PSFTI_FONT_TYPE_OTHER: + default: + rec->downloadableFont = False; + SET_FONT_DOWNLOAD_STATUS(rec, False); + rec->is_iso_encoding = PsIsISOLatin1Encoding(pFont); + break; + } + +#ifdef XP_USE_FREETYPE + if( (rec->font_type == PSFTI_FONT_TYPE_FREETYPE) ) + { + char *s; + register int c; + + if( rec->adobe_ps_name ) + { + rec->download_ps_name = malloc(strlen(rec->adobe_ps_name) + strlen(rec->ft_download_encoding) + 2); + sprintf(rec->download_ps_name, "%s_%s", rec->adobe_ps_name, rec->ft_download_encoding); + } + else + { + /* Unfortunately not all TTF fonts have a PostScript font name (like + * Solaris TTF fonts in /usr/openwin/lib/locale/ko.UTF-8/X11/fonts/TrueType, + * /usr/openwin/lib/locale/ko/X11/fonts/TrueType) - in this case we + * have to generate a font name + */ + char ftfontname[64]; + static long myfontindex = 0L; + sprintf(ftfontname, "psfont_%lx", myfontindex++); + + rec->download_ps_name = malloc(strlen(ftfontname) + strlen(rec->ft_download_encoding) + 2); + sprintf(rec->download_ps_name, "%s_%s", ftfontname, rec->ft_download_encoding); + + fprintf(stderr, "PsCreateFontTypeInfoRec: Note: '%s' has no PS font name, using '%s' for now.\n", dlfnam, rec->download_ps_name); + } + + /* Make sure the font name we use for download is a valid PS font name */ + for( s = rec->download_ps_name ; *s != '\0'; s++ ) + { + c = *s; + + /* Check for allowed chars, invalid ones are replaced with a '_' + * (and check that the first char is not a digit) */ + if( !(isalnum(c) || c == '.' || c == '_' || c == '-') || (s==rec->download_ps_name && isdigit(c)) ) + { + *s = '_'; + } + } + } + else +#endif /* XP_USE_FREETYPE */ + { + if( rec->adobe_ps_name ) + { + rec->download_ps_name = strdup(rec->adobe_ps_name); + } + else + { + rec->download_ps_name = NULL; + } + } + + /* Safeguard - only treat font as downloadable when we have a PS font name!! */ + if (!rec->download_ps_name && rec->downloadableFont) + { + /* XXX: Log this message to the log when the logging service has been hook'ed up */ + fprintf(stderr, "PsCreateFontTypeInfoRec: Safeguard: No PS font name for '%s'!\n", dlfnam); + rec->downloadableFont = False; + } + +#ifdef DEBUG_gisburn + fprintf(stderr, "PsCreateFontTypeInfoRec: Created PsFontTypeInfoRec '%s' ('%s'/'%s')\n", + ((rec->filename) ?(rec->filename) :("<null>")), + ((rec->adobe_ps_name) ?(rec->adobe_ps_name):("<null>")), + ((rec->download_ps_name)?(rec->download_ps_name):("<null>"))); +#endif /* DEBUG_gisburn */ + + return rec; +} + +static +PsFontTypeInfoRec *PsGetFontTypeInfoRec(DrawablePtr pDrawable, FontPtr pFont) +{ + PsFontTypeInfoRec *rec; + char *dlfnam; + + if(!(dlfnam = PsGetFontName(pFont))) + return NULL; + + rec = PsFindFontTypeInfoRec(pDrawable, pFont); + if (rec) + return rec; + + rec = PsCreateFontTypeInfoRec(pDrawable, pFont); + if (!rec) + return NULL; + + PsAddFontTypeInfoRec(pDrawable, rec); + + return rec; +} + +static +void PsFreeFontTypeInfoRecords( PsContextPrivPtr priv ) +{ + PsFontTypeInfoRec *curr, *next; + curr = priv->fontTypeInfoRecords; + while( curr != NULL ) + { + if (curr->filename) + free(curr->filename); /* Free memory allocated by |strdup()| */ + + if (curr->download_ps_name) + free(curr->download_ps_name); + + next = curr->next; + xfree(curr); + curr = next; + } +} + +static +PsFontInfoRec *PsFindFontInfoRec(DrawablePtr pDrawable, FontPtr pFont) +{ + PsContextPrivRec *cPriv = PsGetPsContextPriv(pDrawable); + PsFontInfoRec *rec; + + if (!pFont) + return NULL; + + for( rec = cPriv->fontInfoRecords ; rec != NULL ; rec = rec->next ) + { + if ((rec->font == pFont) && + (rec->font_fontPrivate == pFont->fontPrivate)) + return rec; + } + + return NULL; +} + +static +void PsAddFontInfoRec(DrawablePtr pDrawable, PsFontInfoRec *add_rec) +{ + PsContextPrivRec *cPriv = PsGetPsContextPriv(pDrawable); + + /* ToDO: Always move the last used entry to the top that the list get's + * sorted in an efficient order... :-) */ + add_rec->next = cPriv->fontInfoRecords; + cPriv->fontInfoRecords = add_rec; +} + +static +PsFontInfoRec *PsCreateFontInfoRec(DrawablePtr pDrawable, FontPtr pFont) +{ + PsFontInfoRec *rec; + PsFontTypeInfoRec *ftir; + + if (!(ftir = PsGetFontTypeInfoRec(pDrawable, pFont))) + return NULL; + + if (!(rec = (PsFontInfoRec *)xalloc(sizeof(PsFontInfoRec)))) + return NULL; + memset(rec, 0, sizeof(PsFontInfoRec)); + + rec->font = pFont; + rec->font_fontPrivate = pFont->fontPrivate; + rec->ftir = ftir; + rec->next = NULL; + rec->dfl_name = PsGetFontName(pFont); + rec->size = PsGetFontSize(pFont, rec->mtx); + +#ifdef DEBUG_gisburn + fprintf(stderr, "PsCreateFontInfoRec: Created PsFontInfoRec '%s'\n", + ((rec->dfl_name)?(rec->dfl_name):("<null>"))); +#endif /* DEBUG_gisburn */ + + return rec; +} + +PsFontInfoRec *PsGetFontInfoRec(DrawablePtr pDrawable, FontPtr pFont) +{ + PsFontInfoRec *rec; + + rec = PsFindFontInfoRec(pDrawable, pFont); + if (rec) + return rec; + + rec = PsCreateFontInfoRec(pDrawable, pFont); + if (!rec) + return NULL; + + PsAddFontInfoRec(pDrawable, rec); + + return rec; +} + +void PsFreeFontInfoRecords( PsContextPrivPtr priv ) +{ + PsFontInfoRec *curr, *next; + curr = priv->fontInfoRecords; + while( curr != NULL ) + { + next = curr->next; + xfree(curr); + curr = next; + } + + PsFreeFontTypeInfoRecords(priv); + + priv->fontTypeInfoRecords = NULL; + priv->fontInfoRecords = NULL; +} diff --git a/Xprint/ps/PsGC.c b/Xprint/ps/PsGC.c index ea441cff5..78c83930d 100644 --- a/Xprint/ps/PsGC.c +++ b/Xprint/ps/PsGC.c @@ -57,7 +57,6 @@ in this Software without prior written authorization from The Open Group. * or other dealings in this Software without prior written authorization * from said copyright holders. */ -/* $XFree86: xc/programs/Xserver/Xprint/ps/PsGC.c,v 1.6tsi Exp $ */ /******************************************************************* ** @@ -157,13 +156,19 @@ PsGetDrawablePrivateStuff( if( pCon==NULL ) return FALSE; else { + Colormap c; + ColormapPtr cmap; + + c = wColormap((WindowPtr)pDrawable); + cmap = (ColormapPtr)LookupIDByType(c, RT_COLORMAP); + cPriv = pCon->devPrivates[PsContextPrivateIndex].ptr; sPriv = (PsScreenPrivPtr) pDrawable->pScreen->devPrivates[PsScreenPrivateIndex].ptr; *gc = cPriv->lastGC; *valid = cPriv->validGC; *psOut = cPriv->pPsOut; - *cMap = sPriv->CMap; + *cMap = cmap; return TRUE; } default: @@ -171,6 +176,26 @@ PsGetDrawablePrivateStuff( } } +PsContextPrivPtr +PsGetPsContextPriv( DrawablePtr pDrawable ) +{ + XpContextPtr pCon; + PsContextPrivPtr cPriv; + + switch(pDrawable->type) + { + case DRAWABLE_PIXMAP: + return FALSE; + case DRAWABLE_WINDOW: + pCon = PsGetContextFromWindow((WindowPtr)pDrawable); + if (pCon != NULL) + { + return pCon->devPrivates[PsContextPrivateIndex].ptr; + } + } + return NULL; +} + int PsUpdateDrawableGC( GCPtr pGC, @@ -181,6 +206,7 @@ PsUpdateDrawableGC( GC dGC; unsigned long valid; int i; + PsContextPrivPtr cPriv; BoxPtr boxes; if (!PsGetDrawablePrivateStuff(pDrawable, &dGC, &valid, psOut, cMap)) @@ -232,6 +258,8 @@ PsUpdateDrawableGC( PsOut_Offset(*psOut, pDrawable->x, pDrawable->y); PsOut_Clip(*psOut, pGC->clientClipType, (PsClipPtr)pGC->clientClip); } + cPriv = ( PsGetContextFromWindow( (WindowPtr)pDrawable ) ) + ->devPrivates[PsContextPrivateIndex].ptr; break; } return TRUE; diff --git a/Xprint/ps/PsInit.c b/Xprint/ps/PsInit.c index a7a63343d..f2e064921 100644 --- a/Xprint/ps/PsInit.c +++ b/Xprint/ps/PsInit.c @@ -71,9 +71,8 @@ in this Software without prior written authorization from The Open Group. ** * Copyright: Copyright 1996 The Open Group, Inc. ** * ** ********************************************************* -** +** ********************************************************************/ -/* $XFree86: xc/programs/Xserver/Xprint/ps/PsInit.c,v 1.13tsi Exp $ */ #include <stdio.h> #include <string.h> @@ -84,6 +83,7 @@ in this Software without prior written authorization from The Open Group. #include "Ps.h" #include "mi.h" +#include "micmap.h" #include "AttrValid.h" #include "../../mfb/mfb.h" @@ -101,6 +101,10 @@ int PsContextPrivateIndex; int PsPixmapPrivateIndex; int PsWindowPrivateIndex; +#ifdef GLXEXT +extern void GlxWrapInitVisuals(miInitVisualsProcPtr *); +#endif /* GLXEXT */ + Bool InitializePsDriver(ndx, pScreen, argc, argv) int ndx; @@ -109,12 +113,18 @@ InitializePsDriver(ndx, pScreen, argc, argv) char **argv; { #if 0 + int maxXres, maxYres, maxWidth, maxHeight; + int maxRes, maxDim, numBytes; PsScreenPrivPtr pPriv; #endif + char **printerNames; + int numPrinters; int nVisuals; int nDepths; VisualPtr visuals; DepthPtr depths; + VisualID defaultVisual; + int rootDepth; /* * Register this driver's InitContext function with the print @@ -188,7 +198,7 @@ InitializePsDriver(ndx, pScreen, argc, argv) visuals[1].vid = FakeClientID(0); visuals[1].class = PseudoColor; - visuals[1].bitsPerRGBValue = 0; + visuals[1].bitsPerRGBValue = 8; visuals[1].ColormapEntries = 256; visuals[1].nplanes = 8; visuals[1].redMask = 0x0; @@ -200,27 +210,35 @@ InitializePsDriver(ndx, pScreen, argc, argv) depths[0].depth = 24; depths[0].numVids = 1; - depths[0].vids = &visuals[0].vid; + depths[0].vids = (VisualID *)xalloc(sizeof(VisualID)); + depths[0].vids[0] = visuals[0].vid; depths[1].depth = 8; depths[1].numVids = 1; - depths[1].vids = &visuals[1].vid; + depths[1].vids = (VisualID *)xalloc(sizeof(VisualID)); + depths[1].vids[0] = visuals[1].vid; -/* THE FOLLOWING CAUSES SERVER DEFAULT VISUAL TO BE 24 BIT */ -/* miScreenInit(pScreen, (pointer)0, - pScreen->width, pScreen->height, - pScreen->width / (pScreen->mmWidth / 25.40), - pScreen->height / (pScreen->mmHeight / 25.40), - 0, 24, nDepths, - depths, visuals[1].vid, nVisuals, visuals); */ + /* Defaul visual is 8bit PseudoColor */ + defaultVisual = visuals[1].vid; + rootDepth = visuals[1].nplanes; + +#ifdef GLXEXT + { + miInitVisualsProcPtr proc = NULL; + + GlxWrapInitVisuals(&proc); + /* GlxInitVisuals ignores the last three arguments. */ + proc(&visuals, &depths, &nVisuals, &nDepths, + &rootDepth, &defaultVisual, 0, 0, 0); + } +#endif /* GLXEXT */ -/* THE FOLLOWING CAUSES SERVER DEFAULT VISUAL TO BE 8 BIT */ miScreenInit(pScreen, (pointer)0, - pScreen->width, pScreen->height, - (int) (pScreen->width / (pScreen->mmWidth / 25.40)), - (int) (pScreen->height / (pScreen->mmHeight / 25.40)), - 0, 8, nDepths, - depths, visuals[1].vid, nVisuals, visuals); + pScreen->width, pScreen->height, + (int) (pScreen->width / (pScreen->mmWidth / 25.40)), + (int) (pScreen->height / (pScreen->mmHeight / 25.40)), + 0, rootDepth, nDepths, + depths, defaultVisual, nVisuals, visuals); if( cfbCreateDefColormap(pScreen)==FALSE ) return FALSE; @@ -243,7 +261,7 @@ AllocatePsPrivates(ScreenPtr pScreen) sizeof(PsWindowPrivRec)); PsContextPrivateIndex = XpAllocateContextPrivateIndex(); - XpAllocateContextPrivate(PsContextPrivateIndex, + XpAllocateContextPrivate(PsContextPrivateIndex, sizeof(PsContextPrivRec)); PsPixmapPrivateIndex = AllocatePixmapPrivateIndex(); @@ -278,7 +296,7 @@ PsInitContext(pCon) XpDriverFuncsPtr pFuncs; PsContextPrivPtr pConPriv; char *server, *attrStr; - + /* * Initialize the attribute store for this printer. */ @@ -304,18 +322,23 @@ PsInitContext(pCon) pFuncs->GetMediumDimensions = PsGetMediumDimensions; pFuncs->GetReproducibleArea = PsGetReproducibleArea; pFuncs->SetImageResolution = PsSetImageResolution; - + /* * Set up the context privates */ pConPriv = (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr; - pConPriv->jobFileName = (char *)NULL; - pConPriv->pJobFile = (FILE *)NULL; - - pConPriv->getDocClient = (ClientPtr)NULL; - pConPriv->getDocBufSize = 0; + memset(pConPriv, 0, sizeof(PsContextPrivRec)); + pConPriv->jobFileName = (char *)NULL; + pConPriv->pJobFile = (FILE *)NULL; + pConPriv->dash = (unsigned char *)NULL; + pConPriv->validGC = 0; + pConPriv->getDocClient = (ClientPtr)NULL; + pConPriv->getDocBufSize = 0; + pConPriv->pPsOut = NULL; + pConPriv->fontInfoRecords = NULL; + pConPriv->fontTypeInfoRecords = NULL; /* * document-attributes-supported @@ -323,15 +346,15 @@ PsInitContext(pCon) server = XpGetOneAttribute( pCon, XPServerAttr, DOC_ATT_SUPP ); if ((attrStr = (char *) xalloc(strlen(server) + strlen(DOC_ATT_SUPP) + strlen(DOC_ATT_VAL) - + strlen(PAGE_ATT_VAL) + 6)) == NULL) + + strlen(PAGE_ATT_VAL) + 6)) == NULL) { return BadAlloc; } - sprintf(attrStr, "*%s:\t%s %s %s", + sprintf(attrStr, "*%s:\t%s %s %s", DOC_ATT_SUPP, server, DOC_ATT_VAL, PAGE_ATT_VAL); XpAugmentAttributes( pCon, XPPrinterAttr, attrStr); xfree(attrStr); - + /* * job-attributes-supported */ @@ -344,7 +367,7 @@ PsInitContext(pCon) sprintf(attrStr, "*%s:\t%s %s", JOB_ATT_SUPP, server, JOB_ATT_VAL); XpAugmentAttributes(pCon, XPPrinterAttr, attrStr); xfree(attrStr); - + /* * xp-page-attributes-supported */ @@ -375,7 +398,7 @@ PsDestroyContext(pCon) { PsContextPrivPtr pConPriv = (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr; - + if( pConPriv->pJobFile!=(FILE *)NULL ) { fclose(pConPriv->pJobFile); @@ -388,6 +411,11 @@ PsDestroyContext(pCon) pConPriv->jobFileName = (char *)NULL; } + PsFreeFontInfoRecords(pConPriv); + + /* Reset context to make sure we do not use any stale/invalid/obsolete data */ + memset(pConPriv, 0, sizeof(PsContextPrivRec)); + /*### free up visuals/depths ###*/ return Success; diff --git a/Xprint/ps/PsLine.c b/Xprint/ps/PsLine.c index dd01fcb65..23e105804 100644 --- a/Xprint/ps/PsLine.c +++ b/Xprint/ps/PsLine.c @@ -73,7 +73,6 @@ in this Software without prior written authorization from The Open Group. ** ********************************************************* ** ********************************************************************/ -/* $XFree86: xc/programs/Xserver/Xprint/ps/PsLine.c,v 1.5 2001/01/17 22:36:32 dawes Exp $ */ #include "Ps.h" #include "gcstruct.h" diff --git a/Xprint/ps/PsMisc.c b/Xprint/ps/PsMisc.c index 3085888c7..86d862ce1 100644 --- a/Xprint/ps/PsMisc.c +++ b/Xprint/ps/PsMisc.c @@ -73,7 +73,6 @@ in this Software without prior written authorization from The Open Group. ** ********************************************************* ** ********************************************************************/ -/* $XFree86: xc/programs/Xserver/Xprint/ps/PsMisc.c,v 1.5 2001/01/17 22:36:32 dawes Exp $ */ #include "Xos.h" /* for SIGCLD on pre-POSIX systems */ #include <stdio.h> diff --git a/Xprint/ps/PsPixel.c b/Xprint/ps/PsPixel.c index 303b0d5ec..c2c360d2e 100644 --- a/Xprint/ps/PsPixel.c +++ b/Xprint/ps/PsPixel.c @@ -73,7 +73,6 @@ in this Software without prior written authorization from The Open Group. ** ********************************************************* ** ********************************************************************/ -/* $XFree86: xc/programs/Xserver/Xprint/ps/PsPixel.c,v 1.5 2001/01/17 22:36:32 dawes Exp $ */ #include <stdio.h> diff --git a/Xprint/ps/PsPixmap.c b/Xprint/ps/PsPixmap.c index a020aba22..616c2dbe8 100644 --- a/Xprint/ps/PsPixmap.c +++ b/Xprint/ps/PsPixmap.c @@ -57,7 +57,7 @@ in this Software without prior written authorization from The Open Group. * or other dealings in this Software without prior written authorization * from said copyright holders. */ -/* $XFree86: xc/programs/Xserver/Xprint/ps/PsPixmap.c,v 1.4 2001/01/17 22:36:32 dawes Exp $ */ + /******************************************************************* ** ** ********************************************************* @@ -79,6 +79,10 @@ in this Software without prior written authorization from The Open Group. #include "Ps.h" +#define _BitsPerPixel(d) (\ + (1 << PixmapWidthPaddingInfo[d].padBytesLog2) * 8 / \ + (PixmapWidthPaddingInfo[d].padRoundUp+1)) + PixmapPtr PsCreatePixmap( ScreenPtr pScreen, @@ -94,7 +98,7 @@ PsCreatePixmap( pPixmap->drawable.class = 0; pPixmap->drawable.pScreen = pScreen; pPixmap->drawable.depth = depth; - pPixmap->drawable.bitsPerPixel = BitsPerPixel(depth); + pPixmap->drawable.bitsPerPixel = _BitsPerPixel(depth); pPixmap->drawable.id = 0; pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER; pPixmap->drawable.x = 0; @@ -199,7 +203,7 @@ PsGetFreeDisplayBlock(PsPixmapPrivPtr priv) return(disp); } -static void +void PsReplay(DisplayElmPtr elm, DrawablePtr pDrawable) { switch(elm->type) @@ -488,8 +492,6 @@ PsCreateFillElementList(PixmapPtr pix, int *nElms) case PolyFillArcCmd: *nElms += elm->c.arcs.nArcs; break; - default: - break; } } } @@ -552,8 +554,6 @@ PsCreateFillElementList(PixmapPtr pix, int *nElms) *nElms += 1; } break; - default: - break; } } } diff --git a/Xprint/ps/PsPolygon.c b/Xprint/ps/PsPolygon.c index d334c7778..a5b373775 100644 --- a/Xprint/ps/PsPolygon.c +++ b/Xprint/ps/PsPolygon.c @@ -73,7 +73,6 @@ in this Software without prior written authorization from The Open Group. ** ********************************************************* ** ********************************************************************/ -/* $XFree86: xc/programs/Xserver/Xprint/ps/PsPolygon.c,v 1.6 2001/01/17 22:36:32 dawes Exp $ */ #include "Ps.h" #include "gcstruct.h" @@ -176,7 +175,8 @@ PsFillPolygon( } else { - pts[0].x = pPoints[0].x; pts[0].y = pPoints[0].y; + i = 0; + pts[0].x = pPoints[i].x; pts[0].y = pPoints[i].y; for( i=1 ; i<nPoints ; i++ ) { pts[i].x = pts[i-1].x+pPoints[i].x; diff --git a/Xprint/ps/PsPrint.c b/Xprint/ps/PsPrint.c index 5e549836f..f0356d705 100644 --- a/Xprint/ps/PsPrint.c +++ b/Xprint/ps/PsPrint.c @@ -73,7 +73,6 @@ in this Software without prior written authorization from The Open Group. ** ********************************************************* ** ********************************************************************/ -/* $XFree86: xc/programs/Xserver/Xprint/ps/PsPrint.c,v 1.10 2001/12/14 19:59:17 dawes Exp $ */ #include <stdio.h> #include <string.h> @@ -91,6 +90,7 @@ in this Software without prior written authorization from The Open Group. #include "Ps.h" #include "windowstr.h" +#include "attributes.h" #include "Oid.h" /* static utility function to get document/page attributes */ @@ -206,6 +206,8 @@ PsEndJob( unlink(priv->jobFileName); xfree(priv->jobFileName); priv->jobFileName = (char *)NULL; + + PsFreeFontInfoRecords(priv); return Success; } @@ -214,6 +216,7 @@ PsEndJob( * Append any trailing information here */ PsOut_EndFile(priv->pPsOut, 0); + priv->pPsOut = NULL; /* this is where we find out if we're out of space */ error = (fclose(priv->pJobFile) == EOF); @@ -233,6 +236,8 @@ PsEndJob( xfree(priv->jobFileName); priv->jobFileName = (char *)NULL; + PsFreeFontInfoRecords(priv); + return BadAlloc; } @@ -265,10 +270,12 @@ PsEndJob( xfree(priv->jobFileName); priv->jobFileName = (char *)NULL; + PsFreeFontInfoRecords(priv); + #ifdef BM_CACHE PsBmClearImageCache(); #endif - + return r; } @@ -281,10 +288,13 @@ PsStartPage( { int iorient, iplex, icount, ires; unsigned short iwd, iht; + register WindowPtr pChild; PsContextPrivPtr pConPriv = (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr; PsWindowPrivPtr pWinPriv = (PsWindowPrivPtr)pWin->devPrivates[PsWindowPrivateIndex].ptr; + char s[80]; + xEvent event; /* * Put a pointer to the context in the window private structure @@ -298,9 +308,16 @@ PsStartPage( * Start the page */ if (pConPriv->pPsOut == NULL) { - pConPriv->pPsOut = PsOut_BeginFile(pConPriv->pJobFile, - iorient, icount, iplex, ires, - (int)iwd, (int)iht, False); + char *title; + + /* get job level attributes */ + title = XpGetOneAttribute(pCon, XPJobAttr, "job-name"); + + pConPriv->pPsOut = PsOut_BeginFile(pConPriv->pJobFile, + title, iorient, icount, iplex, ires, + (int)iwd, (int)iht, False); + pConPriv->fontInfoRecords = NULL; + pConPriv->fontTypeInfoRecords = NULL; } PsOut_BeginPage(pConPriv->pPsOut, iorient, icount, iplex, ires, (int)iwd, (int)iht); @@ -348,15 +365,22 @@ PsStartDoc(XpContextPtr pCon, XPDocumentType type) { int iorient, iplex, icount, ires; unsigned short iwd, iht; + char *title; PsContextPrivPtr pConPriv = (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr; + /* get job level attributes */ + title = XpGetOneAttribute(pCon, XPJobAttr, "job-name"); + /* get document level attributes */ S_GetPageAttributes(pCon,&iorient,&icount,&iplex,&ires,&iwd,&iht); pConPriv->pPsOut = PsOut_BeginFile(pConPriv->pJobFile, - iorient, icount, iplex, ires, - (int)iwd, (int)iht, (type == XPDocRaw)); + title, iorient, icount, iplex, ires, + (int)iwd, (int)iht, (Bool)(type == XPDocRaw)); + + pConPriv->fontInfoRecords = NULL; + pConPriv->fontTypeInfoRecords = NULL; return Success; } @@ -391,8 +415,11 @@ PsDocumentData( PsContextPrivPtr cPriv; PsOutPtr psOut; - if (len_fmt != 12 || !strcmp(pFmt, "PostScript 2") || len_opt) + if (len_fmt != 12 || + strncasecmp(pFmt, "PostScript 2", len_fmt) != 0 || + len_opt) return BadValue; + cPriv = pCon->devPrivates[PsContextPrivateIndex].ptr; psOut = cPriv->pPsOut; diff --git a/Xprint/ps/PsText.c b/Xprint/ps/PsText.c index ae44b3f1c..8bb0b0fb2 100644 --- a/Xprint/ps/PsText.c +++ b/Xprint/ps/PsText.c @@ -73,49 +73,13 @@ in this Software without prior written authorization from The Open Group. ** ********************************************************* ** ********************************************************************/ -/* $XFree86: xc/programs/Xserver/Xprint/ps/PsText.c,v 1.12tsi Exp $ */ #include "Ps.h" #include "gcstruct.h" #include "windowstr.h" +#include "fntfil.h" #include "fntfilst.h" -#include <sys/stat.h> - -static int readFontName(char *fileName, char *file_name, char *dlfnam) -{ - FILE *file; - struct stat statb; - char buf[256]; - char *front, *fn; - - file = fopen(fileName, "r"); - if(file) - { - if (fstat (fileno(file), &statb) == -1) - return 0; - while(fgets(buf, 255, file)) - { - if((fn = strstr(buf, " -"))) - { - strcpy(file_name, buf); - file_name[fn - buf - 4] = '\0'; - fn++; - if((front = strstr(fn, "normal-"))) - { - fn[front - fn] = '\0'; - if(strstr(dlfnam, fn)) - { - fclose(file); - return 1; - } - } - } - } - } - file_name[0] = '\0'; - fclose(file); - return 0; -} +#include <limits.h> int PsPolyText8( @@ -147,70 +111,97 @@ PsPolyText8( elm->c.text8.string = (char *)xalloc(count); memcpy(elm->c.text8.string, string, count); disp->nelms += 1; + + return x; } else { - char *fnam, ffname[512], *dlfnam; - FontDirectoryPtr dir; - char file_name[MAXFONTNAMELEN]; - - dir = pGC->font->fpe->private; - sprintf(ffname, "%s%s", dir->directory, "fonts.dir"); - - fnam = PsGetPSFontName(pGC->font); - if(!fnam){ - if(!(dlfnam = PsGetFontName(pGC->font))) - return x; - /* If Type1 font, try to download to printer first */ - if(strstr(ffname, "Type1") && readFontName(ffname, file_name, dlfnam)) - { - int siz; - float mtx[4]; - PsOutPtr psOut; - ColormapPtr cMap; - - if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) - return x; - sprintf(ffname, "%s%s%s", dir->directory, file_name, ".pfa"); - PsOut_DownloadType1(psOut, file_name, ffname); - PsOut_Offset(psOut, pDrawable->x, pDrawable->y); - PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel)); - siz = PsGetFontSize(pGC->font, mtx); - if( !siz ) PsOut_TextAttrsMtx(psOut, file_name, mtx, 1); - else PsOut_TextAttrs(psOut, file_name, siz, 1); - PsOut_Text(psOut, x, y, string, count, -1); - return x; - } - { - unsigned long n, i; - int w; - CharInfoPtr charinfo[255]; - - GetGlyphs(pGC->font, (unsigned long)count, - (unsigned char *)string, Linear8Bit,&n, charinfo); - w = 0; - for (i=0; i < n; i++) w += charinfo[i]->metrics.characterWidth; - if (n != 0) - PsPolyGlyphBlt(pDrawable, pGC, x, y, n, - charinfo, FONTGLYPHS(pGC->font)); - x += w; - } - }else{ - int iso; - int siz; - float mtx[4]; - PsOutPtr psOut; - ColormapPtr cMap; - - if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return x; - PsOut_Offset(psOut, pDrawable->x, pDrawable->y); - PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel)); - siz = PsGetFontSize(pGC->font, mtx); - iso = PsIsISOLatin1Encoding(pGC->font); - if( !siz ) PsOut_TextAttrsMtx(psOut, fnam, mtx, iso); - else PsOut_TextAttrs(psOut, fnam, siz, iso); - PsOut_Text(psOut, x, y, string, count, -1); + PsFontInfoRec *firec; + + /* We need a context for rendering... */ + if (PsGetPsContextPriv(pDrawable) == NULL) + return x; + + firec = PsGetFontInfoRec(pDrawable, pGC->font); + if (!firec) + return x; + +#ifdef XP_USE_FREETYPE + if (firec->ftir->downloadableFont && + (firec->ftir->font_type == PSFTI_FONT_TYPE_FREETYPE)) + { + PsOutPtr psOut; + ColormapPtr cMap; + + if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) + return x; + + if (firec->ftir->alreadyDownloaded[0] == False) + { + PsOut_DownloadFreeType(psOut, + firec->ftir->ft_download_font_type, + firec->ftir->download_ps_name, pGC->font, 0); + firec->ftir->alreadyDownloaded[0] = True; + } + + PsOut_Offset(psOut, pDrawable->x, pDrawable->y); + PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel)); + if (!firec->size) + PsOut_TextAttrsMtx(psOut, firec->ftir->download_ps_name, firec->mtx, firec->ftir->is_iso_encoding); + else + PsOut_TextAttrs(psOut, firec->ftir->download_ps_name, firec->size, firec->ftir->is_iso_encoding); + PsOut_FreeType_Text(pGC->font, psOut, x, y, string, count); + + return x; } + else +#endif /* XP_USE_FREETYPE */ + if (firec->ftir->downloadableFont && + (firec->ftir->font_type != PSFTI_FONT_TYPE_FREETYPE)) + { + PsOutPtr psOut; + ColormapPtr cMap; + + if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) + return x; + + if (firec->ftir->alreadyDownloaded[0] == False) + { + PsOut_DownloadType1(psOut, "PsPolyText8", + firec->ftir->download_ps_name, firec->ftir->filename); + firec->ftir->alreadyDownloaded[0] = True; + } + + PsOut_Offset(psOut, pDrawable->x, pDrawable->y); + PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel)); + if (!firec->size) + PsOut_TextAttrsMtx(psOut, firec->ftir->download_ps_name, firec->mtx, firec->ftir->is_iso_encoding); + else + PsOut_TextAttrs(psOut, firec->ftir->download_ps_name, firec->size, firec->ftir->is_iso_encoding); + PsOut_Text(psOut, x, y, string, count, -1); + + return x; + } + + /* Render glyphs as bitmaps */ + { + unsigned long n, i; + int w; + CharInfoPtr charinfo[255]; + + GetGlyphs(pGC->font, (unsigned long)count, + (unsigned char *)string, Linear8Bit, &n, charinfo); + w = 0; + for (i=0; i < n; i++) + w += charinfo[i]->metrics.characterWidth; + + if (n != 0) + PsPolyGlyphBlt(pDrawable, pGC, x, y, n, + charinfo, FONTGLYPHS(pGC->font)); + x += w; + + return x; + } } return x; } @@ -246,21 +237,136 @@ PsPolyText16( (unsigned short *)xalloc(count*sizeof(unsigned short)); memcpy(elm->c.text16.string, string, count*sizeof(unsigned short)); disp->nelms += 1; + + return x; } else { - unsigned long n, i; - int w; - CharInfoPtr charinfo[255]; /* encoding only has 1 byte for count */ - - GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)string, - (FONTLASTROW(pGC->font) == 0) ? Linear16Bit : TwoD16Bit, - &n, charinfo); - w = 0; - for (i=0; i < n; i++) w += charinfo[i]->metrics.characterWidth; - if (n != 0) - PsPolyGlyphBlt(pDrawable, pGC, x, y, n, charinfo, FONTGLYPHS(pGC->font)); - x += w; + PsFontInfoRec *firec; + + /* We need a context for rendering... */ + if (PsGetPsContextPriv(pDrawable) == NULL) + return x; + + firec = PsGetFontInfoRec(pDrawable, pGC->font); + if (!firec) + return x; + +#ifdef XP_USE_FREETYPE + if (firec->ftir->downloadableFont && + (firec->ftir->font_type == PSFTI_FONT_TYPE_FREETYPE)) + { + PsOutPtr psOut; + ColormapPtr cMap; + unsigned short c, + c_hiByte, + c_lowByte, + fontPage; + int i; + + if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) + return x; + + /* Scan the string we want to render and download all neccesary parts + * of the font (one part(="font page") has 256 glyphs) + */ + for( i = 0 ; i < count ; i++ ) + { + c = string[i]; +#if IMAGE_BYTE_ORDER == LSBFirst + c_hiByte = c & 0x00FF; + c_lowByte = (c >> 8) & 0x00FF; +#elif IMAGE_BYTE_ORDER == MSBFirst + c_hiByte = (c >> 8) & 0x00FF; + c_lowByte = c & 0x00FF; +#else +#error Unsupported byte order +#endif + fontPage = c_hiByte; + + if (firec->ftir->alreadyDownloaded[fontPage] == False) + { + char buffer[256]; + const char *ps_name; + + if (fontPage > 0) + { + sprintf(buffer, "%s_%x", firec->ftir->download_ps_name, (int)fontPage); + ps_name = buffer; + } + else + { + ps_name = firec->ftir->download_ps_name; + } + + PsOut_DownloadFreeType(psOut, + firec->ftir->ft_download_font_type, + ps_name, pGC->font, (fontPage * 0x100)); /* same as (fontPage << 8) */ + + firec->ftir->alreadyDownloaded[fontPage] = True; + } + } + + + PsOut_Offset(psOut, pDrawable->x, pDrawable->y); + PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel)); + if (!firec->size) + PsOut_FreeType_TextAttrsMtx16(psOut, firec->ftir->download_ps_name, firec->mtx, firec->ftir->is_iso_encoding); + else + PsOut_FreeType_TextAttrs16(psOut, firec->ftir->download_ps_name, firec->size, firec->ftir->is_iso_encoding); + PsOut_FreeType_Text16(pGC->font, psOut, x, y, string, count); + + return x; + } + else +#endif /* XP_USE_FREETYPE */ + if (firec->ftir->downloadableFont && + (firec->ftir->font_type != PSFTI_FONT_TYPE_FREETYPE)) + { + PsOutPtr psOut; + ColormapPtr cMap; + unsigned short c, + c_hiByte, + c_lowByte, + fontPage; + int i; + + if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) + return x; + + PsOut_DownloadType1(psOut, "PsPolyText16", + firec->ftir->download_ps_name, firec->ftir->filename); + firec->ftir->alreadyDownloaded[fontPage] = True; + + PsOut_Offset(psOut, pDrawable->x, pDrawable->y); + PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel)); + if (!firec->size) + PsOut_TextAttrsMtx(psOut, firec->ftir->download_ps_name, firec->mtx, firec->ftir->is_iso_encoding); + else + PsOut_TextAttrs(psOut, firec->ftir->download_ps_name, firec->size, firec->ftir->is_iso_encoding); + PsOut_Text16(psOut, x, y, string, count, -1); + + return x; + } + + /* Render glyphs as bitmaps */ + { + unsigned long n, i; + int w; + CharInfoPtr charinfo[255]; /* encoding only has 1 byte for count */ + + GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)string, + (FONTLASTROW(pGC->font) == 0) ? Linear16Bit : TwoD16Bit, + &n, charinfo); + w = 0; + for (i=0; i < n; i++) + w += charinfo[i]->metrics.characterWidth; + if (n != 0) + PsPolyGlyphBlt(pDrawable, pGC, x, y, n, charinfo, FONTGLYPHS(pGC->font)); + x += w; + + return x; + } } return x; } @@ -386,7 +492,7 @@ PsPolyGlyphBlt( pointer pGlyphBase) { int width, height; - PixmapPtr pPixmap = NullPixmap; + PixmapPtr pPixmap; int nbyLine; /* bytes per line of padded pixmap */ FontPtr pfont; GCPtr pGCtmp; @@ -399,7 +505,7 @@ PsPolyGlyphBlt( int gWidth, gHeight; /* width and height of glyph */ register int nbyGlyphWidth; /* bytes per scanline of glyph */ int nbyPadGlyph; /* server padded line of glyph */ - int w; + int w, tmpx; XID gcvals[3]; pfont = pGC->font; @@ -435,6 +541,7 @@ PsPolyGlyphBlt( PsDestroyPixmap(pPixmap); return; } + tmpx = 0; while(nGlyphs--) { pci = *pCharInfo++; @@ -466,8 +573,9 @@ PsPolyGlyphBlt( 1, x + pci->metrics.leftSideBearing, y - pci->metrics.ascent, gWidth, gHeight, 0, XYBitmap, (char *)pb); - x += pci->metrics.characterWidth; } + + x += pci->metrics.characterWidth; } DEALLOCATE_LOCAL(pbits); FreeScratchGC(pGCtmp); diff --git a/Xprint/ps/PsWindow.c b/Xprint/ps/PsWindow.c index 987d434ff..3a9a7ed2a 100644 --- a/Xprint/ps/PsWindow.c +++ b/Xprint/ps/PsWindow.c @@ -73,11 +73,9 @@ in this Software without prior written authorization from The Open Group. ** ********************************************************* ** ********************************************************************/ -/* $XFree86: xc/programs/Xserver/Xprint/ps/PsWindow.c,v 1.12tsi Exp $ */ #include <stdio.h> #include <string.h> -#include <sys/types.h> #include <sys/wait.h> #include "mistruct.h" @@ -87,7 +85,8 @@ in this Software without prior written authorization from The Open Group. #include "Ps.h" -#if 0 +extern WindowPtr *WindowTable; + /* * The following list of strings defines the properties which will be * placed on the screen's root window if the property was defined in @@ -104,7 +103,7 @@ static char *propStrings[] = { DT_PRINT_PAGE_COMMAND, (char *)NULL }; -#endif + /* * PsCreateWindow - watch for the creation of the root window. @@ -219,6 +218,8 @@ PsPaintWindow( RegionPtr pRegion, int what) { + int status; + WindowPtr pRoot; #define FUNCTION 0 #define FOREGROUND 1 @@ -298,6 +299,7 @@ PsPaintWindow( gcmask |= GCFunction | GCClipMask; i = pScreen->myNum; + pRoot = WindowTable[i]; pBgWin = pWin; if (what == PW_BORDER) @@ -375,14 +377,14 @@ PsPaintWindow( } break; case GCClipMask: - if( (pointer)(long)pGC->clientClipType!=(pointer)CT_NONE ) + if( (pointer)pGC->clientClipType!=(pointer)CT_NONE ) { gcmask |= index; gcval[i++] = (pointer)CT_NONE; } break; case GCSubwindowMode: - if( (pointer)(long)pGC->subWindowMode!=newValues[SUBWINDOW] ) + if( (pointer)pGC->subWindowMode!=newValues[SUBWINDOW] ) { gcmask |= index; gcval[i++] = newValues[SUBWINDOW]; @@ -396,7 +398,7 @@ PsPaintWindow( } break; case GCFillStyle: - if( (pointer)(long)pGC->fillStyle!=newValues[FILLSTYLE] ) + if( (pointer)pGC->fillStyle!=newValues[FILLSTYLE] ) { gcmask |= index; gcval[i++] = newValues[FILLSTYLE]; diff --git a/Xprint/ps/psout.c b/Xprint/ps/psout.c index 6b4c71a2b..d66374a4c 100644 --- a/Xprint/ps/psout.c +++ b/Xprint/ps/psout.c @@ -73,79 +73,21 @@ in this Software without prior written authorization from The Open Group. ** ********************************************************* ** ********************************************************************/ -/* $XFree86: xc/programs/Xserver/Xprint/ps/psout.c,v 1.11 2001/12/19 21:55:59 dawes Exp $ */ - -/* - * For XFree86 3.3.3: - * - * As a *quick* way of preventing some buffers overflowing onto the stack, - * they have been made static. There are potential problems with - * PsOutRec.Buf overflowing too which should be investigated as part of a - * review of this code, but that is at least always allocated with malloc - * and shouldn't pose an immediate stack trashing problem. - * - */ #include <stdlib.h> +#include <stdio.h> #include "os.h" -#include "Ps.h" +#define USE_PSOUT_PRIVATE 1 #include "psout.h" +#ifdef XP_USE_FREETYPE +#include <ft2build.h> +#include FT_FREETYPE_H +#endif /* XP_USE_FREETYPE */ +/* For VENDOR_STRING and VENDOR_RELEASE */ +#include "site.h" -typedef void *voidPtr; - -typedef struct PsPatRec_ -{ - PsFillEnum type; - voidPtr tag; -} PsPatRec; - -typedef PsPatRec *PsPatPtr; - -typedef struct PsOutRec_ -{ - FILE *Fp; - char Buf[256]; - int CurColor; - int LineWidth; - PsCapEnum LineCap; - PsJoinEnum LineJoin; - int NDashes; - int *Dashes; - int DashOffset; - int LineBClr; - PsRuleEnum FillRule; - char *FontName; - int FontSize; - float FontMtx[4]; - int ImageFormat; - int RevImage; - int NPatterns; - int MxPatterns; - PsPatPtr Patterns; - int ClipType; - PsClipRec Clip; - int InFrame; - int XOff; - int YOff; - - PsFillEnum InTile; - int ImgSkip; - int ImgBClr; - int ImgFClr; - int ImgX; - int ImgY; - int ImgW; - int ImgH; - int SclW; - int SclH; - - int NDownloads; - int MxDownloads; - char **Downloads; - Bool isRaw; - - int start_image; -} PsOutRec; +extern PsElmPtr PsCloneFillElementList(int nElms, PsElmPtr elms); +extern void PsDestroyFillElementList(int nElms, PsElmPtr elms); /* * Standard definitions @@ -174,6 +116,7 @@ static char *S_StandardDefs = "\ /ie{ifelse}bd\ /len{length}bd\ /m{moveto}bd\ +/rm{rmoveto}bd\ /l{lineto}bd\ /rl{rlineto}bd\ /a{arc}bd\ @@ -236,7 +179,11 @@ static char *S_StandardDefs = "\ /mp{makepattern}bd\ /spt{setpattern}bd\ /spd{setpagedevice}bd\ -"; +" +#ifdef XP_USE_FREETYPE +"/trmoveto{currentfont /FontMatrix get transform rm}d" +#endif /* XP_USE_FREETYPE */ +; /* * Composite definitions @@ -341,7 +288,6 @@ static char *S_CompositeDefs = "\ /mtx{scl t [3 i 0 0 5 i 0 0]}bd \ "; -int pagenum = 0; char *pg_orient[] = {"Portrait","Landscape","Reverse Portrait","Reverse Landscape"}; /* * Setup definitions @@ -360,7 +306,7 @@ static char *S_SetupDefs = "\ * PRIVATE FUNCTIONS * *******************************************************************/ -static void +void S_Flush(PsOutPtr self) { if( self->Buf[0] ) @@ -388,7 +334,7 @@ S_OutDefs(PsOutPtr self, char *defs) { int i, k=0; S_Flush(self); - memset(self->Buf, 0, 256); + memset(self->Buf, 0, sizeof(self->Buf)); for( i=0 ; defs[i]!='\0' ;) { if( k>70 && (i==0 || (i && defs[i-1]!='/')) && @@ -396,7 +342,7 @@ S_OutDefs(PsOutPtr self, char *defs) { S_Flush(self); k = 0; - memset(self->Buf, 0, 256); + memset(self->Buf, 0, sizeof(self->Buf)); } if( k && self->Buf[k-1]==' ' && defs[i]==' ' ) { i++; continue; } self->Buf[k] = defs[i]; @@ -405,11 +351,11 @@ S_OutDefs(PsOutPtr self, char *defs) S_Flush(self); } -static void +void S_OutNum(PsOutPtr self, float num) { int i; - static char buf[64]; + char buf[64]; sprintf(buf, "%.3f", num); for( i=strlen(buf)-1 ; buf[i]=='0' ; i-- ); buf[i+1] = '\0'; if( buf[strlen(buf)-1]=='.' ) buf[strlen(buf)-1] = '\0'; @@ -422,7 +368,7 @@ static void S_OutStr(PsOutPtr self, char *txt, int txtl) { int i, k; - static char buf[512]; + char buf[1024]; for( i=0,k=0 ; i<txtl ; i++ ) { if( (txt[i]>=' ' && txt[i]<='~') && @@ -430,7 +376,9 @@ S_OutStr(PsOutPtr self, char *txt, int txtl) { buf[k] = txt[i]; k++; continue; } buf[k] = '\\'; k++; sprintf(&buf[k], "%03o", txt[i]&0xFF); - k += 3; + /* Skip to the end of the buffer */ + while( buf[k] != '\0' ) + k++; } strcat(self->Buf, "("); i = strlen(self->Buf); @@ -440,7 +388,32 @@ S_OutStr(PsOutPtr self, char *txt, int txtl) if( strlen(self->Buf)>70 ) S_Flush(self); } +/* Same as S_OutStr() but takes |short *| instead of |char *| */ static void +S_OutStr16(PsOutPtr self, unsigned short *txt, int txtl) +{ + int i, k; + char buf[2048]; + for( i=0,k=0 ; i<txtl ; i++ ) + { + if( (txt[i]>=' ' && txt[i]<='~') && + txt[i]!='(' && txt[i]!=')' && txt[i]!='\\' ) + { buf[k] = txt[i]; k++; continue; } + buf[k] = '\\'; k++; + sprintf(&buf[k], "%03o", txt[i]&0xFFFF); + /* Skip to the end of the buffer */ + while( buf[k] != '\0' ) + k++; + } + strcat(self->Buf, "("); + i = strlen(self->Buf); + memcpy(&self->Buf[i], buf, k); + self->Buf[i+k] = '\0'; + strcat(self->Buf, ")"); + if( strlen(self->Buf)>70 ) S_Flush(self); +} + +void S_OutTok(PsOutPtr self, char *tok, int cr) { if( self->Buf[0] ) strcat(self->Buf, " "); @@ -471,6 +444,27 @@ S_SetPageDevice(PsOutPtr self, int orient, int count, int plex, int res, float fwd = ((float)wd/(float)res)*72.; float fht = ((float)ht/(float)res)*72.; +#define USE_WORKAROUND_COPY_COUNT_BUG 1 + +#ifdef USE_WORKAROUND_COPY_COUNT_BUG + /* Workaround (see http://xprint.mozdev.org/bugs/show_bug.cgi?id=1861 - + * 'Need workaround for bug 1378 ...') to avoid that we print n^2 copies + * instead of n copies. + * The problem is that we use both /NumCopies here but pass the + * %copy-count% to the spooler, too. + * But we only have to use _one_ way... + * + * The final fix for bug 1378 (http://xprint.mozdev.org/bugs/show_bug.cgi?id=1378 - + * "PS DDX creates n^2 copies of a job instead of n copies") will back this + * workaround out and replace it with a better solution. + * (see mozilla.org bug 140030 + * (http://bugzilla.mozilla.org/show_bug.cgi?id=140030 - "Setting number + * of copies causes too many copies to print") for the initial report for + * this issue...) + */ + count = 1; +#endif /* USE_WORKAROUND_COPY_COUNT_BUG */ + S_OutTok(self, "/pWd", 0); S_OutNum(self, fwd); S_OutTok(self, "d /pHt", 0); @@ -577,10 +571,11 @@ PsOut_ChangeFile(PsOutPtr self, FILE *fp) } PsOutPtr -PsOut_BeginFile(FILE *fp, int orient, int count, int plex, int res, +PsOut_BeginFile(FILE *fp, char *title, int orient, int count, int plex, int res, int wd, int ht, Bool raw) { int i; + char buffer[256+32]; /* enougth space for a title with 256 chars... */ /* * Get ready to output PostScript header */ @@ -589,15 +584,41 @@ PsOut_BeginFile(FILE *fp, int orient, int count, int plex, int res, memset(psout, 0, sizeof(PsOutRec)); psout->Fp = fp; psout->isRaw = raw; - pagenum = 0; + psout->pagenum = 0; if (!raw) { /* * Output PostScript header */ - S_Comment(psout, "%!PS-Adobe-3.0 EPSF-3.0"); - S_Comment(psout, "%%Creator: The Open Group PostScript Print Server"); - /*### BoundingBox ###*/ + /* GhostScript will rant about the missing BoundingBox if we use + * "%!PS-Adobe-3.0 EPSF-3.0" here... */ + S_Comment(psout, "%!PS-Adobe-3.0"); +#ifdef XP_USE_FREETYPE + { + FT_Int ftmajor = 0, + ftminor = 0, + ftpatch = 0; + extern FT_Library ftypeLibrary; /* defined in xc/lib/font/FreeType/ftfuncs.c */ + + FT_Library_Version(ftypeLibrary, &ftmajor, &ftminor, &ftpatch); + sprintf(buffer, + "%%%%Creator: The X Print Server's PostScript DDX " + "(%s, release %d, FreeType version %d.%d.%d)", + VENDOR_STRING, VENDOR_RELEASE, + (int)ftmajor, (int)ftminor, (int)ftpatch); + } +#else + sprintf(buffer, + "%%%%Creator: The X Print Server's PostScript DDX (%s, release %d)", + VENDOR_STRING, VENDOR_RELEASE); +#endif /* XP_USE_FREETYPE */ + S_Comment(psout, buffer); + + if (title) + { + sprintf(buffer, "%%%%Title: %.256s", title); + S_Comment(psout, buffer); + } S_Comment(psout, "%%EndComments"); S_Comment(psout, "%%BeginProlog"); S_Comment(psout, "%%BeginProcSet: XServer_PS_Functions"); @@ -634,10 +655,13 @@ PsOut_EndFile(PsOutPtr self, int closeFile) { char coms[50]; int i; + + if (!self) + return; if (!self->isRaw) { S_Comment(self,"%%Trailer"); - sprintf(coms,"%%%%Pages: %d",pagenum); + sprintf(coms,"%%%%Pages: %d", self->pagenum); S_Comment(self, coms); S_Comment(self, "%%EOF"); } @@ -646,9 +670,6 @@ PsOut_EndFile(PsOutPtr self, int closeFile) if( self->Patterns ) xfree(self->Patterns); if( self->Clip.rects ) xfree(self->Clip.rects); if( closeFile ) fclose(self->Fp); - for( i=0 ; i<self->NDownloads ; i++ ) xfree(self->Downloads[i]); - if( self->Downloads ) xfree(self->Downloads); - pagenum = 0; /* reset page num back to 0 */ xfree(self); } @@ -661,8 +682,8 @@ PsOut_BeginPage(PsOutPtr self, int orient, int count, int plex, int res, /*** comment for pagenumbers *****/ S_Comment(self,"%%PageHeader"); - pagenum++; - sprintf(coms,"%%%%Page: %d %d",pagenum,pagenum); + self->pagenum++; + sprintf(coms,"%%%%Page: %d %d", self->pagenum, self->pagenum); S_Comment(self, coms); sprintf(coms,"%%%%PageOrientation: %s",pg_orient[orient]); S_Comment(self, coms); @@ -959,7 +980,7 @@ void PsOut_TextAttrs(PsOutPtr self, char *fnam, int siz, int iso) { int i; - static char buf[256]; + char buf[256]; if( self->FontName && strcmp(fnam, self->FontName)==0 && siz==self->FontSize ) return; if( self->FontName ) xfree(self->FontName); @@ -979,7 +1000,7 @@ void PsOut_TextAttrsMtx(PsOutPtr self, char *fnam, float *mtx, int iso) { int i; - static char buf[256]; + char buf[256]; if( self->FontName && strcmp(fnam, self->FontName)==0 && mtx[0]==self->FontMtx[0] && mtx[1]==self->FontMtx[1] && mtx[2]==self->FontMtx[2] && mtx[3]==self->FontMtx[3] ) return; @@ -1171,6 +1192,30 @@ PsOut_Text(PsOutPtr self, int x, int y, char *text, int textl, int bclr) } } +void +PsOut_Text16(PsOutPtr self, int x, int y, unsigned short *text, int textl, int bclr) +{ + int xo = self->XOff; + int yo = self->YOff; + + if( self->InFrame || self->InTile ) xo = yo = 0; + x += xo; y += yo; + S_OutStr16(self, text, textl); + S_OutNum(self, (float)x); + S_OutNum(self, (float)y); + if( bclr<0 ) S_OutTok(self, "T", 1); + else + { + int ir = bclr>>16; + int ig = (bclr>>8)&0xFF; + int ib = bclr&0xFF; + S_OutNum(self, (float)ir/255.); + S_OutNum(self, (float)ig/255.); + S_OutNum(self, (float)ib/255.); + S_OutTok(self, "Tb", 1); + } +} + #ifdef BM_CACHE void /* new */ PsOut_ImageCache(PsOutPtr self, int x, int y, long cache_id, int bclr, int fclr) @@ -1181,7 +1226,7 @@ PsOut_ImageCache(PsOutPtr self, int x, int y, long cache_id, int bclr, int fclr) if( self->InFrame || self->InTile ) xo = yo = 0; x += xo; y += yo; - sprintf(cacheID, "c%ldi", cache_id); + sprintf(cacheID, "c%di", cache_id); S_OutNum(self, (float)x); S_OutNum(self, (float)y); @@ -1214,7 +1259,7 @@ PsOut_BeginImageCache(PsOutPtr self, long cache_id) { char cacheID[10]; - sprintf(cacheID, "/c%ldi {", cache_id); + sprintf(cacheID, "/c%di {", cache_id); S_OutTok(self, cacheID, 0); } /* new */ @@ -1225,7 +1270,7 @@ PsOut_EndImageCache(PsOutPtr self) S_OutTok(self, "}bd", 1); } /* new */ #endif - + void PsOut_BeginImage(PsOutPtr self, int bclr, int fclr, int x, int y, int w, int h, int sw, int sh, int format) @@ -1488,13 +1533,11 @@ PsOut_BeginPattern(PsOutPtr self, void *tag, int w, int h, PsFillEnum type, } self->Patterns[self->NPatterns].tag = tag; self->Patterns[self->NPatterns].type = type; - sprintf(key, "/ %ld", (long)tag); + sprintf(key, "/ %d", (int)tag); switch(type) { case PsTile: key[1] = 't'; break; case PsStip: key[1] = 's'; break; - case PsOpStip: key[1] = 'o'; break; - default: break; - } + case PsOpStip: key[1] = 'o'; break; } S_OutTok(self, key, 0); S_OutTok(self, "db/PatternType 1 d/PaintType 1 d", 0); S_OutTok(self, "/TilingType 1 d/BBox[0 0", 0); @@ -1535,13 +1578,11 @@ PsOut_SetPattern(PsOutPtr self, void *tag, PsFillEnum type) for( i=0 ; i<self->NPatterns ; i++ ) { if( tag==self->Patterns[i].tag && type==self->Patterns[i].type ) break; } if( i>=self->NPatterns ) return; - sprintf(key, " %ld", (long)tag); + sprintf(key, " %d", (int)tag); switch(type) { case PsTile: key[0] = 't'; break; case PsStip: key[0] = 's'; break; - case PsOpStip: key[0] = 'o'; break; - default: break; - } + case PsOpStip: key[0] = 'o'; break; } S_OutTok(self, key, 0); S_OutTok(self, "spt", 1); self->CurColor = 0xFFFFFFFF; @@ -1556,83 +1597,141 @@ PsOut_RawData(PsOutPtr self, char *data, int len) } } -void -PsOut_DownloadType1(PsOutPtr self, char *name, char *fname) +typedef enum PsDownfontFontType_ +{ + PsDFT_Type1PFA=0, + PsDFT_Type1PFB, + PsDFT_TrueType /* not implemented yet */ +} PsDownfontFontType; + +/* Download a PS Type1 font */ +int +PsOut_DownloadType1(PsOutPtr self, const char *auditmsg, const char *name, const char *fname) { int i; int stt; - static char buf[256]; + char buf[256]; FILE *fp; + PsDownfontFontType type; + + fp = fopen(fname, "r"); + if( !fp ) + return 0; + +#ifdef DEBUG_gisburn + /* This should be log-able! */ + fprintf(stderr, "PsOut_DownloadType1: %s: Downloading '%s' from '%s'\n", auditmsg, name, fname); +#endif /* DEBUG_gisburn */ - for( i=0 ; i<self->NDownloads ; i++ ) - { if( strcmp(name, self->Downloads[i])==0 ) break; } - if( i<self->NDownloads ) return; + fread(buf, 32, 1, fp); + fseek(fp, (long)0, 0); - if( (self->NDownloads+1)>self->MxDownloads ) + /* Is this a Adobe PostScript Type 1 binary font (PFB) ? */ + if( (buf[0]&0xFF)==0x80 && (buf[1]&0xFF)==0x01 ) { - if( self->NDownloads ) - { - self->MxDownloads *= 2; - self->Downloads = (char **)xrealloc(self->Downloads, - self->MxDownloads*sizeof(char *)); - } - else - { - self->MxDownloads = 32; - self->Downloads = (char **)xalloc(self->MxDownloads*sizeof(char *)); - } + type = PsDFT_Type1PFB; + } + /* Is this a Adobe PostScript ASCII font (PFA) ? */ + else if (!strncmp(buf, "%!PS-AdobeFont", 14)) + { + type = PsDFT_Type1PFA; } - - self->Downloads[self->NDownloads] = (char *)xalloc(strlen(name)+1); - strcpy(self->Downloads[self->NDownloads], name); - self->NDownloads += 1; + else + { + /* This should be log-able! */ + fprintf(stderr, "PsOut_DownloadType1: Unknown font type for '%s'\n", fname); + return 0; + } S_Flush(self); sprintf(buf, "%%%%BeginFont: %s", name); S_Comment(self, buf); - fp = fopen(fname, "r"); - if( !fp ) return; - fread(buf, 1, 1, fp); - fseek(fp, (long)0, 0); - if( (buf[0]&0xFF)==0x80 ) - { - int len; - for(;;) + if( type == PsDFT_Type1PFB ) + { + char *buf, + *pt; + int len, + ch, + stype; + + ch = fgetc(fp); + /* Strip out the binary headers and de-binary it */ + while( (ch&0xFF) == 0x80 ) { - stt = fread(buf, 1, 2, fp); - if( stt!=2 || (buf[0]&0xFF)!=0x80 ) break; - if( (int)buf[1]<1 || (int)buf[1]>2 ) break; - stt = fread(buf, 1, 4, fp); - if( stt!=4 ) break; - len = ((buf[3]&0xFF)<<24)|((buf[2]&0xFF)<<16)| - ((buf[1]&0xFF)<<8)|(buf[0]&0xFF); - for(; len ;) + stype = fgetc(fp); + if( stype==3 ) /* eof mark */ + break; + len = fgetc(fp); + len |= fgetc(fp)<<8; + len |= fgetc(fp)<<16; + len |= fgetc(fp)<<24; + buf = (char *)xalloc(len+1); + if( stype==1 ) + { + /* Process ASCII section */ + len = fread(buf, 1, len, fp); + /* convert any lone CRs (ie Mac eol) to LFs */ + for( pt = buf ; (pt = memchr(pt, '\r', len-(pt-buf))) != NULL ; pt++ ) + { + if ( pt[1]!='\n' ) + *pt = '\n'; + } + fwrite(buf, 1, len, self->Fp); + } + else if( stype==2 ) { - i = len<256 ? len : 256; - stt = fread(buf, 1, i, fp); - if( stt<=0 ) break; - if (!ferror(self->Fp)) { - (void) fwrite(buf, 1, stt, self->Fp); - } - if( stt<i ) break; - len -= i; + int i; + + /* Process binary section */ + len = fread(buf, 1, len, fp); + for( i=0 ; i<len ; i++ ) + { + ch = buf[i]; + if( ((ch>>4)&0xf) <= 9 ) + fputc('0'+((ch>>4)&0xf), self->Fp); + else + fputc('A'-10+((ch>>4)&0xf), self->Fp); + + if( (ch&0xf) <= 9 ) + fputc('0'+(ch&0xf), self->Fp); + else + fputc('A'-10+(ch&0xf), self->Fp); + + if( (i&0x1f)==0x1f ) + fputc('\n', self->Fp); + } } + xfree(buf); + + /* Next block... */ + ch = fgetc(fp); } } - else + /* Is this a Adobe PostScript ASCII font (PFA) ? */ + else if (type == PsDFT_Type1PFA) { for(;;) { stt = fread(buf, 1, 256, fp); if( stt<=0 ) break; if (!ferror(self->Fp)) { - (void) fwrite(buf, 1, stt, self->Fp); + (void) fwrite(buf, 1, stt, self->Fp); } - if( stt<256 ) break; + if( stt<256 ) + break; } } fclose(fp); S_Flush(self); S_Comment(self, "%%EndFont"); + + /* Success... */ + return 1; } + + + + + + diff --git a/Xprint/ps/psout.h b/Xprint/ps/psout.h index 37b089ece..c592d7250 100644 --- a/Xprint/ps/psout.h +++ b/Xprint/ps/psout.h @@ -57,7 +57,6 @@ in this Software without prior written authorization from The Open Group. * or other dealings in this Software without prior written authorization * from said copyright holders. */ -/* $XFree86: xc/programs/Xserver/Xprint/ps/psout.h,v 1.4 2001/12/14 19:59:18 dawes Exp $ */ /******************************************************************* ** @@ -147,10 +146,80 @@ typedef struct PsClipRec_ typedef PsClipRec *PsClipPtr; +typedef enum PsFTDownloadFontType_ +{ + PsFontBitmap=0, + PsFontType1, + PsFontType3 +} PsFTDownloadFontType; + +#ifdef USE_PSOUT_PRIVATE +typedef void *voidPtr; + +typedef struct PsPatRec_ +{ + PsFillEnum type; + voidPtr tag; +} PsPatRec; + +typedef PsPatRec *PsPatPtr; + +typedef struct PsOutRec_ +{ + FILE *Fp; + char Buf[16384]; + int CurColor; + int LineWidth; + PsCapEnum LineCap; + PsJoinEnum LineJoin; + int NDashes; + int *Dashes; + int DashOffset; + int LineBClr; + PsRuleEnum FillRule; + char *FontName; + int FontSize; + float FontMtx[4]; + int ImageFormat; + int RevImage; + int NPatterns; + int MxPatterns; + PsPatPtr Patterns; + int ClipType; + PsClipRec Clip; + int InFrame; + int XOff; + int YOff; + + PsFillEnum InTile; + int ImgSkip; + int ImgBClr; + int ImgFClr; + int ImgX; + int ImgY; + int ImgW; + int ImgH; + int SclW; + int SclH; + + Bool isRaw; + + int pagenum; + + int start_image; +} PsOutRec; + typedef struct PsOutRec_ *PsOutPtr; -extern PsOutPtr PsOut_BeginFile(FILE *fp, int orient, int count, int plex, - int res, int wd, int ht, Bool raw); +extern void S_Flush(PsOutPtr self); +extern void S_OutNum(PsOutPtr self, float num); +extern void S_OutTok(PsOutPtr self, char *tok, int cr); +#else +typedef struct PsOutRec_ *PsOutPtr; +#endif /* USE_PSOUT_PRIVATE */ + +extern PsOutPtr PsOut_BeginFile(FILE *fp, char *title, int orient, int count, int plex, + int res, int wd, int ht, Bool raw); extern void PsOut_EndFile(PsOutPtr self, int closeFile); extern void PsOut_BeginPage(PsOutPtr self, int orient, int count, int plex, int res, int wd, int ht); @@ -182,8 +251,9 @@ extern void PsOut_DrawArc(PsOutPtr self, int x, int y, int w, int h, extern void PsOut_Text(PsOutPtr self, int x, int y, char *text, int textl, int bclr); +extern void PsOut_Text16(PsOutPtr self, int x, int y, unsigned short *text, int textl, int bclr); -extern void PsOut_BeginImage(PsOutPtr self, int bclr, int fclr, int x, int y, +extern void PsOut_BeginImage(PsOutPtr self, int bclr, int fclr, int x, int y, int w, int h, int sw, int sh, int format); extern void PsOut_BeginImageIM(PsOutPtr self, int bclr, int fclr, int x, int y, int w, int h, int sw, int sh, int format); @@ -200,16 +270,17 @@ extern void PsOut_EndPattern(PsOutPtr self); extern void PsOut_SetPattern(PsOutPtr self, void *tag, PsFillEnum type); extern void PsOut_RawData(PsOutPtr self, char *data, int len); -extern void PsOut_DownloadType1(PsOutPtr self, char *name, char *fname); -#ifdef BM_CACHE -extern void PsOut_BeginImageCache(PsOutPtr self, long cache_id); -extern void PsOut_EndImageCache(PsOutPtr self); -extern void PsOut_ImageCache(PsOutPtr self, int x, int y, long cache_id, - int bclr, int fclr); -#endif +extern int PsOut_DownloadType1(PsOutPtr self, const char *auditmsg, const char *name, const char *fname); -extern FILE *PsOut_ChangeFile(PsOutPtr self, FILE *fp); +extern int PsOut_DownloadFreeType1(PsOutPtr self, const char *psfontname, FontPtr pFont, long block_offset); +extern int PsOut_DownloadFreeType3(PsOutPtr self, const char *psfontname, FontPtr pFont, long block_offset); +extern int PsOut_DownloadFreeType(PsOutPtr self, PsFTDownloadFontType downloadfonttype, const char *psfontname, FontPtr pFont, long block_offset); +extern void PsOut_Get_FreeType_Glyph_Name( char *destbuf, FontPtr pFont, unsigned long x11fontindex); +extern void PsOut_FreeType_Text(FontPtr pFont, PsOutPtr self, int x, int y, char *text, int textl); +extern void PsOut_FreeType_Text16(FontPtr pFont, PsOutPtr self, int x, int y, unsigned short *text, int textl); +extern void PsOut_FreeType_TextAttrs16(PsOutPtr self, char *fnam, int siz, int iso); +extern void PsOut_FreeType_TextAttrsMtx16(PsOutPtr self, char *fnam, float *mtx, int iso); #endif diff --git a/Xprint/ps/ttf2pt1wrap.c b/Xprint/ps/ttf2pt1wrap.c new file mode 100644 index 000000000..bd5ef526e --- /dev/null +++ b/Xprint/ps/ttf2pt1wrap.c @@ -0,0 +1,10 @@ +/* + * Wrapper to add missing symbol to externally supplied code + */ + +#ifdef Lynx +extern int optind; +extern char *optarg; +#endif + +#include "ttf2pt1.c" diff --git a/Xprint/raster/Raster.h b/Xprint/raster/Raster.h index 750dc0722..9b335743f 100644 --- a/Xprint/raster/Raster.h +++ b/Xprint/raster/Raster.h @@ -30,8 +30,6 @@ not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from said copyright holders. */ -/* $XFree86: xc/programs/Xserver/Xprint/raster/Raster.h,v 1.3 2001/10/31 22:50:29 tsi Exp $ */ - /******************************************************************* ** ** ********************************************************* @@ -53,6 +51,7 @@ copyright holders. * Some sleazes to force the XrmDB stuff into the server */ #ifndef HAVE_XPointer +#define HAVE_XPointer 1 typedef char *XPointer; #endif #define Status int @@ -110,6 +109,6 @@ typedef struct { extern XpValidatePoolsRec RasterValidatePoolsRec; extern Bool InitializeRasterDriver(int ndx, ScreenPtr pScreen, int argc, - char **argv); + char **argv); #endif /* _RASTER_H_ */ diff --git a/cfb/cfbpntwin.c b/cfb/cfbpntwin.c index 88d8e0f07..91a6cd467 100644 --- a/cfb/cfbpntwin.c +++ b/cfb/cfbpntwin.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/cfb/cfbpntwin.c,v 1.1.4.4.2.2 2004/03/04 17:47:25 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/cfb/cfbpntwin.c,v 1.2 2004/04/23 19:00:12 eich Exp $ */ /* $Xorg: cfbpntwin.c,v 1.4 2001/02/09 02:04:38 xorgcvs Exp $ */ /*********************************************************** diff --git a/cfb/stipsparc.s b/cfb/stipsparc.s index a6a40491f..8ee5e2698 100644 --- a/cfb/stipsparc.s +++ b/cfb/stipsparc.s @@ -1,5 +1,6 @@ /* * $Xorg: stipsparc.s,v 1.4 2001/02/09 02:04:39 xorgcvs Exp $ + * $XdotOrg: xc/programs/Xserver/cfb/stipsparc.s,v 1.3 2004/04/26 02:39:58 alanc Exp $ * Copyright 1990, 1998 The Open Group @@ -101,9 +102,17 @@ in this Software without prior written authorization from The Open Group. .globl _cfbStippleStack _cfbStippleStack: save %sp,-64,%sp +#ifdef SHAREDCODE +1: + call 2f + nop +2: + mov %o7,sbase /* sbase = 1b(1:) */ + add sbase, CaseBegin-1b, sbase +#else /* !SHAREDCODE */ sethi %hi(CaseBegin),sbase /* load up switch table */ or sbase,%lo(CaseBegin),sbase - +#endif /* SHAREDCODE */ mov 4,lshift /* compute offset within */ sub lshift, shift, lshift /* stipple of remaining bits */ #ifdef LITTLE_ENDIAN diff --git a/cfb/stipsprc32.s b/cfb/stipsprc32.s index 5703c0f1b..59d953f3b 100644 --- a/cfb/stipsprc32.s +++ b/cfb/stipsprc32.s @@ -1,5 +1,6 @@ /* * $Xorg: stipsprc32.s,v 1.4 2001/02/09 02:04:39 xorgcvs Exp $ + * $XdotOrg: xc/programs/Xserver/cfb/stipsprc32.s,v 1.3 2004/04/26 02:39:58 alanc Exp $ * Copyright 1990, 1998 The Open Group @@ -98,9 +99,17 @@ in this Software without prior written authorization from The Open Group. .globl _cfb32StippleStack _cfb32StippleStack: save %sp,-64,%sp +#ifdef SHAREDCODE +1: + call 2f + nop +2: + mov %o7,sbase /* sbase = 1b(1:) */ + add sbase, CaseBegin-1b, sbase +#else /* !SHAREDCODE */ sethi %hi(CaseBegin),sbase /* load up switch table */ or sbase,%lo(CaseBegin),sbase - +#endif /* !SHAREDCODE */ mov 4,lshift /* compute offset within */ sub lshift, shift, lshift /* stipple of remaining bits */ #ifdef LITTLE_ENDIAN diff --git a/composite/compalloc.c b/composite/compalloc.c new file mode 100644 index 000000000..2e4eeb0c7 --- /dev/null +++ b/composite/compalloc.c @@ -0,0 +1,552 @@ +/* + * $Id$ + * + * Copyright © 2003 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 "compint.h" + +void +compReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure) +{ + WindowPtr pWin = (WindowPtr) closure; + ScreenPtr pScreen = pWin->drawable.pScreen; + CompScreenPtr cs = GetCompScreen (pScreen); + CompWindowPtr cw = GetCompWindow (pWin); + + cs->damaged = TRUE; + cw->damaged = TRUE; +} + +static void +compDestroyDamage (DamagePtr pDamage, void *closure) +{ + WindowPtr pWin = (WindowPtr) closure; + CompWindowPtr cw = GetCompWindow (pWin); + + cw->damage = 0; +} + +/* + * Redirect one window for one client + */ +int +compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update) +{ + CompWindowPtr cw = GetCompWindow (pWin); + CompClientWindowPtr ccw; + Bool wasMapped = pWin->mapped; + + /* + * Only one Manual update is allowed + */ + if (cw && update == CompositeRedirectManual) + for (ccw = cw->clients; ccw; ccw = ccw->next) + if (ccw->update == CompositeRedirectManual) + return BadAccess; + + /* + * Allocate per-client per-window structure + * The client *could* allocate multiple, but while supported, + * it is not expected to be common + */ + ccw = xalloc (sizeof (CompClientWindowRec)); + if (!ccw) + return BadAlloc; + ccw->id = FakeClientID (pClient->index); + ccw->update = update; + /* + * Now make sure there's a per-window structure to hang this from + */ + if (!cw) + { + cw = xalloc (sizeof (CompWindowRec)); + if (!cw) + { + xfree (ccw); + return BadAlloc; + } + cw->damage = DamageCreate (compReportDamage, + compDestroyDamage, + DamageReportNonEmpty, + FALSE, + pWin->drawable.pScreen, + pWin); + if (!cw->damage) + { + xfree (ccw); + xfree (cw); + return BadAlloc; + } + if (wasMapped) + UnmapWindow (pWin, FALSE); + + REGION_NULL (pScreen, &cw->borderClip); + cw->update = CompositeRedirectAutomatic; + cw->clients = 0; + cw->oldx = COMP_ORIGIN_INVALID; + cw->oldy = COMP_ORIGIN_INVALID; + cw->damageRegistered = FALSE; + cw->damaged = FALSE; + pWin->devPrivates[CompWindowPrivateIndex].ptr = cw; + } + ccw->next = cw->clients; + cw->clients = ccw; + if (!AddResource (ccw->id, CompositeClientWindowType, pWin)) + return BadAlloc; + if (ccw->update == CompositeRedirectManual) + { + if (cw->damageRegistered) + { + DamageUnregister (&pWin->drawable, cw->damage); + cw->damageRegistered = FALSE; + } + cw->update = CompositeRedirectManual; + } + + if (!compCheckRedirect (pWin)) + { + FreeResource (ccw->id, RT_NONE); + return BadAlloc; + } + if (wasMapped && !pWin->mapped) + { + Bool overrideRedirect = pWin->overrideRedirect; + pWin->overrideRedirect = TRUE; + MapWindow (pWin, pClient); + pWin->overrideRedirect = overrideRedirect; + } + + return Success; +} + +/* + * Free one of the per-client per-window resources, clearing + * redirect and the per-window pointer as appropriate + */ +void +compFreeClientWindow (WindowPtr pWin, XID id) +{ + CompWindowPtr cw = GetCompWindow (pWin); + CompClientWindowPtr ccw, *prev; + Bool wasMapped = pWin->mapped; + + if (!cw) + return; + for (prev = &cw->clients; (ccw = *prev); prev = &ccw->next) + { + if (ccw->id == id) + { + *prev = ccw->next; + if (ccw->update == CompositeRedirectManual) + cw->update = CompositeRedirectAutomatic; + xfree (ccw); + break; + } + } + if (!cw->clients) + { + if (wasMapped) + UnmapWindow (pWin, FALSE); + + if (pWin->redirectDraw) + compFreePixmap (pWin); + + if (cw->damage) + DamageDestroy (cw->damage); + + REGION_UNINIT (pScreen, &cw->borderClip); + + pWin->devPrivates[CompWindowPrivateIndex].ptr = 0; + xfree (cw); + } + else if (cw->update == CompositeRedirectAutomatic && + !cw->damageRegistered && pWin->redirectDraw) + { + DamageRegister (&pWin->drawable, cw->damage); + cw->damageRegistered = TRUE; + DamageDamageRegion (&pWin->drawable, &pWin->borderSize); + } + if (wasMapped && !pWin->mapped) + { + Bool overrideRedirect = pWin->overrideRedirect; + pWin->overrideRedirect = TRUE; + MapWindow (pWin, clients[CLIENT_ID(id)]); + pWin->overrideRedirect = overrideRedirect; + } +} + +/* + * This is easy, just free the appropriate resource. + */ + +int +compUnredirectWindow (ClientPtr pClient, WindowPtr pWin, int update) +{ + CompWindowPtr cw = GetCompWindow (pWin); + CompClientWindowPtr ccw; + + if (!cw) + return BadValue; + + for (ccw = cw->clients; ccw; ccw = ccw->next) + if (ccw->update == update && CLIENT_ID(ccw->id) == pClient->index) + { + FreeResource (ccw->id, RT_NONE); + return Success; + } + return BadValue; +} + +/* + * Redirect all subwindows for one client + */ + +int +compRedirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update) +{ + CompSubwindowsPtr csw = GetCompSubwindows (pWin); + CompClientWindowPtr ccw; + WindowPtr pChild; + + /* + * Only one Manual update is allowed + */ + if (csw && update == CompositeRedirectManual) + for (ccw = csw->clients; ccw; ccw = ccw->next) + if (ccw->update == CompositeRedirectManual) + return BadAccess; + /* + * Allocate per-client per-window structure + * The client *could* allocate multiple, but while supported, + * it is not expected to be common + */ + ccw = xalloc (sizeof (CompClientWindowRec)); + if (!ccw) + return BadAlloc; + ccw->id = FakeClientID (pClient->index); + ccw->update = update; + /* + * Now make sure there's a per-window structure to hang this from + */ + if (!csw) + { + csw = xalloc (sizeof (CompSubwindowsRec)); + if (!csw) + { + xfree (ccw); + return BadAlloc; + } + csw->update = CompositeRedirectAutomatic; + csw->clients = 0; + pWin->devPrivates[CompSubwindowsPrivateIndex].ptr = csw; + } + /* + * Redirect all existing windows + */ + for (pChild = pWin->lastChild; pChild; pChild = pChild->prevSib) + { + int ret = compRedirectWindow (pClient, pChild, update); + if (ret != Success) + { + for (pChild = pChild->nextSib; pChild; pChild = pChild->nextSib) + (void) compUnredirectWindow (pClient, pChild, update); + if (!csw->clients) + { + xfree (csw); + pWin->devPrivates[CompSubwindowsPrivateIndex].ptr = 0; + } + xfree (ccw); + return ret; + } + } + /* + * Hook into subwindows list + */ + ccw->next = csw->clients; + csw->clients = ccw; + if (!AddResource (ccw->id, CompositeClientSubwindowsType, pWin)) + return BadAlloc; + if (ccw->update == CompositeRedirectManual) + { + csw->update = CompositeRedirectManual; + /* + * tell damage extension that damage events for this client are + * critical output + */ + DamageExtSetCritical (pClient, TRUE); + } + return Success; +} + +/* + * Free one of the per-client per-subwindows resources, + * which frees one redirect per subwindow + */ +void +compFreeClientSubwindows (WindowPtr pWin, XID id) +{ + CompSubwindowsPtr csw = GetCompSubwindows (pWin); + CompClientWindowPtr ccw, *prev; + WindowPtr pChild; + + if (!csw) + return; + for (prev = &csw->clients; (ccw = *prev); prev = &ccw->next) + { + if (ccw->id == id) + { + ClientPtr pClient = clients[CLIENT_ID(id)]; + + *prev = ccw->next; + if (ccw->update == CompositeRedirectManual) + { + /* + * tell damage extension that damage events for this client are + * critical output + */ + DamageExtSetCritical (pClient, FALSE); + csw->update = CompositeRedirectAutomatic; + if (pWin->mapped) + (*pWin->drawable.pScreen->ClearToBackground)(pWin, 0, 0, 0, 0, TRUE); + } + + /* + * Unredirect all existing subwindows + */ + for (pChild = pWin->lastChild; pChild; pChild = pChild->prevSib) + (void) compUnredirectWindow (pClient, pChild, ccw->update); + + xfree (ccw); + break; + } + } + + /* + * Check if all of the per-client records are gone + */ + if (!csw->clients) + { + pWin->devPrivates[CompSubwindowsPrivateIndex].ptr = 0; + xfree (csw); + } +} + +/* + * This is easy, just free the appropriate resource. + */ + +int +compUnredirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update) +{ + CompSubwindowsPtr csw = GetCompSubwindows (pWin); + CompClientWindowPtr ccw; + + if (!csw) + return BadValue; + for (ccw = csw->clients; ccw; ccw = ccw->next) + if (ccw->update == update && CLIENT_ID(ccw->id) == pClient->index) + { + FreeResource (ccw->id, RT_NONE); + return Success; + } + return BadValue; +} + +/* + * Add redirection information for one subwindow (during reparent) + */ + +int +compRedirectOneSubwindow (WindowPtr pParent, WindowPtr pWin) +{ + CompSubwindowsPtr csw = GetCompSubwindows (pParent); + CompClientWindowPtr ccw; + + if (!csw) + return Success; + for (ccw = csw->clients; ccw; ccw = ccw->next) + { + int ret = compRedirectWindow (clients[CLIENT_ID(ccw->id)], + pWin, ccw->update); + if (ret != Success) + return ret; + } + return Success; +} + +/* + * Remove redirection information for one subwindow (during reparent) + */ + +int +compUnredirectOneSubwindow (WindowPtr pParent, WindowPtr pWin) +{ + CompSubwindowsPtr csw = GetCompSubwindows (pParent); + CompClientWindowPtr ccw; + + if (!csw) + return Success; + for (ccw = csw->clients; ccw; ccw = ccw->next) + { + int ret = compUnredirectWindow (clients[CLIENT_ID(ccw->id)], + pWin, ccw->update); + if (ret != Success) + return ret; + } + return Success; +} + +static PixmapPtr +compNewPixmap (WindowPtr pWin, int x, int y, int w, int h) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + WindowPtr pParent = pWin->parent; + PixmapPtr pPixmap; + GCPtr pGC; + + pPixmap = (*pScreen->CreatePixmap) (pScreen, w, h, pWin->drawable.depth); + + if (!pPixmap) + return 0; + + pPixmap->screen_x = x; + pPixmap->screen_y = y; + + pGC = GetScratchGC (pWin->drawable.depth, pScreen); + + /* + * Copy bits from the parent into the new pixmap so that it will + * have "reasonable" contents in case for background None areas. + */ + if (pGC) + { + XID val = IncludeInferiors; + + ValidateGC(&pPixmap->drawable, pGC); + dixChangeGC (serverClient, pGC, GCSubwindowMode, &val, NULL); + (*pGC->ops->CopyArea) (&pParent->drawable, + &pPixmap->drawable, + pGC, + x - pParent->drawable.x, + y - pParent->drawable.y, + w, h, 0, 0); + FreeScratchGC (pGC); + } + return pPixmap; +} + +Bool +compAllocPixmap (WindowPtr pWin) +{ + int bw = (int) pWin->borderWidth; + int x = pWin->drawable.x - bw; + int y = pWin->drawable.y - bw; + int w = pWin->drawable.width + (bw << 1); + int h = pWin->drawable.height + (bw << 1); + PixmapPtr pPixmap = compNewPixmap (pWin, x, y, w, h); + CompWindowPtr cw = GetCompWindow (pWin); + + if (!pPixmap) + return FALSE; + pWin->redirectDraw = TRUE; + compSetPixmap (pWin, pPixmap); + cw->oldx = COMP_ORIGIN_INVALID; + cw->oldy = COMP_ORIGIN_INVALID; + cw->damageRegistered = FALSE; + if (cw->update == CompositeRedirectAutomatic) + { + DamageRegister (&pWin->drawable, cw->damage); + cw->damageRegistered = TRUE; + } + return TRUE; +} + +void +compFreePixmap (WindowPtr pWin) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + PixmapPtr pRedirectPixmap, pParentPixmap; + CompWindowPtr cw = GetCompWindow (pWin); + + if (cw->damageRegistered) + { + DamageUnregister (&pWin->drawable, cw->damage); + cw->damageRegistered = FALSE; + DamageEmpty (cw->damage); + } + /* + * Move the parent-constrained border clip region back into + * the window so that ValidateTree will handle the unmap + * case correctly. Unmap adds the window borderClip to the + * parent exposed area; regions beyond the parent cause crashes + */ + REGION_COPY (pScreen, &pWin->borderClip, &cw->borderClip); + pRedirectPixmap = (*pScreen->GetWindowPixmap) (pWin); + pParentPixmap = (*pScreen->GetWindowPixmap) (pWin->parent); + pWin->redirectDraw = FALSE; + compSetPixmap (pWin, pParentPixmap); + (*pScreen->DestroyPixmap) (pRedirectPixmap); +} + +/* + * Make sure the pixmap is the right size and offset. Allocate a new + * pixmap to change size, adjust origin to change offset, leaving the + * old pixmap in cw->pOldPixmap so bits can be recovered + */ +Bool +compReallocPixmap (WindowPtr pWin, int draw_x, int draw_y, + unsigned int w, unsigned int h, int bw) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + PixmapPtr pOld = (*pScreen->GetWindowPixmap) (pWin); + PixmapPtr pNew; + CompWindowPtr cw = GetCompWindow (pWin); + int pix_x, pix_y; + int pix_w, pix_h; + + assert (cw && pWin->redirectDraw); + cw->oldx = pOld->screen_x; + cw->oldy = pOld->screen_y; + pix_x = draw_x - bw; + pix_y = draw_y - bw; + pix_w = w + (bw << 1); + pix_h = h + (bw << 1); + if (pix_w != pOld->drawable.width || pix_h != pOld->drawable.height) + { + pNew = compNewPixmap (pWin, pix_x, pix_y, pix_w, pix_h); + if (!pNew) + return FALSE; + cw->pOldPixmap = pOld; + compSetPixmap (pWin, pNew); + } + else + { + pNew = pOld; + cw->pOldPixmap = 0; + } + pNew->screen_x = pix_x; + pNew->screen_y = pix_y; + return TRUE; +} diff --git a/composite/compinit.c b/composite/compinit.c new file mode 100644 index 000000000..5109a74fa --- /dev/null +++ b/composite/compinit.c @@ -0,0 +1,389 @@ +/* + * $Id$ + * + * Copyright © 2003 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 "compint.h" + +int CompScreenPrivateIndex; +int CompWindowPrivateIndex; +int CompSubwindowsPrivateIndex; +int CompGeneration; + +static Bool +compCloseScreen (int index, ScreenPtr pScreen) +{ + CompScreenPtr cs = GetCompScreen (pScreen); + Bool ret; + + pScreen->CloseScreen = cs->CloseScreen; + pScreen->BlockHandler = cs->BlockHandler; + pScreen->InstallColormap = cs->InstallColormap; + pScreen->ReparentWindow = cs->ReparentWindow; + pScreen->MoveWindow = cs->MoveWindow; + pScreen->ResizeWindow = cs->ResizeWindow; + pScreen->ChangeBorderWidth = cs->ChangeBorderWidth; + + pScreen->ClipNotify = cs->ClipNotify; + pScreen->PaintWindowBackground = cs->PaintWindowBackground; + pScreen->UnrealizeWindow = cs->UnrealizeWindow; + pScreen->RealizeWindow = cs->RealizeWindow; + pScreen->DestroyWindow = cs->DestroyWindow; + pScreen->CreateWindow = cs->CreateWindow; + pScreen->CopyWindow = cs->CopyWindow; + pScreen->PositionWindow = cs->PositionWindow; + xfree (cs); + pScreen->devPrivates[CompScreenPrivateIndex].ptr = 0; + ret = (*pScreen->CloseScreen) (index, pScreen); + return ret; +} + +static void +compInstallColormap (ColormapPtr pColormap) +{ + VisualPtr pVisual = pColormap->pVisual; + ScreenPtr pScreen = pColormap->pScreen; + CompScreenPtr cs = GetCompScreen (pScreen); + int a; + + for (a = 0; a < NUM_COMP_ALTERNATE_VISUALS; a++) + if (pVisual->vid == cs->alternateVisuals[a]) + return; + pScreen->InstallColormap = cs->InstallColormap; + (*pScreen->InstallColormap) (pColormap); + cs->InstallColormap = pScreen->InstallColormap; + pScreen->InstallColormap = compInstallColormap; +} + +static void +compScreenUpdate (ScreenPtr pScreen) +{ + CompScreenPtr cs = GetCompScreen (pScreen); + + compCheckTree (pScreen); + if (cs->damaged) + { + compWindowUpdate (WindowTable[pScreen->myNum]); + cs->damaged = FALSE; + } +} + +static void +compBlockHandler (int i, + pointer blockData, + pointer pTimeout, + pointer pReadmask) +{ + ScreenPtr pScreen = screenInfo.screens[i]; + CompScreenPtr cs = GetCompScreen (pScreen); + + pScreen->BlockHandler = cs->BlockHandler; + compScreenUpdate (pScreen); + (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask); + cs->BlockHandler = pScreen->BlockHandler; + pScreen->BlockHandler = compBlockHandler; +} + +/* + * Add alternate visuals -- always expose an ARGB32 and RGB24 visual + */ + +static DepthPtr +compFindVisuallessDepth (ScreenPtr pScreen, int d) +{ + int i; + + for (i = 0; i < pScreen->numDepths; i++) + { + DepthPtr depth = &pScreen->allowedDepths[i]; + if (depth->depth == d) + { + /* + * Make sure it doesn't have visuals already + */ + if (depth->numVids) + return 0; + /* + * looks fine + */ + return depth; + } + } + /* + * If there isn't one, then it's gonna be hard to have + * an associated visual + */ + return 0; +} + +typedef struct _alternateVisual { + int depth; + CARD32 format; +} CompAlternateVisual; + +static CompAlternateVisual altVisuals[NUM_COMP_ALTERNATE_VISUALS] = { +#if COMP_INCLUDE_RGB24_VISUAL + { 24, PICT_r8g8b8 }, +#endif + { 32, PICT_a8r8g8b8 }, +}; + +static Bool +compAddAlternateVisuals (ScreenPtr pScreen, CompScreenPtr cs) +{ + VisualPtr visuals; + DepthPtr depths[NUM_COMP_ALTERNATE_VISUALS]; + PictFormatPtr pPictFormats[NUM_COMP_ALTERNATE_VISUALS]; + int i; + int numVisuals; + VisualID *vids[NUM_COMP_ALTERNATE_VISUALS]; + XID *installedCmaps; + ColormapPtr installedCmap; + int numInstalledCmaps; + int numAlternate = 0; + int alt; + + memset (cs->alternateVisuals, '\0', sizeof (cs->alternateVisuals)); + + for (alt = 0; alt < NUM_COMP_ALTERNATE_VISUALS; alt++) + { + DepthPtr depth; + PictFormatPtr pPictFormat; + + depth = compFindVisuallessDepth (pScreen, altVisuals[alt].depth); + if (!depth) + continue; + /* + * Find the right picture format + */ + pPictFormat = PictureMatchFormat (pScreen, altVisuals[alt].depth, + altVisuals[alt].format); + if (!pPictFormat) + continue; + + /* + * Allocate vid list for this depth + */ + vids[numAlternate] = xalloc (sizeof (VisualID)); + if (!vids[numAlternate]) + continue; + depths[numAlternate] = depth; + pPictFormats[numAlternate] = pPictFormat; + numAlternate++; + } + + if (!numAlternate) + return TRUE; + + /* + * Find the installed colormaps + */ + installedCmaps = xalloc (pScreen->maxInstalledCmaps * sizeof (XID)); + if (!installedCmaps) + { + for (alt = 0; alt < numAlternate; alt++) + xfree (vids[alt]); + return FALSE; + } + numInstalledCmaps = (*pScreen->ListInstalledColormaps) (pScreen, + installedCmaps); + + /* + * realloc the visual array to fit the new one in place + */ + numVisuals = pScreen->numVisuals; + visuals = xrealloc (pScreen->visuals, + (numVisuals + numAlternate) * sizeof (VisualRec)); + if (!visuals) + { + for (alt = 0; alt < numAlternate; alt++) + xfree (vids[alt]); + xfree (installedCmaps); + return FALSE; + } + + /* + * Fix up any existing installed colormaps -- we'll assume that + * the only ones created so far have been installed. If this + * isn't true, we'll have to walk the resource database looking + * for all colormaps. + */ + for (i = 0; i < numInstalledCmaps; i++) + { + int j; + + installedCmap = LookupIDByType (installedCmaps[i], RT_COLORMAP); + if (!installedCmap) + continue; + j = installedCmap->pVisual - pScreen->visuals; + installedCmap->pVisual = &visuals[j]; + } + + xfree (installedCmaps); + + pScreen->visuals = visuals; + pScreen->numVisuals = numVisuals + numAlternate; + + for (alt = 0; alt < numAlternate; alt++) + { + DepthPtr depth = depths[alt]; + PictFormatPtr pPictFormat = pPictFormats[alt]; + VisualPtr visual = &visuals[numVisuals + alt]; + unsigned long alphaMask; + + /* + * Initialize the visual + */ + visual->class = TrueColor; + visual->bitsPerRGBValue = 8; + + visual->vid = FakeClientID (0); + visual->redMask = (((unsigned long) pPictFormat->direct.redMask) << + pPictFormat->direct.red); + visual->greenMask = (((unsigned long) pPictFormat->direct.greenMask) << + pPictFormat->direct.green); + visual->blueMask = (((unsigned long) pPictFormat->direct.blueMask) << + pPictFormat->direct.blue); + alphaMask = (((unsigned long) pPictFormat->direct.alphaMask) << + pPictFormat->direct.alpha); + visual->offsetRed = pPictFormat->direct.red; + visual->offsetGreen = pPictFormat->direct.green; + visual->offsetBlue = pPictFormat->direct.blue; + /* + * Include A bits in this (unlike GLX which includes only RGB) + * This lets DIX compute suitable masks for colormap allocations + */ + visual->nplanes = Ones (visual->redMask | + visual->greenMask | + visual->blueMask | + alphaMask); + /* + * find widest component + */ + visual->ColormapEntries = (1 << max (Ones (visual->redMask), + max (Ones (visual->greenMask), + Ones (visual->blueMask)))); + + /* + * remember the visual ID to detect auto-update windows + */ + cs->alternateVisuals[alt] = visual->vid; + + /* + * Fix up the depth + */ + vids[alt][0] = visual->vid; + depth->numVids = 1; + depth->vids = vids[alt]; + } + return TRUE; +} + +Bool +compScreenInit (ScreenPtr pScreen) +{ + CompScreenPtr cs; + + if (CompGeneration != serverGeneration) + { + CompScreenPrivateIndex = AllocateScreenPrivateIndex (); + if (CompScreenPrivateIndex == -1) + return FALSE; + CompWindowPrivateIndex = AllocateWindowPrivateIndex (); + if (CompWindowPrivateIndex == -1) + return FALSE; + CompSubwindowsPrivateIndex = AllocateWindowPrivateIndex (); + if (CompSubwindowsPrivateIndex == -1) + return FALSE; + CompGeneration = serverGeneration; + } + if (!AllocateWindowPrivate (pScreen, CompWindowPrivateIndex, 0)) + return FALSE; + + if (!AllocateWindowPrivate (pScreen, CompSubwindowsPrivateIndex, 0)) + return FALSE; + + if (GetCompScreen (pScreen)) + return TRUE; + cs = (CompScreenPtr) xalloc (sizeof (CompScreenRec)); + if (!cs) + return FALSE; + + cs->damaged = FALSE; + + if (!compAddAlternateVisuals (pScreen, cs)) + { + xfree (cs); + return FALSE; + } + + cs->PositionWindow = pScreen->PositionWindow; + pScreen->PositionWindow = compPositionWindow; + + cs->CopyWindow = pScreen->CopyWindow; + pScreen->CopyWindow = compCopyWindow; + + cs->CreateWindow = pScreen->CreateWindow; + pScreen->CreateWindow = compCreateWindow; + + cs->DestroyWindow = pScreen->DestroyWindow; + pScreen->DestroyWindow = compDestroyWindow; + + cs->RealizeWindow = pScreen->RealizeWindow; + pScreen->RealizeWindow = compRealizeWindow; + + cs->UnrealizeWindow = pScreen->UnrealizeWindow; + pScreen->UnrealizeWindow = compUnrealizeWindow; + + cs->PaintWindowBackground = pScreen->PaintWindowBackground; + pScreen->PaintWindowBackground = compPaintWindowBackground; + + cs->ClipNotify = pScreen->ClipNotify; + pScreen->ClipNotify = compClipNotify; + + cs->MoveWindow = pScreen->MoveWindow; + pScreen->MoveWindow = compMoveWindow; + + cs->ResizeWindow = pScreen->ResizeWindow; + pScreen->ResizeWindow = compResizeWindow; + + cs->ChangeBorderWidth = pScreen->ChangeBorderWidth; + pScreen->ChangeBorderWidth = compChangeBorderWidth; + + cs->ReparentWindow = pScreen->ReparentWindow; + pScreen->ReparentWindow = compReparentWindow; + + cs->InstallColormap = pScreen->InstallColormap; + pScreen->InstallColormap = compInstallColormap; + + cs->BlockHandler = pScreen->BlockHandler; + pScreen->BlockHandler = compBlockHandler; + + cs->CloseScreen = pScreen->CloseScreen; + pScreen->CloseScreen = compCloseScreen; + + pScreen->devPrivates[CompScreenPrivateIndex].ptr = (pointer) cs; + return TRUE; +} diff --git a/composite/compint.h b/composite/compint.h new file mode 100644 index 000000000..81b4027ec --- /dev/null +++ b/composite/compint.h @@ -0,0 +1,256 @@ +/* + * $Id$ + * + * Copyright © 2003 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. + */ + +#ifndef _COMPINT_H_ +#define _COMPINT_H_ + +#include "misc.h" +#include "scrnintstr.h" +#include "os.h" +#include "regionstr.h" +#include "validate.h" +#include "windowstr.h" +#include "input.h" +#include "resource.h" +#include "colormapst.h" +#include "cursorstr.h" +#include "dixstruct.h" +#include "gcstruct.h" +#include "servermd.h" +#include "dixevents.h" +#include "globals.h" +#include "picturestr.h" +#include "extnsionst.h" +#include "mi.h" +#include "damage.h" +#include "damageextint.h" +#include "xfixes.h" +#include <X11/extensions/compositeproto.h> +#include <assert.h> + +/* + * enable this for debugging + + #define COMPOSITE_DEBUG + */ + +typedef struct _CompClientWindow { + struct _CompClientWindow *next; + XID id; + int update; +} CompClientWindowRec, *CompClientWindowPtr; + +typedef struct _CompWindow { + RegionRec borderClip; + DamagePtr damage; /* for automatic update mode */ + Bool damageRegistered; + Bool damaged; + int update; + CompClientWindowPtr clients; + int oldx; + int oldy; + PixmapPtr pOldPixmap; + int borderClipX, borderClipY; +} CompWindowRec, *CompWindowPtr; + +#define COMP_ORIGIN_INVALID 0x80000000 + +typedef struct _CompSubwindows { + int update; + CompClientWindowPtr clients; +} CompSubwindowsRec, *CompSubwindowsPtr; + +#ifndef COMP_INCLUDE_RGB24_VISUAL +#define COMP_INCLUDE_RGB24_VISUAL 0 +#endif + +#if COMP_INCLUDE_RGB24_VISUAL +#define NUM_COMP_ALTERNATE_VISUALS 2 +#else +#define NUM_COMP_ALTERNATE_VISUALS 1 +#endif + +typedef struct _CompScreen { + PositionWindowProcPtr PositionWindow; + CopyWindowProcPtr CopyWindow; + CreateWindowProcPtr CreateWindow; + DestroyWindowProcPtr DestroyWindow; + RealizeWindowProcPtr RealizeWindow; + UnrealizeWindowProcPtr UnrealizeWindow; + PaintWindowProcPtr PaintWindowBackground; + ClipNotifyProcPtr ClipNotify; + /* + * Called from ConfigureWindow, these + * three track changes to the offscreen storage + * geometry + */ + MoveWindowProcPtr MoveWindow; + ResizeWindowProcPtr ResizeWindow; + ChangeBorderWidthProcPtr ChangeBorderWidth; + /* + * Reparenting has an effect on Subwindows redirect + */ + ReparentWindowProcPtr ReparentWindow; + + /* + * Colormaps for new visuals better not get installed + */ + InstallColormapProcPtr InstallColormap; + + ScreenBlockHandlerProcPtr BlockHandler; + CloseScreenProcPtr CloseScreen; + Bool damaged; + XID alternateVisuals[NUM_COMP_ALTERNATE_VISUALS]; +} CompScreenRec, *CompScreenPtr; + +extern int CompScreenPrivateIndex; +extern int CompWindowPrivateIndex; +extern int CompSubwindowsPrivateIndex; + +#define GetCompScreen(s) ((CompScreenPtr) ((s)->devPrivates[CompScreenPrivateIndex].ptr)) +#define GetCompWindow(w) ((CompWindowPtr) ((w)->devPrivates[CompWindowPrivateIndex].ptr)) +#define GetCompSubwindows(w) ((CompSubwindowsPtr) ((w)->devPrivates[CompSubwindowsPrivateIndex].ptr)) + +extern RESTYPE CompositeClientWindowType; +extern RESTYPE CompositeClientSubwindowsType; + +/* + * compalloc.c + */ + +void +compReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure); + +Bool +compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update); + +void +compFreeClientWindow (WindowPtr pWin, XID id); + +int +compUnredirectWindow (ClientPtr pClient, WindowPtr pWin, int update); + +int +compRedirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update); + +void +compFreeClientSubwindows (WindowPtr pWin, XID id); + +int +compUnredirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update); + +int +compRedirectOneSubwindow (WindowPtr pParent, WindowPtr pWin); + +int +compUnredirectOneSubwindow (WindowPtr pParent, WindowPtr pWin); + +Bool +compAllocPixmap (WindowPtr pWin); + +void +compFreePixmap (WindowPtr pWin); + +Bool +compReallocPixmap (WindowPtr pWin, int x, int y, + unsigned int w, unsigned int h, int bw); + +/* + * compext.c + */ + +void +CompositeExtensionInit (void); + +/* + * compinit.c + */ + +Bool +compScreenInit (ScreenPtr pScreen); + +/* + * compwindow.c + */ + +#ifdef COMPOSITE_DEBUG +void +compCheckTree (ScreenPtr pScreen); +#else +#define compCheckTree(s) +#endif + +void +compSetPixmap (WindowPtr pWin, PixmapPtr pPixmap); + +Bool +compCheckRedirect (WindowPtr pWin); + +Bool +compPositionWindow (WindowPtr pWin, int x, int y); + +Bool +compRealizeWindow (WindowPtr pWin); + +Bool +compUnrealizeWindow (WindowPtr pWin); + +void +compPaintWindowBackground (WindowPtr pWin, RegionPtr pRegion, int what); + +void +compClipNotify (WindowPtr pWin, int dx, int dy); + +void +compMoveWindow (WindowPtr pWin, int x, int y, WindowPtr pSib, VTKind kind); + +void +compResizeWindow (WindowPtr pWin, int x, int y, + unsigned int w, unsigned int h, WindowPtr pSib); + +void +compChangeBorderWidth (WindowPtr pWin, unsigned int border_width); + +void +compReparentWindow (WindowPtr pWin, WindowPtr pPriorParent); + +Bool +compCreateWindow (WindowPtr pWin); + +Bool +compDestroyWindow (WindowPtr pWin); + +void +compSetRedirectBorderClip (WindowPtr pWin, RegionPtr pRegion); + +RegionPtr +compGetRedirectBorderClip (WindowPtr pWin); + +void +compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc); + +void +compWindowUpdate (WindowPtr pWin); + +#endif /* _COMPINT_H_ */ diff --git a/composite/compwindow.c b/composite/compwindow.c new file mode 100644 index 000000000..c7ea98c13 --- /dev/null +++ b/composite/compwindow.c @@ -0,0 +1,754 @@ +/* + * $Id$ + * + * Copyright © 2003 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 "compint.h" + +#ifdef COMPOSITE_DEBUG +static int +compCheckWindow (WindowPtr pWin, pointer data) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + PixmapPtr pWinPixmap = (*pScreen->GetWindowPixmap) (pWin); + PixmapPtr pParentPixmap = pWin->parent ? (*pScreen->GetWindowPixmap) (pWin->parent) : 0; + PixmapPtr pScreenPixmap = (*pScreen->GetScreenPixmap) (pScreen); + + if (!pWin->parent) + { + assert (!pWin->redirectDraw); + assert (pWinPixmap == pScreenPixmap); + } + else if (pWin->redirectDraw) + { + assert (pWinPixmap != pParentPixmap); + assert (pWinPixmap != pScreenPixmap); + } + else + { + assert (pWinPixmap == pParentPixmap); + } + assert (0 < pWinPixmap->refcnt && pWinPixmap->refcnt < 3); + assert (0 < pScreenPixmap->refcnt && pScreenPixmap->refcnt < 3); + if (pParentPixmap) + assert (0 <= pParentPixmap->refcnt && pParentPixmap->refcnt < 3); + return WT_WALKCHILDREN; +} + +void +compCheckTree (ScreenPtr pScreen) +{ + WalkTree (pScreen, compCheckWindow, 0); +} +#endif + +typedef struct _compPixmapVisit { + WindowPtr pWindow; + PixmapPtr pPixmap; +} CompPixmapVisitRec, *CompPixmapVisitPtr; + +static Bool +compRepaintBorder (ClientPtr pClient, pointer closure) +{ + WindowPtr pWindow = LookupWindow ((XID) closure, pClient); + + if (pWindow) + { + RegionRec exposed; + + REGION_NULL(pScreen, &exposed); + REGION_SUBTRACT(pScreen, &exposed, &pWindow->borderClip, &pWindow->winSize); + (*pWindow->drawable.pScreen->PaintWindowBorder)(pWindow, &exposed, PW_BORDER); + REGION_UNINIT(pScreen, &exposed); + } + return TRUE; +} + +static int +compSetPixmapVisitWindow (WindowPtr pWindow, pointer data) +{ + CompPixmapVisitPtr pVisit = (CompPixmapVisitPtr) data; + ScreenPtr pScreen = pWindow->drawable.pScreen; + + if (pWindow != pVisit->pWindow && pWindow->redirectDraw) + return WT_DONTWALKCHILDREN; + (*pScreen->SetWindowPixmap) (pWindow, pVisit->pPixmap); + /* + * Recompute winSize and borderSize. This is duplicate effort + * when resizing pixmaps, but necessary when changing redirection. + * Might be nice to fix this. + */ + SetWinSize (pWindow); + SetBorderSize (pWindow); + if (HasBorder (pWindow)) + QueueWorkProc (compRepaintBorder, serverClient, + (pointer) pWindow->drawable.id); + return WT_WALKCHILDREN; +} + +void +compSetPixmap (WindowPtr pWindow, PixmapPtr pPixmap) +{ + CompPixmapVisitRec visitRec; + + visitRec.pWindow = pWindow; + visitRec.pPixmap = pPixmap; + TraverseTree (pWindow, compSetPixmapVisitWindow, (pointer) &visitRec); + compCheckTree (pWindow->drawable.pScreen); +} + +Bool +compCheckRedirect (WindowPtr pWin) +{ + CompWindowPtr cw = GetCompWindow (pWin); + Bool should; + + should = pWin->realized && (pWin->drawable.class != InputOnly) && + (cw != NULL); + + if (should != pWin->redirectDraw) + { + if (should) + return compAllocPixmap (pWin); + else + compFreePixmap (pWin); + } + return TRUE; +} + +Bool +compPositionWindow (WindowPtr pWin, int x, int y) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + CompScreenPtr cs = GetCompScreen (pScreen); + Bool ret = TRUE; + + pScreen->PositionWindow = cs->PositionWindow; + /* + * "Shouldn't need this as all possible places should be wrapped + * + compCheckRedirect (pWin); + */ +#ifdef COMPOSITE_DEBUG + if (pWin->redirectDraw != (pWin->viewable && (GetCompWindow(pWin) != NULL))) + abort (); +#endif + if (pWin->redirectDraw) + { + PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin); + int bw = wBorderWidth (pWin); + int nx = pWin->drawable.x - bw; + int ny = pWin->drawable.y - bw; + + if (pPixmap->screen_x != nx || pPixmap->screen_y != ny) + { + pPixmap->screen_x = nx; + pPixmap->screen_y = ny; + pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER; + } + } + + if (!(*pScreen->PositionWindow) (pWin, x, y)) + ret = FALSE; + cs->PositionWindow = pScreen->PositionWindow; + pScreen->PositionWindow = compPositionWindow; + compCheckTree (pWin->drawable.pScreen); + return ret; +} + +Bool +compRealizeWindow (WindowPtr pWin) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + CompScreenPtr cs = GetCompScreen (pScreen); + Bool ret = TRUE; + + pScreen->RealizeWindow = cs->RealizeWindow; + compCheckRedirect (pWin); + if (!(*pScreen->RealizeWindow) (pWin)) + ret = FALSE; + cs->RealizeWindow = pScreen->RealizeWindow; + pScreen->RealizeWindow = compRealizeWindow; + compCheckTree (pWin->drawable.pScreen); + return ret; +} + +Bool +compUnrealizeWindow (WindowPtr pWin) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + CompScreenPtr cs = GetCompScreen (pScreen); + Bool ret = TRUE; + + pScreen->UnrealizeWindow = cs->UnrealizeWindow; + compCheckRedirect (pWin); + if (!(*pScreen->UnrealizeWindow) (pWin)) + ret = FALSE; + cs->UnrealizeWindow = pScreen->UnrealizeWindow; + pScreen->UnrealizeWindow = compUnrealizeWindow; + compCheckTree (pWin->drawable.pScreen); + return ret; +} + +void +compPaintWindowBackground (WindowPtr pWin, RegionPtr pRegion, int what) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + CompSubwindowsPtr csw = GetCompSubwindows (pWin); + CompScreenPtr cs = GetCompScreen (pScreen); + + if (csw && csw->update == CompositeRedirectManual) + return; + pScreen->PaintWindowBackground = cs->PaintWindowBackground; + (*pScreen->PaintWindowBackground) (pWin, pRegion, what); + cs->PaintWindowBackground = pScreen->PaintWindowBackground; + pScreen->PaintWindowBackground = compPaintWindowBackground; +} + +/* + * Called after the borderClip for the window has settled down + * We use this to make sure our extra borderClip has the right origin + */ + +void +compClipNotify (WindowPtr pWin, int dx, int dy) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + CompScreenPtr cs = GetCompScreen (pScreen); + CompWindowPtr cw = GetCompWindow (pWin); + + if (cw) + { + if (cw->borderClipX != pWin->drawable.x || + cw->borderClipY != pWin->drawable.y) + { + REGION_TRANSLATE (pScreen, &cw->borderClip, + pWin->drawable.x - cw->borderClipX, + pWin->drawable.y - cw->borderClipY); + cw->borderClipX = pWin->drawable.x; + cw->borderClipY = pWin->drawable.y; + } + } + if (cs->ClipNotify) + { + pScreen->ClipNotify = cs->ClipNotify; + (*pScreen->ClipNotify) (pWin, dx, dy); + cs->ClipNotify = pScreen->ClipNotify; + pScreen->ClipNotify = compClipNotify; + } +} + +/* + * Returns TRUE if the window needs server-provided automatic redirect, + * which is true if the child and parent aren't both regular or ARGB visuals + */ + +static Bool +compIsAlternateVisual (ScreenPtr pScreen, + XID visual) +{ + CompScreenPtr cs = GetCompScreen (pScreen); + int i; + + for (i = 0; i < NUM_COMP_ALTERNATE_VISUALS; i++) + if (cs->alternateVisuals[i] == visual) + return TRUE; + return FALSE; +} + +static Bool +compImplicitRedirect (WindowPtr pWin, WindowPtr pParent) +{ + if (pParent) + { + ScreenPtr pScreen = pWin->drawable.pScreen; + XID winVisual = wVisual (pWin); + XID parentVisual = wVisual (pParent); + + if (winVisual != parentVisual && + (compIsAlternateVisual (pScreen, winVisual) || + compIsAlternateVisual (pScreen, parentVisual))) + return TRUE; + } + return FALSE; +} + +void +compMoveWindow (WindowPtr pWin, int x, int y, WindowPtr pSib, VTKind kind) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + CompScreenPtr cs = GetCompScreen (pScreen); + + compCheckTree (pScreen); + if (pWin->redirectDraw) + { + WindowPtr pParent; + int draw_x, draw_y; + unsigned int w, h, bw; + + /* if this is a root window, can't be moved */ + if (!(pParent = pWin->parent)) + return; + + bw = wBorderWidth (pWin); + draw_x = pParent->drawable.x + x + (int)bw; + draw_y = pParent->drawable.y + y + (int)bw; + w = pWin->drawable.width; + h = pWin->drawable.height; + compReallocPixmap (pWin, draw_x, draw_y, w, h, bw); + } + compCheckTree (pScreen); + + pScreen->MoveWindow = cs->MoveWindow; + (*pScreen->MoveWindow) (pWin, x, y, pSib, kind); + cs->MoveWindow = pScreen->MoveWindow; + pScreen->MoveWindow = compMoveWindow; + + if (pWin->redirectDraw) + { + CompWindowPtr cw = GetCompWindow (pWin); + if (cw->pOldPixmap) + { + (*pScreen->DestroyPixmap) (cw->pOldPixmap); + cw->pOldPixmap = NullPixmap; + } + } + + compCheckTree (pScreen); +} + +void +compResizeWindow (WindowPtr pWin, int x, int y, + unsigned int w, unsigned int h, WindowPtr pSib) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + CompScreenPtr cs = GetCompScreen (pScreen); + + compCheckTree (pScreen); + if (pWin->redirectDraw) + { + WindowPtr pParent; + int draw_x, draw_y; + unsigned int bw; + + /* if this is a root window, can't be moved */ + if (!(pParent = pWin->parent)) + return; + + bw = wBorderWidth (pWin); + draw_x = pParent->drawable.x + x + (int)bw; + draw_y = pParent->drawable.y + y + (int)bw; + compReallocPixmap (pWin, draw_x, draw_y, w, h, bw); + } + compCheckTree (pScreen); + + pScreen->ResizeWindow = cs->ResizeWindow; + (*pScreen->ResizeWindow) (pWin, x, y, w, h, pSib); + cs->ResizeWindow = pScreen->ResizeWindow; + pScreen->ResizeWindow = compResizeWindow; + if (pWin->redirectDraw) + { + CompWindowPtr cw = GetCompWindow (pWin); + if (cw->pOldPixmap) + { + (*pScreen->DestroyPixmap) (cw->pOldPixmap); + cw->pOldPixmap = NullPixmap; + } + } + compCheckTree (pWin->drawable.pScreen); +} + +void +compChangeBorderWidth (WindowPtr pWin, unsigned int bw) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + CompScreenPtr cs = GetCompScreen (pScreen); + + compCheckTree (pScreen); + if (pWin->redirectDraw) + { + WindowPtr pParent; + int draw_x, draw_y; + unsigned int w, h; + + /* if this is a root window, can't be moved */ + if (!(pParent = pWin->parent)) + return; + + draw_x = pWin->drawable.x; + draw_y = pWin->drawable.y; + w = pWin->drawable.width; + h = pWin->drawable.height; + compReallocPixmap (pWin, draw_x, draw_y, w, h, bw); + } + compCheckTree (pScreen); + + pScreen->ChangeBorderWidth = cs->ChangeBorderWidth; + (*pScreen->ChangeBorderWidth) (pWin, bw); + cs->ChangeBorderWidth = pScreen->ChangeBorderWidth; + pScreen->ChangeBorderWidth = compChangeBorderWidth; + if (pWin->redirectDraw) + { + CompWindowPtr cw = GetCompWindow (pWin); + if (cw->pOldPixmap) + { + (*pScreen->DestroyPixmap) (cw->pOldPixmap); + cw->pOldPixmap = NullPixmap; + } + } + compCheckTree (pWin->drawable.pScreen); +} + +void +compReparentWindow (WindowPtr pWin, WindowPtr pPriorParent) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + CompScreenPtr cs = GetCompScreen (pScreen); + + pScreen->ReparentWindow = cs->ReparentWindow; + /* + * Remove any implicit redirect due to synthesized visual + */ + if (compImplicitRedirect (pWin, pPriorParent)) + compUnredirectWindow (serverClient, pWin, CompositeRedirectAutomatic); + /* + * Handle subwindows redirection + */ + compUnredirectOneSubwindow (pPriorParent, pWin); + compRedirectOneSubwindow (pWin->parent, pWin); + /* + * Add any implict redirect due to synthesized visual + */ + if (compImplicitRedirect (pWin, pWin->parent)) + compRedirectWindow (serverClient, pWin, CompositeRedirectAutomatic); + + /* + * Allocate any necessary redirect pixmap + * (this actually should never be true; pWin is always unmapped) + */ + compCheckRedirect (pWin); + + /* + * Reset pixmap pointers as appropriate + */ + if (pWin->parent && !pWin->redirectDraw) + compSetPixmap (pWin, (*pScreen->GetWindowPixmap) (pWin->parent)); + /* + * Call down to next function + */ + if (pScreen->ReparentWindow) + (*pScreen->ReparentWindow) (pWin, pPriorParent); + cs->ReparentWindow = pScreen->ReparentWindow; + pScreen->ReparentWindow = compReparentWindow; + compCheckTree (pWin->drawable.pScreen); +} + +void +compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + CompScreenPtr cs = GetCompScreen (pScreen); + int dx = 0, dy = 0; + + if (pWin->redirectDraw) + { + PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin); + CompWindowPtr cw = GetCompWindow (pWin); + + assert (cw->oldx != COMP_ORIGIN_INVALID); + assert (cw->oldy != COMP_ORIGIN_INVALID); + if (cw->pOldPixmap) + { + /* + * Ok, the old bits are available in pOldPixmap and + * need to be copied to pNewPixmap. + */ + RegionRec rgnDst; + PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin); + GCPtr pGC; + + dx = ptOldOrg.x - pWin->drawable.x; + dy = ptOldOrg.y - pWin->drawable.y; + REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy); + + REGION_NULL (pWin->drawable.pScreen, &rgnDst); + + REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, + &pWin->borderClip, prgnSrc); + + REGION_TRANSLATE (pWin->drawable.pScreen, &rgnDst, + -pPixmap->screen_x, -pPixmap->screen_y); + + dx = dx + pPixmap->screen_x - cw->oldx; + dy = dy + pPixmap->screen_y - cw->oldy; + pGC = GetScratchGC (pPixmap->drawable.depth, pScreen); + if (pGC) + { + BoxPtr pBox = REGION_RECTS (&rgnDst); + int nBox = REGION_NUM_RECTS (&rgnDst); + + ValidateGC(&pPixmap->drawable, pGC); + while (nBox--) + { + (void) (*pGC->ops->CopyArea) (&cw->pOldPixmap->drawable, + &pPixmap->drawable, + pGC, + pBox->x1 + dx, pBox->y1 + dy, + pBox->x2 - pBox->x1, + pBox->y2 - pBox->y1, + pBox->x1, pBox->y1); + pBox++; + } + FreeScratchGC (pGC); + } + return; + } + dx = pPixmap->screen_x - cw->oldx; + dy = pPixmap->screen_y - cw->oldy; + ptOldOrg.x += dx; + ptOldOrg.y += dy; + } + + pScreen->CopyWindow = cs->CopyWindow; + if (ptOldOrg.x != pWin->drawable.x || ptOldOrg.y != pWin->drawable.y) + { + if (dx || dy) + REGION_TRANSLATE (pScreen, prgnSrc, dx, dy); + (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc); + if (dx || dy) + REGION_TRANSLATE (pScreen, prgnSrc, -dx, -dy); + } + else + { + ptOldOrg.x -= dx; + ptOldOrg.y -= dy; + REGION_TRANSLATE (prgnSrc, prgnSrc, + pWin->drawable.x - ptOldOrg.x, + pWin->drawable.y - ptOldOrg.y); + DamageDamageRegion (&pWin->drawable, prgnSrc); + } + cs->CopyWindow = pScreen->CopyWindow; + pScreen->CopyWindow = compCopyWindow; + compCheckTree (pWin->drawable.pScreen); +} + +Bool +compCreateWindow (WindowPtr pWin) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + CompScreenPtr cs = GetCompScreen (pScreen); + Bool ret; + + pScreen->CreateWindow = cs->CreateWindow; + ret = (*pScreen->CreateWindow) (pWin); + if (pWin->parent && ret) + { + CompSubwindowsPtr csw = GetCompSubwindows (pWin->parent); + CompClientWindowPtr ccw; + + (*pScreen->SetWindowPixmap) (pWin, (*pScreen->GetWindowPixmap) (pWin->parent)); + if (csw) + for (ccw = csw->clients; ccw; ccw = ccw->next) + compRedirectWindow (clients[CLIENT_ID(ccw->id)], + pWin, ccw->update); + if (compImplicitRedirect (pWin, pWin->parent)) + compRedirectWindow (serverClient, pWin, CompositeRedirectAutomatic); + } + cs->CreateWindow = pScreen->CreateWindow; + pScreen->CreateWindow = compCreateWindow; + compCheckTree (pWin->drawable.pScreen); + return ret; +} + +Bool +compDestroyWindow (WindowPtr pWin) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + CompScreenPtr cs = GetCompScreen (pScreen); + CompWindowPtr cw; + CompSubwindowsPtr csw; + Bool ret; + + pScreen->DestroyWindow = cs->DestroyWindow; + while ((cw = GetCompWindow (pWin))) + FreeResource (cw->clients->id, RT_NONE); + while ((csw = GetCompSubwindows (pWin))) + FreeResource (csw->clients->id, RT_NONE); + + if (pWin->redirectDraw) + compFreePixmap (pWin); + ret = (*pScreen->DestroyWindow) (pWin); + cs->DestroyWindow = pScreen->DestroyWindow; + pScreen->DestroyWindow = compDestroyWindow; +/* compCheckTree (pWin->drawable.pScreen); can't check -- tree isn't good*/ + return ret; +} + +void +compSetRedirectBorderClip (WindowPtr pWin, RegionPtr pRegion) +{ + CompWindowPtr cw = GetCompWindow (pWin); + RegionRec damage; + + REGION_NULL (pScreen, &damage); + /* + * Align old border clip with new border clip + */ + REGION_TRANSLATE (pScreen, &cw->borderClip, + pWin->drawable.x - cw->borderClipX, + pWin->drawable.y - cw->borderClipY); + /* + * Compute newly visible portion of window for repaint + */ + REGION_SUBTRACT (pScreen, &damage, pRegion, &cw->borderClip); + /* + * Report that as damaged so it will be redrawn + */ + DamageDamageRegion (&pWin->drawable, &damage); + REGION_UNINIT (pScreen, &damage); + /* + * Save the new border clip region + */ + REGION_COPY (pScreen, &cw->borderClip, pRegion); + cw->borderClipX = pWin->drawable.x; + cw->borderClipY = pWin->drawable.y; +} + +RegionPtr +compGetRedirectBorderClip (WindowPtr pWin) +{ + CompWindowPtr cw = GetCompWindow (pWin); + + return &cw->borderClip; +} + +static VisualPtr +compGetWindowVisual (WindowPtr pWin) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + VisualID vid = wVisual (pWin); + int i; + + for (i = 0; i < pScreen->numVisuals; i++) + if (pScreen->visuals[i].vid == vid) + return &pScreen->visuals[i]; + return 0; +} + +static PictFormatPtr +compWindowFormat (WindowPtr pWin) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + + return PictureMatchVisual (pScreen, pWin->drawable.depth, + compGetWindowVisual (pWin)); +} + +static void +compWindowUpdateAutomatic (WindowPtr pWin) +{ + CompWindowPtr cw = GetCompWindow (pWin); + ScreenPtr pScreen = pWin->drawable.pScreen; + WindowPtr pParent = pWin->parent; + PixmapPtr pSrcPixmap = (*pScreen->GetWindowPixmap) (pWin); + PictFormatPtr pSrcFormat = compWindowFormat (pWin); + PictFormatPtr pDstFormat = compWindowFormat (pWin->parent); + int error; + RegionPtr pRegion = DamageRegion (cw->damage); + PicturePtr pSrcPicture = CreatePicture (0, &pSrcPixmap->drawable, + pSrcFormat, + 0, 0, + serverClient, + &error); + XID subwindowMode = IncludeInferiors; + PicturePtr pDstPicture = CreatePicture (0, &pParent->drawable, + pDstFormat, + CPSubwindowMode, + &subwindowMode, + serverClient, + &error); + + /* + * First move the region from window to screen coordinates + */ + REGION_TRANSLATE (pScreen, pRegion, + pWin->drawable.x, pWin->drawable.y); + + /* + * Clip against the "real" border clip + */ + REGION_INTERSECT (pScreen, pRegion, pRegion, &cw->borderClip); + + /* + * Now translate from screen to dest coordinates + */ + REGION_TRANSLATE (pScreen, pRegion, + -pParent->drawable.x, -pParent->drawable.y); + + /* + * Clip the picture + */ + SetPictureClipRegion (pDstPicture, 0, 0, pRegion); + + /* + * And paint + */ + CompositePicture (PictOpSrc, + pSrcPicture, + 0, + pDstPicture, + 0, 0, /* src_x, src_y */ + 0, 0, /* msk_x, msk_y */ + pSrcPixmap->screen_x - pParent->drawable.x, + pSrcPixmap->screen_y - pParent->drawable.y, + pSrcPixmap->drawable.width, + pSrcPixmap->drawable.height); + FreePicture (pSrcPicture, 0); + FreePicture (pDstPicture, 0); + /* + * Empty the damage region. This has the nice effect of + * rendering the translations above harmless + */ + DamageEmpty (cw->damage); +} + +void +compWindowUpdate (WindowPtr pWin) +{ + WindowPtr pChild; + + for (pChild = pWin->lastChild; pChild; pChild = pChild->prevSib) + compWindowUpdate (pChild); + if (pWin->redirectDraw) + { + CompWindowPtr cw = GetCompWindow(pWin); + + if (cw->damaged) + { + compWindowUpdateAutomatic (pWin); + cw->damaged = FALSE; + } + } +} @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/dbe/dbe.c,v 1.1.4.3.2.2 2004/03/04 17:47:26 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/dbe/dbe.c,v 1.2 2004/04/23 19:03:43 eich Exp $ */ /* $Xorg: dbe.c,v 1.3 2000/08/17 19:48:16 cpqbld Exp $ */ /****************************************************************************** * diff --git a/dix/colormap.c b/dix/colormap.c index 306ff941f..28677d53e 100644 --- a/dix/colormap.c +++ b/dix/colormap.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/dix/colormap.c,v 1.1.4.4.2.3 2004/03/04 20:16:04 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/dix/colormap.c,v 1.5 2004/08/13 08:16:14 keithp Exp $ */ /* $XFree86: xc/programs/Xserver/dix/colormap.c,v 3.11 2003/11/03 05:10:59 tsi Exp $ */ /*********************************************************** @@ -190,7 +190,14 @@ static void FindColorInRootCmap ( #define NUMRED(vis) ((vis->redMask >> vis->offsetRed) + 1) #define NUMGREEN(vis) ((vis->greenMask >> vis->offsetGreen) + 1) #define NUMBLUE(vis) ((vis->blueMask >> vis->offsetBlue) + 1) -#define RGBMASK(vis) (vis->redMask | vis->greenMask | vis->blueMask) +#if COMPOSITE +#define ALPHAMASK(vis) ((vis)->nplanes < 32 ? 0 : \ + (CARD32) ~((vis)->redMask|(vis)->greenMask|(vis)->blueMask)) +#else +#define ALPHAMASK(vis) 0 +#endif + +#define RGBMASK(vis) (vis->redMask | vis->greenMask | vis->blueMask | ALPHAMASK(vis)) /* GetNextBitsOrBreak(bits, mask, base) -- * (Suggestion: First read the macro, then read this explanation. @@ -865,7 +872,9 @@ AllocColor (pmap, pred, pgreen, pblue, pPix, client) pixB = FindBestPixel(pmap->blue, NUMBLUE(pVisual), &rgb, BLUEMAP); *pPix = (pixR << pVisual->offsetRed) | (pixG << pVisual->offsetGreen) | - (pixB << pVisual->offsetBlue); + (pixB << pVisual->offsetBlue) | + ALPHAMASK(pVisual); + *pred = pmap->red[pixR].co.local.red; *pgreen = pmap->green[pixG].co.local.green; *pblue = pmap->blue[pixB].co.local.blue; @@ -955,7 +964,8 @@ AllocColor (pmap, pred, pgreen, pblue, pPix, client) (void)FreeCo(pmap, client, REDMAP, 1, &pixR, (Pixel)0); return (BadAlloc); } - *pPix = pixR | pixG | pixB; + *pPix = pixR | pixG | pixB | ALPHAMASK(pVisual); + break; } @@ -1929,6 +1939,10 @@ AllocDirect (client, pmap, c, r, g, b, contig, pixels, prmask, pgmask, pbmask) pmap->numPixelsBlue[client] += npixB; pmap->freeBlue -= npixB; + + for (pDst = pixels; pDst < pixels + c; pDst++) + *pDst |= ALPHAMASK(pmap->pVisual); + DEALLOCATE_LOCAL(ppixBlue); DEALLOCATE_LOCAL(ppixGreen); DEALLOCATE_LOCAL(ppixRed); diff --git a/dix/cursor.c b/dix/cursor.c index fc81a5197..9e0724fb4 100644 --- a/dix/cursor.c +++ b/dix/cursor.c @@ -68,6 +68,10 @@ typedef struct _GlyphShare { static GlyphSharePtr sharedGlyphs = (GlyphSharePtr)NULL; +#ifdef XFIXES +static CARD32 cursorSerial; +#endif + static void FreeCursorBits(CursorBitsPtr bits) { @@ -189,6 +193,10 @@ AllocCursorARGB(psrcbits, pmaskbits, argb, cm, pCurs->bits = bits; pCurs->refcnt = 1; +#ifdef XFIXES + pCurs->serialNumber = ++cursorSerial; + pCurs->name = None; +#endif pCurs->foreRed = foreRed; pCurs->foreGreen = foreGreen; @@ -379,6 +387,10 @@ AllocGlyphCursor(source, sourceChar, mask, maskChar, CheckForEmptyMask(bits); pCurs->bits = bits; pCurs->refcnt = 1; +#ifdef XFIXES + pCurs->serialNumber = ++cursorSerial; + pCurs->name = None; +#endif pCurs->foreRed = foreRed; pCurs->foreGreen = foreGreen; diff --git a/dix/dispatch.c b/dix/dispatch.c index e6602969a..be6f006b4 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/dix/dispatch.c,v 1.1.4.4.2.3 2004/03/08 00:36:56 alanc Exp $ */ +/* $XdotOrg: xc/programs/Xserver/dix/dispatch.c,v 1.5 2004/07/31 01:48:27 anholt Exp $ */ /* $Xorg: dispatch.c,v 1.5 2001/02/09 02:04:40 xorgcvs Exp $ */ /************************************************************ @@ -132,6 +132,7 @@ extern char *ConnectionInfo; Selection *CurrentSelections; int NumCurrentSelections; +CallbackListPtr SelectionCallback = NULL; static ClientPtr grabClient; #define GrabNone 0 @@ -253,7 +254,7 @@ FlushClientCaches(id) #define SMART_SCHEDULE_DEFAULT_INTERVAL 20 /* ms */ #define SMART_SCHEDULE_MAX_SLICE 200 /* ms */ -Bool SmartScheduleDisable; +Bool SmartScheduleDisable = FALSE; long SmartScheduleSlice = SMART_SCHEDULE_DEFAULT_INTERVAL; long SmartScheduleInterval = SMART_SCHEDULE_DEFAULT_INTERVAL; long SmartScheduleMaxSlice = SMART_SCHEDULE_MAX_SLICE; @@ -463,6 +464,9 @@ Dispatch(void) client->errorValue, result); break; } +#ifdef DAMAGEEXT + FlushIfCriticalOutputPending (); +#endif } FlushAllOutput(); #ifdef SMART_SCHEDULE @@ -631,7 +635,7 @@ ProcChangeSaveSet(client) return BadMatch; if ((stuff->mode == SetModeInsert) || (stuff->mode == SetModeDelete)) { - result = AlterSaveSetForClient(client, pWin, stuff->mode); + result = AlterSaveSetForClient(client, pWin, stuff->mode, FALSE, TRUE); if (client->noClientException != Success) return(client->noClientException); else @@ -1044,6 +1048,14 @@ ProcSetSelectionOwner(client) CurrentSelections[i].window = stuff->window; CurrentSelections[i].pWin = pWin; CurrentSelections[i].client = (pWin ? client : NullClient); + if (SelectionCallback) + { + SelectionInfoRec info; + + info.selection = &CurrentSelections[i]; + info.kind= SelectionSetOwner; + CallCallbacks(&SelectionCallback, &info); + } return (client->noClientException); } else @@ -2117,7 +2129,9 @@ DoGetImage(client, format, drawable, x, y, width, height, planemask, im_return) Mask plane = 0; char *pBuf; xGetImageReply xgi; +#ifdef XCSECURITY RegionPtr pVisibleRegion = NULL; +#endif if ((format != XYPixmap) && (format != ZPixmap)) { @@ -3724,7 +3738,7 @@ void InitClient(client, i, ospriv) client->lastGC = (GCPtr) NULL; client->lastGCID = INVALID; client->numSaved = 0; - client->saveSet = (pointer *)NULL; + client->saveSet = (SaveSetElt *)NULL; client->noClientException = Success; #ifdef DEBUG client->requestLogIndex = 0; @@ -4057,6 +4071,14 @@ DeleteWindowFromAnySelections(pWin) for (i = 0; i< NumCurrentSelections; i++) if (CurrentSelections[i].pWin == pWin) { + if (SelectionCallback) + { + SelectionInfoRec info; + + info.selection = &CurrentSelections[i]; + info.kind = SelectionWindowDestroy; + CallCallbacks(&SelectionCallback, &info); + } CurrentSelections[i].pWin = (WindowPtr)NULL; CurrentSelections[i].window = None; CurrentSelections[i].client = NullClient; @@ -4072,6 +4094,14 @@ DeleteClientFromAnySelections(client) for (i = 0; i< NumCurrentSelections; i++) if (CurrentSelections[i].client == client) { + if (SelectionCallback) + { + SelectionInfoRec info; + + info.selection = &CurrentSelections[i]; + info.kind = SelectionWindowDestroy; + CallCallbacks(&SelectionCallback, &info); + } CurrentSelections[i].pWin = (WindowPtr)NULL; CurrentSelections[i].window = None; CurrentSelections[i].client = NullClient; diff --git a/dix/dixfonts.c b/dix/dixfonts.c index 98f734f64..595a6bdf3 100644 --- a/dix/dixfonts.c +++ b/dix/dixfonts.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/dix/dixfonts.c,v 1.1.4.4.2.4 2004/03/08 00:36:56 alanc Exp $ */ +/* $XdotOrg: xc/programs/Xserver/dix/dixfonts.c,v 1.2 2004/04/23 19:04:44 eich Exp $ */ /* $XFree86: xc/programs/Xserver/dix/dixfonts.c,v 3.28 2003/11/08 02:02:03 dawes Exp $ */ /************************************************************************ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. @@ -23,8 +23,7 @@ SOFTWARE. ************************************************************************/ /* The panoramix components contained the following notice */ -/***************************************************************** - +/* Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts. Permission is hereby granted, free of charge, to any person obtaining a copy @@ -50,7 +49,6 @@ dealings in this Software without prior written authorization from Digital Equipment Corporation. ******************************************************************/ - /* $Xorg: dixfonts.c,v 1.4 2000/08/17 19:48:18 cpqbld Exp $ */ #define NEED_REPLIES diff --git a/dix/dixutils.c b/dix/dixutils.c index 40f80d348..5bd5841a9 100644 --- a/dix/dixutils.c +++ b/dix/dixutils.c @@ -152,6 +152,22 @@ ClientTimeToServerTime(c) * beware of too-small buffers */ +static unsigned char +ISOLatin1ToLower (unsigned char source) +{ + unsigned char dest; + if ((source >= XK_A) && (source <= XK_Z)) + dest = source + (XK_a - XK_A); + else if ((source >= XK_Agrave) && (source <= XK_Odiaeresis)) + dest = source + (XK_agrave - XK_Agrave); + else if ((source >= XK_Ooblique) && (source <= XK_Thorn)) + dest = source + (XK_oslash - XK_Ooblique); + else + dest = source; + return dest; +} + + void CopyISOLatin1Lowered(dest, source, length) register unsigned char *dest, *source; @@ -160,17 +176,27 @@ CopyISOLatin1Lowered(dest, source, length) register int i; for (i = 0; i < length; i++, source++, dest++) + *dest = ISOLatin1ToLower (*source); + *dest = '\0'; +} + +int +CompareISOLatin1Lowered(unsigned char *s1, int s1len, + unsigned char *s2, int s2len) +{ + unsigned char c1, c2; + + for (;;) { - if ((*source >= XK_A) && (*source <= XK_Z)) - *dest = *source + (XK_a - XK_A); - else if ((*source >= XK_Agrave) && (*source <= XK_Odiaeresis)) - *dest = *source + (XK_agrave - XK_Agrave); - else if ((*source >= XK_Ooblique) && (*source <= XK_Thorn)) - *dest = *source + (XK_oslash - XK_Ooblique); - else - *dest = *source; + /* note -- compare against zero so that -1 ignores len */ + c1 = s1len-- ? *s1++ : '\0'; + c2 = s2len-- ? *s2++ : '\0'; + if (!c1 || + (c1 != c2 && + (c1 = ISOLatin1ToLower (c1)) != (c2 = ISOLatin1ToLower (c2)))) + break; } - *dest = '\0'; + return (int) c1 - (int) c2; } #ifdef XCSECURITY @@ -321,13 +347,14 @@ LookupClient(rid, client) int -AlterSaveSetForClient(client, pWin, mode) - ClientPtr client; - WindowPtr pWin; - unsigned mode; +AlterSaveSetForClient(ClientPtr client, + WindowPtr pWin, + unsigned mode, + Bool toRoot, + Bool remap) { int numnow; - pointer *pTmp = NULL; + SaveSetElt *pTmp = NULL; int j; numnow = client->numSaved; @@ -335,7 +362,7 @@ AlterSaveSetForClient(client, pWin, mode) if (numnow) { pTmp = client->saveSet; - while ((j < numnow) && (pTmp[j] != (pointer)pWin)) + while ((j < numnow) && (SaveSetWindow(pTmp[j]) != (pointer)pWin)) j++; } if (mode == SetModeInsert) @@ -343,12 +370,14 @@ AlterSaveSetForClient(client, pWin, mode) if (j < numnow) /* duplicate */ return(Success); numnow++; - pTmp = (pointer *)xrealloc(client->saveSet, sizeof(pointer) * numnow); + pTmp = (SaveSetElt *)xrealloc(client->saveSet, sizeof(*pTmp) * numnow); if (!pTmp) return(BadAlloc); client->saveSet = pTmp; client->numSaved = numnow; - client->saveSet[numnow - 1] = (pointer)pWin; + SaveSetAssignWindow(client->saveSet[numnow - 1], pWin); + SaveSetAssignToRoot(client->saveSet[numnow - 1], toRoot); + SaveSetAssignRemap(client->saveSet[numnow - 1], remap); return(Success); } else if ((mode == SetModeDelete) && (j < numnow)) @@ -361,15 +390,14 @@ AlterSaveSetForClient(client, pWin, mode) numnow--; if (numnow) { - pTmp = (pointer *)xrealloc(client->saveSet, - sizeof(pointer) * numnow); + pTmp = (SaveSetElt *)xrealloc(client->saveSet, sizeof(*pTmp) * numnow); if (pTmp) client->saveSet = pTmp; } else { xfree(client->saveSet); - client->saveSet = (pointer *)NULL; + client->saveSet = (SaveSetElt *)NULL; } client->numSaved = numnow; return(Success); @@ -388,7 +416,7 @@ DeleteWindowFromAnySaveSet(pWin) { client = clients[i]; if (client && client->numSaved) - (void)AlterSaveSetForClient(client, pWin, SetModeDelete); + (void)AlterSaveSetForClient(client, pWin, SetModeDelete, FALSE, TRUE); } } diff --git a/dix/events.c b/dix/events.c index 11cdca280..17b5d4182 100644 --- a/dix/events.c +++ b/dix/events.c @@ -1,3 +1,4 @@ +/* $XdotOrg: xc/programs/Xserver/dix/events.c,v 1.6 2004/08/09 02:08:35 kem Exp $ */ /* $XFree86: xc/programs/Xserver/dix/events.c,v 3.51 2004/01/12 17:04:52 tsi Exp $ */ /************************************************************ @@ -105,6 +106,20 @@ extern Bool XkbFilterEvents(ClientPtr, int, xEvent *); #include "security.h" #endif +#ifdef XEVIE +extern WindowPtr *WindowTable; +extern int xevieFlag; +extern int xevieClientIndex; +extern DeviceIntPtr xeviemouse; +extern DeviceIntPtr xeviekb; +extern Mask xevieMask; +extern Mask xevieFilters[128]; +extern int xevieEventSent; +extern int xevieKBEventSent; +int xeviegrabState = 0; +xEvent *xeviexE; +#endif + #include "XIproto.h" #include "exevents.h" #include "extnsionst.h" @@ -181,11 +196,6 @@ static WindowPtr *spriteTrace = (WindowPtr *)NULL; static int spriteTraceSize = 0; static int spriteTraceGood; -typedef struct { - int x, y; - ScreenPtr pScreen; -} HotSpot; - static struct { CursorPtr current; BoxRec hotLimits; /* logical constraints of hot spot */ @@ -206,6 +216,11 @@ static struct { #endif } sprite; /* info about the cursor sprite */ +#ifdef XEVIE +WindowPtr xeviewin; +HotSpot xeviehot; +#endif + static void DoEnterLeaveEvents( WindowPtr /*fromWin*/, WindowPtr /*toWin*/, @@ -2035,6 +2050,46 @@ WindowsRestructured() (void) CheckMotion((xEvent *)NULL); } +#ifdef PANORAMIX +/* This was added to support reconfiguration under Xdmx. The problem is + * that if the 0th screen (i.e., WindowTable[0]) is moved to an origin + * other than 0,0, the information in the private sprite structure must + * be updated accordingly, or XYToWindow (and other routines) will not + * compute correctly. */ +void ReinitializeRootWindow(WindowPtr win, int xoff, int yoff) +{ + ScreenPtr pScreen = win->drawable.pScreen; + GrabPtr grab; + + if (noPanoramiXExtension) return; + + sprite.hot.x -= xoff; + sprite.hot.y -= yoff; + + sprite.hotPhys.x -= xoff; + sprite.hotPhys.y -= yoff; + + sprite.hotLimits.x1 -= xoff; + sprite.hotLimits.y1 -= yoff; + sprite.hotLimits.x2 -= xoff; + sprite.hotLimits.y2 -= yoff; + + if (REGION_NOTEMPTY(sprite.screen, &sprite.Reg1)) + REGION_TRANSLATE(sprite.screen, &sprite.Reg1, xoff, yoff); + if (REGION_NOTEMPTY(sprite.screen, &sprite.Reg2)) + REGION_TRANSLATE(sprite.screen, &sprite.Reg2, xoff, yoff); + + /* FIXME: if we call ConfineCursorToWindow, must we do anything else? */ + if ((grab = inputInfo.pointer->grab) && grab->confineTo) { + if (grab->confineTo->drawable.pScreen != sprite.hotPhys.pScreen) + sprite.hotPhys.x = sprite.hotPhys.y = 0; + ConfineCursorToWindow(grab->confineTo, TRUE, TRUE); + } else + ConfineCursorToWindow(WindowTable[sprite.hotPhys.pScreen->myNum], + TRUE, FALSE); +} +#endif + void DefineInitialRootWindow(win) register WindowPtr win; @@ -2637,6 +2692,52 @@ ProcessKeyboardEvent (xE, keybd, count) GrabPtr grab = keybd->grab; Bool deactivateGrab = FALSE; register KeyClassPtr keyc = keybd->key; +#ifdef XEVIE + static Window rootWin = 0; + + if(!xeviegrabState && xevieFlag && clients[xevieClientIndex] && + (xevieMask & xevieFilters[xE->u.u.type])) { + key = xE->u.u.detail; + kptr = &keyc->down[key >> 3]; + bit = 1 << (key & 7); + if((xE->u.u.type == KeyPress && (*kptr & bit)) || + (xE->u.u.type == KeyRelease && !(*kptr & bit))) + {} else { +#ifdef XKB + if(!noXkbExtension) + xevieKBEventSent = 0; +#endif + if(!xevieKBEventSent) + { + xeviekb = keybd; + if(!rootWin) { + WindowPtr pWin = xeviewin->parent; + while(pWin) { + if(!pWin->parent) { + rootWin = pWin->drawable.id; + break; + } + pWin = pWin->parent; + }; + } + xE->u.keyButtonPointer.event = xeviewin->drawable.id; + xE->u.keyButtonPointer.root = rootWin; + xE->u.keyButtonPointer.child = (xeviewin->firstChild) ? xeviewin->firstChild-> +drawable.id:0; + xE->u.keyButtonPointer.rootX = xeviehot.x; + xE->u.keyButtonPointer.rootY = xeviehot.y; + xE->u.keyButtonPointer.state = keyc->state; + WriteToClient(clients[xevieClientIndex], sizeof(xEvent), (char *)xE); +#ifdef XKB + if(noXkbExtension) +#endif + return; + }else { + xevieKBEventSent = 0; + } + } + } +#endif if (!syncEvents.playingEvents) { @@ -2782,6 +2883,18 @@ ProcessPointerEvent (xE, mouse, count) #ifdef XKB XkbSrvInfoPtr xkbi= inputInfo.keyboard->key->xkbInfo; #endif +#ifdef XEVIE + if(xevieFlag && clients[xevieClientIndex] && !xeviegrabState && + (xevieMask & xevieFilters[xE->u.u.type])) { + if(xevieEventSent) + xevieEventSent = 0; + else { + xeviemouse = mouse; + WriteToClient(clients[xevieClientIndex], sizeof(xEvent), (char *)xE); + return; + } + } +#endif if (!syncEvents.playingEvents) NoticeTime(xE) diff --git a/dix/globals.c b/dix/globals.c index 0ffedc828..4b62e4867 100644 --- a/dix/globals.c +++ b/dix/globals.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/dix/globals.c,v 1.1.4.3.4.2 2004/03/04 20:16:04 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/dix/globals.c,v 1.2 2004/04/23 19:04:44 eich Exp $ */ /* $XFree86: xc/programs/Xserver/dix/globals.c,v 1.12tsi Exp $ */ /************************************************************ diff --git a/dix/main.c b/dix/main.c index ed6b6f6e1..0d0842215 100644 --- a/dix/main.c +++ b/dix/main.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/dix/main.c,v 1.1.4.5.2.4 2004/03/08 00:36:56 alanc Exp $ */ +/* $XdotOrg: xc/programs/Xserver/dix/main.c,v 1.3 2004/06/30 20:06:53 kem Exp $ */ /* $XFree86: xc/programs/Xserver/dix/main.c,v 3.43 2003/10/30 21:21:02 herrb Exp $ */ /*********************************************************** @@ -251,6 +251,8 @@ main(int argc, char *argv[], char *envp[]) display = "0"; + InitGlobals(); + /* Quartz support on Mac OS X requires that the Cocoa event loop be in * the main thread. This allows the X server main to be called again * from another thread. */ @@ -498,6 +500,21 @@ main(int argc, char *argv[], char *envp[]) return(0); } +static int VendorRelease = VENDOR_RELEASE; +static char *VendorString = VENDOR_STRING; + +void +SetVendorRelease(int release) +{ + VendorRelease = release; +} + +void +SetVendorString(char *string) +{ + VendorString = string; +} + static int padlength[4] = {0, 3, 2, 1}; #ifndef PANORAMIX @@ -521,7 +538,7 @@ CreateConnectionBlock() /* Leave off the ridBase and ridMask, these must be sent with connection */ - setup.release = VENDOR_RELEASE; + setup.release = VendorRelease; /* * per-server image and bitmap parameters are defined in Xmd.h */ @@ -533,7 +550,7 @@ CreateConnectionBlock() setup.bitmapBitOrder = screenInfo.bitmapBitOrder; setup.motionBufferSize = NumMotionEvents(); setup.numRoots = screenInfo.numScreens; - setup.nbytesVendor = strlen(VENDOR_STRING); + setup.nbytesVendor = strlen(VendorString); setup.numFormats = screenInfo.numPixmapFormats; setup.maxRequestSize = MAX_REQUEST_SIZE; QueryMinMaxKeyCodes(&setup.minKeyCode, &setup.maxKeyCode); @@ -550,7 +567,7 @@ CreateConnectionBlock() sizesofar = sizeof(xConnSetup); pBuf = ConnectionInfo + sizeof(xConnSetup); - memmove(pBuf, VENDOR_STRING, (int)setup.nbytesVendor); + memmove(pBuf, VendorString, (int)setup.nbytesVendor); sizesofar += setup.nbytesVendor; pBuf += setup.nbytesVendor; i = padlength[setup.nbytesVendor & 3]; diff --git a/dix/privates.c b/dix/privates.c index 64d705e24..672738f29 100644 --- a/dix/privates.c +++ b/dix/privates.c @@ -358,7 +358,7 @@ InitCmapPrivFunc initPrivFunc; pColormap->devPrivates = privs; - if (!privs || !(*initPrivFunc)(pColormap)) + if (!privs || !(*initPrivFunc)(pColormap,index)) { colormapPrivateCount--; return -1; diff --git a/dix/resource.c b/dix/resource.c index 7984f01ac..e394fdd57 100644 --- a/dix/resource.c +++ b/dix/resource.c @@ -74,7 +74,7 @@ Equipment Corporation. ******************************************************************/ /* $Xorg: resource.c,v 1.5 2001/02/09 02:04:40 xorgcvs Exp $ */ -/* $XdotOrg: xc/programs/Xserver/dix/resource.c,v 1.1.4.4.2.3 2004/03/08 00:36:56 alanc Exp $ */ +/* $XdotOrg: xc/programs/Xserver/dix/resource.c,v 1.3 2004/04/25 22:42:09 gisburn Exp $ */ /* $TOG: resource.c /main/41 1998/02/09 14:20:31 kaleb $ */ /* Routines to manage various kinds of resources: @@ -559,7 +559,7 @@ FreeResource(id, skipDeleteFuncType) } } if (!gotOne) - FatalError("Freeing resource id=%lX which isn't there", + ErrorF("Freeing resource id=%lX which isn't there.\n", (unsigned long)id); } diff --git a/dix/window.c b/dix/window.c index 36289db5b..6660bfbd6 100644 --- a/dix/window.c +++ b/dix/window.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/dix/window.c,v 1.1.4.4.2.3 2004/03/08 00:36:56 alanc Exp $ */ +/* $XdotOrg: xc/programs/Xserver/dix/window.c,v 1.6 2004/07/31 08:24:13 anholt Exp $ */ /* $Xorg: window.c,v 1.4 2001/02/09 02:04:41 xorgcvs Exp $ */ /* @@ -291,6 +291,9 @@ SetWindowToDefaults(register WindowPtr pWin) pWin->srcBuffer = DBE_FRONT_BUFFER; pWin->dstBuffer = DBE_FRONT_BUFFER; #endif +#ifdef COMPOSITE + pWin->redirectDraw = 0; +#endif } static void @@ -1661,6 +1664,19 @@ void SetWinSize (pWin) register WindowPtr pWin; { +#ifdef COMPOSITE + if (pWin->redirectDraw) + { + BoxRec box; + + box.x1 = pWin->drawable.x; + box.y1 = pWin->drawable.y; + box.x2 = pWin->drawable.x + pWin->drawable.width; + box.y2 = pWin->drawable.y + pWin->drawable.height; + REGION_RESET (pScreen, &pWin->winSize, &box); + } + else +#endif ClippedRegionFromBox(pWin->parent, &pWin->winSize, pWin->drawable.x, pWin->drawable.y, (int)pWin->drawable.width, @@ -1691,6 +1707,19 @@ SetBorderSize (pWin) if (HasBorder (pWin)) { bw = wBorderWidth (pWin); +#ifdef COMPOSITE + if (pWin->redirectDraw) + { + BoxRec box; + + box.x1 = pWin->drawable.x - bw; + box.y1 = pWin->drawable.y - bw; + box.x2 = pWin->drawable.x + pWin->drawable.width + bw; + box.y2 = pWin->drawable.y + pWin->drawable.height + bw; + REGION_RESET (pScreen, &pWin->borderSize, &box); + } + else +#endif ClippedRegionFromBox(pWin->parent, &pWin->borderSize, pWin->drawable.x - bw, pWin->drawable.y - bw, (int)(pWin->drawable.width + (bw<<1)), @@ -3152,10 +3181,17 @@ HandleSaveSet(client) for (j=0; j<client->numSaved; j++) { - pWin = (WindowPtr)client->saveSet[j]; - pParent = pWin->parent; - while (pParent && (wClient (pParent) == client)) - pParent = pParent->parent; + pWin = SaveSetWindow(client->saveSet[j]); +#ifdef XFIXES + if (SaveSetToRoot(client->saveSet[j])) + pParent = WindowTable[pWin->drawable.pScreen->myNum]; + else +#endif + { + pParent = pWin->parent; + while (pParent && (wClient (pParent) == client)) + pParent = pParent->parent; + } if (pParent) { if (pParent != pWin->parent) @@ -3167,12 +3203,15 @@ HandleSaveSet(client) if(!pWin->realized && pWin->mapped) pWin->mapped = FALSE; } - MapWindow(pWin, client); +#ifdef XFIXES + if (SaveSetRemap (client->saveSet[j])) +#endif + MapWindow(pWin, client); } } xfree(client->saveSet); client->numSaved = 0; - client->saveSet = (pointer *)NULL; + client->saveSet = (SaveSetElt *)NULL; } Bool @@ -3227,8 +3266,9 @@ SendVisibilityNotify(pWin) WindowPtr pWin; { xEvent event; +#ifndef NO_XINERAMA_PORT unsigned int visibility = pWin->visibility; - +#endif #ifdef PANORAMIX /* This is not quite correct yet, but it's close */ if(!noPanoramiXExtension) { @@ -22,6 +22,8 @@ * PERFORMANCE OF THIS SOFTWARE. */ +/* $XdotOrg: xc/programs/Xserver/fb/fb.h,v 1.6 2004/08/11 21:14:17 kem Exp $ */ + #ifndef _FB_H_ #define _FB_H_ @@ -103,9 +105,10 @@ typedef unsigned __int64 FbBits; # else # if defined(__alpha__) || defined(__alpha) || \ defined(ia64) || defined(__ia64__) || \ - defined(__sparc64__) || \ + defined(__sparc64__) || defined(_LP64) || \ defined(__s390x__) || \ defined(amd64) || defined (__amd64__) || \ + defined (__powerpc64__) || \ (defined(sgi) && (_MIPS_SZLONG == 64)) typedef unsigned long FbBits; # else @@ -562,9 +565,13 @@ extern void fbSetBits (FbStip *bits, int stride, FbStip data); } \ } +/* XXX fb*PrivateIndex should be static, but it breaks the ABI */ + extern int fbGCPrivateIndex; +extern int fbGetGCPrivateIndex(void); #ifndef FB_NO_WINDOW_PIXMAPS extern int fbWinPrivateIndex; +extern int fbGetWinPrivateIndex(void); #endif extern const GCOps fbGCOps; extern const GCFuncs fbGCFuncs; @@ -575,6 +582,7 @@ extern const GCFuncs fbGCFuncs; #endif #ifdef FB_OLD_SCREEN +# define FB_OLD_MISCREENINIT /* miScreenInit requires 14 args, not 13 */ extern WindowPtr *WindowTable; #endif @@ -584,6 +592,7 @@ extern WindowPtr *WindowTable; #ifdef FB_SCREEN_PRIVATE extern int fbScreenPrivateIndex; +extern int fbGetScreenPrivateIndex(void); /* private field of a screen */ typedef struct { @@ -592,7 +601,7 @@ typedef struct { } FbScreenPrivRec, *FbScreenPrivPtr; #define fbGetScreenPrivate(pScreen) ((FbScreenPrivPtr) \ - (pScreen)->devPrivates[fbScreenPrivateIndex].ptr) + (pScreen)->devPrivates[fbGetScreenPrivateIndex()].ptr) #endif /* private field of GC */ @@ -616,7 +625,7 @@ typedef struct { } FbGCPrivRec, *FbGCPrivPtr; #define fbGetGCPrivate(pGC) ((FbGCPrivPtr)\ - (pGC)->devPrivates[fbGCPrivateIndex].ptr) + (pGC)->devPrivates[fbGetGCPrivateIndex()].ptr) #ifdef FB_OLD_GC #define fbGetCompositeClip(pGC) (fbGetGCPrivate(pGC)->pCompositeClip) @@ -635,7 +644,7 @@ typedef struct { #define fbGetWindowPixmap(d) fbGetScreenPixmap(((DrawablePtr) (d))->pScreen) #else #define fbGetWindowPixmap(pWin) ((PixmapPtr)\ - ((WindowPtr) (pWin))->devPrivates[fbWinPrivateIndex].ptr) + ((WindowPtr) (pWin))->devPrivates[fbGetWinPrivateIndex()].ptr) #endif #if defined(__DARWIN__)||defined(__CYGWIN__) diff --git a/fb/fballpriv.c b/fb/fballpriv.c index e7fcfd45b..29e98ae9f 100644 --- a/fb/fballpriv.c +++ b/fb/fballpriv.c @@ -27,10 +27,22 @@ #ifdef FB_SCREEN_PRIVATE int fbScreenPrivateIndex; +int fbGetScreenPrivateIndex(void) +{ + return fbScreenPrivateIndex; +} #endif int fbGCPrivateIndex; +int fbGetGCPrivateIndex(void) +{ + return fbGCPrivateIndex; +} #ifndef FB_NO_WINDOW_PIXMAPS int fbWinPrivateIndex; +int fbGetWinPrivateIndex(void) +{ + return fbWinPrivateIndex; +} #endif int fbGeneration; diff --git a/fb/fbcompose.c b/fb/fbcompose.c index e374de692..181a85f4f 100644 --- a/fb/fbcompose.c +++ b/fb/fbcompose.c @@ -1,5 +1,5 @@ /* - * $XdotOrg: xc/programs/Xserver/fb/fbcompose.c,v 1.1.4.2.4.2 2004/03/04 20:16:09 kaleb Exp $ + * $XdotOrg: xc/programs/Xserver/fb/fbcompose.c,v 1.3 2004/05/12 01:49:46 anholt Exp $ * $XFree86: xc/programs/Xserver/fb/fbcompose.c,v 1.17tsi Exp $ * * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc. @@ -191,15 +191,15 @@ fbCombineMaskAlphaC (FbCompositeOperand *src, a = (*msk->fetcha) (msk); if (!a) return 0; - - x = (*src->fetcha) (src); - if (a == 0xffffffff) - return x; - - m = FbInC(x,0,a,t); - n = FbInC(x,8,a,t); - o = FbInC(x,16,a,t); - p = FbInC(x,24,a,t); + + x = (*src->fetch) (src) >> 24; + if (x == 0xff) + return a; + + m = FbInU(a,0,x,t); + n = FbInU(a,8,x,t); + o = FbInU(a,16,x,t); + p = FbInU(a,24,x,t); return m|n|o|p; } @@ -608,7 +608,7 @@ fbCombineAtopC (FbCompositeOperand *src, cs = fbCombineMaskC (src, msk); d = (*dst->fetch) (dst); s = cs.value; - ad = cs.alpha; + ad = ~cs.alpha; as = d >> 24; m = FbGen(s,d,0,as,FbGet8(ad,0),t,u,v); n = FbGen(s,d,8,as,FbGet8(ad,8),t,u,v); @@ -698,10 +698,10 @@ fbCombineXorC (FbCompositeOperand *src, s = cs.value; ad = ~cs.alpha; as = ~d >> 24; - m = FbGen(s,d,0,as,ad,t,u,v); - n = FbGen(s,d,8,as,ad,t,u,v); - o = FbGen(s,d,16,as,ad,t,u,v); - p = FbGen(s,d,24,as,ad,t,u,v); + m = FbGen(s,d,0,as,FbGet8(ad,0),t,u,v); + n = FbGen(s,d,8,as,FbGet8(ad,8),t,u,v); + o = FbGen(s,d,16,as,FbGet8(ad,16),t,u,v); + p = FbGen(s,d,24,as,FbGet8(ad,24),t,u,v); (*dst->store) (dst, m|n|o|p); } @@ -763,10 +763,9 @@ fbCombineSaturateU (FbCompositeOperand *src, FbCompositeOperand *dst) { CARD32 s = fbCombineMaskU (src, msk), d; -#if 0 CARD16 sa, da; CARD16 ad, as; - CARD16 t; + CARD16 t, u, v; CARD32 m,n,o,p; d = (*dst->fetch) (dst); @@ -789,16 +788,6 @@ fbCombineSaturateU (FbCompositeOperand *src, p = FbGen(s,d,24,as,ad,t,u,v); } (*dst->store) (dst, m|n|o|p); -#else - if ((s >> 24) == 0xff) - (*dst->store) (dst, s); - else - { - d = (*dst->fetch) (dst); - if ((s >> 24) > (d >> 24)) - (*dst->store) (dst, s); - } -#endif } void @@ -831,7 +820,7 @@ fbCombineSaturateC (FbCompositeOperand *src, else n = FbGen (s, d, 8, (da << 8) / sg, 0xff, t, u, v); - if (sr < da) + if (sr <= da) o = FbAdd(s,d,16,t); else o = FbGen (s, d, 16, (da << 8) / sr, 0xff, t, u, v); @@ -972,8 +961,8 @@ fbCombineDisjointGeneralC (FbCompositeOperand *src, FbCompSrc cs; CARD32 s, d; CARD32 m,n,o,p; - CARD32 Fa; - CARD16 Fb, t, u, v; + CARD32 Fa, Fb; + CARD16 t, u, v; CARD32 sa; CARD8 da; @@ -996,10 +985,10 @@ fbCombineDisjointGeneralC (FbCompositeOperand *src, Fa = m|n|o|p; break; case CombineAIn: - m = fbCombineDisjointOutPart ((CARD8) (sa >> 0), da); - n = fbCombineDisjointOutPart ((CARD8) (sa >> 8), da) << 8; - o = fbCombineDisjointOutPart ((CARD8) (sa >> 16), da) << 16; - p = fbCombineDisjointOutPart ((CARD8) (sa >> 24), da) << 24; + m = fbCombineDisjointInPart ((CARD8) (sa >> 0), da); + n = fbCombineDisjointInPart ((CARD8) (sa >> 8), da) << 8; + o = fbCombineDisjointInPart ((CARD8) (sa >> 16), da) << 16; + p = fbCombineDisjointInPart ((CARD8) (sa >> 24), da) << 24; Fa = m|n|o|p; break; case CombineA: @@ -1012,19 +1001,27 @@ fbCombineDisjointGeneralC (FbCompositeOperand *src, Fb = 0; break; case CombineBOut: - Fb = fbCombineDisjointOutPart (da, sa); + m = fbCombineDisjointOutPart (da, (CARD8) (sa >> 0)); + n = fbCombineDisjointOutPart (da, (CARD8) (sa >> 8)) << 8; + o = fbCombineDisjointOutPart (da, (CARD8) (sa >> 16)) << 16; + p = fbCombineDisjointOutPart (da, (CARD8) (sa >> 24)) << 24; + Fb = m|n|o|p; break; case CombineBIn: - Fb = fbCombineDisjointInPart (da, sa); + m = fbCombineDisjointInPart (da, (CARD8) (sa >> 0)); + n = fbCombineDisjointInPart (da, (CARD8) (sa >> 8)) << 8; + o = fbCombineDisjointInPart (da, (CARD8) (sa >> 16)) << 16; + p = fbCombineDisjointInPart (da, (CARD8) (sa >> 24)) << 24; + Fb = m|n|o|p; break; case CombineB: - Fb = 0xff; + Fb = 0xffffffff; break; } - m = FbGen (s,d,0,FbGet8(Fa,0),Fb,t,u,v); - n = FbGen (s,d,8,FbGet8(Fa,8),Fb,t,u,v); - o = FbGen (s,d,16,FbGet8(Fa,16),Fb,t,u,v); - p = FbGen (s,d,24,FbGet8(Fa,24),Fb,t,u,v); + m = FbGen (s,d,0,FbGet8(Fa,0),FbGet8(Fb,0),t,u,v); + n = FbGen (s,d,8,FbGet8(Fa,8),FbGet8(Fb,8),t,u,v); + o = FbGen (s,d,16,FbGet8(Fa,16),FbGet8(Fb,16),t,u,v); + p = FbGen (s,d,24,FbGet8(Fa,24),FbGet8(Fb,24),t,u,v); s = m|n|o|p; (*dst->store) (dst, s); } @@ -1065,21 +1062,6 @@ fbCombineDisjointOverC (FbCompositeOperand *src, fbCombineDisjointGeneralC (src, msk, dst, CombineAOver); } -void -fbCombineDisjointOverReverseU (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst) -{ - fbCombineDisjointGeneralU (src, msk, dst, CombineBOver); -} - -void -fbCombineDisjointOverReverseC (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst) -{ - fbCombineDisjointGeneralC (src, msk, dst, CombineBOver); -} void fbCombineDisjointInU (FbCompositeOperand *src, @@ -1281,8 +1263,8 @@ fbCombineConjointGeneralC (FbCompositeOperand *src, FbCompSrc cs; CARD32 s, d; CARD32 m,n,o,p; - CARD32 Fa; - CARD16 Fb, t, u, v; + CARD32 Fa, Fb; + CARD16 t, u, v; CARD32 sa; CARD8 da; @@ -1305,10 +1287,10 @@ fbCombineConjointGeneralC (FbCompositeOperand *src, Fa = m|n|o|p; break; case CombineAIn: - m = fbCombineConjointOutPart ((CARD8) (sa >> 0), da); - n = fbCombineConjointOutPart ((CARD8) (sa >> 8), da) << 8; - o = fbCombineConjointOutPart ((CARD8) (sa >> 16), da) << 16; - p = fbCombineConjointOutPart ((CARD8) (sa >> 24), da) << 24; + m = fbCombineConjointInPart ((CARD8) (sa >> 0), da); + n = fbCombineConjointInPart ((CARD8) (sa >> 8), da) << 8; + o = fbCombineConjointInPart ((CARD8) (sa >> 16), da) << 16; + p = fbCombineConjointInPart ((CARD8) (sa >> 24), da) << 24; Fa = m|n|o|p; break; case CombineA: @@ -1321,19 +1303,27 @@ fbCombineConjointGeneralC (FbCompositeOperand *src, Fb = 0; break; case CombineBOut: - Fb = fbCombineConjointOutPart (da, sa); + m = fbCombineConjointOutPart (da, (CARD8) (sa >> 0)); + n = fbCombineConjointOutPart (da, (CARD8) (sa >> 8)) << 8; + o = fbCombineConjointOutPart (da, (CARD8) (sa >> 16)) << 16; + p = fbCombineConjointOutPart (da, (CARD8) (sa >> 24)) << 24; + Fb = m|n|o|p; break; case CombineBIn: - Fb = fbCombineConjointInPart (da, sa); + m = fbCombineConjointInPart (da, (CARD8) (sa >> 0)); + n = fbCombineConjointInPart (da, (CARD8) (sa >> 8)) << 8; + o = fbCombineConjointInPart (da, (CARD8) (sa >> 16)) << 16; + p = fbCombineConjointInPart (da, (CARD8) (sa >> 24)) << 24; + Fb = m|n|o|p; break; case CombineB: - Fb = 0xff; + Fb = 0xffffffff; break; } - m = FbGen (s,d,0,FbGet8(Fa,0),Fb,t,u,v); - n = FbGen (s,d,8,FbGet8(Fa,8),Fb,t,u,v); - o = FbGen (s,d,16,FbGet8(Fa,16),Fb,t,u,v); - p = FbGen (s,d,24,FbGet8(Fa,24),Fb,t,u,v); + m = FbGen (s,d,0,FbGet8(Fa,0),FbGet8(Fb,0),t,u,v); + n = FbGen (s,d,8,FbGet8(Fa,8),FbGet8(Fb,8),t,u,v); + o = FbGen (s,d,16,FbGet8(Fa,16),FbGet8(Fb,16),t,u,v); + p = FbGen (s,d,24,FbGet8(Fa,24),FbGet8(Fb,24),t,u,v); s = m|n|o|p; (*dst->store) (dst, s); } @@ -1519,14 +1509,14 @@ FbCombineFunc fbCombineFuncU[] = { fbCombineAtopReverseU, fbCombineXorU, fbCombineAddU, - fbCombineDisjointOverU, /* Saturate */ + fbCombineSaturateU, 0, 0, fbCombineClear, fbCombineSrcU, fbCombineDst, fbCombineDisjointOverU, - fbCombineDisjointOverReverseU, + fbCombineSaturateU, /* DisjointOverReverse */ fbCombineDisjointInU, fbCombineDisjointInReverseU, fbCombineDisjointOutU, @@ -1566,14 +1556,14 @@ FbCombineFunc fbCombineFuncC[] = { fbCombineAtopReverseC, fbCombineXorC, fbCombineAddC, - fbCombineDisjointOverC, /* Saturate */ + fbCombineSaturateC, 0, 0, fbCombineClear, /* 0x10 */ fbCombineSrcC, fbCombineDst, fbCombineDisjointOverC, - fbCombineDisjointOverReverseC, + fbCombineSaturateC, /* DisjointOverReverse */ fbCombineDisjointInC, fbCombineDisjointInReverseC, fbCombineDisjointOutC, diff --git a/fb/fbedge.c b/fb/fbedge.c new file mode 100644 index 000000000..7a383020b --- /dev/null +++ b/fb/fbedge.c @@ -0,0 +1,134 @@ +/* + * $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 "fb.h" + +#ifdef RENDER + +#include "picturestr.h" +#include "mipict.h" +#include "renderedge.h" +#include "fbpict.h" + +/* + * 8 bit alpha + */ + +#define N_BITS 8 +#define rasterizeEdges fbRasterizeEdges8 + +#define DefineAlpha(line,x) \ + CARD8 *__ap = (CARD8 *) line + (x) + +#define StepAlpha __ap++ + +#define AddAlpha(a) { \ + CARD16 __a = a + *__ap; \ + *__ap = ((CARD8) ((__a) | (0 - ((__a) >> 8)))); \ +} + +#include "fbedgeimp.h" + +#undef AddAlpha +#undef StepAlpha +#undef DefineAlpha +#undef rasterizeEdges +#undef N_BITS + +/* + * 4 bit alpha + */ + +#define N_BITS 4 +#define rasterizeEdges fbRasterizeEdges4 + +#if BITMAP_BIT_ORDER == LSBFirst +#define Shift4(o) ((o) << 2) +#else +#define Shift4(o) ((1-(o)) << 2) +#endif + +#define Get4(x,o) (((x) >> Shift4(o)) & 0xf) +#define Put4(x,o,v) (((x) & ~(0xf << Shift4(o))) | (((v) & 0xf) << Shift4(o))) + +#define DefineAlpha(line,x) \ + CARD8 *__ap = (CARD8 *) line + ((x) >> 1); \ + int __ao = (x) & 1 + +#define StepAlpha ((__ap += __ao), (__ao ^= 1)) + +#define AddAlpha(a) { \ + CARD8 __o = *__ap; \ + CARD8 __a = (a) + Get4(__o, __ao); \ + *__ap = Put4 (__o, __ao, __a | (0 - ((__a) >> 4))); \ +} + +#include "fbedgeimp.h" + +#undef AddAlpha +#undef StepAlpha +#undef DefineAlpha +#undef rasterizeEdges +#undef N_BITS + + +/* + * 1 bit alpha + */ + +#define N_BITS 1 +#define rasterizeEdges fbRasterizeEdges1 + +#include "fbedgeimp.h" + +#undef rasterizeEdges +#undef N_BITS + +void +fbRasterizeEdges (FbBits *buf, + int bpp, + int width, + int stride, + RenderEdge *l, + RenderEdge *r, + xFixed t, + xFixed b) +{ + switch (bpp) { + case 1: + fbRasterizeEdges1 (buf, width, stride, l, r, t, b); + break; + case 4: + fbRasterizeEdges4 (buf, width, stride, l, r, t, b); + break; + case 8: + fbRasterizeEdges8 (buf, width, stride, l, r, t, b); + break; + } +} + +#endif /* RENDER */ diff --git a/fb/fbedgeimp.h b/fb/fbedgeimp.h new file mode 100644 index 000000000..4a91adc19 --- /dev/null +++ b/fb/fbedgeimp.h @@ -0,0 +1,134 @@ +/* + * $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. + */ + +#ifndef rasterizeSpan +#endif + +static void +rasterizeEdges (FbBits *buf, + int width, + int stride, + RenderEdge *l, + RenderEdge *r, + xFixed t, + xFixed b) +{ + xFixed y = t; + FbBits *line; + + line = buf + xFixedToInt (y) * stride; + + for (;;) + { + xFixed lx, rx; + int lxi, rxi; + + /* clip X */ + lx = l->x; + if (lx < 0) + lx = 0; + rx = r->x; + if (xFixedToInt (rx) >= width) + rx = IntToxFixed (width); + + /* Skip empty (or backwards) sections */ + if (rx > lx) + { + + /* Find pixel bounds for span */ + lxi = xFixedToInt (lx); + rxi = xFixedToInt (rx); + +#if N_BITS == 1 + { + FbBits *a = line; + FbBits startmask, endmask; + int nmiddle; + int width = rxi - lxi; + int x = lxi; + + a += x >> FB_SHIFT; + x &= FB_MASK; + + FbMaskBits (x, width, startmask, nmiddle, endmask); + if (startmask) + *a++ |= startmask; + while (nmiddle--) + *a++ = FB_ALLONES; + if (endmask) + *a |= endmask; + } +#else + { + DefineAlpha(line,lxi); + int lxs, rxs; + + /* Sample coverage for edge pixels */ + lxs = RenderSamplesX (lx, N_BITS); + rxs = RenderSamplesX (rx, N_BITS); + + /* Add coverage across row */ + if (lxi == rxi) + { + AddAlpha (rxs - lxs); + } + else + { + int xi; + + AddAlpha (N_X_FRAC(N_BITS) - lxs); + StepAlpha; + for (xi = lxi + 1; xi < rxi; xi++) + { + AddAlpha (N_X_FRAC(N_BITS)); + StepAlpha; + } + AddAlpha (rxs); + } + } +#endif + } + + if (y == b) + break; + +#if N_BITS > 1 + if (xFixedFrac (y) != Y_FRAC_LAST(N_BITS)) + { + RenderEdgeStepSmall (l); + RenderEdgeStepSmall (r); + y += STEP_Y_SMALL(N_BITS); + } + else +#endif + { + RenderEdgeStepBig (l); + RenderEdgeStepBig (r); + y += STEP_Y_BIG(N_BITS); + line += stride; + } + } +} + +#undef rasterizeSpan diff --git a/fb/fbfill.c b/fb/fbfill.c index d03bc6461..f5842c252 100644 --- a/fb/fbfill.c +++ b/fb/fbfill.c @@ -24,6 +24,7 @@ /* $XFree86: xc/programs/Xserver/fb/fbfill.c,v 1.5 2003/01/29 00:43:33 torrey Exp $ */ #include "fb.h" +#include "fbmmx.h" void fbFill (DrawablePtr pDrawable, @@ -43,6 +44,11 @@ fbFill (DrawablePtr pDrawable, switch (pGC->fillStyle) { case FillSolid: +#ifdef USE_GCC34_MMX + if (!pPriv->and && fbHaveMMX()) + if (fbSolidFillmmx (pDrawable, x, y, width, height, pPriv->xor)) + return; +#endif fbSolid (dst + (y + dstYoff) * dstStride, dstStride, (x + dstXoff) * dstBpp, @@ -21,7 +21,7 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ -/* $XdotOrg: xc/programs/Xserver/fb/fbgc.c,v 1.1.4.1.4.2 2004/03/04 20:16:09 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/fb/fbgc.c,v 1.2 2004/04/23 19:05:14 eich Exp $ */ /* $XFree86: xc/programs/Xserver/fb/fbgc.c,v 1.14 2003/12/18 15:22:32 alanh Exp $ */ #include "fb.h" diff --git a/fb/fbglyph.c b/fb/fbglyph.c index 1e13f76d1..128abc4bf 100644 --- a/fb/fbglyph.c +++ b/fb/fbglyph.c @@ -1,5 +1,5 @@ /* - * $XdotOrg: xc/programs/Xserver/fb/fbglyph.c,v 1.1.4.1.4.2 2004/03/04 20:16:09 kaleb Exp $ + * $XdotOrg: xc/programs/Xserver/fb/fbglyph.c,v 1.2 2004/04/23 19:05:14 eich Exp $ * $XFree86: xc/programs/Xserver/fb/fbglyph.c,v 1.12tsi Exp $ * * Copyright © 1998 Keith Packard diff --git a/fb/fboverlay.c b/fb/fboverlay.c index 28068db83..e9ac14eda 100644 --- a/fb/fboverlay.c +++ b/fb/fboverlay.c @@ -1,5 +1,5 @@ /* - * $XFree86: xc/programs/Xserver/fb/fboverlay.c,v 1.6tsi Exp $ + * $XFree86: xc/programs/Xserver/fb/fboverlay.c,v 1.7 2003/11/10 18:21:47 tsi Exp $ * * Copyright © 2000 SuSE, Inc. * @@ -23,12 +23,19 @@ * Author: Keith Packard, SuSE, Inc. */ +/* $XdotOrg: xc/programs/Xserver/fb/fboverlay.c,v 1.4 2004/07/30 20:30:51 ajax Exp $ */ + #include "fb.h" #include "fboverlay.h" int fbOverlayGeneration; int fbOverlayScreenPrivateIndex = -1; +int fbOverlayGetScreenPrivateIndex(void) +{ + return fbOverlayScreenPrivateIndex; +} + /* * Replace this if you want something supporting * multiple overlays with the same depth @@ -402,7 +409,7 @@ fbOverlayFinishScreenInit(ScreenPtr pScreen, if (! miScreenInit(pScreen, 0, xsize, ysize, dpix, dpiy, 0, depth1, ndepths, depths, defaultVisual, nvisuals, visuals -#ifdef FB_OLD_SCREEN +#ifdef FB_OLD_MISCREENINIT , (miBSFuncPtr) 0 #endif )) diff --git a/fb/fboverlay.h b/fb/fboverlay.h index 72891ece3..aecb3856f 100644 --- a/fb/fboverlay.h +++ b/fb/fboverlay.h @@ -27,7 +27,8 @@ #define _FBOVERLAY_H_ extern int fbOverlayGeneration; -extern int fbOverlayScreenPrivateIndex; +extern int fbOverlayScreenPrivateIndex; /* XXX should be static */ +extern int fbOverlayGetScreenPrivateIndex(void); #ifndef FB_OVERLAY_MAX #define FB_OVERLAY_MAX 2 @@ -58,8 +59,8 @@ typedef struct _fbOverlayScrPriv { } FbOverlayScrPrivRec, *FbOverlayScrPrivPtr; #define fbOverlayGetScrPriv(s) \ - ((fbOverlayScreenPrivateIndex != -1) ? \ - (s)->devPrivates[fbOverlayScreenPrivateIndex].ptr : NULL) + ((fbOverlayGetScreenPrivateIndex() != -1) ? \ + (s)->devPrivates[fbOverlayGetScreenPrivateIndex()].ptr : NULL) Bool fbOverlayCreateWindow(WindowPtr pWin); diff --git a/fb/fbpict.c b/fb/fbpict.c index 533f08d01..ff638e5ce 100644 --- a/fb/fbpict.c +++ b/fb/fbpict.c @@ -30,34 +30,8 @@ #include "picturestr.h" #include "mipict.h" #include "fbpict.h" +#include "fbmmx.h" -#define cvt8888to0565(s) ((((s) >> 3) & 0x001f) | \ - (((s) >> 5) & 0x07e0) | \ - (((s) >> 8) & 0xf800)) -#define cvt0565to8888(s) (((((s) << 3) & 0xf8) | (((s) >> 2) & 0x7)) | \ - ((((s) << 5) & 0xfc00) | (((s) >> 1) & 0x300)) | \ - ((((s) << 8) & 0xf80000) | (((s) << 3) & 0x70000))) - -#if IMAGE_BYTE_ORDER == MSBFirst -#define Fetch24(a) ((unsigned long) (a) & 1 ? \ - ((*(a) << 16) | *((CARD16 *) ((a)+1))) : \ - ((*((CARD16 *) (a)) << 8) | *((a)+2))) -#define Store24(a,v) ((unsigned long) (a) & 1 ? \ - ((*(a) = (CARD8) ((v) >> 16)), \ - (*((CARD16 *) ((a)+1)) = (CARD16) (v))) : \ - ((*((CARD16 *) (a)) = (CARD16) ((v) >> 8)), \ - (*((a)+2) = (CARD8) (v)))) -#else -#define Fetch24(a) ((unsigned long) (a) & 1 ? \ - ((*(a)) | (*((CARD16 *) ((a)+1)) << 8)) : \ - ((*((CARD16 *) (a))) | (*((a)+2) << 16))) -#define Store24(a,v) ((unsigned long) (a) & 1 ? \ - ((*(a) = (CARD8) (v)), \ - (*((CARD16 *) ((a)+1)) = (CARD16) ((v) >> 8))) : \ - ((*((CARD16 *) (a)) = (CARD16) (v)),\ - (*((a)+2) = (CARD8) ((v) >> 16)))) -#endif - CARD32 fbOver (CARD32 x, CARD32 y) { @@ -99,43 +73,6 @@ fbIn (CARD32 x, CARD8 y) return m|n|o|p; } -#define fbComposeGetSolid(pict, bits) { \ - FbBits *__bits__; \ - FbStride __stride__; \ - int __bpp__; \ - int __xoff__,__yoff__; \ -\ - fbGetDrawable((pict)->pDrawable,__bits__,__stride__,__bpp__,__xoff__,__yoff__); \ - switch (__bpp__) { \ - case 32: \ - (bits) = *(CARD32 *) __bits__; \ - break; \ - case 24: \ - (bits) = Fetch24 ((CARD8 *) __bits__); \ - break; \ - case 16: \ - (bits) = *(CARD16 *) __bits__; \ - (bits) = cvt0565to8888(bits); \ - break; \ - default: \ - return; \ - } \ - /* manage missing src alpha */ \ - if ((pict)->pFormat->direct.alphaMask == 0) \ - (bits) |= 0xff000000; \ -} - -#define fbComposeGetStart(pict,x,y,type,stride,line,mul) {\ - FbBits *__bits__; \ - FbStride __stride__; \ - int __bpp__; \ - int __xoff__,__yoff__; \ -\ - fbGetDrawable((pict)->pDrawable,__bits__,__stride__,__bpp__,__xoff__,__yoff__); \ - (stride) = __stride__ * sizeof (FbBits) / sizeof (type); \ - (line) = ((type *) __bits__) + (stride) * ((y) - __yoff__) + (mul) * ((x) - __xoff__); \ -} - /* * Naming convention: * @@ -168,7 +105,7 @@ fbCompositeSolidMask_nx8x8888 (CARD8 op, srca = src >> 24; if (src == 0) return; - + fbComposeGetStart (pDst, xDst, yDst, CARD32, dstStride, dstLine, 1); fbComposeGetStart (pMask, xMask, yMask, CARD8, maskStride, maskLine, 1); @@ -940,7 +877,12 @@ fbComposite (CARD8 op, switch (pDst->format) { case PICT_r5g6b5: case PICT_b5g6r5: - func = fbCompositeSolidMask_nx8x0565; +#ifdef USE_GCC34_MMX + if (fbHaveMMX()) + func = fbCompositeSolidMask_nx8x0565mmx; + else +#endif + func = fbCompositeSolidMask_nx8x0565; break; case PICT_r8g8b8: case PICT_b8g8r8: @@ -950,7 +892,12 @@ fbComposite (CARD8 op, case PICT_x8r8g8b8: case PICT_a8b8g8r8: case PICT_x8b8g8r8: - func = fbCompositeSolidMask_nx8x8888; +#ifdef USE_GCC34_MMX + if (fbHaveMMX()) + func = fbCompositeSolidMask_nx8x8888mmx; + else +#endif + func = fbCompositeSolidMask_nx8x8888; break; } break; @@ -959,10 +906,20 @@ fbComposite (CARD8 op, switch (pDst->format) { case PICT_a8r8g8b8: case PICT_x8r8g8b8: - func = fbCompositeSolidMask_nx8888x8888C; +#ifdef USE_GCC34_MMX + if (fbHaveMMX()) + func = fbCompositeSolidMask_nx8888x8888Cmmx; + else +#endif + func = fbCompositeSolidMask_nx8888x8888C; break; case PICT_r5g6b5: - func = fbCompositeSolidMask_nx8888x0565C; +#ifdef USE_GCC34_MMX + if (fbHaveMMX()) + func = fbCompositeSolidMask_nx8888x0565Cmmx; + else +#endif + func = fbCompositeSolidMask_nx8888x0565C; break; } } @@ -972,10 +929,20 @@ fbComposite (CARD8 op, switch (pDst->format) { case PICT_a8b8g8r8: case PICT_x8b8g8r8: - func = fbCompositeSolidMask_nx8888x8888C; +#ifdef USE_GCC34_MMX + if (fbHaveMMX()) + func = fbCompositeSolidMask_nx8888x8888Cmmx; + else +#endif + func = fbCompositeSolidMask_nx8888x8888C; break; case PICT_b5g6r5: - func = fbCompositeSolidMask_nx8888x0565C; +#ifdef USE_GCC34_MMX + if (fbHaveMMX()) + func = fbCompositeSolidMask_nx8888x0565Cmmx; + else +#endif + func = fbCompositeSolidMask_nx8888x0565C; break; } } @@ -993,57 +960,145 @@ fbComposite (CARD8 op, func = fbCompositeSolidMask_nx1xn; break; } + break; + } + } + } + else /* has mask and non-repeating source */ + { + if (pSrc->pDrawable == pMask->pDrawable && + xSrc == xMask && ySrc == yMask && + !pMask->componentAlpha) + { + switch (pSrc->format) { + case PICT_x8b8g8r8: + switch (pMask->format) { + case PICT_a8r8g8b8: + case PICT_a8b8g8r8: + switch (pDst->format) { + case PICT_a8r8g8b8: + case PICT_x8r8g8b8: +#ifdef USE_GCC34_MMX + if (fbHaveMMX()) + func = fbCompositeSrc_8888RevNPx8888mmx; +#endif + break; + case PICT_r5g6b5: +#ifdef USE_GCC34_MMX + if (fbHaveMMX()) + func = fbCompositeSrc_8888RevNPx0565mmx; +#endif + break; + } + break; + } + break; + case PICT_x8r8g8b8: + switch (pMask->format) { + case PICT_a8r8g8b8: + case PICT_a8b8g8r8: + switch (pDst->format) { + case PICT_a8b8g8r8: + case PICT_x8b8g8r8: +#ifdef USE_GCC34_MMX + if (fbHaveMMX()) + func = fbCompositeSrc_8888RevNPx8888mmx; +#endif + break; + case PICT_r5g6b5: +#ifdef USE_GCC34_MMX + if (fbHaveMMX()) + func = fbCompositeSrc_8888RevNPx0565mmx; +#endif + break; + } + break; + } + break; } + break; } } } else { - switch (pSrc->format) { - case PICT_a8r8g8b8: - case PICT_x8r8g8b8: - switch (pDst->format) { + if (srcRepeat && + pSrc->pDrawable->width == 1 && + pSrc->pDrawable->height == 1) + { + /* no mask and repeating source */ + switch (pSrc->format) { case PICT_a8r8g8b8: - case PICT_x8r8g8b8: - func = fbCompositeSrc_8888x8888; - break; - case PICT_r8g8b8: - func = fbCompositeSrc_8888x0888; - break; - case PICT_r5g6b5: - func = fbCompositeSrc_8888x0565; + switch (pDst->format) { + case PICT_a8r8g8b8: + case PICT_x8r8g8b8: +#ifdef USE_GCC34_MMX + if (fbHaveMMX()) + { + srcRepeat = FALSE; + func = fbCompositeSolid_nx8888mmx; + } +#endif + break; + case PICT_r5g6b5: +#ifdef USE_GCC34_MMX + if (fbHaveMMX()) + { + srcRepeat = FALSE; + func = fbCompositeSolid_nx0565mmx; + } +#endif + break; + } break; } - break; - case PICT_a8b8g8r8: - case PICT_x8b8g8r8: - switch (pDst->format) { - case PICT_a8b8g8r8: - case PICT_x8b8g8r8: - func = fbCompositeSrc_8888x8888; - break; - case PICT_b8g8r8: - func = fbCompositeSrc_8888x0888; + } + else + { + switch (pSrc->format) { + case PICT_a8r8g8b8: + switch (pDst->format) { + case PICT_a8r8g8b8: + case PICT_x8r8g8b8: + func = fbCompositeSrc_8888x8888; + break; + case PICT_r8g8b8: + func = fbCompositeSrc_8888x0888; + break; + case PICT_r5g6b5: + func = fbCompositeSrc_8888x0565; + break; + } break; - case PICT_b5g6r5: - func = fbCompositeSrc_8888x0565; + case PICT_a8b8g8r8: + switch (pDst->format) { + case PICT_a8b8g8r8: + case PICT_x8b8g8r8: + func = fbCompositeSrc_8888x8888; + break; + case PICT_b8g8r8: + func = fbCompositeSrc_8888x0888; + break; + case PICT_b5g6r5: + func = fbCompositeSrc_8888x0565; + break; + } break; - } - break; - case PICT_r5g6b5: - switch (pDst->format) { case PICT_r5g6b5: - func = fbCompositeSrc_0565x0565; + switch (pDst->format) { + case PICT_r5g6b5: + func = fbCompositeSrc_0565x0565; + break; + } break; - } - break; - case PICT_b5g6r5: - switch (pDst->format) { case PICT_b5g6r5: - func = fbCompositeSrc_0565x0565; + switch (pDst->format) { + case PICT_b5g6r5: + func = fbCompositeSrc_0565x0565; + break; + } break; } - break; } } break; @@ -1054,21 +1109,36 @@ fbComposite (CARD8 op, case PICT_a8r8g8b8: switch (pDst->format) { case PICT_a8r8g8b8: - func = fbCompositeSrcAdd_8888x8888; +#ifdef USE_GCC34_MMX + if (fbHaveMMX()) + func = fbCompositeSrcAdd_8888x8888mmx; + else +#endif + func = fbCompositeSrcAdd_8888x8888; break; } break; case PICT_a8b8g8r8: switch (pDst->format) { case PICT_a8b8g8r8: - func = fbCompositeSrcAdd_8888x8888; +#ifdef USE_GCC34_MMX + if (fbHaveMMX()) + func = fbCompositeSrcAdd_8888x8888mmx; + else +#endif + func = fbCompositeSrcAdd_8888x8888; break; } break; case PICT_a8: switch (pDst->format) { case PICT_a8: - func = fbCompositeSrcAdd_8000x8000; +#ifdef USE_GCC34_MMX + if (fbHaveMMX()) + func = fbCompositeSrcAdd_8000x8000mmx; + else +#endif + func = fbCompositeSrcAdd_8000x8000; break; } break; @@ -1160,6 +1230,8 @@ fbPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats) ps->Glyphs = miGlyphs; ps->CompositeRects = miCompositeRects; ps->RasterizeTrapezoid = fbRasterizeTrapezoid; + ps->AddTraps = fbAddTraps; + ps->AddTriangles = fbAddTriangles; #endif /* RENDER */ diff --git a/fb/fbpict.h b/fb/fbpict.h index 9ecc7a909..82f722c41 100644 --- a/fb/fbpict.h +++ b/fb/fbpict.h @@ -25,6 +25,8 @@ #ifndef _FBPICT_H_ #define _FBPICT_H_ +#include "renderedge.h" + #define FbIntMult(a,b,t) ( (t) = (a) * (b) + 0x80, ( ( ( (t)>>8 ) + (t) )>>8 ) ) #define FbIntDiv(a,b) (((CARD16) (a) * 255) / (b)) @@ -70,6 +72,70 @@ typedef void (*CompositeFunc) (CARD8 op, CARD16 width, CARD16 height); +#define fbComposeGetSolid(pict, bits) { \ + FbBits *__bits__; \ + FbStride __stride__; \ + int __bpp__; \ + int __xoff__,__yoff__; \ +\ + fbGetDrawable((pict)->pDrawable,__bits__,__stride__,__bpp__,__xoff__,__yoff__); \ + switch (__bpp__) { \ + case 32: \ + (bits) = *(CARD32 *) __bits__; \ + break; \ + case 24: \ + (bits) = Fetch24 ((CARD8 *) __bits__); \ + break; \ + case 16: \ + (bits) = *(CARD16 *) __bits__; \ + (bits) = cvt0565to8888(bits); \ + break; \ + default: \ + return; \ + } \ + /* manage missing src alpha */ \ + if ((pict)->pFormat->direct.alphaMask == 0) \ + (bits) |= 0xff000000; \ +} + +#define fbComposeGetStart(pict,x,y,type,stride,line,mul) {\ + FbBits *__bits__; \ + FbStride __stride__; \ + int __bpp__; \ + int __xoff__,__yoff__; \ +\ + fbGetDrawable((pict)->pDrawable,__bits__,__stride__,__bpp__,__xoff__,__yoff__); \ + (stride) = __stride__ * sizeof (FbBits) / sizeof (type); \ + (line) = ((type *) __bits__) + (stride) * ((y) - __yoff__) + (mul) * ((x) - __xoff__); \ +} +#define cvt8888to0565(s) ((((s) >> 3) & 0x001f) | \ + (((s) >> 5) & 0x07e0) | \ + (((s) >> 8) & 0xf800)) +#define cvt0565to8888(s) (((((s) << 3) & 0xf8) | (((s) >> 2) & 0x7)) | \ + ((((s) << 5) & 0xfc00) | (((s) >> 1) & 0x300)) | \ + ((((s) << 8) & 0xf80000) | (((s) << 3) & 0x70000))) + +#if IMAGE_BYTE_ORDER == MSBFirst +#define Fetch24(a) ((unsigned long) (a) & 1 ? \ + ((*(a) << 16) | *((CARD16 *) ((a)+1))) : \ + ((*((CARD16 *) (a)) << 8) | *((a)+2))) +#define Store24(a,v) ((unsigned long) (a) & 1 ? \ + ((*(a) = (CARD8) ((v) >> 16)), \ + (*((CARD16 *) ((a)+1)) = (CARD16) (v))) : \ + ((*((CARD16 *) (a)) = (CARD16) ((v) >> 8)), \ + (*((a)+2) = (CARD8) (v)))) +#else +#define Fetch24(a) ((unsigned long) (a) & 1 ? \ + ((*(a)) | (*((CARD16 *) ((a)+1)) << 8)) : \ + ((*((CARD16 *) (a))) | (*((a)+2) << 16))) +#define Store24(a,v) ((unsigned long) (a) & 1 ? \ + ((*(a) = (CARD8) (v)), \ + (*((CARD16 *) ((a)+1)) = (CARD16) ((v) >> 8))) : \ + ((*((CARD16 *) (a)) = (CARD16) (v)),\ + (*((a)+2) = (CARD8) ((v) >> 16)))) +#endif + + typedef struct _FbCompositeOperand FbCompositeOperand; typedef CARD32 (*FbCompositeFetch)(FbCompositeOperand *op); @@ -333,15 +399,8 @@ fbCombineDisjointOverC (FbCompositeOperand *src, FbCompositeOperand *msk, FbCompositeOperand *dst); -void -fbCombineDisjointOverReverseU (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); - -void -fbCombineDisjointOverReverseC (FbCompositeOperand *src, - FbCompositeOperand *msk, - FbCompositeOperand *dst); +#define fbCombineDisjointOverReverseU fbCombineSaturateU +#define fbCombineDisjointOverReverseC fbCombineSaturateC void fbCombineDisjointInU (FbCompositeOperand *src, @@ -760,6 +819,17 @@ fbCompositeGeneral (CARD8 op, CARD16 height); +/* fbedge.c */ +void +fbRasterizeEdges (FbBits *buf, + int bpp, + int width, + int stride, + RenderEdge *l, + RenderEdge *r, + xFixed t, + xFixed b); + /* fbpict.c */ CARD32 fbOver (CARD32 x, CARD32 y); @@ -967,10 +1037,25 @@ fbComposite (CARD8 op, CARD16 height); /* fbtrap.c */ + +void +fbAddTraps (PicturePtr pPicture, + INT16 xOff, + INT16 yOff, + int ntrap, + xTrap *traps); + void fbRasterizeTrapezoid (PicturePtr alpha, xTrapezoid *trap, int x_off, int y_off); +void +fbAddTriangles (PicturePtr pPicture, + INT16 xOff, + INT16 yOff, + int ntri, + xTriangle *tris); + #endif /* _FBPICT_H_ */ diff --git a/fb/fbpixmap.c b/fb/fbpixmap.c index e47999dbb..e3abf2b4c 100644 --- a/fb/fbpixmap.c +++ b/fb/fbpixmap.c @@ -73,6 +73,11 @@ fbCreatePixmapBpp (ScreenPtr pScreen, int width, int height, int depth, int bpp) fbInitializeDrawable (&pPixmap->drawable); #endif +#ifdef COMPOSITE + pPixmap->screen_x = 0; + pPixmap->screen_y = 0; +#endif + return pPixmap; } diff --git a/fb/fbscreen.c b/fb/fbscreen.c index 2a46b00be..8815c69e6 100644 --- a/fb/fbscreen.c +++ b/fb/fbscreen.c @@ -1,4 +1,4 @@ -/* +/* $XdotOrg: xc/programs/Xserver/fb/fbscreen.c,v 1.3 2004/05/16 05:08:39 alanc Exp $ * Id: fbscreen.c,v 1.1 1999/11/02 03:54:45 keithp Exp $ * * Copyright © 1998 Keith Packard @@ -21,7 +21,7 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ -/* $XFree86: xc/programs/Xserver/fb/fbscreen.c,v 1.11 2000/09/03 05:09:47 keithp Exp $ */ +/* $XFree86: xc/programs/Xserver/fb/fbscreen.c,v 1.13 2001/05/29 04:54:09 keithp Exp $ */ #include "fb.h" @@ -229,7 +229,7 @@ fbFinishScreenInit(ScreenPtr pScreen, if (! miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width, rootdepth, ndepths, depths, defaultVisual, nvisuals, visuals -#ifdef FB_OLD_SCREEN +#ifdef FB_OLD_MISCREENINIT , (miBSFuncPtr) 0 #endif )) diff --git a/fb/fbsolid.c b/fb/fbsolid.c index a325da0c2..4b7ff1936 100644 --- a/fb/fbsolid.c +++ b/fb/fbsolid.c @@ -49,7 +49,6 @@ fbSolid (FbBits *dst, return; } #endif - dst += dstX >> FB_SHIFT; dstX &= FB_MASK; FbMaskBitsBytes(dstX, width, and == 0, startmask, startbyte, diff --git a/fb/fbtrap.c b/fb/fbtrap.c index 8fcd2b5cc..09bff0bfd 100644 --- a/fb/fbtrap.c +++ b/fb/fbtrap.c @@ -1,30 +1,26 @@ /* - * $XFree86: xc/programs/Xserver/fb/fbtrap.c,v 1.9 2002/09/26 02:56:48 keithp Exp $ + * $Id$ * - * Copyright © 2000 University of Southern California + * 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 University - * of Southern California not be used in advertising or publicity - * pertaining to distribution of the software without specific, - * written prior permission. University of Southern California makes - * no representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied - * warranty. + * 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. * - * University of Southern California DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE 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: Carl Worth, USC, Information Sciences Institute */ + * 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 "fb.h" @@ -32,1351 +28,208 @@ #include "picturestr.h" #include "mipict.h" +#include "renderedge.h" #include "fbpict.h" -#ifdef DEBUG -#include <stdio.h> -#include <assert.h> - -#define ASSERT(e) assert(e) - -#endif - -#ifndef ASSERT -#define ASSERT(e) -#endif - -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#define MIN(a, b) ((a) < (b) ? (a) : (b)) - -#define MAX_AREA 0x80000000 - -/* - * A RationalPoint is an exact position along one of the trapezoid - * edges represented by an approximate position (x,y) and two error - * terms (ex_dy, ey_dx). The error in X is multiplied by the Y - * dimension of the line while the error in Y is multiplied by the - * X dimension of the line, allowing an exact measurement of the - * distance from (x,y) to the line. - * - * Generally, while walking an edge, one of ex_dy/ey_dx will be zero - * indicating that the position error is held in the other. - */ -typedef struct { - xFixed x; - xFixed ex_dy; - xFixed y; - xFixed ey_dx; -} RationalPoint; - -/* - * Edges are walked both horizontally and vertically - * They are walked vertically to get to a particular row - * of pixels, and then walked horizontally within that row - * to compute pixel coverage. - * - * Edges are always walked from top to bottom and from - * left to right. This means that for lines moving leftwards - * from top to bottom, the left to right walking actually moves - * backwards along the line with respect to the top to bottom - * walking. - */ - -/* - * A RationalRow represents the two positions where - * an edge intersects a row of pixels. This is used - * to walk an edge vertically - */ - -typedef struct { - RationalPoint top; /* intersection at top of row */ - RationalPoint bottom; /* intersection at bottom of row */ - RationalPoint pixel_top; /* intersection at top of pixel */ -} RationalRow; - -/* - * A RationalCol represents the two positions where - * an edge intersects a column of pixels - */ - -typedef struct { - RationalPoint left; /* intersection at left of column */ - RationalPoint right; /* intersection at right of column */ -} RationalCol; - -/* - Here are some thoughts on line walking: - - Conditions: c2.x - c1.x = 1 - r2.y - r1.y = 1 - - A B C D E F G H - c1\ c1 c2 /c2 -r1 r1 |\ \ r1 r1 / r1/| r1 r1 -\-+---+ \-+---+ +-\-+ +\--+ +--/+ +-/-+ +---+-/ +---+-/ - \| | `.c1 | |r1\| | \ | | / | |/ | | .' | |/ -c1\ | |`-.|c2 | \c2 | | | | | | c1/ | c1|,_/|c2 | /c2 - |\ | | `. | |\ | \ | | / | /| | ./ | | /| - +-\-+ +---+-\ +---+-\ +--\+ +/--+ /-+---+ /-+---+ +-/-+ - r2\| r2 r2 r2\ /r2 r2 r2 |/r2 - \c2 c2 c1 c1/ - - Bottom Right Right Bottom Top Top Right Right - -State transitions: - -A -> C, D E -> E, F -B -> A, B F -> G, H -C -> A, B G -> G, H -D -> C, D H -> E, F - -*/ - -/* - * Values for PixelWalk.depart. Top and Bottom can have the same value - * as only one mode is possible given a line of either positive or - * negative slope. These mark the departure edge while walking - * rightwards across columns. - */ - -typedef enum _departure { - DepartTop = 0, /* edge exits top of pixel */ - DepartBottom = 0, /* edge exits bottom of pixel */ - DepartRight = 1 /* edge exits right edge of pixel */ -} Departure; - -/* - * PixelWalk - * - * This structure holds state to walk a single edge down the trapezoid. - * - * The edge is walked twice -- once by rows and once by columns. - * The two intersections of the pixel by the edge are then set - * from either the row or column position, depending on which edge - * is intersected. - * - * Note that for lines moving left, walking by rows moves down the - * line (increasing y) while walking by columns moves up the line - * (decreasing y). - */ -typedef struct { - xFixed dx; - xFixed ey_thresh; - xFixed dy; - xFixed ex_thresh; - - Departure depart; - - /* slope */ - xFixed m; - xFixed em_dx; - xFixed y_correct; - xFixed ey_correct; - - /* Inverse slope. Does this have a standard symbol? */ - xFixed p; - xFixed ep_dy; - xFixed x_correct; - xFixed ex_correct; - - /* Trapezoid bottom, used to limit walking to the last row */ - xFixed bottom; - - /* - * Current edge positions along pixel rows and columns - */ - RationalRow row; - RationalCol col; - - /* - * The three pixel intersection points, copied from the appropriate - * row or column position above - */ - RationalPoint p_pixel_top; - RationalPoint p_trap_top; - RationalPoint p_trap_bottom; -} PixelWalk; - -#if 0 -#ifdef GCC -#define INLINE inline -#endif -#endif - -#ifndef INLINE -#define INLINE -#endif - -/* - * Step 'pt' vertically to 'newy'. - */ -static INLINE void -pixelWalkMovePointToRow (PixelWalk *pw, RationalPoint *pt, xFixed newy) +void +fbAddTraps (PicturePtr pPicture, + INT16 x_off, + INT16 y_off, + int ntrap, + xTrap *traps) { - xFixed_32_32 oex; - xFixed xoff; - - /* X error of old X position and new Y position */ - oex = (xFixed_32_32) pw->dx * (newy - pt->y) - pt->ey_dx + pt->ex_dy; + FbBits *buf; + int bpp; + int width; + int stride; + int height; + int pxoff, pyoff; + + xFixed x_off_fixed; + xFixed y_off_fixed; + RenderEdge l, r; + xFixed t, b; - /* amount to step X by */ - xoff = oex / pw->dy; + fbGetDrawable (pPicture->pDrawable, buf, stride, bpp, pxoff, pyoff); - /* step X */ - pt->x = pt->x + xoff; + width = pPicture->pDrawable->width; + height = pPicture->pDrawable->height; + x_off += pxoff; + y_off += pyoff; - /* set new X error value for new X position and new Y positition */ - pt->ex_dy = oex - (xFixed_32_32) pw->dy * xoff; + x_off_fixed = IntToxFixed(y_off); + y_off_fixed = IntToxFixed(y_off); - /* set new Y position, set Y error to zero */ - pt->y = newy; - pt->ey_dx = 0; -} - -/* - * Step 'pt' horizontally to 'newx' - */ -static INLINE void -pixelWalkMovePointToCol (PixelWalk *pw, RationalPoint *pt, xFixed newx) -{ - xFixed_32_32 oey; - xFixed yoff; - - /* Special case vertical lines to arbitrary y */ - if (pw->dx == 0) + while (ntrap--) { - pt->x = newx; - pt->ex_dy = 0; - pt->y = 0; - pt->ey_dx = 0; - } - else - { - /* Y error of old Y position and new X position */ - oey = (xFixed_32_32) pw->dy * (newx - pt->x) - pt->ex_dy + pt->ey_dx; - - /* amount to step Y by */ - yoff = oey / pw->dx; - - /* step Y */ - pt->y = pt->y + yoff; - - /* set new Y error value for new Y position and new X position */ - pt->ey_dx = oey - (xFixed_32_32) pw->dx * yoff; - - /* set new X position, set X error to zero */ - pt->x = newx; - pt->ex_dy = 0; - } -} - -/* - * Step the 'row' element of 'pw' vertically - * (increasing y) by one whole pixel - */ -static INLINE void -pixelWalkStepRow (PixelWalk *pw) -{ - xFixed y_next = xFixedFloor (pw->row.bottom.y) + xFixed1; + t = traps->top.y + y_off_fixed; + if (t < 0) + t = 0; + t = RenderSampleCeilY (t, bpp); - if (y_next > pw->bottom) - y_next = pw->bottom; - - /* pw.row.top.y < pw.row.bottom.y */ - pw->row.top = pw->row.bottom; - - if (y_next - pw->row.bottom.y == xFixed1) - { - pw->row.pixel_top = pw->row.bottom; - pw->row.bottom.y += xFixed1; - pw->row.bottom.x += pw->p; - pw->row.bottom.ex_dy += pw->ep_dy; - if (abs (pw->row.bottom.ex_dy) > pw->ex_thresh) - { - pw->row.bottom.x += pw->x_correct; - pw->row.bottom.ex_dy += pw->ex_correct; - } - } - else - { - pixelWalkMovePointToRow (pw, &pw->row.pixel_top, - xFixedCeil (y_next) - xFixed1); - pixelWalkMovePointToRow (pw, &pw->row.bottom, y_next); - } -} - -/* - * Step the 'col' element of 'pw' horizontally - * (increasing x) by one whole pixel - */ -static INLINE void -pixelWalkStepCol (PixelWalk *pw) -{ - /* pw.col.p1.x < pw.col.p2.x */ - /* - * Copy the current right point into the left point - */ - pw->col.left = pw->col.right; - - /* - * Now incrementally walk across the pixel - */ - pw->col.right.x += xFixed1; - pw->col.right.y += pw->m; - pw->col.right.ey_dx += pw->em_dx; - if (pw->col.right.ey_dx > pw->ey_thresh) - { - pw->col.right.y += pw->y_correct; - pw->col.right.ey_dx += pw->ey_correct; - } -} -/* - * Walk to the nearest edge of the next pixel, filling in both p1 and - * p2 as necessary from either the row or col intersections. - * - * The "next" pixel is defined to be the next pixel intersected by the - * line with pixels visited in raster scan order, (for the benefit of - * cache performance). For lines with positive slope it is easy to - * achieve raster scan order by simply calling StepCol for each pixel - * in a given scanline, then calling StepRow once at the end of each - * scanline. - * - * However, for lines of negative slope where the magnitude of dx is - * greater than dy, a little more work needs to be done. The pixels of - * a particular scanline will be visited by succesive calls to StepCol - * as before. This will effectively step "up" the line as we scan from - * left to right. But, the call to StepRow at the end of the scan line - * will step "down" the line and the column information will be - * invalid at that point. - * - * For now, I fix up the column of all negative slope lines by calling - * MovePointToCol at the end of each scanline. However, this is an - * extremely expensive operation since it involves a 64-bit multiply - * and a 64-bit divide. It would be much better, (at least as long as - * abs(dx) is not much greater than dy), to instead step the col - * backwards as many times as necessary. Or even better, we could - * simply restore col to the position it began at when we started the - * scanline, then simply step it backwards once. That would give a - * performance benefit for lines with slope of any magnitude. - */ - -static INLINE void -pixelWalkNextPixel (PixelWalk *pw) -{ - if (pw->dx < 0) - { - /* - * left moving lines - * - * Check which pixel edge we're departing from - * - * Remember that in this case (dx < 0), the 'row' element of 'pw' - * walks down the line while 'col' walks up - */ - if (pw->depart == DepartTop) - { - /* - * The edge departs the row at this pixel, the - * next time it gets used will be for the next row - * - * Step down one row and then recompute the - * column values to start the next row of - * pixels - */ - pixelWalkStepRow(pw); - /* - * Set column exit pixel - */ - pixelWalkMovePointToCol(pw, &pw->col.right, xFixedFloor(pw->row.bottom.x)); - /* - * This moves the exit pixel to the entry pixel - * and computes the next exit pixel - */ - pixelWalkStepCol(pw); - /* - * The first pixel on the next row will always - * be entered from below, set the lower - * intersection of this edge with that pixel - */ - pw->p_trap_bottom = pw->row.bottom; - } - else /* pw->depart == DepartRight */ - { - /* - * easy case -- just move right one pixel - */ - pixelWalkStepCol(pw); - /* - * Set the lower intersection of the edge with the - * pixel -- that's just where the edge entered - * the pixel from the left - */ - pw->p_trap_bottom = pw->col.left; - } - /* - * Now compute which edge the pixel - * is departing from - */ - if (pw->row.top.x <= pw->col.right.x) - { - /* - * row intersection is left of column intersection, - * that means the edge hits the top of the pixel - * before it hits the right edge - */ - pw->p_trap_top = pw->row.top; - pw->depart = DepartTop; - /* - * Further check to see whether the edge - * leaves the right or top edge of the - * whole pixel - */ - if (pw->row.pixel_top.x <= pw->col.right.x) - pw->p_pixel_top = pw->row.pixel_top; - else - pw->p_pixel_top = pw->col.right; - } - else - { - /* - * Row intersection is right of colum intersection, - * that means the edge hits the right edge of the - * pixel first - */ - pw->p_trap_top = pw->col.right; - pw->p_pixel_top = pw->col.right; - pw->depart = DepartRight; - } - } - else - { - /* - * right moving lines - * - * Check which edge we're departing from - * - * In the dx >= 0 case, the row and col elements both - * walk downwards - */ - if (pw->depart == DepartBottom) - { - /* - * The edge departs the row at this pixel, - * the next time it gets used will be for the - * next row - * - * Step down one row and (maybe) over one - * column to prepare for the next row - */ - if (pw->row.bottom.x == pw->col.right.x) - { - /* - * right through the corner of the pixel, - * adjust the column - */ - pixelWalkStepCol(pw); - } - pixelWalkStepRow(pw); - /* - * Set the upper intersection of the edge with - * the pixel, the first pixel on the next - * row is always entered from the top - */ - pw->p_trap_top = pw->row.top; - pw->p_pixel_top = pw->row.pixel_top; - } - else /* pw->depart == DepartRight */ - { - /* - * Easy case -- move right one - * pixel - */ - pixelWalkStepCol(pw); - /* - * Set the upper intersection of the edge - * with the pixel, that's along the left - * edge of the pixel - */ - pw->p_trap_top = pw->col.left; - pw->p_pixel_top = pw->col.left; - } - /* - * Now compute the exit edge and the - * lower intersection of the edge with the pixel - */ - if (pw->row.bottom.x <= pw->col.right.x) - { - /* - * Hit the place where the edge leaves - * the pixel, the lower intersection is - * where the edge hits the bottom - */ - pw->p_trap_bottom = pw->row.bottom; - pw->depart = DepartBottom; - } - else - { - /* - * The edge goes through the - * next pixel on the row, - * the lower intersection is where the - * edge hits the right side of the pixel - */ - pw->p_trap_bottom = pw->col.right; - pw->depart = DepartRight; - } - } -} - -/* - * Compute the first pixel intersection points - * and the departure type from that pixel - */ -static void -pixelWalkFirstPixel (PixelWalk *pw) -{ - if (pw->dx < 0) - { - if (pw->row.top.x <= pw->col.right.x) - { - /* - * leaving through the top. - * upper position is the upper point of - * the 'row' element - */ - pw->depart = DepartTop; - pw->p_trap_top = pw->row.top; - /* - * further check for pixel top - */ - if (pw->row.pixel_top.x <= pw->col.right.x) - pw->p_pixel_top = pw->row.pixel_top; - else - pw->p_pixel_top = pw->col.right; - } - else - { - /* - * leaving through the right side - * upper position is the right point of - * the 'col' element - */ - pw->depart = DepartRight; - pw->p_trap_top = pw->col.right; - pw->p_pixel_top = pw->col.right; - } - /* - * Now find the lower pixel intersection point - */ - if (pw->row.bottom.x >= pw->col.left.x) - /* - * entering through bottom, - * lower position is the bottom point of - * the 'row' element - */ - pw->p_trap_bottom = pw->row.bottom; - else - /* - * entering through left side, - * lower position is the left point of - * the 'col' element - */ - pw->p_trap_bottom = pw->col.left; - } - else - { - if (pw->row.bottom.x <= pw->col.right.x) - { - /* - * leaving through the bottom (or corner). - * lower position is the lower point of - * the 'row' element - */ - pw->depart = DepartBottom; - pw->p_trap_bottom = pw->row.bottom; - } - else - { - /* - * leaving through the right side - * lower position is the right point of - * the 'col' element - */ - pw->depart = DepartRight; - pw->p_trap_bottom = pw->col.right; - } - /* - * Now find the upper pixel intersection point - */ - if (pw->row.top.x >= pw->col.left.x) - { - /* - * entering through the top (or corner), - * upper position is the top point - * of the 'row' element - */ - pw->p_trap_top = pw->row.top; - /* - * further check for pixel entry - */ - if (pw->row.pixel_top.x >= pw->col.left.x) - pw->p_pixel_top = pw->row.pixel_top; - else - pw->p_pixel_top = pw->col.left; - } - else - { - /* - * entering through the left side, - * upper position is the left point of - * the 'col' element - */ - pw->p_trap_top = pw->col.left; - pw->p_pixel_top = pw->col.left; + b = traps->bot.y + y_off_fixed; + if (xFixedToInt (b) >= height) + b = IntToxFixed (height) - 1; + b = RenderSampleFloorY (b, bpp); + + if (b >= t) + { + /* initialize edge walkers */ + RenderEdgeInit (&l, bpp, t, + traps->top.l + x_off_fixed, + traps->top.y + y_off_fixed, + traps->bot.l + x_off_fixed, + traps->bot.y + y_off_fixed); + + RenderEdgeInit (&r, bpp, t, + traps->top.r + x_off_fixed, + traps->top.y + y_off_fixed, + traps->bot.r + x_off_fixed, + traps->bot.y + y_off_fixed); + + fbRasterizeEdges (buf, bpp, width, stride, &l, &r, t, b); } + traps++; } } -static void -pixelWalkInit (PixelWalk *pw, xLineFixed *line, xFixed top_y, xFixed bottom_y) +void +fbRasterizeTrapezoid (PicturePtr pPicture, + xTrapezoid *trap, + int x_off, + int y_off) { - xFixed_32_32 dy_inc, dx_inc; - xFixed next_y; - xFixed left_x; - xPointFixed *top, *bot; - - next_y = xFixedFloor (top_y) + xFixed1; - if (next_y > bottom_y) - next_y = bottom_y; - - /* - * Orient lines top down - */ - if (line->p1.y < line->p2.y) - { - top = &line->p1; - bot = &line->p2; - } - else - { - top = &line->p2; - bot = &line->p1; - } - - pw->dx = bot->x - top->x; - pw->ey_thresh = abs(pw->dx >> 1); - pw->dy = bot->y - top->y; - pw->ex_thresh = pw->dy >> 1; - - /* - * Set step values for walking lines - */ - if (pw->dx < 0) - { - pw->x_correct = -1; - pw->ex_correct = pw->dy; - pw->y_correct = -1; - pw->ey_correct = pw->dx; - } - else - { - pw->x_correct = 1; - pw->ex_correct = -pw->dy; - pw->y_correct = 1; - pw->ey_correct = -pw->dx; - } - - pw->bottom = bottom_y; - - /* - * Compute Bresenham values for walking edges incrementally - */ - dy_inc = (xFixed_32_32) xFixed1 * pw->dy; /* > 0 */ - if (pw->dx != 0) - { - pw->m = dy_inc / pw->dx; /* sign(dx) */ - pw->em_dx = dy_inc - (xFixed_32_32) pw->m * pw->dx; /* > 0 */ - } - else - { - /* Vertical line. Setting these to zero prevents us from - having to put any conditions in pixelWalkStepCol. */ - pw->m = 0; - pw->em_dx = 0; - } - - dx_inc = (xFixed_32_32) xFixed1 * (xFixed_32_32) pw->dx; /* sign(dx) */ - pw->p = dx_inc / pw->dy; /* sign(dx) */ - pw->ep_dy = dx_inc - (xFixed_32_32) pw->p * pw->dy; /* sign(dx) */ - - /* - * Initialize 'row' for walking down rows - */ - pw->row.bottom.x = top->x; - pw->row.bottom.ex_dy = 0; - pw->row.bottom.y = top->y; - pw->row.bottom.ey_dx = 0; - - /* - * Initialize 'pixel_top' to be on the line for - * the first step - */ - pw->row.pixel_top = pw->row.bottom; - /* - * Move to the pixel above the 'top_y' coordinate, - * first setting 'bottom' and then using StepRow - * which moves that to 'top' and computes the next 'bottom' - */ - pixelWalkMovePointToRow(pw, &pw->row.bottom, top_y); - pixelWalkStepRow(pw); - - /* - * Initialize 'col' for walking across columns - */ - pw->col.right.x = top->x; - pw->col.right.ex_dy = 0; - pw->col.right.y = top->y; - pw->col.right.ey_dx = 0; - - /* - * First set the column to the left most - * pixel hit by the row - */ - if (pw->dx < 0) - left_x = pw->row.bottom.x; - else - left_x = pw->row.top.x; + FbBits *buf; + int bpp; + int width; + int stride; + int height; + int pxoff, pyoff; + + xFixed x_off_fixed; + xFixed y_off_fixed; + RenderEdge l, r; + xFixed t, b; - pixelWalkMovePointToCol(pw, &pw->col.right, xFixedFloor (left_x)); - pixelWalkStepCol(pw); - - /* - * Compute first pixel intersections and the - * first departure state - */ - pixelWalkFirstPixel (pw); -} - -#define RoundShift(a,b) (((a) + (1 << ((b) - 1))) >> (b)) -#define MaxAlpha(depth) ((1 << (depth)) - 1) - -#define AreaAlpha(area, depth) (RoundShift (RoundShift (area, depth) * \ - MaxAlpha (depth), \ - (31 - depth))) - -/* - Pixel coverage from the upper-left corner bounded by one horizontal - bottom line (bottom) and one line defined by two points, (x1,y1) and - (x2,y2), which intersect the pixel. y1 must be less than y2. There - are 8 cases yielding the following area calculations: - - A B C D E F G H -+---+ +---+ +-1-+ +1--+ +--1+ +-1-+ +---+ +---+ -| | 1 | | \| | \ | | / | |/ | | 1 | | -1 | |`-.| | 2 | | | | | | 2 | |,_/| | 1 -|\ | | 2 | | | \ | | / | | | 2 | | /| -+-2-+ +---+ +---+ +--2+ +2--+ +---+ +---+ +-2-+ - -A: (1/2 * x2 * (y2 - y1)) -B: (1/2 * x2 * (y2 - y1)) + (bottom - y2) * x2 -C: (1/2 * (x1 + x2) * y2 ) + (bottom - y2) * x2 -D: (1/2 * (x1 + x2) * y2 ) -E: (1/2 * (x1 + x2) * y2 ) -F: (1/2 * x1 * y2 ) -G: (1/2 * x1 * (y2 - y1)) + x1 * y1 -H: (1/2 * (x1 + x2) * (y2 - y1)) + x1 * y1 - -The union of these calculations is valid for all cases. Namely: - - (1/2 * (x1 + x2) * (y2 - y1)) + (bottom - y2) * x2 + x1 * y1 - -An exercise for later would perhaps be to optimize the calculations -for some of the cases above. Specifically, it's possible to eliminate -multiplications by zero in several cases, leaving a maximum of two -multiplies per pixel calculation. (This is even more promising now -that the higher level code actually computes the exact same 8 cases -as part of its pixel walking). - -But, for now, I just want to get something working correctly even if -slower. So, we'll use the non-optimized general equation. - -*/ - -/* 1.16 * 1.16 -> 1.31 */ -#define AREA_MULT(w, h) ( (xFixed_1_31) (((((xFixed_1_16)w)*((xFixed_1_16)h) + 1) >> 1) | (((xFixed_1_16)w)&((xFixed_1_16)h)&0x10000) << 15)) - -/* (1.16 + 1.16) / 2 -> 1.16 */ -#define WIDTH_AVG(x1,x2) (((x1) + (x2) + 1) >> 1) - -#define SubPixelArea(x1, y1, x2, y2, bottom) \ -(xFixed_1_31) ( \ - AREA_MULT((x1), (y1)) \ - + AREA_MULT(WIDTH_AVG((x1), (x2)), (y2) - (y1))\ - + AREA_MULT((x2), (bottom) - (y2)) \ -) + fbGetDrawable (pPicture->pDrawable, buf, stride, bpp, pxoff, pyoff); -/* -static xFixed_1_31 -SubPixelArea (xFixed_1_16 x1, - xFixed_1_16 y1, - xFixed_1_16 x2, - xFixed_1_16 y2, - xFixed_1_16 bottom) -{ - xFixed_1_16 x_trap; - xFixed_1_16 h_top, h_trap, h_bot; - xFixed_1_31 area; - - x_trap = WIDTH_AVG(x1,x2); - h_top = y1; - h_trap = (y2 - y1); - h_bot = (bottom - y2); + width = pPicture->pDrawable->width; + height = pPicture->pDrawable->height; + x_off += pxoff; + y_off += pyoff; - area = AREA_MULT(x1, h_top) + - AREA_MULT(x_trap, h_trap) + - AREA_MULT(x2, h_bot); - - return area; -} -*/ - -#define SubPixelAlpha(x1, y1, x2, y2, bottom, depth) \ -( \ - AreaAlpha( \ - SubPixelArea((x1), (y1), (x2), (y2), (bottom)), \ - (depth) \ - ) \ -) - -/* -static int -SubPixelAlpha (xFixed_1_16 x1, - xFixed_1_16 y1, - xFixed_1_16 x2, - xFixed_1_16 y2, - xFixed_1_16 bottom, - int depth) -{ - xFixed_1_31 area; - - area = SubPixelArea(x1, y1, x2, y2, bottom); + x_off_fixed = IntToxFixed(x_off); + y_off_fixed = IntToxFixed(y_off); + t = trap->top + y_off_fixed; + if (t < 0) + t = 0; + t = RenderSampleCeilY (t, bpp); + + b = trap->bottom + y_off_fixed; + if (xFixedToInt (b) >= height) + b = IntToxFixed (height) - 1; + b = RenderSampleFloorY (b, bpp); - return AreaAlpha(area, depth); + if (b >= t) + { + /* initialize edge walkers */ + RenderLineFixedEdgeInit (&l, bpp, t, &trap->left, x_off, y_off); + RenderLineFixedEdgeInit (&r, bpp, t, &trap->right, x_off, y_off); + + fbRasterizeEdges (buf, bpp, width, stride, &l, &r, t, b); + } } -*/ - -/* Alpha of a pixel above a given horizontal line */ -#define AlphaAbove(pixel_y, line_y, depth) \ -( \ - AreaAlpha(AREA_MULT((line_y) - (pixel_y), xFixed1), depth) \ -) static int -RectAlpha(xFixed pixel_y, xFixed top, xFixed bottom, int depth) +_GreaterY (xPointFixed *a, xPointFixed *b) { - if (depth == 1) - return top == pixel_y ? 1 : 0; - else - return (AlphaAbove (pixel_y, bottom, depth) - - AlphaAbove (pixel_y, top, depth)); + if (a->y == b->y) + return a->x > b->x; + return a->y > b->y; } - /* - * Pixel coverage from the left edge bounded by one horizontal lines, - * (top and bottom), as well as one PixelWalk line. + * Note that the definition of this function is a bit odd because + * of the X coordinate space (y increasing downwards). */ static int -AlphaAboveLeft(RationalPoint *upper, - RationalPoint *lower, - xFixed bottom, - xFixed pixel_x, - xFixed pixel_y, - int depth) +_Clockwise (xPointFixed *ref, xPointFixed *a, xPointFixed *b) { - return SubPixelAlpha(upper->x - pixel_x, - upper->y - pixel_y, - lower->x - pixel_x, - lower->y - pixel_y, - bottom - pixel_y, - depth); -} - -/* - Pixel coverage from the left edge bounded by two horizontal lines, - (top and bottom), as well as one line two points, p1 and p2, which - intersect the pixel. The following condition must be true: + xPointFixed ad, bd; - p2.y > p1.y -*/ - -/* - lr - |\ - +--|-\-------+ - | a| b\ | - =======|===\========== top - | c| d \ | - =======|=====\======== bot - | | \ | - +--|-------\-+ + ad.x = a->x - ref->x; + ad.y = a->y - ref->y; + bd.x = b->x - ref->x; + bd.y = b->y - ref->y; - alpha(d) = alpha(cd) - alpha(c) = alpha(abcd) - alpha(ab) - (alpha(ac) - alpha(c)) - - alpha(d) = pixelalpha(top, bot, right) - pixelalpha(top, bot, left) - - pixelalpha(top, bot, line) = subpixelalpha(bot, line) - subpixelalpha(top, line) -*/ - -static int -PixelAlpha(xFixed pixel_x, - xFixed pixel_y, - xFixed top, - xFixed bottom, - PixelWalk *pw, - int depth) -{ - int alpha; - -#ifdef DEBUG - fprintf(stderr, "alpha (%f, %f) - (%f, %f) = ", - (double) pw->p1.x / (1 << 16), - (double) pw->p1.y / (1 << 16), - (double) pw->p2.x / (1 << 16), - (double) pw->p2.y / (1 << 16)); - fflush(stderr); -#endif - - /* - * Sharp polygons are different, alpha is 1 if the - * area includes the pixel origin, else zero, in - * the above figure, only 'a' has alpha 1 - */ - if (depth == 1) - { - alpha = 0; - if (top == pixel_y && pw->p_pixel_top.x != pixel_x) - alpha = 1; - } - else - { - alpha = (AlphaAboveLeft(&pw->p_pixel_top, &pw->p_trap_bottom, - bottom, pixel_x, pixel_y, depth) - - AlphaAboveLeft(&pw->p_pixel_top, &pw->p_trap_top, - top, pixel_x, pixel_y, depth)); - } - -#ifdef DEBUG - fprintf(stderr, "0x%x => %f\n", - alpha, - (double) alpha / ((1 << depth) -1 )); - fflush(stderr); -#endif - - return alpha; + return ((xFixed_32_32) bd.y * ad.x - (xFixed_32_32) ad.y * bd.x) < 0; } -#define INCREMENT_X_AND_PIXEL \ -{ \ - pixel_x += xFixed1; \ - (*mask.over) (&mask); \ -} - -/* XXX: What do we really want this prototype to look like? Do we want - separate versions for 1, 4, 8, and 16-bit alpha? */ - -#define saturateAdd(t, a, b) (((t) = (a) + (b)), \ - ((CARD8) ((t) | (0 - ((t) >> 8))))) - -#define addAlpha(mask, depth, alpha, temp) (\ - (*(mask)->store) ((mask), (alpha == (1 << depth) - 1) ? \ - 0xff000000 : \ - (saturateAdd (temp, \ - alpha << (8 - depth), \ - (*(mask)->fetch) (mask) >> 24) << 24)) \ -) - +/* FIXME -- this could be made more efficient */ void -fbRasterizeTrapezoid (PicturePtr pMask, - xTrapezoid *pTrap, - int x_off, - int y_off) +fbAddTriangles (PicturePtr pPicture, + INT16 x_off, + INT16 y_off, + int ntri, + xTriangle *tris) { - xTrapezoid trap = *pTrap; - int alpha, temp; - - FbCompositeOperand mask; + xPointFixed *top, *left, *right, *tmp; + xTrapezoid trap; - int depth = pMask->pDrawable->depth; - int max_alpha = (1 << depth) - 1; - int buf_width = pMask->pDrawable->width; - - xFixed x_off_fixed = IntToxFixed(x_off); - xFixed y_off_fixed = IntToxFixed(y_off); - xFixed buf_width_fixed = IntToxFixed(buf_width); - - PixelWalk left, right; - xFixed pixel_x, pixel_y; - xFixed first_right_x; - xFixed y, y_next; - - /* trap.left and trap.right must be non-horizontal */ - if (trap.left.p1.y == trap.left.p2.y - || trap.right.p1.y == trap.right.p2.y) { - return; - } - - trap.top += y_off_fixed; - trap.bottom += y_off_fixed; - trap.left.p1.x += x_off_fixed; - trap.left.p1.y += y_off_fixed; - trap.left.p2.x += x_off_fixed; - trap.left.p2.y += y_off_fixed; - trap.right.p1.x += x_off_fixed; - trap.right.p1.y += y_off_fixed; - trap.right.p2.x += x_off_fixed; - trap.right.p2.y += y_off_fixed; - -#ifdef DEBUG - fprintf(stderr, "(top, bottom) = (%f, %f)\n", - (double) trap.top / (1 << 16), - (double) trap.bottom / (1 << 16)); -#endif - - pixelWalkInit(&left, &trap.left, trap.top, trap.bottom); - pixelWalkInit(&right, &trap.right, trap.top, trap.bottom); - - /* XXX: I'd still like to optimize this loop for top and - bottom. Only the first row intersects top and only the last - row, (which could also be the first row), intersects bottom. So - we could eliminate some unnecessary calculations from all other - rows. Unfortunately, I haven't found an easy way to do it - without bloating the text, (eg. unrolling a couple iterations - of the loop). So, for sake of maintenance, I'm putting off this - optimization at least until this code is more stable.. */ - - if (!fbBuildCompositeOperand (pMask, &mask, 0, xFixedToInt (trap.top), FALSE, FALSE)) - return; - - for (y = trap.top; y < trap.bottom; y = y_next) + for (; ntri; ntri--, tris++) { - pixel_y = xFixedFloor (y); - y_next = pixel_y + xFixed1; - if (y_next > trap.bottom) - y_next = trap.bottom; - - ASSERT (left.row.top.y == y); - ASSERT (left.row.bottom.y == y_next); - ASSERT (right.row.top.y == y); - ASSERT (right.row.bottom.y == y_next); - - pixel_x = xFixedFloor(left.col.left.x); + top = &tris->p1; + left = &tris->p2; + right = &tris->p3; + if (_GreaterY (top, left)) { + tmp = left; left = top; top = tmp; + } + if (_GreaterY (top, right)) { + tmp = right; right = top; top = tmp; + } + if (_Clockwise (top, right, left)) { + tmp = right; right = left; left = tmp; + } /* - * Walk pixels on this row that are left of the - * first possibly lit pixel + * Two cases: * - * pixelWalkNextPixel will change .row.top.y - * when the last pixel covered by the edge - * is passed + * + + + * / \ / \ + * / \ / \ + * / + + \ + * / -- -- \ + * / -- -- \ + * / --- --- \ + * +-- --+ */ - - first_right_x = xFixedFloor(right.col.left.x); - while (right.row.top.y == y && first_right_x < pixel_x) - { - /* these are empty */ - pixelWalkNextPixel (&right); - /* step over */ - first_right_x += xFixed1; - } - - (*mask.set) (&mask, xFixedToInt (pixel_x), xFixedToInt (y)); - /* - * Walk pixels on this row intersected by only trap.left - * - */ - while (left.row.top.y == y && pixel_x < first_right_x) - { - alpha = (RectAlpha (pixel_y, y, y_next, depth) - - PixelAlpha(pixel_x, pixel_y, y, y_next, &left, depth)); - - if (alpha > 0) - { - if (0 <= pixel_x && pixel_x < buf_width_fixed) - addAlpha (&mask, depth, alpha, temp); - } - - /* - * Step right - */ - pixelWalkNextPixel(&left); - INCREMENT_X_AND_PIXEL; - } - - /* - * Either pixels are covered by both edges or - * there are fully covered pixels on this row - */ - if (pixel_x == first_right_x) - { - /* - * Now walk the pixels on this row intersected - * by both edges - */ - while (left.row.top.y == y && right.row.top.y == y) - { - alpha = (PixelAlpha(pixel_x, pixel_y, y, y_next, &right, depth) - - PixelAlpha(pixel_x, pixel_y, y, y_next, &left, depth)); - if (alpha > 0) - { - ASSERT (0 <= alpha && alpha <= max_alpha); - if (0 <= pixel_x && pixel_x < buf_width_fixed) - addAlpha (&mask, depth, alpha, temp); - } - pixelWalkNextPixel(&left); - pixelWalkNextPixel(&right); - INCREMENT_X_AND_PIXEL; - } - /* - * If the right edge is now left of the left edge, - * the left edge will end up only partially walked, - * walk it the rest of the way - */ - while (left.row.top.y == y) - pixelWalkNextPixel(&left); - } + trap.top = top->y; + trap.left.p1 = *top; + trap.left.p2 = *left; + trap.right.p1 = *top; + trap.right.p2 = *right; + if (right->y < left->y) + trap.bottom = right->y; else + trap.bottom = left->y; + fbRasterizeTrapezoid (pPicture, &trap, x_off, y_off); + if (right->y < left->y) { - /* - * Fully covered pixels simply saturate - */ - alpha = RectAlpha (pixel_y, y, y_next, depth); - if (alpha == max_alpha) - { - while (pixel_x < first_right_x) - { - if (0 <= pixel_x && pixel_x < buf_width_fixed) - (*mask.store) (&mask, 0xff000000); - INCREMENT_X_AND_PIXEL; - } - } - else - { - while (pixel_x < first_right_x) - { - ASSERT (0 <= alpha && alpha <= max_alpha); - if (0 <= pixel_x && pixel_x < buf_width_fixed) - addAlpha (&mask, depth, alpha, temp); - INCREMENT_X_AND_PIXEL; - } - } + trap.top = right->y; + trap.bottom = left->y; + trap.right.p1 = *right; + trap.right.p2 = *left; } - - /* - * Finally, pixels intersected only by trap.right - */ - while (right.row.top.y == y) + else { - alpha = PixelAlpha(pixel_x, pixel_y, y, y_next, &right, depth); - if (alpha > 0) - { - if (0 <= pixel_x && pixel_x < buf_width_fixed) - addAlpha (&mask, depth, alpha, temp); - } - pixelWalkNextPixel(&right); - INCREMENT_X_AND_PIXEL; - } - } -} - -/* Some notes on walking while keeping track of errors in both dimensions: - -That's really pretty easy. Your bresenham should be walking sub-pixel -coordinates rather than pixel coordinates. Now you can calculate the -sub-pixel Y coordinate for any arbitrary sub-pixel X coordinate (or vice -versa). - - ey: y error term (distance from current Y sub-pixel to line) * dx - ex: x error term (distance from current X sub-pixel to line) * dy - dx: difference of X coordinates for line endpoints - dy: difference of Y coordinates for line endpoints - x: current fixed-point X coordinate - y: current fixed-point Y coordinate - -One of ey or ex will always be zero, depending on whether the distance to -the line was measured horizontally or vertically. - -In moving from x, y to x1, y1: - - (x1 + e1x/dy) - (x + ex/dy) dx - --------------------------- = -- - (y1 + e1y/dx) - (y + ey/dx) dy - - (x1dy + e1x) - (xdy + ex) = (y1dx + e1y) - (ydx + ey) - - dy(x1 - x) + (e1x - ex) = dx(y1-y) + (e1y - ey) - -So, if you know y1 and want to know x1: - - Set e1y to zero and compute the error from x: - - oex = dx(y1 - y) - ey + ex - - Compute the number of whole pixels to get close to the line: - - wx = oex / dy - - Set x1: - - Now compute the e1x: - - e1x = oex - wx * dy - -A similar operation moves to a known y1. Note that this computation (in -general) requires 64 bit arithmetic. I suggest just using the available -64 bit datatype for now, we can optimize the common cases with a few -conditionals. There's some cpp code in fb/fb.h that selects a 64 bit type -for machines that XFree86 builds on; there aren't any machines missing a -64 bit datatype that I know of. -*/ - -/* Here's a large-step Bresenham for jogging my memory. - -void large_bresenham_x_major(x1, y1, x2, y2, x_inc) -{ - int x, y, dx, dy, m; - int em_dx, ey_dx; - - dx = x2 - x1; - dy = y2 - y1; - - m = (x_inc * dy) / dx; - em_dx = (x_inc * dy) - m * dx; - - x = x1; - y = y1; - ey = 0; - - set(x,y); - - while (x < x2) { - x += x_inc; - y += m; - ey_dx += em_dx; - if (ey_dx > dx_2) { - y++; - ey_dx -= dx; + trap.top = left->y; + trap.bottom = right->y; + trap.left.p1 = *left; + trap.left.p2 = *right; } - set(x,y); + fbRasterizeTrapezoid (pPicture, &trap, x_off, y_off); } } -*/ - -/* Here are the latest, simplified equations for computing trapezoid - coverage of a pixel: - - alpha_from_area(A) = round(2**depth-1 * A) - - alpha(o) = 2**depth-1 - - alpha(a) = alpha_from_area(area(a)) - - alpha(ab) = alpha_from_area(area(ab)) - - alpha(b) = alpha(ab) - alpha (a) - - alpha(abc) = alpha_from_area(area(abc)) - - alpha(c) = alpha(abc) - alpha(ab) - - alpha(ad) = alpha_from_area(area(ad)) - - alpha (d) = alpha(ad) - alpha (a) - - alpha (abde) = alpha_from_area(area(abde)) - - alpha (de) = alpha (abde) - alpha (ab) - - alpha (e) = alpha (de) - alpha (d) - - alpha (abcdef) = alpha_from_area(area(abcdef)) - - alpha (def) = alpha (abcdef) - alpha (abc) - - alpha (f) = alpha (def) - alpha (de) - - alpha (adg) = alpha_from_area(area(adg)) - - alpha (g) = alpha (adg) - alpha (ad) - - alpha (abdegh) = alpha_from_area(area(abdegh)) - - alpha (gh) = alpha (abdegh) - alpha (abde) - - alpha (h) = alpha (gh) - alpha (g) - - alpha (abcdefghi) = alpha_from_area(area(abcdefghi)) = - alpha_from_area(area(o)) = alpha_from_area(1) = alpha(o) - - alpha (ghi) = alpha (abcdefghi) - alpha (abcdef) - - alpha (i) = alpha (ghi) - alpha (gh) -*/ - -/* Latest thoughts from Keith on implementing area/alpha computations: - -*** 1.16 * 1.16 -> 1.31 *** -#define AREA_MULT(w,h) ((w)&(h) == 0x10000 ? 0x80000000 : (((w)*(h) + 1) >> 1) - -*** (1.16 + 1.16) / 2 -> 1.16 *** -#define WIDTH_AVG(x1,x2) (((x1) + (x2) + 1) >> 1) - -xFixed_1_31 -SubpixelArea (xFixed_1_16 x1, - xFixed_1_16 x2, - xFixed_1_16 y1, - xFixed_1_16 y2, - xFixed_1_16 bottom) - { - xFixed_1_16 x_trap; - xFixed_1_16 h_top, h_trap, h_bot; - xFixed_1_31 area; - - x_trap = WIDTH_AVG(x1,x2); - h_top = y1; - h_trap = (y2 - y1); - h_bot = (bottom - y2); - - area = AREA_MULT(x1, h_top) + - AREA_MULT(x_trap, h_trap) + - AREA_MULT(x2, h_bot); - - return area; - } - -To convert this xFixed_1_31 value to alpha using 32 bit arithmetic: - -int -AreaAlpha (xFixed_1_31 area, int depth) - { - return ((area >> bits) * ((1 << depth) - 1)) >> (31 - depth); - } - -Avoiding the branch bubble in the AREA_MULT could be done with either: - -area = (w * h + 1) >> 1; -area |= ((area - 1) & 0x80000000); - -or - #define AREA_MULT(w,h) ((((w)*(h) + 1) >> 1) | ((w)&(h)&0x10000) << 15) - -depending on your preference, the first takes one less operation but -can't be expressed as a macro; the second takes a large constant which may -require an additional instruction on some processors. The differences -will be swamped by the cost of the multiply. - -*/ - #endif /* RENDER */ diff --git a/fb/fbwindow.c b/fb/fbwindow.c index ebf35bba8..9e70d56e1 100644 --- a/fb/fbwindow.c +++ b/fb/fbwindow.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/fb/fbwindow.c,v 1.1.4.3.2.2 2004/03/04 17:47:28 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/fb/fbwindow.c,v 1.4 2004/08/13 08:16:14 keithp Exp $ */ /* * Id: fbwindow.c,v 1.1 1999/11/02 03:54:45 keithp Exp $ * @@ -122,9 +122,12 @@ fbCopyWindow(WindowPtr pWin, { RegionRec rgnDst; int dx, dy; - WindowPtr pwinRoot; - - pwinRoot = WindowTable[pWin->drawable.pScreen->myNum]; +#ifdef COMPOSITE + PixmapPtr pPixmap = fbGetWindowPixmap (pWin); + DrawablePtr pDrawable = &pPixmap->drawable; +#else + DrawablePtr pDrawable = &WindowTable[pWin->drawable.pScreen->myNum]->drawable; +#endif dx = ptOldOrg.x - pWin->drawable.x; dy = ptOldOrg.y - pWin->drawable.y; @@ -134,7 +137,13 @@ fbCopyWindow(WindowPtr pWin, REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc); - fbCopyRegion ((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot, +#ifdef COMPOSITE + if (pPixmap->screen_x || pPixmap->screen_y) + REGION_TRANSLATE (pWin->drawable.pScreen, &rgnDst, + -pPixmap->screen_x, -pPixmap->screen_y); +#endif + + fbCopyRegion (pDrawable, pDrawable, 0, &rgnDst, dx, dy, fbCopyWindowProc, 0, 0); diff --git a/hw/darwin/bundle/Dutch.lproj/XDarwinHelp.html.cpp b/hw/darwin/bundle/Dutch.lproj/XDarwinHelp.html.cpp index d91d90449..1113b8ae6 100644 --- a/hw/darwin/bundle/Dutch.lproj/XDarwinHelp.html.cpp +++ b/hw/darwin/bundle/Dutch.lproj/XDarwinHelp.html.cpp @@ -1 +1,103 @@ -<!-- $XFree86: xc/programs/Xserver/hw/darwin/bundle/English.lproj/XDarwinHelp.html.cpp,v 1.2 2001/11/04 07:02:28 torrey Exp $ -->
<html>
<head>
<title>XDarwin Help</title>
</head>
<body>
<center>
<h1>XDarwin X Server for Mac OS X</h1>
X_VENDOR_NAME X_VERSION<br>
Release Date: X_REL_DATE
</center>
<h2>Inhoud</h2>
<ol>
<li><A HREF="#notice">Belangrijke Informatie</A></li>
<li><A HREF="#usage">Gebruik</A></li>
<li><A HREF="#path">Instellen van het Path</A></li>
<li><A HREF="#prefs">Voorkeursinstellingen</A></li>
<li><A HREF="#license">Licentie</A></li>
</ol>
<center>
<h2><a NAME="notice">Belangrijke Informatie</a></h2>
</center>
<blockquote>
#if X_PRE_RELEASE
Dit is een pre-release van XDarwin, waarvoor geen ondersteuning beschikbaar is. Rapporteren van bugs en aanleveren van patches kan op de <A HREF="http://sourceforge.net/projects/xonx/">XonX project pagina</A> bij SourceForge. Kijk alvorens een bug te rapporteren in een pre-release eerst of een nieuwe versie beschikbaar is bij <A HREF="http://sourceforge.net/projects/xonx/">XonX</A> of de X_VENDOR_LINK.
#else
Als de server ouder is dan 6-12 maanden, of als uw hardware nieuwer is dan de bovenstaande datum, kijk dan of een nieuwe versie beschikbaar is voor u een probleem aanmeldt. Rapporteren van bugs en aanleveren van patches kan op de <A HREF="http://sourceforge.net/projects/xonx/">XonX project pagina</A> bij SourceForge.
#endif
</blockquote>
<blockquote>
Deze software is beschikbaar gesteld onder de voorwaarden van de <A HREF="#license">MIT X11 / X Consortium Licentie</A> en is beschikbaar 'AS IS',zonder enige garantie. Lees s.v.p. de <A HREF="#license">Licentie</A> voor gebruik.</blockquote>
<h2><a NAME="usage">Gebruik</a></h2>
<p>XDarwin is een open-source X server van het <a HREF="http://www.x.org/">X Window Systeem</a>. This version of XDarwin was produced by the X_VENDOR_LINK. XDarwin werkt op Mac OS X in schermvullende of rootless modus.</p>
<p>Het X window systeem in schermvullende modus neemt het hele beeldscherm in beslag. U schakelt terug naar de Mac OS X desktop door de toesten Command-Option-A in te drukken. Deze toetsencombinatie kunt u veranderen in de Voorkeuren. Op de Mac OS X desktop klikt u op de XDarwin icoon in de Dock om weer naar het X window systeem te schakelen. (In de Voorkeuren kunt er voor kiezen om een apart XDarwin schakelpaneel te gebruiken op de Mac OS X desktop.)</p>
<p>In rootless modus verschijnen het X window systeem en Aqua (de Mac OS X desktop) tegelijk op het scherm. Het achtergrondscherm van X11, waarbinnen alle X11 vensters vallen, is net zo groot als het gehele scherm, maar het achtergrondscherm zelf is onzichtbaar.</p>
<h3>Meerknopsmuis emulatie</h3>
<p>Voor veel X11 programma's hebt u een 3-knops muis nodig. Met een 1-knops muis kunt u een 3-knops muis nabootsen door een toets in te drukken terwijl u klikt met de muis. Het instellen hiervan kan bij Voorkeuren, "Meerknopsmuis emulatie" in "Algemeen". Emulatie is standaard ingeschakeld: ingedrukt houden van de "command" toets terwijl u klikt emuleert knop 2, ingedrukt houden van "option" emuleert knop 3. Deze toetsen kunt u dus wijzigen in de Voorkeuren. Let op: als u xmodmap gebruikt om de indeling van het toetsenbord te wijzigen, moet u toch de oorspronkelijke toetsen op het toetsenbord gebruiken voor deze functie.</p>
<h2><a NAME="path">Instellen van het Path</a></h2>
<p>Het path is de lijst van directories waarin gezocht wordt naar commando's. De X11 commando's staan in de directory <code>/usr/X11R6/bin</code>, die dus aan uw path moet worden toegevoegd. XDarwin doet dit automatisch voor u en kan extra directories toevoegen waarin u commando's hebt geïnstalleerd.</p>
<p>Ervaren gebruikers zullen het path al correct hebben ingesteld in de configuratiebestanden voor hun shell. In dat geval kunt u XDarwin via de Voorkeuren vertellen het path niet te wijzigen. XDarwin start de eerste X11 clients binnen de standaard login shell van de gebruiker (bij de Voorkeuren kunt u een afwijkende shell opgeven). Het instellen van het path is afhankelijk van de shell. Zie hiervoor de man pages voor de shell.</p>
<p>Het kan handig zijn de manualpages voor X11 toe te voegen aan de lijst waarin gezocht wordt als u documentatie opvraagt. De manualpages voor X11 staan in <code>/usr/X11R6/man</code> en de <code>MANPATH</code> environment variable bevat de lijst van directories waarin naar documentatie wordt gezocht.</p>
<h2><a NAME="prefs">Voorkeursinstellingen</a></h2>
<p>Een aantal instellingen kan worden gewijzigd door "Voorkeuren..." te kiezen in het "XDarwin" menu. Wijzigingen van de instellingen genoemd onder "Start" gaan pas in als u XDarwin opnieuw hebt gestart. Een wijziging van de overige instellingen is direct effectief. Hier onder vindt u de verschillende mogelijkheden beschreven:</p>
<h3>Algemeen</h3>
<ul>
<li><b>Gebruik systeempiep voor X11:</b> Als u dit inschakelt wordt het Mac OS X waarschuwingssignaal ook gebruikt door X11, anders gebruikt X11 een simpele pieptoon (dit is de standaardinstelling).</li>
<li><b>Wijzigen muis-versnelling door X11 mogelijk:</b> In een standaard X window systeem kan de window manager de muis-versnelling aanpassen. Dit kan verwarrend zijn omdat de snelheid onder X11 dan verschillend kan zijn van de snelheid die u in Mac OS X bij Systeemvoorkeuren hebt ingesteld. Om verwarring te voorkomen is de standaardinstelling dat X11 de versnelling niet kan wijzigen.</li>
<li><b>Meerknopsmuis emulatie:</b> Dit is hierboven beschreven bij <a HREF="#usage">Gebruik</a>. Als emulatie is ingeschakeld moet u de gekozen toetsen ingedrukt houden terwijl u met de muis klikt om de tweede en derde muisknop na te bootsen.</li>
</ul>
<h3>Start</h3>
<ul>
<li><b>Standaard modus:</b> Hier kiest u de standaard scherm-modus: schermvullend of rootless (hierboven beschreven bij <a HREF="#usage">Gebruik</a>). U kunt ook kiezen tijdens het starten van XDarwin, zie de optie hieronder.</li>
<li><b>Kies scherm-modus tijdens start:</b> Dit is standaard ingeschakeld zodat u tijdens het starten van XDarwin kunt kiezen tussen schermvullend en rootless scherm-modus. Als u dit uitschakelt start XDarwin in de standaard modus zonder u iets te vragen.</li>
<li><b>X11 scherm nummer:</b> Met X11 kunnen meerdere schermen worden aangestuurd door verschillende X servers op dezelfde computer. Als u meerdere X servers tegelijk wilt gebruiken stelt u hier het scherm nummer in dat door XDarwin wordt gebruikt.</li>
<li><b>Xinerama multi-monitor ondersteuning mogelijk:</b> XDarwin ondersteunt het gebruik van meerdere monitoren met Xinerama, waarbij elke monitor wordt gezien als deel van één groot rechthoekig scherm. U kunt Xinerama hier uitschakelen, maar XDarwin werkt op dit moment zonder Xinerama niet goed met meerdere monitoren. Als u maar 1 monitor gebruikt is deze instelling automatisch uitgeschakeld.</li>
<li><b>Toetsenbordindeling-bestand:</b> Een toetsenbordindeling-bestand wordt bij het starten geladen en omgezet naar een X11 toetsenbordindeling. Voor verschillende talen vindt u toetsenbordindelingen in de directory <code>/System/Library/Keyboards</code>.</li>
<li><b>Bij starten eerste X11 clients:</b> Als XDarwin start, wordt <code>xinit</code> uitgevoerd om de X window manager en andere X clients te starten (zie "<code>man xinit</code>"). Voordat XDarwin <code>xinit</code> uitvoert voegt het de opgegeven directories toe aan het path. Standaard wordt alleen <code>/usr/X11R6/bin</code> toegevoegd. U kunt meerdere directories opgeven, gescheiden door een dubbelepunt. X clients worden gestart met de standaard login shell van de gebruiker met gebruik van de configuratiebestanden voor die shell. U kunt een afwijkende shell opgeven.</li>
</ul>
<h3>Schermvullend</h3>
<ul>
<li><b>Toetscombinatie knop:</b> Klik op deze knop om de toetscombinatie te wijzigen waarmee u tussen de Mac OS X desktop en X11 schakelt. Als toetscombinatie kunt u elke combinatie gebruiken van de shift, control, command en option toetsen samen met één normale toets.</li>
<li><b>Klikken op icoon in Dock schakelt naar X11:</b> Hiermee is een klik op de XDarwin icoon in de Dock voldoende om naar X11 te schakelen. In sommige versies van Mac OS X verdwijnt soms de cursor als u deze mogelijkheid gebruikt en daarna terugkeert naar de Mac OS X desktop.</li>
<li><b>Toon help bij schermvullend starten:</b> Hiermee wordt een inleidend scherm getoond als XDarwin schermvullend start.</li>
<li><b>Kleurdiepte:</b> In de schermvullende modus kan X11 een andere kleurdiepte gebruiken dan Aqua (en de Mac OS X desktop). Als u "Huidig" kiest, neemt XDarwin bij het starten de kleurdiepte over van Aqua. U kunt ook kiezen voor 8, 15 of 24 bits.</li>
</ul>
<h2><a NAME="license">Licentie</a></h2>
The main license for XDarwin is one based on the traditional MIT X11 / X Consortium License, which does not impose any conditions on modification or redistribution of source code or binaries other than requiring that copyright/license notices are left intact. For more information and additional copyright/licensing notices covering some sections of the code, please refer to the source code.
<H3><A NAME="3"></A>X Consortium License</H3>
<p>Copyright (C) 1996 X Consortium</p>
<p>Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without
limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to
whom the Software is furnished to do so, subject to the following conditions:</p>
<p>The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.</p>
<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.</p>
<p>Except as contained in this notice, the name of the X Consortium shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization from
the X Consortium.</p>
<p>X Window System is a trademark of X Consortium, Inc.</p>
</body>
</html>
\ No newline at end of file +<!-- $XFree86: xc/programs/Xserver/hw/darwin/bundle/English.lproj/XDarwinHelp.html.cpp,v 1.2 2001/11/04 07:02:28 torrey Exp $ --> + +<html> +<head> +<title>XDarwin Help</title> +</head> +<body> +<center> + <h1>XDarwin X Server for Mac OS X</h1> + X_VENDOR_NAME X_VERSION<br> + Release Date: X_REL_DATE +</center> +<h2>Inhoud</h2> +<ol> + <li><A HREF="#notice">Belangrijke Informatie</A></li> + <li><A HREF="#usage">Gebruik</A></li> + <li><A HREF="#path">Instellen van het Path</A></li> + <li><A HREF="#prefs">Voorkeursinstellingen</A></li> + <li><A HREF="#license">Licentie</A></li> +</ol> +<center> + <h2><a NAME="notice">Belangrijke Informatie</a></h2> +</center> +<blockquote> +#if X_PRE_RELEASE +Dit is een pre-release van XDarwin, waarvoor geen ondersteuning beschikbaar is. Rapporteren van bugs en aanleveren van patches kan op de <A HREF="http://sourceforge.net/projects/xonx/">XonX project pagina</A> bij SourceForge. Kijk alvorens een bug te rapporteren in een pre-release eerst of een nieuwe versie beschikbaar is bij <A HREF="http://sourceforge.net/projects/xonx/">XonX</A> of de X_VENDOR_LINK. +#else +Als de server ouder is dan 6-12 maanden, of als uw hardware nieuwer is dan de bovenstaande datum, kijk dan of een nieuwe versie beschikbaar is voor u een probleem aanmeldt. Rapporteren van bugs en aanleveren van patches kan op de <A HREF="http://sourceforge.net/projects/xonx/">XonX project pagina</A> bij SourceForge. +#endif +</blockquote> +<blockquote> +Deze software is beschikbaar gesteld onder de voorwaarden van de <A HREF="#license">MIT X11 / X Consortium Licentie</A> en is beschikbaar 'AS IS',zonder enige garantie. Lees s.v.p. de <A HREF="#license">Licentie</A> voor gebruik.</blockquote> + +<h2><a NAME="usage">Gebruik</a></h2> +<p>XDarwin is een open-source X server van het <a HREF="http://www.x.org/">X Window Systeem</a>. This version of XDarwin was produced by the X_VENDOR_LINK. XDarwin werkt op Mac OS X in schermvullende of rootless modus.</p> +<p>Het X window systeem in schermvullende modus neemt het hele beeldscherm in beslag. U schakelt terug naar de Mac OS X desktop door de toesten Command-Option-A in te drukken. Deze toetsencombinatie kunt u veranderen in de Voorkeuren. Op de Mac OS X desktop klikt u op de XDarwin icoon in de Dock om weer naar het X window systeem te schakelen. (In de Voorkeuren kunt er voor kiezen om een apart XDarwin schakelpaneel te gebruiken op de Mac OS X desktop.)</p> +<p>In rootless modus verschijnen het X window systeem en Aqua (de Mac OS X desktop) tegelijk op het scherm. Het achtergrondscherm van X11, waarbinnen alle X11 vensters vallen, is net zo groot als het gehele scherm, maar het achtergrondscherm zelf is onzichtbaar.</p> + +<h3>Meerknopsmuis emulatie</h3> +<p>Voor veel X11 programma's hebt u een 3-knops muis nodig. Met een 1-knops muis kunt u een 3-knops muis nabootsen door een toets in te drukken terwijl u klikt met de muis. Het instellen hiervan kan bij Voorkeuren, "Meerknopsmuis emulatie" in "Algemeen". Emulatie is standaard ingeschakeld: ingedrukt houden van de "command" toets terwijl u klikt emuleert knop 2, ingedrukt houden van "option" emuleert knop 3. Deze toetsen kunt u dus wijzigen in de Voorkeuren. Let op: als u xmodmap gebruikt om de indeling van het toetsenbord te wijzigen, moet u toch de oorspronkelijke toetsen op het toetsenbord gebruiken voor deze functie.</p> + +<h2><a NAME="path">Instellen van het Path</a></h2> +<p>Het path is de lijst van directories waarin gezocht wordt naar commando's. De X11 commando's staan in de directory <code>/usr/X11R6/bin</code>, die dus aan uw path moet worden toegevoegd. XDarwin doet dit automatisch voor u en kan extra directories toevoegen waarin u commando's hebt geïnstalleerd.</p> + +<p>Ervaren gebruikers zullen het path al correct hebben ingesteld in de configuratiebestanden voor hun shell. In dat geval kunt u XDarwin via de Voorkeuren vertellen het path niet te wijzigen. XDarwin start de eerste X11 clients binnen de standaard login shell van de gebruiker (bij de Voorkeuren kunt u een afwijkende shell opgeven). Het instellen van het path is afhankelijk van de shell. Zie hiervoor de man pages voor de shell.</p> + +<p>Het kan handig zijn de manualpages voor X11 toe te voegen aan de lijst waarin gezocht wordt als u documentatie opvraagt. De manualpages voor X11 staan in <code>/usr/X11R6/man</code> en de <code>MANPATH</code> environment variable bevat de lijst van directories waarin naar documentatie wordt gezocht.</p> + +<h2><a NAME="prefs">Voorkeursinstellingen</a></h2> +<p>Een aantal instellingen kan worden gewijzigd door "Voorkeuren..." te kiezen in het "XDarwin" menu. Wijzigingen van de instellingen genoemd onder "Start" gaan pas in als u XDarwin opnieuw hebt gestart. Een wijziging van de overige instellingen is direct effectief. Hier onder vindt u de verschillende mogelijkheden beschreven:</p> + +<h3>Algemeen</h3> +<ul> + <li><b>Gebruik systeempiep voor X11:</b> Als u dit inschakelt wordt het Mac OS X waarschuwingssignaal ook gebruikt door X11, anders gebruikt X11 een simpele pieptoon (dit is de standaardinstelling).</li> + <li><b>Wijzigen muis-versnelling door X11 mogelijk:</b> In een standaard X window systeem kan de window manager de muis-versnelling aanpassen. Dit kan verwarrend zijn omdat de snelheid onder X11 dan verschillend kan zijn van de snelheid die u in Mac OS X bij Systeemvoorkeuren hebt ingesteld. Om verwarring te voorkomen is de standaardinstelling dat X11 de versnelling niet kan wijzigen.</li> + <li><b>Meerknopsmuis emulatie:</b> Dit is hierboven beschreven bij <a HREF="#usage">Gebruik</a>. Als emulatie is ingeschakeld moet u de gekozen toetsen ingedrukt houden terwijl u met de muis klikt om de tweede en derde muisknop na te bootsen.</li> +</ul> + +<h3>Start</h3> +<ul> + <li><b>Standaard modus:</b> Hier kiest u de standaard scherm-modus: schermvullend of rootless (hierboven beschreven bij <a HREF="#usage">Gebruik</a>). U kunt ook kiezen tijdens het starten van XDarwin, zie de optie hieronder.</li> + <li><b>Kies scherm-modus tijdens start:</b> Dit is standaard ingeschakeld zodat u tijdens het starten van XDarwin kunt kiezen tussen schermvullend en rootless scherm-modus. Als u dit uitschakelt start XDarwin in de standaard modus zonder u iets te vragen.</li> + <li><b>X11 scherm nummer:</b> Met X11 kunnen meerdere schermen worden aangestuurd door verschillende X servers op dezelfde computer. Als u meerdere X servers tegelijk wilt gebruiken stelt u hier het scherm nummer in dat door XDarwin wordt gebruikt.</li> + <li><b>Xinerama multi-monitor ondersteuning mogelijk:</b> XDarwin ondersteunt het gebruik van meerdere monitoren met Xinerama, waarbij elke monitor wordt gezien als deel van één groot rechthoekig scherm. U kunt Xinerama hier uitschakelen, maar XDarwin werkt op dit moment zonder Xinerama niet goed met meerdere monitoren. Als u maar 1 monitor gebruikt is deze instelling automatisch uitgeschakeld.</li> + <li><b>Toetsenbordindeling-bestand:</b> Een toetsenbordindeling-bestand wordt bij het starten geladen en omgezet naar een X11 toetsenbordindeling. Voor verschillende talen vindt u toetsenbordindelingen in de directory <code>/System/Library/Keyboards</code>.</li> + <li><b>Bij starten eerste X11 clients:</b> Als XDarwin start, wordt <code>xinit</code> uitgevoerd om de X window manager en andere X clients te starten (zie "<code>man xinit</code>"). Voordat XDarwin <code>xinit</code> uitvoert voegt het de opgegeven directories toe aan het path. Standaard wordt alleen <code>/usr/X11R6/bin</code> toegevoegd. U kunt meerdere directories opgeven, gescheiden door een dubbelepunt. X clients worden gestart met de standaard login shell van de gebruiker met gebruik van de configuratiebestanden voor die shell. U kunt een afwijkende shell opgeven.</li> +</ul> + +<h3>Schermvullend</h3> +<ul> + <li><b>Toetscombinatie knop:</b> Klik op deze knop om de toetscombinatie te wijzigen waarmee u tussen de Mac OS X desktop en X11 schakelt. Als toetscombinatie kunt u elke combinatie gebruiken van de shift, control, command en option toetsen samen met één normale toets.</li> + <li><b>Klikken op icoon in Dock schakelt naar X11:</b> Hiermee is een klik op de XDarwin icoon in de Dock voldoende om naar X11 te schakelen. In sommige versies van Mac OS X verdwijnt soms de cursor als u deze mogelijkheid gebruikt en daarna terugkeert naar de Mac OS X desktop.</li> + <li><b>Toon help bij schermvullend starten:</b> Hiermee wordt een inleidend scherm getoond als XDarwin schermvullend start.</li> + <li><b>Kleurdiepte:</b> In de schermvullende modus kan X11 een andere kleurdiepte gebruiken dan Aqua (en de Mac OS X desktop). Als u "Huidig" kiest, neemt XDarwin bij het starten de kleurdiepte over van Aqua. U kunt ook kiezen voor 8, 15 of 24 bits.</li> +</ul> + +<h2><a NAME="license">Licentie</a></h2> +The main license for XDarwin is one based on the traditional MIT X11 / X Consortium License, which does not impose any conditions on modification or redistribution of source code or binaries other than requiring that copyright/license notices are left intact. For more information and additional copyright/licensing notices covering some sections of the code, please refer to the source code. +<H3><A NAME="3"></A>X Consortium License</H3> +<p>Copyright (C) 1996 X Consortium</p> +<p>Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without +limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to +whom the Software is furnished to do so, subject to the following conditions:</p> +<p>The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software.</p> +<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE.</p> +<p>Except as contained in this notice, the name of the X Consortium shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization from +the X Consortium.</p> +<p>X Window System is a trademark of X Consortium, Inc.</p> +</body> +</html> + diff --git a/hw/darwin/bundle/Japanese.lproj/Credits.rtf b/hw/darwin/bundle/Japanese.lproj/Credits.rtf index 4ba4d4938..cf9eae207 100644 --- a/hw/darwin/bundle/Japanese.lproj/Credits.rtf +++ b/hw/darwin/bundle/Japanese.lproj/Credits.rtf @@ -190,4 +190,4 @@ Dave Zarzycki\ \f1 \ Torrey T. Lyons\ XFree86 4.0.2 -\f0 \'83\'76\'83\'8d\'83\'57\'83\'46\'83\'4e\'83\'67\'82\'d6\'82\'cc\'93\'9d\'8d\'87} +\f0 \'83\'76\'83\'8d\'83\'57\'83\'46\'83\'4e\'83\'67\'82\'d6\'82\'cc\'93\'9d\'8d\'87}
\ No newline at end of file diff --git a/hw/darwin/bundle/XDarwin.icns b/hw/darwin/bundle/XDarwin.icns Binary files differindex 2dd5f786e..9c560846e 100644 --- a/hw/darwin/bundle/XDarwin.icns +++ b/hw/darwin/bundle/XDarwin.icns diff --git a/hw/darwin/darwin.c b/hw/darwin/darwin.c index c774ba1dc..29a31aba1 100644 --- a/hw/darwin/darwin.c +++ b/hw/darwin/darwin.c @@ -29,7 +29,7 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ -/* $XdotOrg: xc/programs/Xserver/hw/darwin/darwin.c,v 1.1.4.2.4.1 2004/03/04 17:47:29 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/darwin/darwin.c,v 1.4 2004/08/11 23:53:36 torrey Exp $ */ /* $XFree86: xc/programs/Xserver/hw/darwin/darwin.c,v 1.55 2003/11/15 00:07:09 torrey Exp $ */ #include "X.h" @@ -48,6 +48,13 @@ #include "xf86Date.h" #include "dix.h" +#ifdef XINPUT +# include "XI.h" +# include "XIproto.h" +# include "exevents.h" +# include "extinit.h" +#endif + #include <sys/types.h> #include <sys/time.h> #include <sys/syslimits.h> @@ -131,7 +138,7 @@ DarwinPrintBanner() "repository hosted at http://www.freedesktop.org/Software/xorg/"); #endif #if XORG_VERSION_SNAP > 0 - ErrorF(".%d", XF86_VERSION_SNAP); + ErrorF(".%d", XORG_VERSION_SNAP); #endif #if XORG_VERSION_SNAP >= 900 @@ -404,6 +411,22 @@ static int DarwinMouseProc( miPointerGetMotionEvents, DarwinChangePointerControl, 0 ); +#ifdef XINPUT + InitValuatorAxisStruct( pPointer, + 0, // X axis + 0, // min value + 16000, // max value (fixme screen size?) + 1, // resolution (fixme ?) + 1, // min resolution + 1 ); // max resolution + InitValuatorAxisStruct( pPointer, + 1, // X axis + 0, // min value + 16000, // max value (fixme screen size?) + 1, // resolution (fixme ?) + 1, // min resolution + 1 ); // max resolution +#endif break; case DEVICE_ON: @@ -699,7 +722,16 @@ void OsVendorInit(void) /* - * ddxProcessArgument -- + * ddxInitGlobals + * Called by InitGlobals() from os/util.c. + */ +void ddxInitGlobals(void) +{ +} + + +/* + * ddxProcessArgument * Process device-dependent command line args. Returns 0 if argument is * not device dependent, otherwise Count of number of elements of argv * that are part of a device dependent commandline option. diff --git a/hw/darwin/iokit/xfIOKit.c b/hw/darwin/iokit/xfIOKit.c index ef3aebb29..9a9d4b530 100644 --- a/hw/darwin/iokit/xfIOKit.c +++ b/hw/darwin/iokit/xfIOKit.c @@ -9,7 +9,7 @@ * **************************************************************/ /* - * Copyright (c) 2001-2002 Torrey T. Lyons. All Rights Reserved. + * Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -33,7 +33,7 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ -/* $XdotOrg: xc/programs/Xserver/hw/darwin/iokit/xfIOKit.c,v 1.1.4.1.4.2 2004/03/04 20:16:10 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/darwin/iokit/xfIOKit.c,v 1.3 2004/07/30 17:37:09 torrey Exp $ */ /* $XFree86: xc/programs/Xserver/hw/darwin/iokit/xfIOKit.c,v 1.2 2003/10/16 23:50:09 torrey Exp $ */ #include "X.h" @@ -269,7 +269,7 @@ static void *XFIOKitHIDThread(void *unused) default: continue; } - + DarwinEQEnqueue(&xe); } } @@ -466,7 +466,9 @@ static Bool SetupFBandHID( #ifdef __i386__ /* x86 in 8bit mode currently needs fixed color map... */ - if( pixelInfo.bitsPerComponent == 8 ) { + if (pixelInfo.bitsPerComponent == 8 && + pixelInfo.componentCount == 1) + { pixelInfo.pixelType = kIOFixedCLUTPixels; } #endif @@ -574,7 +576,7 @@ Bool DarwinModeAddScreen( * XFIOKitShadowUpdate * Update the damaged regions of the shadow framebuffer on the screen. */ -static void XFIOKitShadowUpdate(ScreenPtr pScreen, +static void XFIOKitShadowUpdate(ScreenPtr pScreen, shadowBufPtr pBuf) { DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen); diff --git a/hw/darwin/quartz/Preferences.h b/hw/darwin/quartz/Preferences.h index feecf24d6..d8c3c2ea2 100644 --- a/hw/darwin/quartz/Preferences.h +++ b/hw/darwin/quartz/Preferences.h @@ -84,6 +84,7 @@ + (void)setModeWindow:(BOOL)newModeWindow; + (void)setStartupHelp:(BOOL)newStartupHelp; + (void)setSystemBeep:(BOOL)newSystemBeep; ++ (void)setEnableKeyEquivalents:(BOOL)newKeyEquivs; + (void)setXinerama:(BOOL)newXinerama; + (void)setAddToPath:(BOOL)newAddToPath; + (void)setAddToPathString:(NSString *)newAddToPathString; @@ -110,6 +111,7 @@ + (BOOL)modeWindow; + (BOOL)startupHelp; + (BOOL)systemBeep; ++ (BOOL)enableKeyEquivalents; + (BOOL)xinerama; + (BOOL)addToPath; + (NSString *)addToPathString; diff --git a/hw/darwin/quartz/Preferences.m b/hw/darwin/quartz/Preferences.m index cca2f695d..6c14f4982 100644 --- a/hw/darwin/quartz/Preferences.m +++ b/hw/darwin/quartz/Preferences.m @@ -4,7 +4,7 @@ // This class keeps track of the user preferences. // /* - * Copyright (c) 2002-2003 Torrey T. Lyons. All Rights Reserved. + * Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the @@ -30,7 +30,7 @@ * sale, use or other dealings in this Software without prior written * authorization. */ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/Preferences.m,v 1.3 2003/05/14 05:27:56 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/Preferences.m,v 1.5 2004/06/08 22:58:10 torrey Exp $ */ #import "quartzCommon.h" @@ -49,6 +49,9 @@ #define STR(s) #s #define XSTRPATH(s) STR(s) +// Keys for user defaults dictionary +static NSString *X11EnableKeyEquivalentsKey = @"EnableKeyEquivalents"; + @implementation Preferences @@ -70,6 +73,7 @@ [NSNumber numberWithInt:0], @"SwitchKeyCode", [NSNumber numberWithInt:(NSCommandKeyMask | NSAlternateKeyMask)], @"SwitchModifiers", @"NO", @"UseSystemBeep", + @"YES", X11EnableKeyEquivalentsKey, @"YES", @"DockSwitch", @"NO", @"AllowMouseAccelChange", [NSNumber numberWithInt:qdCursor_Not8Bit], @"UseQDCursor", @@ -391,6 +395,14 @@ quartzUseSysBeep = newSystemBeep; } ++ (void)setEnableKeyEquivalents:(BOOL)newKeyEquivs +{ + [[NSUserDefaults standardUserDefaults] setBool:newKeyEquivs + forKey:X11EnableKeyEquivalentsKey]; + // Update the setting used by the X server thread + quartzEnableKeyEquivalents = newKeyEquivs; +} + + (void)setXinerama:(BOOL)newXinerama { [[NSUserDefaults standardUserDefaults] setBool:newXinerama @@ -537,6 +549,11 @@ return [[NSUserDefaults standardUserDefaults] boolForKey:@"UseSystemBeep"]; } ++ (BOOL)enableKeyEquivalents +{ + return [[NSUserDefaults standardUserDefaults] boolForKey:X11EnableKeyEquivalentsKey]; +} + + (BOOL)xinerama { return [[NSUserDefaults standardUserDefaults] boolForKey:@"Xinerama"]; diff --git a/hw/darwin/quartz/XDarwin.pbproj/project.pbxproj b/hw/darwin/quartz/XDarwin.pbproj/project.pbxproj index 9dc2bb92c..109e313f3 100644 --- a/hw/darwin/quartz/XDarwin.pbproj/project.pbxproj +++ b/hw/darwin/quartz/XDarwin.pbproj/project.pbxproj @@ -334,7 +334,7 @@ <key>CFBundleExecutable</key> <string>XDarwin</string> <key>CFBundleGetInfoString</key> - <string>XDarwin 1.3.0, X.Org Foundation</string> + <string>XDarwin 1.4.0, X.Org Foundation</string> <key>CFBundleIconFile</key> <string>XDarwin.icns</string> <key>CFBundleIdentifier</key> @@ -346,7 +346,7 @@ <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleShortVersionString</key> - <string>XDarwin 1.3.0</string> + <string>XDarwin 1.4.0</string> <key>CFBundleSignature</key> <string>????</string> <key>CFBundleVersion</key> diff --git a/hw/darwin/quartz/XServer.h b/hw/darwin/quartz/XServer.h index 5fef683a8..dc6701b22 100644 --- a/hw/darwin/quartz/XServer.h +++ b/hw/darwin/quartz/XServer.h @@ -29,7 +29,7 @@ * sale, use or other dealings in this Software without prior written * authorization. */ -/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/XServer.h,v 1.1.4.2.4.2 2004/03/04 20:16:11 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/XServer.h,v 1.3 2004/07/30 19:12:17 torrey Exp $ */ /* $XFree86: xc/programs/Xserver/hw/darwin/quartz/XServer.h,v 1.16 2003/11/23 06:04:01 torrey Exp $ */ #define BOOL xBOOL @@ -39,7 +39,7 @@ #import <Cocoa/Cocoa.h> @interface XServer : NSObject { - // server state + // Server state int serverState; NSRecursiveLock *serverLock; NSMutableArray *pendingClients; @@ -49,6 +49,7 @@ BOOL quitWithoutQuery; BOOL pendingAppQuitReply; UInt32 mouseState; + unsigned short swallowedKey; BOOL sendServerEvents; BOOL x11Active; @@ -73,7 +74,7 @@ - (BOOL)translateEvent:(NSEvent *)anEvent; - (BOOL)getMousePosition:(xEvent *)xe fromEvent:(NSEvent *)anEvent; -+ (void)append:(NSString *)value toEnv:(NSString *)name; +- (NSString *)makeSafePath:(NSString *)path; - (BOOL)loadDisplayBundle; - (void)startX; diff --git a/hw/darwin/quartz/XServer.m b/hw/darwin/quartz/XServer.m index 58cba6fbc..3b30d1bf3 100644 --- a/hw/darwin/quartz/XServer.m +++ b/hw/darwin/quartz/XServer.m @@ -34,7 +34,7 @@ * sale, use or other dealings in this Software without prior written * authorization. */ -/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/XServer.m,v 1.1.4.2.4.2 2004/03/04 20:16:11 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/XServer.m,v 1.3 2004/07/30 19:12:17 torrey Exp $ */ /* $XFree86: xc/programs/Xserver/hw/darwin/quartz/XServer.m,v 1.19 2003/11/24 05:39:01 torrey Exp $ */ #include "quartzCommon.h" @@ -83,11 +83,11 @@ typedef struct { } shellList_t; static shellList_t const shellList[] = { - { "csh", shell_C }, // standard C shell - { "tcsh", shell_C }, // ... needs no introduction - { "sh", shell_Bourne }, // standard Bourne shell - { "zsh", shell_Bourne }, // Z shell - { "bash", shell_Bourne }, // GNU Bourne again shell + { "csh", shell_C }, // standard C shell + { "tcsh", shell_C }, // ... needs no introduction + { "sh", shell_Bourne }, // standard Bourne shell + { "zsh", shell_Bourne }, // Z shell + { "bash", shell_Bourne }, // GNU Bourne again shell { NULL, shell_Unknown } }; @@ -267,6 +267,7 @@ static io_connect_t root_port; xe.u.u.type = ButtonRelease; xe.u.u.detail = 1; break; + case NSLeftMouseDown: [self getMousePosition:&xe fromEvent:anEvent]; if (quartzRootless) { @@ -286,6 +287,7 @@ static io_connect_t root_port; xe.u.u.type = ButtonPress; xe.u.u.detail = 1; break; + case NSMouseMoved: case NSLeftMouseDragged: case NSRightMouseDragged: @@ -293,6 +295,7 @@ static io_connect_t root_port; [self getMousePosition:&xe fromEvent:anEvent]; xe.u.u.type = MotionNotify; break; + case NSSystemDefined: { long hwButtons = [anEvent data2]; @@ -309,36 +312,56 @@ static io_connect_t root_port; xe.u.clientMessage.u.l.longs1 =[anEvent data2]; break; } + case NSScrollWheel: [self getMousePosition:&xe fromEvent:anEvent]; xe.u.u.type = kXDarwinScrollWheel; - xe.u.clientMessage.u.s.shorts0 = [anEvent deltaY]; + xe.u.clientMessage.u.s.shorts0 = [anEvent deltaX] + + [anEvent deltaY]; break; + case NSKeyDown: case NSKeyUp: - if (!x11Active) + if (!x11Active) { + swallowedKey = 0; return NO; - // If the mouse is not on the valid X display area, - // we don't send the X server key events. - if (![self getMousePosition:&xe fromEvent:nil]) - return NO; - if (type == NSKeyDown) - xe.u.u.type = KeyPress; - else - xe.u.u.type = KeyRelease; + } + + if (type == NSKeyDown) { + // If the mouse is not on the valid X display area, + // don't send the X server key events. + if (![self getMousePosition:&xe fromEvent:nil]) { + swallowedKey = [anEvent keyCode]; + return NO; + } + + // See if there are any global shortcuts for this key combo. + if (quartzEnableKeyEquivalents + && [[NSApp mainMenu] performKeyEquivalent:anEvent]) + { + swallowedKey = [anEvent keyCode]; + return YES; + } + } else { + // If the down key event was a valid key combo, + // don't pass the up event to X11. + if (swallowedKey != 0 && [anEvent keyCode] == swallowedKey) { + swallowedKey = 0; + return NO; + } + } + + xe.u.u.type = (type == NSKeyDown) ? KeyPress : KeyRelease; xe.u.u.detail = [anEvent keyCode]; break; + case NSFlagsChanged: if (!x11Active) return NO; - [self getMousePosition:&xe fromEvent:nil]; xe.u.u.type = kXDarwinUpdateModifiers; xe.u.clientMessage.u.l.longs0 = flags; break; - case NSOtherMouseDown: // undocumented MouseDown - case NSOtherMouseUp: // undocumented MouseUp - // Hide these from AppKit to avoid its log messages - return YES; + default: return NO; } @@ -395,14 +418,33 @@ static io_connect_t root_port; } } -// Append a string to the given enviroment variable -+ (void)append:(NSString*)value toEnv:(NSString*)name + +// Make a safe path +// +// Return the path in single quotes in case there are problematic characters in it. +// We still have to worry about there being single quotes in the path. So, replace +// all instances of the ' character in the path with '\''. +- (NSString *)makeSafePath:(NSString *)path { - setenv([name cString], - [[[NSString stringWithCString:getenv([name cString])] - stringByAppendingString:value] cString],1); + NSMutableString *safePath = [NSMutableString stringWithString:path]; + NSRange aRange = NSMakeRange(0, [safePath length]); + + while (aRange.length) { + aRange = [safePath rangeOfString:@"'" options:0 range:aRange]; + if (!aRange.length) + break; + [safePath replaceCharactersInRange:aRange + withString:@"\'\\'\'"]; + aRange.location += 4; + aRange.length = [safePath length] - aRange.location; + } + + safePath = [NSMutableString stringWithFormat:@"'%@'", safePath]; + + return safePath; } + - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { // Block SIGPIPE @@ -488,13 +530,21 @@ static io_connect_t root_port; if (![self loadDisplayBundle]) [NSApp terminate:nil]; - // In rootless mode register to receive notification of key window changes if (quartzRootless) { + // We need to track whether the key window is an X11 window [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowBecameKey:) name:NSWindowDidBecomeKeyNotification object:nil]; + + // Request notification of screen layout changes even when this + // is not the active application + [[NSDistributedNotificationCenter defaultCenter] + addObserver:self + selector:@selector(applicationDidChangeScreenParameters:) + name:NSApplicationDidChangeScreenParametersNotification + object:nil]; } // Start the X server thread @@ -581,8 +631,7 @@ static io_connect_t root_port; { struct passwd *passwdUser; NSString *shellPath, *dashShellName, *commandStr, *startXPath; - NSMutableString *safeStartXPath; - NSRange aRange; + NSString *safeStartXPath; NSBundle *thisBundle; const char *shellPathStr, *newargv[3], *shellNameStr; int fd[2], outFD, length, shellType, i; @@ -645,11 +694,11 @@ static io_connect_t root_port; // Inside the new process: if (fd[0] != STDIN_FILENO) { - dup2(fd[0], STDIN_FILENO); // Take stdin from pipe + dup2(fd[0], STDIN_FILENO); // Take stdin from pipe close(fd[0]); } - close(fd[1]); // Close write end of pipe - if (outFD == STDOUT_FILENO) { // Setup stdout and stderr + close(fd[1]); // Close write end of pipe + if (outFD == STDOUT_FILENO) { // Setup stdout and stderr dup2(outFD, STDERR_FILENO); } else if (outFD == STDERR_FILENO) { dup2(outFD, STDOUT_FILENO); @@ -685,28 +734,14 @@ static io_connect_t root_port; return NO; } - // We will run the startXClients script with the path in single quotes - // in case there are problematic characters in the path. We still have - // to worry about there being single quotes in the path. So, replace - // all instances of the ' character in startXPath with '\''. - safeStartXPath = [NSMutableString stringWithString:startXPath]; - aRange = NSMakeRange(0, [safeStartXPath length]); - while (aRange.length) { - aRange = [safeStartXPath rangeOfString:@"'" options:0 range:aRange]; - if (!aRange.length) - break; - [safeStartXPath replaceCharactersInRange:aRange - withString:@"\'\\'\'"]; - aRange.location += 4; - aRange.length = [safeStartXPath length] - aRange.location; - } + safeStartXPath = [self makeSafePath:startXPath]; if ([Preferences addToPath]) { - commandStr = [NSString stringWithFormat:@"'%@' :%d %@\n", + commandStr = [NSString stringWithFormat:@"%@ :%d %@\n", safeStartXPath, [Preferences display], [Preferences addToPathString]]; } else { - commandStr = [NSString stringWithFormat:@"'%@' :%d\n", + commandStr = [NSString stringWithFormat:@"%@ :%d\n", safeStartXPath, [Preferences display]]; } @@ -726,7 +761,7 @@ static io_connect_t root_port; // FIXME: This should be unified with startXClients - (void)runClient:(NSString *)filename { - const char *command = [filename UTF8String]; + const char *command = [[self makeSafePath:filename] UTF8String]; const char *shell; const char *argv[5]; int child1, child2 = 0; @@ -1177,10 +1212,10 @@ static io_connect_t root_port; - (void)activateX11:(BOOL)state { if (state) { - QuartzMessageServerThread(kXDarwinActivate, 0); + QuartzMessageServerThread(kXDarwinActivate, 0); } else { - QuartzMessageServerThread(kXDarwinDeactivate, 0); + QuartzMessageServerThread(kXDarwinDeactivate, 0); } x11Active = state; @@ -1311,6 +1346,12 @@ static io_connect_t root_port; * Application Delegate Methods */ +- (void)applicationDidChangeScreenParameters:(NSNotification *)aNotification +{ + if (quartzProcs->ScreenChanged) + quartzProcs->ScreenChanged(); +} + - (void)applicationDidHide:(NSNotification *)aNotification { if ((AppleWMSelectedEvents() & AppleWMControllerNotifyMask) != 0) { diff --git a/hw/darwin/quartz/cr/crFrame.m b/hw/darwin/quartz/cr/crFrame.m index 1ea40f0aa..81ec3688f 100644 --- a/hw/darwin/quartz/cr/crFrame.m +++ b/hw/darwin/quartz/cr/crFrame.m @@ -27,6 +27,7 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ +/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/cr/crFrame.m,v 1.2 2004/04/23 19:15:51 eich Exp $ */ /* $XFree86: xc/programs/Xserver/hw/darwin/quartz/cr/crFrame.m,v 1.9 2004/03/19 02:05:29 torrey Exp $ */ #include "quartzCommon.h" diff --git a/hw/darwin/quartz/cr/crScreen.m b/hw/darwin/quartz/cr/crScreen.m index 6b5a2c8cf..1006e0adc 100644 --- a/hw/darwin/quartz/cr/crScreen.m +++ b/hw/darwin/quartz/cr/crScreen.m @@ -1,10 +1,10 @@ -/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/cr/crScreen.m,v 1.1.4.2.4.2 2004/03/04 17:47:30 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/cr/crScreen.m,v 1.4 2004/08/12 20:24:36 torrey Exp $ */ /* * Cocoa rootless implementation initialization */ /* * Copyright (c) 2001 Greg Parker. All Rights Reserved. - * Copyright (c) 2002-2003 Torrey T. Lyons. All Rights Reserved. + * Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -47,6 +47,9 @@ #include "scrnintstr.h" #include "picturestr.h" #include "globals.h" +#ifdef DAMAGE +# include "damage.h" +#endif #undef BOOL // Name of GLX bundle using AGL framework @@ -79,6 +82,79 @@ CRDisplayInit(void) /* + * CRAddPseudoramiXScreens + * Add a single virtual screen encompassing all the physical screens + * with PseudoramiX. + */ +static void +CRAddPseudoramiXScreens(int *x, int *y, int *width, int *height) +{ + int i; + NSRect unionRect = NSMakeRect(0, 0, 0, 0); + NSArray *screens = [NSScreen screens]; + + // Get the union of all screens (minus the menu bar on main screen) + for (i = 0; i < [screens count]; i++) { + NSScreen *screen = [screens objectAtIndex:i]; + NSRect frame = [screen frame]; + frame.origin.y = [[NSScreen mainScreen] frame].size.height - + frame.size.height - frame.origin.y; + if (NSEqualRects([screen frame], [[NSScreen mainScreen] frame])) { + frame.origin.y += aquaMenuBarHeight; + frame.size.height -= aquaMenuBarHeight; + } + unionRect = NSUnionRect(unionRect, frame); + } + + // Use unionRect as the screen size for the X server. + *x = unionRect.origin.x; + *y = unionRect.origin.y; + *width = unionRect.size.width; + *height = unionRect.size.height; + + // Tell PseudoramiX about the real screens. + // InitOutput() will move the big screen to (0,0), + // so compensate for that here. + for (i = 0; i < [screens count]; i++) { + NSScreen *screen = [screens objectAtIndex:i]; + NSRect frame = [screen frame]; + int j; + + // Skip this screen if it's a mirrored copy of an earlier screen. + for (j = 0; j < i; j++) { + if (NSEqualRects(frame, [[screens objectAtIndex:j] frame])) { + ErrorF("PseudoramiX screen %d is a mirror of screen %d.\n", + i, j); + break; + } + } + if (j < i) continue; // this screen is a mirrored copy + + frame.origin.y = [[NSScreen mainScreen] frame].size.height - + frame.size.height - frame.origin.y; + + if (NSEqualRects([screen frame], [[NSScreen mainScreen] frame])) { + frame.origin.y += aquaMenuBarHeight; + frame.size.height -= aquaMenuBarHeight; + } + + ErrorF("PseudoramiX screen %d added: %dx%d @ (%d,%d).\n", i, + (int)frame.size.width, (int)frame.size.height, + (int)frame.origin.x, (int)frame.origin.y); + + frame.origin.x -= unionRect.origin.x; + frame.origin.y -= unionRect.origin.y; + + ErrorF("PseudoramiX screen %d placed at X11 coordinate (%d,%d).\n", + i, (int)frame.origin.x, (int)frame.origin.y); + + PseudoramiXAddScreen(frame.origin.x, frame.origin.y, + frame.size.width, frame.size.height); + } +} + + +/* * CRScreenParams * Set the basic screen parameters. */ @@ -100,7 +176,6 @@ CRScreenParams(int index, DarwinFramebufferPtr dfb) dfb->width = NSWidth(frame); dfb->height = NSHeight(frame); - dfb->pitch = (dfb->width) * (dfb->bitsPerPixel) / 8; // Shift the usable part of main screen down to avoid the menu bar. if (NSEqualRects(frame, [[NSScreen mainScreen] frame])) { @@ -109,69 +184,7 @@ CRScreenParams(int index, DarwinFramebufferPtr dfb) } } else { - int i; - NSRect unionRect = NSMakeRect(0, 0, 0, 0); - NSArray *screens = [NSScreen screens]; - - // Get the union of all screens (minus the menu bar on main screen) - for (i = 0; i < [screens count]; i++) { - NSScreen *screen = [screens objectAtIndex:i]; - NSRect frame = [screen frame]; - frame.origin.y = [[NSScreen mainScreen] frame].size.height - - frame.size.height - frame.origin.y; - if (NSEqualRects([screen frame], [[NSScreen mainScreen] frame])) { - frame.origin.y += aquaMenuBarHeight; - frame.size.height -= aquaMenuBarHeight; - } - unionRect = NSUnionRect(unionRect, frame); - } - - // Use unionRect as the screen size for the X server. - dfb->x = unionRect.origin.x; - dfb->y = unionRect.origin.y; - dfb->width = unionRect.size.width; - dfb->height = unionRect.size.height; - dfb->pitch = (dfb->width) * (dfb->bitsPerPixel) / 8; - - // Tell PseudoramiX about the real screens. - // InitOutput() will move the big screen to (0,0), - // so compensate for that here. - for (i = 0; i < [screens count]; i++) { - NSScreen *screen = [screens objectAtIndex:i]; - NSRect frame = [screen frame]; - int j; - - // Skip this screen if it's a mirrored copy of an earlier screen. - for (j = 0; j < i; j++) { - if (NSEqualRects(frame, [[screens objectAtIndex:j] frame])) { - ErrorF("PseudoramiX screen %d is a mirror of screen %d.\n", - i, j); - break; - } - } - if (j < i) continue; // this screen is a mirrored copy - - frame.origin.y = [[NSScreen mainScreen] frame].size.height - - frame.size.height - frame.origin.y; - - if (NSEqualRects([screen frame], [[NSScreen mainScreen] frame])) { - frame.origin.y += aquaMenuBarHeight; - frame.size.height -= aquaMenuBarHeight; - } - - ErrorF("PseudoramiX screen %d added: %dx%d @ (%d,%d).\n", i, - (int)frame.size.width, (int)frame.size.height, - (int)frame.origin.x, (int)frame.origin.y); - - frame.origin.x -= unionRect.origin.x; - frame.origin.y -= unionRect.origin.y; - - ErrorF("PseudoramiX screen %d placed at X11 coordinate (%d,%d).\n", - i, (int)frame.origin.x, (int)frame.origin.y); - - PseudoramiXAddScreen(frame.origin.x, frame.origin.y, - frame.size.width, frame.size.height); - } + CRAddPseudoramiXScreens(&dfb->x, &dfb->y, &dfb->width, &dfb->height); } } @@ -195,8 +208,11 @@ CRAddScreen(int index, ScreenPtr pScreen) dfb->colorType = TrueColor; - // No frame buffer - it's all in window pixmaps. - dfb->framebuffer = NULL; // malloc(dfb.pitch * dfb.height); + /* Passing zero width (pitch) makes miCreateScreenResources set the + screen pixmap to the framebuffer pointer, i.e. NULL. The generic + rootless code takes care of making this work. */ + dfb->pitch = 0; + dfb->framebuffer = NULL; // Get all CoreGraphics displays covered by this X11 display. cgRect = CGRectMake(dfb->x, dfb->y, dfb->width, dfb->height); @@ -245,12 +261,47 @@ CRSetupScreen(int index, ScreenPtr pScreen) } #endif /* RENDER */ +#ifdef DAMAGE + // The Damage extension needs to wrap underneath the + // generic rootless layer, so do it now. + if (!DamageSetup(pScreen)) + return FALSE; +#endif + // Initialize generic rootless code return CRInit(pScreen); } /* + * CRScreenChanged + * Configuration of displays has changed. + */ +static void +CRScreenChanged(void) +{ + QuartzMessageServerThread(kXDarwinDisplayChanged, 0); +} + + +/* + * CRUpdateScreen + * Update screen after configuation change. + */ +static void +CRUpdateScreen(ScreenPtr pScreen) +{ + rootlessGlobalOffsetX = darwinMainScreenX; + rootlessGlobalOffsetY = darwinMainScreenY; + + AppleWMSetScreenOrigin(WindowTable[pScreen->myNum]); + + RootlessRepositionWindows(pScreen); + RootlessUpdateScreenPixmap(pScreen); +} + + +/* * CRInitInput * Finalize CR specific setup. */ @@ -300,11 +351,14 @@ static QuartzModeProcsRec crModeProcs = { QuartzResumeXCursor, NULL, // No capture or release in rootless mode NULL, + CRScreenChanged, + CRAddPseudoramiXScreens, + CRUpdateScreen, CRIsX11Window, NULL, // Cocoa NSWindows hide themselves RootlessFrameForWindow, TopLevelParent, - NULL, // No support for DRI surfaces + NULL, // No support for DRI surfaces NULL }; diff --git a/hw/darwin/quartz/fullscreen/fullscreen.c b/hw/darwin/quartz/fullscreen/fullscreen.c index 54223e85e..05542eafe 100644 --- a/hw/darwin/quartz/fullscreen/fullscreen.c +++ b/hw/darwin/quartz/fullscreen/fullscreen.c @@ -25,7 +25,7 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ -/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/fullscreen/fullscreen.c,v 1.1.4.2.4.2 2004/03/04 20:16:14 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/fullscreen/fullscreen.c,v 1.3 2004/07/30 19:12:18 torrey Exp $ */ /* $XFree86: xc/programs/Xserver/hw/darwin/quartz/fullscreen/fullscreen.c,v 1.3 2003/11/27 01:59:53 torrey Exp $ */ #include "quartzCommon.h" @@ -261,7 +261,7 @@ static void FSSuspendScreen( */ static void FSResumeScreen( ScreenPtr pScreen, - int x, // cursor location + int x, // cursor location int y ) { QuartzResumeXCursor(pScreen, x, y); @@ -537,18 +537,21 @@ static QuartzModeProcsRec fsModeProcs = { FSDisplayInit, FSAddScreen, FSSetupScreen, - NULL, // Not needed + NULL, // Not needed QuartzInitCursor, QuartzReallySetCursor, FSSuspendScreen, FSResumeScreen, FSCapture, FSRelease, - NULL, // No rootless code in fullscreen + NULL, // No dynamic screen change support NULL, NULL, + NULL, // No rootless code in fullscreen NULL, - NULL, // No support for DRI surfaces + NULL, + NULL, + NULL, // No support for DRI surfaces NULL }; @@ -561,6 +564,6 @@ Bool QuartzModeBundleInit(void) { quartzProcs = &fsModeProcs; - quartzOpenGLBundle = NULL; // Only Mesa support for now + quartzOpenGLBundle = NULL; // Only Mesa support for now return TRUE; } diff --git a/hw/darwin/quartz/pseudoramiX.c b/hw/darwin/quartz/pseudoramiX.c index 2dd7c3ae5..9f71eae89 100644 --- a/hw/darwin/quartz/pseudoramiX.c +++ b/hw/darwin/quartz/pseudoramiX.c @@ -32,7 +32,7 @@ shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from Digital Equipment Corporation. ******************************************************************/ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/pseudoramiX.c,v 1.3 2003/04/30 23:15:39 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/pseudoramiX.c,v 1.4 2004/07/02 01:30:33 torrey Exp $ */ #include "pseudoramiX.h" @@ -111,11 +111,15 @@ void PseudoramiXExtensionInit(int argc, char *argv[]) if (noPseudoramiXExtension) return; + /* Even with only one screen we need to enable PseudoramiX to allow + dynamic screen configuration changes. */ +#if 0 if (pseudoramiXNumScreens == 1) { // Only one screen - disable Xinerama extension. noPseudoramiXExtension = TRUE; return; } +#endif // The server must not run the PanoramiX operations. noPanoramiXExtension = TRUE; @@ -142,12 +146,18 @@ void PseudoramiXExtensionInit(int argc, char *argv[]) } -static void PseudoramiXResetProc(ExtensionEntry *extEntry) +void PseudoramiXResetScreens(void) { pseudoramiXNumScreens = 0; } +static void PseudoramiXResetProc(ExtensionEntry *extEntry) +{ + PseudoramiXResetScreens(); +} + + // was PanoramiX static int ProcPseudoramiXQueryVersion(ClientPtr client) { diff --git a/hw/darwin/quartz/pseudoramiX.h b/hw/darwin/quartz/pseudoramiX.h index 23738cfb3..c2943369d 100644 --- a/hw/darwin/quartz/pseudoramiX.h +++ b/hw/darwin/quartz/pseudoramiX.h @@ -1,9 +1,10 @@ /* * Minimal implementation of PanoramiX/Xinerama */ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/pseudoramiX.h,v 1.2 2003/04/30 23:15:39 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/pseudoramiX.h,v 1.3 2004/07/02 01:30:33 torrey Exp $ */ extern int noPseudoramiXExtension; void PseudoramiXAddScreen(int x, int y, int w, int h); void PseudoramiXExtensionInit(int argc, char *argv[]); +void PseudoramiXResetScreens(void); diff --git a/hw/darwin/quartz/quartz.c b/hw/darwin/quartz/quartz.c index e7bdb0049..22151198a 100644 --- a/hw/darwin/quartz/quartz.c +++ b/hw/darwin/quartz/quartz.c @@ -1,11 +1,11 @@ -/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/quartz.c,v 1.1.4.3.4.2 2004/03/04 17:47:30 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/quartz.c,v 1.3 2004/07/30 19:12:17 torrey Exp $ */ /************************************************************** * * Quartz-specific support for the Darwin X Server * **************************************************************/ /* - * Copyright (c) 2001-2003 Greg Parker and Torrey T. Lyons. + * Copyright (c) 2001-2004 Greg Parker and Torrey T. Lyons. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -30,7 +30,7 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartz.c,v 1.13 2003/11/12 20:21:51 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartz.c,v 1.16 2004/07/02 01:30:33 torrey Exp $ */ #include "quartzCommon.h" #include "quartz.h" @@ -43,7 +43,9 @@ // X headers #include "scrnintstr.h" +#include "windowstr.h" #include "colormapst.h" +#include "globals.h" // System headers #include <sys/types.h> @@ -57,6 +59,7 @@ int quartzStartClients = 1; int quartzRootless = -1; int quartzUseSysBeep = 0; int quartzUseAGL = 1; +int quartzEnableKeyEquivalents = 1; int quartzServerVisible = TRUE; int quartzServerQuitting = FALSE; int quartzScreenIndex = 0; @@ -166,13 +169,78 @@ void DarwinModeInitInput( /* + * QuartzUpdateScreens + * Adjust for screen arrangement changes. + */ +static void QuartzUpdateScreens(void) +{ + ScreenPtr pScreen; + WindowPtr pRoot; + int x, y, width, height, sx, sy; + xEvent e; + + if (noPseudoramiXExtension || screenInfo.numScreens != 1) + { + /* FIXME: if not using Xinerama, we have multiple screens, and + to do this properly may need to add or remove screens. Which + isn't possible. So don't do anything. Another reason why + we default to running with Xinerama. */ + + return; + } + + pScreen = screenInfo.screens[0]; + + PseudoramiXResetScreens(); + quartzProcs->AddPseudoramiXScreens(&x, &y, &width, &height); + + dixScreenOrigins[pScreen->myNum].x = x; + dixScreenOrigins[pScreen->myNum].y = y; + pScreen->mmWidth = pScreen->mmWidth * ((double) width / pScreen->width); + pScreen->mmHeight = pScreen->mmHeight * ((double) height / pScreen->height); + pScreen->width = width; + pScreen->height = height; + + /* FIXME: should probably do something with RandR here. */ + + DarwinAdjustScreenOrigins(&screenInfo); + quartzProcs->UpdateScreen(pScreen); + + sx = dixScreenOrigins[pScreen->myNum].x + darwinMainScreenX; + sy = dixScreenOrigins[pScreen->myNum].y + darwinMainScreenY; + + /* Adjust the root window. */ + pRoot = WindowTable[pScreen->myNum]; + AppleWMSetScreenOrigin(pRoot); + pScreen->ResizeWindow(pRoot, x - sx, y - sy, width, height, NULL); + pScreen->PaintWindowBackground(pRoot, &pRoot->borderClip, PW_BACKGROUND); +// QuartzIgnoreNextWarpCursor(); + DefineInitialRootWindow(pRoot); + + /* Send an event for the root reconfigure */ + e.u.u.type = ConfigureNotify; + e.u.configureNotify.window = pRoot->drawable.id; + e.u.configureNotify.aboveSibling = None; + e.u.configureNotify.x = x - sx; + e.u.configureNotify.y = y - sy; + e.u.configureNotify.width = width; + e.u.configureNotify.height = height; + e.u.configureNotify.borderWidth = wBorderWidth(pRoot); + e.u.configureNotify.override = pRoot->overrideRedirect; + DeliverEvents(pRoot, &e, 1, NullWindow); + + /* FIXME: Should we use RREditConnectionInfo(pScreen)? */ +} + + +/* * QuartzShow * Show the X server on screen. Does nothing if already shown. * Calls mode specific screen resume to restore the X clip regions * (if needed) and the X server cursor state. */ static void QuartzShow( - int x, // cursor location + int x, // cursor location int y ) { int i; @@ -252,10 +320,10 @@ QuartzMessageServerThread( max_args = 4; if (argc > 0 && argc <= max_args) { - va_start (args, argc); - for (i = 0; i < argc; i++) - argv[i] = (int) va_arg (args, int); - va_end (args); + va_start (args, argc); + for (i = 0; i < argc; i++) + argv[i] = (int) va_arg (args, int); + va_end (args); } DarwinEQEnqueue(&xe); @@ -308,8 +376,8 @@ void DarwinModeProcessEvent( case kXDarwinControllerNotify: AppleWMSendEvent(AppleWMControllerNotify, AppleWMControllerNotifyMask, - xe->u.clientMessage.u.l.longs0, - xe->u.clientMessage.u.l.longs1); + xe->u.clientMessage.u.l.longs0, + xe->u.clientMessage.u.l.longs1); break; case kXDarwinPasteboardNotify: @@ -320,6 +388,9 @@ void DarwinModeProcessEvent( break; case kXDarwinDisplayChanged: + QuartzUpdateScreens(); + break; + case kXDarwinWindowState: case kXDarwinWindowMoved: // FIXME: Not implemented yet diff --git a/hw/darwin/quartz/quartz.h b/hw/darwin/quartz/quartz.h index 3961fe031..cee43325d 100644 --- a/hw/darwin/quartz/quartz.h +++ b/hw/darwin/quartz/quartz.h @@ -30,7 +30,7 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ -/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/quartz.h,v 1.1.4.2.4.2 2004/03/04 20:16:11 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/quartz.h,v 1.3 2004/07/30 19:12:17 torrey Exp $ */ /* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartz.h,v 1.7 2003/11/12 20:21:51 torrey Exp $ */ #ifndef _QUARTZ_H @@ -68,6 +68,13 @@ typedef void (*CaptureScreensProc)(void); typedef void (*ReleaseScreensProc)(void); /* + * Screen state change support + */ +typedef void (*ScreenChangedProc)(void); +typedef void (*AddPseudoramiXScreensProc)(int *x, int *y, int *width, int *height); +typedef void (*UpdateScreenProc)(ScreenPtr pScreen); + +/* * Rootless helper functions */ typedef Bool (*IsX11WindowProc)(void *nsWindow, int windowNumber); @@ -104,6 +111,10 @@ typedef struct _QuartzModeProcs { CaptureScreensProc CaptureScreens; // Only called in fullscreen ReleaseScreensProc ReleaseScreens; // Only called in fullscreen + ScreenChangedProc ScreenChanged; + AddPseudoramiXScreensProc AddPseudoramiXScreens; + UpdateScreenProc UpdateScreen; + IsX11WindowProc IsX11Window; HideWindowsProc HideWindows; diff --git a/hw/darwin/quartz/quartzCocoa.m b/hw/darwin/quartz/quartzCocoa.m index 6adbaafba..52832ccd6 100644 --- a/hw/darwin/quartz/quartzCocoa.m +++ b/hw/darwin/quartz/quartzCocoa.m @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/quartzCocoa.m,v 1.1.4.3.2.2 2004/03/04 17:47:30 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/quartzCocoa.m,v 1.3 2004/07/30 19:12:17 torrey Exp $ */ /************************************************************** * * Quartz-specific support for the Darwin X Server @@ -9,7 +9,7 @@ * **************************************************************/ /* - * Copyright (c) 2001-2003 Torrey T. Lyons and Greg Parker. + * Copyright (c) 2001-2004 Torrey T. Lyons and Greg Parker. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -34,7 +34,7 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzCocoa.m,v 1.3 2003/01/19 06:52:54 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzCocoa.m,v 1.5 2004/06/08 22:58:10 torrey Exp $ */ #include "quartzCommon.h" @@ -65,6 +65,7 @@ void QuartzReadPreferences(void) darwinFakeMouse3Mask = [Preferences button3Mask]; darwinMouseAccelChange = [Preferences mouseAccelChange]; quartzUseSysBeep = [Preferences systemBeep]; + quartzEnableKeyEquivalents = [Preferences enableKeyEquivalents]; // quartzRootless has already been set if (quartzRootless) { diff --git a/hw/darwin/quartz/quartzCommon.h b/hw/darwin/quartz/quartzCommon.h index a09475d31..949f724c1 100644 --- a/hw/darwin/quartz/quartzCommon.h +++ b/hw/darwin/quartz/quartzCommon.h @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/quartzCommon.h,v 1.1.4.2.4.2 2004/03/04 17:47:30 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/quartzCommon.h,v 1.3 2004/07/30 19:12:17 torrey Exp $ */ /* * quartzCommon.h * @@ -7,7 +7,7 @@ * This file should be included before any X11 or IOKit headers * so that it can avoid symbol conflicts. * - * Copyright (c) 2001-2003 Torrey T. Lyons and Greg Parker. + * Copyright (c) 2001-2004 Torrey T. Lyons and Greg Parker. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -32,7 +32,7 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzCommon.h,v 1.13 2003/10/16 23:50:10 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzCommon.h,v 1.15 2004/06/08 22:58:10 torrey Exp $ */ #ifndef _QUARTZCOMMON_H #define _QUARTZCOMMON_H @@ -70,6 +70,7 @@ extern int quartzStartClients; extern int quartzRootless; extern int quartzUseSysBeep; extern int quartzUseAGL; +extern int quartzEnableKeyEquivalents; // Other shared data extern int quartzServerVisible; @@ -104,4 +105,4 @@ enum { kQuartzSetCanQuit }; -#endif /* _QUARTZCOMMON_H */ +#endif /* _QUARTZCOMMON_H */ diff --git a/hw/darwin/quartz/xpr/xpr.h b/hw/darwin/quartz/xpr/xpr.h index ab9b9fd42..5b881c725 100644 --- a/hw/darwin/quartz/xpr/xpr.h +++ b/hw/darwin/quartz/xpr/xpr.h @@ -26,7 +26,7 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ -/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/xpr/xpr.h,v 1.1.4.1.4.2 2004/03/04 20:16:15 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/xpr/xpr.h,v 1.2 2004/04/23 19:16:52 eich Exp $ */ /* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/xpr.h,v 1.4 2003/11/12 20:21:52 torrey Exp $ */ #ifndef XPR_H diff --git a/hw/darwin/quartz/xpr/xprFrame.c b/hw/darwin/quartz/xpr/xprFrame.c index 0bf104a09..089f18c71 100644 --- a/hw/darwin/quartz/xpr/xprFrame.c +++ b/hw/darwin/quartz/xpr/xprFrame.c @@ -27,7 +27,7 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ -/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/xpr/xprFrame.c,v 1.1.4.1.4.2 2004/03/04 20:16:15 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/xpr/xprFrame.c,v 1.2 2004/04/23 19:16:52 eich Exp $ */ /* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/xprFrame.c,v 1.4 2003/11/12 20:21:52 torrey Exp $ */ #include "xpr.h" diff --git a/hw/darwin/quartz/xpr/xprScreen.c b/hw/darwin/quartz/xpr/xprScreen.c index 3adb62a63..5c77756fd 100644 --- a/hw/darwin/quartz/xpr/xprScreen.c +++ b/hw/darwin/quartz/xpr/xprScreen.c @@ -1,10 +1,10 @@ -/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/xpr/xprScreen.c,v 1.1.4.2.4.2 2004/03/04 17:47:30 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/darwin/quartz/xpr/xprScreen.c,v 1.4 2004/08/12 20:24:36 torrey Exp $ */ /* * Xplugin rootless implementation screen functions */ /* * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved. - * Copyright (c) 2003 Torrey T. Lyons. All Rights Reserved. + * Copyright (c) 2004 Torrey T. Lyons. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -28,7 +28,7 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ -/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/xprScreen.c,v 1.8 2003/11/12 20:21:52 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/xpr/xprScreen.c,v 1.11 2004/07/15 18:53:25 torrey Exp $ */ #include "quartzCommon.h" #include "quartz.h" @@ -42,6 +42,10 @@ #include "Xplugin.h" #include "applewmExt.h" +#ifdef DAMAGE +# include "damage.h" +#endif + // Name of GLX bundle for native OpenGL static const char *xprOpenGLBundle = "glxCGL.bundle"; @@ -57,41 +61,42 @@ eventHandler(unsigned int type, const void *arg, switch (type) { case XP_EVENT_DISPLAY_CHANGED: - QuartzMessageServerThread(kXDarwinDisplayChanged, 0); - break; + QuartzMessageServerThread(kXDarwinDisplayChanged, 0); + break; case XP_EVENT_WINDOW_STATE_CHANGED: - if (arg_size >= sizeof(xp_window_state_event)) + if (arg_size >= sizeof(xp_window_state_event)) { - const xp_window_state_event *ws_arg = arg; - QuartzMessageServerThread(kXDarwinWindowState, 2, + const xp_window_state_event *ws_arg = arg; + + QuartzMessageServerThread(kXDarwinWindowState, 2, ws_arg->id, ws_arg->state); - } - break; + } + break; case XP_EVENT_WINDOW_MOVED: - if (arg_size == sizeof(xp_window_id)) - { - xp_window_id id = * (xp_window_id *) arg; + if (arg_size == sizeof(xp_window_id)) + { + xp_window_id id = * (xp_window_id *) arg; - QuartzMessageServerThread(kXDarwinWindowMoved, 1, id); - } - break; + QuartzMessageServerThread(kXDarwinWindowMoved, 1, id); + } + break; case XP_EVENT_SURFACE_DESTROYED: case XP_EVENT_SURFACE_CHANGED: - if (arg_size == sizeof(xp_surface_id)) - { - int kind; - - if (type == XP_EVENT_SURFACE_DESTROYED) - kind = AppleDRISurfaceNotifyDestroyed; - else - kind = AppleDRISurfaceNotifyChanged; - - DRISurfaceNotify(*(xp_surface_id *) arg, kind); - } - break; + if (arg_size == sizeof(xp_surface_id)) + { + int kind; + + if (type == XP_EVENT_SURFACE_DESTROYED) + kind = AppleDRISurfaceNotifyDestroyed; + else + kind = AppleDRISurfaceNotifyChanged; + + DRISurfaceNotify(*(xp_surface_id *) arg, kind); + } + break; } } @@ -139,11 +144,12 @@ displayScreenBounds(CGDirectDisplayID id) /* - * addPseudoramiXScreens - * Add a physical screen with PseudoramiX. + * xprAddPseudoramiXScreens + * Add a single virtual screen encompassing all the physical screens + * with PseudoramiX. */ static void -addPseudoramiXScreens(int *x, int *y, int *width, int *height) +xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height) { CGDisplayCount i, displayCount; CGDirectDisplayID *displayList = NULL; @@ -286,7 +292,7 @@ xprAddScreen(int index, ScreenPtr pScreen) } else { - addPseudoramiXScreens(&dfb->x, &dfb->y, &dfb->width, &dfb->height); + xprAddPseudoramiXScreens(&dfb->x, &dfb->y, &dfb->width, &dfb->height); } /* Passing zero width (pitch) makes miCreateScreenResources set the @@ -319,6 +325,13 @@ xprSetupScreen(int index, ScreenPtr pScreen) } #endif /* RENDER */ +#ifdef DAMAGE + // The Damage extension needs to wrap underneath the + // generic rootless layer, so do it now. + if (!DamageSetup(pScreen)) + return FALSE; +#endif + // Initialize generic rootless code if (!xprInit(pScreen)) return FALSE; @@ -328,6 +341,23 @@ xprSetupScreen(int index, ScreenPtr pScreen) /* + * xprUpdateScreen + * Update screen after configuation change. + */ +static void +xprUpdateScreen(ScreenPtr pScreen) +{ + rootlessGlobalOffsetX = darwinMainScreenX; + rootlessGlobalOffsetY = darwinMainScreenY; + + AppleWMSetScreenOrigin(WindowTable[pScreen->myNum]); + + RootlessRepositionWindows(pScreen); + RootlessUpdateScreenPixmap(pScreen); +} + + +/* * xprInitInput * Finalize xpr specific setup. */ @@ -358,6 +388,9 @@ static QuartzModeProcsRec xprModeProcs = { QuartzResumeXCursor, NULL, // No capture or release in rootless mode NULL, + NULL, // Xplugin sends screen change events directly + xprAddPseudoramiXScreens, + xprUpdateScreen, xprIsX11Window, xprHideWindows, RootlessFrameForWindow, diff --git a/hw/dmx/dmx.c b/hw/dmx/dmx.c new file mode 100644 index 000000000..14b7d9858 --- /dev/null +++ b/hw/dmx/dmx.c @@ -0,0 +1,1129 @@ +/* $XFree86$ */ +/* + * Copyright 2002-2004 Red Hat Inc., Durham, North Carolina. + * + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation on the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* + * Authors: + * Rickard E. (Rik) Faith <faith@redhat.com> + * + */ + +/** \file + * This file implements the server-side part of the DMX protocol. A + * vector of fucntions is provided at extension initialization time, so + * most all of the useful functions in this file are declared static and + * do not appear in the doxygen documentation. + * + * Much of the low-level work is done by functions in #dmxextension.c + * + * Please see the Client-to-Server DMX Extension to the X Protocol + * document for details about the protocol. */ + +#include "X.h" +#include "Xproto.h" +#include "misc.h" +#include "os.h" +#include "dixstruct.h" +#define EXTENSION_PROC_ARGS void * +#include "extnsionst.h" +#include "opaque.h" + +#include "dmxextension.h" +#include "dmxproto.h" + +#define _DMX_SERVER_ +#include "dmxext.h" + +#ifdef PANORAMIX +#include "panoramiX.h" +extern unsigned long XRT_WINDOW; +extern int PanoramiXNumScreens; +#endif + +extern void DMXExtensionInit(void); + +static unsigned char DMXCode; + +static DISPATCH_PROC(ProcDMXDispatch); +static DISPATCH_PROC(ProcDMXQueryVersion); +static DISPATCH_PROC(ProcDMXSync); +static DISPATCH_PROC(ProcDMXForceWindowCreation); +static DISPATCH_PROC(ProcDMXGetScreenCount); +static DISPATCH_PROC(ProcDMXGetScreenAttributes); +static DISPATCH_PROC(ProcDMXChangeScreensAttributes); +static DISPATCH_PROC(ProcDMXAddScreen); +static DISPATCH_PROC(ProcDMXRemoveScreen); +static DISPATCH_PROC(ProcDMXGetWindowAttributes); +static DISPATCH_PROC(ProcDMXGetDesktopAttributes); +static DISPATCH_PROC(ProcDMXChangeDesktopAttributes); +static DISPATCH_PROC(ProcDMXGetInputCount); +static DISPATCH_PROC(ProcDMXGetInputAttributes); +static DISPATCH_PROC(ProcDMXAddInput); +static DISPATCH_PROC(ProcDMXRemoveInput); + +static DISPATCH_PROC(SProcDMXDispatch); +static DISPATCH_PROC(SProcDMXQueryVersion); +static DISPATCH_PROC(SProcDMXSync); +static DISPATCH_PROC(SProcDMXForceWindowCreation); +static DISPATCH_PROC(SProcDMXGetScreenCount); +static DISPATCH_PROC(SProcDMXGetScreenAttributes); +static DISPATCH_PROC(SProcDMXChangeScreensAttributes); +static DISPATCH_PROC(SProcDMXAddScreen); +static DISPATCH_PROC(SProcDMXRemoveScreen); +static DISPATCH_PROC(SProcDMXGetWindowAttributes); +static DISPATCH_PROC(SProcDMXGetDesktopAttributes); +static DISPATCH_PROC(SProcDMXChangeDesktopAttributes); +static DISPATCH_PROC(SProcDMXGetInputCount); +static DISPATCH_PROC(SProcDMXGetInputAttributes); +static DISPATCH_PROC(SProcDMXAddInput); +static DISPATCH_PROC(SProcDMXRemoveInput); + +static int _DMXXineramaActive(void) +{ +#ifdef PANORAMIX + return !noPanoramiXExtension; +#endif + return 0; +} + +static void DMXResetProc(ExtensionEntry *extEntry) +{ +} + +/** Initialize the extension. */ +void DMXExtensionInit(void) +{ + ExtensionEntry *extEntry; + + if ((extEntry = AddExtension(DMX_EXTENSION_NAME, 0, 0, + ProcDMXDispatch, SProcDMXDispatch, + DMXResetProc, StandardMinorOpcode))) + DMXCode = extEntry->base; +} + +static void dmxSetScreenAttribute(int bit, DMXScreenAttributesPtr attr, + CARD32 value) +{ + switch (1 << bit) { + case DMXScreenWindowWidth: attr->screenWindowWidth = value; break; + case DMXScreenWindowHeight: attr->screenWindowHeight = value; break; + case DMXScreenWindowXoffset: attr->screenWindowXoffset = value; break; + case DMXScreenWindowYoffset: attr->screenWindowYoffset = value; break; + case DMXRootWindowWidth: attr->rootWindowWidth = value; break; + case DMXRootWindowHeight: attr->rootWindowHeight = value; break; + case DMXRootWindowXoffset: attr->rootWindowXoffset = value; break; + case DMXRootWindowYoffset: attr->rootWindowYoffset = value; break; + case DMXRootWindowXorigin: attr->rootWindowXorigin = value; break; + case DMXRootWindowYorigin: attr->rootWindowYorigin = value; break; + } +} + +static int dmxFetchScreenAttributes(unsigned int mask, + DMXScreenAttributesPtr attr, + CARD32 *value_list) +{ + int i; + CARD32 *value = value_list; + int count = 0; + + for (i = 0; i < 32; i++) { + if (mask & (1 << i)) { + dmxSetScreenAttribute(i, attr, *value); + ++value; + ++count; + } + } + return count; +} + +static void dmxSetDesktopAttribute(int bit, DMXDesktopAttributesPtr attr, + CARD32 value) +{ + switch (1 << bit) { + case DMXDesktopWidth: attr->width = value; break; + case DMXDesktopHeight: attr->height = value; break; + case DMXDesktopShiftX: attr->shiftX = value; break; + case DMXDesktopShiftY: attr->shiftY = value; break; + } +} + +static int dmxFetchDesktopAttributes(unsigned int mask, + DMXDesktopAttributesPtr attr, + CARD32 *value_list) +{ + int i; + CARD32 *value = value_list; + int count = 0; + + for (i = 0; i < 32; i++) { + if (mask & (1 << i)) { + dmxSetDesktopAttribute(i, attr, *value); + ++value; + ++count; + } + } + return count; +} + +static void dmxSetInputAttribute(int bit, DMXInputAttributesPtr attr, + CARD32 value) +{ + switch (1 << bit) { + case DMXInputType: attr->inputType = value; break; + case DMXInputPhysicalScreen: attr->physicalScreen = value; break; + case DMXInputSendsCore: attr->sendsCore = !!value; break; + } +} + +static int dmxFetchInputAttributes(unsigned int mask, + DMXInputAttributesPtr attr, + CARD32 *value_list) +{ + int i; + CARD32 *value = value_list; + int count = 0; + + for (i = 0; i < 32; i++) { + if (mask & (1 << i)) { + dmxSetInputAttribute(i, attr, *value); + ++value; + ++count; + } + } + return count; +} + +static int ProcDMXQueryVersion(ClientPtr client) +{ + xDMXQueryVersionReply rep; + int n; + + REQUEST_SIZE_MATCH(xDMXQueryVersionReq); + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.majorVersion = DMX_EXTENSION_MAJOR; + rep.minorVersion = DMX_EXTENSION_MINOR; + rep.patchVersion = DMX_EXTENSION_PATCH; + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.majorVersion, n); + swapl(&rep.minorVersion, n); + swapl(&rep.patchVersion, n); + } + WriteToClient(client, sizeof(xDMXQueryVersionReply), (char *)&rep); + return client->noClientException; +} + +static int ProcDMXSync(ClientPtr client) +{ + xDMXSyncReply rep; + int n; + + REQUEST_SIZE_MATCH(xDMXSyncReq); + + dmxFlushPendingSyncs(); + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.status = 0; + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.status, n); + } + WriteToClient(client, sizeof(xDMXSyncReply), (char *)&rep); + return client->noClientException; +} + +static int ProcDMXForceWindowCreation(ClientPtr client) +{ + xDMXForceWindowCreationReply rep; + REQUEST(xDMXForceWindowCreationReq); + WindowPtr pWin; + int n; + + REQUEST_SIZE_MATCH(xDMXForceWindowCreationReq); + +#ifdef PANORAMIX + if (!noPanoramiXExtension) { + PanoramiXRes *win; + int i; + + if (!(win = SecurityLookupIDByType(client, stuff->window, XRT_WINDOW, + SecurityReadAccess))) + return -1; /* BadWindow */ + + FOR_NSCREENS(i) { + if (!(pWin = SecurityLookupWindow(win->info[i].id, client, + SecurityReadAccess))) + return -1; /* BadWindow */ + + dmxForceWindowCreation(pWin); + } + goto doreply; + } +#endif + + if (!(pWin = SecurityLookupWindow(stuff->window, client, + SecurityReadAccess))) + return -1; /* BadWindow */ + + dmxForceWindowCreation(pWin); + doreply: + dmxFlushPendingSyncs(); + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.status = 0; + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.status, n); + } + WriteToClient(client, sizeof(xDMXForceWindowCreationReply), (char *)&rep); + return Success; +} + +static int ProcDMXGetScreenCount(ClientPtr client) +{ + xDMXGetScreenCountReply rep; + int n; + + REQUEST_SIZE_MATCH(xDMXGetScreenCountReq); + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.screenCount = dmxGetNumScreens(); + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.screenCount, n); + } + WriteToClient(client, sizeof(xDMXGetScreenCountReply), (char *)&rep); + return client->noClientException; +} + +static int ProcDMXGetScreenAttributes(ClientPtr client) +{ + REQUEST(xDMXGetScreenAttributesReq); + xDMXGetScreenAttributesReply rep; + int n; + int length; + int paddedLength; + DMXScreenAttributesRec attr; + + REQUEST_SIZE_MATCH(xDMXGetScreenAttributesReq); + + if (stuff->physicalScreen < 0 + || stuff->physicalScreen >= dmxGetNumScreens()) return BadValue; + + if (!dmxGetScreenAttributes(stuff->physicalScreen, &attr)) + return BadValue; + + rep.logicalScreen = attr.logicalScreen; + rep.screenWindowWidth = attr.screenWindowWidth; + rep.screenWindowHeight = attr.screenWindowHeight; + rep.screenWindowXoffset = attr.screenWindowXoffset; + rep.screenWindowYoffset = attr.screenWindowYoffset; + rep.rootWindowWidth = attr.rootWindowWidth; + rep.rootWindowHeight = attr.rootWindowHeight; + rep.rootWindowXoffset = attr.rootWindowXoffset; + rep.rootWindowYoffset = attr.rootWindowYoffset; + rep.rootWindowXorigin = attr.rootWindowXorigin; + rep.rootWindowYorigin = attr.rootWindowYorigin; + + length = attr.displayName ? strlen(attr.displayName) : 0; + paddedLength = (length + 3) & ~3; + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = paddedLength >> 2; + rep.displayNameLength = length; + + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.displayNameLength, n); + swapl(&rep.logicalScreen, n); + swaps(&rep.screenWindowWidth, n); + swaps(&rep.screenWindowHeight, n); + swaps(&rep.screenWindowXoffset, n); + swaps(&rep.screenWindowYoffset, n); + swaps(&rep.rootWindowWidth, n); + swaps(&rep.rootWindowHeight, n); + swaps(&rep.rootWindowXoffset, n); + swaps(&rep.rootWindowYoffset, n); + swaps(&rep.rootWindowXorigin, n); + swaps(&rep.rootWindowYorigin, n); + } + WriteToClient(client, sizeof(xDMXGetScreenAttributesReply), (char *)&rep); + if (length) WriteToClient(client, length, (char *)attr.displayName); + return client->noClientException; +} + +static int ProcDMXChangeScreensAttributes(ClientPtr client) +{ + REQUEST(xDMXChangeScreensAttributesReq); + xDMXChangeScreensAttributesReply rep; + int n; + int status = DMX_BAD_XINERAMA; + unsigned int mask = 0; + unsigned int i; + CARD32 *screen_list; + CARD32 *mask_list; + CARD32 *value_list; + DMXScreenAttributesPtr attribs; + int errorScreen = 0; + unsigned int len; + int ones = 0; + + + REQUEST_AT_LEAST_SIZE(xDMXChangeScreensAttributesReq); + len = client->req_len - (sizeof(xDMXChangeScreensAttributesReq) >> 2); + if (len < stuff->screenCount + stuff->maskCount) + return BadLength; + + screen_list = (CARD32 *)(stuff + 1); + mask_list = &screen_list[stuff->screenCount]; + value_list = &mask_list[stuff->maskCount]; + + for (i = 0; i < stuff->maskCount; i++) ones += Ones(mask_list[i]); + if (len != stuff->screenCount + stuff->maskCount + ones) + return BadLength; + + if (!_DMXXineramaActive()) goto noxinerama; + + if (!(attribs = ALLOCATE_LOCAL(stuff->screenCount * sizeof(*attribs)))) + return BadAlloc; + + for (i = 0; i < stuff->screenCount; i++) { + int count; + + if (i < stuff->maskCount) mask = mask_list[i]; + dmxGetScreenAttributes(screen_list[i], &attribs[i]); + count = dmxFetchScreenAttributes(mask, &attribs[i], value_list); + value_list += count; + } + +#if PANORAMIX + status = dmxConfigureScreenWindows(stuff->screenCount, + screen_list, + attribs, + &errorScreen); +#endif + + DEALLOCATE_LOCAL(attribs); + + if (status == BadValue) return status; + + noxinerama: + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.status = status; + rep.errorScreen = errorScreen; + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.status, n); + swapl(&rep.errorScreen, n); + } + WriteToClient(client, + sizeof(xDMXChangeScreensAttributesReply), + (char *)&rep); + return client->noClientException; +} + +static int ProcDMXAddScreen(ClientPtr client) +{ + REQUEST(xDMXAddScreenReq); + xDMXAddScreenReply rep; + int n; + int status = 0; + CARD32 *value_list; + DMXScreenAttributesRec attr; + int count; + char *name; + int len; + int paddedLength; + + REQUEST_AT_LEAST_SIZE(xDMXAddScreenReq); + paddedLength = (stuff->displayNameLength + 3) & ~3; + len = client->req_len - (sizeof(xDMXAddScreenReq) >> 2); + if (len != Ones(stuff->valueMask) + paddedLength/4) + return BadLength; + + memset(&attr, 0, sizeof(attr)); + dmxGetScreenAttributes(stuff->physicalScreen, &attr); + value_list = (CARD32 *)(stuff + 1); + count = dmxFetchScreenAttributes(stuff->valueMask, &attr, value_list); + + if (!(name = ALLOCATE_LOCAL(stuff->displayNameLength + 1 + 4))) + return BadAlloc; + memcpy(name, &value_list[count], stuff->displayNameLength); + name[stuff->displayNameLength] = '\0'; + attr.displayName = name; + + status = dmxAttachScreen(stuff->physicalScreen, &attr); + + DEALLOCATE_LOCAL(name); + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.status = status; + rep.physicalScreen = stuff->physicalScreen; + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.status, n); + swapl(&rep.physicalScreen, n); + } + WriteToClient(client, + sizeof(xDMXAddScreenReply), + (char *)&rep); + return client->noClientException; +} + +static int ProcDMXRemoveScreen(ClientPtr client) +{ + REQUEST(xDMXRemoveScreenReq); + xDMXRemoveScreenReply rep; + int n; + int status = 0; + + REQUEST_SIZE_MATCH(xDMXRemoveScreenReq); + + status = dmxDetachScreen(stuff->physicalScreen); + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.status = status; + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.status, n); + } + WriteToClient(client, + sizeof(xDMXRemoveScreenReply), + (char *)&rep); + return client->noClientException; +} + + +#ifdef PANORAMIX +static int dmxPopulatePanoramiX(ClientPtr client, Window window, + CARD32 *screens, CARD32 *windows, + xRectangle *pos, xRectangle *vis) +{ + WindowPtr pWin; + PanoramiXRes *win; + int i; + int count = 0; + DMXWindowAttributesRec attr; + + if (!(win = SecurityLookupIDByType(client, window, XRT_WINDOW, + SecurityReadAccess))) + return -1; /* BadWindow */ + + FOR_NSCREENS(i) { + if (!(pWin = SecurityLookupWindow(win->info[i].id, client, + SecurityReadAccess))) + return -1; /* BadWindow */ + if (dmxGetWindowAttributes(pWin, &attr)) { + screens[count] = attr.screen; + windows[count] = attr.window; + pos[count] = attr.pos; + vis[count] = attr.vis; + ++count; /* Only count existing windows */ + } + } + return count; +} +#endif + +static int dmxPopulate(ClientPtr client, Window window, CARD32 *screens, + CARD32 *windows, xRectangle *pos, xRectangle *vis) +{ + WindowPtr pWin; + DMXWindowAttributesRec attr; + +#ifdef PANORAMIX + if (!noPanoramiXExtension) + return dmxPopulatePanoramiX(client, window, screens, windows, + pos, vis); +#endif + + if (!(pWin = SecurityLookupWindow(window, client, SecurityReadAccess))) + return -1; /* BadWindow */ + + dmxGetWindowAttributes(pWin, &attr); + *screens = attr.screen; + *windows = attr.window; + *pos = attr.pos; + *vis = attr.vis; + return 1; +} + +static int dmxMaxNumScreens(void) +{ +#ifdef PANORAMIX + if (!noPanoramiXExtension) return PanoramiXNumScreens; +#endif + return 1; +} + +static int ProcDMXGetWindowAttributes(ClientPtr client) +{ + REQUEST(xDMXGetWindowAttributesReq); + xDMXGetWindowAttributesReply rep; + int i, n; + CARD32 *screens; + CARD32 *windows; + xRectangle *pos, *vis; + int count = dmxMaxNumScreens(); + + REQUEST_SIZE_MATCH(xDMXGetWindowAttributesReq); + + if (!(screens = ALLOCATE_LOCAL(count * sizeof(*screens)))) + return BadAlloc; + if (!(windows = ALLOCATE_LOCAL(count * sizeof(*windows)))) { + DEALLOCATE_LOCAL(screens); + return BadAlloc; + } + if (!(pos = ALLOCATE_LOCAL(count * sizeof(*pos)))) { + DEALLOCATE_LOCAL(windows); + DEALLOCATE_LOCAL(screens); + return BadAlloc; + } + if (!(vis = ALLOCATE_LOCAL(count * sizeof(*vis)))) { + DEALLOCATE_LOCAL(pos); + DEALLOCATE_LOCAL(windows); + DEALLOCATE_LOCAL(screens); + return BadAlloc; + } + + if ((count = dmxPopulate(client, stuff->window, screens, windows, + pos, vis)) < 0) { + DEALLOCATE_LOCAL(vis); + DEALLOCATE_LOCAL(pos); + DEALLOCATE_LOCAL(windows); + DEALLOCATE_LOCAL(screens); + return BadWindow; + } + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = count * 6; + rep.screenCount = count; + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.screenCount, n); + for (i = 0; i < count; i++) { + swapl(&screens[i], n); + swapl(&windows[i], n); + + swaps(&pos[i].x, n); + swaps(&pos[i].y, n); + swaps(&pos[i].width, n); + swaps(&pos[i].height, n); + + swaps(&vis[i].x, n); + swaps(&vis[i].y, n); + swaps(&vis[i].width, n); + swaps(&vis[i].height, n); + } + } + + dmxFlushPendingSyncs(); + + WriteToClient(client, sizeof(xDMXGetWindowAttributesReply), (char *)&rep); + if (count) { + WriteToClient(client, count * sizeof(*screens), (char *)screens); + WriteToClient(client, count * sizeof(*windows), (char *)windows); + WriteToClient(client, count * sizeof(*pos), (char *)pos); + WriteToClient(client, count * sizeof(*vis), (char *)vis); + } + + DEALLOCATE_LOCAL(vis); + DEALLOCATE_LOCAL(pos); + DEALLOCATE_LOCAL(windows); + DEALLOCATE_LOCAL(screens); + + return client->noClientException; +} + +static int ProcDMXGetDesktopAttributes(ClientPtr client) +{ + xDMXGetDesktopAttributesReply rep; + int n; + DMXDesktopAttributesRec attr; + + REQUEST_SIZE_MATCH(xDMXGetDesktopAttributesReq); + + dmxGetDesktopAttributes(&attr); + + rep.width = attr.width; + rep.height = attr.height; + rep.shiftX = attr.shiftX; + rep.shiftY = attr.shiftY; + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.width, n); + swapl(&rep.height, n); + swapl(&rep.shiftX, n); + swapl(&rep.shiftY, n); + } + WriteToClient(client, sizeof(xDMXGetDesktopAttributesReply), (char *)&rep); + return client->noClientException; +} + +static int ProcDMXChangeDesktopAttributes(ClientPtr client) +{ + REQUEST(xDMXChangeDesktopAttributesReq); + xDMXChangeDesktopAttributesReply rep; + int n; + int status = DMX_BAD_XINERAMA; + CARD32 *value_list; + DMXDesktopAttributesRec attr; + int len; + + REQUEST_AT_LEAST_SIZE(xDMXChangeDesktopAttributesReq); + len = client->req_len - (sizeof(xDMXChangeDesktopAttributesReq) >> 2); + if (len != Ones(stuff->valueMask)) + return BadLength; + + if (!_DMXXineramaActive()) goto noxinerama; + + value_list = (CARD32 *)(stuff + 1); + + dmxGetDesktopAttributes(&attr); + dmxFetchDesktopAttributes(stuff->valueMask, &attr, value_list); + +#if PANORAMIX + status = dmxConfigureDesktop(&attr); +#endif + if (status == BadValue) return status; + + noxinerama: + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.status = status; + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.status, n); + } + WriteToClient(client, + sizeof(xDMXChangeDesktopAttributesReply), + (char *)&rep); + return client->noClientException; +} + +static int ProcDMXGetInputCount(ClientPtr client) +{ + xDMXGetInputCountReply rep; + int n; + + REQUEST_SIZE_MATCH(xDMXGetInputCountReq); + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.inputCount = dmxGetInputCount(); + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.inputCount, n); + } + WriteToClient(client, sizeof(xDMXGetInputCountReply), (char *)&rep); + return client->noClientException; +} + +static int ProcDMXGetInputAttributes(ClientPtr client) +{ + REQUEST(xDMXGetInputAttributesReq); + xDMXGetInputAttributesReply rep; + int n; + int length; + int paddedLength; + DMXInputAttributesRec attr; + + REQUEST_SIZE_MATCH(xDMXGetInputAttributesReq); + + if (dmxGetInputAttributes(stuff->deviceId, &attr)) return BadValue; + rep.inputType = attr.inputType; + rep.physicalScreen = attr.physicalScreen; + rep.physicalId = attr.physicalId; + rep.isCore = attr.isCore; + rep.sendsCore = attr.sendsCore; + rep.detached = attr.detached; + + length = attr.name ? strlen(attr.name) : 0; + paddedLength = (length + 3) & ~3; + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = paddedLength >> 2; + rep.nameLength = length; + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.inputType, n); + swapl(&rep.physicalScreen, n); + swapl(&rep.physicalId, n); + swapl(&rep.nameLength, n); + } + WriteToClient(client, sizeof(xDMXGetInputAttributesReply), (char *)&rep); + if (length) WriteToClient(client, length, (char *)attr.name); + return client->noClientException; +} + +static int ProcDMXAddInput(ClientPtr client) +{ + REQUEST(xDMXAddInputReq); + xDMXAddInputReply rep; + int n; + int status = 0; + CARD32 *value_list; + DMXInputAttributesRec attr; + int count; + char *name; + int len; + int paddedLength; + int id = -1; + + REQUEST_AT_LEAST_SIZE(xDMXAddInputReq); + paddedLength = (stuff->displayNameLength + 3) & ~3; + len = client->req_len - (sizeof(xDMXAddInputReq) >> 2); + if (len != Ones(stuff->valueMask) + paddedLength/4) + return BadLength; + + memset(&attr, 0, sizeof(attr)); + value_list = (CARD32 *)(stuff + 1); + count = dmxFetchInputAttributes(stuff->valueMask, &attr, value_list); + + if (!(name = ALLOCATE_LOCAL(stuff->displayNameLength + 1 + 4))) + return BadAlloc; + memcpy(name, &value_list[count], stuff->displayNameLength); + name[stuff->displayNameLength] = '\0'; + attr.name = name; + + status = dmxAddInput(&attr, &id); + + DEALLOCATE_LOCAL(name); + + if (status) return status; + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.status = status; + rep.physicalId = id; + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.status, n); + swapl(&rep.physicalId, n); + } + WriteToClient(client, sizeof(xDMXAddInputReply), (char *)&rep); + return client->noClientException; +} + +static int ProcDMXRemoveInput(ClientPtr client) +{ + REQUEST(xDMXRemoveInputReq); + xDMXRemoveInputReply rep; + int n; + int status = 0; + + REQUEST_SIZE_MATCH(xDMXRemoveInputReq); + + status = dmxRemoveInput(stuff->physicalId); + + if (status) return status; + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.status = status; + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.status, n); + } + WriteToClient(client, sizeof(xDMXRemoveInputReply), (char *)&rep); + return client->noClientException; +} + +static int ProcDMXDispatch(ClientPtr client) +{ + REQUEST(xReq); + + switch (stuff->data) { + case X_DMXQueryVersion: return ProcDMXQueryVersion(client); + case X_DMXSync: return ProcDMXSync(client); + case X_DMXForceWindowCreation: return ProcDMXForceWindowCreation(client); + case X_DMXGetScreenCount: return ProcDMXGetScreenCount(client); + case X_DMXGetScreenAttributes: return ProcDMXGetScreenAttributes(client); + case X_DMXChangeScreensAttributes: + return ProcDMXChangeScreensAttributes(client); + case X_DMXAddScreen: return ProcDMXAddScreen(client); + case X_DMXRemoveScreen: return ProcDMXRemoveScreen(client); + case X_DMXGetWindowAttributes: return ProcDMXGetWindowAttributes(client); + case X_DMXGetDesktopAttributes: return ProcDMXGetDesktopAttributes(client); + case X_DMXChangeDesktopAttributes: + return ProcDMXChangeDesktopAttributes(client); + case X_DMXGetInputCount: return ProcDMXGetInputCount(client); + case X_DMXGetInputAttributes: return ProcDMXGetInputAttributes(client); + case X_DMXAddInput: return ProcDMXAddInput(client); + case X_DMXRemoveInput: return ProcDMXRemoveInput(client); + + case X_DMXGetScreenInformationDEPRECATED: + case X_DMXForceWindowCreationDEPRECATED: + case X_DMXReconfigureScreenDEPRECATED: + return BadImplementation; + + default: return BadRequest; + } +} + +static int SProcDMXQueryVersion(ClientPtr client) +{ + int n; + REQUEST(xDMXQueryVersionReq); + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xDMXQueryVersionReq); + return ProcDMXQueryVersion(client); +} + +static int SProcDMXSync(ClientPtr client) +{ + int n; + REQUEST(xDMXSyncReq); + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xDMXSyncReq); + return ProcDMXSync(client); +} + +static int SProcDMXForceWindowCreation(ClientPtr client) +{ + int n; + REQUEST(xDMXForceWindowCreationReq); + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xDMXForceWindowCreationReq); + swaps(&stuff->window, n); + return ProcDMXForceWindowCreation(client); +} + +static int SProcDMXGetScreenCount(ClientPtr client) +{ + int n; + REQUEST(xDMXGetScreenCountReq); + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xDMXGetScreenCountReq); + return ProcDMXGetScreenCount(client); +} + +static int SProcDMXGetScreenAttributes(ClientPtr client) +{ + int n; + REQUEST(xDMXGetScreenAttributesReq); + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xDMXGetScreenAttributesReq); + swapl(&stuff->physicalScreen, n); + return ProcDMXGetScreenAttributes(client); +} + +static int SProcDMXChangeScreensAttributes(ClientPtr client) +{ + int n; + REQUEST(xDMXChangeScreensAttributesReq); + + swaps(&stuff->length, n); + REQUEST_AT_LEAST_SIZE(xDMXGetScreenAttributesReq); + swapl(&stuff->screenCount, n); + swapl(&stuff->maskCount, n); + SwapRestL(stuff); + return ProcDMXGetScreenAttributes(client); +} + +static int SProcDMXAddScreen(ClientPtr client) +{ + int n; + int paddedLength; + REQUEST(xDMXAddScreenReq); + + swaps(&stuff->length, n); + REQUEST_AT_LEAST_SIZE(xDMXAddScreenReq); + swapl(&stuff->displayNameLength, n); + swapl(&stuff->valueMask, n); + paddedLength = (stuff->displayNameLength + 3) & ~3; + SwapLongs((CARD32 *)(stuff+1), LengthRestL(stuff) - paddedLength/4); + return ProcDMXAddScreen(client); +} + +static int SProcDMXRemoveScreen(ClientPtr client) +{ + int n; + REQUEST(xDMXRemoveScreenReq); + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xDMXRemoveScreenReq); + swapl(&stuff->physicalScreen, n); + return ProcDMXRemoveScreen(client); +} + +static int SProcDMXGetWindowAttributes(ClientPtr client) +{ + int n; + REQUEST(xDMXGetWindowAttributesReq); + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xDMXGetWindowAttributesReq); + swapl(&stuff->window, n); + return ProcDMXGetWindowAttributes(client); +} + +static int SProcDMXGetDesktopAttributes(ClientPtr client) +{ + int n; + REQUEST(xDMXGetDesktopAttributesReq); + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xDMXGetDesktopAttributesReq); + return ProcDMXGetDesktopAttributes(client); +} + +static int SProcDMXChangeDesktopAttributes(ClientPtr client) +{ + int n; + REQUEST(xDMXChangeDesktopAttributesReq); + + swaps(&stuff->length, n); + REQUEST_AT_LEAST_SIZE(xDMXChangeDesktopAttributesReq); + swapl(&stuff->valueMask, n); + SwapRestL(stuff); + return ProcDMXChangeDesktopAttributes(client); +} + +static int SProcDMXGetInputCount(ClientPtr client) +{ + int n; + REQUEST(xDMXGetInputCountReq); + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xDMXGetInputCountReq); + return ProcDMXGetInputCount(client); +} + +static int SProcDMXGetInputAttributes(ClientPtr client) +{ + int n; + REQUEST(xDMXGetInputAttributesReq); + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xDMXGetInputAttributesReq); + swapl(&stuff->deviceId, n); + return ProcDMXGetInputAttributes(client); +} + +static int SProcDMXAddInput(ClientPtr client) +{ + int n; + int paddedLength; + REQUEST(xDMXAddInputReq); + + swaps(&stuff->length, n); + REQUEST_AT_LEAST_SIZE(xDMXAddInputReq); + swapl(&stuff->displayNameLength, n); + swapl(&stuff->valueMask, n); + paddedLength = (stuff->displayNameLength + 3) & ~3; + SwapLongs((CARD32 *)(stuff+1), LengthRestL(stuff) - paddedLength/4); + return ProcDMXAddInput(client); +} + +static int SProcDMXRemoveInput(ClientPtr client) +{ + int n; + REQUEST(xDMXRemoveInputReq); + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xDMXRemoveInputReq); + swapl(&stuff->physicalId, n); + return ProcDMXRemoveInput(client); +} + +static int SProcDMXDispatch (ClientPtr client) +{ + REQUEST(xReq); + + switch (stuff->data) { + case X_DMXQueryVersion: return SProcDMXQueryVersion(client); + case X_DMXSync: return SProcDMXSync(client); + case X_DMXForceWindowCreation: return SProcDMXForceWindowCreation(client); + case X_DMXGetScreenCount: return SProcDMXGetScreenCount(client); + case X_DMXGetScreenAttributes: return SProcDMXGetScreenAttributes(client); + case X_DMXChangeScreensAttributes: + return SProcDMXChangeScreensAttributes(client); + case X_DMXAddScreen: return SProcDMXAddScreen(client); + case X_DMXRemoveScreen: return SProcDMXRemoveScreen(client); + case X_DMXGetWindowAttributes: return SProcDMXGetWindowAttributes(client); + case X_DMXGetDesktopAttributes: + return SProcDMXGetDesktopAttributes(client); + case X_DMXChangeDesktopAttributes: + return SProcDMXChangeDesktopAttributes(client); + case X_DMXGetInputCount: return SProcDMXGetInputCount(client); + case X_DMXGetInputAttributes: return SProcDMXGetInputAttributes(client); + case X_DMXAddInput: return SProcDMXAddInput(client); + case X_DMXRemoveInput: return SProcDMXRemoveInput(client); + + case X_DMXGetScreenInformationDEPRECATED: + case X_DMXForceWindowCreationDEPRECATED: + case X_DMXReconfigureScreenDEPRECATED: + return BadImplementation; + + default: return BadRequest; + } +} diff --git a/hw/dmx/dmxdpms.c b/hw/dmx/dmxdpms.c new file mode 100644 index 000000000..b29e6004a --- /dev/null +++ b/hw/dmx/dmxdpms.c @@ -0,0 +1,209 @@ +/* $XFree86$ */ +/* + * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina. + * + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation on the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* + * Author: + * Rickard E. (Rik) Faith <faith@redhat.com> + * + */ + +/** \file + * Provides DPMS support and unifies all DPMS and other screen-saver + * support in one file. If -dpms is given on the command line, or the + * Xdmx server is not compiled with DPMS support, then the DPMS extension + * does not work for clients, but DPMS on the backends is still disables + * (and restored at Xdmx server shutdown time). + */ + +#include "dmx.h" +#include "dmxdpms.h" +#include "dmxlog.h" +#include "dmxsync.h" +#ifdef DPMSExtension +#include "dpmsproc.h" +#endif +#include "windowstr.h" /* For screenIsSaved */ +#include "X11/extensions/dpms.h" + +static unsigned long dpmsGeneration = 0; +static Bool dpmsSupported = TRUE; + +static void _dmxDPMSInit(DMXScreenInfo *dmxScreen) +{ + int event_base, error_base; + int major, minor; + CARD16 level, standby, suspend, off; + BOOL state; + const char *monitor; + + if (dpmsGeneration != serverGeneration) { + dpmsSupported = TRUE; /* On unless a backend doesn't support it */ + dpmsGeneration = serverGeneration; + } + +#ifdef DPMSExtension + if (DPMSDisabledSwitch) dpmsSupported = FALSE; /* -dpms turns off */ +#endif + + dmxScreen->dpmsCapable = 0; + + if (!dmxScreen->beDisplay) { + dmxLogOutput(dmxScreen, + "Cannot determine if DPMS supported (detached screen)\n"); + dpmsSupported = FALSE; + return; + } + + if (!DPMSQueryExtension(dmxScreen->beDisplay, + &event_base, &error_base)) { + dmxLogOutput(dmxScreen, "DPMS not supported\n"); + dpmsSupported = FALSE; + return; + } + if (!DPMSGetVersion(dmxScreen->beDisplay, &major, &minor)) { + dmxLogOutput(dmxScreen, "DPMS not supported\n"); + dpmsSupported = FALSE; + return; + } + if (!DPMSCapable(dmxScreen->beDisplay)) { + dmxLogOutput(dmxScreen, "DPMS %d.%d (not DPMS capable)\n", + major, minor); + dpmsSupported = FALSE; + return; + } + + DPMSInfo(dmxScreen->beDisplay, &level, &state); + DPMSGetTimeouts(dmxScreen->beDisplay, &standby, &suspend, &off); + DPMSSetTimeouts(dmxScreen->beDisplay, 0, 0, 0); + DPMSEnable(dmxScreen->beDisplay); + DPMSForceLevel(dmxScreen->beDisplay, DPMSModeOn); + dmxScreen->dpmsCapable = 1; + dmxScreen->dpmsEnabled = !!state; + dmxScreen->dpmsStandby = standby; + dmxScreen->dpmsSuspend = suspend; + dmxScreen->dpmsOff = off; + + switch (level) { + case DPMSModeOn: monitor = "on"; break; + case DPMSModeStandby: monitor = "standby"; break; + case DPMSModeSuspend: monitor = "suspend"; break; + case DPMSModeOff: monitor = "off"; break; + default: monitor = "unknown"; break; + } + + dmxLogOutput(dmxScreen, + "DPMS %d.%d (%s, %s, %d %d %d)\n", + major, minor, monitor, state ? "enabled" : "disabled", + standby, suspend, off); +} + +/** Initialize DPMS support. We save the current settings and turn off + * DPMS. The settings are restored in #dmxDPMSTerm. */ +void dmxDPMSInit(DMXScreenInfo *dmxScreen) +{ + int interval, preferBlanking, allowExposures; + + /* Turn off DPMS */ + _dmxDPMSInit(dmxScreen); + + if (!dmxScreen->beDisplay) + return; + + /* Turn off screen saver */ + XGetScreenSaver(dmxScreen->beDisplay, &dmxScreen->savedTimeout, &interval, + &preferBlanking, &allowExposures); + XSetScreenSaver(dmxScreen->beDisplay, 0, interval, + preferBlanking, allowExposures); + XResetScreenSaver(dmxScreen->beDisplay); + dmxSync(dmxScreen, FALSE); +} + +/** Terminate DPMS support on \a dmxScreen. We restore the settings + * saved in #dmxDPMSInit. */ +void dmxDPMSTerm(DMXScreenInfo *dmxScreen) +{ + int timeout, interval, preferBlanking, allowExposures; + + if (!dmxScreen->beDisplay) + return; + + XGetScreenSaver(dmxScreen->beDisplay, &timeout, &interval, + &preferBlanking, &allowExposures); + XSetScreenSaver(dmxScreen->beDisplay, dmxScreen->savedTimeout, interval, + preferBlanking, allowExposures); + if (dmxScreen->dpmsCapable) { + /* Restore saved state */ + DPMSForceLevel(dmxScreen->beDisplay, DPMSModeOn); + DPMSSetTimeouts(dmxScreen->beDisplay, dmxScreen->dpmsStandby, + dmxScreen->dpmsSuspend, dmxScreen->dpmsOff); + if (dmxScreen->dpmsEnabled) DPMSEnable(dmxScreen->beDisplay); + else DPMSDisable(dmxScreen->beDisplay); + } + dmxSync(dmxScreen, FALSE); +} + +/** Called when activity is detected so that DPMS power-saving mode can + * be deactivated. */ +void dmxDPMSWakeup(void) +{ + if (screenIsSaved == SCREEN_SAVER_ON) + SaveScreens(SCREEN_SAVER_OFF, ScreenSaverReset); +#ifdef DPMSExtension + if (DPMSPowerLevel) DPMSSet(0); +#endif +} + +#ifdef DPMSExtension +/** This is called on each server generation. It should determine if + * DPMS is supported on all of the backends and, if so, return TRUE. */ +Bool DPMSSupported(void) +{ + return dpmsSupported; +} + +/** This is used by clients (e.g., xset) to set the DPMS level. */ +void DPMSSet(int level) +{ + int i; + + if (!dpmsSupported) return; + + if (level < 0) level = DPMSModeOn; + if (level > 3) level = DPMSModeOff; + + DPMSPowerLevel = level; + + for (i = 0; i < dmxNumScreens; i++) { + DMXScreenInfo *dmxScreen = &dmxScreens[i]; + if (dmxScreen->beDisplay) { + DPMSForceLevel(dmxScreen->beDisplay, level); + dmxSync(dmxScreen, FALSE); + } + } +} +#endif diff --git a/hw/vfb/InitOutput.c b/hw/vfb/InitOutput.c index b0418508c..0fbf014d6 100644 --- a/hw/vfb/InitOutput.c +++ b/hw/vfb/InitOutput.c @@ -45,6 +45,7 @@ from The Open Group. #include "gcstruct.h" #include "input.h" #include "mipointer.h" +#include "micmap.h" #include <sys/types.h> #ifdef HAS_MMAP #include <sys/mman.h> @@ -64,13 +65,12 @@ from The Open Group. #endif /* HAS_SHM */ #include "dix.h" #include "miline.h" -#include "mfb.h" #define VFB_DEFAULT_WIDTH 1280 #define VFB_DEFAULT_HEIGHT 1024 #define VFB_DEFAULT_DEPTH 8 -#define VFB_DEFAULT_WHITEPIXEL 0 -#define VFB_DEFAULT_BLACKPIXEL 1 +#define VFB_DEFAULT_WHITEPIXEL 1 +#define VFB_DEFAULT_BLACKPIXEL 0 #define VFB_DEFAULT_LINEBIAS 0 #define XWD_WINDOW_NAME_LEN 60 @@ -278,6 +278,11 @@ ddxUseMsg() #endif } +/* ddxInitGlobals - called by |InitGlobals| from os/util.c */ +void ddxInitGlobals(void) +{ +} + int ddxProcessArgument(int argc, char *argv[], int i) { @@ -437,60 +442,6 @@ GetTimeInMillis() } #endif - -static Bool -vfbMultiDepthCreateGC(GCPtr pGC) -{ - switch (vfbBitsPerPixel(pGC->depth)) - { - case 1: return mfbCreateGC (pGC); - case 8: - case 16: - case 32: return fbCreateGC (pGC); - default: return FALSE; - } -} - -static void -vfbMultiDepthGetSpans( - DrawablePtr pDrawable, /* drawable from which to get bits */ - int wMax, /* largest value of all *pwidths */ - register DDXPointPtr ppt, /* points to start copying from */ - int *pwidth, /* list of number of bits to copy */ - int nspans, /* number of scanlines to copy */ - char *pdstStart) /* where to put the bits */ -{ - switch (pDrawable->bitsPerPixel) { - case 1: - mfbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart); - break; - case 8: - case 16: - case 32: - fbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart); - break; - } - return; -} - -static void -vfbMultiDepthGetImage(DrawablePtr pDrawable, int sx, int sy, int w, int h, - unsigned int format, unsigned long planeMask, - char *pdstLine) -{ - switch (pDrawable->bitsPerPixel) - { - case 1: - mfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine); - break; - case 8: - case 16: - case 32: - fbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine); - break; - } -} - static ColormapPtr InstalledMaps[MAXSCREENS]; static int @@ -917,39 +868,54 @@ vfbScreenInit(int index, ScreenPtr pScreen, int argc, char **argv) pbits = vfbAllocateFramebufferMemory(pvfb); if (!pbits) return FALSE; - /* miSetPixmapDepths ();*/ + miSetPixmapDepths (); - switch (pvfb->bitsPerPixel) - { - case 1: - ret = mfbScreenInit(pScreen, pbits, pvfb->width, pvfb->height, - dpix, dpiy, pvfb->paddedWidth); - break; + switch (pvfb->depth) { case 8: + miSetVisualTypesAndMasks (8, + ((1 << StaticGray) | + (1 << GrayScale) | + (1 << StaticColor) | + (1 << PseudoColor) | + (1 << TrueColor) | + (1 << DirectColor)), + 8, PseudoColor, 0x07, 0x38, 0xc0); + break; + case 15: + miSetVisualTypesAndMasks (15, + ((1 << TrueColor) | + (1 << DirectColor)), + 8, TrueColor, 0x7c00, 0x03e0, 0x001f); + break; case 16: - case 32: - ret = fbScreenInit(pScreen, pbits, pvfb->width, pvfb->height, - dpix, dpiy, pvfb->paddedWidth,pvfb->bitsPerPixel); -#ifdef RENDER - if (ret && Render) - fbPictureInit (pScreen, 0, 0); -#endif + miSetVisualTypesAndMasks (16, + ((1 << TrueColor) | + (1 << DirectColor)), + 8, TrueColor, 0xf800, 0x07e0, 0x001f); + break; + case 24: + miSetVisualTypesAndMasks (24, + ((1 << TrueColor) | + (1 << DirectColor)), + 8, TrueColor, 0xff0000, 0x00ff00, 0x0000ff); break; - default: - return FALSE; } + + ret = fbScreenInit(pScreen, pbits, pvfb->width, pvfb->height, + dpix, dpiy, pvfb->paddedWidth,pvfb->bitsPerPixel); +#ifdef RENDER + if (ret && Render) + fbPictureInit (pScreen, 0, 0); +#endif if (!ret) return FALSE; - miInitializeBackingStore(pScreen); + /* miInitializeBackingStore(pScreen); */ /* * Circumvent the backing store that was just initialised. This amounts * to a truely bizarre way of initialising SaveDoomedAreas and friends. */ - pScreen->CreateGC = vfbMultiDepthCreateGC; - pScreen->GetImage = vfbMultiDepthGetImage; - pScreen->GetSpans = vfbMultiDepthGetSpans; pScreen->InstallColormap = vfbInstallColormap; pScreen->UninstallColormap = vfbUninstallColormap; @@ -965,14 +931,7 @@ vfbScreenInit(int index, ScreenPtr pScreen, int argc, char **argv) pScreen->blackPixel = pvfb->blackPixel; pScreen->whitePixel = pvfb->whitePixel; - if (pvfb->bitsPerPixel == 1) - { - ret = mfbCreateDefColormap(pScreen); - } - else - { - ret = fbCreateDefColormap(pScreen); - } + ret = fbCreateDefColormap(pScreen); miSetZeroLineBias(pScreen, pvfb->lineBias); @@ -1003,7 +962,7 @@ InitOutput(ScreenInfo *screenInfo, int argc, char **argv) vfbPixmapDepths[1] = TRUE; vfbPixmapDepths[4] = TRUE; vfbPixmapDepths[8] = TRUE; - vfbPixmapDepths[15] = TRUE; +/* vfbPixmapDepths[15] = TRUE; */ vfbPixmapDepths[16] = TRUE; vfbPixmapDepths[24] = TRUE; vfbPixmapDepths[32] = TRUE; diff --git a/hw/vfb/Xvfb.man.pre b/hw/vfb/Xvfb.man.pre index dd03a3a4b..95efc4f61 100644 --- a/hw/vfb/Xvfb.man.pre +++ b/hw/vfb/Xvfb.man.pre @@ -1,4 +1,4 @@ -.\" $XdotOrg: xc/programs/Xserver/hw/vfb/Xvfb.man,v 1.1.4.2.4.1 2004/03/04 17:47:33 eich Exp $ +.\" $XdotOrg: xc/programs/Xserver/hw/vfb/Xvfb.man,v 1.2 2004/04/23 19:19:32 eich Exp $ .\" $Xorg: Xvfb.man,v 1.4 2001/02/09 02:04:45 xorgcvs Exp $ .\" Copyright 1993, 1998 The Open Group .\" diff --git a/hw/xfree86/common/compiler.h b/hw/xfree86/common/compiler.h index f888eb0f6..269b8bfb4 100644 --- a/hw/xfree86/common/compiler.h +++ b/hw/xfree86/common/compiler.h @@ -122,7 +122,8 @@ extern int ffs(unsigned long); # if defined(NO_INLINE) || defined(DO_PROTOTYPES) -# if !defined(__sparc__) && !defined(__arm32__) \ +# if !defined(__arm__) +# if !defined(__sparc__) && !defined(__arm32__) \ && !(defined(__alpha__) && defined(linux)) extern void outb(unsigned short, unsigned char); @@ -132,7 +133,7 @@ extern unsigned int inb(unsigned short); extern unsigned int inw(unsigned short); extern unsigned int inl(unsigned short); -# else /* __sparc__, __arm32__, __alpha__*/ +# else /* __sparc__, __arm32__, __alpha__*/ extern void outb(unsigned long, unsigned char); extern void outw(unsigned long, unsigned short); @@ -141,7 +142,8 @@ extern unsigned int inb(unsigned long); extern unsigned int inw(unsigned long); extern unsigned int inl(unsigned long); -# endif /* __sparc__, __arm32__, __alpha__ */ +# endif /* __sparc__, __arm32__, __alpha__ */ +# endif /* __arm__ */ extern unsigned long ldq_u(unsigned long *); extern unsigned long ldl_u(unsigned int *); @@ -897,12 +899,12 @@ static __inline__ void stw_u(unsigned long val, unsigned short *p) # define mem_barrier() /* XXX: nop for now */ # define write_mem_barrier() /* XXX: nop for now */ -# elif defined(__mips__) || defined(__arm32__) -#ifdef __arm32__ -#define PORT_SIZE long -#else -#define PORT_SIZE short -#endif +# elif defined(__mips__) || (defined(__arm32__) && !defined(__linux__)) +# ifdef __arm32__ +# define PORT_SIZE long +# else +# define PORT_SIZE short +# endif unsigned int IOPortBase; /* Memory mapped I/O port area */ @@ -1293,6 +1295,55 @@ inl(unsigned short port) # define mem_barrier() eieio() # define write_mem_barrier() eieio() +#elif defined(__arm__) && defined(__linux__) + +#define ldq_u(p) (*((unsigned long *)(p))) +#define ldl_u(p) (*((unsigned int *)(p))) +#define ldw_u(p) (*((unsigned short *)(p))) +#define stq_u(v,p) (*(unsigned long *)(p)) = (v) +#define stl_u(v,p) (*(unsigned int *)(p)) = (v) +#define stw_u(v,p) (*(unsigned short *)(p)) = (v) +#define mem_barrier() /* NOP */ +#define write_mem_barrier() /* NOP */ + +/* for Linux on ARM, we use the LIBC inx/outx routines */ +/* note that the appropriate setup via "ioperm" needs to be done */ +/* *before* any inx/outx is done. */ + +#include <sys/io.h> + +static __inline__ void +xf_outb(unsigned short port, unsigned char val) +{ + outb(val, port); +} + +static __inline__ void +xf_outw(unsigned short port, unsigned short val) +{ + outw(val, port); +} + +static __inline__ void +xf_outl(unsigned short port, unsigned int val) +{ + outl(val, port); +} + +#define outb xf_outb +#define outw xf_outw +#define outl xf_outl + +#define arm_flush_cache(addr) \ +do { \ + register unsigned long _beg __asm ("a1") = (unsigned long) (addr); \ + register unsigned long _end __asm ("a2") = (unsigned long) (addr) + 4;\ + register unsigned long _flg __asm ("a3") = 0; \ + __asm __volatile ("swi 0x9f0002 @ sys_cacheflush" \ + : "=r" (_beg) \ + : "0" (_beg), "r" (_end), "r" (_flg)); \ +} while (0) + # else /* ix86 */ # define ldq_u(p) (*((unsigned long *)(p))) @@ -1732,7 +1783,7 @@ static __inline__ void ppc_flush_icache(char *addr) : : "r"(addr) : "memory"); } -# elif defined(__sparc__) +# elif defined(__sparc__) || defined(sparc) /* * Like powerpc, we provide byteswapping and no byteswapping functions * here with byteswapping as default, drivers that don't need byteswapping diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c index 5e002c8db..255e65674 100644 --- a/hw/xfree86/common/xf86Bus.c +++ b/hw/xfree86/common/xf86Bus.c @@ -2988,7 +2988,7 @@ static void CheckGenericGA() { /* This needs to be changed for multiple domains */ -#if !defined(__sparc__) && !defined(__powerpc__) && !defined(__mips__) +#if !defined(__sparc__) && !defined(__powerpc__) && !defined(__mips__) && !defined(__ia64__) IOADDRESS GenericIOBase = VGAHW_GET_IOBASE(); CARD8 CurrentValue, TestValue; diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c index 66a6268ab..54c92ff8f 100644 --- a/hw/xfree86/common/xf86Config.c +++ b/hw/xfree86/common/xf86Config.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86Config.c,v 1.1.4.4.2.3 2004/03/04 20:16:17 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86Config.c,v 1.5 2004/08/16 20:17:51 kem Exp $ */ /* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Config.c,v 3.276 2003/10/08 14:58:26 dawes Exp $ */ @@ -128,6 +128,7 @@ static Bool addDefaultModes(MonPtr monitorp); #ifdef XF86DRI static Bool configDRI(XF86ConfDRIPtr drip); #endif +static Bool configExtensions(XF86ConfExtensionsPtr conf_ext); /* * xf86GetPathElem -- @@ -373,13 +374,14 @@ xf86DriverlistFromConfig() Bool xf86BuiltinInputDriver(const char *name) { +#ifdef USE_DEPRECATED_KEYBOARD_DRIVER if (xf86NameCmp(name, "keyboard") == 0) return TRUE; else +#endif return FALSE; } - char ** xf86InputDriverlistFromConfig() { @@ -2396,6 +2398,62 @@ configDRI(XF86ConfDRIPtr drip) #endif static Bool +configExtensions(XF86ConfExtensionsPtr conf_ext) +{ + XF86OptionPtr o; + + /* Extension enable/disable in miinitext.c */ + extern Bool EnableDisableExtension(char *name, Bool enable); + + if (conf_ext && conf_ext->ext_option_lst) { + for (o = conf_ext->ext_option_lst; o; o = xf86NextOption(o)) { + char *name = xf86OptionName(o); + char *val = xf86OptionValue(o); + char *n; + Bool enable = TRUE; + + /* Handle "No<ExtensionName>" */ + n = xf86NormalizeName(name); + if (strncmp(n, "no", 2) == 0) { + name += 2; + enable = FALSE; + } + + if (!val || + xf86NameCmp(val, "enable") == 0 || + xf86NameCmp(val, "on") == 0 || + xf86NameCmp(val, "1") == 0 || + xf86NameCmp(val, "yes") == 0 || + xf86NameCmp(val, "true") == 0) { + /* NOTHING NEEDED -- enabling is handled below */ + } else if (xf86NameCmp(val, "disable") == 0 || + xf86NameCmp(val, "off") == 0 || + xf86NameCmp(val, "0") == 0 || + xf86NameCmp(val, "no") == 0 || + xf86NameCmp(val, "false") == 0) { + enable = !enable; + } else { + xf86Msg(X_ERROR, + "%s is not a valid value for the Extension option\n", + val); + return FALSE; + } + + if (EnableDisableExtension(name, enable)) { + xf86Msg(X_CONFIG, "Extension \"%s\" is %s\n", + name, enable ? "enabled" : "disabled"); + } else { + xf86Msg(X_ERROR, + "Extension \"%s\" is unrecognized\n", name); + return FALSE; + } + } + } + + return TRUE; +} + +static Bool configInput(IDevPtr inputp, XF86ConfInputPtr conf_input, MessageType from) { xf86Msg(from, "|-->Input Device \"%s\"\n", conf_input->inp_identifier); @@ -2551,7 +2609,8 @@ xf86HandleConfigFile(Bool autoconfig) if (!configFiles(xf86configptr->conf_files) || !configServerFlags(xf86configptr->conf_flags, - xf86ConfigLayout.options) + xf86ConfigLayout.options) || + !configExtensions(xf86configptr->conf_extensions) #ifdef XF86DRI || !configDRI(xf86configptr->conf_dri) #endif diff --git a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c index 4e1473ef7..be37f53be 100644 --- a/hw/xfree86/common/xf86Configure.c +++ b/hw/xfree86/common/xf86Configure.c @@ -1,5 +1,4 @@ /* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Configure.c,v 3.80 2003/10/08 14:58:27 dawes Exp $ */ -/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86Configure.c,v 1.1.4.1.2.1 2004/03/17 20:30:26 ago Exp $ */ /* * Copyright 2000-2002 by Alan Hourihane, Flint Mountain, North Wales. * @@ -258,7 +257,11 @@ configureInputSection (void) parsePrologue (XF86ConfInputPtr, XF86ConfInputRec) ptr->inp_identifier = "Keyboard0"; +#ifdef USE_DEPRECATED_KEYBOARD_DRIVER ptr->inp_driver = "keyboard"; +#else + ptr->inp_driver = "kbd"; +#endif ptr->list.next = NULL; /* Crude mechanism to auto-detect mouse (os dependent) */ @@ -750,8 +753,8 @@ configureDDCMonitorSection (int screennum) ptr->mon_vrefresh[ptr->mon_n_hsync].lo = ConfiguredMonitor->det_mon[i].section.ranges.min_v; ptr->mon_vrefresh[ptr->mon_n_hsync].hi = + ConfiguredMonitor->det_mon[i].section.ranges.max_v; ptr->mon_n_hsync++; - ConfiguredMonitor->det_mon[i].section.ranges.max_v; default: break; } @@ -1004,7 +1007,7 @@ DoConfigure() } ErrorF("\nYour %s file is %s\n\n", XF86CONFIGFILE ,filename); - ErrorF("To test the server, run 'X -xf86config %s'\n\n", filename); + ErrorF("To test the server, run 'X -config %s'\n\n", filename); bail: OsCleanup(TRUE); diff --git a/hw/xfree86/common/xf86Cursor.c b/hw/xfree86/common/xf86Cursor.c index 22b7b00e6..51015e1f4 100644 --- a/hw/xfree86/common/xf86Cursor.c +++ b/hw/xfree86/common/xf86Cursor.c @@ -222,7 +222,7 @@ xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode) if (mode == pScr->currentMode) return TRUE; - if (mode->HDisplay > pScreen->width || mode->VDisplay > pScreen->height) + if (mode->HDisplay > pScr->virtualX || mode->VDisplay > pScr->virtualY) return FALSE; pCursorScreen = miPointerCurrentScreen(); diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c index ac57935e0..d57eab6e5 100644 --- a/hw/xfree86/common/xf86DGA.c +++ b/hw/xfree86/common/xf86DGA.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86DGA.c,v 1.1.4.3.2.3 2004/03/04 20:16:18 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86DGA.c,v 1.2 2004/04/23 19:20:32 eich Exp $ */ /* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86DGA.c,v 1.46 2002/12/03 18:17:40 tsi Exp $ */ /* * Copyright (c) 1998-2002 by The XFree86 Project, Inc. diff --git a/hw/xfree86/common/xf86DPMS.c b/hw/xfree86/common/xf86DPMS.c index df968797c..82004b953 100644 --- a/hw/xfree86/common/xf86DPMS.c +++ b/hw/xfree86/common/xf86DPMS.c @@ -118,6 +118,16 @@ DPMSClose(int i, ScreenPtr pScreen) pScreen->CloseScreen = pDPMS->CloseScreen; + /* + * Turn on DPMS when shutting down. If this function can be used + * depends on the order the driver wraps things. If this is called + * after the driver has shut down everything the driver will have + * to deal with this internally. + */ + if (xf86Screens[i]->vtSema && xf86Screens[i]->DPMSSet) { + xf86Screens[i]->DPMSSet(xf86Screens[i],DPMSModeOn,0); + } + xfree((pointer)pDPMS); pScreen->devPrivates[DPMSIndex].ptr = NULL; if (--DPMSCount == 0) diff --git a/hw/xfree86/common/xf86Date.h b/hw/xfree86/common/xf86Date.h index 7d37ac7ef..15aafb817 100644 --- a/hw/xfree86/common/xf86Date.h +++ b/hw/xfree86/common/xf86Date.h @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/hw/xfree86/xf86Date.h,v 1.1.4.3 2003/12/20 00:28:26 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/xf86Date.h,v 1.4 2004/08/16 22:48:50 kem Exp $ */ /* $XFree86: xc/programs/Xserver/hw/xfree86/xf86Date.h,v 1.54 2003/12/19 04:52:10 dawes Exp $ */ /* * Copyright (c) 2003 by The XFree86 Project, Inc. diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c index 791fd2673..d61d4d67a 100644 --- a/hw/xfree86/common/xf86Events.c +++ b/hw/xfree86/common/xf86Events.c @@ -49,7 +49,7 @@ */ /* $XConsortium: xf86Events.c /main/46 1996/10/25 11:36:30 kaleb $ */ -/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86Events.c,v 1.1.4.3 2003/12/06 13:24:24 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86Events.c,v 1.3 2004/07/30 20:56:53 eich Exp $ */ /* [JCH-96/01/21] Extended std reverse map to four buttons. */ @@ -95,6 +95,12 @@ extern Bool noXkbExtension; #endif +#ifdef DPMSExtension +#define DPMS_SERVER +#include "extensions/dpms.h" +#include "dpmsproc.h" +#endif + #define XE_POINTER 1 #define XE_KEYBOARD 2 @@ -403,7 +409,7 @@ xf86ProcessActionEvent(ActionEvent action, void *arg) /* */ /* otherwise fallback to sending a key event message to */ /* the current screen's driver: */ - if (*pScr->HandleMessage) { + if (*pScr->HandleMessage != NULL) { (void) (*pScr->HandleMessage)(pScr->scrnIndex, "KeyEventMessage", message, &retstr); } @@ -1348,7 +1354,11 @@ xf86VTSwitch() #endif /* !__UNIXOS2__ */ xf86EnterServerState(SETUP); for (i = 0; i < xf86NumScreens; i++) { - xf86Screens[i]->LeaveVT(i, 0); +#ifdef DPMSExtension + if (xf86Screens[i]->DPMSSet) + xf86Screens[i]->DPMSSet(xf86Screens[i],DPMSModeOn,0); +#endif + xf86Screens[i]->LeaveVT(i, 0); } for (ih = InputHandlers; ih; ih = ih->next) xf86DisableInputHandler(ih); diff --git a/hw/xfree86/common/xf86Globals.c b/hw/xfree86/common/xf86Globals.c index a2bb3f504..6f2e9135a 100644 --- a/hw/xfree86/common/xf86Globals.c +++ b/hw/xfree86/common/xf86Globals.c @@ -157,7 +157,7 @@ xf86InfoRec xf86Info = { FALSE, /* vidModeAllowNonLocal */ TRUE, /* miscModInDevEnabled */ FALSE, /* miscModInDevAllowNonLocal */ - PCIProbe1, /* pciFlags */ + PCIOsConfig, /* pciFlags */ Pix24DontCare, /* pixmap24 */ X_DEFAULT, /* pix24From */ #if defined(i386) || defined(__i386__) diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c index 076a97f16..822cdfd8b 100644 --- a/hw/xfree86/common/xf86Helper.c +++ b/hw/xfree86/common/xf86Helper.c @@ -873,7 +873,6 @@ Bool xf86SetDefaultVisual(ScrnInfoPtr scrp, int visual) { MessageType visualFrom = X_DEFAULT; - Bool bad = FALSE; if (defaultColorVisualClass >= 0) { scrp->defaultVisual = defaultColorVisualClass; @@ -902,25 +901,6 @@ xf86SetDefaultVisual(ScrnInfoPtr scrp, int visual) case DirectColor: xf86DrvMsg(scrp->scrnIndex, visualFrom, "Default visual is %s\n", xf86VisualNames[scrp->defaultVisual]); - /* Check if the visual is valid for the depth */ - if (scrp->depth == 1 && scrp->defaultVisual != StaticGray) - bad = TRUE; -#if 0 - else if (scrp->depth == 4 && - (scrp->defaultVisual == TrueColor || - scrp->defaultVisual == DirectColor)) - bad = TRUE; -#endif - else if (scrp->depth > MAX_PSEUDO_DEPTH && - scrp->defaultVisual != TrueColor && - scrp->defaultVisual != DirectColor) - bad = TRUE; - if (bad) { - xf86DrvMsg(scrp->scrnIndex, X_ERROR, "Selected default " - "visual (%s) is not valid for depth %d\n", - xf86VisualNames[scrp->defaultVisual], scrp->depth); - return FALSE; - } else return TRUE; default: diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c index c1918c6ef..f507753fe 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c @@ -93,6 +93,11 @@ extern int xtest_command_key; #endif /* XTESTEXT1 */ +#ifdef DPMSExtension +#define DPMS_SERVER +#include "extensions/dpms.h" +#endif + /* forward declarations */ @@ -139,7 +144,7 @@ static int numFormats = 6; #endif static Bool formatsDone = FALSE; -InputDriverRec xf86KEYBOARD = { +InputDriverRec XF86KEYBOARD = { 1, "keyboard", NULL, @@ -418,8 +423,10 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv) xfree(modulelist); } +#ifdef USE_DEPRECATED_KEYBOARD_DRIVER /* Setup the builtin input drivers */ - xf86AddInputDriver(&xf86KEYBOARD, NULL, 0); + xf86AddInputDriver(&XF86KEYBOARD, NULL, 0); +#endif /* Load all input driver modules specified in the config file. */ if ((modulelist = xf86InputDriverlistFromConfig())) { xf86LoadModules(modulelist, NULL); @@ -897,6 +904,8 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv) xf86Screens[i]->DPMSSet = NULL; xf86Screens[i]->LoadPalette = NULL; xf86Screens[i]->SetOverscan = NULL; + xf86Screens[i]->RRFunc = NULL; + xf86Screens[i]->pScreen = NULL; scr_index = AddScreen(xf86Screens[i]->ScreenInit, argc, argv); if (scr_index == i) { /* @@ -1008,12 +1017,18 @@ InitInput(argc, argv) if (serverGeneration == 1) { /* Call the PreInit function for each input device instance. */ for (pDev = xf86ConfigLayout.inputs; pDev && pDev->identifier; pDev++) { +#ifdef USE_DEPRECATED_KEYBOARD_DRIVER /* XXX The keyboard driver is a special case for now. */ if (!xf86NameCmp(pDev->driver, "keyboard")) { - xf86Msg(X_INFO, "Keyboard \"%s\" handled by legacy driver\n", + xf86MsgVerb(X_WARNING, 0, "*** WARNING the legacy keyboard driver \"keyboard\" is deprecated\n"); + xf86MsgVerb(X_WARNING, 0, "*** and will be removed in the next release of the Xorg server.\n"); + xf86MsgVerb(X_WARNING, 0, "*** Please consider using the the new \"kbd\" driver for \"%s\".\n", pDev->identifier); + continue; } +#endif + if ((pDrv = MatchInput(pDev)) == NULL) { xf86Msg(X_ERROR, "No Input driver matching `%s'\n", pDev->driver); /* XXX For now, just continue. */ @@ -1093,11 +1108,15 @@ InitInput(argc, argv) xf86Info.kbdEvents = NULL; /* to prevent the internal keybord driver usage*/ } else { +#ifdef USE_DEPRECATED_KEYBOARD_DRIVER + /* Only set this if we're allowing the old driver. */ xf86Info.pKeyboard = AddInputDevice(xf86Info.kbdProc, TRUE); +#endif } if (corePointer) xf86Info.pMouse = corePointer->dev; - RegisterKeyboardDevice(xf86Info.pKeyboard); + if (xf86Info.pKeyboard) + RegisterKeyboardDevice(xf86Info.pKeyboard); miRegisterPointerDevice(screenInfo.screens[0], xf86Info.pMouse); #ifdef XINPUT @@ -1246,6 +1265,10 @@ AbortDDX() * screen explicitely. */ xf86EnableAccess(xf86Screens[i]); +#ifdef DPMSExtension + if (xf86Screens[i]->DPMSSet) + xf86Screens[i]->DPMSSet(xf86Screens[i],DPMSModeOn,0); +#endif (xf86Screens[i]->LeaveVT)(i, 0); } } @@ -1344,15 +1367,15 @@ ddxProcessArgument(int argc, char **argv, int i) return 2; } } - if (!strcmp(argv[i], "-xf86config")) + if (!strcmp(argv[i], "-config") || !strcmp(argv[i], "-xf86config")) { if (!argv[i + 1]) return 0; if (getuid() != 0 && !xf86PathIsSafe(argv[i + 1])) { - FatalError("\nInvalid argument for -xf86config\n" - "\tFor non-root users, the file specified with -xf86config must be\n" + FatalError("\nInvalid argument for -config\n" + "\tFor non-root users, the file specified with -config must be\n" "\ta relative path and must not contain any \"..\" elements.\n" - "\tUsing default XF86Config search path.\n\n"); + "\tUsing default "__XCONFIGFILE__" search path.\n\n"); } xf86ConfigFile = argv[i + 1]; return 2; @@ -1641,6 +1664,11 @@ ddxProcessArgument(int argc, char **argv, int i) return xf86ProcessArgument(argc, argv, i); } +/* ddxInitGlobals - called by |InitGlobals| from os/util.c */ +void ddxInitGlobals(void) +{ +} + /* * ddxUseMsg -- * Print out correct use of device dependent commandline options. @@ -1655,15 +1683,14 @@ ddxUseMsg() ErrorF("Device Dependent Usage\n"); if (getuid() == 0) { - ErrorF("-xf86config file specify a configuration file\n"); ErrorF("-modulepath paths specify the module search path\n"); ErrorF("-logfile file specify a log file name\n"); - ErrorF("-configure probe for devices and write an XF86Config\n"); + ErrorF("-configure probe for devices and write an "__XCONFIGFILE__"\n"); } else { - ErrorF("-xf86config file specify a configuration file, relative to the\n"); - ErrorF(" XF86Config search path, only root can use absolute\n"); + ErrorF("-config file specify a configuration file, relative to the\n"); + ErrorF(" "__XCONFIGFILE__" search path, only root can use absolute\n"); } ErrorF("-probeonly probe for devices, then exit\n"); ErrorF("-scanpci execute the scanpci module and exit\n"); @@ -1720,16 +1747,19 @@ xf86PrintBanner() #if PRE_RELEASE ErrorF("\n" "This is a pre-release version of the " XVENDORNAME " X11.\n" - "Portions of this release are based on XFree86 4.4RC2 and selected\n" - "files from XFree86 4.4RC3. It is not supported in any way.\n" + "It is not supported in any way.\n" "Bugs may be filed in the bugzilla at http://bugs.freedesktop.org/.\n" "Select the \"xorg\" product for bugs you find in this release.\n" "Before reporting bugs in pre-release versions please check the\n" "latest version in the " XVENDORNAME " \"monolithic tree\" CVS\n" "repository hosted at http://www.freedesktop.org/Software/xorg/"); #endif + ErrorF("\nX Window System Version %d.%d.%d", + XORG_VERSION_MAJOR, + XORG_VERSION_MINOR, + XORG_VERSION_PATCH); #if XORG_VERSION_SNAP > 0 - ErrorF(".%d", XF86_VERSION_SNAP); + ErrorF(".%d", XORG_VERSION_SNAP); #endif #if XORG_VERSION_SNAP >= 900 @@ -1738,9 +1768,12 @@ xf86PrintBanner() #endif #ifdef XORG_CUSTOM_VERSION - ErrorF(" (%s)", XF86_CUSTOM_VERSION); + ErrorF(" (%s)", XORG_CUSTOM_VERSION); +#endif +#ifndef XORG_DATE +#define XORG_DATE XF86_DATE #endif - ErrorF("\nRelease Date: %s\n", XF86_DATE); + ErrorF("\nRelease Date: %s\n", XORG_DATE); ErrorF("X Protocol Version %d, Revision %d, %s\n", X_PROTOCOL, X_PROTOCOL_REVISION, XORG_RELEASE ); ErrorF("Build Operating System:%s%s\n", OSNAME, OSVENDOR); diff --git a/hw/xfree86/common/xf86Io.c b/hw/xfree86/common/xf86Io.c index bd44bdeb5..7f9ba6f0e 100644 --- a/hw/xfree86/common/xf86Io.c +++ b/hw/xfree86/common/xf86Io.c @@ -49,6 +49,7 @@ */ /* $XConsortium: xf86Io.c /main/27 1996/10/19 17:58:55 kaleb $ */ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86Io.c,v 1.2 2004/07/28 03:57:19 alanc Exp $ */ #define NEED_EVENTS #include "X.h" @@ -148,6 +149,10 @@ xf86KbdLeds () if (leds & XLED4) real_leds |= LED_SCR; #endif #endif +#ifdef sun + /* Pass through any additional LEDs, such as Kana LED on Sun Japanese kbd */ + real_leds |= (leds & 0xFFFFFFF0); +#endif xf86SetKbdLeds(real_leds); (void)leds; } diff --git a/hw/xfree86/common/xf86Mode.c b/hw/xfree86/common/xf86Mode.c index ec83f514b..4462322d9 100644 --- a/hw/xfree86/common/xf86Mode.c +++ b/hw/xfree86/common/xf86Mode.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86Mode.c,v 1.1.4.3.2.1 2004/02/27 21:30:59 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86Mode.c,v 1.2 2004/04/23 19:20:32 eich Exp $ */ /* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Mode.c,v 1.69 2003/10/08 14:58:28 dawes Exp $ */ /* * Copyright (c) 1997-2003 by The XFree86 Project, Inc. diff --git a/hw/xfree86/common/xf86PciInfo.h b/hw/xfree86/common/xf86PciInfo.h index 19cc009dd..a14ad1897 100644 --- a/hw/xfree86/common/xf86PciInfo.h +++ b/hw/xfree86/common/xf86PciInfo.h @@ -113,6 +113,18 @@ #define PCI_CHIP_QV1280 0x3033 /* ATI */ +#define PCI_CHIP_RV380_3150 0x3150 +#define PCI_CHIP_RV380_3151 0x3151 +#define PCI_CHIP_RV380_3152 0x3152 +#define PCI_CHIP_RV380_3153 0x3153 +#define PCI_CHIP_RV380_3154 0x3154 +#define PCI_CHIP_RV380_3156 0x3156 +#define PCI_CHIP_RV380_3E50 0x3E50 +#define PCI_CHIP_RV380_3E51 0x3E51 +#define PCI_CHIP_RV380_3E52 0x3E52 +#define PCI_CHIP_RV380_3E53 0x3E53 +#define PCI_CHIP_RV380_3E54 0x3E54 +#define PCI_CHIP_RV380_3E56 0x3E56 #define PCI_CHIP_RS100_4136 0x4136 #define PCI_CHIP_RS200_4137 0x4137 #define PCI_CHIP_R300_AD 0x4144 @@ -161,6 +173,14 @@ #define PCI_CHIP_RV250_Ie 0x4965 #define PCI_CHIP_RV250_If 0x4966 #define PCI_CHIP_RV250_Ig 0x4967 +#define PCI_CHIP_R420_JH 0x4A48 +#define PCI_CHIP_R420_JI 0x4A49 +#define PCI_CHIP_R420_JJ 0x4A4A +#define PCI_CHIP_R420_JK 0x4A4B +#define PCI_CHIP_R420_JL 0x4A4C +#define PCI_CHIP_R420_JM 0x4A4D +#define PCI_CHIP_R420_JN 0x4A4E +#define PCI_CHIP_R420_JP 0x4A50 #define PCI_CHIP_MACH64LB 0x4C42 #define PCI_CHIP_MACH64LD 0x4C44 #define PCI_CHIP_RAGE128LE 0x4C45 @@ -257,6 +277,21 @@ #define PCI_CHIP_RAGE128TS 0x5453 #define PCI_CHIP_RAGE128TT 0x5454 #define PCI_CHIP_RAGE128TU 0x5455 +#define PCI_CHIP_RV370_5460 0x5460 +#define PCI_CHIP_RV370_5461 0x5461 +#define PCI_CHIP_RV370_5462 0x5462 +#define PCI_CHIP_RV370_5463 0x5463 +#define PCI_CHIP_RV370_5464 0x5464 +#define PCI_CHIP_RV370_5465 0x5465 +#define PCI_CHIP_RV370_5466 0x5466 +#define PCI_CHIP_RV370_5467 0x5467 +#define PCI_CHIP_R423_UH 0x5548 +#define PCI_CHIP_R423_UI 0x5549 +#define PCI_CHIP_R423_UJ 0x554A +#define PCI_CHIP_R423_UK 0x554B +#define PCI_CHIP_R423_UQ 0x5551 +#define PCI_CHIP_R423_UR 0x5552 +#define PCI_CHIP_R423_UT 0x5554 #define PCI_CHIP_MACH64VT 0x5654 #define PCI_CHIP_MACH64VU 0x5655 #define PCI_CHIP_MACH64VV 0x5656 @@ -264,12 +299,23 @@ #define PCI_CHIP_RS300_5835 0x5835 #define PCI_CHIP_RS300_5836 0x5836 #define PCI_CHIP_RS300_5837 0x5837 +#define PCI_CHIP_RV370_5B60 0x5B60 +#define PCI_CHIP_RV370_5B61 0x5B61 +#define PCI_CHIP_RV370_5B62 0x5B62 +#define PCI_CHIP_RV370_5B63 0x5B63 +#define PCI_CHIP_RV370_5B64 0x5B64 +#define PCI_CHIP_RV370_5B65 0x5B65 +#define PCI_CHIP_RV370_5B66 0x5B66 +#define PCI_CHIP_RV370_5B67 0x5B67 #define PCI_CHIP_RV280_5960 0x5960 #define PCI_CHIP_RV280_5961 0x5961 #define PCI_CHIP_RV280_5962 0x5962 #define PCI_CHIP_RV280_5964 0x5964 #define PCI_CHIP_RV280_5C61 0x5C61 #define PCI_CHIP_RV280_5C63 0x5C63 +#define PCI_CHIP_R423_5D57 0x5D57 +#define PCI_CHIP_RS350_7834 0x7834 +#define PCI_CHIP_RS350_7835 0x7835 /* Avance Logic */ #define PCI_CHIP_ALG2064 0x2064 diff --git a/hw/xfree86/common/xf86RandR.c b/hw/xfree86/common/xf86RandR.c index 6f7fac3d3..457793efc 100644 --- a/hw/xfree86/common/xf86RandR.c +++ b/hw/xfree86/common/xf86RandR.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86RandR.c,v 1.1.4.3.2.2 2004/03/04 17:47:34 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86RandR.c,v 1.5 2004/08/13 18:24:07 sandmann Exp $ */ /* * $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86RandR.c,v 1.7tsi Exp $ * @@ -38,6 +38,9 @@ typedef struct _xf86RandRInfo { CloseScreenProcPtr CloseScreen; int virtualX; int virtualY; + int mmWidth; + int mmHeight; + Rotation rotation; } XF86RandRInfoRec, *XF86RandRInfoPtr; static int xf86RandRIndex; @@ -72,13 +75,13 @@ xf86RandRGetInfo (ScreenPtr pScreen, Rotation *rotations) refresh0 = refresh; pSize = RRRegisterSize (pScreen, mode->HDisplay, mode->VDisplay, - pScreen->mmWidth, pScreen->mmHeight); + randrp->mmWidth, randrp->mmHeight); if (!pSize) return FALSE; RRRegisterRate (pScreen, pSize, refresh); if (mode == scrp->currentMode && - mode->HDisplay == pScreen->width && mode->VDisplay == pScreen->height) - RRSetCurrentConfig (pScreen, RR_Rotate_0, refresh, pSize); + mode->HDisplay == scrp->virtualX && mode->VDisplay == scrp->virtualY) + RRSetCurrentConfig (pScreen, randrp->rotation, refresh, pSize); if (mode->next == scrp->modes) break; } @@ -88,33 +91,48 @@ xf86RandRGetInfo (ScreenPtr pScreen, Rotation *rotations) mode = scrp->modes; pSize = RRRegisterSize (pScreen, randrp->virtualX, randrp->virtualY, - pScreen->mmWidth * randrp->virtualX / scrp->currentMode->HDisplay, - pScreen->mmHeight * randrp->virtualY / scrp->currentMode->VDisplay); + randrp->mmWidth, + randrp->mmHeight); if (!pSize) return FALSE; RRRegisterRate (pScreen, pSize, refresh0); - if (pScreen->width == randrp->virtualX && - pScreen->height == randrp->virtualY) + if (scrp->virtualX == randrp->virtualX && + scrp->virtualY == randrp->virtualY) { - RRSetCurrentConfig (pScreen, RR_Rotate_0, refresh0, pSize); + RRSetCurrentConfig (pScreen, randrp->rotation, refresh0, pSize); } } + + /* If there is driver support for randr, let it set our supported rotations */ + if(scrp->RRFunc) { + xorgRRRotation RRRotation; + + RRRotation.RRRotations = *rotations; + if (!(*scrp->RRFunc)(scrp, RR_GET_INFO, &RRRotation)) + return FALSE; + *rotations = RRRotation.RRRotations; + } + return TRUE; } static Bool xf86RandRSetMode (ScreenPtr pScreen, DisplayModePtr mode, - Bool useVirtual) + Bool useVirtual, + int mmWidth, + int mmHeight) { ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); int oldWidth = pScreen->width; int oldHeight = pScreen->height; + int oldmmWidth = pScreen->mmWidth; + int oldmmHeight = pScreen->mmHeight; WindowPtr pRoot = WindowTable[pScreen->myNum]; if (pRoot) - xf86EnableDisableFBAccess (pScreen->myNum, FALSE); + (*scrp->EnableDisableFBAccess) (pScreen->myNum, FALSE); if (useVirtual) { scrp->virtualX = randrp->virtualX; @@ -125,12 +143,27 @@ xf86RandRSetMode (ScreenPtr pScreen, scrp->virtualX = mode->HDisplay; scrp->virtualY = mode->VDisplay; } - pScreen->width = scrp->virtualX; - pScreen->height = scrp->virtualY; + if(randrp->rotation & (RR_Rotate_90 | RR_Rotate_270)) + { + /* If the screen is rotated 90 or 270 degrees, swap the sizes. */ + pScreen->width = scrp->virtualY; + pScreen->height = scrp->virtualX; + pScreen->mmWidth = mmHeight; + pScreen->mmHeight = mmWidth; + } + else + { + pScreen->width = scrp->virtualX; + pScreen->height = scrp->virtualY; + pScreen->mmWidth = mmWidth; + pScreen->mmHeight = mmHeight; + } if (!xf86SwitchMode (pScreen, mode)) { scrp->virtualX = pScreen->width = oldWidth; scrp->virtualY = pScreen->height = oldHeight; + pScreen->mmWidth = oldmmWidth; + pScreen->mmHeight = oldmmHeight; return FALSE; } /* @@ -144,7 +177,7 @@ xf86RandRSetMode (ScreenPtr pScreen, xf86SetViewport (pScreen, pScreen->width, pScreen->height); xf86SetViewport (pScreen, 0, 0); if (pRoot) - xf86EnableDisableFBAccess (pScreen->myNum, TRUE); + (*scrp->EnableDisableFBAccess) (pScreen->myNum, TRUE); return TRUE; } @@ -160,6 +193,8 @@ xf86RandRSetConfig (ScreenPtr pScreen, int px, py; Bool useVirtual = FALSE; + randrp->rotation = rotation; + miPointerPosition (&px, &py); for (mode = scrp->modes; ; mode = mode->next) { @@ -179,7 +214,20 @@ xf86RandRSetConfig (ScreenPtr pScreen, return FALSE; } } - if (!xf86RandRSetMode (pScreen, mode, useVirtual)) + + /* Have the driver do its thing. */ + if (scrp->RRFunc) { + xorgRRRotation RRRotation; + RRRotation.RRConfig.rotation = rotation; + RRRotation.RRConfig.rate = rate; + RRRotation.RRConfig.width = pSize->width; + RRRotation.RRConfig.height = pSize->height; + + if (!(*scrp->RRFunc)(scrp, RR_SET_CONFIG, &RRRotation)) + return FALSE; + } + + if (!xf86RandRSetMode (pScreen, mode, useVirtual, pSize->mmWidth, pSize->mmHeight)) return FALSE; /* * Move the cursor back where it belongs; SwitchMode repositions it @@ -189,6 +237,7 @@ xf86RandRSetConfig (ScreenPtr pScreen, if (px < pSize->width && py < pSize->height) (*pScreen->SetCursorPosition) (pScreen, px, py, FALSE); } + return TRUE; } @@ -270,6 +319,8 @@ xf86RandRInit (ScreenPtr pScreen) randrp->virtualX = scrp->virtualX; randrp->virtualY = scrp->virtualY; + randrp->mmWidth = pScreen->mmWidth; + randrp->mmHeight = pScreen->mmHeight; randrp->CreateScreenResources = pScreen->CreateScreenResources; pScreen->CreateScreenResources = xf86RandRCreateScreenResources; @@ -277,6 +328,8 @@ xf86RandRInit (ScreenPtr pScreen) randrp->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = xf86RandRCloseScreen; + randrp->rotation = RR_Rotate_0; + pScreen->devPrivates[xf86RandRIndex].ptr = randrp; return TRUE; } diff --git a/hw/xfree86/common/xf86Version.h b/hw/xfree86/common/xf86Version.h index a044230ed..45746bc90 100644 --- a/hw/xfree86/common/xf86Version.h +++ b/hw/xfree86/common/xf86Version.h @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/hw/xfree86/xf86Version.h,v 1.1.4.4 2003/12/20 00:28:26 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/xf86Version.h,v 1.2 2004/04/23 19:20:02 eich Exp $ */ /* $XFree86: xc/programs/Xserver/hw/xfree86/xf86Version.h,v 3.566 2003/12/19 04:52:11 dawes Exp $ */ /* @@ -59,4 +59,4 @@ #endif /* $XConsortium: xf86Version.h /main/78 1996/10/28 05:42:10 kaleb $ */ -/* $XdotOrg: xc/programs/Xserver/hw/xfree86/xf86Version.h,v 1.1.4.4 2003/12/20 00:28:26 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/xf86Version.h,v 1.2 2004/04/23 19:20:02 eich Exp $ */ diff --git a/hw/xfree86/common/xf86cmap.c b/hw/xfree86/common/xf86cmap.c index c3b09e361..77d2ed174 100644 --- a/hw/xfree86/common/xf86cmap.c +++ b/hw/xfree86/common/xf86cmap.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86cmap.c,v 1.1.4.2 2004/02/16 20:19:59 alanc Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86cmap.c,v 1.3 2004/07/30 21:10:46 eich Exp $ */ /* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86cmap.c,v 1.25 2003/10/17 20:02:12 alanh Exp $ */ /* * Copyright (c) 1998-2001 by The XFree86 Project, Inc. @@ -117,7 +117,7 @@ static int CMapChangeGamma(int, Gamma); static void ComputeGamma(CMapScreenPtr); static Bool CMapAllocateColormapPrivate(ColormapPtr); -static Bool CMapInitDefMap(ColormapPtr); +static Bool CMapInitDefMap(ColormapPtr,int); static void CMapRefreshColors(ColormapPtr, int, int*); static void CMapSetOverscan(ColormapPtr, int, int *); static void CMapReinstallMap(ColormapPtr); @@ -211,7 +211,7 @@ Bool xf86HandleColormaps( /* get the default map */ pDefMap = (ColormapPtr) LookupIDByType(pScreen->defColormap, RT_COLORMAP); - + if(!CMapAllocateColormapPrivate(pDefMap)) { CMapUnwrapScreen(pScreen); return FALSE; @@ -224,7 +224,7 @@ Bool xf86HandleColormaps( } static Bool -CMapInitDefMap(ColormapPtr cmap) +CMapInitDefMap(ColormapPtr cmap, int index) { return TRUE; } @@ -433,7 +433,8 @@ CMapInstallColormap(ColormapPtr pmap) /* Important. We let the lower layers, namely DGA, overwrite the choice of Colormap to install */ - pmap = miInstalledMaps[index]; + if (miInstalledMaps[index]) + pmap = miInstalledMaps[index]; if(!(pScreenPriv->flags & CMAP_PALETTED_TRUECOLOR) && (pmap->pVisual->class == TrueColor) && diff --git a/hw/xfree86/common/xf86fbman.c b/hw/xfree86/common/xf86fbman.c index b7c4afa1c..ee286d172 100644 --- a/hw/xfree86/common/xf86fbman.c +++ b/hw/xfree86/common/xf86fbman.c @@ -1095,12 +1095,10 @@ localQueryLargestOffscreenLinear( *size = 0; - if (!offman->LinearAreas) return FALSE; - pLink = offman->LinearAreas; - pLinkRet = pLink; - if (!pLink->area) { + if (pLink && !pLink->area) { + pLinkRet = pLink; while (pLink) { if (pLink->free) { if (pLink->linear.size > pLinkRet->linear.size) diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c index 790bf7409..c5a022bf9 100644 --- a/hw/xfree86/common/xf86pciBus.c +++ b/hw/xfree86/common/xf86pciBus.c @@ -424,7 +424,7 @@ FindPCIVideoInfo(void) if ((pcrp->pci_command & PCI_CMD_MEM_ENABLE) && (num == 1 || ((info->class == PCI_CLASS_DISPLAY) && - (info->subclass == PCI_SUBCLASS_DISPLAY_MISC)))) { + (info->subclass == PCI_SUBCLASS_DISPLAY_VGA)))) { if (primaryBus.type == BUS_NONE) { primaryBus.type = BUS_PCI; primaryBus.id.pci.bus = pcrp->busnum; @@ -3230,10 +3230,14 @@ pciVideoPtr xf86GetPciInfoForEntity(int entityIndex) { pciVideoPtr *ppPci; - EntityPtr p = xf86Entities[entityIndex]; + EntityPtr p; - if (entityIndex >= xf86NumEntities - || p->busType != BUS_PCI) return NULL; + if (entityIndex >= xf86NumEntities) + return NULL; + + p = xf86Entities[entityIndex]; + if (p->busType != BUS_PCI) + return NULL; for (ppPci = xf86PciVideoInfo; *ppPci != NULL; ppPci++) { if (p->pciBusId.bus == (*ppPci)->bus && diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h index 367cb19a9..770233033 100644 --- a/hw/xfree86/common/xf86str.h +++ b/hw/xfree86/common/xf86str.h @@ -476,7 +476,7 @@ typedef struct _confdrirec { /* These values should be adjusted when new fields are added to ScrnInfoRec */ #define NUM_RESERVED_INTS 16 #define NUM_RESERVED_POINTERS 15 -#define NUM_RESERVED_FUNCS 12 +#define NUM_RESERVED_FUNCS 11 typedef pointer (*funcPointer)(void); @@ -737,6 +737,24 @@ typedef struct { PixmapPtr pPix; } DGADeviceRec, *DGADevicePtr; +typedef enum { + RR_GET_INFO, + RR_SET_CONFIG +} xorgRRFuncFlags; + +typedef struct { + int rotation; + int rate; + int width; + int height; +} xorgRRConfig; + +typedef union { + short RRRotations; + xorgRRConfig RRConfig; +} xorgRRRotation, *xorgRRRotationPtr; + + /* * Flags for driver Probe() functions. */ @@ -767,6 +785,9 @@ typedef int xf86HandleMessageProc (int, const char*, const char*, char**); typedef void xf86DPMSSetProc (ScrnInfoPtr, int, int); typedef void xf86LoadPaletteProc (ScrnInfoPtr, int, int *, LOCO *, VisualPtr); typedef void xf86SetOverscanProc (ScrnInfoPtr, int); +typedef Bool xorgRRFuncProc (ScrnInfoPtr, xorgRRFuncFlags, + xorgRRRotationPtr); + /* * ScrnInfoRec @@ -921,6 +942,7 @@ typedef struct _ScrnInfoRec { xf86DPMSSetProc *DPMSSet; xf86LoadPaletteProc *LoadPalette; xf86SetOverscanProc *SetOverscan; + xorgRRFuncProc *RRFunc; /* * This can be used when the minor ABI version is incremented. diff --git a/hw/xfree86/common/xorgHelper.c b/hw/xfree86/common/xorgHelper.c index c6364f19e..4b904dc06 100644 --- a/hw/xfree86/common/xorgHelper.c +++ b/hw/xfree86/common/xorgHelper.c @@ -1,4 +1,4 @@ -/* $XdotOrg$ */ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xorgHelper.c,v 1.2 2004/04/23 19:20:32 eich Exp $ */ #include "X.h" #include "os.h" diff --git a/hw/xfree86/common/xorgVersion.h b/hw/xfree86/common/xorgVersion.h index bfc66a59c..47005320a 100644 --- a/hw/xfree86/common/xorgVersion.h +++ b/hw/xfree86/common/xorgVersion.h @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/hw/xfree86/xf86Version.h,v 1.1.4.3 2003/12/06 13:24:23 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/xorgVersion.h,v 1.3 2004/08/16 02:07:53 kem Exp $ */ /* * Copyright (c) 2004, X.Org Foundation @@ -45,7 +45,7 @@ # define XORG_VERSION_MAJOR XORG_GET_MAJOR_VERSION(XORG_VERSION_CURRENT) # define XORG_VERSION_MINOR XORG_GET_MINOR_VERSION(XORG_VERSION_CURRENT) # define XORG_VERSION_PATCH XORG_GET_PATCH_VERSION(XORG_VERSION_CURRENT) -# define XORG_VERSION_SNAP XORG_GET_PATCH_VERSION(XORG_VERSION_CURRENT) +# define XORG_VERSION_SNAP XORG_GET_SNAP_VERSION(XORG_VERSION_CURRENT) #endif -/* $XdotOrg: xc/programs/Xserver/hw/xfree86/xf86Version.h,v 1.1.4.3 2003/12/06 13:24:23 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/xorgVersion.h,v 1.3 2004/08/16 02:07:53 kem Exp $ */ diff --git a/hw/xfree86/ddc/interpret_edid.c b/hw/xfree86/ddc/interpret_edid.c index bf2509c95..d5a791570 100644 --- a/hw/xfree86/ddc/interpret_edid.c +++ b/hw/xfree86/ddc/interpret_edid.c @@ -185,7 +185,9 @@ get_monitor_ranges(Uchar *c, struct monitor_ranges *r) r->max_v = MAX_V; r->min_h = MIN_H; r->max_h = MAX_H; - r->max_clock = MAX_CLOCK * 10; + r->max_clock = 0; + if(MAX_CLOCK != 0xff) /* is specified? */ + r->max_clock = MAX_CLOCK * 10; } static void diff --git a/hw/xfree86/ddc/xf86DDC.c b/hw/xfree86/ddc/xf86DDC.c index 123bb492e..2cdeacab5 100644 --- a/hw/xfree86/ddc/xf86DDC.c +++ b/hw/xfree86/ddc/xf86DDC.c @@ -34,7 +34,7 @@ static XF86ModuleVersionInfo ddcVersRec = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 1, 0, 0, ABI_CLASS_VIDEODRV, /* needs the video driver ABI */ ABI_VIDEODRV_VERSION, @@ -83,7 +83,7 @@ ddcSetup(pointer module, pointer opts, int *errmaj, int *errmin) static unsigned char *EDIDRead_DDC1( ScrnInfoPtr pScrn, - void (*)(ScrnInfoPtr,xf86ddcSpeed), + DDC1SetSpeedProc, unsigned int (*)(ScrnInfoPtr) ); @@ -139,7 +139,7 @@ DDCAvailableOptions(void *unused) xf86MonPtr xf86DoEDID_DDC1( - int scrnIndex, void (*DDC1SetSpeed)(ScrnInfoPtr, xf86ddcSpeed), + int scrnIndex, DDC1SetSpeedProc DDC1SetSpeed, unsigned int (*DDC1Read)(ScrnInfoPtr) ) { @@ -227,7 +227,7 @@ xf86DoEDID_DDC2(int scrnIndex, I2CBusPtr pBus) * function; it will also decide if we need to reread it */ static unsigned char * -EDIDRead_DDC1(ScrnInfoPtr pScrn, void (*DDCSpeed)(ScrnInfoPtr,xf86ddcSpeed), +EDIDRead_DDC1(ScrnInfoPtr pScrn, DDC1SetSpeedProc DDCSpeed, unsigned int (*read_DDC)(ScrnInfoPtr)) { unsigned char *EDID_block = NULL; diff --git a/hw/xfree86/ddc/xf86DDC.h b/hw/xfree86/ddc/xf86DDC.h index ae2e26641..3d94fd976 100644 --- a/hw/xfree86/ddc/xf86DDC.h +++ b/hw/xfree86/ddc/xf86DDC.h @@ -24,9 +24,11 @@ typedef enum { DDC_FAST } xf86ddcSpeed; +typedef void (* DDC1SetSpeedProc)(ScrnInfoPtr, xf86ddcSpeed); + extern xf86MonPtr xf86DoEDID_DDC1( int scrnIndex, - void (*DDC1SetSpeed)(ScrnInfoPtr, xf86ddcSpeed), + DDC1SetSpeedProc DDC1SetSpeed, unsigned int (*DDC1Read)(ScrnInfoPtr) ); diff --git a/hw/xfree86/dixmods/GLcoremodule.c b/hw/xfree86/dixmods/GLcoremodule.c index 422da4820..a62b33ce4 100644 --- a/hw/xfree86/dixmods/GLcoremodule.c +++ b/hw/xfree86/dixmods/GLcoremodule.c @@ -42,7 +42,7 @@ static XF86ModuleVersionInfo VersRec = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 1, 0, 0, ABI_CLASS_EXTENSION, ABI_EXTENSION_VERSION, diff --git a/hw/xfree86/dixmods/afbmodule.c b/hw/xfree86/dixmods/afbmodule.c index 19f196ad8..ac7049c10 100644 --- a/hw/xfree86/dixmods/afbmodule.c +++ b/hw/xfree86/dixmods/afbmodule.c @@ -36,7 +36,7 @@ static XF86ModuleVersionInfo VersRec = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 1, 0, 0, ABI_CLASS_ANSIC, /* Only need the ansic layer */ ABI_ANSIC_VERSION, diff --git a/hw/xfree86/dixmods/bitmapmod.c b/hw/xfree86/dixmods/bitmapmod.c index 27fc23d32..458cc62c9 100644 --- a/hw/xfree86/dixmods/bitmapmod.c +++ b/hw/xfree86/dixmods/bitmapmod.c @@ -43,7 +43,7 @@ static XF86ModuleVersionInfo VersRec = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 1, 0, 0, ABI_CLASS_FONT, /* Font module */ ABI_FONT_VERSION, diff --git a/hw/xfree86/dixmods/cfb16module.c b/hw/xfree86/dixmods/cfb16module.c index c8c79b545..ef5c79459 100644 --- a/hw/xfree86/dixmods/cfb16module.c +++ b/hw/xfree86/dixmods/cfb16module.c @@ -38,7 +38,7 @@ static XF86ModuleVersionInfo VersRec = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 1, 0, 0, ABI_CLASS_ANSIC, /* Only need the ansic layer */ ABI_ANSIC_VERSION, diff --git a/hw/xfree86/dixmods/cfb24module.c b/hw/xfree86/dixmods/cfb24module.c index cf363f3c7..e7e683ae0 100644 --- a/hw/xfree86/dixmods/cfb24module.c +++ b/hw/xfree86/dixmods/cfb24module.c @@ -38,7 +38,7 @@ static XF86ModuleVersionInfo VersRec = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 1, 0, 0, ABI_CLASS_ANSIC, /* Only need the ansic layer */ ABI_ANSIC_VERSION, diff --git a/hw/xfree86/dixmods/cfb32module.c b/hw/xfree86/dixmods/cfb32module.c index 791b64285..2d75763b0 100644 --- a/hw/xfree86/dixmods/cfb32module.c +++ b/hw/xfree86/dixmods/cfb32module.c @@ -38,7 +38,7 @@ static XF86ModuleVersionInfo VersRec = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 1, 0, 0, ABI_CLASS_ANSIC, /* Only need the ansic layer */ ABI_ANSIC_VERSION, diff --git a/hw/xfree86/dixmods/cfbmodule.c b/hw/xfree86/dixmods/cfbmodule.c index 87af699db..142442adb 100644 --- a/hw/xfree86/dixmods/cfbmodule.c +++ b/hw/xfree86/dixmods/cfbmodule.c @@ -38,7 +38,7 @@ static XF86ModuleVersionInfo VersRec = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 1, 0, 0, ABI_CLASS_ANSIC, /* Only need the ansic layer */ ABI_ANSIC_VERSION, diff --git a/hw/xfree86/dixmods/dbemodule.c b/hw/xfree86/dixmods/dbemodule.c index 914678b71..ff2b7ffbc 100644 --- a/hw/xfree86/dixmods/dbemodule.c +++ b/hw/xfree86/dixmods/dbemodule.c @@ -20,7 +20,7 @@ static XF86ModuleVersionInfo VersRec = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 1, 0, 0, ABI_CLASS_EXTENSION, ABI_EXTENSION_VERSION, diff --git a/hw/xfree86/dixmods/extmod/modinit.c b/hw/xfree86/dixmods/extmod/modinit.c index a27fa5994..56776accf 100644 --- a/hw/xfree86/dixmods/extmod/modinit.c +++ b/hw/xfree86/dixmods/extmod/modinit.c @@ -213,7 +213,7 @@ static XF86ModuleVersionInfo VersRec = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 1, 0, 0, ABI_CLASS_EXTENSION, ABI_EXTENSION_VERSION, diff --git a/hw/xfree86/dixmods/extmod/modinit.h b/hw/xfree86/dixmods/extmod/modinit.h index 71b54866d..73f4d1b14 100644 --- a/hw/xfree86/dixmods/extmod/modinit.h +++ b/hw/xfree86/dixmods/extmod/modinit.h @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/Xext/extmod/modinit.h,v 1.1.4.2.2.2 2004/03/04 20:16:03 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/Xext/extmod/modinit.h,v 1.2 2004/04/23 18:44:43 eich Exp $ */ /* $XFree86: xc/programs/Xserver/Xext/extmod/modinit.h,v 1.1 2003/07/16 01:38:33 dawes Exp $ */ #ifndef INITARGS diff --git a/hw/xfree86/dixmods/extmod/xf86vmode.c b/hw/xfree86/dixmods/extmod/xf86vmode.c index 74119e4a1..8060aec52 100644 --- a/hw/xfree86/dixmods/extmod/xf86vmode.c +++ b/hw/xfree86/dixmods/extmod/xf86vmode.c @@ -29,7 +29,7 @@ or other dealings in this Software without prior written authorization from Kaleb S. KEITHLEY */ -/* $XdotOrg: xc/programs/Xserver/Xext/xf86vmode.c,v 1.1.4.3.4.1 2004/03/04 17:47:20 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/Xext/xf86vmode.c,v 1.2 2004/04/23 18:44:41 eich Exp $ */ /* $Xorg: xf86vmode.c,v 1.3 2000/08/17 19:47:59 cpqbld Exp $ */ /* THIS IS NOT AN X CONSORTIUM STANDARD OR AN X PROJECT TEAM SPECIFICATION */ diff --git a/hw/xfree86/dixmods/fbmodule.c b/hw/xfree86/dixmods/fbmodule.c index 2b9c50408..1b9b665dd 100644 --- a/hw/xfree86/dixmods/fbmodule.c +++ b/hw/xfree86/dixmods/fbmodule.c @@ -36,7 +36,7 @@ static XF86ModuleVersionInfo VersRec = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 1, 0, 0, ABI_CLASS_ANSIC, /* Only need the ansic layer */ ABI_ANSIC_VERSION, diff --git a/hw/xfree86/dixmods/ftmodule.c b/hw/xfree86/dixmods/ftmodule.c index ceb5485c0..1f65cefbe 100644 --- a/hw/xfree86/dixmods/ftmodule.c +++ b/hw/xfree86/dixmods/ftmodule.c @@ -43,7 +43,7 @@ static XF86ModuleVersionInfo VersRec = MODULEVENDORSTRING " & the After X-TT Project", MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 2, 1, 0, ABI_CLASS_FONT, /* Font module */ ABI_FONT_VERSION, diff --git a/hw/xfree86/dixmods/glxmodule.c b/hw/xfree86/dixmods/glxmodule.c index eb8e54f26..853d49b0f 100644 --- a/hw/xfree86/dixmods/glxmodule.c +++ b/hw/xfree86/dixmods/glxmodule.c @@ -113,6 +113,8 @@ static const char *glcoreSymbols[] = { "__glTexGeniv_size", "__glTexParameterfv_size", "__glTexParameteriv_size", + "__glXglDDXExtensionInfo", + "__glXglDDXScreenInfo", "__glXActiveScreens", "__glXAssociateContext", "__glXBadContext", @@ -776,7 +778,6 @@ static const char *glcoreSymbols[] = { "__glXFogfvReqSize", "__glXFogivReqSize", "__glXForceCurrent", - "__glXFormatGLModes", "__glXFree", "__glXFreeBuffers", "__glXFreeContext", @@ -1222,7 +1223,7 @@ static XF86ModuleVersionInfo VersRec = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 1, 0, 0, ABI_CLASS_EXTENSION, ABI_EXTENSION_VERSION, diff --git a/hw/xfree86/dixmods/laymodule.c b/hw/xfree86/dixmods/laymodule.c index 274e68b2e..6d7c4e280 100644 --- a/hw/xfree86/dixmods/laymodule.c +++ b/hw/xfree86/dixmods/laymodule.c @@ -43,7 +43,7 @@ static XF86ModuleVersionInfo VersRec = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 1, 0, 0, ABI_CLASS_ANSIC, /* Only need the ansic layer */ ABI_ANSIC_VERSION, diff --git a/hw/xfree86/dixmods/mfbmodule.c b/hw/xfree86/dixmods/mfbmodule.c index 0617226d0..40d884c9e 100644 --- a/hw/xfree86/dixmods/mfbmodule.c +++ b/hw/xfree86/dixmods/mfbmodule.c @@ -35,7 +35,7 @@ static XF86ModuleVersionInfo VersRec = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 1, 0, 0, ABI_CLASS_ANSIC, /* Only need the ansic layer */ ABI_ANSIC_VERSION, diff --git a/hw/xfree86/dixmods/recordmod.c b/hw/xfree86/dixmods/recordmod.c index bd1022193..4eebf0ee6 100644 --- a/hw/xfree86/dixmods/recordmod.c +++ b/hw/xfree86/dixmods/recordmod.c @@ -21,7 +21,7 @@ static XF86ModuleVersionInfo VersRec = { MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 1, 13, 0, ABI_CLASS_EXTENSION, ABI_EXTENSION_VERSION, diff --git a/hw/xfree86/dixmods/shmodule.c b/hw/xfree86/dixmods/shmodule.c index d24f8a823..f47b03aa9 100644 --- a/hw/xfree86/dixmods/shmodule.c +++ b/hw/xfree86/dixmods/shmodule.c @@ -43,7 +43,7 @@ static XF86ModuleVersionInfo VersRec = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 1, 0, 0, ABI_CLASS_ANSIC, /* Only need the ansic layer */ ABI_ANSIC_VERSION, diff --git a/hw/xfree86/dixmods/type1mod.c b/hw/xfree86/dixmods/type1mod.c index 9c25f4c0b..868de3de4 100644 --- a/hw/xfree86/dixmods/type1mod.c +++ b/hw/xfree86/dixmods/type1mod.c @@ -43,7 +43,7 @@ static XF86ModuleVersionInfo VersRec = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 1, 0, 2, ABI_CLASS_FONT, /* Font module */ ABI_FONT_VERSION, diff --git a/hw/xfree86/dixmods/xf86XTrapModule.c b/hw/xfree86/dixmods/xf86XTrapModule.c index 65062108e..f6e37b54e 100644 --- a/hw/xfree86/dixmods/xf86XTrapModule.c +++ b/hw/xfree86/dixmods/xf86XTrapModule.c @@ -27,7 +27,7 @@ static XF86ModuleVersionInfo xtrapVersRec = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 1, 0, 0, ABI_CLASS_EXTENSION, /* needs the server extension ABI */ ABI_EXTENSION_VERSION, diff --git a/hw/xfree86/doc/README.DRI b/hw/xfree86/doc/README.DRI index 3962a0686..7fc52eb32 100644 --- a/hw/xfree86/doc/README.DRI +++ b/hw/xfree86/doc/README.DRI @@ -1253,3 +1253,4 @@ demo programs is available from http://dri.sourceforge.net/res.phtml Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml,v 1.28 dawes Exp $ + diff --git a/hw/xfree86/doc/README.fonts b/hw/xfree86/doc/README.fonts index 26b92cd01..87f264f14 100644 --- a/hw/xfree86/doc/README.fonts +++ b/hw/xfree86/doc/README.fonts @@ -1,4 +1,4 @@ - Fonts in X11R6.7 + Fonts in X11R6.8 Juliusz Chroboczek, <jch@pps.jussieu.fr> @@ -6,10 +6,9 @@ 1. Introduction -This document describes the support for fonts in X11R6.7. Installing fonts +This document describes the support for fonts in X11R6.8. Installing fonts (section 2., page 1) is aimed at the casual user wishing to install fonts in -X11R6.7 or XFree86; the rest of the document describes the font support in -more detail. +X11R6.8 the rest of the document describes the font support in more detail. We assume some familiarity with digital fonts. If anything is not clear to you, please consult Appendix: Background (section 5., page 1) at the end of @@ -19,7 +18,7 @@ this document for background information. X includes two font systems: the original core X11 fonts system, which is present in all implementations of X11, and the Xft fonts system, which may -not be distributed with implementations of X11 that are not based on X116.7.0 +not be distributed with implementations of X11 that are not based on X11R6.8 but will hopefully be included by them in the future The core X11 fonts system is directly derived from the fonts system included @@ -49,13 +48,13 @@ access newly-installed fonts. Xft has no configuration mechanism itself, rather it relies upon the fontcon- fig library to configure and customize fonts. That library is not specific -to X11R6.7.0 or indeed on any particular font output mechanism. This discus- +to X11R6.8 or indeed on any particular font output mechanism. This discus- sion describes how fontconfig, rather than Xft, works. 2.1.1 Installing fonts in Xft Fontconfig looks for fonts in a set of well-known directories that include -all of X11R6.7's standard font directories (`/usr/X11R6/lib/X11/lib/fonts/*') +all of X11R6.8's standard font directories (`/usr/X11R6/lib/X11/lib/fonts/*') by default) as well as a directory called `.fonts/' in the user's home direc- tory. Installing a font for use by Xft applications is as simple as copying a font file into one of these directories. @@ -115,9 +114,9 @@ Anti-aliasing can be disabled for all fonts by the following incantation: </edit> </match> -Xft supports sub-pixel rasterisation on LCD displays. X11R67 should automat- -ically enable this feature on laptops and when using an LCD monitor connected -with a DVI cable; you can check whether this was done by typing +Xft supports sub-pixel rasterisation on LCD displays. X11R6.8 should auto- +matically enable this feature on laptops and when using an LCD monitor con- +nected with a DVI cable; you can check whether this was done by typing $ xdpyinfo -ext RENDER | grep sub-pixel @@ -186,8 +185,8 @@ of this new directory by including it in the font path. 2.2.1 Installing bitmap fonts -The X11R6.7 server can use bitmap fonts in both the cross-platform BDF format -and the somewhat more efficient binary PCF format. (X11R6.7 also supports +The X11R6.8 server can use bitmap fonts in both the cross-platform BDF format +and the somewhat more efficient binary PCF format. (X11R6.8 also supports the obsolete SNF format.) Bitmap fonts are normally distributed in the BDF format. Before installing @@ -216,7 +215,7 @@ directory; see Setting the server font path (section 2.2.4, page 1) below. 2.2.2 Installing scalable fonts -The X11R6.7 server supports scalable fonts in four formats: Type 1, Speedo, +The X11R6.8 server supports scalable fonts in four formats: Type 1, Speedo, TrueType and CIDFont. This section only applies to the former three; for information on CIDFonts, please see Installing CIDFonts (section 2.2.3, page 1) later in this document. @@ -252,7 +251,7 @@ CMap `UniKS-UCS2-H' is called Munhwa-Regular--UniKS-UCS2-H -The CIDFont code in X11R6.7 requires a very rigid directory structure. The +The CIDFont code in X11R6.8 requires a very rigid directory structure. The main directory must be called `CID' (its location defaults to `/usr/X11R6/lib/X11/fonts/CID' but it may be located anywhere), and it should contain a subdirectory for every CID collection. Every subdirectory must @@ -311,7 +310,7 @@ For best results, scalable fonts should appear in the font path before the bitmap fonts; this way, the server will prefer bitmap fonts to scalable fonts when an exact match is possible, but will avoid scaling bitmap fonts when a scalable font can be used. (The `:unscaled' hack, while still supported, -should no longer be necessary in X11R6.7.0.) +should no longer be necessary in X11R6.8.) You may check the font path of the running server by typing the command @@ -354,11 +353,11 @@ mounted font directories). If this doesn't help, it is quite possible that you are trying to use a font in a format that is not supported by your server. -X11R6.7 supports the BDF, PCF, SNF, Type 1, Speedo, TrueType, OpenType and -CIDFont font formats. However, not all X11R6.7 or XFree86 servers come with -all the font backends configured in. +X11R6.8 supports the BDF, PCF, SNF, Type 1, Speedo, TrueType, OpenType and +CIDFont font formats. However, not all X11R6.8 servers come with all the +font backends configured in. -On most platforms, the X11R6.7 servers are modular: the font backends are +On most platforms, the X11R6.8 servers are modular: the font backends are included in modules that are loaded at runtime. The modules to be loaded are specified in the `xorg.conf' file using the `Load' directive: @@ -366,7 +365,7 @@ specified in the `xorg.conf' file using the `Load' directive: If you have trouble installing fonts in a specific format, you may want to check the server's log file in order to see whether the relevant modules are -properly loaded. The list of font modules distributed with X11R6.7 is as +properly loaded. The list of font modules distributed with X11R6.8 is as follows: o "bitmap": bitmap fonts (`*.bdf', `*.pcf' and `*.snf'); @@ -383,7 +382,7 @@ follows: Please note that the argument of the `Load' directive is case-sensitive. -3. Fonts included with X11R6.7 +3. Fonts included with X11R6.8 3.1 Standard bitmap fonts @@ -392,7 +391,7 @@ fonts, including the `fixed' family, and bitmap versions of Courier, Times, Helvetica and some members of the Lucida family. In the SI, these fonts are provided in the ISO 8859-1 encoding (ISO Latin Western-European). -In X11R6.7, a number of these fonts are provided in Unicode-encoded font +In X11R6.8, a number of these fonts are provided in Unicode-encoded font files instead. At build time, these fonts are split into font files encoded according to legacy encodings, a process which allows us to provide the stan- dard fonts in a number of regional encodings with no duplication of work. @@ -470,7 +469,7 @@ for improved presentation of text. 3.3 Standard scalable fonts -X11R6.7 includes all the scalable fonts distributed with X11R6. +X11R6.8 includes all the scalable fonts distributed with X11R6. 3.3.1 Standard Type 1 fonts @@ -492,7 +491,7 @@ and reside in the font files /usr/X11R6/lib/X11/fonts/Type1/UT*.pfa -Finally, X11R6.7 also comes with Type 1 versions of Bitstream Courier and +Finally, X11R6.8 also comes with Type 1 versions of Bitstream Courier and Charter. These fonts have XLFD -bitstream-courier-*-*-normal--0-0-0-0-m-0-iso8859-1 @@ -504,7 +503,7 @@ and reside in the font files 3.3.2 Standard Speedo fonts -X11R6.7 includes Speedo versions of the Bitstream Courier and Charter fonts. +X11R6.8 includes Speedo versions of the Bitstream Courier and Charter fonts. In order to use these fonts, you should ensure that your X server is loading the `Speedo' font backend; see Troubleshooting (section 2.2.5, page 1). @@ -520,7 +519,7 @@ and reside in the font files 3.4 The Bigelow & Holmes Luxi family -X11R6.7 includes the Luxi family of scalable fonts, in both TrueType and +X11R6.8 includes the Luxi family of scalable fonts, in both TrueType and Type 1 format. This family consists of the fonts Luxi Serif, with XLFD -b&h-luxi serif-medium-*-normal--*-*-*-*-p-*-*-* @@ -566,11 +565,11 @@ For more information, please contact <design@bigelowandholmes.com> or An earlier version of the Luxi fonts was made available under the name Lucidux. This name should no longer be used due to trademark uncertainties, -and all traces of the Lucidux name have been removed from X11R6.7. +and all traces of the Lucidux name have been removed from X11R6.8. 4. More about core fonts -This section describes X11R6.7-specific enhancements to the core X11 fonts +This section describes X11R6.8-specific enhancements to the core X11 fonts system. 4.1 Core fonts and internationalisation @@ -593,11 +592,8 @@ backend) use a common fontenc layer for font re-encoding. This allows these backends to share their encoding data, and allows simple configuration of new locales independently of font type. -Please note: the X-TrueType (X-TT) backend does not use the fontenc layer, -but instead uses its own method for font reencoding. If you are only inter- -ested in X-TT you may want to skip to Using Symbol Fonts (section 4.1.5, page -1), as the intervening information does not apply to X-TT. X-TT itself is -described in more detail in X-TrueType (section 4.2.2, page 1). +Please note: the X-TrueType (X-TT) backend is not included in X11R6.8. That +functionality has been merged into the FreeType backend.> In the fontenc layer, an encoding is defined by a name (such as iso8859-1), possibly a number of aliases (alternate names), and an ordered collection of @@ -656,7 +652,7 @@ option followed by the name of a directory containing encoding files, can be used to automatically build `encodings.dir' files. Please see the mkfont- dir(1) manual page for more details. -A number of encoding files for common encodings are included with X11R6.7. +A number of encoding files for common encodings are included with X11R6.8. Information on writing new encoding files can be found in Format of encodings directory files (section 4.1.3, page 1) and Format of encoding files (section 4.1.4, page 1) later in this document. @@ -976,8 +972,8 @@ options are indispensable in CJKV. For example, bw=0.5:ds=y:ai=0.2:mincho.ttc -misc-mincho-bold-i-normal--0-0-0-0-c-0-jisx0201.1976-0 setup the complete combination of jisx0208 and jisx0201 using mincho.ttc -only. More information on the TTCap syntax is found on the After X-TT -Project page <URL:http://x-tt.sourceforge.jp/>. +only. More information on the TTCap syntax is found on the After X-TT Pro- +ject page <URL:http://x-tt.sourceforge.jp/>. The FreeType backend uses the fontenc layer in order to support recoding of fonts; this was described in The fontenc layer (section 4.1.1, page 1) and @@ -992,7 +988,7 @@ ings, but instead uses its own database of encodings. Since the functionalities for CJKV support introduced by X-TT have been merged into the new FreeType backend, the X-TT backend will be removed from -X11R6.7's tree near the future. Therefore, the use of FreeType backend is +X11R6.8's tree near the future. Therefore, the use of FreeType backend is preferred over the X-TT backend. General information on X-TrueType may be found at the After X-TT Project page @@ -1120,10 +1116,10 @@ and `cursor' aliases are defined in 5.3 Unicode -Unicode (<URL:http://www.unicode.org>) is a coded character set with the goal -of uniquely identifying all characters for all scripts, current and histori- -cal. While Unicode was explicitly not designed as a glyph encoding scheme, -it is often possible to use it as such. +Unicode (urlnam <URL:http://www.unicode.org>) is a coded character set with +the goal of uniquely identifying all characters for all scripts, current and +historical. While Unicode was explicitly not designed as a glyph encoding +scheme, it is often possible to use it as such. Unicode is an open character set, meaning that codepoint assignments may be added to Unicode at any time (once specified, though, an assignment can never @@ -1139,15 +1135,15 @@ last two fields of their XLFD set to `iso10646-1'. 6. References -X11R6.7 comes with extensive documentation in the form of manual pages and +X11R6.8 comes with extensive documentation in the form of manual pages and typeset documents. Before installing fonts, you really should read the font- config(3) and mkfontdir(1) manual pages; other manual pages of interest include X(7), Xserver(1), xset(1), Xft(3), xlsfonts(1) and showfont(1). In addition, you may want to read the X Logical Font Description document, by Jim Flowers, which is provided in the file `xc/doc/xlfd.PS.Z'. -The latest released version of the X11R6.7 documentation (including this doc- -ument and all manual pages) can be found from current X11R6.7 documentation +The latest released version of the X11R6.8 documentation (including this doc- +ument and all manual pages) can be found from current X11R6.8 documentation <URL:http://wiki.x.org/>. The comp.fonts FAQ <URL:http://www.netmeg.net/faq/computers/fonts/>, which is @@ -1182,5 +1178,5 @@ The IANA RFC documents, available from a number of sites throughout the world, often provide interesting information about character set issues; see for example RFC 373. - $Id$ +$XdotOrg: xc/programs/Xserver/hw/xfree86/doc/README.fonts,v 1.3 2004/09/03 23:41:21 kem Exp $ diff --git a/hw/xfree86/doc/devel/README.DRIcomp b/hw/xfree86/doc/devel/README.DRIcomp index aafbd4237..89f40a759 100644 --- a/hw/xfree86/doc/devel/README.DRIcomp +++ b/hw/xfree86/doc/devel/README.DRIcomp @@ -553,3 +553,4 @@ trouble shooting and how to use the DRI-enabled X server for 3D applications. Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml,v 1.19 dawes Exp $ + diff --git a/hw/xfree86/doc/man/Xorg.man.pre b/hw/xfree86/doc/man/Xorg.man.pre index d4bb08bc4..3d9466775 100644 --- a/hw/xfree86/doc/man/Xorg.man.pre +++ b/hw/xfree86/doc/man/Xorg.man.pre @@ -1,4 +1,4 @@ -.\" $XdotOrg: $ +.\" $XdotOrg: xc/programs/Xserver/hw/xfree86/Xorg.man,v 1.2 2004/04/23 19:20:02 eich Exp $ .TH __xservername__ __appmansuffix__ __vendorversion__ .SH NAME __xservername__ - X11R6 X server diff --git a/hw/xfree86/doc/man/xorg.conf.man.pre b/hw/xfree86/doc/man/xorg.conf.man.pre index e530991e8..a785c29ae 100644 --- a/hw/xfree86/doc/man/xorg.conf.man.pre +++ b/hw/xfree86/doc/man/xorg.conf.man.pre @@ -1,4 +1,4 @@ -.\" $XdotOrg: xc/programs/Xserver/hw/xfree86/xorg.conf.man,v 1.1.2.1 2004/03/27 17:01:11 keithp Exp $ +.\" $XdotOrg: xc/programs/Xserver/hw/xfree86/xorg.conf.man,v 1.2 2004/04/23 19:20:02 eich Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' .TH __xconfigfile__ __filemansuffix__ __vendorversion__ diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c index acef4c54b..4748f17df 100644 --- a/hw/xfree86/dri/dri.c +++ b/hw/xfree86/dri/dri.c @@ -34,8 +34,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ -#ifdef XFree86LOADER #include "xf86.h" +#ifdef XFree86LOADER #include "xf86_ansic.h" #else #include <sys/time.h> @@ -57,6 +57,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define _XF86DRI_SERVER_ #include "xf86dristr.h" #include "swaprep.h" +#include "xf86str.h" #include "dri.h" #include "sarea.h" #include "dristruct.h" @@ -113,11 +114,14 @@ Bool DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) { DRIScreenPrivPtr pDRIPriv; - drmContextPtr reserved; + drm_context_t * reserved; int reserved_count; int i, fd, drmWasAvailable; Bool xineramaInCore = FALSE; int err = 0; + char *openbusid; + drmVersionPtr drmlibv; + int drmlibmajor, drmlibminor, drmdimajor, drmdiminor; if (DRIGeneration != serverGeneration) { if ((DRIScreenPrivIndex = AllocateScreenPrivateIndex()) < 0) @@ -148,8 +152,31 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) drmWasAvailable = drmAvailable(); + /* Check the DRM lib version. + * drmGetLibVersion was not supported in version 1.0, so check for + * symbol first to avoid possible crash or hang. + */ + drmlibmajor = 1; + drmlibminor = 0; + if (xf86LoaderCheckSymbol("drmGetLibVersion")) { + drmlibv = drmGetLibVersion(-1); + if (drmlibv != NULL) { + drmlibmajor = drmlibv->version_major; + drmlibminor = drmlibv->version_minor; + drmFreeVersion(drmlibv); + } + } + + /* Check if the libdrm can handle falling back to loading based on name + * if a busid string is passed. + */ + if (drmlibmajor == 1 && drmlibminor >= 2) + openbusid = pDRIInfo->busIdString; + else + openbusid = NULL; + /* Note that drmOpen will try to load the kernel module, if needed. */ - fd = drmOpen(pDRIInfo->drmDriverName, NULL ); + fd = drmOpen(pDRIInfo->drmDriverName, openbusid); if (fd < 0) { /* failed to open DRM */ pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL; @@ -184,7 +211,40 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) pDRIPriv->grabbedDRILock = FALSE; pDRIPriv->drmSIGIOHandlerInstalled = FALSE; - if ((err = drmSetBusid(pDRIPriv->drmFD, pDRIPriv->pDriverInfo->busIdString)) < 0) { + if (drmlibmajor == 1 && drmlibminor >= 2) { + drmSetVersion sv; + + /* Get the interface version, asking for 1.1. */ + sv.drm_di_major = 1; + sv.drm_di_minor = 1; + sv.drm_dd_major = -1; + err = drmSetInterfaceVersion(pDRIPriv->drmFD, &sv); + if (err == 0) { + drmdimajor = sv.drm_di_major; + drmdiminor = sv.drm_di_minor; + } else { + /* failure, so set it to 1.0.0. */ + drmdimajor = 1; + drmdiminor = 0; + } + } + else { + /* We can't check the DI DRM interface version, so set it to 1.0.0. */ + drmdimajor = 1; + drmdiminor = 0; + } + DRIDrvMsg(pScreen->myNum, X_INFO, + "[drm] DRM interface version %d.%d\n", drmdimajor, drmdiminor); + + /* If the interface minor number is 1.1, then we've opened a DRM device + * that already had the busid set through drmOpen. + */ + if (drmdimajor == 1 && drmdiminor >= 1) + err = 0; + else + err = drmSetBusid(pDRIPriv->drmFD, pDRIPriv->pDriverInfo->busIdString); + + if (err < 0) { pDRIPriv->directRenderingSupport = FALSE; pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL; drmClose(pDRIPriv->drmFD); @@ -235,7 +295,7 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) pDRIPriv->hSAREA, pDRIPriv->pSAREA); if (drmAddMap( pDRIPriv->drmFD, - (drmHandle)pDRIPriv->pDriverInfo->frameBufferPhysicalAddress, + (drm_handle_t)pDRIPriv->pDriverInfo->frameBufferPhysicalAddress, pDRIPriv->pDriverInfo->frameBufferSize, DRM_FRAME_BUFFER, 0, @@ -424,7 +484,7 @@ DRICloseScreen(ScreenPtr pScreen) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); DRIInfoPtr pDRIInfo; - drmContextPtr reserved; + drm_context_t * reserved; int reserved_count; if (pDRIPriv && pDRIPriv->directRenderingSupport) { @@ -575,7 +635,7 @@ DRIQueryDirectRenderingCapable(ScreenPtr pScreen, Bool* isCapable) } Bool -DRIOpenConnection(ScreenPtr pScreen, drmHandlePtr hSAREA, char **busIdString) +DRIOpenConnection(ScreenPtr pScreen, drm_handle_t * hSAREA, char **busIdString) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); @@ -586,7 +646,7 @@ DRIOpenConnection(ScreenPtr pScreen, drmHandlePtr hSAREA, char **busIdString) } Bool -DRIAuthConnection(ScreenPtr pScreen, drmMagic magic) +DRIAuthConnection(ScreenPtr pScreen, drm_magic_t magic) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); @@ -620,18 +680,18 @@ DRIGetClientDriverName(ScreenPtr pScreen, /* DRICreateContextPriv and DRICreateContextPrivFromHandle are helper functions that layer on drmCreateContext and drmAddContextTag. - DRICreateContextPriv always creates a kernel drmContext and then calls + DRICreateContextPriv always creates a kernel drm_context_t and then calls DRICreateContextPrivFromHandle to create a DRIContextPriv structure for - DRI tracking. For the SIGIO handler, the drmContext is associated with + DRI tracking. For the SIGIO handler, the drm_context_t is associated with DRIContextPrivPtr. Any special flags are stored in the DRIContextPriv area and are passed to the kernel (if necessary). DRICreateContextPriv returns a pointer to newly allocated - DRIContextPriv, and returns the kernel drmContext in pHWContext. */ + DRIContextPriv, and returns the kernel drm_context_t in pHWContext. */ DRIContextPrivPtr DRICreateContextPriv(ScreenPtr pScreen, - drmContextPtr pHWContext, + drm_context_t * pHWContext, DRIContextFlags flags) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); @@ -645,7 +705,7 @@ DRICreateContextPriv(ScreenPtr pScreen, DRIContextPrivPtr DRICreateContextPrivFromHandle(ScreenPtr pScreen, - drmContext hHWContext, + drm_context_t hHWContext, DRIContextFlags flags) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); @@ -720,8 +780,8 @@ static Bool DRICreateDummyContext(ScreenPtr pScreen, Bool needCtxPriv) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - __GLXscreenInfo *pGLXScreen = &__glXActiveScreens[pScreen->myNum]; - __GLXvisualConfig *pGLXVis = pGLXScreen->pGlxVisual; + __GLXscreenInfo *pGLXScreen = __glXgetActiveScreen(pScreen->myNum); + __GLcontextModes *modes = pGLXScreen->modes; void **pVisualConfigPriv = pGLXScreen->pVisualPriv; DRIContextPrivPtr pDRIContextPriv; void *contextStore; @@ -734,7 +794,7 @@ DRICreateDummyContext(ScreenPtr pScreen, Bool needCtxPriv) for (visNum = 0; visNum < pScreen->numVisuals; visNum++, visual++) { - if (pGLXVis->vid == visual->vid) + if (modes->visualID == visual->vid) break; } if (visNum == pScreen->numVisuals) return FALSE; @@ -781,15 +841,14 @@ DRIDestroyDummyContext(ScreenPtr pScreen, Bool hasCtxPriv) Bool DRICreateContext(ScreenPtr pScreen, VisualPtr visual, - XID context, drmContextPtr pHWContext) + XID context, drm_context_t * pHWContext) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - __GLXscreenInfo *pGLXScreen = &__glXActiveScreens[pScreen->myNum]; - __GLXvisualConfig *pGLXVis = pGLXScreen->pGlxVisual; + __GLXscreenInfo *pGLXScreen = __glXgetActiveScreen(pScreen->myNum); + __GLcontextModes *modes = pGLXScreen->modes; void **pVisualConfigPriv = pGLXScreen->pVisualPriv; DRIContextPrivPtr pDRIContextPriv; void *contextStore; - int visNum; if (pDRIPriv->createDummyCtx && !pDRIPriv->dummyCtxPriv) { if (!DRICreateDummyContext(pScreen, pDRIPriv->createDummyCtxPriv)) { @@ -800,12 +859,13 @@ DRICreateContext(ScreenPtr pScreen, VisualPtr visual, } /* Find the GLX visual associated with the one requested */ - for (visNum = 0; - visNum < pGLXScreen->numVisuals; - visNum++, pGLXVis++, pVisualConfigPriv++) - if (pGLXVis->vid == visual->vid) + for (modes = pGLXScreen->modes; modes != NULL; modes = modes->next) { + if (modes->visualID == visual->vid) break; - if (visNum == pGLXScreen->numVisuals) { + pVisualConfigPriv++; + } + + if (modes == NULL) { /* No matching GLX visual found */ return FALSE; } @@ -928,7 +988,7 @@ DRITransitionTo2d(ScreenPtr pScreen) Bool DRICreateDrawable(ScreenPtr pScreen, Drawable id, - DrawablePtr pDrawable, drmDrawablePtr hHWDrawable) + DrawablePtr pDrawable, drm_drawable_t * hHWDrawable) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); DRIDrawablePrivPtr pDRIDrawablePriv; @@ -945,7 +1005,7 @@ DRICreateDrawable(ScreenPtr pScreen, Drawable id, return FALSE; } - /* Only create a drmDrawable once */ + /* Only create a drm_drawable_t once */ if (drmCreateDrawable(pDRIPriv->drmFD, hHWDrawable)) { xfree(pDRIDrawablePriv); return FALSE; @@ -1065,11 +1125,11 @@ DRIGetDrawableInfo(ScreenPtr pScreen, int* W, int* H, int* numClipRects, - XF86DRIClipRectPtr* pClipRects, + drm_clip_rect_t ** pClipRects, int* backX, int* backY, int* numBackClipRects, - XF86DRIClipRectPtr* pBackClipRects) + drm_clip_rect_t ** pBackClipRects) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); DRIDrawablePrivPtr pDRIDrawablePriv, pOldDrawPriv; @@ -1165,7 +1225,7 @@ DRIGetDrawableInfo(ScreenPtr pScreen, *W = (int)(pWin->drawable.width); *H = (int)(pWin->drawable.height); *numClipRects = REGION_NUM_RECTS(&pWin->clipList); - *pClipRects = (XF86DRIClipRectPtr)REGION_RECTS(&pWin->clipList); + *pClipRects = (drm_clip_rect_t *)REGION_RECTS(&pWin->clipList); if (!*numClipRects && pDRIPriv->fullscreen) { /* use fake full-screen clip rect */ @@ -1222,7 +1282,7 @@ DRIGetDrawableInfo(ScreenPtr pScreen, Bool DRIGetDeviceInfo(ScreenPtr pScreen, - drmHandlePtr hFrameBuffer, + drm_handle_t * hFrameBuffer, int* fbOrigin, int* fbSize, int* fbStride, @@ -1870,7 +1930,7 @@ DRIGetSAREAPrivate(ScreenPtr pScreen) return (void *)(((char*)pDRIPriv->pSAREA)+sizeof(XF86DRISAREARec)); } -drmContext +drm_context_t DRIGetContext(ScreenPtr pScreen) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); @@ -1967,7 +2027,7 @@ DRIOpenFullScreen(ScreenPtr pScreen, DrawablePtr pDrawable) DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; WindowPtr pWin = (WindowPtr)pDrawable; - XF86DRIClipRectPtr pClipRects = (void *)REGION_RECTS(&pWin->clipList); + drm_clip_rect_t * pClipRects = (void *)REGION_RECTS(&pWin->clipList); _DRIAdjustFrame(pScrn, pDRIPriv, pScrn->frameX0, pScrn->frameY0); @@ -2115,3 +2175,21 @@ DRIMoveBuffersHelper( } else *xdir = 1; } + +char * +DRICreatePCIBusID(pciVideoPtr PciInfo) +{ + char *busID; + int domain; + PCITAG tag; + + busID = xalloc(20); + if (busID == NULL) + return NULL; + + tag = pciTag(PciInfo->bus, PciInfo->device, PciInfo->func); + domain = xf86GetPciDomain(tag); + snprintf(busID, 20, "pci:%04x:%02x:%02x.%d", domain, PciInfo->bus, + PciInfo->device, PciInfo->func); + return busID; +} diff --git a/hw/xfree86/dri/dri.h b/hw/xfree86/dri/dri.h index 149534417..f556d261e 100644 --- a/hw/xfree86/dri/dri.h +++ b/hw/xfree86/dri/dri.h @@ -105,11 +105,11 @@ typedef struct { */ Bool (*CreateContext)(ScreenPtr pScreen, VisualPtr visual, - drmContext hHWContext, + drm_context_t hHWContext, void* pVisualConfigPriv, DRIContextType context); void (*DestroyContext)(ScreenPtr pScreen, - drmContext hHWContext, + drm_context_t hHWContext, DRIContextType context); void (*SwapContext)(ScreenPtr pScreen, DRISyncType syncType, @@ -175,10 +175,10 @@ extern Bool DRIQueryDirectRenderingCapable(ScreenPtr pScreen, Bool *isCapable); extern Bool DRIOpenConnection(ScreenPtr pScreen, - drmHandlePtr hSAREA, + drm_handle_t * hSAREA, char **busIdString); -extern Bool DRIAuthConnection(ScreenPtr pScreen, drmMagic magic); +extern Bool DRIAuthConnection(ScreenPtr pScreen, drm_magic_t magic); extern Bool DRICloseConnection(ScreenPtr pScreen); @@ -191,7 +191,7 @@ extern Bool DRIGetClientDriverName(ScreenPtr pScreen, extern Bool DRICreateContext(ScreenPtr pScreen, VisualPtr visual, XID context, - drmContextPtr pHWContext); + drm_context_t * pHWContext); extern Bool DRIDestroyContext(ScreenPtr pScreen, XID context); @@ -200,7 +200,7 @@ extern Bool DRIContextPrivDelete(pointer pResource, XID id); extern Bool DRICreateDrawable(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable, - drmDrawablePtr hHWDrawable); + drm_drawable_t * hHWDrawable); extern Bool DRIDestroyDrawable(ScreenPtr pScreen, Drawable id, @@ -218,14 +218,14 @@ extern Bool DRIGetDrawableInfo(ScreenPtr pScreen, int* W, int* H, int* numClipRects, - XF86DRIClipRectPtr* pClipRects, + drm_clip_rect_t ** pClipRects, int* backX, int* backY, int* numBackClipRects, - XF86DRIClipRectPtr* pBackClipRects); + drm_clip_rect_t ** pBackClipRects); extern Bool DRIGetDeviceInfo(ScreenPtr pScreen, - drmHandlePtr hFrameBuffer, + drm_handle_t * hFrameBuffer, int* fbOrigin, int* fbSize, int* fbStride, @@ -298,16 +298,16 @@ extern unsigned int DRIGetDrawableStamp(ScreenPtr pScreen, CARD32 drawable_index); extern DRIContextPrivPtr DRICreateContextPriv(ScreenPtr pScreen, - drmContextPtr pHWContext, + drm_context_t * pHWContext, DRIContextFlags flags); extern DRIContextPrivPtr DRICreateContextPrivFromHandle(ScreenPtr pScreen, - drmContext hHWContext, + drm_context_t hHWContext, DRIContextFlags flags); extern Bool DRIDestroyContextPriv(DRIContextPrivPtr pDRIContextPriv); -extern drmContext DRIGetContext(ScreenPtr pScreen); +extern drm_context_t DRIGetContext(ScreenPtr pScreen); extern void DRIQueryVersion(int *majorVersion, int *minorVersion, @@ -325,6 +325,8 @@ extern void DRIMoveBuffersHelper(ScreenPtr pScreen, int *ydir, RegionPtr reg); +extern char *DRICreatePCIBusID(pciVideoPtr PciInfo); + #define _DRI_H_ #endif diff --git a/hw/xfree86/dri/drimodule.c b/hw/xfree86/dri/drimodule.c index 1a6a4c696..1fa7a8edc 100644 --- a/hw/xfree86/dri/drimodule.c +++ b/hw/xfree86/dri/drimodule.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/GL/dri/drimodule.c,v 1.1.4.1.4.2 2004/03/04 17:47:18 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/GL/dri/drimodule.c,v 1.2 2004/04/23 18:44:36 eich Exp $ */ /************************************************************************** Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. @@ -44,7 +44,7 @@ static XF86ModuleVersionInfo VersRec = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 1, 0, 0, ABI_CLASS_EXTENSION, ABI_EXTENSION_VERSION, diff --git a/hw/xfree86/dri/dristruct.h b/hw/xfree86/dri/dristruct.h index 6d90d770a..cf1b1eacf 100644 --- a/hw/xfree86/dri/dristruct.h +++ b/hw/xfree86/dri/dristruct.h @@ -50,7 +50,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. typedef struct _DRIDrawablePrivRec { - drmDrawable hwDrawable; + drm_drawable_t hwDrawable; int drawableIndex; ScreenPtr pScreen; int refCount; @@ -58,7 +58,7 @@ typedef struct _DRIDrawablePrivRec struct _DRIContextPrivRec { - drmContext hwContext; + drm_context_t hwContext; ScreenPtr pScreen; Bool valid3D; DRIContextFlags flags; @@ -78,19 +78,19 @@ typedef struct _DRIScreenPrivRec { Bool directRenderingSupport; int drmFD; /* File descriptor for /dev/video/? */ - drmHandle hSAREA; /* Handle to SAREA, for mapping */ + drm_handle_t hSAREA; /* Handle to SAREA, for mapping */ XF86DRISAREAPtr pSAREA; /* Mapped pointer to SAREA */ - drmHandle hFrameBuffer; /* Handle to framebuffer, for mapping */ - drmContext myContext; /* DDX Driver's context */ + drm_handle_t hFrameBuffer; /* Handle to framebuffer, for mapping */ + drm_context_t myContext; /* DDX Driver's context */ DRIContextPrivPtr myContextPriv;/* Pointer to server's private area */ DRIContextPrivPtr lastPartial3DContext; /* last one partially saved */ void** hiddenContextStore; /* hidden X context */ void** partial3DContextStore; /* parital 3D context */ DRIInfoPtr pDriverInfo; int nrWindows; - XF86DRIClipRectRec private_buffer_rect; /* management of private buffers */ + drm_clip_rect_t private_buffer_rect; /* management of private buffers */ DrawablePtr fullscreen; /* pointer to fullscreen drawable */ - XF86DRIClipRectRec fullscreen_rect; /* fake rect for fullscreen mode */ + drm_clip_rect_t fullscreen_rect; /* fake rect for fullscreen mode */ DRIWrappedFuncsRec wrap; DrawablePtr DRIDrawables[SAREA_MAX_DRAWABLES]; DRIContextPrivPtr dummyCtxPriv; /* Pointer to dummy context */ diff --git a/hw/xfree86/dri/sarea.h b/hw/xfree86/dri/sarea.h index d4d83df93..77c16e0ef 100644 --- a/hw/xfree86/dri/sarea.h +++ b/hw/xfree86/dri/sarea.h @@ -88,7 +88,7 @@ typedef struct _XF86DRISAREA { drmLock drawable_lock; XF86DRISAREADrawableRec drawableTable[SAREA_MAX_DRAWABLES]; XF86DRISAREAFrameRec frame; - drmContext dummy_context; + drm_context_t dummy_context; } XF86DRISAREARec, *XF86DRISAREAPtr; #endif diff --git a/hw/xfree86/dri/xf86dri.c b/hw/xfree86/dri/xf86dri.c index bc8a17ad2..ae5a6d608 100644 --- a/hw/xfree86/dri/xf86dri.c +++ b/hw/xfree86/dri/xf86dri.c @@ -35,8 +35,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ -#ifdef XFree86LOADER #include "xf86.h" +#ifdef XFree86LOADER #include "xf86_ansic.h" #endif @@ -54,6 +54,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define _XF86DRI_SERVER_ #include "xf86dristr.h" #include "swaprep.h" +#include "xf86str.h" #include "dri.h" #include "sarea.h" #include "dristruct.h" @@ -184,7 +185,7 @@ ProcXF86DRIOpenConnection( ) { xXF86DRIOpenConnectionReply rep; - drmHandle hSAREA; + drm_handle_t hSAREA; char* busIdString; REQUEST(xXF86DRIOpenConnectionReq); @@ -340,7 +341,7 @@ ProcXF86DRICreateContext( if (!DRICreateContext( pScreen, visual, stuff->context, - (drmContextPtr)&rep.hHWContext)) { + (drm_context_t *)&rep.hHWContext)) { return BadValue; } @@ -397,7 +398,7 @@ ProcXF86DRICreateDrawable( if (!DRICreateDrawable( screenInfo.screens[stuff->screen], (Drawable)stuff->drawable, pDrawable, - (drmDrawablePtr)&rep.hHWDrawable)) { + (drm_drawable_t *)&rep.hHWDrawable)) { return BadValue; } @@ -442,8 +443,8 @@ ProcXF86DRIGetDrawableInfo( xXF86DRIGetDrawableInfoReply rep; DrawablePtr pDrawable; int X, Y, W, H; - XF86DRIClipRectPtr pClipRects; - XF86DRIClipRectPtr pBackClipRects; + drm_clip_rect_t * pClipRects; + drm_clip_rect_t * pBackClipRects; int backX, backY; REQUEST(xXF86DRIGetDrawableInfoReq); @@ -492,10 +493,10 @@ ProcXF86DRIGetDrawableInfo( rep.backY = backY; if (rep.numBackClipRects) - rep.length += sizeof(XF86DRIClipRectRec) * rep.numBackClipRects; + rep.length += sizeof(drm_clip_rect_t) * rep.numBackClipRects; if (rep.numClipRects) - rep.length += sizeof(XF86DRIClipRectRec) * rep.numClipRects; + rep.length += sizeof(drm_clip_rect_t) * rep.numClipRects; rep.length = ((rep.length + 3) & ~3) >> 2; @@ -503,13 +504,13 @@ ProcXF86DRIGetDrawableInfo( if (rep.numClipRects) { WriteToClient(client, - sizeof(XF86DRIClipRectRec) * rep.numClipRects, + sizeof(drm_clip_rect_t) * rep.numClipRects, (char *)pClipRects); } if (rep.numBackClipRects) { WriteToClient(client, - sizeof(XF86DRIClipRectRec) * rep.numBackClipRects, + sizeof(drm_clip_rect_t) * rep.numBackClipRects, (char *)pBackClipRects); } @@ -522,7 +523,7 @@ ProcXF86DRIGetDeviceInfo( ) { xXF86DRIGetDeviceInfoReply rep; - drmHandle hFrameBuffer; + drm_handle_t hFrameBuffer; void *pDevPrivate; REQUEST(xXF86DRIGetDeviceInfoReq); diff --git a/hw/xfree86/fbdevhw/fbdevhw.c b/hw/xfree86/fbdevhw/fbdevhw.c index 0345aa41f..0ca3c93ef 100644 --- a/hw/xfree86/fbdevhw/fbdevhw.c +++ b/hw/xfree86/fbdevhw/fbdevhw.c @@ -14,7 +14,12 @@ #include "fbdevhw.h" #include "fbpriv.h" -#include "asm/page.h" /* #define for PAGE_* */ +#if 0 +/* kernel header doesn't work with -ansi */ +# include "asm/page.h" /* #define for PAGE_* */ +#else +# define PAGE_MASK (~(getpagesize() - 1)) +#endif #include "globals.h" #define DPMS_SERVER @@ -22,6 +27,8 @@ #define DEBUG 0 +#define PAGE_MASK (~(getpagesize() - 1)) + #if DEBUG # define TRACE_ENTER(str) ErrorF("fbdevHW: " str " %d\n",pScrn->scrnIndex) #else @@ -40,7 +47,7 @@ static XF86ModuleVersionInfo fbdevHWVersRec = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 0, 0, 2, ABI_CLASS_VIDEODRV, ABI_VIDEODRV_VERSION, @@ -724,7 +731,7 @@ fbdevHWLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, unsigned short red,green,blue; int i; - TRACE_ENTER("ModeInit"); + TRACE_ENTER("LoadPalette"); cmap.len = 1; cmap.red = &red; cmap.green = &green; @@ -789,7 +796,6 @@ fbdevHWAdjustFrame(int scrnIndex, int x, int y, int flags) fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); TRACE_ENTER("AdjustFrame"); - if ( x < 0 || x + fPtr->var.xres > fPtr->var.xres_virtual || y < 0 || y + fPtr->var.yres > fPtr->var.yres_virtual ) return; @@ -828,6 +834,7 @@ fbdevHWDPMSSet(ScrnInfoPtr pScrn, int mode, int flags) fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); unsigned long fbmode; + TRACE_ENTER("DPMSSet"); if (!pScrn->vtSema) return; @@ -860,6 +867,7 @@ fbdevHWSaveScreen(ScreenPtr pScreen, int mode) fbdevHWPtr fPtr = FBDEVHWPTR(pScrn); unsigned long unblank; + TRACE_ENTER("HWSaveScreen"); if (!pScrn->vtSema) return TRUE; @@ -873,3 +881,27 @@ fbdevHWSaveScreen(ScreenPtr pScreen, int mode) return TRUE; } + +xf86SwitchModeProc * +fbdevHWSwitchModeWeak(void) { return fbdevHWSwitchMode; } + +xf86AdjustFrameProc * +fbdevHWAdjustFrameWeak(void) { return fbdevHWAdjustFrame; } + +xf86EnterVTProc * +fbdevHWEnterVTWeak(void) { return fbdevHWEnterVT; } + +xf86LeaveVTProc * +fbdevHWLeaveVTWeak(void) { return fbdevHWLeaveVT; } + +xf86ValidModeProc * +fbdevHWValidModeWeak(void) { return fbdevHWValidMode; } + +xf86DPMSSetProc * +fbdevHWDPMSSetWeak(void) { return fbdevHWDPMSSet; } + +xf86LoadPaletteProc * +fbdevHWLoadPaletteWeak(void) { return fbdevHWLoadPalette; } + +SaveScreenProcPtr +fbdevHWSaveScreenWeak(void) { return fbdevHWSaveScreen; } diff --git a/hw/xfree86/fbdevhw/fbdevhw.h b/hw/xfree86/fbdevhw/fbdevhw.h index 219ca07d3..cfc3fcdb6 100644 --- a/hw/xfree86/fbdevhw/fbdevhw.h +++ b/hw/xfree86/fbdevhw/fbdevhw.h @@ -49,4 +49,13 @@ void fbdevHWDPMSSet(ScrnInfoPtr pScrn, int mode, int flags); Bool fbdevHWSaveScreen(ScreenPtr pScreen, int mode); +xf86SwitchModeProc *fbdevHWSwitchModeWeak(void); +xf86AdjustFrameProc *fbdevHWAdjustFrameWeak(void); +xf86EnterVTProc *fbdevHWEnterVTWeak(void); +xf86LeaveVTProc *fbdevHWLeaveVTWeak(void); +xf86ValidModeProc *fbdevHWValidModeWeak(void); +xf86DPMSSetProc *fbdevHWDPMSSetWeak(void); +xf86LoadPaletteProc *fbdevHWLoadPaletteWeak(void); +SaveScreenProcPtr fbdevHWSaveScreenWeak(void); + #endif diff --git a/hw/xfree86/fbdevhw/fbdevhwstub.c b/hw/xfree86/fbdevhw/fbdevhwstub.c index dc1169362..7869bb31d 100644 --- a/hw/xfree86/fbdevhw/fbdevhwstub.c +++ b/hw/xfree86/fbdevhw/fbdevhwstub.c @@ -168,3 +168,27 @@ fbdevHWSaveScreen(ScreenPtr pScreen, int mode) { return FALSE; } + +xf86SwitchModeProc * +fbdevHWSwitchModeWeak(void) { return fbdevHWSwitchMode; } + +xf86AdjustFrameProc * +fbdevHWAdjustFrameWeak(void) { return fbdevHWAdjustFrame; } + +xf86EnterVTProc * +fbdevHWEnterVTWeak(void) { return fbdevHWEnterVT; } + +xf86LeaveVTProc * +fbdevHWLeaveVTWeak(void) { return fbdevHWLeaveVT; } + +xf86ValidModeProc * +fbdevHWValidModeWeak(void) { return fbdevHWValidMode; } + +xf86DPMSSetProc * +fbdevHWDPMSSetWeak(void) { return fbdevHWDPMSSet; } + +xf86LoadPaletteProc * +fbdevHWLoadPaletteWeak(void) { return fbdevHWLoadPalette; } + +SaveScreenProcPtr +fbdevHWSaveScreenWeak(void) { return fbdevHWSaveScreen; } diff --git a/hw/xfree86/getconfig/cfg.sample b/hw/xfree86/getconfig/cfg.sample index 8e26fd2e3..93c98e4e2 100644 --- a/hw/xfree86/getconfig/cfg.sample +++ b/hw/xfree86/getconfig/cfg.sample @@ -1,4 +1,4 @@ -# $XdotOrg$ +# $DHD: xc/programs/Xserver/hw/xfree86/getconfig/cfg.sample,v 1.2 2003/09/23 05:12:07 dawes Exp $ # Some sample Xorg getconfig rules file. diff --git a/hw/xfree86/getconfig/getconfig b/hw/xfree86/getconfig/getconfig index a9e2b3ef2..531125a7f 100644 --- a/hw/xfree86/getconfig/getconfig +++ b/hw/xfree86/getconfig/getconfig @@ -1,6 +1,6 @@ #!/bin/sh -# $XdotOrg$ +# $XdotOrg: xc/programs/Xserver/hw/xfree86/getconfig/getconfig.sh,v 1.2 2004/04/23 19:54:01 eich Exp $ # # Copyright 2003 by David H. Dawes. diff --git a/hw/xfree86/getconfig/xorg.cfg b/hw/xfree86/getconfig/xorg.cfg index 848d5eb90..c164bf77c 100644 --- a/hw/xfree86/getconfig/xorg.cfg +++ b/hw/xfree86/getconfig/xorg.cfg @@ -1,4 +1,4 @@ -# $XdotOrg$ +# $XdotOrg: xc/programs/Xserver/hw/xfree86/getconfig/xorg.cfg,v 1.3 2004/05/25 20:33:46 alanc Exp $ # Base Xorg getconfig rules file. @@ -7,7 +7,7 @@ # first non-blank, non-comment line. # -Xorg Project getconfig rules file. Version: 1.0 +Xorg Foundation getconfig rules file. Version: 1.0 # # Set the weight for the following rules. This should be set, otherwise diff --git a/hw/xfree86/i2c/xf86i2c.c b/hw/xfree86/i2c/xf86i2c.c index 55a6cb059..77e3c2634 100644 --- a/hw/xfree86/i2c/xf86i2c.c +++ b/hw/xfree86/i2c/xf86i2c.c @@ -818,6 +818,7 @@ xf86I2CBusInit(I2CBusPtr b) if (b->I2CPutByte == NULL || b->I2CGetByte == NULL || b->I2CAddress == NULL || + b->I2CStart == NULL || b->I2CStop == NULL) return FALSE; } else { @@ -825,6 +826,7 @@ xf86I2CBusInit(I2CBusPtr b) b->I2CGetByte = I2CGetByte; b->I2CAddress = I2CAddress; b->I2CStop = I2CStop; + b->I2CStart = I2CStart; } } diff --git a/hw/xfree86/i2c/xf86i2c.h b/hw/xfree86/i2c/xf86i2c.h index b6ef41feb..099406e8f 100644 --- a/hw/xfree86/i2c/xf86i2c.h +++ b/hw/xfree86/i2c/xf86i2c.h @@ -27,6 +27,7 @@ typedef struct _I2CBusRec { /* Look at the generic routines to see how these functions should behave. */ + Bool (*I2CStart) (I2CBusPtr b, int timeout); Bool (*I2CAddress)(I2CDevPtr d, I2CSlaveAddr); void (*I2CStop) (I2CDevPtr d); Bool (*I2CPutByte)(I2CDevPtr d, I2CByte data); diff --git a/hw/xfree86/i2c/xf86i2cmodule.c b/hw/xfree86/i2c/xf86i2cmodule.c index 8f0c56f59..0058795f0 100644 --- a/hw/xfree86/i2c/xf86i2cmodule.c +++ b/hw/xfree86/i2c/xf86i2cmodule.c @@ -17,7 +17,7 @@ static XF86ModuleVersionInfo i2cVersRec = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 1, 2, 0, ABI_CLASS_VIDEODRV, /* This needs the video driver ABI */ ABI_VIDEODRV_VERSION, diff --git a/hw/xfree86/int10/xf86int10module.c b/hw/xfree86/int10/xf86int10module.c index 5857d23d2..2bb49cb0c 100644 --- a/hw/xfree86/int10/xf86int10module.c +++ b/hw/xfree86/int10/xf86int10module.c @@ -31,7 +31,7 @@ static XF86ModuleVersionInfo NAME(VersRec) = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 1, 0, 0, ABI_CLASS_VIDEODRV, /* needs the video driver ABI */ ABI_VIDEODRV_VERSION, diff --git a/hw/xfree86/loader/dixsym.c b/hw/xfree86/loader/dixsym.c index fda75b89d..96fed9bbc 100644 --- a/hw/xfree86/loader/dixsym.c +++ b/hw/xfree86/loader/dixsym.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/hw/xfree86/loader/dixsym.c,v 1.1.4.4.4.2 2004/03/04 17:48:07 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/loader/dixsym.c,v 1.5 2004/08/19 04:08:40 kem Exp $ */ /* $XFree86: xc/programs/Xserver/hw/xfree86/loader/dixsym.c,v 1.63 2003/12/03 * 17:11:29 tsi Exp $ */ @@ -81,6 +81,7 @@ #include "dgaproc.h" #ifdef RENDER #include "mipict.h" +#include "renderedge.h" #endif #include "selection.h" #ifdef XKB @@ -198,6 +199,7 @@ LOOKUP dixLookupTab[] = { SYMFUNC(VerifyRectOrder) SYMFUNC(SetDashes) /* globals.c */ +#ifdef DPMSExtension SYMVAR(DPMSEnabled) SYMVAR(DPMSCapableFlag) SYMVAR(DPMSOffTime) @@ -207,6 +209,7 @@ LOOKUP dixLookupTab[] = { SYMVAR(DPMSEnabledSwitch) SYMVAR(DPMSDisabledSwitch) SYMVAR(defaultDPMSEnabled) +#endif /* bigreq */ SYMVAR(maxBigRequestSize) #ifdef XV @@ -322,6 +325,16 @@ LOOKUP dixLookupTab[] = { SYMFUNC(AdjustWaitForDelay) SYMVAR(noTestExtensions) SYMFUNC(GiveUp) +#ifdef COMPOSITE + SYMVAR(noCompositeExtension) +#endif +#ifdef RENDER + SYMVAR(noRenderExtension) +#endif +#ifdef XEVIE + SYMVAR(noXevieExtension) +#endif + /* log.c */ SYMFUNC(LogVWrite) SYMFUNC(LogWrite) @@ -345,7 +358,9 @@ LOOKUP dixLookupTab[] = { SYMFUNC(TimerFree) SYMFUNC(TimerSet) SYMFUNC(TimerCancel) +#ifdef DPMSExtension SYMFUNC(SetDPMSTimers) +#endif /* io.c */ SYMFUNC(WriteToClient) SYMFUNC(SetCriticalOutputPending) @@ -400,6 +415,11 @@ LOOKUP dixLookupTab[] = { SYMFUNC(PictureSetFilterAlias) SYMFUNC(PictureGetSubpixelOrder) SYMFUNC(PictureSetSubpixelOrder) + SYMFUNC(RenderSampleCeilY) + SYMFUNC(RenderSampleFloorY) + SYMFUNC(RenderEdgeStep) + SYMFUNC(RenderEdgeInit) + SYMFUNC(RenderLineFixedEdgeInit) #endif {0, 0} diff --git a/hw/xfree86/loader/elfloader.c b/hw/xfree86/loader/elfloader.c index 933df1e61..98c51bb44 100644 --- a/hw/xfree86/loader/elfloader.c +++ b/hw/xfree86/loader/elfloader.c @@ -1,5 +1,6 @@ -/* $XdotOrg: xc/programs/Xserver/hw/xfree86/loader/elfloader.c,v 1.1.4.1.6.4 2004/03/18 02:18:27 alanc Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/loader/elfloader.c,v 1.2 2004/04/23 19:54:06 eich Exp $ */ /* $XFree86: xc/programs/Xserver/hw/xfree86/loader/elfloader.c,v 1.61tsi Exp $ */ + /* * * Copyright 1995-1998 by Metro Link, Inc. diff --git a/hw/xfree86/loader/extsym.c b/hw/xfree86/loader/extsym.c index bc51e2e0d..bbae6775f 100644 --- a/hw/xfree86/loader/extsym.c +++ b/hw/xfree86/loader/extsym.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/hw/xfree86/loader/extsym.c,v 1.1.4.3.2.1 2004/02/27 21:31:00 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/loader/extsym.c,v 1.4 2004/08/09 03:40:50 krh Exp $ */ /* $XFree86: xc/programs/Xserver/hw/xfree86/loader/extsym.c,v 1.9 2003/10/15 16:29:03 dawes Exp $ */ /* diff --git a/hw/xfree86/loader/hash.c b/hw/xfree86/loader/hash.c index f96bc55b2..559c0d8f3 100644 --- a/hw/xfree86/loader/hash.c +++ b/hw/xfree86/loader/hash.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/hw/xfree86/loader/hash.c,v 1.1.4.2.4.2 2004/03/04 20:16:43 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/loader/hash.c,v 1.2 2004/04/23 19:54:06 eich Exp $ */ /* $XFree86: xc/programs/Xserver/hw/xfree86/loader/hash.c,v 1.24 2003/11/17 22:20:40 dawes Exp $ */ /* diff --git a/hw/xfree86/loader/loader.c b/hw/xfree86/loader/loader.c index efa60f20a..14c9a320d 100644 --- a/hw/xfree86/loader/loader.c +++ b/hw/xfree86/loader/loader.c @@ -331,6 +331,13 @@ LoaderInit(void) { const char *osname = NULL; +#ifdef DLOPEN_SUPPORT + char *ld_bind_now = getenv("LD_BIND_NOW"); + if (ld_bind_now && *ld_bind_now) { + xf86Msg(X_ERROR, "LD_BIND_NOW is set, dlloader will NOT work!\n"); + } +#endif + LoaderAddSymbols(-1, -1, miLookupTab); LoaderAddSymbols(-1, -1, xfree86LookupTab); LoaderAddSymbols(-1, -1, dixLookupTab); diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c index 733f6feb1..4bf36a38a 100644 --- a/hw/xfree86/loader/loadmod.c +++ b/hw/xfree86/loader/loadmod.c @@ -86,7 +86,7 @@ static char *LoaderGetCanonicalName(const char *, PatternPtr); static void RemoveChild(ModuleDescPtr); ModuleVersions LoaderVersionInfo = { - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, ABI_ANSIC_VERSION, ABI_VIDEODRV_VERSION, ABI_XINPUT_VERSION, diff --git a/hw/xfree86/loader/misym.c b/hw/xfree86/loader/misym.c index 5f2e858e8..048f8996a 100644 --- a/hw/xfree86/loader/misym.c +++ b/hw/xfree86/loader/misym.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/hw/xfree86/loader/misym.c,v 1.1.4.2.4.1 2004/02/27 21:31:00 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/loader/misym.c,v 1.2 2004/04/23 19:54:06 eich Exp $ */ /* $XFree86: xc/programs/Xserver/hw/xfree86/loader/misym.c,v 1.38 2003/10/15 16:29:04 dawes Exp $ */ /* diff --git a/hw/xfree86/loader/xf86sym.c b/hw/xfree86/loader/xf86sym.c index b2823c2e5..a622b505e 100644 --- a/hw/xfree86/loader/xf86sym.c +++ b/hw/xfree86/loader/xf86sym.c @@ -75,7 +75,9 @@ #include "xf86cmap.h" #include "xf86fbman.h" #include "dgaproc.h" +#ifdef DPMSExtension #include "dpmsproc.h" +#endif #include "vidmodeproc.h" #include "xf86miscproc.h" #include "loader.h" @@ -233,6 +235,12 @@ extern unsigned long ldl_brx(volatile unsigned char *, int); extern unsigned short ldw_brx(volatile unsigned char *, int); #endif +#ifdef __SSP__ +/* Propolice! */ +extern long __guard[]; +extern void __stack_smash_handler(char [], int); +#endif + /* XFree86 things */ LOOKUP xfree86LookupTab[] = { @@ -695,9 +703,11 @@ LOOKUP xfree86LookupTab[] = { SYMFUNC(xf86XInputSetSendCoreEvents) /* End merged segment */ #endif +#ifdef DPMSExtension SYMFUNC(DPMSGet) SYMFUNC(DPMSSet) SYMFUNC(DPMSSupported) +#endif /* xf86Debug.c */ #ifdef BUILDDEBUG SYMFUNC(xf86Break1) @@ -1045,27 +1055,39 @@ LOOKUP xfree86LookupTab[] = { # endif #endif #if defined(__GNUC__) -#ifndef __UNIXOS2__ +#if !defined(__UNIXOS2__) && !defined(Lynx) SYMFUNC(__div64) #endif +#if !defined(Lynx) /* FIXME: test on others than x86 and !3.1.0a/x86 */ SYMFUNC(__divdf3) +#endif SYMFUNC(__divdi3) +#if !defined(Lynx) SYMFUNC(__divsf3) SYMFUNC(__divsi3) +#endif SYMFUNC(__moddi3) +#if !defined(Lynx) SYMFUNC(__modsi3) -#ifndef __UNIXOS2__ +#endif +#if !defined(__UNIXOS2__) && !defined(Lynx) SYMFUNC(__mul64) #endif +#if !defined(Lynx) SYMFUNC(__muldf3) +#endif SYMFUNC(__muldi3) +#if !defined(Lynx) SYMFUNC(__mulsf3) SYMFUNC(__mulsi3) SYMFUNC(__udivdi3) SYMFUNC(__udivsi3) +#endif SYMFUNC(__umoddi3) +#if !defined(Lynx) SYMFUNC(__umodsi3) #endif +#endif #if defined(__ia64__) SYMFUNC(_outw) SYMFUNC(_outb) @@ -1093,6 +1115,12 @@ LOOKUP xfree86LookupTab[] = { #endif #endif +#ifdef __SSP__ + /* propolice */ + SYMFUNC(__stack_smash_handler) + SYMVAR(__guard) +#endif + /* Some variables. */ SYMVAR(xf86stdin) diff --git a/hw/xfree86/os-support/bsd/bsd_mouse.c b/hw/xfree86/os-support/bsd/bsd_mouse.c index bb5936a1e..679f3099a 100644 --- a/hw/xfree86/os-support/bsd/bsd_mouse.c +++ b/hw/xfree86/os-support/bsd/bsd_mouse.c @@ -430,6 +430,7 @@ wsconsReadInput(InputInfoPtr pInfo) default: xf86Msg(X_WARNING, "%s: bad wsmouse event type=%d\n", pInfo->name, event->type); + ++event; continue; } @@ -472,6 +473,7 @@ wsconsPreInit(InputInfoPtr pInfo, const char *protocol, int flags) /* Setup the local input proc. */ pInfo->read_input = wsconsReadInput; + pMse->xisbscale = sizeof(struct wscons_event); pInfo->flags |= XI86_CONFIGURED; return TRUE; diff --git a/hw/xfree86/os-support/bsd/i386_video.c b/hw/xfree86/os-support/bsd/i386_video.c index 3c55ee72f..62d063655 100644 --- a/hw/xfree86/os-support/bsd/i386_video.c +++ b/hw/xfree86/os-support/bsd/i386_video.c @@ -46,6 +46,11 @@ #include <sys/queue.h> #endif +#if defined(__OpenBSD__) && defined(__amd64__) +#include <machine/mtrr.h> +#include <machine/sysarch.h> +#endif + #include "xf86_OSlib.h" #include "xf86OSpriv.h" @@ -94,7 +99,11 @@ static pointer NetBSDsetWC(int, unsigned long, unsigned long, Bool, MessageType); static void NetBSDundoWC(int, pointer); #endif - +#if defined(__amd64__) && defined(__OpenBSD__) +static pointer amd64setWC(int, unsigned long, unsigned long, Bool, + MessageType); +static void amd64undoWC(int, pointer); +#endif /* * Check if /dev/mem can be mmap'd. If it can't print a warning when @@ -206,6 +215,10 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem) pVidMem->setWC = NetBSDsetWC; pVidMem->undoWC = NetBSDundoWC; #endif +#if defined(__amd64__) && defined(__OpenBSD__) + pVidMem->setWC = amd64setWC; + pVidMem->undoWC = amd64undoWC; +#endif pVidMem->initialised = TRUE; } @@ -311,7 +324,6 @@ xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, return(Len); } - #ifdef USE_I386_IOPL /***************************************************************************/ /* I/O Permissions section */ @@ -354,6 +366,51 @@ xf86DisableIO() #endif /* USE_I386_IOPL */ +#ifdef USE_AMD64_IOPL +/***************************************************************************/ +/* I/O Permissions section */ +/***************************************************************************/ + +static Bool ExtendedEnabled = FALSE; + +void +xf86EnableIO() +{ + if (ExtendedEnabled) + return; + + if (amd64_iopl(TRUE) < 0) + { +#ifndef __OpenBSD__ + FatalError("%s: Failed to set IOPL for extended I/O", + "xf86EnableIO"); +#else + FatalError("%s: Failed to set IOPL for extended I/O\n%s", + "xf86EnableIO", SYSCTL_MSG); +#endif + } + ExtendedEnabled = TRUE; + + return; +} + +void +xf86DisableIO() +{ + if (!ExtendedEnabled) + return; + + if (amd64_iopl(FALSE) == 0) { + ExtendedEnabled = FALSE; + } + /* Otherwise, the X server has revoqued its root uid, + and thus cannot give up IO privileges any more */ + + return; +} + +#endif /* USE_AMD64_IOPL */ + #ifdef USE_DEV_IO static int IoFd = -1; @@ -471,7 +528,6 @@ xf86SetRGBOut() } #endif - #ifdef HAS_MTRR_SUPPORT /* memory range (MTRR) support for FreeBSD */ @@ -879,3 +935,55 @@ NetBSDundoWC(int screenNum, pointer list) xfree(mtrrp); } #endif + +#if defined(__OpenBSD__) && defined(__amd64__) +static pointer +amd64setWC(int screenNum, unsigned long base, unsigned long size, Bool enable, + MessageType from) +{ + struct mtrr *mtrrp; + int n; + + xf86DrvMsg(screenNum, X_WARNING, + "%s MTRR %lx - %lx\n", enable ? "set" : "remove", + base, (base + size)); + + mtrrp = xnfalloc(sizeof (struct mtrr)); + mtrrp->base = base; + mtrrp->len = size; + mtrrp->type = MTRR_TYPE_WC; + + /* + * MTRR_PRIVATE will make this MTRR get reset automatically + * if this process exits, so we have no need for an explicit + * cleanup operation when starting a new server. + */ + + if (enable) + mtrrp->flags = MTRR_VALID | MTRR_PRIVATE; + else + mtrrp->flags = 0; + n = 1; + + if (amd64_set_mtrr(mtrrp, &n) < 0) { + xfree(mtrrp); + return NULL; + } + return mtrrp; +} + +static void +amd64undoWC(int screenNum, pointer list) +{ + struct mtrr *mtrrp = (struct mtrr *)list; + int n; + + if (mtrrp == NULL) + return; + n = 1; + mtrrp->flags &= ~MTRR_VALID; + amd64_set_mtrr(mtrrp, &n); + xfree(mtrrp); +} +#endif /* OpenBSD/amd64 */ + diff --git a/hw/xfree86/os-support/bus/Pci.c b/hw/xfree86/os-support/bus/Pci.c index 6b36fdaf2..ffa906505 100644 --- a/hw/xfree86/os-support/bus/Pci.c +++ b/hw/xfree86/os-support/bus/Pci.c @@ -1203,7 +1203,8 @@ handlePciBIOS(PCITAG Tag, int basereg, if ((xf86ReadDomainMemory(Tag, hostbase, sizeof(tmp), tmp) != sizeof(tmp)) || (tmp[0] != 0x55) || (tmp[1] != 0xaa) || !tmp[2] ) { - /* Restore the base register if it was changed. */ + /* Restore the base registers if they were changed. */ + pciWriteLong(Tag, PCI_MAP_ROM_REG, romsave); if (savebase) pciWriteLong(Tag, PCI_MAP_REG_START + (b_reg << 2), (CARD32) savebase); diff --git a/hw/xfree86/os-support/bus/Pci.h b/hw/xfree86/os-support/bus/Pci.h index b0c767d5c..3e965265b 100644 --- a/hw/xfree86/os-support/bus/Pci.h +++ b/hw/xfree86/os-support/bus/Pci.h @@ -112,7 +112,7 @@ /* * Global Definitions */ -#define MAX_PCI_DEVICES 64 /* Max number of devices accomodated */ +#define MAX_PCI_DEVICES 128 /* Max number of devices accomodated */ /* by xf86scanpci */ #if defined(sun) && defined(SVR4) && defined(sparc) # define MAX_PCI_BUSES 4096 /* Max number of PCI buses */ @@ -280,7 +280,7 @@ # define INCLUDE_XF86_MAP_PCI_MEM # define INCLUDE_XF86_NO_DOMAIN # endif -#elif defined(__powerpc__) +#elif defined(__powerpc__) || defined(__powerpc64__) # if defined(linux) # define ARCH_PCI_INIT linuxPciInit # define INCLUDE_XF86_MAP_PCI_MEM @@ -312,7 +312,7 @@ # define INCLUDE_XF86_MAP_PCI_MEM # define INCLUDE_XF86_NO_DOMAIN # endif -#elif defined(__sparc__) +#elif defined(__sparc__) || defined(sparc) # if defined(linux) # define ARCH_PCI_INIT linuxPciInit # define INCLUDE_XF86_MAP_PCI_MEM diff --git a/hw/xfree86/os-support/bus/ix86Pci.c b/hw/xfree86/os-support/bus/ix86Pci.c index b135d0b73..da1aa7d2f 100644 --- a/hw/xfree86/os-support/bus/ix86Pci.c +++ b/hw/xfree86/os-support/bus/ix86Pci.c @@ -272,10 +272,16 @@ void ix86PciSelectCfgmech(void) */ switch (xf86Info.pciFlags) { - case PCIProbe1: /* { */ + case PCIOsConfig: +#if ARCH_PCI_OS_INIT + return; +#endif + + case PCIProbe1: - xf86MsgVerb(X_INFO, 2, "PCI: Probing config type using method 1\n"); - oldVal1 = inl(PCI_CFGMECH1_ADDRESS_REG); + xf86MsgVerb(X_INFO, 2, + "PCI: Probing config type using method 1\n"); + oldVal1 = inl(PCI_CFGMECH1_ADDRESS_REG); #ifdef DEBUGPCI if (xf86Verbose > 2) { @@ -492,9 +498,6 @@ void ix86PciSelectCfgmech(void) ix86Pci0.funcs = &ix86Funcs2; return; - case PCIOsConfig: - return; - case PCIForceNone: break; } diff --git a/hw/xfree86/os-support/bus/linuxPci.c b/hw/xfree86/os-support/bus/linuxPci.c index 4846ee0ed..6e33c2550 100644 --- a/hw/xfree86/os-support/bus/linuxPci.c +++ b/hw/xfree86/os-support/bus/linuxPci.c @@ -104,6 +104,7 @@ linuxPciOpenFile(PCITAG tag) static int lbus,ldev,lfunc,fd = -1; int bus, dev, func; char file[32]; + struct stat ignored; bus = PCI_BUS_FROM_TAG(tag); dev = PCI_DEV_FROM_TAG(tag); @@ -111,12 +112,21 @@ linuxPciOpenFile(PCITAG tag) if (fd == -1 || bus != lbus || dev != ldev || func != lfunc) { if (fd != -1) close(fd); - if (bus < 256) - sprintf(file, "/proc/bus/pci/%02x/%02x.%1x", - bus, dev, func); - else - sprintf(file, "/proc/bus/pci/%04x/%02x.%1x", - bus, dev, func); + if (bus < 256) { + if (stat("/proc/bus/pci/00", &ignored) < 0) + sprintf(file, "/proc/bus/pci/0000:%02x/%02x.%1x", + bus, dev, func); + else + sprintf(file, "/proc/bus/pci/%02x/%02x.%1x", + bus, dev, func); + } else { + if (stat("/proc/bus/pci/00", &ignored) < 0) + sprintf(file, "/proc/bus/pci/0000:%04x/%02x.%1x", + bus, dev, func); + else + sprintf(file, "/proc/bus/pci/%04x/%02x.%1x", + bus, dev, func); + } fd = open(file,O_RDWR); lbus = bus; ldev = dev; diff --git a/hw/xfree86/os-support/drm/drmmodule.c b/hw/xfree86/os-support/drm/drmmodule.c index 8192e97eb..2fb082c36 100644 --- a/hw/xfree86/os-support/drm/drmmodule.c +++ b/hw/xfree86/os-support/drm/drmmodule.c @@ -39,7 +39,7 @@ static XF86ModuleVersionInfo VersRec = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 1, 0, 0, ABI_CLASS_EXTENSION, ABI_EXTENSION_VERSION, diff --git a/hw/xfree86/os-support/linux/int10/linux.c b/hw/xfree86/os-support/linux/int10/linux.c index 984c79122..b01004931 100644 --- a/hw/xfree86/os-support/linux/int10/linux.c +++ b/hw/xfree86/os-support/linux/int10/linux.c @@ -172,6 +172,9 @@ xf86ExtendedInitInt10(int entityIndex, int Flags) if (errno == ENOSYS) xf86DrvMsg(screen, X_ERROR, "shmget error\n Please reconfigure" " your kernel to include System V IPC support\n"); + else + xf86DrvMsg(screen, X_ERROR, + "shmget(highmem) error: %s\n",strerror(errno)); goto error1; } } else { @@ -198,16 +201,27 @@ xf86ExtendedInitInt10(int entityIndex, int Flags) ErrorF("Mapping 640kB area\n"); #endif if ((low_mem = shmget(counter++, V_RAM, - IPC_CREAT | SHM_R | SHM_W)) == -1) + IPC_CREAT | SHM_R | SHM_W)) == -1) { + xf86DrvMsg(screen, X_ERROR, + "shmget(lowmem) error: %s\n",strerror(errno)); goto error2; + } ((linuxInt10Priv*)pInt->private)->lowMem = low_mem; base = shmat(low_mem, 0, 0); - if (base == SHMERRORPTR) goto error4; + if (base == SHMERRORPTR) { + xf86DrvMsg(screen, X_ERROR, + "shmat(low_mem) error: %s\n",strerror(errno)); + goto error3; + } ((linuxInt10Priv *)pInt->private)->base = base; if (high_mem > -1) { base_high = shmat(high_mem, 0, 0); - if (base_high == SHMERRORPTR) goto error4; + if (base_high == SHMERRORPTR) { + xf86DrvMsg(screen, X_ERROR, + "shmat(high_mem) error: %s\n",strerror(errno)); + goto error3; + } ((linuxInt10Priv*)pInt->private)->base_high = base_high; } else ((linuxInt10Priv*)pInt->private)->base_high = NULL; @@ -388,8 +402,6 @@ xf86ExtendedInitInt10(int entityIndex, int Flags) xfree(options); return pInt; -error4: - xf86DrvMsg(screen, X_ERROR, "shmat() call returned errno %d\n", errno); error3: if (base_high) shmdt(base_high); @@ -429,6 +441,8 @@ MapCurrentInt10(xf86Int10InfoPtr pInt) addr = shmat(((linuxInt10Priv*)pInt->private)->lowMem, (char*)1, SHM_RND); if (addr == SHMERRORPTR) { xf86DrvMsg(pInt->scrnIndex, X_ERROR, "Cannot shmat() low memory\n"); + xf86DrvMsg(pInt->scrnIndex, X_ERROR, + "shmat(low_mem) error: %s\n",strerror(errno)); return FALSE; } @@ -438,6 +452,8 @@ MapCurrentInt10(xf86Int10InfoPtr pInt) if (addr == SHMERRORPTR) { xf86DrvMsg(pInt->scrnIndex, X_ERROR, "Cannot shmat() high memory\n"); + xf86DrvMsg(pInt->scrnIndex, X_ERROR, + "shmget error: %s\n",strerror(errno)); return FALSE; } } else { diff --git a/hw/xfree86/os-support/linux/lnx_ia64.c b/hw/xfree86/os-support/linux/lnx_ia64.c new file mode 100644 index 000000000..8d0976a36 --- /dev/null +++ b/hw/xfree86/os-support/linux/lnx_ia64.c @@ -0,0 +1,45 @@ +/* + * Copyright 2004, Egbert Eich + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * EGBERT EICH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON- + * NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of Egbert Eich shall not + * be used in advertising or otherwise to promote the sale, use or other deal- + *ings in this Software without prior written authorization from Egbert Eich. + * + */ + +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> + +#include "ia64Pci.h" +#include "Pci.h" + +#if defined OS_PROBE_PCI_CHIPSET +IA64Chipset OS_PROBE_PCI_CHIPSET(scanpciWrapperOpt flags) +{ + struct stat unused; + + if (!stat("/proc/bus/mckinley/zx1",&unused) + || !stat("/proc/bus/mckinley/zx2",&unused)) + return ZX1_CHIPSET; + + return NONE_CHIPSET; +} +#endif diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c index 5564f5ab9..da7c0a043 100644 --- a/hw/xfree86/os-support/linux/lnx_init.c +++ b/hw/xfree86/os-support/linux/lnx_init.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c,v 1.1.4.2.4.2 2004/03/04 20:16:46 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c,v 1.2 2004/04/23 19:54:08 eich Exp $ */ /* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c,v 3.14 2001/10/31 22:50:30 tsi Exp $ */ /* * Copyright 1992 by Orest Zborowski <obz@Kodak.com> diff --git a/hw/xfree86/os-support/linux/lnx_io.c b/hw/xfree86/os-support/linux/lnx_io.c index 89afc8d64..dda1ff8ef 100644 --- a/hw/xfree86/os-support/linux/lnx_io.c +++ b/hw/xfree86/os-support/linux/lnx_io.c @@ -1,5 +1,4 @@ /* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c,v 3.25 2003/08/19 17:32:34 tsi Exp $ */ -/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c,v 1.1.4.2.6.2 2004/03/04 17:48:09 eich Exp $ */ /* * Copyright 1992 by Orest Zborowski <obz@Kodak.com> * Copyright 1993 by David Dawes <dawes@xfree86.org> diff --git a/hw/xfree86/os-support/linux/lnx_kbd.c b/hw/xfree86/os-support/linux/lnx_kbd.c index ab75fce09..68f3af38b 100644 --- a/hw/xfree86/os-support/linux/lnx_kbd.c +++ b/hw/xfree86/os-support/linux/lnx_kbd.c @@ -1,5 +1,4 @@ /* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_kbd.c,v 1.4 2003/11/03 05:11:52 tsi Exp $ */ -/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_kbd.c,v 1.1.4.1.6.2 2004/03/04 17:48:09 eich Exp $ */ /* * Copyright (c) 2002 by The XFree86 Project, Inc. diff --git a/hw/xfree86/os-support/linux/lnx_video.c b/hw/xfree86/os-support/linux/lnx_video.c index 5144cdf3e..4cd8152df 100644 --- a/hw/xfree86/os-support/linux/lnx_video.c +++ b/hw/xfree86/os-support/linux/lnx_video.c @@ -450,7 +450,7 @@ mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) /* This requires linux-0.99.pl10 or above */ base = mmap((caddr_t)0, Size + alignOff, prot, mapflags, fd, - (off_t)(off_t)realBase + BUS_BASE); + (off_t)realBase + BUS_BASE); close(fd); if (base == MAP_FAILED) { FatalError("xf86MapVidMem: Could not mmap framebuffer" diff --git a/hw/xfree86/os-support/shared/ia64Pci.c b/hw/xfree86/os-support/shared/ia64Pci.c new file mode 100644 index 000000000..d0046a7f2 --- /dev/null +++ b/hw/xfree86/os-support/shared/ia64Pci.c @@ -0,0 +1,81 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/ia64Pci.c,v 1.3 2003/02/23 20:26:49 tsi Exp $ */ +/* + * Copyright (C) 2002-2003 The XFree86 Project, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the XFree86 Project shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from the + * XFree86 Project. + */ + +/* + * This file contains the glue needed to support various IA-64 chipsets. + */ + +#include "460gxPCI.h" +#include "e8870PCI.h" +#include "zx1PCI.h" +#include "Pci.h" +#include "ia64Pci.h" + +void +ia64ScanPCIWrapper(scanpciWrapperOpt flags) +{ + static IA64Chipset chipset = NONE_CHIPSET; + + if (flags == SCANPCI_INIT) { + + /* PCI configuration space probes should be done first */ + if (xorgProbe460GX(flags)) { + chipset = I460GX_CHIPSET; + xf86PreScan460GX(); + return; + } else if (xorgProbeE8870(flags)) { + chipset = E8870_CHIPSET; + xf86PreScanE8870(); + return; + } +#ifdef OS_PROBE_PCI_CHIPSET + chipset = OS_PROBE_PCI_CHIPSET(flags); + switch (chipset) { + case ZX1_CHIPSET: + xf86PreScanZX1(); + return; + default: + return; + } +#endif + } else /* if (flags == SCANPCI_TERM) */ { + + switch (chipset) { + case I460GX_CHIPSET: + xf86PostScan460GX(); + return; + case E8870_CHIPSET: + xf86PostScanE8870(); + return; + case ZX1_CHIPSET: + xf86PostScanZX1(); + return; + default: + return; + } + } +} diff --git a/hw/xfree86/os-support/shared/ia64Pci.h b/hw/xfree86/os-support/shared/ia64Pci.h new file mode 100644 index 000000000..1ee2fc091 --- /dev/null +++ b/hw/xfree86/os-support/shared/ia64Pci.h @@ -0,0 +1,41 @@ +/* + * Copyright 2004, Egbert Eich + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * EGBERT EICH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON- + * NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of Egbert Eich shall not + * be used in advertising or otherwise to promote the sale, use or other deal- + *ings in this Software without prior written authorization from Egbert Eich. + * + */ +#ifndef _IA64_PCI_H +# define _IA64_PCI_H + +#include "Pci.h" + +typedef enum { + NONE_CHIPSET, + I460GX_CHIPSET, + E8870_CHIPSET, + ZX1_CHIPSET +} IA64Chipset; + +# ifdef OS_PROBE_PCI_CHIPSET +extern IA64Chipset OS_PROBE_PCI_CHIPSET(scanpciWrapperOpt flags); +# endif +#endif diff --git a/hw/xfree86/os-support/shared/libc_wrapper.c b/hw/xfree86/os-support/shared/libc_wrapper.c index 34f375f6c..59c08d85a 100644 --- a/hw/xfree86/os-support/shared/libc_wrapper.c +++ b/hw/xfree86/os-support/shared/libc_wrapper.c @@ -1884,7 +1884,8 @@ int xf86shmget(xf86key_t key, int size, int xf86shmflg) { int shmflg; - + int ret; + /* This copies the permissions (SHM_R, SHM_W for u, g, o). */ shmflg = xf86shmflg & 0777; @@ -1893,14 +1894,20 @@ xf86shmget(xf86key_t key, int size, int xf86shmflg) if (xf86shmflg & XF86IPC_CREAT) shmflg |= IPC_CREAT; if (xf86shmflg & XF86IPC_EXCL) shmflg |= IPC_EXCL; if (xf86shmflg & XF86IPC_NOWAIT) shmflg |= IPC_NOWAIT; - return shmget((key_t) key, size, shmflg); + ret = shmget((key_t) key, size, shmflg); + + if (ret == -1) + xf86errno = xf86GetErrno(); + + return ret; } char * xf86shmat(int id, char *addr, int xf86shmflg) { int shmflg = 0; - + pointer ret; + #ifdef SHM_RDONLY if (xf86shmflg & XF86SHM_RDONLY) shmflg |= SHM_RDONLY; #endif @@ -1911,13 +1918,25 @@ xf86shmat(int id, char *addr, int xf86shmflg) if (xf86shmflg & XF86SHM_REMAP) shmflg |= SHM_REMAP; #endif - return shmat(id,addr,shmflg); + ret = shmat(id,addr,shmflg); + + if (ret == (pointer) -1) + xf86errno = xf86GetErrno(); + + return ret; } int xf86shmdt(char *addr) { - return shmdt(addr); + int ret; + + ret = shmdt(addr); + + if (ret == -1) + xf86errno = xf86GetErrno(); + + return ret; } /* @@ -1927,7 +1946,8 @@ int xf86shmctl(int id, int xf86cmd, pointer buf) { int cmd; - + int ret; + switch (xf86cmd) { case XF86IPC_RMID: cmd = IPC_RMID; @@ -1936,32 +1956,44 @@ xf86shmctl(int id, int xf86cmd, pointer buf) return 0; } - return shmctl(id, cmd, buf); + ret = shmctl(id, cmd, buf); + + if (ret == -1) + xf86errno = xf86GetErrno(); + + return ret; } #else int xf86shmget(xf86key_t key, int size, int xf86shmflg) { - return -1; + xf86errno = ENOSYS; + return -1; } char * xf86shmat(int id, char *addr, int xf86shmflg) { + xf86errno = ENOSYS; + return (char *)-1; } int xf86shmctl(int id, int xf86cmd, pointer buf) { + xf86errno = ENOSYS; + return -1; } int xf86shmdt(char *addr) { + xf86errno = ENOSYS; + return -1; } #endif /* HAVE_SYSV_IPC */ diff --git a/hw/xfree86/os-support/shared/sigio.c b/hw/xfree86/os-support/shared/sigio.c index fbab2a517..7bcb93a0b 100644 --- a/hw/xfree86/os-support/shared/sigio.c +++ b/hw/xfree86/os-support/shared/sigio.c @@ -259,17 +259,25 @@ int xf86BlockSIGIO (void) { sigset_t set, old; - + int ret; + sigemptyset (&set); sigaddset (&set, SIGIO); sigprocmask (SIG_BLOCK, &set, &old); - return sigismember (&old, SIGIO); + ret = sigismember (&old, SIGIO); +#ifdef DEBUG + ErrorF("%i = xf86BlockSIGIO()\n",ret); +#endif + return ret; } void xf86UnblockSIGIO (int wasset) { sigset_t set; +#ifdef DEBUG + ErrorF("xf86UnblockSIGIO(%i)\n",wasset); +#endif if (!wasset) { diff --git a/hw/xfree86/os-support/shared/sigiostubs.c b/hw/xfree86/os-support/shared/sigiostubs.c index 51f98f2a4..5e08d4fbe 100644 --- a/hw/xfree86/os-support/shared/sigiostubs.c +++ b/hw/xfree86/os-support/shared/sigiostubs.c @@ -25,6 +25,7 @@ * the sale, use or other dealings in this Software without prior written * authorization from the copyright holder(s) and author(s). */ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/shared/sigiostubs.c,v 1.2 2004/06/28 18:08:26 alanc Exp $ */ #ifdef XFree86Server #ifdef __UNIXOS2__ @@ -32,10 +33,8 @@ #endif # include "X.h" # include "xf86.h" -# include "xf86drm.h" # include "xf86Priv.h" # include "xf86_OSlib.h" -# include "xf86drm.h" #else # include <unistd.h> # include <signal.h> diff --git a/hw/xfree86/os-support/solaris/sun_init.c b/hw/xfree86/os-support/solaris/sun_init.c index fe8205e13..c7382e0e1 100644 --- a/hw/xfree86/os-support/solaris/sun_init.c +++ b/hw/xfree86/os-support/solaris/sun_init.c @@ -26,6 +26,9 @@ #include "xf86.h" #include "xf86Priv.h" #include "xf86_OSlib.h" +#ifdef __i386 +# include <sys/kd.h> +#endif static Bool KeepTty = FALSE; static Bool Protect0 = FALSE; @@ -34,7 +37,11 @@ static int VTnum = -1; static int xf86StartVT = -1; #endif +#if defined(__SOL8__) || !defined(__i386) +static char fb_dev[PATH_MAX] = "/dev/fb"; +#else static char fb_dev[PATH_MAX] = "/dev/console"; +#endif void xf86OpenConsole(void) @@ -162,12 +169,15 @@ xf86OpenConsole(void) if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0) FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n"); - +#endif +#ifdef __i386 if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed\n"); +#endif } else /* serverGeneration != 1 */ { +#ifdef HAS_USL_VTS /* * Now re-get the VT */ @@ -245,6 +255,11 @@ xf86CloseConsole(void) #endif +#ifdef __i386 + /* Reset the display back to text mode */ + ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); +#endif + #ifdef HAS_USL_VTS /* @@ -261,8 +276,6 @@ xf86CloseConsole(void) * Did the whole thing similarly to the way linux does it */ - /* Reset the display back to text mode */ - ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1) { VT.mode = VT_AUTO; /* Set default vt handling */ diff --git a/hw/xfree86/os-support/solaris/sun_kbd.c b/hw/xfree86/os-support/solaris/sun_kbd.c index 0213a0732..56929d69b 100644 --- a/hw/xfree86/os-support/solaris/sun_kbd.c +++ b/hw/xfree86/os-support/solaris/sun_kbd.c @@ -23,7 +23,9 @@ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbd.c,v 1.3 2004/06/13 04:50:21 alanc Exp $ */ +#include "xf86.h" #include "xf86Priv.h" #include "xf86_OSlib.h" @@ -55,6 +57,7 @@ void xf86KbdInit() { int klayout; + const char *ktype_name; if (xf86Info.kbdFd < 0) { xf86Info.kbdFd = open("/dev/kbd", O_RDWR|O_NONBLOCK); @@ -63,7 +66,7 @@ xf86KbdInit() } /* - * None of the followin should ever fail. If it does, something is + * None of the following should ever fail. If it does, something is * broken (IMO) - DWH 8/21/99 */ @@ -78,6 +81,21 @@ xf86KbdInit() if (ioctl(xf86Info.kbdFd, KIOCGDIRECT, &sun_odirect) < 0) FatalError("Unable to determine keyboard direct setting\n"); + + switch (sun_ktype) { + case KB_SUN3: + ktype_name = "Sun Type 3"; break; + case KB_SUN4: + ktype_name = "Sun Type 4/5/6"; break; + case KB_USB: + ktype_name = "USB"; break; + case KB_PC: + ktype_name = "PC"; break; + default: + ktype_name = "Unknown"; break; + } + xf86Msg(X_PROBED, "Keyboard type: %s (%d)\n", ktype_name, sun_ktype); + xf86Msg(X_PROBED, "Keyboard layout: %d\n", klayout); } int diff --git a/hw/xfree86/os-support/solaris/sun_kbdEv.c b/hw/xfree86/os-support/solaris/sun_kbdEv.c index 30cf288ca..c8626a285 100644 --- a/hw/xfree86/os-support/solaris/sun_kbdEv.c +++ b/hw/xfree86/os-support/solaris/sun_kbdEv.c @@ -23,6 +23,7 @@ */ /* [JCH-96/01/21] Extended std reverse map to four buttons. */ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbdEv.c,v 1.3 2004/07/28 03:57:19 alanc Exp $ */ #include "xf86.h" #include "xf86Priv.h" @@ -107,6 +108,11 @@ static OsTimerPtr sunTimer = NULL; * This doesn't seem right. It probably needs to be dependent on a keyboard * type. */ + +/* Additional Sun Japanese Keyboard Keys not defined in common/atKeynames.h */ +#define KEY_Kanji 0x82 +#define KEY_Execute 0x83 + static unsigned char map[256] = { #if defined(i386) || defined(__i386) || defined(__i386__) KEY_NOTUSED, /* 0 */ @@ -519,11 +525,11 @@ static unsigned char usbmap[256] = { /* 132 */ KEY_NOTUSED, /* 133 */ KEY_NOTUSED, /* 134 */ KEY_NOTUSED, - /* 135 */ KEY_NOTUSED, - /* 136 */ KEY_NOTUSED, - /* 137 */ KEY_NOTUSED, - /* 138 */ KEY_NOTUSED, - /* 139 */ KEY_NOTUSED, + /* 135 */ KEY_BSlash2, /* Sun Japanese Kbd: Backslash / Underscore */ + /* 136 */ KEY_XFER, /* Sun Japanese Kbd: Henkan Mode */ + /* 137 */ KEY_Yen, /* Sun Japanese Kbd: Yen / Brokenbar */ + /* 138 */ KEY_Kanji, /* Sun Japanese Kbd: Kanji */ + /* 139 */ KEY_Execute, /* Sun Japanese Kbd: Execute */ /* 140 */ KEY_NOTUSED, /* 141 */ KEY_NOTUSED, /* 142 */ KEY_NOTUSED, diff --git a/hw/xfree86/os-support/solaris/sun_mouse.c b/hw/xfree86/os-support/solaris/sun_mouse.c index 2e9cee2b1..4cbd1cd5e 100644 --- a/hw/xfree86/os-support/solaris/sun_mouse.c +++ b/hw/xfree86/os-support/solaris/sun_mouse.c @@ -1,4 +1,5 @@ /* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_mouse.c,v 1.4 2002/01/25 21:56:21 tsi Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_mouse.c,v 1.2 2004/04/23 19:54:13 eich Exp $ */ /* * Copyright 1999-2001 The XFree86 Project, Inc. All Rights Reserved. * @@ -24,16 +25,53 @@ * dealings in this Software without prior written authorization from the * XFree86 Project. */ +/* Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons + * to whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * of the copyright holder. + */ #include "xf86.h" #include "xf86_OSlib.h" #include "xf86OSmouse.h" -#if defined(__SOL8__) || !defined(i386) +#if defined(__SOL8__) || !defined(__i386) #include "xisb.h" #include "mipointer.h" +#include <sys/stropts.h> #include <sys/vuid_event.h> +#include <sys/msio.h> + +/* Wheel mouse support in VUID drivers in Solaris 9 updates & Solaris 10 */ +#ifdef WHEEL_DEVID /* Defined in vuid_event.h if VUID wheel support present */ +# define HAVE_VUID_WHEEL +#endif +#ifdef HAVE_VUID_WHEEL +# include <sys/vuid_wheel.h> +#endif /* Names of protocols that are handled internally here. */ @@ -42,21 +80,71 @@ static const char *internalNames[] = { NULL }; +static const char *solarisMouseDevs[] = { + /* Device file: Protocol: */ + "/dev/mouse", "VUID", /* USB or SPARC */ +#ifdef __i386 + "/dev/kdmouse", "PS/2", /* PS/2 */ +#endif + NULL +}; + typedef struct _VuidMseRec { Firm_event event; unsigned char *buffer; + char *strmod; } VuidMseRec, *VuidMsePtr; static int vuidMouseProc(DeviceIntPtr pPointer, int what); static void vuidReadInput(InputInfoPtr pInfo); +/* + * Initialize and enable the mouse wheel, if present. + * + * Returns 1 if mouse wheel was successfully enabled. + * Returns 0 if an error occurred or if there is no mouse wheel. + */ +static int +vuidMouseWheelInit(InputInfoPtr pInfo) +{ +#ifdef HAVE_VUID_WHEEL + wheel_state wstate; + int nwheel = -1; + + wstate.vers = VUID_WHEEL_STATE_VERS; + wstate.id = 0; + wstate.stateflags = -1; + + if (ioctl(pInfo->fd, VUIDGWHEELCOUNT, &nwheel) != 0) + return (0); + + if (ioctl(pInfo->fd, VUIDGWHEELSTATE, &wstate) != 0) { + xf86Msg(X_WARNING, "%s: couldn't get wheel state\n", pInfo->name); + return (0); + } + + wstate.stateflags |= VUID_WHEEL_STATE_ENABLED; + + if (ioctl(pInfo->fd, VUIDSWHEELSTATE, &wstate) != 0) { + xf86Msg(X_WARNING, "%s: couldn't enable wheel\n", pInfo->name); + return (0); + } + + return (1); +#else + return (0); +#endif +} + + /* This function is called when the protocol is "VUID". */ static Bool vuidPreInit(InputInfoPtr pInfo, const char *protocol, int flags) { MouseDevPtr pMse = pInfo->private; VuidMsePtr pVuidMse; + int buttons; pVuidMse = xalloc(sizeof(VuidMseRec)); if (pVuidMse == NULL) { @@ -84,7 +172,40 @@ vuidPreInit(InputInfoPtr pInfo, const char *protocol, int flags) return FALSE; } } + pVuidMse->buffer = (unsigned char *)&pVuidMse->event; + + pVuidMse->strmod = xf86SetStrOption(pInfo->options, "StreamsModule", NULL); + if (pVuidMse->strmod && + (ioctl(pInfo->fd, I_PUSH, pVuidMse->strmod) == -1)) { + xf86Msg(X_ERROR, + "%s: cannot push module '%s' onto mouse device: %s\n", + pInfo->name, pVuidMse->strmod, strerror(errno)); + xf86CloseSerial(pInfo->fd); + pInfo->fd = -1; + xfree(pVuidMse); + xfree(pMse); + return FALSE; + } + + buttons = xf86SetIntOption(pInfo->options, "Buttons", 0); + if (buttons == 0) { + if(ioctl(pInfo->fd, MSIOBUTTONS, &buttons) == 0) { + pInfo->conf_idev->commonOptions = + xf86ReplaceIntOption(pInfo->conf_idev->commonOptions, + "Buttons", buttons); + xf86Msg(X_INFO, "%s: Setting Buttons option to \"%d\"\n", + pInfo->name, buttons); + } + } + + if (pVuidMse->strmod && + (ioctl(pInfo->fd, I_POP, pVuidMse->strmod) == -1)) { + xf86Msg(X_WARNING, + "%s: cannot pop module '%s' off mouse device: %s\n", + pInfo->name, pVuidMse->strmod, strerror(errno)); + } + xf86CloseSerial(pInfo->fd); pInfo->fd = -1; @@ -112,6 +233,7 @@ vuidReadInput(InputInfoPtr pInfo) unsigned int n; int c; unsigned char *pBuf; + int wmask; pMse = pInfo->private; pVuidMse = pMse->mousePriv; @@ -154,7 +276,15 @@ vuidReadInput(InputInfoPtr pInfo) dy -= delta; break; } + } +#ifdef HAVE_VUID_WHEEL + else if (vuid_in_range(VUID_WHEEL, pVuidMse->event.id)) { + if (vuid_id_offset(pVuidMse->event.id) == 0) + dz -= VUID_WHEEL_GETDELTA(pVuidMse->event.value); + else + dw -= VUID_WHEEL_GETDELTA(pVuidMse->event.value); } +#endif n = 0; if ((c = XisbRead(pMse->buffer)) >= 0) { @@ -219,9 +349,20 @@ vuidMouseProc(DeviceIntPtr pPointer, int what) pInfo->fd = -1; } else { int fmt = VUID_FIRM_EVENT; - ioctl(pInfo->fd, VUIDSFORMAT, &fmt); - xf86FlushInput(pInfo->fd); - AddEnabledDevice(pInfo->fd); + + if (pVuidMse->strmod && + (ioctl(pInfo->fd, I_PUSH, pVuidMse->strmod) == -1)) { + xf86Msg(X_ERROR, + "%s: cannot push module '%s' onto mouse device: %s\n", + pInfo->name, pVuidMse->strmod, strerror(errno)); + xf86CloseSerial(pInfo->fd); + pInfo->fd = -1; + } else { + ioctl(pInfo->fd, VUIDSFORMAT, &fmt); + vuidMouseWheelInit(pInfo); + xf86FlushInput(pInfo->fd); + AddEnabledDevice(pInfo->fd); + } } } pMse->lastButtons = 0; @@ -237,6 +378,12 @@ vuidMouseProc(DeviceIntPtr pPointer, int what) XisbFree(pMse->buffer); pMse->buffer = NULL; } + if (pVuidMse->strmod && + (ioctl(pInfo->fd, I_POP, pVuidMse->strmod) == -1)) { + xf86Msg(X_WARNING, + "%s: cannot pop module '%s' off mouse device: %s\n", + pInfo->name, pVuidMse->strmod, strerror(errno)); + } xf86CloseSerial(pInfo->fd); pInfo->fd = -1; } @@ -278,21 +425,98 @@ CheckProtocol(const char *protocol) static const char * DefaultProtocol(void) { - return "VUID"; + return "Auto"; +} + +static Bool +solarisMouseAutoProbe(InputInfoPtr pInfo, const char **protocol, + const char **device) +{ + const char **pdev, **pproto, *dev = NULL; + int fd = -1; + Bool found; + + for (pdev = solarisMouseDevs; *pdev; pdev += 2) { + pproto = pdev + 1; + if ((*protocol != NULL) && (strcmp(*protocol, "Auto") != 0) && + (*pproto != NULL) && (strcmp(*pproto, *protocol) != 0)) { + continue; + } + if ((*device != NULL) && (strcmp(*device, *pdev) != 0)) { + continue; + } + SYSCALL (fd = open(*pdev, O_RDWR | O_NONBLOCK)); + if (fd == -1) { +#ifdef DEBUG + ErrorF("Cannot open %s (%s)\n", pdev, strerror(errno)); +#endif + } else { + found = TRUE; + if ((*pproto != NULL) && (strcmp(*pproto, "VUID") == 0)) { + int i; + if (ioctl(fd, VUIDGFORMAT, &i) < 0) { + found = FALSE; + } + } + close(fd); + if (found == TRUE) { + if (*pproto != NULL) { + *protocol = *pproto; + } + *device = *pdev; + return TRUE; + } + } + } + return FALSE; } static const char * SetupAuto(InputInfoPtr pInfo, int *protoPara) { - return DefaultProtocol(); + const char *pdev = NULL; + const char *pproto = NULL; + MouseDevPtr pMse = pInfo->private; + + if (pInfo->fd == -1) { + /* probe to find device/protocol to use */ + if (solarisMouseAutoProbe(pInfo, &pproto, &pdev) != FALSE) { + /* Set the Device option. */ + pInfo->conf_idev->commonOptions = + xf86AddNewOption(pInfo->conf_idev->commonOptions, "Device", pdev); + xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n", + pInfo->name, pdev); + } + } else if (pMse->protocolID == PROT_AUTO) { + pdev = xf86CheckStrOption(pInfo->conf_idev->commonOptions, + "Device", NULL); + solarisMouseAutoProbe(pInfo, &pproto, &pdev); + } + return pproto; +} + +static const char * +FindDevice(InputInfoPtr pInfo, const char *protocol, int flags) +{ + const char *pdev = NULL; + const char *pproto = protocol; + + if (solarisMouseAutoProbe(pInfo, &pproto, &pdev) != FALSE) { + /* Set the Device option. */ + pInfo->conf_idev->commonOptions = + xf86AddNewOption(pInfo->conf_idev->commonOptions, "Device", pdev); + xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n", + pInfo->name, pdev); + } + return pdev; } -#else /* __SOL8__ || !i386 */ +#else /* __SOL8__ || !__i386 */ #undef MSE_MISC #define MSE_MISC 0 -#endif /* !__SOL8__ && i386 */ +#endif /* !__SOL8__ && __i386 */ static int SupportedInterfaces(void) @@ -310,12 +534,13 @@ xf86OSMouseInit(int flags) if (!p) return NULL; p->SupportedInterfaces = SupportedInterfaces; -#if defined(__SOL8__) || !defined(i386) +#if defined(__SOL8__) || !defined(__i386) p->BuiltinNames = BuiltinNames; p->CheckProtocol = CheckProtocol; p->PreInit = sunMousePreInit; p->DefaultProtocol = DefaultProtocol; p->SetupAuto = SetupAuto; + p->FindDevice = FindDevice; #endif return p; } diff --git a/hw/xfree86/os-support/xf86OSmouse.h b/hw/xfree86/os-support/xf86OSmouse.h index ee6313a3b..87d742d5e 100644 --- a/hw/xfree86/os-support/xf86OSmouse.h +++ b/hw/xfree86/os-support/xf86OSmouse.h @@ -169,11 +169,12 @@ extern OSMouseInfoPtr xf86OSMouseInit(int flags); * * 1.0.0 - Everything up to when versioning was started. * 1.1.0 - FindDevice and GuessProtocol added to OSMouseInfoRec + * 1.2.0 - xisbscale added to MouseDevRec * */ #define OS_MOUSE_VERSION_MAJOR 1 -#define OS_MOUSE_VERSION_MINOR 1 +#define OS_MOUSE_VERSION_MINOR 2 #define OS_MOUSE_VERSION_PATCH 0 #define OS_MOUSE_VERSION_CURRENT \ @@ -267,6 +268,7 @@ typedef struct _MouseDevRec { dataGoodProc dataGood; int angleOffset; pointer pDragLock; /* drag lock area */ + int xisbscale; /* buffer size for 1 event */ } MouseDevRec, *MouseDevPtr; /* Z axis mapping */ diff --git a/hw/xfree86/os-support/xf86_OSlib.h b/hw/xfree86/os-support/xf86_OSlib.h index 4df2d502a..5a9c9b1ff 100644 --- a/hw/xfree86/os-support/xf86_OSlib.h +++ b/hw/xfree86/os-support/xf86_OSlib.h @@ -67,6 +67,7 @@ */ /* $XConsortium: xf86_OSlib.h /main/22 1996/10/27 11:06:31 kaleb $ */ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h,v 1.4 2004/07/28 03:57:19 alanc Exp $ */ /* * This is private, and should not be included by any drivers. Drivers @@ -260,6 +261,7 @@ typedef signed long xf86ssize_t; # define LED_CAP LED_CAPS_LOCK # define LED_NUM LED_NUM_LOCK # define LED_SCR LED_SCROLL_LOCK +# define LED_COMP LED_COMPOSE # include <signal.h> @@ -532,7 +534,7 @@ extern int errno; # endif # endif /* __bsdi__ */ -#ifdef USE_I386_IOPL +#if defined(USE_I386_IOPL) || defined(USE_AMD64_IOPL) #include <machine/sysarch.h> #endif diff --git a/hw/xfree86/os-support/xf86_libc.h b/hw/xfree86/os-support/xf86_libc.h index ca54e480e..9579a6611 100644 --- a/hw/xfree86/os-support/xf86_libc.h +++ b/hw/xfree86/os-support/xf86_libc.h @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/xf86_libc.h,v 1.1.4.3 2003/12/20 00:28:30 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/xf86_libc.h,v 1.2 2004/04/23 19:54:07 eich Exp $ */ /* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86_libc.h,v 3.63 2003/12/08 21:46:55 alanh Exp $ */ /* * Copyright (c) 1997-2003 by The XFree86 Project, Inc. diff --git a/hw/xfree86/parser/configProcs.h b/hw/xfree86/parser/configProcs.h index 522cf5c2f..cc694666f 100644 --- a/hw/xfree86/parser/configProcs.h +++ b/hw/xfree86/parser/configProcs.h @@ -116,6 +116,10 @@ void xf86freeBuffersList (XF86ConfBuffersPtr ptr); XF86ConfDRIPtr xf86parseDRISection (void); void xf86printDRISection (FILE * cf, XF86ConfDRIPtr ptr); void xf86freeDRI (XF86ConfDRIPtr ptr); +/* Extensions.c */ +XF86ConfExtensionsPtr xf86parseExtensionsSection (void); +void xf86printExtensionsSection (FILE * cf, XF86ConfExtensionsPtr ptr); +void xf86freeExtensions (XF86ConfExtensionsPtr ptr); #ifndef IN_XSERVER /* Externally provided functions */ diff --git a/hw/xfree86/parser/read.c b/hw/xfree86/parser/read.c index 2a5afeb27..2946dc8b1 100644 --- a/hw/xfree86/parser/read.c +++ b/hw/xfree86/parser/read.c @@ -191,6 +191,12 @@ xf86readConfigFile (void) val.str = NULL; HANDLE_RETURN (conf_dri, xf86parseDRISection ()); } + else if (xf86nameCompare (val.str, "extensions") == 0) + { + xf86conffree(val.str); + val.str = NULL; + HANDLE_RETURN (conf_extensions, xf86parseExtensionsSection ()); + } else { Error (INVALID_SECTION_MSG, xf86tokenString ()); @@ -304,6 +310,7 @@ xf86freeConfig (XF86ConfigPtr p) xf86freeInputList (p->conf_input_lst); xf86freeVendorList (p->conf_vendor_lst); xf86freeDRI (p->conf_dri); + xf86freeExtensions (p->conf_extensions); TestFree(p->conf_comment); xf86conffree (p); diff --git a/hw/xfree86/parser/write.c b/hw/xfree86/parser/write.c index e096c6247..499b6a11e 100644 --- a/hw/xfree86/parser/write.c +++ b/hw/xfree86/parser/write.c @@ -130,6 +130,8 @@ doWriteConfigFile (const char *filename, XF86ConfigPtr cptr) xf86printDRISection (cf, cptr->conf_dri); + xf86printExtensionsSection (cf, cptr->conf_extensions); + fclose(cf); return 1; } diff --git a/hw/xfree86/parser/xf86Parser.h b/hw/xfree86/parser/xf86Parser.h index 1a30d17a8..b6a974d3c 100644 --- a/hw/xfree86/parser/xf86Parser.h +++ b/hw/xfree86/parser/xf86Parser.h @@ -416,6 +416,13 @@ XF86ConfDRIRec, *XF86ConfDRIPtr; typedef struct { + XF86OptionPtr ext_option_lst; + char *extensions_comment; +} +XF86ConfExtensionsRec, *XF86ConfExtensionsPtr; + +typedef struct +{ XF86ConfFilesPtr conf_files; XF86ConfModulePtr conf_modules; XF86ConfFlagsPtr conf_flags; @@ -428,6 +435,7 @@ typedef struct XF86ConfLayoutPtr conf_layout_lst; XF86ConfVendorPtr conf_vendor_lst; XF86ConfDRIPtr conf_dri; + XF86ConfExtensionsPtr conf_extensions; char *conf_comment; } XF86ConfigRec, *XF86ConfigPtr; diff --git a/hw/xfree86/rac/xf86RACmodule.c b/hw/xfree86/rac/xf86RACmodule.c index fd436ef85..83c60e3fd 100644 --- a/hw/xfree86/rac/xf86RACmodule.c +++ b/hw/xfree86/rac/xf86RACmodule.c @@ -8,7 +8,7 @@ static XF86ModuleVersionInfo racVersRec = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 1, 0, 0, ABI_CLASS_VIDEODRV, /* requires the video driver ABI */ ABI_VIDEODRV_VERSION, diff --git a/hw/xfree86/ramdac/IBM.c b/hw/xfree86/ramdac/IBM.c index 69207c2e2..4fede5720 100644 --- a/hw/xfree86/ramdac/IBM.c +++ b/hw/xfree86/ramdac/IBM.c @@ -374,6 +374,10 @@ IBMramdac526SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg) } } +IBMramdac526SetBppProc *IBMramdac526SetBppWeak(void) { + return IBMramdac526SetBpp; +} + void IBMramdac640SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg) { diff --git a/hw/xfree86/ramdac/IBM.h b/hw/xfree86/ramdac/IBM.h index 00d039031..eb211883c 100644 --- a/hw/xfree86/ramdac/IBM.h +++ b/hw/xfree86/ramdac/IBM.h @@ -18,6 +18,9 @@ unsigned long IBMramdac640CalculateMNPCForClock(unsigned long RefClock, void IBMramdac526HWCursorInit(xf86CursorInfoPtr infoPtr); void IBMramdac640HWCursorInit(xf86CursorInfoPtr infoPtr); +typedef void IBMramdac526SetBppProc(ScrnInfoPtr, RamDacRegRecPtr); +IBMramdac526SetBppProc *IBMramdac526SetBppWeak(void); + #define IBM524_RAMDAC ((VENDOR_IBM << 16) | 0x00) #define IBM524A_RAMDAC ((VENDOR_IBM << 16) | 0x01) #define IBM525_RAMDAC ((VENDOR_IBM << 16) | 0x02) diff --git a/hw/xfree86/ramdac/TI.c b/hw/xfree86/ramdac/TI.c index ce6dd9a04..024cb49eb 100644 --- a/hw/xfree86/ramdac/TI.c +++ b/hw/xfree86/ramdac/TI.c @@ -711,3 +711,7 @@ void TIramdacLoadPalette( } } } + +TIramdacLoadPaletteProc *TIramdacLoadPaletteWeak(void) { + return TIramdacLoadPalette; +} diff --git a/hw/xfree86/ramdac/TI.h b/hw/xfree86/ramdac/TI.h index f87ebd13f..f33247cfc 100644 --- a/hw/xfree86/ramdac/TI.h +++ b/hw/xfree86/ramdac/TI.h @@ -19,6 +19,9 @@ void TIramdacHWCursorInit(xf86CursorInfoPtr infoPtr); void TIramdacLoadPalette( ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, VisualPtr pVisual); +typedef void TIramdacLoadPaletteProc(ScrnInfoPtr, int, int *, LOCO *, + VisualPtr); +TIramdacLoadPaletteProc *TIramdacLoadPaletteWeak(void); #define TI3030_RAMDAC (VENDOR_TI << 16) | 0x00 #define TI3026_RAMDAC (VENDOR_TI << 16) | 0x01 diff --git a/hw/xfree86/ramdac/xf86RamDacMod.c b/hw/xfree86/ramdac/xf86RamDacMod.c index cb100d7bb..0fe5ce6aa 100644 --- a/hw/xfree86/ramdac/xf86RamDacMod.c +++ b/hw/xfree86/ramdac/xf86RamDacMod.c @@ -33,7 +33,7 @@ static XF86ModuleVersionInfo VersRec = { MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 0, 1, 0, ABI_CLASS_VIDEODRV, ABI_VIDEODRV_VERSION, diff --git a/hw/xfree86/scanpci/extrapci.ids b/hw/xfree86/scanpci/extrapci.ids index a65732072..71664cbee 100644 --- a/hw/xfree86/scanpci/extrapci.ids +++ b/hw/xfree86/scanpci/extrapci.ids @@ -14,7 +14,7 @@ # changes/additions that aren't XFree86-specific to the pciids # project (http://pciids.sf.net/). # -# $XdotOrg: xc/programs/Xserver/hw/xfree86/etc/extrapci.ids,v 1.1.4.2.4.2 2004/03/04 20:16:34 kaleb Exp $ +# $XdotOrg: xc/programs/Xserver/hw/xfree86/etc/extrapci.ids,v 1.2 2004/04/23 19:53:57 eich Exp $ # $XFree86: xc/programs/Xserver/hw/xfree86/etc/extrapci.ids,v 1.11 2003/12/18 16:22:27 dawes Exp $ # diff --git a/hw/xfree86/scanpci/xf86ScanPci.c b/hw/xfree86/scanpci/xf86ScanPci.c index cf12c42cc..8231ea05a 100644 --- a/hw/xfree86/scanpci/xf86ScanPci.c +++ b/hw/xfree86/scanpci/xf86ScanPci.c @@ -96,7 +96,7 @@ static XF86ModuleVersionInfo pciDataVersRec = { MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 1, 0, 0, ABI_CLASS_VIDEODRV, ABI_VIDEODRV_VERSION, @@ -113,7 +113,7 @@ static XF86ModuleVersionInfo scanPciVersRec = { MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 1, 0, 0, ABI_CLASS_VIDEODRV, ABI_VIDEODRV_VERSION, diff --git a/hw/xfree86/shadowfb/sfbmodule.c b/hw/xfree86/shadowfb/sfbmodule.c index ad090d43c..6793c8f95 100644 --- a/hw/xfree86/shadowfb/sfbmodule.c +++ b/hw/xfree86/shadowfb/sfbmodule.c @@ -11,7 +11,7 @@ static XF86ModuleVersionInfo VersRec = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 1, 0, 0, ABI_CLASS_ANSIC, /* Only need the ansic layer */ ABI_ANSIC_VERSION, diff --git a/hw/xfree86/utils/gtf/gtf.c b/hw/xfree86/utils/gtf/gtf.c index 3535300fc..fbc620709 100644 --- a/hw/xfree86/utils/gtf/gtf.c +++ b/hw/xfree86/utils/gtf/gtf.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/hw/xfree86/etc/gtf.c,v 1.1.10.1.4.1 2004/03/19 17:09:00 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/etc/gtf.c,v 1.2 2004/04/23 19:53:57 eich Exp $ */ /* gtf.c Generate mode timings using the GTF Timing Standard * * gcc gtf.c -o gtf -lm -Wall diff --git a/hw/xfree86/utils/gtf/gtf.man.pre b/hw/xfree86/utils/gtf/gtf.man.pre index 4dc228d2c..fd0c406d3 100644 --- a/hw/xfree86/utils/gtf/gtf.man.pre +++ b/hw/xfree86/utils/gtf/gtf.man.pre @@ -1,5 +1,4 @@ .\" $XFree86$ -.\" $XdotOrg: xc/programs/Xserver/hw/xfree86/etc/gtf.man,v 1.1.10.1.4.2 2004/03/27 16:56:43 keithp Exp $ .TH GTF 1 __vendorversion__ .SH NAME gtf - calculate VESA GTF mode lines diff --git a/hw/xfree86/utils/xorgcfg/loader.c b/hw/xfree86/utils/xorgcfg/loader.c index 138b77778..ad928c4d8 100644 --- a/hw/xfree86/utils/xorgcfg/loader.c +++ b/hw/xfree86/utils/xorgcfg/loader.c @@ -26,7 +26,7 @@ * * Author: Paulo César Pereira de Andrade <pcpa@conectiva.com.br> * - * $XdotOrg: xc/programs/Xserver/hw/xfree86/xf86cfg/loader.c,v 1.1.4.1.4.2.4.1 2004/03/23 13:54:01 eich Exp $ + * $XdotOrg: xc/programs/Xserver/hw/xfree86/xf86cfg/loader.c,v 1.2 2004/04/23 19:54:18 eich Exp $ * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/loader.c,v 1.19 2002/06/06 21:03:32 paulo Exp $ */ diff --git a/hw/xfree86/utils/xorgconfig/cards.c b/hw/xfree86/utils/xorgconfig/cards.c index d5f405f4a..29c1c0e2b 100644 --- a/hw/xfree86/utils/xorgconfig/cards.c +++ b/hw/xfree86/utils/xorgconfig/cards.c @@ -1,3 +1,4 @@ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/xf86config/cards.c,v 1.3 2004/08/13 23:57:38 alanc Exp $ */ /* $XConsortium: cards.c /main/9 1996/10/19 18:15:32 kaleb $ */ @@ -16,6 +17,19 @@ #include "cards.h" +/* Some vars to make path names in texts more flexible. */ +#ifndef PROJECTROOT +# define PROJECTROOT "/usr/X11R6" +#endif +#define TREEROOT PROJECTROOT +#define TREEROOTLX TREEROOT "/lib/X11" +#define TREEROOTCFG TREEROOT "/etc/X11" +#ifdef XDOCDIR +# define TREEROOTDOC XDOCDIR +#else +# define TREEROOTDOC TREEROOTLX "/doc" +#endif + /* * Database format: * @@ -92,12 +106,12 @@ static char *s3_comment = "# (this avoids the linear framebuffer probe). If that fails try\n" "# option \"nomemaccess\".\n" "#\n" -"# Refer to /usr/X11R6/lib/doc/README.S3, and the XF86_S3 man page.\n"; +"# Refer to " TREEROOTDOC "/README.S3, and the XF86_S3 man page.\n"; static char *cirrus_comment = "# Use Option \"no_bitblt\" if you have graphics problems. If that fails\n" "# try Option \"noaccel\".\n" -"# Refer to /usr/X11R6/lib/doc/README.cirrus.\n" +"# Refer to " TREEROOTDOC "/README.cirrus.\n" "# To allow linear addressing, uncomment the Option line and the\n" "# address that the card maps the framebuffer to.\n"; diff --git a/hw/xfree86/utils/xorgconfig/xorgconfig.c b/hw/xfree86/utils/xorgconfig/xorgconfig.c index 7f4c18d6a..a8fef000b 100644 --- a/hw/xfree86/utils/xorgconfig/xorgconfig.c +++ b/hw/xfree86/utils/xorgconfig/xorgconfig.c @@ -94,6 +94,7 @@ * Chisato Yamauchi(cyamauch@phyas.aichi-edu.ac.jp) */ /* $XConsortium: xf86config.c /main/21 1996/10/28 05:43:57 kaleb $ */ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/xf86config/xorgconfig.c,v 1.6 2004/08/13 23:57:38 alanc Exp $ */ #include <stdlib.h> #include <stdio.h> @@ -169,6 +170,11 @@ static int getuid() { return 0; } #define TREEROOT PROJECTROOT #define TREEROOTLX TREEROOT "/lib/X11" #define TREEROOTCFG TREEROOT "/etc/X11" +#ifdef XDOCDIR +# define TREEROOTDOC XDOCDIR +#else +# define TREEROOTDOC TREEROOTLX "/doc" +#endif #define MODULEPATH TREEROOT "/lib/modules" #ifndef XCONFIGFILE @@ -256,7 +262,7 @@ CONFIGNAME " file is supplied with "__XSERVERNAME__"; it is configured for a sta "configuration, or let this program produce a base " CONFIGNAME " file for your\n" "configuration and fine-tune it.\n" #if 0 -" Refer to " TREEROOTLX "/doc/README.Config\n" +" Refer to " TREEROOTDOC "/README.Config\n" "for a detailed overview of the configuration process.\n" "\n" "(what should we change this section to?)\n" @@ -372,7 +378,7 @@ int M_OSMOUSE, M_WSMOUSE, M_AUTO, M_NETMOUSE_PS2, M_NETSCROLL_PS2, M_THINKINGMOUSE_PS2, M_ACECAD, M_GLIDEPOINT, M_INTELLIMOUSE, M_LOGITECH, M_MMHITTAB, M_MMSERIES, - M_MOUSEMAN, M_THINKINGMOUSE; + M_MOUSEMAN, M_THINKINGMOUSE, M_VUID; struct { char *name; @@ -398,6 +404,11 @@ struct { {"Auto", &M_AUTO, "Auto detect" }, +#ifdef sun + {"VUID", &M_VUID, + "Solaris VUID" + }, +#endif {"SysMouse", &M_SYSMOUSE, "SysMouse" }, @@ -464,6 +475,14 @@ struct { }, }; +#ifdef WSCONS_SUPPORT +# define DEF_MOUSEDEV "/dev/wsmouse"; +#elif defined(__FreeBSD__) +# define DEF_MOUSEDEV "/dev/sysmouse"; +#else +# define DEF_MOUSEDEV "/dev/mouse"; +#endif + #ifndef __UNIXOS2__ static char *mouseintro_text = "First specify a mouse protocol type. Choose one from the following list:\n" @@ -471,13 +490,7 @@ static char *mouseintro_text = static char *mousedev_text = "Now give the full device name that the mouse is connected to, for example\n" -"/dev/tty00. Just pressing enter will use the default, /dev/mouse.\n" -#ifdef WSCONS_SUPPORT -"On systems with wscons, the default is /dev/wsmouse.\n" -#endif -#ifdef __FreeBSD__ -"On FreeBSD, the default is /dev/sysmouse.\n" -#endif +"/dev/tty00. Just pressing enter will use the default, %s.\n" "\n"; static char *mousecomment_text = @@ -529,6 +542,7 @@ mouse_configuration(void) { #if !defined(__UNIXOS2__) && !defined(QNX4) int i, j; char s[80]; + char *def_mousedev = DEF_MOUSEDEV; #define MOUSETYPE_COUNT sizeof(mouse_info)/sizeof(mouse_info[0]) for (i = 0; i < MOUSETYPE_COUNT; i++) @@ -621,22 +635,24 @@ mouse_configuration(void) { config_emulate3buttons = 0; printf("\n"); - printf("%s", mousedev_text); +#if (defined(sun) && defined(__i386)) + /* SPARC & USB mice (VUID or AUTO protocols) default to /dev/mouse, + but PS/2 mice default to /dev/kdmouse */ + if ((config_mousetype != M_AUTO) && (config_mousetype != M_VUID)) { + def_mousedev = "/dev/kdmouse"; + } +#endif + + printf(mousedev_text, def_mousedev); printf("Mouse device: "); getstring(s); - if (strlen(s) == 0) -#ifdef WSCONS_SUPPORT - config_pointerdevice = "/dev/wsmouse"; -#elif defined(__FreeBSD__) - config_pointerdevice = "/dev/sysmouse"; -#else - config_pointerdevice = "/dev/mouse"; -#endif - else { + if (strlen(s) == 0) { + config_pointerdevice = def_mousedev; + } else { config_pointerdevice = Malloc(strlen(s) + 1); strcpy(config_pointerdevice, s); - } - printf("\n"); + } + printf("\n"); #else /* __UNIXOS2__ */ /* set some reasonable defaults for OS/2 */ @@ -706,7 +722,7 @@ keyboard_configuration(void) rulesfile = XKB_RULES_DIR "/xfree98"; #else config_xkbrules = __XKBDEFRULES__; /* static */ - rulesfile = XKB_RULES_DIR "/"; + rulesfile = XKB_RULES_DIR "/" __XKBDEFRULES__; #endif rules = XkbRF_Load(rulesfile, "", True, False); @@ -839,7 +855,7 @@ static char *monitorintro_text = "\n" "The valid range for horizontal sync and vertical sync should be documented\n" "in the manual of your monitor. If in doubt, check the monitor database\n" -TREEROOTLX "/doc/Monitors to see if your monitor is there.\n" +TREEROOTDOC "/Monitors to see if your monitor is there.\n" "\n"; static char *hsyncintro_text = @@ -1852,10 +1868,10 @@ depth_configuration(void) */ static char *XF86Config_firstchunk_text = -"# File generated by xf86config.\n" +"# File generated by xorgconfig.\n" "\n" "#\n" -"# Copyright (c) 2004, by the "XVENDORNAMESHORT"\n" +"# Copyright 2004 "XVENDORNAME"\n" "#\n" "# Permission is hereby granted, free of charge, to any person obtaining a\n" "# copy of this software and associated documentation files (the \"Software\"),\n" @@ -1870,19 +1886,19 @@ static char *XF86Config_firstchunk_text = "# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n" "# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n" "# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n" -"# THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n" +"# "XVENDORNAME" BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n" "# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF\n" "# OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n" "# SOFTWARE.\n" "# \n" -"# Except as contained in this notice, the name of "XVENDORNAMESHORT" shall\n" +"# Except as contained in this notice, the name of "XVENDORNAME" shall\n" "# not be used in advertising or otherwise to promote the sale, use or other\n" -"# dealings in this Software without prior written authorization from the\n" -"# "XVENDORNAMESHORT".\n" +"# dealings in this Software without prior written authorization from\n" +"# "XVENDORNAME".\n" "#\n" "\n" "# **********************************************************************\n" -"# Refer to the XF86Config(4/5) man page for details about the format of \n" +"# Refer to the " CONFIGNAME "(" FILEMANSUFFIX ") man page for details about the format of \n" "# this file.\n" "# **********************************************************************\n" "\n" @@ -1903,9 +1919,17 @@ static char *XF86Config_firstchunk_text = " Option \"omit xfree86-dga\" # don't initialise the DGA extension\n" " EndSubSection\n" "\n" -"# This loads the Type1 and FreeType font modules\n" +"# This loads the font modules\n" +#ifdef HAS_TYPE1 " Load \"type1\"\n" +#else +"# Load \"type1\"\n" +#endif +#ifdef HAS_SPEEDO " Load \"speedo\"\n" +#else +"# Load \"speedo\"\n" +#endif " Load \"freetype\"\n" "# Load \"xtt\"\n" "\n" @@ -1932,9 +1956,11 @@ static char *XF86Config_firstchunk_text = "# as well as specifying multiple comma-separated entries in one FontPath\n" "# command (or a combination of both methods)\n" "# \n" +#if 0 "# If you don't have a floating point coprocessor and emacs, Mosaic or other\n" "# programs take long to start up, try moving the Type1 and Speedo directory\n" "# to the end of this list (or comment them out).\n" +#endif "# \n" "\n"; @@ -2025,7 +2051,11 @@ static char *XF86Config_fontpathchunk_text = "Section \"InputDevice\"\n" "\n" " Identifier \"Keyboard1\"\n" +#ifdef USE_DEPRECATED_KEYBOARD_DRIVER " Driver \"Keyboard\"\n" +#else +" Driver \"kbd\"\n" +#endif "\n" "# For most OSs the protocol can be omitted (it defaults to \"Standard\").\n" "# When using XQUEUE (only for SVR3 and SVR4, but not Solaris),\n" @@ -2061,8 +2091,8 @@ static char *keyboardchunk3_text = "# control keys, use:\n" "# Option \"XkbOptions\" \"ctrl:swapcaps\"\n" "\n" -"# These are the default XKB settings for "XVENDORNAMESHORT"\n" -"# Option \"XkbRules\" \"__XKBDEFRULES__\"\n" +"# These are the default XKB settings for "__XSERVERNAME__"\n" +"# Option \"XkbRules\" \""__XKBDEFRULES__"\"\n" "# Option \"XkbModel\" \"pc101\"\n" "# Option \"XkbLayout\" \"us\"\n" "# Option \"XkbVariant\" \"\"\n" @@ -2114,7 +2144,7 @@ static char *xinputsection_text = "# Other input device sections \n" "# this is optional and is required only if you\n" "# are using extended input devices. This is for example only. Refer\n" -"# to the XF86Config man page for a description of the options.\n" +"# to the " CONFIGNAME " man page for a description of the options.\n" "# **********************************************************************\n" "#\n" "# Section \"InputDevice\" \n" @@ -2384,7 +2414,7 @@ static char *devicesection_text = "\n" "EndSection\n" "\n" -"# Device configured by xf86config:\n" +"# Device configured by xorgconfig:\n" "\n"; static char *screensection_text1 = @@ -2448,12 +2478,43 @@ write_fontpath_section(FILE *f) int i; char cur[256+20],*colon, *hash; +#ifdef COMPILEDDEFAULTFONTPATH + static const char dfp[] = COMPILEDDEFAULTFONTPATH; + const char *thisdir; + const char *nextdir; + int len; + + for (thisdir = dfp; thisdir != NULL; thisdir = nextdir) { + nextdir = strchr(thisdir, ','); + if (nextdir == NULL) { + len = strlen(thisdir); + } else { + len = nextdir - thisdir; + nextdir++; + } + if (len > sizeof(cur)) + continue; + strncpy(cur, thisdir, len); + cur[len] = '\0'; + colon = strchr(cur+2,':'); /* OS/2: C:/...:scaled */ + if (colon) *colon = 0; + hash = exists_dir(cur) ? "" : "#"; + if (colon) *colon = ':'; + fprintf(f,"%s FontPath \"%s\"\n", hash, cur); + } +#endif + for (i=0; XF86Config_fontpaths[i]; i++) { strcpy(cur,TREEROOTLX); strcat(cur,XF86Config_fontpaths[i]); /* remove a ':' */ colon = strchr(cur+2,':'); /* OS/2: C:/...:scaled */ if (colon) *colon = 0; +#ifdef COMPILEDDEFAULTFONTPATH + /* skip if we already added it as part of the default font path */ + if (strstr(dfp, cur) != NULL) + continue; +#endif hash = exists_dir(cur) ? "" : "#"; fprintf(f,"%s FontPath \"%s%s\"\n", hash, @@ -2701,7 +2762,7 @@ ask_XF86Config_location(void) { char *filename = NULL; printf( -"I am going to write the XF86Config file now. Make sure you don't accidently\n" +"I am going to write the " CONFIGNAME " file now. Make sure you don't accidently\n" "overwrite a previously configured one.\n\n"); #ifndef __EMX__ @@ -2778,22 +2839,23 @@ ask_XF86Config_location(void) { static char *notinstalled_text = "The directory " TREEROOT " does not exist. This probably means that you have\n" -"not yet installed an X11R6-based version of "__XSERVERNAME__". Please install\n" -"XFree86 3.1+ before running this program, following the instructions in\n" -"the INSTALL or README that comes with the "__XSERVERNAME__" distribution for your OS.\n" +"not yet installed the version of "__XSERVERNAME__" that this program was built\n" +"to configure. Please install "__XSERVERNAME__" "XVERSIONSTRING" before running this program,\n" +"following the instructions in the INSTALL or README that comes with the\n" +__XSERVERNAME__" distribution for your OS.\n" "For a minimal installation it is sufficient to only install base binaries,\n" "libraries, configuration files and a server that you want to use.\n" "\n"; #ifndef __UNIXOS2__ static char *oldxfree86_text = -"The directory '/usr/X386/bin' exists. You probably have an old version of\n" -"__XSERVERNAME__ installed (XFree86 3.1 installs in '" TREEROOT "' instead of\n" -"'/usr/X386').\n" +"The directory '/usr/X386/bin' exists. You probably have a very old version of\n" +"XFree86 installed, but this program was built to configure "__XSERVERNAME__" "XVERSIONSTRING"\n" +"installed in '" TREEROOT "' instead of '/usr/X386'.\n" "\n" "It is important that the directory '" TREEROOT "' is present in your\n" "search path, *before* any occurrence of '/usr/X386/bin'. If you have installed\n" -"X program binaries that are not in the base __XSERVERNAME__ distribution in\n" +"X program binaries that are not in the base "__XSERVERNAME__" distribution in\n" "'/usr/X386/bin', you can keep the directory in your path as long as it is\n" "after '" TREEROOT "'.\n" "\n"; diff --git a/hw/xfree86/vbe/vbe.c b/hw/xfree86/vbe/vbe.c index 9cc8be74d..0513b8758 100644 --- a/hw/xfree86/vbe/vbe.c +++ b/hw/xfree86/vbe/vbe.c @@ -57,14 +57,17 @@ VBEExtendedInit(xf86Int10InfoPtr pInt, int entityIndex, int Flags) vbeControllerInfoPtr vbe = NULL; Bool init_int10 = FALSE; vbeInfoPtr vip = NULL; - int screen = pScrn->scrnIndex; + int screen; + if (!pScrn) return NULL; + screen = pScrn->scrnIndex; + if (!pInt) { if (!xf86LoadSubModule(pScrn, "int10")) goto error; xf86DrvMsg(screen,X_INFO,"initializing int10\n"); - pInt = xf86InitInt10(entityIndex); + pInt = xf86ExtendedInitInt10(entityIndex,Flags); if (!pInt) goto error; init_int10 = TRUE; @@ -336,6 +339,8 @@ vbeDoEDID(vbeInfoPtr pVbe, pointer pDDCModule) return pMonitor; } +#define GET_UNALIGNED2(x) \ + ((*(CARD16*)(x)) | (*(((CARD16*)(x) + 1))) << 16) VbeInfoBlock * VBEGetVBEInfo(vbeInfoPtr pVbe) @@ -381,7 +386,7 @@ VBEGetVBEInfo(vbeInfoPtr pVbe) block->VESAVersion = *(CARD16*)(((char*)pVbe->memory) + 4); major = (unsigned)block->VESAVersion >> 8; - pStr = *(CARD32*)(((char*)pVbe->memory) + 6); + pStr = GET_UNALIGNED2((((char*)pVbe->memory) + 6)); str = xf86int10Addr(pVbe->pInt10, FARP(pStr)); block->OEMStringPtr = strdup(str); @@ -390,7 +395,7 @@ VBEGetVBEInfo(vbeInfoPtr pVbe) block->Capabilities[2] = ((char*)pVbe->memory)[12]; block->Capabilities[3] = ((char*)pVbe->memory)[13]; - pModes = *(CARD32*)(((char*)pVbe->memory) + 14); + pModes = GET_UNALIGNED2((((char*)pVbe->memory) + 14)); modes = xf86int10Addr(pVbe->pInt10, FARP(pModes)); i = 0; while (modes[i] != 0xffff) @@ -405,13 +410,13 @@ VBEGetVBEInfo(vbeInfoPtr pVbe) memcpy(&block->OemSoftwareRev, ((char*)pVbe->memory) + 20, 236); else { block->OemSoftwareRev = *(CARD16*)(((char*)pVbe->memory) + 20); - pStr = *(CARD32*)(((char*)pVbe->memory) + 22); + pStr = GET_UNALIGNED2((((char*)pVbe->memory) + 22)); str = xf86int10Addr(pVbe->pInt10, FARP(pStr)); block->OemVendorNamePtr = strdup(str); - pStr = *(CARD32*)(((char*)pVbe->memory) + 26); + pStr = GET_UNALIGNED2((((char*)pVbe->memory) + 26)); str = xf86int10Addr(pVbe->pInt10, FARP(pStr)); block->OemProductNamePtr = strdup(str); - pStr = *(CARD32*)(((char*)pVbe->memory) + 30); + pStr = GET_UNALIGNED2((((char*)pVbe->memory) + 30)); str = xf86int10Addr(pVbe->pInt10, FARP(pStr)); block->OemProductRevPtr = strdup(str); memcpy(&block->Reserved, ((char*)pVbe->memory) + 34, 222); diff --git a/hw/xfree86/vbe/vbe_module.c b/hw/xfree86/vbe/vbe_module.c index 0347f7fb7..d6f49a5c8 100644 --- a/hw/xfree86/vbe/vbe_module.c +++ b/hw/xfree86/vbe/vbe_module.c @@ -16,7 +16,7 @@ static XF86ModuleVersionInfo vbeVersRec = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 1, 1, 0, ABI_CLASS_VIDEODRV, /* needs the video driver ABI */ ABI_VIDEODRV_VERSION, diff --git a/hw/xfree86/vgahw/vgaHW.c b/hw/xfree86/vgahw/vgaHW.c index b8bcbdba9..2e12f00ac 100644 --- a/hw/xfree86/vgahw/vgaHW.c +++ b/hw/xfree86/vgahw/vgaHW.c @@ -596,6 +596,9 @@ vgaHWProtect(ScrnInfoPtr pScrn, Bool on) } } +vgaHWProtectProc *vgaHWProtectWeak(void) { + return vgaHWProtect; +} /* * vgaHWBlankScreen -- blank the screen. @@ -620,6 +623,9 @@ vgaHWBlankScreen(ScrnInfoPtr pScrn, Bool on) vgaHWSeqReset(hwp, FALSE); } +vgaHWBlankScreenProc *vgaHWBlankScreenWeak(void) { + return vgaHWBlankScreen; +} /* * vgaHWSaveScreen -- blank the screen. @@ -1988,3 +1994,7 @@ vgaHWddc1SetSpeed(ScrnInfoPtr pScrn, xf86ddcSpeed speed) break; } } + +DDC1SetSpeedProc vgaHWddc1SetSpeedWeak(void) { return vgaHWddc1SetSpeed; } + +SaveScreenProcPtr vgaHWSaveScreenWeak(void) { return vgaHWSaveScreen; } diff --git a/hw/xfree86/vgahw/vgaHW.h b/hw/xfree86/vgahw/vgaHW.h index 9a51f1046..2874c2cfb 100644 --- a/hw/xfree86/vgahw/vgaHW.h +++ b/hw/xfree86/vgahw/vgaHW.h @@ -190,11 +190,16 @@ typedef struct _vgaHWRec { /* vgaHW.c */ +typedef void vgaHWProtectProc(ScrnInfoPtr, Bool); +typedef void vgaHWBlankScreenProc(ScrnInfoPtr, Bool); + void vgaHWSetStdFuncs(vgaHWPtr hwp); void vgaHWSetMmioFuncs(vgaHWPtr hwp, CARD8 *base, int offset); void vgaHWProtect(ScrnInfoPtr pScrn, Bool on); +vgaHWProtectProc *vgaHWProtectWeak(void); Bool vgaHWSaveScreen(ScreenPtr pScreen, int mode); void vgaHWBlankScreen(ScrnInfoPtr pScrn, Bool on); +vgaHWBlankScreenProc *vgaHWBlankScreenWeak(void); void vgaHWSeqReset(vgaHWPtr hwp, Bool start); void vgaHWRestoreFonts(ScrnInfoPtr scrninfp, vgaRegPtr restore); void vgaHWRestoreMode(ScrnInfoPtr scrninfp, vgaRegPtr restore); @@ -225,4 +230,8 @@ CARD32 vgaHWHBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits, CARD32 vgaHWVBlankKGA(DisplayModePtr mode, vgaRegPtr regp, int nBits, unsigned int Flags); Bool vgaHWAllocDefaultRegs(vgaRegPtr regp); + +DDC1SetSpeedProc vgaHWddc1SetSpeedWeak(void); +SaveScreenProcPtr vgaHWSaveScreenWeak(void); + #endif /* _VGAHW_H */ diff --git a/hw/xfree86/vgahw/vgaHWmodule.c b/hw/xfree86/vgahw/vgaHWmodule.c index 409e7b511..d6044bbb7 100644 --- a/hw/xfree86/vgahw/vgaHWmodule.c +++ b/hw/xfree86/vgahw/vgaHWmodule.c @@ -14,7 +14,7 @@ static XF86ModuleVersionInfo VersRec = { MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 0, 1, 0, ABI_CLASS_VIDEODRV, ABI_VIDEODRV_VERSION, diff --git a/hw/xfree86/x86emu/debug.c b/hw/xfree86/x86emu/debug.c index 481374d53..6fd7f11cf 100644 --- a/hw/xfree86/x86emu/debug.c +++ b/hw/xfree86/x86emu/debug.c @@ -36,12 +36,9 @@ * emulator. * ****************************************************************************/ -/* $XFree86: xc/extras/x86emu/src/x86emu/debug.c,v 1.2 2000/04/05 18:13:14 dawes Exp $ */ #include "x86emu/x86emui.h" -#ifdef IN_MODULE -#include "xf86_ansic.h" -#else +#ifndef NO_SYS_HEADERS #include <stdarg.h> #include <stdlib.h> #endif @@ -307,7 +304,8 @@ void x86emu_single_step (void) } break; case 'q': - exit(1); + M.x86.debug |= DEBUG_EXIT; + return; case 'P': noDecode = (noDecode)?0:1; printk("Toggled decoding to %s\n",(noDecode)?"FALSE":"TRUE"); diff --git a/hw/xfree86/x86emu/decode.c b/hw/xfree86/x86emu/decode.c index 1294640df..25415d9fa 100644 --- a/hw/xfree86/x86emu/decode.c +++ b/hw/xfree86/x86emu/decode.c @@ -37,8 +37,6 @@ * ****************************************************************************/ -/* $XdotOrg: xc/extras/x86emu/src/x86emu/decode.c,v 1.1.4.1.4.2 2004/03/05 12:46:30 eich Exp $ */ -/* $XFree86: xc/extras/x86emu/src/x86emu/decode.c,v 1.11 2002/07/23 20:20:43 tsi Exp $ */ #include "x86emu/x86emui.h" @@ -105,8 +103,14 @@ DB( if (CHECK_IP_FETCH()) INC_DECODED_INST_LEN(1); if (M.x86.intr) { if (M.x86.intr & INTR_HALTED) { -DB( printk("halted\n"); - X86EMU_trace_regs();) +DB( if (M.x86.R_SP != 0) { + printk("halted\n"); + X86EMU_trace_regs(); + } + else { + if (M.x86.debug) + printk("Service completed successfully\n"); + }) return; } if (((M.x86.intr & INTR_SYNCH) && (M.x86.intno == 0 || M.x86.intno == 2)) || @@ -116,6 +120,10 @@ DB( printk("halted\n"); } op1 = (*sys_rdb)(((u32)M.x86.R_CS << 4) + (M.x86.R_IP++)); (*x86emu_optab[op1])(op1); + if (M.x86.debug & DEBUG_EXIT) { + M.x86.debug &= ~DEBUG_EXIT; + return; + } } } @@ -834,6 +842,7 @@ u32 decode_rm00_address( int sib; if (M.x86.mode & SYSMODE_PREFIX_ADDR) { + /* 32-bit addressing */ switch (rm) { case 0: DECODE_PRINTF("[EAX]"); @@ -863,21 +872,22 @@ u32 decode_rm00_address( } HALT_SYS(); } else { + /* 16-bit addressing */ switch (rm) { case 0: DECODE_PRINTF("[BX+SI]"); - return M.x86.R_BX + M.x86.R_SI; + return (M.x86.R_BX + M.x86.R_SI) & 0xffff; case 1: DECODE_PRINTF("[BX+DI]"); - return M.x86.R_BX + M.x86.R_DI; + return (M.x86.R_BX + M.x86.R_DI) & 0xffff; case 2: DECODE_PRINTF("[BP+SI]"); M.x86.mode |= SYSMODE_SEG_DS_SS; - return M.x86.R_BP + M.x86.R_SI; + return (M.x86.R_BP + M.x86.R_SI) & 0xffff; case 3: DECODE_PRINTF("[BP+DI]"); M.x86.mode |= SYSMODE_SEG_DS_SS; - return M.x86.R_BP + M.x86.R_DI; + return (M.x86.R_BP + M.x86.R_DI) & 0xffff; case 4: DECODE_PRINTF("[SI]"); return M.x86.R_SI; @@ -919,6 +929,7 @@ u32 decode_rm01_address( displacement = (s8)fetch_byte_imm(); if (M.x86.mode & SYSMODE_PREFIX_ADDR) { + /* 32-bit addressing */ switch (rm) { case 0: DECODE_PRINTF2("%d[EAX]", displacement); @@ -949,34 +960,35 @@ u32 decode_rm01_address( } HALT_SYS(); } else { + /* 16-bit addressing */ switch (rm) { case 0: DECODE_PRINTF2("%d[BX+SI]", displacement); - return M.x86.R_BX + M.x86.R_SI + displacement; + return (M.x86.R_BX + M.x86.R_SI + displacement) & 0xffff; case 1: DECODE_PRINTF2("%d[BX+DI]", displacement); - return M.x86.R_BX + M.x86.R_DI + displacement; + return (M.x86.R_BX + M.x86.R_DI + displacement) & 0xffff; case 2: DECODE_PRINTF2("%d[BP+SI]", displacement); M.x86.mode |= SYSMODE_SEG_DS_SS; - return M.x86.R_BP + M.x86.R_SI + displacement; + return (M.x86.R_BP + M.x86.R_SI + displacement) & 0xffff; case 3: DECODE_PRINTF2("%d[BP+DI]", displacement); M.x86.mode |= SYSMODE_SEG_DS_SS; - return M.x86.R_BP + M.x86.R_DI + displacement; + return (M.x86.R_BP + M.x86.R_DI + displacement) & 0xffff; case 4: DECODE_PRINTF2("%d[SI]", displacement); - return M.x86.R_SI + displacement; + return (M.x86.R_SI + displacement) & 0xffff; case 5: DECODE_PRINTF2("%d[DI]", displacement); - return M.x86.R_DI + displacement; + return (M.x86.R_DI + displacement) & 0xffff; case 6: DECODE_PRINTF2("%d[BP]", displacement); M.x86.mode |= SYSMODE_SEG_DS_SS; - return M.x86.R_BP + displacement; + return (M.x86.R_BP + displacement) & 0xffff; case 7: DECODE_PRINTF2("%d[BX]", displacement); - return M.x86.R_BX + displacement; + return (M.x86.R_BX + displacement) & 0xffff; } HALT_SYS(); } @@ -1010,6 +1022,7 @@ u32 decode_rm10_address( } if (M.x86.mode & SYSMODE_PREFIX_ADDR) { + /* 32-bit addressing */ switch (rm) { case 0: DECODE_PRINTF2("%08x[EAX]", displacement); @@ -1042,34 +1055,35 @@ u32 decode_rm10_address( } HALT_SYS(); } else { + /* 16-bit addressing */ switch (rm) { case 0: - DECODE_PRINTF2("%04x[BX+SI]", displacement); - return M.x86.R_BX + M.x86.R_SI + displacement; + DECODE_PRINTF2("%04x[BX+SI]", displacement); + return (M.x86.R_BX + M.x86.R_SI + displacement) & 0xffff; case 1: - DECODE_PRINTF2("%04x[BX+DI]", displacement); - return M.x86.R_BX + M.x86.R_DI + displacement; + DECODE_PRINTF2("%04x[BX+DI]", displacement); + return (M.x86.R_BX + M.x86.R_DI + displacement) & 0xffff; case 2: DECODE_PRINTF2("%04x[BP+SI]", displacement); M.x86.mode |= SYSMODE_SEG_DS_SS; - return M.x86.R_BP + M.x86.R_SI + displacement; + return (M.x86.R_BP + M.x86.R_SI + displacement) & 0xffff; case 3: DECODE_PRINTF2("%04x[BP+DI]", displacement); M.x86.mode |= SYSMODE_SEG_DS_SS; - return M.x86.R_BP + M.x86.R_DI + displacement; + return (M.x86.R_BP + M.x86.R_DI + displacement) & 0xffff; case 4: - DECODE_PRINTF2("%04x[SI]", displacement); - return M.x86.R_SI + displacement; + DECODE_PRINTF2("%04x[SI]", displacement); + return (M.x86.R_SI + displacement) & 0xffff; case 5: - DECODE_PRINTF2("%04x[DI]", displacement); - return M.x86.R_DI + displacement; + DECODE_PRINTF2("%04x[DI]", displacement); + return (M.x86.R_DI + displacement) & 0xffff; case 6: DECODE_PRINTF2("%04x[BP]", displacement); M.x86.mode |= SYSMODE_SEG_DS_SS; - return M.x86.R_BP + displacement; + return (M.x86.R_BP + displacement) & 0xffff; case 7: - DECODE_PRINTF2("%04x[BX]", displacement); - return M.x86.R_BX + displacement; + DECODE_PRINTF2("%04x[BX]", displacement); + return (M.x86.R_BX + displacement) & 0xffff; } HALT_SYS(); } diff --git a/hw/xfree86/x86emu/fpu.c b/hw/xfree86/x86emu/fpu.c index 4b801dc94..b72de1ee5 100644 --- a/hw/xfree86/x86emu/fpu.c +++ b/hw/xfree86/x86emu/fpu.c @@ -36,7 +36,6 @@ * emulation of the FPU instructions. * ****************************************************************************/ -/* $XFree86$ */ #include "x86emu/x86emui.h" diff --git a/hw/xfree86/x86emu/ops.c b/hw/xfree86/x86emu/ops.c index 88ee7e108..37ae2c9c9 100644 --- a/hw/xfree86/x86emu/ops.c +++ b/hw/xfree86/x86emu/ops.c @@ -70,8 +70,6 @@ * ****************************************************************************/ -/* $XFree86: xc/extras/x86emu/src/x86emu/ops.c,v 1.8tsi Exp $ */ - #include "x86emu/x86emui.h" /*----------------------------- Implementation ----------------------------*/ @@ -87,11 +85,22 @@ static void x86emuOp_illegal_op( u8 op1) { START_OF_INSTR(); + if (M.x86.R_SP != 0) { DECODE_PRINTF("ILLEGAL X86 OPCODE\n"); TRACE_REGS(); - printk("%04x:%04x: %02X ILLEGAL X86 OPCODE!\n", - M.x86.R_CS, M.x86.R_IP-1,op1); + DB( printk("%04x:%04x: %02X ILLEGAL X86 OPCODE!\n", + M.x86.R_CS, M.x86.R_IP-1,op1)); HALT_SYS(); + } + else { + /* If we get here, it means the stack pointer is back to zero + * so we are just returning from an emulator service call + * so therte is no need to display an error message. We trap + * the emulator with an 0xF1 opcode to finish the service + * call. + */ + X86EMU_halt_sys(); + } END_OF_INSTR(); } @@ -9404,6 +9413,8 @@ static void x86emuOp_aam(u8 X86EMU_UNUSED(op1)) DECODE_PRINTF("AAM\n"); a = fetch_byte_imm(); /* this is a stupid encoding. */ if (a != 10) { + /* fix: add base decoding + aam_word(u8 val, int base a) */ DECODE_PRINTF("ERROR DECODING AAM\n"); TRACE_REGS(); HALT_SYS(); @@ -9421,9 +9432,18 @@ Handles opcode 0xd5 ****************************************************************************/ static void x86emuOp_aad(u8 X86EMU_UNUSED(op1)) { + u8 a; + START_OF_INSTR(); DECODE_PRINTF("AAD\n"); - (void) fetch_byte_imm(); + a = fetch_byte_imm(); + if (a != 10) { + /* fix: add base decoding + aad_word(u16 val, int base a) */ + DECODE_PRINTF("ERROR DECODING AAM\n"); + TRACE_REGS(); + HALT_SYS(); + } TRACE_AND_STEP(); M.x86.R_AX = aad_word(M.x86.R_AX); DECODE_CLEAR_SEGOVR(); diff --git a/hw/xfree86/x86emu/ops2.c b/hw/xfree86/x86emu/ops2.c index 7cb585bc8..d9e5de9c5 100644 --- a/hw/xfree86/x86emu/ops2.c +++ b/hw/xfree86/x86emu/ops2.c @@ -37,7 +37,6 @@ * instructions. * ****************************************************************************/ -/* $XFree86: xc/extras/x86emu/src/x86emu/ops2.c,v 1.6tsi Exp $ */ #include "x86emu/x86emui.h" diff --git a/hw/xfree86/x86emu/prim_ops.c b/hw/xfree86/x86emu/prim_ops.c index ba4ffdeda..56ab8cc9a 100644 --- a/hw/xfree86/x86emu/prim_ops.c +++ b/hw/xfree86/x86emu/prim_ops.c @@ -102,8 +102,6 @@ /*------------------------- Global Variables ------------------------------*/ -#ifndef __HAVE_INLINE_ASSEMBLER__ - static u32 x86emu_parity_tab[8] = { 0x96696996, @@ -116,15 +114,11 @@ static u32 x86emu_parity_tab[8] = 0x69969669, }; -#endif - #define PARITY(x) (((x86emu_parity_tab[(x) / 32] >> ((x) % 32)) & 1) == 0) #define XOR2(x) (((x) ^ ((x)>>1)) & 0x1) /*----------------------------- Implementation ----------------------------*/ -#ifndef __HAVE_INLINE_ASSEMBLER__ - /**************************************************************************** REMARKS: Implements the AAA instruction and side effects. @@ -2454,8 +2448,6 @@ void div_long(u32 s) M.x86.R_EDX = (u32)mod; } -#endif /* __HAVE_INLINE_ASSEMBLER__ */ - /**************************************************************************** REMARKS: Implements the IN string instruction and side effects. @@ -2660,255 +2652,3 @@ DB( if (CHECK_SP_ACCESS()) return res; } -#ifdef __HAVE_INLINE_ASSEMBLER__ - -u16 aaa_word (u16 d) -{ return aaa_word_asm(&M.x86.R_EFLG,d); } - -u16 aas_word (u16 d) -{ return aas_word_asm(&M.x86.R_EFLG,d); } - -u16 aad_word (u16 d) -{ return aad_word_asm(&M.x86.R_EFLG,d); } - -u16 aam_word (u8 d) -{ return aam_word_asm(&M.x86.R_EFLG,d); } - -u8 adc_byte (u8 d, u8 s) -{ return adc_byte_asm(&M.x86.R_EFLG,d,s); } - -u16 adc_word (u16 d, u16 s) -{ return adc_word_asm(&M.x86.R_EFLG,d,s); } - -u32 adc_long (u32 d, u32 s) -{ return adc_long_asm(&M.x86.R_EFLG,d,s); } - -u8 add_byte (u8 d, u8 s) -{ return add_byte_asm(&M.x86.R_EFLG,d,s); } - -u16 add_word (u16 d, u16 s) -{ return add_word_asm(&M.x86.R_EFLG,d,s); } - -u32 add_long (u32 d, u32 s) -{ return add_long_asm(&M.x86.R_EFLG,d,s); } - -u8 and_byte (u8 d, u8 s) -{ return and_byte_asm(&M.x86.R_EFLG,d,s); } - -u16 and_word (u16 d, u16 s) -{ return and_word_asm(&M.x86.R_EFLG,d,s); } - -u32 and_long (u32 d, u32 s) -{ return and_long_asm(&M.x86.R_EFLG,d,s); } - -u8 cmp_byte (u8 d, u8 s) -{ return cmp_byte_asm(&M.x86.R_EFLG,d,s); } - -u16 cmp_word (u16 d, u16 s) -{ return cmp_word_asm(&M.x86.R_EFLG,d,s); } - -u32 cmp_long (u32 d, u32 s) -{ return cmp_long_asm(&M.x86.R_EFLG,d,s); } - -u8 daa_byte (u8 d) -{ return daa_byte_asm(&M.x86.R_EFLG,d); } - -u8 das_byte (u8 d) -{ return das_byte_asm(&M.x86.R_EFLG,d); } - -u8 dec_byte (u8 d) -{ return dec_byte_asm(&M.x86.R_EFLG,d); } - -u16 dec_word (u16 d) -{ return dec_word_asm(&M.x86.R_EFLG,d); } - -u32 dec_long (u32 d) -{ return dec_long_asm(&M.x86.R_EFLG,d); } - -u8 inc_byte (u8 d) -{ return inc_byte_asm(&M.x86.R_EFLG,d); } - -u16 inc_word (u16 d) -{ return inc_word_asm(&M.x86.R_EFLG,d); } - -u32 inc_long (u32 d) -{ return inc_long_asm(&M.x86.R_EFLG,d); } - -u8 or_byte (u8 d, u8 s) -{ return or_byte_asm(&M.x86.R_EFLG,d,s); } - -u16 or_word (u16 d, u16 s) -{ return or_word_asm(&M.x86.R_EFLG,d,s); } - -u32 or_long (u32 d, u32 s) -{ return or_long_asm(&M.x86.R_EFLG,d,s); } - -u8 neg_byte (u8 s) -{ return neg_byte_asm(&M.x86.R_EFLG,s); } - -u16 neg_word (u16 s) -{ return neg_word_asm(&M.x86.R_EFLG,s); } - -u32 neg_long (u32 s) -{ return neg_long_asm(&M.x86.R_EFLG,s); } - -u8 not_byte (u8 s) -{ return not_byte_asm(&M.x86.R_EFLG,s); } - -u16 not_word (u16 s) -{ return not_word_asm(&M.x86.R_EFLG,s); } - -u32 not_long (u32 s) -{ return not_long_asm(&M.x86.R_EFLG,s); } - -u8 rcl_byte (u8 d, u8 s) -{ return rcl_byte_asm(&M.x86.R_EFLG,d,s); } - -u16 rcl_word (u16 d, u8 s) -{ return rcl_word_asm(&M.x86.R_EFLG,d,s); } - -u32 rcl_long (u32 d, u8 s) -{ return rcl_long_asm(&M.x86.R_EFLG,d,s); } - -u8 rcr_byte (u8 d, u8 s) -{ return rcr_byte_asm(&M.x86.R_EFLG,d,s); } - -u16 rcr_word (u16 d, u8 s) -{ return rcr_word_asm(&M.x86.R_EFLG,d,s); } - -u32 rcr_long (u32 d, u8 s) -{ return rcr_long_asm(&M.x86.R_EFLG,d,s); } - -u8 rol_byte (u8 d, u8 s) -{ return rol_byte_asm(&M.x86.R_EFLG,d,s); } - -u16 rol_word (u16 d, u8 s) -{ return rol_word_asm(&M.x86.R_EFLG,d,s); } - -u32 rol_long (u32 d, u8 s) -{ return rol_long_asm(&M.x86.R_EFLG,d,s); } - -u8 ror_byte (u8 d, u8 s) -{ return ror_byte_asm(&M.x86.R_EFLG,d,s); } - -u16 ror_word (u16 d, u8 s) -{ return ror_word_asm(&M.x86.R_EFLG,d,s); } - -u32 ror_long (u32 d, u8 s) -{ return ror_long_asm(&M.x86.R_EFLG,d,s); } - -u8 shl_byte (u8 d, u8 s) -{ return shl_byte_asm(&M.x86.R_EFLG,d,s); } - -u16 shl_word (u16 d, u8 s) -{ return shl_word_asm(&M.x86.R_EFLG,d,s); } - -u32 shl_long (u32 d, u8 s) -{ return shl_long_asm(&M.x86.R_EFLG,d,s); } - -u8 shr_byte (u8 d, u8 s) -{ return shr_byte_asm(&M.x86.R_EFLG,d,s); } - -u16 shr_word (u16 d, u8 s) -{ return shr_word_asm(&M.x86.R_EFLG,d,s); } - -u32 shr_long (u32 d, u8 s) -{ return shr_long_asm(&M.x86.R_EFLG,d,s); } - -u8 sar_byte (u8 d, u8 s) -{ return sar_byte_asm(&M.x86.R_EFLG,d,s); } - -u16 sar_word (u16 d, u8 s) -{ return sar_word_asm(&M.x86.R_EFLG,d,s); } - -u32 sar_long (u32 d, u8 s) -{ return sar_long_asm(&M.x86.R_EFLG,d,s); } - -u16 shld_word (u16 d, u16 fill, u8 s) -{ return shld_word_asm(&M.x86.R_EFLG,d,fill,s); } - -u32 shld_long (u32 d, u32 fill, u8 s) -{ return shld_long_asm(&M.x86.R_EFLG,d,fill,s); } - -u16 shrd_word (u16 d, u16 fill, u8 s) -{ return shrd_word_asm(&M.x86.R_EFLG,d,fill,s); } - -u32 shrd_long (u32 d, u32 fill, u8 s) -{ return shrd_long_asm(&M.x86.R_EFLG,d,fill,s); } - -u8 sbb_byte (u8 d, u8 s) -{ return sbb_byte_asm(&M.x86.R_EFLG,d,s); } - -u16 sbb_word (u16 d, u16 s) -{ return sbb_word_asm(&M.x86.R_EFLG,d,s); } - -u32 sbb_long (u32 d, u32 s) -{ return sbb_long_asm(&M.x86.R_EFLG,d,s); } - -u8 sub_byte (u8 d, u8 s) -{ return sub_byte_asm(&M.x86.R_EFLG,d,s); } - -u16 sub_word (u16 d, u16 s) -{ return sub_word_asm(&M.x86.R_EFLG,d,s); } - -u32 sub_long (u32 d, u32 s) -{ return sub_long_asm(&M.x86.R_EFLG,d,s); } - -void test_byte (u8 d, u8 s) -{ test_byte_asm(&M.x86.R_EFLG,d,s); } - -void test_word (u16 d, u16 s) -{ test_word_asm(&M.x86.R_EFLG,d,s); } - -void test_long (u32 d, u32 s) -{ test_long_asm(&M.x86.R_EFLG,d,s); } - -u8 xor_byte (u8 d, u8 s) -{ return xor_byte_asm(&M.x86.R_EFLG,d,s); } - -u16 xor_word (u16 d, u16 s) -{ return xor_word_asm(&M.x86.R_EFLG,d,s); } - -u32 xor_long (u32 d, u32 s) -{ return xor_long_asm(&M.x86.R_EFLG,d,s); } - -void imul_byte (u8 s) -{ imul_byte_asm(&M.x86.R_EFLG,&M.x86.R_AX,M.x86.R_AL,s); } - -void imul_word (u16 s) -{ imul_word_asm(&M.x86.R_EFLG,&M.x86.R_AX,&M.x86.R_DX,M.x86.R_AX,s); } - -void imul_long (u32 s) -{ imul_long_asm(&M.x86.R_EFLG,&M.x86.R_EAX,&M.x86.R_EDX,M.x86.R_EAX,s); } - -void imul_long_direct(u32 *res_lo, u32* res_hi,u32 d, u32 s) -{ imul_long_asm(&M.x86.R_EFLG,res_lo,res_hi,d,s); } - -void mul_byte (u8 s) -{ mul_byte_asm(&M.x86.R_EFLG,&M.x86.R_AX,M.x86.R_AL,s); } - -void mul_word (u16 s) -{ mul_word_asm(&M.x86.R_EFLG,&M.x86.R_AX,&M.x86.R_DX,M.x86.R_AX,s); } - -void mul_long (u32 s) -{ mul_long_asm(&M.x86.R_EFLG,&M.x86.R_EAX,&M.x86.R_EDX,M.x86.R_EAX,s); } - -void idiv_byte (u8 s) -{ idiv_byte_asm(&M.x86.R_EFLG,&M.x86.R_AL,&M.x86.R_AH,M.x86.R_AX,s); } - -void idiv_word (u16 s) -{ idiv_word_asm(&M.x86.R_EFLG,&M.x86.R_AX,&M.x86.R_DX,M.x86.R_AX,M.x86.R_DX,s); } - -void idiv_long (u32 s) -{ idiv_long_asm(&M.x86.R_EFLG,&M.x86.R_EAX,&M.x86.R_EDX,M.x86.R_EAX,M.x86.R_EDX,s); } - -void div_byte (u8 s) -{ div_byte_asm(&M.x86.R_EFLG,&M.x86.R_AL,&M.x86.R_AH,M.x86.R_AX,s); } - -void div_word (u16 s) -{ div_word_asm(&M.x86.R_EFLG,&M.x86.R_AX,&M.x86.R_DX,M.x86.R_AX,M.x86.R_DX,s); } - -void div_long (u32 s) -{ div_long_asm(&M.x86.R_EFLG,&M.x86.R_EAX,&M.x86.R_EDX,M.x86.R_EAX,M.x86.R_EDX,s); } - -#endif diff --git a/hw/xfree86/x86emu/sys.c b/hw/xfree86/x86emu/sys.c index 39941360d..4d90ea315 100644 --- a/hw/xfree86/x86emu/sys.c +++ b/hw/xfree86/x86emu/sys.c @@ -39,16 +39,13 @@ * user library. * ****************************************************************************/ -/* $XFree86: xc/extras/x86emu/src/x86emu/sys.c,v 1.6 2002/09/16 18:05:18 eich Exp $ */ #include "x86emu.h" #include "x86emu/x86emui.h" #include "x86emu/regs.h" #include "x86emu/debug.h" #include "x86emu/prim_ops.h" -#ifdef IN_MODULE -#include "xf86_ansic.h" -#else +#ifndef NO_SYS_HEADERS #include <string.h> #endif /*------------------------- Global Variables ------------------------------*/ @@ -60,6 +57,7 @@ X86EMU_intrFuncs _X86EMU_intrTab[256]; #if defined(__alpha__) || defined(__alpha) /* to cope with broken egcs-1.1.2 :-(((( */ +#define ALPHA_UALOADS /* * inline functions to do unaligned accesses * from linux/include/asm-alpha/unaligned.h @@ -211,6 +209,60 @@ static __inline__ void stw_u(unsigned long r5, unsigned short * r11) :"r" (r5), "r" (r11)); #endif } + +#elif defined(__GNUC__) && ((__GNUC__ < 3)) && \ + (defined (__ia64__) || defined (ia64__)) +#define IA64_UALOADS +/* + * EGCS 1.1 knows about arbitrary unaligned loads. Define some + * packed structures to talk about such things with. + */ +struct __una_u64 { unsigned long x __attribute__((packed)); }; +struct __una_u32 { unsigned int x __attribute__((packed)); }; +struct __una_u16 { unsigned short x __attribute__((packed)); }; + +static __inline__ unsigned long +__uldq (const unsigned long * r11) +{ + const struct __una_u64 *ptr = (const struct __una_u64 *) r11; + return ptr->x; +} + +static __inline__ unsigned long +uldl (const unsigned int * r11) +{ + const struct __una_u32 *ptr = (const struct __una_u32 *) r11; + return ptr->x; +} + +static __inline__ unsigned long +uldw (const unsigned short * r11) +{ + const struct __una_u16 *ptr = (const struct __una_u16 *) r11; + return ptr->x; +} + +static __inline__ void +ustq (unsigned long r5, unsigned long * r11) +{ + struct __una_u64 *ptr = (struct __una_u64 *) r11; + ptr->x = r5; +} + +static __inline__ void +ustl (unsigned long r5, unsigned int * r11) +{ + struct __una_u32 *ptr = (struct __una_u32 *) r11; + ptr->x = r5; +} + +static __inline__ void +ustw (unsigned long r5, unsigned short * r11) +{ + struct __una_u16 *ptr = (struct __una_u16 *) r11; + ptr->x = r5; +} + #endif /**************************************************************************** @@ -264,8 +316,10 @@ u16 X86API rdw( } else #endif -#if defined(__alpha__) || defined(__alpha) +#if defined(ALPHA_UALOADS) val = ldw_u((u16*)(M.mem_base + addr)); +#elif defined(IA64_UALOADS) + val = uldw((u16*)(M.mem_base + addr)); #else val = *(u16*)(M.mem_base + addr); #endif @@ -301,8 +355,10 @@ u32 X86API rdl( } else #endif -#if defined(__alpha__) || defined(__alpha) +#if defined(ALPHA_UALOADS) val = ldl_u((u32*)(M.mem_base + addr)); +#elif defined(IA64_UALOADS) + val = uldl((u32*)(M.mem_base + addr)); #else val = *(u32*)(M.mem_base + addr); #endif @@ -357,8 +413,10 @@ DB( if (DEBUG_MEM_TRACE()) } else #endif -#if defined(__alpha__) || defined(__alpha) +#if defined(ALPHA_UALOADS) stw_u(val,(u16*)(M.mem_base + addr)); +#elif defined(IA64_UALOADS) + ustw(val,(u16*)(M.mem_base + addr)); #else *(u16*)(M.mem_base + addr) = val; #endif @@ -391,8 +449,10 @@ DB( if (DEBUG_MEM_TRACE()) } else #endif -#if defined(__alpha__) || defined(__alpha) +#if defined(ALPHA_UALOADS) stl_u(val,(u32*)(M.mem_base + addr)); +#elif defined(IA64_UALOADS) + ustl(val,(u32*)(M.mem_base + addr)); #else *(u32*)(M.mem_base + addr) = val; #endif diff --git a/hw/xfree86/x86emu/x86emu.h b/hw/xfree86/x86emu/x86emu.h index 1df9ac50d..795e2d688 100644 --- a/hw/xfree86/x86emu/x86emu.h +++ b/hw/xfree86/x86emu/x86emu.h @@ -37,7 +37,6 @@ * include this header * ****************************************************************************/ -/* $XFree86$ */ #ifndef __X86EMU_X86EMU_H #define __X86EMU_X86EMU_H @@ -56,7 +55,9 @@ typedef int X86EMU_pioAddr; /*---------------------- Macros and type definitions ----------------------*/ -/* #pragma pack(1) */ /* Don't pack structs with function pointers! */ +#ifdef PACK +# pragma PACK /* Don't pack structs with function pointers! */ +#endif /**************************************************************************** REMARKS: @@ -129,8 +130,10 @@ extern u32 X86API rdl(u32 addr); extern void X86API wrb(u32 addr, u8 val); extern void X86API wrw(u32 addr, u16 val); extern void X86API wrl(u32 addr, u32 val); - -/* #pragma pack() */ + +#ifdef END_PACK +# pragma END_PACK +#endif /*--------------------- type definitions -----------------------------------*/ @@ -169,6 +172,7 @@ void X86EMU_halt_sys(void); #define DEBUG_DISASSEMBLE_F 0x000008 #define DEBUG_BREAK_F 0x000010 #define DEBUG_SVC_F 0x000020 +#define DEBUG_SAVE_IP_CS_F 0x000040 #define DEBUG_FS_F 0x000080 #define DEBUG_PROC_F 0x000100 #define DEBUG_SYSINT_F 0x000200 /* bios system interrupts. */ @@ -178,7 +182,7 @@ void X86EMU_halt_sys(void); #define DEBUG_IO_TRACE_F 0x002000 #define DEBUG_TRACECALL_REGS_F 0x004000 #define DEBUG_DECODE_NOPRINT_F 0x008000 -#define DEBUG_SAVE_IP_CS_F 0x010000 +#define DEBUG_EXIT 0x010000 #define DEBUG_SYS_F (DEBUG_SVC_F|DEBUG_FS_F|DEBUG_PROC_F) void X86EMU_trace_regs(void); diff --git a/hw/xfree86/x86emu/x86emu/debug.h b/hw/xfree86/x86emu/x86emu/debug.h index 8abedf616..47aacb6c3 100644 --- a/hw/xfree86/x86emu/x86emu/debug.h +++ b/hw/xfree86/x86emu/x86emu/debug.h @@ -35,7 +35,6 @@ * Description: Header file for debug definitions. * ****************************************************************************/ -/* $XFree86: xc/extras/x86emu/src/x86emu/x86emu/debug.h,v 1.3 2000/04/19 15:48:15 tsi Exp $ */ #ifndef __X86EMU_DEBUG_H #define __X86EMU_DEBUG_H diff --git a/hw/xfree86/x86emu/x86emu/decode.h b/hw/xfree86/x86emu/x86emu/decode.h index bb2bc0bee..61cd4dc10 100644 --- a/hw/xfree86/x86emu/x86emu/decode.h +++ b/hw/xfree86/x86emu/x86emu/decode.h @@ -35,7 +35,6 @@ * Description: Header file for instruction decoding logic. * ****************************************************************************/ -/* $XFree86$ */ #ifndef __X86EMU_DECODE_H #define __X86EMU_DECODE_H diff --git a/hw/xfree86/x86emu/x86emu/fpu_regs.h b/hw/xfree86/x86emu/x86emu/fpu_regs.h index a125075b7..e59b80783 100644 --- a/hw/xfree86/x86emu/x86emu/fpu_regs.h +++ b/hw/xfree86/x86emu/x86emu/fpu_regs.h @@ -35,13 +35,16 @@ * Description: Header file for FPU register definitions. * ****************************************************************************/ -/* $XFree86: xc/extras/x86emu/include/x86emu/fpu_regs.h,v 1.2 2003/10/22 20:03:05 tsi Exp $ */ #ifndef __X86EMU_FPU_REGS_H #define __X86EMU_FPU_REGS_H #ifdef X86_FPU_SUPPORT +#ifdef PACK +# pragma PACK +#endif + /* Basic 8087 register can hold any of the following values: */ union x86_fpu_reg_u { @@ -86,6 +89,10 @@ struct x86_fpu_registers { short x86_fpu_tos, x86_fpu_bos; }; +#ifdef END_PACK +# pragma END_PACK +#endif + /* * There are two versions of the following macro. * diff --git a/hw/xfree86/x86emu/x86emu/prim_asm.h b/hw/xfree86/x86emu/x86emu/prim_asm.h index 041255f18..e023cf88d 100644 --- a/hw/xfree86/x86emu/x86emu/prim_asm.h +++ b/hw/xfree86/x86emu/x86emu/prim_asm.h @@ -39,7 +39,6 @@ * platform. * ****************************************************************************/ -/* $XFree86$ */ #ifndef __X86EMU_PRIM_ASM_H #define __X86EMU_PRIM_ASM_H diff --git a/hw/xfree86/x86emu/x86emu/prim_ops.h b/hw/xfree86/x86emu/x86emu/prim_ops.h index 1633fe1fa..bea8357e4 100644 --- a/hw/xfree86/x86emu/x86emu/prim_ops.h +++ b/hw/xfree86/x86emu/x86emu/prim_ops.h @@ -39,8 +39,6 @@ #ifndef __X86EMU_PRIM_OPS_H #define __X86EMU_PRIM_OPS_H -#include "x86emu/prim_asm.h" - #ifdef __cplusplus extern "C" { /* Use "C" linkage when in C++ mode */ #endif @@ -136,94 +134,6 @@ void push_long (u32 w); u16 pop_word (void); u32 pop_long (void); -#if defined(__HAVE_INLINE_ASSEMBLER__) && !defined(PRIM_OPS_NO_REDEFINE_ASM) - -#define aaa_word(d) aaa_word_asm(&M.x86.R_EFLG,d) -#define aas_word(d) aas_word_asm(&M.x86.R_EFLG,d) -#define aad_word(d) aad_word_asm(&M.x86.R_EFLG,d) -#define aam_word(d) aam_word_asm(&M.x86.R_EFLG,d) -#define adc_byte(d,s) adc_byte_asm(&M.x86.R_EFLG,d,s) -#define adc_word(d,s) adc_word_asm(&M.x86.R_EFLG,d,s) -#define adc_long(d,s) adc_long_asm(&M.x86.R_EFLG,d,s) -#define add_byte(d,s) add_byte_asm(&M.x86.R_EFLG,d,s) -#define add_word(d,s) add_word_asm(&M.x86.R_EFLG,d,s) -#define add_long(d,s) add_long_asm(&M.x86.R_EFLG,d,s) -#define and_byte(d,s) and_byte_asm(&M.x86.R_EFLG,d,s) -#define and_word(d,s) and_word_asm(&M.x86.R_EFLG,d,s) -#define and_long(d,s) and_long_asm(&M.x86.R_EFLG,d,s) -#define cmp_byte(d,s) cmp_byte_asm(&M.x86.R_EFLG,d,s) -#define cmp_word(d,s) cmp_word_asm(&M.x86.R_EFLG,d,s) -#define cmp_long(d,s) cmp_long_asm(&M.x86.R_EFLG,d,s) -#define daa_byte(d) daa_byte_asm(&M.x86.R_EFLG,d) -#define das_byte(d) das_byte_asm(&M.x86.R_EFLG,d) -#define dec_byte(d) dec_byte_asm(&M.x86.R_EFLG,d) -#define dec_word(d) dec_word_asm(&M.x86.R_EFLG,d) -#define dec_long(d) dec_long_asm(&M.x86.R_EFLG,d) -#define inc_byte(d) inc_byte_asm(&M.x86.R_EFLG,d) -#define inc_word(d) inc_word_asm(&M.x86.R_EFLG,d) -#define inc_long(d) inc_long_asm(&M.x86.R_EFLG,d) -#define or_byte(d,s) or_byte_asm(&M.x86.R_EFLG,d,s) -#define or_word(d,s) or_word_asm(&M.x86.R_EFLG,d,s) -#define or_long(d,s) or_long_asm(&M.x86.R_EFLG,d,s) -#define neg_byte(s) neg_byte_asm(&M.x86.R_EFLG,s) -#define neg_word(s) neg_word_asm(&M.x86.R_EFLG,s) -#define neg_long(s) neg_long_asm(&M.x86.R_EFLG,s) -#define not_byte(s) not_byte_asm(&M.x86.R_EFLG,s) -#define not_word(s) not_word_asm(&M.x86.R_EFLG,s) -#define not_long(s) not_long_asm(&M.x86.R_EFLG,s) -#define rcl_byte(d,s) rcl_byte_asm(&M.x86.R_EFLG,d,s) -#define rcl_word(d,s) rcl_word_asm(&M.x86.R_EFLG,d,s) -#define rcl_long(d,s) rcl_long_asm(&M.x86.R_EFLG,d,s) -#define rcr_byte(d,s) rcr_byte_asm(&M.x86.R_EFLG,d,s) -#define rcr_word(d,s) rcr_word_asm(&M.x86.R_EFLG,d,s) -#define rcr_long(d,s) rcr_long_asm(&M.x86.R_EFLG,d,s) -#define rol_byte(d,s) rol_byte_asm(&M.x86.R_EFLG,d,s) -#define rol_word(d,s) rol_word_asm(&M.x86.R_EFLG,d,s) -#define rol_long(d,s) rol_long_asm(&M.x86.R_EFLG,d,s) -#define ror_byte(d,s) ror_byte_asm(&M.x86.R_EFLG,d,s) -#define ror_word(d,s) ror_word_asm(&M.x86.R_EFLG,d,s) -#define ror_long(d,s) ror_long_asm(&M.x86.R_EFLG,d,s) -#define shl_byte(d,s) shl_byte_asm(&M.x86.R_EFLG,d,s) -#define shl_word(d,s) shl_word_asm(&M.x86.R_EFLG,d,s) -#define shl_long(d,s) shl_long_asm(&M.x86.R_EFLG,d,s) -#define shr_byte(d,s) shr_byte_asm(&M.x86.R_EFLG,d,s) -#define shr_word(d,s) shr_word_asm(&M.x86.R_EFLG,d,s) -#define shr_long(d,s) shr_long_asm(&M.x86.R_EFLG,d,s) -#define sar_byte(d,s) sar_byte_asm(&M.x86.R_EFLG,d,s) -#define sar_word(d,s) sar_word_asm(&M.x86.R_EFLG,d,s) -#define sar_long(d,s) sar_long_asm(&M.x86.R_EFLG,d,s) -#define shld_word(d,fill,s) shld_word_asm(&M.x86.R_EFLG,d,fill,s) -#define shld_long(d,fill,s) shld_long_asm(&M.x86.R_EFLG,d,fill,s) -#define shrd_word(d,fill,s) shrd_word_asm(&M.x86.R_EFLG,d,fill,s) -#define shrd_long(d,fill,s) shrd_long_asm(&M.x86.R_EFLG,d,fill,s) -#define sbb_byte(d,s) sbb_byte_asm(&M.x86.R_EFLG,d,s) -#define sbb_word(d,s) sbb_word_asm(&M.x86.R_EFLG,d,s) -#define sbb_long(d,s) sbb_long_asm(&M.x86.R_EFLG,d,s) -#define sub_byte(d,s) sub_byte_asm(&M.x86.R_EFLG,d,s) -#define sub_word(d,s) sub_word_asm(&M.x86.R_EFLG,d,s) -#define sub_long(d,s) sub_long_asm(&M.x86.R_EFLG,d,s) -#define test_byte(d,s) test_byte_asm(&M.x86.R_EFLG,d,s) -#define test_word(d,s) test_word_asm(&M.x86.R_EFLG,d,s) -#define test_long(d,s) test_long_asm(&M.x86.R_EFLG,d,s) -#define xor_byte(d,s) xor_byte_asm(&M.x86.R_EFLG,d,s) -#define xor_word(d,s) xor_word_asm(&M.x86.R_EFLG,d,s) -#define xor_long(d,s) xor_long_asm(&M.x86.R_EFLG,d,s) -#define imul_byte(s) imul_byte_asm(&M.x86.R_EFLG,&M.x86.R_AX,M.x86.R_AL,s) -#define imul_word(s) imul_word_asm(&M.x86.R_EFLG,&M.x86.R_AX,&M.x86.R_DX,M.x86.R_AX,s) -#define imul_long(s) imul_long_asm(&M.x86.R_EFLG,&M.x86.R_EAX,&M.x86.R_EDX,M.x86.R_EAX,s) -#define imul_long_direct(res_lo,res_hi,d,s) imul_long_asm(&M.x86.R_EFLG,res_lo,res_hi,d,s) -#define mul_byte(s) mul_byte_asm(&M.x86.R_EFLG,&M.x86.R_AX,M.x86.R_AL,s) -#define mul_word(s) mul_word_asm(&M.x86.R_EFLG,&M.x86.R_AX,&M.x86.R_DX,M.x86.R_AX,s) -#define mul_long(s) mul_long_asm(&M.x86.R_EFLG,&M.x86.R_EAX,&M.x86.R_EDX,M.x86.R_EAX,s) -#define idiv_byte(s) idiv_byte_asm(&M.x86.R_EFLG,&M.x86.R_AL,&M.x86.R_AH,M.x86.R_AX,s) -#define idiv_word(s) idiv_word_asm(&M.x86.R_EFLG,&M.x86.R_AX,&M.x86.R_DX,M.x86.R_AX,M.x86.R_DX,s) -#define idiv_long(s) idiv_long_asm(&M.x86.R_EFLG,&M.x86.R_EAX,&M.x86.R_EDX,M.x86.R_EAX,M.x86.R_EDX,s) -#define div_byte(s) div_byte_asm(&M.x86.R_EFLG,&M.x86.R_AL,&M.x86.R_AH,M.x86.R_AX,s) -#define div_word(s) div_word_asm(&M.x86.R_EFLG,&M.x86.R_AX,&M.x86.R_DX,M.x86.R_AX,M.x86.R_DX,s) -#define div_long(s) div_long_asm(&M.x86.R_EFLG,&M.x86.R_EAX,&M.x86.R_EDX,M.x86.R_EAX,M.x86.R_EDX,s) - -#endif - #ifdef __cplusplus } /* End of "C" linkage for C++ */ #endif diff --git a/hw/xfree86/x86emu/x86emu/regs.h b/hw/xfree86/x86emu/x86emu/regs.h index fba2991d4..52cf8e41b 100644 --- a/hw/xfree86/x86emu/x86emu/regs.h +++ b/hw/xfree86/x86emu/x86emu/regs.h @@ -35,13 +35,16 @@ * Description: Header file for x86 register definitions. * ****************************************************************************/ -/* $XFree86: xc/extras/x86emu/include/x86emu/regs.h,v 1.5 2003/10/22 20:03:05 tsi Exp $ */ #ifndef __X86EMU_REGS_H #define __X86EMU_REGS_H /*---------------------- Macros and type definitions ----------------------*/ +#ifdef PACK +# pragma PACK +#endif + /* * General EAX, EBX, ECX, EDX type registers. Note that for * portability, and speed, the issue of byte swapping is not addressed @@ -303,6 +306,10 @@ typedef struct { X86EMU_regs x86; } X86EMU_sysEnv; +#ifdef END_PACK +# pragma END_PACK +#endif + /*----------------------------- Global Variables --------------------------*/ #ifdef __cplusplus diff --git a/hw/xfree86/x86emu/x86emu/types.h b/hw/xfree86/x86emu/x86emu/types.h index 5232d10ac..c0c09c1b0 100644 --- a/hw/xfree86/x86emu/x86emu/types.h +++ b/hw/xfree86/x86emu/x86emu/types.h @@ -36,12 +36,11 @@ * ****************************************************************************/ -/* $XFree86: xc/extras/x86emu/include/x86emu/types.h,v 1.6 2003/06/12 14:12:26 eich Exp $ */ #ifndef __X86EMU_TYPES_H #define __X86EMU_TYPES_H -#ifndef IN_MODULE +#ifndef NO_SYS_HEADERS #include <sys/types.h> #endif diff --git a/hw/xfree86/x86emu/x86emu/x86emui.h b/hw/xfree86/x86emu/x86emu/x86emui.h index 3adf61ec6..112ee366f 100644 --- a/hw/xfree86/x86emu/x86emu/x86emui.h +++ b/hw/xfree86/x86emu/x86emu/x86emui.h @@ -38,7 +38,6 @@ * ****************************************************************************/ -/* $XFree86: xc/extras/x86emu/src/x86emu/x86emu/x86emui.h,v 1.3 2000/04/17 16:29:47 eich Exp $ */ #ifndef __X86EMU_X86EMUI_H #define __X86EMU_X86EMUI_H @@ -71,9 +70,7 @@ #include "x86emu/fpu.h" #include "x86emu/fpu_regs.h" -#ifdef IN_MODULE -#include <xf86_ansic.h> -#else +#ifndef NO_SYS_HEADERS #include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/hw/xfree86/xaa/xaa.h b/hw/xfree86/xaa/xaa.h index 98db3cf50..d4ff7bbd8 100644 --- a/hw/xfree86/xaa/xaa.h +++ b/hw/xfree86/xaa/xaa.h @@ -1278,6 +1278,10 @@ typedef struct _XAAInfoRec { GlyphPtr *glyphs ); + /* The old SetupForCPUToScreenAlphaTexture function is no longer used because + * it doesn't pass in enough information to write a conforming + * implementation. See SetupForCPUToScreenAlphaTexture2. + */ Bool (*SetupForCPUToScreenAlphaTexture) ( ScrnInfoPtr pScrn, int op, @@ -1304,6 +1308,10 @@ typedef struct _XAAInfoRec { int CPUToScreenAlphaTextureFlags; CARD32 * CPUToScreenAlphaTextureFormats; + /* The old SetupForCPUToScreenTexture function is no longer used because + * it doesn't pass in enough information to write a conforming + * implementation. See SetupForCPUToScreenTexture2. + */ Bool (*SetupForCPUToScreenTexture) ( ScrnInfoPtr pScrn, int op, @@ -1333,6 +1341,38 @@ typedef struct _XAAInfoRec { BoxRec SolidLineLimits; BoxRec DashedLineLimits; +#ifdef RENDER + /* These were added for X.Org 6.8.0 */ + Bool (*SetupForCPUToScreenAlphaTexture2) ( + ScrnInfoPtr pScrn, + int op, + CARD16 red, + CARD16 green, + CARD16 blue, + CARD16 alpha, + CARD32 maskFormat, + CARD32 dstFormat, + CARD8 *alphaPtr, + int alphaPitch, + int width, + int height, + int flags + ); + CARD32 *CPUToScreenAlphaTextureDstFormats; + + Bool (*SetupForCPUToScreenTexture2) ( + ScrnInfoPtr pScrn, + int op, + CARD32 srcFormat, + CARD32 dstFormat, + CARD8 *texPtr, + int texPitch, + int width, + int height, + int flags + ); + CARD32 *CPUToScreenTextureDstFormats; +#endif /* RENDER */ } XAAInfoRec, *XAAInfoRecPtr; #define SET_SYNC_FLAG(infoRec) (infoRec)->NeedToSync = TRUE diff --git a/hw/xfree86/xaa/xaaFallback.c b/hw/xfree86/xaa/xaaFallback.c index 6bc7bfed3..df67342ff 100644 --- a/hw/xfree86/xaa/xaaFallback.c +++ b/hw/xfree86/xaa/xaaFallback.c @@ -347,6 +347,7 @@ GCOps XAAFallbackOps = { {NULL} /* devPrivate */ }; - - - +GCOps *XAAGetFallbackOps(void) +{ + return &XAAFallbackOps; +} diff --git a/hw/xfree86/xaa/xaaInit.c b/hw/xfree86/xaa/xaaInit.c index 186711e3f..f6f2d491e 100644 --- a/hw/xfree86/xaa/xaaInit.c +++ b/hw/xfree86/xaa/xaaInit.c @@ -40,11 +40,29 @@ static int XAASetDGAMode(int index, int num, DGADevicePtr devRet); static void XAAEnableDisableFBAccess (int index, Bool enable); static Bool XAAChangeWindowAttributes (WindowPtr pWin, unsigned long mask); +/* + * XXX These three should be static, but that breaks ABI compat with XF4.4 + * and Xorg 6.7.0 modules. DO NOT use them in new code, you should never + * be setting them, and you've got Get functions below. + */ int XAAScreenIndex = -1; int XAAGCIndex = -1; int XAAPixmapIndex = -1; + static unsigned long XAAGeneration = 0; +int XAAGetScreenIndex(void) { + return XAAScreenIndex; +} + +int XAAGetGCIndex(void) { + return XAAGCIndex; +} + +int XAAGetPixmapIndex(void) { + return XAAPixmapIndex; +} + /* temp kludge */ static Bool SwitchedOut = FALSE; diff --git a/hw/xfree86/xaa/xaaInitAccel.c b/hw/xfree86/xaa/xaaInitAccel.c index 7233e215c..9d3764506 100644 --- a/hw/xfree86/xaa/xaaInitAccel.c +++ b/hw/xfree86/xaa/xaaInitAccel.c @@ -101,8 +101,8 @@ static XF86ModuleVersionInfo xaaVersRec = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, - 1, 1, 0, + XORG_VERSION_CURRENT, + 1, 2, 0, ABI_CLASS_VIDEODRV, /* requires the video driver ABI */ ABI_VIDEODRV_VERSION, MOD_CLASS_NONE, @@ -1269,10 +1269,12 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec) #ifdef RENDER { Bool haveTexture = infoRec->CPUToScreenTextureFormats && - infoRec->SetupForCPUToScreenTexture && + infoRec->CPUToScreenTextureDstFormats && + infoRec->SetupForCPUToScreenTexture2 && infoRec->SubsequentCPUToScreenTexture; Bool haveAlphaTexture = infoRec->CPUToScreenAlphaTextureFormats && - infoRec->SetupForCPUToScreenAlphaTexture && + infoRec->CPUToScreenAlphaTextureDstFormats && + infoRec->SetupForCPUToScreenAlphaTexture2 && infoRec->SubsequentCPUToScreenAlphaTexture; if(!infoRec->Composite && (haveTexture || haveAlphaTexture)) diff --git a/hw/xfree86/xaa/xaaOverlay.c b/hw/xfree86/xaa/xaaOverlay.c index 42a9428c4..f0505a8b6 100644 --- a/hw/xfree86/xaa/xaaOverlay.c +++ b/hw/xfree86/xaa/xaaOverlay.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/hw/xfree86/xaa/xaaOverlay.c,v 1.1.4.3.2.3 2004/03/04 20:16:48 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/xaa/xaaOverlay.c,v 1.2 2004/04/23 19:54:16 eich Exp $ */ /* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaOverlay.c,v 1.14tsi Exp $ */ #include "misc.h" diff --git a/hw/xfree86/xaa/xaaPCache.c b/hw/xfree86/xaa/xaaPCache.c index 25f8bd486..94790d21c 100644 --- a/hw/xfree86/xaa/xaaPCache.c +++ b/hw/xfree86/xaa/xaaPCache.c @@ -1653,7 +1653,8 @@ XAACachePlanarMonoStipple(ScrnInfoPtr pScrn, PixmapPtr pPix) return pCache; } - +XAACachePlanarMonoStippleProc +XAAGetCachePlanarMonoStipple(void) { return XAACachePlanarMonoStipple; } XAACacheInfoPtr XAACacheStipple(ScrnInfoPtr pScrn, PixmapPtr pPix, int fg, int bg) diff --git a/hw/xfree86/xaa/xaaPaintWin.c b/hw/xfree86/xaa/xaaPaintWin.c index 1cf6c3422..351d0e85f 100644 --- a/hw/xfree86/xaa/xaaPaintWin.c +++ b/hw/xfree86/xaa/xaaPaintWin.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/hw/xfree86/xaa/xaaPaintWin.c,v 1.1.4.2.2.3 2004/03/04 20:16:48 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/xaa/xaaPaintWin.c,v 1.2 2004/04/23 19:54:16 eich Exp $ */ /* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaPaintWin.c,v 1.10 2001/10/28 03:34:04 tsi Exp $ */ #include "misc.h" diff --git a/hw/xfree86/xaa/xaaPict.c b/hw/xfree86/xaa/xaaPict.c index af3380231..12523e85f 100644 --- a/hw/xfree86/xaa/xaaPict.c +++ b/hw/xfree86/xaa/xaaPict.c @@ -172,6 +172,10 @@ XAA_888_plus_PICT_a8_to_8888 ( } } +#define DRAWABLE_IS_ON_CARD(pDraw) \ + (pDraw->type == DRAWABLE_WINDOW || \ + (pDraw->type == DRAWABLE_PIXMAP && IS_OFFSCREEN_PIXMAP(pDraw))) + Bool XAADoComposite ( CARD8 op, @@ -190,7 +194,7 @@ XAADoComposite ( ScreenPtr pScreen = pDst->pDrawable->pScreen; XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); RegionRec region; - CARD32 *formats; + CARD32 *formats, *dstformats; int flags = 0; BoxPtr pbox; int nbox, w, h; @@ -198,13 +202,10 @@ XAADoComposite ( if(!REGION_NUM_RECTS(pDst->pCompositeClip)) return TRUE; - if(!infoRec->pScrn->vtSema || - ((pDst->pDrawable->type != DRAWABLE_WINDOW) && - !IS_OFFSCREEN_PIXMAP(pDst->pDrawable))) + if(!infoRec->pScrn->vtSema || !DRAWABLE_IS_ON_CARD(pDst->pDrawable)) return FALSE; - if((pSrc->pDrawable->type != DRAWABLE_PIXMAP) || - IS_OFFSCREEN_PIXMAP(pSrc->pDrawable)) + if(DRAWABLE_IS_ON_CARD(pSrc->pDrawable)) return FALSE; if (pSrc->transform || (pMask && pMask->transform)) @@ -279,7 +280,9 @@ XAADoComposite ( return TRUE; } - if(!(formats = infoRec->CPUToScreenAlphaTextureFormats)) + formats = infoRec->CPUToScreenAlphaTextureFormats; + dstformats = infoRec->CPUToScreenAlphaTextureDstFormats; + if(!formats || !dstformats) return FALSE; w = pMask->pDrawable->width; @@ -304,6 +307,11 @@ XAADoComposite ( if(!(*formats)) return FALSE; formats++; } + while(*dstformats != pDst->format) { + if(!(*dstformats)) + return FALSE; + dstformats++; + } if (!miComputeCompositeRegion (®ion, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, xDst, yDst, @@ -318,8 +326,9 @@ XAADoComposite ( return TRUE; } - if(!(infoRec->SetupForCPUToScreenAlphaTexture)(infoRec->pScrn, - op, red, green, blue, alpha, pMask->format, + if(!(infoRec->SetupForCPUToScreenAlphaTexture2)(infoRec->pScrn, + op, red, green, blue, alpha, pMask->format, + pDst->format, ((PixmapPtr)(pMask->pDrawable))->devPrivate.ptr, ((PixmapPtr)(pMask->pDrawable))->devKind, w, h, flags)) @@ -343,8 +352,10 @@ XAADoComposite ( REGION_UNINIT(pScreen, ®ion); return TRUE; } - } else { - if(!(formats = infoRec->CPUToScreenTextureFormats)) + } else { + formats = infoRec->CPUToScreenTextureFormats; + dstformats = infoRec->CPUToScreenTextureDstFormats; + if(!formats || !dstformats) return FALSE; w = pSrc->pDrawable->width; @@ -361,11 +372,15 @@ XAADoComposite ( flags |= XAA_RENDER_REPEAT; } - while(*formats != pSrc->format) { if(!(*formats)) return FALSE; formats++; } + while(*dstformats != pDst->format) { + if(!(*dstformats)) + return FALSE; + dstformats++; + } if (!miComputeCompositeRegion (®ion, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, xDst, yDst, @@ -380,8 +395,8 @@ XAADoComposite ( return TRUE; } - if(!(infoRec->SetupForCPUToScreenTexture)(infoRec->pScrn, - op, pSrc->format, + if(!(infoRec->SetupForCPUToScreenTexture2)(infoRec->pScrn, + op, pSrc->format, pDst->format, ((PixmapPtr)(pSrc->pDrawable))->devPrivate.ptr, ((PixmapPtr)(pSrc->pDrawable))->devKind, w, h, flags)) @@ -411,6 +426,63 @@ XAADoComposite ( return FALSE; } +static void +XAACompositeSrcCopy (PicturePtr pSrc, + PicturePtr pDst, + INT16 xSrc, + INT16 ySrc, + INT16 xDst, + INT16 yDst, + CARD16 width, + CARD16 height) +{ + ScreenPtr pScreen = pDst->pDrawable->pScreen; + XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); + int i, nbox; + int xoff, yoff; + BoxPtr pbox; + DDXPointPtr pptSrc; + RegionRec region; + + xDst += pDst->pDrawable->x; + yDst += pDst->pDrawable->y; + xSrc += pSrc->pDrawable->x; + ySrc += pSrc->pDrawable->y; + + if (!miComputeCompositeRegion (®ion, pSrc, NULL, pDst, + xSrc, ySrc, 0, 0, xDst, yDst, + width, height)) + return; + + nbox = REGION_NUM_RECTS(®ion); + pbox = REGION_RECTS(®ion); + + if(!nbox) { + REGION_UNINIT(pScreen, ®ion); + return; + } + pptSrc = ALLOCATE_LOCAL(sizeof(DDXPointRec) * nbox); + if (!pptSrc) { + REGION_UNINIT(pScreen, ®ion); + return; + } + xoff = xSrc - xDst; + yoff = ySrc - yDst; + for (i = 0; i < nbox; i++) { + pptSrc[i].x = pbox[i].x1 + xoff; + pptSrc[i].y = pbox[i].y1 + yoff; + } + + infoRec->ScratchGC.planemask = ~0L; + infoRec->ScratchGC.alu = GXcopy; + + XAADoBitBlt(pSrc->pDrawable, pDst->pDrawable, &infoRec->ScratchGC, ®ion, + pptSrc); + + DEALLOCATE_LOCAL(pptSrc); + REGION_UNINIT(pScreen, ®ion); + return; +} void XAAComposite (CARD8 op, @@ -430,7 +502,14 @@ XAAComposite (CARD8 op, XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); XAA_RENDER_PROLOGUE(pScreen, Composite); - if(!infoRec->Composite || + if((op == PictOpSrc) && !pMask && infoRec->pScrn->vtSema && + infoRec->ScreenToScreenBitBlt && + DRAWABLE_IS_ON_CARD(pSrc->pDrawable) && + DRAWABLE_IS_ON_CARD(pDst->pDrawable) && + !pSrc->transform && !pSrc->repeat && (pSrc->format == pDst->format)) + { + XAACompositeSrcCopy(pSrc, pDst, xSrc, ySrc, xDst, yDst, width, height); + } else if(!infoRec->Composite || !(*infoRec->Composite)(op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, xDst, yDst, width, height)) diff --git a/hw/xfree86/xaa/xaaROP.c b/hw/xfree86/xaa/xaaROP.c index 70a7b1d7d..931740159 100644 --- a/hw/xfree86/xaa/xaaROP.c +++ b/hw/xfree86/xaa/xaaROP.c @@ -94,6 +94,25 @@ int XAAPatternROP_PM[16] = ROP_DPo }; +int XAAGetCopyROP(int i) +{ + return XAACopyROP[i]; +} + +int XAAGetCopyROP_PM(int i) +{ + return XAACopyROP_PM[i]; +} + +int XAAGetPatternROP(int i) +{ + return XAAPatternROP[i]; +} + +int XAAGetPatternROP_PM(int i) +{ + return XAAPatternROP_PM[i]; +} int XAAHelpPatternROP(ScrnInfoPtr pScrn, int *fg, int *bg, int pm, int *rop) diff --git a/hw/xfree86/xaa/xaaStipple.c b/hw/xfree86/xaa/xaaStipple.c index 8b111d1cf..66d3a81e3 100644 --- a/hw/xfree86/xaa/xaaStipple.c +++ b/hw/xfree86/xaa/xaaStipple.c @@ -15,8 +15,10 @@ static CARD32* StippleOver32_Inverted(CARD32*, CARD32*, int, int, int); #ifdef TRIPLE_BITS #define stipple_scanline_func EXPNAME(XAAStippleScanlineFunc3) +#define stipple_get_scanline_func EXPNAME(XAAGetStippleScanlineFunc3) #else #define stipple_scanline_func EXPNAME(XAAStippleScanlineFunc) +#define stipple_get_scanline_func EXPNAME(XAAGetStippleScanlineFunc) #endif StippleScanlineProcPtr stipple_scanline_func[6] = { @@ -28,6 +30,9 @@ StippleScanlineProcPtr stipple_scanline_func[6] = { StippleOver32_Inverted }; +StippleScanlineProcPtr *stipple_get_scanline_func(void) { + return stipple_scanline_func; +} #ifdef FIXEDBASE # define DEST(i) *dest diff --git a/hw/xfree86/xaa/xaaTEGlyph.c b/hw/xfree86/xaa/xaaTEGlyph.c index 0fd572617..7a699fd1f 100644 --- a/hw/xfree86/xaa/xaaTEGlyph.c +++ b/hw/xfree86/xaa/xaaTEGlyph.c @@ -74,7 +74,7 @@ static CARD32 *DrawTETextScanlineWidth9(CARD32 *base, unsigned int **glyphp, #endif #define glyph_scanline_func EXPNAME(XAAGlyphScanlineFunc) - +#define glyph_get_scanline_func EXPNAME(XAAGetGlyphScanlineFunc) GlyphScanlineFuncPtr glyph_scanline_func[32] = { @@ -125,6 +125,10 @@ GlyphScanlineFuncPtr glyph_scanline_func[32] = { DrawTETextScanlineGeneric, DrawTETextScanlineGeneric }; +GlyphScanlineFuncPtr *glyph_get_scanline_func(void) { + return glyph_scanline_func; +} + /******************************************************************** diff --git a/hw/xfree86/xaa/xaaWideLine.c b/hw/xfree86/xaa/xaaWideLine.c index fedd8f44d..cbe5fe70f 100644 --- a/hw/xfree86/xaa/xaaWideLine.c +++ b/hw/xfree86/xaa/xaaWideLine.c @@ -1,5 +1,5 @@ /* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaWideLine.c,v 1.10 2001/11/16 16:47:56 dawes Exp $ */ - +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/xaa/xaaWideLine.c,v 1.3 2004/08/29 00:48:17 alanc Exp $ */ /* XAAPolylinesWideSolid does not maintain a span list and subsequently does @@ -15,7 +15,8 @@ Original mi code written by Keith Packard. */ #ifndef XFree86LOADER -#if defined(_XOPEN_SOURCE) || defined(__QNXNTO__) +#if defined(_XOPEN_SOURCE) || defined(__QNXNTO__) \ + || (defined(sun) && defined(__SVR4)) #include <math.h> #else #define _XOPEN_SOURCE /* to get prototype for hypot on some systems */ diff --git a/hw/xfree86/xaa/xaalocal.h b/hw/xfree86/xaa/xaalocal.h index 04d8d154a..883e64d5b 100644 --- a/hw/xfree86/xaa/xaalocal.h +++ b/hw/xfree86/xaa/xaalocal.h @@ -727,6 +727,11 @@ extern CARD32 *(*XAAGlyphScanlineFuncLSBFirst[32])( CARD32 *base, unsigned int **glyphp, int line, int nglyph, int width ); +GlyphScanlineFuncPtr *XAAGetGlyphScanlineFuncMSBFirstFixedBase(void); +GlyphScanlineFuncPtr *XAAGetGlyphScanlineFuncMSBFirst(void); +GlyphScanlineFuncPtr *XAAGetGlyphScanlineFuncLSBFirstFixedBase(void); +GlyphScanlineFuncPtr *XAAGetGlyphScanlineFuncLSBFirst(void); + void XAAFillColorExpandRectsLSBFirst( ScrnInfoPtr pScrn, @@ -1046,6 +1051,11 @@ extern CARD32 *(*XAAStippleScanlineFuncLSBFirst[6])( CARD32* base, CARD32* src, int offset, int width, int dwords ); +StippleScanlineProcPtr *XAAGetStippleScanlineFuncMSBFirstFixedBase(void); +StippleScanlineProcPtr *XAAGetStippleScanlineFuncMSBFirst(void); +StippleScanlineProcPtr *XAAGetStippleScanlineFuncLSBFirstFixedBase(void); +StippleScanlineProcPtr *XAAGetStippleScanlineFuncLSBFirst(void); + int XAAPolyText8TEColorExpansion( DrawablePtr pDraw, @@ -1506,6 +1516,9 @@ XAACacheMonoStipple(ScrnInfoPtr Scrn, PixmapPtr pPix); XAACacheInfoPtr XAACachePlanarMonoStipple(ScrnInfoPtr Scrn, PixmapPtr pPix); +typedef XAACacheInfoPtr (*XAACachePlanarMonoStippleProc)(ScrnInfoPtr, PixmapPtr); +XAACachePlanarMonoStippleProc XAAGetCachePlanarMonoStipple(void); + XAACacheInfoPtr XAACacheStipple(ScrnInfoPtr Scrn, PixmapPtr pPix, int fg, int bg); @@ -1623,13 +1636,17 @@ XAAGetPixelFromRGBA ( ); #endif - +/* XXX should be static */ extern GCOps XAAFallbackOps; +extern GCOps *XAAGetFallbackOps(void); extern GCFuncs XAAGCFuncs; -extern int XAAScreenIndex; -extern int XAAGCIndex; -extern int XAAPixmapIndex; +extern int XAAScreenIndex; /* XXX DONTUSE */ +extern int XAAGCIndex; /* XXX DONTUSE */ +extern int XAAPixmapIndex; /* XXX DONTUSE */ +extern int XAAGetScreenIndex(void); +extern int XAAGetGCIndex(void); +extern int XAAGetPixmapIndex(void); extern unsigned int XAAShiftMasks[32]; @@ -1638,28 +1655,28 @@ extern unsigned int byte_expand3[256], byte_reversed_expand3[256]; CARD32 XAAReverseBitOrder(CARD32 data); #define GET_XAASCREENPTR_FROM_SCREEN(pScreen)\ - (pScreen)->devPrivates[XAAScreenIndex].ptr + (pScreen)->devPrivates[XAAGetScreenIndex()].ptr #define GET_XAASCREENPTR_FROM_GC(pGC)\ - (pGC)->pScreen->devPrivates[XAAScreenIndex].ptr + (pGC)->pScreen->devPrivates[XAAGetScreenIndex()].ptr #define GET_XAASCREENPTR_FROM_DRAWABLE(pDraw)\ - (pDraw)->pScreen->devPrivates[XAAScreenIndex].ptr + (pDraw)->pScreen->devPrivates[XAAGetScreenIndex()].ptr #define GET_XAAINFORECPTR_FROM_SCREEN(pScreen)\ - ((XAAScreenPtr)((pScreen)->devPrivates[XAAScreenIndex].ptr))->AccelInfoRec + ((XAAScreenPtr)((pScreen)->devPrivates[XAAGetScreenIndex()].ptr))->AccelInfoRec #define GET_XAAINFORECPTR_FROM_GC(pGC)\ -((XAAScreenPtr)((pGC)->pScreen->devPrivates[XAAScreenIndex].ptr))->AccelInfoRec +((XAAScreenPtr)((pGC)->pScreen->devPrivates[XAAGetScreenIndex()].ptr))->AccelInfoRec #define GET_XAAINFORECPTR_FROM_DRAWABLE(pDraw)\ -((XAAScreenPtr)((pDraw)->pScreen->devPrivates[XAAScreenIndex].ptr))->AccelInfoRec +((XAAScreenPtr)((pDraw)->pScreen->devPrivates[XAAGetScreenIndex()].ptr))->AccelInfoRec #define GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn)\ -((XAAScreenPtr)((pScrn)->pScreen->devPrivates[XAAScreenIndex].ptr))->AccelInfoRec +((XAAScreenPtr)((pScrn)->pScreen->devPrivates[XAAGetScreenIndex()].ptr))->AccelInfoRec #define XAA_GET_PIXMAP_PRIVATE(pix)\ - (XAAPixmapPtr)((pix)->devPrivates[XAAPixmapIndex].ptr) + (XAAPixmapPtr)((pix)->devPrivates[XAAGetPixmapIndex()].ptr) #define CHECK_RGB_EQUAL(c) (!((((c) >> 8) ^ (c)) & 0xffff)) diff --git a/hw/xfree86/xaa/xaarop.h b/hw/xfree86/xaa/xaarop.h index 048ed00fc..1c95727b3 100644 --- a/hw/xfree86/xaa/xaarop.h +++ b/hw/xfree86/xaa/xaarop.h @@ -299,9 +299,15 @@ int XAAHelpSolidROP(ScrnInfoPtr pScrn, int *fg, int pm, int *rop); int XAAHelpPatternROP(ScrnInfoPtr pScrn, int *fg, int *bg, int pm, int *rop); +/* XXX These four should be static, but it breaks the 6.7.0 ABI. */ extern int XAACopyROP[16]; extern int XAACopyROP_PM[16]; extern int XAAPatternROP[16]; extern int XAAPatternROP_PM[16]; +extern int XAAGetCopyROP(int i); +extern int XAAGetCopyROP_PM(int i); +extern int XAAGetPatternROP(int i); +extern int XAAGetPatternROP_PM(int i); + #endif /* _XAAROP_H */ diff --git a/hw/xfree86/xaa/xaawrap.h b/hw/xfree86/xaa/xaawrap.h index 59f0a2cc7..5e3e0e683 100644 --- a/hw/xfree86/xaa/xaawrap.h +++ b/hw/xfree86/xaa/xaawrap.h @@ -2,14 +2,14 @@ #define XAA_SCREEN_PROLOGUE(pScreen, field)\ ((pScreen)->field = \ - ((XAAScreenPtr) (pScreen)->devPrivates[XAAScreenIndex].ptr)->field) + ((XAAScreenPtr) (pScreen)->devPrivates[XAAGetScreenIndex()].ptr)->field) #define XAA_SCREEN_EPILOGUE(pScreen, field, wrapper)\ ((pScreen)->field = wrapper) #define XAA_GC_FUNC_PROLOGUE(pGC)\ - XAAGCPtr pGCPriv = (XAAGCPtr) (pGC)->devPrivates[XAAGCIndex].ptr;\ + XAAGCPtr pGCPriv = (XAAGCPtr) (pGC)->devPrivates[XAAGetGCIndex()].ptr;\ (pGC)->funcs = pGCPriv->wrapFuncs;\ if(pGCPriv->flags)\ (pGC)->ops = pGCPriv->wrapOps @@ -25,13 +25,13 @@ #define XAA_GC_OP_PROLOGUE(pGC)\ - XAAGCPtr pGCPriv = (XAAGCPtr)(pGC->devPrivates[XAAGCIndex].ptr);\ + XAAGCPtr pGCPriv = (XAAGCPtr)(pGC->devPrivates[XAAGetGCIndex()].ptr);\ GCFuncs *oldFuncs = pGC->funcs;\ pGC->funcs = pGCPriv->wrapFuncs;\ pGC->ops = pGCPriv->wrapOps #define XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC)\ - XAAGCPtr pGCPriv = (XAAGCPtr)(pGC->devPrivates[XAAGCIndex].ptr);\ + XAAGCPtr pGCPriv = (XAAGCPtr)(pGC->devPrivates[XAAGetGCIndex()].ptr);\ GCFuncs *oldFuncs = pGC->funcs;\ if(!REGION_NUM_RECTS(pGC->pCompositeClip)) return; \ pGC->funcs = pGCPriv->wrapFuncs;\ @@ -45,7 +45,7 @@ #define XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw)\ - XAAGCPtr pGCPriv = (XAAGCPtr)(pGC->devPrivates[XAAGCIndex].ptr);\ + XAAGCPtr pGCPriv = (XAAGCPtr)(pGC->devPrivates[XAAGetGCIndex()].ptr);\ XAAPixmapPtr pixPriv = XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pDraw));\ GCFuncs *oldFuncs = pGC->funcs;\ pGC->funcs = pGCPriv->wrapFuncs;\ @@ -61,7 +61,7 @@ #ifdef RENDER #define XAA_RENDER_PROLOGUE(pScreen,field)\ (GetPictureScreen(pScreen)->field = \ - ((XAAScreenPtr) (pScreen)->devPrivates[XAAScreenIndex].ptr)->field) + ((XAAScreenPtr) (pScreen)->devPrivates[XAAGetScreenIndex()].ptr)->field) #define XAA_RENDER_EPILOGUE(pScreen, field, wrapper)\ (GetPictureScreen(pScreen)->field = wrapper) @@ -71,7 +71,7 @@ #define SYNC_CHECK(pGC) {\ XAAInfoRecPtr infoRec =\ -((XAAScreenPtr)((pGC)->pScreen->devPrivates[XAAScreenIndex].ptr))->AccelInfoRec;\ +((XAAScreenPtr)((pGC)->pScreen->devPrivates[XAAGetScreenIndex()].ptr))->AccelInfoRec;\ if(infoRec->NeedToSync) {\ (*infoRec->Sync)(infoRec->pScrn);\ infoRec->NeedToSync = FALSE;\ diff --git a/hw/xfree86/xf1bpp/mfbmap.h b/hw/xfree86/xf1bpp/mfbmap.h index a29332497..bf04b7320 100644 --- a/hw/xfree86/xf1bpp/mfbmap.h +++ b/hw/xfree86/xf1bpp/mfbmap.h @@ -34,13 +34,21 @@ #define mfbDoBitbltGeneral xf1bppDoBitbltGeneral #define mfbDoBitbltOr xf1bppDoBitbltOr #define mfbDoBitbltXor xf1bppDoBitbltXor +#define mfbFillInScreen xf1bppFillInScreen #define mfbFillPolyBlack xf1bppFillPolyBlack #define mfbFillPolyInvert xf1bppFillPolyInvert #define mfbFillPolyWhite xf1bppFillPolyWhite #define mfbGCPrivateIndex xf1bppGCPrivateIndex +#define mfbGetGCPrivateIndex xf1bppGetGCPrivateIndex #define mfbGetImage xf1bppGetImage #define mfbGetSpans xf1bppGetSpans #define mfbGetWindowPixmap xf1bppGetWindowPixmap +#define mfbGetWindowPrivateIndex xf1bppGetWindowPrivateIndex +#define mfbGetmask xf1bppGetmask +#define mfbGetpartmasks xf1bppGetpartmasks +#define mfbGetrmask xf1bppGetrmask +#define mfbGetstarttab xf1bppGetstarttab +#define mfbGetendtab xf1bppGetendtab #define mfbHorzS xf1bppHorzS #define mfbImageGlyphBltBlack xf1bppImageGlyphBltBlack #define mfbImageGlyphBltWhite xf1bppImageGlyphBltWhite diff --git a/hw/xfree86/xf1bpp/mfbmodule.c b/hw/xfree86/xf1bpp/mfbmodule.c index 4fb795152..81baf5d7e 100644 --- a/hw/xfree86/xf1bpp/mfbmodule.c +++ b/hw/xfree86/xf1bpp/mfbmodule.c @@ -35,7 +35,7 @@ static XF86ModuleVersionInfo VersRec = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 1, 0, 0, ABI_CLASS_ANSIC, /* Only need ansic layer */ ABI_ANSIC_VERSION, diff --git a/hw/xfree86/xf4bpp/mfbbres.c b/hw/xfree86/xf4bpp/mfbbres.c index 82b17e59e..ae9df6e10 100644 --- a/hw/xfree86/xf4bpp/mfbbres.c +++ b/hw/xfree86/xf4bpp/mfbbres.c @@ -79,8 +79,8 @@ int len; /* length of line */ register PixelType *addrl; /* bitmask long pointer *dont* * cast to char pointer */ register PixelType bit; /* current bit being set/cleared/etc. */ - PixelType leftbit = mask[0]; /* leftmost bit to process in new word */ - PixelType rightbit = mask[PPW-1]; /* rightmost bit to process in new word */ + PixelType leftbit = mfbGetmask(0); /* leftmost bit to process in new word */ + PixelType rightbit = mfbGetmask(PPW-1); /* rightmost bit to process in new word */ register int e3 = e2-e1; @@ -88,7 +88,7 @@ int len; /* length of line */ addrl = mfbScanline(addrlbase, x1, y1, nlwidth); yinc = signdy * nlwidth; e = e-e1; /* to make looping easier */ - bit = mask[x1 & PIM]; + bit = mfbGetmask(x1 & PIM); if (!len) return; diff --git a/hw/xfree86/xf4bpp/mfbbresd.c b/hw/xfree86/xf4bpp/mfbbresd.c index 29b816a3a..0f320ebc6 100644 --- a/hw/xfree86/xf4bpp/mfbbresd.c +++ b/hw/xfree86/xf4bpp/mfbbresd.c @@ -102,8 +102,8 @@ int len; /* length of line */ register PixelType *addrl; register int e3 = e2-e1; register unsigned long bit; - PixelType leftbit = mask[0]; /* leftmost bit to process in new word */ - PixelType rightbit = mask[PPW-1]; /* rightmost bit to process in new word */ + PixelType leftbit = mfbGetmask(0); /* leftmost bit to process in new word */ + PixelType rightbit = mfbGetmask(PPW-1); /* rightmost bit to process in new word */ int dashIndex; int dashOffset; int dashRemaining; @@ -125,7 +125,7 @@ int len; /* length of line */ addrl = mfbScanline(addrlbase, x1, y1, nlwidth); yinc = signdy * nlwidth; e = e-e1; /* to make looping easier */ - bit = mask[x1 & PIM]; + bit = mfbGetmask(x1 & PIM); if (axis == X_AXIS) { if (signdx > 0) diff --git a/hw/xfree86/xf4bpp/mfbfillarc.c b/hw/xfree86/xf4bpp/mfbfillarc.c index 5d677174d..c3f62cb64 100644 --- a/hw/xfree86/xf4bpp/mfbfillarc.c +++ b/hw/xfree86/xf4bpp/mfbfillarc.c @@ -252,7 +252,7 @@ xf4bppPolyFillArcSolid mfbPrivGC *priv; int rop; - priv = (mfbPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr; + priv = (mfbPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr; rop = priv->rop; if ((rop == RROP_NOP) || !(pGC->planemask & 1)) #else diff --git a/hw/xfree86/xf4bpp/mfbhrzvert.c b/hw/xfree86/xf4bpp/mfbhrzvert.c index c53edd19d..0e5594356 100644 --- a/hw/xfree86/xf4bpp/mfbhrzvert.c +++ b/hw/xfree86/xf4bpp/mfbhrzvert.c @@ -128,6 +128,6 @@ register int len; /* length of line */ len = -len; } - bitmask = mask[x1 & PIM]; + bitmask = mfbGetmask(x1 & PIM); Duff(len, UPDRW(addrl,bitmask); addrl += nlwidth); } diff --git a/hw/xfree86/xf4bpp/mfbimggblt.c b/hw/xfree86/xf4bpp/mfbimggblt.c index b4f5bd014..95d7a7fcb 100644 --- a/hw/xfree86/xf4bpp/mfbimggblt.c +++ b/hw/xfree86/xf4bpp/mfbimggblt.c @@ -148,7 +148,7 @@ xf4bppImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase) backrect.height = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font); - pPrivGC = pGC->devPrivates[mfbGCPrivateIndex].ptr; + pPrivGC = pGC->devPrivates[mfbGetGCPrivateIndex()].ptr; oldfillStyle = pPrivGC->colorRrop.fillStyle; /* GJA */ oldfg = pPrivGC->colorRrop.fgPixel; /* GJA */ oldalu = pPrivGC->colorRrop.alu; /* GJA */ @@ -243,7 +243,7 @@ doImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase,infop) /* UNCLEAN CODE we know the mfbPolyFillRect uses only three fields in - devPrivate[mfbGCPrivateIndex].ptr, two of which (the rotated + devPrivate[mfbGetGCPrivateIndex()].ptr, two of which (the rotated tile/stipple and the ropFillArea) are irrelevant for solid filling, so we just poke the FillArea field. the GC is now in an inconsistent state, but we'll fix @@ -253,7 +253,7 @@ doImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase,infop) NOTE: if you are not using the standard mfbFillRectangle code, you need to poke any fields in the GC the rectangle stuff need - (probably alu, fgPixel, and fillStyle) and in devPrivate[mfbGCPrivateIndex].ptr + (probably alu, fgPixel, and fillStyle) and in devPrivate[mfbGetGCPrivateIndex()].ptr (probably rop or ropFillArea.) You could just call ValidateGC, but that is usually not a cheap thing to do. */ diff --git a/hw/xfree86/xf4bpp/mfbline.c b/hw/xfree86/xf4bpp/mfbline.c index b200a611e..356028b8c 100644 --- a/hw/xfree86/xf4bpp/mfbline.c +++ b/hw/xfree86/xf4bpp/mfbline.c @@ -466,9 +466,9 @@ DoV16LineSS (pDrawable, pGC, mode, npt, pptInit) PixelType _mask; if (alu == RROP_BLACK) - _mask = rmask[x2 & PIM]; + _mask = mfbGetrmask(x2 & PIM); else - _mask = mask[x2 & PIM]; + _mask = mfbGetmask(x2 & PIM); nbox = nboxInit; pbox = pboxInit; @@ -797,7 +797,7 @@ dontStep: ; { unsigned long _mask; - _mask = mask[x2 & PIM]; + _mask = mfbGetmask(x2 & PIM); addrl = mfbScanline(addrl, x2, y2, nlwidth); UPDRW(addrl,_mask); break; diff --git a/hw/xfree86/xf4bpp/mfbzerarc.c b/hw/xfree86/xf4bpp/mfbzerarc.c index 106fc6ae5..4853f8807 100644 --- a/hw/xfree86/xf4bpp/mfbzerarc.c +++ b/hw/xfree86/xf4bpp/mfbzerarc.c @@ -108,7 +108,7 @@ v16ZeroArcSS int pmask; register int *paddr; - if (((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->rop == + if (((mfbPrivGC *)(pGC->devPrivates[mfbGetGCPrivateIndex()].ptr))->rop == RROP_BLACK) pixel = 0; else diff --git a/hw/xfree86/xf4bpp/ppcArea.c b/hw/xfree86/xf4bpp/ppcArea.c index 0d1a2075b..663672878 100644 --- a/hw/xfree86/xf4bpp/ppcArea.c +++ b/hw/xfree86/xf4bpp/ppcArea.c @@ -47,7 +47,7 @@ int alu ; unsigned long int fg, bg, pm ; int xSrc, ySrc ; PixmapPtr pPixmap ; -ppcPrivGC *pPrivGC = pGC->devPrivates[mfbGCPrivateIndex].ptr; +ppcPrivGC *pPrivGC = pGC->devPrivates[mfbGetGCPrivateIndex()].ptr; TRACE( ( "xf4bppFillArea(0x%x,%d,0x%x,0x%x)\n", pWin, nboxes, pBox, pGC ) ) ; diff --git a/hw/xfree86/xf4bpp/ppcGC.c b/hw/xfree86/xf4bpp/ppcGC.c index bbc64c97c..881dfbf05 100644 --- a/hw/xfree86/xf4bpp/ppcGC.c +++ b/hw/xfree86/xf4bpp/ppcGC.c @@ -184,7 +184,7 @@ register GCPtr pGC ; * a pointer to a ppcPrivGC in its slot. */ *pPriv = vgaPrototypeGCPriv; - (pGC->devPrivates[mfbGCPrivateIndex].ptr) = (pointer) pPriv; + (pGC->devPrivates[mfbGetGCPrivateIndex()].ptr) = (pointer) pPriv; /* Set the vgaGCOps */ *pOps = vgaGCOps; @@ -210,7 +210,7 @@ xf4bppDestroyGC( pGC ) if ( pGC->freeCompClip && pGC->pCompositeClip ) REGION_DESTROY(pGC->pScreen, pGC->pCompositeClip); if(pGC->ops->devPrivate.val) xfree( pGC->ops ); - xfree( pGC->devPrivates[mfbGCPrivateIndex].ptr ) ; + xfree( pGC->devPrivates[mfbGetGCPrivateIndex()].ptr ) ; return ; } @@ -221,7 +221,7 @@ ppcChangePixmapGC register Mask changes ) { -register ppcPrivGCPtr devPriv = (ppcPrivGCPtr) (pGC->devPrivates[mfbGCPrivateIndex].ptr ) ; +register ppcPrivGCPtr devPriv = (ppcPrivGCPtr) (pGC->devPrivates[mfbGetGCPrivateIndex()].ptr ) ; register unsigned long int idx ; /* used for stepping through bitfields */ #define LOWBIT( x ) ( x & - x ) /* Two's complement */ @@ -303,7 +303,7 @@ xf4bppValidateGC( pGC, changes, pDrawable ) register ppcPrivGCPtr devPriv ; WindowPtr pWin ; - devPriv = (ppcPrivGCPtr) (pGC->devPrivates[mfbGCPrivateIndex].ptr ) ; + devPriv = (ppcPrivGCPtr) (pGC->devPrivates[mfbGetGCPrivateIndex()].ptr ) ; if ( pDrawable->type != devPriv->lastDrawableType ) { devPriv->lastDrawableType = pDrawable->type ; diff --git a/hw/xfree86/xf4bpp/ppcIO.c b/hw/xfree86/xf4bpp/ppcIO.c index 02019b19a..6b6fb1c09 100644 --- a/hw/xfree86/xf4bpp/ppcIO.c +++ b/hw/xfree86/xf4bpp/ppcIO.c @@ -209,22 +209,16 @@ xf4bppScreenInit( pScreen, pbits, virtx, virty, dpix, dpiy, width ) pScreen-> CreateWindow = xf4bppCreateWindowForXYhardware; pScreen-> DestroyWindow = xf4bppDestroyWindow; pScreen-> PositionWindow = xf4bppPositionWindow; - pScreen-> ChangeWindowAttributes = mfbChangeWindowAttributes; - pScreen-> RealizeWindow = mfbMapWindow; - pScreen-> UnrealizeWindow = mfbUnmapWindow; pScreen-> PaintWindowBackground = xf4bppPaintWindow; pScreen-> PaintWindowBorder = xf4bppPaintWindow; pScreen-> CopyWindow = xf4bppCopyWindow; pScreen-> CreatePixmap = xf4bppCreatePixmap; - pScreen-> DestroyPixmap = mfbDestroyPixmap; pScreen-> SaveDoomedAreas = (SaveDoomedAreasProcPtr)NoopDDA; pScreen-> RestoreAreas = (RestoreAreasProcPtr)NoopDDA; pScreen-> ExposeCopy = (ExposeCopyProcPtr)NoopDDA; pScreen-> TranslateBackingStore = (TranslateBackingStoreProcPtr)NoopDDA; pScreen-> ClearBackingStore = (ClearBackingStoreProcPtr)NoopDDA; pScreen-> DrawGuarantee = (DrawGuaranteeProcPtr)NoopDDA; - pScreen-> RealizeFont = mfbRealizeFont; - pScreen-> UnrealizeFont = mfbUnrealizeFont; pScreen-> CreateGC = xf4bppCreateGC; pScreen-> CreateColormap = xf4bppInitializeColormap; pScreen-> DestroyColormap = (DestroyColormapProcPtr)NoopDDA; @@ -233,7 +227,7 @@ xf4bppScreenInit( pScreen, pbits, virtx, virty, dpix, dpiy, width ) pScreen-> ListInstalledColormaps = miListInstalledColormaps; pScreen-> StoreColors = (StoreColorsProcPtr)NoopDDA; pScreen-> ResolveColor = xf4bppResolveColor; - pScreen-> BitmapToRegion = mfbPixmapToRegion; + mfbFillInScreen(pScreen); if (!mfbAllocatePrivates(pScreen, (int*)NULL, (int*)NULL)) return FALSE; diff --git a/hw/xfree86/xf4bpp/ppcPixFS.c b/hw/xfree86/xf4bpp/ppcPixFS.c index 66b547e59..957a88135 100644 --- a/hw/xfree86/xf4bpp/ppcPixFS.c +++ b/hw/xfree86/xf4bpp/ppcPixFS.c @@ -122,7 +122,7 @@ xf4bppSolidPixmapFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) return ; } - if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu ) == GXnoop ) + if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop ) return ; n = nInit * miFindMaxBand(pGC->pCompositeClip) ; @@ -140,8 +140,8 @@ xf4bppSolidPixmapFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) n = miClipSpans( pGC->pCompositeClip, pptInit, pwidthInit, nInit, ppt, pwidth, fSorted ) ; - pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ; - fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.fgPixel ; + pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ; + fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ; npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ; for ( ; n-- ; ppt++, pwidth++ ) { @@ -257,14 +257,14 @@ int fSorted ; return ; } - if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu ) == GXnoop ) + if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop ) return ; SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit, pptFree, pwidth, ppt, fSorted ) ; - pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ; - fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.fgPixel ; + pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ; + fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ; pTile = pGC->stipple ; tlwidth = pTile->devKind ; @@ -356,15 +356,15 @@ int fSorted ; return ; } - if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu ) == GXnoop ) + if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop ) return ; SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit, pptFree, pwidth, ppt, fSorted ) ; - fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.fgPixel ; - bg = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.bgPixel ; - pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ; + fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ; + bg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.bgPixel ; + pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ; npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ; pTile = pGC->stipple ; @@ -459,14 +459,14 @@ int fSorted ; return ; } - if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu ) == GXnoop ) + if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop ) return ; SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit, pptFree, pwidth, ppt, fSorted ) ; /* the following code is for 8 bits per pixel addressable memory only */ - pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ; + pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ; npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ; pTile = pGC->tile.pixmap ; tileWidth = pTile->drawable.width ; diff --git a/hw/xfree86/xf4bpp/ppcPntWin.c b/hw/xfree86/xf4bpp/ppcPntWin.c index 65ff055d2..f68dbdc19 100644 --- a/hw/xfree86/xf4bpp/ppcPntWin.c +++ b/hw/xfree86/xf4bpp/ppcPntWin.c @@ -98,7 +98,7 @@ xf4bppPaintWindow(pWin, pRegion, what) { register mfbPrivWin *pPrivWin; - pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr); + pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbGetWindowPrivateIndex()].ptr); TRACE(("xf4bppPaintWindow( pWin= 0x%x, pRegion= 0x%x, what= %d )\n", pWin,pRegion,what)); diff --git a/hw/xfree86/xf4bpp/ppcPolyPnt.c b/hw/xfree86/xf4bpp/ppcPolyPnt.c index 736d128c6..568902925 100644 --- a/hw/xfree86/xf4bpp/ppcPolyPnt.c +++ b/hw/xfree86/xf4bpp/ppcPolyPnt.c @@ -100,7 +100,7 @@ if ( pDrawable->type == DRAWABLE_PIXMAP ) { return ; } -devPriv = (ppcPrivGC *) ( pGC->devPrivates[mfbGCPrivateIndex].ptr ) ; +devPriv = (ppcPrivGC *) ( pGC->devPrivates[mfbGetGCPrivateIndex()].ptr ) ; if ( ( alu = devPriv->colorRrop.alu ) == GXnoop ) return ; diff --git a/hw/xfree86/xf4bpp/ppcWinFS.c b/hw/xfree86/xf4bpp/ppcWinFS.c index ff59fccff..d7fd6b790 100644 --- a/hw/xfree86/xf4bpp/ppcWinFS.c +++ b/hw/xfree86/xf4bpp/ppcWinFS.c @@ -94,7 +94,7 @@ xf4bppSolidWindowFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) return ; } - if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu ) == GXnoop ) + if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop ) return ; n = nInit * miFindMaxBand( pGC->pCompositeClip ) ; @@ -112,8 +112,8 @@ xf4bppSolidWindowFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) n = miClipSpans( pGC->pCompositeClip, pptInit, pwidthInit, nInit, ppt, pwidth, fSorted ) ; - pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ; - fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.fgPixel ; + pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ; + fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ; for ( ; n-- ; ppt++, pwidth++ ) if ( *pwidth ) @@ -161,14 +161,14 @@ int fSorted ; return ; } - if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu ) == GXnoop ) + if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop ) return ; SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit, pptFree, pwidth, ppt, fSorted ) ; - pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ; - fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.fgPixel ; + pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ; + fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ; xSrc = pGC->patOrg.x + pDrawable->x ; ySrc = pGC->patOrg.y + pDrawable->y ; @@ -213,15 +213,15 @@ int fSorted ; return ; } - if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu ) == GXnoop ) + if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop ) return ; SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit, pptFree, pwidth, ppt, fSorted ) ; - pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ; - fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.fgPixel ; - bg = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.bgPixel ; + pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ; + fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ; + bg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.bgPixel ; xSrc = pGC->patOrg.x + pDrawable->x ; ySrc = pGC->patOrg.y + pDrawable->y ; @@ -258,7 +258,7 @@ int fSorted ; TRACE( ( "xf4bppTileWindowFS(pDrawable=0x%x,pGC=0x%x,nInit=%d,pptInit=0x%x,pwidthInit=0x%x,fSorted=%d)\n", pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ) ; - if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu ) == GXnoop ) + if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop ) return ; SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit, @@ -266,7 +266,7 @@ int fSorted ; xSrc = pGC->patOrg.x + pDrawable->x ; ySrc = pGC->patOrg.y + pDrawable->y ; - pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ; + pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ; for ( ; n-- ; ppt++, pwidth++ ) xf4bppTileRect( (WindowPtr)pDrawable, pGC->tile.pixmap, alu, pm, diff --git a/hw/xfree86/xf4bpp/ppcWindow.c b/hw/xfree86/xf4bpp/ppcWindow.c index a1c7afd9d..c15962aaf 100644 --- a/hw/xfree86/xf4bpp/ppcWindow.c +++ b/hw/xfree86/xf4bpp/ppcWindow.c @@ -214,7 +214,7 @@ register WindowPtr pWin ; TRACE(("xf4bppCreateWindowForXYhardware (pWin= 0x%x)\n", pWin)); - pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr); + pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbGetWindowPrivateIndex()].ptr); pPrivWin->pRotatedBorder = NullPixmap; pPrivWin->pRotatedBackground = NullPixmap; pPrivWin->fastBackground = 0; diff --git a/hw/xfree86/xf4bpp/vgaGC.c b/hw/xfree86/xf4bpp/vgaGC.c index 39597d268..a1aecafbb 100644 --- a/hw/xfree86/xf4bpp/vgaGC.c +++ b/hw/xfree86/xf4bpp/vgaGC.c @@ -106,7 +106,7 @@ xf4bppChangeWindowGC( pGC, changes ) register GC *pGC ; register Mask changes ; { -register ppcPrivGCPtr devPriv = (ppcPrivGCPtr) (pGC->devPrivates[mfbGCPrivateIndex].ptr) ; +register ppcPrivGCPtr devPriv = (ppcPrivGCPtr) (pGC->devPrivates[mfbGetGCPrivateIndex()].ptr) ; register unsigned long int idx ; /* used for stepping through bitfields */ #define LOWBIT( x ) ( x & - x ) /* Two's complement */ diff --git a/hw/xfree86/xf4bpp/vgamodule.c b/hw/xfree86/xf4bpp/vgamodule.c index c7cf1b7d3..828989dd5 100644 --- a/hw/xfree86/xf4bpp/vgamodule.c +++ b/hw/xfree86/xf4bpp/vgamodule.c @@ -36,7 +36,7 @@ static XF86ModuleVersionInfo VersRec = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 1, 0, 0, ABI_CLASS_ANSIC, /* Only need ansic layer */ ABI_ANSIC_VERSION, diff --git a/hw/xfree86/xf8_16bpp/cfb8_16.h b/hw/xfree86/xf8_16bpp/cfb8_16.h index a4a3bda22..97586ba01 100644 --- a/hw/xfree86/xf8_16bpp/cfb8_16.h +++ b/hw/xfree86/xf8_16bpp/cfb8_16.h @@ -14,7 +14,8 @@ typedef struct { unsigned char key; } cfb8_16ScreenRec, *cfb8_16ScreenPtr; -extern int cfb8_16ScreenPrivateIndex; +extern int cfb8_16ScreenPrivateIndex; /* XXX */ +extern int cfb8_16GetScreenPrivateIndex(void); Bool cfb8_16ScreenInit ( @@ -64,6 +65,6 @@ cfb8_16WindowExposures( ); #define CFB8_16_GET_SCREEN_PRIVATE(pScreen)\ - (cfb8_16ScreenPtr)((pScreen)->devPrivates[cfb8_16ScreenPrivateIndex].ptr) + (cfb8_16ScreenPtr)((pScreen)->devPrivates[cfb8_16GetScreenPrivateIndex()].ptr) #endif /* _CFB8_16_H */ diff --git a/hw/xfree86/xf8_16bpp/cfb8_16module.c b/hw/xfree86/xf8_16bpp/cfb8_16module.c index b2b126d95..1a034980a 100644 --- a/hw/xfree86/xf8_16bpp/cfb8_16module.c +++ b/hw/xfree86/xf8_16bpp/cfb8_16module.c @@ -12,7 +12,7 @@ static XF86ModuleVersionInfo VersRec = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 1, 0, 0, ABI_CLASS_ANSIC, /* Only need the ansic layer */ ABI_ANSIC_VERSION, diff --git a/hw/xfree86/xf8_16bpp/cfbscrinit.c b/hw/xfree86/xf8_16bpp/cfbscrinit.c index cb4b8d726..e8d911db4 100644 --- a/hw/xfree86/xf8_16bpp/cfbscrinit.c +++ b/hw/xfree86/xf8_16bpp/cfbscrinit.c @@ -34,6 +34,8 @@ int cfb8_16ScreenPrivateIndex; +int cfb8_16GetScreenPrivateIndex(void) { return cfb8_16ScreenPrivateIndex; } + static unsigned long cfb8_16Generation = 0; static PixmapPtr cfb8_16GetWindowPixmap(WindowPtr pWin); diff --git a/hw/xfree86/xf8_32bpp/cfb8_32.h b/hw/xfree86/xf8_32bpp/cfb8_32.h index 98a50f810..d992b77c5 100644 --- a/hw/xfree86/xf8_32bpp/cfb8_32.h +++ b/hw/xfree86/xf8_32bpp/cfb8_32.h @@ -19,8 +19,10 @@ typedef struct { } cfb8_32ScreenRec, *cfb8_32ScreenPtr; -extern int cfb8_32GCPrivateIndex; -extern int cfb8_32ScreenPrivateIndex; +extern int cfb8_32GCPrivateIndex; /* XXX */ +extern int cfb8_32GetGCPrivateIndex(void); +extern int cfb8_32ScreenPrivateIndex; /* XXX */ +extern int cfb8_32GetScreenPrivateIndex(void); void cfb8_32SaveAreas( @@ -212,10 +214,10 @@ cfb8_32ChangeWindowAttributes( #define CFB8_32_GET_GC_PRIVATE(pGC)\ - (cfb8_32GCPtr)((pGC)->devPrivates[cfb8_32GCPrivateIndex].ptr) + (cfb8_32GCPtr)((pGC)->devPrivates[cfb8_32GetGCPrivateIndex()].ptr) #define CFB8_32_GET_SCREEN_PRIVATE(pScreen)\ - (cfb8_32ScreenPtr)((pScreen)->devPrivates[cfb8_32ScreenPrivateIndex].ptr) + (cfb8_32ScreenPtr)((pScreen)->devPrivates[cfb8_32GetScreenPrivateIndex()].ptr) Bool xf86Overlay8Plus32Init (ScreenPtr pScreen); diff --git a/hw/xfree86/xf8_32bpp/cfb8_32module.c b/hw/xfree86/xf8_32bpp/cfb8_32module.c index 2c8f203f8..7b27e498a 100644 --- a/hw/xfree86/xf8_32bpp/cfb8_32module.c +++ b/hw/xfree86/xf8_32bpp/cfb8_32module.c @@ -13,7 +13,7 @@ static XF86ModuleVersionInfo VersRec = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 1, 0, 0, ABI_CLASS_ANSIC, /* Only need the ansic layer */ ABI_ANSIC_VERSION, diff --git a/hw/xfree86/xf8_32bpp/cfbpntwin.c b/hw/xfree86/xf8_32bpp/cfbpntwin.c index 62026768e..31e66ced5 100644 --- a/hw/xfree86/xf8_32bpp/cfbpntwin.c +++ b/hw/xfree86/xf8_32bpp/cfbpntwin.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/hw/xfree86/xf8_32bpp/cfbpntwin.c,v 1.1.4.2.2.3 2004/03/04 20:16:51 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/xfree86/xf8_32bpp/cfbpntwin.c,v 1.2 2004/04/23 19:54:21 eich Exp $ */ /* $XFree86: xc/programs/Xserver/hw/xfree86/xf8_32bpp/cfbpntwin.c,v 1.1 1999/01/03 03:58:56 dawes Exp $ */ #include "X.h" diff --git a/hw/xfree86/xf8_32bpp/cfbscrinit.c b/hw/xfree86/xf8_32bpp/cfbscrinit.c index 93323d487..dc23d912c 100644 --- a/hw/xfree86/xf8_32bpp/cfbscrinit.c +++ b/hw/xfree86/xf8_32bpp/cfbscrinit.c @@ -38,7 +38,9 @@ static BSFuncRec cfb8_32BSFuncRec = { int cfb8_32GCPrivateIndex; +int cfb8_32GetGCPrivateIndex(void) { return cfb8_32GCPrivateIndex; } int cfb8_32ScreenPrivateIndex; +int cfb8_32GetScreenPrivateIndex(void) { return cfb8_32ScreenPrivateIndex; } static unsigned long cfb8_32Generation = 0; static Bool diff --git a/hw/xfree86/xf8_32wid/cfb8_32wid.h b/hw/xfree86/xf8_32wid/cfb8_32wid.h index 2168054d9..1d1093e54 100644 --- a/hw/xfree86/xf8_32wid/cfb8_32wid.h +++ b/hw/xfree86/xf8_32wid/cfb8_32wid.h @@ -27,7 +27,8 @@ typedef struct { cfb8_32WidOps *WIDOps; } cfb8_32WidScreenRec, *cfb8_32WidScreenPtr; -extern int cfb8_32WidScreenPrivateIndex; +extern int cfb8_32WidScreenPrivateIndex; /* XXX */ +extern int cfb8_32WidGetScreenPrivateIndex(void); Bool cfb8_32WidScreenInit ( @@ -88,6 +89,6 @@ Bool cfb8_32WidGenericOpsInit(cfb8_32WidScreenPtr pScreenPriv); #define CFB8_32WID_GET_SCREEN_PRIVATE(pScreen)\ - (cfb8_32WidScreenPtr)((pScreen)->devPrivates[cfb8_32WidScreenPrivateIndex].ptr) + (cfb8_32WidScreenPtr)((pScreen)->devPrivates[cfb8_32WidGetScreenPrivateIndex()].ptr) #endif /* _CFB8_32WID_H */ diff --git a/hw/xfree86/xf8_32wid/cfb8_32widmodule.c b/hw/xfree86/xf8_32wid/cfb8_32widmodule.c index 83b6118bb..95f8c9d02 100644 --- a/hw/xfree86/xf8_32wid/cfb8_32widmodule.c +++ b/hw/xfree86/xf8_32wid/cfb8_32widmodule.c @@ -12,7 +12,7 @@ static XF86ModuleVersionInfo VersRec = MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, - XF86_VERSION_CURRENT, + XORG_VERSION_CURRENT, 1, 0, 0, ABI_CLASS_ANSIC, /* Only need the ansic layer */ ABI_ANSIC_VERSION, diff --git a/hw/xfree86/xf8_32wid/cfbscrinit.c b/hw/xfree86/xf8_32wid/cfbscrinit.c index 8f307034f..02f6cd21f 100644 --- a/hw/xfree86/xf8_32wid/cfbscrinit.c +++ b/hw/xfree86/xf8_32wid/cfbscrinit.c @@ -36,6 +36,10 @@ compiled with CFB_NEED_SCREEN_PRIVATE */ int cfb8_32WidScreenPrivateIndex; +int cfb8_32WidGetScreenPrivateIndex(void) +{ + return cfb8_32WidScreenPrivateIndex; +} static unsigned long cfb8_32WidGeneration = 0; extern WindowPtr *WindowTable; diff --git a/hw/xfree86/xorgconf.cpp b/hw/xfree86/xorgconf.cpp index c94c1e5a4..71b6dea98 100644 --- a/hw/xfree86/xorgconf.cpp +++ b/hw/xfree86/xorgconf.cpp @@ -1,4 +1,4 @@ -XCOMM $XdotOrg$ +XCOMM $XdotOrg: xc/programs/Xserver/hw/xfree86/xorgconf.cpp,v 1.2 2004/04/23 19:20:02 eich Exp $ XCOMM XCOMM Copyright (c) 1994-1998 by The XFree86 Project, Inc. XCOMM diff --git a/hw/xnest/Args.c b/hw/xnest/Args.c index 0da0d5006..cc9a2707f 100644 --- a/hw/xnest/Args.c +++ b/hw/xnest/Args.c @@ -47,6 +47,11 @@ int xnestNumScreens = 0; Bool xnestDoDirectColormaps = False; Window xnestParentWindow = 0; +/* ddxInitGlobals - called by |InitGlobals| from os/util.c */ +void ddxInitGlobals(void) +{ +} + int ddxProcessArgument (int argc, char *argv[], int i) { diff --git a/hw/xnest/Cursor.c b/hw/xnest/Cursor.c index 146e7ebd0..aaab62c23 100644 --- a/hw/xnest/Cursor.c +++ b/hw/xnest/Cursor.c @@ -33,59 +33,6 @@ is" without express or implied warranty. #include "Keyboard.h" #include "Args.h" -void -xnestConstrainCursor(ScreenPtr pScreen, BoxPtr pBox) -{ -#ifdef _XSERVER64 - Window64 wroot; -#else - Window wroot; -#endif - - int wx, wy; - unsigned int wwidth, wheight; - unsigned int wborderwidth; - unsigned int wdepth; - - XGetGeometry(xnestDisplay, xnestDefaultWindows[pScreen->myNum], &wroot, - &wx, &wy, &wwidth, &wheight, &wborderwidth, &wdepth); - - if (pBox->x1 <= 0 && pBox->y1 <= 0 && - pBox->x2 >= wwidth && pBox->y2 >= wheight) - XUngrabPointer(xnestDisplay, CurrentTime); - else { - XReparentWindow(xnestDisplay, xnestConfineWindow, - xnestDefaultWindows[pScreen->myNum], - pBox->x1, pBox->y1); - XResizeWindow(xnestDisplay, xnestConfineWindow, - pBox->x2 - pBox->x1, pBox->y2 - pBox->y1); - - XGrabPointer(xnestDisplay, - xnestDefaultWindows[pScreen->myNum], - True, - xnestEventMask & (~XNEST_KEYBOARD_EVENT_MASK|KeymapStateMask), - GrabModeAsync, GrabModeAsync, - xnestConfineWindow, - None, CurrentTime); - } -} - -void -xnestCursorLimits(ScreenPtr pScreen, CursorPtr pCursor, BoxPtr pHotBox, - BoxPtr pTopLeftBox) -{ - *pTopLeftBox = *pHotBox; -} - -Bool -xnestDisplayCursor(ScreenPtr pScreen, CursorPtr pCursor) -{ - XDefineCursor(xnestDisplay, - xnestDefaultWindows[pScreen->myNum], - xnestCursor(pCursor, pScreen)); - return True; -} - Bool xnestRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor) { @@ -192,15 +139,17 @@ xnestRecolorCursor(ScreenPtr pScreen, CursorPtr pCursor, Bool displayed) &fg_color, &bg_color); } -Bool -xnestSetCursorPosition(ScreenPtr pScreen, int x, int y, Bool generateEvent) +void xnestSetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y) { - int i; + if (pCursor) + { + XDefineCursor(xnestDisplay, + xnestDefaultWindows[pScreen->myNum], + xnestCursor(pCursor, pScreen)); + } +} - for (i = 0; i < xnestNumScreens; i++) - XWarpPointer(xnestDisplay, xnestDefaultWindows[i], - xnestDefaultWindows[pScreen->myNum], - 0, 0, 0, 0, x, y); - - return True; +void +xnestMoveCursor (ScreenPtr pScreen, int x, int y) +{ } diff --git a/hw/xnest/Events.c b/hw/xnest/Events.c index a36e0d8e8..69a3c208f 100644 --- a/hw/xnest/Events.c +++ b/hw/xnest/Events.c @@ -34,6 +34,7 @@ is" without express or implied warranty. #include "Screen.h" #include "XNWindow.h" #include "Events.h" +#include "mipointer.h" CARD32 lastEventTime = 0; @@ -41,6 +42,7 @@ void ProcessInputEvents() { mieqProcessInputEvents(); + miPointerUpdate(); } int @@ -131,11 +133,15 @@ xnestCollectEvents() break; case MotionNotify: +#if 0 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); +#endif + miPointerAbsoluteCursor (X.xmotion.x, X.xmotion.y, + lastEventTime = GetTimeInMillis()); break; case FocusIn: @@ -162,11 +168,15 @@ xnestCollectEvents() pScreen = xnestScreen(X.xcrossing.window); if (pScreen) { NewCurrentScreen(pScreen, X.xcrossing.x, X.xcrossing.y); +#if 0 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); +#endif + miPointerAbsoluteCursor (X.xcrossing.x, X.xcrossing.y, + lastEventTime = GetTimeInMillis()); xnestDirectInstallColormaps(pScreen); } } diff --git a/hw/xnest/GCOps.c b/hw/xnest/GCOps.c index 042a29f6e..4ccc0b916 100644 --- a/hw/xnest/GCOps.c +++ b/hw/xnest/GCOps.c @@ -310,5 +310,16 @@ void xnestPushPixels(GCPtr pGC, PixmapPtr pBitmap, DrawablePtr pDst, int width, int height, int x, int y) { - ErrorF("xnest warning: function xnestPushPixels not implemented\n"); + /* only works for solid bitmaps */ + if (pGC->fillStyle == FillSolid) + { + XSetStipple (xnestDisplay, xnestGC(pGC), xnestPixmap(pBitmap)); + XSetTSOrigin (xnestDisplay, xnestGC(pGC), x, y); + XSetFillStyle (xnestDisplay, xnestGC(pGC), FillStippled); + XFillRectangle (xnestDisplay, xnestDrawable(pDst), + xnestGC(pGC), x, y, width, height); + XSetFillStyle (xnestDisplay, xnestGC(pGC), FillSolid); + } + else + ErrorF("xnest warning: function xnestPushPixels not implemented\n"); } diff --git a/hw/xnest/Keyboard.c b/hw/xnest/Keyboard.c index 2a4c7d1bb..b7cae839f 100644 --- a/hw/xnest/Keyboard.c +++ b/hw/xnest/Keyboard.c @@ -1,5 +1,5 @@ /* $Xorg: Keyboard.c,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */ -/* $XdotOrg$ */ +/* $XdotOrg: xc/programs/Xserver/hw/xnest/Keyboard.c,v 1.2 2004/04/23 19:54:21 eich Exp $ */ /* Copyright 1993 by Davor Matic @@ -14,6 +14,7 @@ is" without express or implied warranty. */ /* $XFree86: xc/programs/Xserver/hw/xnest/Keyboard.c,v 1.9 2003/09/13 21:33:09 dawes Exp $ */ + #define NEED_EVENTS #include "X.h" #include "Xproto.h" diff --git a/hw/xnest/Screen.c b/hw/xnest/Screen.c index 3412edfb8..8490a7995 100644 --- a/hw/xnest/Screen.c +++ b/hw/xnest/Screen.c @@ -124,6 +124,14 @@ static miPointerScreenFuncRec xnestPointerCursorFuncs = miPointerWarpCursor }; +static miPointerSpriteFuncRec xnestPointerSpriteFuncs = +{ + xnestRealizeCursor, + xnestUnrealizeCursor, + xnestSetCursor, + xnestMoveCursor, +}; + Bool xnestOpenScreen(int index, ScreenPtr pScreen, int argc, char *argv[]) { @@ -241,27 +249,6 @@ xnestOpenScreen(int index, ScreenPtr pScreen, int argc, char *argv[]) xnestHeight = gattributes.height; } - /* myNum */ - /* id */ - miScreenInit(pScreen, NULL, xnestWidth, xnestHeight, 1, 1, xnestWidth, - rootDepth, - numDepths, depths, - defaultVisual, /* root visual */ - numVisuals, visuals); - - miInitializeBackingStore(pScreen); - - miDCInitialize(pScreen, &xnestPointerCursorFuncs); - - pScreen->mmWidth = xnestWidth * DisplayWidthMM(xnestDisplay, - DefaultScreen(xnestDisplay)) / - DisplayWidth(xnestDisplay, - DefaultScreen(xnestDisplay)); - pScreen->mmHeight = xnestHeight * DisplayHeightMM(xnestDisplay, - DefaultScreen(xnestDisplay)) / - DisplayHeight(xnestDisplay, - DefaultScreen(xnestDisplay)); - pScreen->defColormap = (Colormap) FakeClientID(0); pScreen->minInstalledCmaps = MINCMAPS; pScreen->maxInstalledCmaps = MAXCMAPS; @@ -282,7 +269,6 @@ xnestOpenScreen(int index, ScreenPtr pScreen, int argc, char *argv[]) /* Random screen procedures */ - pScreen->CloseScreen = xnestCloseScreen; pScreen->QueryBestSize = xnestQueryBestSize; pScreen->SaveScreen = xnestSaveScreen; pScreen->GetImage = xnestGetImage; @@ -324,16 +310,6 @@ xnestOpenScreen(int index, ScreenPtr pScreen, int argc, char *argv[]) pScreen->RealizeFont = xnestRealizeFont; pScreen->UnrealizeFont = xnestUnrealizeFont; - /* Cursor Procedures */ - - pScreen->ConstrainCursor = xnestConstrainCursor; - pScreen->CursorLimits = xnestCursorLimits; - pScreen->DisplayCursor = xnestDisplayCursor; - pScreen->RealizeCursor = xnestRealizeCursor; - pScreen->UnrealizeCursor = xnestUnrealizeCursor; - pScreen->RecolorCursor = xnestRecolorCursor; - pScreen->SetCursorPosition = xnestSetCursorPosition; - /* GC procedures */ pScreen->CreateGC = xnestCreateGC; @@ -356,6 +332,31 @@ xnestOpenScreen(int index, ScreenPtr pScreen, int argc, char *argv[]) pScreen->WakeupHandler = (ScreenWakeupHandlerProcPtr)NoopDDA; pScreen->blockData = NULL; pScreen->wakeupData = NULL; + /* myNum */ + /* id */ + miScreenInit(pScreen, NULL, xnestWidth, xnestHeight, 1, 1, xnestWidth, + rootDepth, + numDepths, depths, + defaultVisual, /* root visual */ + numVisuals, visuals); + +/* miInitializeBackingStore(pScreen); */ + + miPointerInitialize (pScreen, &xnestPointerSpriteFuncs, + &xnestPointerCursorFuncs, True); + + pScreen->mmWidth = xnestWidth * DisplayWidthMM(xnestDisplay, + DefaultScreen(xnestDisplay)) / + DisplayWidth(xnestDisplay, + DefaultScreen(xnestDisplay)); + pScreen->mmHeight = xnestHeight * DisplayHeightMM(xnestDisplay, + DefaultScreen(xnestDisplay)) / + DisplayHeight(xnestDisplay, + DefaultScreen(xnestDisplay)); + + /* overwrite miCloseScreen with our own */ + pScreen->CloseScreen = xnestCloseScreen; + if (!miScreenDevPrivateInit(pScreen, xnestWidth, NULL)) return FALSE; diff --git a/hw/xnest/XNCursor.h b/hw/xnest/XNCursor.h index b396c80b5..8684a5e7f 100644 --- a/hw/xnest/XNCursor.h +++ b/hw/xnest/XNCursor.h @@ -27,14 +27,9 @@ typedef struct { #define xnestCursor(pCursor, pScreen) \ (xnestCursorPriv(pCursor, pScreen)->cursor) -void xnestConstrainCursor(ScreenPtr pScreen, BoxPtr pBox); -void xnestCursorLimits(ScreenPtr pScreen, CursorPtr pCursor, BoxPtr pHotBox, - BoxPtr pTopLeftBox); -Bool xnestDisplayCursor(ScreenPtr pScreen, CursorPtr pCursor); Bool xnestRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor); Bool xnestUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor); -void xnestRecolorCursor(ScreenPtr pScreen, CursorPtr pCursor, Bool displayed); -Bool xnestSetCursorPosition(ScreenPtr pScreen, int x, int y, - Bool generateEvent); +void xnestSetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y); +void xnestMoveCursor (ScreenPtr pScreen, int x, int y); #endif /* XNESTCURSOR_H */ diff --git a/hw/xwin/ChangeLog b/hw/xwin/ChangeLog index e87adda6c..2f5584cc0 100644 --- a/hw/xwin/ChangeLog +++ b/hw/xwin/ChangeLog @@ -7,6 +7,17 @@ fUseUnicode, because it don't mean wheather Windows support Unicode or not. +2004-07-31 Alexander Gottwald <ago@freedesktop.org> + + * win.h: + adjust prototype for winInitCmapPrivates to match Egberts change. + +2004-07-30 Egbert Eich <eich@freedesktop.org> + + * winallpriv.c: (winInitCmapPrivates): + test if colormap with index really exists in the list of + installed maps before using it. + 2004-07-09 Alexander Gottwald <ago@freedesktop.org> * winconfig.c: Add entry for irish layout (ie) diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c index 63a13be32..673a0aa98 100644 --- a/hw/xwin/InitOutput.c +++ b/hw/xwin/InitOutput.c @@ -375,7 +375,7 @@ OsVendorInit (void) } LogSetParameter (XLOG_FLUSH, 1); LogSetParameter (XLOG_VERBOSITY, g_iLogVerbose); - LogSetParameter (XLOG_FILE_VERBOSITY, g_iLogVerbose); + LogSetParameter (XLOG_FILE_VERBOSITY, 1); /* Log the version information */ if (serverGeneration == 1) @@ -578,6 +578,10 @@ ddxUseMsg(void) MB_ICONINFORMATION); } +/* ddxInitGlobals - called by |InitGlobals| from os/util.c */ +void ddxInitGlobals(void) +{ +} #ifdef DDXTIME /* from ServerOSDefines */ CARD32 diff --git a/hw/xwin/README b/hw/xwin/README new file mode 100644 index 000000000..219fd1337 --- /dev/null +++ b/hw/xwin/README @@ -0,0 +1,141 @@ +Cygwin/X Release Notes +====================== + +Release X11R6.7 +=============== + +Cygwin/X has continued its rapid pace of development that it has sustained +since Spring 2001 and this release shows it, we now have: a stable and fast +multi-window mode, seamless clipboard integration, a configurable tray menu +icon, popups on error messages pointing users to the log file and our mailing +list, the beginnings of indirect 3D acceleration for OpenGL applications, +improved non-US keyboard and clipboard support, and only a handful of bugs +that continue to be reported. + +Between the XFree86 4.3.0 release and the X.Org X11R6.7 release the Cyg- +win/XFree86 project broke away from The XFree86 Project, Inc. due to a lack +of support from the XFree86 project. As such, the Cygwin/XFree86 project was +renamed to the Cygwin/X project and the upstream source code tree that Cyg- +win/X pulls from and pushes to is now the tree managed by the X.Org Founda- +tion. The Cygwin/X project has seen a rush of development and interest in +the project since the split; one metric showing this is that the number of +CVS committers we have has gone from zero to six. + +The most outstanding features of this release are + + o Major multi-window mode improvements. (Takuma Murakami, Earle F. + Philhower III) + + o Initial work of accelerated OpenGL using the windows OpenGL drivers. + (Alexander Gottwald) + + o Massive rework of clipboard integration with windows. (Harold L Hunt II, + Kensuke Matsuzaki) + + o Improved Japanese clipboard and keyboard support. (Kensuke Matsuzaki, + Takuma Murakami, Alexander Gottwald) + + o Customizable tray menu icon allowing shortcuts to start programs, + etc.(Earle F. Philhower III) + + o New icons. (Jehan Bing, Michael Bax, Benjamin Rienfenstahl) + + o Fix some multi-monitor problems.(Takuma Murakami) + + o Fix repeated key strokes. (Ivan Pascal) + + o Automatic keyboard layouts for the most frequently used keyboard lay- + outs. (Alexander Gottwald) + + o Built in SHM support with detection of the SHM engine (cygserver). + (Ralf Habacker, Harold L Hunt II) + + o Merged in work on the NativeGDI engine. (Alan Hourihane) + +OpenGL with Cygwin/X +==================== + +Cygwin/X has supported GLX only with software rendering provided by the Mesa +library. Starting with X11R6.7 we add support for hardware accelerated OpenGL. + +This support is still under development and still has some bigger problems. +To provide both versions (the stable software rendering and the new hardware +accelerated) we ship to binaries. XWin.exe contains the software rendering +and XWin_GL.exe uses the hardware acceleration provided by the windows drivers. + +The known problems with hardware accelerated OpenGL are: + + o Only multiwindow mode is useful. In the other modes the OpenGL output + does not align with the X11 windows. + + o Using two programs which require different visuals will fail. For example + glxgears and glxinfo will not work without restarting XWin_GL.exe. + + o OpenGL extensions and functions from OpenGL 1.2 and later should work + but are not completely tested. + + o The standard Windows OpenGL driver will produce no output. Use the one + from your video adapter vendor. + +If you notice problems with some programs please send a message with the +logfile /tmp/XWin.log and a short error description to <cygwin-xfree@cygwin.com> + +The hardware accelerated OpenGL was tested using: + + o glxgears + o glxinfo + o blender + o tuxkart + o GLUT demos (some did fail) + o tuxracer (currently not working) + + +Release X11R6.8 +=============== + +Having reached a quite mature state in release X11R6.7 the development +has slowed down a little bit. Some of the former active developers have +retired or cut their work for the Cygwin/X project due to conflicts with +job, study and family. + +The X11R6.8 release now includes major improvements from the xserver project. +This includes the XFixes, Damage, Composite and XEVIE extension which is a +major step towards allowing Cygwin/X to have real transparency. + +But at the current state Composite is not working with Cygwin/X. Not all code +in the Cygwin/X Server has been updated to support the Composite feature and +using it will even crash the xserver. But as a second problem nearly all +functions required for compositing are lacking acceleration in Cygwin/X so +the feature would not be very useful if it would work. So it is disabled by +default. + +OpenGL with Cygwin/X +==================== + +The OpenGL support has lost some of it's limitations from the last release +and should be much more stable. But due to missing wide spread testing in +the community it is still available in a separate program. XWin still uses +the old software OpenGL which is known to be stable. + +The known problems with hardware accelerated OpenGL are: + + o Only multiwindow mode is useful. In the other modes the OpenGL output + does not align with the X11 windows. + + o OpenGL extensions and functions from OpenGL 1.2 and later should work + but are not completely tested. + + o The standard Windows OpenGL driver will produce no output. Use the one + from your video adapter vendor. + +If you notice problems with some programs please send a message with the +logfile /tmp/XWin.log and a short error description to <cygwin-xfree@cygwin.com> + +The hardware accelerated OpenGL was tested using: + + o glxgears + o glxinfo + o blender + o tuxkart + o GLUT demos (some did fail) + diff --git a/hw/xwin/win.h b/hw/xwin/win.h index 46ccb7884..3660b9623 100644 --- a/hw/xwin/win.h +++ b/hw/xwin/win.h @@ -719,7 +719,7 @@ Bool winAllocatePrivates (ScreenPtr pScreen); Bool -winInitCmapPrivates (ColormapPtr pCmap); +winInitCmapPrivates (ColormapPtr pCmap, int index); Bool winAllocateCmapPrivates (ColormapPtr pCmap); diff --git a/hw/xwin/winallpriv.c b/hw/xwin/winallpriv.c index 8fca13926..2c85645c7 100644 --- a/hw/xwin/winallpriv.c +++ b/hw/xwin/winallpriv.c @@ -116,7 +116,7 @@ winAllocatePrivates (ScreenPtr pScreen) */ Bool -winInitCmapPrivates (ColormapPtr pcmap) +winInitCmapPrivates (ColormapPtr pcmap, int index) { #if CYGDEBUG winDebug ("winInitCmapPrivates\n"); @@ -129,7 +129,9 @@ winInitCmapPrivates (ColormapPtr pcmap) * anything. Perhaps I am misunderstanding the purpose * of this function. */ - + /* That's definitely true. + * I therefore changed the API and added the index as argument. + */ return TRUE; } diff --git a/include/cursor.h b/include/cursor.h index 40b2fbf59..7e2a9d82d 100644 --- a/include/cursor.h +++ b/include/cursor.h @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/include/cursor.h,v 1.1.4.4.4.3 2004/03/04 20:17:01 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/include/cursor.h,v 1.2 2004/04/23 19:54:23 eich Exp $ */ /* $XFree86: xc/programs/Xserver/include/cursor.h,v 1.6 2002/09/17 01:15:14 dawes Exp $ */ /*********************************************************** diff --git a/include/cursorstr.h b/include/cursorstr.h index 3984245ad..c877d6cc9 100644 --- a/include/cursorstr.h +++ b/include/cursorstr.h @@ -77,10 +77,22 @@ typedef struct _Cursor { unsigned short backRed, backGreen, backBlue; /* device-independent color */ int refcnt; pointer devPriv[MAXSCREENS]; /* set by pScr->RealizeCursor*/ +#ifdef XFIXES + CARD32 serialNumber; + Atom name; +#endif } CursorRec; typedef struct _CursorMetric { unsigned short width, height, xhot, yhot; } CursorMetricRec; +typedef struct { + int x, y; + ScreenPtr pScreen; +} HotSpot; + +#ifdef XEVIE +extern HotSpot xeviehot; +#endif #endif /* CURSORSTRUCT_H */ diff --git a/include/dix.h b/include/dix.h index 20a182d2e..a7d71ef68 100644 --- a/include/dix.h +++ b/include/dix.h @@ -383,6 +383,12 @@ extern void CopyISOLatin1Lowered( unsigned char * /*source*/, int /*length*/); +extern int CompareISOLatin1Lowered( + unsigned char * /*a*/, + int alen, + unsigned char * /*b*/, + int blen); + #ifdef XCSECURITY extern WindowPtr SecurityLookupWindow( @@ -430,8 +436,10 @@ extern void NoopDDA(void); extern int AlterSaveSetForClient( ClientPtr /*client*/, WindowPtr /*pWin*/, - unsigned /*mode*/); - + unsigned /*mode*/, + Bool /*toRoot*/, + Bool /*remap*/); + extern void DeleteWindowFromAnySaveSet( WindowPtr /*pWin*/); @@ -789,4 +797,21 @@ typedef struct { int count; } DeviceEventInfoRec; +/* + * SelectionCallback stuff + */ + +extern CallbackListPtr SelectionCallback; + +typedef enum { + SelectionSetOwner, + SelectionWindowDestroy, + SelectionClientClose +} SelectionCallbackKind; + +typedef struct { + struct _Selection *selection; + SelectionCallbackKind kind; +} SelectionInfoRec; + #endif /* DIX_H */ diff --git a/include/dixstruct.h b/include/dixstruct.h index 9c39a8aec..d7d810272 100644 --- a/include/dixstruct.h +++ b/include/dixstruct.h @@ -68,6 +68,28 @@ typedef enum {ClientStateInitial, ClientStateCheckingSecurity, ClientStateCheckedSecurity} ClientState; +#ifdef XFIXES +typedef struct _saveSet { + struct _Window *windowPtr; + Bool toRoot; + Bool remap; +} SaveSetElt; +#define SaveSetWindow(ss) ((ss).windowPtr) +#define SaveSetToRoot(ss) ((ss).toRoot) +#define SaveSetRemap(ss) ((ss).remap) +#define SaveSetAssignWindow(ss,w) ((ss).windowPtr = (w)) +#define SaveSetAssignToRoot(ss,tr) ((ss).toRoot = (tr)) +#define SaveSetAssignRemap(ss,rm) ((ss).remap = (rm)) +#else +typedef struct _Window *SaveSetElt; +#define SaveSetWindow(ss) (ss) +#define SaveSetToRoot(ss) FALSE +#define SaveSetRemap(ss) TRUE +#define SaveSetAssignWindow(ss,w) ((ss) = (w)) +#define SaveSetAssignToRoot(ss,tr) +#define SaveSetAssignRemap(ss,rm) +#endif + typedef struct _Client { int index; Mask clientAsMask; @@ -85,7 +107,7 @@ typedef struct _Client { Drawable lastDrawableID; GCPtr lastGC; GContext lastGCID; - pointer *saveSet; + SaveSetElt *saveSet; int numSaved; pointer screenPrivate[MAXSCREENS]; int (**requestVector) ( diff --git a/include/globals.h b/include/globals.h index c2e98ea22..9fd55f4b6 100644 --- a/include/globals.h +++ b/include/globals.h @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/include/globals.h,v 1.1.4.2.2.3 2004/03/04 20:17:01 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/include/globals.h,v 1.4 2004/07/31 09:14:06 kem Exp $ */ /* $XFree86: xc/programs/Xserver/include/globals.h,v 1.3 1999/09/25 14:38:21 dawes Exp $ */ #ifndef _XSERV_GLOBAL_H_ @@ -49,5 +49,16 @@ extern Bool PanoramiXWindowExposureSent; extern Bool PanoramiXOneExposeRequest; #endif +#ifdef RENDER +extern Bool noRenderExtension; +#endif + +#ifdef XEVIE +extern Bool noXevieExtension; +#endif + +#ifdef COMPOSITE +extern Bool noCompositeExtension; +#endif #endif /* _XSERV_GLOBAL_H_ */ diff --git a/include/input.h b/include/input.h index fa88febda..9bcdd9f58 100644 --- a/include/input.h +++ b/include/input.h @@ -45,7 +45,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ -/* $XFree86: xc/programs/Xserver/include/input.h,v 3.7 2001/12/14 19:59:54 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/include/input.h,v 3.8 2003/04/27 21:31:04 herrb Exp $ */ #ifndef INPUT_H #define INPUT_H @@ -92,6 +92,17 @@ typedef void (*ProcessInputProc)( DeviceIntPtr /*device*/, int /*count*/); +typedef Bool (*DeviceHandleProc)( + DeviceIntPtr /*device*/, + void* /*data*/ + ); + +typedef void (*DeviceUnwrapProc)( + DeviceIntPtr /*device*/, + DeviceHandleProc /*proc*/, + void* /*data*/ + ); + typedef struct _DeviceRec { pointer devicePrivate; ProcessInputProc processInputProc; /* current */ @@ -145,6 +156,10 @@ typedef struct { unsigned char id; } LedCtrl; +extern int AllocateDevicePrivateIndex(void); +extern Bool AllocateDevicePrivate(DeviceIntPtr device, int index); +extern void ResetDevicePrivateIndex(void); + extern KeybdCtrl defaultKeyboardControl; extern PtrCtrl defaultPointerControl; diff --git a/include/inputstr.h b/include/inputstr.h index 70627629b..b54e8a1d5 100644 --- a/include/inputstr.h +++ b/include/inputstr.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/include/inputstr.h,v 1.5 2001/12/14 19:59:54 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/include/inputstr.h,v 1.6 2003/04/27 21:31:04 herrb Exp $ */ /************************************************************ Copyright 1987, 1998 The Open Group @@ -285,6 +285,9 @@ typedef struct _DeviceIntRec { #ifdef XKB struct _XkbInterest * xkb_interest; #endif + DevUnion *devPrivates; + int nPrivates; + DeviceUnwrapProc unwrapProc; } DeviceIntRec; typedef struct { diff --git a/include/os.h b/include/os.h index d82652c2d..b553e06e1 100644 --- a/include/os.h +++ b/include/os.h @@ -231,6 +231,8 @@ extern SIGVAL GiveUp(int /*sig*/); extern void UseMsg(void); +extern void InitGlobals(void); + extern void ProcessCommandLine(int /*argc*/, char* /*argv*/[]); extern int set_font_authorizations( @@ -412,6 +414,8 @@ extern XID GenerateAuthorization( extern void ExpandCommandLine(int * /*pargc*/, char *** /*pargv*/); #endif +extern void ddxInitGlobals(void); + extern int ddxProcessArgument(int /*argc*/, char * /*argv*/ [], int /*i*/); extern void ddxUseMsg(void); diff --git a/include/pixmapstr.h b/include/pixmapstr.h index 1b0df9fd3..22a1f1025 100644 --- a/include/pixmapstr.h +++ b/include/pixmapstr.h @@ -79,6 +79,10 @@ typedef struct _Pixmap { #ifdef PIXPRIV DevUnion *devPrivates; /* real devPrivates like gcs & windows */ #endif +#ifdef COMPOSITE + short screen_x; + short screen_y; +#endif } PixmapRec; #endif /* PIXMAPSTRUCT_H */ diff --git a/include/regionstr.h b/include/regionstr.h index 1d068ecc5..c47706709 100644 --- a/include/regionstr.h +++ b/include/regionstr.h @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/include/regionstr.h,v 1.1.4.7.4.1 2004/03/04 17:48:21 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/include/regionstr.h,v 1.3 2004/07/29 18:16:56 stukreit Exp $ */ /* $Xorg: regionstr.h,v 1.4 2001/02/09 02:05:15 xorgcvs Exp $ */ /*********************************************************** @@ -95,81 +95,84 @@ extern RegDataRec miBrokenData; #define REGION_END(reg) REGION_BOX(reg, (reg)->data->numRects - 1) #define REGION_SZOF(n) (sizeof(RegDataRec) + ((n) * sizeof(BoxRec))) +/* Keith recommends weaning the region code of pScreen argument */ +#define REG_pScreen screenInfo.screens[0] + #ifdef NEED_SCREEN_REGIONS #define REGION_CREATE(_pScreen, _rect, _size) \ - (*(_pScreen)->RegionCreate)(_rect, _size) + (*(REG_pScreen)->RegionCreate)(_rect, _size) #define REGION_INIT(_pScreen, _pReg, _rect, _size) \ - (*(_pScreen)->RegionInit)(_pReg, _rect, _size) + (*(REG_pScreen)->RegionInit)(_pReg, _rect, _size) #define REGION_COPY(_pScreen, dst, src) \ - (*(_pScreen)->RegionCopy)(dst, src) + (*(REG_pScreen)->RegionCopy)(dst, src) #define REGION_DESTROY(_pScreen, _pReg) \ - (*(_pScreen)->RegionDestroy)(_pReg) + (*(REG_pScreen)->RegionDestroy)(_pReg) #define REGION_UNINIT(_pScreen, _pReg) \ - (*(_pScreen)->RegionUninit)(_pReg) + (*(REG_pScreen)->RegionUninit)(_pReg) #define REGION_INTERSECT(_pScreen, newReg, reg1, reg2) \ - (*(_pScreen)->Intersect)(newReg, reg1, reg2) + (*(REG_pScreen)->Intersect)(newReg, reg1, reg2) #define REGION_UNION(_pScreen, newReg, reg1, reg2) \ - (*(_pScreen)->Union)(newReg, reg1, reg2) + (*(REG_pScreen)->Union)(newReg, reg1, reg2) #define REGION_SUBTRACT(_pScreen, newReg, reg1, reg2) \ - (*(_pScreen)->Subtract)(newReg, reg1, reg2) + (*(REG_pScreen)->Subtract)(newReg, reg1, reg2) #define REGION_INVERSE(_pScreen, newReg, reg1, invRect) \ - (*(_pScreen)->Inverse)(newReg, reg1, invRect) + (*(REG_pScreen)->Inverse)(newReg, reg1, invRect) #define REGION_RESET(_pScreen, _pReg, _pBox) \ - (*(_pScreen)->RegionReset)(_pReg, _pBox) + (*(REG_pScreen)->RegionReset)(_pReg, _pBox) #define REGION_TRANSLATE(_pScreen, _pReg, _x, _y) \ - (*(_pScreen)->TranslateRegion)(_pReg, _x, _y) + (*(REG_pScreen)->TranslateRegion)(_pReg, _x, _y) #define RECT_IN_REGION(_pScreen, _pReg, prect) \ - (*(_pScreen)->RectIn)(_pReg, prect) + (*(REG_pScreen)->RectIn)(_pReg, prect) #define POINT_IN_REGION(_pScreen, _pReg, _x, _y, prect) \ - (*(_pScreen)->PointInRegion)(_pReg, _x, _y, prect) + (*(REG_pScreen)->PointInRegion)(_pReg, _x, _y, prect) #define REGION_NOTEMPTY(_pScreen, _pReg) \ - (*(_pScreen)->RegionNotEmpty)(_pReg) + (*(REG_pScreen)->RegionNotEmpty)(_pReg) #define REGION_EQUAL(_pScreen, _pReg1, _pReg2) \ - (*(_pScreen)->RegionEqual)(_pReg1, _pReg2) + (*(REG_pScreen)->RegionEqual)(_pReg1, _pReg2) #define REGION_BROKEN(_pScreen, _pReg) \ - (*(_pScreen)->RegionBroken)(_pReg) + (*(REG_pScreen)->RegionBroken)(_pReg) #define REGION_BREAK(_pScreen, _pReg) \ - (*(_pScreen)->RegionBreak)(_pReg) + (*(REG_pScreen)->RegionBreak)(_pReg) #define REGION_EMPTY(_pScreen, _pReg) \ - (*(_pScreen)->RegionEmpty)(_pReg) + (*(REG_pScreen)->RegionEmpty)(_pReg) #define REGION_EXTENTS(_pScreen, _pReg) \ - (*(_pScreen)->RegionExtents)(_pReg) + (*(REG_pScreen)->RegionExtents)(_pReg) #define REGION_APPEND(_pScreen, dstrgn, rgn) \ - (*(_pScreen)->RegionAppend)(dstrgn, rgn) + (*(REG_pScreen)->RegionAppend)(dstrgn, rgn) #define REGION_VALIDATE(_pScreen, badreg, pOverlap) \ - (*(_pScreen)->RegionValidate)(badreg, pOverlap) + (*(REG_pScreen)->RegionValidate)(badreg, pOverlap) #define BITMAP_TO_REGION(_pScreen, pPix) \ - (*(_pScreen)->BitmapToRegion)(pPix) + (*(REG_pScreen)->BitmapToRegion)(pPix) #define RECTS_TO_REGION(_pScreen, nrects, prect, ctype) \ - (*(_pScreen)->RectsToRegion)(nrects, prect, ctype) + (*(REG_pScreen)->RectsToRegion)(nrects, prect, ctype) #else /* !NEED_SCREEN_REGIONS */ /* Reference _pScreen macro argument and check its type */ -#define REGION_SCREEN(_pScreen_) (void)((_pScreen_)->myNum) +#define REGION_SCREEN(_pScreen) (void)((REG_pScreen)->myNum) #define REGION_CREATE(_pScreen, _rect, _size) \ (REGION_SCREEN(_pScreen), miRegionCreate(_rect, _size)) diff --git a/include/screenint.h b/include/screenint.h index b3e76c4c2..1c836952e 100644 --- a/include/screenint.h +++ b/include/screenint.h @@ -104,7 +104,7 @@ extern void ResetColormapPrivates(void); typedef struct _ColormapRec *ColormapPtr; -typedef int (*InitCmapPrivFunc)(ColormapPtr); +typedef int (*InitCmapPrivFunc)(ColormapPtr, int); extern int AllocateColormapPrivateIndex( InitCmapPrivFunc /* initPrivFunc */); diff --git a/include/servermd.h b/include/servermd.h index 994f5c087..c2c11fa73 100644 --- a/include/servermd.h +++ b/include/servermd.h @@ -153,7 +153,7 @@ SOFTWARE. #endif /* __arm32__ */ -#if defined (hpux) +#if defined (hpux) || defined __hppa__ #define IMAGE_BYTE_ORDER MSBFirst #define BITMAP_BIT_ORDER MSBFirst @@ -165,7 +165,7 @@ SOFTWARE. #define LARGE_INSTRUCTION_CACHE #define PLENTIFUL_REGISTERS -#endif /* hpux */ +#endif /* hpux || __hppa__ */ #if defined(__powerpc__) diff --git a/include/window.h b/include/window.h index 5056512b8..1a2845f90 100644 --- a/include/window.h +++ b/include/window.h @@ -252,4 +252,14 @@ void ResizeChildrenWinSize( int /*dw*/, int /*dh*/); +extern void SendShapeNotify( + WindowPtr /* pWin */, + int /* which */ ); + +extern RegionPtr CreateBoundingShape( + WindowPtr /* pWin */ ); + +extern RegionPtr CreateClipShape( + WindowPtr /* pWin */ ); + #endif /* WINDOW_H */ diff --git a/include/windowstr.h b/include/windowstr.h index 8e8d2542a..c89c7b18e 100644 --- a/include/windowstr.h +++ b/include/windowstr.h @@ -136,6 +136,9 @@ typedef struct _Window { unsigned dstBuffer:1; /* destination buffer for rendering */ unsigned srcBuffer:1; /* source buffer for rendering */ #endif +#ifdef COMPOSITE + unsigned redirectDraw:1; /* rendering is redirected from here */ +#endif DevUnion *devPrivates; } WindowRec; @@ -222,4 +225,8 @@ extern ScreenSaverStuffRec savedScreenInfo[MAXSCREENS]; extern int numSaveUndersViewable; extern int deltaSaveUndersViewable; +#ifdef XEVIE +extern WindowPtr xeviewin; +#endif + #endif /* WINDOWSTRUCT_H */ diff --git a/lbx/lbxcmap.c b/lbx/lbxcmap.c index b1366aa3f..5c2c062b3 100644 --- a/lbx/lbxcmap.c +++ b/lbx/lbxcmap.c @@ -104,7 +104,7 @@ LbxColormapPrivInit (ColormapPtr pmap) static int -LbxDefCmapPrivInit (ColormapPtr pmap) +LbxDefCmapPrivInit (ColormapPtr pmap, int index) { #if 0 /* BUG: You can't do that. lbxColormapPrivIndex hasn't diff --git a/mfb/maskbits.c b/mfb/maskbits.c index 09f593ec2..4cd2d493b 100644 --- a/mfb/maskbits.c +++ b/mfb/maskbits.c @@ -1003,6 +1003,12 @@ PixelType rmask[] = #undef _1_ +PixelType mfbGetmask(int i) { return mask[i]; } +PixelType mfbGetrmask(int i) { return rmask[i]; } +PixelType mfbGetstarttab(int i) { return starttab[i]; } +PixelType mfbGetendtab(int i) { return endtab[i]; } +PixelType mfbGetpartmasks(int i, int j) { return partmasks[i][j]; } + /* * Merge raster ops for full src + dest + plane mask * diff --git a/mfb/maskbits.h b/mfb/maskbits.h index 4cd30be39..5ca79c929 100644 --- a/mfb/maskbits.h +++ b/mfb/maskbits.h @@ -224,11 +224,18 @@ getshiftedleftbits(psrc, offset, w, dst) #define MFB_PWSH 5 #endif /* MFB_PPW == 32 */ +/* XXX don't use these five */ extern PixelType starttab[]; extern PixelType endtab[]; extern PixelType partmasks[MFB_PPW][MFB_PPW]; extern PixelType rmask[]; extern PixelType mask[]; +/* XXX use these five */ +extern PixelType mfbGetstarttab(int); +extern PixelType mfbGetendtab(int); +extern PixelType mfbGetpartmasks(int, int); +extern PixelType mfbGetrmask(int); +extern PixelType mfbGetmask(int); #ifndef MFB_CONSTS_ONLY @@ -304,19 +311,19 @@ extern PixelType mask[]; } #define maskbits(x, w, startmask, endmask, nlw) \ - startmask = starttab[(x) & PIM]; \ - endmask = endtab[((x)+(w)) & PIM]; \ + startmask = mfbGetstarttab((x) & PIM); \ + endmask = mfbGetendtab(((x)+(w)) & PIM); \ if (startmask) \ nlw = (((w) - (PPW - ((x) & PIM))) >> PWSH); \ else \ nlw = (w) >> PWSH; #define maskpartialbits(x, w, mask) \ - mask = partmasks[(x) & PIM][(w) & PIM]; + mask = mfbGetpartmasks((x) & PIM, (w) & PIM); #define maskPPWbits(x, w, startmask, endmask) \ - startmask = starttab[(x) & PIM]; \ - endmask = endtab[((x)+(w)) & PIM]; + startmask = mfbGetstarttab((x) & PIM); \ + endmask = mfbGetendtab(((x)+(w)) & PIM); #ifdef __GNUC__ /* XXX don't want for Alpha? */ #ifdef vax @@ -390,8 +397,8 @@ extern PixelType mask[]; { \ register int d = PPW-(x); \ *(pdst) = (*(pdst) & endtab[x]) | (SCRRIGHT((src), x)); \ - (pdst)[1] = ((pdst)[1] & starttab[n]) | \ - (SCRLEFT(src, d) & endtab[n]); \ + (pdst)[1] = ((pdst)[1] & mfbGetstarttab(n)) | \ + (SCRLEFT(src, d) & mfbGetendtab(n)); \ } \ } @@ -440,10 +447,10 @@ extern PixelType mask[]; else \ { \ int m = PPW-(x); \ - *(pdst) = (*(pdst) & endtab[x]) | (t2 & starttab[x]); \ + *(pdst) = (*(pdst) & mfbGetendtab(x)) | (t2 & mfbGetstarttab(x)); \ t1 = SCRLEFT((src), m); \ DoRop(t2, rop, t1, (pdst)[1]); \ - (pdst)[1] = ((pdst)[1] & starttab[n]) | (t2 & endtab[n]); \ + (pdst)[1] = ((pdst)[1] & mfbGetstarttab(n)) | (t2 & mfbGetendtab(n)); \ } \ } @@ -514,10 +521,10 @@ extern PixelType mask[]; else \ { \ int m = PPW-(x); \ - *(pdst) = (*(pdst) & endtab[x]) | (t2 & starttab[x]); \ + *(pdst) = (*(pdst) & mfbGetendtab(x)) | (t2 & mfbGetstarttab(x)); \ t1 = SCRLEFT((src), m); \ t2 = DoRRop(rop, t1, (pdst)[1]); \ - (pdst)[1] = ((pdst)[1] & starttab[n]) | (t2 & endtab[n]); \ + (pdst)[1] = ((pdst)[1] & mfbGetstarttab(n)) | (t2 & mfbGetendtab(n)); \ } \ } #endif @@ -645,7 +652,7 @@ extern PixelType mask[]; if ((width) > _flag) \ _src |= SCRRIGHT (*((psrc) + 1), _flag); \ \ - *(pdst) = (*(pdst) & starttab[(width)]) | (_src & endtab[(width)]); \ + *(pdst) = (*(pdst) & mfbGetstarttab((width))) | (_src & mfbGetendtab((width))); \ } @@ -659,7 +666,7 @@ extern PixelType mask[]; _src |= SCRRIGHT (*((psrc) + 1), _flag); \ DoRop(_src, rop, _src, *(pdst)); \ \ - *(pdst) = (*(pdst) & starttab[(width)]) | (_src & endtab[(width)]); \ + *(pdst) = (*(pdst) & mfbGetstarttab((width))) | (_src & mfbGetendtab((width))); \ } #define getandputrrop0(psrc, sbindex, width, pdst, rop) \ @@ -672,7 +679,7 @@ extern PixelType mask[]; _src |= SCRRIGHT (*((psrc) + 1), _flag); \ _src = DoRRop(rop, _src, *(pdst)); \ \ - *(pdst) = (*(pdst) & starttab[(width)]) | (_src & endtab[(width)]); \ + *(pdst) = (*(pdst) & mfbGetstarttab((width))) | (_src & mfbGetendtab((width))); \ } #endif /* FASTGETBITS && FASTPUTBITS */ @@ -713,6 +713,8 @@ extern void mfbSetWindowPixmap( PixmapPtr /*pPix*/ ); +extern void mfbFillInScreen(ScreenPtr pScreen); + /* mfbseg.c */ extern void mfbSegmentSS( @@ -874,10 +876,14 @@ typedef struct { typedef mfbPrivGC *mfbPrivGCPtr; #endif +/* XXX these should be static, but it breaks the ABI */ extern int mfbGCPrivateIndex; /* index into GC private array */ +extern int mfbGetGCPrivateIndex(void); extern int mfbWindowPrivateIndex; /* index into Window private array */ +extern int mfbGetWindowPrivateIndex(void); #ifdef PIXMAP_PER_WINDOW extern int frameWindowPrivateIndex; /* index into Window private array */ +extern int frameGetWindowPrivateIndex(void); #endif #ifndef MFB_PROTOTYPES_ONLY diff --git a/mfb/mfbscrinit.c b/mfb/mfbscrinit.c index c85d4e36b..7e840303c 100644 --- a/mfb/mfbscrinit.c +++ b/mfb/mfbscrinit.c @@ -65,9 +65,12 @@ SOFTWARE. #ifdef PIXMAP_PER_WINDOW int frameWindowPrivateIndex; +int frameGetWindowPrivateIndex(void) { return frameWindowPrivateIndex; } #endif int mfbWindowPrivateIndex; +int mfbGetWindowPrivateIndex(void) { return mfbWindowPrivateIndex; } int mfbGCPrivateIndex; +int mfbGetGCPrivateIndex(void) { return mfbGCPrivateIndex; } static unsigned long mfbGeneration = 0; static VisualRec visual = { @@ -195,3 +198,13 @@ mfbSetWindowPixmap(pWin, pPix) #endif } +void mfbFillInScreen(ScreenPtr pScreen) +{ + pScreen->ChangeWindowAttributes = mfbChangeWindowAttributes; + pScreen->RealizeWindow = mfbMapWindow; + pScreen->UnrealizeWindow = mfbUnmapWindow; + pScreen->DestroyPixmap = mfbDestroyPixmap; + pScreen->RealizeFont = mfbRealizeFont; + pScreen->UnrealizeFont = mfbUnrealizeFont; + pScreen->BitmapToRegion = mfbPixmapToRegion; +} @@ -495,6 +495,16 @@ extern int miShapedWindowIn( int /*y*/ ); +typedef void +(*SetRedirectBorderClipProcPtr) (WindowPtr pWindow, RegionPtr pRegion); + +typedef RegionPtr +(*GetRedirectBorderClipProcPtr) (WindowPtr pWindow); + +void +miRegisterRedirectBorderClipProc (SetRedirectBorderClipProcPtr setBorderClip, + GetRedirectBorderClipProcPtr getBorderClip); + extern int miValidateTree( WindowPtr /*pParent*/, WindowPtr /*pChild*/, diff --git a/mi/miarc.c b/mi/miarc.c index 9f2c8c15c..920eda2b2 100644 --- a/mi/miarc.c +++ b/mi/miarc.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/mi/miarc.c,v 1.1.4.4.2.2 2004/03/04 20:17:04 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/mi/miarc.c,v 1.2 2004/04/23 19:54:26 eich Exp $ */ /* $XFree86: xc/programs/Xserver/mi/miarc.c,v 3.14 2003/10/29 22:57:48 tsi Exp $ */ /*********************************************************** diff --git a/mi/micmap.c b/mi/micmap.c index 018244a2a..45f8e1ed6 100644 --- a/mi/micmap.c +++ b/mi/micmap.c @@ -530,6 +530,7 @@ miDoInitVisuals(VisualPtr *visualp, DepthPtr *depthp, int *nvisualp, int vtype; miVisualsPtr visuals, nextVisuals; int *preferredCVCs, *prefp; + int first_depth; /* none specified, we'll guess from pixmap formats */ if (!miVisuals) @@ -627,7 +628,24 @@ miDoInitVisuals(VisualPtr *visualp, DepthPtr *depthp, int *nvisualp, miVisuals = NULL; visual = *visualp; depth = *depthp; - for (i = 0; i < ndepth; i++) + + /* + * if we did not supplyied by a preferred visual class + * check if there is a preferred class in one of the depth + * structures - if there is, we want to start looking for the + * default visual/depth from that depth. + */ + first_depth = 0; + if (preferredVis < 0 && defaultColorVisualClass < 0 ) { + for (i = 0; i < ndepth; i++) { + if (preferredCVCs[i] >= 0) { + first_depth = i; + break; + } + } + } + + for (i = first_depth; i < ndepth; i++) { int prefColorVisualClass = -1; @@ -123,6 +123,8 @@ mieqEnqueue (e) miEventQueue.events[oldtail].event.u.keyButtonPointer.time = miEventQueue.lastEventTime; } + miEventQueue.lastEventTime = + miEventQueue.events[oldtail].event.u.keyButtonPointer.time; miEventQueue.events[oldtail].pScreen = miEventQueue.pEnqueueScreen; } diff --git a/mi/miexpose.c b/mi/miexpose.c index f2f43f4e3..b13a4ea91 100644 --- a/mi/miexpose.c +++ b/mi/miexpose.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/mi/miexpose.c,v 1.1.4.4.2.4 2004/03/08 00:36:57 alanc Exp $ */ +/* $XdotOrg: xc/programs/Xserver/mi/miexpose.c,v 1.2 2004/04/23 19:54:26 eich Exp $ */ /* $XFree86: xc/programs/Xserver/mi/miexpose.c,v 3.9tsi Exp $ */ /*********************************************************** diff --git a/mi/miinitext.c b/mi/miinitext.c index 4ec997aec..fae1feb0d 100644 --- a/mi/miinitext.c +++ b/mi/miinitext.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/mi/miinitext.c,v 1.1.4.3.2.3 2004/03/04 20:17:04 kaleb Exp $ */ +/* $XdotOrg: xc/programs/Xserver/mi/miinitext.c,v 1.12 2004/08/12 08:45:33 anholt Exp $ */ /* $XFree86: xc/programs/Xserver/mi/miinitext.c,v 3.67 2003/01/12 02:44:27 dawes Exp $ */ /*********************************************************** @@ -62,6 +62,32 @@ SOFTWARE. #undef GLXEXT #endif +/* Make sure Xprt only announces extensions it supports */ +#ifdef PRINT_ONLY_SERVER +#undef MITSHM /* this is incompatible to the vector-based Xprint DDX */ +#undef XKB +#undef PANORAMIX +#undef RES +#undef XIE +#undef XINPUT +#undef XV +#undef SCREENSAVER +#undef XIDLE +#undef XRECORD +#undef DBE +#undef XF86VIDMODE +#undef XF86MISC +#undef XFreeXDGA +#undef XF86DRI +#undef DPMSExtension +#undef DPSEXT +#undef FONTCACHE +#undef RENDER /* not yet */ +#undef DAMAGE +#undef XFIXES +#undef XEVIE +#endif /* PRINT_ONLY_SERVER */ + #ifdef PANORAMIX extern Bool noPanoramiXExtension; #endif @@ -69,6 +95,15 @@ extern Bool noTestExtensions; #ifdef XKB extern Bool noXkbExtension; #endif +#ifdef RENDER +extern Bool noRenderExtension; +#endif +#ifdef XEVIE +extern Bool noXevieExtension; +#endif +#ifdef COMPOSITE +extern Bool noCompositeExtension; +#endif #ifndef XFree86LOADER #define INITARGS void @@ -238,6 +273,75 @@ extern void RRExtensionInit(INITARGS); #ifdef RES extern void ResExtensionInit(INITARGS); #endif +#ifdef DMXEXT +extern void DMXExtensionInit(INITARGS); +#endif +#ifdef XEVIE +extern void XevieExtensionInit(INITARGS); +#endif +#ifdef XFIXES +extern void XFixesExtensionInit(INITARGS); +#endif +#ifdef DAMAGE +extern void DamageExtensionInit(INITARGS); +#endif +#ifdef COMPOSITE +extern void CompositeExtensionInit(INITARGS); +#endif + +/* The following is only a small first step towards run-time + * configurable extensions. + */ +typedef struct { + char *name; + Bool *disablePtr; +} ExtensionToggle; + +static ExtensionToggle ExtensionToggleList[] = +{ + { "XTEST", &noTestExtensions }, +#ifdef PANORAMIX + { "XINERAMA", &noPanoramiXExtension }, +#endif +#ifdef RENDER + { "RENDER", &noRenderExtension }, +#endif +#ifdef XKB + { "XKEYBOARD", &noXkbExtension }, +#endif +#ifdef XEVIE + { "XEVIE", &noXevieExtension }, +#endif +#ifdef COMPOSITE + { "Composite", &noCompositeExtension }, +#endif + { NULL, NULL } +}; + +Bool EnableDisableExtension(char *name, Bool enable) +{ + ExtensionToggle *ext = &ExtensionToggleList[0]; + + for (ext = &ExtensionToggleList[0]; ext->name != NULL; ext++) { + if (strcmp(name, ext->name) == 0) { + *ext->disablePtr = !enable; + return TRUE; + } + } + + return FALSE; +} + +void EnableDisableExtensionError(char *name, Bool enable) +{ + ExtensionToggle *ext = &ExtensionToggleList[0]; + + ErrorF("Extension \"%s\" is not recognized\n", name); + ErrorF("Only the following extensions can be run-time %s:\n", + enable ? "enabled" : "disabled"); + for (ext = &ExtensionToggleList[0]; ext->name != NULL; ext++) + ErrorF(" %s\n", ext->name); +} #ifndef XFree86LOADER @@ -355,21 +459,23 @@ InitExtensions(argc, argv) #endif #endif #ifdef GLXEXT -#ifndef XPRINT /* we don't want Glx in the Xprint server */ #ifndef __DARWIN__ GlxExtensionInit(); #else DarwinGlxExtensionInit(); #endif #endif -#endif #ifdef DPSEXT #ifndef XPRINT DPSExtensionInit(); #endif #endif +#ifdef XFIXES + /* must be before Render to layer DisplayCursor correctly */ + XFixesExtensionInit(); +#endif #ifdef RENDER - RenderExtensionInit(); + if (!noRenderExtension) RenderExtensionInit(); #endif #ifdef RANDR RRExtensionInit(); @@ -377,6 +483,18 @@ InitExtensions(argc, argv) #ifdef RES ResExtensionInit(); #endif +#ifdef DMXEXT + DMXExtensionInit(); +#endif +#ifdef XEVIE + if (!noXevieExtension) XevieExtensionInit(); +#endif +#ifdef COMPOSITE + if (!noCompositeExtension) CompositeExtensionInit(); +#endif +#ifdef DAMAGE + DamageExtensionInit(); +#endif } void @@ -384,14 +502,12 @@ InitVisualWrap() { miResetInitVisuals(); #ifdef GLXEXT -#ifndef XPRINT #ifndef __DARWIN__ GlxWrapInitVisuals(&miInitVisualsProc); #else DarwinGlxWrapInitVisuals(&miInitVisualsProc); #endif #endif -#endif } #else /* XFree86LOADER */ @@ -449,6 +565,7 @@ ExtensionModule extension[] = { NULL, "RENDER", NULL, NULL }, { NULL, "RANDR", NULL, NULL }, { NULL, "X-Resource", NULL, NULL }, + { NULL, "DMX", NULL, NULL }, { NULL, NULL, NULL, NULL } }; #endif @@ -491,15 +608,28 @@ static ExtensionModule staticExtensions[] = { #ifdef PANORAMIX { PanoramiXExtensionInit, PANORAMIX_PROTOCOL_NAME, &noPanoramiXExtension, NULL, NULL }, #endif +#ifdef XFIXES + /* must be before Render to layer DisplayCursor correctly */ + { XFixesExtensionInit, "XFIXES", NULL, NULL, NULL }, +#endif #ifdef XF86BIGFONT { XFree86BigfontExtensionInit, XF86BIGFONTNAME, NULL, NULL, NULL }, #endif #ifdef RENDER - { RenderExtensionInit, "RENDER", NULL, NULL, NULL }, + { RenderExtensionInit, "RENDER", &noRenderExtension, NULL, NULL }, #endif #ifdef RANDR { RRExtensionInit, "RANDR", NULL, NULL, NULL }, #endif +#ifdef COMPOSITE + { CompositeExtensionInit, "COMPOSITE", &noCompositeExtension, NULL }, +#endif +#ifdef DAMAGE + { DamageExtensionInit, "DAMAGE", NULL, NULL }, +#endif +#ifdef XEVIE + { XevieExtensionInit, "XEVIE", &noXevieExtension, NULL }, +#endif { NULL, NULL, NULL, NULL, NULL } }; diff --git a/mi/misprite.c b/mi/misprite.c index 260a4dac0..df19784e0 100644 --- a/mi/misprite.c +++ b/mi/misprite.c @@ -51,6 +51,14 @@ in this Software without prior written authorization from The Open Group. #ifdef RENDER # include "mipict.h" #endif +# include "damage.h" + +#define SPRITE_DEBUG_ENABLE 0 +#if SPRITE_DEBUG_ENABLE +#define SPRITE_DEBUG(x) ErrorF x +#else +#define SPRITE_DEBUG(x) +#endif /* * screen wrappers @@ -68,7 +76,9 @@ static void miSpriteGetSpans(DrawablePtr pDrawable, int wMax, char *pdstStart); static void miSpriteSourceValidate(DrawablePtr pDrawable, int x, int y, int width, int height); -static Bool miSpriteCreateGC(GCPtr pGC); +static void miSpriteCopyWindow (WindowPtr pWindow, + DDXPointRec ptOldOrg, + RegionPtr prgnSrc); static void miSpriteBlockHandler(int i, pointer blockData, pointer pTimeout, pointer pReadMask); @@ -76,45 +86,9 @@ static void miSpriteInstallColormap(ColormapPtr pMap); static void miSpriteStoreColors(ColormapPtr pMap, int ndef, xColorItem *pdef); -static void miSpritePaintWindowBackground(WindowPtr pWin, - RegionPtr pRegion, int what); -static void miSpritePaintWindowBorder(WindowPtr pWin, - RegionPtr pRegion, int what); -static void miSpriteCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, - RegionPtr pRegion); -static void miSpriteClearToBackground(WindowPtr pWin, int x, int y, - int w, int h, - Bool generateExposures); - -#ifdef RENDER -static void miSpriteComposite(CARD8 op, - PicturePtr pSrc, - PicturePtr pMask, - PicturePtr pDst, - INT16 xSrc, - INT16 ySrc, - INT16 xMask, - INT16 yMask, - INT16 xDst, - INT16 yDst, - CARD16 width, - CARD16 height); - -static void miSpriteGlyphs(CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int nlist, - GlyphListPtr list, - GlyphPtr *glyphs); -#endif - static void miSpriteSaveDoomedAreas(WindowPtr pWin, RegionPtr pObscured, int dx, int dy); -static RegionPtr miSpriteRestoreAreas(WindowPtr pWin, RegionPtr pRgnExposed); static void miSpriteComputeSaved(ScreenPtr pScreen); #define SCREEN_PROLOGUE(pScreen, field)\ @@ -125,169 +99,6 @@ static void miSpriteComputeSaved(ScreenPtr pScreen); ((pScreen)->field = wrapper) /* - * GC func wrappers - */ - -static int miSpriteGCIndex; - -static void miSpriteValidateGC(GCPtr pGC, unsigned long stateChanges, - DrawablePtr pDrawable); -static void miSpriteCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst); -static void miSpriteDestroyGC(GCPtr pGC); -static void miSpriteChangeGC(GCPtr pGC, unsigned long mask); -static void miSpriteChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects); -static void miSpriteDestroyClip(GCPtr pGC); -static void miSpriteCopyClip(GCPtr pgcDst, GCPtr pgcSrc); - -static GCFuncs miSpriteGCFuncs = { - miSpriteValidateGC, - miSpriteChangeGC, - miSpriteCopyGC, - miSpriteDestroyGC, - miSpriteChangeClip, - miSpriteDestroyClip, - miSpriteCopyClip, -}; - -#define GC_FUNC_PROLOGUE(pGC) \ - miSpriteGCPtr pGCPriv = \ - (miSpriteGCPtr) (pGC)->devPrivates[miSpriteGCIndex].ptr;\ - (pGC)->funcs = pGCPriv->wrapFuncs; \ - if (pGCPriv->wrapOps) \ - (pGC)->ops = pGCPriv->wrapOps; - -#define GC_FUNC_EPILOGUE(pGC) \ - pGCPriv->wrapFuncs = (pGC)->funcs; \ - (pGC)->funcs = &miSpriteGCFuncs; \ - if (pGCPriv->wrapOps) \ - { \ - pGCPriv->wrapOps = (pGC)->ops; \ - (pGC)->ops = &miSpriteGCOps; \ - } - -/* - * GC op wrappers - */ - -static void miSpriteFillSpans(DrawablePtr pDrawable, GCPtr pGC, - int nInit, DDXPointPtr pptInit, - int *pwidthInit, int fSorted); -static void miSpriteSetSpans(DrawablePtr pDrawable, GCPtr pGC, - char *psrc, DDXPointPtr ppt, int *pwidth, - int nspans, int fSorted); -static void miSpritePutImage(DrawablePtr pDrawable, GCPtr pGC, - int depth, int x, int y, int w, int h, - int leftPad, int format, char *pBits); -static RegionPtr miSpriteCopyArea(DrawablePtr pSrc, DrawablePtr pDst, - GCPtr pGC, int srcx, int srcy, int w, - int h, int dstx, int dsty); -static RegionPtr miSpriteCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, - GCPtr pGC, int srcx, int srcy, int w, - int h, int dstx, int dsty, - unsigned long plane); -static void miSpritePolyPoint(DrawablePtr pDrawable, GCPtr pGC, - int mode, int npt, xPoint *pptInit); -static void miSpritePolylines(DrawablePtr pDrawable, GCPtr pGC, - int mode, int npt, DDXPointPtr pptInit); -static void miSpritePolySegment(DrawablePtr pDrawable, GCPtr pGC, - int nseg, xSegment *pSegs); -static void miSpritePolyRectangle(DrawablePtr pDrawable, GCPtr pGC, - int nrects, xRectangle *pRects); -static void miSpritePolyArc(DrawablePtr pDrawable, GCPtr pGC, - int narcs, xArc *parcs); -static void miSpriteFillPolygon(DrawablePtr pDrawable, GCPtr pGC, - int shape, int mode, int count, - DDXPointPtr pPts); -static void miSpritePolyFillRect(DrawablePtr pDrawable, GCPtr pGC, - int nrectFill, xRectangle *prectInit); -static void miSpritePolyFillArc(DrawablePtr pDrawable, GCPtr pGC, - int narcs, xArc *parcs); -static int miSpritePolyText8(DrawablePtr pDrawable, GCPtr pGC, - int x, int y, int count, char *chars); -static int miSpritePolyText16(DrawablePtr pDrawable, GCPtr pGC, - int x, int y, int count, - unsigned short *chars); -static void miSpriteImageText8(DrawablePtr pDrawable, GCPtr pGC, - int x, int y, int count, char *chars); -static void miSpriteImageText16(DrawablePtr pDrawable, GCPtr pGC, - int x, int y, int count, - unsigned short *chars); -static void miSpriteImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, - int x, int y, unsigned int nglyph, - CharInfoPtr *ppci, - pointer pglyphBase); -static void miSpritePolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, - int x, int y, unsigned int nglyph, - CharInfoPtr *ppci, - pointer pglyphBase); -static void miSpritePushPixels(GCPtr pGC, PixmapPtr pBitMap, - DrawablePtr pDst, int w, int h, - int x, int y); -#ifdef NEED_LINEHELPER -static void miSpriteLineHelper(void); -#endif - -static GCOps miSpriteGCOps = { - miSpriteFillSpans, miSpriteSetSpans, miSpritePutImage, - miSpriteCopyArea, miSpriteCopyPlane, miSpritePolyPoint, - miSpritePolylines, miSpritePolySegment, miSpritePolyRectangle, - miSpritePolyArc, miSpriteFillPolygon, miSpritePolyFillRect, - miSpritePolyFillArc, miSpritePolyText8, miSpritePolyText16, - miSpriteImageText8, miSpriteImageText16, miSpriteImageGlyphBlt, - miSpritePolyGlyphBlt, miSpritePushPixels -#ifdef NEED_LINEHELPER - , miSpriteLineHelper -#endif -}; - -/* - * testing only -- remove cursor for every draw. Eventually, - * each draw operation will perform a bounding box check against - * the saved cursor area - */ - -#define GC_SETUP_CHEAP(pDrawable) \ - miSpriteScreenPtr pScreenPriv = (miSpriteScreenPtr) \ - (pDrawable)->pScreen->devPrivates[miSpriteScreenIndex].ptr; \ - -#define GC_SETUP(pDrawable, pGC) \ - GC_SETUP_CHEAP(pDrawable) \ - miSpriteGCPtr pGCPrivate = (miSpriteGCPtr) \ - (pGC)->devPrivates[miSpriteGCIndex].ptr; \ - GCFuncs *oldFuncs = pGC->funcs; - -#define GC_SETUP_AND_CHECK(pDrawable, pGC) \ - GC_SETUP(pDrawable, pGC); \ - if (GC_CHECK((WindowPtr)pDrawable)) \ - miSpriteRemoveCursor (pDrawable->pScreen); - -#define GC_CHECK(pWin) \ - (pScreenPriv->isUp && \ - (pScreenPriv->pCacheWin == pWin ? \ - pScreenPriv->isInCacheWin : ( \ - (pScreenPriv->pCacheWin = (pWin)), \ - (pScreenPriv->isInCacheWin = \ - (pWin)->drawable.x < pScreenPriv->saved.x2 && \ - pScreenPriv->saved.x1 < (pWin)->drawable.x + \ - (int) (pWin)->drawable.width && \ - (pWin)->drawable.y < pScreenPriv->saved.y2 && \ - pScreenPriv->saved.y1 < (pWin)->drawable.y + \ - (int) (pWin)->drawable.height &&\ - RECT_IN_REGION((pWin)->drawable.pScreen, &(pWin)->borderClip, \ - &pScreenPriv->saved) != rgnOUT)))) - -#define GC_OP_PROLOGUE(pGC) { \ - (pGC)->funcs = pGCPrivate->wrapFuncs; \ - (pGC)->ops = pGCPrivate->wrapOps; \ - } - -#define GC_OP_EPILOGUE(pGC) { \ - pGCPrivate->wrapOps = (pGC)->ops; \ - (pGC)->funcs = oldFuncs; \ - (pGC)->ops = &miSpriteGCOps; \ - } - -/* * pointer-sprite method table */ @@ -311,6 +122,22 @@ miPointerSpriteFuncRec miSpritePointerFuncs = { static void miSpriteRemoveCursor(ScreenPtr pScreen); static void miSpriteRestoreCursor(ScreenPtr pScreen); +static void +miSpriteReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure) +{ + ScreenPtr pScreen = closure; + miSpriteScreenPtr pScreenPriv; + + pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; + + if (pScreenPriv->isUp && + RECT_IN_REGION (pScreen, pRegion, &pScreenPriv->saved) != rgnOUT) + { + SPRITE_DEBUG(("Damage remove\n")); + miSpriteRemoveCursor (pScreen); + } +} + /* * miSpriteInitialize -- called from device-dependent screen * initialization proc after all of the function pointers have @@ -323,101 +150,88 @@ miSpriteInitialize (pScreen, cursorFuncs, screenFuncs) miSpriteCursorFuncPtr cursorFuncs; miPointerScreenFuncPtr screenFuncs; { - miSpriteScreenPtr pPriv; + miSpriteScreenPtr pScreenPriv; VisualPtr pVisual; -#ifdef RENDER - PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); -#endif + if (!DamageSetup (pScreen)) + return FALSE; + if (miSpriteGeneration != serverGeneration) { miSpriteScreenIndex = AllocateScreenPrivateIndex (); if (miSpriteScreenIndex < 0) return FALSE; miSpriteGeneration = serverGeneration; - miSpriteGCIndex = AllocateGCPrivateIndex (); } - if (!AllocateGCPrivate(pScreen, miSpriteGCIndex, sizeof(miSpriteGCRec))) - return FALSE; - pPriv = (miSpriteScreenPtr) xalloc (sizeof (miSpriteScreenRec)); - if (!pPriv) + + pScreenPriv = (miSpriteScreenPtr) xalloc (sizeof (miSpriteScreenRec)); + if (!pScreenPriv) return FALSE; + + pScreenPriv->pDamage = DamageCreate (miSpriteReportDamage, + (DamageDestroyFunc) 0, + DamageReportRawRegion, + TRUE, + pScreen, + (void *) pScreen); + if (!miPointerInitialize (pScreen, &miSpritePointerFuncs, screenFuncs,TRUE)) { - xfree ((pointer) pPriv); + xfree ((pointer) pScreenPriv); return FALSE; } for (pVisual = pScreen->visuals; pVisual->vid != pScreen->rootVisual; pVisual++) ; - pPriv->pVisual = pVisual; - pPriv->CloseScreen = pScreen->CloseScreen; - pPriv->GetImage = pScreen->GetImage; - pPriv->GetSpans = pScreen->GetSpans; - pPriv->SourceValidate = pScreen->SourceValidate; - pPriv->CreateGC = pScreen->CreateGC; - pPriv->BlockHandler = pScreen->BlockHandler; - pPriv->InstallColormap = pScreen->InstallColormap; - pPriv->StoreColors = pScreen->StoreColors; - - pPriv->PaintWindowBackground = pScreen->PaintWindowBackground; - pPriv->PaintWindowBorder = pScreen->PaintWindowBorder; - pPriv->CopyWindow = pScreen->CopyWindow; - pPriv->ClearToBackground = pScreen->ClearToBackground; - - pPriv->SaveDoomedAreas = pScreen->SaveDoomedAreas; - pPriv->RestoreAreas = pScreen->RestoreAreas; -#ifdef RENDER - if (ps) - { - pPriv->Composite = ps->Composite; - pPriv->Glyphs = ps->Glyphs; - } -#endif + pScreenPriv->pVisual = pVisual; + pScreenPriv->CloseScreen = pScreen->CloseScreen; + pScreenPriv->GetImage = pScreen->GetImage; + pScreenPriv->GetSpans = pScreen->GetSpans; + pScreenPriv->SourceValidate = pScreen->SourceValidate; + + pScreenPriv->CopyWindow = pScreen->CopyWindow; + + pScreenPriv->SaveDoomedAreas = pScreen->SaveDoomedAreas; + + pScreenPriv->InstallColormap = pScreen->InstallColormap; + pScreenPriv->StoreColors = pScreen->StoreColors; + + pScreenPriv->BlockHandler = pScreen->BlockHandler; + + pScreenPriv->pCursor = NULL; + pScreenPriv->x = 0; + pScreenPriv->y = 0; + pScreenPriv->isUp = FALSE; + pScreenPriv->shouldBeUp = FALSE; + pScreenPriv->pCacheWin = NullWindow; + pScreenPriv->isInCacheWin = FALSE; + pScreenPriv->checkPixels = TRUE; + pScreenPriv->pInstalledMap = NULL; + pScreenPriv->pColormap = NULL; + pScreenPriv->funcs = cursorFuncs; + pScreenPriv->colors[SOURCE_COLOR].red = 0; + pScreenPriv->colors[SOURCE_COLOR].green = 0; + pScreenPriv->colors[SOURCE_COLOR].blue = 0; + pScreenPriv->colors[MASK_COLOR].red = 0; + pScreenPriv->colors[MASK_COLOR].green = 0; + pScreenPriv->colors[MASK_COLOR].blue = 0; + pScreen->devPrivates[miSpriteScreenIndex].ptr = (pointer) pScreenPriv; - pPriv->pCursor = NULL; - pPriv->x = 0; - pPriv->y = 0; - pPriv->isUp = FALSE; - pPriv->shouldBeUp = FALSE; - pPriv->pCacheWin = NullWindow; - pPriv->isInCacheWin = FALSE; - pPriv->checkPixels = TRUE; - pPriv->pInstalledMap = NULL; - pPriv->pColormap = NULL; - pPriv->funcs = cursorFuncs; - pPriv->colors[SOURCE_COLOR].red = 0; - pPriv->colors[SOURCE_COLOR].green = 0; - pPriv->colors[SOURCE_COLOR].blue = 0; - pPriv->colors[MASK_COLOR].red = 0; - pPriv->colors[MASK_COLOR].green = 0; - pPriv->colors[MASK_COLOR].blue = 0; - pScreen->devPrivates[miSpriteScreenIndex].ptr = (pointer) pPriv; pScreen->CloseScreen = miSpriteCloseScreen; pScreen->GetImage = miSpriteGetImage; pScreen->GetSpans = miSpriteGetSpans; pScreen->SourceValidate = miSpriteSourceValidate; - pScreen->CreateGC = miSpriteCreateGC; - pScreen->BlockHandler = miSpriteBlockHandler; - pScreen->InstallColormap = miSpriteInstallColormap; - pScreen->StoreColors = miSpriteStoreColors; - - pScreen->PaintWindowBackground = miSpritePaintWindowBackground; - pScreen->PaintWindowBorder = miSpritePaintWindowBorder; + pScreen->CopyWindow = miSpriteCopyWindow; - pScreen->ClearToBackground = miSpriteClearToBackground; - + pScreen->SaveDoomedAreas = miSpriteSaveDoomedAreas; - pScreen->RestoreAreas = miSpriteRestoreAreas; -#ifdef RENDER - if (ps) - { - ps->Composite = miSpriteComposite; - ps->Glyphs = miSpriteGlyphs; - } -#endif + + pScreen->InstallColormap = miSpriteInstallColormap; + pScreen->StoreColors = miSpriteStoreColors; + pScreen->BlockHandler = miSpriteBlockHandler; + return TRUE; } @@ -436,9 +250,6 @@ miSpriteCloseScreen (i, pScreen) ScreenPtr pScreen; { miSpriteScreenPtr pScreenPriv; -#ifdef RENDER - PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); -#endif pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; @@ -446,25 +257,14 @@ miSpriteCloseScreen (i, pScreen) pScreen->GetImage = pScreenPriv->GetImage; pScreen->GetSpans = pScreenPriv->GetSpans; pScreen->SourceValidate = pScreenPriv->SourceValidate; - pScreen->CreateGC = pScreenPriv->CreateGC; pScreen->BlockHandler = pScreenPriv->BlockHandler; pScreen->InstallColormap = pScreenPriv->InstallColormap; pScreen->StoreColors = pScreenPriv->StoreColors; - pScreen->PaintWindowBackground = pScreenPriv->PaintWindowBackground; - pScreen->PaintWindowBorder = pScreenPriv->PaintWindowBorder; - pScreen->CopyWindow = pScreenPriv->CopyWindow; - pScreen->ClearToBackground = pScreenPriv->ClearToBackground; - pScreen->SaveDoomedAreas = pScreenPriv->SaveDoomedAreas; - pScreen->RestoreAreas = pScreenPriv->RestoreAreas; -#ifdef RENDER - if (ps) - { - ps->Composite = pScreenPriv->Composite; - ps->Glyphs = pScreenPriv->Glyphs; - } -#endif + miSpriteIsUpFALSE (pScreen, pScreenPriv); + DamageDestroy (pScreenPriv->pDamage); + xfree ((pointer) pScreenPriv); return (*pScreen->CloseScreen) (i, pScreen); @@ -489,6 +289,7 @@ miSpriteGetImage (pDrawable, sx, sy, w, h, format, planemask, pdstLine) pScreenPriv->isUp && ORG_OVERLAP(&pScreenPriv->saved,pDrawable->x,pDrawable->y, sx, sy, w, h)) { + SPRITE_DEBUG (("GetImage remove\n")); miSpriteRemoveCursor (pScreen); } @@ -532,6 +333,7 @@ miSpriteGetSpans (pDrawable, wMax, ppt, pwidth, nspans, pdstStart) if (SPN_OVERLAP(&pScreenPriv->saved,pts->y+yorg, pts->x+xorg,*widths)) { + SPRITE_DEBUG (("GetSpans remove\n")); miSpriteRemoveCursor (pScreen); break; } @@ -559,6 +361,7 @@ miSpriteSourceValidate (pDrawable, x, y, width, height) ORG_OVERLAP(&pScreenPriv->saved, pDrawable->x, pDrawable->y, x, y, width, height)) { + SPRITE_DEBUG (("SourceValidate remove\n")); miSpriteRemoveCursor (pScreen); } @@ -568,27 +371,27 @@ miSpriteSourceValidate (pDrawable, x, y, width, height) SCREEN_EPILOGUE (pScreen, SourceValidate, miSpriteSourceValidate); } -static Bool -miSpriteCreateGC (pGC) - GCPtr pGC; +static void +miSpriteCopyWindow (WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc) { - ScreenPtr pScreen = pGC->pScreen; - Bool ret; - miSpriteGCPtr pPriv; - - SCREEN_PROLOGUE (pScreen, CreateGC); + ScreenPtr pScreen = pWindow->drawable.pScreen; + miSpriteScreenPtr pScreenPriv; - pPriv = (miSpriteGCPtr)pGC->devPrivates[miSpriteGCIndex].ptr; - - ret = (*pScreen->CreateGC) (pGC); - - pPriv->wrapOps = NULL; - pPriv->wrapFuncs = pGC->funcs; - pGC->funcs = &miSpriteGCFuncs; + SCREEN_PROLOGUE (pScreen, CopyWindow); - SCREEN_EPILOGUE (pScreen, CreateGC, miSpriteCreateGC); + pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; + /* + * Damage will take care of destination check + */ + if (pScreenPriv->isUp && + RECT_IN_REGION (pScreen, prgnSrc, &pScreenPriv->saved) != rgnOUT) + { + SPRITE_DEBUG (("CopyWindow remove\n")); + miSpriteRemoveCursor (pScreen); + } - return ret; + (*pScreen->CopyWindow) (pWindow, ptOldOrg, prgnSrc); + SCREEN_EPILOGUE (pScreen, CopyWindow, miSpriteCopyWindow); } static void @@ -610,7 +413,10 @@ miSpriteBlockHandler (i, blockData, pTimeout, pReadmask) SCREEN_EPILOGUE(pScreen, BlockHandler, miSpriteBlockHandler); if (!pPriv->isUp && pPriv->shouldBeUp) + { + SPRITE_DEBUG (("BlockHandler restore\n")); miSpriteRestoreCursor (pScreen); + } } static void @@ -787,1322 +593,6 @@ miSpriteSaveDoomedAreas (pWin, pObscured, dx, dy) SCREEN_EPILOGUE (pScreen, SaveDoomedAreas, miSpriteSaveDoomedAreas); } -static RegionPtr -miSpriteRestoreAreas (pWin, prgnExposed) - WindowPtr pWin; - RegionPtr prgnExposed; -{ - ScreenPtr pScreen; - miSpriteScreenPtr pScreenPriv; - RegionPtr result; - - pScreen = pWin->drawable.pScreen; - - SCREEN_PROLOGUE (pScreen, RestoreAreas); - - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; - if (pScreenPriv->isUp) - { - if (RECT_IN_REGION( pScreen, prgnExposed, &pScreenPriv->saved) != rgnOUT) - miSpriteRemoveCursor (pScreen); - } - - result = (*pScreen->RestoreAreas) (pWin, prgnExposed); - - SCREEN_EPILOGUE (pScreen, RestoreAreas, miSpriteRestoreAreas); - - return result; -} - -/* - * Window wrappers - */ - -static void -miSpritePaintWindowBackground (pWin, pRegion, what) - WindowPtr pWin; - RegionPtr pRegion; - int what; -{ - ScreenPtr pScreen; - miSpriteScreenPtr pScreenPriv; - - pScreen = pWin->drawable.pScreen; - - SCREEN_PROLOGUE (pScreen, PaintWindowBackground); - - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; - if (pScreenPriv->isUp) - { - /* - * If the cursor is on the same screen as the window, check the - * region to paint for the cursor and remove it as necessary - */ - if (RECT_IN_REGION( pScreen, pRegion, &pScreenPriv->saved) != rgnOUT) - miSpriteRemoveCursor (pScreen); - } - - (*pScreen->PaintWindowBackground) (pWin, pRegion, what); - - SCREEN_EPILOGUE (pScreen, PaintWindowBackground, miSpritePaintWindowBackground); -} - -static void -miSpritePaintWindowBorder (pWin, pRegion, what) - WindowPtr pWin; - RegionPtr pRegion; - int what; -{ - ScreenPtr pScreen; - miSpriteScreenPtr pScreenPriv; - - pScreen = pWin->drawable.pScreen; - - SCREEN_PROLOGUE (pScreen, PaintWindowBorder); - - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; - if (pScreenPriv->isUp) - { - /* - * If the cursor is on the same screen as the window, check the - * region to paint for the cursor and remove it as necessary - */ - if (RECT_IN_REGION( pScreen, pRegion, &pScreenPriv->saved) != rgnOUT) - miSpriteRemoveCursor (pScreen); - } - - (*pScreen->PaintWindowBorder) (pWin, pRegion, what); - - SCREEN_EPILOGUE (pScreen, PaintWindowBorder, miSpritePaintWindowBorder); -} - -static void -miSpriteCopyWindow (pWin, ptOldOrg, pRegion) - WindowPtr pWin; - DDXPointRec ptOldOrg; - RegionPtr pRegion; -{ - ScreenPtr pScreen; - miSpriteScreenPtr pScreenPriv; - BoxRec cursorBox; - int dx, dy; - - pScreen = pWin->drawable.pScreen; - - SCREEN_PROLOGUE (pScreen, CopyWindow); - - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; - if (pScreenPriv->isUp) - { - /* - * check both the source and the destination areas. The given - * region is source relative, so offset the cursor box by - * the delta position - */ - cursorBox = pScreenPriv->saved; - dx = pWin->drawable.x - ptOldOrg.x; - dy = pWin->drawable.y - ptOldOrg.y; - cursorBox.x1 -= dx; - cursorBox.x2 -= dx; - cursorBox.y1 -= dy; - cursorBox.y2 -= dy; - if (RECT_IN_REGION( pScreen, pRegion, &pScreenPriv->saved) != rgnOUT || - RECT_IN_REGION( pScreen, pRegion, &cursorBox) != rgnOUT) - miSpriteRemoveCursor (pScreen); - } - - (*pScreen->CopyWindow) (pWin, ptOldOrg, pRegion); - - SCREEN_EPILOGUE (pScreen, CopyWindow, miSpriteCopyWindow); -} - -static void -miSpriteClearToBackground (pWin, x, y, w, h, generateExposures) - WindowPtr pWin; - int x,y; - int w,h; - Bool generateExposures; -{ - ScreenPtr pScreen; - miSpriteScreenPtr pScreenPriv; - int realw, realh; - - pScreen = pWin->drawable.pScreen; - - SCREEN_PROLOGUE (pScreen, ClearToBackground); - - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; - if (GC_CHECK(pWin)) - { - if (!(realw = w)) - realw = (int) pWin->drawable.width - x; - if (!(realh = h)) - realh = (int) pWin->drawable.height - y; - if (ORG_OVERLAP(&pScreenPriv->saved, pWin->drawable.x, pWin->drawable.y, - x, y, realw, realh)) - { - miSpriteRemoveCursor (pScreen); - } - } - - (*pScreen->ClearToBackground) (pWin, x, y, w, h, generateExposures); - - SCREEN_EPILOGUE (pScreen, ClearToBackground, miSpriteClearToBackground); -} - -/* - * GC Func wrappers - */ - -static void -miSpriteValidateGC (pGC, changes, pDrawable) - GCPtr pGC; - unsigned long changes; - DrawablePtr pDrawable; -{ - GC_FUNC_PROLOGUE (pGC); - - (*pGC->funcs->ValidateGC) (pGC, changes, pDrawable); - - pGCPriv->wrapOps = NULL; - if (pDrawable->type == DRAWABLE_WINDOW && ((WindowPtr) pDrawable)->viewable) - { - WindowPtr pWin; - RegionPtr pRegion; - - pWin = (WindowPtr) pDrawable; - pRegion = &pWin->clipList; - if (pGC->subWindowMode == IncludeInferiors) - pRegion = &pWin->borderClip; - if (REGION_NOTEMPTY(pDrawable->pScreen, pRegion)) - pGCPriv->wrapOps = pGC->ops; - } - - GC_FUNC_EPILOGUE (pGC); -} - -static void -miSpriteChangeGC (pGC, mask) - GCPtr pGC; - unsigned long mask; -{ - GC_FUNC_PROLOGUE (pGC); - - (*pGC->funcs->ChangeGC) (pGC, mask); - - GC_FUNC_EPILOGUE (pGC); -} - -static void -miSpriteCopyGC (pGCSrc, mask, pGCDst) - GCPtr pGCSrc, pGCDst; - unsigned long mask; -{ - GC_FUNC_PROLOGUE (pGCDst); - - (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst); - - GC_FUNC_EPILOGUE (pGCDst); -} - -static void -miSpriteDestroyGC (pGC) - GCPtr pGC; -{ - GC_FUNC_PROLOGUE (pGC); - - (*pGC->funcs->DestroyGC) (pGC); - - GC_FUNC_EPILOGUE (pGC); -} - -static void -miSpriteChangeClip (pGC, type, pvalue, nrects) - GCPtr pGC; - int type; - pointer pvalue; - int nrects; -{ - GC_FUNC_PROLOGUE (pGC); - - (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects); - - GC_FUNC_EPILOGUE (pGC); -} - -static void -miSpriteCopyClip(pgcDst, pgcSrc) - GCPtr pgcDst, pgcSrc; -{ - GC_FUNC_PROLOGUE (pgcDst); - - (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc); - - GC_FUNC_EPILOGUE (pgcDst); -} - -static void -miSpriteDestroyClip(pGC) - GCPtr pGC; -{ - GC_FUNC_PROLOGUE (pGC); - - (* pGC->funcs->DestroyClip)(pGC); - - GC_FUNC_EPILOGUE (pGC); -} - -/* - * GC Op wrappers - */ - -static void -miSpriteFillSpans(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted) - DrawablePtr pDrawable; - GCPtr pGC; - int nInit; /* number of spans to fill */ - DDXPointPtr pptInit; /* pointer to list of start points */ - int *pwidthInit; /* pointer to list of n widths */ - int fSorted; -{ - GC_SETUP(pDrawable, pGC); - - if (GC_CHECK((WindowPtr) pDrawable)) - { - register DDXPointPtr pts; - register int *widths; - register int nPts; - - for (pts = pptInit, widths = pwidthInit, nPts = nInit; - nPts--; - pts++, widths++) - { - if (SPN_OVERLAP(&pScreenPriv->saved,pts->y,pts->x,*widths)) - { - miSpriteRemoveCursor (pDrawable->pScreen); - break; - } - } - } - - GC_OP_PROLOGUE (pGC); - - (*pGC->ops->FillSpans) (pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted); - - GC_OP_EPILOGUE (pGC); -} - -static void -miSpriteSetSpans(pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted) - DrawablePtr pDrawable; - GCPtr pGC; - char *psrc; - register DDXPointPtr ppt; - int *pwidth; - int nspans; - int fSorted; -{ - GC_SETUP(pDrawable, pGC); - - if (GC_CHECK((WindowPtr) pDrawable)) - { - register DDXPointPtr pts; - register int *widths; - register int nPts; - - for (pts = ppt, widths = pwidth, nPts = nspans; - nPts--; - pts++, widths++) - { - if (SPN_OVERLAP(&pScreenPriv->saved,pts->y,pts->x,*widths)) - { - miSpriteRemoveCursor(pDrawable->pScreen); - break; - } - } - } - - GC_OP_PROLOGUE (pGC); - - (*pGC->ops->SetSpans) (pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted); - - GC_OP_EPILOGUE (pGC); -} - -static void -miSpritePutImage(pDrawable, pGC, depth, x, y, w, h, leftPad, format, pBits) - DrawablePtr pDrawable; - GCPtr pGC; - int depth; - int x; - int y; - int w; - int h; - int leftPad; - int format; - char *pBits; -{ - GC_SETUP(pDrawable, pGC); - - if (GC_CHECK((WindowPtr) pDrawable)) - { - if (ORG_OVERLAP(&pScreenPriv->saved,pDrawable->x,pDrawable->y, - x,y,w,h)) - { - miSpriteRemoveCursor (pDrawable->pScreen); - } - } - - GC_OP_PROLOGUE (pGC); - - (*pGC->ops->PutImage) (pDrawable, pGC, depth, x, y, w, h, leftPad, format, pBits); - - GC_OP_EPILOGUE (pGC); -} - -static RegionPtr -miSpriteCopyArea (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty) - DrawablePtr pSrc; - DrawablePtr pDst; - GCPtr pGC; - int srcx; - int srcy; - int w; - int h; - int dstx; - int dsty; -{ - RegionPtr rgn; - - GC_SETUP(pDst, pGC); - - /* check destination/source overlap. */ - if (GC_CHECK((WindowPtr) pDst) && - (ORG_OVERLAP(&pScreenPriv->saved,pDst->x,pDst->y,dstx,dsty,w,h) || - ((pDst == pSrc) && - ORG_OVERLAP(&pScreenPriv->saved,pSrc->x,pSrc->y,srcx,srcy,w,h)))) - { - miSpriteRemoveCursor (pDst->pScreen); - } - - GC_OP_PROLOGUE (pGC); - - rgn = (*pGC->ops->CopyArea) (pSrc, pDst, pGC, srcx, srcy, w, h, - dstx, dsty); - - GC_OP_EPILOGUE (pGC); - - return rgn; -} - -static RegionPtr -miSpriteCopyPlane (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty, plane) - DrawablePtr pSrc; - DrawablePtr pDst; - register GCPtr pGC; - int srcx, - srcy; - int w, - h; - int dstx, - dsty; - unsigned long plane; -{ - RegionPtr rgn; - - GC_SETUP(pDst, pGC); - - /* - * check destination/source for overlap. - */ - if (GC_CHECK((WindowPtr) pDst) && - (ORG_OVERLAP(&pScreenPriv->saved,pDst->x,pDst->y,dstx,dsty,w,h) || - ((pDst == pSrc) && - ORG_OVERLAP(&pScreenPriv->saved,pSrc->x,pSrc->y,srcx,srcy,w,h)))) - { - miSpriteRemoveCursor (pDst->pScreen); - } - - GC_OP_PROLOGUE (pGC); - - rgn = (*pGC->ops->CopyPlane) (pSrc, pDst, pGC, srcx, srcy, w, h, - dstx, dsty, plane); - - GC_OP_EPILOGUE (pGC); - - return rgn; -} - -static void -miSpritePolyPoint (pDrawable, pGC, mode, npt, pptInit) - DrawablePtr pDrawable; - GCPtr pGC; - int mode; /* Origin or Previous */ - int npt; - xPoint *pptInit; -{ - xPoint t; - int n; - BoxRec cursor; - register xPoint *pts; - - GC_SETUP (pDrawable, pGC); - - if (npt && GC_CHECK((WindowPtr) pDrawable)) - { - cursor.x1 = pScreenPriv->saved.x1 - pDrawable->x; - cursor.y1 = pScreenPriv->saved.y1 - pDrawable->y; - cursor.x2 = pScreenPriv->saved.x2 - pDrawable->x; - cursor.y2 = pScreenPriv->saved.y2 - pDrawable->y; - - if (mode == CoordModePrevious) - { - t.x = 0; - t.y = 0; - for (pts = pptInit, n = npt; n--; pts++) - { - t.x += pts->x; - t.y += pts->y; - if (cursor.x1 <= t.x && t.x <= cursor.x2 && - cursor.y1 <= t.y && t.y <= cursor.y2) - { - miSpriteRemoveCursor (pDrawable->pScreen); - break; - } - } - } - else - { - for (pts = pptInit, n = npt; n--; pts++) - { - if (cursor.x1 <= pts->x && pts->x <= cursor.x2 && - cursor.y1 <= pts->y && pts->y <= cursor.y2) - { - miSpriteRemoveCursor (pDrawable->pScreen); - break; - } - } - } - } - - GC_OP_PROLOGUE (pGC); - - (*pGC->ops->PolyPoint) (pDrawable, pGC, mode, npt, pptInit); - - GC_OP_EPILOGUE (pGC); -} - -static void -miSpritePolylines (pDrawable, pGC, mode, npt, pptInit) - DrawablePtr pDrawable; - GCPtr pGC; - int mode; - int npt; - DDXPointPtr pptInit; -{ - BoxPtr cursor; - register DDXPointPtr pts; - int n; - int x, y, x1, y1, x2, y2; - int lw; - int extra; - - GC_SETUP (pDrawable, pGC); - - if (npt && GC_CHECK((WindowPtr) pDrawable)) - { - cursor = &pScreenPriv->saved; - lw = pGC->lineWidth; - x = pptInit->x + pDrawable->x; - y = pptInit->y + pDrawable->y; - - if (npt == 1) - { - extra = lw >> 1; - if (LINE_OVERLAP(cursor, x, y, x, y, extra)) - miSpriteRemoveCursor (pDrawable->pScreen); - } - else - { - extra = lw >> 1; - /* - * mitered joins can project quite a way from - * the line end; the 11 degree miter limit limits - * this extension to 10.43 * lw / 2, rounded up - * and converted to int yields 6 * lw - */ - if (pGC->joinStyle == JoinMiter) - extra = 6 * lw; - else if (pGC->capStyle == CapProjecting) - extra = lw; - for (pts = pptInit + 1, n = npt - 1; n--; pts++) - { - x1 = x; - y1 = y; - if (mode == CoordModeOrigin) - { - x2 = pDrawable->x + pts->x; - y2 = pDrawable->y + pts->y; - } - else - { - x2 = x + pts->x; - y2 = y + pts->y; - } - x = x2; - y = y2; - LINE_SORT(x1, y1, x2, y2); - if (LINE_OVERLAP(cursor, x1, y1, x2, y2, extra)) - { - miSpriteRemoveCursor (pDrawable->pScreen); - break; - } - } - } - } - GC_OP_PROLOGUE (pGC); - - (*pGC->ops->Polylines) (pDrawable, pGC, mode, npt, pptInit); - - GC_OP_EPILOGUE (pGC); -} - -static void -miSpritePolySegment(pDrawable, pGC, nseg, pSegs) - DrawablePtr pDrawable; - GCPtr pGC; - int nseg; - xSegment *pSegs; -{ - int n; - register xSegment *segs; - BoxPtr cursor; - int x1, y1, x2, y2; - int extra; - - GC_SETUP(pDrawable, pGC); - - if (nseg && GC_CHECK((WindowPtr) pDrawable)) - { - cursor = &pScreenPriv->saved; - extra = pGC->lineWidth >> 1; - if (pGC->capStyle == CapProjecting) - extra = pGC->lineWidth; - for (segs = pSegs, n = nseg; n--; segs++) - { - x1 = segs->x1 + pDrawable->x; - y1 = segs->y1 + pDrawable->y; - x2 = segs->x2 + pDrawable->x; - y2 = segs->y2 + pDrawable->y; - LINE_SORT(x1, y1, x2, y2); - if (LINE_OVERLAP(cursor, x1, y1, x2, y2, extra)) - { - miSpriteRemoveCursor (pDrawable->pScreen); - break; - } - } - } - - GC_OP_PROLOGUE (pGC); - - (*pGC->ops->PolySegment) (pDrawable, pGC, nseg, pSegs); - - GC_OP_EPILOGUE (pGC); -} - -static void -miSpritePolyRectangle(pDrawable, pGC, nrects, pRects) - DrawablePtr pDrawable; - GCPtr pGC; - int nrects; - xRectangle *pRects; -{ - register xRectangle *rects; - BoxPtr cursor; - int lw; - int n; - int x1, y1, x2, y2; - - GC_SETUP (pDrawable, pGC); - - if (GC_CHECK((WindowPtr) pDrawable)) - { - lw = pGC->lineWidth >> 1; - cursor = &pScreenPriv->saved; - for (rects = pRects, n = nrects; n--; rects++) - { - x1 = rects->x + pDrawable->x; - y1 = rects->y + pDrawable->y; - x2 = x1 + (int)rects->width; - y2 = y1 + (int)rects->height; - if (LINE_OVERLAP(cursor, x1, y1, x2, y1, lw) || - LINE_OVERLAP(cursor, x2, y1, x2, y2, lw) || - LINE_OVERLAP(cursor, x1, y2, x2, y2, lw) || - LINE_OVERLAP(cursor, x1, y1, x1, y2, lw)) - { - miSpriteRemoveCursor (pDrawable->pScreen); - break; - } - } - } - - GC_OP_PROLOGUE (pGC); - - (*pGC->ops->PolyRectangle) (pDrawable, pGC, nrects, pRects); - - GC_OP_EPILOGUE (pGC); -} - -static void -miSpritePolyArc(pDrawable, pGC, narcs, parcs) - DrawablePtr pDrawable; - register GCPtr pGC; - int narcs; - xArc *parcs; -{ - BoxPtr cursor; - int lw; - int n; - register xArc *arcs; - - GC_SETUP (pDrawable, pGC); - - if (GC_CHECK((WindowPtr) pDrawable)) - { - lw = pGC->lineWidth >> 1; - cursor = &pScreenPriv->saved; - for (arcs = parcs, n = narcs; n--; arcs++) - { - if (ORG_OVERLAP (cursor, pDrawable->x, pDrawable->y, - arcs->x - lw, arcs->y - lw, - (int) arcs->width + pGC->lineWidth, - (int) arcs->height + pGC->lineWidth)) - { - miSpriteRemoveCursor (pDrawable->pScreen); - break; - } - } - } - - GC_OP_PROLOGUE (pGC); - - (*pGC->ops->PolyArc) (pDrawable, pGC, narcs, parcs); - - GC_OP_EPILOGUE (pGC); -} - -static void -miSpriteFillPolygon(pDrawable, pGC, shape, mode, count, pPts) - register DrawablePtr pDrawable; - register GCPtr pGC; - int shape, mode; - int count; - DDXPointPtr pPts; -{ - int x, y, minx, miny, maxx, maxy; - register DDXPointPtr pts; - int n; - - GC_SETUP (pDrawable, pGC); - - if (count && GC_CHECK((WindowPtr) pDrawable)) - { - x = pDrawable->x; - y = pDrawable->y; - pts = pPts; - minx = maxx = pts->x; - miny = maxy = pts->y; - pts++; - n = count - 1; - - if (mode == CoordModeOrigin) - { - for (; n--; pts++) - { - if (pts->x < minx) - minx = pts->x; - else if (pts->x > maxx) - maxx = pts->x; - if (pts->y < miny) - miny = pts->y; - else if (pts->y > maxy) - maxy = pts->y; - } - minx += x; - miny += y; - maxx += x; - maxy += y; - } - else - { - x += minx; - y += miny; - minx = maxx = x; - miny = maxy = y; - for (; n--; pts++) - { - x += pts->x; - y += pts->y; - if (x < minx) - minx = x; - else if (x > maxx) - maxx = x; - if (y < miny) - miny = y; - else if (y > maxy) - maxy = y; - } - } - if (BOX_OVERLAP(&pScreenPriv->saved,minx,miny,maxx,maxy)) - miSpriteRemoveCursor (pDrawable->pScreen); - } - - GC_OP_PROLOGUE (pGC); - - (*pGC->ops->FillPolygon) (pDrawable, pGC, shape, mode, count, pPts); - - GC_OP_EPILOGUE (pGC); -} - -static void -miSpritePolyFillRect(pDrawable, pGC, nrectFill, prectInit) - DrawablePtr pDrawable; - GCPtr pGC; - int nrectFill; /* number of rectangles to fill */ - xRectangle *prectInit; /* Pointer to first rectangle to fill */ -{ - GC_SETUP(pDrawable, pGC); - - if (GC_CHECK((WindowPtr) pDrawable)) - { - register int nRect; - register xRectangle *pRect; - register int xorg, yorg; - - xorg = pDrawable->x; - yorg = pDrawable->y; - - for (nRect = nrectFill, pRect = prectInit; nRect--; pRect++) { - if (ORGRECT_OVERLAP(&pScreenPriv->saved,xorg,yorg,pRect)){ - miSpriteRemoveCursor(pDrawable->pScreen); - break; - } - } - } - - GC_OP_PROLOGUE (pGC); - - (*pGC->ops->PolyFillRect) (pDrawable, pGC, nrectFill, prectInit); - - GC_OP_EPILOGUE (pGC); -} - -static void -miSpritePolyFillArc(pDrawable, pGC, narcs, parcs) - DrawablePtr pDrawable; - GCPtr pGC; - int narcs; - xArc *parcs; -{ - GC_SETUP(pDrawable, pGC); - - if (GC_CHECK((WindowPtr) pDrawable)) - { - register int n; - BoxPtr cursor; - register xArc *arcs; - - cursor = &pScreenPriv->saved; - - for (arcs = parcs, n = narcs; n--; arcs++) - { - if (ORG_OVERLAP(cursor, pDrawable->x, pDrawable->y, - arcs->x, arcs->y, - (int) arcs->width, (int) arcs->height)) - { - miSpriteRemoveCursor (pDrawable->pScreen); - break; - } - } - } - - GC_OP_PROLOGUE (pGC); - - (*pGC->ops->PolyFillArc) (pDrawable, pGC, narcs, parcs); - - GC_OP_EPILOGUE (pGC); -} - -/* - * general Poly/Image text function. Extract glyph information, - * compute bounding box and remove cursor if it is overlapped. - */ - -static Bool -miSpriteTextOverlap ( - DrawablePtr pDraw, - FontPtr font, - int x, - int y, - unsigned int n, - CharInfoPtr *charinfo, - Bool imageblt, - unsigned int w, - BoxPtr cursorBox) -{ - ExtentInfoRec extents; - - x += pDraw->x; - y += pDraw->y; - - if (FONTMINBOUNDS(font,characterWidth) >= 0) - { - /* compute an approximate (but covering) bounding box */ - if (!imageblt || (charinfo[0]->metrics.leftSideBearing < 0)) - extents.overallLeft = charinfo[0]->metrics.leftSideBearing; - else - extents.overallLeft = 0; - if (w) - extents.overallRight = w - charinfo[n-1]->metrics.characterWidth; - else - extents.overallRight = FONTMAXBOUNDS(font,characterWidth) - * (n - 1); - if (imageblt && (charinfo[n-1]->metrics.characterWidth > - charinfo[n-1]->metrics.rightSideBearing)) - extents.overallRight += charinfo[n-1]->metrics.characterWidth; - else - extents.overallRight += charinfo[n-1]->metrics.rightSideBearing; - if (imageblt && FONTASCENT(font) > FONTMAXBOUNDS(font,ascent)) - extents.overallAscent = FONTASCENT(font); - else - extents.overallAscent = FONTMAXBOUNDS(font, ascent); - if (imageblt && FONTDESCENT(font) > FONTMAXBOUNDS(font,descent)) - extents.overallDescent = FONTDESCENT(font); - else - extents.overallDescent = FONTMAXBOUNDS(font,descent); - if (!BOX_OVERLAP(cursorBox, - x + extents.overallLeft, - y - extents.overallAscent, - x + extents.overallRight, - y + extents.overallDescent)) - return FALSE; - else if (imageblt && w) - return TRUE; - /* if it does overlap, fall through and compute exactly, because - * taking down the cursor is expensive enough to make this worth it - */ - } - QueryGlyphExtents(font, charinfo, n, &extents); - if (imageblt) - { - if (extents.overallWidth > extents.overallRight) - extents.overallRight = extents.overallWidth; - if (extents.overallWidth < extents.overallLeft) - extents.overallLeft = extents.overallWidth; - if (extents.overallLeft > 0) - extents.overallLeft = 0; - if (extents.fontAscent > extents.overallAscent) - extents.overallAscent = extents.fontAscent; - if (extents.fontDescent > extents.overallDescent) - extents.overallDescent = extents.fontDescent; - } - return (BOX_OVERLAP(cursorBox, - x + extents.overallLeft, - y - extents.overallAscent, - x + extents.overallRight, - y + extents.overallDescent)); -} - -/* - * values for textType: - */ -#define TT_POLY8 0 -#define TT_IMAGE8 1 -#define TT_POLY16 2 -#define TT_IMAGE16 3 - -static int -miSpriteText ( - DrawablePtr pDraw, - GCPtr pGC, - int x, - int y, - unsigned long count, - char *chars, - FontEncoding fontEncoding, - Bool textType, - BoxPtr cursorBox) -{ - CharInfoPtr *charinfo; - register CharInfoPtr *info; - unsigned long i; - unsigned int n; - int w; - - Bool imageblt; - - imageblt = (textType == TT_IMAGE8) || (textType == TT_IMAGE16); - - charinfo = (CharInfoPtr *) ALLOCATE_LOCAL(count * sizeof(CharInfoPtr)); - if (!charinfo) - return x; - - GetGlyphs(pGC->font, count, (unsigned char *)chars, - fontEncoding, &i, charinfo); - n = (unsigned int)i; - w = 0; - if (!imageblt) - for (info = charinfo; i--; info++) - w += (*info)->metrics.characterWidth; - - if (n != 0) { - if (miSpriteTextOverlap(pDraw, pGC->font, x, y, n, charinfo, imageblt, w, cursorBox)) - miSpriteRemoveCursor(pDraw->pScreen); - -#ifdef AVOID_GLYPHBLT - /* - * On displays like Apollos, which do not optimize the GlyphBlt functions because they - * convert fonts to their internal form in RealizeFont and optimize text directly, we - * want to invoke the text functions here, not the GlyphBlt functions. - */ - switch (textType) - { - case TT_POLY8: - (*pGC->ops->PolyText8)(pDraw, pGC, x, y, (int)count, chars); - break; - case TT_IMAGE8: - (*pGC->ops->ImageText8)(pDraw, pGC, x, y, (int)count, chars); - break; - case TT_POLY16: - (*pGC->ops->PolyText16)(pDraw, pGC, x, y, (int)count, - (unsigned short *)chars); - break; - case TT_IMAGE16: - (*pGC->ops->ImageText16)(pDraw, pGC, x, y, (int)count, - (unsigned short *)chars); - break; - } -#else /* don't AVOID_GLYPHBLT */ - /* - * On the other hand, if the device does use GlyphBlt ultimately to do text, we - * don't want to slow it down by invoking the text functions and having them call - * GetGlyphs all over again, so we go directly to the GlyphBlt functions here. - */ - if (imageblt) { - (*pGC->ops->ImageGlyphBlt)(pDraw, pGC, x, y, n, charinfo, - FONTGLYPHS(pGC->font)); - } else { - (*pGC->ops->PolyGlyphBlt)(pDraw, pGC, x, y, n, charinfo, - FONTGLYPHS(pGC->font)); - } -#endif /* AVOID_GLYPHBLT */ - } - DEALLOCATE_LOCAL(charinfo); - return x + w; -} - -static int -miSpritePolyText8(pDrawable, pGC, x, y, count, chars) - DrawablePtr pDrawable; - GCPtr pGC; - int x, y; - int count; - char *chars; -{ - int ret; - - GC_SETUP (pDrawable, pGC); - - GC_OP_PROLOGUE (pGC); - - if (GC_CHECK((WindowPtr) pDrawable)) - ret = miSpriteText (pDrawable, pGC, x, y, (unsigned long)count, chars, - Linear8Bit, TT_POLY8, &pScreenPriv->saved); - else - ret = (*pGC->ops->PolyText8) (pDrawable, pGC, x, y, count, chars); - - GC_OP_EPILOGUE (pGC); - return ret; -} - -static int -miSpritePolyText16(pDrawable, pGC, x, y, count, chars) - DrawablePtr pDrawable; - GCPtr pGC; - int x, y; - int count; - unsigned short *chars; -{ - int ret; - - GC_SETUP(pDrawable, pGC); - - GC_OP_PROLOGUE (pGC); - - if (GC_CHECK((WindowPtr) pDrawable)) - ret = miSpriteText (pDrawable, pGC, x, y, (unsigned long)count, - (char *)chars, - FONTLASTROW(pGC->font) == 0 ? - Linear16Bit : TwoD16Bit, TT_POLY16, &pScreenPriv->saved); - else - ret = (*pGC->ops->PolyText16) (pDrawable, pGC, x, y, count, chars); - - GC_OP_EPILOGUE (pGC); - return ret; -} - -static void -miSpriteImageText8(pDrawable, pGC, x, y, count, chars) - DrawablePtr pDrawable; - GCPtr pGC; - int x, y; - int count; - char *chars; -{ - GC_SETUP(pDrawable, pGC); - - GC_OP_PROLOGUE (pGC); - - if (GC_CHECK((WindowPtr) pDrawable)) - (void) miSpriteText (pDrawable, pGC, x, y, (unsigned long)count, - chars, Linear8Bit, TT_IMAGE8, &pScreenPriv->saved); - else - (*pGC->ops->ImageText8) (pDrawable, pGC, x, y, count, chars); - - GC_OP_EPILOGUE (pGC); -} - -static void -miSpriteImageText16(pDrawable, pGC, x, y, count, chars) - DrawablePtr pDrawable; - GCPtr pGC; - int x, y; - int count; - unsigned short *chars; -{ - GC_SETUP(pDrawable, pGC); - - GC_OP_PROLOGUE (pGC); - - if (GC_CHECK((WindowPtr) pDrawable)) - (void) miSpriteText (pDrawable, pGC, x, y, (unsigned long)count, - (char *)chars, - FONTLASTROW(pGC->font) == 0 ? - Linear16Bit : TwoD16Bit, TT_IMAGE16, &pScreenPriv->saved); - else - (*pGC->ops->ImageText16) (pDrawable, pGC, x, y, count, chars); - - GC_OP_EPILOGUE (pGC); -} - -static void -miSpriteImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase) - DrawablePtr pDrawable; - GCPtr pGC; - int x, y; - unsigned int nglyph; - CharInfoPtr *ppci; /* array of character info */ - pointer pglyphBase; /* start of array of glyphs */ -{ - GC_SETUP(pDrawable, pGC); - - GC_OP_PROLOGUE (pGC); - - if (GC_CHECK((WindowPtr) pDrawable) && - miSpriteTextOverlap (pDrawable, pGC->font, x, y, nglyph, ppci, TRUE, 0, &pScreenPriv->saved)) - { - miSpriteRemoveCursor(pDrawable->pScreen); - } - (*pGC->ops->ImageGlyphBlt) (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); - - GC_OP_EPILOGUE (pGC); -} - -static void -miSpritePolyGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase) - DrawablePtr pDrawable; - GCPtr pGC; - int x, y; - unsigned int nglyph; - CharInfoPtr *ppci; /* array of character info */ - pointer pglyphBase; /* start of array of glyphs */ -{ - GC_SETUP (pDrawable, pGC); - - GC_OP_PROLOGUE (pGC); - - if (GC_CHECK((WindowPtr) pDrawable) && - miSpriteTextOverlap (pDrawable, pGC->font, x, y, nglyph, ppci, FALSE, 0, &pScreenPriv->saved)) - { - miSpriteRemoveCursor(pDrawable->pScreen); - } - (*pGC->ops->PolyGlyphBlt) (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); - - GC_OP_EPILOGUE (pGC); -} - -static void -miSpritePushPixels(pGC, pBitMap, pDrawable, w, h, x, y) - GCPtr pGC; - PixmapPtr pBitMap; - DrawablePtr pDrawable; - int w, h, x, y; -{ - GC_SETUP(pDrawable, pGC); - - if (GC_CHECK((WindowPtr) pDrawable) && - ORG_OVERLAP(&pScreenPriv->saved,pDrawable->x,pDrawable->y,x,y,w,h)) - { - miSpriteRemoveCursor (pDrawable->pScreen); - } - - GC_OP_PROLOGUE (pGC); - - (*pGC->ops->PushPixels) (pGC, pBitMap, pDrawable, w, h, x, y); - - GC_OP_EPILOGUE (pGC); -} - -#ifdef NEED_LINEHELPER -/* - * I don't expect this routine will ever be called, as the GC - * will have been unwrapped for the line drawing - */ - -static void -miSpriteLineHelper() -{ - FatalError("miSpriteLineHelper called\n"); -} -#endif - -#ifdef RENDER - -# define mod(a,b) ((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b)) - -static void -miSpritePictureOverlap (PicturePtr pPict, - INT16 x, - INT16 y, - CARD16 w, - CARD16 h) -{ - if (pPict->pDrawable->type == DRAWABLE_WINDOW) - { - WindowPtr pWin = (WindowPtr) (pPict->pDrawable); - miSpriteScreenPtr pScreenPriv = (miSpriteScreenPtr) - pPict->pDrawable->pScreen->devPrivates[miSpriteScreenIndex].ptr; - if (GC_CHECK(pWin)) - { - if (pPict->repeat) - { - x = mod(x,pWin->drawable.width); - y = mod(y,pWin->drawable.height); - } - if (ORG_OVERLAP (&pScreenPriv->saved, pWin->drawable.x, pWin->drawable.y, - x, y, w, h)) - miSpriteRemoveCursor (pWin->drawable.pScreen); - } - } -} - -#define PICTURE_PROLOGUE(ps, pScreenPriv, field) \ - ps->field = pScreenPriv->field - -#define PICTURE_EPILOGUE(ps, field, wrap) \ - ps->field = wrap - -static void -miSpriteComposite(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; - PictureScreenPtr ps = GetPictureScreen(pScreen); - miSpriteScreenPtr pScreenPriv; - - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; - PICTURE_PROLOGUE(ps, pScreenPriv, Composite); - miSpritePictureOverlap (pSrc, xSrc, ySrc, width, height); - if (pMask) - miSpritePictureOverlap (pMask, xMask, yMask, width, height); - miSpritePictureOverlap (pDst, xDst, yDst, width, height); - - (*ps->Composite) (op, - pSrc, - pMask, - pDst, - xSrc, - ySrc, - xMask, - yMask, - xDst, - yDst, - width, - height); - - PICTURE_EPILOGUE(ps, Composite, miSpriteComposite); -} - -static void -miSpriteGlyphs(CARD8 op, - PicturePtr pSrc, - PicturePtr pDst, - PictFormatPtr maskFormat, - INT16 xSrc, - INT16 ySrc, - int nlist, - GlyphListPtr list, - GlyphPtr *glyphs) -{ - ScreenPtr pScreen = pDst->pDrawable->pScreen; - PictureScreenPtr ps = GetPictureScreen(pScreen); - miSpriteScreenPtr pScreenPriv; - - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; - PICTURE_PROLOGUE(ps, pScreenPriv, Glyphs); - if (pSrc->pDrawable->type == DRAWABLE_WINDOW) - { - WindowPtr pSrcWin = (WindowPtr) (pSrc->pDrawable); - - if (GC_CHECK(pSrcWin)) - miSpriteRemoveCursor (pScreen); - } - if (pDst->pDrawable->type == DRAWABLE_WINDOW) - { - WindowPtr pDstWin = (WindowPtr) (pDst->pDrawable); - - if (GC_CHECK(pDstWin)) - { - BoxRec extents; - - miGlyphExtents (nlist, list, glyphs, &extents); - if (BOX_OVERLAP(&pScreenPriv->saved, - extents.x1 + pDstWin->drawable.x, - extents.y1 + pDstWin->drawable.y, - extents.x2 + pDstWin->drawable.x, - extents.y2 + pDstWin->drawable.y)) - { - miSpriteRemoveCursor (pScreen); - } - } - } - - (*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs); - - PICTURE_EPILOGUE (ps, Glyphs, miSpriteGlyphs); -} -#endif - /* * miPointer interface routines */ @@ -2186,7 +676,8 @@ miSpriteSetCursor (pScreen, pCursor, x, y) pScreenPriv->saved.y2 - pScreenPriv->saved.y1 ) { - pScreenPriv->isUp = FALSE; + DamageDrawInternal (pScreen, TRUE); + miSpriteIsUpFALSE (pScreen, pScreenPriv); if (!(sx >= pScreenPriv->saved.x1 && sx + (int)pCursor->bits->width < pScreenPriv->saved.x2 && sy >= pScreenPriv->saved.y1 && @@ -2218,15 +709,20 @@ miSpriteSetCursor (pScreen, pCursor, x, y) sy - pScreenPriv->saved.y1, pScreenPriv->colors[SOURCE_COLOR].pixel, pScreenPriv->colors[MASK_COLOR].pixel); - pScreenPriv->isUp = TRUE; + miSpriteIsUpTRUE (pScreen, pScreenPriv); + DamageDrawInternal (pScreen, FALSE); } else { + SPRITE_DEBUG (("SetCursor remove\n")); miSpriteRemoveCursor (pScreen); } } if (!pScreenPriv->isUp && pScreenPriv->pCursor) + { + SPRITE_DEBUG (("SetCursor restore\n")); miSpriteRestoreCursor (pScreen); + } } static void @@ -2250,8 +746,9 @@ miSpriteRemoveCursor (pScreen) { miSpriteScreenPtr pScreenPriv; + DamageDrawInternal (pScreen, TRUE); pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; - pScreenPriv->isUp = FALSE; + miSpriteIsUpFALSE (pScreen, pScreenPriv); pScreenPriv->pCacheWin = NullWindow; if (!(*pScreenPriv->funcs->RestoreUnderCursor) (pScreen, pScreenPriv->saved.x1, @@ -2259,8 +756,9 @@ miSpriteRemoveCursor (pScreen) pScreenPriv->saved.x2 - pScreenPriv->saved.x1, pScreenPriv->saved.y2 - pScreenPriv->saved.y1)) { - pScreenPriv->isUp = TRUE; + miSpriteIsUpTRUE (pScreen, pScreenPriv); } + DamageDrawInternal (pScreen, FALSE); } /* @@ -2276,6 +774,7 @@ miSpriteRestoreCursor (pScreen) int x, y; CursorPtr pCursor; + DamageDrawInternal (pScreen, TRUE); miSpriteComputeSaved (pScreen); pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; pCursor = pScreenPriv->pCursor; @@ -2292,8 +791,11 @@ miSpriteRestoreCursor (pScreen) if ((*pScreenPriv->funcs->PutUpCursor) (pScreen, pCursor, x, y, pScreenPriv->colors[SOURCE_COLOR].pixel, pScreenPriv->colors[MASK_COLOR].pixel)) - pScreenPriv->isUp = TRUE; + { + miSpriteIsUpTRUE (pScreen, pScreenPriv); + } } + DamageDrawInternal (pScreen, FALSE); } /* diff --git a/mi/mispritest.h b/mi/mispritest.h index e438dd7d2..7312d2476 100644 --- a/mi/mispritest.h +++ b/mi/mispritest.h @@ -32,58 +32,68 @@ in this Software without prior written authorization from The Open Group. */ /* $XFree86: xc/programs/Xserver/mi/mispritest.h,v 1.4 2001/01/17 22:37:07 dawes Exp $ */ +#ifndef _MISPRITEST_H_ +#define _MISPRITEST_H_ + # include "misprite.h" #ifdef RENDER # include "picturestr.h" #endif +# include "damage.h" /* * per screen information */ typedef struct { + /* screen procedures */ CloseScreenProcPtr CloseScreen; GetImageProcPtr GetImage; GetSpansProcPtr GetSpans; SourceValidateProcPtr SourceValidate; - CreateGCProcPtr CreateGC; - ScreenBlockHandlerProcPtr BlockHandler; - InstallColormapProcPtr InstallColormap; - StoreColorsProcPtr StoreColors; - PaintWindowBackgroundProcPtr PaintWindowBackground; - PaintWindowBorderProcPtr PaintWindowBorder; + + /* window procedures */ CopyWindowProcPtr CopyWindow; - ClearToBackgroundProcPtr ClearToBackground; + + /* backing store procedures */ SaveDoomedAreasProcPtr SaveDoomedAreas; - RestoreAreasProcPtr RestoreAreas; -#ifdef RENDER - CompositeProcPtr Composite; - GlyphsProcPtr Glyphs; -#endif + + /* colormap procedures */ + InstallColormapProcPtr InstallColormap; + StoreColorsProcPtr StoreColors; + + /* os layer procedures */ + ScreenBlockHandlerProcPtr BlockHandler; CursorPtr pCursor; - int x; + int x; /* cursor hotspot */ int y; - BoxRec saved; - Bool isUp; - Bool shouldBeUp; - WindowPtr pCacheWin; + BoxRec saved; /* saved area from the screen */ + Bool isUp; /* cursor in frame buffer */ + Bool shouldBeUp; /* cursor should be displayed */ + WindowPtr pCacheWin; /* window the cursor last seen in */ Bool isInCacheWin; - Bool checkPixels; + Bool checkPixels; /* check colormap collision */ xColorItem colors[2]; ColormapPtr pInstalledMap; ColormapPtr pColormap; VisualPtr pVisual; miSpriteCursorFuncPtr funcs; + DamagePtr pDamage; /* damage tracking structure */ } miSpriteScreenRec, *miSpriteScreenPtr; #define SOURCE_COLOR 0 #define MASK_COLOR 1 -typedef struct { - GCFuncs *wrapFuncs; - GCOps *wrapOps; -} miSpriteGCRec, *miSpriteGCPtr; +#define miSpriteIsUpTRUE(pScreen, pScreenPriv) if (!pScreenPriv->isUp) { \ + pScreenPriv->isUp = TRUE; \ + DamageRegister (&(*pScreen->GetScreenPixmap) (pScreen)->drawable, pScreenPriv->pDamage); \ +} + +#define miSpriteIsUpFALSE(pScreen, pScreenPriv) if (pScreenPriv->isUp) { \ + DamageUnregister (&(*pScreen->GetScreenPixmap) (pScreen)->drawable, pScreenPriv->pDamage); \ + pScreenPriv->isUp = FALSE; \ +} /* * Overlap BoxPtr and Box elements @@ -116,3 +126,5 @@ typedef struct { #define LINE_OVERLAP(pCbox,x1,y1,x2,y2,lw2) \ BOX_OVERLAP((pCbox), (x1)-(lw2), (y1)-(lw2), (x2)+(lw2), (y2)+(lw2)) + +#endif /* _MISPRITEST_H_ */ diff --git a/mi/mivaltree.c b/mi/mivaltree.c index 8cd511240..71ed488e6 100644 --- a/mi/mivaltree.c +++ b/mi/mivaltree.c @@ -1,5 +1,5 @@ /* $Xorg: mivaltree.c,v 1.4 2001/02/09 02:05:22 xorgcvs Exp $ */ -/* $XdotOrg: xc/programs/Xserver/mi/mivaltree.c,v 1.1.4.2.6.2 2004/03/08 00:36:57 alanc Exp $ */ +/* $XdotOrg: xc/programs/Xserver/mi/mivaltree.c,v 1.3 2004/07/31 08:24:14 anholt Exp $ */ /* * mivaltree.c -- * Functions for recalculating window clip lists. Main function @@ -167,6 +167,17 @@ miShapedWindowIn (pScreen, universe, bounding, rect, x, y) } #endif +static GetRedirectBorderClipProcPtr miGetRedirectBorderClipProc; +static SetRedirectBorderClipProcPtr miSetRedirectBorderClipProc; + +void +miRegisterRedirectBorderClipProc (SetRedirectBorderClipProcPtr setBorderClip, + GetRedirectBorderClipProcPtr getBorderClip) +{ + miSetRedirectBorderClipProc = setBorderClip; + miGetRedirectBorderClipProc = getBorderClip; +} + #define HasParentRelativeBorder(w) (!(w)->borderIsPixel && \ HasBorder(w) && \ (w)->backgroundState == ParentRelative) @@ -264,6 +275,18 @@ miComputeClips ( ((pParent->eventMask | wOtherEventMasks(pParent)) & VisibilityChangeMask)) SendVisibilityNotify(pParent); +#ifdef COMPOSITE + /* + * In redirected drawing case, reset universe to borderSize + */ + if (pParent->redirectDraw) + { + if (miSetRedirectBorderClipProc) + (*miSetRedirectBorderClipProc) (pParent, universe); + REGION_COPY(pScreen, universe, &pParent->borderSize); + } +#endif + dx = pParent->drawable.x - pParent->valdata->before.oldAbsCorner.x; dy = pParent->drawable.y - pParent->valdata->before.oldAbsCorner.y; @@ -640,7 +663,12 @@ miValidateTree (pParent, pChild, kind) { if (pWin->valdata) { - REGION_APPEND( pScreen, &totalClip, &pWin->borderClip); + RegionPtr pBorderClip = &pWin->borderClip; +#ifdef COMPOSITE + if (pWin->redirectDraw && miGetRedirectBorderClipProc) + pBorderClip = (*miGetRedirectBorderClipProc)(pWin); +#endif + REGION_APPEND( pScreen, &totalClip, pBorderClip ); if (pWin->viewable) viewvals++; } @@ -654,7 +682,12 @@ miValidateTree (pParent, pChild, kind) { if (pWin->valdata) { - REGION_APPEND( pScreen, &totalClip, &pWin->borderClip); + RegionPtr pBorderClip = &pWin->borderClip; +#ifdef COMPOSITE + if (pWin->redirectDraw && miGetRedirectBorderClipProc) + pBorderClip = (*miGetRedirectBorderClipProc)(pWin); +#endif + REGION_APPEND( pScreen, &totalClip, pBorderClip ); if (pWin->viewable) viewvals++; } diff --git a/miext/cw/cw.c b/miext/cw/cw.c new file mode 100644 index 000000000..f834148a7 --- /dev/null +++ b/miext/cw/cw.c @@ -0,0 +1,685 @@ +/* + * Copyright © 2004 Eric Anholt + * + * 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 Eric Anholt not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Eric Anholt makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ERIC ANHOLT 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. + */ +/* $Header$ */ + +#include "gcstruct.h" +#include "windowstr.h" +#include "cw.h" + +#define CW_DEBUG 1 + +#if CW_DEBUG +#define CW_ASSERT(x) do { \ + if (!(x)) { \ + ErrorF("composite wrapper: assertion failed at %s:%d\n", __FUNC__, \ + __LINE__); \ + } \ +} while (0) +#else +#define CW_ASSERT(x) do {} while (0) +#endif + +int cwGCIndex; +int cwScreenIndex; +int cwWindowIndex; +#ifdef RENDER +int cwPictureIndex; +#endif +static unsigned long cwGeneration = 0; +extern GCOps cwGCOps; + +static Bool +cwCloseScreen (int i, ScreenPtr pScreen); + +static void +cwValidateGC(GCPtr pGC, unsigned long stateChanges, DrawablePtr pDrawable); +static void +cwChangeGC(GCPtr pGC, unsigned long mask); +static void +cwCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst); +static void +cwDestroyGC(GCPtr pGC); +static void +cwChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects); +static void +cwCopyClip(GCPtr pgcDst, GCPtr pgcSrc); +static void +cwDestroyClip(GCPtr pGC); + +GCFuncs cwGCFuncs = { + cwValidateGC, + cwChangeGC, + cwCopyGC, + cwDestroyGC, + cwChangeClip, + cwDestroyClip, + cwCopyClip, +}; + +/* Find the real drawable to draw to, and provide offsets that will translate + * window coordinates to backing pixmap coordinates. + */ +DrawablePtr +cwGetBackingDrawable(DrawablePtr pDrawable, int *x_off, int *y_off) +{ + PixmapPtr pPixmap; + + if (pDrawable->type == DRAWABLE_WINDOW && + (pPixmap = getCwPixmap ((WindowPtr) pDrawable))) + { + *x_off = pDrawable->x - pPixmap->screen_x; + *y_off = pDrawable->y - pPixmap->screen_y; + return &pPixmap->drawable; + } else { + *x_off = *y_off = 0; + return pDrawable; + } +} + +#define FUNC_PROLOGUE(pGC, pPriv) do { \ + (pGC)->funcs = (pPriv)->wrapFuncs; \ + (pGC)->ops = (pPriv)->wrapOps; \ +} while (0) + +#define FUNC_EPILOGUE(pGC, pPriv) do { \ + (pPriv)->wrapFuncs = (pGC)->funcs; \ + (pPriv)->wrapOps = (pGC)->ops; \ + (pGC)->funcs = &cwGCFuncs; \ + (pGC)->ops = &cwGCOps; \ +} while (0) + + +static Bool +cwCreateBackingGC(GCPtr pGC, DrawablePtr pDrawable) +{ + cwGCRec *pPriv = getCwGC(pGC); + int status, x_off, y_off; + XID noexpose = xFalse; + DrawablePtr pBackingDrawable; + + pBackingDrawable = cwGetBackingDrawable(pDrawable, &x_off, &y_off); + pPriv->pBackingGC = CreateGC(pBackingDrawable, GCGraphicsExposures, + &noexpose, &status); + if (status != Success) + return FALSE; + + pPriv->serialNumber = 0; + pPriv->stateChanges = (1 << (GCLastBit + 1)) - 1; + + return TRUE; +} + +static void +cwDestroyBackingGC(GCPtr pGC) +{ + cwGCPtr pPriv; + + pPriv = (cwGCPtr) getCwGC (pGC); + + if (pPriv->pBackingGC) { + FreeGC(pPriv->pBackingGC, (XID)0); + pPriv->pBackingGC = NULL; + } +} + +static void +cwValidateGC(GCPtr pGC, unsigned long stateChanges, DrawablePtr pDrawable) +{ + GCPtr pBackingGC; + cwGCPtr pPriv; + DrawablePtr pBackingDrawable; + int x_off, y_off; + + pPriv = (cwGCPtr) getCwGC (pGC); + + FUNC_PROLOGUE(pGC, pPriv); + + /* + * Must call ValidateGC to ensure pGC->pCompositeClip is valid + */ + (*pGC->funcs->ValidateGC)(pGC, stateChanges, pDrawable); + + if (!cwDrawableIsRedirWindow(pDrawable)) { + cwDestroyBackingGC(pGC); + FUNC_EPILOGUE(pGC, pPriv); + return; + } else { + if (!pPriv->pBackingGC && !cwCreateBackingGC(pGC, pDrawable)) { + FUNC_EPILOGUE(pGC, pPriv); + return; + } + } + + pBackingGC = pPriv->pBackingGC; + pBackingDrawable = cwGetBackingDrawable(pDrawable, &x_off, &y_off); + + pPriv->stateChanges |= stateChanges; + + /* + * Copy the composite clip into the backing GC if either + * the drawable clip list has changed or the client has changed + * the client clip data + */ + if (pDrawable->serialNumber != pPriv->serialNumber || + (pPriv->stateChanges & (GCClipXOrigin|GCClipYOrigin|GCClipMask))) + { + XID vals[2]; + RegionPtr pCompositeClip; + + pCompositeClip = REGION_CREATE (pScreen, NULL, 0); + REGION_COPY (pScreen, pCompositeClip, pGC->pCompositeClip); + + /* Either the drawable has changed, or the clip list in the drawable has + * changed. Copy the new clip list over and set the new translated + * offset for it. + */ + + (*pBackingGC->funcs->ChangeClip) (pBackingGC, CT_REGION, + (pointer) pCompositeClip, 0); + + vals[0] = x_off - pDrawable->x; + vals[1] = y_off - pDrawable->y; + dixChangeGC(NullClient, pBackingGC, + (GCClipXOrigin | GCClipYOrigin), vals, NULL); + + pPriv->serialNumber = pDrawable->serialNumber; + /* + * Mask off any client clip changes to make sure + * the clip list set above remains in effect + */ + pPriv->stateChanges &= ~(GCClipXOrigin|GCClipYOrigin|GCClipMask); + } + + if (pPriv->stateChanges) { + CopyGC(pGC, pBackingGC, pPriv->stateChanges); + pPriv->stateChanges = 0; + } + + if ((pGC->patOrg.x + x_off) != pBackingGC->patOrg.x || + (pGC->patOrg.y + y_off) != pBackingGC->patOrg.y) + { + XID vals[2]; + vals[0] = pGC->patOrg.x + x_off; + vals[1] = pGC->patOrg.y + y_off; + dixChangeGC(NullClient, pBackingGC, + (GCTileStipXOrigin | GCTileStipYOrigin), vals, NULL); + } + + ValidateGC(pBackingDrawable, pBackingGC); + + FUNC_EPILOGUE(pGC, pPriv); +} + +static void +cwChangeGC(GCPtr pGC, unsigned long mask) +{ + cwGCPtr pPriv = (cwGCPtr)(pGC)->devPrivates[cwGCIndex].ptr; + + FUNC_PROLOGUE(pGC, pPriv); + + (*pGC->funcs->ChangeGC) (pGC, mask); + + FUNC_EPILOGUE(pGC, pPriv); +} + +static void +cwCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst) +{ + cwGCPtr pPriv = (cwGCPtr)(pGCDst)->devPrivates[cwGCIndex].ptr; + + FUNC_PROLOGUE(pGCDst, pPriv); + + (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst); + + FUNC_EPILOGUE(pGCDst, pPriv); +} + +static void +cwDestroyGC(GCPtr pGC) +{ + cwGCPtr pPriv = (cwGCPtr)(pGC)->devPrivates[cwGCIndex].ptr; + + FUNC_PROLOGUE(pGC, pPriv); + + cwDestroyBackingGC(pGC); + + (*pGC->funcs->DestroyGC) (pGC); + + /* leave it unwrapped */ +} + +static void +cwChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects) +{ + cwGCPtr pPriv = (cwGCPtr)(pGC)->devPrivates[cwGCIndex].ptr; + + FUNC_PROLOGUE(pGC, pPriv); + + (*pGC->funcs->ChangeClip)(pGC, type, pvalue, nrects); + + FUNC_EPILOGUE(pGC, pPriv); +} + +static void +cwCopyClip(GCPtr pgcDst, GCPtr pgcSrc) +{ + cwGCPtr pPriv = (cwGCPtr)(pgcDst)->devPrivates[cwGCIndex].ptr; + + FUNC_PROLOGUE(pgcDst, pPriv); + + (*pgcDst->funcs->CopyClip)(pgcDst, pgcSrc); + + FUNC_EPILOGUE(pgcDst, pPriv); +} + +static void +cwDestroyClip(GCPtr pGC) +{ + cwGCPtr pPriv = (cwGCPtr)(pGC)->devPrivates[cwGCIndex].ptr; + + FUNC_PROLOGUE(pGC, pPriv); + + (*pGC->funcs->DestroyClip)(pGC); + + FUNC_EPILOGUE(pGC, pPriv); +} + +/* + * Screen wrappers. + */ + +#define SCREEN_PROLOGUE(pScreen, field) \ + ((pScreen)->field = getCwScreen(pScreen)->field) + +#define SCREEN_EPILOGUE(pScreen, field, wrapper) do { \ + getCwScreen(pScreen)->field = (pScreen)->field; \ + (pScreen)->field = (wrapper); \ +} while (0) + +static Bool +cwCreateGC(GCPtr pGC) +{ + cwGCPtr pPriv = getCwGC(pGC); + ScreenPtr pScreen = pGC->pScreen; + Bool ret; + + bzero(pPriv, sizeof(cwGCRec)); + SCREEN_PROLOGUE(pScreen, CreateGC); + + if ( (ret = (*pScreen->CreateGC)(pGC)) ) + FUNC_EPILOGUE(pGC, pPriv); + + SCREEN_EPILOGUE(pScreen, CreateGC, cwCreateGC); + + return ret; +} + +static void +cwGetImage(DrawablePtr pSrc, int x, int y, int w, int h, unsigned int format, + unsigned long planemask, char *pdstLine) +{ + ScreenPtr pScreen = pSrc->pScreen; + DrawablePtr pBackingDrawable; + int src_off_x, src_off_y; + + SCREEN_PROLOGUE(pScreen, GetImage); + + pBackingDrawable = cwGetBackingDrawable(pSrc, &src_off_x, &src_off_y); + + CW_OFFSET_XY_SRC(x, y); + + (*pScreen->GetImage)(pBackingDrawable, x, y, w, h, format, planemask, + pdstLine); + + SCREEN_EPILOGUE(pScreen, GetImage, cwGetImage); +} + +static void +cwGetSpans(DrawablePtr pSrc, int wMax, DDXPointPtr ppt, int *pwidth, + int nspans, char *pdstStart) +{ + ScreenPtr pScreen = pSrc->pScreen; + DrawablePtr pBackingDrawable; + int i; + int src_off_x, src_off_y; + + SCREEN_PROLOGUE(pScreen, GetSpans); + + pBackingDrawable = cwGetBackingDrawable(pSrc, &src_off_x, &src_off_y); + + for (i = 0; i < nspans; i++) + CW_OFFSET_XY_SRC(ppt[i].x, ppt[i].y); + + (*pScreen->GetSpans)(pBackingDrawable, wMax, ppt, pwidth, nspans, + pdstStart); + + SCREEN_EPILOGUE(pScreen, GetSpans, cwGetSpans); +} + +static void +cwFillRegionSolid(DrawablePtr pDrawable, RegionPtr pRegion, unsigned long pixel) +{ + ScreenPtr pScreen = pDrawable->pScreen; + GCPtr pGC; + BoxPtr pBox; + int nbox, i; + ChangeGCVal v[3]; + + pGC = GetScratchGC(pDrawable->depth, pScreen); + v[0].val = GXcopy; + v[1].val = pixel; + v[2].val = FillSolid; + dixChangeGC(NullClient, pGC, (GCFunction | GCForeground | GCFillStyle), + NULL, v); + ValidateGC(pDrawable, pGC); + + pBox = REGION_RECTS(pRegion); + nbox = REGION_NUM_RECTS(pRegion); + + for (i = 0; i < nbox; i++, pBox++) { + xRectangle rect; + rect.x = pBox->x1; + rect.y = pBox->y1; + rect.width = pBox->x2 - pBox->x1; + rect.height = pBox->y2 - pBox->y1; + (*pGC->ops->PolyFillRect)(pDrawable, pGC, 1, &rect); + } + + FreeScratchGC(pGC); +} + +static void +cwFillRegionTiled(DrawablePtr pDrawable, RegionPtr pRegion, PixmapPtr pTile, + int x_off, int y_off) +{ + ScreenPtr pScreen = pDrawable->pScreen; + GCPtr pGC; + BoxPtr pBox; + int nbox, i; + ChangeGCVal v[5]; + + pGC = GetScratchGC(pDrawable->depth, pScreen); + v[0].val = GXcopy; + v[1].val = FillTiled; + v[2].ptr = (pointer) pTile; + v[3].val = x_off; + v[4].val = y_off; + dixChangeGC(NullClient, pGC, (GCFunction | GCFillStyle | GCTile | + GCTileStipXOrigin | GCTileStipYOrigin), NULL, v); + + ValidateGC(pDrawable, pGC); + + pBox = REGION_RECTS(pRegion); + nbox = REGION_NUM_RECTS(pRegion); + + for (i = 0; i < nbox; i++, pBox++) { + xRectangle rect; + rect.x = pBox->x1; + rect.y = pBox->y1; + rect.width = pBox->x2 - pBox->x1; + rect.height = pBox->y2 - pBox->y1; + (*pGC->ops->PolyFillRect)(pDrawable, pGC, 1, &rect); + } + + FreeScratchGC(pGC); +} + +static void +cwPaintWindowBackground(WindowPtr pWin, RegionPtr pRegion, int what) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + + SCREEN_PROLOGUE(pScreen, PaintWindowBackground); + + if (!cwDrawableIsRedirWindow((DrawablePtr)pWin)) { + (*pScreen->PaintWindowBackground)(pWin, pRegion, what); + } else { + DrawablePtr pBackingDrawable; + int x_off, y_off, x_screen, y_screen; + + while (pWin && pWin->backgroundState == ParentRelative) + pWin = pWin->parent; + + pBackingDrawable = cwGetBackingDrawable((DrawablePtr)pWin, &x_off, + &y_off); + + x_screen = x_off - pWin->drawable.x; + y_screen = y_off - pWin->drawable.y; + + if (pWin && (pWin->backgroundState == BackgroundPixel || + pWin->backgroundState == BackgroundPixmap)) + { + REGION_TRANSLATE(pScreen, pRegion, x_screen, y_screen); + + if (pWin->backgroundState == BackgroundPixel) { + cwFillRegionSolid(pBackingDrawable, pRegion, + pWin->background.pixel); + } else { + cwFillRegionTiled(pBackingDrawable, pRegion, + pWin->background.pixmap, x_off, y_off); + } + + REGION_TRANSLATE(pScreen, pRegion, -x_screen, -y_screen); + } + } + + SCREEN_EPILOGUE(pScreen, PaintWindowBackground, cwPaintWindowBackground); +} + +static void +cwPaintWindowBorder(WindowPtr pWin, RegionPtr pRegion, int what) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + + SCREEN_PROLOGUE(pScreen, PaintWindowBorder); + + if (!cwDrawableIsRedirWindow((DrawablePtr)pWin)) { + (*pScreen->PaintWindowBorder)(pWin, pRegion, what); + } else { + DrawablePtr pBackingDrawable; + int x_off, y_off, x_screen, y_screen; + + pBackingDrawable = cwGetBackingDrawable((DrawablePtr)pWin, &x_off, + &y_off); + + x_screen = x_off - pWin->drawable.x; + y_screen = y_off - pWin->drawable.y; + + REGION_TRANSLATE(pScreen, pRegion, x_screen, y_screen); + + if (pWin->borderIsPixel) { + cwFillRegionSolid(pBackingDrawable, pRegion, pWin->border.pixel); + } else { + cwFillRegionTiled(pBackingDrawable, pRegion, pWin->border.pixmap, + x_off, y_off); + } + + REGION_TRANSLATE(pScreen, pRegion, -x_screen, -y_screen); + } + + SCREEN_EPILOGUE(pScreen, PaintWindowBorder, cwPaintWindowBorder); +} + +static void +cwCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + + SCREEN_PROLOGUE(pScreen, CopyWindow); + + if (!cwDrawableIsRedirWindow((DrawablePtr)pWin)) { + (*pScreen->CopyWindow)(pWin, ptOldOrg, prgnSrc); + } else { + GCPtr pGC; + BoxPtr pExtents; + int x_off, y_off; + int dx, dy; + PixmapPtr pBackingPixmap; + RegionPtr pClip; + int src_x, src_y, dst_x, dst_y, w, h; + + dx = ptOldOrg.x - pWin->drawable.x; + dy = ptOldOrg.y - pWin->drawable.y; + + pExtents = REGION_EXTENTS(pScreen, prgnSrc); + + pBackingPixmap = (PixmapPtr) cwGetBackingDrawable((DrawablePtr)pWin, + &x_off, &y_off); + + src_x = pExtents->x1 - pBackingPixmap->screen_x; + src_y = pExtents->y1 - pBackingPixmap->screen_y; + w = pExtents->x2 - pExtents->x1; + h = pExtents->y2 - pExtents->y1; + dst_x = src_x - dx; + dst_y = src_y - dy; + + /* Translate region (as required by API) */ + REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy); + + pGC = GetScratchGC(pBackingPixmap->drawable.depth, pScreen); + /* + * Copy region to GC as clip, aligning as dest clip + */ + pClip = REGION_CREATE (pScreen, NULL, 0); + REGION_INTERSECT(pScreen, pClip, &pWin->borderClip, prgnSrc); + REGION_TRANSLATE(pScreen, pClip, + -pBackingPixmap->screen_x, + -pBackingPixmap->screen_y); + + (*pGC->funcs->ChangeClip) (pGC, CT_REGION, pClip, 0); + + ValidateGC(&pBackingPixmap->drawable, pGC); + + (*pGC->ops->CopyArea) (&pBackingPixmap->drawable, + &pBackingPixmap->drawable, pGC, + src_x, src_y, w, h, dst_x, dst_y); + + (*pGC->funcs->DestroyClip) (pGC); + + FreeScratchGC(pGC); + } + + SCREEN_EPILOGUE(pScreen, CopyWindow, cwCopyWindow); +} + +static PixmapPtr +cwGetWindowPixmap (WindowPtr pWin) +{ + PixmapPtr pPixmap = getCwPixmap (pWin); + + if (!pPixmap) + { + ScreenPtr pScreen = pWin->drawable.pScreen; + SCREEN_PROLOGUE(pScreen, GetWindowPixmap); + if (pScreen->GetWindowPixmap) + pPixmap = (*pScreen->GetWindowPixmap) (pWin); + SCREEN_EPILOGUE(pScreen, GetWindowPixmap, cwGetWindowPixmap); + } + return pPixmap; +} + +static void +cwSetWindowPixmap (WindowPtr pWindow, PixmapPtr pPixmap) +{ + ScreenPtr pScreen = pWindow->drawable.pScreen; + + if (pPixmap == (*pScreen->GetScreenPixmap) (pScreen)) + pPixmap = NULL; + setCwPixmap (pWindow, pPixmap); +} + +/* Screen initialization/teardown */ +void +miInitializeCompositeWrapper(ScreenPtr pScreen) +{ + cwScreenPtr pScreenPriv; + + if (cwGeneration != serverGeneration) + { + cwScreenIndex = AllocateScreenPrivateIndex(); + if (cwScreenIndex < 0) + return; + cwGCIndex = AllocateGCPrivateIndex(); + cwWindowIndex = AllocateWindowPrivateIndex(); +#ifdef RENDER + cwPictureIndex = AllocatePicturePrivateIndex(); +#endif + cwGeneration = serverGeneration; + } + if (!AllocateGCPrivate(pScreen, cwGCIndex, sizeof(cwGCRec))) + return; + if (!AllocateWindowPrivate(pScreen, cwWindowIndex, 0)) + return; +#ifdef RENDER + if (!AllocatePicturePrivate(pScreen, cwPictureIndex, 0)) + return; +#endif + pScreenPriv = (cwScreenPtr)xalloc(sizeof(cwScreenRec)); + if (!pScreenPriv) + return; + + pScreen->devPrivates[cwScreenIndex].ptr = (pointer)pScreenPriv; + + SCREEN_EPILOGUE(pScreen, CloseScreen, cwCloseScreen); + SCREEN_EPILOGUE(pScreen, GetImage, cwGetImage); + SCREEN_EPILOGUE(pScreen, GetSpans, cwGetSpans); + SCREEN_EPILOGUE(pScreen, CreateGC, cwCreateGC); + SCREEN_EPILOGUE(pScreen, PaintWindowBackground, cwPaintWindowBackground); + SCREEN_EPILOGUE(pScreen, PaintWindowBorder, cwPaintWindowBorder); + SCREEN_EPILOGUE(pScreen, CopyWindow, cwCopyWindow); + + SCREEN_EPILOGUE(pScreen, SetWindowPixmap, cwSetWindowPixmap); + SCREEN_EPILOGUE(pScreen, GetWindowPixmap, cwGetWindowPixmap); + +#ifdef RENDER + if (GetPictureScreen (pScreen)) + cwInitializeRender(pScreen); +#endif +} + +static Bool +cwCloseScreen (int i, ScreenPtr pScreen) +{ + cwScreenPtr pScreenPriv; +#ifdef RENDER + PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); +#endif + + pScreenPriv = (cwScreenPtr)pScreen->devPrivates[cwScreenIndex].ptr; + + pScreen->CloseScreen = pScreenPriv->CloseScreen; + pScreen->GetImage = pScreenPriv->GetImage; + pScreen->GetSpans = pScreenPriv->GetSpans; + pScreen->CreateGC = pScreenPriv->CreateGC; + pScreen->PaintWindowBackground = pScreenPriv->PaintWindowBackground; + pScreen->PaintWindowBorder = pScreenPriv->PaintWindowBorder; + pScreen->CopyWindow = pScreenPriv->CopyWindow; + +#ifdef RENDER + if (ps) + cwFiniRender(pScreen); +#endif + + xfree((pointer)pScreenPriv); + + return (*pScreen->CloseScreen)(i, pScreen); +} diff --git a/miext/cw/cw.h b/miext/cw/cw.h new file mode 100644 index 000000000..2e26e097e --- /dev/null +++ b/miext/cw/cw.h @@ -0,0 +1,164 @@ +/* + * Copyright © 2004 Eric Anholt + * + * 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 Eric Anholt not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Eric Anholt makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ERIC ANHOLT 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. + */ +/* $Header$ */ + +#include "picturestr.h" + +/* + * One of these structures is allocated per GC that gets used with a window with + * backing pixmap. + */ + +typedef struct { + GCPtr pBackingGC; /* Copy of the GC but with graphicsExposures + * set FALSE and the clientClip set to + * clip output to the valid regions of the + * backing pixmap. */ + unsigned long serialNumber; /* clientClip computed time */ + unsigned long stateChanges; /* changes in parent gc since last copy */ + GCOps *wrapOps; /* wrapped ops */ + GCFuncs *wrapFuncs; /* wrapped funcs */ +} cwGCRec, *cwGCPtr; + +extern int cwGCIndex; + +#define getCwGC(pGC) ((cwGCPtr)(pGC)->devPrivates[cwGCIndex].ptr) +#define setCwGC(pGC,p) ((pGC)->devPrivates[cwGCIndex].ptr = (pointer) (p)) + +/* + * One of these structures is allocated per Picture that gets used with a + * window with a backing pixmap + */ + +typedef struct { + PicturePtr pBackingPicture; + unsigned long serialNumber; + unsigned long stateChanges; +} cwPictureRec, *cwPicturePtr; + +#define getCwPicture(pPicture) ((cwPicturePtr)(pPicture)->devPrivates[cwPictureIndex].ptr) +#define setCwPicture(pPicture,p) ((pPicture)->devPrivates[cwPictureIndex].ptr = (pointer) (p)) + +extern int cwPictureIndex; + +extern int cwWindowIndex; + +#define cwWindowPrivate(pWindow) ((pWindow)->devPrivates[cwWindowIndex].ptr) +#define getCwPixmap(pWindow) ((PixmapPtr) cwWindowPrivate(pWindow)) +#define setCwPixmap(pWindow,pPixmap) (cwWindowPrivate(pWindow) = (pointer) (pPixmap)) + +#define cwDrawableIsRedirWindow(pDraw) \ + ((pDraw)->type == DRAWABLE_WINDOW && \ + getCwPixmap((WindowPtr) (pDraw)) != NULL) + +typedef struct { + /* + * screen func wrappers + */ + CloseScreenProcPtr CloseScreen; + GetImageProcPtr GetImage; + GetSpansProcPtr GetSpans; + CreateGCProcPtr CreateGC; + + PaintWindowBackgroundProcPtr PaintWindowBackground; + PaintWindowBorderProcPtr PaintWindowBorder; + CopyWindowProcPtr CopyWindow; + + GetWindowPixmapProcPtr GetWindowPixmap; + SetWindowPixmapProcPtr SetWindowPixmap; + +#ifdef RENDER + DestroyPictureProcPtr DestroyPicture; + ChangePictureClipProcPtr ChangePictureClip; + DestroyPictureClipProcPtr DestroyPictureClip; + + ChangePictureProcPtr ChangePicture; + ValidatePictureProcPtr ValidatePicture; + + CompositeProcPtr Composite; + GlyphsProcPtr Glyphs; + CompositeRectsProcPtr CompositeRects; + + TrapezoidsProcPtr Trapezoids; + TrianglesProcPtr Triangles; + TriStripProcPtr TriStrip; + TriFanProcPtr TriFan; + + RasterizeTrapezoidProcPtr RasterizeTrapezoid; +#endif +} cwScreenRec, *cwScreenPtr; + +extern int cwScreenIndex; + +#define getCwScreen(pScreen) ((cwScreenPtr)(pScreen)->devPrivates[cwScreenIndex].ptr) +#define setCwScreen(pScreen,p) ((cwScreenPtr)(pScreen)->devPrivates[cwScreenIndex].ptr = (p)) + +#define CW_OFFSET_XYPOINTS(ppt, npt) do { \ + DDXPointPtr _ppt = (DDXPointPtr)(ppt); \ + int _i; \ + for (_i = 0; _i < npt; _i++) { \ + _ppt[_i].x += dst_off_x; \ + _ppt[_i].y += dst_off_y; \ + } \ +} while (0) + +#define CW_OFFSET_RECTS(prect, nrect) do { \ + int _i; \ + for (_i = 0; _i < nrect; _i++) { \ + (prect)[_i].x += dst_off_x; \ + (prect)[_i].y += dst_off_y; \ + } \ +} while (0) + +#define CW_OFFSET_ARCS(parc, narc) do { \ + int _i; \ + for (_i = 0; _i < narc; _i++) { \ + (parc)[_i].x += dst_off_x; \ + (parc)[_i].y += dst_off_y; \ + } \ +} while (0) + +#define CW_OFFSET_XY_DST(x, y) do { \ + (x) = (x) + dst_off_x; \ + (y) = (y) + dst_off_y; \ +} while (0) + +#define CW_OFFSET_XY_SRC(x, y) do { \ + (x) = (x) + src_off_x; \ + (y) = (y) + src_off_y; \ +} while (0) + +/* cw.c */ +DrawablePtr +cwGetBackingDrawable(DrawablePtr pDrawable, int *x_off, int *y_off); + +/* cw_render.c */ + +void +cwInitializeRender (ScreenPtr pScreen); + +void +cwFiniRender (ScreenPtr pScreen); + +/* cw.c */ +void +miInitializeCompositeWrapper(ScreenPtr pScreen); diff --git a/miext/cw/cw_ops.c b/miext/cw/cw_ops.c new file mode 100644 index 000000000..f4d6e3478 --- /dev/null +++ b/miext/cw/cw_ops.c @@ -0,0 +1,466 @@ +/* + * Copyright © 2004 Eric Anholt + * + * 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 Eric Anholt not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Eric Anholt makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ERIC ANHOLT 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. + */ +/* $Header$ */ + +#include "gcstruct.h" +#include "cw.h" + +#define SETUP_BACKING_DST(_pDst, _pGC) \ + cwGCPtr pGCPrivate = getCwGC (_pGC); \ + int dst_off_x, dst_off_y; \ + DrawablePtr pBackingDst = cwGetBackingDrawable(pDst, &dst_off_x, \ + &dst_off_y); \ + GCPtr pBackingGC = pGCPrivate->pBackingGC ? pGCPrivate->pBackingGC : _pGC + +#define SETUP_BACKING_SRC(pSrc, pGC) \ + int src_off_x, src_off_y; \ + DrawablePtr pBackingSrc = cwGetBackingDrawable(pSrc, &src_off_x, \ + &src_off_y) + +#define PROLOGUE(pGC) do { \ + pGC->funcs = pGCPrivate->wrapFuncs;\ + pGC->ops = pGCPrivate->wrapOps;\ +} while (0) + +#define EPILOGUE(pGC) do { \ + pGCPrivate->wrapFuncs = (pGC)->funcs; \ + pGCPrivate->wrapOps = (pGC)->ops; \ + (pGC)->funcs = &cwGCFuncs; \ + (pGC)->ops = &cwGCOps; \ +} while (0) + +extern GCFuncs cwGCFuncs; + +/* + * GC ops -- wrap each GC operation with our own function + */ + +static void cwFillSpans(DrawablePtr pDst, GCPtr pGC, int nInit, + DDXPointPtr pptInit, int *pwidthInit, int fSorted); +static void cwSetSpans(DrawablePtr pDst, GCPtr pGC, char *psrc, + DDXPointPtr ppt, int *pwidth, int nspans, int fSorted); +static void cwPutImage(DrawablePtr pDst, GCPtr pGC, int depth, + int x, int y, int w, int h, int leftPad, int format, + char *pBits); +static RegionPtr cwCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, + int srcx, int srcy, int w, int h, + int dstx, int dsty); +static RegionPtr cwCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, + int srcx, int srcy, int w, int h, + int dstx, int dsty, unsigned long plane); +static void cwPolyPoint(DrawablePtr pDst, GCPtr pGC, int mode, int npt, + xPoint *pptInit); +static void cwPolylines(DrawablePtr pDst, GCPtr pGC, int mode, int npt, + DDXPointPtr pptInit); +static void cwPolySegment(DrawablePtr pDst, GCPtr pGC, int nseg, + xSegment *pSegs); +static void cwPolyRectangle(DrawablePtr pDst, GCPtr pGC, + int nrects, xRectangle *pRects); +static void cwPolyArc(DrawablePtr pDst, GCPtr pGC, int narcs, xArc *parcs); +static void cwFillPolygon(DrawablePtr pDst, GCPtr pGC, int shape, int mode, + int count, DDXPointPtr pPts); +static void cwPolyFillRect(DrawablePtr pDst, GCPtr pGC, + int nrectFill, xRectangle *prectInit); +static void cwPolyFillArc(DrawablePtr pDst, GCPtr pGC, + int narcs, xArc *parcs); +static int cwPolyText8(DrawablePtr pDrawable, GCPtr pGC, int x, int y, + int count, char *chars); +static int cwPolyText16(DrawablePtr pDst, GCPtr pGC, int x, int y, + int count, unsigned short *chars); +static void cwImageText8(DrawablePtr pDst, GCPtr pGC, int x, int y, + int count, char *chars); +static void cwImageText16(DrawablePtr pDst, GCPtr pGC, int x, int y, + int count, unsigned short *chars); +static void cwImageGlyphBlt(DrawablePtr pDst, GCPtr pGC, int x, int y, + unsigned int nglyph, CharInfoPtr *ppci, + pointer pglyphBase); +static void cwPolyGlyphBlt(DrawablePtr pDst, GCPtr pGC, int x, int y, + unsigned int nglyph, CharInfoPtr *ppci, + pointer pglyphBase); +static void cwPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDst, + int w, int h, int x, int y); + +GCOps cwGCOps = { + cwFillSpans, + cwSetSpans, + cwPutImage, + cwCopyArea, + cwCopyPlane, + cwPolyPoint, + cwPolylines, + cwPolySegment, + cwPolyRectangle, + cwPolyArc, + cwFillPolygon, + cwPolyFillRect, + cwPolyFillArc, + cwPolyText8, + cwPolyText16, + cwImageText8, + cwImageText16, + cwImageGlyphBlt, + cwPolyGlyphBlt, + cwPushPixels +}; + +static void +cwFillSpans(DrawablePtr pDst, GCPtr pGC, int nspans, DDXPointPtr ppt, + int *pwidth, int fSorted) +{ + SETUP_BACKING_DST(pDst, pGC); + + PROLOGUE(pGC); + + CW_OFFSET_XYPOINTS(ppt, nspans); + + (*pBackingGC->ops->FillSpans)(pBackingDst, pBackingGC, nspans, ppt, + pwidth, fSorted); + + EPILOGUE(pGC); +} + +static void +cwSetSpans(DrawablePtr pDst, GCPtr pGC, char *psrc, DDXPointPtr ppt, + int *pwidth, int nspans, int fSorted) +{ + SETUP_BACKING_DST(pDst, pGC); + + PROLOGUE(pGC); + + CW_OFFSET_XYPOINTS(ppt, nspans); + + (*pBackingGC->ops->SetSpans)(pBackingDst, pBackingGC, psrc, ppt, pwidth, + nspans, fSorted); + + EPILOGUE(pGC); +} + +static void +cwPutImage(DrawablePtr pDst, GCPtr pGC, int depth, int x, int y, int w, int h, + int leftPad, int format, char *pBits) +{ + SETUP_BACKING_DST(pDst, pGC); + + PROLOGUE(pGC); + + CW_OFFSET_XY_DST(x, y); + + (*pBackingGC->ops->PutImage)(pBackingDst, pBackingGC, depth, x, y, w, h, + leftPad, format, pBits); + + EPILOGUE(pGC); +} + +static RegionPtr +cwCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, int srcx, int srcy, + int w, int h, int dstx, int dsty) +{ + int odstx, odsty; + RegionPtr exposed = NULL; + SETUP_BACKING_DST(pDst, pGC); + SETUP_BACKING_SRC(pSrc, pGC); + + PROLOGUE(pGC); + + odstx = dstx; + odsty = dsty; + CW_OFFSET_XY_DST(dstx, dsty); + CW_OFFSET_XY_SRC(srcx, srcy); + + exposed = (*pBackingGC->ops->CopyArea)(pBackingSrc, pBackingDst, + pBackingGC, srcx, srcy, w, h, + dstx, dsty); + + if (exposed != NULL) + REGION_TRANSLATE(pDst->pScreen, exposed, odstx - dstx, odsty - dsty); + + EPILOGUE(pGC); + + return exposed; +} + +static RegionPtr +cwCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, int srcx, int srcy, + int w, int h, int dstx, int dsty, unsigned long plane) +{ + int odstx, odsty; + RegionPtr exposed = NULL; + SETUP_BACKING_DST(pDst, pGC); + SETUP_BACKING_SRC(pSrc, pGC); + + PROLOGUE(pGC); + + odstx = dstx; + odsty = dsty; + CW_OFFSET_XY_DST(dstx, dsty); + CW_OFFSET_XY_SRC(srcx, srcy); + + exposed = (*pBackingGC->ops->CopyPlane)(pBackingSrc, pBackingDst, + pBackingGC, srcx, srcy, w, h, + dstx, dsty, plane); + + if (exposed != NULL) + REGION_TRANSLATE(pDst->pScreen, exposed, odstx - dstx, odsty - dsty); + + EPILOGUE(pGC); + + return exposed; +} + +static void +cwPolyPoint(DrawablePtr pDst, GCPtr pGC, int mode, int npt, xPoint *ppt) +{ + SETUP_BACKING_DST(pDst, pGC); + + PROLOGUE(pGC); + + if (mode == CoordModeOrigin) + CW_OFFSET_XYPOINTS(ppt, npt); + else + CW_OFFSET_XYPOINTS(ppt, 1); + + (*pBackingGC->ops->PolyPoint)(pBackingDst, pBackingGC, mode, npt, ppt); + + EPILOGUE(pGC); +} + +static void +cwPolylines(DrawablePtr pDst, GCPtr pGC, int mode, int npt, DDXPointPtr ppt) +{ + SETUP_BACKING_DST(pDst, pGC); + + PROLOGUE(pGC); + + if (mode == CoordModeOrigin) + CW_OFFSET_XYPOINTS(ppt, npt); + else + CW_OFFSET_XYPOINTS(ppt, 1); + + (*pBackingGC->ops->Polylines)(pBackingDst, pBackingGC, mode, npt, ppt); + + EPILOGUE(pGC); +} + +static void +cwPolySegment(DrawablePtr pDst, GCPtr pGC, int nseg, xSegment *pSegs) +{ + SETUP_BACKING_DST(pDst, pGC); + + PROLOGUE(pGC); + + CW_OFFSET_XYPOINTS(pSegs, nseg * 2); + + (*pBackingGC->ops->PolySegment)(pBackingDst, pBackingGC, nseg, pSegs); + + EPILOGUE(pGC); +} + +static void +cwPolyRectangle(DrawablePtr pDst, GCPtr pGC, int nrects, xRectangle *pRects) +{ + SETUP_BACKING_DST(pDst, pGC); + + PROLOGUE(pGC); + + CW_OFFSET_RECTS(pRects, nrects); + + (*pBackingGC->ops->PolyRectangle)(pBackingDst, pBackingGC, nrects, pRects); + + EPILOGUE(pGC); +} + +static void +cwPolyArc(DrawablePtr pDst, GCPtr pGC, int narcs, xArc *pArcs) +{ + SETUP_BACKING_DST(pDst, pGC); + + PROLOGUE(pGC); + + CW_OFFSET_RECTS(pArcs, narcs); + + (*pBackingGC->ops->PolyArc)(pBackingDst, pBackingGC, narcs, pArcs); + + EPILOGUE(pGC); +} + +static void +cwFillPolygon(DrawablePtr pDst, GCPtr pGC, int shape, int mode, int npt, + DDXPointPtr ppt) +{ + SETUP_BACKING_DST(pDst, pGC); + + PROLOGUE(pGC); + + if (mode == CoordModeOrigin) + CW_OFFSET_XYPOINTS(ppt, npt); + else + CW_OFFSET_XYPOINTS(ppt, 1); + + (*pBackingGC->ops->FillPolygon)(pBackingDst, pBackingGC, shape, mode, npt, + ppt); + + EPILOGUE(pGC); +} + +static void +cwPolyFillRect(DrawablePtr pDst, GCPtr pGC, int nrects, xRectangle *pRects) +{ + SETUP_BACKING_DST(pDst, pGC); + + PROLOGUE(pGC); + + CW_OFFSET_RECTS(pRects, nrects); + + (*pBackingGC->ops->PolyFillRect)(pBackingDst, pBackingGC, nrects, pRects); + + EPILOGUE(pGC); +} + +static void +cwPolyFillArc(DrawablePtr pDst, GCPtr pGC, int narcs, xArc *parcs) +{ + SETUP_BACKING_DST(pDst, pGC); + + PROLOGUE(pGC); + + CW_OFFSET_RECTS(parcs, narcs); + + (*pBackingGC->ops->PolyFillArc)(pBackingDst, pBackingGC, narcs, parcs); + + EPILOGUE(pGC); +} + +static int +cwPolyText8(DrawablePtr pDst, GCPtr pGC, int x, int y, int count, char *chars) +{ + int result; + SETUP_BACKING_DST(pDst, pGC); + + PROLOGUE(pGC); + + CW_OFFSET_XY_DST(x, y); + + result = (*pBackingGC->ops->PolyText8)(pBackingDst, pBackingGC, x, y, + count, chars); + + EPILOGUE(pGC); + + return result; +} + +static int +cwPolyText16(DrawablePtr pDst, GCPtr pGC, int x, int y, int count, + unsigned short *chars) +{ + int result; + SETUP_BACKING_DST(pDst, pGC); + + PROLOGUE(pGC); + + CW_OFFSET_XY_DST(x, y); + + result = (*pBackingGC->ops->PolyText16)(pBackingDst, pBackingGC, x, y, + count, chars); + + EPILOGUE(pGC); + return result; +} + +static void +cwImageText8(DrawablePtr pDst, GCPtr pGC, int x, int y, int count, char *chars) +{ + SETUP_BACKING_DST(pDst, pGC); + + PROLOGUE(pGC); + + CW_OFFSET_XY_DST(x, y); + + (*pBackingGC->ops->ImageText8)(pBackingDst, pBackingGC, x, y, count, + chars); + + EPILOGUE(pGC); +} + +static void +cwImageText16(DrawablePtr pDst, GCPtr pGC, int x, int y, int count, + unsigned short *chars) +{ + SETUP_BACKING_DST(pDst, pGC); + + PROLOGUE(pGC); + + CW_OFFSET_XY_DST(x, y); + + (*pBackingGC->ops->ImageText16)(pBackingDst, pBackingGC, x, y, count, + chars); + + EPILOGUE(pGC); +} + +static void +cwImageGlyphBlt(DrawablePtr pDst, GCPtr pGC, int x, int y, unsigned int nglyph, + CharInfoPtr *ppci, pointer pglyphBase) +{ + SETUP_BACKING_DST(pDst, pGC); + + PROLOGUE(pGC); + + CW_OFFSET_XY_DST(x, y); + + (*pBackingGC->ops->ImageGlyphBlt)(pBackingDst, pBackingGC, x, y, nglyph, + ppci, pglyphBase); + + EPILOGUE(pGC); +} + +static void +cwPolyGlyphBlt(DrawablePtr pDst, GCPtr pGC, int x, int y, unsigned int nglyph, + CharInfoPtr *ppci, pointer pglyphBase) +{ + SETUP_BACKING_DST(pDst, pGC); + + PROLOGUE(pGC); + + CW_OFFSET_XY_DST(x, y); + + (*pBackingGC->ops->PolyGlyphBlt)(pBackingDst, pBackingGC, x, y, nglyph, + ppci, pglyphBase); + + EPILOGUE(pGC); +} + +static void +cwPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDst, int w, int h, + int x, int y) +{ + SETUP_BACKING_DST(pDst, pGC); + + PROLOGUE(pGC); + + CW_OFFSET_XY_DST(x, y); + + (*pBackingGC->ops->PushPixels)(pBackingGC, pBitMap, pBackingDst, w, h, + x, y); + + EPILOGUE(pGC); +} + diff --git a/miext/cw/cw_render.c b/miext/cw/cw_render.c new file mode 100644 index 000000000..f7e361496 --- /dev/null +++ b/miext/cw/cw_render.c @@ -0,0 +1,497 @@ +/* + * Copyright © 2004 Eric Anholt + * + * 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 Eric Anholt not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Eric Anholt makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ERIC ANHOLT 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. + */ +/* $Header$ */ + +#include "gcstruct.h" +#include "windowstr.h" +#include "cw.h" + +#ifdef RENDER + +#define cwPsDecl(pScreen) \ + PictureScreenPtr ps = GetPictureScreen (pScreen); \ + cwScreenPtr pCwScreen = getCwScreen (pScreen) + +#define cwPicturePrivate \ + cwPicturePtr pPicturePrivate = getCwPicture(pPicture) + +#define cwSrcPictureDecl \ + int src_picture_x_off, src_picture_y_off; \ + PicturePtr pBackingSrcPicture = cwGetBackingPicture(pSrcPicture, \ + &src_picture_x_off,\ + &src_picture_y_off) + +#define cwDstPictureDecl \ + int dst_picture_x_off, dst_picture_y_off; \ + PicturePtr pBackingDstPicture = cwGetBackingPicture(pDstPicture, \ + &dst_picture_x_off,\ + &dst_picture_y_off) + +#define cwMskPictureDecl \ + int msk_picture_x_off = 0, msk_picture_y_off = 0; \ + PicturePtr pBackingMskPicture = (!pMskPicture ? 0 : \ + cwGetBackingPicture(pMskPicture, \ + &msk_picture_x_off,\ + &msk_picture_y_off)) + +#define cwPsUnwrap(elt) { \ + ps->elt = pCwScreen->elt; \ +} + +#define cwPsWrap(elt,func) { \ + pCwScreen->elt = ps->elt; \ + ps->elt = func; \ +} + +static cwPicturePtr +cwCreatePicturePrivate (PicturePtr pPicture) +{ + WindowPtr pWindow = (WindowPtr) pPicture->pDrawable; + PixmapPtr pPixmap = getCwPixmap (pWindow); + int error; + cwPicturePtr pPicturePrivate; + + pPicturePrivate = xalloc (sizeof (cwPictureRec)); + if (!pPicturePrivate) + return NULL; + + pPicturePrivate->pBackingPicture = CreatePicture (0, &pPixmap->drawable, + pPicture->pFormat, + 0, 0, serverClient, + &error); + if (!pPicturePrivate->pBackingPicture) + { + xfree (pPicturePrivate); + return NULL; + } + + /* + * Ensure that this serial number does not match the window's + */ + pPicturePrivate->serialNumber = pPixmap->drawable.serialNumber; + pPicturePrivate->stateChanges = (1 << (CPLastBit + 1)) - 1; + + setCwPicture(pPicture, pPicturePrivate); + + return pPicturePrivate; +} + +static void +cwDestroyPicturePrivate (PicturePtr pPicture) +{ + cwPicturePrivate; + + if (pPicturePrivate) + { + if (pPicturePrivate->pBackingPicture) + FreePicture (pPicturePrivate->pBackingPicture, 0); + xfree (pPicturePrivate); + setCwPicture(pPicture, NULL); + } +} + +static PicturePtr +cwGetBackingPicture (PicturePtr pPicture, int *x_off, int *y_off) +{ + cwPicturePrivate; + + if (pPicturePrivate) + { + DrawablePtr pDrawable = pPicture->pDrawable; + WindowPtr pWindow = (WindowPtr) pDrawable; + PixmapPtr pPixmap = getCwPixmap (pWindow); + + *x_off = pDrawable->x - pPixmap->screen_x; + *y_off = pDrawable->y - pPixmap->screen_y; + + return pPicturePrivate->pBackingPicture; + } + else + { + *x_off = *y_off = 0; + return pPicture; + } +} + +static void +cwDestroyPicture (PicturePtr pPicture) +{ + ScreenPtr pScreen = pPicture->pDrawable->pScreen; + cwPsDecl(pScreen); + + cwPsUnwrap(DestroyPicture); + cwDestroyPicturePrivate (pPicture); + (*ps->DestroyPicture) (pPicture); + cwPsWrap(DestroyPicture, cwDestroyPicture); +} + +static void +cwChangePicture (PicturePtr pPicture, Mask mask) +{ + ScreenPtr pScreen = pPicture->pDrawable->pScreen; + cwPsDecl(pScreen); + cwPicturePtr pPicturePrivate = getCwPicture(pPicture); + + cwPsUnwrap(ChangePicture); + (*ps->ChangePicture) (pPicture, mask); + if (pPicturePrivate) + pPicturePrivate->stateChanges |= mask; + cwPsWrap(ChangePicture, cwChangePicture); +} + + +static void +cwValidatePicture (PicturePtr pPicture, + Mask mask) +{ + DrawablePtr pDrawable = pPicture->pDrawable; + ScreenPtr pScreen = pDrawable->pScreen; + cwPsDecl(pScreen); + cwPicturePrivate; + + cwPsUnwrap(ValidatePicture); + + /* + * Must call ValidatePicture to ensure pPicture->pCompositeClip is valid + */ + (*ps->ValidatePicture) (pPicture, mask); + + if (!cwDrawableIsRedirWindow (pDrawable)) + { + if (pPicturePrivate) + cwDestroyPicturePrivate (pPicture); + } + else + { + PicturePtr pBackingPicture; + DrawablePtr pBackingDrawable; + int x_off, y_off; + + pBackingDrawable = cwGetBackingDrawable(pDrawable, &x_off, &y_off); + + if (pPicturePrivate && + pPicturePrivate->pBackingPicture->pDrawable != pBackingDrawable) + { + cwDestroyPicturePrivate (pPicture); + pPicturePrivate = 0; + } + + if (!pPicturePrivate) + { + pPicturePrivate = cwCreatePicturePrivate (pPicture); + if (!pPicturePrivate) + { + cwPsWrap(ValidatePicture, cwValidatePicture); + return; + } + } + + pBackingPicture = pPicturePrivate->pBackingPicture; + + /* + * Always copy transform and filters because there's no + * indication of when they've changed + */ + SetPictureTransform(pBackingPicture, pPicture->transform); + + if (pBackingPicture->filter != pPicture->filter || + pPicture->filter_nparams > 0) + { + char *filter = PictureGetFilterName (pPicture->filter); + + SetPictureFilter(pBackingPicture, + filter, strlen (filter), + pPicture->filter_params, + pPicture->filter_nparams); + } + + pPicturePrivate->stateChanges |= mask; + + if (pPicturePrivate->serialNumber != pDrawable->serialNumber || + (pPicturePrivate->stateChanges & (CPClipXOrigin|CPClipYOrigin|CPClipMask))) + { + SetPictureClipRegion (pBackingPicture, + x_off - pDrawable->x, + y_off - pDrawable->y, + pPicture->pCompositeClip); + + pPicturePrivate->serialNumber = pDrawable->serialNumber; + pPicturePrivate->stateChanges &= ~(CPClipXOrigin | CPClipYOrigin | CPClipMask); + } + + CopyPicture(pPicture, pPicturePrivate->stateChanges, pBackingPicture); + + ValidatePicture (pBackingPicture); + } + cwPsWrap(ValidatePicture, cwValidatePicture); +} + +static void +cwComposite (CARD8 op, + PicturePtr pSrcPicture, + PicturePtr pMskPicture, + PicturePtr pDstPicture, + INT16 xSrc, + INT16 ySrc, + INT16 xMsk, + INT16 yMsk, + INT16 xDst, + INT16 yDst, + CARD16 width, + CARD16 height) +{ + ScreenPtr pScreen = pDstPicture->pDrawable->pScreen; + cwPsDecl(pScreen); + cwSrcPictureDecl; + cwMskPictureDecl; + cwDstPictureDecl; + + cwPsUnwrap(Composite); + (*ps->Composite) (op, pBackingSrcPicture, pBackingMskPicture, pBackingDstPicture, + xSrc + src_picture_x_off, ySrc + src_picture_y_off, + xMsk + msk_picture_x_off, yMsk + msk_picture_y_off, + xDst + dst_picture_x_off, yDst + dst_picture_y_off, + width, height); + cwPsWrap(Composite, cwComposite); +} + +static void +cwGlyphs (CARD8 op, + PicturePtr pSrcPicture, + PicturePtr pDstPicture, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, + int nlists, + GlyphListPtr lists, + GlyphPtr *glyphs) +{ + ScreenPtr pScreen = pDstPicture->pDrawable->pScreen; + cwPsDecl(pScreen); + cwSrcPictureDecl; + cwDstPictureDecl; + + cwPsUnwrap(Glyphs); + if (nlists) + { + lists->xOff += dst_picture_x_off; + lists->yOff += dst_picture_y_off; + } + (*ps->Glyphs) (op, pBackingSrcPicture, pBackingDstPicture, maskFormat, + xSrc + src_picture_x_off, ySrc + src_picture_y_off, + nlists, lists, glyphs); + cwPsWrap(Glyphs, cwGlyphs); +} + +static void +cwCompositeRects (CARD8 op, + PicturePtr pDstPicture, + xRenderColor *color, + int nRect, + xRectangle *rects) +{ + ScreenPtr pScreen = pDstPicture->pDrawable->pScreen; + cwPsDecl(pScreen); + cwDstPictureDecl; + int i; + + cwPsUnwrap(CompositeRects); + for (i = 0; i < nRect; i++) + { + rects[i].x += dst_picture_x_off; + rects[i].y += dst_picture_y_off; + } + (*ps->CompositeRects) (op, pBackingDstPicture, color, nRect, rects); + cwPsWrap(CompositeRects, cwCompositeRects); +} + +static void +cwTrapezoids (CARD8 op, + PicturePtr pSrcPicture, + PicturePtr pDstPicture, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, + int ntrap, + xTrapezoid *traps) +{ + ScreenPtr pScreen = pDstPicture->pDrawable->pScreen; + cwPsDecl(pScreen); + cwSrcPictureDecl; + cwDstPictureDecl; + int i; + + cwPsUnwrap(Trapezoids); + if (dst_picture_x_off || dst_picture_y_off) { + for (i = 0; i < ntrap; i++) + { + traps[i].top += dst_picture_y_off << 16; + traps[i].bottom += dst_picture_y_off << 16; + traps[i].left.p1.x += dst_picture_x_off << 16; + traps[i].left.p1.y += dst_picture_y_off << 16; + traps[i].left.p2.x += dst_picture_x_off << 16; + traps[i].left.p2.y += dst_picture_y_off << 16; + traps[i].right.p1.x += dst_picture_x_off << 16; + traps[i].right.p1.y += dst_picture_y_off << 16; + traps[i].right.p2.x += dst_picture_x_off << 16; + traps[i].right.p2.y += dst_picture_y_off << 16; + } + } + (*ps->Trapezoids) (op, pBackingSrcPicture, pBackingDstPicture, maskFormat, + xSrc + src_picture_x_off, ySrc + src_picture_y_off, + ntrap, traps); + cwPsWrap(Trapezoids, cwTrapezoids); +} + +static void +cwTriangles (CARD8 op, + PicturePtr pSrcPicture, + PicturePtr pDstPicture, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, + int ntri, + xTriangle *tris) +{ + ScreenPtr pScreen = pDstPicture->pDrawable->pScreen; + cwPsDecl(pScreen); + cwSrcPictureDecl; + cwDstPictureDecl; + int i; + + cwPsUnwrap(Triangles); + if (dst_picture_x_off || dst_picture_y_off) { + for (i = 0; i < ntri; i++) + { + tris[i].p1.x += dst_picture_x_off << 16; + tris[i].p1.y += dst_picture_y_off << 16; + tris[i].p2.x += dst_picture_x_off << 16; + tris[i].p2.y += dst_picture_y_off << 16; + tris[i].p3.x += dst_picture_x_off << 16; + tris[i].p3.y += dst_picture_y_off << 16; + } + } + (*ps->Triangles) (op, pBackingSrcPicture, pBackingDstPicture, maskFormat, + xSrc + src_picture_x_off, ySrc + src_picture_y_off, + ntri, tris); + cwPsWrap(Triangles, cwTriangles); +} + +static void +cwTriStrip (CARD8 op, + PicturePtr pSrcPicture, + PicturePtr pDstPicture, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, + int npoint, + xPointFixed *points) +{ + ScreenPtr pScreen = pDstPicture->pDrawable->pScreen; + cwPsDecl(pScreen); + cwSrcPictureDecl; + cwDstPictureDecl; + int i; + + cwPsUnwrap(TriStrip); + if (dst_picture_x_off || dst_picture_y_off) { + for (i = 0; i < npoint; i++) + { + points[i].x += dst_picture_x_off << 16; + points[i].y += dst_picture_y_off << 16; + } + } + (*ps->TriStrip) (op, pBackingSrcPicture, pBackingDstPicture, maskFormat, + xSrc + src_picture_x_off, ySrc + src_picture_y_off, + npoint, points); + cwPsWrap(TriStrip, cwTriStrip); +} + +static void +cwTriFan (CARD8 op, + PicturePtr pSrcPicture, + PicturePtr pDstPicture, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, + int npoint, + xPointFixed *points) +{ + ScreenPtr pScreen = pDstPicture->pDrawable->pScreen; + cwPsDecl(pScreen); + cwSrcPictureDecl; + cwDstPictureDecl; + int i; + + cwPsUnwrap(TriFan); + if (dst_picture_x_off || dst_picture_y_off) { + for (i = 0; i < npoint; i++) + { + points[i].x += dst_picture_x_off << 16; + points[i].y += dst_picture_y_off << 16; + } + } + (*ps->TriFan) (op, pBackingSrcPicture, pBackingDstPicture, maskFormat, + xSrc + src_picture_x_off, ySrc + src_picture_y_off, + npoint, points); + cwPsWrap(TriFan, cwTriFan); +} + +void +cwInitializeRender (ScreenPtr pScreen) +{ + cwPsDecl (pScreen); + + cwPsWrap(DestroyPicture, cwDestroyPicture); + cwPsWrap(ChangePicture, cwChangePicture); + cwPsWrap(ValidatePicture, cwValidatePicture); + cwPsWrap(Composite, cwComposite); + cwPsWrap(Glyphs, cwGlyphs); + cwPsWrap(CompositeRects, cwCompositeRects); + cwPsWrap(Trapezoids, cwTrapezoids); + cwPsWrap(Triangles, cwTriangles); + cwPsWrap(TriStrip, cwTriStrip); + cwPsWrap(TriFan, cwTriFan); + /* There is no need to wrap AddTraps as far as we can tell. AddTraps can + * only be done on alpha-only pictures, and we won't be getting + * alpha-only window pictures, so there's no need to translate. + */ +} + +void +cwFiniRender (ScreenPtr pScreen) +{ + cwPsDecl (pScreen); + + cwPsUnwrap(DestroyPicture); + cwPsUnwrap(ChangePicture); + cwPsUnwrap(ValidatePicture); + cwPsUnwrap(Composite); + cwPsUnwrap(Glyphs); + cwPsUnwrap(CompositeRects); + cwPsUnwrap(Trapezoids); + cwPsUnwrap(Triangles); + cwPsUnwrap(TriStrip); + cwPsUnwrap(TriFan); +} + +#endif /* RENDER */ diff --git a/miext/damage/damage.c b/miext/damage/damage.c new file mode 100755 index 000000000..963780f70 --- /dev/null +++ b/miext/damage/damage.c @@ -0,0 +1,1933 @@ +/* + * $Id$ + * + * Copyright © 2003 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 <X11/X.h> +#include "scrnintstr.h" +#include "windowstr.h" +#include "font.h" +#include "dixfontstr.h" +#include "fontstruct.h" +#include "mi.h" +#include "regionstr.h" +#include "globals.h" +#include "gcstruct.h" +#include "damage.h" +#include "damagestr.h" +#ifdef COMPOSITE +#include "cw.h" +#endif + +#define wrap(priv, real, mem, func) {\ + priv->mem = real->mem; \ + real->mem = func; \ +} + +#define unwrap(priv, real, mem) {\ + real->mem = priv->mem; \ +} + +#define BOX_SAME(a,b) \ + ((a)->x1 == (b)->x1 && \ + (a)->y1 == (b)->y1 && \ + (a)->x2 == (b)->x2 && \ + (a)->y2 == (b)->y2) + +#define DAMAGE_VALIDATE_ENABLE 0 +#define DAMAGE_DEBUG_ENABLE 0 +#if DAMAGE_DEBUG_ENABLE +#define DAMAGE_DEBUG(x) ErrorF x +#else +#define DAMAGE_DEBUG(x) +#endif + +#define getPixmapDamageRef(pPixmap) \ + ((DamagePtr *) &(pPixmap->devPrivates[damagePixPrivateIndex].ptr)) + +#define pixmapDamage(pPixmap) damagePixPriv(pPixmap) + +static DamagePtr * +getDrawableDamageRef (DrawablePtr pDrawable) +{ + PixmapPtr pPixmap; + + if (pDrawable->type == DRAWABLE_WINDOW) + { + ScreenPtr pScreen = pDrawable->pScreen; + + pPixmap = 0; + if (pScreen->GetWindowPixmap +#ifdef ROOTLESS_WORKAROUND + && ((WindowPtr)pDrawable)->viewable +#endif + ) + pPixmap = (*pScreen->GetWindowPixmap) ((WindowPtr)pDrawable); + + if (!pPixmap) + { + damageScrPriv(pScreen); + + return &pScrPriv->pScreenDamage; + } + } + else + pPixmap = (PixmapPtr) pDrawable; + return getPixmapDamageRef (pPixmap); +} + +#define getDrawableDamage(pDrawable) (*getDrawableDamageRef (pDrawable)) +#define getWindowDamage(pWin) getDrawableDamage(&(pWin)->drawable) + +#define drawableDamage(pDrawable) \ + DamagePtr pDamage = getDrawableDamage(pDrawable) + +#define windowDamage(pWin) drawableDamage(&(pWin)->drawable) + +#define winDamageRef(pWindow) \ + DamagePtr *pPrev = (DamagePtr *) \ + &(pWindow->devPrivates[damageWinPrivateIndex].ptr) + +#if DAMAGE_DEBUG_ENABLE +static void +_damageDamageRegion (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip, char *where) +#define damageDamageRegion(d,r,c) _damageDamageRegion(d,r,c,__FUNCTION__) +#else +static void +damageDamageRegion (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip) +#endif +{ + ScreenPtr pScreen = pDrawable->pScreen; + damageScrPriv(pScreen); + drawableDamage(pDrawable); + DamagePtr pNext; + RegionPtr pClip; + RegionRec clippedRec; + RegionPtr pDamageRegion; + RegionRec pixClip; + Bool was_empty; + RegionRec tmpRegion; + BoxRec tmpBox; + int draw_x, draw_y; +#ifdef COMPOSITE + int screen_x = 0, screen_y = 0; +#endif + + /* short circuit for empty regions */ + if (!REGION_NOTEMPTY(pScreen, pRegion)) + return; + +#ifdef COMPOSITE + /* + * When drawing to a pixmap which is storing window contents, + * the region presented is in pixmap relative coordinates which + * need to be converted to screen relative coordinates + */ + if (pDrawable->type != DRAWABLE_WINDOW) + { + screen_x = ((PixmapPtr) pDrawable)->screen_x - pDrawable->x; + screen_y = ((PixmapPtr) pDrawable)->screen_y - pDrawable->y; + } + if (screen_x || screen_y) + REGION_TRANSLATE (pScreen, pRegion, screen_x, screen_y); +#endif + + REGION_NULL (pScreen, &clippedRec); + for (; pDamage; pDamage = pNext) + { + pNext = pDamage->pNext; + /* + * Check for internal damage and don't send events + */ + if (pScrPriv->internalLevel > 0 && !pDamage->isInternal) + { + DAMAGE_DEBUG (("non internal damage, skipping at %d\n", + pScrPriv->internalLevel)); + continue; + } + /* + * Check for unrealized windows + */ + if (pDamage->pDrawable->type == DRAWABLE_WINDOW && + !((WindowPtr) (pDamage->pDrawable))->realized) + { +#if 0 + DAMAGE_DEBUG (("damage while window unrealized\n")); +#endif + continue; + } + + draw_x = pDamage->pDrawable->x; + draw_y = pDamage->pDrawable->y; +#ifdef COMPOSITE + /* + * Need to move everyone to screen coordinates + * XXX what about off-screen pixmaps with non-zero x/y? + */ + if (pDamage->pDrawable->type != DRAWABLE_WINDOW) + { + draw_x += ((PixmapPtr) pDamage->pDrawable)->screen_x; + draw_y += ((PixmapPtr) pDamage->pDrawable)->screen_y; + } +#endif + + /* + * Clip against border or pixmap bounds + */ + + pDamageRegion = pRegion; + if (clip || pDamage->pDrawable != pDrawable) + { + pDamageRegion = &clippedRec; + if (pDamage->pDrawable->type == DRAWABLE_WINDOW) + pClip = &((WindowPtr)(pDamage->pDrawable))->borderClip; + else + { + BoxRec box; + box.x1 = draw_x; + box.y1 = draw_y; + box.x2 = draw_x + pDamage->pDrawable->width; + box.y2 = draw_y + pDamage->pDrawable->height; + REGION_INIT(pScreen, &pixClip, &box, 1); + pClip = &pixClip; + } + REGION_INTERSECT (pScreen, pDamageRegion, pRegion, pClip); + /* + * Short circuit empty results + */ + if (!REGION_NOTEMPTY(pScreen, pDamageRegion)) + continue; + } + + DAMAGE_DEBUG (("%s %d x %d +%d +%d (target 0x%lx monitor 0x%lx)\n", + where, + pDamageRegion->extents.x2 - pDamageRegion->extents.x1, + pDamageRegion->extents.y2 - pDamageRegion->extents.y1, + pDamageRegion->extents.x1, pDamageRegion->extents.y1, + pDrawable->id, pDamage->pDrawable->id)); + + /* + * Move region to target coordinate space + */ + if (draw_x || draw_y) + REGION_TRANSLATE (pScreen, pDamageRegion, -draw_x, -draw_y); + + switch (pDamage->damageLevel) { + case DamageReportRawRegion: + (*pDamage->damageReport) (pDamage, pDamageRegion, pDamage->closure); + break; + case DamageReportDeltaRegion: + REGION_NULL (pScreen, &tmpRegion); + REGION_SUBTRACT (pScreen, &tmpRegion, pDamageRegion, &pDamage->damage); + if (REGION_NOTEMPTY (pScreen, &tmpRegion)) + { + REGION_UNION(pScreen, &pDamage->damage, + &pDamage->damage, pDamageRegion); + (*pDamage->damageReport) (pDamage, &tmpRegion, pDamage->closure); + } + break; + case DamageReportBoundingBox: + tmpBox = *REGION_EXTENTS (pScreen, &pDamage->damage); + REGION_UNION(pScreen, &pDamage->damage, + &pDamage->damage, pDamageRegion); + if (!BOX_SAME (&tmpBox, REGION_EXTENTS (pScreen, &pDamage->damage))) + (*pDamage->damageReport) (pDamage, &pDamage->damage, pDamage->closure); + break; + case DamageReportNonEmpty: + was_empty = !REGION_NOTEMPTY(pScreen, &pDamage->damage); + REGION_UNION(pScreen, &pDamage->damage, &pDamage->damage, + pDamageRegion); + if (was_empty && REGION_NOTEMPTY(pScreen, &pDamage->damage)) + (*pDamage->damageReport) (pDamage, &pDamage->damage, pDamage->closure); + break; + case DamageReportNone: + REGION_UNION(pScreen, &pDamage->damage, &pDamage->damage, + pDamageRegion); + break; + } + /* + * translate original region back + */ + if (pDamageRegion == pRegion && (draw_x || draw_y)) + REGION_TRANSLATE (pScreen, pDamageRegion, draw_x, draw_y); + } +#ifdef COMPOSITE + if (screen_x || screen_y) + REGION_TRANSLATE (pScreen, pRegion, -screen_x, -screen_y); +#endif + + REGION_UNINIT (pScreen, &clippedRec); +} + +#if DAMAGE_DEBUG_ENABLE +#define damageDamageBox(d,b) _damageDamageBox(d,b,__FUNCTION__) +static void +_damageDamageBox (DrawablePtr pDrawable, BoxPtr pBox, char *where) +#else +static void +damageDamageBox (DrawablePtr pDrawable, BoxPtr pBox) +#endif +{ + RegionRec region; + + REGION_INIT (pDrawable->pScreen, ®ion, pBox, 1); +#if DAMAGE_DEBUG_ENABLE + _damageDamageRegion (pDrawable, ®ion, TRUE, where); +#else + damageDamageRegion (pDrawable, ®ion, TRUE); +#endif + REGION_UNINIT (pDrawable->pScreen, ®ion); +} + +static void damageValidateGC(GCPtr, unsigned long, DrawablePtr); +static void damageChangeGC(GCPtr, unsigned long); +static void damageCopyGC(GCPtr, unsigned long, GCPtr); +static void damageDestroyGC(GCPtr); +static void damageChangeClip(GCPtr, int, pointer, int); +static void damageDestroyClip(GCPtr); +static void damageCopyClip(GCPtr, GCPtr); + +GCFuncs damageGCFuncs = { + damageValidateGC, damageChangeGC, damageCopyGC, damageDestroyGC, + damageChangeClip, damageDestroyClip, damageCopyClip +}; + +extern GCOps damageGCOps; + +static Bool +damageCreateGC(GCPtr pGC) +{ + ScreenPtr pScreen = pGC->pScreen; + damageScrPriv(pScreen); + damageGCPriv(pGC); + Bool ret; + + pGC->pCompositeClip = 0; + unwrap (pScrPriv, pScreen, CreateGC); + if((ret = (*pScreen->CreateGC) (pGC))) { + pGCPriv->ops = NULL; + pGCPriv->funcs = pGC->funcs; + pGC->funcs = &damageGCFuncs; + } + wrap (pScrPriv, pScreen, CreateGC, damageCreateGC); + + return ret; +} + +#ifdef NOTUSED +static void +damageWrapGC (GCPtr pGC) +{ + damageGCPriv(pGC); + + pGCPriv->ops = NULL; + pGCPriv->funcs = pGC->funcs; + pGC->funcs = &damageGCFuncs; +} + +static void +damageUnwrapGC (GCPtr pGC) +{ + damageGCPriv(pGC); + + pGC->funcs = pGCPriv->funcs; + if (pGCPriv->ops) + pGC->ops = pGCPriv->ops; +} +#endif + +#define DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable) \ + damageGCPriv(pGC); \ + GCFuncs *oldFuncs = pGC->funcs; \ + unwrap(pGCPriv, pGC, funcs); \ + unwrap(pGCPriv, pGC, ops); \ + +#define DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable) \ + wrap(pGCPriv, pGC, funcs, oldFuncs); \ + wrap(pGCPriv, pGC, ops, &damageGCOps) + +#define DAMAGE_GC_FUNC_PROLOGUE(pGC) \ + damageGCPriv(pGC); \ + unwrap(pGCPriv, pGC, funcs); \ + if (pGCPriv->ops) unwrap(pGCPriv, pGC, ops) + +#define DAMAGE_GC_FUNC_EPILOGUE(pGC) \ + wrap(pGCPriv, pGC, funcs, &damageGCFuncs); \ + if (pGCPriv->ops) wrap(pGCPriv, pGC, ops, &damageGCOps) + +static void +damageValidateGC(GCPtr pGC, + unsigned long changes, + DrawablePtr pDrawable) +{ + DAMAGE_GC_FUNC_PROLOGUE (pGC); + (*pGC->funcs->ValidateGC)(pGC, changes, pDrawable); + pGCPriv->ops = pGC->ops; /* just so it's not NULL */ + DAMAGE_GC_FUNC_EPILOGUE (pGC); +} + +static void +damageDestroyGC(GCPtr pGC) +{ + DAMAGE_GC_FUNC_PROLOGUE (pGC); + (*pGC->funcs->DestroyGC)(pGC); + DAMAGE_GC_FUNC_EPILOGUE (pGC); +} + +static void +damageChangeGC (GCPtr pGC, + unsigned long mask) +{ + DAMAGE_GC_FUNC_PROLOGUE (pGC); + (*pGC->funcs->ChangeGC) (pGC, mask); + DAMAGE_GC_FUNC_EPILOGUE (pGC); +} + +static void +damageCopyGC (GCPtr pGCSrc, + unsigned long mask, + GCPtr pGCDst) +{ + DAMAGE_GC_FUNC_PROLOGUE (pGCDst); + (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst); + DAMAGE_GC_FUNC_EPILOGUE (pGCDst); +} + +static void +damageChangeClip (GCPtr pGC, + int type, + pointer pvalue, + int nrects) +{ + DAMAGE_GC_FUNC_PROLOGUE (pGC); + (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects); + DAMAGE_GC_FUNC_EPILOGUE (pGC); +} + +static void +damageCopyClip(GCPtr pgcDst, GCPtr pgcSrc) +{ + DAMAGE_GC_FUNC_PROLOGUE (pgcDst); + (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc); + DAMAGE_GC_FUNC_EPILOGUE (pgcDst); +} + +static void +damageDestroyClip(GCPtr pGC) +{ + DAMAGE_GC_FUNC_PROLOGUE (pGC); + (* pGC->funcs->DestroyClip)(pGC); + DAMAGE_GC_FUNC_EPILOGUE (pGC); +} + +#define TRIM_BOX(box, pGC) if (pGC->pCompositeClip) { \ + BoxPtr extents = &pGC->pCompositeClip->extents;\ + if(box.x1 < extents->x1) box.x1 = extents->x1; \ + if(box.x2 > extents->x2) box.x2 = extents->x2; \ + if(box.y1 < extents->y1) box.y1 = extents->y1; \ + if(box.y2 > extents->y2) box.y2 = extents->y2; \ + } + +#define TRANSLATE_BOX(box, pDrawable) { \ + box.x1 += pDrawable->x; \ + box.x2 += pDrawable->x; \ + box.y1 += pDrawable->y; \ + box.y2 += pDrawable->y; \ + } + +#define TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC) { \ + TRANSLATE_BOX(box, pDrawable); \ + TRIM_BOX(box, pGC); \ + } + +#define BOX_NOT_EMPTY(box) \ + (((box.x2 - box.x1) > 0) && ((box.y2 - box.y1) > 0)) + +#define checkGCDamage(d,g) (getDrawableDamage(d) && \ + (!g->pCompositeClip ||\ + REGION_NOTEMPTY(d->pScreen, \ + g->pCompositeClip))) + +#ifdef RENDER + +#define TRIM_PICTURE_BOX(box, pDst) { \ + BoxPtr extents = &pDst->pCompositeClip->extents;\ + if(box.x1 < extents->x1) box.x1 = extents->x1; \ + if(box.x2 > extents->x2) box.x2 = extents->x2; \ + if(box.y1 < extents->y1) box.y1 = extents->y1; \ + if(box.y2 > extents->y2) box.y2 = extents->y2; \ + } + +#define checkPictureDamage(p) (getDrawableDamage(p->pDrawable) && \ + REGION_NOTEMPTY(pScreen, p->pCompositeClip)) + +static void +damageComposite (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; + PictureScreenPtr ps = GetPictureScreen(pScreen); + damageScrPriv(pScreen); + + if (checkPictureDamage (pDst)) + { + BoxRec box; + + box.x1 = xDst + pDst->pDrawable->x; + box.y1 = yDst + pDst->pDrawable->y; + box.x2 = box.x1 + width; + box.y2 = box.y1 + height; + TRIM_PICTURE_BOX(box, pDst); + if (BOX_NOT_EMPTY(box)) + damageDamageBox (pDst->pDrawable, &box); + } + unwrap (pScrPriv, ps, Composite); + (*ps->Composite) (op, + pSrc, + pMask, + pDst, + xSrc, + ySrc, + xMask, + yMask, + xDst, + yDst, + width, + height); + wrap (pScrPriv, ps, Composite, damageComposite); +} + +static void +damageGlyphs (CARD8 op, + PicturePtr pSrc, + PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, + INT16 ySrc, + int nlist, + GlyphListPtr list, + GlyphPtr *glyphs) +{ + ScreenPtr pScreen = pDst->pDrawable->pScreen; + PictureScreenPtr ps = GetPictureScreen(pScreen); + damageScrPriv(pScreen); + + if (checkPictureDamage (pDst)) + { + int nlistTmp = nlist; + GlyphListPtr listTmp = list; + GlyphPtr *glyphsTmp = glyphs; + int x, y; + int n; + GlyphPtr glyph; + BoxRec box; + int x1, y1, x2, y2; + + box.x1 = 32767; + box.y1 = 32767; + box.x2 = -32767; + box.y2 = -32767; + x = pDst->pDrawable->x; + y = pDst->pDrawable->y; + while (nlistTmp--) + { + x += listTmp->xOff; + y += listTmp->yOff; + n = listTmp->len; + while (n--) + { + glyph = *glyphsTmp++; + x1 = x - glyph->info.x; + y1 = y - glyph->info.y; + x2 = x1 + glyph->info.width; + y2 = y1 + glyph->info.height; + if (x1 < box.x1) + box.x1 = x1; + if (y1 < box.y1) + box.y1 = y1; + if (x2 > box.x2) + box.x2 = x2; + if (y2 > box.y2) + box.y2 = y2; + x += glyph->info.xOff; + y += glyph->info.yOff; + } + listTmp++; + } + TRIM_PICTURE_BOX (box, pDst); + if (BOX_NOT_EMPTY(box)) + damageDamageBox (pDst->pDrawable, &box); + } + unwrap (pScrPriv, ps, Glyphs); + (*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs); + wrap (pScrPriv, ps, Glyphs, damageGlyphs); +} +#endif + +/**********************************************************/ + + +static void +damageFillSpans(DrawablePtr pDrawable, + GC *pGC, + int npt, + DDXPointPtr ppt, + int *pwidth, + int fSorted) +{ + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); + + if (npt && checkGCDamage (pDrawable, pGC)) + { + int nptTmp = npt; + DDXPointPtr pptTmp = ppt; + int *pwidthTmp = pwidth; + BoxRec box; + + box.x1 = pptTmp->x; + box.x2 = box.x1 + *pwidthTmp; + box.y2 = box.y1 = pptTmp->y; + + while(--nptTmp) + { + pptTmp++; + pwidthTmp++; + if(box.x1 > pptTmp->x) box.x1 = pptTmp->x; + if(box.x2 < (pptTmp->x + *pwidthTmp)) + box.x2 = pptTmp->x + *pwidthTmp; + if(box.y1 > pptTmp->y) box.y1 = pptTmp->y; + else if(box.y2 < pptTmp->y) box.y2 = pptTmp->y; + } + + box.y2++; + + if(!pGC->miTranslate) { + TRANSLATE_BOX(box, pDrawable); + } + TRIM_BOX(box, pGC); + + if(BOX_NOT_EMPTY(box)) + damageDamageBox (pDrawable, &box); + } + + (*pGC->ops->FillSpans)(pDrawable, pGC, npt, ppt, pwidth, fSorted); + + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); +} + +static void +damageSetSpans(DrawablePtr pDrawable, + GCPtr pGC, + char *pcharsrc, + DDXPointPtr ppt, + int *pwidth, + int npt, + int fSorted) +{ + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); + + if (npt && checkGCDamage (pDrawable, pGC)) + { + DDXPointPtr pptTmp = ppt; + int *pwidthTmp = pwidth; + int nptTmp = npt; + BoxRec box; + + box.x1 = pptTmp->x; + box.x2 = box.x1 + *pwidthTmp; + box.y2 = box.y1 = pptTmp->y; + + while(--nptTmp) + { + pptTmp++; + pwidthTmp++; + if(box.x1 > pptTmp->x) box.x1 = pptTmp->x; + if(box.x2 < (pptTmp->x + *pwidthTmp)) + box.x2 = pptTmp->x + *pwidthTmp; + if(box.y1 > pptTmp->y) box.y1 = pptTmp->y; + else if(box.y2 < pptTmp->y) box.y2 = pptTmp->y; + } + + box.y2++; + + if(!pGC->miTranslate) { + TRANSLATE_BOX(box, pDrawable); + } + TRIM_BOX(box, pGC); + + if(BOX_NOT_EMPTY(box)) + damageDamageBox (pDrawable, &box); + } + (*pGC->ops->SetSpans)(pDrawable, pGC, pcharsrc, ppt, pwidth, npt, fSorted); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); +} + +static void +damagePutImage(DrawablePtr pDrawable, + GCPtr pGC, + int depth, + int x, + int y, + int w, + int h, + int leftPad, + int format, + char *pImage) +{ + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); + if (checkGCDamage (pDrawable, pGC)) + { + BoxRec box; + + box.x1 = x + pDrawable->x; + box.x2 = box.x1 + w; + box.y1 = y + pDrawable->y; + box.y2 = box.y1 + h; + + TRIM_BOX(box, pGC); + if(BOX_NOT_EMPTY(box)) + damageDamageBox (pDrawable, &box); + } + (*pGC->ops->PutImage)(pDrawable, pGC, depth, x, y, w, h, + leftPad, format, pImage); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); +} + +static RegionPtr +damageCopyArea(DrawablePtr pSrc, + DrawablePtr pDst, + GC *pGC, + int srcx, + int srcy, + int width, + int height, + int dstx, + int dsty) +{ + RegionPtr ret; + DAMAGE_GC_OP_PROLOGUE(pGC, pDst); + + /* The driver will only call SourceValidate() when pSrc != pDst, + * but the software sprite (misprite.c) always need to know when a + * drawable is copied so it can remove the sprite. See #1030. */ + if ((pSrc == pDst) && pSrc->pScreen->SourceValidate) + (*pSrc->pScreen->SourceValidate) (pSrc, srcx, srcy, width, height); + + if (checkGCDamage (pDst, pGC)) + { + BoxRec box; + + box.x1 = dstx + pDst->x; + box.x2 = box.x1 + width; + box.y1 = dsty + pDst->y; + box.y2 = box.y1 + height; + + TRIM_BOX(box, pGC); + if(BOX_NOT_EMPTY(box)) + damageDamageBox (pDst, &box); + } + + ret = (*pGC->ops->CopyArea)(pSrc, pDst, + pGC, srcx, srcy, width, height, dstx, dsty); + DAMAGE_GC_OP_EPILOGUE(pGC, pDst); + return ret; +} + +static RegionPtr +damageCopyPlane(DrawablePtr pSrc, + DrawablePtr pDst, + GCPtr pGC, + int srcx, + int srcy, + int width, + int height, + int dstx, + int dsty, + unsigned long bitPlane) +{ + RegionPtr ret; + DAMAGE_GC_OP_PROLOGUE(pGC, pDst); + + /* The driver will only call SourceValidate() when pSrc != pDst, + * but the software sprite (misprite.c) always need to know when a + * drawable is copied so it can remove the sprite. See #1030. */ + if ((pSrc == pDst) && pSrc->pScreen->SourceValidate) + (*pSrc->pScreen->SourceValidate) (pSrc, srcx, srcy, width, height); + + if (checkGCDamage (pDst, pGC)) + { + BoxRec box; + + box.x1 = dstx + pDst->x; + box.x2 = box.x1 + width; + box.y1 = dsty + pDst->y; + box.y2 = box.y1 + height; + + TRIM_BOX(box, pGC); + if(BOX_NOT_EMPTY(box)) + damageDamageBox (pDst, &box); + } + + ret = (*pGC->ops->CopyPlane)(pSrc, pDst, + pGC, srcx, srcy, width, height, dstx, dsty, bitPlane); + DAMAGE_GC_OP_EPILOGUE(pGC, pDst); + return ret; +} + +static void +damagePolyPoint(DrawablePtr pDrawable, + GCPtr pGC, + int mode, + int npt, + xPoint *ppt) +{ + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); + + if (npt && checkGCDamage (pDrawable, pGC)) + { + BoxRec box; + int nptTmp = npt; + xPoint *pptTmp = ppt; + + box.x2 = box.x1 = pptTmp->x; + box.y2 = box.y1 = pptTmp->y; + + /* this could be slow if the points were spread out */ + + while(--nptTmp) + { + pptTmp++; + if(box.x1 > pptTmp->x) box.x1 = pptTmp->x; + else if(box.x2 < pptTmp->x) box.x2 = pptTmp->x; + if(box.y1 > pptTmp->y) box.y1 = pptTmp->y; + else if(box.y2 < pptTmp->y) box.y2 = pptTmp->y; + } + + box.x2++; + box.y2++; + + TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC); + if(BOX_NOT_EMPTY(box)) + damageDamageBox (pDrawable, &box); + } + (*pGC->ops->PolyPoint)(pDrawable, pGC, mode, npt, ppt); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); +} + +static void +damagePolylines(DrawablePtr pDrawable, + GCPtr pGC, + int mode, + int npt, + DDXPointPtr ppt) +{ + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); + + if (npt && checkGCDamage (pDrawable, pGC)) + { + int nptTmp = npt; + DDXPointPtr pptTmp = ppt; + BoxRec box; + int extra = pGC->lineWidth >> 1; + + box.x2 = box.x1 = pptTmp->x; + box.y2 = box.y1 = pptTmp->y; + + if(nptTmp > 1) + { + if(pGC->joinStyle == JoinMiter) + extra = 6 * pGC->lineWidth; + else if(pGC->capStyle == CapProjecting) + extra = pGC->lineWidth; + } + + if(mode == CoordModePrevious) + { + int x = box.x1; + int y = box.y1; + while(--nptTmp) + { + pptTmp++; + x += pptTmp->x; + y += pptTmp->y; + if(box.x1 > x) box.x1 = x; + else if(box.x2 < x) box.x2 = x; + if(box.y1 > y) box.y1 = y; + else if(box.y2 < y) box.y2 = y; + } + } + else + { + while(--nptTmp) + { + pptTmp++; + if(box.x1 > pptTmp->x) box.x1 = pptTmp->x; + else if(box.x2 < pptTmp->x) box.x2 = pptTmp->x; + if(box.y1 > pptTmp->y) box.y1 = pptTmp->y; + else if(box.y2 < pptTmp->y) box.y2 = pptTmp->y; + } + } + + box.x2++; + box.y2++; + + if(extra) + { + box.x1 -= extra; + box.x2 += extra; + box.y1 -= extra; + box.y2 += extra; + } + + TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC); + if(BOX_NOT_EMPTY(box)) + damageDamageBox (pDrawable, &box); + } + (*pGC->ops->Polylines)(pDrawable, pGC, mode, npt, ppt); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); +} + +static void +damagePolySegment(DrawablePtr pDrawable, + GCPtr pGC, + int nSeg, + xSegment *pSeg) +{ + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); + + if (nSeg && checkGCDamage (pDrawable, pGC)) + { + BoxRec box; + int extra = pGC->lineWidth; + int nsegTmp = nSeg; + xSegment *pSegTmp = pSeg; + + if(pGC->capStyle != CapProjecting) + extra >>= 1; + + if(pSegTmp->x2 > pSegTmp->x1) { + box.x1 = pSegTmp->x1; + box.x2 = pSegTmp->x2; + } else { + box.x2 = pSegTmp->x1; + box.x1 = pSegTmp->x2; + } + + if(pSegTmp->y2 > pSegTmp->y1) { + box.y1 = pSegTmp->y1; + box.y2 = pSegTmp->y2; + } else { + box.y2 = pSegTmp->y1; + box.y1 = pSegTmp->y2; + } + + while(--nsegTmp) + { + pSegTmp++; + if(pSegTmp->x2 > pSegTmp->x1) + { + if(pSegTmp->x1 < box.x1) box.x1 = pSegTmp->x1; + if(pSegTmp->x2 > box.x2) box.x2 = pSegTmp->x2; + } + else + { + if(pSegTmp->x2 < box.x1) box.x1 = pSegTmp->x2; + if(pSegTmp->x1 > box.x2) box.x2 = pSegTmp->x1; + } + if(pSegTmp->y2 > pSegTmp->y1) + { + if(pSegTmp->y1 < box.y1) box.y1 = pSegTmp->y1; + if(pSegTmp->y2 > box.y2) box.y2 = pSegTmp->y2; + } + else + { + if(pSegTmp->y2 < box.y1) box.y1 = pSegTmp->y2; + if(pSegTmp->y1 > box.y2) box.y2 = pSegTmp->y1; + } + } + + box.x2++; + box.y2++; + + if(extra) + { + box.x1 -= extra; + box.x2 += extra; + box.y1 -= extra; + box.y2 += extra; + } + + TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC); + if(BOX_NOT_EMPTY(box)) + damageDamageBox (pDrawable, &box); + } + (*pGC->ops->PolySegment)(pDrawable, pGC, nSeg, pSeg); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); +} + +static void +damagePolyRectangle(DrawablePtr pDrawable, + GCPtr pGC, + int nRects, + xRectangle *pRects) +{ + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); + + if (nRects && checkGCDamage (pDrawable, pGC)) + { + BoxRec box; + int offset1, offset2, offset3; + int nRectsTmp = nRects; + xRectangle *pRectsTmp = pRects; + + offset2 = pGC->lineWidth; + if(!offset2) offset2 = 1; + offset1 = offset2 >> 1; + offset3 = offset2 - offset1; + + while(nRectsTmp--) + { + box.x1 = pRectsTmp->x - offset1; + box.y1 = pRectsTmp->y - offset1; + box.x2 = box.x1 + pRectsTmp->width + offset2; + box.y2 = box.y1 + offset2; + TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC); + if(BOX_NOT_EMPTY(box)) + damageDamageBox (pDrawable, &box); + + box.x1 = pRectsTmp->x - offset1; + box.y1 = pRectsTmp->y + offset3; + box.x2 = box.x1 + offset2; + box.y2 = box.y1 + pRectsTmp->height - offset2; + TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC); + if(BOX_NOT_EMPTY(box)) + damageDamageBox (pDrawable, &box); + + box.x1 = pRectsTmp->x + pRectsTmp->width - offset1; + box.y1 = pRectsTmp->y + offset3; + box.x2 = box.x1 + offset2; + box.y2 = box.y1 + pRectsTmp->height - offset2; + TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC); + if(BOX_NOT_EMPTY(box)) + damageDamageBox (pDrawable, &box); + + box.x1 = pRectsTmp->x - offset1; + box.y1 = pRectsTmp->y + pRectsTmp->height - offset1; + box.x2 = box.x1 + pRectsTmp->width + offset2; + box.y2 = box.y1 + offset2; + TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC); + if(BOX_NOT_EMPTY(box)) + damageDamageBox (pDrawable, &box); + + pRectsTmp++; + } + } + (*pGC->ops->PolyRectangle)(pDrawable, pGC, nRects, pRects); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); +} + +static void +damagePolyArc(DrawablePtr pDrawable, + GCPtr pGC, + int nArcs, + xArc *pArcs) +{ + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); + + if (nArcs && checkGCDamage (pDrawable, pGC)) + { + int extra = pGC->lineWidth >> 1; + BoxRec box; + int nArcsTmp = nArcs; + xArc *pArcsTmp = pArcs; + + box.x1 = pArcsTmp->x; + box.x2 = box.x1 + pArcsTmp->width; + box.y1 = pArcsTmp->y; + box.y2 = box.y1 + pArcsTmp->height; + + while(--nArcsTmp) + { + pArcsTmp++; + if(box.x1 > pArcsTmp->x) + box.x1 = pArcsTmp->x; + if(box.x2 < (pArcsTmp->x + pArcsTmp->width)) + box.x2 = pArcsTmp->x + pArcsTmp->width; + if(box.y1 > pArcsTmp->y) + box.y1 = pArcsTmp->y; + if(box.y2 < (pArcsTmp->y + pArcsTmp->height)) + box.y2 = pArcsTmp->y + pArcsTmp->height; + } + + if(extra) + { + box.x1 -= extra; + box.x2 += extra; + box.y1 -= extra; + box.y2 += extra; + } + + box.x2++; + box.y2++; + + TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC); + if(BOX_NOT_EMPTY(box)) + damageDamageBox (pDrawable, &box); + } + (*pGC->ops->PolyArc)(pDrawable, pGC, nArcs, pArcs); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); +} + +static void +damageFillPolygon(DrawablePtr pDrawable, + GCPtr pGC, + int shape, + int mode, + int npt, + DDXPointPtr ppt) +{ + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); + + if (npt > 2 && checkGCDamage (pDrawable, pGC)) + { + DDXPointPtr pptTmp = ppt; + int nptTmp = npt; + BoxRec box; + + box.x2 = box.x1 = pptTmp->x; + box.y2 = box.y1 = pptTmp->y; + + if(mode != CoordModeOrigin) + { + int x = box.x1; + int y = box.y1; + while(--nptTmp) + { + pptTmp++; + x += pptTmp->x; + y += pptTmp->y; + if(box.x1 > x) box.x1 = x; + else if(box.x2 < x) box.x2 = x; + if(box.y1 > y) box.y1 = y; + else if(box.y2 < y) box.y2 = y; + } + } + else + { + while(--nptTmp) + { + pptTmp++; + if(box.x1 > pptTmp->x) box.x1 = pptTmp->x; + else if(box.x2 < pptTmp->x) box.x2 = pptTmp->x; + if(box.y1 > pptTmp->y) box.y1 = pptTmp->y; + else if(box.y2 < pptTmp->y) box.y2 = pptTmp->y; + } + } + + box.x2++; + box.y2++; + + TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC); + if(BOX_NOT_EMPTY(box)) + damageDamageBox (pDrawable, &box); + } + + (*pGC->ops->FillPolygon)(pDrawable, pGC, shape, mode, npt, ppt); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); +} + + +static void +damagePolyFillRect(DrawablePtr pDrawable, + GCPtr pGC, + int nRects, + xRectangle *pRects) +{ + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); + if (nRects && checkGCDamage (pDrawable, pGC)) + { + BoxRec box; + xRectangle *pRectsTmp = pRects; + int nRectsTmp = nRects; + + box.x1 = pRectsTmp->x; + box.x2 = box.x1 + pRectsTmp->width; + box.y1 = pRectsTmp->y; + box.y2 = box.y1 + pRectsTmp->height; + + while(--nRectsTmp) + { + pRectsTmp++; + if(box.x1 > pRectsTmp->x) box.x1 = pRectsTmp->x; + if(box.x2 < (pRectsTmp->x + pRectsTmp->width)) + box.x2 = pRectsTmp->x + pRectsTmp->width; + if(box.y1 > pRectsTmp->y) box.y1 = pRectsTmp->y; + if(box.y2 < (pRectsTmp->y + pRectsTmp->height)) + box.y2 = pRectsTmp->y + pRectsTmp->height; + } + + TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC); + if(BOX_NOT_EMPTY(box)) + damageDamageBox (pDrawable, &box); + } + (*pGC->ops->PolyFillRect)(pDrawable, pGC, nRects, pRects); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); +} + + +static void +damagePolyFillArc(DrawablePtr pDrawable, + GCPtr pGC, + int nArcs, + xArc *pArcs) +{ + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); + + if (nArcs && checkGCDamage (pDrawable, pGC)) + { + BoxRec box; + int nArcsTmp = nArcs; + xArc *pArcsTmp = pArcs; + + box.x1 = pArcsTmp->x; + box.x2 = box.x1 + pArcsTmp->width; + box.y1 = pArcsTmp->y; + box.y2 = box.y1 + pArcsTmp->height; + + while(--nArcsTmp) + { + pArcsTmp++; + if(box.x1 > pArcsTmp->x) + box.x1 = pArcsTmp->x; + if(box.x2 < (pArcsTmp->x + pArcsTmp->width)) + box.x2 = pArcsTmp->x + pArcsTmp->width; + if(box.y1 > pArcsTmp->y) + box.y1 = pArcsTmp->y; + if(box.y2 < (pArcsTmp->y + pArcsTmp->height)) + box.y2 = pArcsTmp->y + pArcsTmp->height; + } + + TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC); + if(BOX_NOT_EMPTY(box)) + damageDamageBox (pDrawable, &box); + } + (*pGC->ops->PolyFillArc)(pDrawable, pGC, nArcs, pArcs); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); +} + +/* + * general Poly/Image text function. Extract glyph information, + * compute bounding box and remove cursor if it is overlapped. + */ + +static void +damageDamageChars (DrawablePtr pDrawable, + FontPtr font, + int x, + int y, + unsigned int n, + CharInfoPtr *charinfo, + Bool imageblt) +{ + ExtentInfoRec extents; + BoxRec box; + + QueryGlyphExtents(font, charinfo, n, &extents); + if (imageblt) + { + if (extents.overallWidth > extents.overallRight) + extents.overallRight = extents.overallWidth; + if (extents.overallWidth < extents.overallLeft) + extents.overallLeft = extents.overallWidth; + if (extents.overallLeft > 0) + extents.overallLeft = 0; + if (extents.fontAscent > extents.overallAscent) + extents.overallAscent = extents.fontAscent; + if (extents.fontDescent > extents.overallDescent) + extents.overallDescent = extents.fontDescent; + } + box.x1 = x + extents.overallLeft; + box.y1 = y - extents.overallAscent; + box.x2 = x + extents.overallRight; + box.y2 = y + extents.overallDescent; + damageDamageBox (pDrawable, &box); +} + +/* + * values for textType: + */ +#define TT_POLY8 0 +#define TT_IMAGE8 1 +#define TT_POLY16 2 +#define TT_IMAGE16 3 + +static int +damageText (DrawablePtr pDrawable, + GCPtr pGC, + int x, + int y, + unsigned long count, + char *chars, + FontEncoding fontEncoding, + Bool textType) +{ + CharInfoPtr *charinfo; + CharInfoPtr *info; + unsigned long i; + unsigned int n; + int w; + Bool imageblt; + + imageblt = (textType == TT_IMAGE8) || (textType == TT_IMAGE16); + + charinfo = (CharInfoPtr *) ALLOCATE_LOCAL(count * sizeof(CharInfoPtr)); + if (!charinfo) + return x; + + GetGlyphs(pGC->font, count, (unsigned char *)chars, + fontEncoding, &i, charinfo); + n = (unsigned int)i; + w = 0; + if (!imageblt) + for (info = charinfo; i--; info++) + w += (*info)->metrics.characterWidth; + + if (n != 0) { + damageDamageChars (pDrawable, pGC->font, x + pDrawable->x, y + pDrawable->y, n, + charinfo, imageblt); + if (imageblt) + (*pGC->ops->ImageGlyphBlt)(pDrawable, pGC, x, y, n, charinfo, + FONTGLYPHS(pGC->font)); + else + (*pGC->ops->PolyGlyphBlt)(pDrawable, pGC, x, y, n, charinfo, + FONTGLYPHS(pGC->font)); + } + DEALLOCATE_LOCAL(charinfo); + return x + w; +} + +static int +damagePolyText8(DrawablePtr pDrawable, + GCPtr pGC, + int x, + int y, + int count, + char *chars) +{ + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); + + if (checkGCDamage (pDrawable, pGC)) + damageText (pDrawable, pGC, x, y, (unsigned long) count, chars, + Linear8Bit, TT_POLY8); + else + x = (*pGC->ops->PolyText8)(pDrawable, pGC, x, y, count, chars); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); + return x; +} + +static int +damagePolyText16(DrawablePtr pDrawable, + GCPtr pGC, + int x, + int y, + int count, + unsigned short *chars) +{ + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); + + if (checkGCDamage (pDrawable, pGC)) + damageText (pDrawable, pGC, x, y, (unsigned long) count, (char *) chars, + FONTLASTROW(pGC->font) == 0 ? Linear16Bit : TwoD16Bit, + TT_POLY16); + else + x = (*pGC->ops->PolyText16)(pDrawable, pGC, x, y, count, chars); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); + return x; +} + +static void +damageImageText8(DrawablePtr pDrawable, + GCPtr pGC, + int x, + int y, + int count, + char *chars) +{ + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); + + if (checkGCDamage (pDrawable, pGC)) + damageText (pDrawable, pGC, x, y, (unsigned long) count, chars, + Linear8Bit, TT_IMAGE8); + else + (*pGC->ops->ImageText8)(pDrawable, pGC, x, y, count, chars); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); +} + +static void +damageImageText16(DrawablePtr pDrawable, + GCPtr pGC, + int x, + int y, + int count, + unsigned short *chars) +{ + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); + + if (checkGCDamage (pDrawable, pGC)) + damageText (pDrawable, pGC, x, y, (unsigned long) count, (char *) chars, + FONTLASTROW(pGC->font) == 0 ? Linear16Bit : TwoD16Bit, + TT_IMAGE16); + else + (*pGC->ops->ImageText16)(pDrawable, pGC, x, y, count, chars); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); +} + + +static void +damageImageGlyphBlt(DrawablePtr pDrawable, + GCPtr pGC, + int x, + int y, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase) +{ + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); + damageDamageChars (pDrawable, pGC->font, x + pDrawable->x, y + pDrawable->y, + nglyph, ppci, TRUE); + (*pGC->ops->ImageGlyphBlt)(pDrawable, pGC, x, y, nglyph, + ppci, pglyphBase); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); +} + +static void +damagePolyGlyphBlt(DrawablePtr pDrawable, + GCPtr pGC, + int x, + int y, + unsigned int nglyph, + CharInfoPtr *ppci, + pointer pglyphBase) +{ + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); + damageDamageChars (pDrawable, pGC->font, x + pDrawable->x, y + pDrawable->y, + nglyph, ppci, FALSE); + (*pGC->ops->PolyGlyphBlt)(pDrawable, pGC, x, y, nglyph, + ppci, pglyphBase); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); +} + +static void +damagePushPixels(GCPtr pGC, + PixmapPtr pBitMap, + DrawablePtr pDrawable, + int dx, + int dy, + int xOrg, + int yOrg) +{ + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); + if(checkGCDamage (pDrawable, pGC)) + { + BoxRec box; + + box.x1 = xOrg; + box.y1 = yOrg; + + if(!pGC->miTranslate) { + box.x1 += pDrawable->x; + box.y1 += pDrawable->y; + } + + box.x2 = box.x1 + dx; + box.y2 = box.y1 + dy; + + TRIM_BOX(box, pGC); + if(BOX_NOT_EMPTY(box)) + damageDamageBox (pDrawable, &box); + } + (*pGC->ops->PushPixels)(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); +} + +static void +damageRemoveDamage (DamagePtr *pPrev, DamagePtr pDamage) +{ + while (*pPrev) + { + if (*pPrev == pDamage) + { + *pPrev = pDamage->pNext; + return; + } + pPrev = &(*pPrev)->pNext; + } +#if DAMAGE_VALIDATE_ENABLE + ErrorF ("Damage not on list\n"); + abort (); +#endif +} + +static void +damageInsertDamage (DamagePtr *pPrev, DamagePtr pDamage) +{ +#if DAMAGE_VALIDATE_ENABLE + DamagePtr pOld; + + for (pOld = *pPrev; pOld; pOld = pOld->pNext) + if (pOld == pDamage) { + ErrorF ("Damage already on list\n"); + abort (); + } +#endif + pDamage->pNext = *pPrev; + *pPrev = pDamage; +} + +static Bool +damageDestroyPixmap (PixmapPtr pPixmap) +{ + ScreenPtr pScreen = pPixmap->drawable.pScreen; + damageScrPriv(pScreen); + + if (pPixmap->refcnt == 1) + { + DamagePtr *pPrev = getPixmapDamageRef (pPixmap); + DamagePtr pDamage; + + while ((pDamage = *pPrev)) + { + damageRemoveDamage (pPrev, pDamage); + if (!pDamage->isWindow) + DamageDestroy (pDamage); + } + } + unwrap (pScrPriv, pScreen, DestroyPixmap); + (*pScreen->DestroyPixmap) (pPixmap); + wrap (pScrPriv, pScreen, DestroyPixmap, damageDestroyPixmap); + return TRUE; +} + +static void +damagePaintWindow(WindowPtr pWindow, + RegionPtr prgn, + int what) +{ + ScreenPtr pScreen = pWindow->drawable.pScreen; + damageScrPriv(pScreen); + + /* + * Painting background none doesn't actually *do* anything, so + * no damage is recorded + */ + if ((what != PW_BACKGROUND || pWindow->backgroundState != None) && + getWindowDamage (pWindow)) + damageDamageRegion (&pWindow->drawable, prgn, FALSE); + if(what == PW_BACKGROUND) { + unwrap (pScrPriv, pScreen, PaintWindowBackground); + (*pScreen->PaintWindowBackground) (pWindow, prgn, what); + wrap (pScrPriv, pScreen, PaintWindowBackground, damagePaintWindow); + } else { + unwrap (pScrPriv, pScreen, PaintWindowBorder); + (*pScreen->PaintWindowBorder) (pWindow, prgn, what); + wrap (pScrPriv, pScreen, PaintWindowBorder, damagePaintWindow); + } +} + + +static void +damageCopyWindow(WindowPtr pWindow, + DDXPointRec ptOldOrg, + RegionPtr prgnSrc) +{ + ScreenPtr pScreen = pWindow->drawable.pScreen; + damageScrPriv(pScreen); + + if (getWindowDamage (pWindow)) + { + int dx = pWindow->drawable.x - ptOldOrg.x; + int dy = pWindow->drawable.y - ptOldOrg.y; + + /* + * The region comes in source relative, but the damage occurs + * at the destination location. Translate back and forth. + */ + REGION_TRANSLATE (pScreen, prgnSrc, dx, dy); + damageDamageRegion (&pWindow->drawable, prgnSrc, FALSE); + REGION_TRANSLATE (pScreen, prgnSrc, -dx, -dy); + } + unwrap (pScrPriv, pScreen, CopyWindow); + (*pScreen->CopyWindow) (pWindow, ptOldOrg, prgnSrc); + wrap (pScrPriv, pScreen, CopyWindow, damageCopyWindow); +} + +GCOps damageGCOps = { + damageFillSpans, damageSetSpans, + damagePutImage, damageCopyArea, + damageCopyPlane, damagePolyPoint, + damagePolylines, damagePolySegment, + damagePolyRectangle, damagePolyArc, + damageFillPolygon, damagePolyFillRect, + damagePolyFillArc, damagePolyText8, + damagePolyText16, damageImageText8, + damageImageText16, damageImageGlyphBlt, + damagePolyGlyphBlt, damagePushPixels, +#ifdef NEED_LINEHELPER + NULL, +#endif + {NULL} /* devPrivate */ +}; + +static void +damageRestoreAreas (PixmapPtr pPixmap, + RegionPtr prgn, + int xorg, + int yorg, + WindowPtr pWindow) +{ + ScreenPtr pScreen = pWindow->drawable.pScreen; + damageScrPriv(pScreen); + + damageDamageRegion (&pWindow->drawable, prgn, FALSE); + unwrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas); + (*pScreen->BackingStoreFuncs.RestoreAreas) (pPixmap, prgn, + xorg, yorg, pWindow); + wrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas, + damageRestoreAreas); +} + +static void +damageSetWindowPixmap (WindowPtr pWindow, PixmapPtr pPixmap) +{ + DamagePtr pDamage; + ScreenPtr pScreen = pWindow->drawable.pScreen; + damageScrPriv(pScreen); + + if ((pDamage = damageGetWinPriv(pWindow))) + { + PixmapPtr pOldPixmap = (*pScreen->GetWindowPixmap) (pWindow); + DamagePtr *pPrev = getPixmapDamageRef(pOldPixmap); + + while (pDamage) + { + damageRemoveDamage (pPrev, pDamage); + pDamage = pDamage->pNextWin; + } + } + unwrap (pScrPriv, pScreen, SetWindowPixmap); + (*pScreen->SetWindowPixmap) (pWindow, pPixmap); + wrap (pScrPriv, pScreen, SetWindowPixmap, damageSetWindowPixmap); + if ((pDamage = damageGetWinPriv(pWindow))) + { + DamagePtr *pPrev = getPixmapDamageRef(pPixmap); + + while (pDamage) + { + damageInsertDamage (pPrev, pDamage); + pDamage = pDamage->pNextWin; + } + } +} + +static Bool +damageDestroyWindow (WindowPtr pWindow) +{ + DamagePtr pDamage; + ScreenPtr pScreen = pWindow->drawable.pScreen; + Bool ret; + damageScrPriv(pScreen); + + while ((pDamage = damageGetWinPriv(pWindow))) + { + DamageUnregister (&pWindow->drawable, pDamage); + DamageDestroy (pDamage); + } + unwrap (pScrPriv, pScreen, DestroyWindow); + ret = (*pScreen->DestroyWindow) (pWindow); + wrap (pScrPriv, pScreen, DestroyWindow, damageDestroyWindow); + return ret; +} + +static Bool +damageCloseScreen (int i, ScreenPtr pScreen) +{ + damageScrPriv(pScreen); + + unwrap (pScrPriv, pScreen, DestroyPixmap); + unwrap (pScrPriv, pScreen, CreateGC); + unwrap (pScrPriv, pScreen, PaintWindowBackground); + unwrap (pScrPriv, pScreen, PaintWindowBorder); + unwrap (pScrPriv, pScreen, CopyWindow); + unwrap (pScrPriv, pScreen, CloseScreen); + unwrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas); + xfree (pScrPriv); + return (*pScreen->CloseScreen) (i, pScreen); +} + +int damageScrPrivateIndex; +int damagePixPrivateIndex; +int damageGCPrivateIndex; +int damageWinPrivateIndex; +int damageGeneration; + +Bool +DamageSetup (ScreenPtr pScreen) +{ + DamageScrPrivPtr pScrPriv; +#ifdef RENDER + PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); +#endif + + if (damageGeneration != serverGeneration) + { + damageScrPrivateIndex = AllocateScreenPrivateIndex (); + if (damageScrPrivateIndex == -1) + return FALSE; + damageGCPrivateIndex = AllocateGCPrivateIndex (); + if (damageGCPrivateIndex == -1) + return FALSE; + damagePixPrivateIndex = AllocatePixmapPrivateIndex (); + if (damagePixPrivateIndex == -1) + return FALSE; + damageWinPrivateIndex = AllocateWindowPrivateIndex (); + if (damageWinPrivateIndex == -1) + return FALSE; + damageGeneration = serverGeneration; + } + if (pScreen->devPrivates[damageScrPrivateIndex].ptr) + return TRUE; + + if (!AllocateGCPrivate (pScreen, damageGCPrivateIndex, sizeof (DamageGCPrivRec))) + return FALSE; + if (!AllocatePixmapPrivate (pScreen, damagePixPrivateIndex, 0)) + return FALSE; + if (!AllocateWindowPrivate (pScreen, damageWinPrivateIndex, 0)) + return FALSE; + + pScrPriv = (DamageScrPrivPtr) xalloc (sizeof (DamageScrPrivRec)); + if (!pScrPriv) + return FALSE; + +#ifdef COMPOSITE + /* This is a kludge to ensure wrapping order with the composite wrapper. + * If it's done from compinit.c, then DamageSetup may be called before the + * extension init phase, so that cw will be higher in the wrapping chain and + * rewrite drawables before damage gets to it, causing confusion. + */ + if (!noCompositeExtension) + miInitializeCompositeWrapper (pScreen); +#endif + + pScrPriv->internalLevel = 0; + pScrPriv->pScreenDamage = 0; + + wrap (pScrPriv, pScreen, DestroyPixmap, damageDestroyPixmap); + wrap (pScrPriv, pScreen, CreateGC, damageCreateGC); + wrap (pScrPriv, pScreen, PaintWindowBackground, damagePaintWindow); + wrap (pScrPriv, pScreen, PaintWindowBorder, damagePaintWindow); + wrap (pScrPriv, pScreen, DestroyWindow, damageDestroyWindow); + wrap (pScrPriv, pScreen, SetWindowPixmap, damageSetWindowPixmap); + wrap (pScrPriv, pScreen, CopyWindow, damageCopyWindow); + wrap (pScrPriv, pScreen, CloseScreen, damageCloseScreen); + wrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas, + damageRestoreAreas); +#ifdef RENDER + if (ps) { + wrap (pScrPriv, ps, Glyphs, damageGlyphs); + wrap (pScrPriv, ps, Composite, damageComposite); + } +#endif + + pScreen->devPrivates[damageScrPrivateIndex].ptr = (pointer) pScrPriv; + return TRUE; +} + +DamagePtr +DamageCreate (DamageReportFunc damageReport, + DamageDestroyFunc damageDestroy, + DamageReportLevel damageLevel, + Bool isInternal, + ScreenPtr pScreen, + void *closure) +{ + DamagePtr pDamage; + + pDamage = xalloc (sizeof (DamageRec)); + if (!pDamage) + return 0; + pDamage->pNext = 0; + pDamage->pNextWin = 0; + REGION_NULL(pScreen, &pDamage->damage); + + pDamage->damageLevel = damageLevel; + pDamage->isInternal = isInternal; + pDamage->closure = closure; + pDamage->isWindow = FALSE; + pDamage->pDrawable = 0; + + pDamage->damageReport = damageReport; + pDamage->damageDestroy = damageDestroy; + return pDamage; +} + +void +DamageRegister (DrawablePtr pDrawable, + DamagePtr pDamage) +{ + if (pDrawable->type == DRAWABLE_WINDOW) + { + WindowPtr pWindow = (WindowPtr) pDrawable; + winDamageRef(pWindow); + +#if DAMAGE_VALIDATE_ENABLE + DamagePtr pOld; + + for (pOld = *pPrev; pOld; pOld = pOld->pNextWin) + if (pOld == pDamage) { + ErrorF ("Damage already on window list\n"); + abort (); + } +#endif + pDamage->pNextWin = *pPrev; + *pPrev = pDamage; + pDamage->isWindow = TRUE; + } + else + pDamage->isWindow = FALSE; + pDamage->pDrawable = pDrawable; + damageInsertDamage (getDrawableDamageRef (pDrawable), pDamage); +} + +void +DamageDrawInternal (ScreenPtr pScreen, Bool enable) +{ + damageScrPriv (pScreen); + + pScrPriv->internalLevel += enable ? 1 : -1; +} + +void +DamageUnregister (DrawablePtr pDrawable, + DamagePtr pDamage) +{ + if (pDrawable->type == DRAWABLE_WINDOW) + { + WindowPtr pWindow = (WindowPtr) pDrawable; + winDamageRef (pWindow); +#if DAMAGE_VALIDATE_ENABLE + int found = 0; +#endif + + while (*pPrev) + { + if (*pPrev == pDamage) + { + *pPrev = pDamage->pNextWin; +#if DAMAGE_VALIDATE_ENABLE + found = 1; +#endif + break; + } + pPrev = &(*pPrev)->pNextWin; + } +#if DAMAGE_VALIDATE_ENABLE + if (!found) { + ErrorF ("Damage not on window list\n"); + abort (); + } +#endif + } + pDamage->pDrawable = 0; + damageRemoveDamage (getDrawableDamageRef (pDrawable), pDamage); +} + +void +DamageDestroy (DamagePtr pDamage) +{ + if (pDamage->damageDestroy) + (*pDamage->damageDestroy) (pDamage, pDamage->closure); + REGION_UNINIT (pDamage->pDrawable->pScreen, &pDamage->damage); + xfree (pDamage); +} + +Bool +DamageSubtract (DamagePtr pDamage, + const RegionPtr pRegion) +{ + RegionPtr pClip; + RegionRec pixmapClip; + DrawablePtr pDrawable = pDamage->pDrawable; + + REGION_SUBTRACT (pDrawable->pScreen, &pDamage->damage, &pDamage->damage, pRegion); + if (pDrawable) + { + if (pDrawable->type == DRAWABLE_WINDOW) + pClip = &((WindowPtr) pDrawable)->borderClip; + else + { + BoxRec box; + + box.x1 = pDrawable->x; + box.y1 = pDrawable->y; + box.x2 = pDrawable->x + pDrawable->width; + box.y2 = pDrawable->y + pDrawable->height; + REGION_INIT (pDrawable->pScreen, &pixmapClip, &box, 1); + pClip = &pixmapClip; + } + REGION_TRANSLATE (pDrawable->pScreen, &pDamage->damage, pDrawable->x, pDrawable->y); + REGION_INTERSECT (pDrawable->pScreen, &pDamage->damage, &pDamage->damage, pClip); + REGION_TRANSLATE (pDrawable->pScreen, &pDamage->damage, -pDrawable->x, -pDrawable->y); + } + return REGION_NOTEMPTY (pDrawable->pScreen, &pDamage->damage); +} + +void +DamageEmpty (DamagePtr pDamage) +{ + REGION_EMPTY (pDamage->pDrawable->pScreen, &pDamage->damage); +} + +RegionPtr +DamageRegion (DamagePtr pDamage) +{ + return &pDamage->damage; +} + +void +DamageDamageRegion (DrawablePtr pDrawable, + RegionPtr pRegion) +{ + damageDamageRegion (pDrawable, pRegion, FALSE); +} diff --git a/miext/damage/damagestr.h b/miext/damage/damagestr.h new file mode 100755 index 000000000..d975ee23b --- /dev/null +++ b/miext/damage/damagestr.h @@ -0,0 +1,107 @@ +/* + * $Id$ + * + * Copyright © 2003 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. + */ + +#ifndef _DAMAGESTR_H_ +#define _DAMAGESTR_H_ + +#include "damage.h" +#include "picturestr.h" + +typedef struct _damage { + DamagePtr pNext; + DamagePtr pNextWin; + RegionRec damage; + + DamageReportLevel damageLevel; + Bool isInternal; + void *closure; + Bool isWindow; + DrawablePtr pDrawable; + + DamageReportFunc damageReport; + DamageDestroyFunc damageDestroy; +} DamageRec; + +typedef struct _damageScrPriv { + int internalLevel; + + /* + * For DDXen which don't provide GetScreenPixmap, this provides + * a place to hook damage for windows on the screen + */ + DamagePtr pScreenDamage; + + PaintWindowBackgroundProcPtr PaintWindowBackground; + PaintWindowBorderProcPtr PaintWindowBorder; + CopyWindowProcPtr CopyWindow; + CloseScreenProcPtr CloseScreen; + CreateGCProcPtr CreateGC; + DestroyPixmapProcPtr DestroyPixmap; + SetWindowPixmapProcPtr SetWindowPixmap; + DestroyWindowProcPtr DestroyWindow; +#ifdef RENDER + CompositeProcPtr Composite; + GlyphsProcPtr Glyphs; +#endif + BSFuncRec BackingStoreFuncs; +} DamageScrPrivRec, *DamageScrPrivPtr; + +typedef struct _damageGCPriv { + GCOps *ops; + GCFuncs *funcs; +} DamageGCPrivRec, *DamageGCPrivPtr; + +extern int damageScrPrivateIndex; +extern int damagePixPrivateIndex; +extern int damageGCPrivateIndex; +extern int damageWinPrivateIndex; + +#define damageGetScrPriv(pScr) \ + ((DamageScrPrivPtr) (pScr)->devPrivates[damageScrPrivateIndex].ptr) + +#define damageScrPriv(pScr) \ + DamageScrPrivPtr pScrPriv = damageGetScrPriv(pScr) + +#define damageGetPixPriv(pPix) \ + ((DamagePtr) (pPix)->devPrivates[damagePixPrivateIndex].ptr) + +#define damgeSetPixPriv(pPix,v) \ + ((pPix)->devPrivates[damagePixPrivateIndex].ptr = (pointer ) (v)) + +#define damagePixPriv(pPix) \ + DamagePtr pDamage = damageGetPixPriv(pPix) + +#define damageGetGCPriv(pGC) \ + ((DamageGCPrivPtr) (pGC)->devPrivates[damageGCPrivateIndex].ptr) + +#define damageGCPriv(pGC) \ + DamageGCPrivPtr pGCPriv = damageGetGCPriv(pGC) + +#define damageGetWinPriv(pWin) \ + ((DamagePtr) (pWin)->devPrivates[damageWinPrivateIndex].ptr) + +#define damageSetWinPriv(pWin,d) \ + ((pWin)->devPrivates[damageWinPrivateIndex].ptr = (d)) + +#endif /* _DAMAGESTR_H_ */ diff --git a/miext/rootless/rootless.h b/miext/rootless/rootless.h index aefefcab2..1bada3865 100644 --- a/miext/rootless/rootless.h +++ b/miext/rootless/rootless.h @@ -27,7 +27,7 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ -/* $XFree86: xc/programs/Xserver/miext/rootless/rootless.h,v 1.5 2003/10/18 00:00:34 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/miext/rootless/rootless.h,v 1.7 2004/07/02 01:30:33 torrey Exp $ */ #ifndef _ROOTLESS_H #define _ROOTLESS_H @@ -395,5 +395,16 @@ void RootlessStartDrawing(WindowPtr pWindow); */ void RootlessStopDrawing(WindowPtr pWindow, Bool flush); +/* + * Alocate a new screen pixmap. + * miCreateScreenResources does not do this properly with a null + * framebuffer pointer. + */ +void RootlessUpdateScreenPixmap(ScreenPtr pScreen); + +/* + * Reposition all windows on a screen to their correct positions. + */ +void RootlessRepositionWindows(ScreenPtr pScreen); #endif /* _ROOTLESS_H */ diff --git a/miext/rootless/rootlessCommon.c b/miext/rootless/rootlessCommon.c index 85655a9e1..b24d2a226 100644 --- a/miext/rootless/rootlessCommon.c +++ b/miext/rootless/rootlessCommon.c @@ -28,7 +28,7 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ -/* $XFree86: xc/programs/Xserver/miext/rootless/rootlessCommon.c,v 1.4tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/miext/rootless/rootlessCommon.c,v 1.6 2004/07/02 01:30:33 torrey Exp $ */ #include "rootlessCommon.h" @@ -166,8 +166,8 @@ void RootlessStopDrawing(WindowPtr pWindow, Bool flush) } if (flush && winRec->is_reorder_pending) { - winRec->is_reorder_pending = FALSE; - RootlessReorderWindow(pWindow); + winRec->is_reorder_pending = FALSE; + RootlessReorderWindow(pWindow); } } @@ -190,11 +190,11 @@ RootlessDamageRegion(WindowPtr pWindow, RegionPtr pRegion) pTop = TopLevelParent(pWindow); if (pTop == NULL) - return; + return; winRec = WINREC(pTop); if (winRec == NULL) - return; + return; /* We need to intersect the drawn region with the clip of the window to avoid marking places we didn't actually draw (which can cause @@ -208,43 +208,43 @@ RootlessDamageRegion(WindowPtr pWindow, RegionPtr pRegion) b2 = REGION_EXTENTS(pScreen, pRegion); if (EXTENTCHECK(b1, b2)) { - /* Regions may overlap. */ + /* Regions may overlap. */ - if (REGION_NUM_RECTS(pRegion) == 1) { - int in; + if (REGION_NUM_RECTS(pRegion) == 1) { + int in; - /* Damaged region only has a single rect, so we can - just compare that against the region */ + /* Damaged region only has a single rect, so we can + just compare that against the region */ - in = RECT_IN_REGION(pScreen, &pWindow->borderClip, + in = RECT_IN_REGION(pScreen, &pWindow->borderClip, REGION_RECTS (pRegion)); - if (in == rgnIN) { - /* clip totally contains pRegion */ + if (in == rgnIN) { + /* clip totally contains pRegion */ #ifdef ROOTLESS_TRACK_DAMAGE REGION_UNION(pScreen, &winRec->damage, - &winRec->damage, (pRegion)); + &winRec->damage, (pRegion)); #else - SCREENREC(pScreen)->imp->DamageRects(winRec->wid, + SCREENREC(pScreen)->imp->DamageRects(winRec->wid, REGION_NUM_RECTS(pRegion), - REGION_RECTS(pRegion), - -winRec->x, -winRec->y); + REGION_RECTS(pRegion), + -winRec->x, -winRec->y); #endif - RootlessQueueRedisplay(pTop->drawable.pScreen); - goto out; - } - else if (in == rgnOUT) { - /* clip doesn't contain pRegion */ + RootlessQueueRedisplay(pTop->drawable.pScreen); + goto out; + } + else if (in == rgnOUT) { + /* clip doesn't contain pRegion */ - goto out; - } - } + goto out; + } + } - /* clip overlaps pRegion, need to intersect */ + /* clip overlaps pRegion, need to intersect */ - REGION_NULL(pScreen, &clipped); - REGION_INTERSECT(pScreen, &clipped, &pWindow->borderClip, pRegion); + REGION_NULL(pScreen, &clipped); + REGION_INTERSECT(pScreen, &clipped, &pWindow->borderClip, pRegion); #ifdef ROOTLESS_TRACK_DAMAGE REGION_UNION(pScreen, &winRec->damage, @@ -256,9 +256,9 @@ RootlessDamageRegion(WindowPtr pWindow, RegionPtr pRegion) -winRec->x, -winRec->y); #endif - REGION_UNINIT(pScreen, &clipped); + REGION_UNINIT(pScreen, &clipped); - RootlessQueueRedisplay(pTop->drawable.pScreen); + RootlessQueueRedisplay(pTop->drawable.pScreen); } out: @@ -291,7 +291,7 @@ RootlessDamageBox(WindowPtr pWindow, BoxPtr pBox) RootlessDamageRegion(pWindow, ®ion); - REGION_UNINIT(pWindow->drawable.pScreen, ®ion); /* no-op */ + REGION_UNINIT(pWindow->drawable.pScreen, ®ion); /* no-op */ } @@ -318,7 +318,7 @@ RootlessDamageRect(WindowPtr pWindow, int x, int y, int w, int h) RootlessDamageRegion(pWindow, ®ion); - REGION_UNINIT(pWindow->drawable.pScreen, ®ion); /* no-op */ + REGION_UNINIT(pWindow->drawable.pScreen, ®ion); /* no-op */ } @@ -350,7 +350,7 @@ RootlessRedisplay(WindowPtr pWindow) REGION_EMPTY(pScreen, &winRec->damage); } -#else /* !ROOTLESS_TRACK_DAMAGE */ +#else /* !ROOTLESS_TRACK_DAMAGE */ RootlessStopDrawing(pWindow, TRUE); @@ -359,6 +359,27 @@ RootlessRedisplay(WindowPtr pWindow) /* + * RootlessRepositionWindows + * Reposition all windows on a screen to their correct positions. + */ +void +RootlessRepositionWindows(ScreenPtr pScreen) +{ + WindowPtr root = WindowTable[pScreen->myNum]; + WindowPtr win; + + if (root != NULL) { + RootlessRepositionWindow(root); + + for (win = root->firstChild; win; win = win->nextSib) { + if (WINREC(win) != NULL) + RootlessRepositionWindow(win); + } + } +} + + +/* * RootlessRedisplayScreen * Walk every window on a screen and redisplay the damaged regions. */ diff --git a/miext/rootless/rootlessCommon.h b/miext/rootless/rootlessCommon.h index c75c45a2e..b5fcae7f9 100644 --- a/miext/rootless/rootlessCommon.h +++ b/miext/rootless/rootlessCommon.h @@ -3,7 +3,7 @@ */ /* * Copyright (c) 2001 Greg Parker. All Rights Reserved. - * Copyright (c) 2002-2003 Torrey T. Lyons. All Rights Reserved. + * Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -27,7 +27,7 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ -/* $XFree86: xc/programs/Xserver/miext/rootless/rootlessCommon.h,v 1.3 2003/06/30 01:45:13 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/miext/rootless/rootlessCommon.h,v 1.5 2004/07/02 01:30:33 torrey Exp $ */ #ifndef _ROOTLESSCOMMON_H #define _ROOTLESSCOMMON_H @@ -139,10 +139,10 @@ typedef struct _RootlessScreenRec { // Call a rootless implementation function. // Many rootless implementation functions are allowed to be NULL. -#define CallFrameProc(pScreen, proc, params) \ - if (SCREENREC(pScreen)->frameProcs.proc) { \ - RL_DEBUG_MSG("calling frame proc " #proc " "); \ - SCREENREC(pScreen)->frameProcs.proc params; \ +#define CallFrameProc(pScreen, proc, params) \ + if (SCREENREC(pScreen)->frameProcs.proc) { \ + RL_DEBUG_MSG("calling frame proc " #proc " "); \ + SCREENREC(pScreen)->frameProcs.proc params; \ } @@ -217,19 +217,19 @@ extern RegionRec rootlessHugeRoot; * Can't access the bits before the first word of the drawable's data in * rootless mode, so make sure our base address is always 32-bit aligned. */ -#define SetPixmapBaseToScreen(pix, _x, _y) { \ - PixmapPtr _pPix = (PixmapPtr) (pix); \ - _pPix->devPrivate.ptr = (char *) (_pPix->devPrivate.ptr) - \ - ((int)(_x) * _pPix->drawable.bitsPerPixel/8 + \ - (int)(_y) * _pPix->devKind); \ - if (_pPix->drawable.bitsPerPixel != FB_UNIT) { \ - unsigned _diff = ((unsigned) _pPix->devPrivate.ptr) & \ - (FB_UNIT / CHAR_BIT - 1); \ - _pPix->devPrivate.ptr = (char *) (_pPix->devPrivate.ptr) - \ - _diff; \ - _pPix->drawable.x = _diff / \ - (_pPix->drawable.bitsPerPixel / CHAR_BIT); \ - } \ +#define SetPixmapBaseToScreen(pix, _x, _y) { \ + PixmapPtr _pPix = (PixmapPtr) (pix); \ + _pPix->devPrivate.ptr = (char *) (_pPix->devPrivate.ptr) - \ + ((int)(_x) * _pPix->drawable.bitsPerPixel/8 + \ + (int)(_y) * _pPix->devKind); \ + if (_pPix->drawable.bitsPerPixel != FB_UNIT) { \ + unsigned _diff = ((unsigned) _pPix->devPrivate.ptr) & \ + (FB_UNIT / CHAR_BIT - 1); \ + _pPix->devPrivate.ptr = (char *) (_pPix->devPrivate.ptr) - \ + _diff; \ + _pPix->drawable.x = _diff / \ + (_pPix->drawable.bitsPerPixel / CHAR_BIT); \ + } \ } @@ -246,9 +246,12 @@ void RootlessDamageBox(WindowPtr pWindow, BoxPtr pBox); void RootlessRedisplay(WindowPtr pWindow); void RootlessRedisplayScreen(ScreenPtr pScreen); -void RootlessQueueRedisplay (ScreenPtr pScreen); +void RootlessQueueRedisplay(ScreenPtr pScreen); + +// Move a window to its proper location on the screen. +void RootlessRepositionWindow(WindowPtr pWin); // Move the window to it's correct place in the physical stacking order. -void RootlessReorderWindow (WindowPtr pWin); +void RootlessReorderWindow(WindowPtr pWin); #endif /* _ROOTLESSCOMMON_H */ diff --git a/miext/rootless/rootlessValTree.c b/miext/rootless/rootlessValTree.c index 7b0337bce..9e61603b5 100644 --- a/miext/rootless/rootlessValTree.c +++ b/miext/rootless/rootlessValTree.c @@ -81,7 +81,6 @@ dealings in this Software without prior written authorization from Digital Equipment Corporation. ******************************************************************/ - /* * Aug '86: Susan Angebranndt -- original code * July '87: Adam de Boor -- substantially modified and commented diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c index ddd0d1891..9f1cfa1e6 100644 --- a/miext/rootless/rootlessWindow.c +++ b/miext/rootless/rootlessWindow.c @@ -1,10 +1,10 @@ -/* $XdotOrg: xc/programs/Xserver/miext/rootless/rootlessWindow.c,v 1.1.4.1.4.1 2004/03/04 17:48:29 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/miext/rootless/rootlessWindow.c,v 1.3 2004/07/30 19:12:17 torrey Exp $ */ /* * Rootless window management */ /* * Copyright (c) 2001 Greg Parker. All Rights Reserved. - * Copyright (c) 2002-2003 Torrey T. Lyons. All Rights Reserved. + * Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved. * Copyright (c) 2002 Apple Computer, Inc. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -29,7 +29,7 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ -/* $XFree86: xc/programs/Xserver/miext/rootless/rootlessWindow.c,v 1.10 2003/11/13 20:26:31 torrey Exp $ */ +/* $XFree86: xc/programs/Xserver/miext/rootless/rootlessWindow.c,v 1.12 2004/07/02 01:30:33 torrey Exp $ */ #include "rootlessCommon.h" #include "rootlessWindow.h" @@ -1219,6 +1219,31 @@ RootlessResizeWindow(WindowPtr pWin, int x, int y, /* + * RootlessRepositionWindow + * Called by the implementation when a window needs to be repositioned to + * its correct location on the screen. This routine is typically needed + * due to changes in the underlying window system, such as a screen layout + * change. + */ +void +RootlessRepositionWindow(WindowPtr pWin) +{ + RootlessWindowRec *winRec = WINREC(pWin); + ScreenPtr pScreen = pWin->drawable.pScreen; + + if (winRec == NULL) + return; + + RootlessStopDrawing(pWin, FALSE); + SCREENREC(pScreen)->imp->MoveFrame(winRec->wid, pScreen, + winRec->x + SCREEN_TO_GLOBAL_X, + winRec->y + SCREEN_TO_GLOBAL_Y); + + RootlessReorderWindow(pWin); +} + + +/* * RootlessReparentWindow * Called after a window has been reparented. Generally windows are not * framed until they are mapped. However, a window may be framed early by the @@ -1236,9 +1261,9 @@ RootlessReparentWindow(WindowPtr pWin, WindowPtr pPriorParent) /* Check that window is not top-level now, but used to be. */ if (IsRoot(pWin) || IsRoot(pWin->parent) - || IsTopLevel(pWin) || winRec == NULL) + || IsTopLevel(pWin) || winRec == NULL) { - goto out; + goto out; } /* If the formerly top-level window has a frame, we want to give the @@ -1249,20 +1274,20 @@ RootlessReparentWindow(WindowPtr pWin, WindowPtr pPriorParent) assert(pTopWin != pWin); if (WINREC(pTopWin) != NULL) { - /* We're screwed. */ - RootlessDestroyFrame(pWin, winRec); + /* We're screwed. */ + RootlessDestroyFrame(pWin, winRec); } else { - if (!pTopWin->realized && pWin->realized) { + if (!pTopWin->realized && pWin->realized) { SCREENREC(pScreen)->imp->UnmapFrame(winRec->wid); - } + } - /* Switch the frame record from one to the other. */ + /* Switch the frame record from one to the other. */ - WINREC(pWin) = NULL; - WINREC(pTopWin) = winRec; + WINREC(pWin) = NULL; + WINREC(pTopWin) = winRec; - RootlessInitializeFrame(pTopWin, winRec); - RootlessReshapeFrame(pTopWin); + RootlessInitializeFrame(pTopWin, winRec); + RootlessReshapeFrame(pTopWin); SCREENREC(pScreen)->imp->ResizeFrame(winRec->wid, pScreen, winRec->x + SCREEN_TO_GLOBAL_X, @@ -1274,8 +1299,8 @@ RootlessReparentWindow(WindowPtr pWin, WindowPtr pPriorParent) SCREENREC(pScreen)->imp->SwitchWindow(winRec, pWin); } - if (pTopWin->realized && !pWin->realized) - winRec->is_reorder_pending = TRUE; + if (pTopWin->realized && !pWin->realized) + winRec->is_reorder_pending = TRUE; } out: diff --git a/miext/rootless/safeAlpha/safeAlphaWindow.c b/miext/rootless/safeAlpha/safeAlphaWindow.c index 1c6a8a747..4e70a73e1 100644 --- a/miext/rootless/safeAlpha/safeAlphaWindow.c +++ b/miext/rootless/safeAlpha/safeAlphaWindow.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/miext/rootless/safeAlpha/safeAlphaWindow.c,v 1.1.4.2.2.2 2004/03/04 17:48:30 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/miext/rootless/safeAlpha/safeAlphaWindow.c,v 1.2 2004/04/23 19:54:28 eich Exp $ */ /* * Specialized window functions to protect the alpha channel */ diff --git a/miext/shadow/shadow.h b/miext/shadow/shadow.h index d343a171f..d301916e4 100644 --- a/miext/shadow/shadow.h +++ b/miext/shadow/shadow.h @@ -163,6 +163,13 @@ void shadowUpdateRotate32_270 (ScreenPtr pScreen, shadowBufPtr pBuf); +typedef void (* shadowUpdateProc)(ScreenPtr, shadowBufPtr); + +shadowUpdateProc shadowUpdatePackedWeak(void); +shadowUpdateProc shadowUpdatePlanar4Weak(void); +shadowUpdateProc shadowUpdatePlanar4x8Weak(void); +shadowUpdateProc shadowUpdateRotatePackedWeak(void); + void shadowWrapGC (GCPtr pGC); diff --git a/miext/shadow/shpacked.c b/miext/shadow/shpacked.c index 441409776..de2643e9f 100644 --- a/miext/shadow/shpacked.c +++ b/miext/shadow/shpacked.c @@ -106,3 +106,5 @@ shadowUpdatePacked (ScreenPtr pScreen, pbox++; } } + +shadowUpdateProc shadowUpdatePackedWeak(void) { return shadowUpdatePacked; } diff --git a/miext/shadow/shplanar.c b/miext/shadow/shplanar.c index aaa6d58eb..3b842d57b 100644 --- a/miext/shadow/shplanar.c +++ b/miext/shadow/shplanar.c @@ -165,4 +165,11 @@ shadowUpdatePlanar4 (ScreenPtr pScreen, pbox++; } } - + +shadowUpdateProc shadowUpdatePlanar4Weak(void) { + return shadowUpdatePlanar4; +} + +shadowUpdateProc shadowUpdatePlanar4x8Weak(void) { + return shadowUpdatePlanar4x8; +} diff --git a/miext/shadow/shrotate.c b/miext/shadow/shrotate.c index a0f5b6e06..620559e69 100644 --- a/miext/shadow/shrotate.c +++ b/miext/shadow/shrotate.c @@ -304,3 +304,7 @@ shadowUpdateRotatePacked (ScreenPtr pScreen, } } } + +shadowUpdateProc shadowUpdateRotatePackedWeak(void) { + return shadowUpdateRotatePacked; +} diff --git a/os/access.c b/os/access.c index 4519b56eb..2cc050860 100644 --- a/os/access.c +++ b/os/access.c @@ -1,5 +1,5 @@ /* $Xorg: access.c,v 1.5 2001/02/09 02:05:23 xorgcvs Exp $ */ -/* $XdotOrg$ */ +/* $XdotOrg: xc/programs/Xserver/os/access.c,v 1.5 2004/07/17 01:13:31 alanc Exp $ */ /*********************************************************** Copyright 1987, 1998 The Open Group @@ -88,6 +88,12 @@ SOFTWARE. #include <netdnet/dnetdb.h> #endif +#ifdef HAS_GETPEERUCRED +# include <ucred.h> +# ifdef sun +# include <zone.h> +# endif +#endif #if defined(DGUX) #include <sys/ioctl.h> @@ -224,6 +230,10 @@ static Bool NewHost(int /*family*/, int /*len*/, int /* addingLocalHosts */); +int LocalClientCredAndGroups(ClientPtr client, int *pUid, int *pGid, + int **pSuppGids, int *nSuppGids); + + /* XFree86 bug #156: To keep track of which hosts were explicitly requested in /etc/X<display>.hosts, we've added a requested field to the HOST struct, and a LocalHostRequested variable. These default to FALSE, but are set @@ -302,7 +312,7 @@ AccessUsingXdmcp (void) } -#if ((defined(SVR4) && !defined(DGUX) && !defined(SCO325) && !defined(sun) && !defined(NCR)) || defined(ISC)) && defined(SIOCGIFCONF) && !defined(USE_SIOCGLIFCONF) +#if ((defined(SVR4) && !defined(DGUX) && !defined(SCO325) && !defined(sun) && !defined(NCR)) || defined(ISC)) && !defined(__sgi) && defined(SIOCGIFCONF) && !defined(USE_SIOCGLIFCONF) /* Deal with different SIOCGIFCONF ioctl semantics on these OSs */ @@ -1393,19 +1403,38 @@ Bool LocalClient(ClientPtr client) /* * Return the uid and gid of a connected local client - * or the uid/gid for nobody those ids cannot be determinded + * or the uid/gid for nobody those ids cannot be determined * * Used by XShm to test access rights to shared memory segments */ int LocalClientCred(ClientPtr client, int *pUid, int *pGid) { -#if defined(HAS_GETPEEREID) || defined(SO_PEERCRED) + return LocalClientCredAndGroups(client, pUid, pGid, NULL, NULL); +} + +/* + * Return the uid and all gids of a connected local client + * or the uid/gid for nobody those ids cannot be determined + * + * If the caller passes non-NULL values for pSuppGids & nSuppGids, + * they are responsible for calling XFree(*pSuppGids) to release the + * memory allocated for the supplemental group ids list. + * + * Used by localuser & localgroup ServerInterpreted access control forms below + */ +int +LocalClientCredAndGroups(ClientPtr client, int *pUid, int *pGid, + int **pSuppGids, int *nSuppGids) +{ +#if defined(HAS_GETPEEREID) || defined(HAS_GETPEERUCRED) || defined(SO_PEERCRED) int fd; XtransConnInfo ci; #ifdef HAS_GETPEEREID uid_t uid; gid_t gid; +#elif defined(HAS_GETPEERUCRED) + ucred_t *peercred = NULL; #elif defined(SO_PEERCRED) struct ucred peercred; socklen_t so_len = sizeof(peercred); @@ -1414,10 +1443,21 @@ LocalClientCred(ClientPtr client, int *pUid, int *pGid) if (client == NULL) return -1; ci = ((OsCommPtr)client->osPrivate)->trans_conn; - /* We can only determine peer credentials for Unix domain sockets */ +#if !(defined(sun) && defined(HAS_GETPEERUCRED)) + /* Most implementations can only determine peer credentials for Unix + * domain sockets - Solaris getpeerucred can work with a bit more, so + * we just let it tell us if the connection type is supported or not + */ if (!_XSERVTransIsLocal(ci)) { return -1; } +#endif + + if (pSuppGids != NULL) + *pSuppGids = NULL; + if (nSuppGids != NULL) + *nSuppGids = 0; + fd = _XSERVTransGetConnectionNumber(ci); #ifdef HAS_GETPEEREID if (getpeereid(fd, &uid, &gid) == -1) @@ -1427,6 +1467,36 @@ LocalClientCred(ClientPtr client, int *pUid, int *pGid) if (pGid != NULL) *pGid = gid; return 0; +#elif defined(HAS_GETPEERUCRED) + if (getpeerucred(fd, &peercred) < 0) + return -1; +#ifdef sun /* Ensure process is in the same zone */ + if (getzoneid() != ucred_getzoneid(peercred)) { + ucred_free(peercred); + return -1; + } +#endif + if (pUid != NULL) + *pUid = ucred_geteuid(peercred); + if (pGid != NULL) + *pGid = ucred_getegid(peercred); + if (pSuppGids != NULL && nSuppGids != NULL) { + const gid_t *gids; + *nSuppGids = ucred_getgroups(peercred, &gids); + if (*nSuppGids > 0) { + *pSuppGids = xalloc(sizeof(int) * (*nSuppGids)); + if (*pSuppGids == NULL) { + *nSuppGids = 0; + } else { + int i; + for (i = 0 ; i < *nSuppGids; i++) { + (*pSuppGids)[i] = (int) gids[i]; + } + } + } + } + ucred_free(peercred); + return 0; #elif defined(SO_PEERCRED) if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &peercred, &so_len) == -1) return -1; @@ -1438,6 +1508,7 @@ LocalClientCred(ClientPtr client, int *pUid, int *pGid) #endif #else /* No system call available to get the credentials of the peer */ +#define NO_LOCAL_CLIENT_CRED return -1; #endif } @@ -1743,7 +1814,6 @@ InvalidHost ( return 0; } } - return 1; } else return 0; } @@ -2206,6 +2276,121 @@ siIPv6CheckAddr(const char *addrString, int length, void *typePriv) } #endif /* IPv6 */ +#if !defined(NO_LOCAL_CLIENT_CRED) +/*** + * "localuser" & "localgroup" server interpreted types + * + * Allows local connections from a given local user or group + */ + +#include <pwd.h> +#include <grp.h> + +#define LOCAL_USER 1 +#define LOCAL_GROUP 2 + +typedef struct { + int credType; +} siLocalCredPrivRec, *siLocalCredPrivPtr; + +static siLocalCredPrivRec siLocalUserPriv = { LOCAL_USER }; +static siLocalCredPrivRec siLocalGroupPriv = { LOCAL_GROUP }; + +static Bool +siLocalCredGetId(const char *addr, int len, siLocalCredPrivPtr lcPriv, int *id) +{ + Bool parsedOK = FALSE; + char *addrbuf = xalloc(len + 1); + + if (addrbuf == NULL) { + return FALSE; + } + + memcpy(addrbuf, addr, len); + addrbuf[len] = '\0'; + + if (addr[0] == '#') { /* numeric id */ + char *cp; + errno = 0; + *id = strtol(addrbuf + 1, &cp, 0); + if ((errno == 0) && (cp != (addrbuf+1))) { + parsedOK = TRUE; + } + } else { /* non-numeric name */ + if (lcPriv->credType == LOCAL_USER) { + struct passwd *pw = getpwnam(addrbuf); + + if (pw != NULL) { + *id = (int) pw->pw_uid; + parsedOK = TRUE; + } + } else { /* group */ + struct group *gr = getgrnam(addrbuf); + + if (gr != NULL) { + *id = (int) gr->gr_gid; + parsedOK = TRUE; + } + } + } + + xfree(addrbuf); + return parsedOK; +} + +static Bool +siLocalCredAddrMatch(int family, pointer addr, int len, + const char *siAddr, int siAddrlen, ClientPtr client, void *typePriv) +{ + int connUid, connGid, *connSuppGids, connNumSuppGids, siAddrId; + siLocalCredPrivPtr lcPriv = (siLocalCredPrivPtr) typePriv; + + if (LocalClientCredAndGroups(client, &connUid, &connGid, + &connSuppGids, &connNumSuppGids) == -1) { + return FALSE; + } + + if (siLocalCredGetId(siAddr, siAddrlen, lcPriv, &siAddrId) == FALSE) { + return FALSE; + } + + if (lcPriv->credType == LOCAL_USER) { + if (connUid == siAddrId) { + return TRUE; + } + } else { + if (connGid == siAddrId) { + return TRUE; + } + if (connSuppGids != NULL) { + int i; + + for (i = 0 ; i < connNumSuppGids; i++) { + if (connSuppGids[i] == siAddrId) { + xfree(connSuppGids); + return TRUE; + } + } + xfree(connSuppGids); + } + } + return FALSE; +} + +static int +siLocalCredCheckAddr(const char *addrString, int length, void *typePriv) +{ + int len = length; + int id; + + if (siLocalCredGetId(addrString, length, + (siLocalCredPrivPtr)typePriv, &id) == FALSE) { + len = -1; + } + return len; +} +#endif /* localuser */ + static void siTypesInitialize(void) { @@ -2213,4 +2398,10 @@ siTypesInitialize(void) #if defined(IPv6) && defined(AF_INET6) siTypeAdd("ipv6", siIPv6AddrMatch, siIPv6CheckAddr, NULL); #endif +#if !defined(NO_LOCAL_CLIENT_CRED) + siTypeAdd("localuser", siLocalCredAddrMatch, siLocalCredCheckAddr, + &siLocalUserPriv); + siTypeAdd("localgroup", siLocalCredAddrMatch, siLocalCredCheckAddr, + &siLocalGroupPriv); +#endif } @@ -385,10 +385,10 @@ LogMessage(MessageType type, const char *format, ...) } #ifdef __GNUC__ -static void AbortServer(void) __attribute__((noreturn)); +void AbortServer(void) __attribute__((noreturn)); #endif -static void +void AbortServer(void) { OsCleanup(TRUE); @@ -487,6 +487,15 @@ VAuditF(const char *f, va_list args) prefix = AuditPrefix(); len = vsnprintf(buf, sizeof(buf), f, args); +#if 1 + /* XXX Compressing duplicated messages is temporarily disabled to + * work around bugzilla 964: + * https://freedesktop.org/bugzilla/show_bug.cgi?id=964 + */ + ErrorF("%s%s", prefix != NULL ? prefix : "", buf); + oldlen = -1; + nrepeat = 0; +#else if (len == oldlen && strcmp(buf, oldbuf) == 0) { /* Message already seen */ nrepeat++; @@ -500,6 +509,7 @@ VAuditF(const char *f, va_list args) nrepeat = 0; auditTimer = TimerSet(auditTimer, 0, AUDIT_TIMEOUT, AuditFlush, NULL); } +#endif if (prefix != NULL) free(prefix); } diff --git a/os/utils.c b/os/utils.c index 5b9ca5436..522530a7b 100644 --- a/os/utils.c +++ b/os/utils.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/os/utils.c,v 1.1.4.6.2.4 2004/03/04 17:48:31 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/os/utils.c,v 1.6 2004/08/11 22:27:50 kem Exp $ */ /* $Xorg: utils.c,v 1.5 2001/02/09 02:05:24 xorgcvs Exp $ */ /* @@ -119,6 +119,7 @@ OR PERFORMANCE OF THIS SOFTWARE. #ifdef RENDER #include "picture.h" +Bool noRenderExtension = FALSE; #endif #define X_INCLUDE_NETDB_H @@ -137,6 +138,14 @@ Bool PanoramiXWindowExposureSent = FALSE; Bool PanoramiXOneExposeRequest = FALSE; #endif +#ifdef XEVIE +Bool noXevieExtension = TRUE; +#endif + +#ifdef COMPOSITE +Bool noCompositeExtension = TRUE; +#endif + int auditTrailLevel = 1; Bool Must_have_memory = FALSE; @@ -170,6 +179,10 @@ char *dev_tty_from_init = NULL; /* since we need to parse it anyway */ extern char dispatchExceptionAtReset; +/* Extension enable/disable in miinitext.c */ +extern Bool EnableDisableExtension(char *name, Bool enable); +extern void EnableDisableExtensionError(char *name, Bool enable); + OsSigHandlerPtr OsSignal(sig, handler) int sig; @@ -516,6 +529,8 @@ void UseMsg(void) ErrorF("nologo disable logo in screen saver\n"); #endif ErrorF("-nolisten string don't listen on protocol\n"); + ErrorF("-noreset don't reset after last client exists\n"); + ErrorF("-reset reset after last client exists\n"); ErrorF("-p # screen-saver pattern duration (minutes)\n"); ErrorF("-pn accept failure to listen on all ports\n"); ErrorF("-nopn reject failure to listen on all ports\n"); @@ -547,6 +562,8 @@ void UseMsg(void) ErrorF("-dumbSched Disable smart scheduling, enable old behavior\n"); ErrorF("-schedInterval int Set scheduler interval in msec\n"); #endif + ErrorF("+extension name Enable extension\n"); + ErrorF("-extension name Disable extension\n"); #ifdef XDMCP XdmcpUseMsg(); #endif @@ -576,6 +593,17 @@ VerifyDisplayName(const char *d) } /* + * This function is responsible for doing initalisation of any global + * variables at an very early point of server startup (even before + * |ProcessCommandLine()|. + */ +void InitGlobals(void) +{ + ddxInitGlobals(); +} + + +/* * This function parses the command line. Handles device-independent fields * and allows ddx to handle additional fields. It is not allowed to modify * argc or any of the strings pointed to by argv. @@ -812,6 +840,10 @@ ProcessCommandLine(int argc, char *argv[]) { dispatchExceptionAtReset = 0; } + else if ( strcmp( argv[i], "-reset") == 0) + { + dispatchExceptionAtReset = DE_RESET; + } else if ( strcmp( argv[i], "-p") == 0) { if(++i < argc) @@ -982,6 +1014,26 @@ ProcessCommandLine(int argc, char *argv[]) UseMsg (); } #endif + else if ( strcmp( argv[i], "+extension") == 0) + { + if (++i < argc) + { + if (!EnableDisableExtension(argv[i], TRUE)) + EnableDisableExtensionError(argv[i], TRUE); + } + else + UseMsg(); + } + else if ( strcmp( argv[i], "-extension") == 0) + { + if (++i < argc) + { + if (!EnableDisableExtension(argv[i], FALSE)) + EnableDisableExtensionError(argv[i], FALSE); + } + else + UseMsg(); + } else { ErrorF("Unrecognized option: %s\n", argv[i]); @@ -1846,16 +1898,24 @@ enum BadCode { InternalError }; +#if defined(VENDORSUPPORT) +#define BUGADDRESS VENDORSUPPORT +#elif defined(BUILDERADDR) +#define BUGADDRESS BUILDERADDR +#else +#define BUGADDRESS "xorg@freedesktop.org" +#endif + #define ARGMSG \ "\nIf the arguments used are valid, and have been rejected incorrectly\n" \ "please send details of the arguments and why they are valid to\n" \ - "&&&&&@X.org. In the meantime, you can start the Xserver as\n" \ + "%s. In the meantime, you can start the Xserver as\n" \ "the \"super user\" (root).\n" #define ENVMSG \ "\nIf the environment is valid, and have been rejected incorrectly\n" \ "please send details of the environment and why it is valid to\n" \ - "&&&&&@X.org. In the meantime, you can start the Xserver as\n" \ + "%s. In the meantime, you can start the Xserver as\n" \ "the \"super user\" (root).\n" void @@ -1963,20 +2023,20 @@ CheckUserParameters(int argc, char **argv, char **envp) return; case UnsafeArg: ErrorF("Command line argument number %d is unsafe\n", i); - ErrorF(ARGMSG); + ErrorF(ARGMSG, BUGADDRESS); break; case ArgTooLong: ErrorF("Command line argument number %d is too long\n", i); - ErrorF(ARGMSG); + ErrorF(ARGMSG, BUGADDRESS); break; case UnprintableArg: ErrorF("Command line argument number %d contains unprintable" " characters\n", i); - ErrorF(ARGMSG); + ErrorF(ARGMSG, BUGADDRESS); break; case EnvTooLong: ErrorF("Environment variable `%s' is too long\n", e); - ErrorF(ENVMSG); + ErrorF(ENVMSG, BUGADDRESS); break; case OutputIsPipe: ErrorF("Stdout and/or stderr is a pipe\n"); @@ -1986,8 +2046,8 @@ CheckUserParameters(int argc, char **argv, char **envp) break; default: ErrorF("Unknown error\n"); - ErrorF(ARGMSG); - ErrorF(ENVMSG); + ErrorF(ARGMSG, BUGADDRESS); + ErrorF(ENVMSG, BUGADDRESS); break; } FatalError("X server aborted because of unsafe environment\n"); diff --git a/os/xalloc.c b/os/xalloc.c index 5677896dc..6740e89cb 100644 --- a/os/xalloc.c +++ b/os/xalloc.c @@ -185,6 +185,7 @@ extern Bool Must_have_memory; defined(__sparc64__) || \ defined(__s390x__) || \ defined(__amd64__) || defined(amd64) || \ + defined(__powerpc64__) || \ (defined(sgi) && _MIPS_SZLONG == 64)) #define MAGIC 0x1404196414071968 #define MAGIC_FREE 0x1506196615061966 diff --git a/os/xdmcp.c b/os/xdmcp.c index 87e207382..96478d7bb 100644 --- a/os/xdmcp.c +++ b/os/xdmcp.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/os/xdmcp.c,v 1.1.4.3.2.4 2004/07/19 18:59:05 ago Exp $ */ +/* $XdotOrg: xc/programs/Xserver/os/xdmcp.c,v 1.3 2004/07/20 15:15:13 ago Exp $ */ /* $Xorg: xdmcp.c,v 1.4 2001/01/31 13:37:19 pookie Exp $ */ /* * Copyright 1989 Network Computing Devices, Inc., Mountain View, California. diff --git a/record/record.c b/record/record.c index 85c74d1f3..117bba864 100644 --- a/record/record.c +++ b/record/record.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/record/record.c,v 1.1.4.4.2.2 2004/03/04 17:48:44 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/record/record.c,v 1.2 2004/04/23 19:54:28 eich Exp $ */ /* $Xorg: record.c,v 1.4 2001/02/09 02:05:27 xorgcvs Exp $ */ /* diff --git a/render/filter.c b/render/filter.c index 4435197e2..cb9297e9c 100644 --- a/render/filter.c +++ b/render/filter.c @@ -1,7 +1,7 @@ /* - * $XFree86$ + * $Id$ * - * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc. + * Copyright © 2002 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 @@ -22,6 +22,9 @@ * PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif #include "misc.h" #include "scrnintstr.h" #include "os.h" @@ -40,6 +43,12 @@ static char **filterNames; static int nfilterNames; +/* + * standard but not required filters don't have constant indices + */ + +int pictFilterConvolution; + int PictureGetFilterId (char *filter, int len, Bool makeit) { @@ -50,15 +59,14 @@ PictureGetFilterId (char *filter, int len, Bool makeit) if (len < 0) len = strlen (filter); for (i = 0; i < nfilterNames; i++) - if (len == strlen (filterNames[i]) && - !strncmp (filterNames[i], filter, len)) + if (!CompareISOLatin1Lowered ((unsigned char *) filterNames[i], -1, (unsigned char *) filter, len)) return i; if (!makeit) return -1; - name = xalloc (strlen (filter) + 1); + name = xalloc (len + 1); if (!name) return -1; - strncpy (name, filter, len); + memcpy (name, filter, len); name[len] = '\0'; if (filterNames) names = xrealloc (filterNames, (nfilterNames + 1) * sizeof (char *)); @@ -116,7 +124,9 @@ PictureFreeFilterIds (void) } int -PictureAddFilter (ScreenPtr pScreen, char *filter, xFixed *params, int nparams) +PictureAddFilter (ScreenPtr pScreen, + char *filter, + PictFilterValidateParamsProcPtr ValidateParams) { PictureScreenPtr ps = GetPictureScreen(pScreen); int id = PictureGetFilterId (filter, -1, TRUE); @@ -140,9 +150,8 @@ PictureAddFilter (ScreenPtr pScreen, char *filter, xFixed *params, int nparams) ps->filters = filters; i = ps->nfilters++; ps->filters[i].name = PictureGetFilterName (id); - ps->filters[i].params = params; - ps->filters[i].nparams = nparams; ps->filters[i].id = id; + ps->filters[i].ValidateParams = ValidateParams; return id; } @@ -209,9 +218,9 @@ PictureSetDefaultFilters (ScreenPtr pScreen) if (!filterNames) if (!PictureSetDefaultIds ()) return FALSE; - if (PictureAddFilter (pScreen, FilterNearest, 0, 0) < 0) + if (PictureAddFilter (pScreen, FilterNearest, 0) < 0) return FALSE; - if (PictureAddFilter (pScreen, FilterBilinear, 0, 0) < 0) + if (PictureAddFilter (pScreen, FilterBilinear, 0) < 0) return FALSE; if (!PictureSetFilterAlias (pScreen, FilterNearest, FilterFast)) @@ -243,21 +252,26 @@ SetPictureFilter (PicturePtr pPicture, char *name, int len, xFixed *params, int if (!pFilter) return BadName; - if (nparams > pFilter->nparams) + if (pFilter->ValidateParams) + { + if (!(*pFilter->ValidateParams) (pPicture, pFilter->id, params, nparams)) + return BadMatch; + } + else if (nparams) return BadMatch; - if (pFilter->nparams != pPicture->filter_nparams) + + if (nparams != pPicture->filter_nparams) { - new_params = xalloc (pFilter->nparams * sizeof (xFixed)); + new_params = xalloc (nparams * sizeof (xFixed)); if (!new_params) return BadAlloc; xfree (pPicture->filter_params); pPicture->filter_params = new_params; - pPicture->filter_nparams = pFilter->nparams; + pPicture->filter_nparams = nparams; } for (i = 0; i < nparams; i++) pPicture->filter_params[i] = params[i]; - for (; i < pFilter->nparams; i++) - pPicture->filter_params[i] = pFilter->params[i]; pPicture->filter = pFilter->id; + pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT; return Success; } diff --git a/render/glyph.c b/render/glyph.c index 5dd700581..e4c2f689e 100644 --- a/render/glyph.c +++ b/render/glyph.c @@ -89,6 +89,50 @@ FindGlyphHashSet (CARD32 filled) return 0; } +static int _GlyphSetPrivateAllocateIndex = 0; + +int +AllocateGlyphSetPrivateIndex (void) +{ + return _GlyphSetPrivateAllocateIndex++; +} + +void +ResetGlyphSetPrivateIndex (void) +{ + _GlyphSetPrivateAllocateIndex = 0; +} + +Bool +_GlyphSetSetNewPrivate (GlyphSetPtr glyphSet, int n, pointer ptr) +{ + pointer *new; + + if (n > glyphSet->maxPrivate) { + if (glyphSet->devPrivates && + glyphSet->devPrivates != (pointer)(&glyphSet[1])) { + new = (pointer *) xrealloc (glyphSet->devPrivates, + (n + 1) * sizeof (pointer)); + if (!new) + return FALSE; + } else { + new = (pointer *) xalloc ((n + 1) * sizeof (pointer)); + if (!new) + return FALSE; + if (glyphSet->devPrivates) + memcpy (new, + glyphSet->devPrivates, + (glyphSet->maxPrivate + 1) * sizeof (pointer)); + } + glyphSet->devPrivates = new; + /* Zero out new, uninitialize privates */ + while (++glyphSet->maxPrivate < n) + glyphSet->devPrivates[glyphSet->maxPrivate] = (pointer)0; + } + glyphSet->devPrivates[n] = ptr; + return TRUE; +} + Bool GlyphInit (ScreenPtr pScreen) { @@ -363,15 +407,24 @@ GlyphSetPtr AllocateGlyphSet (int fdepth, PictFormatPtr format) { GlyphSetPtr glyphSet; + int size; if (!globalGlyphs[fdepth].hashSet) { if (!AllocateGlyphHash (&globalGlyphs[fdepth], &glyphHashSets[0])) return FALSE; } - glyphSet = xalloc (sizeof (GlyphSetRec)); + + size = (sizeof (GlyphSetRec) + + (sizeof (pointer) * _GlyphSetPrivateAllocateIndex)); + glyphSet = xalloc (size); if (!glyphSet) return FALSE; + bzero((char *)glyphSet, size); + glyphSet->maxPrivate = _GlyphSetPrivateAllocateIndex - 1; + if (_GlyphSetPrivateAllocateIndex) + glyphSet->devPrivates = (pointer)(&glyphSet[1]); + if (!AllocateGlyphHash (&glyphSet->hash, &glyphHashSets[0])) { xfree (glyphSet); @@ -410,6 +463,11 @@ FreeGlyphSet (pointer value, else ResizeGlyphHash (&globalGlyphs[glyphSet->fdepth], 0, TRUE); xfree (table); + + if (glyphSet->devPrivates && + glyphSet->devPrivates != (pointer)(&glyphSet[1])) + xfree(glyphSet->devPrivates); + xfree (glyphSet); } return Success; diff --git a/render/glyphstr.h b/render/glyphstr.h index 68d6f2085..0f496d704 100644 --- a/render/glyphstr.h +++ b/render/glyphstr.h @@ -68,8 +68,20 @@ typedef struct _GlyphSet { PictFormatPtr format; int fdepth; GlyphHashRec hash; + int maxPrivate; + pointer *devPrivates; } GlyphSetRec, *GlyphSetPtr; +#define GlyphSetGetPrivate(pGlyphSet,n) \ + ((n) > (pGlyphSet)->maxPrivate ? \ + (pointer) 0 : \ + (pGlyphSet)->devPrivates[n]) + +#define GlyphSetSetPrivate(pGlyphSet,n,ptr) \ + ((n) > (pGlyphSet)->maxPrivate ? \ + _GlyphSetSetNewPrivate(pGlyphSet, n, ptr) : \ + ((((pGlyphSet)->devPrivates[n] = (ptr)) != 0) || TRUE)) + typedef struct _GlyphList { INT16 xOff; INT16 yOff; @@ -82,6 +94,15 @@ extern GlyphHashRec globalGlyphs[GlyphFormatNum]; GlyphHashSetPtr FindGlyphHashSet (CARD32 filled); +int +AllocateGlyphSetPrivateIndex (void); + +void +ResetGlyphSetPrivateIndex (void); + +Bool +_GlyphSetSetNewPrivate (GlyphSetPtr glyphSet, int n, pointer ptr); + Bool GlyphInit (ScreenPtr pScreen); diff --git a/render/mipict.c b/render/mipict.c index ed97acc7b..8e51ebeab 100644 --- a/render/mipict.c +++ b/render/mipict.c @@ -249,8 +249,7 @@ miValidatePicture (PicturePtr pPicture, #define BOUND(v) (INT16) ((v) < MINSHORT ? MINSHORT : (v) > MAXSHORT ? MAXSHORT : (v)) static __inline Bool -miClipPictureReg (ScreenPtr pScreen, - RegionPtr pRegion, +miClipPictureReg (RegionPtr pRegion, RegionPtr pClip, int dx, int dy) @@ -276,19 +275,22 @@ miClipPictureReg (ScreenPtr pScreen, REGION_EMPTY(pScreen, pRegion); } } + else if (!REGION_NOTEMPTY (pScreen, pClip)) + return FALSE; else { - REGION_TRANSLATE(pScreen, pRegion, dx, dy); + if (dx || dy) + REGION_TRANSLATE(pScreen, pRegion, -dx, -dy); if (!REGION_INTERSECT (pScreen, pRegion, pRegion, pClip)) return FALSE; - REGION_TRANSLATE(pScreen, pRegion, -dx, -dy); + if (dx || dy) + REGION_TRANSLATE(pScreen, pRegion, dx, dy); } - return TRUE; + return REGION_NOTEMPTY(pScreen, pRegion); } static __inline Bool -miClipPictureSrc (ScreenPtr pScreen, - RegionPtr pRegion, +miClipPictureSrc (RegionPtr pRegion, PicturePtr pPicture, int dx, int dy) @@ -314,11 +316,70 @@ miClipPictureSrc (ScreenPtr pScreen, } else { - return miClipPictureReg (pScreen, pRegion, pPicture->pCompositeClip, - dx, dy); + return miClipPictureReg (pRegion, + pPicture->pCompositeClip, + dx, + dy); + } +} + +static void +miCompositeSourceValidate (PicturePtr pPicture, + INT16 x, + INT16 y, + CARD16 width, + CARD16 height) +{ + DrawablePtr pDrawable = pPicture->pDrawable; + ScreenPtr pScreen = pDrawable->pScreen; + + if (pScreen->SourceValidate) + { + x -= pPicture->pDrawable->x; + y -= pPicture->pDrawable->y; + if (pPicture->transform) + { + xPoint points[4]; + int i; + int xmin, ymin, xmax, ymax; + +#define VectorSet(i,_x,_y) { points[i].x = _x; points[i].y = _y; } + VectorSet (0, x, y); + VectorSet (1, x + width, y); + VectorSet (2, x, y + height); + VectorSet (3, x + width, y + height); + xmin = ymin = 32767; + xmax = ymax = -32737; + for (i = 0; i < 4; i++) + { + PictVector t; + t.vector[0] = IntToxFixed (points[i].x); + t.vector[1] = IntToxFixed (points[i].y); + t.vector[2] = xFixed1; + if (PictureTransformPoint (pPicture->transform, &t)) + { + int tx = xFixedToInt (t.vector[0]); + int ty = xFixedToInt (t.vector[1]); + if (tx < xmin) xmin = tx; + if (tx > xmax) xmax = tx; + if (ty < ymin) ymin = ty; + if (ty > ymax) ymax = ty; + } + } + x = xmin; + y = ymin; + width = xmax - xmin; + height = ymax - ymin; + } + (*pScreen->SourceValidate) (pDrawable, x, y, width, height); } } +/* + * returns FALSE if the final region is empty. Indistinguishable from + * an allocation failure, but rendering ignores those anyways. + */ + Bool miComputeCompositeRegion (RegionPtr pRegion, PicturePtr pSrc, @@ -333,7 +394,6 @@ miComputeCompositeRegion (RegionPtr pRegion, CARD16 width, CARD16 height) { - ScreenPtr pScreen = pSrc->pDrawable->pScreen; int v; pRegion->extents.x1 = xDst; @@ -347,18 +407,34 @@ miComputeCompositeRegion (RegionPtr pRegion, if (pRegion->extents.x1 >= pRegion->extents.x2 || pRegion->extents.y1 >= pRegion->extents.y2) { - REGION_EMPTY (pScreen, pRegion); - return TRUE; + REGION_EMPTY (pDst->pDrawable->pScreen, pRegion); + return FALSE; + } + /* clip against dst */ + if (!miClipPictureReg (pRegion, pDst->pCompositeClip, 0, 0)) + { + REGION_UNINIT (pScreen, pRegion); + return FALSE; + } + if (pDst->alphaMap) + { + if (!miClipPictureReg (pRegion, pDst->alphaMap->pCompositeClip, + -pDst->alphaOrigin.x, + -pDst->alphaOrigin.y)) + { + REGION_UNINIT (pScreen, pRegion); + return FALSE; + } } /* clip against src */ - if (!miClipPictureSrc (pScreen, pRegion, pSrc, xDst - xSrc, yDst - ySrc)) + if (!miClipPictureSrc (pRegion, pSrc, xDst - xSrc, yDst - ySrc)) { REGION_UNINIT (pScreen, pRegion); return FALSE; } if (pSrc->alphaMap) { - if (!miClipPictureSrc (pScreen, pRegion, pSrc->alphaMap, + if (!miClipPictureSrc (pRegion, pSrc->alphaMap, xDst - (xSrc + pSrc->alphaOrigin.x), yDst - (ySrc + pSrc->alphaOrigin.y))) { @@ -369,15 +445,14 @@ miComputeCompositeRegion (RegionPtr pRegion, /* clip against mask */ if (pMask) { - if (!miClipPictureSrc (pScreen, pRegion, pMask, - xDst - xMask, yDst - yMask)) + if (!miClipPictureSrc (pRegion, pMask, xDst - xMask, yDst - yMask)) { REGION_UNINIT (pScreen, pRegion); return FALSE; } if (pMask->alphaMap) { - if (!miClipPictureSrc (pScreen, pRegion, pMask->alphaMap, + if (!miClipPictureSrc (pRegion, pMask->alphaMap, xDst - (xMask + pMask->alphaOrigin.x), yDst - (yMask + pMask->alphaOrigin.y))) { @@ -386,22 +461,9 @@ miComputeCompositeRegion (RegionPtr pRegion, } } } - if (!miClipPictureReg (pScreen, pRegion, pDst->pCompositeClip, 0, 0)) - { - REGION_UNINIT (pScreen, pRegion); - return FALSE; - } - if (pDst->alphaMap) - { - if (!miClipPictureReg (pScreen, - pRegion, pDst->alphaMap->pCompositeClip, - -pDst->alphaOrigin.x, - -pDst->alphaOrigin.y)) - { - REGION_UNINIT (pScreen, pRegion); - return FALSE; - } - } + miCompositeSourceValidate (pSrc, xSrc, ySrc, width, height); + if (pMask) + miCompositeSourceValidate (pMask, xMask, yMask, width, height); return TRUE; } @@ -456,6 +518,35 @@ miFillColor (CARD32 pixel, int bits) return (CARD16) pixel; } +Bool +miIsSolidAlpha (PicturePtr pSrc) +{ + ScreenPtr pScreen = pSrc->pDrawable->pScreen; + char line[1]; + + /* Alpha-only */ + if (PICT_FORMAT_TYPE (pSrc->format) != PICT_TYPE_A) + return FALSE; + /* repeat */ + if (!pSrc->repeat) + return FALSE; + /* 1x1 */ + if (pSrc->pDrawable->width != 1 || pSrc->pDrawable->height != 1) + return FALSE; + line[0] = 1; + (*pScreen->GetImage) (pSrc->pDrawable, 0, 0, 1, 1, ZPixmap, ~0L, line); + switch (pSrc->pDrawable->bitsPerPixel) { + case 1: + return (CARD8) line[0] == 1 || (CARD8) line[0] == 0x80; + case 4: + return (CARD8) line[0] == 0xf || (CARD8) line[0] == 0xf0; + case 8: + return (CARD8) line[0] == 0xff; + default: + return FALSE; + } +} + void miRenderPixelToColor (PictFormatPtr format, CARD32 pixel, @@ -516,5 +607,9 @@ miPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats) ps->TriStrip = miTriStrip; ps->TriFan = miTriFan; + ps->RasterizeTrapezoid = 0; /* requires DDX support */ + ps->AddTraps = 0; /* requires DDX support */ + ps->AddTriangles = 0; /* requires DDX support */ + return TRUE; } diff --git a/render/mipict.h b/render/mipict.h index 4af4c56be..f990e7939 100644 --- a/render/mipict.h +++ b/render/mipict.h @@ -124,6 +124,9 @@ miRenderPixelToColor (PictFormatPtr pPict, CARD32 pixel, xRenderColor *color); +Bool +miIsSolidAlpha (PicturePtr pSrc); + void miCompositeRects (CARD8 op, PicturePtr pDst, diff --git a/render/mirect.c b/render/mirect.c index 63e9c7cc4..bb50e8583 100644 --- a/render/mirect.c +++ b/render/mirect.c @@ -42,7 +42,7 @@ miColorRects (PicturePtr pDst, ScreenPtr pScreen = pDst->pDrawable->pScreen; CARD32 pixel; GCPtr pGC; - CARD32 tmpval[4]; + CARD32 tmpval[5]; RegionPtr pClip; unsigned long mask; @@ -53,12 +53,13 @@ miColorRects (PicturePtr pDst, return; tmpval[0] = GXcopy; tmpval[1] = pixel; - mask = GCFunction | GCForeground; + tmpval[2] = pDst->subWindowMode; + mask = GCFunction | GCForeground | GCSubwindowMode; if (pClipPict->clientClipType == CT_REGION) { - tmpval[2] = pDst->clipOrigin.x - xoff; - tmpval[3] = pDst->clipOrigin.y - yoff; - mask |= CPClipXOrigin|CPClipYOrigin; + tmpval[3] = pDst->clipOrigin.x - xoff; + tmpval[4] = pDst->clipOrigin.y - yoff; + mask |= GCClipXOrigin|GCClipYOrigin; pClip = REGION_CREATE (pScreen, NULL, 1); REGION_COPY (pScreen, pClip, diff --git a/render/mitrap.c b/render/mitrap.c index 05db36ec8..77cdcf03f 100644 --- a/render/mitrap.c +++ b/render/mitrap.c @@ -136,16 +136,25 @@ miTrapezoids (CARD8 op, { ScreenPtr pScreen = pDst->pDrawable->pScreen; PictureScreenPtr ps = GetPictureScreen(pScreen); - PicturePtr pPicture = 0; - BoxRec bounds; - INT16 xDst, yDst; - INT16 xRel, yRel; - - xDst = traps[0].left.p1.x >> 16; - yDst = traps[0].left.p1.y >> 16; - - if (maskFormat) + + /* + * Check for solid alpha add + */ + if (op == PictOpAdd && miIsSolidAlpha (pSrc)) + { + for (; ntrap; ntrap--, traps++) + (*ps->RasterizeTrapezoid) (pDst, traps, 0, 0); + } + else if (maskFormat) { + PicturePtr pPicture; + BoxRec bounds; + INT16 xDst, yDst; + INT16 xRel, yRel; + + xDst = traps[0].left.p1.x >> 16; + yDst = traps[0].left.p1.y >> 16; + miTrapezoidBounds (ntrap, traps, &bounds); if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2) return; @@ -154,37 +163,9 @@ miTrapezoids (CARD8 op, bounds.y2 - bounds.y1); if (!pPicture) return; - } - for (; ntrap; ntrap--, traps++) - { - if (!xTrapezoidValid(traps)) - continue; - if (!maskFormat) - { - miTrapezoidBounds (1, traps, &bounds); - if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2) - continue; - pPicture = miCreateAlphaPicture (pScreen, pDst, maskFormat, - bounds.x2 - bounds.x1, - bounds.y2 - bounds.y1); - if (!pPicture) - continue; - } - (*ps->RasterizeTrapezoid) (pPicture, traps, - -bounds.x1, -bounds.y1); - if (!maskFormat) - { - xRel = bounds.x1 + xSrc - xDst; - yRel = bounds.y1 + ySrc - yDst; - CompositePicture (op, pSrc, pPicture, pDst, - xRel, yRel, 0, 0, bounds.x1, bounds.y1, - bounds.x2 - bounds.x1, - bounds.y2 - bounds.y1); - FreePicture (pPicture, 0); - } - } - if (maskFormat) - { + for (; ntrap; ntrap--, traps++) + (*ps->RasterizeTrapezoid) (pPicture, traps, + -bounds.x1, -bounds.y1); xRel = bounds.x1 + xSrc - xDst; yRel = bounds.y1 + ySrc - yDst; CompositePicture (op, pSrc, pPicture, pDst, @@ -193,4 +174,13 @@ miTrapezoids (CARD8 op, bounds.y2 - bounds.y1); FreePicture (pPicture, 0); } + else + { + if (pDst->polyEdge == PolyEdgeSharp) + maskFormat = PictureMatchFormat (pScreen, 1, PICT_a1); + else + maskFormat = PictureMatchFormat (pScreen, 8, PICT_a8); + for (; ntrap; ntrap--, traps++) + miTrapezoids (op, pSrc, pDst, maskFormat, xSrc, ySrc, 1, traps); + } } diff --git a/render/mitri.c b/render/mitri.c index b0526256d..5d5df1c61 100644 --- a/render/mitri.c +++ b/render/mitri.c @@ -65,82 +65,6 @@ miTriangleBounds (int ntri, xTriangle *tris, BoxPtr bounds) } void -miRasterizeTriangle (PicturePtr pPicture, - xTriangle *tri, - int x_off, - int y_off) -{ - ScreenPtr pScreen = pPicture->pDrawable->pScreen; - PictureScreenPtr ps = GetPictureScreen(pScreen); - xPointFixed *top, *left, *right, *t; - xTrapezoid trap[2]; - - top = &tri->p1; - left = &tri->p2; - right = &tri->p3; - if (left->y < top->y) { - t = left; left = top; top = t; - } - if (right->y < top->y) { - t = right; right = top; top = t; - } - if (right->x < left->x) { - t = right; right = left; left = t; - } - - /* - * Two cases: - * - * + + - * / \ / \ - * / \ / \ - * / + + \ - * / -- -- \ - * / -- -- \ - * / --- --- \ - * +-- --+ - */ - - trap[0].top = top->y; - - trap[0].left.p1.x = top->x; - trap[0].left.p1.y = trap[0].top; - trap[0].left.p2.x = left->x; - trap[0].left.p2.y = left->y; - - trap[0].right.p1 = trap[0].left.p1; - trap[0].right.p2.x = right->x; - trap[0].right.p2.y = right->y; - - if (right->y < left->y) - { - trap[0].bottom = trap[0].right.p2.y; - - trap[1].top = trap[0].bottom; - trap[1].bottom = trap[0].left.p2.y; - - trap[1].left = trap[0].left; - trap[1].right.p1 = trap[0].right.p2; - trap[1].right.p2 = trap[0].left.p2; - } - else - { - trap[0].bottom = trap[0].left.p2.y; - - trap[1].top = trap[0].bottom; - trap[1].bottom = trap[0].right.p2.y; - - trap[1].right = trap[0].right; - trap[1].left.p1 = trap[0].left.p2; - trap[1].left.p2 = trap[0].right.p2; - } - if (trap[0].top != trap[0].bottom) - (*ps->RasterizeTrapezoid) (pPicture, &trap[0], x_off, y_off); - if (trap[1].top != trap[1].bottom) - (*ps->RasterizeTrapezoid) (pPicture, &trap[1], x_off, y_off); -} - -void miTriangles (CARD8 op, PicturePtr pSrc, PicturePtr pDst, @@ -151,16 +75,25 @@ miTriangles (CARD8 op, xTriangle *tris) { ScreenPtr pScreen = pDst->pDrawable->pScreen; - BoxRec bounds; - PicturePtr pPicture = 0; - INT16 xDst, yDst; - INT16 xRel, yRel; - - xDst = tris[0].p1.x >> 16; - yDst = tris[0].p1.y >> 16; + PictureScreenPtr ps = GetPictureScreen(pScreen); - if (maskFormat) + /* + * Check for solid alpha add + */ + if (op == PictOpAdd && miIsSolidAlpha (pSrc)) { + (*ps->AddTriangles) (pDst, 0, 0, ntri, tris); + } + else if (maskFormat) + { + BoxRec bounds; + PicturePtr pPicture; + INT16 xDst, yDst; + INT16 xRel, yRel; + + xDst = tris[0].p1.x >> 16; + yDst = tris[0].p1.y >> 16; + miTriangleBounds (ntri, tris, &bounds); if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1) return; @@ -169,34 +102,8 @@ miTriangles (CARD8 op, bounds.y2 - bounds.y1); if (!pPicture) return; - } - for (; ntri; ntri--, tris++) - { - if (!maskFormat) - { - miTriangleBounds (1, tris, &bounds); - if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1) - continue; - pPicture = miCreateAlphaPicture (pScreen, pDst, maskFormat, - bounds.x2 - bounds.x1, - bounds.y2 - bounds.y1); - if (!pPicture) - break; - } - miRasterizeTriangle (pPicture, tris, -bounds.x1, -bounds.y1); - if (!maskFormat) - { - xRel = bounds.x1 + xSrc - xDst; - yRel = bounds.y1 + ySrc - yDst; - CompositePicture (op, pSrc, pPicture, pDst, - xRel, yRel, 0, 0, bounds.x1, bounds.y1, - bounds.x2 - bounds.x1, bounds.y2 - bounds.y1); - FreePicture (pPicture, 0); - } - /* XXX adjust xSrc and ySrc */ - } - if (maskFormat) - { + (*ps->AddTriangles) (pPicture, -bounds.x1, -bounds.y1, ntri, tris); + xRel = bounds.x1 + xSrc - xDst; yRel = bounds.y1 + ySrc - yDst; CompositePicture (op, pSrc, pPicture, pDst, @@ -204,6 +111,16 @@ miTriangles (CARD8 op, bounds.x2 - bounds.x1, bounds.y2 - bounds.y1); FreePicture (pPicture, 0); } + else + { + if (pDst->polyEdge == PolyEdgeSharp) + maskFormat = PictureMatchFormat (pScreen, 1, PICT_a1); + else + maskFormat = PictureMatchFormat (pScreen, 8, PICT_a8); + + for (; ntri; ntri--, tris++) + miTriangles (op, pSrc, pDst, maskFormat, xSrc, ySrc, 1, tris); + } } void @@ -217,64 +134,24 @@ miTriStrip (CARD8 op, xPointFixed *points) { ScreenPtr pScreen = pDst->pDrawable->pScreen; - xTriangle tri; - BoxRec bounds; - PicturePtr pPicture = 0; - INT16 xDst, yDst; - INT16 xRel, yRel; - - xDst = points[0].x >> 16; - yDst = points[0].y >> 16; + PictureScreenPtr ps = GetPictureScreen(pScreen); + xTriangle *tris, *tri; + int ntri; if (npoint < 3) return; - if (maskFormat) - { - miPointFixedBounds (npoint, points, &bounds); - if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1) - return; - pPicture = miCreateAlphaPicture (pScreen, pDst, maskFormat, - bounds.x2 - bounds.x1, - bounds.y2 - bounds.y1); - if (!pPicture) - return; - } - for (; npoint >= 3; npoint--, points++) - { - tri.p1 = points[0]; - tri.p2 = points[1]; - tri.p3 = points[2]; - if (!maskFormat) - { - miTriangleBounds (1, &tri, &bounds); - if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1) - continue; - pPicture = miCreateAlphaPicture (pScreen, pDst, maskFormat, - bounds.x2 - bounds.x1, - bounds.y2 - bounds.y1); - if (!pPicture) - continue; - } - miRasterizeTriangle (pPicture, &tri, -bounds.x1, -bounds.y1); - if (!maskFormat) - { - xRel = bounds.x1 + xSrc - xDst; - yRel = bounds.y1 + ySrc - yDst; - CompositePicture (op, pSrc, pPicture, pDst, - xRel, yRel, 0, 0, bounds.x1, bounds.y1, - bounds.x2 - bounds.x1, bounds.y2 - bounds.y1); - FreePicture (pPicture, 0); - } - } - if (maskFormat) + ntri = npoint - 2; + tris = ALLOCATE_LOCAL (ntri & sizeof (xTriangle)); + if (!tris) + return; + for (tri = tris; npoint >= 3; npoint--, points++, tri++) { - xRel = bounds.x1 + xSrc - xDst; - yRel = bounds.y1 + ySrc - yDst; - CompositePicture (op, pSrc, pPicture, pDst, - xRel, yRel, 0, 0, bounds.x1, bounds.y1, - bounds.x2 - bounds.x1, bounds.y2 - bounds.y1); - FreePicture (pPicture, 0); + tri->p1 = points[0]; + tri->p2 = points[1]; + tri->p3 = points[2]; } + (*ps->Triangles) (op, pSrc, pDst, maskFormat, xSrc, ySrc, ntri, tris); + DEALLOCATE_LOCAL (tris); } void @@ -288,65 +165,24 @@ miTriFan (CARD8 op, xPointFixed *points) { ScreenPtr pScreen = pDst->pDrawable->pScreen; - xTriangle tri; - BoxRec bounds; - PicturePtr pPicture = 0; + PictureScreenPtr ps = GetPictureScreen(pScreen); + xTriangle *tris, *tri; xPointFixed *first; - INT16 xDst, yDst; - INT16 xRel, yRel; - - xDst = points[0].x >> 16; - yDst = points[0].y >> 16; + int ntri; if (npoint < 3) return; - if (maskFormat) - { - miPointFixedBounds (npoint, points, &bounds); - if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1) - return; - pPicture = miCreateAlphaPicture (pScreen, pDst, maskFormat, - bounds.x2 - bounds.x1, - bounds.y2 - bounds.y1); - if (!pPicture) - return; - } + ntri = npoint - 2; + tris = ALLOCATE_LOCAL (ntri & sizeof (xTriangle)); + if (!tris) + return; first = points++; - npoint--; - for (; npoint >= 2; npoint--, points++) + for (tri = tris; npoint >= 3; npoint--, points++, tri++) { - tri.p1 = *first; - tri.p2 = points[0]; - tri.p3 = points[1]; - if (!maskFormat) - { - miTriangleBounds (1, &tri, &bounds); - if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1) - continue; - pPicture = miCreateAlphaPicture (pScreen, pDst, maskFormat, - bounds.x2 - bounds.x1, - bounds.y2 - bounds.y1); - if (!pPicture) - continue; - } - miRasterizeTriangle (pPicture, &tri, -bounds.x1, -bounds.y1); - if (!maskFormat) - { - xRel = bounds.x1 + xSrc - xDst; - yRel = bounds.y1 + ySrc - yDst; - CompositePicture (op, pSrc, pPicture, pDst, - xRel, yRel, 0, 0, bounds.x1, bounds.y1, - bounds.x2 - bounds.x1, bounds.y2 - bounds.y1); - FreePicture (pPicture, 0); - } - } - if (maskFormat) - { - xRel = bounds.x1 + xSrc - xDst; - yRel = bounds.y1 + ySrc - yDst; - CompositePicture (op, pSrc, pPicture, pDst, - xRel, yRel, 0, 0, bounds.x1, bounds.y1, - bounds.x2 - bounds.x1, bounds.y2 - bounds.y1); - FreePicture (pPicture, 0); + tri->p1 = *first; + tri->p2 = points[0]; + tri->p3 = points[1]; } + (*ps->Triangles) (op, pSrc, pDst, maskFormat, xSrc, ySrc, ntri, tris); + DEALLOCATE_LOCAL (tris); } diff --git a/render/picture.c b/render/picture.c index ad746b277..b0c44e694 100644 --- a/render/picture.c +++ b/render/picture.c @@ -23,6 +23,9 @@ * Author: Keith Packard, SuSE, Inc. */ +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif #include "misc.h" #include "scrnintstr.h" #include "os.h" @@ -46,6 +49,57 @@ RESTYPE PictFormatType; RESTYPE GlyphSetType; int PictureCmapPolicy = PictureCmapPolicyDefault; +/* Picture Private machinery */ + +static int picturePrivateCount; + +void +ResetPicturePrivateIndex (void) +{ + picturePrivateCount = 0; +} + +int +AllocatePicturePrivateIndex (void) +{ + return picturePrivateCount++; +} + +Bool +AllocatePicturePrivate (ScreenPtr pScreen, int index2, unsigned int amount) +{ + PictureScreenPtr ps = GetPictureScreen(pScreen); + unsigned int oldamount; + + /* Round up sizes for proper alignment */ + amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long); + + if (index2 >= ps->PicturePrivateLen) + { + unsigned int *nsizes; + + nsizes = (unsigned int *)xrealloc(ps->PicturePrivateSizes, + (index2 + 1) * sizeof(unsigned int)); + if (!nsizes) + return FALSE; + while (ps->PicturePrivateLen <= index2) + { + nsizes[ps->PicturePrivateLen++] = 0; + ps->totalPictureSize += sizeof(DevUnion); + } + ps->PicturePrivateSizes = nsizes; + } + oldamount = ps->PicturePrivateSizes[index2]; + if (amount > oldamount) + { + ps->PicturePrivateSizes[index2] = amount; + ps->totalPictureSize += (amount - oldamount); + } + + return TRUE; +} + + Bool PictureDestroyWindow (WindowPtr pWindow) { @@ -82,6 +136,8 @@ PictureCloseScreen (int index, ScreenPtr pScreen) if (ps->formats[n].type == PictTypeIndexed) (*ps->CloseIndexed) (pScreen, &ps->formats[n]); SetPictureScreen(pScreen, 0); + if (ps->PicturePrivateSizes) + xfree (ps->PicturePrivateSizes); xfree (ps->formats); xfree (ps); return ret; @@ -367,7 +423,7 @@ PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp) case PICT_TYPE_COLOR: case PICT_TYPE_GRAY: pFormats[f].type = PictTypeIndexed; - pFormats[f].index.pVisual = &pScreen->visuals[PICT_FORMAT_VIS(format)]; + pFormats[f].index.vid = pScreen->visuals[PICT_FORMAT_VIS(format)].vid; break; } } @@ -375,6 +431,21 @@ PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp) return pFormats; } +static VisualPtr +PictureFindVisual (ScreenPtr pScreen, VisualID visual) +{ + int i; + VisualPtr pVisual; + for (i = 0, pVisual = pScreen->visuals; + i < pScreen->numVisuals; + i++, pVisual++) + { + if (pVisual->vid == visual) + return pVisual; + } + return 0; +} + Bool PictureInitIndexedFormats (ScreenPtr pScreen) { @@ -390,13 +461,16 @@ PictureInitIndexedFormats (ScreenPtr pScreen) { if (format->type == PictTypeIndexed && !format->index.pColormap) { - if (format->index.pVisual->vid == pScreen->rootVisual) + if (format->index.vid == pScreen->rootVisual) format->index.pColormap = (ColormapPtr) LookupIDByType(pScreen->defColormap, RT_COLORMAP); else { + VisualPtr pVisual; + + pVisual = PictureFindVisual (pScreen, format->index.vid); if (CreateColormap (FakeClientID (0), pScreen, - format->index.pVisual, + pVisual, &format->index.pColormap, AllocNone, 0) != Success) { @@ -480,7 +554,7 @@ PictureMatchVisual (ScreenPtr pScreen, int depth, VisualPtr pVisual) { if (type == PictTypeIndexed) { - if (format->index.pVisual == pVisual) + if (format->index.vid == pVisual->vid) return format; } else @@ -585,7 +659,8 @@ PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats) } if (formats[n].type == PictTypeIndexed) { - if ((formats[n].index.pVisual->class | DynamicClass) == PseudoColor) + VisualPtr pVisual = PictureFindVisual (pScreen, formats[n].index.vid); + if ((pVisual->class | DynamicClass) == PseudoColor) type = PICT_TYPE_COLOR; else type = PICT_TYPE_GRAY; @@ -1027,6 +1102,51 @@ SetPictureClipRects (PicturePtr pPicture, } int +SetPictureClipRegion (PicturePtr pPicture, + int xOrigin, + int yOrigin, + RegionPtr pRegion) +{ + ScreenPtr pScreen = pPicture->pDrawable->pScreen; + PictureScreenPtr ps = GetPictureScreen(pScreen); + RegionPtr clientClip; + int result; + int type; + + if (pRegion) + { + type = CT_REGION; + clientClip = REGION_CREATE (pScreen, + REGION_EXTENTS(pScreen, pRegion), + REGION_NUM_RECTS(pRegion)); + if (!clientClip) + return BadAlloc; + if (!REGION_COPY (pSCreen, clientClip, pRegion)) + { + REGION_DESTROY (pScreen, clientClip); + return BadAlloc; + } + } + else + { + type = CT_NONE; + clientClip = 0; + } + + result =(*ps->ChangePictureClip) (pPicture, type, + (pointer) clientClip, 0); + if (result == Success) + { + pPicture->clipOrigin.x = xOrigin; + pPicture->clipOrigin.y = yOrigin; + pPicture->stateChanges |= CPClipXOrigin|CPClipYOrigin|CPClipMask; + pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT; + } + return result; +} + + +int SetPictureTransform (PicturePtr pPicture, PictTransform *transform) { @@ -1057,9 +1177,94 @@ SetPictureTransform (PicturePtr pPicture, pPicture->transform = 0; } } + pPicture->serialNumber |= GC_CHANGE_SERIAL_BIT; + return Success; } +void +CopyPicture (PicturePtr pSrc, + Mask mask, + PicturePtr pDst) +{ + PictureScreenPtr ps = GetPictureScreen(pSrc->pDrawable->pScreen); + Mask origMask = mask; + + pDst->serialNumber |= GC_CHANGE_SERIAL_BIT; + pDst->stateChanges |= mask; + + while (mask) { + Mask bit = lowbit(mask); + + switch (bit) + { + case CPRepeat: + pDst->repeat = pSrc->repeat; + break; + case CPAlphaMap: + if (pSrc->alphaMap && pSrc->alphaMap->pDrawable->type == DRAWABLE_PIXMAP) + pSrc->alphaMap->refcnt++; + if (pDst->alphaMap) + FreePicture ((pointer) pDst->alphaMap, (XID) 0); + pDst->alphaMap = pSrc->alphaMap; + break; + case CPAlphaXOrigin: + pDst->alphaOrigin.x = pSrc->alphaOrigin.x; + break; + case CPAlphaYOrigin: + pDst->alphaOrigin.y = pSrc->alphaOrigin.y; + break; + case CPClipXOrigin: + pDst->clipOrigin.x = pSrc->clipOrigin.x; + break; + case CPClipYOrigin: + pDst->clipOrigin.y = pSrc->clipOrigin.y; + break; + case CPClipMask: + switch (pSrc->clientClipType) { + case CT_NONE: + (*ps->ChangePictureClip)(pDst, CT_NONE, NULL, 0); + break; + case CT_REGION: + if (!pSrc->clientClip) { + (*ps->ChangePictureClip)(pDst, CT_NONE, NULL, 0); + } else { + RegionPtr clientClip; + RegionPtr srcClientClip = (RegionPtr)pSrc->clientClip; + + clientClip = REGION_CREATE(pSrc->pDrawable->pScreen, + REGION_EXTENTS(pSrc->pDrawable->pScreen, srcClientClip), + REGION_NUM_RECTS(srcClientClip)); + (*ps->ChangePictureClip)(pDst, CT_REGION, clientClip, 0); + } + break; + default: + /* XXX: CT_PIXMAP unimplemented */ + break; + } + break; + case CPGraphicsExposure: + pDst->graphicsExposures = pSrc->graphicsExposures; + break; + case CPPolyEdge: + pDst->polyEdge = pSrc->polyEdge; + break; + case CPPolyMode: + pDst->polyMode = pSrc->polyMode; + break; + case CPDither: + pDst->dither = pSrc->dither; + break; + case CPComponentAlpha: + pDst->componentAlpha = pSrc->componentAlpha; + break; + } + mask &= ~bit; + } + + (*ps->ChangePicture)(pDst, origMask); +} + static void ValidateOnePicture (PicturePtr pPicture) { @@ -1263,7 +1468,18 @@ CompositeTriFan (CARD8 op, (*ps->TriFan) (op, pSrc, pDst, maskFormat, xSrc, ySrc, npoints, points); } -typedef xFixed_32_32 xFixed_48_16; +void +AddTraps (PicturePtr pPicture, + INT16 xOff, + INT16 yOff, + int ntrap, + xTrap *traps) +{ + PictureScreenPtr ps = GetPictureScreen(pPicture->pDrawable->pScreen); + + ValidatePicture (pPicture); + (*ps->AddTraps) (pPicture, xOff, yOff, ntrap, traps); +} #define MAX_FIXED_48_16 ((xFixed_48_16) 0x7fffffff) #define MIN_FIXED_48_16 (-((xFixed_48_16) 1 << 31)) diff --git a/render/picture.h b/render/picture.h index b4e3bd27c..4ed6e6ae0 100644 --- a/render/picture.h +++ b/render/picture.h @@ -160,6 +160,9 @@ extern int PictureCmapPolicy; int PictureParseCmapPolicy (const char *name); +extern int RenderErrBase; +extern int RenderClientPrivateIndex; + /* Fixed point updates from Carl Worth, USC, Information Sciences Institute */ #ifdef WIN32 @@ -183,6 +186,11 @@ typedef long long int xFixed_32_32; # endif #endif +typedef xFixed_32_32 xFixed_48_16; + +#define MAX_FIXED_48_16 ((xFixed_48_16) 0x7fffffff) +#define MIN_FIXED_48_16 (-((xFixed_48_16) 1 << 31)) + typedef CARD32 xFixed_1_31; typedef CARD32 xFixed_1_16; typedef INT32 xFixed_16_16; diff --git a/render/picturestr.h b/render/picturestr.h index ca766ce94..cdeb207a6 100644 --- a/render/picturestr.h +++ b/render/picturestr.h @@ -1,6 +1,5 @@ -/* $XdotOrg: xc/programs/Xserver/render/picturestr.h,v 1.1.4.2.2.2 2004/03/04 17:48:45 eich Exp $ */ /* - * $XFree86: xc/programs/Xserver/render/picturestr.h,v 1.21 2002/11/06 22:45:36 keithp Exp $ + * $Id$ * * Copyright © 2000 SuSE, Inc. * @@ -39,7 +38,7 @@ typedef struct _DirectFormat { } DirectFormatRec; typedef struct _IndexFormat { - VisualPtr pVisual; + VisualID vid; ColormapPtr pColormap; int nvalues; xIndexValue *pValues; @@ -103,11 +102,12 @@ typedef struct _Picture { int filter_nparams; } PictureRec; +typedef Bool (*PictFilterValidateParamsProcPtr) (PicturePtr pPicture, int id, + xFixed *params, int nparams); typedef struct { - char *name; - xFixed *params; - int nparams; - int id; + char *name; + int id; + PictFilterValidateParamsProcPtr ValidateParams; } PictFilterRec, *PictFilterPtr; #define PictFilterNearest 0 @@ -226,6 +226,18 @@ typedef void (*UpdateIndexedProcPtr) (ScreenPtr pScreen, int ndef, xColorItem *pdef); +typedef void (*AddTrapsProcPtr) (PicturePtr pPicture, + INT16 xOff, + INT16 yOff, + int ntrap, + xTrap *traps); + +typedef void (*AddTrianglesProcPtr) (PicturePtr pPicture, + INT16 xOff, + INT16 yOff, + int ntri, + xTriangle *tris); + typedef struct _PictureScreen { int totalPictureSize; unsigned int *PicturePrivateSizes; @@ -273,6 +285,11 @@ typedef struct _PictureScreen { TriFanProcPtr TriFan; RasterizeTrapezoidProcPtr RasterizeTrapezoid; + + AddTrianglesProcPtr AddTriangles; + + AddTrapsProcPtr AddTraps; + } PictureScreenRec, *PictureScreenPtr; extern int PictureScreenPrivateIndex; @@ -303,6 +320,15 @@ extern RESTYPE GlyphSetType; } \ } \ +void +ResetPicturePrivateIndex (void); + +int +AllocatePicturePrivateIndex (void); + +Bool +AllocatePicturePrivate (ScreenPtr pScreen, int index2, unsigned int amount); + Bool PictureDestroyWindow (WindowPtr pWindow); @@ -340,7 +366,9 @@ char * PictureGetFilterName (int id); int -PictureAddFilter (ScreenPtr pScreen, char *filter, xFixed *params, int nparams); +PictureAddFilter (ScreenPtr pScreen, + char *filter, + PictFilterValidateParamsProcPtr ValidateParams); Bool PictureSetFilterAlias (ScreenPtr pScreen, char *filter, char *alias); @@ -396,9 +424,20 @@ SetPictureClipRects (PicturePtr pPicture, xRectangle *rects); int +SetPictureClipRegion (PicturePtr pPicture, + int xOrigin, + int yOrigin, + RegionPtr pRegion); + +int SetPictureTransform (PicturePtr pPicture, PictTransform *transform); - + +void +CopyPicture (PicturePtr pSrc, + Mask mask, + PicturePtr pDst); + void ValidatePicture(PicturePtr pPicture); @@ -494,6 +533,13 @@ AnimCurInit (ScreenPtr pScreen); int AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *ppCursor); +void +AddTraps (PicturePtr pPicture, + INT16 xOff, + INT16 yOff, + int ntraps, + xTrap *traps); + #ifdef PANORAMIX void PanoramiXRenderInit (void); void PanoramiXRenderReset (void); diff --git a/render/render.c b/render/render.c index 542599adf..5a852ba68 100644 --- a/render/render.c +++ b/render/render.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/render/render.c,v 1.1.4.3.2.2 2004/03/04 17:48:45 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/render/render.c,v 1.5 2004/08/06 23:42:10 keithp Exp $ */ /* * $XFree86: xc/programs/Xserver/render/render.c,v 1.27tsi Exp $ * @@ -78,6 +78,7 @@ static int ProcRenderSetPictureTransform (ClientPtr pClient); static int ProcRenderQueryFilters (ClientPtr pClient); static int ProcRenderSetPictureFilter (ClientPtr pClient); static int ProcRenderCreateAnimCursor (ClientPtr pClient); +static int ProcRenderAddTraps (ClientPtr pClient); static int ProcRenderDispatch (ClientPtr pClient); @@ -111,6 +112,7 @@ static int SProcRenderSetPictureTransform (ClientPtr pClient); static int SProcRenderQueryFilters (ClientPtr pClient); static int SProcRenderSetPictureFilter (ClientPtr pClient); static int SProcRenderCreateAnimCursor (ClientPtr pClient); +static int SProcRenderAddTraps (ClientPtr pClient); static int SProcRenderDispatch (ClientPtr pClient); @@ -147,6 +149,7 @@ int (*ProcRenderVector[RenderNumberRequests])(ClientPtr) = { ProcRenderQueryFilters, ProcRenderSetPictureFilter, ProcRenderCreateAnimCursor, + ProcRenderAddTraps, }; int (*SProcRenderVector[RenderNumberRequests])(ClientPtr) = { @@ -182,6 +185,7 @@ int (*SProcRenderVector[RenderNumberRequests])(ClientPtr) = { SProcRenderQueryFilters, SProcRenderSetPictureFilter, SProcRenderCreateAnimCursor, + SProcRenderAddTraps, }; static void @@ -243,6 +247,8 @@ RenderExtensionInit (void) static void RenderResetProc (ExtensionEntry *extEntry) { + ResetPicturePrivateIndex(); + ResetGlyphSetPrivateIndex(); } static int @@ -1508,7 +1514,7 @@ ProcRenderCreateCursor (ClientPtr client) } pPicture = CreatePicture (0, &pPixmap->drawable, pFormat, 0, 0, client, &error); - if (!pPicture); + if (!pPicture) { xfree (argbbits); xfree (srcbits); @@ -1811,6 +1817,27 @@ ProcRenderCreateAnimCursor (ClientPtr client) } static int +ProcRenderAddTraps (ClientPtr client) +{ + int ntraps; + PicturePtr pPicture; + REQUEST(xRenderAddTrapsReq); + + REQUEST_AT_LEAST_SIZE(xRenderAddTrapsReq); + VERIFY_PICTURE (pPicture, stuff->picture, client, SecurityWriteAccess, + RenderErrBase + BadPicture); + ntraps = (client->req_len << 2) - sizeof (xRenderAddTrapsReq); + if (ntraps % sizeof (xTrap)) + return BadLength; + ntraps /= sizeof (xTrap); + if (ntraps) + AddTraps (pPicture, + stuff->xOff, stuff->yOff, + ntraps, (xTrap *) &stuff[1]); + return client->noClientException; +} + +static int ProcRenderDispatch (ClientPtr client) { REQUEST(xReq); @@ -2276,6 +2303,21 @@ SProcRenderCreateAnimCursor (ClientPtr client) } static int +SProcRenderAddTraps (ClientPtr client) +{ + register int n; + REQUEST (xRenderAddTrapsReq); + REQUEST_AT_LEAST_SIZE (xRenderAddTrapsReq); + + swaps(&stuff->length, n); + swapl(&stuff->picture, n); + swaps(&stuff->xOff, n); + swaps(&stuff->yOff, n); + SwapRestL(stuff); + return (*ProcRenderVector[stuff->renderReqType]) (client); +} + +static int SProcRenderDispatch (ClientPtr client) { REQUEST(xReq); @@ -2920,6 +2962,44 @@ PanoramiXRenderColorTriangles(ClientPtr client) #endif +static int +PanoramiXRenderAddTraps (ClientPtr client) +{ + PanoramiXRes *picture; + int result = Success, j; + REQUEST(xRenderAddTrapsReq); + char *extra; + int extra_len; + INT16 x_off, y_off; + + REQUEST_AT_LEAST_SIZE (xRenderAddTrapsReq); + VERIFY_XIN_PICTURE (picture, stuff->picture, client, SecurityWriteAccess, + RenderErrBase + BadPicture); + extra_len = (client->req_len << 2) - sizeof (xRenderAddTrapsReq); + if (extra_len && + (extra = (char *) ALLOCATE_LOCAL (extra_len))) + { + memcpy (extra, stuff + 1, extra_len); + x_off = stuff->xOff; + y_off = stuff->yOff; + FOR_NSCREENS_FORWARD(j) { + if (j) memcpy (stuff + 1, extra, extra_len); + stuff->picture = picture->info[j].id; + + if (picture->u.pict.root) + { + stuff->xOff = x_off + panoramiXdataPtr[j].x; + stuff->yOff = y_off + panoramiXdataPtr[j].y; + } + result = (*PanoramiXSaveRenderVector[X_RenderAddTraps]) (client); + if(result != Success) break; + } + DEALLOCATE_LOCAL(extra); + } + + return result; +} + void PanoramiXRenderInit (void) { @@ -2947,6 +3027,7 @@ PanoramiXRenderInit (void) ProcRenderVector[X_RenderTriangles] = PanoramiXRenderTriangles; ProcRenderVector[X_RenderTriStrip] = PanoramiXRenderTriStrip; ProcRenderVector[X_RenderTriFan] = PanoramiXRenderTriFan; + ProcRenderVector[X_RenderAddTraps] = PanoramiXRenderAddTraps; } void diff --git a/render/renderedge.c b/render/renderedge.c new file mode 100644 index 000000000..b84eec14d --- /dev/null +++ b/render/renderedge.c @@ -0,0 +1,197 @@ +/* + * $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 "renderedge.h" + +/* + * Compute the smallest value no less than y which is on a + * grid row + */ + +xFixed +RenderSampleCeilY (xFixed y, int n) +{ + xFixed f = xFixedFrac(y); + xFixed i = xFixedFloor(y); + + f = ((f + Y_FRAC_FIRST(n)) / STEP_Y_SMALL(n)) * STEP_Y_SMALL(n) + Y_FRAC_FIRST(n); + if (f > Y_FRAC_LAST(n)) + { + f = Y_FRAC_FIRST(n); + i += xFixed1; + } + return (i | f); +} + +#define _div(a,b) ((a) >= 0 ? (a) / (b) : -((-(a) + (b) - 1) / (b))) + +/* + * Compute the largest value no greater than y which is on a + * grid row + */ +xFixed +RenderSampleFloorY (xFixed y, int n) +{ + xFixed f = xFixedFrac(y); + xFixed i = xFixedFloor (y); + + f = _div(f - Y_FRAC_FIRST(n), STEP_Y_SMALL(n)) * STEP_Y_SMALL(n) + Y_FRAC_FIRST(n); + if (f < Y_FRAC_FIRST(n)) + { + f = Y_FRAC_LAST(n); + i -= xFixed1; + } + return (i | f); +} + +/* + * Step an edge by any amount (including negative values) + */ +void +RenderEdgeStep (RenderEdge *e, int n) +{ + xFixed_48_16 ne; + + e->x += n * e->stepx; + + ne = e->e + n * (xFixed_48_16) e->dx; + + if (n >= 0) + { + if (ne > 0) + { + int nx = (ne + e->dy - 1) / e->dy; + e->e = ne - nx * (xFixed_48_16) e->dy; + e->x += nx * e->signdx; + } + } + else + { + if (ne <= -e->dy) + { + int nx = (-ne) / e->dy; + e->e = ne + nx * (xFixed_48_16) e->dy; + e->x -= nx * e->signdx; + } + } +} + +/* + * A private routine to initialize the multi-step + * elements of an edge structure + */ +static void +_RenderEdgeMultiInit (RenderEdge *e, int n, xFixed *stepx_p, xFixed *dx_p) +{ + xFixed stepx; + xFixed_48_16 ne; + + ne = n * (xFixed_48_16) e->dx; + stepx = n * e->stepx; + if (ne > 0) + { + int nx = ne / e->dy; + ne -= nx * e->dy; + stepx += nx * e->signdx; + } + *dx_p = ne; + *stepx_p = stepx; +} + +/* + * Initialize one edge structure given the line endpoints and a + * starting y value + */ +void +RenderEdgeInit (RenderEdge *e, + int n, + xFixed y_start, + xFixed x_top, + xFixed y_top, + xFixed x_bot, + xFixed y_bot) +{ + xFixed dx, dy; + + e->x = x_top; + e->e = 0; + dx = x_bot - x_top; + dy = y_bot - y_top; + e->dy = dy; + if (dy) + { + if (dx >= 0) + { + e->signdx = 1; + e->stepx = dx / dy; + e->dx = dx % dy; + e->e = -dy; + } + else + { + e->signdx = -1; + e->stepx = -(-dx / dy); + e->dx = -dx % dy; + e->e = 0; + } + + _RenderEdgeMultiInit (e, STEP_Y_SMALL(n), &e->stepx_small, &e->dx_small); + _RenderEdgeMultiInit (e, STEP_Y_BIG(n), &e->stepx_big, &e->dx_big); + } + RenderEdgeStep (e, y_start - y_top); +} + +/* + * Initialize one edge structure given a line, starting y value + * and a pixel offset for the line + */ +void +RenderLineFixedEdgeInit (RenderEdge *e, + int n, + xFixed y, + xLineFixed *line, + int x_off, + int y_off) +{ + xFixed x_off_fixed = IntToxFixed(x_off); + xFixed y_off_fixed = IntToxFixed(y_off); + xPointFixed *top, *bot; + + if (line->p1.y <= line->p2.y) + { + top = &line->p1; + bot = &line->p2; + } + else + { + top = &line->p2; + bot = &line->p1; + } + RenderEdgeInit (e, n, y, + top->x + x_off_fixed, + top->y + y_off_fixed, + bot->x + x_off_fixed, + bot->y + y_off_fixed); +} + diff --git a/render/renderedge.h b/render/renderedge.h new file mode 100644 index 000000000..d621d9dcf --- /dev/null +++ b/render/renderedge.h @@ -0,0 +1,120 @@ +/* + * $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. + */ + +#ifndef _RENDEREDGE_H_ +#define _RENDEREDGE_H_ + +#include "picturestr.h" + +#define MAX_ALPHA(n) ((1 << (n)) - 1) +#define N_Y_FRAC(n) ((n) == 1 ? 1 : (1 << ((n)/2)) - 1) +#define N_X_FRAC(n) ((1 << ((n)/2)) + 1) + +#define STEP_Y_SMALL(n) (xFixed1 / N_Y_FRAC(n)) +#define STEP_Y_BIG(n) (xFixed1 - (N_Y_FRAC(n) - 1) * STEP_Y_SMALL(n)) + +#define Y_FRAC_FIRST(n) (STEP_Y_SMALL(n) / 2) +#define Y_FRAC_LAST(n) (Y_FRAC_FIRST(n) + (N_Y_FRAC(n) - 1) * STEP_Y_SMALL(n)) + +#define STEP_X_SMALL(n) (xFixed1 / N_X_FRAC(n)) +#define STEP_X_BIG(n) (xFixed1 - (N_X_FRAC(n) - 1) * STEP_X_SMALL(n)) + +#define X_FRAC_FIRST(n) (STEP_X_SMALL(n) / 2) +#define X_FRAC_LAST(n) (X_FRAC_FIRST(n) + (N_X_FRAC(n) - 1) * STEP_X_SMALL(n)) + +#define RenderSamplesX(x,n) ((n) == 1 ? 0 : (xFixedFrac (x) + X_FRAC_FIRST(n)) / STEP_X_SMALL(n)) + +/* + * An edge structure. This represents a single polygon edge + * and can be quickly stepped across small or large gaps in the + * sample grid + */ + +typedef struct { + xFixed x; + xFixed e; + xFixed stepx; + xFixed signdx; + xFixed dy; + xFixed dx; + + xFixed stepx_small; + xFixed stepx_big; + xFixed dx_small; + xFixed dx_big; +} RenderEdge; + +/* + * Step across a small sample grid gap + */ +#define RenderEdgeStepSmall(edge) { \ + edge->x += edge->stepx_small; \ + edge->e += edge->dx_small; \ + if (edge->e > 0) \ + { \ + edge->e -= edge->dy; \ + edge->x += edge->signdx; \ + } \ +} + +/* + * Step across a large sample grid gap + */ +#define RenderEdgeStepBig(edge) { \ + edge->x += edge->stepx_big; \ + edge->e += edge->dx_big; \ + if (edge->e > 0) \ + { \ + edge->e -= edge->dy; \ + edge->x += edge->signdx; \ + } \ +} + +xFixed +RenderSampleCeilY (xFixed y, int bpp); + +xFixed +RenderSampleFloorY (xFixed y, int bpp); + +void +RenderEdgeStep (RenderEdge *e, int n); + +void +RenderEdgeInit (RenderEdge *e, + int bpp, + xFixed y_start, + xFixed x_top, + xFixed y_top, + xFixed x_bot, + xFixed y_bot); + +void +RenderLineFixedEdgeInit (RenderEdge *e, + int bpp, + xFixed y, + xLineFixed *line, + int x_off, + int y_off); + +#endif /* _RENDEREDGE_H_ */ diff --git a/xkb/ddxFakeMtn.c b/xkb/ddxFakeMtn.c index 56d81cf5e..f581760ce 100644 --- a/xkb/ddxFakeMtn.c +++ b/xkb/ddxFakeMtn.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/xkb/ddxFakeMtn.c,v 1.1.4.5.2.2 2004/03/04 17:48:45 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/xkb/ddxFakeMtn.c,v 1.2 2004/04/23 19:54:30 eich Exp $ */ /* $Xorg: ddxFakeMtn.c,v 1.3 2000/08/17 19:53:45 cpqbld Exp $ */ /************************************************************ Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc. diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c index b582845d9..4d572e7ff 100644 --- a/xkb/xkbInit.c +++ b/xkb/xkbInit.c @@ -1,4 +1,5 @@ /* $Xorg: xkbInit.c,v 1.3 2000/08/17 19:53:47 cpqbld Exp $ */ +/* $XdotOrg: xc/programs/Xserver/xkb/xkbInit.c,v 1.2 2004/04/23 19:54:30 eich Exp $ */ /************************************************************ Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc. @@ -188,6 +189,9 @@ char * pval; if (XkbRulesFile) { strcpy(&pval[out],XkbRulesFile); out+= strlen(XkbRulesFile); + } else { + strcpy(&pval[out],XKB_DFLT_RULES_FILE); + out+= strlen(XKB_DFLT_RULES_FILE); } pval[out++]= '\0'; if (XkbModelUsed) { |