/*
* Mesa 3-D graphics library
- * Version: 6.5.1
+ * Version: 7.1
*
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
#include "drivers/common/driverfuncs.h"
+/**
+ * Pixel formats we support:
+ */
#define PF_B8G8R8 1
#define PF_B8G8R8A8 2
#define PF_B5G6R5 3
#define PF_CI8 5
-/*
+/**
* Derived from Mesa's GLvisual class.
*/
struct GLFBDevVisualRec {
int pixelFormat;
};
-/*
+/**
* Derived from Mesa's GLframebuffer class.
*/
struct GLFBDevBufferRec {
GLuint bytesPerPixel;
};
-/*
+/**
* Derived from Mesa's GLcontext class.
*/
struct GLFBDevContextRec {
GLFBDevBufferPtr curBuffer;
};
-/*
+/**
* Derived from Mesa's gl_renderbuffer class.
*/
struct GLFBDevRenderbufferRec {
};
-
-#define GLFBDEV_CONTEXT(CTX) ((GLFBDevContextPtr) (CTX))
-#define GLFBDEV_BUFFER(BUF) ((GLFBDevBufferPtr) (BUF))
-
-
/**********************************************************************/
/* Internal device driver functions */
/**********************************************************************/
static void
get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
{
- const GLFBDevBufferPtr fbdevbuffer = GLFBDEV_BUFFER(buffer);
+ const GLFBDevBufferPtr fbdevbuffer = (GLFBDevBufferPtr) buffer;
*width = fbdevbuffer->var.xres;
*height = fbdevbuffer->var.yres;
}
/* ignored for now */
break;
case GLFBDEV_MULTISAMPLE:
- numSamples = attrib[1];
- attrib++;
+ numSamples = attrib[1];
+ attrib++;
break;
default:
/* unexpected token */
alphaBits = varInfo->transp.length;
if (fixInfo->visual == FB_VISUAL_TRUECOLOR ||
- fixInfo->visual == FB_VISUAL_DIRECTCOLOR) {
- if(varInfo->bits_per_pixel == 24
- && varInfo->red.offset == 16
- && varInfo->green.offset == 8
- && varInfo->blue.offset == 0)
- vis->pixelFormat = PF_B8G8R8;
-
- else if(varInfo->bits_per_pixel == 32
- && varInfo->red.offset == 16
- && varInfo->green.offset == 8
- && varInfo->blue.offset == 0)
- vis->pixelFormat = PF_B8G8R8A8;
-
- else if(varInfo->bits_per_pixel == 16
- && varInfo->red.offset == 11
- && varInfo->green.offset == 5
- && varInfo->blue.offset == 0)
- vis->pixelFormat = PF_B5G6R5;
-
- else if(varInfo->bits_per_pixel == 16
- && varInfo->red.offset == 10
- && varInfo->green.offset == 5
- && varInfo->blue.offset == 0)
- vis->pixelFormat = PF_B5G5R5;
-
- else {
- _mesa_problem(NULL, "Unsupported fbdev RGB visual/bitdepth!\n");
- _mesa_free(vis);
- return NULL;
- }
+ fixInfo->visual == FB_VISUAL_DIRECTCOLOR) {
+ if (varInfo->bits_per_pixel == 24
+ && varInfo->red.offset == 16
+ && varInfo->green.offset == 8
+ && varInfo->blue.offset == 0) {
+ vis->pixelFormat = PF_B8G8R8;
+ }
+ else if (varInfo->bits_per_pixel == 32
+ && varInfo->red.offset == 16
+ && varInfo->green.offset == 8
+ && varInfo->blue.offset == 0) {
+ vis->pixelFormat = PF_B8G8R8A8;
+ }
+ else if (varInfo->bits_per_pixel == 16
+ && varInfo->red.offset == 11
+ && varInfo->green.offset == 5
+ && varInfo->blue.offset == 0) {
+ vis->pixelFormat = PF_B5G6R5;
+ }
+ else if (varInfo->bits_per_pixel == 16
+ && varInfo->red.offset == 10
+ && varInfo->green.offset == 5
+ && varInfo->blue.offset == 0) {
+ vis->pixelFormat = PF_B5G5R5;
+ }
+ else {
+ _mesa_problem(NULL, "Unsupported fbdev RGB visual/bitdepth!\n");
+ _mesa_free(vis);
+ return NULL;
+ }
}
}
else {
rb->rowStride = visual->var.xres_virtual * visual->var.bits_per_pixel / 8;
rb->bottom = (GLubyte *) bufferStart
- + (visual->var.yres - 1) * rb->rowStride;
+ + (visual->var.yres - 1) * rb->rowStride;
rb->Base.Width = visual->var.xres;
rb->Base.Height = visual->var.yres;
&frontrb->Base);
/* add back renderbuffer */
if (visual->glvisual.doubleBufferMode) {
- int malloced = !backBuffer;
+ const int malloced = !backBuffer;
if (malloced) {
/* malloc a back buffer */
backBuffer = _mesa_malloc(size);
}
backrb = new_glfbdev_renderbuffer(backBuffer, visual);
- if(malloced)
- backrb->mallocedBuffer = GL_TRUE;
+ if (!backrb) {
+ /* out of mem */
+ return NULL;
+ }
+ backrb->mallocedBuffer = malloced;
_mesa_add_renderbuffer(&buf->glframebuffer, BUFFER_BACK_LEFT,
&backrb->Base);
if (buffer == curDraw || buffer == curRead) {
glFBDevMakeCurrent( NULL, NULL, NULL);
}
-#if 0
- /* free the software depth, stencil, accum buffers */
- _mesa_free_framebuffer_data(&buffer->glframebuffer);
- _mesa_free(buffer);
-#else
{
struct gl_framebuffer *fb = &buffer->glframebuffer;
_mesa_unreference_framebuffer(&fb);
}
-#endif
}
}