summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/osmesa/osmesa.c23
-rw-r--r--src/mesa/drivers/windows/gdi/wmesa.c56
-rw-r--r--src/mesa/drivers/x11/xm_api.c5
-rw-r--r--src/mesa/drivers/x11/xm_buffer.c9
-rw-r--r--src/mesa/drivers/x11/xmesaP.h2
5 files changed, 71 insertions, 24 deletions
diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c
index 8afd0a71769..2ba3b81706c 100644
--- a/src/mesa/drivers/osmesa/osmesa.c
+++ b/src/mesa/drivers/osmesa/osmesa.c
@@ -601,6 +601,7 @@ osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
{
const OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
+ /* Note: we can ignoring internalFormat for "window-system" renderbuffers */
if (osmesa->format == OSMESA_RGBA) {
rb->GetRow = get_row_RGBA;
rb->GetValues = get_values_RGBA;
@@ -609,6 +610,10 @@ osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutMonoRow = put_mono_row_RGBA;
rb->PutValues = put_values_RGBA;
rb->PutMonoValues = put_mono_values_RGBA;
+ rb->RedBits =
+ rb->GreenBits =
+ rb->BlueBits =
+ rb->AlphaBits = 8 * sizeof(GLchan);
}
else if (osmesa->format == OSMESA_BGRA) {
rb->GetRow = get_row_BGRA;
@@ -618,6 +623,10 @@ osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutMonoRow = put_mono_row_BGRA;
rb->PutValues = put_values_BGRA;
rb->PutMonoValues = put_mono_values_BGRA;
+ rb->RedBits =
+ rb->GreenBits =
+ rb->BlueBits =
+ rb->AlphaBits = 8 * sizeof(GLchan);
}
else if (osmesa->format == OSMESA_ARGB) {
rb->GetRow = get_row_ARGB;
@@ -627,6 +636,10 @@ osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutMonoRow = put_mono_row_ARGB;
rb->PutValues = put_values_ARGB;
rb->PutMonoValues = put_mono_values_ARGB;
+ rb->RedBits =
+ rb->GreenBits =
+ rb->BlueBits =
+ rb->AlphaBits = 8 * sizeof(GLchan);
}
else if (osmesa->format == OSMESA_RGB) {
rb->GetRow = get_row_RGB;
@@ -636,6 +649,9 @@ osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutMonoRow = put_mono_row_RGB;
rb->PutValues = put_values_RGB;
rb->PutMonoValues = put_mono_values_RGB;
+ rb->RedBits =
+ rb->GreenBits =
+ rb->BlueBits = 8 * sizeof(GLchan);
}
else if (osmesa->format == OSMESA_BGR) {
rb->GetRow = get_row_BGR;
@@ -645,6 +661,9 @@ osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutMonoRow = put_mono_row_BGR;
rb->PutValues = put_values_BGR;
rb->PutMonoValues = put_mono_values_BGR;
+ rb->RedBits =
+ rb->GreenBits =
+ rb->BlueBits = 8 * sizeof(GLchan);
}
#if CHAN_TYPE == GL_UNSIGNED_BYTE
else if (osmesa->format == OSMESA_RGB_565) {
@@ -655,6 +674,9 @@ osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutMonoRow = put_mono_row_RGB_565;
rb->PutValues = put_values_RGB_565;
rb->PutMonoValues = put_mono_values_RGB_565;
+ rb->RedBits = 5;
+ rb->GreenBits = 6;
+ rb->BlueBits = 5;
}
#endif
else if (osmesa->format == OSMESA_COLOR_INDEX) {
@@ -664,6 +686,7 @@ osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->PutMonoRow = put_mono_row_CI;
rb->PutValues = put_values_CI;
rb->PutMonoValues = put_mono_values_CI;
+ rb->IndexBits = 8;
}
else {
_mesa_problem(ctx, "bad pixel format in osmesa renderbuffer_storage");
diff --git a/src/mesa/drivers/windows/gdi/wmesa.c b/src/mesa/drivers/windows/gdi/wmesa.c
index fe1ea69c6d1..789fe53c3db 100644
--- a/src/mesa/drivers/windows/gdi/wmesa.c
+++ b/src/mesa/drivers/windows/gdi/wmesa.c
@@ -432,12 +432,13 @@ static void clear(GLcontext *ctx,
#define FLIP(Y) (rb->Height - (Y) - 1)
-/* SINGLE BUFFER */
-
-/* These are slow, but work with all non-indexed visual types */
+/**
+ ** Front Buffer reading/writing
+ ** These are slow, but work with all non-indexed visual types.
+ **/
/* Write a horizontal span of RGBA color pixels with a boolean mask. */
-static void write_rgba_span_single(const GLcontext *ctx,
+static void write_rgba_span_front(const GLcontext *ctx,
struct gl_renderbuffer *rb,
GLuint n, GLint x, GLint y,
const GLubyte rgba[][4],
@@ -463,7 +464,7 @@ static void write_rgba_span_single(const GLcontext *ctx,
}
/* Write a horizontal span of RGB color pixels with a boolean mask. */
-static void write_rgb_span_single(const GLcontext *ctx,
+static void write_rgb_span_front(const GLcontext *ctx,
struct gl_renderbuffer *rb,
GLuint n, GLint x, GLint y,
const GLubyte rgb[][3],
@@ -492,7 +493,7 @@ static void write_rgb_span_single(const GLcontext *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_single(const GLcontext *ctx,
+static void write_mono_rgba_span_front(const GLcontext *ctx,
struct gl_renderbuffer *rb,
GLuint n, GLint x, GLint y,
const GLchan color[4],
@@ -517,7 +518,7 @@ static void write_mono_rgba_span_single(const GLcontext *ctx,
}
/* Write an array of RGBA pixels with a boolean mask. */
-static void write_rgba_pixels_single(const GLcontext *ctx,
+static void write_rgba_pixels_front(const GLcontext *ctx,
struct gl_renderbuffer *rb,
GLuint n,
const GLint x[], const GLint y[],
@@ -540,7 +541,7 @@ static void write_rgba_pixels_single(const GLcontext *ctx,
* Write an array of pixels with a boolean mask. The current color
* is used for all pixels.
*/
-static void write_mono_rgba_pixels_single(const GLcontext *ctx,
+static void write_mono_rgba_pixels_front(const GLcontext *ctx,
struct gl_renderbuffer *rb,
GLuint n,
const GLint x[], const GLint y[],
@@ -558,7 +559,7 @@ static void write_mono_rgba_pixels_single(const GLcontext *ctx,
}
/* Read a horizontal span of color pixels. */
-static void read_rgba_span_single(const GLcontext *ctx,
+static void read_rgba_span_front(const GLcontext *ctx,
struct gl_renderbuffer *rb,
GLuint n, GLint x, GLint y,
GLubyte rgba[][4] )
@@ -578,7 +579,7 @@ static void read_rgba_span_single(const GLcontext *ctx,
/* Read an array of color pixels. */
-static void read_rgba_pixels_single(const GLcontext *ctx,
+static void read_rgba_pixels_front(const GLcontext *ctx,
struct gl_renderbuffer *rb,
GLuint n, const GLint x[], const GLint y[],
GLubyte rgba[][4])
@@ -981,10 +982,16 @@ wmesa_renderbuffer_storage(GLcontext *ctx,
return GL_TRUE;
}
+
+/**
+ * Plug in the Get/PutRow/Values functions for a renderbuffer depending
+ * on if we're drawing to the front or back color buffer.
+ */
void wmesa_set_renderbuffer_funcs(struct gl_renderbuffer *rb, int pixelformat,
int double_buffer)
{
if (double_buffer) {
+ /* back buffer */
/* Picking the correct span functions is important because
* the DIB was allocated with the indicated depth. */
switch(pixelformat) {
@@ -996,6 +1003,9 @@ void wmesa_set_renderbuffer_funcs(struct gl_renderbuffer *rb, int pixelformat,
rb->PutMonoValues = write_mono_rgba_pixels_16;
rb->GetRow = read_rgba_span_16;
rb->GetValues = read_rgba_pixels_16;
+ rb->RedBits = 5;
+ rb->GreenBits = 6;
+ rb->BlueBits = 5;
break;
case PF_8R8G8B:
rb->PutRow = write_rgba_span_32;
@@ -1005,19 +1015,26 @@ void wmesa_set_renderbuffer_funcs(struct gl_renderbuffer *rb, int pixelformat,
rb->PutMonoValues = write_mono_rgba_pixels_32;
rb->GetRow = read_rgba_span_32;
rb->GetValues = read_rgba_pixels_32;
+ rb->RedBits = 8;
+ rb->GreenBits = 8;
+ rb->BlueBits = 8;
break;
default:
break;
}
}
- else { /* single buffer */
- rb->PutRow = write_rgba_span_single;
- rb->PutRowRGB = write_rgb_span_single;
- rb->PutMonoRow = write_mono_rgba_span_single;
- rb->PutValues = write_rgba_pixels_single;
- rb->PutMonoValues = write_mono_rgba_pixels_single;
- rb->GetRow = read_rgba_span_single;
- rb->GetValues = read_rgba_pixels_single;
+ else {
+ /* 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;
+ rb->RedBits = 8; /* XXX fix these (565?) */
+ rb->GreenBits = 8;
+ rb->BlueBits = 8;
}
}
@@ -1317,6 +1334,9 @@ void WMesaMakeCurrent(WMesaContext c, HDC hdc)
pwfb = wmesa_new_framebuffer(hdc, visual);
/* need a color renderbuffer */
+ /* XXX we need to make two renderbuffers if double-buffering,
+ * one for front color buffer and one for the back.
+ */
rb = wmesa_new_renderbuffer();
if (c->db_flag)
_mesa_add_renderbuffer(&pwfb->Base, BUFFER_BACK_LEFT, rb);
diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c
index 261ebb90458..d2e2c7137b5 100644
--- a/src/mesa/drivers/x11/xm_api.c
+++ b/src/mesa/drivers/x11/xm_api.c
@@ -355,15 +355,14 @@ alloc_xmesa_buffer(XMesaVisual vis, BufferType type, XMesaColormap cmap)
assert(!b->mesa_buffer.Attachment[BUFFER_BACK_LEFT].Renderbuffer);
/* front renderbuffer */
- b->frontxrb = xmesa_new_renderbuffer(NULL, 0, vis->mesa_visual.rgbMode,
+ b->frontxrb = xmesa_new_renderbuffer(NULL, 0, &vis->mesa_visual,
GL_FALSE);
_mesa_add_renderbuffer(&b->mesa_buffer, BUFFER_FRONT_LEFT,
&b->frontxrb->Base);
/* back renderbuffer */
if (vis->mesa_visual.doubleBufferMode) {
- b->backxrb = xmesa_new_renderbuffer(NULL, 0,
- vis->mesa_visual.rgbMode,
+ b->backxrb = xmesa_new_renderbuffer(NULL, 0, &vis->mesa_visual,
GL_TRUE);
/* determine back buffer implementation */
b->db_mode = vis->ximage_flag ? BACK_XIMAGE : BACK_PIXMAP;
diff --git a/src/mesa/drivers/x11/xm_buffer.c b/src/mesa/drivers/x11/xm_buffer.c
index 8067b648407..2f20b162a7f 100644
--- a/src/mesa/drivers/x11/xm_buffer.c
+++ b/src/mesa/drivers/x11/xm_buffer.c
@@ -107,7 +107,7 @@ xmesa_alloc_back_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
struct xmesa_renderbuffer *
-xmesa_new_renderbuffer(GLcontext *ctx, GLuint name, GLboolean rgbMode,
+xmesa_new_renderbuffer(GLcontext *ctx, GLuint name, const GLvisual *visual,
GLboolean backBuffer)
{
struct xmesa_renderbuffer *xrb = CALLOC_STRUCT(xmesa_renderbuffer);
@@ -121,15 +121,20 @@ xmesa_new_renderbuffer(GLcontext *ctx, GLuint name, GLboolean rgbMode,
else
xrb->Base.AllocStorage = xmesa_alloc_front_storage;
- if (rgbMode) {
+ if (visual->rgbMode) {
xrb->Base.InternalFormat = GL_RGBA;
xrb->Base._BaseFormat = GL_RGBA;
xrb->Base.DataType = GL_UNSIGNED_BYTE;
+ xrb->Base.RedBits = visual->redBits;
+ xrb->Base.GreenBits = visual->greenBits;
+ xrb->Base.BlueBits = visual->blueBits;
+ xrb->Base.AlphaBits = visual->alphaBits;
}
else {
xrb->Base.InternalFormat = GL_COLOR_INDEX;
xrb->Base._BaseFormat = GL_COLOR_INDEX;
xrb->Base.DataType = GL_UNSIGNED_INT;
+ xrb->Base.IndexBits = visual->indexBits;
}
/* only need to set Red/Green/EtcBits fields for user-created RBs */
}
diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h
index afba40ae034..9d4e6946090 100644
--- a/src/mesa/drivers/x11/xmesaP.h
+++ b/src/mesa/drivers/x11/xmesaP.h
@@ -496,7 +496,7 @@ extern const int xmesa_kernel1[16];
*/
extern struct xmesa_renderbuffer *
-xmesa_new_renderbuffer(GLcontext *ctx, GLuint name, GLboolean rgbMode,
+xmesa_new_renderbuffer(GLcontext *ctx, GLuint name, const GLvisual *visual,
GLboolean backBuffer);
extern unsigned long