aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xquartz/xpr/appledri.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/hw/xquartz/xpr/appledri.c')
-rw-r--r--xorg-server/hw/xquartz/xpr/appledri.c80
1 files changed, 77 insertions, 3 deletions
diff --git a/xorg-server/hw/xquartz/xpr/appledri.c b/xorg-server/hw/xquartz/xpr/appledri.c
index 3667c0dea..4d1a82fcc 100644
--- a/xorg-server/hw/xquartz/xpr/appledri.c
+++ b/xorg-server/hw/xquartz/xpr/appledri.c
@@ -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
@@ -39,8 +39,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <dix-config.h>
#endif
-#define NEED_REPLIES
-#define NEED_EVENTS
#include <X11/X.h>
#include <X11/Xproto.h>
#include "misc.h"
@@ -64,6 +62,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 +273,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 +372,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;
}