diff options
author | Daria Volvenkova <d.volvenkova@corp.mail.ru> | 2018-07-30 21:10:25 +0300 |
---|---|---|
committer | Roman Kuznetsov <r.kuznetsow@gmail.com> | 2018-08-01 16:21:56 +0300 |
commit | bc461840fe7462cb6d55cd3f577824de07583e0c (patch) | |
tree | 660b121ddc9dcecc4405151117b355687a77773e /drape_frontend | |
parent | bf38632215f55ed8fe284d2e53013bf2fd216aff (diff) |
Graphic context added.
Diffstat (limited to 'drape_frontend')
-rw-r--r-- | drape_frontend/backend_renderer.cpp | 14 | ||||
-rw-r--r-- | drape_frontend/backend_renderer.hpp | 4 | ||||
-rw-r--r-- | drape_frontend/base_renderer.cpp | 12 | ||||
-rw-r--r-- | drape_frontend/base_renderer.hpp | 10 | ||||
-rw-r--r-- | drape_frontend/drape_engine.cpp | 2 | ||||
-rw-r--r-- | drape_frontend/drape_engine.hpp | 8 | ||||
-rwxr-xr-x | drape_frontend/frontend_renderer.cpp | 74 | ||||
-rwxr-xr-x | drape_frontend/frontend_renderer.hpp | 4 |
8 files changed, 62 insertions, 66 deletions
diff --git a/drape_frontend/backend_renderer.cpp b/drape_frontend/backend_renderer.cpp index ac4e252e03..35a480e526 100644 --- a/drape_frontend/backend_renderer.cpp +++ b/drape_frontend/backend_renderer.cpp @@ -577,15 +577,15 @@ void BackendRenderer::ReleaseResources() m_trafficGenerator.reset(); m_texMng->Release(); - m_contextFactory->getResourcesUploadContext()->doneCurrent(); + m_contextFactory->GetResourcesUploadContext()->DoneCurrent(); } void BackendRenderer::OnContextCreate() { LOG(LINFO, ("On context create.")); - dp::OGLContext * context = m_contextFactory->getResourcesUploadContext(); - m_contextFactory->waitForInitialization(context); - context->makeCurrent(); + auto context = m_contextFactory->GetResourcesUploadContext(); + m_contextFactory->WaitForInitialization(context); + context->MakeCurrent(); GLFunctions::Init(m_apiVersion); @@ -603,7 +603,7 @@ void BackendRenderer::OnContextDestroy() m_overlays.clear(); m_trafficGenerator->ClearGLDependentResources(); - m_contextFactory->getResourcesUploadContext()->doneCurrent(); + m_contextFactory->GetResourcesUploadContext()->DoneCurrent(); } BackendRenderer::Routine::Routine(BackendRenderer & renderer) : m_renderer(renderer) {} @@ -612,10 +612,10 @@ void BackendRenderer::Routine::Do() { LOG(LINFO, ("Start routine.")); m_renderer.OnContextCreate(); - dp::OGLContext * context = m_renderer.m_contextFactory->getResourcesUploadContext(); + dp::GraphicContext * context = m_renderer.m_contextFactory->GetResourcesUploadContext(); while (!IsCancelled()) { - if (context->validate()) + if (context->Validate()) m_renderer.ProcessSingleMessage(); m_renderer.CheckRenderingEnabled(); } diff --git a/drape_frontend/backend_renderer.hpp b/drape_frontend/backend_renderer.hpp index 83fd6ce54d..a1cec276e6 100644 --- a/drape_frontend/backend_renderer.hpp +++ b/drape_frontend/backend_renderer.hpp @@ -17,7 +17,7 @@ namespace dp { -class OGLContextFactory; +class GraphicContextFactory; class TextureManager; } // namespace dp @@ -38,7 +38,7 @@ public: struct Params : BaseRenderer::Params { Params(dp::ApiVersion apiVersion, ref_ptr<ThreadsCommutator> commutator, - ref_ptr<dp::OGLContextFactory> factory, ref_ptr<dp::TextureManager> texMng, + ref_ptr<dp::GraphicContextFactory> factory, ref_ptr<dp::TextureManager> texMng, MapDataProvider const & model, TUpdateCurrentCountryFn const & updateCurrentCountryFn, ref_ptr<RequestedTiles> requestedTiles, bool allow3dBuildings, bool trafficEnabled, bool simplifiedTrafficColors, TIsUGCFn && isUGCFn) diff --git a/drape_frontend/base_renderer.cpp b/drape_frontend/base_renderer.cpp index b46e1836ea..7a49101c75 100644 --- a/drape_frontend/base_renderer.cpp +++ b/drape_frontend/base_renderer.cpp @@ -40,7 +40,7 @@ void BaseRenderer::StopThread() m_selfThread.Join(); } -void BaseRenderer::SetRenderingEnabled(ref_ptr<dp::OGLContextFactory> contextFactory) +void BaseRenderer::SetRenderingEnabled(ref_ptr<dp::GraphicContextFactory> contextFactory) { if (m_wasContextReset && contextFactory != nullptr) m_contextFactory = contextFactory; @@ -107,7 +107,7 @@ void BaseRenderer::CheckRenderingEnabled() { if (!m_isEnabled) { - dp::OGLContext * context = nullptr; + dp::GraphicContext * context = nullptr; if (m_wasContextReset) { @@ -118,9 +118,9 @@ void BaseRenderer::CheckRenderingEnabled() else { bool const isDrawContext = m_threadName == ThreadsCommutator::RenderThread; - context = isDrawContext ? m_contextFactory->getDrawContext() : - m_contextFactory->getResourcesUploadContext(); - context->setRenderingEnabled(false); + context = isDrawContext ? m_contextFactory->GetDrawContext() : + m_contextFactory->GetResourcesUploadContext(); + context->SetRenderingEnabled(false); } // notify initiator-thread about rendering disabling @@ -145,7 +145,7 @@ void BaseRenderer::CheckRenderingEnabled() } else { - context->setRenderingEnabled(true); + context->SetRenderingEnabled(true); } } // notify initiator-thread about rendering enabling diff --git a/drape_frontend/base_renderer.hpp b/drape_frontend/base_renderer.hpp index b44f8fc277..afcb4ff00b 100644 --- a/drape_frontend/base_renderer.hpp +++ b/drape_frontend/base_renderer.hpp @@ -4,7 +4,7 @@ #include "drape_frontend/threads_commutator.hpp" #include "drape_frontend/tile_utils.hpp" -#include "drape/oglcontextfactory.hpp" +#include "drape/graphic_context_factory.hpp" #include "drape/texture_manager.hpp" #include "base/thread.hpp" @@ -25,7 +25,7 @@ public: { Params(dp::ApiVersion apiVersion, ref_ptr<ThreadsCommutator> commutator, - ref_ptr<dp::OGLContextFactory> factory, + ref_ptr<dp::GraphicContextFactory> factory, ref_ptr<dp::TextureManager> texMng) : m_apiVersion(apiVersion) , m_commutator(commutator) @@ -36,7 +36,7 @@ public: dp::ApiVersion m_apiVersion; ref_ptr<ThreadsCommutator> m_commutator; - ref_ptr<dp::OGLContextFactory> m_oglContextFactory; + ref_ptr<dp::GraphicContextFactory> m_oglContextFactory; ref_ptr<dp::TextureManager> m_texMng; }; @@ -44,7 +44,7 @@ public: bool CanReceiveMessages(); - void SetRenderingEnabled(ref_ptr<dp::OGLContextFactory> contextFactory); + void SetRenderingEnabled(ref_ptr<dp::GraphicContextFactory> contextFactory); void SetRenderingDisabled(bool const destroyContext); bool IsRenderingEnabled() const; @@ -52,7 +52,7 @@ public: protected: dp::ApiVersion m_apiVersion; ref_ptr<ThreadsCommutator> m_commutator; - ref_ptr<dp::OGLContextFactory> m_contextFactory; + ref_ptr<dp::GraphicContextFactory> m_contextFactory; ref_ptr<dp::TextureManager> m_texMng; void StartThread(); diff --git a/drape_frontend/drape_engine.cpp b/drape_frontend/drape_engine.cpp index a271d88e04..83fa37ee39 100644 --- a/drape_frontend/drape_engine.cpp +++ b/drape_frontend/drape_engine.cpp @@ -344,7 +344,7 @@ void DrapeEngine::UpdateUserMarks(UserMarksProvider * provider, bool firstTime) } } -void DrapeEngine::SetRenderingEnabled(ref_ptr<dp::OGLContextFactory> contextFactory) +void DrapeEngine::SetRenderingEnabled(ref_ptr<dp::GraphicContextFactory> contextFactory) { m_backend->SetRenderingEnabled(contextFactory); m_frontend->SetRenderingEnabled(contextFactory); diff --git a/drape_frontend/drape_engine.hpp b/drape_frontend/drape_engine.hpp index 0397b6fd25..a1d1bf7136 100644 --- a/drape_frontend/drape_engine.hpp +++ b/drape_frontend/drape_engine.hpp @@ -37,7 +37,7 @@ namespace dp { class GlyphGenerator; -class OGLContextFactory; +class GraphicContextFactory; } // namespace dp namespace df @@ -51,7 +51,7 @@ public: struct Params { Params(dp::ApiVersion apiVersion, - ref_ptr<dp::OGLContextFactory> factory, + ref_ptr<dp::GraphicContextFactory> factory, dp::Viewport const & viewport, MapDataProvider const & model, Hints const & hints, @@ -93,7 +93,7 @@ public: {} dp::ApiVersion m_apiVersion; - ref_ptr<dp::OGLContextFactory> m_factory; + ref_ptr<dp::GraphicContextFactory> m_factory; dp::Viewport m_viewport; MapDataProvider m_model; Hints m_hints; @@ -141,7 +141,7 @@ public: void UpdateUserMarks(UserMarksProvider * provider, bool firstTime); void InvalidateUserMarks(); - void SetRenderingEnabled(ref_ptr<dp::OGLContextFactory> contextFactory = nullptr); + void SetRenderingEnabled(ref_ptr<dp::GraphicContextFactory> contextFactory = nullptr); void SetRenderingDisabled(bool const destroyContext); void InvalidateRect(m2::RectD const & rect); void UpdateMapStyle(); diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp index 9941bdff48..88ac585c75 100755 --- a/drape_frontend/frontend_renderer.cpp +++ b/drape_frontend/frontend_renderer.cpp @@ -1038,7 +1038,7 @@ void FrontendRenderer::OnResize(ScreenBase const & screen) if (viewportChanged || m_needRestoreSize) { - m_contextFactory->getDrawContext()->resize(sx, sy); + m_contextFactory->GetDrawContext()->Resize(sx, sy); m_buildingsFramebuffer->SetSize(sx, sy); m_postprocessRenderer->Resize(sx, sy); m_needRestoreSize = false; @@ -1223,11 +1223,13 @@ void FrontendRenderer::RenderScene(ScreenBase const & modelView, bool activeFram DrapeMeasurer::Instance().BeforeRenderFrame(); #endif + auto context = m_contextFactory->GetDrawContext(); + if (m_postprocessRenderer->BeginFrame(activeFrame)) { m_viewport.Apply(); RefreshBgColor(); - GLFunctions::glClear(gl_const::GLColorBit | gl_const::GLDepthBit | gl_const::GLStencilBit); + context->Clear(dp::ClearBits::ColorBit | dp::ClearBits::DepthBit | dp::ClearBits::StencilBit); Render2dLayer(modelView); RenderUserMarksLayer(modelView, RenderState::UserLineLayer); @@ -1247,7 +1249,7 @@ void FrontendRenderer::RenderScene(ScreenBase const & modelView, bool activeFram RenderRouteLayer(modelView); } - GLFunctions::glClear(gl_const::GLDepthBit); + context->Clear(dp::ClearBits::DepthBit); if (m_selectionShape != nullptr) { @@ -1336,17 +1338,18 @@ void FrontendRenderer::Render3dLayer(ScreenBase const & modelView, bool useFrame if (layer.m_renderGroups.empty()) return; + auto context = m_contextFactory->GetDrawContext(); float const kOpacity = 0.7f; if (useFramebuffer) { ASSERT(m_buildingsFramebuffer->IsSupported(), ()); m_buildingsFramebuffer->Enable(); - GLFunctions::glClearColor(0.0f, 0.0f, 0.0f, 0.0f); - GLFunctions::glClear(gl_const::GLColorBit | gl_const::GLDepthBit); + context->SetClearColor(0.0f, 0.0f, 0.0f, 0.0f); + context->Clear(dp::ClearBits::ColorBit | dp::ClearBits::DepthBit); } else { - GLFunctions::glClear(gl_const::GLDepthBit); + context->Clear(dp::ClearBits::DepthBit); } layer.Sort(make_ref(m_overlayTree)); @@ -1395,7 +1398,7 @@ bool FrontendRenderer::HasRouteData() const void FrontendRenderer::RenderTransitSchemeLayer(ScreenBase const & modelView) { - GLFunctions::glClear(gl_const::GLDepthBit); + m_contextFactory->GetDrawContext()->Clear(dp::ClearBits::DepthBit); if (m_transitSchemeEnabled && m_transitSchemeRenderer->IsSchemeVisible(m_currentZoomLevel)) { RenderTransitBackground(); @@ -1406,7 +1409,7 @@ void FrontendRenderer::RenderTransitSchemeLayer(ScreenBase const & modelView) void FrontendRenderer::RenderTrafficLayer(ScreenBase const & modelView) { - GLFunctions::glClear(gl_const::GLDepthBit); + m_contextFactory->GetDrawContext()->Clear(dp::ClearBits::DepthBit); if (m_trafficRenderer->HasRenderData()) { m_trafficRenderer->RenderTraffic(modelView, m_currentZoomLevel, 1.0f /* opacity */, @@ -1438,7 +1441,7 @@ void FrontendRenderer::RenderRouteLayer(ScreenBase const & modelView) if (HasTransitRouteData()) RenderTransitBackground(); - GLFunctions::glClear(gl_const::GLDepthBit); + m_contextFactory->GetDrawContext()->Clear(dp::ClearBits::DepthBit); m_routeRenderer->RenderRoute(modelView, m_trafficRenderer->HasRenderData(), make_ref(m_gpuProgramManager), m_frameValues); } @@ -1449,7 +1452,7 @@ void FrontendRenderer::RenderUserMarksLayer(ScreenBase const & modelView, Render if (renderGroups.empty()) return; - GLFunctions::glClear(gl_const::GLDepthBit); + m_contextFactory->GetDrawContext()->Clear(dp::ClearBits::DepthBit); for (drape_ptr<RenderGroup> & group : renderGroups) RenderSingleGroup(modelView, make_ref(group)); @@ -1467,19 +1470,20 @@ void FrontendRenderer::RenderSearchMarksLayer(ScreenBase const & modelView) RenderUserMarksLayer(modelView, RenderState::SearchMarkLayer); } -void FrontendRenderer::RenderEmptyFrame(dp::OGLContext * context) +void FrontendRenderer::RenderEmptyFrame() { - if (!context->validate()) + auto context = m_contextFactory->GetDrawContext(); + if (!context->Validate()) return; - context->setDefaultFramebuffer(); + context->SetDefaultFramebuffer(); auto const c = dp::Extract(drule::rules().GetBgColor(1 /* scale */), 0); - GLFunctions::glClearColor(c.GetRedF(), c.GetGreenF(), c.GetBlueF(), 1.0f); + context->SetClearColor(c.GetRedF(), c.GetGreenF(), c.GetBlueF(), 1.0f); m_viewport.Apply(); - GLFunctions::glClear(gl_const::GLColorBit); + context->Clear(dp::ClearBits::ColorBit); - context->present(); + context->Present(); } void FrontendRenderer::BuildOverlayTree(ScreenBase const & modelView) @@ -1617,7 +1621,7 @@ void FrontendRenderer::RefreshBgColor() scales::GetUpperStyleScale()); auto const color = drule::rules().GetBgColor(scale); auto const c = dp::Extract(color, 0 /*255 - (color >> 24)*/); - GLFunctions::glClearColor(c.GetRedF(), c.GetGreenF(), c.GetBlueF(), 1.0f); + m_contextFactory->GetDrawContext()->SetClearColor(c.GetRedF(), c.GetGreenF(), c.GetBlueF(), 1.0f); } void FrontendRenderer::DisablePerspective() @@ -1929,7 +1933,8 @@ void FrontendRenderer::OnContextDestroy() dp::DebugRectRenderer::Instance().Destroy(); m_gpuProgramManager.reset(); - m_contextFactory->getDrawContext()->doneCurrent(); + + m_contextFactory->GetDrawContext()->DoneCurrent(); m_needRestoreSize = true; m_firstTilesReady = false; @@ -1942,26 +1947,17 @@ void FrontendRenderer::OnContextCreate() { LOG(LINFO, ("On context create.")); - dp::OGLContext * context = m_contextFactory->getDrawContext(); - m_contextFactory->waitForInitialization(context); + auto context = m_contextFactory->GetDrawContext(); + m_contextFactory->WaitForInitialization(context); - context->makeCurrent(); + context->MakeCurrent(); - GLFunctions::Init(m_apiVersion); + context->SetApiVersion(m_apiVersion); // Render empty frame here to avoid black initialization screen. - RenderEmptyFrame(context); - - GLFunctions::glPixelStore(gl_const::GLUnpackAlignment, 1); - - GLFunctions::glClearDepthValue(1.0); - GLFunctions::glDepthFunc(gl_const::GLLessOrEqual); - GLFunctions::glDepthMask(true); + RenderEmptyFrame(); - GLFunctions::glFrontFace(gl_const::GLClockwise); - GLFunctions::glCullFace(gl_const::GLBack); - GLFunctions::glEnable(gl_const::GLCullFace); - GLFunctions::glEnable(gl_const::GLScissorTest); + context->Init(); dp::SupportManager::Instance().Init(); @@ -1989,9 +1985,9 @@ void FrontendRenderer::OnContextCreate() m_postprocessRenderer->Init(m_apiVersion, [context]() { - if (!context->validate()) + if (!context->Validate()) return false; - context->setDefaultFramebuffer(); + context->SetDefaultFramebuffer(); return true; }); #ifndef OMIM_OS_IPHONE_SIMULATOR @@ -2030,7 +2026,7 @@ void FrontendRenderer::Routine::Do() bool forceFullRedrawNextFrame = false; uint32_t constexpr kMaxInactiveFrames = 2; - dp::OGLContext * context = m_renderer.m_contextFactory->getDrawContext(); + auto context = m_renderer.m_contextFactory->GetDrawContext(); auto & scaleFpsHelper = gui::DrapeGui::Instance().GetScaleFpsHelper(); #ifdef DEBUG @@ -2052,7 +2048,7 @@ void FrontendRenderer::Routine::Do() while (!IsCancelled()) { - if (context->validate()) + if (context->Validate()) { timer.Reset(); @@ -2133,7 +2129,7 @@ void FrontendRenderer::Routine::Do() while (availableTime > 0.0); } - context->present(); + context->Present(); // Limit fps in following mode. double constexpr kFrameTime = 1.0 / 30.0; @@ -2177,7 +2173,7 @@ void FrontendRenderer::ReleaseResources() m_transitBackground.reset(); m_gpuProgramManager.reset(); - m_contextFactory->getDrawContext()->doneCurrent(); + m_contextFactory->GetDrawContext()->DoneCurrent(); } void FrontendRenderer::AddUserEvent(drape_ptr<UserEvent> && event) diff --git a/drape_frontend/frontend_renderer.hpp b/drape_frontend/frontend_renderer.hpp index 9889bee2e1..95e7e55d78 100755 --- a/drape_frontend/frontend_renderer.hpp +++ b/drape_frontend/frontend_renderer.hpp @@ -78,7 +78,7 @@ public: struct Params : BaseRenderer::Params { Params(dp::ApiVersion apiVersion, ref_ptr<ThreadsCommutator> commutator, - ref_ptr<dp::OGLContextFactory> factory, ref_ptr<dp::TextureManager> texMng, + ref_ptr<dp::GraphicContextFactory> factory, ref_ptr<dp::TextureManager> texMng, MyPositionController::Params && myPositionParams, dp::Viewport viewport, TModelViewChanged const & modelViewChangedFn, TTapEventInfoFn const & tapEventFn, TUserPositionChangedFn const & positionChangedFn, ref_ptr<RequestedTiles> requestedTiles, @@ -169,7 +169,7 @@ private: void RenderRouteLayer(ScreenBase const & modelView); void RenderSearchMarksLayer(ScreenBase const & modelView); void RenderTransitBackground(); - void RenderEmptyFrame(dp::OGLContext * context); + void RenderEmptyFrame(); bool HasTransitRouteData() const; bool HasRouteData() const; |