00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
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