XQuartz: Integrate DRI changes backported from the 1.6 branch
This commit is contained in:
parent
4901b8147e
commit
ffaec14cd1
|
@ -9,6 +9,7 @@ AM_CPPFLAGS = \
|
|||
libXquartzXpr_la_SOURCES = \
|
||||
appledri.c \
|
||||
dri.c \
|
||||
driWrap.c \
|
||||
xprAppleWM.c \
|
||||
xprCursor.c \
|
||||
xprEvent.c \
|
||||
|
@ -20,6 +21,7 @@ libXquartzXpr_la_SOURCES = \
|
|||
|
||||
EXTRA_DIST = \
|
||||
dri.h \
|
||||
driWrap.h \
|
||||
dristruct.h \
|
||||
appledri.h \
|
||||
appledristr.h \
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
Copyright 2000 VA Linux Systems, Inc.
|
||||
Copyright (c) 2002 Apple Computer, Inc.
|
||||
Copyright (c) 2002, 2009 Apple Computer, Inc.
|
||||
All Rights Reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
|
@ -64,6 +64,7 @@ static DISPATCH_PROC(ProcAppleDRIDispatch);
|
|||
static DISPATCH_PROC(SProcAppleDRIDispatch);
|
||||
|
||||
static void AppleDRIResetProc(ExtensionEntry* extEntry);
|
||||
static int ProcAppleDRICreatePixmap(ClientPtr client);
|
||||
|
||||
static unsigned char DRIReqCode = 0;
|
||||
static int DRIEventBase = 0;
|
||||
|
@ -274,6 +275,76 @@ ProcAppleDRIDestroySurface(
|
|||
return (client->noClientException);
|
||||
}
|
||||
|
||||
static int
|
||||
ProcAppleDRICreatePixmap(ClientPtr client)
|
||||
{
|
||||
REQUEST(xAppleDRICreatePixmapReq);
|
||||
DrawablePtr pDrawable;
|
||||
int rc;
|
||||
char path[PATH_MAX];
|
||||
xAppleDRICreatePixmapReply rep;
|
||||
int width, height, pitch, bpp;
|
||||
void *ptr;
|
||||
|
||||
REQUEST_SIZE_MATCH(xAppleDRICreatePixmapReq);
|
||||
|
||||
rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
|
||||
DixReadAccess);
|
||||
|
||||
if(rc != Success)
|
||||
return rc;
|
||||
|
||||
if(!DRICreatePixmap(screenInfo.screens[stuff->screen],
|
||||
(Drawable)stuff->drawable,
|
||||
pDrawable,
|
||||
path, PATH_MAX)) {
|
||||
return BadValue;
|
||||
}
|
||||
|
||||
if(!DRIGetPixmapData(pDrawable, &width, &height,
|
||||
&pitch, &bpp, &ptr)) {
|
||||
return BadValue;
|
||||
}
|
||||
|
||||
rep.stringLength = strlen(path) + 1;
|
||||
|
||||
/* No need for swapping, because this only runs if LocalClient is true. */
|
||||
rep.type = X_Reply;
|
||||
rep.length = sizeof(rep) + rep.stringLength;
|
||||
rep.sequenceNumber = client->sequence;
|
||||
rep.width = width;
|
||||
rep.height = height;
|
||||
rep.pitch = pitch;
|
||||
rep.bpp = bpp;
|
||||
rep.size = pitch * height;
|
||||
|
||||
if(sizeof(rep) != sz_xAppleDRICreatePixmapReply)
|
||||
ErrorF("error sizeof(rep) is %zu\n", sizeof(rep));
|
||||
|
||||
WriteReplyToClient(client, sizeof(rep), &rep);
|
||||
(void)WriteToClient(client, rep.stringLength, path);
|
||||
|
||||
return (client->noClientException);
|
||||
}
|
||||
|
||||
static int
|
||||
ProcAppleDRIDestroyPixmap(ClientPtr client)
|
||||
{
|
||||
DrawablePtr pDrawable;
|
||||
int rc;
|
||||
REQUEST(xAppleDRIDestroyPixmapReq);
|
||||
REQUEST_SIZE_MATCH(xAppleDRIDestroyPixmapReq);
|
||||
|
||||
rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
|
||||
DixReadAccess);
|
||||
|
||||
if(rc != Success)
|
||||
return rc;
|
||||
|
||||
DRIDestroyPixmap(pDrawable);
|
||||
|
||||
return (client->noClientException);
|
||||
}
|
||||
|
||||
/* dispatch */
|
||||
|
||||
|
@ -303,6 +374,11 @@ ProcAppleDRIDispatch (
|
|||
return ProcAppleDRICreateSurface(client);
|
||||
case X_AppleDRIDestroySurface:
|
||||
return ProcAppleDRIDestroySurface(client);
|
||||
case X_AppleDRICreatePixmap:
|
||||
return ProcAppleDRICreatePixmap(client);
|
||||
case X_AppleDRIDestroyPixmap:
|
||||
return ProcAppleDRIDestroyPixmap(client);
|
||||
|
||||
default:
|
||||
return BadRequest;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
/* $XFree86: xc/lib/GL/dri/xf86dri.h,v 1.7 2000/12/07 20:26:02 dawes Exp $ */
|
||||
/**************************************************************************
|
||||
|
||||
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
Copyright 2000 VA Linux Systems, Inc.
|
||||
Copyright (c) 2002 Apple Computer, Inc.
|
||||
Copyright (c) 2002, 2008, 2009 Apple Computer, Inc.
|
||||
All Rights Reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
|
@ -45,6 +46,11 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#define X_AppleDRICreateSurface 2
|
||||
#define X_AppleDRIDestroySurface 3
|
||||
#define X_AppleDRIAuthConnection 4
|
||||
#define X_AppleDRICreateSharedBuffer 5
|
||||
#define X_AppleDRISwapBuffers 6
|
||||
#define X_AppleDRICreatePixmap 7
|
||||
#define X_AppleDRIDestroyPixmap 8
|
||||
|
||||
/* Requests up to and including 18 were used in a previous version */
|
||||
|
||||
/* Events */
|
||||
|
@ -99,8 +105,19 @@ Bool XAppleDRIDestroySurface (Display *dpy, int screen, Drawable drawable);
|
|||
|
||||
Bool XAppleDRISynchronizeSurfaces (Display *dpy);
|
||||
|
||||
Bool XAppleDRICreateSharedBuffer(Display *dpy, int screen, Drawable drawable,
|
||||
Bool doubleSwap, char *path, size_t pathlen,
|
||||
int *width, int *height);
|
||||
|
||||
Bool XAppleDRISwapBuffers(Display *dpy, int screen, Drawable drawable);
|
||||
|
||||
Bool XAppleDRICreatePixmap(Display *dpy, int screen, Drawable drawable,
|
||||
int *width, int *height, int *pitch, int *bpp,
|
||||
size_t *size, char *bufname, size_t bufnamesize);
|
||||
|
||||
Bool XAppleDRIDestroyPixmap(Display *dpy, Pixmap pixmap);
|
||||
|
||||
_XFUNCPROTOEND
|
||||
|
||||
#endif /* _APPLEDRI_SERVER_ */
|
||||
#endif /* _APPLEDRI_H_ */
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
Copyright 2000 VA Linux Systems, Inc.
|
||||
Copyright (c) 2002 Apple Computer, Inc.
|
||||
Copyright (c) 2002, 2008, 2009 Apple Computer, Inc.
|
||||
All Rights Reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
|
@ -153,13 +153,85 @@ typedef struct _AppleDRINotify {
|
|||
BYTE type; /* always eventBase + event type */
|
||||
BYTE kind;
|
||||
CARD16 sequenceNumber B16;
|
||||
Time time B32; /* time of change */
|
||||
CARD32 time B32; /* time of change */
|
||||
CARD32 pad1 B32;
|
||||
CARD32 arg B32;
|
||||
CARD32 pad3 B32;
|
||||
} xAppleDRINotifyEvent;
|
||||
#define sz_xAppleDRINotifyEvent 20
|
||||
|
||||
|
||||
typedef struct {
|
||||
CARD8 reqType;
|
||||
CARD8 driReqType;
|
||||
CARD16 length B16;
|
||||
CARD32 screen B32;
|
||||
CARD32 drawable B32;
|
||||
BOOL doubleSwap;
|
||||
CARD8 pad1, pad2, pad3;
|
||||
} xAppleDRICreateSharedBufferReq;
|
||||
|
||||
#define sz_xAppleDRICreateSharedBufferReq 16
|
||||
|
||||
typedef struct {
|
||||
BYTE type;
|
||||
BYTE data1;
|
||||
CARD16 sequenceNumber B16;
|
||||
CARD32 length B32;
|
||||
CARD32 stringLength B32; /* 0 on error */
|
||||
CARD32 width B32;
|
||||
CARD32 height B32;
|
||||
CARD32 pad1 B32;
|
||||
CARD32 pad2 B32;
|
||||
CARD32 pad3 B32;
|
||||
} xAppleDRICreateSharedBufferReply;
|
||||
|
||||
#define sz_xAppleDRICreateSharedBufferReply 32
|
||||
|
||||
typedef struct {
|
||||
CARD8 reqType;
|
||||
CARD8 driReqType;
|
||||
CARD16 length B16;
|
||||
CARD32 screen B32;
|
||||
CARD32 drawable B32;
|
||||
} xAppleDRISwapBuffersReq;
|
||||
|
||||
#define sz_xAppleDRISwapBuffersReq 12
|
||||
|
||||
typedef struct {
|
||||
CARD8 reqType; /*1*/
|
||||
CARD8 driReqType; /*2*/
|
||||
CARD16 length B16; /*4*/
|
||||
CARD32 screen B32; /*8*/
|
||||
CARD32 drawable B32; /*12*/
|
||||
} xAppleDRICreatePixmapReq;
|
||||
|
||||
#define sz_xAppleDRICreatePixmapReq 12
|
||||
|
||||
typedef struct {
|
||||
BYTE type; /*1*/
|
||||
BOOL pad1; /*2*/
|
||||
CARD16 sequenceNumber B16; /*4*/
|
||||
CARD32 length B32; /*8*/
|
||||
CARD32 width B32; /*12*/
|
||||
CARD32 height B32; /*16*/
|
||||
CARD32 pitch B32; /*20*/
|
||||
CARD32 bpp B32; /*24*/
|
||||
CARD32 size B32; /*28*/
|
||||
CARD32 stringLength B32; /*32*/
|
||||
} xAppleDRICreatePixmapReply;
|
||||
|
||||
#define sz_xAppleDRICreatePixmapReply 32
|
||||
|
||||
typedef struct {
|
||||
CARD8 reqType; /*1*/
|
||||
CARD8 driReqType; /*2*/
|
||||
CARD16 length B16; /*4*/
|
||||
CARD32 drawable B32; /*8*/
|
||||
} xAppleDRIDestroyPixmapReq;
|
||||
|
||||
#define sz_xAppleDRIDestroyPixmapReq 8
|
||||
|
||||
#ifdef _APPLEDRI_SERVER_
|
||||
|
||||
void AppleDRISendEvent (
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
Copyright 2000 VA Linux Systems, Inc.
|
||||
Copyright (c) 2002 Apple Computer, Inc.
|
||||
Copyright (c) 2002, 2009 Apple Computer, Inc.
|
||||
All Rights Reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
|
@ -50,6 +50,10 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#define NEED_EVENTS
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xproto.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include "misc.h"
|
||||
#include "dixstruct.h"
|
||||
#include "extnsionst.h"
|
||||
|
@ -68,17 +72,21 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#include "rootless.h"
|
||||
#include "x-hash.h"
|
||||
#include "x-hook.h"
|
||||
#include "driWrap.h"
|
||||
|
||||
#include <AvailabilityMacros.h>
|
||||
|
||||
static int DRIScreenPrivIndex = -1;
|
||||
static int DRIWindowPrivIndex = -1;
|
||||
static int DRIPixmapPrivIndex = -1;
|
||||
static int DRIPixmapBufferPrivIndex = -1;
|
||||
|
||||
static RESTYPE DRIDrawablePrivResType;
|
||||
|
||||
static x_hash_table *surface_hash; /* maps surface ids -> drawablePrivs */
|
||||
|
||||
static Bool DRIFreePixmapImp(DrawablePtr pDrawable);
|
||||
|
||||
/* FIXME: don't hardcode this? */
|
||||
#define CG_INFO_FILE "/System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreGraphics.framework/Resources/Info-macos.plist"
|
||||
|
||||
|
@ -87,6 +95,18 @@ static x_hash_table *surface_hash; /* maps surface ids -> drawablePrivs */
|
|||
#define CG_REQUIRED_MINOR 157
|
||||
#define CG_REQUIRED_MICRO 11
|
||||
|
||||
typedef struct {
|
||||
DrawablePtr pDrawable;
|
||||
int refCount;
|
||||
int bytesPerPixel;
|
||||
int width;
|
||||
int height;
|
||||
char shmPath[PATH_MAX];
|
||||
int fd; /* From shm_open (for now) */
|
||||
size_t length; /* length of buffer */
|
||||
void *buffer;
|
||||
} DRIPixmapBuffer, *DRIPixmapBufferPtr;
|
||||
|
||||
/* Returns version as major.minor.micro in 10.10.10 fixed form */
|
||||
static unsigned int
|
||||
get_cg_version (void)
|
||||
|
@ -245,7 +265,7 @@ DRIFinishScreenInit(ScreenPtr pScreen)
|
|||
|
||||
// ErrorF("[DRI] screen %d installation complete\n", pScreen->myNum);
|
||||
|
||||
return TRUE;
|
||||
return DRIWrapInit(pScreen);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -279,6 +299,8 @@ DRIExtensionInit(void)
|
|||
return FALSE;
|
||||
if ((DRIPixmapPrivIndex = AllocatePixmapPrivateIndex()) < 0)
|
||||
return FALSE;
|
||||
if ((DRIPixmapBufferPrivIndex = AllocatePixmapPrivateIndex()) < 0)
|
||||
return FALSE;
|
||||
|
||||
DRIDrawablePrivResType = CreateNewResourceType(DRIDrawablePrivDelete);
|
||||
|
||||
|
@ -368,6 +390,110 @@ DRIUpdateSurface(DRIDrawablePrivPtr pDRIDrawablePriv, DrawablePtr pDraw)
|
|||
xp_configure_surface(pDRIDrawablePriv->sid, flags, &wc);
|
||||
}
|
||||
|
||||
/* Return NULL if an error occurs. */
|
||||
static DRIDrawablePrivPtr
|
||||
CreateSurfaceForWindow(ScreenPtr pScreen, WindowPtr pWin, xp_window_id *widPtr) {
|
||||
DRIDrawablePrivPtr pDRIDrawablePriv;
|
||||
xp_window_id wid = 0;
|
||||
|
||||
*widPtr = 0;
|
||||
|
||||
pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
|
||||
|
||||
if (pDRIDrawablePriv == NULL) {
|
||||
xp_error err;
|
||||
xp_window_changes wc;
|
||||
|
||||
/* allocate a DRI Window Private record */
|
||||
if (!(pDRIDrawablePriv = xalloc(sizeof(*pDRIDrawablePriv)))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pDRIDrawablePriv->pDraw = (DrawablePtr)pWin;
|
||||
pDRIDrawablePriv->pScreen = pScreen;
|
||||
pDRIDrawablePriv->refCount = 0;
|
||||
pDRIDrawablePriv->drawableIndex = -1;
|
||||
pDRIDrawablePriv->notifiers = NULL;
|
||||
|
||||
/* find the physical window */
|
||||
wid = x_cvt_vptr_to_uint(RootlessFrameForWindow(pWin, TRUE));
|
||||
|
||||
if (wid == 0) {
|
||||
xfree(pDRIDrawablePriv);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* allocate the physical surface */
|
||||
err = xp_create_surface(wid, &pDRIDrawablePriv->sid);
|
||||
|
||||
if (err != Success) {
|
||||
xfree(pDRIDrawablePriv);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Make it visible */
|
||||
wc.stack_mode = XP_MAPPED_ABOVE;
|
||||
wc.sibling = 0;
|
||||
err = xp_configure_surface(pDRIDrawablePriv->sid, XP_STACKING, &wc);
|
||||
|
||||
if (err != Success) {
|
||||
xp_destroy_surface(pDRIDrawablePriv->sid);
|
||||
xfree(pDRIDrawablePriv);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* save private off of preallocated index */
|
||||
pWin->devPrivates[DRIWindowPrivIndex].ptr = pDRIDrawablePriv;
|
||||
}
|
||||
|
||||
*widPtr = wid;
|
||||
|
||||
return pDRIDrawablePriv;
|
||||
}
|
||||
|
||||
/* Return NULL if an error occurs. */
|
||||
static DRIDrawablePrivPtr
|
||||
CreateSurfaceForPixmap(ScreenPtr pScreen, PixmapPtr pPix) {
|
||||
DRIDrawablePrivPtr pDRIDrawablePriv;
|
||||
|
||||
pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix);
|
||||
|
||||
if (pDRIDrawablePriv == NULL) {
|
||||
xp_error err;
|
||||
|
||||
/* allocate a DRI Window Private record */
|
||||
if (!(pDRIDrawablePriv = xcalloc(1, sizeof(*pDRIDrawablePriv)))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pDRIDrawablePriv->pDraw = (DrawablePtr)pPix;
|
||||
pDRIDrawablePriv->pScreen = pScreen;
|
||||
pDRIDrawablePriv->refCount = 0;
|
||||
pDRIDrawablePriv->drawableIndex = -1;
|
||||
pDRIDrawablePriv->notifiers = NULL;
|
||||
|
||||
/* Passing a null window id to Xplugin in 10.3+ asks for
|
||||
an accelerated offscreen surface. */
|
||||
|
||||
err = xp_create_surface(0, &pDRIDrawablePriv->sid);
|
||||
if (err != Success) {
|
||||
xfree(pDRIDrawablePriv);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* The DRIUpdateSurface will be called to resize the surface
|
||||
* after this function, if the export is successful.
|
||||
*/
|
||||
|
||||
/* save private off of preallocated index */
|
||||
pPix->devPrivates[DRIPixmapPrivIndex].ptr = pDRIDrawablePriv;
|
||||
}
|
||||
|
||||
return pDRIDrawablePriv;
|
||||
}
|
||||
|
||||
|
||||
Bool
|
||||
DRICreateSurface(ScreenPtr pScreen, Drawable id,
|
||||
DrawablePtr pDrawable, xp_client_id client_id,
|
||||
|
@ -375,110 +501,62 @@ DRICreateSurface(ScreenPtr pScreen, Drawable id,
|
|||
void (*notify) (void *arg, void *data), void *notify_data)
|
||||
{
|
||||
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
|
||||
DRIDrawablePrivPtr pDRIDrawablePriv;
|
||||
xp_window_id wid = 0;
|
||||
DRIDrawablePrivPtr pDRIDrawablePriv;
|
||||
|
||||
if (pDrawable->type == DRAWABLE_WINDOW) {
|
||||
WindowPtr pWin = (WindowPtr)pDrawable;
|
||||
pDRIDrawablePriv = CreateSurfaceForWindow(pScreen,
|
||||
(WindowPtr)pDrawable, &wid);
|
||||
|
||||
pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
|
||||
if (pDRIDrawablePriv == NULL) {
|
||||
xp_error err;
|
||||
xp_window_changes wc;
|
||||
|
||||
/* allocate a DRI Window Private record */
|
||||
if (!(pDRIDrawablePriv = xalloc(sizeof(DRIDrawablePrivRec)))) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pDRIDrawablePriv->pDraw = pDrawable;
|
||||
pDRIDrawablePriv->pScreen = pScreen;
|
||||
pDRIDrawablePriv->refCount = 0;
|
||||
pDRIDrawablePriv->drawableIndex = -1;
|
||||
pDRIDrawablePriv->notifiers = NULL;
|
||||
|
||||
/* find the physical window */
|
||||
wid = x_cvt_vptr_to_uint(RootlessFrameForWindow(pWin, TRUE));
|
||||
if (wid == 0) {
|
||||
xfree(pDRIDrawablePriv);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* allocate the physical surface */
|
||||
err = xp_create_surface(wid, &pDRIDrawablePriv->sid);
|
||||
if (err != Success) {
|
||||
xfree(pDRIDrawablePriv);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Make it visible */
|
||||
wc.stack_mode = XP_MAPPED_ABOVE;
|
||||
wc.sibling = 0;
|
||||
err = xp_configure_surface(pDRIDrawablePriv->sid, XP_STACKING, &wc);
|
||||
if (err != Success)
|
||||
{
|
||||
xp_destroy_surface(pDRIDrawablePriv->sid);
|
||||
xfree(pDRIDrawablePriv);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* save private off of preallocated index */
|
||||
pWin->devPrivates[DRIWindowPrivIndex].ptr = (pointer)pDRIDrawablePriv;
|
||||
}
|
||||
if(NULL == pDRIDrawablePriv)
|
||||
return FALSE; /*error*/
|
||||
}
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
|
||||
else if (pDrawable->type == DRAWABLE_PIXMAP) {
|
||||
PixmapPtr pPix = (PixmapPtr)pDrawable;
|
||||
pDRIDrawablePriv = CreateSurfaceForPixmap(pScreen,
|
||||
(PixmapPtr)pDrawable);
|
||||
|
||||
pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix);
|
||||
if (pDRIDrawablePriv == NULL) {
|
||||
xp_error err;
|
||||
|
||||
/* allocate a DRI Window Private record */
|
||||
if (!(pDRIDrawablePriv = xcalloc(1, sizeof(DRIDrawablePrivRec)))) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pDRIDrawablePriv->pDraw = pDrawable;
|
||||
pDRIDrawablePriv->pScreen = pScreen;
|
||||
pDRIDrawablePriv->refCount = 0;
|
||||
pDRIDrawablePriv->drawableIndex = -1;
|
||||
pDRIDrawablePriv->notifiers = NULL;
|
||||
|
||||
/* Passing a null window id to Xplugin in 10.3+ asks for
|
||||
an accelerated offscreen surface. */
|
||||
|
||||
err = xp_create_surface(0, &pDRIDrawablePriv->sid);
|
||||
if (err != Success) {
|
||||
xfree(pDRIDrawablePriv);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* save private off of preallocated index */
|
||||
pPix->devPrivates[DRIPixmapPrivIndex].ptr = (pointer)pDRIDrawablePriv;
|
||||
}
|
||||
if(NULL == pDRIDrawablePriv)
|
||||
return FALSE; /*error*/
|
||||
}
|
||||
#endif
|
||||
|
||||
else { /* for GLX 1.3, a PBuffer */
|
||||
/* NOT_DONE */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Finish initialization of new surfaces */
|
||||
if (pDRIDrawablePriv->refCount == 0) {
|
||||
unsigned int key[2] = {0};
|
||||
xp_error err;
|
||||
|
||||
/* try to give the client access to the surface */
|
||||
if (client_id != 0 && wid != 0)
|
||||
{
|
||||
if (client_id != 0) {
|
||||
/*
|
||||
* Xplugin accepts a 0 wid if the surface id is offscreen, such
|
||||
* as for a pixmap.
|
||||
*/
|
||||
err = xp_export_surface(wid, pDRIDrawablePriv->sid,
|
||||
client_id, key);
|
||||
if (err != Success) {
|
||||
xp_destroy_surface(pDRIDrawablePriv->sid);
|
||||
xfree(pDRIDrawablePriv);
|
||||
|
||||
/*
|
||||
* Now set the dix privates to NULL that were previously set.
|
||||
* This prevents reusing an invalid pointer.
|
||||
*/
|
||||
if(pDrawable->type == DRAWABLE_WINDOW) {
|
||||
WindowPtr pWin = (WindowPtr)pDrawable;
|
||||
|
||||
pWin->devPrivates[DRIWindowPrivIndex].ptr = NULL;
|
||||
} else if(pDrawable->type == DRAWABLE_PIXMAP) {
|
||||
PixmapPtr pPix = (PixmapPtr)pDrawable;
|
||||
|
||||
pPix->devPrivates[DRIPixmapPrivIndex].ptr = NULL;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -564,8 +642,9 @@ DRIDrawablePrivDelete(pointer pResource, XID id)
|
|||
pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix);
|
||||
}
|
||||
|
||||
if (pDRIDrawablePriv == NULL)
|
||||
return FALSE;
|
||||
if (pDRIDrawablePriv == NULL) {
|
||||
return DRIFreePixmapImp(pDrawable);
|
||||
}
|
||||
|
||||
if (pDRIDrawablePriv->drawableIndex != -1) {
|
||||
/* release drawable table entry */
|
||||
|
@ -758,3 +837,139 @@ DRISurfaceNotify(xp_surface_id id, int kind)
|
|||
DRIDrawablePrivResType, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
Bool DRICreatePixmap(ScreenPtr pScreen, Drawable id,
|
||||
DrawablePtr pDrawable, char *path,
|
||||
size_t pathmax)
|
||||
{
|
||||
DRIPixmapBufferPtr shared;
|
||||
PixmapPtr pPix;
|
||||
|
||||
if(pDrawable->type != DRAWABLE_PIXMAP)
|
||||
return FALSE;
|
||||
|
||||
pPix = (PixmapPtr)pDrawable;
|
||||
|
||||
shared = xalloc(sizeof(*shared));
|
||||
if(NULL == shared) {
|
||||
FatalError("failed to allocate DRIPixmapBuffer in %s\n", __func__);
|
||||
}
|
||||
|
||||
shared->pDrawable = pDrawable;
|
||||
shared->refCount = 1;
|
||||
|
||||
if(pDrawable->bitsPerPixel >= 24) {
|
||||
shared->bytesPerPixel = 4;
|
||||
} else if(pDrawable->bitsPerPixel <= 16) {
|
||||
shared->bytesPerPixel = 2;
|
||||
}
|
||||
|
||||
shared->width = pDrawable->width;
|
||||
shared->height = pDrawable->height;
|
||||
|
||||
if(-1 == snprintf(shared->shmPath, sizeof(shared->shmPath),
|
||||
"%d_0x%lx", getpid(),
|
||||
(unsigned long)id)) {
|
||||
FatalError("buffer overflow in %s\n", __func__);
|
||||
}
|
||||
|
||||
shared->fd = shm_open(shared->shmPath,
|
||||
O_RDWR | O_EXCL | O_CREAT,
|
||||
S_IRUSR | S_IWUSR | S_IROTH | S_IWOTH);
|
||||
|
||||
if(-1 == shared->fd) {
|
||||
xfree(shared);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
shared->length = shared->width * shared->height * shared->bytesPerPixel;
|
||||
|
||||
if(-1 == ftruncate(shared->fd, shared->length)) {
|
||||
ErrorF("failed to ftruncate (extend) file.");
|
||||
shm_unlink(shared->shmPath);
|
||||
close(shared->fd);
|
||||
xfree(shared);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
shared->buffer = mmap(NULL, shared->length,
|
||||
PROT_READ | PROT_WRITE,
|
||||
MAP_FILE | MAP_SHARED, shared->fd, 0);
|
||||
|
||||
if(MAP_FAILED == shared->buffer) {
|
||||
ErrorF("failed to mmap shared memory.");
|
||||
shm_unlink(shared->shmPath);
|
||||
close(shared->fd);
|
||||
xfree(shared);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
strncpy(path, shared->shmPath, pathmax);
|
||||
path[pathmax - 1] = '\0';
|
||||
|
||||
pPix->devPrivates[DRIPixmapBufferPrivIndex].ptr = shared;
|
||||
|
||||
AddResource(id, DRIDrawablePrivResType, (pointer)pDrawable);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
Bool DRIGetPixmapData(DrawablePtr pDrawable, int *width, int *height,
|
||||
int *pitch, int *bpp, void **ptr) {
|
||||
PixmapPtr pPix;
|
||||
DRIPixmapBufferPtr shared;
|
||||
|
||||
if(pDrawable->type != DRAWABLE_PIXMAP)
|
||||
return FALSE;
|
||||
|
||||
pPix = (PixmapPtr)pDrawable;
|
||||
|
||||
shared = pPix->devPrivates[DRIPixmapBufferPrivIndex].ptr;
|
||||
|
||||
if(NULL == shared)
|
||||
return FALSE;
|
||||
|
||||
assert(pDrawable->width == shared->width);
|
||||
assert(pDrawable->height == shared->height);
|
||||
|
||||
*width = shared->width;
|
||||
*height = shared->height;
|
||||
*bpp = shared->bytesPerPixel;
|
||||
*pitch = shared->width * shared->bytesPerPixel;
|
||||
*ptr = shared->buffer;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Bool
|
||||
DRIFreePixmapImp(DrawablePtr pDrawable) {
|
||||
DRIPixmapBufferPtr shared;
|
||||
PixmapPtr pPix;
|
||||
|
||||
if(pDrawable->type != DRAWABLE_PIXMAP)
|
||||
return FALSE;
|
||||
|
||||
pPix = (PixmapPtr)pDrawable;
|
||||
|
||||
shared = pPix->devPrivates[DRIPixmapBufferPrivIndex].ptr;
|
||||
|
||||
if(NULL == shared)
|
||||
return FALSE;
|
||||
|
||||
close(shared->fd);
|
||||
munmap(shared->buffer, shared->length);
|
||||
shm_unlink(shared->shmPath);
|
||||
xfree(shared);
|
||||
|
||||
pPix->devPrivates[DRIPixmapBufferPrivIndex].ptr = NULL;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
DRIDestroyPixmap(DrawablePtr pDrawable) {
|
||||
if(DRIFreePixmapImp(pDrawable))
|
||||
FreeResourceByType(pDrawable->id, DRIDrawablePrivResType, FALSE);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**************************************************************************
|
||||
|
||||
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
Copyright (c) 2002 Apple Computer, Inc.
|
||||
Copyright (c) 2002, 2009 Apple Computer, Inc.
|
||||
All Rights Reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
|
@ -125,4 +125,14 @@ extern void DRIQueryVersion(int *majorVersion,
|
|||
int *minorVersion,
|
||||
int *patchVersion);
|
||||
|
||||
extern Bool DRICreatePixmap(ScreenPtr pScreen, Drawable id,
|
||||
DrawablePtr pDrawable, char *path,
|
||||
size_t pathmax);
|
||||
|
||||
extern Bool DRIGetPixmapData(DrawablePtr pDrawable, int *width, int *height,
|
||||
int *pitch, int *bpp, void **ptr);
|
||||
|
||||
|
||||
extern void DRIDestroyPixmap(DrawablePtr pDrawable);
|
||||
|
||||
#endif
|
||||
|
|
545
hw/xquartz/xpr/driWrap.c
Normal file
545
hw/xquartz/xpr/driWrap.c
Normal file
|
@ -0,0 +1,545 @@
|
|||
/*
|
||||
Copyright (c) 2009 Apple Computer, 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, sub license, 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 PRECISION INSIGHT AND/OR ITS 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.
|
||||
*/
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include "mi.h"
|
||||
#include "scrnintstr.h"
|
||||
#include "gcstruct.h"
|
||||
#include "pixmapstr.h"
|
||||
#include "windowstr.h"
|
||||
#include "dixfontstr.h"
|
||||
#include "mivalidate.h"
|
||||
#include "driWrap.h"
|
||||
#include "dri.h"
|
||||
|
||||
#include <OpenGL/OpenGL.h>
|
||||
|
||||
typedef struct {
|
||||
GCOps *originalOps;
|
||||
GCOps *driOps;
|
||||
} DRIGCRec;
|
||||
|
||||
typedef struct {
|
||||
GCOps *originalOps;
|
||||
CreateGCProcPtr CreateGC;
|
||||
} DRIWrapScreenRec;
|
||||
|
||||
typedef struct {
|
||||
Bool didSave;
|
||||
int devKind;
|
||||
DevUnion devPrivate;
|
||||
} DRISavedDrawableState;
|
||||
|
||||
static int driGCPrivIndex = -1;
|
||||
static int driWrapScreenPrivIndex = -1;
|
||||
|
||||
static GCOps driGCOps;
|
||||
|
||||
#define wrap(priv, real, member, func) { \
|
||||
priv->member = real->member; \
|
||||
real->member = func; \
|
||||
}
|
||||
|
||||
#define unwrap(priv, real, member) { \
|
||||
real->member = priv->member; \
|
||||
}
|
||||
|
||||
static DRIGCRec *
|
||||
DRIGetGCPriv(GCPtr pGC) {
|
||||
return pGC->devPrivates[driGCPrivIndex].ptr;
|
||||
}
|
||||
|
||||
static void
|
||||
DRIUnwrapGC(GCPtr pGC) {
|
||||
DRIGCRec *pGCPriv = DRIGetGCPriv(pGC);
|
||||
|
||||
pGC->ops = pGCPriv->originalOps;
|
||||
}
|
||||
|
||||
static void
|
||||
DRIWrapGC(GCPtr pGC) {
|
||||
DRIGCRec *pGCPriv = DRIGetGCPriv(pGC);
|
||||
|
||||
pGC->ops = pGCPriv->driOps;
|
||||
}
|
||||
|
||||
static void
|
||||
DRISurfaceSetDrawable(DrawablePtr pDraw,
|
||||
DRISavedDrawableState *saved) {
|
||||
saved->didSave = FALSE;
|
||||
|
||||
if(pDraw->type == DRAWABLE_PIXMAP) {
|
||||
int pitch, width, height, bpp;
|
||||
void *buffer;
|
||||
|
||||
if(DRIGetPixmapData(pDraw, &width, &height, &pitch, &bpp, &buffer)) {
|
||||
PixmapPtr pPix = (PixmapPtr)pDraw;
|
||||
|
||||
saved->devKind = pPix->devKind;
|
||||
saved->devPrivate.ptr = pPix->devPrivate.ptr;
|
||||
saved->didSave = TRUE;
|
||||
|
||||
pPix->devKind = pitch;
|
||||
pPix->devPrivate.ptr = buffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
DRISurfaceRestoreDrawable(DrawablePtr pDraw,
|
||||
DRISavedDrawableState *saved) {
|
||||
PixmapPtr pPix = (PixmapPtr)pDraw;
|
||||
|
||||
if(!saved->didSave)
|
||||
return;
|
||||
|
||||
pPix->devKind = saved->devKind;
|
||||
pPix->devPrivate.ptr = saved->devPrivate.ptr;
|
||||
}
|
||||
|
||||
static void
|
||||
DRIFillSpans(DrawablePtr dst, GCPtr pGC, int nInit,
|
||||
DDXPointPtr pptInit, int *pwidthInit,
|
||||
int sorted) {
|
||||
DRISavedDrawableState saved;
|
||||
|
||||
DRISurfaceSetDrawable(dst, &saved);
|
||||
|
||||
DRIUnwrapGC(pGC);
|
||||
|
||||
pGC->ops->FillSpans(dst, pGC, nInit, pptInit, pwidthInit, sorted);
|
||||
|
||||
DRIWrapGC(pGC);
|
||||
|
||||
DRISurfaceRestoreDrawable(dst, &saved);
|
||||
}
|
||||
|
||||
static void
|
||||
DRISetSpans(DrawablePtr dst, GCPtr pGC, char *pSrc,
|
||||
DDXPointPtr pptInit, int *pwidthInit,
|
||||
int nspans, int sorted) {
|
||||
DRISavedDrawableState saved;
|
||||
|
||||
DRISurfaceSetDrawable(dst, &saved);
|
||||
|
||||
DRIUnwrapGC(pGC);
|
||||
|
||||
pGC->ops->SetSpans(dst, pGC, pSrc, pptInit, pwidthInit, nspans, sorted);
|
||||
|
||||
DRIWrapGC(pGC);
|
||||
|
||||
DRISurfaceRestoreDrawable(dst, &saved);
|
||||
}
|
||||
|
||||
static void
|
||||
DRIPutImage(DrawablePtr dst, GCPtr pGC,
|
||||
int depth, int x, int y, int w, int h,
|
||||
int leftPad, int format, char *pBits) {
|
||||
DRISavedDrawableState saved;
|
||||
|
||||
DRISurfaceSetDrawable(dst, &saved);
|
||||
|
||||
DRIUnwrapGC(pGC);
|
||||
|
||||
pGC->ops->PutImage(dst, pGC, depth, x, y, w, h, leftPad, format, pBits);
|
||||
|
||||
DRIWrapGC(pGC);
|
||||
|
||||
DRISurfaceRestoreDrawable(dst, &saved);
|
||||
}
|
||||
|
||||
static RegionPtr
|
||||
DRICopyArea(DrawablePtr pSrc, DrawablePtr dst, GCPtr pGC,
|
||||
int srcx, int srcy, int w, int h,
|
||||
int dstx, int dsty) {
|
||||
RegionPtr pReg;
|
||||
DRISavedDrawableState pSrcSaved, dstSaved;
|
||||
|
||||
DRISurfaceSetDrawable(pSrc, &pSrcSaved);
|
||||
DRISurfaceSetDrawable(dst, &dstSaved);
|
||||
|
||||
DRIUnwrapGC(pGC);
|
||||
|
||||
pReg = pGC->ops->CopyArea(pSrc, dst, pGC, srcx, srcy, w, h, dstx, dsty);
|
||||
|
||||
DRIWrapGC(pGC);
|
||||
|
||||
DRISurfaceRestoreDrawable(pSrc, &pSrcSaved);
|
||||
DRISurfaceRestoreDrawable(dst, &dstSaved);
|
||||
|
||||
return pReg;
|
||||
}
|
||||
|
||||
static RegionPtr
|
||||
DRICopyPlane(DrawablePtr pSrc, DrawablePtr dst,
|
||||
GCPtr pGC, int srcx, int srcy,
|
||||
int w, int h, int dstx, int dsty,
|
||||
unsigned long plane) {
|
||||
RegionPtr pReg;
|
||||
DRISavedDrawableState pSrcSaved, dstSaved;
|
||||
|
||||
DRISurfaceSetDrawable(pSrc, &pSrcSaved);
|
||||
DRISurfaceSetDrawable(dst, &dstSaved);
|
||||
|
||||
|
||||
DRIUnwrapGC(pGC);
|
||||
|
||||
pReg = pGC->ops->CopyPlane(pSrc, dst, pGC, srcx, srcy, w, h, dstx, dsty,
|
||||
plane);
|
||||
|
||||
DRIWrapGC(pGC);
|
||||
|
||||
DRISurfaceRestoreDrawable(pSrc, &pSrcSaved);
|
||||
DRISurfaceRestoreDrawable(dst, &dstSaved);
|
||||
|
||||
return pReg;
|
||||
}
|
||||
|
||||
static void
|
||||
DRIPolyPoint(DrawablePtr dst, GCPtr pGC,
|
||||
int mode, int npt, DDXPointPtr pptInit) {
|
||||
DRISavedDrawableState saved;
|
||||
|
||||
DRISurfaceSetDrawable(dst, &saved);
|
||||
|
||||
DRIUnwrapGC(pGC);
|
||||
|
||||
pGC->ops->PolyPoint(dst, pGC, mode, npt, pptInit);
|
||||
|
||||
DRIWrapGC(pGC);
|
||||
|
||||
DRISurfaceRestoreDrawable(dst, &saved);
|
||||
}
|
||||
|
||||
static void
|
||||
DRIPolylines(DrawablePtr dst, GCPtr pGC,
|
||||
int mode, int npt, DDXPointPtr pptInit) {
|
||||
DRISavedDrawableState saved;
|
||||
|
||||
DRISurfaceSetDrawable(dst, &saved);
|
||||
|
||||
DRIUnwrapGC(pGC);
|
||||
|
||||
pGC->ops->Polylines(dst, pGC, mode, npt, pptInit);
|
||||
|
||||
DRIWrapGC(pGC);
|
||||
|
||||
DRISurfaceRestoreDrawable(dst, &saved);
|
||||
}
|
||||
|
||||
static void
|
||||
DRIPolySegment(DrawablePtr dst, GCPtr pGC,
|
||||
int nseg, xSegment *pSeg) {
|
||||
DRISavedDrawableState saved;
|
||||
|
||||
DRISurfaceSetDrawable(dst, &saved);
|
||||
|
||||
DRIUnwrapGC(pGC);
|
||||
|
||||
pGC->ops->PolySegment(dst, pGC, nseg, pSeg);
|
||||
|
||||
DRIWrapGC(pGC);
|
||||
|
||||
DRISurfaceRestoreDrawable(dst, &saved);
|
||||
}
|
||||
|
||||
static void
|
||||
DRIPolyRectangle(DrawablePtr dst, GCPtr pGC,
|
||||
int nRects, xRectangle *pRects) {
|
||||
DRISavedDrawableState saved;
|
||||
|
||||
DRISurfaceSetDrawable(dst, &saved);
|
||||
|
||||
DRIUnwrapGC(pGC);
|
||||
|
||||
pGC->ops->PolyRectangle(dst, pGC, nRects, pRects);
|
||||
|
||||
DRIWrapGC(pGC);
|
||||
|
||||
DRISurfaceRestoreDrawable(dst, &saved);
|
||||
}
|
||||
static void
|
||||
DRIPolyArc(DrawablePtr dst, GCPtr pGC, int narcs, xArc *parcs) {
|
||||
DRISavedDrawableState saved;
|
||||
|
||||
DRISurfaceSetDrawable(dst, &saved);
|
||||
|
||||
DRIUnwrapGC(pGC);
|
||||
|
||||
pGC->ops->PolyArc(dst, pGC, narcs, parcs);
|
||||
|
||||
DRIWrapGC(pGC);
|
||||
|
||||
DRISurfaceRestoreDrawable(dst, &saved);
|
||||
}
|
||||
|
||||
static void
|
||||
DRIFillPolygon(DrawablePtr dst, GCPtr pGC,
|
||||
int shape, int mode, int count,
|
||||
DDXPointPtr pptInit) {
|
||||
DRISavedDrawableState saved;
|
||||
|
||||
DRISurfaceSetDrawable(dst, &saved);
|
||||
|
||||
DRIUnwrapGC(pGC);
|
||||
|
||||
pGC->ops->FillPolygon(dst, pGC, shape, mode, count, pptInit);
|
||||
|
||||
DRIWrapGC(pGC);
|
||||
|
||||
DRISurfaceRestoreDrawable(dst, &saved);
|
||||
}
|
||||
|
||||
static void
|
||||
DRIPolyFillRect(DrawablePtr dst, GCPtr pGC,
|
||||
int nRectsInit, xRectangle *pRectsInit) {
|
||||
DRISavedDrawableState saved;
|
||||
|
||||
DRISurfaceSetDrawable(dst, &saved);
|
||||
|
||||
DRIUnwrapGC(pGC);
|
||||
|
||||
pGC->ops->PolyFillRect(dst, pGC, nRectsInit, pRectsInit);
|
||||
|
||||
DRIWrapGC(pGC);
|
||||
|
||||
DRISurfaceRestoreDrawable(dst, &saved);
|
||||
}
|
||||
|
||||
static void
|
||||
DRIPolyFillArc(DrawablePtr dst, GCPtr pGC,
|
||||
int narcsInit, xArc *parcsInit) {
|
||||
DRISavedDrawableState saved;
|
||||
|
||||
DRISurfaceSetDrawable(dst, &saved);
|
||||
|
||||
DRIUnwrapGC(pGC);
|
||||
|
||||
pGC->ops->PolyFillArc(dst, pGC, narcsInit, parcsInit);
|
||||
|
||||
DRIWrapGC(pGC);
|
||||
|
||||
DRISurfaceRestoreDrawable(dst, &saved);
|
||||
}
|
||||
|
||||
static int
|
||||
DRIPolyText8(DrawablePtr dst, GCPtr pGC,
|
||||
int x, int y, int count, char *chars) {
|
||||
int ret;
|
||||
DRISavedDrawableState saved;
|
||||
|
||||
DRISurfaceSetDrawable(dst, &saved);
|
||||
|
||||
DRIUnwrapGC(pGC);
|
||||
|
||||
ret = pGC->ops->PolyText8(dst, pGC, x, y, count, chars);
|
||||
|
||||
DRIWrapGC(pGC);
|
||||
|
||||
DRISurfaceRestoreDrawable(dst, &saved);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
DRIPolyText16(DrawablePtr dst, GCPtr pGC,
|
||||
int x, int y, int count, unsigned short *chars) {
|
||||
int ret;
|
||||
DRISavedDrawableState saved;
|
||||
|
||||
DRISurfaceSetDrawable(dst, &saved);
|
||||
|
||||
DRIUnwrapGC(pGC);
|
||||
|
||||
ret = pGC->ops->PolyText16(dst, pGC, x, y, count, chars);
|
||||
|
||||
DRIWrapGC(pGC);
|
||||
|
||||
DRISurfaceRestoreDrawable(dst, &saved);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
DRIImageText8(DrawablePtr dst, GCPtr pGC,
|
||||
int x, int y, int count, char *chars) {
|
||||
DRISavedDrawableState saved;
|
||||
|
||||
DRISurfaceSetDrawable(dst, &saved);
|
||||
|
||||
DRIUnwrapGC(pGC);
|
||||
|
||||
pGC->ops->ImageText8(dst, pGC, x, y, count, chars);
|
||||
|
||||
DRIWrapGC(pGC);
|
||||
|
||||
DRISurfaceRestoreDrawable(dst, &saved);
|
||||
}
|
||||
|
||||
static void
|
||||
DRIImageText16(DrawablePtr dst, GCPtr pGC,
|
||||
int x, int y, int count, unsigned short *chars) {
|
||||
DRISavedDrawableState saved;
|
||||
|
||||
DRISurfaceSetDrawable(dst, &saved);
|
||||
|
||||
DRIUnwrapGC(pGC);
|
||||
|
||||
pGC->ops->ImageText16(dst, pGC, x, y, count, chars);
|
||||
|
||||
DRIWrapGC(pGC);
|
||||
|
||||
DRISurfaceRestoreDrawable(dst, &saved);
|
||||
}
|
||||
|
||||
static void
|
||||
DRIImageGlyphBlt(DrawablePtr dst, GCPtr pGC,
|
||||
int x, int y, unsigned int nglyphInit,
|
||||
CharInfoPtr *ppciInit, pointer unused) {
|
||||
DRISavedDrawableState saved;
|
||||
|
||||
DRISurfaceSetDrawable(dst, &saved);
|
||||
|
||||
DRIUnwrapGC(pGC);
|
||||
|
||||
pGC->ops->ImageGlyphBlt(dst, pGC, x, y, nglyphInit, ppciInit, unused);
|
||||
|
||||
DRIWrapGC(pGC);
|
||||
|
||||
DRISurfaceRestoreDrawable(dst, &saved);
|
||||
}
|
||||
|
||||
static void DRIPolyGlyphBlt(DrawablePtr dst, GCPtr pGC,
|
||||
int x, int y, unsigned int nglyph,
|
||||
CharInfoPtr *ppci, pointer pglyphBase) {
|
||||
DRISavedDrawableState saved;
|
||||
|
||||
DRISurfaceSetDrawable(dst, &saved);
|
||||
|
||||
DRIUnwrapGC(pGC);
|
||||
|
||||
pGC->ops->PolyGlyphBlt(dst, pGC, x, y, nglyph, ppci, pglyphBase);
|
||||
|
||||
DRIWrapGC(pGC);
|
||||
|
||||
DRISurfaceRestoreDrawable(dst, &saved);
|
||||
}
|
||||
|
||||
static void
|
||||
DRIPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr dst,
|
||||
int dx, int dy, int xOrg, int yOrg) {
|
||||
DRISavedDrawableState bitMapSaved, dstSaved;
|
||||
|
||||
DRISurfaceSetDrawable(&pBitMap->drawable, &bitMapSaved);
|
||||
DRISurfaceSetDrawable(dst, &dstSaved);
|
||||
|
||||
DRIUnwrapGC(pGC);
|
||||
|
||||
pGC->ops->PushPixels(pGC, pBitMap, dst, dx, dy, xOrg, yOrg);
|
||||
|
||||
DRIWrapGC(pGC);
|
||||
|
||||
DRISurfaceRestoreDrawable(&pBitMap->drawable, &bitMapSaved);
|
||||
DRISurfaceRestoreDrawable(dst, &dstSaved);
|
||||
}
|
||||
|
||||
|
||||
static GCOps driGCOps = {
|
||||
DRIFillSpans,
|
||||
DRISetSpans,
|
||||
DRIPutImage,
|
||||
DRICopyArea,
|
||||
DRICopyPlane,
|
||||
DRIPolyPoint,
|
||||
DRIPolylines,
|
||||
DRIPolySegment,
|
||||
DRIPolyRectangle,
|
||||
DRIPolyArc,
|
||||
DRIFillPolygon,
|
||||
DRIPolyFillRect,
|
||||
DRIPolyFillArc,
|
||||
DRIPolyText8,
|
||||
DRIPolyText16,
|
||||
DRIImageText8,
|
||||
DRIImageText16,
|
||||
DRIImageGlyphBlt,
|
||||
DRIPolyGlyphBlt,
|
||||
DRIPushPixels
|
||||
};
|
||||
|
||||
|
||||
static Bool
|
||||
DRICreateGC(GCPtr pGC) {
|
||||
ScreenPtr pScreen = pGC->pScreen;
|
||||
DRIWrapScreenRec *pScreenPriv;
|
||||
DRIGCRec *pGCPriv;
|
||||
Bool ret;
|
||||
|
||||
pScreenPriv = pScreen->devPrivates[driWrapScreenPrivIndex].ptr;
|
||||
|
||||
pGCPriv = DRIGetGCPriv(pGC);
|
||||
|
||||
unwrap(pScreenPriv, pScreen, CreateGC);
|
||||
ret = pScreen->CreateGC(pGC);
|
||||
|
||||
if(ret) {
|
||||
pGCPriv->originalOps = pGC->ops;
|
||||
pGC->ops = &driGCOps;
|
||||
pGCPriv->driOps = &driGCOps;
|
||||
}
|
||||
|
||||
wrap(pScreenPriv, pScreen, CreateGC, DRICreateGC);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* Return false if an error occurred. */
|
||||
Bool
|
||||
DRIWrapInit(ScreenPtr pScreen) {
|
||||
DRIWrapScreenRec *pScreenPriv;
|
||||
|
||||
if ((driGCPrivIndex = AllocateGCPrivateIndex()) < 0)
|
||||
return FALSE;
|
||||
if ((driWrapScreenPrivIndex = AllocateScreenPrivateIndex()) < 0)
|
||||
return FALSE;
|
||||
if(!AllocateGCPrivate(pScreen, driGCPrivIndex, sizeof(DRIGCRec)))
|
||||
return FALSE;
|
||||
|
||||
pScreenPriv = xalloc(sizeof(*pScreenPriv));
|
||||
|
||||
if(NULL == pScreenPriv)
|
||||
return FALSE;
|
||||
|
||||
pScreenPriv->CreateGC = pScreen->CreateGC;
|
||||
pScreen->CreateGC = DRICreateGC;
|
||||
|
||||
pScreen->devPrivates[driWrapScreenPrivIndex].ptr = pScreenPriv;
|
||||
|
||||
return TRUE;
|
||||
}
|
31
hw/xquartz/xpr/driWrap.h
Normal file
31
hw/xquartz/xpr/driWrap.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
Copyright (c) 2009 Apple Computer, 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, sub license, 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 PRECISION INSIGHT AND/OR ITS 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.
|
||||
*/
|
||||
|
||||
#ifndef DRIWRAP_H
|
||||
#include "scrnintstr.h"
|
||||
|
||||
Bool DRIWrapInit(ScreenPtr pScreen);
|
||||
|
||||
#endif /*DRIWRAP_H*/
|
Loading…
Reference in New Issue
Block a user