summaryrefslogtreecommitdiffstats
path: root/src/glx/apple/glxreply.c
diff options
context:
space:
mode:
authorJeremy Huddleston <[email protected]>2010-04-01 11:01:31 -0700
committerJeremy Huddleston <[email protected]>2010-04-27 11:26:50 -0700
commitad503c41557606d15b0420c824369456f6d20a8f (patch)
tree7155272412f9b20b559fa172a1718fd8dfe6e98a /src/glx/apple/glxreply.c
parentf1381880a8e0e0cdd96c4c725ff35a28b250b09d (diff)
apple: Initial import of libGL for OSX from AppleSGLX svn repository.
Signed-off-by: Jeremy Huddleston <[email protected]>
Diffstat (limited to 'src/glx/apple/glxreply.c')
-rw-r--r--src/glx/apple/glxreply.c134
1 files changed, 134 insertions, 0 deletions
diff --git a/src/glx/apple/glxreply.c b/src/glx/apple/glxreply.c
new file mode 100644
index 00000000000..7280bc9715a
--- /dev/null
+++ b/src/glx/apple/glxreply.c
@@ -0,0 +1,134 @@
+/*
+ * (C) Copyright Apple Inc. 2008
+ * (C) Copyright IBM Corporation 2004, 2005
+ * 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
+ * IBM,
+ * 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.
+ */
+
+#include <GL/gl.h>
+#include "glxclient.h"
+#include <GL/glxproto.h>
+
+CARD32
+__glXReadReply(Display * dpy, size_t size, void *dest,
+ GLboolean reply_is_always_array)
+{
+ xGLXSingleReply reply;
+
+ (void) _XReply(dpy, (xReply *) & reply, 0, False);
+ if (size != 0) {
+ if ((reply.length > 0) || reply_is_always_array) {
+ const GLint bytes = (reply_is_always_array)
+ ? (4 * reply.length) : (reply.size * size);
+ const GLint extra = 4 - (bytes & 3);
+
+ _XRead(dpy, dest, bytes);
+ if (extra < 4) {
+ _XEatData(dpy, extra);
+ }
+ }
+ else {
+ (void) memcpy(dest, &(reply.pad3), size);
+ }
+ }
+
+ return reply.retval;
+}
+
+void
+__glXReadPixelReply(Display * dpy, __GLXcontext * gc, unsigned max_dim,
+ GLint width, GLint height, GLint depth, GLenum format,
+ GLenum type, void *dest, GLboolean dimensions_in_reply)
+{
+ xGLXSingleReply reply;
+ GLint size;
+
+ (void) _XReply(dpy, (xReply *) & reply, 0, False);
+
+ if (dimensions_in_reply) {
+ width = reply.pad3;
+ height = reply.pad4;
+ depth = reply.pad5;
+
+ if ((height == 0) || (max_dim < 2)) {
+ height = 1;
+ }
+ if ((depth == 0) || (max_dim < 3)) {
+ depth = 1;
+ }
+ }
+
+ size = reply.length * 4;
+ if (size != 0) {
+ void *buf = Xmalloc(size);
+
+ if (buf == NULL) {
+ _XEatData(dpy, size);
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ }
+ else {
+ const GLint extra = 4 - (size & 3);
+
+ _XRead(dpy, buf, size);
+ if (extra < 4) {
+ _XEatData(dpy, extra);
+ }
+
+ __glEmptyImage(gc, 3, width, height, depth, format, type, buf, dest);
+ Xfree(buf);
+ }
+ }
+}
+
+#if 0
+GLubyte *
+__glXSetupSingleRequest(__GLXcontext * gc, GLint sop, GLint cmdlen)
+{
+ xGLXSingleReq *req;
+ Display *const dpy = gc->currentDpy;
+
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ LockDisplay(dpy);
+ GetReqExtra(GLXSingle, cmdlen, req);
+ req->reqType = gc->majorOpcode;
+ req->contextTag = gc->currentContextTag;
+ req->glxCode = sop;
+ return (GLubyte *) (req) + sz_xGLXSingleReq;
+}
+#endif
+
+GLubyte *
+__glXSetupVendorRequest(__GLXcontext * gc, GLint code, GLint vop,
+ GLint cmdlen)
+{
+ xGLXVendorPrivateReq *req;
+ Display *const dpy = gc->currentDpy;
+
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ LockDisplay(dpy);
+ GetReqExtra(GLXVendorPrivate, cmdlen, req);
+ req->reqType = gc->majorOpcode;
+ req->glxCode = code;
+ req->vendorCode = vop;
+ req->contextTag = gc->currentContextTag;
+ return (GLubyte *) (req) + sz_xGLXVendorPrivateReq;
+}