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/polygon.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/polygon.c')
-rw-r--r-- | src/mesa/main/polygon.c | 77 |
1 files changed, 30 insertions, 47 deletions
diff --git a/src/mesa/main/polygon.c b/src/mesa/main/polygon.c index d11c9424d5e..e327a524159 100644 --- a/src/mesa/main/polygon.c +++ b/src/mesa/main/polygon.c @@ -193,32 +193,25 @@ _mesa_PolygonMode( GLenum face, GLenum mode ) void _mesa_polygon_stipple(GLcontext *ctx, const GLubyte *pattern) { - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - /* Get/unpack the stipple pattern from a PBO */ - GLubyte *buf; - if (!_mesa_validate_pbo_access(2, &ctx->Unpack, 32, 32, 1, - GL_COLOR_INDEX, GL_BITMAP, pattern)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glPolygonStipple(bad PBO access)"); - return; - } - buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - GL_READ_ONLY_ARB, - ctx->Unpack.BufferObj); - if (!buf) { + if (!_mesa_validate_pbo_access(2, &ctx->Unpack, 32, 32, 1, + GL_COLOR_INDEX, GL_BITMAP, pattern)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glPolygonStipple(bad PBO access)"); + return; + } + + pattern = _mesa_map_pbo_source(ctx, &ctx->Unpack, pattern); + if (!pattern) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glPolygonStipple(PBO mapped)"); - return; } - buf = ADD_POINTERS(buf, pattern); - _mesa_unpack_polygon_stipple(buf, ctx->PolygonStipple, &ctx->Unpack); - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - ctx->Unpack.BufferObj); - } - else { - /* Get/unpack the stipple pattern from user memory */ - _mesa_unpack_polygon_stipple(pattern, ctx->PolygonStipple, &ctx->Unpack); + return; } + + _mesa_unpack_polygon_stipple(pattern, ctx->PolygonStipple, &ctx->Unpack); + + _mesa_unmap_pbo_source(ctx, &ctx->Unpack); } @@ -255,35 +248,25 @@ _mesa_GetPolygonStipple( GLubyte *dest ) if (MESA_VERBOSE&VERBOSE_API) _mesa_debug(ctx, "glGetPolygonStipple\n"); - /* XXX someday we may put this code into a separate function and call - * it with ctx->Driver.GetPolygonStipple(). - */ - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - /* Put/pack the stipple pattern into a PBO */ - GLubyte *buf; - if (!_mesa_validate_pbo_access(2, &ctx->Pack, 32, 32, 1, - GL_COLOR_INDEX, GL_BITMAP, dest)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetPolygonStipple(bad 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(2, &ctx->Pack, 32, 32, 1, + GL_COLOR_INDEX, GL_BITMAP, dest)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetPolygonStipple(bad PBO access)"); + return; + } + + dest = _mesa_map_pbo_dest(ctx, &ctx->Pack, dest); + if (!dest) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetPolygonStipple(PBO mapped)"); - return; } - buf = ADD_POINTERS(buf, dest); - _mesa_pack_polygon_stipple(ctx->PolygonStipple, buf, &ctx->Pack); - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT, - ctx->Pack.BufferObj); - } - else { - /* Put/pack the stipple pattern into user memory */ - _mesa_pack_polygon_stipple(ctx->PolygonStipple, dest, &ctx->Pack); + return; } + + _mesa_pack_polygon_stipple(ctx->PolygonStipple, dest, &ctx->Pack); + + _mesa_unmap_pbo_dest(ctx, &ctx->Pack); } |