Mesa (master): trace: Simplify cast wrappers.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Wed Apr 8 08:26:12 PDT 2009


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

Author: José Fonseca <jfonseca at vmware.com>
Date:   Wed Apr  8 15:29:50 2009 +0100

trace: Simplify cast wrappers.

---

 src/gallium/drivers/trace/tr_context.c |    8 ++------
 src/gallium/drivers/trace/tr_dump.c    |   11 +++--------
 src/gallium/drivers/trace/tr_screen.c  |   29 ++++++++++++-----------------
 src/gallium/drivers/trace/tr_texture.c |   12 +++---------
 src/gallium/drivers/trace/tr_texture.h |   27 +++++++++------------------
 5 files changed, 29 insertions(+), 58 deletions(-)

diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c
index d50d872..d8d5821 100644
--- a/src/gallium/drivers/trace/tr_context.c
+++ b/src/gallium/drivers/trace/tr_context.c
@@ -58,16 +58,14 @@ static INLINE struct pipe_texture *
 trace_texture_unwrap(struct trace_context *tr_ctx,
                      struct pipe_texture *texture)
 {
-   struct trace_screen *tr_scr = trace_screen(tr_ctx->base.screen);
    struct trace_texture *tr_tex;
 
    if(!texture)
       return NULL;
 
-   tr_tex = trace_texture(tr_scr, texture);
+   tr_tex = trace_texture(texture);
 
    assert(tr_tex->texture);
-   assert(tr_tex->texture->screen == tr_scr->screen);
    return tr_tex->texture;
 }
 
