summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/histogram.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main/histogram.c')
-rw-r--r--src/mesa/main/histogram.c67
1 files changed, 22 insertions, 45 deletions
diff --git a/src/mesa/main/histogram.c b/src/mesa/main/histogram.c
index 726a50d3b1b..f1d01cdb621 100644
--- a/src/mesa/main/histogram.c
+++ b/src/mesa/main/histogram.c
@@ -649,27 +649,19 @@ _mesa_GetMinmax(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvo
return;
}
- if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) {
- /* pack min/max values into a PBO */
- GLubyte *buf;
- if (!_mesa_validate_pbo_access(1, &ctx->Pack, 2, 1, 1,
- format, type, values)) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetMinMax(invalid PBO access)");
- return;
- }
- buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
- GL_WRITE_ONLY_ARB,
- ctx->Pack.BufferObj);
- if (!buf) {
+ if (!_mesa_validate_pbo_access(1, &ctx->Pack, 2, 1, 1,
+ format, type, values)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetMinMax(invalid PBO access)");
+ return;
+ }
+
+ values = _mesa_map_pbo_dest(ctx, &ctx->Pack, values);
+ if (!values) {
+ if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) {
/* buffer is already mapped - that's an error */
_mesa_error(ctx, GL_INVALID_OPERATION,"glGetMinMax(PBO is mapped)");
- return;
}
- values = ADD_POINTERS(buf, values);
- }
- else if (!values) {
- /* not an error */
return;
}
@@ -687,10 +679,7 @@ _mesa_GetMinmax(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvo
format, type, values, &ctx->Pack, 0x0);
}
- if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) {
- ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
- ctx->Pack.BufferObj);
- }
+ _mesa_unmap_pbo_dest(ctx, &ctx->Pack);
if (reset) {
_mesa_ResetMinmax(GL_MINMAX);
@@ -733,27 +722,18 @@ _mesa_GetHistogram(GLenum target, GLboolean reset, GLenum format, GLenum type, G
return;
}
- if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) {
- /* pack min/max values into a PBO */
- GLubyte *buf;
- if (!_mesa_validate_pbo_access(1, &ctx->Pack, ctx->Histogram.Width, 1, 1,
- format, type, values)) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetHistogram(invalid PBO access)");
- return;
- }
- buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
- GL_WRITE_ONLY_ARB,
- ctx->Pack.BufferObj);
- if (!buf) {
- /* buffer is already mapped - that's an error */
+ if (!_mesa_validate_pbo_access(1, &ctx->Pack, ctx->Histogram.Width, 1, 1,
+ format, type, values)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetHistogram(invalid PBO access)");
+ return;
+ }
+
+ values = _mesa_map_pbo_dest(ctx, &ctx->Pack, values);
+ if (!values) {
+ if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) {
_mesa_error(ctx,GL_INVALID_OPERATION,"glGetHistogram(PBO is mapped)");
- return;
}
- values = ADD_POINTERS(buf, values);
- }
- else if (!values) {
- /* not an error */
return;
}
@@ -761,10 +741,7 @@ _mesa_GetHistogram(GLenum target, GLboolean reset, GLenum format, GLenum type, G
(CONST GLuint (*)[4]) ctx->Histogram.Count,
format, type, values, &ctx->Pack);
- if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) {
- ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
- ctx->Pack.BufferObj);
- }
+ _mesa_unmap_pbo_dest(ctx, &ctx->Pack);
if (reset) {
GLuint i;