trace: Simplify cast wrappers.
authorJosé Fonseca <jfonseca@vmware.com>
Wed, 8 Apr 2009 14:29:50 +0000 (15:29 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Wed, 8 Apr 2009 15:26:05 +0000 (16:26 +0100)
src/gallium/drivers/trace/tr_context.c
src/gallium/drivers/trace/tr_dump.c
src/gallium/drivers/trace/tr_screen.c
src/gallium/drivers/trace/tr_texture.c
src/gallium/drivers/trace/tr_texture.h

index d50d872a77709a812763b065a9419bc76e9763af..d8d5821a1d16478d3dc3a33ea1ef33fa9154ef86 100644 (file)
@@ -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);
index 97872be784de95ab15ce5fd8c72cc21abcd65c79..314e4fa350bae15453b9ca53564518460bd21bd9 100644 (file)
@@ -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();
index c83ec4e30e61ee1193b49f59cef1e34009c953b6..679250538332e9083fbd2538eb70ad31fd04f697 100644 (file)
@@ -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;
 
index 7b392f0728692b445ba870205a96c40904c7e473..f4e433792b1bdfa7e7e3b0f61597e5baff90270b 100644 (file)
@@ -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);
index 9c21bc7d27651098a5813465c81044f44611000c..14dafd8b2c3e6e1b03e69c27423873dd29a5a476 100644 (file)
@@ -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_ */