/*
* Mesa 3-D graphics library
- * Version: 6.1
+ * Version: 6.3
*
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
#include "glheader.h"
-#include "imports.h"
+#include "bufferobj.h"
#include "colortab.h"
#include "context.h"
#include "image.h"
* Update/replace all or part of a color table. Helper function
* used by _mesa_ColorTable() and _mesa_ColorSubTable().
* The table->Table buffer should already be allocated.
- * \param start - first entry to update
- * \param count - number of entries to update
- * \param format - format of user-provided table data
- * \param type - datatype of user-provided table data
- * \param data - user-provided table data
+ * \param start first entry to update
+ * \param count number of entries to update
+ * \param format format of user-provided table data
+ * \param type datatype of user-provided table data
+ * \param data user-provided table data
* \param [rgba]Scale - RGBA scale factors
* \param [rgba]Bias - RGBA bias factors
*/
GLfloat bScale, GLfloat bBias,
GLfloat aScale, GLfloat aBias)
{
+ if (ctx->Unpack.BufferObj->Name) {
+ /* 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) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glColor[Sub]Table(PBO mapped)");
+ return;
+ }
+ data = ADD_POINTERS(buf, data);
+ }
+
+
if (table->Type == GL_FLOAT) {
/* convert user-provided data to GLfloat values */
GLfloat tempTab[MAX_COLOR_TABLE_SIZE * 4];
GLint i;
_mesa_unpack_color_span_float(ctx,
- count, /* number of pixels */
- table->Format, /* dest format */
- tempTab, /* dest address */
- format, type, data, /* src data */
- &ctx->Unpack,
+ count, /* number of pixels */
+ table->Format, /* dest format */
+ tempTab, /* dest address */
+ format, type, /* src format/type */
+ data, /* src data */
+ &ctx->Unpack,
IMAGE_CLAMP_BIT); /* transfer ops */
+ /* the destination */
tableF = (GLfloat *) table->Table;
+ /* Apply scale & bias & clamp now */
switch (table->Format) {
case GL_INTENSITY:
for (i = 0; i < count; i++) {
&ctx->Unpack,
0); /* transfer ops */
}
+
+ if (ctx->Unpack.BufferObj->Name) {
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ ctx->Unpack.BufferObj);
+ }
}
assert(table);
- if (!_mesa_is_legal_format_and_type(format, type) ||
+ if (!_mesa_is_legal_format_and_type(ctx, format, type) ||
format == GL_INTENSITY) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glColorTable(format or type)");
return;
table->Size = width;
table->IntFormat = internalFormat;
table->Format = (GLenum) baseFormat;
- set_component_sizes(table);
comps = _mesa_components_in_format(table->Format);
assert(comps > 0); /* error should have been caught sooner */
}
} /* proxy */
+ /* do this after the table's Type and Format are set */
+ set_component_sizes(table);
+
if (texObj || target == GL_SHARED_TEXTURE_PALETTE_EXT) {
/* texture object palette, texObj==NULL means the shared palette */
if (ctx->Driver.UpdateTexturePalette) {
struct gl_color_table *table = NULL;
GLfloat rScale = 1.0, gScale = 1.0, bScale = 1.0, aScale = 1.0;
GLfloat rBias = 0.0, gBias = 0.0, bBias = 0.0, aBias = 0.0;
- GLint comps;
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
switch (target) {
assert(table);
- if (!_mesa_is_legal_format_and_type(format, type) ||
+ if (!_mesa_is_legal_format_and_type(ctx, format, type) ||
format == GL_INTENSITY) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glColorSubTable(format or type)");
return;
return;
}
- comps = _mesa_components_in_format(table->Format);
- assert(comps > 0); /* error should have been caught sooner */
+ /* error should have been caught sooner */
+ assert(_mesa_components_in_format(table->Format) > 0);
if (start + count > (GLint) table->Size) {
_mesa_error(ctx, GL_INVALID_VALUE, "glColorSubTable(count)");
-/* XXX not tested */
void GLAPIENTRY
_mesa_CopyColorTable(GLenum target, GLenum internalformat,
GLint x, GLint y, GLsizei width)
-/* XXX not tested */
void GLAPIENTRY
_mesa_CopyColorSubTable(GLenum target, GLsizei start,
GLint x, GLint y, GLsizei width)
return;
}
+ if (ctx->Pack.BufferObj->Name) {
+ /* 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) {
+ /* buffer is already mapped - that's an error */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetColorTable(PBO is mapped)");
+ return;
+ }
+ data = ADD_POINTERS(buf, data);
+ }
+
_mesa_pack_rgba_span_chan(ctx, table->Size, (const GLchan (*)[4]) rgba,
format, type, data, &ctx->Pack, GL_FALSE);
+
+ if (ctx->Pack.BufferObj->Name) {
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
+ ctx->Pack.BufferObj);
+ }
}