}
-#if HAVE_HW_DEPTH_SPANS
-/* implement MonoWriteDepthSpan() in terms of WriteDepthSpan() */
-static void
-TAG(WriteMonoDepthSpan)( struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint n, GLint x, GLint y,
- const void *value, const GLubyte mask[] )
-{
- const GLuint depthVal = *((GLuint *) value);
- GLuint depths[MAX_WIDTH];
- GLuint i;
- for (i = 0; i < n; i++)
- depths[i] = depthVal;
- TAG(WriteDepthSpan)(ctx, rb, n, x, y, depths, mask);
-}
-#else
-static void TAG(WriteMonoDepthSpan)( struct gl_context *ctx,
- struct gl_renderbuffer *rb,
- GLuint n, GLint x, GLint y,
- const void *value,
- const GLubyte mask[] )
-{
- HW_WRITE_LOCK()
- {
- const GLuint depth = *((GLuint *) value);
- GLint x1;
- GLint n1;
- LOCAL_DEPTH_VARS;
-
- y = Y_FLIP( y );
-
- HW_CLIPLOOP()
- {
- GLint i = 0;
- CLIPSPAN( x, y, n, x1, n1, i );
-
- if ( DBG ) fprintf( stderr, "%s %d..%d (x1 %d) = %u\n",
- __FUNCTION__, (int)i, (int)n1, (int)x1, (GLuint)depth );
-
- if ( mask ) {
- for ( ; n1>0 ; i++, x1++, n1-- ) {
- if ( mask[i] ) WRITE_DEPTH( x1, y, depth );
- }
- } else {
- for ( ; n1>0 ; x1++, n1-- ) {
- WRITE_DEPTH( x1, y, depth );
- }
- }
- }
- HW_ENDCLIPLOOP();
- }
- HW_WRITE_UNLOCK();
-
- (void) ctx;
-}
-#endif
-
-
static void TAG(WriteDepthPixels)( struct gl_context *ctx,
struct gl_renderbuffer *rb,
GLuint n,
rb->GetValues = TAG(ReadDepthPixels);
rb->PutRow = TAG(WriteDepthSpan);
rb->PutRowRGB = NULL;
- rb->PutMonoRow = TAG(WriteMonoDepthSpan);
rb->PutValues = TAG(WriteDepthPixels);
- rb->PutMonoValues = NULL;
}
#define PUT_VALUE(_x, _y, _v) *(volatile GLushort *)(GET_PTR(_x, _y)) = (_v)
#endif /* GET_VALUE */
-#define INIT_MONO_PIXEL(p, color) \
- p = PACK_COLOR_565( color[0], color[1], color[2] )
-
#define WRITE_RGBA( _x, _y, r, g, b, a ) \
PUT_VALUE(_x, _y, ((((int)r & 0xf8) << 8) | \
(((int)g & 0xfc) << 3) | \
#define PUT_VALUE(_x, _y, _v) *(volatile GLushort *)(GET_PTR(_x, _y)) = (_v)
#endif /* GET_VALUE */
-#define INIT_MONO_PIXEL(p, color) \
- p = PACK_COLOR_565_REV( color[0], color[1], color[2] )
-
#define WRITE_RGBA( _x, _y, r, g, b, a ) \
PUT_VALUE(_x, _y, PACK_COLOR_565_REV( r, g, b ))
#define PUT_VALUE(_x, _y, _v) *(volatile GLushort *)(GET_PTR(_x, _y)) = (_v)
#endif /* GET_VALUE */
-#define INIT_MONO_PIXEL(p, color) \
- p = PACK_COLOR_4444_REV(color[3], color[0], color[1], color[2])
-
#define WRITE_RGBA( _x, _y, r, g, b, a ) \
PUT_VALUE(_x, _y, PACK_COLOR_4444_REV(a, r, g, b)) \
#define PUT_VALUE(_x, _y, _v) *(volatile GLushort *)(GET_PTR(_x, _y)) = (_v)
#endif /* GET_VALUE */
-#define INIT_MONO_PIXEL(p, color) \
- p = PACK_COLOR_4444(color[3], color[0], color[1], color[2])
-
#define WRITE_RGBA( _x, _y, r, g, b, a ) \
PUT_VALUE(_x, _y, PACK_COLOR_4444(a, r, g, b)) \
#define PUT_VALUE(_x, _y, _v) *(volatile GLushort *)(GET_PTR(_x, _y)) = (_v)
#endif /* GET_VALUE */
-#define INIT_MONO_PIXEL(p, color) \
- p = PACK_COLOR_1555(color[3], color[0], color[1], color[2])
-
#define WRITE_RGBA( _x, _y, r, g, b, a ) \
PUT_VALUE(_x, _y, PACK_COLOR_1555(a, r, g, b)) \
#define PUT_VALUE(_x, _y, _v) *(volatile GLushort *)(GET_PTR(_x, _y)) = (_v)
#endif /* GET_VALUE */
-#define INIT_MONO_PIXEL(p, color) \
- p = PACK_COLOR_1555_REV(color[3], color[0], color[1], color[2])
-
#define WRITE_RGBA( _x, _y, r, g, b, a ) \
PUT_VALUE(_x, _y, PACK_COLOR_1555_REV(a, r, g, b)) \
#define PUT_VALUE(_x, _y, _v) *(volatile GLuint *)(GET_PTR(_x, _y)) = (_v)
#endif /* GET_VALUE */
-# define INIT_MONO_PIXEL(p, color) \
- p = PACK_COLOR_8888(color[3], color[0], color[1], color[2])
-
# define WRITE_RGBA(_x, _y, r, g, b, a) \
PUT_VALUE(_x, _y, ((r << 16) | \
(g << 8) | \
#define PUT_VALUE(_x, _y, _v) *(volatile GLuint *)(GET_PTR(_x, _y)) = (_v)
#endif /* GET_VALUE */
-# define INIT_MONO_PIXEL(p, color) \
- p = PACK_COLOR_8888(color[2], color[1], color[0], color[3])
-
# define WRITE_RGBA(_x, _y, r, g, b, a) \
PUT_VALUE(_x, _y, ((r << 8) | \
(g << 16) | \
#define PUT_VALUE(_x, _y, _v) *(volatile GLuint *)(GET_PTR(_x, _y)) = (_v)
#endif /* GET_VALUE */
-# define INIT_MONO_PIXEL(p, color) \
- p = PACK_COLOR_8888(0xff, color[0], color[1], color[2])
-
# define WRITE_RGBA(_x, _y, r, g, b, a) \
PUT_VALUE(_x, _y, ((r << 16) | \
(g << 8) | \
#define PUT_VALUE(_x, _y, _v) *(volatile GLubyte *)(GET_PTR(_x, _y)) = (_v)
#endif /* GET_VALUE */
-# define INIT_MONO_PIXEL(p, color) \
- p = color[3]
-
# define WRITE_RGBA(_x, _y, r, g, b, a) \
PUT_VALUE(_x, _y, a | (r & 0 /* quiet warnings */))
}
-static void TAG(WriteMonoRGBASpan)( struct gl_context *ctx,
- struct gl_renderbuffer *rb,
- GLuint n, GLint x, GLint y,
- const void *value, const GLubyte mask[] )
-{
- (void) ctx;
-
- HW_WRITE_LOCK()
- {
- const GLubyte *color = (const GLubyte *) value;
- GLint x1;
- GLint n1;
- LOCAL_VARS;
- INIT_MONO_PIXEL(p, color);
-
- y = Y_FLIP( y );
-
- if (DBG) fprintf(stderr, "WriteMonoRGBASpan\n");
-
- HW_WRITE_CLIPLOOP()
- {
- GLint i = 0;
- CLIPSPAN(x,y,n,x1,n1,i);
- if (mask)
- {
- for (;n1>0;i++,x1++,n1--)
- if (mask[i])
- WRITE_PIXEL( x1, y, p );
- }
- else
- {
- for (;n1>0;i++,x1++,n1--)
- WRITE_PIXEL( x1, y, p );
- }
- }
- HW_ENDCLIPLOOP();
- }
- HW_WRITE_UNLOCK();
-}
-
-
-static void TAG(WriteMonoRGBAPixels)( struct gl_context *ctx,
- struct gl_renderbuffer *rb,
- GLuint n,
- const GLint x[], const GLint y[],
- const void *value,
- const GLubyte mask[] )
-{
- (void) ctx;
-
- HW_WRITE_LOCK()
- {
- const GLubyte *color = (const GLubyte *) value;
- GLint i;
- LOCAL_VARS;
- INIT_MONO_PIXEL(p, color);
-
- if (DBG) fprintf(stderr, "WriteMonoRGBAPixels\n");
-
- HW_WRITE_CLIPLOOP()
- {
- if (mask)
- {
- for (i=0;i<n;i++)
- if (mask[i]) {
- int fy = Y_FLIP(y[i]);
- if (CLIPPIXEL( x[i], fy ))
- WRITE_PIXEL( x[i], fy, p );
- }
- }
- else
- {
- for (i=0;i<n;i++) {
- int fy = Y_FLIP(y[i]);
- if (CLIPPIXEL( x[i], fy ))
- WRITE_PIXEL( x[i], fy, p );
- }
- }
- }
- HW_ENDCLIPLOOP();
- }
- HW_WRITE_UNLOCK();
-}
-
-
static void TAG(ReadRGBASpan)( struct gl_context *ctx,
struct gl_renderbuffer *rb,
GLuint n, GLint x, GLint y, void *values)
{
rb->PutRow = TAG(WriteRGBASpan);
rb->PutRowRGB = TAG(WriteRGBSpan);
- rb->PutMonoRow = TAG(WriteMonoRGBASpan);
rb->PutValues = TAG(WriteRGBAPixels);
- rb->PutMonoValues = TAG(WriteMonoRGBAPixels);
rb->GetValues = TAG(ReadRGBAPixels);
#if defined(GET_PTR)
}
-#undef INIT_MONO_PIXEL
#undef WRITE_PIXEL
#undef WRITE_RGBA
#undef READ_RGBA
HW_WRITE_UNLOCK();
}
-#if HAVE_HW_STENCIL_SPANS
-/* implement MonoWriteDepthSpan() in terms of WriteDepthSpan() */
-static void
-TAG(WriteMonoStencilSpan)( struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint n, GLint x, GLint y,
- const void *value, const GLubyte mask[] )
-{
- const GLuint stenVal = *((GLuint *) value);
- GLuint stens[MAX_WIDTH];
- GLuint i;
- for (i = 0; i < n; i++)
- stens[i] = stenVal;
- TAG(WriteStencilSpan)(ctx, rb, n, x, y, stens, mask);
-}
-#else /* HAVE_HW_STENCIL_SPANS */
-static void TAG(WriteMonoStencilSpan)( struct gl_context *ctx,
- struct gl_renderbuffer *rb,
- GLuint n, GLint x, GLint y,
- const void *value,
- const GLubyte mask[] )
-{
- HW_WRITE_LOCK()
- {
- const GLubyte stencil = *((const GLubyte *) value);
- GLint x1;
- GLint n1;
- LOCAL_STENCIL_VARS;
-
- y = Y_FLIP(y);
-
- HW_CLIPLOOP()
- {
- GLint i = 0;
- CLIPSPAN(x,y,n,x1,n1,i);
-
- if (DBG) fprintf(stderr, "WriteStencilSpan %d..%d (x1 %d)\n",
- (int)i, (int)n1, (int)x1);
-
- if (mask)
- {
- for (;n1>0;i++,x1++,n1--)
- if (mask[i])
- WRITE_STENCIL( x1, y, stencil );
- }
- else
- {
- for (;n1>0;i++,x1++,n1--)
- WRITE_STENCIL( x1, y, stencil );
- }
- }
- HW_ENDCLIPLOOP();
- }
- HW_WRITE_UNLOCK();
-}
-#endif /* !HAVE_HW_STENCIL_SPANS */
-
static void TAG(WriteStencilPixels)( struct gl_context *ctx,
struct gl_renderbuffer *rb,
rb->GetValues = TAG(ReadStencilPixels);
rb->PutRow = TAG(WriteStencilSpan);
rb->PutRowRGB = NULL;
- rb->PutMonoRow = TAG(WriteMonoStencilSpan);
rb->PutValues = TAG(WriteStencilPixels);
- rb->PutMonoValues = NULL;
}
xrb->Base.GetValues = get_values_A8R8G8B8;
xrb->Base.PutRow = put_row_A8R8G8B8;
xrb->Base.PutRowRGB = put_row_rgb_A8R8G8B8;
- xrb->Base.PutMonoRow = put_mono_row_A8R8G8B8;
xrb->Base.PutValues = put_values_A8R8G8B8;
- xrb->Base.PutMonoValues = put_mono_values_A8R8G8B8;
break;
case PF_X8R8G8B8:
xrb->Base.GetRow = get_row_X8R8G8B8;
xrb->Base.GetValues = get_values_X8R8G8B8;
xrb->Base.PutRow = put_row_X8R8G8B8;
xrb->Base.PutRowRGB = put_row_rgb_X8R8G8B8;
- xrb->Base.PutMonoRow = put_mono_row_X8R8G8B8;
xrb->Base.PutValues = put_values_X8R8G8B8;
- xrb->Base.PutMonoValues = put_mono_values_X8R8G8B8;
break;
case PF_R5G6B5:
xrb->Base.GetRow = get_row_R5G6B5;
xrb->Base.GetValues = get_values_R5G6B5;
xrb->Base.PutRow = put_row_R5G6B5;
xrb->Base.PutRowRGB = put_row_rgb_R5G6B5;
- xrb->Base.PutMonoRow = put_mono_row_R5G6B5;
xrb->Base.PutValues = put_values_R5G6B5;
- xrb->Base.PutMonoValues = put_mono_values_R5G6B5;
break;
case PF_R3G3B2:
xrb->Base.GetRow = get_row_R3G3B2;
xrb->Base.GetValues = get_values_R3G3B2;
xrb->Base.PutRow = put_row_R3G3B2;
xrb->Base.PutRowRGB = put_row_rgb_R3G3B2;
- xrb->Base.PutMonoRow = put_mono_row_R3G3B2;
xrb->Base.PutValues = put_values_R3G3B2;
- xrb->Base.PutMonoValues = put_mono_values_R3G3B2;
break;
default:
assert(0);
xrb->Base.GetValues = get_values_A8R8G8B8_front;
xrb->Base.PutRow = put_row_A8R8G8B8_front;
xrb->Base.PutRowRGB = put_row_rgb_A8R8G8B8_front;
- xrb->Base.PutMonoRow = put_mono_row_A8R8G8B8_front;
xrb->Base.PutValues = put_values_A8R8G8B8_front;
- xrb->Base.PutMonoValues = put_mono_values_A8R8G8B8_front;
break;
case PF_X8R8G8B8:
xrb->Base.GetRow = get_row_X8R8G8B8_front;
xrb->Base.GetValues = get_values_X8R8G8B8_front;
xrb->Base.PutRow = put_row_X8R8G8B8_front;
xrb->Base.PutRowRGB = put_row_rgb_X8R8G8B8_front;
- xrb->Base.PutMonoRow = put_mono_row_X8R8G8B8_front;
xrb->Base.PutValues = put_values_X8R8G8B8_front;
- xrb->Base.PutMonoValues = put_mono_values_X8R8G8B8_front;
break;
case PF_R5G6B5:
xrb->Base.GetRow = get_row_R5G6B5_front;
xrb->Base.GetValues = get_values_R5G6B5_front;
xrb->Base.PutRow = put_row_R5G6B5_front;
xrb->Base.PutRowRGB = put_row_rgb_R5G6B5_front;
- xrb->Base.PutMonoRow = put_mono_row_R5G6B5_front;
xrb->Base.PutValues = put_values_R5G6B5_front;
- xrb->Base.PutMonoValues = put_mono_values_R5G6B5_front;
break;
case PF_R3G3B2:
xrb->Base.GetRow = get_row_R3G3B2_front;
xrb->Base.GetValues = get_values_R3G3B2_front;
xrb->Base.PutRow = put_row_R3G3B2_front;
xrb->Base.PutRowRGB = put_row_rgb_R3G3B2_front;
- xrb->Base.PutMonoRow = put_mono_row_R3G3B2_front;
xrb->Base.PutValues = put_values_R3G3B2_front;
- xrb->Base.PutMonoValues = put_mono_values_R3G3B2_front;
break;
default:
assert(0);
/*
* Templates for the span/pixel-array write/read functions called via
- * the gl_renderbuffer's GetRow, GetValues, PutRow, PutMonoRow, PutValues
- * and PutMonoValues functions.
+ * the gl_renderbuffer's GetRow, GetValues, PutRow and PutValues.
*
* Define the following macros before including this file:
* NAME(BASE) to generate the function name (i.e. add prefix or suffix)
}
-static void
-NAME(put_mono_row)( struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, GLint x, GLint y,
- const void *value, const GLubyte mask[] )
-{
-#ifdef SPAN_VARS
- SPAN_VARS
-#endif
- const RB_TYPE *src = (const RB_TYPE *) value;
- GLuint i;
- if (mask) {
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- RB_TYPE row[4];
- INIT_PIXEL_PTR(pixel, x, y);
- STORE_PIXEL(pixel, x + i, y, src);
- PUT_PIXEL(ctx, x + i, YFLIP(xrb, y), pixel);
- }
- }
- }
- else {
- char *row = swrast_drawable(ctx->DrawBuffer)->row;
- INIT_PIXEL_PTR(pixel, x, y);
- for (i = 0; i < count; i++) {
- STORE_PIXEL(pixel, x + i, y, src);
- INC_PIXEL_PTR(pixel);
- }
- PUT_ROW( ctx, x, YFLIP(xrb, y), count, row );
- }
- (void) rb;
-}
-
-
static void
NAME(put_values)( struct gl_context *ctx, struct gl_renderbuffer *rb,
GLuint count, const GLint x[], const GLint y[],
}
-static void
-NAME(put_mono_values)( struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- const void *value, const GLubyte mask[] )
-{
-#ifdef SPAN_VARS
- SPAN_VARS
-#endif
- const RB_TYPE *src = (const RB_TYPE *) value;
- GLuint i;
- ASSERT(mask);
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- RB_TYPE row[4];
- INIT_PIXEL_PTR(pixel, x, y);
- STORE_PIXEL(pixel, x[i], y[i], src);
- PUT_PIXEL(ctx, x[i], YFLIP(xrb, y[i]), pixel);
- }
- }
- (void) rb;
-}
#undef NAME
rb->GetValues = get_values_RGBA8;
rb->PutRow = put_row_RGBA8;
rb->PutRowRGB = put_row_rgb_RGBA8;
- rb->PutMonoRow = put_mono_row_RGBA8;
rb->PutValues = put_values_RGBA8;
- rb->PutMonoValues = put_mono_values_RGBA8;
}
else if (rb->DataType == GL_UNSIGNED_SHORT) {
rb->GetRow = get_row_RGBA16;
rb->GetValues = get_values_RGBA16;
rb->PutRow = put_row_RGBA16;
rb->PutRowRGB = put_row_rgb_RGBA16;
- rb->PutMonoRow = put_mono_row_RGBA16;
rb->PutValues = put_values_RGBA16;
- rb->PutMonoValues = put_mono_values_RGBA16;
}
else {
rb->GetRow = get_row_RGBA32;
rb->GetValues = get_values_RGBA32;
rb->PutRow = put_row_RGBA32;
rb->PutRowRGB = put_row_rgb_RGBA32;
- rb->PutMonoRow = put_mono_row_RGBA32;
rb->PutValues = put_values_RGBA32;
- rb->PutMonoValues = put_mono_values_RGBA32;
}
}
else if (osmesa->format == OSMESA_BGRA) {
rb->GetValues = get_values_BGRA8;
rb->PutRow = put_row_BGRA8;
rb->PutRowRGB = put_row_rgb_BGRA8;
- rb->PutMonoRow = put_mono_row_BGRA8;
rb->PutValues = put_values_BGRA8;
- rb->PutMonoValues = put_mono_values_BGRA8;
}
else if (rb->DataType == GL_UNSIGNED_SHORT) {
rb->GetRow = get_row_BGRA16;
rb->GetValues = get_values_BGRA16;
rb->PutRow = put_row_BGRA16;
rb->PutRowRGB = put_row_rgb_BGRA16;
- rb->PutMonoRow = put_mono_row_BGRA16;
rb->PutValues = put_values_BGRA16;
- rb->PutMonoValues = put_mono_values_BGRA16;
}
else {
rb->GetRow = get_row_BGRA32;
rb->GetValues = get_values_BGRA32;
rb->PutRow = put_row_BGRA32;
rb->PutRowRGB = put_row_rgb_BGRA32;
- rb->PutMonoRow = put_mono_row_BGRA32;
rb->PutValues = put_values_BGRA32;
- rb->PutMonoValues = put_mono_values_BGRA32;
}
}
else if (osmesa->format == OSMESA_ARGB) {
rb->GetValues = get_values_ARGB8;
rb->PutRow = put_row_ARGB8;
rb->PutRowRGB = put_row_rgb_ARGB8;
- rb->PutMonoRow = put_mono_row_ARGB8;
rb->PutValues = put_values_ARGB8;
- rb->PutMonoValues = put_mono_values_ARGB8;
}
else if (rb->DataType == GL_UNSIGNED_SHORT) {
rb->GetRow = get_row_ARGB16;
rb->GetValues = get_values_ARGB16;
rb->PutRow = put_row_ARGB16;
rb->PutRowRGB = put_row_rgb_ARGB16;
- rb->PutMonoRow = put_mono_row_ARGB16;
rb->PutValues = put_values_ARGB16;
- rb->PutMonoValues = put_mono_values_ARGB16;
}
else {
rb->GetRow = get_row_ARGB32;
rb->GetValues = get_values_ARGB32;
rb->PutRow = put_row_ARGB32;
rb->PutRowRGB = put_row_rgb_ARGB32;
- rb->PutMonoRow = put_mono_row_ARGB32;
rb->PutValues = put_values_ARGB32;
- rb->PutMonoValues = put_mono_values_ARGB32;
}
}
else if (osmesa->format == OSMESA_RGB) {
rb->GetValues = get_values_RGB8;
rb->PutRow = put_row_RGB8;
rb->PutRowRGB = put_row_rgb_RGB8;
- rb->PutMonoRow = put_mono_row_RGB8;
rb->PutValues = put_values_RGB8;
- rb->PutMonoValues = put_mono_values_RGB8;
}
else if (rb->DataType == GL_UNSIGNED_SHORT) {
rb->GetRow = get_row_RGB16;
rb->GetValues = get_values_RGB16;
rb->PutRow = put_row_RGB16;
rb->PutRowRGB = put_row_rgb_RGB16;
- rb->PutMonoRow = put_mono_row_RGB16;
rb->PutValues = put_values_RGB16;
- rb->PutMonoValues = put_mono_values_RGB16;
}
else {
rb->GetRow = get_row_RGB32;
rb->GetValues = get_values_RGB32;
rb->PutRow = put_row_RGB32;
rb->PutRowRGB = put_row_rgb_RGB32;
- rb->PutMonoRow = put_mono_row_RGB32;
rb->PutValues = put_values_RGB32;
- rb->PutMonoValues = put_mono_values_RGB32;
}
}
else if (osmesa->format == OSMESA_BGR) {
rb->GetValues = get_values_BGR8;
rb->PutRow = put_row_BGR8;
rb->PutRowRGB = put_row_rgb_BGR8;
- rb->PutMonoRow = put_mono_row_BGR8;
rb->PutValues = put_values_BGR8;
- rb->PutMonoValues = put_mono_values_BGR8;
}
else if (rb->DataType == GL_UNSIGNED_SHORT) {
rb->GetRow = get_row_BGR16;
rb->GetValues = get_values_BGR16;
rb->PutRow = put_row_BGR16;
rb->PutRowRGB = put_row_rgb_BGR16;
- rb->PutMonoRow = put_mono_row_BGR16;
rb->PutValues = put_values_BGR16;
- rb->PutMonoValues = put_mono_values_BGR16;
}
else {
rb->GetRow = get_row_BGR32;
rb->GetValues = get_values_BGR32;
rb->PutRow = put_row_BGR32;
rb->PutRowRGB = put_row_rgb_BGR32;
- rb->PutMonoRow = put_mono_row_BGR32;
rb->PutValues = put_values_BGR32;
- rb->PutMonoValues = put_mono_values_BGR32;
}
}
else if (osmesa->format == OSMESA_RGB_565) {
rb->GetValues = get_values_RGB_565;
rb->PutRow = put_row_RGB_565;
rb->PutRowRGB = put_row_rgb_RGB_565;
- rb->PutMonoRow = put_mono_row_RGB_565;
rb->PutValues = put_values_RGB_565;
- rb->PutMonoValues = put_mono_values_RGB_565;
}
else {
_mesa_problem(ctx, "bad pixel format in osmesa renderbuffer_storage");
}
-/*
- * Write a horizontal span of pixels with a boolean mask. The current color
- * is used for all pixels.
- */
-static void write_mono_rgba_span_front(struct gl_context *ctx,
- struct gl_renderbuffer *rb,
- GLuint n, GLint x, GLint y,
- const void *value,
- const GLubyte *mask)
-{
- const GLchan *color = (const GLchan *)value;
- GLuint i;
- WMesaContext pwc = wmesa_context(ctx);
- COLORREF colorref;
-
- (void) ctx;
- colorref = RGB(color[RCOMP], color[GCOMP], color[BCOMP]);
- y=FLIP(y);
- if (mask) {
- for (i=0; i<n; i++)
- if (mask[i])
- SetPixel(pwc->hDC, x+i, y, colorref);
- }
- else
- for (i=0; i<n; i++)
- SetPixel(pwc->hDC, x+i, y, colorref);
-
-}
/* Write an array of RGBA pixels with a boolean mask. */
static void write_rgba_pixels_front(struct gl_context *ctx,
-/*
- * Write an array of pixels with a boolean mask. The current color
- * is used for all pixels.
- */
-static void write_mono_rgba_pixels_front(struct gl_context *ctx,
- struct gl_renderbuffer *rb,
- GLuint n,
- const GLint x[], const GLint y[],
- const void *value,
- const GLubyte *mask)
-{
- const GLchan *color = (const GLchan *)value;
- GLuint i;
- WMesaContext pwc = wmesa_context(ctx);
- COLORREF colorref;
- (void) ctx;
- colorref = RGB(color[RCOMP], color[GCOMP], color[BCOMP]);
- for (i=0; i<n; i++)
- if (mask[i])
- SetPixel(pwc->hDC, x[i], FLIP(y[i]), colorref);
-}
-
/* Read a horizontal span of color pixels. */
static void read_rgba_span_front(struct gl_context *ctx,
struct gl_renderbuffer *rb,
}
}
-/*
- * Write a horizontal span of pixels with a boolean mask. The current color
- * is used for all pixels.
- */
-static void write_mono_rgba_span_32(struct gl_context *ctx,
- struct gl_renderbuffer *rb,
- GLuint n, GLint x, GLint y,
- const void *value,
- const GLubyte *mask)
-{
- const GLchan *color = (const GLchan *)value;
- LPDWORD lpdw;
- DWORD pixel;
- GLuint i;
- WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer);
- lpdw = ((LPDWORD)(pwfb->pbPixels + pwfb->ScanWidth * y)) + x;
- y=FLIP(y);
- pixel = BGR32(color[RCOMP], color[GCOMP], color[BCOMP]);
- if (mask) {
- for (i=0; i<n; i++)
- if (mask[i])
- lpdw[i] = pixel;
- }
- else
- for (i=0; i<n; i++)
- *lpdw++ = pixel;
-
-}
-
/* Write an array of RGBA pixels with a boolean mask. */
static void write_rgba_pixels_32(struct gl_context *ctx,
struct gl_renderbuffer *rb,
rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
}
-/*
- * Write an array of pixels with a boolean mask. The current color
- * is used for all pixels.
- */
-static void write_mono_rgba_pixels_32(struct gl_context *ctx,
- struct gl_renderbuffer *rb,
- GLuint n,
- const GLint x[], const GLint y[],
- const void *value,
- const GLubyte *mask)
-{
- const GLchan *color = (const GLchan *)value;
- GLuint i;
- WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer);
- for (i=0; i<n; i++)
- if (mask[i])
- WMSETPIXEL32(pwfb, FLIP(y[i]),x[i],color[RCOMP],
- color[GCOMP], color[BCOMP]);
-}
/* Read a horizontal span of color pixels. */
static void read_rgba_span_32(struct gl_context *ctx,
}
}
-/*
- * Write a horizontal span of pixels with a boolean mask. The current color
- * is used for all pixels.
- */
-static void write_mono_rgba_span_24(struct gl_context *ctx,
- struct gl_renderbuffer *rb,
- GLuint n, GLint x, GLint y,
- const void *value,
- const GLubyte *mask)
-{
- const GLchan *color = (const GLchan *)value;
- LPBYTE lpb;
- GLuint i;
- WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer);
- lpb = ((LPBYTE)(pwfb->pbPixels + pwfb->ScanWidth * y)) + (3 * x);
- y=FLIP(y);
- if (mask) {
- for (i=0; i<n; i++)
- if (mask[i]) {
- lpb[3*i] = color[BCOMP];
- lpb[3*i+1] = color[GCOMP];
- lpb[3*i+2] = color[RCOMP];
- }
- }
- else
- for (i=0; i<n; i++) {
- *lpb++ = color[BCOMP];
- *lpb++ = color[GCOMP];
- *lpb++ = color[RCOMP];
- }
-}
/* Write an array of RGBA pixels with a boolean mask. */
static void write_rgba_pixels_24(struct gl_context *ctx,
rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
}
-/*
- * Write an array of pixels with a boolean mask. The current color
- * is used for all pixels.
- */
-static void write_mono_rgba_pixels_24(struct gl_context *ctx,
- struct gl_renderbuffer *rb,
- GLuint n,
- const GLint x[], const GLint y[],
- const void *value,
- const GLubyte *mask)
-{
- const GLchan *color = (const GLchan *)value;
- GLuint i;
- WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer);
- for (i=0; i<n; i++)
- if (mask[i])
- WMSETPIXEL24(pwfb, FLIP(y[i]),x[i],color[RCOMP],
- color[GCOMP], color[BCOMP]);
-}
/* Read a horizontal span of color pixels. */
static void read_rgba_span_24(struct gl_context *ctx,
}
}
-/*
- * Write a horizontal span of pixels with a boolean mask. The current color
- * is used for all pixels.
- */
-static void write_mono_rgba_span_16(struct gl_context *ctx,
- struct gl_renderbuffer *rb,
- GLuint n, GLint x, GLint y,
- const void *value,
- const GLubyte *mask)
-{
- const GLchan *color = (const GLchan *)value;
- LPWORD lpw;
- WORD pixel;
- GLuint i;
- WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer);
- (void) ctx;
- lpw = ((LPWORD)(pwfb->pbPixels + pwfb->ScanWidth * y)) + x;
- y=FLIP(y);
- pixel = BGR16(color[RCOMP], color[GCOMP], color[BCOMP]);
- if (mask) {
- for (i=0; i<n; i++)
- if (mask[i])
- lpw[i] = pixel;
- }
- else
- for (i=0; i<n; i++)
- *lpw++ = pixel;
-
-}
/* Write an array of RGBA pixels with a boolean mask. */
static void write_rgba_pixels_16(struct gl_context *ctx,
rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
}
-/*
- * Write an array of pixels with a boolean mask. The current color
- * is used for all pixels.
- */
-static void write_mono_rgba_pixels_16(struct gl_context *ctx,
- struct gl_renderbuffer *rb,
- GLuint n,
- const GLint x[], const GLint y[],
- const void *value,
- const GLubyte *mask)
-{
- const GLchan *color = (const GLchan *)value;
- GLuint i;
- WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer);
- (void) ctx;
- for (i=0; i<n; i++)
- if (mask[i])
- WMSETPIXEL16(pwfb, FLIP(y[i]),x[i],color[RCOMP],
- color[GCOMP], color[BCOMP]);
-}
/* Read a horizontal span of color pixels. */
static void read_rgba_span_16(struct gl_context *ctx,
case PF_5R6G5B:
rb->PutRow = write_rgba_span_16;
rb->PutRowRGB = write_rgb_span_16;
- rb->PutMonoRow = write_mono_rgba_span_16;
rb->PutValues = write_rgba_pixels_16;
- rb->PutMonoValues = write_mono_rgba_pixels_16;
rb->GetRow = read_rgba_span_16;
rb->GetValues = read_rgba_pixels_16;
break;
{
rb->PutRow = write_rgba_span_24;
rb->PutRowRGB = write_rgb_span_24;
- rb->PutMonoRow = write_mono_rgba_span_24;
rb->PutValues = write_rgba_pixels_24;
- rb->PutMonoValues = write_mono_rgba_pixels_24;
rb->GetRow = read_rgba_span_24;
rb->GetValues = read_rgba_pixels_24;
}
else
{
- rb->PutRow = write_rgba_span_32;
- rb->PutRowRGB = write_rgb_span_32;
- rb->PutMonoRow = write_mono_rgba_span_32;
- rb->PutValues = write_rgba_pixels_32;
- rb->PutMonoValues = write_mono_rgba_pixels_32;
- rb->GetRow = read_rgba_span_32;
- rb->GetValues = read_rgba_pixels_32;
+ rb->PutRow = write_rgba_span_32;
+ rb->PutRowRGB = write_rgb_span_32;
+ rb->PutValues = write_rgba_pixels_32;
+ rb->GetRow = read_rgba_span_32;
+ rb->GetValues = read_rgba_pixels_32;
}
break;
default:
/* front buffer (actual Windows window) */
rb->PutRow = write_rgba_span_front;
rb->PutRowRGB = write_rgb_span_front;
- rb->PutMonoRow = write_mono_rgba_span_front;
rb->PutValues = write_rgba_pixels_front;
- rb->PutMonoValues = write_mono_rgba_pixels_front;
rb->GetRow = read_rgba_span_front;
rb->GetValues = read_rgba_pixels_front;
}
*
* The function naming convention is:
*
- * [put|get]_[mono]_[row|values]_[format]_[pixmap|ximage]
+ * [put|get]_[row|values]_[format]_[pixmap|ximage]
*
* New functions optimized for specific cases can be added without too much
* trouble. An example might be the 24-bit TrueColor mode 8A8R8G8B which is
-/**********************************************************************/
-/*** Write MONO COLOR SPAN functions ***/
-/**********************************************************************/
-
-#define PUT_MONO_ROW_ARGS \
- struct gl_context *ctx, struct gl_renderbuffer *rb, \
- GLuint n, GLint x, GLint y, const void *value, \
- const GLubyte mask[]
-
-
-
-/*
- * Write a span of identical pixels to a pixmap.
- */
-static void put_mono_row_pixmap( PUT_MONO_ROW_ARGS )
-{
- const GLubyte *color = (const GLubyte *) value;
- GET_XRB(xrb);
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
- XMesaDisplay *dpy = xmesa->xm_visual->display;
- XMesaDrawable buffer = xrb->drawable;
- XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
- const unsigned long pixel = xmesa_color_to_pixel(ctx, color[RCOMP],
- color[GCOMP], color[BCOMP], color[ACOMP], xmesa->pixelformat);
- register GLuint i;
- XMesaSetForeground( xmesa->display, gc, pixel );
- y = YFLIP(xrb, y);
-
- /* New code contributed by Jeff Epler and cleaned up by Keith
- * Whitwell.
- */
- for (i = 0; i < n; ) {
- GLuint start = i;
-
- /* Identify and emit contiguous rendered pixels
- */
- while (i < n && (!mask || mask[i]))
- i++;
-
- if (start < i)
- XMesaFillRectangle( dpy, buffer, gc,
- (int)(x+start), (int) y,
- (int)(i-start), 1);
-
- /* Eat up non-rendered pixels
- */
- while (i < n && !mask[i])
- i++;
- }
-}
-
-
-
-/*
- * Write a span of PF_TRUEDITHER pixels to a pixmap.
- */
-static void put_mono_row_TRUEDITHER_pixmap( PUT_MONO_ROW_ARGS )
-{
- const GLubyte *color = (const GLubyte *) value;
- GET_XRB(xrb);
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
- XMesaDisplay *dpy = xmesa->xm_visual->display;
- XMesaDrawable buffer = xrb->drawable;
- XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
- const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
- register GLuint i;
- int yy = YFLIP(xrb, y);
- for (i=0;i<n;i++,x++) {
- if (!mask || mask[i]) {
- unsigned long p;
- PACK_TRUEDITHER(p, x, yy, r, g, b);
- XMesaSetForeground( dpy, gc, p );
- XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) yy );
- }
- }
-}
-
-
-/*
- * Write a span of identical pixels to an XImage.
- */
-static void put_mono_row_ximage( PUT_MONO_ROW_ARGS )
-{
- const GLubyte *color = (const GLubyte *) value;
- GET_XRB(xrb);
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
- XMesaImage *img = xrb->ximage;
- register GLuint i;
- const unsigned long pixel = xmesa_color_to_pixel(ctx, color[RCOMP],
- color[GCOMP], color[BCOMP], color[ACOMP], xmesa->pixelformat);
- y = YFLIP(xrb, y);
- for (i=0;i<n;i++,x++) {
- if (!mask || mask[i]) {
- XMesaPutPixel( img, x, y, pixel );
- }
- }
-}
-
-
-/*
- * Write a span of identical PF_TRUEDITHER pixels to an XImage.
- */
-static void put_mono_row_TRUEDITHER_ximage( PUT_MONO_ROW_ARGS )
-{
- const GLubyte *color = (const GLubyte *) value;
- GET_XRB(xrb);
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
- XMesaImage *img = xrb->ximage;
- const GLint r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
- GLuint i;
- y = YFLIP(xrb, y);
- for (i=0;i<n;i++) {
- if (!mask || mask[i]) {
- unsigned long p;
- PACK_TRUEDITHER( p, x+i, y, r, g, b);
- XMesaPutPixel( img, x+i, y, p );
- }
- }
-}
-
-
-/*
- * Write a span of identical 8A8B8G8R pixels to an XImage.
- */
-static void put_mono_row_8A8B8G8R_ximage( PUT_MONO_ROW_ARGS )
-{
- const GLubyte *color = (const GLubyte *) value;
- GET_XRB(xrb);
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
- GLuint i, *ptr;
- const unsigned long pixel = xmesa_color_to_pixel(ctx, color[RCOMP],
- color[GCOMP], color[BCOMP], color[ACOMP], xmesa->pixelformat);
- ptr = PIXEL_ADDR4(xrb, x, y );
- for (i=0;i<n;i++) {
- if (!mask || mask[i]) {
- ptr[i] = pixel;
- }
- }
-}
-
-/*
- * Write a span of identical 8A8R8G8B pixels to an XImage.
- */
-static void put_mono_row_8A8R8G8B_ximage( PUT_MONO_ROW_ARGS )
-{
- const GLubyte *color = (const GLubyte *) value;
- GET_XRB(xrb);
- GLuint i, *ptr;
- XMesaContext xmesa = XMESA_CONTEXT(ctx);
- const unsigned long pixel = xmesa_color_to_pixel(ctx, color[RCOMP],
- color[GCOMP], color[BCOMP], color[ACOMP], xmesa->pixelformat);
- ptr = PIXEL_ADDR4(xrb, x, y );
- for (i=0;i<n;i++) {
- if (!mask || mask[i]) {
- ptr[i] = pixel;
- }
- }
-}
-
-
-/*
- * Write a span of identical 8R8G8B pixels to an XImage.
- */
-static void put_mono_row_8R8G8B_ximage( PUT_MONO_ROW_ARGS )
-{
- const GLubyte *color = (const GLubyte *) value;
- GET_XRB(xrb);
- const GLuint pixel = PACK_8R8G8B(color[RCOMP], color[GCOMP], color[BCOMP]);
- GLuint *ptr = PIXEL_ADDR4(xrb, x, y );
- GLuint i;
- for (i=0;i<n;i++) {
- if (!mask || mask[i]) {
- ptr[i] = pixel;
- }
- }
-}
-
-
-/*
- * Write a span of identical 8R8G8B pixels to an XImage.
- */
-static void put_mono_row_8R8G8B24_ximage( PUT_MONO_ROW_ARGS )
-{
- const GLubyte *color = (const GLubyte *) value;
- GET_XRB(xrb);
- const GLubyte r = color[RCOMP];
- const GLubyte g = color[GCOMP];
- const GLubyte b = color[BCOMP];
- GLuint i;
- bgr_t *ptr = PIXEL_ADDR3(xrb, x, y );
- for (i=0;i<n;i++) {
- if (!mask || mask[i]) {
- ptr[i].r = r;
- ptr[i].g = g;
- ptr[i].b = b;
- }
- }
-}
-
-
-/*
- * Write a span of identical PF_DITHER_5R6G5B pixels to an XImage.
- */
-static void put_mono_row_DITHER_5R6G5B_ximage( PUT_MONO_ROW_ARGS )
-{
- const GLubyte *color = (const GLubyte *) value;
- GET_XRB(xrb);
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- register GLushort *ptr = PIXEL_ADDR2(xrb, x, y );
- const GLint r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
- GLuint i;
- y = YFLIP(xrb, y);
- for (i=0;i<n;i++) {
- if (!mask || mask[i]) {
- PACK_TRUEDITHER(ptr[i], x+i, y, r, g, b);
- }
- }
-}
-
-
-
-/**********************************************************************/
-/*** Write MONO COLOR PIXELS functions ***/
-/**********************************************************************/
-
-#define PUT_MONO_VALUES_ARGS \
- struct gl_context *ctx, struct gl_renderbuffer *rb, \
- GLuint n, const GLint x[], const GLint y[], \
- const void *value, const GLubyte mask[]
-
-
-
-/*
- * Write an array of identical pixels to a pixmap.
- */
-static void put_mono_values_pixmap( PUT_MONO_VALUES_ARGS )
-{
- const GLubyte *color = (const GLubyte *) value;
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- GET_XRB(xrb);
- XMesaDisplay *dpy = xmesa->xm_visual->display;
- XMesaDrawable buffer = xrb->drawable;
- XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
- register GLuint i;
- const unsigned long pixel = xmesa_color_to_pixel(ctx, color[RCOMP],
- color[GCOMP], color[BCOMP], color[ACOMP], xmesa->pixelformat);
- XMesaSetForeground( xmesa->display, gc, pixel );
- for (i=0;i<n;i++) {
- if (mask[i]) {
- XMesaDrawPoint( dpy, buffer, gc,
- (int) x[i], (int) YFLIP(xrb, y[i]) );
- }
- }
-}
-
-
-/*
- * Write an array of PF_TRUEDITHER pixels to a pixmap.
- */
-static void put_mono_values_TRUEDITHER_pixmap( PUT_MONO_VALUES_ARGS )
-{
- const GLubyte *color = (const GLubyte *) value;
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- GET_XRB(xrb);
- XMesaDisplay *dpy = xmesa->xm_visual->display;
- XMesaDrawable buffer = xrb->drawable;
- XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
- register GLuint i;
- const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
- for (i=0;i<n;i++) {
- if (mask[i]) {
- unsigned long p;
- PACK_TRUEDITHER(p, x[i], y[i], r, g, b);
- XMesaSetForeground( dpy, gc, p );
- XMesaDrawPoint( dpy, buffer, gc,
- (int) x[i], (int) YFLIP(xrb, y[i]) );
- }
- }
-}
-
-
-/*
- * Write an array of identical pixels to an XImage.
- */
-static void put_mono_values_ximage( PUT_MONO_VALUES_ARGS )
-{
- const GLubyte *color = (const GLubyte *) value;
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- GET_XRB(xrb);
- XMesaImage *img = xrb->ximage;
- register GLuint i;
- const unsigned long pixel = xmesa_color_to_pixel(ctx, color[RCOMP],
- color[GCOMP], color[BCOMP], color[ACOMP], xmesa->pixelformat);
- for (i=0;i<n;i++) {
- if (mask[i]) {
- XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]), pixel );
- }
- }
-}
-
-
-/*
- * Write an array of identical TRUEDITHER pixels to an XImage.
- */
-static void put_mono_values_TRUEDITHER_ximage( PUT_MONO_VALUES_ARGS )
-{
- const GLubyte *color = (const GLubyte *) value;
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- GET_XRB(xrb);
- XMesaImage *img = xrb->ximage;
- register GLuint i;
- const int r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
- for (i=0;i<n;i++) {
- if (mask[i]) {
- unsigned long p;
- PACK_TRUEDITHER(p, x[i], YFLIP(xrb, y[i]), r, g, b);
- XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]), p );
- }
- }
-}
-
-
-
-/*
- * Write an array of identical 8A8B8G8R pixels to an XImage
- */
-static void put_mono_values_8A8B8G8R_ximage( PUT_MONO_VALUES_ARGS )
-{
- const GLubyte *color = (const GLubyte *) value;
- GET_XRB(xrb);
- const GLuint p = PACK_8A8B8G8R(color[RCOMP], color[GCOMP],
- color[BCOMP], color[ACOMP]);
- register GLuint i;
- for (i=0;i<n;i++) {
- if (mask[i]) {
- GLuint *ptr = PIXEL_ADDR4(xrb, x[i], y[i] );
- *ptr = p;
- }
- }
-}
-
-/*
- * Write an array of identical 8A8R8G8B pixels to an XImage
- */
-static void put_mono_values_8A8R8G8B_ximage( PUT_MONO_VALUES_ARGS )
-{
- const GLubyte *color = (const GLubyte *) value;
- GET_XRB(xrb);
- const GLuint p = PACK_8A8R8G8B(color[RCOMP], color[GCOMP],
- color[BCOMP], color[ACOMP]);
- register GLuint i;
- for (i=0;i<n;i++) {
- if (mask[i]) {
- GLuint *ptr = PIXEL_ADDR4(xrb, x[i], y[i] );
- *ptr = p;
- }
- }
-}
-
-/*
- * Write an array of identical 8R8G8B pixels to an XImage.
- */
-static void put_mono_values_8R8G8B_ximage( PUT_MONO_VALUES_ARGS )
-{
- const GLubyte *color = (const GLubyte *) value;
- GET_XRB(xrb);
- register GLuint i;
- const GLuint p = PACK_8R8G8B(color[RCOMP], color[GCOMP], color[BCOMP]);
- for (i=0;i<n;i++) {
- if (mask[i]) {
- GLuint *ptr = PIXEL_ADDR4(xrb, x[i], y[i] );
- *ptr = p;
- }
- }
-}
-
-
-/*
- * Write an array of identical 8R8G8B pixels to an XImage.
- */
-static void put_mono_values_8R8G8B24_ximage( PUT_MONO_VALUES_ARGS )
-{
- const GLubyte *color = (const GLubyte *) value;
- GET_XRB(xrb);
- const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
- register GLuint i;
- for (i=0;i<n;i++) {
- if (mask[i]) {
- bgr_t *ptr = PIXEL_ADDR3(xrb, x[i], y[i] );
- ptr->r = r;
- ptr->g = g;
- ptr->b = b;
- }
- }
-}
-
-
-/*
- * Write an array of identical PF_DITHER_5R6G5B pixels to an XImage.
- */
-static void put_mono_values_DITHER_5R6G5B_ximage( PUT_MONO_VALUES_ARGS )
-{
- const GLubyte *color = (const GLubyte *) value;
- GET_XRB(xrb);
- const XMesaContext xmesa = XMESA_CONTEXT(ctx);
- const int r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
- register GLuint i;
- for (i=0;i<n;i++) {
- if (mask[i]) {
- GLushort *ptr = PIXEL_ADDR2(xrb, x[i], y[i] );
- PACK_TRUEDITHER(*ptr, x[i], y[i], r, g, b);
- }
- }
-}
-
-
-
/**********************************************************************/
/***** Pixel reading *****/
/**********************************************************************/
if (pixmap) {
xrb->Base.PutRow = put_row_TRUECOLOR_pixmap;
xrb->Base.PutRowRGB = put_row_rgb_TRUECOLOR_pixmap;
- xrb->Base.PutMonoRow = put_mono_row_pixmap;
xrb->Base.PutValues = put_values_TRUECOLOR_pixmap;
- xrb->Base.PutMonoValues = put_mono_values_pixmap;
}
else {
xrb->Base.PutRow = put_row_TRUECOLOR_ximage;
xrb->Base.PutRowRGB = put_row_rgb_TRUECOLOR_ximage;
- xrb->Base.PutMonoRow = put_mono_row_ximage;
xrb->Base.PutValues = put_values_TRUECOLOR_ximage;
- xrb->Base.PutMonoValues = put_mono_values_ximage;
}
break;
case PF_Dither_True:
if (pixmap) {
xrb->Base.PutRow = put_row_TRUEDITHER_pixmap;
xrb->Base.PutRowRGB = put_row_rgb_TRUEDITHER_pixmap;
- xrb->Base.PutMonoRow = put_mono_row_TRUEDITHER_pixmap;
xrb->Base.PutValues = put_values_TRUEDITHER_pixmap;
- xrb->Base.PutMonoValues = put_mono_values_TRUEDITHER_pixmap;
}
else {
xrb->Base.PutRow = put_row_TRUEDITHER_ximage;
xrb->Base.PutRowRGB = put_row_rgb_TRUEDITHER_ximage;
- xrb->Base.PutMonoRow = put_mono_row_TRUEDITHER_ximage;
xrb->Base.PutValues = put_values_TRUEDITHER_ximage;
- xrb->Base.PutMonoValues = put_mono_values_TRUEDITHER_ximage;
}
break;
case PF_8A8B8G8R:
if (pixmap) {
xrb->Base.PutRow = put_row_8A8B8G8R_pixmap;
xrb->Base.PutRowRGB = put_row_rgb_8A8B8G8R_pixmap;
- xrb->Base.PutMonoRow = put_mono_row_pixmap;
xrb->Base.PutValues = put_values_8A8B8G8R_pixmap;
- xrb->Base.PutMonoValues = put_mono_values_pixmap;
}
else {
xrb->Base.PutRow = put_row_8A8B8G8R_ximage;
xrb->Base.PutRowRGB = put_row_rgb_8A8B8G8R_ximage;
- xrb->Base.PutMonoRow = put_mono_row_8A8B8G8R_ximage;
xrb->Base.PutValues = put_values_8A8B8G8R_ximage;
- xrb->Base.PutMonoValues = put_mono_values_8A8B8G8R_ximage;
}
break;
case PF_8A8R8G8B:
if (pixmap) {
xrb->Base.PutRow = put_row_8A8R8G8B_pixmap;
xrb->Base.PutRowRGB = put_row_rgb_8A8R8G8B_pixmap;
- xrb->Base.PutMonoRow = put_mono_row_pixmap;
xrb->Base.PutValues = put_values_8A8R8G8B_pixmap;
- xrb->Base.PutMonoValues = put_mono_values_pixmap;
}
else {
xrb->Base.PutRow = put_row_8A8R8G8B_ximage;
xrb->Base.PutRowRGB = put_row_rgb_8A8R8G8B_ximage;
- xrb->Base.PutMonoRow = put_mono_row_8A8R8G8B_ximage;
xrb->Base.PutValues = put_values_8A8R8G8B_ximage;
- xrb->Base.PutMonoValues = put_mono_values_8A8R8G8B_ximage;
}
break;
case PF_8R8G8B:
if (pixmap) {
xrb->Base.PutRow = put_row_8R8G8B_pixmap;
xrb->Base.PutRowRGB = put_row_rgb_8R8G8B_pixmap;
- xrb->Base.PutMonoRow = put_mono_row_pixmap;
xrb->Base.PutValues = put_values_8R8G8B_pixmap;
- xrb->Base.PutMonoValues = put_mono_values_pixmap;
}
else {
xrb->Base.PutRow = put_row_8R8G8B_ximage;
xrb->Base.PutRowRGB = put_row_rgb_8R8G8B_ximage;
- xrb->Base.PutMonoRow = put_mono_row_8R8G8B_ximage;
xrb->Base.PutValues = put_values_8R8G8B_ximage;
- xrb->Base.PutMonoValues = put_mono_values_8R8G8B_ximage;
}
break;
case PF_8R8G8B24:
if (pixmap) {
xrb->Base.PutRow = put_row_8R8G8B24_pixmap;
xrb->Base.PutRowRGB = put_row_rgb_8R8G8B24_pixmap;
- xrb->Base.PutMonoRow = put_mono_row_pixmap;
xrb->Base.PutValues = put_values_8R8G8B24_pixmap;
- xrb->Base.PutMonoValues = put_mono_values_pixmap;
}
else {
xrb->Base.PutRow = put_row_8R8G8B24_ximage;
xrb->Base.PutRowRGB = put_row_rgb_8R8G8B24_ximage;
- xrb->Base.PutMonoRow = put_mono_row_8R8G8B24_ximage;
xrb->Base.PutValues = put_values_8R8G8B24_ximage;
- xrb->Base.PutMonoValues = put_mono_values_8R8G8B24_ximage;
}
break;
case PF_5R6G5B:
if (pixmap) {
xrb->Base.PutRow = put_row_5R6G5B_pixmap;
xrb->Base.PutRowRGB = put_row_rgb_5R6G5B_pixmap;
- xrb->Base.PutMonoRow = put_mono_row_pixmap;
xrb->Base.PutValues = put_values_5R6G5B_pixmap;
- xrb->Base.PutMonoValues = put_mono_values_pixmap;
}
else {
xrb->Base.PutRow = put_row_5R6G5B_ximage;
xrb->Base.PutRowRGB = put_row_rgb_5R6G5B_ximage;
- xrb->Base.PutMonoRow = put_mono_row_ximage;
xrb->Base.PutValues = put_values_5R6G5B_ximage;
- xrb->Base.PutMonoValues = put_mono_values_ximage;
}
break;
case PF_Dither_5R6G5B:
if (pixmap) {
xrb->Base.PutRow = put_row_DITHER_5R6G5B_pixmap;
xrb->Base.PutRowRGB = put_row_rgb_DITHER_5R6G5B_pixmap;
- xrb->Base.PutMonoRow = put_mono_row_TRUEDITHER_pixmap;
xrb->Base.PutValues = put_values_DITHER_5R6G5B_pixmap;
- xrb->Base.PutMonoValues = put_mono_values_TRUEDITHER_pixmap;
}
else {
xrb->Base.PutRow = put_row_DITHER_5R6G5B_ximage;
xrb->Base.PutRowRGB = put_row_rgb_DITHER_5R6G5B_ximage;
- xrb->Base.PutMonoRow = put_mono_row_DITHER_5R6G5B_ximage;
xrb->Base.PutValues = put_values_DITHER_5R6G5B_ximage;
- xrb->Base.PutMonoValues = put_mono_values_DITHER_5R6G5B_ximage;
}
break;
default:
GLint x, GLint y, const void *values, const GLubyte *mask);
- /* Put/Write a row of identical values.
- * The values will be of format _BaseFormat and type DataType.
- */
- void (*PutMonoRow)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *value, const GLubyte *mask);
-
/* Put/Write values at arbitrary locations.
* The values will be of format _BaseFormat and type DataType.
*/
void (*PutValues)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
const GLint x[], const GLint y[], const void *values,
const GLubyte *mask);
- /* Put/Write identical values at arbitrary locations.
- * The values will be of format _BaseFormat and type DataType.
- */
- void (*PutMonoValues)(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- const void *value, const GLubyte *mask);
};
rb->GetValues = NULL;
rb->PutRow = NULL;
rb->PutRowRGB = NULL;
- rb->PutMonoRow = NULL;
rb->PutValues = NULL;
- rb->PutMonoValues = NULL;
}
}
}
-static void
-put_mono_row_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, GLuint count,
- GLint x, GLint y, const void *value, const GLubyte *mask)
-{
- struct gl_renderbuffer *dsrb = z24rb->Wrapped;
- GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y);
- ASSERT(z24rb->DataType == GL_UNSIGNED_INT);
- ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
- if (dst) {
- /* direct access */
- GLuint i;
- if (dsrb->Format == MESA_FORMAT_Z24_S8) {
- const GLuint shiftedVal = *((GLuint *) value) << 8;
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- dst[i] = shiftedVal | (dst[i] & 0xff);
- }
- }
- }
- else {
- const GLuint shiftedVal = *((GLuint *) value);
- assert(dsrb->Format == MESA_FORMAT_S8_Z24);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- dst[i] = shiftedVal | (dst[i] & 0xff000000);
- }
- }
- }
- }
- else {
- /* get, modify, put */
- GLuint temp[MAX_WIDTH], i;
- dsrb->GetRow(ctx, dsrb, count, x, y, temp);
- if (dsrb->Format == MESA_FORMAT_Z24_S8) {
- const GLuint shiftedVal = *((GLuint *) value) << 8;
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- temp[i] = shiftedVal | (temp[i] & 0xff);
- }
- }
- }
- else {
- const GLuint shiftedVal = *((GLuint *) value);
- assert(dsrb->Format == MESA_FORMAT_S8_Z24);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- temp[i] = shiftedVal | (temp[i] & 0xff000000);
- }
- }
- }
- dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask);
- }
-}
static void
put_values_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb, GLuint count,
}
}
-static void
-put_mono_values_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb,
- GLuint count, const GLint x[], const GLint y[],
- const void *value, const GLubyte *mask)
-{
- struct gl_renderbuffer *dsrb = z24rb->Wrapped;
- GLuint temp[MAX_WIDTH], i;
- /* get, modify, put */
- dsrb->GetValues(ctx, dsrb, count, x, y, temp);
- if (dsrb->Format == MESA_FORMAT_Z24_S8) {
- const GLuint shiftedVal = *((GLuint *) value) << 8;
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- temp[i] = shiftedVal | (temp[i] & 0xff);
- }
- }
- }
- else {
- const GLuint shiftedVal = *((GLuint *) value);
- assert(dsrb->Format == MESA_FORMAT_S8_Z24);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- temp[i] = shiftedVal | (temp[i] & 0xff000000);
- }
- }
- }
- dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask);
-}
-
/**
* Wrap the given GL_DEPTH_STENCIL renderbuffer so that it acts like
z24rb->GetValues = get_values_z24;
z24rb->PutRow = put_row_z24;
z24rb->PutRowRGB = NULL;
- z24rb->PutMonoRow = put_mono_row_z24;
z24rb->PutValues = put_values_z24;
- z24rb->PutMonoValues = put_mono_values_z24;
return z24rb;
}
}
}
-static void
-put_mono_row_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count,
- GLint x, GLint y, const void *value, const GLubyte *mask)
-{
- struct gl_renderbuffer *dsrb = z32frb->Wrapped;
- GLfloat *dst = (GLfloat *) dsrb->GetPointer(ctx, dsrb, x, y);
- ASSERT(z32frb->DataType == GL_FLOAT);
- ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
- ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
- if (dst) {
- /* direct access */
- GLuint i;
- const GLfloat val = *(GLfloat*)value;
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- dst[i*2] = val;
- }
- }
- }
- else {
- /* get, modify, put */
- GLfloat temp[MAX_WIDTH*2];
- GLuint i;
- const GLfloat val = *(GLfloat *)value;
- dsrb->GetRow(ctx, dsrb, count, x, y, temp);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- temp[i*2] = val;
- }
- }
- dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask);
- }
-}
static void
put_values_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb, GLuint count,
}
}
-static void
-put_mono_values_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb,
- GLuint count, const GLint x[], const GLint y[],
- const void *value, const GLubyte *mask)
-{
- struct gl_renderbuffer *dsrb = z32frb->Wrapped;
- GLfloat temp[MAX_WIDTH*2];
- GLuint i;
- const GLfloat val = *(GLfloat *)value;
- ASSERT(z32frb->DataType == GL_FLOAT);
- ASSERT(dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
- ASSERT(dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
- /* get, modify, put */
- dsrb->GetValues(ctx, dsrb, count, x, y, temp);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- temp[i*2] = val;
- }
- }
- dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask);
-}
-
/**
* Wrap the given GL_DEPTH_STENCIL renderbuffer so that it acts like
z32frb->GetValues = get_values_z32f;
z32frb->PutRow = put_row_z32f;
z32frb->PutRowRGB = NULL;
- z32frb->PutMonoRow = put_mono_row_z32f;
z32frb->PutValues = put_values_z32f;
- z32frb->PutMonoValues = put_mono_values_z32f;
return z32frb;
}
}
}
-static void
-put_mono_row_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count,
- GLint x, GLint y, const void *value, const GLubyte *mask)
-{
- struct gl_renderbuffer *dsrb = s8rb->Wrapped;
- const GLubyte val = *((GLubyte *) value);
- GLuint *dst = (GLuint *) dsrb->GetPointer(ctx, dsrb, x, y);
- ASSERT(s8rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT ||
- dsrb->DataType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
- if (dst) {
- /* direct access */
- GLuint i;
- if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- dst[i*2+1] = val;
- }
- }
- }
- else if (dsrb->Format == MESA_FORMAT_Z24_S8) {
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- dst[i] = (dst[i] & 0xffffff00) | val;
- }
- }
- }
- else {
- assert(dsrb->Format == MESA_FORMAT_S8_Z24);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- dst[i] = (dst[i] & 0xffffff) | (val << 24);
- }
- }
- }
- }
- else {
- /* get, modify, put */
- GLuint temp[MAX_WIDTH*2], i;
- dsrb->GetRow(ctx, dsrb, count, x, y, temp);
- if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- temp[i*2+1] = val;
- }
- }
- }
- else if (dsrb->Format == MESA_FORMAT_Z24_S8) {
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- temp[i] = (temp[i] & 0xffffff00) | val;
- }
- }
- }
- else {
- assert(dsrb->Format == MESA_FORMAT_S8_Z24);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- temp[i] = (temp[i] & 0xffffff) | (val << 24);
- }
- }
- }
- dsrb->PutRow(ctx, dsrb, count, x, y, temp, mask);
- }
-}
static void
put_values_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count,
}
}
-static void
-put_mono_values_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint count,
- const GLint x[], const GLint y[],
- const void *value, const GLubyte *mask)
-{
- struct gl_renderbuffer *dsrb = s8rb->Wrapped;
- GLuint temp[MAX_WIDTH*2], i;
- const GLubyte val = *((GLubyte *) value);
- /* get, modify, put */
- dsrb->GetValues(ctx, dsrb, count, x, y, temp);
- if (dsrb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- temp[i*2+1] = val;
- }
- }
- }
- else if (dsrb->Format == MESA_FORMAT_Z24_S8) {
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- temp[i] = (temp[i] & 0xffffff00) | val;
- }
- }
- }
- else {
- assert(dsrb->Format == MESA_FORMAT_S8_Z24);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- temp[i] = (temp[i] & 0xffffff) | (val << 24);
- }
- }
- }
- dsrb->PutValues(ctx, dsrb, count, x, y, temp, mask);
-}
-
/**
* Wrap the given GL_DEPTH_STENCIL renderbuffer so that it acts like
s8rb->GetValues = get_values_s8;
s8rb->PutRow = put_row_s8;
s8rb->PutRowRGB = NULL;
- s8rb->PutMonoRow = put_mono_row_s8;
s8rb->PutValues = put_values_s8;
- s8rb->PutMonoValues = put_mono_values_s8;
return s8rb;
}
}
}
-static void
-put_mono_row_generic(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, GLint x, GLint y,
- const void *value, const GLubyte *mask)
-{
- void *row = rb->GetPointer(ctx, rb, x, y);
- int format_bytes = _mesa_get_format_bytes(rb->Format) / sizeof(GLfloat);
- unsigned int i;
-
- if (mask) {
- for (i = 0; i < count; i++) {
- char *dst = (char *) row + i * format_bytes;
- if (mask[i]) {
- memcpy(dst, value, format_bytes);
- }
- }
- }
- else {
- for (i = 0; i < count; i++) {
- char *dst = (char *) row + i * format_bytes;
- memcpy(dst, value, format_bytes);
- }
- }
-}
-
static void
put_values_generic(struct gl_context *ctx, struct gl_renderbuffer *rb,
}
-static void
-put_mono_values_generic(struct gl_context *ctx,
- struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- const void *value, const GLubyte *mask)
-{
- int format_bytes = _mesa_get_format_bytes(rb->Format) / sizeof(GLfloat);
- unsigned int i;
-
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- void *dst = rb->GetPointer(ctx, rb, x[i], y[i]);
- memcpy(dst, value, format_bytes);
- }
- }
-}
/**********************************************************************
* Functions for buffers of 1 X GLubyte values.
}
-static void
-put_mono_row_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *value, const GLubyte *mask)
-{
- const GLubyte val = *((const GLubyte *) value);
- GLubyte *dst = (GLubyte *) rb->Data + y * rb->RowStride + x;
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- if (mask) {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i] = val;
- }
- }
- }
- else {
- GLuint i;
- for (i = 0; i < count; i++) {
- dst[i] = val;
- }
- }
-}
-
-
static void
put_values_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
const GLint x[], const GLint y[],
}
-static void
-put_mono_values_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[],
- const void *value, const GLubyte *mask)
-{
- const GLubyte val = *((const GLubyte *) value);
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLubyte *dst = (GLubyte *) rb->Data + y[i] * rb->RowStride + x[i];
- *dst = val;
- }
- }
-}
-
-
/**********************************************************************
* Functions for buffers of 1 X GLushort values.
* Typically depth/Z.
}
-static void
-put_mono_row_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *value, const GLubyte *mask)
-{
- const GLushort val = *((const GLushort *) value);
- GLushort *dst = (GLushort *) rb->Data + y * rb->RowStride + x;
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
- if (mask) {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i] = val;
- }
- }
- }
- else {
- GLuint i;
- for (i = 0; i < count; i++) {
- dst[i] = val;
- }
- }
-}
-
-
static void
put_values_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
const GLint x[], const GLint y[], const void *values,
}
-static void
-put_mono_values_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- const void *value, const GLubyte *mask)
-{
- const GLushort val = *((const GLushort *) value);
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
- if (mask) {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- GLushort *dst = (GLushort *) rb->Data + y[i] * rb->RowStride + x[i];
- *dst = val;
- }
- }
- }
- else {
- GLuint i;
- for (i = 0; i < count; i++) {
- GLushort *dst = (GLushort *) rb->Data + y[i] * rb->RowStride + x[i];
- *dst = val;
- }
- }
-}
-
-
/**********************************************************************
* Functions for buffers of 1 X GLuint values.
* Typically depth/Z or color index.
}
-static void
-put_mono_row_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *value, const GLubyte *mask)
-{
- const GLuint val = *((const GLuint *) value);
- GLuint *dst = (GLuint *) rb->Data + y * rb->RowStride + x;
- ASSERT(rb->DataType == GL_UNSIGNED_INT ||
- rb->DataType == GL_UNSIGNED_INT_24_8_EXT);
- if (mask) {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i] = val;
- }
- }
- }
- else {
- GLuint i;
- for (i = 0; i < count; i++) {
- dst[i] = val;
- }
- }
-}
-
-
static void
put_values_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
const GLint x[], const GLint y[], const void *values,
}
-static void
-put_mono_values_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- const GLint x[], const GLint y[], const void *value,
- const GLubyte *mask)
-{
- const GLuint val = *((const GLuint *) value);
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_INT ||
- rb->DataType == GL_UNSIGNED_INT_24_8_EXT);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLuint *dst = (GLuint *) rb->Data + y[i] * rb->RowStride + x[i];
- *dst = val;
- }
- }
-}
-
-
/**********************************************************************
* Functions for buffers of 3 X GLubyte (or GLbyte) values.
* Typically color buffers.
}
-static void
-put_mono_row_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *value, const GLubyte *mask)
-{
- /* note: incoming value is RGB+A! */
- const GLubyte val0 = ((const GLubyte *) value)[0];
- const GLubyte val1 = ((const GLubyte *) value)[1];
- const GLubyte val2 = ((const GLubyte *) value)[2];
- GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->RowStride + x);
- ASSERT(rb->Format == MESA_FORMAT_RGB888);
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- if (!mask && val0 == val1 && val1 == val2) {
- /* optimized case */
- memset(dst, val0, 3 * count);
- }
- else {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- dst[i * 3 + 0] = val0;
- dst[i * 3 + 1] = val1;
- dst[i * 3 + 2] = val2;
- }
- }
- }
-}
-
-
static void
put_values_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
const GLint x[], const GLint y[], const void *values,
}
-static void
-put_mono_values_ubyte3(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- const void *value, const GLubyte *mask)
-{
- /* note: incoming value is RGB+A! */
- const GLubyte val0 = ((const GLubyte *) value)[0];
- const GLubyte val1 = ((const GLubyte *) value)[1];
- const GLubyte val2 = ((const GLubyte *) value)[2];
- GLuint i;
- ASSERT(rb->Format == MESA_FORMAT_RGB888);
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLubyte *dst = ((GLubyte *) rb->Data) +
- 3 * (y[i] * rb->RowStride + x[i]);
- dst[0] = val0;
- dst[1] = val1;
- dst[2] = val2;
- }
- }
-}
-
-
/**********************************************************************
* Functions for buffers of 4 X GLubyte (or GLbyte) values.
* Typically color buffers.
}
-static void
-put_mono_row_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *value, const GLubyte *mask)
-{
- /* treat 4*GLubyte as 1*GLuint */
- const GLuint val = *((const GLuint *) value);
- GLuint *dst = (GLuint *) rb->Data + (y * rb->RowStride + x);
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(rb->Format == MESA_FORMAT_RGBA8888 ||
- rb->Format == MESA_FORMAT_RGBA8888_REV);
- if (!mask && val == 0) {
- /* common case */
- memset(dst, 0, count * 4 * sizeof(GLubyte));
- }
- else {
- /* general case */
- if (mask) {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i] = val;
- }
- }
- }
- else {
- GLuint i;
- for (i = 0; i < count; i++) {
- dst[i] = val;
- }
- }
- }
-}
-
-
static void
put_values_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
const GLint x[], const GLint y[], const void *values,
}
-static void
-put_mono_values_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- const void *value, const GLubyte *mask)
-{
- /* treat 4*GLubyte as 1*GLuint */
- const GLuint val = *((const GLuint *) value);
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(rb->Format == MESA_FORMAT_RGBA8888 ||
- rb->Format == MESA_FORMAT_RGBA8888_REV);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLuint *dst = (GLuint *) rb->Data + (y[i] * rb->RowStride + x[i]);
- *dst = val;
- }
- }
-}
-
-
/**********************************************************************
* Functions for buffers of 4 X GLushort (or GLshort) values.
* Typically accum buffer.
}
-static void
-put_mono_row_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *value, const GLubyte *mask)
-{
- const GLushort val0 = ((const GLushort *) value)[0];
- const GLushort val1 = ((const GLushort *) value)[1];
- const GLushort val2 = ((const GLushort *) value)[2];
- const GLushort val3 = ((const GLushort *) value)[3];
- GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->RowStride + x);
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
- if (!mask && val0 == 0 && val1 == 0 && val2 == 0 && val3 == 0) {
- /* common case for clearing accum buffer */
- memset(dst, 0, count * 4 * sizeof(GLushort));
- }
- else {
- GLuint i;
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- dst[i * 4 + 0] = val0;
- dst[i * 4 + 1] = val1;
- dst[i * 4 + 2] = val2;
- dst[i * 4 + 3] = val3;
- }
- }
- }
-}
-
-
static void
put_values_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
const GLint x[], const GLint y[], const void *values,
}
-static void
-put_mono_values_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- const void *value, const GLubyte *mask)
-{
- const GLushort val0 = ((const GLushort *) value)[0];
- const GLushort val1 = ((const GLushort *) value)[1];
- const GLushort val2 = ((const GLushort *) value)[2];
- const GLushort val3 = ((const GLushort *) value)[3];
- GLuint i;
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- GLushort *dst = ((GLushort *) rb->Data) +
- 4 * (y[i] * rb->RowStride + x[i]);
- dst[0] = val0;
- dst[1] = val1;
- dst[2] = val2;
- dst[3] = val3;
- }
- }
-}
-
/**********************************************************************
* Functions for MESA_FORMAT_R8.
*/
}
}
-static void
-put_mono_row_a_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, GLint x, GLint y,
- const void *value, const GLubyte *mask)
-{
- float *dst = rb->GetPointer(ctx, rb, x, y);
- const float *src = value;
- unsigned int i;
-
- if (mask) {
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- dst[i] = src[ACOMP];
- }
- }
- }
- else {
- for (i = 0; i < count; i++) {
- dst[i] = src[ACOMP];
- }
- }
-}
-
static void
put_values_a_float32(struct gl_context *ctx, struct gl_renderbuffer *rb,
GLuint count, const GLint x[], const GLint y[],
}
}
-static void
-put_mono_values_a_float32(struct gl_context *ctx,
- struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- const void *value, const GLubyte *mask)
-{
- const float *src = value;
- unsigned int i;
-
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- float *dst = rb->GetPointer(ctx, rb, x[i], y[i]);
- *dst = src[ACOMP];
- }
- }
-}
-
/**********************************************************************
* Functions for MESA_FORMAT_R_FLOAT32.
*/
rb->GetValues = get_values_ubyte3;
rb->PutRow = put_row_ubyte3;
rb->PutRowRGB = put_row_rgb_ubyte3;
- rb->PutMonoRow = put_mono_row_ubyte3;
rb->PutValues = put_values_ubyte3;
- rb->PutMonoValues = put_mono_values_ubyte3;
break;
case MESA_FORMAT_RGBA8888:
rb->GetValues = get_values_ubyte4;
rb->PutRow = put_row_ubyte4;
rb->PutRowRGB = put_row_rgb_ubyte4;
- rb->PutMonoRow = put_mono_row_ubyte4;
rb->PutValues = put_values_ubyte4;
- rb->PutMonoValues = put_mono_values_ubyte4;
break;
case MESA_FORMAT_R8:
rb->GetRow = get_row_r8;
rb->PutRow = put_row_generic;
rb->PutRowRGB = put_row_generic;
- rb->PutMonoRow = put_mono_row_generic;
rb->PutValues = put_values_generic;
- rb->PutMonoValues = put_mono_values_generic;
break;
case MESA_FORMAT_GR88:
rb->GetRow = get_row_rg88;
rb->PutRow = put_row_generic;
rb->PutRowRGB = put_row_generic;
- rb->PutMonoRow = put_mono_row_generic;
rb->PutValues = put_values_generic;
- rb->PutMonoValues = put_mono_values_generic;
break;
case MESA_FORMAT_R16:
rb->GetRow = get_row_r16;
rb->PutRow = put_row_generic;
rb->PutRowRGB = put_row_generic;
- rb->PutMonoRow = put_mono_row_generic;
rb->PutValues = put_values_generic;
- rb->PutMonoValues = put_mono_values_generic;
break;
case MESA_FORMAT_RG1616:
rb->GetRow = get_row_rg1616;
rb->PutRow = put_row_generic;
rb->PutRowRGB = put_row_generic;
- rb->PutMonoRow = put_mono_row_generic;
rb->PutValues = put_values_generic;
- rb->PutMonoValues = put_mono_values_generic;
break;
case MESA_FORMAT_SIGNED_RGBA_16:
rb->GetValues = get_values_ushort4;
rb->PutRow = put_row_ushort4;
rb->PutRowRGB = put_row_rgb_ushort4;
- rb->PutMonoRow = put_mono_row_ushort4;
rb->PutValues = put_values_ushort4;
- rb->PutMonoValues = put_mono_values_ushort4;
break;
case MESA_FORMAT_S8:
rb->GetValues = get_values_ubyte;
rb->PutRow = put_row_ubyte;
rb->PutRowRGB = NULL;
- rb->PutMonoRow = put_mono_row_ubyte;
rb->PutValues = put_values_ubyte;
- rb->PutMonoValues = put_mono_values_ubyte;
break;
case MESA_FORMAT_Z16:
rb->GetValues = get_values_ushort;
rb->PutRow = put_row_ushort;
rb->PutRowRGB = NULL;
- rb->PutMonoRow = put_mono_row_ushort;
rb->PutValues = put_values_ushort;
- rb->PutMonoValues = put_mono_values_ushort;
break;
case MESA_FORMAT_Z32:
rb->GetValues = get_values_uint;
rb->PutRow = put_row_uint;
rb->PutRowRGB = NULL;
- rb->PutMonoRow = put_mono_row_uint;
rb->PutValues = put_values_uint;
- rb->PutMonoValues = put_mono_values_uint;
break;
case MESA_FORMAT_Z24_S8:
rb->GetValues = get_values_uint;
rb->PutRow = put_row_uint;
rb->PutRowRGB = NULL;
- rb->PutMonoRow = put_mono_row_uint;
rb->PutValues = put_values_uint;
- rb->PutMonoValues = put_mono_values_uint;
break;
case MESA_FORMAT_RGBA_FLOAT32:
rb->GetValues = get_values_generic;
rb->PutRow = put_row_generic;
rb->PutRowRGB = NULL;
- rb->PutMonoRow = put_mono_row_generic;
rb->PutValues = put_values_generic;
- rb->PutMonoValues = put_mono_values_generic;
break;
case MESA_FORMAT_INTENSITY_FLOAT32:
rb->GetValues = get_values_i_float32;
rb->PutRow = put_row_generic;
rb->PutRowRGB = NULL;
- rb->PutMonoRow = put_mono_row_generic;
rb->PutValues = put_values_generic;
- rb->PutMonoValues = put_mono_values_generic;
break;
case MESA_FORMAT_LUMINANCE_FLOAT32:
rb->GetValues = get_values_l_float32;
rb->PutRow = put_row_generic;
rb->PutRowRGB = NULL;
- rb->PutMonoRow = put_mono_row_generic;
rb->PutValues = put_values_generic;
- rb->PutMonoValues = put_mono_values_generic;
break;
case MESA_FORMAT_ALPHA_FLOAT32:
rb->GetValues = get_values_a_float32;
rb->PutRow = put_row_a_float32;
rb->PutRowRGB = NULL;
- rb->PutMonoRow = put_mono_row_a_float32;
rb->PutValues = put_values_a_float32;
- rb->PutMonoValues = put_mono_values_a_float32;
break;
case MESA_FORMAT_RG_FLOAT32:
rb->GetValues = get_values_rg_float32;
rb->PutRow = put_row_generic;
rb->PutRowRGB = NULL;
- rb->PutMonoRow = put_mono_row_generic;
rb->PutValues = put_values_generic;
- rb->PutMonoValues = put_mono_values_generic;
break;
case MESA_FORMAT_R_FLOAT32:
rb->GetValues = get_values_r_float32;
rb->PutRow = put_row_generic;
rb->PutRowRGB = NULL;
- rb->PutMonoRow = put_mono_row_generic;
rb->PutValues = put_values_generic;
- rb->PutMonoValues = put_mono_values_generic;
break;
default:
ASSERT(rb->GetRow);
ASSERT(rb->GetValues);
ASSERT(rb->PutRow);
- ASSERT(rb->PutMonoRow);
ASSERT(rb->PutValues);
- ASSERT(rb->PutMonoValues);
/* free old buffer storage */
if (rb->Data) {
/*
* Templates for the span/pixel-array write/read functions called via
- * the gl_renderbuffer's GetRow, GetValues, PutRow, PutMonoRow, PutValues
- * and PutMonoValues functions.
+ * the gl_renderbuffer's GetRow, GetValues, PutRow, and PutValues.
*
* Define the following macros before including this file:
* NAME(BASE) to generate the function name (i.e. add prefix or suffix)
}
-static void
-NAME(put_mono_row)( struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, GLint x, GLint y,
- const void *value, const GLubyte mask[] )
-{
-#ifdef SPAN_VARS
- SPAN_VARS
-#endif
- const RB_TYPE *src = (const RB_TYPE *) value;
- GLuint i;
- INIT_PIXEL_PTR(pixel, x, y);
- if (mask) {
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- STORE_PIXEL(pixel, x + i, y, src);
- }
- INC_PIXEL_PTR(pixel);
- }
- }
- else {
- for (i = 0; i < count; i++) {
- STORE_PIXEL(pixel, x + i, y, src);
- INC_PIXEL_PTR(pixel);
- }
- }
- (void) rb;
- (void) ctx;
-}
-
-
static void
NAME(put_values)( struct gl_context *ctx, struct gl_renderbuffer *rb,
GLuint count, const GLint x[], const GLint y[],
}
-static void
-NAME(put_mono_values)( struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- const void *value, const GLubyte mask[] )
-{
-#ifdef SPAN_VARS
- SPAN_VARS
-#endif
- const RB_TYPE *src = (const RB_TYPE *) value;
- GLuint i;
- ASSERT(mask);
- for (i = 0; i < count; i++) {
- if (mask[i]) {
- INIT_PIXEL_PTR(pixel, x[i], y[i]);
- STORE_PIXEL(pixel, x[i], y[i], src);
- }
- }
- (void) rb;
- (void) ctx;
-}
-
-
#undef NAME
#undef RB_TYPE
#undef RB_COMPONENTS
}
-static void
-texture_put_mono_row(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, const void *value, const GLubyte *mask)
-{
- struct texture_renderbuffer *trb = texture_renderbuffer(rb);
- const GLint z = trb->Zoffset;
- GLuint i;
-
- y += trb->Yoffset;
-
- if (rb->DataType == CHAN_TYPE) {
- const GLchan *rgba = (const GLchan *) value;
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- trb->Store(trb->TexImage, x + i, y, z, rgba);
- }
- }
- }
- else if (rb->DataType == GL_UNSIGNED_SHORT) {
- const GLushort zValue = *((const GLushort *) value);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- trb->Store(trb->TexImage, x + i, y, z, &zValue);
- }
- }
- }
- else if (rb->DataType == GL_UNSIGNED_INT) {
- const GLuint zValue = *((const GLuint *) value);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- trb->Store(trb->TexImage, x + i, y, z, &zValue);
- }
- }
- }
- else if (rb->DataType == GL_UNSIGNED_INT_24_8_EXT) {
- const GLuint zValue = *((const GLuint *) value);
- const GLfloat flt = (GLfloat) ((zValue >> 8) * (1.0 / 0xffffff));
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- trb->Store(trb->TexImage, x + i, y, z, &flt);
- }
- }
- }
- else if (rb->DataType == GL_UNSIGNED_INT_8_24_REV_MESA) {
- const GLuint zValue = *((const GLuint *) value);
- const GLfloat flt = (GLfloat) ((zValue & 0xffffff) * (1.0 / 0xffffff));
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- trb->Store(trb->TexImage, x + i, y, z, &flt);
- }
- }
- }
- else {
- _mesa_problem(ctx, "invalid rb->DataType in texture_put_mono_row");
- }
-}
-
-
static void
texture_put_values(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
const GLint x[], const GLint y[], const void *values,
}
-static void
-texture_put_mono_values(struct gl_context *ctx, struct gl_renderbuffer *rb,
- GLuint count, const GLint x[], const GLint y[],
- const void *value, const GLubyte *mask)
-{
- struct texture_renderbuffer *trb = texture_renderbuffer(rb);
- const GLint z = trb->Zoffset;
- GLuint i;
-
- if (rb->DataType == CHAN_TYPE) {
- const GLchan *rgba = (const GLchan *) value;
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, rgba);
- }
- }
- }
- else if (rb->DataType == GL_UNSIGNED_INT) {
- const GLuint zValue = *((const GLuint *) value);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, &zValue);
- }
- }
- }
- else if (rb->DataType == GL_UNSIGNED_SHORT) {
- const GLushort zValue = *((const GLushort *) value);
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, &zValue);
- }
- }
- }
- else if (rb->DataType == GL_UNSIGNED_INT_24_8_EXT) {
- const GLuint zValue = *((const GLuint *) value);
- const GLfloat flt = (GLfloat) ((zValue >> 8) * (1.0 / 0xffffff));
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, &flt);
- }
- }
- }
- else if (rb->DataType == GL_UNSIGNED_INT_8_24_REV_MESA) {
- const GLuint zValue = *((const GLuint *) value);
- const GLfloat flt = (GLfloat) ((zValue & 0xffffff) * (1.0 / 0xffffff));
- for (i = 0; i < count; i++) {
- if (!mask || mask[i]) {
- trb->Store(trb->TexImage, x[i], y[i] + trb->Yoffset, z, &flt);
- }
- }
- }
- else {
- _mesa_problem(ctx, "invalid rb->DataType in texture_put_mono_values");
- }
-}
-
-
static void
store_nop(struct swrast_texture_image *texImage,
GLint col, GLint row, GLint img,
trb->Base.GetValues = texture_get_values;
trb->Base.PutRow = texture_put_row;
trb->Base.PutRowRGB = texture_put_row_rgb;
- trb->Base.PutMonoRow = texture_put_mono_row;
trb->Base.PutValues = texture_put_values;
- trb->Base.PutMonoValues = texture_put_mono_values;
/* update attachment point */
_mesa_reference_renderbuffer(&att->Renderbuffer, &(trb->Base));