From 429d311c2a0568695a3ae671b995437bf359e91e Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Thu, 5 Jun 2003 22:18:42 +0000 Subject: [PATCH] Remove composited text. The large amount of memory it uses is a bigger penalty than drawing a quad for each glyph. --- stepmania/Data/VideoCards.ini | 24 +++++-- stepmania/src/CompositedText.cpp | 108 ---------------------------- stepmania/src/CompositedText.h | 22 ------ stepmania/src/RageBitmapTexture.cpp | 12 +--- stepmania/src/RageTexture.cpp | 2 - stepmania/src/RageTexture.h | 3 +- stepmania/src/SDL_utils.cpp | 62 ---------------- stepmania/src/SDL_utils.h | 6 -- stepmania/src/ScreenSandbox.cpp | 7 -- stepmania/src/StepMania.dsp | 47 ++++-------- stepmania/src/StepMania.vcproj | 6 -- stepmania/src/TextBanner.cpp | 9 +-- stepmania/src/TextBanner.h | 1 - 13 files changed, 37 insertions(+), 272 deletions(-) delete mode 100644 stepmania/src/CompositedText.cpp delete mode 100644 stepmania/src/CompositedText.h diff --git a/stepmania/Data/VideoCards.ini b/stepmania/Data/VideoCards.ini index 9e2148148c..e072e0710f 100644 --- a/stepmania/Data/VideoCards.ini +++ b/stepmania/Data/VideoCards.ini @@ -1,13 +1,14 @@ [VideoCards] -NumEntries=3 +NumEntries=4 [0000] DriverRegex=Voodoo3|3dfx -Renderers=opengl,d3d +Renderers=d3d Width=640 Height=480 DisplayColor=16 TextureColor=16 +AntiAliasing=0 // broken [0001] DriverRegex=GeForce|Radeon @@ -15,14 +16,27 @@ Renderers=opengl,d3d Width=640 Height=480 DisplayColor=32 -TextureColor=32 +TextureColor=32 // 32 bit textures are faster to load +AntiAliasing=1 // hardware accelerated + +[0002] +DriverRegex=G400 +Renderers=d3d,opengl // Frame rates are ~30% higher with D3D +Width=640 +Height=480 +DisplayColor=16 +TextureColor=16 +AntiAliasing=0 // Default graphics settings used for all cards that don't match above. // This must be the very last entry! -[0002] +[0003] DriverRegex= Renderers=opengl,d3d Width=640 Height=480 DisplayColor=16 -TextureColor=16 \ No newline at end of file +TextureColor=16 +AntiAliasing=0 +// AA is slow on some cards, so let's selectively enable it on cards we know are hardware +// accelerated. Enabling AA on a G400 slows screenSelectMusic from 45fps to 35fps. diff --git a/stepmania/src/CompositedText.cpp b/stepmania/src/CompositedText.cpp deleted file mode 100644 index 5ae472282a..0000000000 --- a/stepmania/src/CompositedText.cpp +++ /dev/null @@ -1,108 +0,0 @@ -#include "global.h" -/* ------------------------------------------------------------------------------ - Class: CompositedText - - Desc: See header. - - Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. - Chris Danford ------------------------------------------------------------------------------ -*/ - -#include "CompositedText.h" -#include "Font.h" -#include "FontManager.h" -#include "RageDisplay.h" -#include "Actor.h" -#include "SDL_video.h" -#include "SDL_utils.h" - - -SDL_Surface* CreateCompositedText( CString sFontFile, CString sText ) -{ - // build a font texture - Font* pFont = FONT->LoadFont( sFontFile ); - - vector asTextLines; - split(CStringToWstring(sText), L"\n", asTextLines, false); - - /* calculate line lengths and widths */ - vector LineWidths; - int iWidestLineWidth = 0; - for( unsigned l=0; lGetLineWidthInSourcePixels( asTextLines[l] )); - iWidestLineWidth = max(iWidestLineWidth, LineWidths.back()); - } - - int TotalHeight = pFont->GetHeight() * asTextLines.size(); - unsigned i; - int MinSpacing = 0; - - /* The height (from the origin to the baseline): */ - int Padding = max(pFont->GetLineSpacing(), MinSpacing) - pFont->GetHeight(); - - /* There's padding between every line: */ - TotalHeight += Padding * (asTextLines.size()-1); - - - /* Because of the "draw extra pixels" and the fact that frame height is often - * greater than the line spacing, we need to add some padding around all edges. - * Is there a more elegant way we could be handling this? */ - const int PADDING = 32; - int imageWidth = iWidestLineWidth+PADDING; - int imageHeight = TotalHeight+PADDING; - - /* Make sure the image size is even to maintain pixel/texel alignment. */ - if( imageWidth%2==1 ) imageWidth++; - if( imageHeight%2==1 ) imageHeight++; - - /* Allocate surface */ - PixelFormat pixfmt = FMT_RGBA8; - const PixelFormatDesc *pfd = DISPLAY->GetPixelFormatDesc(pixfmt); - SDL_Surface *img = SDL_CreateRGBSurfaceSane(SDL_SWSURFACE, imageWidth, imageHeight, - pfd->bpp, pfd->masks[0], pfd->masks[1], pfd->masks[2], pfd->masks[3]); - SDL_FillRect( img, NULL, 0x00000000 ); - - - int iY = PADDING/2; - - for( i=0; iGetHeight(); - const wstring &sLine = asTextLines[i]; - const int iLineWidth = LineWidths[i]; - - int iX = PADDING/2; - - for( unsigned j=0; jGetGlyph( sLine[j] ); - - SDL_Rect blitSrc; - blitSrc.x = g.blitSrc.left; - blitSrc.w = g.blitSrc.right - g.blitSrc.left; - blitSrc.y = g.blitSrc.top; - blitSrc.h = g.blitSrc.bottom - g.blitSrc.top; - - SDL_Rect blitDst; - blitDst.x = iX+g.hshift; - blitDst.w = g.width; - blitDst.y = iY+g.fp->vshift; - blitDst.h = g.height; - - mySDL_BlitSurfaceSmartBlend( g.GetSurface(), &blitSrc, img, &blitDst ); - -// SDL_SaveBMP( img, "testingText.bmp" ); - - /* Advance the cursor. */ - iX += g.hadvance; - } - - /* The amount of padding a line needs: */ - iY += Padding; - } - - return img; -} \ No newline at end of file diff --git a/stepmania/src/CompositedText.h b/stepmania/src/CompositedText.h deleted file mode 100644 index a317f51362..0000000000 --- a/stepmania/src/CompositedText.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef CompositedText_H -#define CompositedText_H -/* ------------------------------------------------------------------------------ - Class: CompositedText - - Desc: A little graphic to the left of the song's text banner in the MusicWheel. - - Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. - Chris Danford ------------------------------------------------------------------------------ -*/ - -#include "Sprite.h" - -struct SDL_Surface; - - -SDL_Surface* CreateCompositedText( CString sFontFile, CString sText ); - - -#endif diff --git a/stepmania/src/RageBitmapTexture.cpp b/stepmania/src/RageBitmapTexture.cpp index fb512444af..71a0f80469 100644 --- a/stepmania/src/RageBitmapTexture.cpp +++ b/stepmania/src/RageBitmapTexture.cpp @@ -25,8 +25,6 @@ #include "SDL_utils.h" #include "SDL_dither.h" -#include "CompositedText.h" - #include "RageTimer.h" static void GetResolutionFromFileName( CString sPath, int &Width, int &Height ) @@ -84,15 +82,7 @@ void RageBitmapTexture::Create() /* Create (and return) a surface ready to be loaded to OpenGL */ /* Load the image into an SDL surface. */ - SDL_Surface *img; - if( GetID().filename.Right(3).CompareNoCase("ini")==0 ) - { - img = CreateCompositedText( GetID().filename, GetID().text ); - } - else - { - img = IMG_Load( GetID().filename ); - } + SDL_Surface *img = IMG_Load( GetID().filename ); /* XXX: Wait, we don't want to throw for all images; in particular, we diff --git a/stepmania/src/RageTexture.cpp b/stepmania/src/RageTexture.cpp index 04ec30874d..f09c51ab09 100644 --- a/stepmania/src/RageTexture.cpp +++ b/stepmania/src/RageTexture.cpp @@ -49,7 +49,6 @@ bool RageTextureID::operator<(const RageTextureID &rhs) const { #define COMP(a) if(arhs.a) return false; COMP(filename); - COMP(text); COMP(iMaxSize); COMP(iMipMaps); COMP(iAlphaBits); @@ -67,7 +66,6 @@ bool RageTextureID::operator==(const RageTextureID &rhs) const #define EQUAL(a) (a==rhs.a) return EQUAL(filename) && - EQUAL(text) && EQUAL(iMaxSize) && EQUAL(iMipMaps) && EQUAL(iAlphaBits) && diff --git a/stepmania/src/RageTexture.h b/stepmania/src/RageTexture.h index 1ec4519434..ee12e9b1bb 100644 --- a/stepmania/src/RageTexture.h +++ b/stepmania/src/RageTexture.h @@ -21,8 +21,7 @@ * of these. */ struct RageTextureID { - CString filename; // font file name if !text.empty() - CString text; + CString filename; int iMaxSize; int iMipMaps; int iAlphaBits; diff --git a/stepmania/src/SDL_utils.cpp b/stepmania/src/SDL_utils.cpp index f326e20514..11289e5d0e 100644 --- a/stepmania/src/SDL_utils.cpp +++ b/stepmania/src/SDL_utils.cpp @@ -603,68 +603,6 @@ void mySDL_WM_SetIcon( CString sIconFile ) } -void mySDL_BlitSurfaceSmartBlend( - SDL_Surface* src, SDL_Rect *srcrect, - SDL_Surface* dst, SDL_Rect *dstrect ) -{ - /* Can't blit to paletted surfaces. */ - ASSERT(dst->format->BytesPerPixel > 1); - - /* Rects must be same dimensions. */ - ASSERT( srcrect->w==dstrect->w && srcrect->h==dstrect->h ); - - /* TODO: Add clipping. - * For now, just ASSERT if out of bounds. */ - ASSERT( - srcrect->x >= 0 && - srcrect->x+srcrect->w <= src->w && - srcrect->y >= 0 && - srcrect->y+srcrect->h <= src->h ); - ASSERT( - dstrect->x >= 0 && - dstrect->x+dstrect->w <= dst->w && - dstrect->y >= 0 && - dstrect->y+dstrect->h <= dst->h ); - - /* For each row: */ - for(int row = 0; row < srcrect->h; ++row) - { - const Uint8 *srcp = (const Uint8 *)src->pixels; - srcp += (srcrect->y+row) * src->pitch; - srcp += srcrect->x * src->format->BytesPerPixel; - Uint8 *dstp = (Uint8 *)dst->pixels; - dstp += (dstrect->y+row) * dst->pitch; - dstp += dstrect->x * dst->format->BytesPerPixel; - - /* For each pixel in row: */ - for(int col = 0; col < srcrect->w; ++col) - { - Uint8 srcColors[4]; - mySDL_GetRGBAV(srcp, src, srcColors); - - Uint8 dstColors[4]; - mySDL_GetRGBAV(dstp, dst, dstColors); - - float fColorWeightSrc = srcColors[3] / (float)(srcColors[3]+dstColors[3]); - float fColorWeightDst = dstColors[3] / (float)(srcColors[3]+dstColors[3]); - - Uint32 temp[4]; - temp[0] = srcColors[0] * fColorWeightSrc + dstColors[0] * fColorWeightDst; - temp[1] = srcColors[1] * fColorWeightSrc + dstColors[1] * fColorWeightDst; - temp[2] = srcColors[2] * fColorWeightSrc + dstColors[2] * fColorWeightDst; - temp[3] = srcColors[3] + (dstColors[3] * (255-srcColors[3]))/255; - - Uint8 blendedColors[4] = { temp[0], temp[1], temp[2], temp[3] }; - mySDL_SetRGBAV(dstp, dst, blendedColors); - - /* Next column */ - srcp += src->format->BytesPerPixel; - dstp += dst->format->BytesPerPixel; - } - } -} - - struct SurfaceHeader { int width, height, pitch; diff --git a/stepmania/src/SDL_utils.h b/stepmania/src/SDL_utils.h index 5727523673..f3b3fc8797 100644 --- a/stepmania/src/SDL_utils.h +++ b/stepmania/src/SDL_utils.h @@ -56,12 +56,6 @@ int FindSurfaceTraits(const SDL_Surface *img); void mySDL_WM_SetIcon( CString sIconFile ); - -void mySDL_BlitSurfaceSmartBlend( - SDL_Surface* src, SDL_Rect *srcrect, - SDL_Surface* dst, SDL_Rect *dstrect ); - - bool mySDL_SaveSurface( SDL_Surface *img, CString file ); SDL_Surface *mySDL_LoadSurface( CString file ); diff --git a/stepmania/src/ScreenSandbox.cpp b/stepmania/src/ScreenSandbox.cpp index e55bf5cda6..e18c15334b 100644 --- a/stepmania/src/ScreenSandbox.cpp +++ b/stepmania/src/ScreenSandbox.cpp @@ -48,13 +48,6 @@ ScreenSandbox::ScreenSandbox() : Screen("ScreenSandbox") // this->AddChild(&m_model); // m_model.SetEffectSpin( RageVector3(0,90,90) ); - RageTextureID ID; - ID.filename = THEME->GetPathToF("MusicWheelItem roulette"); - ID.text = "testing,\ntesting,\n1\n2\n3\n\n\n"; - m_text.Load( ID ); - m_text.SetXY( CENTER_X, CENTER_Y ); - this->AddChild( &m_text ); - this->AddChild( &m_In ); this->AddChild( &m_Out ); diff --git a/stepmania/src/StepMania.dsp b/stepmania/src/StepMania.dsp index 44f8cf99a8..59567a2486 100644 --- a/stepmania/src/StepMania.dsp +++ b/stepmania/src/StepMania.dsp @@ -64,7 +64,7 @@ IntDir=.\../Debug6 TargetDir=\stepmania\stepmania TargetName=StepMania-debug SOURCE="$(InputPath)" -PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ +PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi # End Special Build Tool @@ -82,25 +82,25 @@ PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania # PROP Intermediate_Dir "StepMania___Xbox_Debug___VC6" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" -CPP=cl.exe -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I "." /I "SDL-1.2.5\include" /I "SDL_image-1.2" /I "plib-1.6.0" /D "WIN32" /D "_XBOX" /D "_DEBUG" /Fr /YX"global.h" /FD /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "." /I "SDL-1.2.5\include" /I "SDL_image-1.2" /I "plib-1.6.0" /D "WIN32" /D "_XBOX" /D "_DEBUG" /Fr /YX"global.h" /FD /c -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo +XBCP=xbecopy.exe +# ADD BASE XBCP /NOLOGO +# ADD XBCP /NOLOGO +XBE=imagebld.exe +# ADD BASE XBE /nologo /stack:0x10000 /debug +# ADD XBE /nologo /stack:0x10000 /debug LINK32=link.exe # ADD BASE LINK32 $(intdir)\verstub.obj kernel32.lib shell32.lib user32.lib gdi32.lib advapi32.lib winmm.lib /nologo /pdb:"../debug6/StepMania-debug.pdb" /map /debug /machine:IX86 /nodefaultlib:"libcmtd.lib" /out:"../StepMania-debug.exe" # SUBTRACT BASE LINK32 /verbose /profile /pdb:none /incremental:no /nodefaultlib # ADD LINK32 $(intdir)\verstub.obj kernel32.lib shell32.lib user32.lib gdi32.lib advapi32.lib winmm.lib /nologo /pdb:"../debug6/StepMania-debug.pdb" /map /debug /machine:IX86 /nodefaultlib:"libcmtd.lib" /out:"../StepMania-debug.exe" # SUBTRACT LINK32 /verbose /profile /pdb:none /incremental:no /nodefaultlib -XBE=imagebld.exe -# ADD BASE XBE /nologo /stack:0x10000 /debug -# ADD XBE /nologo /stack:0x10000 /debug -XBCP=xbecopy.exe -# ADD BASE XBCP /NOLOGO -# ADD XBCP /NOLOGO +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +CPP=cl.exe +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I "." /I "SDL-1.2.5\include" /I "SDL_image-1.2" /I "plib-1.6.0" /D "WIN32" /D "_XBOX" /D "_DEBUG" /Fr /YX"global.h" /FD /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "." /I "SDL-1.2.5\include" /I "SDL_image-1.2" /I "plib-1.6.0" /D "WIN32" /D "_XBOX" /D "_DEBUG" /Fr /YX"global.h" /FD /c # Begin Special Build Tool -PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ +PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi # End Special Build Tool @@ -140,7 +140,7 @@ IntDir=.\../Release6 TargetDir=\stepmania\stepmania TargetName=StepMania SOURCE="$(InputPath)" -PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ +PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi # End Special Build Tool @@ -1941,23 +1941,6 @@ SOURCE=.\BitmapText.h # End Source File # Begin Source File -SOURCE=.\CompositedText.cpp - -!IF "$(CFG)" == "StepMania - Win32 Debug" - -!ELSEIF "$(CFG)" == "StepMania - Xbox Debug" - -!ELSEIF "$(CFG)" == "StepMania - Win32 Release" - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\CompositedText.h -# End Source File -# Begin Source File - SOURCE=.\mathlib.c !IF "$(CFG)" == "StepMania - Win32 Debug" diff --git a/stepmania/src/StepMania.vcproj b/stepmania/src/StepMania.vcproj index e15691cfb4..59e31f4ac9 100644 --- a/stepmania/src/StepMania.vcproj +++ b/stepmania/src/StepMania.vcproj @@ -1661,12 +1661,6 @@ cl /Zl /nologo /c verstub.cpp /Fo"$(IntDir)"\ - - - - diff --git a/stepmania/src/TextBanner.cpp b/stepmania/src/TextBanner.cpp index e849cb9d31..6cad51dc2e 100644 --- a/stepmania/src/TextBanner.cpp +++ b/stepmania/src/TextBanner.cpp @@ -16,6 +16,7 @@ #include "PrefsManager.h" #include "ThemeManager.h" #include "SongManager.h" +#include "RageTextureManager.h" #define WIDTH THEME->GetMetricF("TextBanner","Width") @@ -104,14 +105,6 @@ void TextBanner::LoadFromString( m_textSubTitle.SetZoom( fSubTitleZoom ); m_textArtist.SetZoom( fArtistZoom ); -// RageTextureID ID; -// ID.filename = THEME->GetPathToF("TextBanner"); -// ID.text = sDisplayTitle; -// m_textTitle.Load( ID ); -// ID.text = sDisplaySubTitle; -// m_textSubTitle.Load( ID ); -// ID.text = sDisplayArtist; -// m_textArtist.Load( ID ); m_textTitle.SetTextMaxWidth( g_fWidth, sDisplayTitle, sTranslitTitle ); m_textSubTitle.SetTextMaxWidth( g_fWidth, sDisplaySubTitle, sTranslitSubTitle ); m_textArtist.SetTextMaxWidth( g_fWidth, sDisplayArtist, sTranslitArtist ); diff --git a/stepmania/src/TextBanner.h b/stepmania/src/TextBanner.h index b9c7da57ab..385805c483 100644 --- a/stepmania/src/TextBanner.h +++ b/stepmania/src/TextBanner.h @@ -28,7 +28,6 @@ public: private: BitmapText m_textTitle, m_textSubTitle, m_textArtist; - //Sprite m_textTitle, m_textSubTitle, m_textArtist; }; #endif