From f28b92831d166ddc5624f9606f315767a6d69b2c Mon Sep 17 00:00:00 2001 From: ExMix Date: Mon, 7 Jul 2014 10:16:06 +0200 Subject: [PATCH] new tests for font loading --- data/font_test.fdf | 4 + data/font_test.png | Bin 0 -> 1700 bytes data/font_test2.fdf | 3 + data/font_test2.png | Bin 0 -> 748 bytes data/test.png | Bin 16376 -> 0 bytes data/test.txt | 10 - data/test1.png | Bin 36980 -> 0 bytes data/test1.txt | 10 - drape/drape_tests/drape_tests.pro | 2 +- drape/drape_tests/font_texture_tests.cpp | 241 ++++++++++++++--------- 10 files changed, 152 insertions(+), 118 deletions(-) create mode 100644 data/font_test.fdf create mode 100644 data/font_test.png create mode 100644 data/font_test2.fdf create mode 100644 data/font_test2.png delete mode 100644 data/test.png delete mode 100644 data/test.txt delete mode 100644 data/test1.png delete mode 100644 data/test1.txt diff --git a/data/font_test.fdf b/data/font_test.fdf new file mode 100644 index 0000000000..15a98d5e51 --- /dev/null +++ b/data/font_test.fdf @@ -0,0 +1,4 @@ +1 0 0 20 20 0.0 0.0 0.1 +2 20 20 25 25 2.0 4.3 0.2 +3 512 256 256 256 0.1 0.2 1.2 +4 768 512 100 100 0.8 1.0 1.3 diff --git a/data/font_test.png b/data/font_test.png new file mode 100644 index 0000000000000000000000000000000000000000..f9c98713001a60d54071178604639c615534c47d GIT binary patch literal 1700 zcmeAS@N?(olHy`uVBq!ia0y~yU;#2&7&w3=LsVHwJdoln@Q5sCVBi)8VMc~ob0mO* z3dtTpz6=aistgPb%?u1b{{!il3=E|P3=FRl7#OT(FffScPl`Y4#=yX)<>}%WQgQ3e zosGN)6nI=6-~25vW8+{I3GAv5503mKY;tAI_9%xYGbRBB2L=X4p!Eb84feVF|Ic21 zxj~vifuVtcfeGkd5*R?|4=-@Q{S?QhUe=ClVT8kunD9kbLqv2SD<>FtK*gg*QZEFk zXHwZI4iB@3-p|+==8=)7@Mb`c2EhiBb17aE6-deNC?*ZBoIjj=!#DSMin{<#TlZgdrD`NwL1A_vC0ML3YT%fH(3M^>l zOk4d>e{x*INfx{w!|!eUveXTcs4LydWzT|%i4FYDA|Q)1jtS@^6pRnjfXVm&e`bc` W=U9RQq&ByLg2&U<&t;ucLK6U_tV=uq literal 0 HcmV?d00001 diff --git a/data/test.png b/data/test.png deleted file mode 100644 index ee027a91bc3237b13e4ee59c9044b8c550cfbb9e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16376 zcmeI3dr%X19>7(whAU#)tMy$2^vdvfD-dfJ}eS?$$FtGzp&`WR>0!$-N_CLx3$Ve8Fx z=I&-TGfDRQ{QdUx`+dLr%O7dZU%GHq%A^zw!$w*2ECuj;nD`zJKd={DKiCPsMtJi| zc?=slR(ub^T3=7cu%vX>Y|hWG;slPb;=Bs0*{tyTI4A1@7#29ol$XD8;qPBw`e=G6 zl%H=exb)bi^oeN`+d~a+G``gMTBG=yO8)v+AyN@~R=mb@@RlLt2o3Rc$L~YOLZOhi z^z^4)e`smcg<4nU+dqVg^^J`m%${*L3r1fYnUrL%tF`8iNJ?T-lahjY1vTO8A>wsS z-pg93hdyJMS=Y>mK1o5oAr~xn)-7mmdb7Q~y@^@WP_Sp77p$|c@f>WbT;*$6p4+gz z!n!5}I-eT-0DP_5diUYv?~Zm$kL_BrvA|eZyCE>^=7?LiueM%X zJ@;qR4wyeFy77Geo=?VHT$MI%(~+GQcdkAP@>|e)SdO%obdws-O4vlAo4+ zyJh8$-@b5n%7%BI->|4|5!Z5h&m+59cYSYva@V=`v^~4u>dw8o{@dx>?PYVabB`3? zUYI&Q{V$Wc(m!uK)~0Fe)OD11o~&rTJZvv@b!A)D=RbL}_^GuIG7BG_rLUYZA-T9V zGuaQuR4*&T$8wXW_|KQWKdk5O`rD!A+{HovhLx%H6OTVKbpktXTv}P0R$H^|ufbvO zS-yDdz@?3^>UU?JG-&2(w1>WSuKpODICNtF?9c4~e7B@y`d*>vOk2vmk2dcq)4zCl zRdwOjDH&Jvf7b1Ax2&Dx$~pV^7e%M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0000000000 --- a/data/test.txt +++ /dev/null @@ -1,10 +0,0 @@ -1 1024 1024 0 0 5 24 5 -2 1024 1 8 11 1 8 11 -3 10 1024 8 15 2 4 11 -4 18 1 8 11 1 8 10 -100 26 0 9 15 1 4 11 -32 1024 1 0 0 5 24 5 -97 2 1 8 11 1 8 11 -98 10 1 8 15 2 4 11 -99 18 1 8 11 1 8 10 -100 26 0 9 15 1 4 11 \ No newline at end of file diff --git a/data/test1.png b/data/test1.png deleted file mode 100644 index e62834774389de5d173d026be16c7750b6a49155..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 36980 zcmeI3&yOQV6~}9nRg@jEumTAp4yfZzP!M>!+dn4b#^cOpX2XoMURJY%GAjh~+BbBA; zeN%q#TdzLvRacL-{@%U2U%9^a*)>AQ_5How143?4^9FgAUdbQc{MPU3Ki39(4@QK1 z`bGA0W&hxX_Xyd1Av`>akD7P9cGO$m*2}eZx9V0l-7i@s$1U4V*>=lCx8ylB z&#hY1SD~>+t@^NY;vMY1Hl2?CwpBQbvk4 ze(aBn{n5=tEq~wu5fa3;OYh#<{|{!C4eXqqAtql(V;&PE2dkY|iEu=G*HDryj+( z-=GMlNQIH3!$*U_J_tt9`LG?_euFOMrfBtXcrq`}f)aaYY3{)|ToT6KNy2z5Bo(UD zwR$_lz>lNhVH9;6NtfNbL}=~oST8mGcGzb~zfiZ+{_|qbrGi~Q4jQx>D@A9c=++Kh z*K^Tk)Njy^;&8QQeJj!U4J$J(^J5U37rZwp1>G-j)qyl|`PN(giM8lpR zH^QEO8rXyWY2BU=0?%1Xc{@=z8q&0ahFiBq!yt;cnYZ5`#eTmX?C&<{zEOHta{;vg0^g;OYIWEqEe%^*kq`22|kx_IK zU--k|)+y}?=|)c^7h}@eb(`JyyWwILlF`NDT()brn00nL^JpW`q zBUaGvdE#HGIP_(^>^hBw@26uQNMhmp>DYPb*ZN`HC{3qJ4TC6l*G=vU_vr&d(AcO} z%XIUmhtm=F!g0_&+70RU9kHg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umber; namespace { - void TestCoords(m2::RectF const & texRect, float x1, float y1, float x2, float y2) - { - TEST_ALMOST_EQUAL(texRect.minX(), x1, ("TESTING_TEXTURE_COORDS_FAILURE")) - TEST_ALMOST_EQUAL(texRect.minY(), y1, ("TESTING_TEXTURE_COORDS_FAILURE")) - TEST_ALMOST_EQUAL(texRect.maxX(), x2, ("TESTING_TEXTURE_COORDS_FAILURE")) - TEST_ALMOST_EQUAL(texRect.maxY(), y2, ("TESTING_TEXTURE_COORDS_FAILURE")) - } - void PrepareOpenGL(int size) { EXPECTGL(glGetInteger(gl_const::GLMaxTextureSize)).WillOnce(Return(size)); @@ -30,103 +26,154 @@ namespace EXPECTGL(glTexImage2D(_, _, _, _, _)).Times(AnyNumber()); EXPECTGL(glGenTexture()).Times(AnyNumber()); } -} -UNIT_TEST(SimpleFontLoading_1024) + FontTexture::GlyphInfo const * FindSymbol(int uni, vector > & textures, + int & w, int & h) + { + FontTexture::GlyphKey key(uni); + for (size_t i = 0; i < textures.size(); ++i) + { + RefPointer texture = textures[i].GetRefPointer(); + Texture::ResourceInfo const * info = texture->FindResource(key); + if (info != NULL) + { + w = texture->GetWidth(); + h = texture->GetHeight(); + return static_cast(info); + } + } + + ASSERT(false, ()); + return NULL; + } + + void TestSymbol(FontTexture::GlyphInfo const * srcInfo, FontTexture::GlyphInfo dstInfo, int texW, int texH) + { + m2::RectF srcTexRect = srcInfo->GetTexRect(); + m2::RectU srcRect(srcTexRect.minX() * texW, srcTexRect.minY() * texH, + srcTexRect.maxX() * texW, srcTexRect.maxY() * texH); + + m2::RectF dstTexRect = dstInfo.GetTexRect(); + m2::RectU dstRect(dstTexRect.minX() * texW, dstTexRect.minY() * texH, + dstTexRect.maxX() * texW, dstTexRect.maxY() * texH); + + TEST_EQUAL(dstRect, srcRect, ()); + + float srcXoff, srcYoff, srcAdvance; + srcInfo->GetMetrics(srcXoff, srcYoff, srcAdvance); + float dstXoff, dstYoff, dstAdvance; + dstInfo.GetMetrics(dstXoff, dstYoff, dstAdvance); + + TEST(my::AlmostEqual(srcXoff, dstXoff), ()); + TEST(my::AlmostEqual(srcYoff, dstYoff), ()); + TEST(my::AlmostEqual(srcAdvance, dstAdvance), ()); + } + + class Tester + { + public: + Tester(int textureSize) + { + PrepareOpenGL(textureSize); + } + + void AddInfo(int id, FontTexture::GlyphInfo const & info) + { + m_infos.push_back(make_pair(id, info)); + } + + void TestThis(string const & resPath) + { + vector > textures; + { + vector > tempTextures; + LoadFont(resPath, tempTextures); + textures.reserve(tempTextures.size()); + for (size_t i = 0; i < tempTextures.size(); ++i) + textures.push_back(MasterPointer(tempTextures[i])); + + for (size_t i = 0; i < m_infos.size(); ++i) + { + int id = m_infos[i].first; + + int w, h; + FontTexture::GlyphInfo const * info = FindSymbol(id, textures, w, h); + TestSymbol(info, m_infos[i].second, w, h); + } + + DeleteRange(textures, MasterPointerDeleter()); + } + } + + private: + vector > m_infos; + }; +} +typedef FontTexture::GlyphInfo glyph_t; + +UNIT_TEST(CutTextureTest_1024) { - FontLoader converter; + Tester t(1024); + int w = 1024; + int h = 1024; + t.AddInfo(1, glyph_t(m2::RectF(0.0 / w, 0.0 / h, + 20.0 / w, 20.0 / h), 0.0, 0.0, 0.1)); + t.AddInfo(2, glyph_t(m2::RectF(20.0 / w, 20.0 / h, + 45.0 / w, 45.0 / h), 2.0, 4.3, 0.2)); + t.AddInfo(3, glyph_t(m2::RectF(512.0 / w, 256.0 / h, + 768.0 / w, 512.0 / h), 0.1, 0.2, 1.2)); + t.AddInfo(4, glyph_t(m2::RectF(768.0 / w, 512.0 / h, + 868.0 / w, 612.0 / h), 0.8, 1.0, 1.3)); - PrepareOpenGL(1024); - - vector tf = converter.Load("test1"); - TEST_EQUAL(converter.GetBlockByUnicode(1), 5, ("TESTING_BLOCK_RESIZING_FAILURE")); - TEST_EQUAL(converter.GetBlockByUnicode(2), 10, ("TESTING_BLOCK_RESIZING_FAILURE")); - TEST_EQUAL(converter.GetBlockByUnicode(3), 15, ("TESTING_BLOCK_RESIZING_FAILURE")); - TEST_EQUAL(converter.GetBlockByUnicode(4), 7, ("TESTING_BLOCK_RESIZING_FAILURE")); - TEST_EQUAL(converter.GetBlockByUnicode(5), 13, ("TESTING_BLOCK_RESIZING_FAILURE")); - TEST_EQUAL(converter.GetBlockByUnicode(6), 0, ("TESTING_BLOCK_RESIZING_FAILURE")); - TEST_EQUAL(converter.GetBlockByUnicode(7), 12, ("TESTING_BLOCK_RESIZING_FAILURE")); - TEST_EQUAL(converter.GetBlockByUnicode(8), 14, ("TESTING_BLOCK_RESIZING_FAILURE")); - TEST_EQUAL(converter.GetBlockByUnicode(9), 7, ("TESTING_BLOCK_RESIZING_FAILURE")); - TEST_EQUAL(converter.GetBlockByUnicode(10), 9, ("TESTING_BLOCK_RESIZING_FAILURE")); - - FontChar symbol; - TEST(tf[5].GetSymbolByUnicode(1, symbol), ("UNICODE_SYMBOL_NOT_FOUND")); - TEST_EQUAL(symbol.m_x, 0, ("TESTING_SYMBOL_COORDS_FAILURE")); - TEST_EQUAL(symbol.m_y, 0, ("TESTING_SYMBOL_COORDS_FAILURE")); - TEST(tf[9].GetSymbolByUnicode(10, symbol), ("UNICODE_SYMBOL_NOT_FOUND")); - TEST_EQUAL(symbol.m_x, 910, ("TESTING_SYMBOL_COORDS_FAILURE")); - TEST_EQUAL(symbol.m_y, 886, ("TESTING_SYMBOL_COORDS_FAILURE")); - - m2::RectF texRect; - m2::PointU pixelSize; - TEST(tf[5].FindResource(TextureFont::FontKey(1), texRect, pixelSize), - ("UNICODE_SYMBOL_NOT_FOUND")); - TestCoords(texRect, 0.0f, 0.0f, 8.0f/1024.0f, 8.0f/1024.0f); + t.TestThis("font_test"); } -UNIT_TEST(SimpleFontLoading_2048) +UNIT_TEST(CutTextureTest_512) { - FontLoader converter; + Tester t(512); + int w = 512; + int h = 512; + t.AddInfo(1, glyph_t(m2::RectF(0.0 / w, 0.0 / h, + 20.0 / w, 20.0 / h), 0.0, 0.0, 0.1)); + t.AddInfo(2, glyph_t(m2::RectF(20.0 / w, 20.0 / h, + 45.0 / w, 45.0 / h), 2.0, 4.3, 0.2)); + t.AddInfo(3, glyph_t(m2::RectF(0.0 / w, 256.0 / h, + 256.0 / w, 512.0 / h), 0.1, 0.2, 1.2)); + t.AddInfo(4, glyph_t(m2::RectF(256.0 / w, 0.0 / h, + 356.0 / w, 100.0 / h), 0.8, 1.0, 1.3)); - PrepareOpenGL(2048); - - vector tf = converter.Load("test1"); - TEST_EQUAL(converter.GetBlockByUnicode(1), 0, ("TESTING_BLOCK_RESIZING_FAILURE")); - TEST_EQUAL(converter.GetBlockByUnicode(2), 3, ("TESTING_BLOCK_RESIZING_FAILURE")); - TEST_EQUAL(converter.GetBlockByUnicode(3), 3, ("TESTING_BLOCK_RESIZING_FAILURE")); - TEST_EQUAL(converter.GetBlockByUnicode(4), 1, ("TESTING_BLOCK_RESIZING_FAILURE")); - TEST_EQUAL(converter.GetBlockByUnicode(5), 2, ("TESTING_BLOCK_RESIZING_FAILURE")); - TEST_EQUAL(converter.GetBlockByUnicode(6), 0, ("TESTING_BLOCK_RESIZING_FAILURE")); - TEST_EQUAL(converter.GetBlockByUnicode(7), 2, ("TESTING_BLOCK_RESIZING_FAILURE")); - TEST_EQUAL(converter.GetBlockByUnicode(8), 3, ("TESTING_BLOCK_RESIZING_FAILURE")); - TEST_EQUAL(converter.GetBlockByUnicode(9), 1, ("TESTING_BLOCK_RESIZING_FAILURE")); - TEST_EQUAL(converter.GetBlockByUnicode(10), 2, ("TESTING_BLOCK_RESIZING_FAILURE")); - - FontChar symbol; - TEST(tf[0].GetSymbolByUnicode(1, symbol), ("UNICODE_SYMBOL_NOT_FOUND")); - TEST_EQUAL(symbol.m_x, 1024, ("TESTING_SYMBOL_COORDS_FAILURE")); - TEST_EQUAL(symbol.m_y, 1024, ("TESTING_SYMBOL_COORDS_FAILURE")); - TEST(tf[2].GetSymbolByUnicode(10, symbol), ("UNICODE_SYMBOL_NOT_FOUND")); - TEST_EQUAL(symbol.m_x, 1934, ("TESTING_SYMBOL_COORDS_FAILURE")); - TEST_EQUAL(symbol.m_y, 886, ("TESTING_SYMBOL_COORDS_FAILURE")); - - m2::RectF texRect; - m2::PointU pixelSize; - TEST(tf[2].FindResource(TextureFont::FontKey(7), texRect, pixelSize), - ("UNICODE_SYMBOL_NOT_FOUND")); - TestCoords(texRect, 234.0f/2048.0f, 1024.0f/2048.0f, 242.0f/2048.0f, 1035.0f/2048.0f); + t.TestThis("font_test"); } -UNIT_TEST(SimpleFontLoading_4096) +UNIT_TEST(RectangleCut_1024) { - FontLoader converter; + Tester t(1024); + int w1 = 512; + int h1 = 512; + int w2 = 256; + int h2 = 256; + t.AddInfo(1, glyph_t(m2::RectF(0.0 / w1, 0.0 / h1, + 20.0 / w1, 20.0 / h1), 0.0, 0.0, 0.1)); + t.AddInfo(2, glyph_t(m2::RectF(0.0 / w1, 412.0 / h1, + 100.0 / w1, 512.0 / h1), 2.0, 4.3, 0.2)); + t.AddInfo(3, glyph_t(m2::RectF(0.0 / w2, 0.0 / h2, + 50.0 / w2, 50.0 / h2), 0.1, 0.2, 1.2)); - PrepareOpenGL(4096); - - vector tf = converter.Load("test1"); - TEST_EQUAL(converter.GetBlockByUnicode(1), 0, ("TESTING_BLOCK_RESIZING_FAILURE")); - TEST_EQUAL(converter.GetBlockByUnicode(2), 0, ("TESTING_BLOCK_RESIZING_FAILURE")); - TEST_EQUAL(converter.GetBlockByUnicode(3), 0, ("TESTING_BLOCK_RESIZING_FAILURE")); - TEST_EQUAL(converter.GetBlockByUnicode(4), 0, ("TESTING_BLOCK_RESIZING_FAILURE")); - TEST_EQUAL(converter.GetBlockByUnicode(5), 0, ("TESTING_BLOCK_RESIZING_FAILURE")); - TEST_EQUAL(converter.GetBlockByUnicode(6), 0, ("TESTING_BLOCK_RESIZING_FAILURE")); - TEST_EQUAL(converter.GetBlockByUnicode(7), 0, ("TESTING_BLOCK_RESIZING_FAILURE")); - TEST_EQUAL(converter.GetBlockByUnicode(8), 0, ("TESTING_BLOCK_RESIZING_FAILURE")); - TEST_EQUAL(converter.GetBlockByUnicode(9), 0, ("TESTING_BLOCK_RESIZING_FAILURE")); - TEST_EQUAL(converter.GetBlockByUnicode(10), 0, ("TESTING_BLOCK_RESIZING_FAILURE")); - - FontChar symbol; - TEST(tf[0].GetSymbolByUnicode(1, symbol), ("UNICODE_SYMBOL_NOT_FOUND")); - TEST_EQUAL(symbol.m_x, 1024, ("TESTING_SYMBOL_COORDS_FAILURE")); - TEST_EQUAL(symbol.m_y, 1024, ("TESTING_SYMBOL_COORDS_FAILURE")); - TEST(tf[0].GetSymbolByUnicode(10, symbol), ("UNICODE_SYMBOL_NOT_FOUND")); - TEST_EQUAL(symbol.m_x, 1934, ("TESTING_SYMBOL_COORDS_FAILURE")); - TEST_EQUAL(symbol.m_y, 2934, ("TESTING_SYMBOL_COORDS_FAILURE")); - - m2::RectF texRect; - m2::PointU pixelSize; - TEST(tf[0].FindResource(TextureFont::FontKey(3), texRect, pixelSize), - ("UNICODE_SYMBOL_NOT_FOUND")); - TestCoords(texRect, 3072.0f/4096.0f, 3072.0f/4096.0f, 3080.0f/4096.0f, 3087.0f/4096.0f); + t.TestThis("font_test2"); +} + + +UNIT_TEST(RectangleCut_256) +{ + Tester t(256); + int w = 256; + int h = 256; + t.AddInfo(1, glyph_t(m2::RectF(0.0 / w, 0.0 / h, + 20.0 / w, 20.0 / h), 0.0, 0.0, 0.1)); + t.AddInfo(2, glyph_t(m2::RectF(0.0 / w, 156.0 / h, + 100.0 / w, 256.0 / h), 2.0, 4.3, 0.2)); + t.AddInfo(3, glyph_t(m2::RectF(0.0 / w, 0.0 / h, + 50.0 / w, 50.0 / h), 0.1, 0.2, 1.2)); + + t.TestThis("font_test2"); }