convert size_t to uint32_t and int to int32

This commit is contained in:
Jeremie Roy 2013-04-23 22:32:39 +02:00
parent e851f5dec6
commit 5096f82d12
3 changed files with 38 additions and 42 deletions

View file

@ -89,7 +89,7 @@ bool RectanglePacker::addRectangle(uint16_t _width, uint16_t _height, uint16_t&
_outX = 0; _outX = 0;
_outY = 0; _outY = 0;
size_t i; uint32_t i;
best_height = INT_MAX; best_height = INT_MAX;
best_index = -1; best_index = -1;

View file

@ -191,10 +191,10 @@ bool FontManager::TrueTypeFont::bakeGlyphAlpha(CodePoint_t _codePoint, GlyphInfo
FT_BitmapGlyph bitmap = (FT_BitmapGlyph)glyph; FT_BitmapGlyph bitmap = (FT_BitmapGlyph)glyph;
int x = bitmap->left; int32_t x = bitmap->left;
int y = -bitmap->top; int32_t y = -bitmap->top;
int w = bitmap->bitmap.width; int32_t w = bitmap->bitmap.width;
int h = bitmap->bitmap.rows; int32_t h = bitmap->bitmap.rows;
_glyphInfo.m_offset_x = (float) x; _glyphInfo.m_offset_x = (float) x;
_glyphInfo.m_offset_y = (float) y; _glyphInfo.m_offset_y = (float) y;
@ -203,10 +203,10 @@ bool FontManager::TrueTypeFont::bakeGlyphAlpha(CodePoint_t _codePoint, GlyphInfo
_glyphInfo.m_advance_x = (float)slot->advance.x /64.0f; _glyphInfo.m_advance_x = (float)slot->advance.x /64.0f;
_glyphInfo.m_advance_y = (float)slot->advance.y /64.0f; _glyphInfo.m_advance_y = (float)slot->advance.y /64.0f;
int charsize = 1; int32_t charsize = 1;
int depth=1; int32_t depth=1;
int stride = bitmap->bitmap.pitch; int32_t stride = bitmap->bitmap.pitch;
for( int i=0; i<h; ++i ) for( int32_t i=0; i<h; ++i )
{ {
memcpy(_outBuffer+(i*w) * charsize * depth, memcpy(_outBuffer+(i*w) * charsize * depth,
bitmap->bitmap.buffer + (i*stride) * charsize, w * charsize * depth ); bitmap->bitmap.buffer + (i*stride) * charsize, w * charsize * depth );
@ -234,10 +234,10 @@ bool FontManager::TrueTypeFont::bakeGlyphSubpixel(CodePoint_t _codePoint, GlyphI
if(error){ return false; } if(error){ return false; }
FT_BitmapGlyph bitmap = (FT_BitmapGlyph)glyph; FT_BitmapGlyph bitmap = (FT_BitmapGlyph)glyph;
int x = bitmap->left; int32_t x = bitmap->left;
int y = -bitmap->top; int32_t y = -bitmap->top;
int w = bitmap->bitmap.width; int32_t w = bitmap->bitmap.width;
int h = bitmap->bitmap.rows; int32_t h = bitmap->bitmap.rows;
_glyphInfo.m_offset_x = (float) x; _glyphInfo.m_offset_x = (float) x;
_glyphInfo.m_offset_y = (float) y; _glyphInfo.m_offset_y = (float) y;
@ -245,10 +245,10 @@ bool FontManager::TrueTypeFont::bakeGlyphSubpixel(CodePoint_t _codePoint, GlyphI
_glyphInfo.m_height = (float) h; _glyphInfo.m_height = (float) h;
_glyphInfo.m_advance_x = (float)slot->advance.x /64.0f; _glyphInfo.m_advance_x = (float)slot->advance.x /64.0f;
_glyphInfo.m_advance_y = (float)slot->advance.y /64.0f; _glyphInfo.m_advance_y = (float)slot->advance.y /64.0f;
int charsize = 1; int32_t charsize = 1;
int depth=3; int32_t depth=3;
int stride = bitmap->bitmap.pitch; int32_t stride = bitmap->bitmap.pitch;
for( int i=0; i<h; ++i ) for( int32_t i=0; i<h; ++i )
{ {
memcpy(_outBuffer+(i*w) * charsize * depth, memcpy(_outBuffer+(i*w) * charsize * depth,
bitmap->bitmap.buffer + (i*stride) * charsize, w * charsize * depth ); bitmap->bitmap.buffer + (i*stride) * charsize, w * charsize * depth );
@ -358,10 +358,10 @@ bool FontManager::TrueTypeFont::bakeGlyphDistance(CodePoint_t _codePoint, GlyphI
FT_BitmapGlyph bitmap = (FT_BitmapGlyph)glyph; FT_BitmapGlyph bitmap = (FT_BitmapGlyph)glyph;
int x = bitmap->left; int32_t x = bitmap->left;
int y = -bitmap->top; int32_t y = -bitmap->top;
int w = bitmap->bitmap.width; int32_t w = bitmap->bitmap.width;
int h = bitmap->bitmap.rows; int32_t h = bitmap->bitmap.rows;
_glyphInfo.m_offset_x = (float) x; _glyphInfo.m_offset_x = (float) x;
_glyphInfo.m_offset_y = (float) y; _glyphInfo.m_offset_y = (float) y;
@ -370,11 +370,11 @@ bool FontManager::TrueTypeFont::bakeGlyphDistance(CodePoint_t _codePoint, GlyphI
_glyphInfo.m_advance_x = (float)slot->advance.x /64.0f; _glyphInfo.m_advance_x = (float)slot->advance.x /64.0f;
_glyphInfo.m_advance_y = (float)slot->advance.y /64.0f; _glyphInfo.m_advance_y = (float)slot->advance.y /64.0f;
int charsize = 1; int32_t charsize = 1;
int depth=1; int32_t depth=1;
int stride = bitmap->bitmap.pitch; int32_t stride = bitmap->bitmap.pitch;
for( int i=0; i<h; ++i ) for(int32_t i=0; i<h; ++i )
{ {
memcpy(_outBuffer+(i*w) * charsize * depth, memcpy(_outBuffer+(i*w) * charsize * depth,
@ -522,7 +522,7 @@ TrueTypeHandle FontManager::loadTrueTypeFromFile(const char* _fontPath)
fseek(pFile, 0L, SEEK_SET); fseek(pFile, 0L, SEEK_SET);
// Read the entire file into memory. // Read the entire file into memory.
size_t newLen = fread((void*)buffer, sizeof(char), bufsize, pFile); uint32_t newLen = fread((void*)buffer, sizeof(char), bufsize, pFile);
if (newLen == 0) if (newLen == 0)
{ {
fclose(pFile); fclose(pFile);
@ -653,7 +653,7 @@ bool FontManager::preloadGlyph(FontHandle _handle, const wchar_t* _string)
if(font.m_trueTypeFont != NULL) if(font.m_trueTypeFont != NULL)
{ {
//parse string //parse string
for( size_t i=0, end = wcslen(_string) ; i < end; ++i ) for( uint32_t i=0, end = wcslen(_string) ; i < end; ++i )
{ {
//if glyph cached, continue //if glyph cached, continue
CodePoint_t codePoint = _string[i]; CodePoint_t codePoint = _string[i];

View file

@ -148,7 +148,7 @@ private:
(((_rgba >> 24) & 0xff) << 0); (((_rgba >> 24) & 0xff) << 0);
} }
static const size_t MAX_BUFFERED_CHARACTERS = 8192; static const uint32_t MAX_BUFFERED_CHARACTERS = 8192;
uint32_t m_styleFlags; uint32_t m_styleFlags;
@ -174,7 +174,7 @@ private:
/// ///
FontManager* m_fontManager; FontManager* m_fontManager;
void setVertex(size_t _i, float _x, float _y, uint32_t _rgba, uint8_t _style = STYLE_NORMAL) void setVertex(uint32_t _i, float _x, float _y, uint32_t _rgba, uint8_t _style = STYLE_NORMAL)
{ {
m_vertexBuffer[_i].x = _x; m_vertexBuffer[_i].x = _x;
m_vertexBuffer[_i].y = _y; m_vertexBuffer[_i].y = _y;
@ -193,9 +193,9 @@ private:
uint16_t* m_indexBuffer; uint16_t* m_indexBuffer;
uint8_t* m_styleBuffer; uint8_t* m_styleBuffer;
size_t m_vertexCount; uint32_t m_vertexCount;
size_t m_indexCount; uint32_t m_indexCount;
size_t m_lineStartIndex; uint32_t m_lineStartIndex;
}; };
@ -288,7 +288,7 @@ void TextBuffer::appendText(FontHandle _fontHandle, const wchar_t * _string)
} }
//parse string //parse string
for( size_t i=0, end = wcslen(_string) ; i < end; ++i ) for( uint32_t i=0, end = wcslen(_string) ; i < end; ++i )
{ {
//if glyph cached, continue //if glyph cached, continue
uint32_t _codePoint = _string[i]; uint32_t _codePoint = _string[i];
@ -489,7 +489,7 @@ void TextBuffer::appendGlyph(CodePoint_t _codePoint, const FontInfo& _font, cons
void TextBuffer::verticalCenterLastLine(float _dy, float _top, float _bottom) void TextBuffer::verticalCenterLastLine(float _dy, float _top, float _bottom)
{ {
for( size_t i=m_lineStartIndex; i < m_vertexCount; i+=4 ) for( uint32_t i=m_lineStartIndex; i < m_vertexCount; i+=4 )
{ {
if( m_styleBuffer[i] == STYLE_BACKGROUND) if( m_styleBuffer[i] == STYLE_BACKGROUND)
{ {
@ -621,8 +621,8 @@ void TextBufferManager::submitTextBuffer(TextBufferHandle _handle, uint8_t _id,
assert(bgfx::invalidHandle != _handle.idx); assert(bgfx::invalidHandle != _handle.idx);
BufferCache& bc = m_textBuffers[_handle.idx]; BufferCache& bc = m_textBuffers[_handle.idx];
size_t indexSize = bc.m_textBuffer->getIndexCount() * bc.m_textBuffer->getIndexSize(); uint32_t indexSize = bc.m_textBuffer->getIndexCount() * bc.m_textBuffer->getIndexSize();
size_t vertexSize = bc.m_textBuffer->getVertexCount() * bc.m_textBuffer->getVertexSize(); uint32_t vertexSize = bc.m_textBuffer->getVertexCount() * bc.m_textBuffer->getVertexSize();
const bgfx::Memory* mem; const bgfx::Memory* mem;
bgfx::setTexture(0, m_u_texColor, m_fontManager->getAtlas()->getTextureHandle()); bgfx::setTexture(0, m_u_texColor, m_fontManager->getAtlas()->getTextureHandle());
@ -692,11 +692,8 @@ void TextBufferManager::submitTextBuffer(TextBufferHandle _handle, uint8_t _id,
}else }else
{ {
ibh.idx = bc.m_indexBufferHandle; ibh.idx = bc.m_indexBufferHandle;
vbh.idx = bc.m_vertexBufferHandle; vbh.idx = bc.m_vertexBufferHandle;
static int i=0;
//if(i++ < 5)
{
mem = bgfx::alloc(indexSize); mem = bgfx::alloc(indexSize);
memcpy(mem->data, bc.m_textBuffer->getIndexBuffer(), indexSize); memcpy(mem->data, bc.m_textBuffer->getIndexBuffer(), indexSize);
bgfx::updateDynamicIndexBuffer(ibh, mem); bgfx::updateDynamicIndexBuffer(ibh, mem);
@ -704,7 +701,6 @@ void TextBufferManager::submitTextBuffer(TextBufferHandle _handle, uint8_t _id,
mem = bgfx::alloc(vertexSize); mem = bgfx::alloc(vertexSize);
memcpy(mem->data, bc.m_textBuffer->getVertexBuffer(), vertexSize); memcpy(mem->data, bc.m_textBuffer->getVertexBuffer(), vertexSize);
bgfx::updateDynamicVertexBuffer(vbh, mem); bgfx::updateDynamicVertexBuffer(vbh, mem);
}
} }
bgfx::setVertexBuffer(vbh, bc.m_textBuffer->getVertexCount()); bgfx::setVertexBuffer(vbh, bc.m_textBuffer->getVertexCount());
bgfx::setIndexBuffer(ibh, bc.m_textBuffer->getIndexCount()); bgfx::setIndexBuffer(ibh, bc.m_textBuffer->getIndexCount());