removed m_dynamicPagesCount and m_textPagesCount from Skin as unnecessary.

This commit is contained in:
rachytski 2012-04-23 19:14:53 +04:00 committed by Alex Zolotarev
parent 8f700f3cdb
commit 6211015040
19 changed files with 59 additions and 122 deletions

View file

@ -55,7 +55,7 @@ ScreenCoverage * CoverageGenerator::CreateCoverage()
params.m_glyphCacheID = m_resourceManager->cacheThreadGlyphCacheID();
shared_ptr<yg::gl::Screen> screen(new yg::gl::Screen(params));
shared_ptr<yg::Skin> skin(loadSkin(m_resourceManager, m_skinName, 2, 2));
shared_ptr<yg::Skin> skin(loadSkin(m_resourceManager, m_skinName));
screen->setSkin(skin);

View file

@ -18,9 +18,7 @@
DrawerYG::Params::Params()
: m_dynamicPagesCount(2),
m_textPagesCount(2),
m_threadID(0),
: m_threadID(0),
m_visualScale(1)
{
}
@ -58,9 +56,7 @@ DrawerYG::DrawerYG(params_t const & params)
{
m_pScreen = shared_ptr<yg::gl::Screen>(new yg::gl::Screen(params));
m_pSkin = shared_ptr<yg::Skin>(loadSkin(params.m_resourceManager,
params.m_skinName,
params.m_dynamicPagesCount,
params.m_textPagesCount));
params.m_skinName));
m_pScreen->setSkin(m_pSkin);
if (m_pSkin)

View file

