1 /**************************************************************************
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
31 #include "p_context.h"
32 #include "p_defines.h"
41 /* XXX: these are a kludge. will fix when all surfaces are views into
42 * textures, and free-floating winsys surfaces go away.
45 pipe_surface_map( struct pipe_surface
*surf
, unsigned flags
)
47 struct pipe_screen
*screen
;
48 assert(surf
->texture
);
49 screen
= surf
->texture
->screen
;
50 return screen
->surface_map( screen
, surf
, flags
);
54 pipe_surface_unmap( struct pipe_surface
*surf
)
56 struct pipe_screen
*screen
;
57 assert(surf
->texture
);
58 screen
= surf
->texture
->screen
;
59 screen
->surface_unmap( screen
, surf
);
65 * Set 'ptr' to point to 'surf' and update reference counting.
66 * The old thing pointed to, if any, will be unreferenced first.
70 pipe_surface_reference(struct pipe_surface
**ptr
, struct pipe_surface
*surf
)
72 /* bump the refcount first */
74 assert(surf
->refcount
);
79 struct pipe_screen
*screen
;
80 assert((*ptr
)->refcount
);
81 assert((*ptr
)->texture
);
82 screen
= (*ptr
)->texture
->screen
;
83 screen
->tex_surface_release( screen
, ptr
);
92 * \sa pipe_surface_reference
95 pipe_texture_reference(struct pipe_texture
**ptr
,
96 struct pipe_texture
*pt
)
101 assert(pt
->refcount
);
106 struct pipe_screen
*screen
= (*ptr
)->screen
;
108 assert((*ptr
)->refcount
);
109 screen
->texture_release(screen
, ptr
);
119 pipe_texture_release(struct pipe_texture
**ptr
)
121 struct pipe_screen
*screen
;
123 screen
= (*ptr
)->screen
;
124 assert((*ptr
)->refcount
);
125 screen
->texture_release(screen
, ptr
);
131 * Convenience wrappers for screen buffer functions.
134 static INLINE
struct pipe_buffer
*
135 pipe_buffer_create( struct pipe_screen
*screen
,
136 unsigned alignment
, unsigned usage
, unsigned size
)
138 return screen
->buffer_create(screen
, alignment
, usage
, size
);
141 static INLINE
struct pipe_buffer
*
142 pipe_user_buffer_create( struct pipe_screen
*screen
, void *ptr
, unsigned size
)
144 return screen
->user_buffer_create(screen
, ptr
, size
);
148 pipe_buffer_map(struct pipe_screen
*screen
,
149 struct pipe_buffer
*buf
,
152 return screen
->buffer_map(screen
, buf
, usage
);
156 pipe_buffer_unmap(struct pipe_screen
*screen
,
157 struct pipe_buffer
*buf
)
159 screen
->buffer_unmap(screen
, buf
);
162 /* XXX: thread safety issues!
165 pipe_buffer_reference(struct pipe_screen
*screen
,
166 struct pipe_buffer
**ptr
,
167 struct pipe_buffer
*buf
)
170 assert(buf
->refcount
);
175 assert((*ptr
)->refcount
);
176 if(--(*ptr
)->refcount
== 0) {
177 screen
->buffer_destroy( screen
, *ptr
);
189 #endif /* P_INLINES_H */