@@ -77,7 +75,6 @@ trace_surface_unwrap(struct trace_context *tr_ctx,
                      struct pipe_surface *surface)
 {
    struct trace_screen *tr_scr = trace_screen(tr_ctx->base.screen);
-   struct trace_texture *tr_tex;
    struct trace_surface *tr_surf;
 
    if(!surface)
@@ -87,8 +84,7 @@ trace_surface_unwrap(struct trace_context *tr_ctx,
    if(!surface->texture)
       return surface;
 
-   tr_tex = trace_texture(tr_scr, surface->texture);
-   tr_surf = trace_surface(tr_tex, surface);
+   tr_surf = trace_surface(surface);
 
    assert(tr_surf->surface);
    assert(tr_surf->surface->texture->screen == tr_scr->screen);
diff --git a/src/gallium/drivers/trace/tr_dump.c b/src/gallium/drivers/trace/tr_dump.c
index 97872be..314e4fa 100644
--- a/src/gallium/drivers/trace/tr_dump.c
+++ b/src/gallium/drivers/trace/tr_dump.c
@@ -428,8 +428,7 @@ void trace_dump_buffer_ptr(struct pipe_buffer *_buffer)
 void trace_dump_texture_ptr(struct pipe_texture *_texture)
 {
    if (_texture) {
-      struct trace_screen *tr_scr = trace_screen(_texture->screen);
-      struct trace_texture *tr_tex = trace_texture(tr_scr, _texture);
+      struct trace_texture *tr_tex = trace_texture(_texture);
       trace_dump_ptr(tr_tex->texture);
    } else {
       trace_dump_null();
@@ -439,9 +438,7 @@ void trace_dump_texture_ptr(struct pipe_texture *_texture)
 void trace_dump_surface_ptr(struct pipe_surface *_surface)
 {
    if (_surface) {
-      struct trace_screen *tr_scr = trace_screen(_surface->texture->screen);
-      struct trace_texture *tr_tex = trace_texture(tr_scr, _surface->texture);
-      struct trace_surface *tr_surf = trace_surface(tr_tex, _surface);
+      struct trace_surface *tr_surf = trace_surface(_surface);
       trace_dump_ptr(tr_surf->surface);
    } else {
       trace_dump_null();
@@ -451,9 +448,7 @@ void trace_dump_surface_ptr(struct pipe_surface *_surface)
 void trace_dump_transfer_ptr(struct pipe_transfer *_transfer)
 {
    if (_transfer) {
-      struct trace_screen *tr_scr = trace_screen(_transfer->texture->screen);
-      struct trace_texture *tr_tex = trace_texture(tr_scr, _transfer->texture);
-      struct trace_transfer *tr_tran = trace_transfer(tr_tex, _transfer);
+      struct trace_transfer *tr_tran = trace_transfer(_transfer);
       trace_dump_ptr(tr_tran->transfer);
    } else {
       trace_dump_null();
diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c
index c83ec4e..6792505 100644
--- a/src/gallium/drivers/trace/tr_screen.c
+++ b/src/gallium/drivers/trace/tr_screen.c
@@ -159,8 +159,7 @@ trace_screen_flush_frontbuffer(struct pipe_screen *_screen,
                                void *context_private)
 {
    struct trace_screen *tr_scr = trace_screen(_screen);
-   struct trace_texture *tr_tex = trace_texture(tr_scr, _surface->texture);
-   struct trace_surface *tr_surf = trace_surface(tr_tex, _surface);
+   struct trace_surface *tr_surf = trace_surface(_surface);
    struct pipe_screen *screen = tr_scr->screen;
    struct pipe_surface *surface = tr_surf->surface;
 
@@ -242,7 +241,7 @@ static void
 trace_screen_texture_destroy(struct pipe_texture *_texture)
 {
    struct trace_screen *tr_scr = trace_screen(_texture->screen);
-   struct trace_texture *tr_tex = trace_texture(tr_scr, _texture);
+   struct trace_texture *tr_tex = trace_texture(_texture);
    struct pipe_screen *screen = tr_scr->screen;
    struct pipe_texture *texture = tr_tex->texture;
 
@@ -255,7 +254,7 @@ trace_screen_texture_destroy(struct pipe_texture *_texture)
 
    trace_dump_call_end();
 
-   trace_texture_destroy(tr_scr, _texture);
+   trace_texture_destroy(tr_tex);
 }
 
 
@@ -272,7 +271,7 @@ trace_screen_get_tex_surface(struct pipe_screen *_screen,
                              unsigned usage)
 {
    struct trace_screen *tr_scr = trace_screen(_screen);
-   struct trace_texture *tr_tex = trace_texture(tr_scr, _texture);
+   struct trace_texture *tr_tex = trace_texture(_texture);
    struct pipe_screen *screen = tr_scr->screen;
    struct pipe_texture *texture = tr_tex->texture;
    struct pipe_surface *result = NULL;
@@ -304,8 +303,7 @@ static void
 trace_screen_tex_surface_destroy(struct pipe_surface *_surface)
 {
    struct trace_screen *tr_scr = trace_screen(_surface->texture->screen);
-   struct trace_texture *tr_tex = trace_texture(tr_scr, _surface->texture);
-   struct trace_surface *tr_surf = trace_surface(tr_tex, _surface);
+   struct trace_surface *tr_surf = trace_surface(_surface);
    struct pipe_screen *screen = tr_scr->screen;
    struct pipe_surface *surface = tr_surf->surface;
 
@@ -316,7 +314,7 @@ trace_screen_tex_surface_destroy(struct pipe_surface *_surface)
 
    trace_dump_call_end();
 
-   trace_surface_destroy(tr_tex, _surface);
+   trace_surface_destroy(tr_surf);
 }
 
 
@@ -334,7 +332,7 @@ trace_screen_get_tex_transfer(struct pipe_screen *_screen,
                               unsigned x, unsigned y, unsigned w, unsigned h)
 {
    struct trace_screen *tr_scr = trace_screen(_screen);
-   struct trace_texture *tr_tex = trace_texture(tr_scr, _texture);
+   struct trace_texture *tr_tex = trace_texture(_texture);
    struct pipe_screen *screen = tr_scr->screen;
    struct pipe_texture *texture = tr_tex->texture;
    struct pipe_transfer *result = NULL;
@@ -372,10 +370,9 @@ static void
 trace_screen_tex_transfer_destroy(struct pipe_transfer *_transfer)
 {
    struct trace_screen *tr_scr = trace_screen(_transfer->texture->screen);
-   struct trace_texture *tr_tex = trace_texture(tr_scr, _transfer->texture);
-   struct trace_transfer *tr_tran = trace_transfer(tr_tex, _transfer);
+   struct trace_transfer *tr_trans = trace_transfer(_transfer);
    struct pipe_screen *screen = tr_scr->screen;
-   struct pipe_transfer *transfer = tr_tran->transfer;
+   struct pipe_transfer *transfer = tr_trans->transfer;
 
    trace_dump_call_begin("pipe_screen", "tex_transfer_destroy");
 
@@ -384,7 +381,7 @@ trace_screen_tex_transfer_destroy(struct pipe_transfer *_transfer)
 
    trace_dump_call_end();
 
-   trace_transfer_destroy(tr_tex, _transfer);
+   trace_transfer_destroy(tr_trans);
 }
 
 
@@ -393,8 +390,7 @@ trace_screen_transfer_map(struct pipe_screen *_screen,
                           struct pipe_transfer *_transfer)
 {
    struct trace_screen *tr_scr = trace_screen(_screen);
-   struct trace_texture *tr_tex = trace_texture(tr_scr, _transfer->texture);
-   struct trace_transfer *tr_trans = trace_transfer(tr_tex, _transfer);
+   struct trace_transfer *tr_trans = trace_transfer(_transfer);
    struct pipe_screen *screen = tr_scr->screen;
    struct pipe_transfer *transfer = tr_trans->transfer;
    void *map;
@@ -416,8 +412,7 @@ trace_screen_transfer_unmap(struct pipe_screen *_screen,
                            struct pipe_transfer *_transfer)
 {
    struct trace_screen *tr_scr = trace_screen(_screen);
-   struct trace_texture *tr_tex = trace_texture(tr_scr, _transfer->texture);
-   struct trace_transfer *tr_trans = trace_transfer(tr_tex, _transfer);
+   struct trace_transfer *tr_trans = trace_transfer(_transfer);
    struct pipe_screen *screen = tr_scr->screen;
    struct pipe_transfer *transfer = tr_trans->transfer;
 
diff --git a/src/gallium/drivers/trace/tr_texture.c b/src/gallium/drivers/trace/tr_texture.c
index 7b392f0..f4e4337 100644
--- a/src/gallium/drivers/trace/tr_texture.c
+++ b/src/gallium/drivers/trace/tr_texture.c
@@ -62,10 +62,8 @@ error:
 
 
 void
-trace_texture_destroy(struct trace_screen *tr_scr,
-                      struct pipe_texture *texture)
+trace_texture_destroy(struct trace_texture *tr_tex)
 {
-   struct trace_texture *tr_tex = trace_texture(tr_scr, texture);
    pipe_texture_reference(&tr_tex->texture, NULL);
    FREE(tr_tex);
 }
@@ -102,10 +100,8 @@ error:
 
 
 void
-trace_surface_destroy(struct trace_texture *tr_tex,
-                      struct pipe_surface *surface)
+trace_surface_destroy(struct trace_surface *tr_surf)
 {
-   struct trace_surface *tr_surf = trace_surface(tr_tex, surface);
    pipe_texture_reference(&tr_surf->base.texture, NULL);
    pipe_surface_reference(&tr_surf->surface, NULL);
    FREE(tr_surf);
@@ -143,10 +139,8 @@ error:
 
 
 void
-trace_transfer_destroy(struct trace_texture *tr_tex,
-                      struct pipe_transfer *transfer)
+trace_transfer_destroy(struct trace_transfer *tr_trans)
 {
-   struct trace_transfer *tr_trans = trace_transfer(tr_tex, transfer);
    struct pipe_screen *screen = tr_trans->transfer->texture->screen;
    pipe_texture_reference(&tr_trans->base.texture, NULL);
    screen->tex_transfer_destroy(tr_trans->transfer);
diff --git a/src/gallium/drivers/trace/tr_texture.h b/src/gallium/drivers/trace/tr_texture.h
index 9c21bc7..14dafd8 100644
--- a/src/gallium/drivers/trace/tr_texture.h
+++ b/src/gallium/drivers/trace/tr_texture.h
@@ -62,37 +62,31 @@ struct trace_transfer
 
 
 static INLINE struct trace_texture *
-trace_texture(struct trace_screen *tr_scr,
-              struct pipe_texture *texture)
+trace_texture(struct pipe_texture *texture)
 {
    if(!texture)
       return NULL;
-   assert(tr_scr);
-   assert(texture->screen == &tr_scr->base);
+   (void)trace_screen(texture->screen);
    return (struct trace_texture *)texture;
 }
 
 
 static INLINE struct trace_surface *
-trace_surface(struct trace_texture *tr_tex,
-              struct pipe_surface *surface)
+trace_surface(struct pipe_surface *surface)
 {
    if(!surface)
       return NULL;
-   assert(tr_tex);
-   assert(surface->texture == &tr_tex->base);
+   (void)trace_texture(surface->texture);
    return (struct trace_surface *)surface;
 }
 
 
 static INLINE struct trace_transfer *
-trace_transfer(struct trace_texture *tr_tex,
-               struct pipe_transfer *transfer)
+trace_transfer(struct pipe_transfer *transfer)
 {
    if(!transfer)
       return NULL;
-   assert(tr_tex);
-   assert(transfer->texture == &tr_tex->base);
+   (void)trace_texture(transfer->texture);
    return (struct trace_transfer *)transfer;
 }
 
@@ -102,24 +96,21 @@ trace_texture_create(struct trace_screen *tr_scr,
                      struct pipe_texture *texture);
 
 void
-trace_texture_destroy(struct trace_screen *tr_scr,
-                      struct pipe_texture *texture);
+trace_texture_destroy(struct trace_texture *tr_tex);
 
 struct pipe_surface *
 trace_surface_create(struct trace_texture *tr_tex,
                      struct pipe_surface *surface);
 
 void
-trace_surface_destroy(struct trace_texture *tr_tex,
-                      struct pipe_surface *surface);
+trace_surface_destroy(struct trace_surface *tr_surf);
 
 struct pipe_transfer *
 trace_transfer_create(struct trace_texture *tr_tex,
                       struct pipe_transfer *transfer);
 
 void
-trace_transfer_destroy(struct trace_texture *tr_tex,
-                       struct pipe_transfer *transfer);
+trace_transfer_destroy(struct trace_transfer *tr_trans);
 
 
 #endif /* TR_TEXTURE_H_ */



More information about the mesa-commit mailing list