diff --git a/android/jni/framework.cpp b/android/jni/framework.cpp index 6dc3c6bd2c..3d294a420d 100644 --- a/android/jni/framework.cpp +++ b/android/jni/framework.cpp @@ -4,7 +4,10 @@ #include "../../std/shared_ptr.hpp" #include "../../base/logging.hpp" - +#include "../../map/render_policy_st.hpp" +#include "../../std/shared_ptr.hpp" +#include "../../std/bind.hpp" +#include "../../map/framework.hpp" void AndroidFramework::ViewHandle::invalidateImpl() { @@ -21,6 +24,8 @@ AndroidFramework::AndroidFramework() : m_view(new ViewHandle(this)), m_work(m_view, 0) { m_work.InitStorage(m_storage); + shared_ptr renderPolicy(new RenderPolicyST(m_view, bind(&Framework::DrawModel, &m_work, _1, _2, _3, _4))); + m_work.SetRenderPolicy(renderPolicy); } void AndroidFramework::SetParentView(JNIEnv * env, jobject view) @@ -44,25 +49,22 @@ void AndroidFramework::InitRenderer() LOG(LDEBUG, ("AF::InitRenderer 4")); m_work.initializeGL(pRC, pRM); - //m_work.ShowAll(); + m_work.ShowAll(); LOG(LDEBUG, ("AF::InitRenderer 5")); } void AndroidFramework::Resize(int w, int h) { - LOG(LDEBUG, ("AF::Resize 1")); m_view->drawer()->onSize(w, h); - LOG(LDEBUG, ("AF::Resize 2")); + m_work.OnSize(w, h); } void AndroidFramework::DrawFrame() { -// m_work.Paint(make_shared_ptr(new PaintEvent(m_view->drawer()))); - yg::gl::Screen * screen = m_view->drawer()->screen().get(); +/* yg::gl::Screen * screen = m_view->drawer()->screen().get(); screen->beginFrame(); screen->clear(); - yg::Color c(255, 0, 0, 255); m2::PointD centerPt(screen->width() / 2, screen->height() / 2); @@ -72,7 +74,10 @@ void AndroidFramework::DrawFrame() centerPt.x + 100, centerPt.y + 50); - screen->drawRectangle(r, c, yg::maxDepth); - //screen->drawText(yg::FontDesc::defaultFont, centerPt, yg::EPosCenter, "Simplicity is the ultimate sophistication", yg::maxDepth, false); + screen->drawText(yg::FontDesc::defaultFont, centerPt, yg::EPosCenter, "Simplicity is the ultimate sophistication", yg::maxDepth, false); + screen->drawRectangle(r, yg::Color(255, 0, 0, 255), yg::maxDepth); + screen->drawRectangle(m2::Offset(r, m2::PointD(50, 50)), yg::Color(0, 255, 0, 255), yg::maxDepth); screen->endFrame(); +*/ + m_work.Paint(make_shared_ptr(new PaintEvent(m_view->drawer()))); } diff --git a/android/jni/framework.h b/android/jni/framework.h index 4918393da9..583f924d84 100644 --- a/android/jni/framework.h +++ b/android/jni/framework.h @@ -22,7 +22,7 @@ public: private: shared_ptr m_view; - FrameWork m_work; + Framework m_work; storage::Storage m_storage; JNIEnv * m_env; diff --git a/android/jni/platform.cpp b/android/jni/platform.cpp index c6c5aee1f9..16ecfe15c4 100644 --- a/android/jni/platform.cpp +++ b/android/jni/platform.cpp @@ -29,6 +29,7 @@ bool AndroidPlatform::IsMultiSampled() const void AndroidPlatform::GetFontNames(FilesList & res) const { + res.push_back("01_dejavusans.ttf"); /// @todo Need to make refactoring of yg fonts } diff --git a/map/framework.cpp b/map/framework.cpp index b343ec7af2..f42cbd4cb3 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -24,6 +24,8 @@ #include "../std/algorithm.hpp" #include "../std/fstream.hpp" +#include "render_policy_st.hpp" + #include "tiling_render_policy_st.hpp" #include "tiling_render_policy_mt.hpp" @@ -86,6 +88,7 @@ Framework::Framework(shared_ptr windowHandle, m_centeringMode(EDoNothing), m_tileSize(GetPlatform().TileSize()) { +// SetRenderPolicy(make_shared_ptr(new RenderPolicyST(windowHandle, bind(&this_type::DrawModel, this, _1, _2, _3, _4)))); SetRenderPolicy(make_shared_ptr(new TilingRenderPolicyMT(windowHandle, bind(&this_type::DrawModel, this, _1, _2, _3, _4)))); m_informationDisplay.setBottomShift(bottomShift); #ifdef DRAW_TOUCH_POINTS @@ -165,7 +168,7 @@ void Framework::initializeGL( shared_ptr const & primaryContext, shared_ptr const & resourceManager) { - m_renderPolicy->initialize(primaryContext, resourceManager); + m_renderPolicy->Initialize(primaryContext, resourceManager); } template @@ -253,7 +256,7 @@ void Framework::OnSize(int w, int h) m_navigator.OnSize(0, 0, w, h); - m_renderPolicy->onSize(w, h); + m_renderPolicy->OnSize(w, h); } template @@ -313,6 +316,7 @@ template void Framework::Paint(shared_ptr e) { DrawerYG * pDrawer = e->drawer().get(); + pDrawer->SetVisualScale(GetPlatform().VisualScale()); m_informationDisplay.setScreen(m_navigator.Screen()); @@ -327,7 +331,7 @@ void Framework::Paint(shared_ptr e) e->drawer()->screen()->beginFrame(); - m_renderPolicy->drawFrame(e, m_navigator.Screen()); + m_renderPolicy->DrawFrame(e, m_navigator.Screen()); m_informationDisplay.doDraw(pDrawer); diff --git a/map/framework.hpp b/map/framework.hpp index ed070da5f7..c8f08a7f99 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -137,12 +137,13 @@ protected: void OnCompassUpdate(location::CompassInfo const & info); - void SetRenderPolicy(shared_ptr const & rp); - public: + Framework(shared_ptr windowHandle, size_t bottomShift); + void SetRenderPolicy(shared_ptr const & rp); + void initializeGL(shared_ptr const & primaryContext, shared_ptr const & resourceManager); diff --git a/map/map.pro b/map/map.pro index 7e519005e5..e1c7482926 100644 --- a/map/map.pro +++ b/map/map.pro @@ -29,7 +29,8 @@ HEADERS += \ tiling_render_policy_st.hpp \ tiling_render_policy.hpp \ benchmark_framework.hpp \ - framework_factory.hpp + framework_factory.hpp \ + render_policy_st.hpp SOURCES += \ feature_vec_model.cpp \ @@ -48,7 +49,8 @@ SOURCES += \ tiling_render_policy_st.cpp \ tiling_render_policy.cpp \ benchmark_framework.cpp \ - framework_factory.cpp + framework_factory.cpp \ + render_policy_st.cpp !iphone*:!bada*:!android* { HEADERS += qgl_render_context.hpp diff --git a/map/render_policy.cpp b/map/render_policy.cpp index 036e3bf729..c6f51196b9 100644 --- a/map/render_policy.cpp +++ b/map/render_policy.cpp @@ -28,7 +28,7 @@ RenderPolicy::render_fn_t RenderPolicy::renderFn() const return m_renderFn; } -void RenderPolicy::initialize(shared_ptr const &, +void RenderPolicy::Initialize(shared_ptr const &, shared_ptr const & resourceManager) { m_resourceManager = resourceManager; diff --git a/map/render_policy.hpp b/map/render_policy.hpp index 70708b22e2..1bef66e7fe 100644 --- a/map/render_policy.hpp +++ b/map/render_policy.hpp @@ -47,10 +47,10 @@ public: /// constructor RenderPolicy(shared_ptr const & windowHandle, render_fn_t const & renderFn); /// drawing single frame - virtual void drawFrame(shared_ptr const & paintEvent, ScreenBase const & currentScreen) = 0; + virtual void DrawFrame(shared_ptr const & paintEvent, ScreenBase const & currentScreen) = 0; /// processing resize request - virtual void onSize(int w, int h) = 0; + virtual void OnSize(int w, int h) = 0; /// initialize render policy - virtual void initialize(shared_ptr const & primaryContext, + virtual void Initialize(shared_ptr const & primaryContext, shared_ptr const & resourceManager) = 0; }; diff --git a/map/render_policy_st.cpp b/map/render_policy_st.cpp new file mode 100644 index 0000000000..2c59d4608c --- /dev/null +++ b/map/render_policy_st.cpp @@ -0,0 +1,42 @@ +#include "../base/SRC_FIRST.hpp" + +#include "render_policy_st.hpp" +#include "events.hpp" +#include "drawer_yg.hpp" + +#include "../indexer/scales.hpp" +#include "../geometry/screenbase.hpp" + +#include "../platform/platform.hpp" + +RenderPolicyST::RenderPolicyST(shared_ptr const & wh, + RenderPolicy::render_fn_t const & renderFn) + : RenderPolicy(wh, renderFn) +{} + +void RenderPolicyST::Initialize(shared_ptr const & rc, + shared_ptr const & rm) +{ + RenderPolicy::Initialize(rc, rm); +} + +void RenderPolicyST::DrawFrame(shared_ptr const & e, + ScreenBase const & s) +{ + int scaleEtalonSize = GetPlatform().ScaleEtalonSize(); + + m2::RectD glbRect; + m2::PointD pxCenter = s.PixelRect().Center(); + s.PtoG(m2::RectD(pxCenter - m2::PointD(scaleEtalonSize / 2, scaleEtalonSize / 2), + pxCenter + m2::PointD(scaleEtalonSize / 2, scaleEtalonSize / 2)), + glbRect); + + e->drawer()->SetVisualScale(GetPlatform().VisualScale()); + + e->drawer()->screen()->clear(bgColor()); + renderFn()(e, s, s.GlobalRect(), scales::GetScaleLevel(glbRect)); +} + +void RenderPolicyST::OnSize(int w, int h) +{ +} diff --git a/map/render_policy_st.hpp b/map/render_policy_st.hpp new file mode 100644 index 0000000000..e8d5a9ebab --- /dev/null +++ b/map/render_policy_st.hpp @@ -0,0 +1,21 @@ +#pragma once + +#include "render_policy.hpp" + +class WindowHandle; + +class RenderPolicyST : public RenderPolicy +{ +private: +public: + RenderPolicyST(shared_ptr const & wh, + RenderPolicy::render_fn_t const & renderFn); + + void Initialize(shared_ptr const & rc, + shared_ptr const & rm); + + void DrawFrame(shared_ptr const & paintEvent, + ScreenBase const & screenBase); + + void OnSize(int w, int h); +}; diff --git a/map/tiling_render_policy.hpp b/map/tiling_render_policy.hpp index a7a3bcb927..a6e94b0e00 100644 --- a/map/tiling_render_policy.hpp +++ b/map/tiling_render_policy.hpp @@ -8,5 +8,5 @@ public: virtual void renderTile() = 0; - void drawFrame(shared_ptr const & e, ScreenBase const & s); + void DrawFrame(shared_ptr const & e, ScreenBase const & s); }; diff --git a/map/tiling_render_policy_mt.cpp b/map/tiling_render_policy_mt.cpp index 606b452a6b..7cbf63a9d4 100644 --- a/map/tiling_render_policy_mt.cpp +++ b/map/tiling_render_policy_mt.cpp @@ -22,18 +22,18 @@ TilingRenderPolicyMT::TilingRenderPolicyMT(shared_ptr const & wind m_renderQueue.AddWindowHandle(windowHandle); } -void TilingRenderPolicyMT::initialize(shared_ptr const & primaryContext, +void TilingRenderPolicyMT::Initialize(shared_ptr const & primaryContext, shared_ptr const & resourceManager) { - RenderPolicy::initialize(primaryContext, resourceManager); + RenderPolicy::Initialize(primaryContext, resourceManager); m_renderQueue.InitializeGL(primaryContext, resourceManager, GetPlatform().VisualScale()); } -void TilingRenderPolicyMT::onSize(int w, int h) +void TilingRenderPolicyMT::OnSize(int w, int h) { } -void TilingRenderPolicyMT::drawFrame(shared_ptr const & e, ScreenBase const & currentScreen) +void TilingRenderPolicyMT::DrawFrame(shared_ptr const & e, ScreenBase const & currentScreen) { DrawerYG * pDrawer = e->drawer().get(); pDrawer->screen()->clear(bgColor()); diff --git a/map/tiling_render_policy_mt.hpp b/map/tiling_render_policy_mt.hpp index d5dcf1d8b3..f801e6069a 100644 --- a/map/tiling_render_policy_mt.hpp +++ b/map/tiling_render_policy_mt.hpp @@ -32,10 +32,10 @@ public: TilingRenderPolicyMT(shared_ptr const & windowHandle, RenderPolicy::render_fn_t const & renderFn); - void initialize(shared_ptr const & renderContext, + void Initialize(shared_ptr const & renderContext, shared_ptr const & resourceManager); - void onSize(int w, int h); + void OnSize(int w, int h); - void drawFrame(shared_ptr const & ev, ScreenBase const & currentScreen); + void DrawFrame(shared_ptr const & ev, ScreenBase const & currentScreen); }; diff --git a/map/tiling_render_policy_st.cpp b/map/tiling_render_policy_st.cpp index fe09084ae9..031bf9a691 100644 --- a/map/tiling_render_policy_st.cpp +++ b/map/tiling_render_policy_st.cpp @@ -19,10 +19,10 @@ TilingRenderPolicyST::TilingRenderPolicyST(shared_ptr const & wind m_tileCache(GetPlatform().MaxTilesCount() - 1) {} -void TilingRenderPolicyST::initialize(shared_ptr const & primaryContext, +void TilingRenderPolicyST::Initialize(shared_ptr const & primaryContext, shared_ptr const & rm) { - RenderPolicy::initialize(primaryContext, rm); + RenderPolicy::Initialize(primaryContext, rm); /// render single tile on the same thread shared_ptr frameBuffer(new yg::gl::FrameBuffer()); @@ -50,10 +50,10 @@ void TilingRenderPolicyST::initialize(shared_ptr const & m_tileScreen.OnSize(renderRect); } -void TilingRenderPolicyST::onSize(int w, int h) +void TilingRenderPolicyST::OnSize(int w, int h) {} -void TilingRenderPolicyST::drawFrame(shared_ptr const & e, ScreenBase const & currentScreen) +void TilingRenderPolicyST::DrawFrame(shared_ptr const & e, ScreenBase const & currentScreen) { DrawerYG * pDrawer = e->drawer().get(); diff --git a/map/tiling_render_policy_st.hpp b/map/tiling_render_policy_st.hpp index 29716982f1..825e7104e9 100644 --- a/map/tiling_render_policy_st.hpp +++ b/map/tiling_render_policy_st.hpp @@ -30,10 +30,10 @@ public: TilingRenderPolicyST(shared_ptr const & windowHandle, RenderPolicy::render_fn_t const & renderFn); - void initialize(shared_ptr const & renderContext, + void Initialize(shared_ptr const & renderContext, shared_ptr const & resourceManager); - void drawFrame(shared_ptr const & paintEvent, ScreenBase const & screenBase); + void DrawFrame(shared_ptr const & paintEvent, ScreenBase const & screenBase); - void onSize(int w, int h); + void OnSize(int w, int h); };