2006-11-26 11:13:41 -07:00
|
|
|
/*
|
|
|
|
|
|
|
|
Copyright 1990, 1998 The Open Group
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
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 OPEN GROUP 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 Open Group 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 Open Group.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
#include <dix-config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <X11/X.h>
|
|
|
|
#include "servermd.h"
|
|
|
|
#include "misc.h"
|
|
|
|
#include "mi.h"
|
|
|
|
#include "scrnintstr.h"
|
|
|
|
#include "pixmapstr.h"
|
|
|
|
#include "dix.h"
|
|
|
|
#include "miline.h"
|
|
|
|
#ifdef MITSHM
|
2010-07-27 13:02:24 -06:00
|
|
|
#include <X11/extensions/shm.h>
|
2010-04-13 13:54:46 -06:00
|
|
|
#include "shmint.h"
|
|
|
|
#endif
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* We use this structure to propogate some information from miScreenInit to
|
|
|
|
* miCreateScreenResources. miScreenInit allocates the structure, fills it
|
2015-09-16 13:10:19 -06:00
|
|
|
* in, and puts it into pScreen->devPrivate. miCreateScreenResources
|
2006-11-26 11:13:41 -07:00
|
|
|
* extracts the info and frees the structure. We could've accomplished the
|
|
|
|
* same thing by adding fields to the screen structure, but they would have
|
|
|
|
* ended up being redundant, and would have exposed this mi implementation
|
|
|
|
* detail to the whole server.
|
|
|
|
*/
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
typedef struct {
|
2014-09-27 11:52:59 -06:00
|
|
|
void *pbits; /* pointer to framebuffer */
|
2012-06-10 07:21:05 -06:00
|
|
|
int width; /* delta to add to a framebuffer addr to move one row down */
|
2006-11-26 11:13:41 -07:00
|
|
|
} miScreenInitParmsRec, *miScreenInitParmsPtr;
|
|
|
|
|
|
|
|
/* this plugs into pScreen->ModifyPixmapHeader */
|
2010-07-27 13:02:24 -06:00
|
|
|
Bool
|
2009-09-06 13:44:18 -06:00
|
|
|
miModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int depth,
|
2014-09-27 11:52:59 -06:00
|
|
|
int bitsPerPixel, int devKind, void *pPixData)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
if (!pPixmap)
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If all arguments are specified, reinitialize everything (including
|
|
|
|
* validated state).
|
|
|
|
*/
|
|
|
|
if ((width > 0) && (height > 0) && (depth > 0) && (bitsPerPixel > 0) &&
|
2012-06-10 07:21:05 -06:00
|
|
|
(devKind > 0) && pPixData) {
|
|
|
|
pPixmap->drawable.depth = depth;
|
|
|
|
pPixmap->drawable.bitsPerPixel = bitsPerPixel;
|
|
|
|
pPixmap->drawable.id = 0;
|
|
|
|
pPixmap->drawable.x = 0;
|
|
|
|
pPixmap->drawable.y = 0;
|
|
|
|
pPixmap->drawable.width = width;
|
|
|
|
pPixmap->drawable.height = height;
|
|
|
|
pPixmap->devKind = devKind;
|
|
|
|
pPixmap->refcnt = 1;
|
|
|
|
pPixmap->devPrivate.ptr = pPixData;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/*
|
|
|
|
* Only modify specified fields, keeping all others intact.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (width > 0)
|
|
|
|
pPixmap->drawable.width = width;
|
|
|
|
|
|
|
|
if (height > 0)
|
|
|
|
pPixmap->drawable.height = height;
|
|
|
|
|
|
|
|
if (depth > 0)
|
|
|
|
pPixmap->drawable.depth = depth;
|
|
|
|
|
|
|
|
if (bitsPerPixel > 0)
|
|
|
|
pPixmap->drawable.bitsPerPixel = bitsPerPixel;
|
|
|
|
else if ((bitsPerPixel < 0) && (depth > 0))
|
|
|
|
pPixmap->drawable.bitsPerPixel = BitsPerPixel(depth);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* CAVEAT: Non-SI DDXen may use devKind and devPrivate fields for
|
|
|
|
* other purposes.
|
|
|
|
*/
|
|
|
|
if (devKind > 0)
|
|
|
|
pPixmap->devKind = devKind;
|
|
|
|
else if ((devKind < 0) && ((width > 0) || (depth > 0)))
|
|
|
|
pPixmap->devKind = PixmapBytePad(pPixmap->drawable.width,
|
|
|
|
pPixmap->drawable.depth);
|
|
|
|
|
|
|
|
if (pPixData)
|
|
|
|
pPixmap->devPrivate.ptr = pPixData;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
|
2006-11-26 11:13:41 -07:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
static Bool
|
2013-06-07 11:28:45 -06:00
|
|
|
miCloseScreen(ScreenPtr pScreen)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
return ((*pScreen->DestroyPixmap) ((PixmapPtr) pScreen->devPrivate));
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* With the introduction of pixmap privates, the "screen pixmap" can no
|
|
|
|
* longer be created in miScreenInit, since all the modules that could
|
|
|
|
* possibly ask for pixmap private space have not been initialized at
|
|
|
|
* that time. pScreen->CreateScreenResources is called after all
|
|
|
|
* possible private-requesting modules have been inited; we create the
|
|
|
|
* screen pixmap here.
|
|
|
|
*/
|
2010-07-27 13:02:24 -06:00
|
|
|
Bool
|
2009-09-06 13:44:18 -06:00
|
|
|
miCreateScreenResources(ScreenPtr pScreen)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
miScreenInitParmsPtr pScrInitParms;
|
2014-09-27 11:52:59 -06:00
|
|
|
void *value;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pScrInitParms = (miScreenInitParmsPtr) pScreen->devPrivate;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* if width is non-zero, pScreen->devPrivate will be a pixmap
|
|
|
|
* else it will just take the value pbits
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pScrInitParms->width) {
|
|
|
|
PixmapPtr pPixmap;
|
|
|
|
|
|
|
|
/* create a pixmap with no data, then redirect it to point to
|
|
|
|
* the screen
|
|
|
|
*/
|
|
|
|
pPixmap =
|
|
|
|
(*pScreen->CreatePixmap) (pScreen, 0, 0, pScreen->rootDepth, 0);
|
|
|
|
if (!pPixmap)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!(*pScreen->ModifyPixmapHeader) (pPixmap, pScreen->width,
|
|
|
|
pScreen->height,
|
|
|
|
pScreen->rootDepth,
|
|
|
|
BitsPerPixel(pScreen->rootDepth),
|
|
|
|
PixmapBytePad(pScrInitParms->width,
|
|
|
|
pScreen->rootDepth),
|
|
|
|
pScrInitParms->pbits))
|
|
|
|
return FALSE;
|
2014-09-27 11:52:59 -06:00
|
|
|
value = (void *) pPixmap;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else {
|
|
|
|
value = pScrInitParms->pbits;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
free(pScreen->devPrivate); /* freeing miScreenInitParmsRec */
|
|
|
|
pScreen->devPrivate = value; /* pPixmap or pbits */
|
2006-11-26 11:13:41 -07:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
Bool
|
2014-09-27 11:52:59 -06:00
|
|
|
miScreenDevPrivateInit(ScreenPtr pScreen, int width, void *pbits)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
miScreenInitParmsPtr pScrInitParms;
|
|
|
|
|
|
|
|
/* Stash pbits and width in a short-lived miScreenInitParmsRec attached
|
|
|
|
* to the screen, until CreateScreenResources can put them in the
|
|
|
|
* screen pixmap.
|
|
|
|
*/
|
2010-12-05 08:36:02 -07:00
|
|
|
pScrInitParms = malloc(sizeof(miScreenInitParmsRec));
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!pScrInitParms)
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
pScrInitParms->pbits = pbits;
|
|
|
|
pScrInitParms->width = width;
|
2014-09-27 11:52:59 -06:00
|
|
|
pScreen->devPrivate = (void *) pScrInitParms;
|
2006-11-26 11:13:41 -07:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
static PixmapPtr
|
|
|
|
miGetScreenPixmap(ScreenPtr pScreen)
|
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
return (PixmapPtr) (pScreen->devPrivate);
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
miSetScreenPixmap(PixmapPtr pPix)
|
|
|
|
{
|
|
|
|
if (pPix)
|
2014-09-27 11:52:59 -06:00
|
|
|
pPix->drawable.pScreen->devPrivate = (void *) pPix;
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
Bool
|
2014-09-27 11:52:59 -06:00
|
|
|
miScreenInit(ScreenPtr pScreen, void *pbits, /* pointer to screen bits */
|
2012-06-10 07:21:05 -06:00
|
|
|
int xsize, int ysize, /* in pixels */
|
|
|
|
int dpix, int dpiy, /* dots per inch */
|
|
|
|
int width, /* pixel width of frame buffer */
|
|
|
|
int rootDepth, /* depth of root window */
|
|
|
|
int numDepths, /* number of depths supported */
|
|
|
|
DepthRec * depths, /* supported depths */
|
|
|
|
VisualID rootVisual, /* root visual */
|
|
|
|
int numVisuals, /* number of visuals supported */
|
|
|
|
VisualRec * visuals /* supported visuals */
|
2009-09-06 13:44:18 -06:00
|
|
|
)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
pScreen->width = xsize;
|
|
|
|
pScreen->height = ysize;
|
|
|
|
pScreen->mmWidth = (xsize * 254 + dpix * 5) / (dpix * 10);
|
|
|
|
pScreen->mmHeight = (ysize * 254 + dpiy * 5) / (dpiy * 10);
|
|
|
|
pScreen->numDepths = numDepths;
|
|
|
|
pScreen->rootDepth = rootDepth;
|
|
|
|
pScreen->allowedDepths = depths;
|
|
|
|
pScreen->rootVisual = rootVisual;
|
|
|
|
/* defColormap */
|
|
|
|
pScreen->minInstalledCmaps = 1;
|
|
|
|
pScreen->maxInstalledCmaps = 1;
|
|
|
|
pScreen->backingStoreSupport = NotUseful;
|
|
|
|
pScreen->saveUnderSupport = NotUseful;
|
|
|
|
/* whitePixel, blackPixel */
|
|
|
|
pScreen->ModifyPixmapHeader = miModifyPixmapHeader;
|
|
|
|
pScreen->CreateScreenResources = miCreateScreenResources;
|
|
|
|
pScreen->GetScreenPixmap = miGetScreenPixmap;
|
|
|
|
pScreen->SetScreenPixmap = miSetScreenPixmap;
|
|
|
|
pScreen->numVisuals = numVisuals;
|
|
|
|
pScreen->visuals = visuals;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (width) {
|
2006-11-26 11:13:41 -07:00
|
|
|
#ifdef MITSHM
|
2012-06-10 07:21:05 -06:00
|
|
|
ShmRegisterFbFuncs(pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
pScreen->CloseScreen = miCloseScreen;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
/* else CloseScreen */
|
|
|
|
/* QueryBestSize, SaveScreen, GetImage, GetSpans */
|
|
|
|
pScreen->SourceValidate = (SourceValidateProcPtr) 0;
|
|
|
|
/* CreateWindow, DestroyWindow, PositionWindow, ChangeWindowAttributes */
|
|
|
|
/* RealizeWindow, UnrealizeWindow */
|
|
|
|
pScreen->ValidateTree = miValidateTree;
|
|
|
|
pScreen->PostValidateTree = (PostValidateTreeProcPtr) 0;
|
|
|
|
pScreen->WindowExposures = miWindowExposures;
|
2008-11-02 08:26:08 -07:00
|
|
|
/* CopyWindow */
|
2006-11-26 11:13:41 -07:00
|
|
|
pScreen->ClearToBackground = miClearToBackground;
|
|
|
|
pScreen->ClipNotify = (ClipNotifyProcPtr) 0;
|
|
|
|
pScreen->RestackWindow = (RestackWindowProcPtr) 0;
|
2016-05-29 06:02:34 -06:00
|
|
|
pScreen->PaintWindow = miPaintWindow;
|
2006-11-26 11:13:41 -07:00
|
|
|
/* CreatePixmap, DestroyPixmap */
|
|
|
|
/* RealizeFont, UnrealizeFont */
|
|
|
|
/* CreateGC */
|
|
|
|
/* CreateColormap, DestroyColormap, InstallColormap, UninstallColormap */
|
|
|
|
/* ListInstalledColormaps, StoreColors, ResolveColor */
|
|
|
|
/* BitmapToRegion */
|
2012-06-10 07:21:05 -06:00
|
|
|
pScreen->BlockHandler = (ScreenBlockHandlerProcPtr) NoopDDA;
|
|
|
|
pScreen->WakeupHandler = (ScreenWakeupHandlerProcPtr) NoopDDA;
|
2006-11-26 11:13:41 -07:00
|
|
|
pScreen->MarkWindow = miMarkWindow;
|
|
|
|
pScreen->MarkOverlappedWindows = miMarkOverlappedWindows;
|
|
|
|
pScreen->MoveWindow = miMoveWindow;
|
2015-09-16 13:10:19 -06:00
|
|
|
pScreen->ResizeWindow = miResizeWindow;
|
2006-11-26 11:13:41 -07:00
|
|
|
pScreen->GetLayerWindow = miGetLayerWindow;
|
|
|
|
pScreen->HandleExposures = miHandleValidateExposures;
|
|
|
|
pScreen->ReparentWindow = (ReparentWindowProcPtr) 0;
|
|
|
|
pScreen->ChangeBorderWidth = miChangeBorderWidth;
|
|
|
|
pScreen->SetShape = miSetShape;
|
|
|
|
pScreen->MarkUnrealizedWindow = miMarkUnrealizedWindow;
|
2014-09-27 11:52:59 -06:00
|
|
|
pScreen->XYToWindow = miXYToWindow;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
miSetZeroLineBias(pScreen, DEFAULTZEROLINEBIAS);
|
|
|
|
|
|
|
|
return miScreenDevPrivateInit(pScreen, width, pbits);
|
|
|
|
}
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
DevPrivateKeyRec miZeroLineScreenKeyRec;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
2009-09-06 13:44:18 -06:00
|
|
|
miSetZeroLineBias(ScreenPtr pScreen, unsigned int bias)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2010-12-05 08:36:02 -07:00
|
|
|
if (!dixRegisterPrivateKey(&miZeroLineScreenKeyRec, PRIVATE_SCREEN, 0))
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2010-12-05 08:36:02 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
dixSetPrivate(&pScreen->devPrivates, miZeroLineScreenKey,
|
|
|
|
(unsigned long *) (unsigned long) bias);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|