Mesa (master): mesa: use inline function wrapper for _mesa_reference_texobj ()

Brian Paul brianp at kemper.freedesktop.org
Thu Jul 14 14:16:33 UTC 2011


Module: Mesa
Branch: master
Commit: db0f2b363750d57652140c68c9436f1d2d540a87
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=db0f2b363750d57652140c68c9436f1d2d540a87

Author: Brian Paul <brianp at vmware.com>
Date:   Thu Jul 14 08:09:21 2011 -0600

mesa: use inline function wrapper for _mesa_reference_texobj()

---

 src/mesa/main/texobj.c |   10 ++++------
 src/mesa/main/texobj.h |   12 +++++++++++-
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index 0e84b87..3021716 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -325,16 +325,14 @@ valid_texture_object(const struct gl_texture_object *tex)
  * Reference (or unreference) a texture object.
  * If '*ptr', decrement *ptr's refcount (and delete if it becomes zero).
  * If 'tex' is non-null, increment its refcount.
+ * This is normally only called from the _mesa_reference_texobj() macro
+ * when there's a real pointer change.
  */
 void
-_mesa_reference_texobj(struct gl_texture_object **ptr,
-                       struct gl_texture_object *tex)
+_mesa_reference_texobj_(struct gl_texture_object **ptr,
+                        struct gl_texture_object *tex)
 {
    assert(ptr);
-   if (*ptr == tex) {
-      /* no change */
-      return;
-   }
 
    if (*ptr) {
       /* Unreference the old texture */
diff --git a/src/mesa/main/texobj.h b/src/mesa/main/texobj.h
index 476a175..1faae6f 100644
--- a/src/mesa/main/texobj.h
+++ b/src/mesa/main/texobj.h
@@ -32,6 +32,7 @@
 #define TEXTOBJ_H
 
 
+#include "compiler.h"
 #include "glheader.h"
 
 struct gl_context;
@@ -64,8 +65,17 @@ _mesa_clear_texture_object(struct gl_context *ctx,
                            struct gl_texture_object *obj);
 
 extern void
+_mesa_reference_texobj_(struct gl_texture_object **ptr,
+                        struct gl_texture_object *tex);
+
+static INLINE void
 _mesa_reference_texobj(struct gl_texture_object **ptr,
-                       struct gl_texture_object *tex);
+                       struct gl_texture_object *tex)
+{
+   if (*ptr != tex)
+      _mesa_reference_texobj_(ptr, tex);
+}
+
 
 extern void
 _mesa_test_texobj_completeness( const struct gl_context *ctx,




More information about the mesa-commit mailing list