glx: unify GLX_SGIX_pbuffer aliased declarations
[mesa.git] / src / glx / apple / apple_glx_surface.c
index 6db2910a464de7137e6ead62b620a482567f1c86..51583bb40bc582ba14b52e6a1a00a4e2939a78fb 100644 (file)
@@ -53,8 +53,7 @@ update_viewport_and_scissor(Display * dpy, GLXDrawable drawable)
 
    XGetGeometry(dpy, drawable, &root, &x, &y, &width, &height, &bd, &depth);
 
-   glViewport(0, 0, width, height);
-   glScissor(0, 0, width, height);
+   apple_glapi_oglfw_viewport_scissor(0, 0, width, height);
 }
 
 static bool
@@ -125,7 +124,7 @@ surface_destroy(Display * dpy, struct apple_glx_drawable *d)
    }
 }
 
-/* Return true if an error occured. */
+/* Return true if an error occurred. */
 static bool
 create_surface(Display * dpy, int screen, struct apple_glx_drawable *d)
 {
@@ -159,7 +158,7 @@ create_surface(Display * dpy, int screen, struct apple_glx_drawable *d)
    return true;                 /* unable to create a surface. */
 }
 
-/* Return true if an error occured. */
+/* Return true if an error occurred. */
 /* This returns a referenced object via resultptr. */
 bool
 apple_glx_surface_create(Display * dpy, int screen,
@@ -207,6 +206,7 @@ apple_glx_surface_destroy(unsigned int uid)
    if (d) {
       d->types.surface.pending_destroy = true;
       d->release(d);
+
       /* 
        * We release 2 references to the surface.  One was acquired by
        * the find, and the other was leftover from a context, or 
@@ -217,8 +217,9 @@ apple_glx_surface_destroy(unsigned int uid)
        * to actually destroy it when the pending_destroy is processed
        * by a glViewport callback (see apple_glx_context_update()).
        */
-      d->destroy(d);
-
-      d->unlock(d);
+      if (!d->destroy(d)) {
+          /* apple_glx_drawable_find_by_uid returns a locked drawable */
+          d->unlock(d);
+      }
    }
 }