optimized the font stuff

This commit is contained in:
ardi@ist-einmalig.de 2009-10-19 23:09:27 +00:00
parent 31cd4d03e2
commit 6d1178c26d
7 changed files with 142 additions and 157 deletions

View File

@ -64,12 +64,16 @@ typedef struct ftgxDataOffset_ {
* @param textureFormat Optional format (GX_TF_*) of the texture as defined by the libogc gx.h header file. If not specified default value is GX_TF_RGBA8. * @param textureFormat Optional format (GX_TF_*) of the texture as defined by the libogc gx.h header file. If not specified default value is GX_TF_RGBA8.
* @param vertexIndex Optional vertex format index (GX_VTXFMT*) of the glyph textures as defined by the libogc gx.h header file. If not specified default value is GX_VTXFMT1. * @param vertexIndex Optional vertex format index (GX_VTXFMT*) of the glyph textures as defined by the libogc gx.h header file. If not specified default value is GX_VTXFMT1.
*/ */
FreeTypeGX::FreeTypeGX(uint8_t textureFormat, uint8_t vertexIndex) : ftFace(NULL), ftFace_fromFile(NULL) { FreeTypeGX::FreeTypeGX(uint8_t textureFormat, uint8_t vertexIndex, uint32_t compatibilityMode)
:
ftFace(NULL),
ftFace_fromFile(NULL)
{
FT_Init_FreeType(&this->ftLibrary); FT_Init_FreeType(&this->ftLibrary);
this->textureFormat = textureFormat; this->textureFormat = textureFormat;
this->setVertexFormat(vertexIndex); this->setVertexFormat(vertexIndex);
this->setCompatibilityMode(FTGX_COMPATIBILITY_NONE); this->setCompatibilityMode(compatibilityMode);
} }
/** /**
@ -89,10 +93,10 @@ FreeTypeGX::~FreeTypeGX() {
* @param strChar Character string to be converted. * @param strChar Character string to be converted.
* @return Wide character representation of supplied character string. * @return Wide character representation of supplied character string.
*/ */
wchar_t* FreeTypeGX::charToWideChar(char* strChar) { wchar_t* FreeTypeGX::charToWideChar(const char* strChar) {
wchar_t *strWChar; wchar_t *strWChar;
try {strWChar = new wchar_t[strlen(strChar) + 1];} strWChar = new(std::nothrow) wchar_t[strlen(strChar) + 1];
catch (...) { return 0; } if(!strWChar) return NULL;
// UTF-8 // UTF-8
int bt; int bt;
bt = mbstowcs(strWChar, strChar, strlen(strChar)); bt = mbstowcs(strWChar, strChar, strlen(strChar));
@ -101,21 +105,12 @@ wchar_t* FreeTypeGX::charToWideChar(char* strChar) {
return strWChar; return strWChar;
} }
char *tempSrc = strChar;
wchar_t *tempDest = strWChar; wchar_t *tempDest = strWChar;
while ((*tempDest++ = *tempSrc++)); while ((*tempDest++ = *strChar++));
return strWChar; return strWChar;
} }
/**
*
* \overload
*/
wchar_t* FreeTypeGX::charToWideChar(const char* strChar) {
return FreeTypeGX::charToWideChar((char*) strChar);
}
/** /**
* Setup the vertex attribute formats for the glyph textures. * Setup the vertex attribute formats for the glyph textures.
* *
@ -205,9 +200,9 @@ void FreeTypeGX::setDefaultMode() {
* @param pointSize The desired point size this wrapper's configured font face. * @param pointSize The desired point size this wrapper's configured font face.
* @param cacheAll Optional flag to specify if all font characters should be cached when the class object is created. If specified as false the characters only become cached the first time they are used. If not specified default value is false. * @param cacheAll Optional flag to specify if all font characters should be cached when the class object is created. If specified as false the characters only become cached the first time they are used. If not specified default value is false.
*/ */
uint16_t FreeTypeGX::loadFont(char* fontPath, uint8_t* fontBuffer, FT_Long bufferSize, FT_UInt pointSize, bool cacheAll) { uint16_t FreeTypeGX::loadFont(const char* fontPath, const uint8_t* fontBuffer, FT_Long bufferSize, FT_UInt pointSize, bool cacheAll) {
this->unloadFont(); this->unloadFont();
this->ftPointSize = pointSize; this->ftPointSize_v = this->ftPointSize_h = 0;
struct stat st; struct stat st;
if (fontPath && (stat(fontPath, &st)==0)) { if (fontPath && (stat(fontPath, &st)==0)) {
@ -229,8 +224,8 @@ uint16_t FreeTypeGX::loadFont(char* fontPath, uint8_t* fontBuffer, FT_Long buffe
if (ftFace_fromFile == NULL) if (ftFace_fromFile == NULL)
FT_New_Memory_Face(this->ftLibrary, (FT_Byte *)fontBuffer, bufferSize, 0, &this->ftFace); FT_New_Memory_Face(this->ftLibrary, (FT_Byte *)fontBuffer, bufferSize, 0, &this->ftFace);
if (this->ftPointSize > 0) if (pointSize > 0)
FT_Set_Pixel_Sizes(this->ftFace, 0, this->ftPointSize); changeSize(pointSize);
this->ftSlot = this->ftFace->glyph; this->ftSlot = this->ftFace->glyph;
this->ftKerningEnabled = FT_HAS_KERNING(this->ftFace); this->ftKerningEnabled = FT_HAS_KERNING(this->ftFace);
@ -242,14 +237,6 @@ uint16_t FreeTypeGX::loadFont(char* fontPath, uint8_t* fontBuffer, FT_Long buffe
return 0; return 0;
} }
/**
*
* \overload
*/
uint16_t FreeTypeGX::loadFont(const char* fontPath, const uint8_t* fontBuffer, FT_Long bufferSize, FT_UInt pointSize, bool cacheAll) {
return this->loadFont((char*)fontPath, (uint8_t *)fontBuffer, bufferSize, pointSize, cacheAll);
}
void FreeTypeGX::unloadFont() { void FreeTypeGX::unloadFont() {
clearGlyphData(); clearGlyphData();
@ -268,23 +255,38 @@ void FreeTypeGX::unloadFont() {
* This routine clears all members of the font map structure and frees all allocated memory back to the system. * This routine clears all members of the font map structure and frees all allocated memory back to the system.
*/ */
void FreeTypeGX::clearGlyphData() { void FreeTypeGX::clearGlyphData() {
if (this->fontData.size() == 0) if (this->fontDatas.size() == 0)
return; return;
GX_DrawDone(); GX_DrawDone();
GX_Flush(); GX_Flush();
for ( std::map<wchar_t, ftgxCharData>::iterator i = this->fontData.begin(); i != this->fontData.end(); i++) { for ( std::map<uint16_t, FTGX_Cache>::iterator i = this->fontDatas.begin(); i != this->fontDatas.end(); i++)
{
for ( FTGX_Cache::iterator j = i->second.begin(); j != i->second.end(); j++)
{
free(j->second.glyphDataTexture);
}
i->second.clear();
}
/* for ( std::map<wchar_t, ftgxCharData>::iterator i = this->fontData.begin(); i != this->fontData.end(); i++) {
free(i->second.glyphDataTexture); free(i->second.glyphDataTexture);
} }
*/
this->fontData.clear(); this->fontDatas.clear();
} }
void FreeTypeGX::changeSize(FT_UInt vPointSize, FT_UInt hPointSize/*=0*/) { void FreeTypeGX::changeSize(FT_UInt vPointSize, FT_UInt hPointSize/*=0*/) {
this->clearGlyphData(); if(hPointSize == 0) hPointSize = vPointSize;
this->ftPointSize = vPointSize; if(vPointSize > 255) vPointSize = 255;// limit to 255
FT_Set_Pixel_Sizes(this->ftFace, hPointSize, this->ftPointSize); if(hPointSize > 255) hPointSize = 255;
if(this->ftPointSize_v != vPointSize || this->ftPointSize_h != hPointSize)
{
// this->clearGlyphData();
this->ftPointSize_v = vPointSize;
this->ftPointSize_h = hPointSize;
FT_Set_Pixel_Sizes(this->ftFace, this->ftPointSize_h, this->ftPointSize_v);
}
} }
/** /**
@ -358,7 +360,13 @@ uint16_t FreeTypeGX::adjustTextureHeight(uint16_t textureHeight, uint8_t texture
* @param charCode The requested glyph's character code. * @param charCode The requested glyph's character code.
* @return A pointer to the allocated font structure. * @return A pointer to the allocated font structure.
*/ */
ftgxCharData *FreeTypeGX::cacheGlyphData(wchar_t charCode) { ftgxCharData *FreeTypeGX::cacheGlyphData(wchar_t charCode)
{
FTGX_Cache &fontData = this->fontDatas[ftPointSize_v | ftPointSize_h << 8];
return cacheGlyphData(charCode, fontData);
}
ftgxCharData *FreeTypeGX::cacheGlyphData(wchar_t charCode, FTGX_Cache &fontData)
{
FT_UInt gIndex; FT_UInt gIndex;
uint16_t textureWidth = 0, textureHeight = 0; uint16_t textureWidth = 0, textureHeight = 0;
@ -372,7 +380,7 @@ ftgxCharData *FreeTypeGX::cacheGlyphData(wchar_t charCode) {
textureWidth = adjustTextureWidth(glyphBitmap->width, this->textureFormat); textureWidth = adjustTextureWidth(glyphBitmap->width, this->textureFormat);
textureHeight = adjustTextureHeight(glyphBitmap->rows, this->textureFormat); textureHeight = adjustTextureHeight(glyphBitmap->rows, this->textureFormat);
this->fontData[charCode] = (ftgxCharData) { fontData[charCode] = (ftgxCharData) {
this->ftSlot->bitmap_left, this->ftSlot->bitmap_left,
this->ftSlot->advance.x >> 6, this->ftSlot->advance.x >> 6,
gIndex, gIndex,
@ -383,9 +391,9 @@ ftgxCharData *FreeTypeGX::cacheGlyphData(wchar_t charCode) {
glyphBitmap->rows - this->ftSlot->bitmap_top, glyphBitmap->rows - this->ftSlot->bitmap_top,
NULL NULL
}; };
this->loadGlyphData(glyphBitmap, &this->fontData[charCode]); this->loadGlyphData(glyphBitmap, &fontData[charCode]);
return &this->fontData[charCode]; return &fontData[charCode];
} }
} }
@ -544,6 +552,7 @@ uint16_t FreeTypeGX::drawText(int16_t x, int16_t y, wchar_t *text, GXColor color
GXTexObj glyphTexture; GXTexObj glyphTexture;
FT_Vector pairDelta; FT_Vector pairDelta;
ftgxDataOffset offset; ftgxDataOffset offset;
FTGX_Cache &fontData = this->fontDatas[ftPointSize_v | ftPointSize_h << 8];
if (textStyle & FTGX_JUSTIFY_MASK) { if (textStyle & FTGX_JUSTIFY_MASK) {
x_offset = this->getStyleOffsetWidth(this->getWidth(text), textStyle); x_offset = this->getStyleOffsetWidth(this->getWidth(text), textStyle);
@ -555,16 +564,16 @@ uint16_t FreeTypeGX::drawText(int16_t x, int16_t y, wchar_t *text, GXColor color
for (uint16_t i = 0; i < strLength; i++) { for (uint16_t i = 0; i < strLength; i++) {
ftgxCharData* glyphData = NULL; ftgxCharData* glyphData = NULL;
if ( this->fontData.find(text[i]) != this->fontData.end() ) { if ( fontData.find(text[i]) != fontData.end() ) {
glyphData = &this->fontData[text[i]]; glyphData = &fontData[text[i]];
} else { } else {
glyphData = this->cacheGlyphData(text[i]); glyphData = this->cacheGlyphData(text[i], fontData);
} }
if (glyphData != NULL) { if (glyphData != NULL) {
if (this->ftKerningEnabled && i) { if (this->ftKerningEnabled && i) {
FT_Get_Kerning( this->ftFace, this->fontData[text[i - 1]].glyphIndex, glyphData->glyphIndex, FT_KERNING_DEFAULT, &pairDelta ); FT_Get_Kerning( this->ftFace, fontData[text[i - 1]].glyphIndex, glyphData->glyphIndex, FT_KERNING_DEFAULT, &pairDelta );
x_pos += pairDelta.x >> 6; x_pos += pairDelta.x >> 6;
} }
@ -591,7 +600,7 @@ uint16_t FreeTypeGX::drawText(int16_t x, int16_t y, wchar_t const *text, GXColor
} }
void FreeTypeGX::drawTextFeature(int16_t x, int16_t y, uint16_t width, ftgxDataOffset *offsetData, uint16_t format, GXColor color) { void FreeTypeGX::drawTextFeature(int16_t x, int16_t y, uint16_t width, ftgxDataOffset *offsetData, uint16_t format, GXColor color) {
uint16_t featureHeight = this->ftPointSize >> 4 > 0 ? this->ftPointSize >> 4 : 1; uint16_t featureHeight = this->ftPointSize_v >> 4 > 0 ? this->ftPointSize_v >> 4 : 1;
if (format & FTGX_STYLE_UNDERLINE ) { if (format & FTGX_STYLE_UNDERLINE ) {
switch (format & FTGX_ALIGN_MASK) { switch (format & FTGX_ALIGN_MASK) {
@ -642,23 +651,24 @@ void FreeTypeGX::drawTextFeature(int16_t x, int16_t y, uint16_t width, ftgxDataO
* @param text NULL terminated string to calculate. * @param text NULL terminated string to calculate.
* @return The width of the text string in pixels. * @return The width of the text string in pixels.
*/ */
uint16_t FreeTypeGX::getWidth(wchar_t *text) { uint16_t FreeTypeGX::getWidth(const wchar_t *text) {
uint16_t strLength = wcslen(text); uint16_t strLength = wcslen(text);
uint16_t strWidth = 0; uint16_t strWidth = 0;
FT_Vector pairDelta; FT_Vector pairDelta;
FTGX_Cache &fontData = this->fontDatas[ftPointSize_v | ftPointSize_h << 8];
for (uint16_t i = 0; i < strLength; i++) { for (uint16_t i = 0; i < strLength; i++) {
ftgxCharData* glyphData = NULL; ftgxCharData* glyphData = NULL;
if ( this->fontData.find(text[i]) != this->fontData.end() ) { if ( fontData.find(text[i]) != fontData.end() ) {
glyphData = &this->fontData[text[i]]; glyphData = &fontData[text[i]];
} else { } else {
glyphData = this->cacheGlyphData(text[i]); glyphData = this->cacheGlyphData(text[i]);
} }
if (glyphData != NULL) { if (glyphData != NULL) {
if (this->ftKerningEnabled && (i > 0)) { if (this->ftKerningEnabled && (i > 0)) {
FT_Get_Kerning( this->ftFace, this->fontData[text[i - 1]].glyphIndex, glyphData->glyphIndex, FT_KERNING_DEFAULT, &pairDelta ); FT_Get_Kerning( this->ftFace, fontData[text[i - 1]].glyphIndex, glyphData->glyphIndex, FT_KERNING_DEFAULT, &pairDelta );
strWidth += pairDelta.x >> 6; strWidth += pairDelta.x >> 6;
} }
@ -669,13 +679,6 @@ uint16_t FreeTypeGX::getWidth(wchar_t *text) {
return strWidth; return strWidth;
} }
/**
*
* \overload
*/
uint16_t FreeTypeGX::getWidth(wchar_t const *text) {
return this->getWidth((wchar_t *)text);
}
/** /**
* Processes the supplied string and return the height of the string in pixels. * Processes the supplied string and return the height of the string in pixels.
@ -686,21 +689,13 @@ uint16_t FreeTypeGX::getWidth(wchar_t const *text) {
* @param text NULL terminated string to calculate. * @param text NULL terminated string to calculate.
* @return The height of the text string in pixels. * @return The height of the text string in pixels.
*/ */
uint16_t FreeTypeGX::getHeight(wchar_t *text) { uint16_t FreeTypeGX::getHeight(const wchar_t *text) {
ftgxDataOffset offset; ftgxDataOffset offset;
this->getOffset(text, &offset); this->getOffset(text, &offset);
return offset.max - offset.min; return offset.max - offset.min;
} }
/**
*
* \overload
*/
uint16_t FreeTypeGX::getHeight(wchar_t const *text) {
return this->getHeight((wchar_t *)text);
}
/** /**
* Get the maximum offset above and minimum offset below the font origin line. * Get the maximum offset above and minimum offset below the font origin line.
* *
@ -711,15 +706,16 @@ uint16_t FreeTypeGX::getHeight(wchar_t const *text) {
* @param offset returns the max and min values above and below the font origin line * @param offset returns the max and min values above and below the font origin line
* *
*/ */
ftgxDataOffset* FreeTypeGX::getOffset(wchar_t *text, ftgxDataOffset* offset) { ftgxDataOffset* FreeTypeGX::getOffset(const wchar_t *text, ftgxDataOffset* offset) {
uint16_t strLength = wcslen(text); uint16_t strLength = wcslen(text);
int16_t strMax = 0, strMin = 9999; int16_t strMax = 0, strMin = 9999;
FTGX_Cache &fontData = this->fontDatas[ftPointSize_v | ftPointSize_h << 8];
for (uint16_t i = 0; i < strLength; i++) { for (uint16_t i = 0; i < strLength; i++) {
ftgxCharData* glyphData = NULL; ftgxCharData* glyphData = NULL;
if ( this->fontData.find(text[i]) != this->fontData.end() ) { if ( fontData.find(text[i]) != fontData.end() ) {
glyphData = &this->fontData[text[i]]; glyphData = &fontData[text[i]];
} else { } else {
glyphData = this->cacheGlyphData(text[i]); glyphData = this->cacheGlyphData(text[i]);
} }
@ -736,13 +732,6 @@ ftgxDataOffset* FreeTypeGX::getOffset(wchar_t *text, ftgxDataOffset* offset) {
return offset; return offset;
} }
/**
*
* \overload
*/
ftgxDataOffset* FreeTypeGX::getOffset(wchar_t const *text, ftgxDataOffset* offset) {
return this->getOffset(text, offset);
}
/** /**
* Copies the supplied texture quad to the EFB. * Copies the supplied texture quad to the EFB.

View File

@ -217,6 +217,7 @@ const GXColor ftgxWhite = (GXColor) {
* a specified texture format. Rendering of the data to the EFB is accomplished through the application of high performance * a specified texture format. Rendering of the data to the EFB is accomplished through the application of high performance
* GX texture functions resulting in high throughput of string rendering. * GX texture functions resulting in high throughput of string rendering.
*/ */
typedef std::map<wchar_t, ftgxCharData> FTGX_Cache;
class FreeTypeGX { class FreeTypeGX {
private: private:
@ -224,13 +225,15 @@ private:
FT_Face ftFace; /**< FreeType reusable FT_Face typographic object. */ FT_Face ftFace; /**< FreeType reusable FT_Face typographic object. */
FT_Byte *ftFace_fromFile; FT_Byte *ftFace_fromFile;
FT_GlyphSlot ftSlot; /**< FreeType reusable FT_GlyphSlot glyph container object. */ FT_GlyphSlot ftSlot; /**< FreeType reusable FT_GlyphSlot glyph container object. */
FT_UInt ftPointSize; /**< Requested size of the rendered font. */ FT_UInt ftPointSize_v; /**< Requested size of the rendered font. */
FT_UInt ftPointSize_h; /**< Requested size of the rendered font. */
bool ftKerningEnabled; /**< Flag indicating the availability of font kerning data. */ bool ftKerningEnabled; /**< Flag indicating the availability of font kerning data. */
uint8_t textureFormat; /**< Defined texture format of the target EFB. */ uint8_t textureFormat; /**< Defined texture format of the target EFB. */
uint8_t vertexIndex; /**< Vertex format descriptor index. */ uint8_t vertexIndex; /**< Vertex format descriptor index. */
uint32_t compatibilityMode; /**< Compatibility mode for default tev operations and vertex descriptors. */ uint32_t compatibilityMode; /**< Compatibility mode for default tev operations and vertex descriptors. */
std::map<wchar_t, ftgxCharData> fontData; /**< Map which holds the glyph data structures for the corresponding characters. */ // FTGX_Cache fontData; /**< Map which holds the glyph data structures for the corresponding characters. */
std::map<uint16_t, FTGX_Cache> fontDatas;
static uint16_t adjustTextureWidth(uint16_t textureWidth, uint8_t textureFormat); static uint16_t adjustTextureWidth(uint16_t textureWidth, uint8_t textureFormat);
static uint16_t adjustTextureHeight(uint16_t textureHeight, uint8_t textureFormat); static uint16_t adjustTextureHeight(uint16_t textureHeight, uint8_t textureFormat);
@ -241,6 +244,7 @@ private:
void unloadFont(); void unloadFont();
void clearGlyphData(); void clearGlyphData();
ftgxCharData *cacheGlyphData(wchar_t charCode); ftgxCharData *cacheGlyphData(wchar_t charCode);
ftgxCharData *cacheGlyphData(wchar_t charCode, FTGX_Cache &fontData);
uint16_t cacheGlyphDataComplete(); uint16_t cacheGlyphDataComplete();
void loadGlyphData(FT_Bitmap *bmp, ftgxCharData *charData); void loadGlyphData(FT_Bitmap *bmp, ftgxCharData *charData);
@ -251,27 +255,22 @@ private:
void copyFeatureToFramebuffer(f32 featureWidth, f32 featureHeight, int16_t screenX, int16_t screenY, GXColor color); void copyFeatureToFramebuffer(f32 featureWidth, f32 featureHeight, int16_t screenX, int16_t screenY, GXColor color);
public: public:
FreeTypeGX(uint8_t textureFormat = GX_TF_RGBA8, uint8_t vertexIndex = GX_VTXFMT1); FreeTypeGX(uint8_t textureFormat = GX_TF_RGBA8, uint8_t vertexIndex = GX_VTXFMT1, uint32_t compatibilityMode = FTGX_COMPATIBILITY_NONE);
~FreeTypeGX(); ~FreeTypeGX();
static wchar_t* charToWideChar(char* p);
static wchar_t* charToWideChar(const char* p); static wchar_t* charToWideChar(const char* p);
void setVertexFormat(uint8_t vertexIndex); void setVertexFormat(uint8_t vertexIndex);
void setCompatibilityMode(uint32_t compatibilityMode); void setCompatibilityMode(uint32_t compatibilityMode);
uint16_t loadFont(char* fontPath, uint8_t* fontBuffer, FT_Long bufferSize, FT_UInt pointSize, bool cacheAll = false);
uint16_t loadFont(const char* fontPath, const uint8_t* fontBuffer, FT_Long bufferSize, FT_UInt pointSize, bool cacheAll = false); uint16_t loadFont(const char* fontPath, const uint8_t* fontBuffer, FT_Long bufferSize, FT_UInt pointSize, bool cacheAll = false);
void changeSize(FT_UInt vPointSize, FT_UInt hPointSize=0); void changeSize(FT_UInt vPointSize, FT_UInt hPointSize=0);
uint16_t drawText(int16_t x, int16_t y, wchar_t *text, GXColor color = ftgxWhite, uint16_t textStyling = FTGX_NULL); uint16_t drawText(int16_t x, int16_t y, wchar_t *text, GXColor color = ftgxWhite, uint16_t textStyling = FTGX_NULL);
uint16_t drawText(int16_t x, int16_t y, wchar_t const *text, GXColor color = ftgxWhite, uint16_t textStyling = FTGX_NULL); uint16_t drawText(int16_t x, int16_t y, wchar_t const *text, GXColor color = ftgxWhite, uint16_t textStyling = FTGX_NULL);
uint16_t getWidth(wchar_t *text); uint16_t getWidth(const wchar_t *text);
uint16_t getWidth(wchar_t const *text); uint16_t getHeight(const wchar_t *text);
uint16_t getHeight(wchar_t *text); ftgxDataOffset* getOffset(const wchar_t *text, ftgxDataOffset* offset);
uint16_t getHeight(wchar_t const *text);
ftgxDataOffset* getOffset(wchar_t *text, ftgxDataOffset* offset);
ftgxDataOffset* getOffset(wchar_t const *text, ftgxDataOffset* offset);
}; };
#endif /* FREETYPEGX_H_ */ #endif /* FREETYPEGX_H_ */

View File

@ -10,8 +10,6 @@
#include "gui.h" #include "gui.h"
static int currentSize = 0;
static int currentWidescreen = 0;
static int presetSize = 0; static int presetSize = 0;
static GXColor presetColor = (GXColor){255, 255, 255, 255}; static GXColor presetColor = (GXColor){255, 255, 255, 255};
static int presetMaxWidth = 0; static int presetMaxWidth = 0;
@ -255,13 +253,7 @@ int GuiText::GetTextWidth()
int newSize = size*this->GetScale(); int newSize = size*this->GetScale();
if(newSize != currentSize || currentWidescreen != widescreen)
{
//fontSystem->changeSize(newSize);
(font ? font : fontSystem)->changeSize(newSize, widescreen ? newSize*0.8 : 0); (font ? font : fontSystem)->changeSize(newSize, widescreen ? newSize*0.8 : 0);
currentSize = newSize;
currentWidescreen = widescreen;
}
return (font ? font : fontSystem)->getWidth(text); return (font ? font : fontSystem)->getWidth(text);
} }
@ -287,14 +279,7 @@ void GuiText::Draw()
int newSize = size*this->GetScale(); int newSize = size*this->GetScale();
if(newSize != currentSize || currentWidescreen != widescreen)
{
//fontSystem->changeSize(newSize);
(font ? font : fontSystem)->changeSize(newSize, widescreen ? newSize*0.8 : 0); (font ? font : fontSystem)->changeSize(newSize, widescreen ? newSize*0.8 : 0);
currentSize = newSize;
currentWidescreen = widescreen;
}
int voffset = 0; int voffset = 0;
// if(alignmentVert == ALIGN_MIDDLE) // if(alignmentVert == ALIGN_MIDDLE)

View File

@ -30,6 +30,7 @@ static int showProgress = 0;
static f32 progressDone = 0.0; static f32 progressDone = 0.0;
static bool showTime = false; static bool showTime = false;
static bool showSize = false; static bool showSize = false;
static bool changed = true;
static s32 gameinstalldone = 0; static s32 gameinstalldone = 0;
static s32 gameinstalltotal = -1; static s32 gameinstalltotal = -1;
static time_t start; static time_t start;
@ -52,8 +53,13 @@ static void GameInstallProgress() {
if (gameinstalltotal <= 0) if (gameinstalltotal <= 0)
return; return;
int oldinstalldone = gameinstalldone;
GetProgressValue(&gameinstalldone, &gameinstalltotal); GetProgressValue(&gameinstalldone, &gameinstalltotal);
if((oldinstalldone == gameinstalldone) && (gameinstalldone > 0))
return;
if (gameinstalldone > gameinstalltotal) if (gameinstalldone > gameinstalltotal)
gameinstalldone = gameinstalltotal; gameinstalldone = gameinstalltotal;
@ -89,6 +95,7 @@ static void GameInstallProgress() {
snprintf(progressSizeLeft, sizeof(progressSizeLeft), "%.2fGB/%.2fGB", gamesize * gameinstalldone/gameinstalltotal, gamesize); snprintf(progressSizeLeft, sizeof(progressSizeLeft), "%.2fGB/%.2fGB", gamesize * gameinstalldone/gameinstalltotal, gamesize);
snprintf(progressSpeed, sizeof(progressSpeed), "%.1fMB/s", speed); snprintf(progressSpeed, sizeof(progressSpeed), "%.1fMB/s", speed);
changed = true;
} }
/**************************************************************************** /****************************************************************************
@ -246,9 +253,13 @@ static void ProgressWindow(const char *title, const char *msg1, const char *msg2
while (showProgress) { while (showProgress) {
VIDEO_WaitVSync (); VIDEO_WaitVSync ();
usleep(20000);
GameInstallProgress(); GameInstallProgress();
if(changed)
{
changed = false;
tmp = static_cast<int>(progressbarImg.GetWidth()*progressDone); tmp = static_cast<int>(progressbarImg.GetWidth()*progressDone);
if (CFG.widescreen && Settings.wsprompt == yes) if (CFG.widescreen && Settings.wsprompt == yes)
@ -269,6 +280,7 @@ static void ProgressWindow(const char *title, const char *msg1, const char *msg2
if (msg2) if (msg2)
msg2Txt.SetText(dyn_message); msg2Txt.SetText(dyn_message);
} }
}
promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
while (promptWindow.GetEffect() > 0) usleep(100); while (promptWindow.GetEffect() > 0) usleep(100);
@ -374,6 +386,7 @@ void ShowProgress(const char *title, const char *msg1, char *dynmsg2, f32 done,
showProgress = 1; showProgress = 1;
progressDone = 100.0*done/total; progressDone = 100.0*done/total;
changed = true;
LWP_ResumeThread(progressthread); LWP_ResumeThread(progressthread);
} }
@ -384,7 +397,7 @@ void ShowProgress(const char *title, const char *msg1, char *dynmsg2, f32 done,
* Startup Progressthread in idle prio * Startup Progressthread in idle prio
***************************************************************************/ ***************************************************************************/
void InitProgressThread() { void InitProgressThread() {
LWP_CreateThread(&progressthread, ProgressThread, NULL, NULL, 0, 0); LWP_CreateThread(&progressthread, ProgressThread, NULL, NULL, 0, 80);
} }
/**************************************************************************** /****************************************************************************

View File

@ -494,7 +494,6 @@ int TitleBrowser(u32 type) {
//install or uninstall it //install or uninstall it
if (pick==1) if (pick==1)
{ {
HaltGui(); HaltGui();
w.Remove(&titleTxt); w.Remove(&titleTxt);
w.Remove(&cancelBtn); w.Remove(&cancelBtn);