00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include "pipe/p_debug.h"
00029 #include "stw_pixelformat.h"
00030
00031 #define MAX_PIXELFORMATS 16
00032
00033 static struct pixelformat_info pixelformats[MAX_PIXELFORMATS];
00034 static uint pixelformat_count = 0;
00035 static uint pixelformat_extended_count = 0;
00036
00037 static void
00038 add_standard_pixelformats(
00039 struct pixelformat_info **ppf,
00040 uint flags )
00041 {
00042 struct pixelformat_info *pf = *ppf;
00043 struct pixelformat_color_info color24 = { 8, 0, 8, 8, 8, 16 };
00044 struct pixelformat_alpha_info alpha8 = { 8, 24 };
00045 struct pixelformat_alpha_info noalpha = { 0, 0 };
00046 struct pixelformat_depth_info depth24s8 = { 24, 8 };
00047 struct pixelformat_depth_info depth16 = { 16, 0 };
00048
00049 pf->flags = PF_FLAG_DOUBLEBUFFER | flags;
00050 pf->color = color24;
00051 pf->alpha = alpha8;
00052 pf->depth = depth16;
00053 pf++;
00054
00055 pf->flags = PF_FLAG_DOUBLEBUFFER | flags;
00056 pf->color = color24;
00057 pf->alpha = alpha8;
00058 pf->depth = depth24s8;
00059 pf++;
00060
00061 pf->flags = PF_FLAG_DOUBLEBUFFER | flags;
00062 pf->color = color24;
00063 pf->alpha = noalpha;
00064 pf->depth = depth16;
00065 pf++;
00066
00067 pf->flags = PF_FLAG_DOUBLEBUFFER | flags;
00068 pf->color = color24;
00069 pf->alpha = noalpha;
00070 pf->depth = depth24s8;
00071 pf++;
00072
00073 pf->flags = flags;
00074 pf->color = color24;
00075 pf->alpha = noalpha;
00076 pf->depth = depth16;
00077 pf++;
00078
00079 pf->flags = flags;
00080 pf->color = color24;
00081 pf->alpha = noalpha;
00082 pf->depth = depth24s8;
00083 pf++;
00084
00085 *ppf = pf;
00086 }
00087
00088 void
00089 pixelformat_init( void )
00090 {
00091 struct pixelformat_info *pf = pixelformats;
00092
00093 add_standard_pixelformats( &pf, 0 );
00094 pixelformat_count = pf - pixelformats;
00095
00096 add_standard_pixelformats( &pf, PF_FLAG_MULTISAMPLED );
00097 pixelformat_extended_count = pf - pixelformats;
00098
00099 assert( pixelformat_extended_count <= MAX_PIXELFORMATS );
00100 }
00101
00102 uint
00103 pixelformat_get_count( void )
00104 {
00105 return pixelformat_count;
00106 }
00107
00108 uint
00109 pixelformat_get_extended_count( void )
00110 {
00111 return pixelformat_extended_count;
00112 }
00113
00114 const struct pixelformat_info *
00115 pixelformat_get_info( uint index )
00116 {
00117 assert( index < pixelformat_extended_count );
00118
00119 return &pixelformats[index];
00120 }