forked from organicmaps/organicmaps
moved uploadData from SkinPage to GeometryBatcher.
This commit is contained in:
parent
962930907f
commit
0e5ce3fc48
7 changed files with 92 additions and 82 deletions
|
@ -375,7 +375,11 @@ namespace yg
|
|||
GeometryPipeline & pipeline = m_pipelines[pipelineID];
|
||||
if (pipeline.m_currentIndex)
|
||||
{
|
||||
skinPage->uploadData(renderQueue());
|
||||
if (skinPage->hasData())
|
||||
{
|
||||
uploadTexture(skinPage->uploadQueue(), skinPage->texture());
|
||||
skinPage->clearUploadQueue();
|
||||
}
|
||||
|
||||
unlockPipeline(pipelineID);
|
||||
|
||||
|
|
|
@ -24,6 +24,76 @@ namespace yg
|
|||
m_displayList(0)
|
||||
{}
|
||||
|
||||
GeometryRenderer::UploadData::UploadData(SkinPage::TUploadQueue const & uploadQueue,
|
||||
shared_ptr<BaseTexture> const & texture)
|
||||
: m_uploadQueue(uploadQueue), m_texture(texture)
|
||||
{}
|
||||
|
||||
GeometryRenderer::UploadData::UploadData()
|
||||
{}
|
||||
|
||||
void GeometryRenderer::UploadData::perform()
|
||||
{
|
||||
if (isDebugging())
|
||||
LOG(LINFO, ("performing UploadData command", m_texture->width(), m_texture->height()));
|
||||
|
||||
if (!m_texture)
|
||||
{
|
||||
LOG(LDEBUG, ("no texture on upload"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (isDebugging())
|
||||
LOG(LINFO, ("uploading to", m_texture->id(), "texture"));
|
||||
|
||||
static_cast<ManagedTexture*>(m_texture.get())->lock();
|
||||
|
||||
TDynamicTexture * dynTexture = static_cast<TDynamicTexture*>(m_texture.get());
|
||||
|
||||
for (size_t i = 0; i < m_uploadQueue.size(); ++i)
|
||||
{
|
||||
shared_ptr<ResourceStyle> const & style = m_uploadQueue[i];
|
||||
|
||||
TDynamicTexture::view_t v = dynTexture->view(style->m_texRect.SizeX(),
|
||||
style->m_texRect.SizeY());
|
||||
|
||||
style->render(&v(0, 0));
|
||||
|
||||
dynTexture->upload(&v(0, 0), style->m_texRect);
|
||||
}
|
||||
|
||||
/// Should call glFlush here and rebind in all
|
||||
/// renderContexts that's using it.
|
||||
/// But for simplification just calling glFinish
|
||||
OGLCHECK(glFinish());
|
||||
|
||||
static_cast<ManagedTexture*>(m_texture.get())->unlock();
|
||||
}
|
||||
|
||||
void GeometryRenderer::UploadData::cancel()
|
||||
{
|
||||
perform();
|
||||
}
|
||||
|
||||
void GeometryRenderer::UploadData::dump()
|
||||
{
|
||||
m2::RectU r(0, 0, 0, 0);
|
||||
if (!m_uploadQueue.empty())
|
||||
r = m_uploadQueue[0]->m_texRect;
|
||||
LOG(LINFO, ("UploadData: texture", m_texture->id(), ", count=", m_uploadQueue.size(), ", first=", r));
|
||||
}
|
||||
|
||||
void GeometryRenderer::uploadTexture(SkinPage::TUploadQueue const & uploadQueue,
|
||||
shared_ptr<BaseTexture> const & texture)
|
||||
{
|
||||
shared_ptr<UploadData> command(new UploadData(uploadQueue, texture));
|
||||
|
||||
if (m_displayList)
|
||||
m_displayList->uploadData(command);
|
||||
else
|
||||
processCommand(command);
|
||||
}
|
||||
|
||||
void GeometryRenderer::DrawGeometry::perform()
|
||||
{
|
||||
if (isDebugging())
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "clipper.hpp"
|
||||
#include "skin_page.hpp"
|
||||
|
||||
#include "../base/threaded_list.hpp"
|
||||
|
||||
|
@ -28,6 +29,20 @@ namespace yg
|
|||
|
||||
typedef Clipper base_t;
|
||||
|
||||
struct UploadData : public Command
|
||||
{
|
||||
SkinPage::TUploadQueue m_uploadQueue;
|
||||
shared_ptr<BaseTexture> m_texture;
|
||||
|
||||
UploadData();
|
||||
UploadData(SkinPage::TUploadQueue const & uploadQueue,
|
||||
shared_ptr<BaseTexture> const & texture);
|
||||
|
||||
void perform();
|
||||
void cancel();
|
||||
void dump();
|
||||
};
|
||||
|
||||
struct DrawGeometry : Command
|
||||
{
|
||||
shared_ptr<BaseTexture> m_texture;
|
||||
|
@ -98,6 +113,7 @@ namespace yg
|
|||
size_t indicesOffs,
|
||||
unsigned primType);
|
||||
|
||||
void uploadTexture(SkinPage::TUploadQueue const & uploadQueue, shared_ptr<BaseTexture> const & texture);
|
||||
void freeTexture(shared_ptr<BaseTexture> const & texture, TTexturePool * texturePool);
|
||||
void freeStorage(Storage const & storage, TStoragePool * storagePool);
|
||||
void unlockStorage(Storage const & storage);
|
||||
|
|
|
@ -133,7 +133,7 @@ namespace yg
|
|||
|
||||
void ResourceStyleCache::upload()
|
||||
{
|
||||
m_cachePage->uploadData(m_glQueue);
|
||||
// m_cachePage->uploadData(m_glQueue);
|
||||
|
||||
if (m_glQueue)
|
||||
m_glQueue->processPacket(yg::gl::Packet(make_shared_ptr(new yg::gl::Renderer::FinishCommand()), yg::gl::Packet::ECommand));
|
||||
|
|
|
@ -98,8 +98,6 @@ namespace yg
|
|||
|
||||
public:
|
||||
|
||||
void uploadData();
|
||||
|
||||
/// clean and destroy
|
||||
~Skin();
|
||||
/// obtain ResourceStyle from id
|
||||
|
|
|
@ -329,69 +329,6 @@ namespace yg
|
|||
it->second->m_pipelineID = pipelineID;
|
||||
}
|
||||
|
||||
SkinPage::UploadData::UploadData(SkinPage::TUploadQueue const & uploadQueue,
|
||||
shared_ptr<yg::gl::BaseTexture> const & texture)
|
||||
: m_uploadQueue(uploadQueue), m_texture(texture)
|
||||
{}
|
||||
|
||||
SkinPage::UploadData::UploadData()
|
||||
{}
|
||||
|
||||
void SkinPage::UploadData::perform()
|
||||
{
|
||||
if (isDebugging())
|
||||
LOG(LINFO, ("performing UploadData command", m_texture->width(), m_texture->height()));
|
||||
|
||||
if (!m_texture)
|
||||
{
|
||||
LOG(LDEBUG, ("no texture on upload"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (isDebugging())
|
||||
LOG(LINFO, ("uploading to", m_texture->id(), "texture"));
|
||||
|
||||
static_cast<gl::ManagedTexture*>(m_texture.get())->lock();
|
||||
|
||||
TDynamicTexture * dynTexture = static_cast<TDynamicTexture*>(m_texture.get());
|
||||
|
||||
for (size_t i = 0; i < m_uploadQueue.size(); ++i)
|
||||
{
|
||||
shared_ptr<ResourceStyle> const & style = m_uploadQueue[i];
|
||||
|
||||
TDynamicTexture::view_t v = dynTexture->view(style->m_texRect.SizeX(),
|
||||
style->m_texRect.SizeY());
|
||||
|
||||
style->render(&v(0, 0));
|
||||
|
||||
dynTexture->upload(&v(0, 0), style->m_texRect);
|
||||
}
|
||||
|
||||
static_cast<gl::ManagedTexture*>(m_texture.get())->unlock();
|
||||
}
|
||||
|
||||
void SkinPage::UploadData::cancel()
|
||||
{
|
||||
perform();
|
||||
}
|
||||
|
||||
void SkinPage::uploadData(yg::gl::PacketsQueue * glQueue)
|
||||
{
|
||||
if (hasData())
|
||||
{
|
||||
checkTexture();
|
||||
|
||||
shared_ptr<UploadData> cmd(new UploadData(m_uploadQueue, m_texture));
|
||||
|
||||
if (glQueue)
|
||||
glQueue->processPacket(yg::gl::Packet(cmd, yg::gl::Packet::ECommand));
|
||||
else
|
||||
cmd->perform();
|
||||
|
||||
m_uploadQueue.clear();
|
||||
}
|
||||
}
|
||||
|
||||
ResourceStyle * SkinPage::fromID(uint32_t idx) const
|
||||
{
|
||||
TStyles::const_iterator it = m_styles.find(idx);
|
||||
|
|
|
@ -97,19 +97,6 @@ namespace yg
|
|||
|
||||
public:
|
||||
|
||||
struct UploadData : public yg::gl::Command
|
||||
{
|
||||
SkinPage::TUploadQueue m_uploadQueue;
|
||||
shared_ptr<yg::gl::BaseTexture> m_texture;
|
||||
|
||||
UploadData();
|
||||
UploadData(SkinPage::TUploadQueue const & uploadQueue,
|
||||
shared_ptr<yg::gl::BaseTexture> const & texture);
|
||||
|
||||
void perform();
|
||||
void cancel();
|
||||
};
|
||||
|
||||
void clearColorHandles();
|
||||
void clearPenInfoHandles();
|
||||
void clearFontHandles();
|
||||
|
@ -123,8 +110,6 @@ namespace yg
|
|||
TUploadQueue const & uploadQueue() const;
|
||||
void clearUploadQueue();
|
||||
|
||||
void uploadData(yg::gl::PacketsQueue * glQueue);
|
||||
|
||||
void checkTexture() const;
|
||||
void setPipelineID(uint8_t pipelineID);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue