tr_texture.c

Go to the documentation of this file.
00001 /**************************************************************************
00002  *
00003  * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
00004  * All Rights Reserved.
00005  *
00006  * Permission is hereby granted, free of charge, to any person obtaining a
00007  * copy of this software and associated documentation files (the
00008  * "Software"), to deal in the Software without restriction, including
00009  * without limitation the rights to use, copy, modify, merge, publish,
00010  * distribute, sub license, and/or sell copies of the Software, and to
00011  * permit persons to whom the Software is furnished to do so, subject to
00012  * the following conditions:
00013  *
00014  * The above copyright notice and this permission notice (including the
00015  * next paragraph) shall be included in all copies or substantial portions
00016  * of the Software.
00017  *
00018  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00019  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00020  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
00021  * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
00022  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
00023  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
00024  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00025  *
00026  **************************************************************************/
00027 
00028 #include "pipe/p_inlines.h"
00029 #include "util/u_hash_table.h"
00030 #include "util/u_memory.h"
00031 
00032 #include "tr_screen.h"
00033 #include "tr_texture.h"
00034 
00035 
00036 struct pipe_texture *
00037 trace_texture_create(struct trace_screen *tr_scr, 
00038                      struct pipe_texture *texture)
00039 {
00040    struct trace_texture *tr_tex;
00041    
00042    if(!texture)
00043       goto error;
00044    
00045    assert(texture->screen == tr_scr->screen);
00046    
00047    tr_tex = CALLOC_STRUCT(trace_texture);
00048    if(!tr_tex)
00049       goto error;
00050    
00051    memcpy(&tr_tex->base, texture, sizeof(struct pipe_texture));
00052    tr_tex->base.screen = &tr_scr->base;
00053    tr_tex->texture = texture;
00054    
00055    return &tr_tex->base;
00056    
00057 error:
00058    pipe_texture_reference(&texture, NULL);
00059    return NULL;
00060 }
00061 
00062 
00063 void
00064 trace_texture_destroy(struct trace_screen *tr_scr, 
00065                       struct pipe_texture *texture)
00066 {
00067    struct trace_texture *tr_tex = trace_texture(tr_scr, texture); 
00068    pipe_texture_reference(&tr_tex->texture, NULL);
00069    FREE(tr_tex);
00070 }
00071 
00072 
00073 struct pipe_surface *
00074 trace_surface_create(struct trace_texture *tr_tex, 
00075                      struct pipe_surface *surface)
00076 {
00077    struct trace_surface *tr_surf;
00078    
00079    if(!surface)
00080       goto error;
00081    
00082    assert(surface->texture == tr_tex->texture);
00083    
00084    tr_surf = CALLOC_STRUCT(trace_surface);
00085    if(!tr_surf)
00086       goto error;
00087    
00088    memcpy(&tr_surf->base, surface, sizeof(struct pipe_surface));
00089    
00090    tr_surf->base.winsys = tr_tex->base.screen->winsys;
00091    tr_surf->base.texture = NULL;
00092    pipe_texture_reference(&tr_surf->base.texture, &tr_tex->base);
00093    tr_surf->surface = surface;
00094 
00095    return &tr_surf->base;
00096    
00097 error:
00098    pipe_surface_reference(&surface, NULL);
00099    return NULL;
00100 }
00101 
00102 
00103 void
00104 trace_surface_destroy(struct trace_texture *tr_tex, 
00105                       struct pipe_surface *surface)
00106 {
00107    struct trace_surface *tr_surf = trace_surface(tr_tex, surface);
00108    pipe_texture_reference(&tr_surf->base.texture, NULL);
00109    pipe_surface_reference(&tr_surf->surface, NULL);
00110    FREE(tr_surf);
00111 }
00112 

Generated on Tue Sep 29 06:25:17 2009 for Gallium3D by  doxygen 1.5.4