From f611e2461ed40fe9cec620cfefae3a69cdea6458 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Fri, 3 Oct 2003 21:38:38 +0000 Subject: [PATCH] namespace cleanup --- stepmania/src/BannerCache.cpp | 4 +- stepmania/src/RageBitmapTexture.cpp | 24 +++++----- stepmania/src/RageDisplay.cpp | 4 +- stepmania/src/RageDisplay.h | 47 +++++++++---------- stepmania/src/RageDisplay_D3D.cpp | 6 +-- stepmania/src/RageDisplay_OGL.cpp | 18 +++---- .../arch/MovieTexture/MovieTexture_DShow.cpp | 24 +++++----- .../arch/MovieTexture/MovieTexture_FFMpeg.cpp | 31 ++++++------ .../arch/MovieTexture/MovieTexture_Null.cpp | 24 +++++----- 9 files changed, 89 insertions(+), 93 deletions(-) diff --git a/stepmania/src/BannerCache.cpp b/stepmania/src/BannerCache.cpp index fda4cde9f2..56fa8badd3 100644 --- a/stepmania/src/BannerCache.cpp +++ b/stepmania/src/BannerCache.cpp @@ -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); diff --git a/stepmania/src/RageBitmapTexture.cpp b/stepmania/src/RageBitmapTexture.cpp index df8c5c4440..9c62d61b70 100644 --- a/stepmania/src/RageBitmapTexture.cpp +++ b/stepmania/src/RageBitmapTexture.cpp @@ -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 "; diff --git a/stepmania/src/RageDisplay.cpp b/stepmania/src/RageDisplay.cpp index 479e318f18..c80044fd8b 100644 --- a/stepmania/src/RageDisplay.cpp +++ b/stepmania/src/RageDisplay.cpp @@ -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 }; diff --git a/stepmania/src/RageDisplay.h b/stepmania/src/RageDisplay.h index 11aa1c22a0..b57b0844a7 100644 --- a/stepmania/src/RageDisplay.h +++ b/stepmania/src/RageDisplay.h @@ -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; diff --git a/stepmania/src/RageDisplay_D3D.cpp b/stepmania/src/RageDisplay_D3D.cpp index 74a7504a44..6270f45a8d 100644 --- a/stepmania/src/RageDisplay_D3D.cpp +++ b/stepmania/src/RageDisplay_D3D.cpp @@ -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]; diff --git a/stepmania/src/RageDisplay_OGL.cpp b/stepmania/src/RageDisplay_OGL.cpp index b80914db2c..ca45a3694c 100644 --- a/stepmania/src/RageDisplay_OGL.cpp +++ b/stepmania/src/RageDisplay_OGL.cpp @@ -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 ); diff --git a/stepmania/src/arch/MovieTexture/MovieTexture_DShow.cpp b/stepmania/src/arch/MovieTexture/MovieTexture_DShow.cpp index 992d12f150..6bf58b98f9 100644 --- a/stepmania/src/arch/MovieTexture/MovieTexture_DShow.cpp +++ b/stepmania/src/arch/MovieTexture/MovieTexture_DShow.cpp @@ -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]); diff --git a/stepmania/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp b/stepmania/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp index ef425f3323..4bc9986f84 100644 --- a/stepmania/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp +++ b/stepmania/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp @@ -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; } } diff --git a/stepmania/src/arch/MovieTexture/MovieTexture_Null.cpp b/stepmania/src/arch/MovieTexture/MovieTexture_Null.cpp index 8f2184afac..1f4ebaba09 100644 --- a/stepmania/src/arch/MovieTexture/MovieTexture_Null.cpp +++ b/stepmania/src/arch/MovieTexture/MovieTexture_Null.cpp @@ -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);