@ -96,8 +96,6 @@ public:
struct Params : screen_t::Params
{
size_t m_dynamicPagesCount;
size_t m_textPagesCount;
size_t m_threadID;
string m_skinName;
double m_visualScale;

View file

@ -122,8 +122,6 @@ RenderPolicyMT::RenderPolicyMT(VideoTimer * videoTimer,
p.m_frameBuffer = make_shared_ptr(new yg::gl::FrameBuffer(useDefaultFB));
p.m_resourceManager = m_resourceManager;
p.m_dynamicPagesCount = 2;
p.m_textPagesCount = 2;
p.m_glyphCacheID = m_resourceManager->guiThreadGlyphCacheID();
p.m_skinName = GetPlatform().SkinName();
p.m_visualScale = GetPlatform().VisualScale();

View file

@ -124,8 +124,6 @@ RenderPolicyST::RenderPolicyST(VideoTimer * videoTimer,
p.m_frameBuffer = make_shared_ptr(new yg::gl::FrameBuffer(useDefaultFB));
p.m_resourceManager = m_resourceManager;
p.m_dynamicPagesCount = 2;
p.m_textPagesCount = 2;
p.m_glyphCacheID = m_resourceManager->guiThreadGlyphCacheID();
p.m_skinName = GetPlatform().SkinName();
p.m_visualScale = GetPlatform().VisualScale();

View file

@ -5,7 +5,6 @@
#include "../geometry/screenbase.hpp"
#include "../yg/info_layer.hpp"
#include "../yg/resource_style_cache.hpp"
#include "tile.hpp"
#include "tiler.hpp"

View file

@ -102,8 +102,6 @@ SimpleRenderPolicy::SimpleRenderPolicy(VideoTimer * videoTimer,
p.m_frameBuffer = make_shared_ptr(new yg::gl::FrameBuffer(useDefaultFB));
p.m_resourceManager = m_resourceManager;
p.m_dynamicPagesCount = 2;
p.m_textPagesCount = 2;
p.m_glyphCacheID = m_resourceManager->guiThreadGlyphCacheID();
p.m_skinName = GetPlatform().SkinName();
p.m_visualScale = GetPlatform().VisualScale();

View file

@ -103,8 +103,6 @@ TestRenderPolicy::TestRenderPolicy(VideoTimer * videoTimer,
p.m_frameBuffer = m_primaryFrameBuffer;
p.m_resourceManager = m_resourceManager;
p.m_dynamicPagesCount = 2;
p.m_textPagesCount = 2;
p.m_glyphCacheID = m_resourceManager->guiThreadGlyphCacheID();
p.m_skinName = GetPlatform().SkinName();
p.m_visualScale = GetPlatform().VisualScale();

View file

@ -149,8 +149,6 @@ TilingRenderPolicyMT::TilingRenderPolicyMT(VideoTimer * videoTimer,
p.m_frameBuffer = make_shared_ptr(new yg::gl::FrameBuffer(useDefaultFB));
p.m_resourceManager = m_resourceManager;
p.m_dynamicPagesCount = 2;
p.m_textPagesCount = 2;
p.m_glyphCacheID = m_resourceManager->guiThreadGlyphCacheID();
p.m_skinName = GetPlatform().SkinName();
p.m_visualScale = GetPlatform().VisualScale();

View file

@ -162,8 +162,6 @@ TilingRenderPolicyST::TilingRenderPolicyST(VideoTimer * videoTimer,
p.m_frameBuffer = make_shared_ptr(new yg::gl::FrameBuffer(useDefaultFB));
p.m_resourceManager = m_resourceManager;
p.m_dynamicPagesCount = 2;
p.m_textPagesCount = 2;
p.m_glyphCacheID = m_resourceManager->guiThreadGlyphCacheID();
p.m_skinName = GetPlatform().SkinName();
p.m_visualScale = GetPlatform().VisualScale();

View file

@ -143,7 +143,7 @@ void GLDrawWidget::initializeGL()
m_primaryFrameBuffer = make_shared_ptr(new yg::gl::FrameBuffer(true));
m_skin = shared_ptr<yg::Skin>(loadSkin(m_resourceManager, GetPlatform().SkinName(), params.m_dynamicPagesCount, params.m_textPagesCount));
m_skin = shared_ptr<yg::Skin>(loadSkin(m_resourceManager, GetPlatform().SkinName()));
m_p->setSkin(m_skin);
params.m_frameBuffer = m_primaryFrameBuffer;

View file

@ -652,12 +652,12 @@ namespace
return m_staticTextures[fileName];
}
Skin * loadSkin(shared_ptr<ResourceManager> const & resourceManager, string const & fileName, size_t dynamicPagesCount, size_t textPagesCount)
Skin * loadSkin(shared_ptr<ResourceManager> const & resourceManager, string const & fileName)
{
if (fileName.empty())
return 0;
SkinLoader loader(resourceManager, dynamicPagesCount, textPagesCount);
SkinLoader loader(resourceManager);
try
{

View file

@ -327,8 +327,6 @@ namespace yg
};
Skin * loadSkin(shared_ptr<ResourceManager> const & resourceManager,
string const & fileName,
size_t dynamicPagesCount,
size_t textPagesCount);
string const & fileName);
}

View file

@ -17,20 +17,16 @@
namespace yg
{
Skin::Skin(shared_ptr<ResourceManager> const & resourceManager,
Skin::TSkinPages const & pages,
size_t dynamicPagesCount,
size_t textPagesCount)
Skin::TSkinPages const & pages)
: m_pages(pages),
m_dynamicPagesCount(dynamicPagesCount),
m_textPagesCount(textPagesCount),
m_staticPagesCount(pages.size()),
m_resourceManager(resourceManager)
{
m_startTextPage = m_currentTextPage = m_pages.size();
addTextPages(m_textPagesCount);
m_textPage = m_pages.size();
addTextPages(1);
m_startDynamicPage = m_currentDynamicPage = m_pages.size();
addDynamicPages(m_dynamicPagesCount);
m_dynamicPage = m_pages.size();
addDynamicPages(1);
}
void Skin::addTextPages(int count)
@ -127,10 +123,10 @@ namespace yg
return packID(i, res);
}
if (!m_pages[m_currentDynamicPage]->hasRoom(c))
changeCurrentDynamicPage();
if (!m_pages[m_dynamicPage]->hasRoom(c))
flushDynamicPage();
return packID(m_currentDynamicPage, m_pages[m_currentDynamicPage]->mapColor(c));
return packID(m_dynamicPage, m_pages[m_dynamicPage]->mapColor(c));
}
uint32_t Skin::mapPenInfo(PenInfo const & penInfo)
@ -151,10 +147,10 @@ namespace yg
return packID(i, res);
}
if (!m_pages[m_currentDynamicPage]->hasRoom(penInfo))
changeCurrentDynamicPage();
if (!m_pages[m_dynamicPage]->hasRoom(penInfo))
flushDynamicPage();
return packID(m_currentDynamicPage, m_pages[m_currentDynamicPage]->mapPenInfo(penInfo));
return packID(m_dynamicPage, m_pages[m_dynamicPage]->mapPenInfo(penInfo));
}
uint32_t Skin::mapCircleInfo(CircleInfo const & circleInfo)
@ -175,36 +171,38 @@ namespace yg
return packID(i, res);
}
if (!m_pages[m_currentDynamicPage]->hasRoom(circleInfo))
changeCurrentDynamicPage();
if (!m_pages[m_dynamicPage]->hasRoom(circleInfo))
flushDynamicPage();
return packID(m_currentDynamicPage, m_pages[m_currentDynamicPage]->mapCircleInfo(circleInfo));
return packID(m_dynamicPage, m_pages[m_dynamicPage]->mapCircleInfo(circleInfo));
}
bool Skin::mapPenInfo(PenInfo const * penInfos, uint32_t * styleIDS, size_t count)
{
uint8_t savedDynamicPage = m_currentDynamicPage;
bool alreadyFlushed = false;
int i = 0;
do
{
styleIDS[i] = m_pages[m_currentDynamicPage]->findPenInfo(penInfos[i]);
styleIDS[i] = m_pages[m_dynamicPage]->findPenInfo(penInfos[i]);
if ((styleIDS[i] == invalidPageHandle()) || (unpackID(styleIDS[i]).first != m_currentDynamicPage))
if ((styleIDS[i] == invalidPageHandle()) || (unpackID(styleIDS[i]).first != m_dynamicPage))
{
/// try to pack on the currentDynamicPage
while (!m_pages[m_currentDynamicPage]->hasRoom(penInfos[i]))
while (!m_pages[m_dynamicPage]->hasRoom(penInfos[i]))
{
/// no room - switch the page
changeCurrentDynamicPage();
if (savedDynamicPage == m_currentDynamicPage)
/// no room - flush the page
flushDynamicPage();
if (alreadyFlushed)
return false; //<cycling
alreadyFlushed = true;
/// re-start packing
i = 0;
}
styleIDS[i] = packID(m_currentDynamicPage, m_pages[m_currentDynamicPage]->mapPenInfo(penInfos[i]));
styleIDS[i] = packID(m_dynamicPage, m_pages[m_dynamicPage]->mapPenInfo(penInfos[i]));
}
++i;
@ -232,17 +230,12 @@ namespace yg
return packID(i, res);
}
if (!m_pages[m_currentTextPage]->hasRoom(gk, glyphCache))
changeCurrentTextPage();
if (!m_pages[m_textPage]->hasRoom(gk, glyphCache))
flushTextPage();
return packID(m_currentTextPage, m_pages[m_currentTextPage]->mapGlyph(gk, glyphCache));
return packID(m_textPage, m_pages[m_textPage]->mapGlyph(gk, glyphCache));
}
/* Skin::TSkinPages const & Skin::pages() const
{
return m_pages;
}*/
shared_ptr<SkinPage> const & Skin::getPage(int i) const
{
if (i < m_pages.size())
@ -301,45 +294,25 @@ namespace yg
/// is explicitly checked in the mapXXX() functions.
void Skin::onDynamicOverflow(uint8_t pipelineID)
{
LOG(LINFO, ("DynamicPage switching, pipelineID=", (uint32_t)pipelineID));
changeCurrentDynamicPage();
LOG(LINFO, ("DynamicPage flushing, pipelineID=", (uint32_t)pipelineID));
flushDynamicPage();
}
void Skin::onTextOverflow(uint8_t pipelineID)
{
LOG(LINFO, ("TextPage switching, pipelineID=", (uint32_t)pipelineID));
changeCurrentTextPage();
LOG(LINFO, ("TextPage flushing, pipelineID=", (uint32_t)pipelineID));
flushTextPage();
}
void Skin::changeCurrentDynamicPage()
void Skin::flushDynamicPage()
{
/// flush screen(through overflowFns)
/// callOverflowFns(m_currentDynamicPage);
/// 1. clear currentDynamicPage
callClearPageFns(m_currentDynamicPage);
/// page should be frozen after flushing(activeCommands > 0)
/// 2. choose next dynamic page
if (m_currentDynamicPage == m_startDynamicPage + m_dynamicPagesCount - 1)
m_currentDynamicPage = m_startDynamicPage;
else
++m_currentDynamicPage;
/// 3. clear new currentDynamicPage
callClearPageFns(m_currentDynamicPage);
callClearPageFns(m_dynamicPage);
}
void Skin::changeCurrentTextPage()
void Skin::flushTextPage()
{
//callOverflowFns(m_currentTextPage);
callClearPageFns(m_currentTextPage);
if (m_currentTextPage == m_startTextPage + m_textPagesCount - 1)
m_currentTextPage = m_startTextPage;
else
++m_currentTextPage;
callClearPageFns(m_currentTextPage);
callClearPageFns(m_textPage);
}
uint32_t Skin::invalidHandle() const
@ -352,14 +325,14 @@ namespace yg
return 0x00FFFFFF;
}
uint8_t Skin::currentTextPage() const
uint8_t Skin::textPage() const
{
return m_currentTextPage;
return m_textPage;
}
uint8_t Skin::currentDynamicPage() const
uint8_t Skin::dynamicPage() const
{
return m_currentDynamicPage;
return m_dynamicPage;
}
void Skin::memoryWarning()

