only call xmesa_set_renderbuffer_funcs() when really necessary
authorBrian Paul <brian.paul@tungstengraphics.com>
Mon, 9 Jan 2006 17:56:55 +0000 (17:56 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Mon, 9 Jan 2006 17:56:55 +0000 (17:56 +0000)
src/mesa/drivers/x11/xm_dd.c
src/mesa/drivers/x11/xmesaP.h

index 931cdd28ab5192101a052677ca12e971b87a8426..e6f90d35bb214aa92539486d0f9df4d004fca23d 100644 (file)
@@ -968,14 +968,13 @@ clear_color_HPCR_pixmap( GLcontext *ctx, const GLfloat color[4] )
 
 
 /**
- * Called when the driver should update it's state, based on the new_state
+ * Called when the driver should update its state, based on the new_state
  * flags.
  */
 void
-xmesa_update_state( GLcontext *ctx, GLuint new_state )
+xmesa_update_state( GLcontext *ctx, GLbitfield new_state )
 {
    const XMesaContext xmesa = XMESA_CONTEXT(ctx);
-   struct xmesa_renderbuffer *front_xrb, *back_xrb;
 
    /* Propagate statechange information to swrast and swrast_setup
     * modules.  The X11 driver has no internal GL-dependent state.
@@ -988,48 +987,55 @@ xmesa_update_state( GLcontext *ctx, GLuint new_state )
    if (ctx->DrawBuffer->Name != 0)
       return;
 
-   front_xrb = XMESA_BUFFER(ctx->DrawBuffer)->frontxrb;
-   if (front_xrb) {
-      /* XXX check for relevant new_state flags */
-      xmesa_set_renderbuffer_funcs(front_xrb, xmesa->pixelformat,
-                                   xmesa->xm_visual->BitsPerPixel);
-      /* setup pointers to front and back buffer clear functions */
-      front_xrb->clearFunc = clear_pixmap;
-   }
+   /*
+    * GL_DITHER and GL_READ/DRAW_BUFFER state effect renderbuffer funcs
+    */
+   if (new_state & (_NEW_COLOR | _NEW_PIXEL)) {
+      struct xmesa_renderbuffer *front_xrb, *back_xrb;
+
+      front_xrb = XMESA_BUFFER(ctx->DrawBuffer)->frontxrb;
+      if (front_xrb) {
+         /* XXX check for relevant new_state flags */
+         xmesa_set_renderbuffer_funcs(front_xrb, xmesa->pixelformat,
+                                      xmesa->xm_visual->BitsPerPixel);
+         /* setup pointers to front and back buffer clear functions */
+         front_xrb->clearFunc = clear_pixmap;
+      }
 
-   back_xrb = XMESA_BUFFER(ctx->DrawBuffer)->backxrb;
-   if (back_xrb) {
-      XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+      back_xrb = XMESA_BUFFER(ctx->DrawBuffer)->backxrb;
+      if (back_xrb) {
+         XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
 
-      /* XXX check for relevant new_state flags */
-      xmesa_set_renderbuffer_funcs(back_xrb, xmesa->pixelformat,
-                                   xmesa->xm_visual->BitsPerPixel);
+         /* XXX check for relevant new_state flags */
+         xmesa_set_renderbuffer_funcs(back_xrb, xmesa->pixelformat,
+                                      xmesa->xm_visual->BitsPerPixel);
 
-      if (xmbuf->backxrb->pixmap) {
-         back_xrb->clearFunc = clear_pixmap;
-      }
-      else {
-         switch (xmesa->xm_visual->BitsPerPixel) {
-         case 8:
-            if (xmesa->xm_visual->hpcr_clear_flag) {
-               back_xrb->clearFunc = clear_HPCR_ximage;
-            }
-            else {
-               back_xrb->clearFunc = clear_8bit_ximage;
+         if (xmbuf->backxrb->pixmap) {
+            back_xrb->clearFunc = clear_pixmap;
+         }
+         else {
+            switch (xmesa->xm_visual->BitsPerPixel) {
+            case 8:
+               if (xmesa->xm_visual->hpcr_clear_flag) {
+                  back_xrb->clearFunc = clear_HPCR_ximage;
+               }
+               else {
+                  back_xrb->clearFunc = clear_8bit_ximage;
+               }
+               break;
+            case 16:
+               back_xrb->clearFunc = clear_16bit_ximage;
+               break;
+            case 24:
+               back_xrb->clearFunc = clear_24bit_ximage;
+               break;
+            case 32:
+               back_xrb->clearFunc = clear_32bit_ximage;
+               break;
+            default:
+               back_xrb->clearFunc = clear_nbit_ximage;
+               break;
             }
-            break;
-         case 16:
-            back_xrb->clearFunc = clear_16bit_ximage;
-            break;
-         case 24:
-            back_xrb->clearFunc = clear_24bit_ximage;
-            break;
-         case 32:
-            back_xrb->clearFunc = clear_32bit_ximage;
-            break;
-         default:
-            back_xrb->clearFunc = clear_nbit_ximage;
-            break;
          }
       }
    }
index 5b9311ff87378c9bc42429d14a53413609a70e3c..afba40ae034005c3cb77cef56bac7a244306d7aa 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.3
+ * Version:  6.5
  *
- * Copyright (C) 1999-2005  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2006  Brian Paul   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"),
@@ -513,7 +513,7 @@ extern void xmesa_resize_buffers(GLcontext *ctx, GLframebuffer *buffer,
 extern void xmesa_init_driver_functions( XMesaVisual xmvisual,
                                          struct dd_function_table *driver );
 
-extern void xmesa_update_state( GLcontext *ctx, GLuint new_state );
+extern void xmesa_update_state( GLcontext *ctx, GLbitfield new_state );
 
 extern void
 xmesa_set_renderbuffer_funcs(struct xmesa_renderbuffer *xrb,