Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaria Volvenkova <d.volvenkova@corp.mail.ru>2016-06-22 15:10:56 +0300
committerDaria Volvenkova <d.volvenkova@corp.mail.ru>2016-07-07 15:31:09 +0300
commit97d1cfd6605875821fb1886e6d9db2b463554089 (patch)
tree09719067f592cd46b221fc29588d85bb0d25c80d /drape_frontend
parente2543477a6425ec36a4fe4088bd255d6f916becc (diff)
Debug labels rendering.
Diffstat (limited to 'drape_frontend')
-rw-r--r--drape_frontend/backend_renderer.cpp13
-rw-r--r--drape_frontend/backend_renderer.hpp4
-rwxr-xr-xdrape_frontend/drape_frontend.pro2
-rwxr-xr-xdrape_frontend/frontend_renderer.cpp13
-rw-r--r--drape_frontend/gui/choose_position_mark.cpp2
-rw-r--r--drape_frontend/gui/debug_label.cpp94
-rw-r--r--drape_frontend/gui/debug_label.hpp28
-rw-r--r--drape_frontend/gui/layer_render.cpp97
-rw-r--r--drape_frontend/gui/layer_render.hpp4
-rw-r--r--drape_frontend/gui/shape.cpp2
-rw-r--r--drape_frontend/gui/skin.hpp12
11 files changed, 255 insertions, 16 deletions
diff --git a/drape_frontend/backend_renderer.cpp b/drape_frontend/backend_renderer.cpp
index cf0c5818b2..e022e72bab 100644
--- a/drape_frontend/backend_renderer.cpp
+++ b/drape_frontend/backend_renderer.cpp
@@ -76,6 +76,15 @@ void BackendRenderer::RecacheGui(gui::TWidgetsInitInfo const & initInfo, bool ne
m_commutator->PostMessage(ThreadsCommutator::RenderThread, move(outputMsg), MessagePriority::Normal);
}
+#ifdef RENRER_DEBUG_INFO_LABELS
+void BackendRenderer::RecacheDebugLabels()
+{
+ drape_ptr<gui::LayerRenderer> layerRenderer = m_guiCacher.RecacheDebugLabels(m_texMng);
+ drape_ptr<Message> outputMsg = make_unique_dp<GuiLayerRecachedMessage>(move(layerRenderer), false);
+ m_commutator->PostMessage(ThreadsCommutator::RenderThread, move(outputMsg), MessagePriority::Normal);
+}
+#endif
+
void BackendRenderer::RecacheChoosePositionMark()
{
drape_ptr<gui::LayerRenderer> layerRenderer = m_guiCacher.RecacheChoosePositionMark(m_texMng);
@@ -117,6 +126,10 @@ void BackendRenderer::AcceptMessage(ref_ptr<Message> message)
{
ref_ptr<GuiRecacheMessage> msg = message;
RecacheGui(msg->GetInitInfo(), msg->NeedResetOldGui());
+
+#ifdef RENRER_DEBUG_INFO_LABELS
+ RecacheDebugLabels();
+#endif
break;
}
case Message::GuiLayerLayout:
diff --git a/drape_frontend/backend_renderer.hpp b/drape_frontend/backend_renderer.hpp
index 3c92d9d5a5..8222f674a7 100644
--- a/drape_frontend/backend_renderer.hpp
+++ b/drape_frontend/backend_renderer.hpp
@@ -63,6 +63,10 @@ private:
void RecacheChoosePositionMark();
void RecacheMapShapes();
+#ifdef RENRER_DEBUG_INFO_LABELS
+ void RecacheDebugLabels();
+#endif
+
void AcceptMessage(ref_ptr<Message> message) override;
class Routine : public threads::IRoutine
diff --git a/drape_frontend/drape_frontend.pro b/drape_frontend/drape_frontend.pro
index 137ae99d4e..246a71d272 100755
--- a/drape_frontend/drape_frontend.pro
+++ b/drape_frontend/drape_frontend.pro
@@ -29,6 +29,7 @@ SOURCES += \
gui/choose_position_mark.cpp \
gui/compass.cpp \
gui/copyright_label.cpp \
+ gui/debug_label.cpp \
gui/drape_gui.cpp \
gui/gui_text.cpp \
gui/layer_render.cpp \
@@ -122,6 +123,7 @@ HEADERS += \
gui/choose_position_mark.hpp \
gui/compass.hpp \
gui/copyright_label.hpp \
+ gui/debug_label.hpp \
gui/drape_gui.hpp \
gui/gui_text.hpp \
gui/layer_render.hpp \
diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp
index 565b4d4505..a74d31f9c3 100755
--- a/drape_frontend/frontend_renderer.cpp
+++ b/drape_frontend/frontend_renderer.cpp
@@ -1074,18 +1074,7 @@ void FrontendRenderer::RenderScene(ScreenBase const & modelView)
modelView, make_ref(m_gpuProgramManager), m_generalUniforms);
if (m_guiRenderer != nullptr)
- {
- if (isPerspective)
- {
- ScreenBase modelView2d = modelView;
- modelView2d.ResetPerspective();
- m_guiRenderer->Render(make_ref(m_gpuProgramManager), modelView2d);
- }
- else
- {
- m_guiRenderer->Render(make_ref(m_gpuProgramManager), modelView);
- }
- }
+ m_guiRenderer->Render(make_ref(m_gpuProgramManager), modelView);
GLFunctions::glEnable(gl_const::GLDepthTest);
diff --git a/drape_frontend/gui/choose_position_mark.cpp b/drape_frontend/gui/choose_position_mark.cpp
index 5c7b87d20d..e08c350d28 100644
--- a/drape_frontend/gui/choose_position_mark.cpp
+++ b/drape_frontend/gui/choose_position_mark.cpp
@@ -37,7 +37,7 @@ public:
bool Update(ScreenBase const & screen) override
{
- SetPivot(glsl::ToVec2(m2::PointF(screen.PixelRect().Center())));
+ SetPivot(glsl::ToVec2(m2::PointF(screen.PixelRectIn3d().Center())));
return TBase::Update(screen);
}
};
diff --git a/drape_frontend/gui/debug_label.cpp b/drape_frontend/gui/debug_label.cpp
new file mode 100644
index 0000000000..7b8c5116ef
--- /dev/null
+++ b/drape_frontend/gui/debug_label.cpp
@@ -0,0 +1,94 @@
+#include "debug_label.hpp"
+
+#include "drape_gui.hpp"
+
+#include "std/bind.hpp"
+
+namespace gui
+{
+
+class DebugLabelHandle : public MutableLabelHandle
+{
+ using TBase = MutableLabelHandle;
+
+public:
+ DebugLabelHandle(uint32_t id, dp::Anchor anchor, m2::PointF const & pivot,
+ ref_ptr<dp::TextureManager> tex, TUpdateDebugLabelFn const & onUpdateFn)
+ : MutableLabelHandle(id, anchor, pivot)
+ , m_onUpdateFn(onUpdateFn)
+ {
+ SetTextureManager(tex);
+ }
+
+ bool Update(ScreenBase const & screen) override
+ {
+ string content;
+ bool const isVisible = m_onUpdateFn(screen, content);
+
+ SetIsVisible(isVisible);
+ SetContent(content);
+
+ return TBase::Update(screen);
+ }
+
+private:
+ TUpdateDebugLabelFn m_onUpdateFn;
+};
+
+void AddSymbols(string const & str, set<char> & symbols)
+{
+ for (size_t i = 0, sz = str.length(); i < sz; ++i)
+ symbols.insert(str[i]);
+}
+
+void DebugInfoLabels::AddLabel(ref_ptr<dp::TextureManager> tex, string const & caption, TUpdateDebugLabelFn const & onUpdateFn)
+{
+ string alphabet;
+ set<char> symbols;
+ AddSymbols(caption, symbols);
+ AddSymbols("0123456789.-e", symbols);
+
+ alphabet.reserve(symbols.size());
+ for (auto const & ch : symbols)
+ alphabet.push_back(ch);
+
+ MutableLabelDrawer::Params params;
+ params.m_anchor = dp::LeftTop;
+ params.m_alphabet = alphabet;
+ params.m_maxLength = 100;
+ params.m_font = DrapeGui::GetGuiTextFont();
+ params.m_font.m_color = dp::Color(0, 0, 255, 255);
+ params.m_font.m_size *= 1.2;
+ params.m_pivot = m_position.m_pixelPivot;
+
+#ifdef RENRER_DEBUG_INFO_LABELS
+ uint32_t const id = GuiHandleDebugLabel + m_labelsCount;
+
+ params.m_handleCreator = [id, onUpdateFn, tex](dp::Anchor anchor, m2::PointF const & pivot)
+ {
+ return make_unique_dp<DebugLabelHandle>(id, anchor, pivot, tex, onUpdateFn);
+ };
+#endif
+ m_labelsParams.push_back(params);
+ ++m_labelsCount;
+}
+
+drape_ptr<ShapeRenderer> DebugInfoLabels::Draw(ref_ptr<dp::TextureManager> tex)
+{
+ drape_ptr<ShapeRenderer> renderer = make_unique_dp<ShapeRenderer>();
+
+ m2::PointF pos = m_position.m_pixelPivot;
+
+ for (auto & params : m_labelsParams)
+ {
+ params.m_pivot.y = pos.y;
+ m2::PointF textSize = MutableLabelDrawer::Draw(params, tex, bind(&ShapeRenderer::AddShape, renderer.get(), _1, _2));
+ pos.y += 2 * textSize.y;
+ }
+
+ m_labelsParams.clear();
+
+ return renderer;
+}
+
+} // namespace gui
diff --git a/drape_frontend/gui/debug_label.hpp b/drape_frontend/gui/debug_label.hpp
new file mode 100644
index 0000000000..b4cf4917cb
--- /dev/null
+++ b/drape_frontend/gui/debug_label.hpp
@@ -0,0 +1,28 @@
+#pragma once
+
+#include "gui_text.hpp"
+#include "shape.hpp"
+
+#include "std/vector.hpp"
+
+namespace gui
+{
+
+using TUpdateDebugLabelFn = function<bool(ScreenBase const & screen, string & content)>;
+
+class DebugInfoLabels : public Shape
+{
+public:
+ DebugInfoLabels(gui::Position const & position)
+ : Shape(position)
+ {}
+
+ void AddLabel(ref_ptr<dp::TextureManager> tex, string const & caption, TUpdateDebugLabelFn const & onUpdateFn);
+ drape_ptr<ShapeRenderer> Draw(ref_ptr<dp::TextureManager> tex);
+
+private:
+ vector<MutableLabelDrawer::Params> m_labelsParams;
+ uint32_t m_labelsCount = 0;
+};
+
+} // namespace gui
diff --git a/drape_frontend/gui/layer_render.cpp b/drape_frontend/gui/layer_render.cpp
index c2521dd38b..4406c04b01 100644
--- a/drape_frontend/gui/layer_render.cpp
+++ b/drape_frontend/gui/layer_render.cpp
@@ -1,6 +1,7 @@
#include "choose_position_mark.hpp"
#include "compass.hpp"
#include "copyright_label.hpp"
+#include "debug_label.hpp"
#include "drape_gui.hpp"
#include "gui_text.hpp"
#include "layer_render.hpp"
@@ -12,6 +13,8 @@
#include "drape/batcher.hpp"
#include "drape/render_bucket.hpp"
+#include "geometry/mercator.hpp"
+
#include "base/stl_add.hpp"
#include "std/bind.hpp"
@@ -212,6 +215,100 @@ drape_ptr<LayerRenderer> LayerCacher::RecacheChoosePositionMark(ref_ptr<dp::Text
return renderer;
}
+#ifdef RENRER_DEBUG_INFO_LABELS
+drape_ptr<LayerRenderer> LayerCacher::RecacheDebugLabels(ref_ptr<dp::TextureManager> textures)
+{
+ drape_ptr<LayerRenderer> renderer = make_unique_dp<LayerRenderer>();
+
+ float const vs = df::VisualParams::Instance().GetVisualScale();
+ DebugInfoLabels debugLabels = DebugInfoLabels(Position(m2::PointF(10.0f * vs, 50.0f * vs), dp::Center));
+
+ debugLabels.AddLabel(textures, "visible: km2, readed: km2, ratio:",
+ [](ScreenBase const & screen, string & content) -> bool
+ {
+ double const sizeX = screen.PixelRectIn3d().SizeX();
+ double const sizeY = screen.PixelRectIn3d().SizeY();
+
+ m2::PointD const p0 = screen.PtoG(screen.P3dtoP(m2::PointD(0.0, 0.0)));
+ m2::PointD const p1 = screen.PtoG(screen.P3dtoP(m2::PointD(0.0, sizeY)));
+ m2::PointD const p2 = screen.PtoG(screen.P3dtoP(m2::PointD(sizeX, sizeY)));
+ m2::PointD const p3 = screen.PtoG(screen.P3dtoP(m2::PointD(sizeX, 0.0)));
+
+ double const areaG = MercatorBounds::AreaOnEarth(p0, p1, p2) +
+ MercatorBounds::AreaOnEarth(p2, p3, p0);
+
+ double const sizeX_2d = screen.PixelRect().SizeX();
+ double const sizeY_2d = screen.PixelRect().SizeY();
+
+ m2::PointD const p0_2d = screen.PtoG(m2::PointD(0.0, 0.0));
+ m2::PointD const p1_2d = screen.PtoG(m2::PointD(0.0, sizeY_2d));
+ m2::PointD const p2_2d = screen.PtoG(m2::PointD(sizeX_2d, sizeY_2d));
+ m2::PointD const p3_2d = screen.PtoG(m2::PointD(sizeX_2d, 0.0));
+
+ double const areaGTotal = MercatorBounds::AreaOnEarth(p0_2d, p1_2d, p2_2d) +
+ MercatorBounds::AreaOnEarth(p2_2d, p3_2d, p0_2d);
+
+ ostringstream out;
+ out << fixed << setprecision(2)
+ << "visible: " << areaG / 1000000.0 << " km2"
+ << ", readed: " << areaGTotal / 1000000.0 << " km2"
+ << ", ratio: " << areaGTotal / areaG;
+ content.assign(out.str());
+ return true;
+ });
+
+ debugLabels.AddLabel(textures, "scale2d: m/px, scale2d * vs: m/px",
+ [](ScreenBase const & screen, string & content) -> bool
+ {
+ double const distanceG = MercatorBounds::DistanceOnEarth(screen.PtoG(screen.PixelRect().LeftBottom()),
+ screen.PtoG(screen.PixelRect().RightBottom()));
+
+ double const vs = df::VisualParams::Instance().GetVisualScale();
+ double const scale = distanceG / screen.PixelRect().SizeX();
+
+ ostringstream out;
+ out << fixed << setprecision(2)
+ << "scale2d: " << scale << " m/px"
+ << ", scale2d * vs: " << scale * vs << " m/px";
+ content.assign(out.str());
+ return true;
+ });
+
+ debugLabels.AddLabel(textures, "distance: m",
+ [](ScreenBase const & screen, string & content) -> bool
+ {
+ double const sizeX = screen.PixelRectIn3d().SizeX();
+ double const sizeY = screen.PixelRectIn3d().SizeY();
+
+ double const distance = MercatorBounds::DistanceOnEarth(screen.PtoG(screen.P3dtoP(m2::PointD(sizeX / 2.0, 0.0))),
+ screen.PtoG(screen.P3dtoP(m2::PointD(sizeX / 2.0, sizeY))));
+
+ ostringstream out;
+ out << fixed << setprecision(2)
+ << "distance: " << distance << " m";
+ content.assign(out.str());
+ return true;
+ });
+
+ debugLabels.AddLabel(textures, "angle: ",
+ [](ScreenBase const & screen, string & content) -> bool
+ {
+ ostringstream out;
+ out << fixed << setprecision(2)
+ << "angle: " << screen.GetRotationAngle() * 180.0 / math::pi;
+ content.assign(out.str());
+ return true;
+ });
+
+ renderer->AddShapeRenderer(WIDGET_DEBUG_INFO, debugLabels.Draw(textures));
+
+ // Flush gui geometry.
+ GLFunctions::glFlush();
+
+ return renderer;
+}
+#endif
+
m2::PointF LayerCacher::CacheCompass(Position const & position, ref_ptr<LayerRenderer> renderer,
ref_ptr<dp::TextureManager> textures)
{
diff --git a/drape_frontend/gui/layer_render.hpp b/drape_frontend/gui/layer_render.hpp
index f48cf76c0c..fdd24e9575 100644
--- a/drape_frontend/gui/layer_render.hpp
+++ b/drape_frontend/gui/layer_render.hpp
@@ -58,6 +58,10 @@ public:
ref_ptr<dp::TextureManager> textures);
drape_ptr<LayerRenderer> RecacheChoosePositionMark(ref_ptr<dp::TextureManager> textures);
+#ifdef RENRER_DEBUG_INFO_LABELS
+ drape_ptr<LayerRenderer> RecacheDebugLabels(ref_ptr<dp::TextureManager> textures);
+#endif
+
private:
m2::PointF CacheCompass(Position const & position, ref_ptr<LayerRenderer> renderer, ref_ptr<dp::TextureManager> textures);
m2::PointF CacheRuler(Position const & position, ref_ptr<LayerRenderer> renderer, ref_ptr<dp::TextureManager> textures);
diff --git a/drape_frontend/gui/shape.cpp b/drape_frontend/gui/shape.cpp
index 794405dc26..3499b32b31 100644
--- a/drape_frontend/gui/shape.cpp
+++ b/drape_frontend/gui/shape.cpp
@@ -91,7 +91,7 @@ void ShapeRenderer::Build(ref_ptr<dp::GpuProgramManager> mng)
void ShapeRenderer::Render(ScreenBase const & screen, ref_ptr<dp::GpuProgramManager> mng)
{
array<float, 16> m;
- m2::RectD const & pxRect = screen.PixelRect();
+ m2::RectD const & pxRect = screen.PixelRectIn3d();
dp::MakeProjection(m, 0.0f, pxRect.SizeX(), pxRect.SizeY(), 0.0f);
dp::UniformValuesStorage uniformStorage;
diff --git a/drape_frontend/gui/skin.hpp b/drape_frontend/gui/skin.hpp
index c34965a026..d326a8e1d0 100644
--- a/drape_frontend/gui/skin.hpp
+++ b/drape_frontend/gui/skin.hpp
@@ -6,6 +6,8 @@
#include "std/map.hpp"
+//#define RENRER_DEBUG_INFO_LABELS
+
namespace gui
{
@@ -16,7 +18,10 @@ enum EWidget
WIDGET_COPYRIGHT = 0x4,
WIDGET_SCALE_LABEL = 0x8,
/// Following widgets controlled by rendering kernel. Don't use them in platform code
- WIDGET_CHOOSE_POSITION_MARK = 0x8000
+ WIDGET_CHOOSE_POSITION_MARK = 0x8000,
+#ifdef RENRER_DEBUG_INFO_LABELS
+ WIDGET_DEBUG_INFO
+#endif
};
enum EGuiHandle
@@ -34,7 +39,10 @@ enum EGuiHandle
GuiHandleRetryButtonLabel,
GuiHandleCancelButton,
GuiHandleCancelButtonLabel,
- GuiHandleChoosePositionMark
+ GuiHandleChoosePositionMark,
+#ifdef RENRER_DEBUG_INFO_LABELS
+ GuiHandleDebugLabel = 100
+#endif
};
struct Position