summaryrefslogtreecommitdiff
path: root/src/mesa/pipe/p_inlines.h
diff options
context:
space:
mode:
authorMichel Dänzer <michel@tungstengraphics.com>2007-12-07 12:30:35 +0100
committerBen Skeggs <skeggsb@gmail.com>2007-12-09 12:05:26 +1100
commit0a44a3fa2f9eb295106cd4c64549f55cc54f432f (patch)
treee4b6a6075dfe37f8ab70505b1cbed33bbb74bece /src/mesa/pipe/p_inlines.h
parent7f984e1d2ab65a3d34ec0c0ef7487211dd644561 (diff)
Eliminate struct pipe_region.
Directly use struct pipe_buffer_handle for storage and struct pipe_surface for (un)mapping.
Diffstat (limited to 'src/mesa/pipe/p_inlines.h')
-rw-r--r--src/mesa/pipe/p_inlines.h53
1 files changed, 28 insertions, 25 deletions
diff --git a/src/mesa/pipe/p_inlines.h b/src/mesa/pipe/p_inlines.h
index c04d46dddd..1697284b04 100644
--- a/src/mesa/pipe/p_inlines.h
+++ b/src/mesa/pipe/p_inlines.h
@@ -29,40 +29,42 @@
#define P_INLINES_H
#include "p_context.h"
+#include "p_defines.h"
#include "p_winsys.h"
-/**
- * Set 'ptr' to point to 'region' and update reference counting.
- * The old thing pointed to, if any, will be unreferenced first.
- * 'region' may be NULL.
- */
+static INLINE ubyte *
+pipe_surface_map(struct pipe_surface *surface)
+{
+ if (!surface->map_refcount++) {
+ surface->map = surface->winsys->buffer_map( surface->winsys,
+ surface->buffer,
+ PIPE_BUFFER_FLAG_WRITE |
+ PIPE_BUFFER_FLAG_READ )
+ + surface->offset;
+ }
+
+ return surface->map;
+}
+
static INLINE void
-pipe_region_reference(struct pipe_region **ptr, struct pipe_region *region)
+pipe_surface_unmap(struct pipe_surface *surface)
{
- assert(ptr);
- if (*ptr) {
- /* unreference the old thing */
- struct pipe_region *oldReg = *ptr;
- assert(oldReg->refcount > 0);
- oldReg->refcount--;
- if (oldReg->refcount == 0) {
- /* free the old region */
- assert(oldReg->map_refcount == 0);
- /* XXX dereference the region->buffer */
- FREE( oldReg );
+ if (surface->map_refcount > 0) {
+ assert(surface->map);
+ if (!--surface->map_refcount) {
+ surface->winsys->buffer_unmap( surface->winsys,
+ surface->buffer );
+ surface->map = NULL;
}
- *ptr = NULL;
- }
- if (region) {
- /* reference the new thing */
- region->refcount++;
- *ptr = region;
}
}
+
/**
- * \sa pipe_region_reference
+ * Set 'ptr' to point to 'surf' and update reference counting.
+ * The old thing pointed to, if any, will be unreferenced first.
+ * 'surf' may be NULL.
*/
static INLINE void
pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf)
@@ -82,7 +84,7 @@ pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf)
/**
- * \sa pipe_region_reference
+ * \sa pipe_surface_reference
*/
static INLINE void
pipe_texture_reference(struct pipe_context *pipe, struct pipe_texture **ptr,
@@ -100,4 +102,5 @@ pipe_texture_reference(struct pipe_context *pipe, struct pipe_texture **ptr,
}
}
+
#endif /* P_INLINES_H */