View file

@ -48,13 +48,8 @@ namespace yg
TSkinPages m_pages;
TSkinPages m_additionalPages;
uint8_t m_startDynamicPage;
uint8_t m_currentDynamicPage;
uint8_t m_dynamicPagesCount;
uint8_t m_startTextPage;
uint8_t m_currentTextPage;
uint8_t m_textPagesCount;
uint8_t m_dynamicPage;
uint8_t m_textPage;
uint8_t m_startStaticPage;
uint8_t m_currentStaticPage;
@ -67,9 +62,7 @@ namespace yg
void clearHandles();
Skin(shared_ptr<ResourceManager> const & resourceManager,
TSkinPages const & pages,
size_t dynamicPagesCount,
size_t textPagesCount);
TSkinPages const & pages);
friend class SkinLoader;
@ -100,8 +93,8 @@ namespace yg
void onDynamicOverflow(uint8_t pipelineID);
void onTextOverflow(uint8_t pipelineID);
void changeCurrentDynamicPage();
void changeCurrentTextPage();
void flushDynamicPage();
void flushTextPage();
public:
@ -146,8 +139,8 @@ namespace yg
uint32_t invalidHandle() const;
uint32_t invalidPageHandle() const;
uint8_t currentTextPage() const;
uint8_t currentDynamicPage() const;
uint8_t textPage() const;
uint8_t dynamicPage() const;
void setAdditionalPage(shared_ptr<SkinPage> const & pages);
void clearAdditionalPage();

