summaryrefslogtreecommitdiff
path: root/src/mesa/pipe/p_inlines.h
diff options
context:
space:
mode:
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 */