Merge branch 'mesa_7_6_branch'
[mesa.git] / src / mesa / drivers / osmesa / osmesa.c
index 42a1bb51233a6824d32b54a155a090220b5d6cf6..692657a5dfd626796240b73098899e159766104c 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.1
+ * Version:  6.5.3
  *
- * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2007  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"),
  */
 
 
-#include "glheader.h"
+#include "main/glheader.h"
 #include "GL/osmesa.h"
-#include "context.h"
-#include "extensions.h"
-#include "framebuffer.h"
-#include "imports.h"
-#include "mtypes.h"
-#include "renderbuffer.h"
+#include "main/context.h"
+#include "main/extensions.h"
+#include "main/framebuffer.h"
+#include "main/imports.h"
+#include "main/mtypes.h"
+#include "main/renderbuffer.h"
 #include "swrast/swrast.h"
 #include "swrast_setup/swrast_setup.h"
 #include "swrast/s_context.h"
@@ -50,7 +50,8 @@
 #include "tnl/t_context.h"
 #include "tnl/t_pipeline.h"
 #include "drivers/common/driverfuncs.h"
-#include "vbo/vbo_context.h"
+#include "drivers/common/meta.h"
+#include "vbo/vbo.h"
 
 
 
@@ -111,6 +112,7 @@ osmesa_update_state( GLcontext *ctx, GLuint new_state )
    _swrast_InvalidateState( ctx, new_state );
    _swsetup_InvalidateState( ctx, new_state );
    _tnl_InvalidateState( ctx, new_state );
+   _vbo_InvalidateState( ctx, new_state );
 }
 
 
@@ -1040,6 +1042,7 @@ new_osmesa_renderbuffer(GLcontext *ctx, GLenum format, GLenum type)
    const GLuint name = 0;
    struct gl_renderbuffer *rb = _mesa_new_renderbuffer(ctx, name);
    if (rb) {
+      rb->RefCount = 1;
       rb->Delete = osmesa_delete_renderbuffer;
       rb->AllocStorage = osmesa_renderbuffer_storage;
 
@@ -1224,6 +1227,8 @@ OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits,
       _mesa_enable_1_3_extensions(&(osmesa->mesa));
       _mesa_enable_1_4_extensions(&(osmesa->mesa));
       _mesa_enable_1_5_extensions(&(osmesa->mesa));
+      _mesa_enable_2_0_extensions(&(osmesa->mesa));
+      _mesa_enable_2_1_extensions(&(osmesa->mesa));
 
       osmesa->gl_buffer = _mesa_create_framebuffer(osmesa->gl_visual);
       if (!osmesa->gl_buffer) {
@@ -1236,6 +1241,7 @@ OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits,
       /* create front color buffer in user-provided memory (no back buffer) */
       osmesa->rb = new_osmesa_renderbuffer(&osmesa->mesa, format, type);
       _mesa_add_renderbuffer(osmesa->gl_buffer, BUFFER_FRONT_LEFT, osmesa->rb);
+      assert(osmesa->rb->RefCount == 2);
                         
       _mesa_add_soft_renderbuffers(osmesa->gl_buffer,
                                    GL_FALSE, /* color */
@@ -1253,6 +1259,8 @@ OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits,
       osmesa->bInd = bind;
       osmesa->aInd = aind;
 
+      _mesa_meta_init(&osmesa->mesa);
+
       /* Initialize the software rasterizer and helper modules. */
       {
         GLcontext *ctx = &osmesa->mesa;
@@ -1296,13 +1304,19 @@ GLAPI void GLAPIENTRY
 OSMesaDestroyContext( OSMesaContext osmesa )
 {
    if (osmesa) {
+      if (osmesa->rb)
+         _mesa_reference_renderbuffer(&osmesa->rb, NULL);
+
+      _mesa_meta_free( &osmesa->mesa );
+
       _swsetup_DestroyContext( &osmesa->mesa );
       _tnl_DestroyContext( &osmesa->mesa );
       _vbo_DestroyContext( &osmesa->mesa );
       _swrast_DestroyContext( &osmesa->mesa );
 
       _mesa_destroy_visual( osmesa->gl_visual );
-      _mesa_destroy_framebuffer( osmesa->gl_buffer );
+      _mesa_reference_framebuffer( &osmesa->gl_buffer, NULL );
+
       _mesa_free_context_data( &osmesa->mesa );
       _mesa_free( osmesa );
    }
@@ -1568,6 +1582,7 @@ static struct name_function functions[] = {
    { "OSMesaGetDepthBuffer", (OSMESAproc) OSMesaGetDepthBuffer },
    { "OSMesaGetColorBuffer", (OSMESAproc) OSMesaGetColorBuffer },
    { "OSMesaGetProcAddress", (OSMESAproc) OSMesaGetProcAddress },
+   { "OSMesaColorClamp", (OSMESAproc) OSMesaColorClamp },
    { NULL, NULL }
 };