u_inlines: split pipe_surface_init in pipe_surface_reset and *_init
authorLuca Barbieri <luca@luca-barbieri.com>
Sun, 18 Apr 2010 20:37:32 +0000 (22:37 +0200)
committerLuca Barbieri <luca@luca-barbieri.com>
Sun, 18 Apr 2010 20:58:09 +0000 (22:58 +0200)
src/gallium/auxiliary/util/u_inlines.h
src/gallium/auxiliary/util/u_surfaces.c

index b2a0408a60ed33474aaa3e977c022036bc5f8cb8..089adcf3827122e86c2450b1ee6ce7062af5fae5 100644 (file)
@@ -122,9 +122,8 @@ pipe_sampler_view_reference(struct pipe_sampler_view **ptr, struct pipe_sampler_
    *ptr = view;
 }
 
-/* you have to call pipe_reference_init(&ps->reference, 1) yourself if it is just allocated */
 static INLINE void
-pipe_surface_init(struct pipe_surface* ps, struct pipe_resource *pt,
+pipe_surface_reset(struct pipe_surface* ps, struct pipe_resource *pt,
                unsigned face, unsigned level, unsigned zslice, unsigned flags)
 {
    pipe_resource_reference(&ps->texture, pt);
@@ -137,6 +136,15 @@ pipe_surface_init(struct pipe_surface* ps, struct pipe_resource *pt,
    ps->zslice = zslice;
 }
 
+static INLINE void
+pipe_surface_init(struct pipe_surface* ps, struct pipe_resource *pt,
+                unsigned face, unsigned level, unsigned zslice, unsigned flags)
+{
+   ps->texture = 0;
+   pipe_reference_init(&ps->reference, 1);
+   pipe_surface_reset(ps, pt, face, level, zslice, flags);
+}
+
 /*
  * Convenience wrappers for screen buffer functions.
  */
index 056b8f2341822b3fc977f87627b8ace8c145fed6..ddfc7a9d28c0e5f6800a8e27cb180591813b046d 100644 (file)
@@ -50,7 +50,6 @@ util_surfaces_do_get(struct util_surfaces *us, unsigned surface_struct_size, str
    if(!ps)
       return NULL;
 
-   pipe_reference_init(&ps->reference, 1);
    pipe_surface_init(ps, pt, face, level, zslice, flags);
    ps->offset = ~0;