namespace cleanup

This commit is contained in:
Glenn Maynard
2003-10-03 21:38:38 +00:00
parent bb02184ff4
commit f611e2461e
9 changed files with 89 additions and 93 deletions
+2 -2
View File
@@ -181,9 +181,9 @@ struct BannerTexture: public RageTexture
/* Find a supported texture format. If it happens to match the stored
* file, we won't have to do any conversion here, and that'll happen often
* with paletted images. */
PixelFormat pf = img->format->BitsPerPixel == 8? FMT_PAL: FMT_RGB5A1;
RageDisplay::PixelFormat pf = img->format->BitsPerPixel == 8? RageDisplay::FMT_PAL: RageDisplay::FMT_RGB5A1;
if( !DISPLAY->SupportsTextureFormat(pf) )
pf = FMT_RGBA4;
pf = RageDisplay::FMT_RGBA4;
ASSERT( DISPLAY->SupportsTextureFormat(pf) );
ASSERT(img);
+12 -12
View File
@@ -194,13 +194,13 @@ apply_color_key:
}
// Format of the image that we will pass to OpenGL and that we want OpenGL to use
PixelFormat pixfmt;
RageDisplay::PixelFormat pixfmt;
/* Figure out which texture format to use. */
// if the source is palleted, load palleted no matter what the prefs
if(img->format->BitsPerPixel == 8 && DISPLAY->SupportsTextureFormat(FMT_PAL))
if(img->format->BitsPerPixel == 8 && DISPLAY->SupportsTextureFormat(RageDisplay::FMT_PAL))
{
pixfmt = FMT_PAL;
pixfmt = RageDisplay::FMT_PAL;
}
else
{
@@ -226,16 +226,16 @@ apply_color_key:
switch( src_alpha_bits ) {
case 0:
case 1:
pixfmt = FMT_RGB5A1;
pixfmt = RageDisplay::FMT_RGB5A1;
break;
default:
pixfmt = FMT_RGBA4;
pixfmt = RageDisplay::FMT_RGBA4;
break;
}
}
break;
case 32:
pixfmt = FMT_RGBA8;
pixfmt = RageDisplay::FMT_RGBA8;
break;
default:
RageException::Throw( "Invalid color depth: %d bits", actualID.iColorDepth );
@@ -244,10 +244,10 @@ apply_color_key:
/* It's either not a paletted image, or we can't handle paletted textures.
* Convert to the desired RGBA format, dithering if appropriate. */
if( actualID.bDither &&
(pixfmt==FMT_RGBA4 || pixfmt==FMT_RGB5A1) ) /* Don't dither if format is 32bpp; there's no point. */
(pixfmt==RageDisplay::FMT_RGBA4 || pixfmt==RageDisplay::FMT_RGB5A1) ) /* Don't dither if format is 32bpp; there's no point. */
{
/* Dither down to the destination format. */
const PixelFormatDesc *pfd = DISPLAY->GetPixelFormatDesc(pixfmt);
const RageDisplay::PixelFormatDesc *pfd = DISPLAY->GetPixelFormatDesc(pixfmt);
SDL_Surface *dst = SDL_CreateRGBSurfaceSane(SDL_SWSURFACE, img->w, img->h,
pfd->bpp, pfd->masks[0], pfd->masks[1], pfd->masks[2], pfd->masks[3]);
@@ -266,15 +266,15 @@ apply_color_key:
* Every card supports either RGBA8 or RGBA4. */
if( !DISPLAY->SupportsTextureFormat(pixfmt) )
{
pixfmt = FMT_RGBA8;
pixfmt = RageDisplay::FMT_RGBA8;
if( !DISPLAY->SupportsTextureFormat(pixfmt) )
pixfmt = FMT_RGBA4;
pixfmt = RageDisplay::FMT_RGBA4;
}
/* Convert the data to the destination format and dimensions
* required by OpenGL if it's not in it already. */
const PixelFormatDesc *pfd = DISPLAY->GetPixelFormatDesc(pixfmt);
const RageDisplay::PixelFormatDesc *pfd = DISPLAY->GetPixelFormatDesc(pixfmt);
ConvertSDLSurface(img, m_iTextureWidth, m_iTextureHeight,
pfd->bpp, pfd->masks[0], pfd->masks[1], pfd->masks[2], pfd->masks[3]);
@@ -331,7 +331,7 @@ apply_color_key:
CString props;
props += PixelFormatToString( pixfmt ) + " ";
props += RageDisplay::PixelFormatToString( pixfmt ) + " ";
if(actualID.iAlphaBits == 0) props += "opaque ";
if(actualID.iAlphaBits == 1) props += "matte ";
if(actualID.bStretch) props += "stretch ";
+2 -2
View File
@@ -37,7 +37,7 @@ static int g_iFramesRenderedSinceLastCheck,
RageDisplay* DISPLAY = NULL;
CString PixelFormatToString( PixelFormat pixfmt )
CString RageDisplay::PixelFormatToString( PixelFormat pixfmt )
{
const CString s[NUM_PIX_FORMATS] = {
"FMT_RGBA8",
@@ -586,7 +586,7 @@ SDL_Surface *RageDisplay::CreateSurfaceFromPixfmt( PixelFormat pixfmt,
return surf;
}
PixelFormat RageDisplay::FindPixelFormat(
RageDisplay::PixelFormat RageDisplay::FindPixelFormat(
int bpp, int Rmask, int Gmask, int Bmask, int Amask )
{
PixelFormatDesc tmp = { bpp, Rmask, Gmask, Bmask, Amask };
+23 -24
View File
@@ -37,34 +37,35 @@ struct SDL_Surface;
};
*/
enum PixelFormat {
FMT_RGBA8,
FMT_RGBA4,
FMT_RGB5A1,
FMT_RGB5,
FMT_RGB8,
FMT_PAL,
/* The above formats differ between OpenGL and D3D. These are provided as
* alternatives for OpenGL that match some format in D3D. Don't use them
* directly; they'll be matched automatically by FindPixelFormat. */
FMT_BGR8,
FMT_A1BGR5,
NUM_PIX_FORMATS
};
CString PixelFormatToString( PixelFormat pixfmt );
struct PixelFormatDesc {
int bpp;
unsigned int masks[4];
};
class RageDisplay
{
friend class RageTexture;
public:
struct PixelFormatDesc {
int bpp;
unsigned int masks[4];
};
enum PixelFormat {
FMT_RGBA8,
FMT_RGBA4,
FMT_RGB5A1,
FMT_RGB5,
FMT_RGB8,
FMT_PAL,
/* The above formats differ between OpenGL and D3D. These are provided as
* alternatives for OpenGL that match some format in D3D. Don't use them
* directly; they'll be matched automatically by FindPixelFormat. */
FMT_BGR8,
FMT_A1BGR5,
NUM_PIX_FORMATS
};
static CString PixelFormatToString( PixelFormat pixfmt );
virtual const PixelFormatDesc *GetPixelFormatDesc(PixelFormat pf) const = 0;
struct VideoModeParams
{
// Initialize with a constructor so to guarantee all paramters
@@ -119,8 +120,6 @@ public:
/* This is needed or the overridden classes' dtors will not be called. */
virtual ~RageDisplay() { }
virtual const PixelFormatDesc *GetPixelFormatDesc(PixelFormat pf) const = 0;
virtual void Update(float fDeltaTime) { }
virtual bool IsSoftwareRenderer() = 0;
+3 -3
View File
@@ -131,7 +131,7 @@ static void SetPalette( unsigned TexResource )
#define D3DFVF_RageModelVertex (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1)
static const PixelFormatDesc PIXEL_FORMAT_DESC[NUM_PIX_FORMATS] = {
static const RageDisplay::PixelFormatDesc PIXEL_FORMAT_DESC[RageDisplay::NUM_PIX_FORMATS] = {
{
/* A8B8G8R8 */
32,
@@ -189,7 +189,7 @@ static const PixelFormatDesc PIXEL_FORMAT_DESC[NUM_PIX_FORMATS] = {
}
};
static D3DFORMAT D3DFORMATS[NUM_PIX_FORMATS] =
static D3DFORMAT D3DFORMATS[RageDisplay::NUM_PIX_FORMATS] =
{
D3DFMT_A8R8G8B8,
D3DFMT_A4R4G4B4,
@@ -205,7 +205,7 @@ static D3DFORMAT D3DFORMATS[NUM_PIX_FORMATS] =
D3DFMT_UNKNOWN /* no ABGR */
};
const PixelFormatDesc *RageDisplay_D3D::GetPixelFormatDesc(PixelFormat pf) const
const RageDisplay::PixelFormatDesc *RageDisplay_D3D::GetPixelFormatDesc(PixelFormat pf) const
{
ASSERT( pf < NUM_PIX_FORMATS );
return &PIXEL_FORMAT_DESC[pf];
+9 -9
View File
@@ -107,7 +107,7 @@ const GLenum RageSpriteVertexFormat = GL_T2F_C4F_N3F_V3F;
LowLevelWindow *wind;
static PixelFormatDesc PIXEL_FORMAT_DESC[NUM_PIX_FORMATS] = {
static RageDisplay::PixelFormatDesc PIXEL_FORMAT_DESC[RageDisplay::NUM_PIX_FORMATS] = {
{
/* R8G8B8A8 */
32,
@@ -202,7 +202,7 @@ struct GLPixFmtInfo_t {
GLenum internalfmt; /* target format */
GLenum format; /* target format */
GLenum type; /* data format */
} GL_PIXFMT_INFO[NUM_PIX_FORMATS] = {
} GL_PIXFMT_INFO[RageDisplay::NUM_PIX_FORMATS] = {
{
/* R8G8B8A8 */
GL_RGBA8,
@@ -255,9 +255,9 @@ static void FixLilEndian()
return;
Initialized = true;
for( int i = 0; i < NUM_PIX_FORMATS; ++i )
for( int i = 0; i < RageDisplay::NUM_PIX_FORMATS; ++i )
{
PixelFormatDesc &pf = PIXEL_FORMAT_DESC[i];
RageDisplay::PixelFormatDesc &pf = PIXEL_FORMAT_DESC[i];
/* OpenGL and SDL handle byte formats differently; we need
* to flip non-paletted masks to make them line up. */
@@ -377,9 +377,9 @@ static void CheckPalettedTextures()
return;
/* Check to see if paletted textures really work. */
GLenum glTexFormat = GL_PIXFMT_INFO[FMT_PAL].internalfmt;
GLenum glImageFormat = GL_PIXFMT_INFO[FMT_PAL].format;
GLenum glImageType = GL_PIXFMT_INFO[FMT_PAL].type;
GLenum glTexFormat = GL_PIXFMT_INFO[RageDisplay::FMT_PAL].internalfmt;
GLenum glImageFormat = GL_PIXFMT_INFO[RageDisplay::FMT_PAL].format;
GLenum glImageType = GL_PIXFMT_INFO[RageDisplay::FMT_PAL].type;
FlushGLErrors();
glTexImage2D(GL_PROXY_TEXTURE_2D,
@@ -1028,7 +1028,7 @@ void RageDisplay_OGL::SetBackfaceCull( bool b )
glDisable( GL_CULL_FACE );
}
const PixelFormatDesc *RageDisplay_OGL::GetPixelFormatDesc(PixelFormat pf) const
const RageDisplay::PixelFormatDesc *RageDisplay_OGL::GetPixelFormatDesc(PixelFormat pf) const
{
ASSERT( pf < NUM_PIX_FORMATS );
return &PIXEL_FORMAT_DESC[pf];
@@ -1053,7 +1053,7 @@ void RageDisplay_OGL::DeleteTexture( unsigned uTexHandle )
}
PixelFormat RageDisplay_OGL::GetImgPixelFormat( SDL_Surface* &img, bool &FreeImg, int width, int height )
RageDisplay::PixelFormat RageDisplay_OGL::GetImgPixelFormat( SDL_Surface* &img, bool &FreeImg, int width, int height )
{
PixelFormat pixfmt = FindPixelFormat( img->format->BitsPerPixel, img->format->Rmask, img->format->Gmask, img->format->Bmask, img->format->Amask );
@@ -453,31 +453,31 @@ void MovieTexture_DShow::CreateTexture()
if(m_uTexHandle)
return;
PixelFormat pixfmt;
RageDisplay::PixelFormat pixfmt;
switch( TEXTUREMAN->GetMovieColorDepth() )
{
default:
ASSERT(0);
case 16:
if( DISPLAY->SupportsTextureFormat(FMT_RGB5) )
pixfmt = FMT_RGB5;
if( DISPLAY->SupportsTextureFormat(RageDisplay::FMT_RGB5) )
pixfmt = RageDisplay::FMT_RGB5;
else
pixfmt = FMT_RGBA4; // everything supports RGBA4
pixfmt = RageDisplay::FMT_RGBA4; // everything supports RGBA4
break;
case 32:
if( DISPLAY->SupportsTextureFormat(FMT_RGB8) )
pixfmt = FMT_RGB8;
else if( DISPLAY->SupportsTextureFormat(FMT_RGBA8) )
pixfmt = FMT_RGBA8;
else if( DISPLAY->SupportsTextureFormat(FMT_RGB5) )
pixfmt = FMT_RGB5;
if( DISPLAY->SupportsTextureFormat(RageDisplay::FMT_RGB8) )
pixfmt = RageDisplay::FMT_RGB8;
else if( DISPLAY->SupportsTextureFormat(RageDisplay::FMT_RGBA8) )
pixfmt = RageDisplay::FMT_RGBA8;
else if( DISPLAY->SupportsTextureFormat(RageDisplay::FMT_RGB5) )
pixfmt = RageDisplay::FMT_RGB5;
else
pixfmt = FMT_RGBA4; // everything supports RGBA4
pixfmt = RageDisplay::FMT_RGBA4; // everything supports RGBA4
break;
}
const PixelFormatDesc *pfd = DISPLAY->GetPixelFormatDesc(pixfmt);
const RageDisplay::PixelFormatDesc *pfd = DISPLAY->GetPixelFormatDesc(pixfmt);
SDL_Surface *img = SDL_CreateRGBSurfaceSane(SDL_SWSURFACE, m_iTextureWidth, m_iTextureHeight,
pfd->bpp, pfd->masks[0], pfd->masks[1], pfd->masks[2], pfd->masks[3]);
@@ -105,7 +105,7 @@ static void FixLilEndian()
#endif
}
static int FindCompatibleAVFormat( PixelFormat &pixfmt, bool HighColor )
static int FindCompatibleAVFormat( RageDisplay::PixelFormat &pixfmt, bool HighColor )
{
for( int i = 0; AVPixelFormats[i].bpp; ++i )
{
@@ -119,7 +119,7 @@ static int FindCompatibleAVFormat( PixelFormat &pixfmt, bool HighColor )
fmt.masks[2],
fmt.masks[3] );
if( pixfmt == NUM_PIX_FORMATS )
if( pixfmt == RageDisplay::NUM_PIX_FORMATS )
continue;
return i;
@@ -346,6 +346,7 @@ MovieTexture_FFMpeg::MovieTexture_FFMpeg( RageTextureID ID ):
m_iImageWidth, m_iImageHeight, m_iTextureWidth, m_iTextureHeight);
LOG->Trace("Bitrate: %i", decoder->m_stream->codec.bit_rate );
LOG->Trace("Codec pixel format: %s", avcodec::avcodec_get_pix_fmt_name(decoder->m_stream->codec.pix_fmt) );
LOG->Trace("Texture pixel format: %i", m_AVTexfmt );
CreateFrameRects();
@@ -474,11 +475,7 @@ void MovieTexture_FFMpeg::CreateTexture()
m_iTextureWidth = power_of_two(m_iImageWidth);
m_iTextureHeight = power_of_two(m_iImageHeight);
/* TODO: We could get a big speed bonus by doing the above if the
* hardware renderer can handle YUV textures. I think D3D can do
* this, as well as OpenGL on the Mac, but we don't have any infrastructure
* for this right now. */
PixelFormat pixfmt;
RageDisplay::PixelFormat pixfmt;
bool PreferHighColor = (TEXTUREMAN->GetMovieColorDepth() == 32);
m_AVTexfmt = FindCompatibleAVFormat( pixfmt, PreferHighColor );
@@ -499,22 +496,22 @@ void MovieTexture_FFMpeg::CreateTexture()
default:
ASSERT(0);
case 16:
if( DISPLAY->SupportsTextureFormat(FMT_RGB5) )
pixfmt = FMT_RGB5;
if( DISPLAY->SupportsTextureFormat(RageDisplay::FMT_RGB5) )
pixfmt = RageDisplay::FMT_RGB5;
else
pixfmt = FMT_RGBA4; // everything supports RGBA4
pixfmt = RageDisplay::FMT_RGBA4; // everything supports RGBA4
break;
case 32:
if( DISPLAY->SupportsTextureFormat(FMT_RGB8) )
pixfmt = FMT_RGB8;
else if( DISPLAY->SupportsTextureFormat(FMT_RGBA8) )
pixfmt = FMT_RGBA8;
else if( DISPLAY->SupportsTextureFormat(FMT_RGB5) )
pixfmt = FMT_RGB5;
if( DISPLAY->SupportsTextureFormat(RageDisplay::FMT_RGB8) )
pixfmt = RageDisplay::FMT_RGB8;
else if( DISPLAY->SupportsTextureFormat(RageDisplay::FMT_RGBA8) )
pixfmt = RageDisplay::FMT_RGBA8;
else if( DISPLAY->SupportsTextureFormat(RageDisplay::FMT_RGB5) )
pixfmt = RageDisplay::FMT_RGB5;
else
pixfmt = FMT_RGBA4; // everything supports RGBA4
pixfmt = RageDisplay::FMT_RGBA4; // everything supports RGBA4
break;
}
}
@@ -35,30 +35,30 @@ MovieTexture_Null::MovieTexture_Null(RageTextureID ID) : RageMovieTexture(ID) {
CreateFrameRects();
PixelFormat pixfmt;
RageDisplay::PixelFormat pixfmt;
switch( TEXTUREMAN->GetMovieColorDepth() ){
default:
ASSERT(0);
case 16:
if( DISPLAY->SupportsTextureFormat(FMT_RGB5) )
pixfmt = FMT_RGB5;
if( DISPLAY->SupportsTextureFormat(RageDisplay::FMT_RGB5) )
pixfmt = RageDisplay::FMT_RGB5;
else
pixfmt = FMT_RGBA4; // everything supports RGBA4
pixfmt = RageDisplay::FMT_RGBA4; // everything supports RGBA4
break;
case 32:
if( DISPLAY->SupportsTextureFormat(FMT_RGB8) )
pixfmt = FMT_RGB8;
else if( DISPLAY->SupportsTextureFormat(FMT_RGBA8) )
pixfmt = FMT_RGBA8;
else if( DISPLAY->SupportsTextureFormat(FMT_RGB5) )
pixfmt = FMT_RGB5;
if( DISPLAY->SupportsTextureFormat(RageDisplay::FMT_RGB8) )
pixfmt = RageDisplay::FMT_RGB8;
else if( DISPLAY->SupportsTextureFormat(RageDisplay::FMT_RGBA8) )
pixfmt = RageDisplay::FMT_RGBA8;
else if( DISPLAY->SupportsTextureFormat(RageDisplay::FMT_RGB5) )
pixfmt = RageDisplay::FMT_RGB5;
else
pixfmt = FMT_RGBA4; // everything supports RGBA4
pixfmt = RageDisplay::FMT_RGBA4; // everything supports RGBA4
break;
}
const PixelFormatDesc *pfd = DISPLAY->GetPixelFormatDesc(pixfmt);
const RageDisplay::PixelFormatDesc *pfd = DISPLAY->GetPixelFormatDesc(pixfmt);
SDL_Surface *img = SDL_CreateRGBSurfaceSane(SDL_SWSURFACE, size, size, pfd->bpp, pfd->masks[0],
pfd->masks[1], pfd->masks[2], pfd->masks[3]);
texHandle = DISPLAY->CreateTexture(pixfmt, img);