forked from organicmaps/organicmaps
renamed RenderPolicyST->BasicRenderPolicy and PartialRenderPolicy->RenderPolicyST for consistency.
This commit is contained in:
parent
4dbb5a2de5
commit
431a4f85c5
8 changed files with 341 additions and 341 deletions
132
map/basic_render_policy.cpp
Normal file
132
map/basic_render_policy.cpp
Normal file
|
@ -0,0 +1,132 @@
|
|||
#include "../base/SRC_FIRST.hpp"
|
||||
|
||||
#include "basic_render_policy.hpp"
|
||||
#include "events.hpp"
|
||||
#include "drawer_yg.hpp"
|
||||
#include "window_handle.hpp"
|
||||
#include "../yg/info_layer.hpp"
|
||||
#include "../yg/internal/opengl.hpp"
|
||||
#include "../yg/skin.hpp"
|
||||
|
||||
#include "../indexer/scales.hpp"
|
||||
#include "../geometry/screenbase.hpp"
|
||||
|
||||
#include "../platform/platform.hpp"
|
||||
|
||||
BasicRenderPolicy::BasicRenderPolicy(VideoTimer * videoTimer,
|
||||
bool useDefaultFB,
|
||||
yg::ResourceManager::Params const & rmParams,
|
||||
shared_ptr<yg::gl::RenderContext> const & primaryRC)
|
||||
: RenderPolicy(primaryRC, false)
|
||||
{
|
||||
yg::ResourceManager::Params rmp = rmParams;
|
||||
|
||||
rmp.m_primaryStoragesParams = yg::ResourceManager::StoragePoolParams(50000 * sizeof(yg::gl::Vertex),
|
||||
sizeof(yg::gl::Vertex),
|
||||
10000 * sizeof(unsigned short),
|
||||
sizeof(unsigned short),
|
||||
15,
|
||||
false,
|
||||
true,
|
||||
1,
|
||||
"primaryStorage");
|
||||
|
||||
rmp.m_smallStoragesParams = yg::ResourceManager::StoragePoolParams(5000 * sizeof(yg::gl::Vertex),
|
||||
sizeof(yg::gl::Vertex),
|
||||
10000 * sizeof(unsigned short),
|
||||
sizeof(unsigned short),
|
||||
100,
|
||||
false,
|
||||
true,
|
||||
1,
|
||||
"smallStorage");
|
||||
|
||||
rmp.m_blitStoragesParams = yg::ResourceManager::StoragePoolParams(10 * sizeof(yg::gl::Vertex),
|
||||
sizeof(yg::gl::Vertex),
|
||||
10 * sizeof(unsigned short),
|
||||
sizeof(unsigned short),
|
||||
50,
|
||||
true,
|
||||
true,
|
||||
1,
|
||||
"blitStorage");
|
||||
|
||||
rmp.m_primaryTexturesParams = yg::ResourceManager::TexturePoolParams(512,
|
||||
256,
|
||||
10,
|
||||
rmp.m_texFormat,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
1,
|
||||
"primaryTexture");
|
||||
|
||||
rmp.m_fontTexturesParams = yg::ResourceManager::TexturePoolParams(512,
|
||||
256,
|
||||
5,
|
||||
rmp.m_texFormat,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
1,
|
||||
"fontTexture");
|
||||
|
||||
rmp.m_glyphCacheParams = yg::ResourceManager::GlyphCacheParams("unicode_blocks.txt",
|
||||
"fonts_whitelist.txt",
|
||||
"fonts_blacklist.txt",
|
||||
2 * 1024 * 1024,
|
||||
1,
|
||||
0);
|
||||
|
||||
|
||||
rmp.m_useSingleThreadedOGL = false;
|
||||
rmp.m_useVA = !yg::gl::g_isBufferObjectsSupported;
|
||||
|
||||
m_resourceManager.reset(new yg::ResourceManager(rmp));
|
||||
|
||||
Platform::FilesList fonts;
|
||||
GetPlatform().GetFontNames(fonts);
|
||||
m_resourceManager->addFonts(fonts);
|
||||
|
||||
DrawerYG::params_t p;
|
||||
|
||||
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();
|
||||
p.m_isSynchronized = true;
|
||||
|
||||
m_drawer.reset(new DrawerYG(p));
|
||||
|
||||
m_windowHandle.reset(new WindowHandle());
|
||||
|
||||
m_windowHandle->setUpdatesEnabled(false);
|
||||
m_windowHandle->setVideoTimer(videoTimer);
|
||||
m_windowHandle->setRenderContext(primaryRC);
|
||||
}
|
||||
|
||||
void BasicRenderPolicy::DrawFrame(shared_ptr<PaintEvent> const & e,
|
||||
ScreenBase const & s)
|
||||
{
|
||||
int scaleEtalonSize = GetPlatform().ScaleEtalonSize();
|
||||
|
||||
m2::RectD glbRect;
|
||||
m2::PointD const pxCenter = s.PixelRect().Center();
|
||||
s.PtoG(m2::RectD(pxCenter - m2::PointD(scaleEtalonSize / 2, scaleEtalonSize / 2),
|
||||
pxCenter + m2::PointD(scaleEtalonSize / 2, scaleEtalonSize / 2)),
|
||||
glbRect);
|
||||
|
||||
shared_ptr<yg::InfoLayer> infoLayer(new yg::InfoLayer());
|
||||
|
||||
e->drawer()->screen()->setInfoLayer(infoLayer);
|
||||
|
||||
e->drawer()->screen()->clear(m_bgColor);
|
||||
|
||||
m_renderFn(e, s, s.ClipRect(), s.ClipRect(), scales::GetScaleLevel(glbRect));
|
||||
|
||||
infoLayer->draw(e->drawer()->screen().get(), math::Identity<double, 3>());
|
||||
e->drawer()->screen()->resetInfoLayer();
|
||||
}
|
18
map/basic_render_policy.hpp
Normal file
18
map/basic_render_policy.hpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
#pragma once
|
||||
|
||||
#include "render_policy.hpp"
|
||||
#include "drawer_yg.hpp"
|
||||
|
||||
class VideoTimer;
|
||||
|
||||
class BasicRenderPolicy : public RenderPolicy
|
||||
{
|
||||
public:
|
||||
BasicRenderPolicy(VideoTimer * videoTimer,
|
||||
bool useDefaultFB,
|
||||
yg::ResourceManager::Params const & rmParams,
|
||||
shared_ptr<yg::gl::RenderContext> const & primaryRC);
|
||||
|
||||
void DrawFrame(shared_ptr<PaintEvent> const & paintEvent,
|
||||
ScreenBase const & screenBase);
|
||||
};
|
|
@ -41,7 +41,7 @@ HEADERS += \
|
|||
benchmark_render_policy_mt.hpp \
|
||||
ruler.hpp \
|
||||
measurement_utils.hpp \
|
||||
partial_render_policy.hpp \
|
||||
basic_render_policy.hpp \
|
||||
proto_to_yg_styles.hpp \
|
||||
test_render_policy.hpp \
|
||||
queued_render_policy.hpp
|
||||
|
@ -75,7 +75,7 @@ SOURCES += \
|
|||
ruler.cpp \
|
||||
measurement_utils.cpp \
|
||||
window_handle.cpp \
|
||||
partial_render_policy.cpp \
|
||||
basic_render_policy.cpp \
|
||||
proto_to_yg_styles.cpp \
|
||||
test_render_policy.cpp \
|
||||
queued_render_policy.cpp
|
||||
|
|
|
@ -1,248 +0,0 @@
|
|||
#include "partial_render_policy.hpp"
|
||||
#include "events.hpp"
|
||||
#include "window_handle.hpp"
|
||||
#include "drawer_yg.hpp"
|
||||
#include "render_queue.hpp"
|
||||
|
||||
#include "../yg/internal/opengl.hpp"
|
||||
#include "../yg/render_state.hpp"
|
||||
#include "../yg/base_texture.hpp"
|
||||
|
||||
#include "../geometry/transformations.hpp"
|
||||
|
||||
#include "../platform/platform.hpp"
|
||||
|
||||
#include "../std/bind.hpp"
|
||||
|
||||
PartialRenderPolicy::PartialRenderPolicy(VideoTimer * videoTimer,
|
||||
bool useDefaultFB,
|
||||
yg::ResourceManager::Params const & rmParams,
|
||||
shared_ptr<yg::gl::RenderContext> const & primaryRC)
|
||||
: QueuedRenderPolicy(1, primaryRC, false),
|
||||
m_DoAddCommand(true)
|
||||
{
|
||||
yg::ResourceManager::Params rmp = rmParams;
|
||||
|
||||
rmp.m_primaryStoragesParams = yg::ResourceManager::StoragePoolParams(5000 * sizeof(yg::gl::Vertex),
|
||||
sizeof(yg::gl::Vertex),
|
||||
10000 * sizeof(unsigned short),
|
||||
sizeof(unsigned short),
|
||||
4,
|
||||
true,
|
||||
false,
|
||||
2,
|
||||
"primaryStorage");
|
||||
|
||||
rmp.m_smallStoragesParams = yg::ResourceManager::StoragePoolParams(2000 * sizeof(yg::gl::Vertex),
|
||||
sizeof(yg::gl::Vertex),
|
||||
4000 * sizeof(unsigned short),
|
||||
sizeof(unsigned short),
|
||||
4,
|
||||
true,
|
||||
false,
|
||||
1,
|
||||
"smallStorage");
|
||||
|
||||
rmp.m_blitStoragesParams = yg::ResourceManager::StoragePoolParams(10 * sizeof(yg::gl::Vertex),
|
||||
sizeof(yg::gl::Vertex),
|
||||
10 * sizeof(unsigned short),
|
||||
sizeof(unsigned short),
|
||||
50,
|
||||
true,
|
||||
true,
|
||||
1,
|
||||
"blitStorage");
|
||||
|
||||
rmp.m_guiThreadStoragesParams = yg::ResourceManager::StoragePoolParams(300 * sizeof(yg::gl::Vertex),
|
||||
sizeof(yg::gl::Vertex),
|
||||
600 * sizeof(unsigned short),
|
||||
sizeof(unsigned short),
|
||||
20,
|
||||
true,
|
||||
true,
|
||||
1,
|
||||
"guiThreadStorage");
|
||||
|
||||
rmp.m_primaryTexturesParams = yg::ResourceManager::TexturePoolParams(512,
|
||||
256,
|
||||
6,
|
||||
rmp.m_texFormat,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
1,
|
||||
"primaryTexture");
|
||||
|
||||
rmp.m_fontTexturesParams = yg::ResourceManager::TexturePoolParams(512,
|
||||
256,
|
||||
6,
|
||||
rmp.m_texFormat,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
1,
|
||||
"fontTextures");
|
||||
|
||||
rmp.m_guiThreadTexturesParams = yg::ResourceManager::TexturePoolParams(256,
|
||||
128,
|
||||
4,
|
||||
rmp.m_texFormat,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
1,
|
||||
"guiThreadTexture");
|
||||
|
||||
rmp.m_glyphCacheParams = yg::ResourceManager::GlyphCacheParams("unicode_blocks.txt",
|
||||
"fonts_whitelist.txt",
|
||||
"fonts_blacklist.txt",
|
||||
2 * 1024 * 1024,
|
||||
2,
|
||||
1);
|
||||
|
||||
rmp.m_useSingleThreadedOGL = true;
|
||||
rmp.m_useVA = !yg::gl::g_isBufferObjectsSupported;
|
||||
|
||||
rmp.fitIntoLimits();
|
||||
|
||||
m_resourceManager.reset(new yg::ResourceManager(rmp));
|
||||
|
||||
Platform::FilesList fonts;
|
||||
GetPlatform().GetFontNames(fonts);
|
||||
m_resourceManager->addFonts(fonts);
|
||||
|
||||
DrawerYG::params_t p;
|
||||
|
||||
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();
|
||||
p.m_isSynchronized = false;
|
||||
p.m_useGuiResources = true;
|
||||
|
||||
m_drawer.reset(new DrawerYG(p));
|
||||
|
||||
m_windowHandle.reset(new WindowHandle());
|
||||
|
||||
m_windowHandle->setUpdatesEnabled(false);
|
||||
m_windowHandle->setVideoTimer(videoTimer);
|
||||
m_windowHandle->setRenderContext(primaryRC);
|
||||
|
||||
m_renderQueue.reset(new RenderQueue(GetPlatform().SkinName(),
|
||||
false,
|
||||
true,
|
||||
0.1,
|
||||
false,
|
||||
GetPlatform().ScaleEtalonSize(),
|
||||
GetPlatform().VisualScale(),
|
||||
m_bgColor));
|
||||
|
||||
m_renderQueue->AddWindowHandle(m_windowHandle);
|
||||
|
||||
m_renderQueue->SetGLQueue(GetPacketsQueue(0));
|
||||
}
|
||||
|
||||
void PartialRenderPolicy::SetRenderFn(TRenderFn renderFn)
|
||||
{
|
||||
RenderPolicy::SetRenderFn(renderFn);
|
||||
m_renderQueue->initializeGL(m_primaryRC, m_resourceManager);
|
||||
}
|
||||
|
||||
void PartialRenderPolicy::SetEmptyModelFn(TEmptyModelFn const & checkFn)
|
||||
{
|
||||
m_renderQueue->SetEmptyModelFn(checkFn);
|
||||
}
|
||||
|
||||
PartialRenderPolicy::~PartialRenderPolicy()
|
||||
{
|
||||
LOG(LINFO, ("destroying PartialRenderPolicy"));
|
||||
|
||||
base_t::DismissQueuedCommands(0);
|
||||
|
||||
LOG(LINFO, ("shutting down renderQueue"));
|
||||
|
||||
m_renderQueue.reset();
|
||||
|
||||
LOG(LINFO, ("PartialRenderPolicy destroyed"));
|
||||
}
|
||||
|
||||
void PartialRenderPolicy::DrawFrame(shared_ptr<PaintEvent> const & e,
|
||||
ScreenBase const & s)
|
||||
{
|
||||
base_t::DrawFrame(e, s);
|
||||
|
||||
/// blitting actualTarget
|
||||
|
||||
m_renderQueue->renderStatePtr()->m_doRepaintAll = DoForceUpdate();
|
||||
|
||||
if (m_DoAddCommand && (DoForceUpdate() || (s != m_renderQueue->renderState().m_actualScreen)))
|
||||
m_renderQueue->AddCommand(m_renderFn, s);
|
||||
|
||||
SetForceUpdate(false);
|
||||
|
||||
DrawerYG * pDrawer = e->drawer();
|
||||
|
||||
e->drawer()->screen()->clear(m_bgColor);
|
||||
|
||||
m_renderQueue->renderState().m_mutex->Lock();
|
||||
|
||||
if (m_renderQueue->renderState().m_actualTarget.get() != 0)
|
||||
{
|
||||
m2::PointD const ptShift = m_renderQueue->renderState().coordSystemShift(false);
|
||||
|
||||
math::Matrix<double, 3, 3> m = m_renderQueue->renderState().m_actualScreen.PtoGMatrix() * s.GtoPMatrix();
|
||||
m = math::Shift(m, -ptShift);
|
||||
|
||||
pDrawer->screen()->blit(m_renderQueue->renderState().m_actualTarget, m);
|
||||
}
|
||||
}
|
||||
|
||||
void PartialRenderPolicy::EndFrame(shared_ptr<PaintEvent> const & ev,
|
||||
ScreenBase const & s)
|
||||
{
|
||||
m_renderQueue->renderState().m_mutex->Unlock();
|
||||
base_t::EndFrame(ev, s);
|
||||
}
|
||||
|
||||
bool PartialRenderPolicy::IsEmptyModel() const
|
||||
{
|
||||
return m_renderQueue->renderState().m_isEmptyModelActual;
|
||||
}
|
||||
|
||||
m2::RectI const PartialRenderPolicy::OnSize(int w, int h)
|
||||
{
|
||||
RenderPolicy::OnSize(w, h);
|
||||
|
||||
m_renderQueue->OnSize(w, h);
|
||||
|
||||
m2::PointU pt = m_renderQueue->renderState().coordSystemShift();
|
||||
|
||||
return m2::RectI(pt.x, pt.y, pt.x + w, pt.y + h);
|
||||
}
|
||||
|
||||
void PartialRenderPolicy::StartDrag()
|
||||
{
|
||||
m_DoAddCommand = false;
|
||||
RenderPolicy::StartDrag();
|
||||
}
|
||||
|
||||
void PartialRenderPolicy::StopDrag()
|
||||
{
|
||||
m_DoAddCommand = true;
|
||||
RenderPolicy::StopDrag();
|
||||
}
|
||||
|
||||
void PartialRenderPolicy::StartScale()
|
||||
{
|
||||
m_DoAddCommand = false;
|
||||
RenderPolicy::StartScale();
|
||||
}
|
||||
|
||||
void PartialRenderPolicy::StopScale()
|
||||
{
|
||||
m_DoAddCommand = true;
|
||||
RenderPolicy::StartScale();
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "queued_render_policy.hpp"
|
||||
#include "../yg/screen.hpp"
|
||||
#include "../base/threaded_list.hpp"
|
||||
#include "../std/scoped_ptr.hpp"
|
||||
|
||||
class RenderQueue;
|
||||
class WindowHandle;
|
||||
|
||||
class PartialRenderPolicy : public QueuedRenderPolicy
|
||||
{
|
||||
private:
|
||||
|
||||
typedef QueuedRenderPolicy base_t;
|
||||
|
||||
scoped_ptr<RenderQueue> m_renderQueue;
|
||||
bool m_DoAddCommand;
|
||||
bool m_DoSynchronize;
|
||||
|
||||
public:
|
||||
|
||||
PartialRenderPolicy(VideoTimer * videoTimer,
|
||||
bool useDefaultFB,
|
||||
yg::ResourceManager::Params const & rmParams,
|
||||
shared_ptr<yg::gl::RenderContext> const & primaryRC);
|
||||
|
||||
~PartialRenderPolicy();
|
||||
|
||||
void DrawFrame(shared_ptr<PaintEvent> const & paintEvent,
|
||||
ScreenBase const & screenBase);
|
||||
|
||||
void EndFrame(shared_ptr<PaintEvent> const & paintEvent,
|
||||
ScreenBase const & screenBase);
|
||||
|
||||
m2::RectI const OnSize(int w, int h);
|
||||
|
||||
bool IsEmptyModel() const;
|
||||
|
||||
void StartDrag();
|
||||
void StopDrag();
|
||||
|
||||
void StartScale();
|
||||
void StopScale();
|
||||
|
||||
RenderQueue & GetRenderQueue();
|
||||
|
||||
void SetRenderFn(TRenderFn renderFn);
|
||||
void SetEmptyModelFn(TEmptyModelFn const & checkFn);
|
||||
};
|
|
@ -5,11 +5,11 @@
|
|||
#include "../indexer/drawing_rules.hpp"
|
||||
|
||||
#include "test_render_policy.hpp"
|
||||
#include "basic_render_policy.hpp"
|
||||
#include "render_policy_st.hpp"
|
||||
#include "render_policy_mt.hpp"
|
||||
#include "tiling_render_policy_st.hpp"
|
||||
#include "tiling_render_policy_mt.hpp"
|
||||
#include "partial_render_policy.hpp"
|
||||
#include "benchmark_render_policy_mt.hpp"
|
||||
#include "benchmark_tiling_render_policy_mt.hpp"
|
||||
|
||||
|
|
|
@ -1,43 +1,45 @@
|
|||
#include "../base/SRC_FIRST.hpp"
|
||||
|
||||
#include "render_policy_st.hpp"
|
||||
#include "events.hpp"
|
||||
#include "drawer_yg.hpp"
|
||||
#include "window_handle.hpp"
|
||||
#include "../yg/info_layer.hpp"
|
||||
#include "../yg/internal/opengl.hpp"
|
||||
#include "../yg/skin.hpp"
|
||||
#include "drawer_yg.hpp"
|
||||
#include "render_queue.hpp"
|
||||
|
||||
#include "../indexer/scales.hpp"
|
||||
#include "../geometry/screenbase.hpp"
|
||||
#include "../yg/internal/opengl.hpp"
|
||||
#include "../yg/render_state.hpp"
|
||||
#include "../yg/base_texture.hpp"
|
||||
|
||||
#include "../geometry/transformations.hpp"
|
||||
|
||||
#include "../platform/platform.hpp"
|
||||
|
||||
#include "../std/bind.hpp"
|
||||
|
||||
RenderPolicyST::RenderPolicyST(VideoTimer * videoTimer,
|
||||
bool useDefaultFB,
|
||||
yg::ResourceManager::Params const & rmParams,
|
||||
shared_ptr<yg::gl::RenderContext> const & primaryRC)
|
||||
: RenderPolicy(primaryRC, false)
|
||||
: QueuedRenderPolicy(1, primaryRC, false),
|
||||
m_DoAddCommand(true)
|
||||
{
|
||||
yg::ResourceManager::Params rmp = rmParams;
|
||||
|
||||
rmp.m_primaryStoragesParams = yg::ResourceManager::StoragePoolParams(50000 * sizeof(yg::gl::Vertex),
|
||||
rmp.m_primaryStoragesParams = yg::ResourceManager::StoragePoolParams(5000 * sizeof(yg::gl::Vertex),
|
||||
sizeof(yg::gl::Vertex),
|
||||
10000 * sizeof(unsigned short),
|
||||
sizeof(unsigned short),
|
||||
15,
|
||||
false,
|
||||
4,
|
||||
true,
|
||||
1,
|
||||
false,
|
||||
2,
|
||||
"primaryStorage");
|
||||
|
||||
rmp.m_smallStoragesParams = yg::ResourceManager::StoragePoolParams(5000 * sizeof(yg::gl::Vertex),
|
||||
rmp.m_smallStoragesParams = yg::ResourceManager::StoragePoolParams(2000 * sizeof(yg::gl::Vertex),
|
||||
sizeof(yg::gl::Vertex),
|
||||
10000 * sizeof(unsigned short),
|
||||
4000 * sizeof(unsigned short),
|
||||
sizeof(unsigned short),
|
||||
100,
|
||||
false,
|
||||
4,
|
||||
true,
|
||||
false,
|
||||
1,
|
||||
"smallStorage");
|
||||
|
||||
|
@ -51,9 +53,19 @@ RenderPolicyST::RenderPolicyST(VideoTimer * videoTimer,
|
|||
1,
|
||||
"blitStorage");
|
||||
|
||||
rmp.m_guiThreadStoragesParams = yg::ResourceManager::StoragePoolParams(300 * sizeof(yg::gl::Vertex),
|
||||
sizeof(yg::gl::Vertex),
|
||||
600 * sizeof(unsigned short),
|
||||
sizeof(unsigned short),
|
||||
20,
|
||||
true,
|
||||
true,
|
||||
1,
|
||||
"guiThreadStorage");
|
||||
|
||||
rmp.m_primaryTexturesParams = yg::ResourceManager::TexturePoolParams(512,
|
||||
256,
|
||||
10,
|
||||
6,
|
||||
rmp.m_texFormat,
|
||||
true,
|
||||
true,
|
||||
|
@ -63,25 +75,36 @@ RenderPolicyST::RenderPolicyST(VideoTimer * videoTimer,
|
|||
|
||||
rmp.m_fontTexturesParams = yg::ResourceManager::TexturePoolParams(512,
|
||||
256,
|
||||
5,
|
||||
6,
|
||||
rmp.m_texFormat,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
1,
|
||||
"fontTexture");
|
||||
"fontTextures");
|
||||
|
||||
rmp.m_guiThreadTexturesParams = yg::ResourceManager::TexturePoolParams(256,
|
||||
128,
|
||||
4,
|
||||
rmp.m_texFormat,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
1,
|
||||
"guiThreadTexture");
|
||||
|
||||
rmp.m_glyphCacheParams = yg::ResourceManager::GlyphCacheParams("unicode_blocks.txt",
|
||||
"fonts_whitelist.txt",
|
||||
"fonts_blacklist.txt",
|
||||
2 * 1024 * 1024,
|
||||
1,
|
||||
0);
|
||||
2,
|
||||
1);
|
||||
|
||||
|
||||
rmp.m_useSingleThreadedOGL = false;
|
||||
rmp.m_useSingleThreadedOGL = true;
|
||||
rmp.m_useVA = !yg::gl::g_isBufferObjectsSupported;
|
||||
|
||||
rmp.fitIntoLimits();
|
||||
|
||||
m_resourceManager.reset(new yg::ResourceManager(rmp));
|
||||
|
||||
Platform::FilesList fonts;
|
||||
|
@ -97,7 +120,8 @@ RenderPolicyST::RenderPolicyST(VideoTimer * videoTimer,
|
|||
p.m_glyphCacheID = m_resourceManager->guiThreadGlyphCacheID();
|
||||
p.m_skinName = GetPlatform().SkinName();
|
||||
p.m_visualScale = GetPlatform().VisualScale();
|
||||
p.m_isSynchronized = true;
|
||||
p.m_isSynchronized = false;
|
||||
p.m_useGuiResources = true;
|
||||
|
||||
m_drawer.reset(new DrawerYG(p));
|
||||
|
||||
|
@ -106,27 +130,119 @@ RenderPolicyST::RenderPolicyST(VideoTimer * videoTimer,
|
|||
m_windowHandle->setUpdatesEnabled(false);
|
||||
m_windowHandle->setVideoTimer(videoTimer);
|
||||
m_windowHandle->setRenderContext(primaryRC);
|
||||
|
||||
m_renderQueue.reset(new RenderQueue(GetPlatform().SkinName(),
|
||||
false,
|
||||
true,
|
||||
0.1,
|
||||
false,
|
||||
GetPlatform().ScaleEtalonSize(),
|
||||
GetPlatform().VisualScale(),
|
||||
m_bgColor));
|
||||
|
||||
m_renderQueue->AddWindowHandle(m_windowHandle);
|
||||
|
||||
m_renderQueue->SetGLQueue(GetPacketsQueue(0));
|
||||
}
|
||||
|
||||
void RenderPolicyST::SetRenderFn(TRenderFn renderFn)
|
||||
{
|
||||
QueuedRenderPolicy::SetRenderFn(renderFn);
|
||||
m_renderQueue->initializeGL(m_primaryRC, m_resourceManager);
|
||||
}
|
||||
|
||||
void RenderPolicyST::SetEmptyModelFn(TEmptyModelFn const & checkFn)
|
||||
{
|
||||
m_renderQueue->SetEmptyModelFn(checkFn);
|
||||
}
|
||||
|
||||
RenderPolicyST::~RenderPolicyST()
|
||||
{
|
||||
LOG(LINFO, ("destroying RenderPolicyST"));
|
||||
|
||||
base_t::DismissQueuedCommands(0);
|
||||
|
||||
LOG(LINFO, ("shutting down renderQueue"));
|
||||
|
||||
m_renderQueue.reset();
|
||||
|
||||
LOG(LINFO, ("PartialRenderPolicy destroyed"));
|
||||
}
|
||||
|
||||
void RenderPolicyST::DrawFrame(shared_ptr<PaintEvent> const & e,
|
||||
ScreenBase const & s)
|
||||
{
|
||||
int scaleEtalonSize = GetPlatform().ScaleEtalonSize();
|
||||
base_t::DrawFrame(e, s);
|
||||
|
||||
m2::RectD glbRect;
|
||||
m2::PointD const pxCenter = s.PixelRect().Center();
|
||||
s.PtoG(m2::RectD(pxCenter - m2::PointD(scaleEtalonSize / 2, scaleEtalonSize / 2),
|
||||
pxCenter + m2::PointD(scaleEtalonSize / 2, scaleEtalonSize / 2)),
|
||||
glbRect);
|
||||
/// blitting actualTarget
|
||||
|
||||
shared_ptr<yg::InfoLayer> infoLayer(new yg::InfoLayer());
|
||||
m_renderQueue->renderStatePtr()->m_doRepaintAll = DoForceUpdate();
|
||||
|
||||
e->drawer()->screen()->setInfoLayer(infoLayer);
|
||||
if (m_DoAddCommand && (DoForceUpdate() || (s != m_renderQueue->renderState().m_actualScreen)))
|
||||
m_renderQueue->AddCommand(m_renderFn, s);
|
||||
|
||||
SetForceUpdate(false);
|
||||
|
||||
DrawerYG * pDrawer = e->drawer();
|
||||
|
||||
e->drawer()->screen()->clear(m_bgColor);
|
||||
|
||||
m_renderFn(e, s, s.ClipRect(), s.ClipRect(), scales::GetScaleLevel(glbRect));
|
||||
m_renderQueue->renderState().m_mutex->Lock();
|
||||
|
||||
infoLayer->draw(e->drawer()->screen().get(), math::Identity<double, 3>());
|
||||
e->drawer()->screen()->resetInfoLayer();
|
||||
if (m_renderQueue->renderState().m_actualTarget.get() != 0)
|
||||
{
|
||||
m2::PointD const ptShift = m_renderQueue->renderState().coordSystemShift(false);
|
||||
|
||||
math::Matrix<double, 3, 3> m = m_renderQueue->renderState().m_actualScreen.PtoGMatrix() * s.GtoPMatrix();
|
||||
m = math::Shift(m, -ptShift);
|
||||
|
||||
pDrawer->screen()->blit(m_renderQueue->renderState().m_actualTarget, m);
|
||||
}
|
||||
}
|
||||
|
||||
void RenderPolicyST::EndFrame(shared_ptr<PaintEvent> const & ev,
|
||||
ScreenBase const & s)
|
||||
{
|
||||
m_renderQueue->renderState().m_mutex->Unlock();
|
||||
base_t::EndFrame(ev, s);
|
||||
}
|
||||
|
||||
bool RenderPolicyST::IsEmptyModel() const
|
||||
{
|
||||
return m_renderQueue->renderState().m_isEmptyModelActual;
|
||||
}
|
||||
|
||||
m2::RectI const RenderPolicyST::OnSize(int w, int h)
|
||||
{
|
||||
QueuedRenderPolicy::OnSize(w, h);
|
||||
|
||||
m_renderQueue->OnSize(w, h);
|
||||
|
||||
m2::PointU pt = m_renderQueue->renderState().coordSystemShift();
|
||||
|
||||
return m2::RectI(pt.x, pt.y, pt.x + w, pt.y + h);
|
||||
}
|
||||
|
||||
void RenderPolicyST::StartDrag()
|
||||
{
|
||||
m_DoAddCommand = false;
|
||||
base_t::StartDrag();
|
||||
}
|
||||
|
||||
void RenderPolicyST::StopDrag()
|
||||
{
|
||||
m_DoAddCommand = true;
|
||||
base_t::StopDrag();
|
||||
}
|
||||
|
||||
void RenderPolicyST::StartScale()
|
||||
{
|
||||
m_DoAddCommand = false;
|
||||
base_t::StartScale();
|
||||
}
|
||||
|
||||
void RenderPolicyST::StopScale()
|
||||
{
|
||||
m_DoAddCommand = true;
|
||||
base_t::StartScale();
|
||||
}
|
||||
|
|
|
@ -1,18 +1,50 @@
|
|||
#pragma once
|
||||
|
||||
#include "render_policy.hpp"
|
||||
#include "drawer_yg.hpp"
|
||||
#include "queued_render_policy.hpp"
|
||||
#include "../yg/screen.hpp"
|
||||
#include "../base/threaded_list.hpp"
|
||||
#include "../std/scoped_ptr.hpp"
|
||||
|
||||
class VideoTimer;
|
||||
class RenderQueue;
|
||||
class WindowHandle;
|
||||
|
||||
class RenderPolicyST : public RenderPolicy
|
||||
class RenderPolicyST : public QueuedRenderPolicy
|
||||
{
|
||||
private:
|
||||
|
||||
typedef QueuedRenderPolicy base_t;
|
||||
|
||||
scoped_ptr<RenderQueue> m_renderQueue;
|
||||
bool m_DoAddCommand;
|
||||
bool m_DoSynchronize;
|
||||
|
||||
public:
|
||||
|
||||
RenderPolicyST(VideoTimer * videoTimer,
|
||||
bool useDefaultFB,
|
||||
yg::ResourceManager::Params const & rmParams,
|
||||
shared_ptr<yg::gl::RenderContext> const & primaryRC);
|
||||
|
||||
~RenderPolicyST();
|
||||
|
||||
void DrawFrame(shared_ptr<PaintEvent> const & paintEvent,
|
||||
ScreenBase const & screenBase);
|
||||
|
||||
void EndFrame(shared_ptr<PaintEvent> const & paintEvent,
|
||||
ScreenBase const & screenBase);
|
||||
|
||||
m2::RectI const OnSize(int w, int h);
|
||||
|
||||
bool IsEmptyModel() const;
|
||||
|
||||
void StartDrag();
|
||||
void StopDrag();
|
||||
|
||||
void StartScale();
|
||||
void StopScale();
|
||||
|
||||
RenderQueue & GetRenderQueue();
|
||||
|
||||
void SetRenderFn(TRenderFn renderFn);
|
||||
void SetEmptyModelFn(TEmptyModelFn const & checkFn);
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue