From 5096f82d12d4097780b256fd42304776cee29aee Mon Sep 17 00:00:00 2001 From: Jeremie Roy Date: Tue, 23 Apr 2013 22:32:39 +0200 Subject: [PATCH] convert size_t to uint32_t and int to int32 --- examples/common/cube_atlas.cpp | 2 +- examples/common/font/font_manager.cpp | 52 ++++++++++---------- examples/common/font/text_buffer_manager.cpp | 26 +++++----- 3 files changed, 38 insertions(+), 42 deletions(-) diff --git a/examples/common/cube_atlas.cpp b/examples/common/cube_atlas.cpp index c56ad3b9..e18c6911 100644 --- a/examples/common/cube_atlas.cpp +++ b/examples/common/cube_atlas.cpp @@ -89,7 +89,7 @@ bool RectanglePacker::addRectangle(uint16_t _width, uint16_t _height, uint16_t& _outX = 0; _outY = 0; - size_t i; + uint32_t i; best_height = INT_MAX; best_index = -1; diff --git a/examples/common/font/font_manager.cpp b/examples/common/font/font_manager.cpp index 8b22a60c..4642c9dc 100644 --- a/examples/common/font/font_manager.cpp +++ b/examples/common/font/font_manager.cpp @@ -191,10 +191,10 @@ bool FontManager::TrueTypeFont::bakeGlyphAlpha(CodePoint_t _codePoint, GlyphInfo FT_BitmapGlyph bitmap = (FT_BitmapGlyph)glyph; - int x = bitmap->left; - int y = -bitmap->top; - int w = bitmap->bitmap.width; - int h = bitmap->bitmap.rows; + int32_t x = bitmap->left; + int32_t y = -bitmap->top; + int32_t w = bitmap->bitmap.width; + int32_t h = bitmap->bitmap.rows; _glyphInfo.m_offset_x = (float) x; _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_y = (float)slot->advance.y /64.0f; - int charsize = 1; - int depth=1; - int stride = bitmap->bitmap.pitch; - for( int i=0; ibitmap.pitch; + for( int32_t i=0; ibitmap.buffer + (i*stride) * charsize, w * charsize * depth ); @@ -234,10 +234,10 @@ bool FontManager::TrueTypeFont::bakeGlyphSubpixel(CodePoint_t _codePoint, GlyphI if(error){ return false; } FT_BitmapGlyph bitmap = (FT_BitmapGlyph)glyph; - int x = bitmap->left; - int y = -bitmap->top; - int w = bitmap->bitmap.width; - int h = bitmap->bitmap.rows; + int32_t x = bitmap->left; + int32_t y = -bitmap->top; + int32_t w = bitmap->bitmap.width; + int32_t h = bitmap->bitmap.rows; _glyphInfo.m_offset_x = (float) x; _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_advance_x = (float)slot->advance.x /64.0f; _glyphInfo.m_advance_y = (float)slot->advance.y /64.0f; - int charsize = 1; - int depth=3; - int stride = bitmap->bitmap.pitch; - for( int i=0; ibitmap.pitch; + for( int32_t i=0; ibitmap.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; - int x = bitmap->left; - int y = -bitmap->top; - int w = bitmap->bitmap.width; - int h = bitmap->bitmap.rows; + int32_t x = bitmap->left; + int32_t y = -bitmap->top; + int32_t w = bitmap->bitmap.width; + int32_t h = bitmap->bitmap.rows; _glyphInfo.m_offset_x = (float) x; _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_y = (float)slot->advance.y /64.0f; - int charsize = 1; - int depth=1; - int stride = bitmap->bitmap.pitch; + int32_t charsize = 1; + int32_t depth=1; + int32_t stride = bitmap->bitmap.pitch; - for( int i=0; i> 24) & 0xff) << 0); } - static const size_t MAX_BUFFERED_CHARACTERS = 8192; + static const uint32_t MAX_BUFFERED_CHARACTERS = 8192; uint32_t m_styleFlags; @@ -174,7 +174,7 @@ private: /// 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].y = _y; @@ -193,9 +193,9 @@ private: uint16_t* m_indexBuffer; uint8_t* m_styleBuffer; - size_t m_vertexCount; - size_t m_indexCount; - size_t m_lineStartIndex; + uint32_t m_vertexCount; + uint32_t m_indexCount; + uint32_t m_lineStartIndex; }; @@ -288,7 +288,7 @@ void TextBuffer::appendText(FontHandle _fontHandle, const wchar_t * _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 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) { - 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) { @@ -621,8 +621,8 @@ void TextBufferManager::submitTextBuffer(TextBufferHandle _handle, uint8_t _id, assert(bgfx::invalidHandle != _handle.idx); BufferCache& bc = m_textBuffers[_handle.idx]; - size_t indexSize = bc.m_textBuffer->getIndexCount() * bc.m_textBuffer->getIndexSize(); - size_t vertexSize = bc.m_textBuffer->getVertexCount() * bc.m_textBuffer->getVertexSize(); + uint32_t indexSize = bc.m_textBuffer->getIndexCount() * bc.m_textBuffer->getIndexSize(); + uint32_t vertexSize = bc.m_textBuffer->getVertexCount() * bc.m_textBuffer->getVertexSize(); const bgfx::Memory* mem; bgfx::setTexture(0, m_u_texColor, m_fontManager->getAtlas()->getTextureHandle()); @@ -692,11 +692,8 @@ void TextBufferManager::submitTextBuffer(TextBufferHandle _handle, uint8_t _id, }else { ibh.idx = bc.m_indexBufferHandle; - vbh.idx = bc.m_vertexBufferHandle; - - static int i=0; - //if(i++ < 5) - { + vbh.idx = bc.m_vertexBufferHandle; + mem = bgfx::alloc(indexSize); memcpy(mem->data, bc.m_textBuffer->getIndexBuffer(), indexSize); bgfx::updateDynamicIndexBuffer(ibh, mem); @@ -704,7 +701,6 @@ void TextBufferManager::submitTextBuffer(TextBufferHandle _handle, uint8_t _id, mem = bgfx::alloc(vertexSize); memcpy(mem->data, bc.m_textBuffer->getVertexBuffer(), vertexSize); bgfx::updateDynamicVertexBuffer(vbh, mem); - } } bgfx::setVertexBuffer(vbh, bc.m_textBuffer->getVertexCount()); bgfx::setIndexBuffer(ibh, bc.m_textBuffer->getIndexCount());