diff options
Diffstat (limited to 'src/mesa/main/colortab.c')
-rw-r--r-- | src/mesa/main/colortab.c | 63 |
1 files changed, 24 insertions, 39 deletions
diff --git a/src/mesa/main/colortab.c b/src/mesa/main/colortab.c index 36304065eb..91c29882ec 100644 --- a/src/mesa/main/colortab.c +++ b/src/mesa/main/colortab.c @@ -179,27 +179,22 @@ store_colortable_entries(GLcontext *ctx, struct gl_color_table *table, GLfloat bScale, GLfloat bBias, GLfloat aScale, GLfloat aBias) { - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - /* Get/unpack the color table data from a PBO */ - GLubyte *buf; - if (!_mesa_validate_pbo_access(1, &ctx->Unpack, count, 1, 1, - format, type, data)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glColor[Sub]Table(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(1, &ctx->Unpack, count, 1, 1, + format, type, data)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glColor[Sub]Table(bad PBO access)"); + return; + } + + data = _mesa_map_pbo_source(ctx, &ctx->Unpack, data); + if (!data) { + if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glColor[Sub]Table(PBO mapped)"); - return; } - data = ADD_POINTERS(buf, data); + return; } - { /* convert user-provided data to GLfloat values */ GLfloat tempTab[MAX_COLOR_TABLE_SIZE * 4]; @@ -279,10 +274,7 @@ store_colortable_entries(GLcontext *ctx, struct gl_color_table *table, } } - if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) { - ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT, - ctx->Unpack.BufferObj); - } + _mesa_unmap_pbo_source(ctx, &ctx->Unpack); } @@ -696,34 +688,27 @@ _mesa_GetColorTable( GLenum target, GLenum format, return; } - if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { - /* pack color table into PBO */ - GLubyte *buf; - if (!_mesa_validate_pbo_access(1, &ctx->Pack, table->Size, 1, 1, - format, type, data)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glGetColorTable(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, table->Size, 1, 1, + format, type, data)) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetColorTable(invalid PBO access)"); + return; + } + + data = _mesa_map_pbo_dest(ctx, &ctx->Pack, data); + if (!data) { + if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) { /* buffer is already mapped - that's an error */ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetColorTable(PBO is mapped)"); - return; } - data = ADD_POINTERS(buf, data); + return; } _mesa_pack_rgba_span_float(ctx, table->Size, rgba, format, type, data, &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); } |