forked from organicmaps/organicmaps
removed yg::RenderState and RenderStateUpdater.
This commit is contained in:
parent
dc35f91b50
commit
c68d9e1ef0
13 changed files with 7 additions and 462 deletions
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include "render_policy.hpp"
|
||||
|
||||
#include "../geometry/screenbase.hpp"
|
||||
|
||||
#include "../std/shared_ptr.hpp"
|
||||
#include "../yg/overlay.hpp"
|
||||
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
#include "../indexer/feature_data.hpp"
|
||||
#include "../indexer/feature_impl.hpp"
|
||||
|
||||
#include "../yg/render_state.hpp"
|
||||
|
||||
#include "../std/bind.hpp"
|
||||
|
||||
|
||||
|
@ -279,12 +277,6 @@ namespace fwork
|
|||
else
|
||||
m_hasNonCoast = true;
|
||||
|
||||
{
|
||||
yg::gl::RenderState * pState = GetDrawer()->screen()->renderState().get();
|
||||
if (pState)
|
||||
pState->m_isEmptyModelCurrent = IsEmptyDrawing();
|
||||
}
|
||||
|
||||
// remove duplicating identical drawing keys
|
||||
PreProcessKeys(keys);
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include "../coding/internal/file_data.hpp"
|
||||
|
||||
#include "../yg/rendercontext.hpp"
|
||||
#include "../yg/render_state.hpp"
|
||||
|
||||
#include "../geometry/angles.hpp"
|
||||
#include "../geometry/distance_on_sphere.hpp"
|
||||
|
@ -669,14 +668,7 @@ void Framework::DrawModel(shared_ptr<PaintEvent> const & e,
|
|||
m_model.ForEachFeature(selectRect, doDraw, scale);
|
||||
}
|
||||
catch (redraw_operation_cancelled const &)
|
||||
{
|
||||
shared_ptr<yg::gl::RenderState> pState = e->drawer()->screen()->renderState();
|
||||
if (pState)
|
||||
{
|
||||
pState->m_isEmptyModelCurrent = false;
|
||||
pState->m_isEmptyModelActual = false;
|
||||
}
|
||||
}
|
||||
{}
|
||||
|
||||
e->setIsEmptyDrawing(doDraw.IsEmptyDrawing());
|
||||
|
||||
|
@ -727,7 +719,7 @@ void Framework::DrawAdditionalInfo(shared_ptr<PaintEvent> const & e)
|
|||
|
||||
m_informationDisplay.setScreen(m_navigator.Screen());
|
||||
|
||||
m_informationDisplay.setDebugInfo(0/*m_renderQueue.renderState().m_duration*/, GetDrawScale());
|
||||
m_informationDisplay.setDebugInfo(0, GetDrawScale());
|
||||
|
||||
m2::PointD const center = m_navigator.Screen().GlobalRect().GlobalCenter();
|
||||
m_informationDisplay.setCenter(m2::PointD(MercatorBounds::XToLon(center.x),
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include "window_handle.hpp"
|
||||
|
||||
#include "../yg/internal/opengl.hpp"
|
||||
#include "../yg/render_state.hpp"
|
||||
#include "../yg/rendercontext.hpp"
|
||||
#include "../yg/base_texture.hpp"
|
||||
#include "../yg/packets_queue.hpp"
|
||||
|
|
|
@ -20,7 +20,6 @@ namespace yg
|
|||
class ResourceManager;
|
||||
namespace gl
|
||||
{
|
||||
class RenderState;
|
||||
class RenderContext;
|
||||
class PacketsQueue;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "buffer_object.hpp"
|
||||
#include "renderbuffer.hpp"
|
||||
#include "framebuffer.hpp"
|
||||
#include "render_state_updater.hpp"
|
||||
#include "blitter.hpp"
|
||||
#include "storage.hpp"
|
||||
#include "skin_page.hpp"
|
||||
#include "resource_manager.hpp"
|
||||
|
@ -29,7 +29,7 @@ namespace yg
|
|||
|
||||
namespace gl
|
||||
{
|
||||
class GeometryBatcher : public RenderStateUpdater
|
||||
class GeometryBatcher : public Blitter
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -37,7 +37,7 @@ namespace yg
|
|||
|
||||
private:
|
||||
|
||||
typedef RenderStateUpdater base_t;
|
||||
typedef Blitter base_t;
|
||||
|
||||
shared_ptr<yg::Skin> m_skin;
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include "path_text_element.hpp"
|
||||
#include "symbol_element.hpp"
|
||||
#include "circle_element.hpp"
|
||||
#include "render_state.hpp"
|
||||
#include "overlay.hpp"
|
||||
#include "resource_manager.hpp"
|
||||
#include "skin.hpp"
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
#include "../base/SRC_FIRST.hpp"
|
||||
#include "../base/logging.hpp"
|
||||
|
||||
#include "render_state.hpp"
|
||||
#include "renderbuffer.hpp"
|
||||
#include "overlay.hpp"
|
||||
|
||||
namespace yg
|
||||
{
|
||||
namespace gl
|
||||
{
|
||||
RenderState::RenderState()
|
||||
: m_actualOverlay(new yg::Overlay()),
|
||||
m_isEmptyModelActual(false),
|
||||
m_currentOverlay(new yg::Overlay()),
|
||||
m_isEmptyModelCurrent(false),
|
||||
m_isResized(false),
|
||||
m_doRepaintAll(false),
|
||||
m_mutex(new threads::Mutex())
|
||||
{}
|
||||
|
||||
bool RenderState::isPanning() const
|
||||
{
|
||||
return IsPanningAndRotate(m_actualScreen, m_currentScreen);
|
||||
}
|
||||
|
||||
void RenderState::copyTo(RenderState &s) const
|
||||
{
|
||||
threads::MutexGuard guard(*m_mutex.get());
|
||||
s = *this;
|
||||
}
|
||||
|
||||
void RenderState::addInvalidateFn(invalidateFn fn)
|
||||
{
|
||||
m_invalidateFns.push_back(fn);
|
||||
}
|
||||
|
||||
void RenderState::invalidate()
|
||||
{
|
||||
for (list<invalidateFn>::const_iterator it = m_invalidateFns.begin(); it != m_invalidateFns.end(); ++it)
|
||||
(*it)();
|
||||
}
|
||||
|
||||
void RenderState::onSize(size_t w, size_t h)
|
||||
{
|
||||
threads::MutexGuard guard(*m_mutex.get());
|
||||
if ((m_surfaceWidth != w) || (m_surfaceHeight != h))
|
||||
{
|
||||
m_isResized = true;
|
||||
|
||||
m_surfaceWidth = w;
|
||||
m_surfaceHeight = h;
|
||||
|
||||
/*
|
||||
double const log2 = log(2.0);
|
||||
|
||||
m_textureWidth = static_cast<uint32_t>(pow(2, ceil(log(double(w)) / log2)));
|
||||
m_textureHeight = static_cast<uint32_t>(pow(2, ceil(log(double(h)) / log2)));
|
||||
|
||||
m_textureWidth = max(m_textureWidth, m_textureHeight);
|
||||
m_textureHeight = max(m_textureWidth, m_textureHeight);
|
||||
*/
|
||||
m_textureWidth = m_textureHeight =
|
||||
1 << static_cast<int>(ceil(log(double(max(w, h))) / log(2.0)));
|
||||
}
|
||||
}
|
||||
|
||||
m2::PointU const RenderState::coordSystemShift(bool doLock) const
|
||||
{
|
||||
if (doLock)
|
||||
m_mutex->Lock();
|
||||
m2::PointU const res((m_textureWidth - m_surfaceWidth) / 2,
|
||||
(m_textureHeight - m_surfaceHeight) / 2);
|
||||
if (doLock)
|
||||
m_mutex->Unlock();
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,88 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "../geometry/screenbase.hpp"
|
||||
|
||||
#include "../base/mutex.hpp"
|
||||
|
||||
#include "../std/function.hpp"
|
||||
#include "../std/list.hpp"
|
||||
#include "../std/shared_ptr.hpp"
|
||||
|
||||
namespace yg
|
||||
{
|
||||
class Overlay;
|
||||
|
||||
namespace gl
|
||||
{
|
||||
class BaseTexture;
|
||||
class RenderBuffer;
|
||||
|
||||
class RenderState
|
||||
{
|
||||
public:
|
||||
|
||||
typedef function<void()> invalidateFn;
|
||||
|
||||
/// Already rendered model params
|
||||
/// @{
|
||||
/// Bitmap
|
||||
shared_ptr<BaseTexture> m_actualTarget;
|
||||
/// Information layer
|
||||
shared_ptr<yg::Overlay> m_actualOverlay;
|
||||
/// Screen parameters
|
||||
ScreenBase m_actualScreen;
|
||||
/// Empty-model flag of the actual target
|
||||
bool m_isEmptyModelActual;
|
||||
/// Name of the country at the center of the actualScreen
|
||||
string m_countryNameActual;
|
||||
/// @}
|
||||
|
||||
/// In-Progress rendering operation params
|
||||
/// @{
|
||||
/// Screen of the rendering operation in progress.
|
||||
ScreenBase m_currentScreen;
|
||||
/// information layer
|
||||
shared_ptr<yg::Overlay> m_currentOverlay;
|
||||
/// at least one backBuffer layer
|
||||
shared_ptr<BaseTexture> m_backBuffer;
|
||||
/// depth buffer used for rendering
|
||||
shared_ptr<RenderBuffer> m_depthBuffer;
|
||||
/// Duration of the rendering operation
|
||||
double m_duration;
|
||||
/// Empty-model flag of the current rendering operation
|
||||
bool m_isEmptyModelCurrent;
|
||||
/// @}
|
||||
|
||||
/// Surface height and width.
|
||||
unsigned int m_surfaceWidth;
|
||||
unsigned int m_surfaceHeight;
|
||||
|
||||
/// Texture height and width.
|
||||
unsigned int m_textureWidth;
|
||||
unsigned int m_textureHeight;
|
||||
|
||||
/// Have this state been resized?
|
||||
bool m_isResized;
|
||||
/// RepaintAll flag
|
||||
bool m_doRepaintAll;
|
||||
|
||||
mutable shared_ptr<threads::Mutex> m_mutex;
|
||||
|
||||
list<invalidateFn> m_invalidateFns;
|
||||
|
||||
RenderState();
|
||||
|
||||
bool isPanning() const;
|
||||
|
||||
void copyTo(RenderState & s) const;
|
||||
|
||||
void invalidate();
|
||||
|
||||
void addInvalidateFn(invalidateFn fn);
|
||||
|
||||
void onSize(size_t w, size_t h);
|
||||
|
||||
m2::PointU const coordSystemShift(bool doLock = false) const;
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,191 +0,0 @@
|
|||
#include "../base/SRC_FIRST.hpp"
|
||||
|
||||
#include "render_state_updater.hpp"
|
||||
#include "render_state.hpp"
|
||||
#include "renderbuffer.hpp"
|
||||
#include "framebuffer.hpp"
|
||||
#include "base_texture.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
#include "internal/opengl.hpp"
|
||||
|
||||
#include "../base/logging.hpp"
|
||||
#include "../std/bind.hpp"
|
||||
|
||||
namespace yg
|
||||
{
|
||||
namespace gl
|
||||
{
|
||||
RenderStateUpdater::Params::Params()
|
||||
: m_doPeriodicalUpdate(false), m_updateInterval(0.0)
|
||||
{}
|
||||
|
||||
RenderStateUpdater::RenderStateUpdater(Params const & params)
|
||||
: base_t(params),
|
||||
m_renderState(params.m_renderState),
|
||||
m_auxFrameBuffer(params.m_auxFrameBuffer),
|
||||
m_doPeriodicalUpdate(params.m_doPeriodicalUpdate),
|
||||
m_updateInterval(params.m_updateInterval)
|
||||
{
|
||||
if ((m_doPeriodicalUpdate) && (!m_auxFrameBuffer))
|
||||
{
|
||||
m_auxFrameBuffer.reset();
|
||||
m_auxFrameBuffer.reset(new FrameBuffer());
|
||||
}
|
||||
}
|
||||
|
||||
shared_ptr<RenderState> const & RenderStateUpdater::renderState() const
|
||||
{
|
||||
return m_renderState;
|
||||
}
|
||||
|
||||
void RenderStateUpdater::drawGeometry(shared_ptr<BaseTexture> const & texture,
|
||||
Storage const & storage,
|
||||
size_t indicesCount,
|
||||
size_t indicesOffs,
|
||||
unsigned primType)
|
||||
{
|
||||
base_t::drawGeometry(texture, storage, indicesCount, indicesOffs, primType);
|
||||
m_indicesCount += indicesCount;
|
||||
if (m_doPeriodicalUpdate
|
||||
&& m_renderState
|
||||
&& (m_indicesCount > 20000)
|
||||
&& (m_updateTimer.ElapsedSeconds() > m_updateInterval))
|
||||
{
|
||||
updateActualTarget();
|
||||
m_indicesCount %= 20000;
|
||||
m_updateTimer.Reset();
|
||||
}
|
||||
}
|
||||
|
||||
void RenderStateUpdater::UpdateBackBuffer::perform()
|
||||
{
|
||||
if (isDebugging())
|
||||
LOG(LINFO, ("performing UpdateBackBuffer command"));
|
||||
|
||||
if (m_doSynchronize)
|
||||
m_renderState->m_mutex->Lock();
|
||||
|
||||
OGLCHECK(glFinish());
|
||||
|
||||
OGLCHECK(glDisableFn(GL_SCISSOR_TEST));
|
||||
|
||||
m_auxFrameBuffer->setRenderTarget(m_renderState->m_backBuffer);
|
||||
m_auxFrameBuffer->makeCurrent();
|
||||
|
||||
OGLCHECK(glClearColor(s_bgColor.r / 255.0,
|
||||
s_bgColor.g / 255.0,
|
||||
s_bgColor.b / 255.0,
|
||||
s_bgColor.a / 255.0));
|
||||
|
||||
OGLCHECK(glClear(GL_COLOR_BUFFER_BIT));
|
||||
|
||||
shared_ptr<IMMDrawTexturedRect> immDrawTexturedRect(
|
||||
new IMMDrawTexturedRect(m2::RectF(0, 0, m_renderState->m_actualTarget->width(), m_renderState->m_actualTarget->height()),
|
||||
m2::RectF(0, 0, 1, 1),
|
||||
m_renderState->m_actualTarget,
|
||||
m_resourceManager));
|
||||
|
||||
immDrawTexturedRect->setIsDebugging(isDebugging());
|
||||
immDrawTexturedRect->perform();
|
||||
|
||||
m_frameBuffer->makeCurrent();
|
||||
|
||||
if (m_isClipRectEnabled)
|
||||
OGLCHECK(glEnableFn(GL_SCISSOR_TEST));
|
||||
|
||||
OGLCHECK(glScissor(m_clipRect.minX(), m_clipRect.minY(), m_clipRect.maxX(), m_clipRect.maxY()));
|
||||
|
||||
OGLCHECK(glFinish());
|
||||
|
||||
if (m_doSynchronize)
|
||||
m_renderState->m_mutex->Unlock();
|
||||
}
|
||||
|
||||
void RenderStateUpdater::Invalidate::perform()
|
||||
{
|
||||
m_renderState->invalidate();
|
||||
}
|
||||
|
||||
void RenderStateUpdater::updateActualTarget()
|
||||
{
|
||||
/// Carefully synchronizing the access to the m_renderState to minimize wait time.
|
||||
finish();
|
||||
|
||||
completeCommands();
|
||||
|
||||
/// to re-set the states
|
||||
base_t::endFrame();
|
||||
base_t::beginFrame();
|
||||
|
||||
m_renderState->m_mutex->Lock();
|
||||
|
||||
swap(m_renderState->m_actualTarget, m_renderState->m_backBuffer);
|
||||
m_renderState->m_actualScreen = m_renderState->m_currentScreen;
|
||||
if (!m_renderState->m_isEmptyModelCurrent)
|
||||
m_renderState->m_isEmptyModelActual = m_renderState->m_isEmptyModelCurrent;
|
||||
|
||||
m_renderState->m_mutex->Unlock();
|
||||
|
||||
base_t::endFrame();
|
||||
|
||||
setRenderTarget(m_renderState->m_backBuffer);
|
||||
|
||||
shared_ptr<UpdateBackBuffer> command1(new UpdateBackBuffer());
|
||||
|
||||
command1->m_renderState = m_renderState;
|
||||
command1->m_resourceManager = resourceManager();
|
||||
command1->m_isClipRectEnabled = clipRectEnabled();
|
||||
command1->m_clipRect = clipRect();
|
||||
command1->m_doSynchronize = renderQueue();
|
||||
command1->m_auxFrameBuffer = m_auxFrameBuffer;
|
||||
command1->m_frameBuffer = frameBuffer();
|
||||
|
||||
base_t::beginFrame();
|
||||
|
||||
processCommand(command1);
|
||||
|
||||
m_renderState->invalidate();
|
||||
|
||||
shared_ptr<Invalidate> command2(new Invalidate());
|
||||
command2->m_renderState = m_renderState;
|
||||
|
||||
processCommand(command2);
|
||||
|
||||
base_t::endFrame();
|
||||
completeCommands();
|
||||
|
||||
setRenderTarget(m_renderState->m_backBuffer);
|
||||
base_t::beginFrame();
|
||||
}
|
||||
|
||||
void RenderStateUpdater::beginFrame()
|
||||
{
|
||||
base_t::beginFrame();
|
||||
m_indicesCount = 0;
|
||||
m_updateTimer.Reset();
|
||||
}
|
||||
|
||||
void RenderStateUpdater::setClipRect(m2::RectI const & rect)
|
||||
{
|
||||
if ((m_renderState) && (m_indicesCount))
|
||||
{
|
||||
updateActualTarget();
|
||||
m_indicesCount = 0;
|
||||
m_updateTimer.Reset();
|
||||
}
|
||||
|
||||
base_t::setClipRect(rect);
|
||||
}
|
||||
|
||||
void RenderStateUpdater::endFrame()
|
||||
{
|
||||
if (m_renderState)
|
||||
updateActualTarget();
|
||||
|
||||
m_indicesCount = 0;
|
||||
m_updateTimer.Reset();
|
||||
base_t::endFrame();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "../std/shared_ptr.hpp"
|
||||
#include "../geometry/screenbase.hpp"
|
||||
#include "../base/timer.hpp"
|
||||
|
||||
#include "blitter.hpp"
|
||||
|
||||
namespace yg
|
||||
{
|
||||
namespace gl
|
||||
{
|
||||
class RenderState;
|
||||
|
||||
class RenderStateUpdater : public Blitter
|
||||
{
|
||||
private:
|
||||
|
||||
typedef Blitter base_t;
|
||||
|
||||
shared_ptr<RenderState> m_renderState;
|
||||
shared_ptr<FrameBuffer> m_auxFrameBuffer;
|
||||
|
||||
int m_indicesCount;
|
||||
bool m_doPeriodicalUpdate;
|
||||
double m_updateInterval;
|
||||
my::Timer m_updateTimer;
|
||||
|
||||
struct UpdateBackBuffer : Command
|
||||
{
|
||||
shared_ptr<RenderState> m_renderState;
|
||||
shared_ptr<ResourceManager> m_resourceManager;
|
||||
shared_ptr<FrameBuffer> m_auxFrameBuffer;
|
||||
shared_ptr<FrameBuffer> m_frameBuffer;
|
||||
bool m_isClipRectEnabled;
|
||||
m2::RectI m_clipRect;
|
||||
bool m_doSynchronize;
|
||||
|
||||
void perform();
|
||||
};
|
||||
|
||||
struct Invalidate : Command
|
||||
{
|
||||
shared_ptr<RenderState> m_renderState;
|
||||
void perform();
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
struct Params : base_t::Params
|
||||
{
|
||||
bool m_doPeriodicalUpdate;
|
||||
double m_updateInterval;
|
||||
shared_ptr<RenderState> m_renderState;
|
||||
shared_ptr<FrameBuffer> m_auxFrameBuffer;
|
||||
Params();
|
||||
};
|
||||
|
||||
RenderStateUpdater(Params const & params);
|
||||
|
||||
shared_ptr<RenderState> const & renderState() const;
|
||||
|
||||
void drawGeometry(shared_ptr<BaseTexture> const & texture,
|
||||
Storage const & storage,
|
||||
size_t indicesCount,
|
||||
size_t indicesOffs,
|
||||
unsigned primType);
|
||||
|
||||
void beginFrame();
|
||||
void endFrame();
|
||||
void setClipRect(m2::RectI const & rect);
|
||||
void updateActualTarget();
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
#include "text_renderer.hpp"
|
||||
#include "render_state.hpp"
|
||||
#include "overlay.hpp"
|
||||
#include "resource_style.hpp"
|
||||
#include "resource_manager.hpp"
|
||||
|
|
|
@ -30,7 +30,6 @@ SOURCES += \
|
|||
blitter.cpp \
|
||||
clipper.cpp \
|
||||
renderer.cpp \
|
||||
render_state.cpp \
|
||||
geometry_renderer.cpp \
|
||||
skin_page.cpp \
|
||||
storage.cpp \
|
||||
|
@ -51,7 +50,6 @@ SOURCES += \
|
|||
overlay_element.cpp \
|
||||
symbol_element.cpp \
|
||||
overlay_renderer.cpp \
|
||||
render_state_updater.cpp \
|
||||
composite_overlay_element.cpp \
|
||||
path_text_element.cpp \
|
||||
straight_text_element.cpp \
|
||||
|
@ -85,7 +83,6 @@ HEADERS += \
|
|||
blitter.hpp \
|
||||
clipper.hpp \
|
||||
renderer.hpp \
|
||||
render_state.hpp \
|
||||
geometry_renderer.hpp \
|
||||
skin_page.hpp \
|
||||
storage.hpp \
|
||||
|
@ -110,7 +107,6 @@ HEADERS += \
|
|||
overlay_element.hpp \
|
||||
symbol_element.hpp \
|
||||
overlay_renderer.hpp \
|
||||
render_state_updater.hpp \
|
||||
composite_overlay_element.hpp \
|
||||
path_text_element.hpp \
|
||||
straight_text_element.hpp \
|
||||
|
|
Loading…
Add table
Reference in a new issue