View file

@ -8,9 +8,7 @@
namespace yg
{
SkinLoader::SkinLoader(shared_ptr<ResourceManager> const & resourceManager,
size_t dynamicPagesCount,
size_t textPagesCount)
SkinLoader::SkinLoader(shared_ptr<ResourceManager> const & resourceManager)
: m_id(-1),
m_texRect(0, 0, 0, 0),
m_xOffset(0),
@ -18,9 +16,7 @@ namespace yg
m_xAdvance(0),
m_fileName(""),
m_resourceManager(resourceManager),
m_skin(0),
m_dynamicPagesCount(dynamicPagesCount),
m_textPagesCount(textPagesCount)
m_skin(0)
{
m_mode.push_back(ERoot);
}
@ -69,7 +65,7 @@ namespace yg
void SkinLoader::popSkin()
{
m_skin = new Skin(m_resourceManager, m_pages, m_dynamicPagesCount, m_textPagesCount);
m_skin = new Skin(m_resourceManager, m_pages);
}
#define PUSH_MODE(mode, name) \

View file

@ -90,14 +90,10 @@ namespace yg
shared_ptr<ResourceManager> m_resourceManager;
Skin * m_skin;
size_t m_dynamicPagesCount;
size_t m_textPagesCount;
public:
SkinLoader(shared_ptr<ResourceManager> const & resourceManager,
size_t dynamicPagesCount,
size_t textPagesCount);
SkinLoader(shared_ptr<ResourceManager> const & resourceManager);
bool Push(string const & element);
void Pop(string const & element);

View file

@ -9,5 +9,5 @@ UNIT_TEST(SkinLoaderTest_Main)
{
GL_TEST_START;
shared_ptr<yg::ResourceManager> rm(new yg::ResourceManager(yg::ResourceManager::Params()));
loadSkin(rm, "basic.skn", 2, 2);
loadSkin(rm, "basic.skn");
};

View file

@ -11,7 +11,7 @@ UNIT_TEST(SkinTest_Main)
GL_TEST_START;
shared_ptr<yg::ResourceManager> rm(new yg::ResourceManager(yg::ResourceManager::Params()));
yg::Skin * skin = loadSkin(rm, "basic.skn", 2, 2);
yg::Skin * skin = loadSkin(rm, "basic.skn");
double p0 [] = {1, 1};
yg::PenInfo penInfo0(yg::Color(0xFF, 0, 0, 0xFF), 1, p0, 2, 0);