diff --git a/gui/controller.cpp b/gui/controller.cpp index d24681894e..c9d228eeab 100644 --- a/gui/controller.cpp +++ b/gui/controller.cpp @@ -1,5 +1,6 @@ #include "controller.hpp" #include "element.hpp" +#include "display_list_cache.hpp" #include "../map/drawer.hpp" @@ -153,6 +154,8 @@ namespace gui m_VisualScale = graphics::visualScale(p.m_Density); m_CacheScreen = p.m_CacheScreen; + m_DisplayListCache.reset(new DisplayListCache(m_CacheScreen, m_GlyphCache)); + LayoutElements(); } @@ -164,6 +167,8 @@ namespace gui m_CacheScreen = 0; PurgeElements(); + + m_DisplayListCache.reset(); } void Controller::DrawFrame(graphics::Screen * screen) @@ -204,6 +209,11 @@ namespace gui return m_CacheScreen; } + DisplayListCache * Controller::GetDisplayListCache() const + { + return m_DisplayListCache.get(); + } + void Controller::UpdateElements() { for_each(m_Elements.begin(), m_Elements.end(), bind(&Element::update, _1)); diff --git a/gui/controller.hpp b/gui/controller.hpp index 468cfc56ab..f3d288d5f3 100644 --- a/gui/controller.hpp +++ b/gui/controller.hpp @@ -1,6 +1,9 @@ #pragma once +#include "display_list_cache.hpp" + #include "../std/shared_ptr.hpp" +#include "../std/scoped_ptr.hpp" #include "../std/function.hpp" #include "../std/list.hpp" @@ -29,6 +32,19 @@ namespace gui /// Invalidate functor type typedef function TInvalidateFn; + struct RenderParams + { + graphics::EDensity m_Density; + TInvalidateFn m_InvalidateFn; + graphics::GlyphCache * m_GlyphCache; + graphics::Screen * m_CacheScreen; + RenderParams(); + RenderParams(graphics::EDensity density, + TInvalidateFn invalidateFn, + graphics::GlyphCache * glyphCache, + graphics::Screen * cacheScreen); + }; + private: /// element that has focus. @@ -54,6 +70,9 @@ namespace gui /// GlyphCache for text rendering by GUI elements. graphics::GlyphCache * m_GlyphCache; + /// Cache for display lists for fast rendering on GUI thread + scoped_ptr m_DisplayListCache; + /// Localized strings for GUI. StringsBundle const * m_bundle; @@ -79,19 +98,6 @@ namespace gui bool OnTapCancelled(m2::PointD const & pt); /// @} - struct RenderParams - { - graphics::EDensity m_Density; - TInvalidateFn m_InvalidateFn; - graphics::GlyphCache * m_GlyphCache; - graphics::Screen * m_CacheScreen; - RenderParams(); - RenderParams(graphics::EDensity density, - TInvalidateFn invalidateFn, - graphics::GlyphCache * glyphCache, - graphics::Screen * cacheScreen); - }; - /// Attach GUI Controller to the renderer void SetRenderParams(RenderParams const & p); /// Set the bundle with localized strings @@ -115,6 +121,8 @@ namespace gui /// Get graphics::Screen, which is used to cache gui::Element's /// into display lists. graphics::Screen * GetCacheScreen() const; + /// Get display list cache + DisplayListCache * GetDisplayListCache() const; /// Redraw GUI void DrawFrame(graphics::Screen * screen); /// Calling gui::Element::update for every element.