Merge default into minor

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2016-05-12 18:20:01 -03:00
16 changed files with 131 additions and 58 deletions
+10
View File
@@ -79,6 +79,16 @@ Quad::Viewport Quad::getViewport() const
return viewport;
}
double Quad::getTextureWidth() const
{
return sw;
}
double Quad::getTextureHeight() const
{
return sh;
}
const Vertex *Quad::getVertices() const
{
return vertices;
+3
View File
@@ -47,6 +47,9 @@ public:
void setViewport(const Viewport &v);
Viewport getViewport() const;
double getTextureWidth() const;
double getTextureHeight() const;
const Vertex *getVertices() const;
private:
+10 -19
View File
@@ -252,7 +252,7 @@ love::font::GlyphData *Font::getRasterizerGlyphData(uint32 glyph)
const Font::Glyph &Font::addGlyph(uint32 glyph)
{
love::font::GlyphData *gd = getRasterizerGlyphData(glyph);
StrongRef<love::font::GlyphData> gd(getRasterizerGlyphData(glyph), Acquire::NORETAIN);
int w = gd->getWidth();
int h = gd->getHeight();
@@ -264,18 +264,15 @@ const Font::Glyph &Font::addGlyph(uint32 glyph)
textureY += rowHeight;
rowHeight = TEXTURE_PADDING;
}
if (textureY + h + TEXTURE_PADDING > textureHeight)
{
// totally out of space - new texture!
try
{
createTexture();
}
catch (love::Exception &)
{
gd->release();
throw;
}
createTexture();
// Makes sure the above code for checking if the glyph can fit at
// the current position in the texture is run again for this glyph.
return addGlyph(glyph);
}
Glyph g;
@@ -318,18 +315,12 @@ const Font::Glyph &Font::addGlyph(uint32 glyph)
g.vertices[i].x += gd->getBearingX();
g.vertices[i].y -= gd->getBearingY();
}
textureX += w + TEXTURE_PADDING;
rowHeight = std::max(rowHeight, h + TEXTURE_PADDING);
}
if (w > 0)
textureX += (w + TEXTURE_PADDING);
if (h > 0)
rowHeight = std::max(rowHeight, h + TEXTURE_PADDING);
gd->release();
const auto p = glyphs.insert(std::make_pair(glyph, g));
return p.first->second;
}
+11
View File
@@ -64,10 +64,21 @@ int w_Quad_getViewport(lua_State *L)
return 4;
}
int w_Quad_getTextureDimensions(lua_State *L)
{
Quad *quad = luax_checkquad(L, 1);
double sw = quad->getTextureWidth();
double sh = quad->getTextureHeight();
lua_pushnumber(L, sw);
lua_pushnumber(L, sh);
return 2;
}
static const luaL_Reg w_Quad_functions[] =
{
{ "setViewport", w_Quad_setViewport },
{ "getViewport", w_Quad_getViewport },
{ "getTextureDimensions", w_Quad_getTextureDimensions },
{ 0, 0 }
};