176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman/*
276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman Copyright (c) 2009 Apple Inc.
376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman Permission is hereby granted, free of charge, to any person
57987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman obtaining a copy of this software and associated documentation files
676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman (the "Software"), to deal in the Software without restriction,
776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman including without limitation the rights to use, copy, modify, merge,
876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman publish, distribute, sublicense, and/or sell copies of the Software,
976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman and to permit persons to whom the Software is furnished to do so,
1076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman subject to the following conditions:
1176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
1276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman The above copyright notice and this permission notice shall be
1376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman included in all copies or substantial portions of the Software.
1476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
1576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman NONINFRINGEMENT.  IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
1976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
2076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman DEALINGS IN THE SOFTWARE.
2376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
2476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman Except as contained in this notice, the name(s) of the above
2576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman copyright holders shall not be used in advertising or otherwise to
2676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman promote the sale, use or other dealings in this Software without
2776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman prior written authorization.
2876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman*/
2976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
3076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include <stdio.h>
3176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include <stdlib.h>
3276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include <pthread.h>
3376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include <fcntl.h>
3476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include <sys/types.h>
3576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include <sys/mman.h>
3676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include <unistd.h>
3776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman#include <assert.h>
38f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman#include "apple_glx.h"
39f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman#include "apple_cgl.h"
40f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman#include "apple_visual.h"
41f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman#include "apple_glx_drawable.h"
42f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman#include "appledri.h"
43f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman#include "glxconfig.h"
44f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman
4576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstatic bool pixmap_make_current(struct apple_glx_context *ac,
468c7122c9519dfd46ea7c8c026eab6f7aed74cf21Wichert Akkerman                                struct apple_glx_drawable *d);
47bf79f2e16b090ffe59cd1e1820935680a2da7b78Wichert Akkerman
48bf79f2e16b090ffe59cd1e1820935680a2da7b78Wichert Akkermanstatic void pixmap_destroy(Display * dpy, struct apple_glx_drawable *d);
498c7122c9519dfd46ea7c8c026eab6f7aed74cf21Wichert Akkerman
508c7122c9519dfd46ea7c8c026eab6f7aed74cf21Wichert Akkermanstatic struct apple_glx_drawable_callbacks callbacks = {
518c7122c9519dfd46ea7c8c026eab6f7aed74cf21Wichert Akkerman   .type = APPLE_GLX_DRAWABLE_PIXMAP,
5276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman   .make_current = pixmap_make_current,
53f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman   .destroy = pixmap_destroy
5476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman};
5576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
5676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanstatic bool
5776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanpixmap_make_current(struct apple_glx_context *ac,
5876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman                    struct apple_glx_drawable *d)
5976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
6076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman   CGLError cglerr;
6176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman   struct apple_glx_pixmap *p = &d->types.pixmap;
6276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
63f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman   assert(APPLE_GLX_DRAWABLE_PIXMAP == d->type);
64f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman
65f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman   cglerr = apple_cgl.set_current_context(p->context_obj);
66f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman
67f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman   if (kCGLNoError != cglerr) {
68f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman      fprintf(stderr, "set current context: %s\n",
69f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman              apple_cgl.error_string(cglerr));
70f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman      return true;
71f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman   }
72f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman
73505e176ded6376a1283093b334c2c6deb47916e7Wichert Akkerman   cglerr = apple_cgl.set_off_screen(p->context_obj, p->width, p->height,
74f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman                                     p->pitch, p->buffer);
75f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman
76f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman   if (kCGLNoError != cglerr) {
77f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman      fprintf(stderr, "set off screen: %s\n", apple_cgl.error_string(cglerr));
78f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman
79f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman      return true;
80f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman   }
81f185065a405794eaf6abc0dcf8345d9e6aa882f7Wichert Akkerman
82505e176ded6376a1283093b334c2c6deb47916e7Wichert Akkerman   if (!ac->made_current) {
832f473da12babff710bbe37c7f95be01fd00118f9Wichert Akkerman      apple_glapi_oglfw_viewport_scissor(0, 0, p->width, p->height);
84505e176ded6376a1283093b334c2c6deb47916e7Wichert Akkerman      ac->made_current = true;
85f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman   }
86f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman
87f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman   return false;
88f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman}
89f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman
90f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkermanstatic void
91f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkermanpixmap_destroy(Display * dpy, struct apple_glx_drawable *d)
92f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman{
93f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman   struct apple_glx_pixmap *p = &d->types.pixmap;
94f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman
95f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman   if (p->pixel_format_obj)
96f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman      (void) apple_cgl.destroy_pixel_format(p->pixel_format_obj);
977987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman
987987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman   if (p->context_obj)
997987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman      (void) apple_cgl.destroy_context(p->context_obj);
1007987cdf192632516d6ba493b0a9943f5a3a7c362Wichert Akkerman
10176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman   XAppleDRIDestroyPixmap(dpy, p->xpixmap);
10276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
10376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman   if (p->buffer) {
10476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman      if (munmap(p->buffer, p->size))
10516a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman         perror("munmap");
10616a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman
10716a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman      if (-1 == close(p->fd))
10816a03d2e97415afe6cf34172a0aea97a95a0b160Wichert Akkerman         perror("close");
10976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
11076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman      if (shm_unlink(p->path))
11176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman         perror("shm_unlink");
11276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman   }
11376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
11476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman   apple_glx_diagnostic("destroyed pixmap buffer for: 0x%lx\n", d->drawable);
11576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman}
11676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
11776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman/* Return true if an error occurred. */
11876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanbool
11976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkermanapple_glx_pixmap_create(Display * dpy, int screen, Pixmap pixmap,
12076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman                        const void *mode)
12176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman{
12276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman   struct apple_glx_drawable *d;
123f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman   struct apple_glx_pixmap *p;
124f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman   bool double_buffered;
125f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman   bool uses_stereo;
126f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman   CGLError error;
127f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman   const struct glx_config *cmodes = mode;
128f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman
129f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman   if (apple_glx_drawable_create(dpy, screen, pixmap, &d, &callbacks))
130f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman      return true;
131f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman
132f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman   /* d is locked and referenced at this point. */
133f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman
134f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman   p = &d->types.pixmap;
135f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman
136f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman   p->xpixmap = pixmap;
137f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman   p->buffer = NULL;
13876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
13976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman   if (!XAppleDRICreatePixmap(dpy, screen, pixmap,
14076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman                              &p->width, &p->height, &p->pitch, &p->bpp,
14176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman                              &p->size, p->path, PATH_MAX)) {
14276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman      d->unlock(d);
14376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman      d->destroy(d);
14476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman      return true;
14576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman   }
14676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
14776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman   p->fd = shm_open(p->path, O_RDWR, 0);
14876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
14976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman   if (p->fd < 0) {
15076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman      perror("shm_open");
15176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman      d->unlock(d);
15276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman      d->destroy(d);
15376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman      return true;
15476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman   }
15576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
15676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman   p->buffer = mmap(NULL, p->size, PROT_READ | PROT_WRITE,
15776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman                    MAP_FILE | MAP_SHARED, p->fd, 0);
15876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
15976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman   if (MAP_FAILED == p->buffer) {
16076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman      perror("mmap");
16176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman      d->unlock(d);
16276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman      d->destroy(d);
16376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman      return true;
16476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman   }
16576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
16676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman   apple_visual_create_pfobj(&p->pixel_format_obj, mode, &double_buffered,
16776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman                             &uses_stereo, /*offscreen */ true);
16876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
16976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman   error = apple_cgl.create_context(p->pixel_format_obj, NULL,
17076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman                                    &p->context_obj);
17176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
17276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman   if (kCGLNoError != error) {
17376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman      d->unlock(d);
17476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman      d->destroy(d);
17576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman      return true;
17676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman   }
17776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
17876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman   p->fbconfigID = cmodes->fbconfigID;
179f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman
180f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman   d->unlock(d);
181f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman
182f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman   apple_glx_diagnostic("created: pixmap buffer for 0x%lx\n", d->drawable);
183e4aafd4c4d5ecd3317419d1681ef5804dbf1333eWichert Akkerman
184f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman   return false;
185e4aafd4c4d5ecd3317419d1681ef5804dbf1333eWichert Akkerman}
186f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman
187f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkermanbool
188f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkermanapple_glx_pixmap_query(GLXPixmap pixmap, int attr, unsigned int *value)
189f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman{
190e4aafd4c4d5ecd3317419d1681ef5804dbf1333eWichert Akkerman   struct apple_glx_drawable *d;
191f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman   struct apple_glx_pixmap *p;
192e4aafd4c4d5ecd3317419d1681ef5804dbf1333eWichert Akkerman   bool result = false;
193e4aafd4c4d5ecd3317419d1681ef5804dbf1333eWichert Akkerman
194f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman   d = apple_glx_drawable_find_by_type(pixmap, APPLE_GLX_DRAWABLE_PIXMAP,
195e4aafd4c4d5ecd3317419d1681ef5804dbf1333eWichert Akkerman                                       APPLE_GLX_DRAWABLE_LOCK);
196e4aafd4c4d5ecd3317419d1681ef5804dbf1333eWichert Akkerman
197f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman   if (d) {
198f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman      p = &d->types.pixmap;
199e4aafd4c4d5ecd3317419d1681ef5804dbf1333eWichert Akkerman
200f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman      switch (attr) {
201f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman      case GLX_WIDTH:
202f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman         *value = p->width;
203f5eeabb156641482abd504fb98b039e1aae4ae87Wichert Akkerman         result = true;
20476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman         break;
20576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
20676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman      case GLX_HEIGHT:
20776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman         *value = p->height;
20876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman         result = true;
20976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman         break;
21076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
21176baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman      case GLX_FBCONFIG_ID:
21276baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman         *value = p->fbconfigID;
21376baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman         result = true;
21476baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman         break;
21576baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman      }
21676baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
21776baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman      d->unlock(d);
21876baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman   }
21976baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman
22076baf7c9f6dd61a15524ad43c1b690c252cf5b7Wichert Akkerman   return result;
221efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman}
222efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman
223efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman/* Return true if the type is valid for pixmap. */
224efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkermanbool
225efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkermanapple_glx_pixmap_destroy(Display * dpy, GLXPixmap pixmap)
226efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman{
227efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman   return !apple_glx_drawable_destroy_by_type(dpy, pixmap,
228efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman                                              APPLE_GLX_DRAWABLE_PIXMAP);
229efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman}
230efdecacc5d7f91c17adb7cdb1dd7306ea6d22c9fWichert Akkerman