Remove composited text. The large amount of memory it uses is a bigger penalty than drawing a quad for each glyph.
This commit is contained in:
@@ -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
|
||||
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.
|
||||
|
||||
@@ -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<wstring> asTextLines;
|
||||
split(CStringToWstring(sText), L"\n", asTextLines, false);
|
||||
|
||||
/* calculate line lengths and widths */
|
||||
vector<int> LineWidths;
|
||||
int iWidestLineWidth = 0;
|
||||
for( unsigned l=0; l<asTextLines.size(); l++ ) // for each line
|
||||
{
|
||||
LineWidths.push_back(pFont->GetLineWidthInSourcePixels( 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; i<asTextLines.size(); i++ ) // foreach line
|
||||
{
|
||||
iY += pFont->GetHeight();
|
||||
const wstring &sLine = asTextLines[i];
|
||||
const int iLineWidth = LineWidths[i];
|
||||
|
||||
int iX = PADDING/2;
|
||||
|
||||
for( unsigned j=0; j<sLine.size(); j++ ) // for each character in the line
|
||||
{
|
||||
const glyph &g = pFont->GetGlyph( 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;
|
||||
}
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -49,7 +49,6 @@ bool RageTextureID::operator<(const RageTextureID &rhs) const
|
||||
{
|
||||
#define COMP(a) if(a<rhs.a) return true; if(a>rhs.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) &&
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 );
|
||||
|
||||
|
||||
@@ -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 );
|
||||
|
||||
+15
-32
@@ -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"
|
||||
|
||||
@@ -1661,12 +1661,6 @@ cl /Zl /nologo /c verstub.cpp /Fo"$(IntDir)"\
|
||||
<File
|
||||
RelativePath=".\BitmapText.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="CompositedText.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="CompositedText.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="Milkshape.h">
|
||||
</File>
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -28,7 +28,6 @@ public:
|
||||
private:
|
||||
|
||||
BitmapText m_textTitle, m_textSubTitle, m_textArtist;
|
||||
//Sprite m_textTitle, m_textSubTitle, m_textArtist;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user