diff options
author | Brian Paul <[email protected]> | 2009-09-03 10:41:14 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2009-09-03 11:45:17 -0600 |
commit | 203f395aaf717a6faf21a76979cc24d544ae148b (patch) | |
tree | 7ea47b4217909be8134d7d32007ff629dd783bcd /src/mesa/main/histogram.c | |
parent | 1b448c7a5cafa68eeead2a4c45f4362a9883383b (diff) |
mesa: use new _mesa_map_pbo_source/dest() functions in more places
This trims down the code a bit. The next step would be to combine
the validate and map operations into one helper...
Diffstat (limited to 'src/mesa/main/histogram.c')
-rw-r--r-- | src/mesa/main/histogram.c | 67 |
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; |