Search
lxdream.org :: lxdream :: r327:00d55a462af3
lxdream 0.9.1
released Jun 29
Download Now
changeset327:00d55a462af3
parent326:0c107e0d0fe0
child328:8da80d8342c5
authornkeynes
dateThu Jan 25 11:46:35 2007 +0000 (12 years ago)
Cleanup framebuffer formats by adding a central source for the information
src/display.c
src/display.h
src/drivers/video_x11.c
src/pvr2/pvr2.h
src/pvr2/pvr2mem.c
1.1 --- a/src/display.c Thu Jan 25 10:18:42 2007 +0000
1.2 +++ b/src/display.c Thu Jan 25 11:46:35 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: display.c,v 1.3 2007-01-11 06:51:52 nkeynes Exp $
1.6 + * $Id: display.c,v 1.4 2007-01-25 11:46:35 nkeynes Exp $
1.7 *
1.8 * Generic support for keyboard and other input sources. The active display
1.9 * driver is expected to deliver events here, where they're translated and
1.10 @@ -31,6 +31,18 @@
1.11 } *keymap_entry_t;
1.12
1.13 /**
1.14 + * Colour format information
1.15 + */
1.16 +struct colour_format colour_formats[] = {
1.17 + { GL_UNSIGNED_SHORT_1_5_5_5_REV, GL_RGBA, GL_RGB5_A1, 2 },
1.18 + { GL_UNSIGNED_SHORT_5_6_5, GL_RGB, GL_RGB5, 2 },
1.19 + { GL_UNSIGNED_SHORT_4_4_4_4_REV, GL_BGRA, GL_RGBA4, 2 },
1.20 + { GL_UNSIGNED_INT_8_8_8_8_REV, GL_BGRA, GL_RGBA8, 4 }, /* YUV decoded to ARGB8888 */
1.21 + { GL_UNSIGNED_BYTE, GL_BGR, GL_RGB, 3 },
1.22 + { GL_UNSIGNED_INT_8_8_8_8_REV, GL_BGRA, GL_RGBA8, 4 }
1.23 +};
1.24 +
1.25 +/**
1.26 * FIXME: make this more memory efficient
1.27 */
1.28 struct keymap_entry *keymap[65536];
2.1 --- a/src/display.h Thu Jan 25 10:18:42 2007 +0000
2.2 +++ b/src/display.h Thu Jan 25 11:46:35 2007 +0000
2.3 @@ -1,5 +1,5 @@
2.4 /**
2.5 - * $Id: display.h,v 1.2 2006-06-18 11:57:55 nkeynes Exp $
2.6 + * $Id: display.h,v 1.3 2007-01-25 11:46:35 nkeynes Exp $
2.7 *
2.8 * The PC side of the video support (responsible for actually displaying /
2.9 * rendering frames)
2.10 @@ -22,6 +22,7 @@
2.11
2.12 #include <stdint.h>
2.13 #include <glib.h>
2.14 +#include <GL/gl.h>
2.15
2.16 #ifdef __cplusplus
2.17 extern "C" {
2.18 @@ -31,14 +32,21 @@
2.19 * Supported colour formats. Note that ARGB4444 is only ever used for texture
2.20 * rendering (it's not valid for display purposes).
2.21 */
2.22 +#define COLFMT_ARGB1555 0
2.23 #define COLFMT_RGB565 1
2.24 -#define COLFMT_RGB888 4
2.25 -#define COLFMT_ARGB1555 0
2.26 -#define COLFMT_ARGB8888 5
2.27 #define COLFMT_ARGB4444 2
2.28 #define COLFMT_YUV422 3 /* 8-bit YUV (texture source only) */
2.29 +#define COLFMT_RGB888 4 /* 24-bit RGB */
2.30 +#define COLFMT_ARGB8888 5
2.31 #define COLFMT_INDEX4 6 /* 4 bit indexed colour (texture source only) */
2.32 #define COLFMT_INDEX8 7 /* 8-bit indexed colour (texture source only) */
2.33 +#define COLFMT_RGB0888 8 /* 32-bit RGB */
2.34 +
2.35 +struct colour_format {
2.36 + GLint type, format, int_format;
2.37 + int bpp;
2.38 +};
2.39 +extern struct colour_format colour_formats[];
2.40
2.41 extern int colour_format_bytes[];
2.42
3.1 --- a/src/drivers/video_x11.c Thu Jan 25 10:18:42 2007 +0000
3.2 +++ b/src/drivers/video_x11.c Thu Jan 25 11:46:35 2007 +0000
3.3 @@ -1,5 +1,5 @@
3.4 /**
3.5 - * $Id: video_x11.c,v 1.9 2007-01-23 11:21:21 nkeynes Exp $
3.6 + * $Id: video_x11.c,v 1.10 2007-01-25 11:46:35 nkeynes Exp $
3.7 *
3.8 * Shared functions for all X11-based display drivers.
3.9 *
3.10 @@ -152,22 +152,9 @@
3.11
3.12 gboolean video_glx_display_frame( video_buffer_t frame )
3.13 {
3.14 - GLenum type, format = GL_BGR;
3.15 - switch( frame->colour_format ) {
3.16 - case COLFMT_RGB565:
3.17 - type = GL_UNSIGNED_SHORT_5_6_5;
3.18 - break;
3.19 - case COLFMT_RGB888:
3.20 - type = GL_UNSIGNED_BYTE;
3.21 - break;
3.22 - case COLFMT_ARGB1555:
3.23 - type = GL_UNSIGNED_SHORT_5_5_5_1;
3.24 - break;
3.25 - case COLFMT_ARGB8888:
3.26 - format = GL_BGRA;
3.27 - type = GL_UNSIGNED_INT_8_8_8_8_REV;
3.28 - break;
3.29 - }
3.30 + GLenum type = colour_formats[frame->colour_format].type;
3.31 + GLenum format = colour_formats[frame->colour_format].format;
3.32 +
3.33 glDrawBuffer( GL_FRONT );
3.34 glViewport( 0, 0, frame->hres, frame->vres );
3.35 glMatrixMode(GL_PROJECTION);
4.1 --- a/src/pvr2/pvr2.h Thu Jan 25 10:18:42 2007 +0000
4.2 +++ b/src/pvr2/pvr2.h Thu Jan 25 11:46:35 2007 +0000
4.3 @@ -1,5 +1,5 @@
4.4 /**
4.5 - * $Id: pvr2.h,v 1.28 2007-01-25 10:16:32 nkeynes Exp $
4.6 + * $Id: pvr2.h,v 1.29 2007-01-25 11:46:35 nkeynes Exp $
4.7 *
4.8 * PVR2 (video chip) functions and macros.
4.9 *
4.10 @@ -30,11 +30,6 @@
4.11 #define DISPMODE_COL 0x0000000C /* Colour mode */
4.12 #define DISPMODE_CD 0x08000000 /* Clock double */
4.13
4.14 -#define COLFMT_RGB15 0x00000000
4.15 -#define COLFMT_RGB16 0x00000004
4.16 -#define COLFMT_RGB24 0x00000008
4.17 -#define COLFMT_RGB32 0x0000000C
4.18 -
4.19 #define DISPSIZE_MODULO 0x3FF00000 /* line skip +1 (32-bit words)*/
4.20 #define DISPSIZE_LPF 0x000FFC00 /* lines per field */
4.21 #define DISPSIZE_PPL 0x000003FF /* pixel words (32 bit) per line */
5.1 --- a/src/pvr2/pvr2mem.c Thu Jan 25 10:18:42 2007 +0000
5.2 +++ b/src/pvr2/pvr2mem.c Thu Jan 25 11:46:35 2007 +0000
5.3 @@ -1,5 +1,5 @@
5.4 /**
5.5 - * $Id: pvr2mem.c,v 1.6 2007-01-25 10:16:32 nkeynes Exp $
5.6 + * $Id: pvr2mem.c,v 1.7 2007-01-25 11:46:35 nkeynes Exp $
5.7 *
5.8 * PVR2 (Video) VRAM handling routines (mainly for the 64-bit region)
5.9 *
5.10 @@ -520,34 +520,10 @@
5.11 {
5.12 if( buffer->render_addr == -1 )
5.13 return;
5.14 - GLenum type, format = GL_BGRA;
5.15 - int line_size = buffer->width, size;
5.16 -
5.17 - switch( buffer->colour_format ) {
5.18 - case COLFMT_RGB565:
5.19 - type = GL_UNSIGNED_SHORT_5_6_5;
5.20 - format = GL_BGR;
5.21 - line_size <<= 1;
5.22 - break;
5.23 - case COLFMT_RGB888:
5.24 - type = GL_UNSIGNED_BYTE;
5.25 - format = GL_BGR;
5.26 - line_size = (line_size<<1)+line_size;
5.27 - break;
5.28 - case COLFMT_ARGB1555:
5.29 - type = GL_UNSIGNED_SHORT_5_5_5_1;
5.30 - line_size <<= 1;
5.31 - break;
5.32 - case COLFMT_ARGB4444:
5.33 - type = GL_UNSIGNED_SHORT_4_4_4_4;
5.34 - line_size <<= 1;
5.35 - break;
5.36 - case COLFMT_ARGB8888:
5.37 - type = GL_UNSIGNED_INT_8_8_8_8;
5.38 - line_size <<= 2;
5.39 - break;
5.40 - }
5.41 - size = line_size * buffer->height;
5.42 + GLenum type = colour_formats[buffer->colour_format].type;
5.43 + GLenum format = colour_formats[buffer->colour_format].format;
5.44 + int line_size = buffer->width * colour_formats[buffer->colour_format].bpp;
5.45 + int size = line_size * buffer->height;
5.46
5.47 if( backBuffer ) {
5.48 glFinish();
5.49 @@ -583,34 +559,12 @@
5.50 {
5.51 if( buffer->render_addr == -1 )
5.52 return;
5.53 - GLenum type, format = GL_RGBA;
5.54 - int size = buffer->width * buffer->height;
5.55
5.56 - switch( buffer->colour_format ) {
5.57 - case COLFMT_RGB565:
5.58 - type = GL_UNSIGNED_SHORT_5_6_5;
5.59 - format = GL_RGB;
5.60 - size <<= 1;
5.61 - break;
5.62 - case COLFMT_RGB888:
5.63 - type = GL_UNSIGNED_BYTE;
5.64 - format = GL_BGR;
5.65 - size = (size<<1)+size;
5.66 - break;
5.67 - case COLFMT_ARGB1555:
5.68 - type = GL_UNSIGNED_SHORT_5_5_5_1;
5.69 - size <<= 1;
5.70 - break;
5.71 - case COLFMT_ARGB4444:
5.72 - type = GL_UNSIGNED_SHORT_4_4_4_4;
5.73 - size <<= 1;
5.74 - break;
5.75 - case COLFMT_ARGB8888:
5.76 - type = GL_UNSIGNED_INT_8_8_8_8;
5.77 - size <<= 2;
5.78 - break;
5.79 - }
5.80 -
5.81 + GLenum type = colour_formats[buffer->colour_format].type;
5.82 + GLenum format = colour_formats[buffer->colour_format].format;
5.83 + int line_size = buffer->width * colour_formats[buffer->colour_format].bpp;
5.84 + int size = line_size * buffer->height;
5.85 +
5.86 if( backBuffer ) {
5.87 glDrawBuffer( GL_BACK );
5.88 } else {
.