refactored RenderPolicy initialization and OpenGL resource allocation. greatly simplifies initialization code.

This commit is contained in:
rachytski 2011-11-11 12:15:36 +04:00 committed by Alex Zolotarev
parent 5b0b5852da
commit 9225cde271
35 changed files with 692 additions and 539 deletions

View file

@ -1,20 +1,15 @@
#import <UIKit/UIKit.h>
#import <OpenGLES/EAGL.h>
#import <OpenGLES/ES1/gl.h>
#import <OpenGLES/ES1/glext.h>
#import <QuartzCore/CADisplayLink.h>
#import "MapViewController.h"
#include "../../std/shared_ptr.hpp"
#include "../../map/drawer_yg.hpp"
#include "../../map/framework.hpp"
#include "../../map/feature_vec_model.hpp"
#include "../../platform/video_timer.hpp"
#include"RenderBuffer.hpp"
namespace iphone
{
class WindowHandle;
class RenderContext;
class RenderBuffer;
}
@ -34,27 +29,21 @@ typedef Framework<model::FeaturesFetcher> framework_t;
// Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel.
@interface EAGLView : UIView
{
@private
// The pixel dimensions of the backbuffer
shared_ptr<iphone::RenderContext> renderContext;
shared_ptr<yg::gl::FrameBuffer> frameBuffer;
@public
shared_ptr<WindowHandle> windowHandle;
shared_ptr<VideoTimer> videoTimer;
shared_ptr<DrawerYG> drawer;
framework_t * framework;
shared_ptr<iphone::RenderContext> renderContext;
shared_ptr<yg::gl::FrameBuffer> frameBuffer;
shared_ptr<iphone::RenderBuffer> renderBuffer;
RenderPolicy * renderPolicy;
}
- (void) drawFrame;
- (void) initRenderPolicy;
@property (nonatomic, assign) framework_t * framework;
@property (nonatomic, assign) shared_ptr<WindowHandle> windowHandle;
@property (nonatomic, assign) shared_ptr<VideoTimer> videoTimer;
@property (nonatomic, assign) shared_ptr<DrawerYG> drawer;
@property (nonatomic, assign) shared_ptr<iphone::RenderContext> renderContext;
@property (nonatomic, assign) shared_ptr<iphone::RenderBuffer> renderBuffer;
@property (nonatomic, assign) shared_ptr<yg::ResourceManager> resourceManager;
@property (nonatomic, assign) shared_ptr<yg::gl::FrameBuffer> frameBuffer;
@property (nonatomic, assign) RenderPolicy * renderPolicy;
@end

View file

@ -8,19 +8,19 @@
#include "../../yg/resource_manager.hpp"
#include "../../yg/internal/opengl.hpp"
#include "../../yg/skin.hpp"
#include "../../map/render_policy.hpp"
#include "../../platform/platform.hpp"
#include "../../platform/video_timer.hpp"
#include "RenderBuffer.hpp"
#include "RenderContext.hpp"
@implementation EAGLView
@synthesize framework;
@synthesize windowHandle;
@synthesize videoTimer;
@synthesize drawer;
@synthesize frameBuffer;
@synthesize renderContext;
@synthesize renderBuffer;
@synthesize resourceManager;
@synthesize renderPolicy;
// You must implement this method
+ (Class)layerClass
@ -47,11 +47,6 @@
}
renderContext->makeCurrent();
// to avoid grid bug on 3G device
yg::RtFormat fmt = yg::Rt4Bpp;
if ([[NSString stringWithFormat:@"%s", glGetString(GL_RENDERER)] hasPrefix:@"PowerVR MBX"])
fmt = yg::Rt8Bpp;
/// ColorFormat : RGB565
/// Backbuffer : YES, (to prevent from loosing content when mixing with ordinary layers).
@ -77,100 +72,55 @@
if (scrW == 640)
self.contentScaleFactor = 2.0;
}
frameBuffer = shared_ptr<yg::gl::FrameBuffer>(new yg::gl::FrameBuffer());
int bigVBSize = pow(2, ceil(log2(15000 * sizeof(yg::gl::Vertex))));
int bigIBSize = pow(2, ceil(log2(30000 * sizeof(unsigned short))));
int smallVBSize = pow(2, ceil(log2(1500 * sizeof(yg::gl::Vertex))));
int smallIBSize = pow(2, ceil(log2(3000 * sizeof(unsigned short))));
int blitVBSize = pow(2, ceil(log2(10 * sizeof(yg::gl::AuxVertex))));
int blitIBSize = pow(2, ceil(log2(10 * sizeof(unsigned short))));
int multiBlitVBSize = pow(2, ceil(log2(300 * sizeof(yg::gl::AuxVertex))));
int multiBlitIBSize = pow(2, ceil(log2(300 * sizeof(unsigned short))));
int tinyVBSize = pow(2, ceil(log2(300 * sizeof(yg::gl::AuxVertex))));
int tinyIBSize = pow(2, ceil(log2(300 * sizeof(unsigned short))));
NSLog(@"Vendor: %s, Renderer: %s", glGetString(GL_VENDOR), glGetString(GL_RENDERER));
Platform & pl = GetPlatform();
size_t dynTexWidth = 512;
size_t dynTexHeight = 256;
size_t dynTexCount = 10;
size_t fontTexWidth = 512;
size_t fontTexHeight = 256;
size_t fontTexCount = 5;
resourceManager = shared_ptr<yg::ResourceManager>(new yg::ResourceManager(
bigVBSize, bigIBSize, 6 * GetPlatform().CpuCores(),
smallVBSize, smallIBSize, 15 * GetPlatform().CpuCores(),
blitVBSize, blitIBSize, 15 * GetPlatform().CpuCores(),
dynTexWidth, dynTexHeight, dynTexCount * GetPlatform().CpuCores(),
fontTexWidth, fontTexHeight, fontTexCount * GetPlatform().CpuCores(),
"unicode_blocks.txt",
"fonts_whitelist.txt",
"fonts_blacklist.txt",
2 * 1024 * 1024,
GetPlatform().CpuCores() + 2,
fmt,
!yg::gl::g_isBufferObjectsSupported));
resourceManager->initMultiBlitStorage(multiBlitVBSize, multiBlitIBSize, 10);
resourceManager->initTinyStorage(tinyVBSize, tinyIBSize, 10);
Platform::FilesList fonts;
pl.GetFontNames(fonts);
resourceManager->addFonts(fonts);
DrawerYG::params_t p;
p.m_resourceManager = resourceManager;
p.m_frameBuffer = frameBuffer;
p.m_glyphCacheID = resourceManager->guiThreadGlyphCacheID();
p.m_skinName = pl.SkinName();
p.m_visualScale = pl.VisualScale();
p.m_isSynchronized = false;
p.m_useTinyStorage = true; //< use tiny buffers to minimize CPU->GPU data transfer overhead.
drawer = shared_ptr<DrawerYG>(new DrawerYG(p));
windowHandle.reset(new WindowHandle());
windowHandle->setUpdatesEnabled(false);
typedef void (*drawFrameFn)(id, SEL);
SEL drawFrameSel = @selector(drawFrame);
drawFrameFn drawFrameImpl = (drawFrameFn)[self methodForSelector:drawFrameSel];
videoTimer.reset(CreateIOSVideoTimer(bind(drawFrameImpl, self, drawFrameSel)));
windowHandle->setVideoTimer(videoTimer);
windowHandle->setRenderContext(renderContext);
}
return self;
}
- (void)initRenderPolicy
{
frameBuffer = shared_ptr<yg::gl::FrameBuffer>(new yg::gl::FrameBuffer());
NSLog(@"Vendor: %s, Renderer: %s", glGetString(GL_VENDOR), glGetString(GL_RENDERER));
// to avoid grid bug on 3G device
yg::RtFormat fmt = yg::Rt4Bpp;
if ([[NSString stringWithFormat:@"%s", glGetString(GL_RENDERER)] hasPrefix:@"PowerVR MBX"])
fmt = yg::Rt8Bpp;
DrawerYG::params_t p;
p.m_frameBuffer = frameBuffer;
typedef void (*drawFrameFn)(id, SEL);
SEL drawFrameSel = @selector(drawFrame);
drawFrameFn drawFrameImpl = (drawFrameFn)[self methodForSelector:drawFrameSel];
VideoTimer * videoTimer = CreateIOSVideoTimer(bind(drawFrameImpl, self, drawFrameSel));
renderPolicy = CreateRenderPolicy(videoTimer, p, renderContext);
framework->SetRenderPolicy(renderPolicy);
}
- (void)onSize:(int)width withHeight:(int)height
{
framework->OnSize(width, height);
/// free old video memory
frameBuffer->resetRenderTarget();
frameBuffer->resetDepthBuffer();
renderBuffer.reset();
/// allocate the new one
renderBuffer = shared_ptr<iphone::RenderBuffer>(new iphone::RenderBuffer(renderContext, (CAEAGLLayer*)self.layer));
frameBuffer->setRenderTarget(renderBuffer);
frameBuffer->setDepthBuffer(make_shared_ptr(new yg::gl::RenderBuffer(width, height, true)));
frameBuffer->onSize(width, height);
drawer->onSize(width, height);
framework->OnSize(width, height);
/* frameBuffer->onSize(width, height);
drawer->onSize(width, height);*/
shared_ptr<DrawerYG> drawer = framework->GetRenderPolicy()->GetDrawer();
drawer->screen()->beginFrame();
drawer->screen()->clear();
drawer->screen()->endFrame();
@ -178,10 +128,13 @@
- (void)drawFrame
{
shared_ptr<DrawerYG> drawer = framework->GetRenderPolicy()->GetDrawer();
shared_ptr<PaintEvent> pe(new PaintEvent(drawer.get()));
if (windowHandle->needRedraw())
if (framework->NeedRedraw())
{
windowHandle->setNeedRedraw(false);
framework->SetNeedRedraw(false);
framework->BeginPaint(pe);
framework->DoPaint(pe);
renderBuffer->present();
@ -198,7 +151,7 @@
- (void)dealloc
{
videoTimer.reset();
// m_framework->SetRenderPolicy(0);
[EAGLContext setCurrentContext:nil];
[super dealloc];
}

View file

@ -118,11 +118,8 @@ framework_t * m_framework = NULL;
// cyclic dependence, @TODO refactor.
// Here we're creating view and window handle in it, and later we should pass framework to the view
EAGLView * v = (EAGLView *)self.view;
shared_ptr<WindowHandle> windowHandle = [(EAGLView*)self.view windowHandle];
shared_ptr<yg::ResourceManager> resourceManager = [(EAGLView*)self.view resourceManager];
m_framework = FrameworkFactory<model::FeaturesFetcher>::CreateFramework(windowHandle, 40);
m_framework = FrameworkFactory<model::FeaturesFetcher>::CreateFramework();
v.framework = m_framework;
m_StickyThreshold = 10;
@ -135,7 +132,7 @@ framework_t * m_framework = NULL;
if (!res)
m_framework->SetMaxWorldRect();
m_framework->InitializeGL([(EAGLView*)self.view renderContext], resourceManager);
[v initRenderPolicy];
m_framework->Invalidate();
}

View file

@ -24,7 +24,7 @@ namespace iphone
void makeCurrent();
unsigned int id();
unsigned int id() const;
void present();

View file

@ -29,7 +29,7 @@ namespace iphone
OGLCHECK(glDeleteRenderbuffersOES(1, &m_id));
}
unsigned int RenderBuffer::id()
unsigned int RenderBuffer::id() const
{
return m_id;
}

View file

@ -12,10 +12,6 @@
#include "../version/version.hpp"
#include "benchmark_tiling_render_policy_mt.hpp"
#include "benchmark_render_policy_mt.hpp"
#include "render_policy_st.hpp"
template <class T> class DoGetBenchmarks
{
set<string> m_processed;
@ -139,21 +135,12 @@ void BenchmarkFramework<TModel>::ReAddLocalMaps()
}
template <typename TModel>
BenchmarkFramework<TModel>::BenchmarkFramework(shared_ptr<WindowHandle> const & wh,
size_t bottomShift)
: base_type(wh, bottomShift),
m_paintDuration(0),
BenchmarkFramework<TModel>::BenchmarkFramework()
: m_paintDuration(0),
m_maxDuration(0),
m_isBenchmarkFinished(false),
m_isBenchmarkInitialized(false)
{
bool isBenchmarkingMT = false;
Settings::Get("IsBenchmarkingMT", isBenchmarkingMT);
if (isBenchmarkingMT)
base_type::SetRenderPolicy(make_shared_ptr(new BenchmarkTilingRenderPolicyMT(wh, bind(&base_type::DrawModel, this, _1, _2, _3, _4, _5, true))));
else
base_type::SetRenderPolicy(make_shared_ptr(new BenchmarkRenderPolicyMT(wh, bind(&base_type::DrawModel, this, _1, _2, _3, _4, _5, false))));
m_startTime = my::FormatCurrentTime();

View file

@ -65,8 +65,7 @@ private:
public:
BenchmarkFramework(shared_ptr<WindowHandle> const & wh,
size_t bottomShift);
BenchmarkFramework();
void OnSize(int w, int h);

View file

@ -4,17 +4,12 @@
#include "../base/logging.hpp"
BenchmarkRenderPolicyMT::BenchmarkRenderPolicyMT(shared_ptr<WindowHandle> const & wh,
RenderPolicy::TRenderFn const & renderFn)
: RenderPolicyMT(wh, renderFn)
BenchmarkRenderPolicyMT::BenchmarkRenderPolicyMT(VideoTimer * videoTimer,
DrawerYG::Params const & params,
shared_ptr<yg::gl::RenderContext> const & primaryRC)
: RenderPolicyMT(videoTimer, params, primaryRC)
{}
void BenchmarkRenderPolicyMT::Initialize(shared_ptr<yg::gl::RenderContext> const & rc,
shared_ptr<yg::ResourceManager> const & rm)
{
RenderPolicyMT::Initialize(rc, rm);
}
void BenchmarkRenderPolicyMT::DrawFrame(shared_ptr<PaintEvent> const & e,
ScreenBase const & s)
{

View file

@ -5,11 +5,9 @@
class BenchmarkRenderPolicyMT : public RenderPolicyMT
{
public:
BenchmarkRenderPolicyMT(shared_ptr<WindowHandle> const & wh,
RenderPolicy::TRenderFn const & renderFn);
void Initialize(shared_ptr<yg::gl::RenderContext> const & rc,
shared_ptr<yg::ResourceManager> const & rm);
BenchmarkRenderPolicyMT(VideoTimer * videoTimer,
DrawerYG::Params const & params,
shared_ptr<yg::gl::RenderContext> const & primaryRC);
void DrawFrame(shared_ptr<PaintEvent> const & e, ScreenBase const & s);
};

View file

@ -2,17 +2,12 @@
#include "benchmark_tiling_render_policy_mt.hpp"
BenchmarkTilingRenderPolicyMT::BenchmarkTilingRenderPolicyMT(
shared_ptr<WindowHandle> const & wh,
RenderPolicy::TRenderFn const & renderFn)
: TilingRenderPolicyMT(wh, renderFn)
VideoTimer * videoTimer,
DrawerYG::Params const & params,
shared_ptr<yg::gl::RenderContext> const & primaryRC)
: TilingRenderPolicyMT(videoTimer, params, primaryRC)
{}
void BenchmarkTilingRenderPolicyMT::Initialize(shared_ptr<yg::gl::RenderContext> const & renderContext,
shared_ptr<yg::ResourceManager> const & resourceManager)
{
TilingRenderPolicyMT::Initialize(renderContext, resourceManager);
}
void BenchmarkTilingRenderPolicyMT::DrawFrame(shared_ptr<PaintEvent> const & e,
ScreenBase const & s)
{

View file

@ -6,11 +6,9 @@ class BenchmarkTilingRenderPolicyMT : public TilingRenderPolicyMT
{
public:
BenchmarkTilingRenderPolicyMT(shared_ptr<WindowHandle> const & wh,
RenderPolicy::TRenderFn const & renderFn);
void Initialize(shared_ptr<yg::gl::RenderContext> const & renderContext,
shared_ptr<yg::ResourceManager> const & resourceManager);
BenchmarkTilingRenderPolicyMT(VideoTimer * videoTimer,
DrawerYG::Params const & params,
shared_ptr<yg::gl::RenderContext> const & primaryRC);
void DrawFrame(shared_ptr<PaintEvent> const & e, ScreenBase const & s);
};

View file

@ -14,7 +14,9 @@ CoverageGenerator::CoverageGenerator(
size_t tileSize,
size_t scaleEtalonSize,
TileRenderer * tileRenderer,
shared_ptr<WindowHandle> const & windowHandle)
shared_ptr<WindowHandle> const & windowHandle,
shared_ptr<yg::gl::RenderContext> const & primaryRC,
shared_ptr<yg::ResourceManager> const & rm)
: m_queue(1),
m_tileRenderer(tileRenderer),
m_workCoverage(0),
@ -22,6 +24,19 @@ CoverageGenerator::CoverageGenerator(
m_sequenceID(0),
m_windowHandle(windowHandle)
{
m_resourceManager = rm;
m_renderContext = primaryRC->createShared();
m_currentStylesCache.reset(new yg::StylesCache(rm,
rm->cacheThreadGlyphCacheID()));
m_workStylesCache.reset(new yg::StylesCache(rm,
rm->cacheThreadGlyphCacheID()));
m_queue.AddInitCommand(bind(&CoverageGenerator::InitializeThreadGL, this));
m_queue.AddFinCommand(bind(&CoverageGenerator::FinalizeThreadGL, this));
m_queue.Start();
}
void CoverageGenerator::InitializeThreadGL()
@ -34,24 +49,6 @@ void CoverageGenerator::FinalizeThreadGL()
m_renderContext->endThreadDrawing();
}
void CoverageGenerator::Initialize(shared_ptr<yg::gl::RenderContext> const & rc,
shared_ptr<yg::ResourceManager> const & rm)
{
m_resourceManager = rm;
m_renderContext = rc->createShared();
m_currentStylesCache.reset(new yg::StylesCache(rm,
rm->cacheThreadGlyphCacheID()));
m_workStylesCache.reset(new yg::StylesCache(rm,
rm->cacheThreadGlyphCacheID()));
m_queue.AddInitCommand(bind(&CoverageGenerator::InitializeThreadGL, this));
m_queue.AddFinCommand(bind(&CoverageGenerator::FinalizeThreadGL, this));
m_queue.Start();
}
CoverageGenerator::~CoverageGenerator()
{
delete m_workCoverage;

View file

@ -50,7 +50,9 @@ public:
CoverageGenerator(size_t tileSize,
size_t scaleEtalonSize,
TileRenderer * tileRenderer,
shared_ptr<WindowHandle> const & windowHandle);
shared_ptr<WindowHandle> const & windowHandle,
shared_ptr<yg::gl::RenderContext> const & primaryRC,
shared_ptr<yg::ResourceManager> const & rm);
~CoverageGenerator();
@ -65,9 +67,6 @@ public:
void Cancel();
void Initialize(shared_ptr<yg::gl::RenderContext> const & rc,
shared_ptr<yg::ResourceManager> const & rm);
void WaitForEmptyAndFinished();
ScreenCoverage & CurrentCoverage();

View file

@ -3,10 +3,6 @@
#include "drawer_yg.hpp"
#include "feature_vec_model.hpp"
#include "benchmark_provider.hpp"
#include "render_policy_st.hpp"
#include "render_policy_mt.hpp"
#include "tiling_render_policy_st.hpp"
#include "tiling_render_policy_mt.hpp"
#include "../defines.hpp"
@ -31,20 +27,8 @@
#include "../std/fstream.hpp"
#include "../std/target_os.hpp"
#include "render_policy_st.hpp"
#include "render_policy_mt.hpp"
#include "tiling_render_policy_st.hpp"
#include "tiling_render_policy_mt.hpp"
#include "partial_render_policy.hpp"
using namespace feature;
template <typename TModel>
Framework<TModel>::~Framework()
{}
template <typename TModel>
void Framework<TModel>::AddMap(string const & file)
{
@ -100,9 +84,8 @@ void Framework<TModel>::OnCompassUpdate(location::CompassInfo const & info)
}
template <typename TModel>
Framework<TModel>::Framework(shared_ptr<WindowHandle> windowHandle,
size_t bottomShift)
: m_windowHandle(windowHandle),
Framework<TModel>::Framework()
: m_hasPendingInvalidate(false),
m_metresMinWidth(20),
m_metresMaxWidth(1000000),
#if defined(OMIM_OS_MAC) || defined(OMIM_OS_WINDOWS) || defined(OMIM_OS_LINUX)
@ -110,21 +93,11 @@ Framework<TModel>::Framework(shared_ptr<WindowHandle> windowHandle,
#else
m_minRulerWidth(60),
#endif
m_width(0),
m_height(0),
m_centeringMode(EDoNothing)
// m_tileSize(GetPlatform().TileSize())
{
// on Android policy is created in AndroidFramework
#ifndef OMIM_OS_ANDROID
// SetRenderPolicy(make_shared_ptr(new RenderPolicyST(windowHandle, bind(&this_type::DrawModel, this, _1, _2, _3, _4, _5, false))));
// SetRenderPolicy(make_shared_ptr(new TilingRenderPolicyMT(windowHandle, bind(&this_type::DrawModel, this, _1, _2, _3, _4, _5, true))));
SetRenderPolicy(make_shared_ptr(new RenderPolicyMT(windowHandle, bind(&this_type::DrawModel, this, _1, _2, _3, _4, _5, false))));
// SetRenderPolicy(make_shared_ptr(new PartialRenderPolicy(windowHandle, bind(&this_type::DrawModel, this, _1, _2, _3, _4, _5, false))));
#endif
m_informationDisplay.setBottomShift(bottomShift);
#ifdef DRAW_TOUCH_POINTS
m_informationDisplay.enableDebugPoints(true);
#endif
@ -141,11 +114,6 @@ Framework<TModel>::Framework(shared_ptr<WindowHandle> windowHandle,
m_informationDisplay.enableDebugInfo(true);
#endif
bool isVisualLogEnabled = false;
Settings::Get("VisualLog", isVisualLogEnabled);
m_informationDisplay.enableLog(isVisualLogEnabled, m_windowHandle.get());
m_informationDisplay.setVisualScale(visScale);
m_model.InitClassificator();
// initializes model with locally downloaded maps
@ -173,6 +141,10 @@ Framework<TModel>::Framework(shared_ptr<WindowHandle> windowHandle,
languages::SaveSettings(langCodes);
}
template <typename TModel>
Framework<TModel>::~Framework()
{}
template <typename TModel>
void Framework<TModel>::GetLocalMaps(vector<string> & outMaps)
{
@ -202,15 +174,6 @@ void Framework<TModel>::GetLocalMaps(vector<string> & outMaps)
outMaps.push_back(dataFiles[i]);
}
template <typename TModel>
void Framework<TModel>::InitializeGL(
shared_ptr<yg::gl::RenderContext> const & primaryContext,
shared_ptr<yg::ResourceManager> const & resourceManager)
{
yg::gl::RenderContext::initParams();
m_renderPolicy->Initialize(primaryContext, resourceManager);
}
template <typename TModel>
TModel & Framework<TModel>::get_model()
{
@ -244,19 +207,22 @@ void Framework<TModel>::SetMaxWorldRect()
template <typename TModel>
bool Framework<TModel>::NeedRedraw() const
{
return m_windowHandle->needRedraw() || m_renderPolicy->NeedRedraw();
return m_renderPolicy->NeedRedraw();
}
template <typename TModel>
void Framework<TModel>::SetNeedRedraw(bool flag)
{
m_windowHandle->setNeedRedraw(false);
m_renderPolicy->GetWindowHandle()->setNeedRedraw(false);
}
template <typename TModel>
void Framework<TModel>::Invalidate()
{
m_windowHandle->invalidate();
if (m_renderPolicy)
m_renderPolicy->GetWindowHandle()->invalidate();
else
m_hasPendingInvalidate = true;
}
template <typename TModel>
@ -282,21 +248,27 @@ void Framework<TModel>::OnSize(int w, int h)
if (w < 2) w = 2;
if (h < 2) h = 2;
m_informationDisplay.setDisplayRect(m2::RectI(m2::PointI(0, 0), m2::PointU(w, h)));
if (m_renderPolicy)
{
m_informationDisplay.setDisplayRect(m2::RectI(m2::PointI(0, 0), m2::PointU(w, h)));
m2::RectI const & viewPort = m_renderPolicy->OnSize(w, h);
m2::RectI const & viewPort = m_renderPolicy->OnSize(w, h);
m_navigator.OnSize(
viewPort.minX(),
viewPort.minY(),
viewPort.SizeX(),
viewPort.SizeY());
m_navigator.OnSize(
viewPort.minX(),
viewPort.minY(),
viewPort.SizeX(),
viewPort.SizeY());
}
m_width = w;
m_height = h;
}
template <typename TModel>
bool Framework<TModel>::SetUpdatesEnabled(bool doEnable)
{
return m_windowHandle->setUpdatesEnabled(doEnable);
return m_renderPolicy->GetWindowHandle()->setUpdatesEnabled(doEnable);
}
template <typename TModel>
@ -312,21 +284,26 @@ double Framework<TModel>::GetCurrentScale() const
return scales::GetScaleLevelD(glbRect);
}
template <typename TModel>
RenderPolicy::TRenderFn Framework<TModel>::DrawModelFn()
{
return bind(&Framework<TModel>::DrawModel, this, _1, _2, _3, _4, _5);
}
/// Actual rendering function.
template <typename TModel>
void Framework<TModel>::DrawModel(shared_ptr<PaintEvent> const & e,
ScreenBase const & screen,
m2::RectD const & selectRect,
m2::RectD const & clipRect,
int scaleLevel,
bool isTiling)
int scaleLevel)
{
fwork::DrawProcessor doDraw(clipRect, screen, e, scaleLevel);
try
{
//threads::MutexGuard lock(m_modelSyn);
if (isTiling)
if (m_renderPolicy->IsTiling())
m_model.ForEachFeature_TileDrawing(selectRect, doDraw, scaleLevel);
else
m_model.ForEachFeature(selectRect, doDraw, scaleLevel);
@ -689,10 +666,34 @@ void Framework<TModel>::Search(string const & text, SearchCallbackT callback)
}
template <typename TModel>
void Framework<TModel>::SetRenderPolicy(shared_ptr<RenderPolicy> const & renderPolicy)
void Framework<TModel>::SetRenderPolicy(RenderPolicy * renderPolicy)
{
m_renderPolicy = renderPolicy;
bool isVisualLogEnabled = false;
Settings::Get("VisualLog", isVisualLogEnabled);
m_informationDisplay.enableLog(isVisualLogEnabled, renderPolicy->GetWindowHandle().get());
m_informationDisplay.setVisualScale(GetPlatform().VisualScale());
yg::gl::RenderContext::initParams();
m_renderPolicy.reset(renderPolicy);
m_renderPolicy->SetRenderFn(DrawModelFn());
m_navigator.SetSupportRotation(m_renderPolicy->DoSupportRotation());
if ((m_width != 0) && (m_height != 0))
OnSize(m_width, m_height);
if (m_hasPendingInvalidate)
{
m_renderPolicy->GetWindowHandle()->invalidate();
m_hasPendingInvalidate = false;
}
}
template <typename TModel>
RenderPolicy * Framework<TModel>::GetRenderPolicy() const
{
return m_renderPolicy.get();
}
template <typename TModel>

View file

@ -69,8 +69,8 @@ protected:
model_t m_model;
Navigator m_navigator;
shared_ptr<WindowHandle> m_windowHandle;
shared_ptr<RenderPolicy> m_renderPolicy;
scoped_ptr<RenderPolicy> m_renderPolicy;
bool m_hasPendingInvalidate;
InformationDisplay m_informationDisplay;
@ -78,6 +78,9 @@ protected:
double const m_metresMaxWidth;
int const m_minRulerWidth;
int m_width;
int m_height;
enum TGpsCenteringMode
{
EDoNothing,
@ -102,7 +105,8 @@ protected:
void GetLocalMaps(vector<string> & outMaps);
public:
Framework(shared_ptr<WindowHandle> windowHandle, size_t bottomShift);
Framework();
virtual ~Framework();
storage::Storage & Storage() { return m_storage; }
@ -111,10 +115,8 @@ public:
void OnGpsUpdate(location::GpsInfo const & info);
void OnCompassUpdate(location::CompassInfo const & info);
void SetRenderPolicy(shared_ptr<RenderPolicy> const & rp);
void InitializeGL(shared_ptr<yg::gl::RenderContext> const & primaryContext,
shared_ptr<yg::ResourceManager> const & resourceManager);
void SetRenderPolicy(RenderPolicy * renderPolicy);
RenderPolicy * GetRenderPolicy() const;
model_t & get_model();
@ -125,16 +127,15 @@ public:
void PrepareToShutdown();
public:
void SetupMeasurementSystem();
RenderPolicy::TRenderFn DrawModelFn();
void DrawModel(shared_ptr<PaintEvent> const & e,
ScreenBase const & screen,
m2::RectD const & selectRect,
m2::RectD const & clipRect,
int scaleLevel,
bool isTiling);
int scaleLevel);
void Search(string const & text, SearchCallbackT callback);
search::Engine * GetSearchEngine();

View file

@ -7,15 +7,15 @@
#include "../platform/settings.hpp"
template <typename TModel>
Framework<TModel> * FrameworkFactory<TModel>::CreateFramework(shared_ptr<WindowHandle> const & wh, size_t bottomShift)
Framework<TModel> * FrameworkFactory<TModel>::CreateFramework()
{
bool benchmarkingEnabled = false;
(void)Settings::Get("IsBenchmarking", benchmarkingEnabled);
if (benchmarkingEnabled)
return new BenchmarkFramework<TModel>(wh, bottomShift);
return new BenchmarkFramework<TModel>();
else
return new Framework<TModel>(wh, bottomShift);
return new Framework<TModel>();
}
template class FrameworkFactory<model::FeaturesFetcher>;

View file

@ -9,5 +9,5 @@ template <typename TModel>
class FrameworkFactory
{
public:
static Framework<TModel> * CreateFramework(shared_ptr<WindowHandle> const & wh, size_t bottomShift);
static Framework<TModel> * CreateFramework();
};

View file

@ -5,18 +5,13 @@
#include "../yg/internal/opengl.hpp"
#include "../std/bind.hpp"
PartialRenderPolicy::PartialRenderPolicy(shared_ptr<WindowHandle> const & wh,
RenderPolicy::TRenderFn const & renderFn)
: RenderPolicyMT(wh, renderFn)
PartialRenderPolicy::PartialRenderPolicy(VideoTimer * videoTimer,
DrawerYG::Params const & params,
shared_ptr<yg::gl::RenderContext> const & primaryRC)
: RenderPolicyMT(videoTimer, params, primaryRC)
{
SetNeedSynchronize(true);
}
void PartialRenderPolicy::Initialize(shared_ptr<yg::gl::RenderContext> const & rc,
shared_ptr<yg::ResourceManager> const & rm)
{
m_renderQueue.SetGLQueue(&m_glQueue, &m_glCondition);
RenderPolicyMT::Initialize(rc, rm);
m_renderQueue->SetGLQueue(&m_glQueue, &m_glCondition);
}
void PartialRenderPolicy::ProcessRenderQueue(list<yg::gl::Renderer::Packet> & renderQueue)
@ -106,5 +101,5 @@ void PartialRenderPolicy::EndFrame(shared_ptr<PaintEvent> const & paintEvent,
bool PartialRenderPolicy::NeedRedraw() const
{
return !m_glQueue.Empty();
return RenderPolicyMT::NeedRedraw() || !m_glQueue.Empty();
}

View file

@ -23,11 +23,9 @@ private:
public:
PartialRenderPolicy(shared_ptr<WindowHandle> const & wh,
RenderPolicy::TRenderFn const & renderFn);
void Initialize(shared_ptr<yg::gl::RenderContext> const & rc,
shared_ptr<yg::ResourceManager> const & rm);
PartialRenderPolicy(VideoTimer * videoTimer,
DrawerYG::Params const & params,
shared_ptr<yg::gl::RenderContext> const & primaryRC);
void DrawFrame(shared_ptr<PaintEvent> const & paintEvent,
ScreenBase const & screenBase);

View file

@ -1,48 +1,30 @@
#include "../base/SRC_FIRST.hpp"
#include "render_policy.hpp"
#include "window_handle.hpp"
#include "../map/render_policy_st.hpp"
#include "../map/render_policy_mt.hpp"
#include "../map/tiling_render_policy_st.hpp"
#include "../map/tiling_render_policy_mt.hpp"
#include "../map/partial_render_policy.hpp"
#include "../map/benchmark_render_policy_mt.hpp"
#include "../map/benchmark_tiling_render_policy_mt.hpp"
#include "../platform/video_timer.hpp"
#include "../platform/settings.hpp"
RenderPolicy::~RenderPolicy()
{}
RenderPolicy::RenderPolicy(shared_ptr<WindowHandle> const & windowHandle,
TRenderFn const & renderFn,
bool doSupportRotation)
RenderPolicy::RenderPolicy(shared_ptr<yg::gl::RenderContext> const & primaryRC, bool doSupportRotation)
: m_bgColor(0xEE, 0xEE, 0xDD, 0xFF),
m_windowHandle(windowHandle),
m_renderFn(renderFn),
m_primaryRC(primaryRC),
m_doSupportRotation(doSupportRotation)
{}
yg::Color const & RenderPolicy::bgColor() const
{
return m_bgColor;
}
shared_ptr<yg::ResourceManager> const & RenderPolicy::resourceManager() const
{
return m_resourceManager;
}
shared_ptr<WindowHandle> const & RenderPolicy::windowHandle() const
{
return m_windowHandle;
}
RenderPolicy::TRenderFn RenderPolicy::renderFn() const
{
return m_renderFn;
}
void RenderPolicy::Initialize(shared_ptr<yg::gl::RenderContext> const &,
shared_ptr<yg::ResourceManager> const & resourceManager)
{
m_resourceManager = resourceManager;
}
m2::RectI const RenderPolicy::OnSize(int w, int h)
{
m_drawer->onSize(w, h);
return m2::RectI(0, 0, w, h);
}
@ -103,6 +85,57 @@ bool RenderPolicy::DoSupportRotation() const
}
bool RenderPolicy::NeedRedraw() const
{
return m_windowHandle->needRedraw();
}
bool RenderPolicy::IsTiling() const
{
return false;
}
shared_ptr<DrawerYG> const & RenderPolicy::GetDrawer() const
{
return m_drawer;
}
shared_ptr<WindowHandle> const & RenderPolicy::GetWindowHandle() const
{
return m_windowHandle;
}
void RenderPolicy::SetRenderFn(TRenderFn renderFn)
{
m_renderFn = renderFn;
}
RenderPolicy * CreateRenderPolicy(VideoTimer * videoTimer,
DrawerYG::Params const & params,
shared_ptr<yg::gl::RenderContext> const & primaryRC)
{
bool benchmarkingEnabled = false;
Settings::Get("IsBenchmarking", benchmarkingEnabled);
if (benchmarkingEnabled)
{
bool isBenchmarkingMT = false;
Settings::Get("IsBenchmarkingMT", isBenchmarkingMT);
if (isBenchmarkingMT)
return new BenchmarkTilingRenderPolicyMT(videoTimer, params, primaryRC);
else
return new BenchmarkRenderPolicyMT(videoTimer, params, primaryRC);
}
else
{
#ifdef OMIM_OS_ANDROID
return new PartialRenderPolicy(videoTimer, params, primaryRC);
#endif
#ifdef OMIM_OS_IPHONE
return new RenderPolicyMT(videoTimer, params, primaryRC);
#endif
#ifdef OMIM_OS_DESKTOP
return new RenderPolicyMT(videoTimer, params, primaryRC);
#endif
}
}

View file

@ -1,5 +1,7 @@
#pragma once
#include "drawer_yg.hpp"
#include "../yg/color.hpp"
#include "../std/function.hpp"
@ -9,6 +11,7 @@
class PaintEvent;
class ScreenBase;
class VideoTimer;
namespace yg
{
@ -26,27 +29,26 @@ class RenderPolicy
{
public:
typedef function<void(shared_ptr<PaintEvent>, ScreenBase const &, m2::RectD const &, m2::RectD const &, int)> TRenderFn;
private:
yg::Color m_bgColor;
shared_ptr<yg::ResourceManager> m_resourceManager;
shared_ptr<WindowHandle> m_windowHandle;
TRenderFn m_renderFn;
bool m_doSupportRotation;
typedef function<void(shared_ptr<PaintEvent>,
ScreenBase const &,
m2::RectD const &,
m2::RectD const &,
int)> TRenderFn;
protected:
yg::Color const & bgColor() const;
shared_ptr<yg::ResourceManager> const & resourceManager() const;
shared_ptr<WindowHandle> const & windowHandle() const;
TRenderFn renderFn() const;
yg::Color m_bgColor;
shared_ptr<yg::ResourceManager> m_resourceManager;
shared_ptr<yg::gl::RenderContext> m_primaryRC;
shared_ptr<WindowHandle> m_windowHandle;
shared_ptr<DrawerYG> m_drawer;
TRenderFn m_renderFn;
bool m_doSupportRotation;
public:
/// constructor
RenderPolicy(shared_ptr<WindowHandle> const & windowHandle, TRenderFn const & renderFn, bool doSupportRotation);
RenderPolicy(shared_ptr<yg::gl::RenderContext> const & primaryRC, bool doSupportRotation);
/// destructor
virtual ~RenderPolicy();
/// starting frame
@ -57,10 +59,6 @@ public:
virtual void EndFrame(shared_ptr<PaintEvent> const & e, ScreenBase const & s);
/// processing resize request
virtual m2::RectI const OnSize(int w, int h);
/// initialize render policy
virtual void Initialize(shared_ptr<yg::gl::RenderContext> const & primaryContext,
shared_ptr<yg::ResourceManager> const & resourceManager) = 0;
/// reacting on navigation actions
/// @{
virtual void StartDrag();
@ -76,7 +74,20 @@ public:
virtual void StopRotate(double a, double timeInSec);
/// @}
/// the start point of rendering in renderpolicy.
virtual void SetRenderFn(TRenderFn renderFn);
bool DoSupportRotation() const;
bool IsTiling() const;
bool NeedRedraw() const;
shared_ptr<DrawerYG> const & GetDrawer() const;
shared_ptr<WindowHandle> const & GetWindowHandle() const;
};
RenderPolicy * CreateRenderPolicy(VideoTimer * videoTimer,
DrawerYG::Params const & params,
shared_ptr<yg::gl::RenderContext> const & primaryRC);

View file

@ -3,7 +3,9 @@
#include "render_policy_mt.hpp"
#include "events.hpp"
#include "drawer_yg.hpp"
#include "window_handle.hpp"
#include "../yg/render_state.hpp"
#include "../yg/internal/opengl.hpp"
#include "../geometry/transformations.hpp"
@ -11,21 +13,76 @@
#include "../platform/platform.hpp"
RenderPolicyMT::RenderPolicyMT(shared_ptr<WindowHandle> const & wh,
RenderPolicy::TRenderFn const & renderFn)
: RenderPolicy(wh, renderFn, false),
m_renderQueue(GetPlatform().SkinName(),
false,
true,
0.1,
false,
GetPlatform().ScaleEtalonSize(),
GetPlatform().VisualScale(),
bgColor()),
RenderPolicyMT::RenderPolicyMT(VideoTimer * videoTimer,
DrawerYG::Params const & params,
shared_ptr<yg::gl::RenderContext> const & primaryRC)
: RenderPolicy(primaryRC, false),
m_DoAddCommand(true),
m_DoSynchronize(true)
{
m_renderQueue.AddWindowHandle(wh);
m_resourceManager = make_shared_ptr(new yg::ResourceManager(
50000 * sizeof(yg::gl::Vertex),
100000 * sizeof(unsigned short),
15,
5000 * sizeof(yg::gl::Vertex),
10000 * sizeof(unsigned short),
100,
10 * sizeof(yg::gl::AuxVertex),
10 * sizeof(unsigned short),
50,
512, 256,
10,
512, 256,
5,
"unicode_blocks.txt",
"fonts_whitelist.txt",
"fonts_blacklist.txt",
2 * 1024 * 1024,
GetPlatform().CpuCores() + 2,
yg::Rt8Bpp,
!yg::gl::g_isBufferObjectsSupported));
m_resourceManager->initTinyStorage(300 * sizeof(yg::gl::Vertex), 600 * sizeof(unsigned short), 20);
Platform::FilesList fonts;
GetPlatform().GetFontNames(fonts);
m_resourceManager->addFonts(fonts);
DrawerYG::params_t p = params;
p.m_resourceManager = m_resourceManager;
p.m_dynamicPagesCount = 2;
p.m_textPagesCount = 2;
p.m_glyphCacheID = m_resourceManager->guiThreadGlyphCacheID();
p.m_skinName = GetPlatform().SkinName();
p.m_visualScale = GetPlatform().VisualScale();
p.m_isSynchronized = true;
p.m_useTinyStorage = true;
m_drawer.reset(new DrawerYG(p));
m_windowHandle.reset(new WindowHandle());
m_windowHandle->setUpdatesEnabled(false);
m_windowHandle->setVideoTimer(make_shared_ptr(videoTimer));
m_windowHandle->setRenderContext(primaryRC);
m_renderQueue.reset(new RenderQueue(GetPlatform().SkinName(),
false,
true,
0.1,
false,
GetPlatform().ScaleEtalonSize(),
GetPlatform().VisualScale(),
m_bgColor));
m_renderQueue->AddWindowHandle(m_windowHandle);
}
void RenderPolicyMT::SetRenderFn(TRenderFn renderFn)
{
RenderPolicy::SetRenderFn(renderFn);
m_renderQueue->initializeGL(m_primaryRC, m_resourceManager);
}
void RenderPolicyMT::SetNeedSynchronize(bool flag)
@ -33,18 +90,13 @@ void RenderPolicyMT::SetNeedSynchronize(bool flag)
m_DoSynchronize = flag;
}
void RenderPolicyMT::Initialize(shared_ptr<yg::gl::RenderContext> const & rc,
shared_ptr<yg::ResourceManager> const & rm)
{
m_renderQueue.initializeGL(rc, rm);
RenderPolicy::Initialize(rc, rm);
}
m2::RectI const RenderPolicyMT::OnSize(int w, int h)
{
m_renderQueue.OnSize(w, h);
RenderPolicy::OnSize(w, h);
m2::PointU pt = m_renderQueue.renderState().coordSystemShift();
m_renderQueue->OnSize(w, h);
m2::PointU pt = m_renderQueue->renderState().coordSystemShift();
return m2::RectI(pt.x, pt.y, pt.x + w, pt.y + h);
}
@ -58,30 +110,30 @@ void RenderPolicyMT::EndFrame(shared_ptr<PaintEvent> const & e,
ScreenBase const & s)
{
if (m_DoSynchronize)
m_renderQueue.renderState().m_mutex->Unlock();
m_renderQueue->renderState().m_mutex->Unlock();
}
void RenderPolicyMT::DrawFrame(shared_ptr<PaintEvent> const & e,
ScreenBase const & s)
{
if (m_DoAddCommand && (s != m_renderQueue.renderState().m_actualScreen))
m_renderQueue.AddCommand(renderFn(), s);
if (m_DoAddCommand && (s != m_renderQueue->renderState().m_actualScreen))
m_renderQueue->AddCommand(m_renderFn, s);
DrawerYG * pDrawer = e->drawer();
e->drawer()->screen()->clear(bgColor());
e->drawer()->screen()->clear(m_bgColor);
if (m_DoSynchronize)
m_renderQueue.renderState().m_mutex->Lock();
m_renderQueue->renderState().m_mutex->Lock();
if (m_renderQueue.renderState().m_actualTarget.get() != 0)
if (m_renderQueue->renderState().m_actualTarget.get() != 0)
{
m2::PointD const ptShift = m_renderQueue.renderState().coordSystemShift(false);
m2::PointD const ptShift = m_renderQueue->renderState().coordSystemShift(false);
math::Matrix<double, 3, 3> m = m_renderQueue.renderState().m_actualScreen.PtoGMatrix() * s.GtoPMatrix();
math::Matrix<double, 3, 3> m = m_renderQueue->renderState().m_actualScreen.PtoGMatrix() * s.GtoPMatrix();
m = math::Shift(m, -ptShift);
pDrawer->screen()->blit(m_renderQueue.renderState().m_actualTarget, m);
pDrawer->screen()->blit(m_renderQueue->renderState().m_actualTarget, m);
}
}
@ -111,5 +163,5 @@ void RenderPolicyMT::StopScale()
RenderQueue & RenderPolicyMT::GetRenderQueue()
{
return m_renderQueue;
return *m_renderQueue.get();
}

View file

@ -2,24 +2,27 @@
#include "render_policy.hpp"
#include "render_queue.hpp"
#include "drawer_yg.hpp"
#include "../geometry/point2d.hpp"
#include "../std/scoped_ptr.hpp"
class WindowHandle;
class VideoTimer;
class RenderPolicyMT : public RenderPolicy
{
protected:
RenderQueue m_renderQueue;
scoped_ptr<RenderQueue> m_renderQueue;
bool m_DoAddCommand;
bool m_DoSynchronize;
public:
RenderPolicyMT(shared_ptr<WindowHandle> const & wh,
RenderPolicy::TRenderFn const & renderFn);
void Initialize(shared_ptr<yg::gl::RenderContext> const & rc,
shared_ptr<yg::ResourceManager> const & rm);
RenderPolicyMT(VideoTimer * videoTimer,
DrawerYG::Params const & params,
shared_ptr<yg::gl::RenderContext> const & primaryRC);
void BeginFrame(shared_ptr<PaintEvent> const & e,
ScreenBase const & s);
@ -41,4 +44,5 @@ public:
RenderQueue & GetRenderQueue();
void SetNeedSynchronize(bool flag);
void SetRenderFn(TRenderFn renderFn);
};

View file

@ -3,22 +3,63 @@
#include "render_policy_st.hpp"
#include "events.hpp"
#include "drawer_yg.hpp"
#include "window_handle.hpp"
#include "../yg/info_layer.hpp"
#include "../yg/internal/opengl.hpp"
#include "../indexer/scales.hpp"
#include "../geometry/screenbase.hpp"
#include "../platform/platform.hpp"
RenderPolicyST::RenderPolicyST(shared_ptr<WindowHandle> const & wh,
RenderPolicy::TRenderFn const & renderFn)
: RenderPolicy(wh, renderFn, false)
{}
void RenderPolicyST::Initialize(shared_ptr<yg::gl::RenderContext> const & rc,
shared_ptr<yg::ResourceManager> const & rm)
RenderPolicyST::RenderPolicyST(VideoTimer * videoTimer,
DrawerYG::Params const & params,
shared_ptr<yg::gl::RenderContext> const & primaryRC)
: RenderPolicy(primaryRC, false)
{
RenderPolicy::Initialize(rc, rm);
m_resourceManager = make_shared_ptr(new yg::ResourceManager(
50000 * sizeof(yg::gl::Vertex),
100000 * sizeof(unsigned short),
15,
5000 * sizeof(yg::gl::Vertex),
10000 * sizeof(unsigned short),
100,
10 * sizeof(yg::gl::AuxVertex),
10 * sizeof(unsigned short),
50,
512, 256,
10,
512, 256,
5,
"unicode_blocks.txt",
"fonts_whitelist.txt",
"fonts_blacklist.txt",
2 * 1024 * 1024,
1,
yg::Rt8Bpp,
!yg::gl::g_isBufferObjectsSupported));
Platform::FilesList fonts;
GetPlatform().GetFontNames(fonts);
m_resourceManager->addFonts(fonts);
DrawerYG::params_t p = params;
p.m_resourceManager = m_resourceManager;
p.m_dynamicPagesCount = 2;
p.m_textPagesCount = 2;
p.m_glyphCacheID = m_resourceManager->guiThreadGlyphCacheID();
p.m_skinName = GetPlatform().SkinName();
p.m_visualScale = GetPlatform().VisualScale();
p.m_isSynchronized = true;
m_drawer.reset(new DrawerYG(p));
m_windowHandle.reset(new WindowHandle());
m_windowHandle->setUpdatesEnabled(false);
m_windowHandle->setVideoTimer(make_shared_ptr(videoTimer));
m_windowHandle->setRenderContext(primaryRC);
}
void RenderPolicyST::DrawFrame(shared_ptr<PaintEvent> const & e,
@ -36,9 +77,9 @@ void RenderPolicyST::DrawFrame(shared_ptr<PaintEvent> const & e,
e->drawer()->screen()->setInfoLayer(infoLayer);
e->drawer()->screen()->clear(bgColor());
e->drawer()->screen()->clear(m_bgColor);
renderFn()(e, s, s.ClipRect(), s.ClipRect(), scales::GetScaleLevel(glbRect));
m_renderFn(e, s, s.ClipRect(), s.ClipRect(), scales::GetScaleLevel(glbRect));
infoLayer->draw(e->drawer()->screen().get(), math::Identity<double, 3>());
e->drawer()->screen()->resetInfoLayer();

View file

@ -1,18 +1,16 @@
#pragma once
#include "render_policy.hpp"
#include "drawer_yg.hpp"
class WindowHandle;
class VideoTimer;
class RenderPolicyST : public RenderPolicy
{
private:
public:
RenderPolicyST(shared_ptr<WindowHandle> const & wh,
RenderPolicy::TRenderFn const & renderFn);
void Initialize(shared_ptr<yg::gl::RenderContext> const & rc,
shared_ptr<yg::ResourceManager> const & rm);
RenderPolicyST(VideoTimer * videoTimer,
DrawerYG::Params const & params,
shared_ptr<yg::gl::RenderContext> const & primaryRC);
void DrawFrame(shared_ptr<PaintEvent> const & paintEvent,
ScreenBase const & screenBase);

View file

@ -17,7 +17,10 @@ TileRenderer::TileRenderer(
unsigned maxTilesCount,
unsigned executorsCount,
yg::Color const & bgColor,
RenderPolicy::TRenderFn const & renderFn
RenderPolicy::TRenderFn const & renderFn,
shared_ptr<yg::gl::RenderContext> const & primaryRC,
shared_ptr<yg::ResourceManager> const & rm,
double visualScale
) : m_queue(executorsCount),
m_tileCache(maxTilesCount - executorsCount - 1),
m_renderFn(renderFn),
@ -25,14 +28,8 @@ TileRenderer::TileRenderer(
m_bgColor(bgColor),
m_sequenceID(0)
{
}
void TileRenderer::Initialize(shared_ptr<yg::gl::RenderContext> const & primaryContext,
shared_ptr<yg::ResourceManager> const & resourceManager,
double visualScale)
{
m_resourceManager = resourceManager;
m_primaryContext = primaryContext;
m_resourceManager = rm;
m_primaryContext = primaryRC;
m_threadData.resize(m_queue.ExecutorsCount());

View file

@ -70,13 +70,12 @@ public:
unsigned maxTilesCount,
unsigned tasksCount,
yg::Color const & bgColor,
RenderPolicy::TRenderFn const & renderFn);
RenderPolicy::TRenderFn const & renderFn,
shared_ptr<yg::gl::RenderContext> const & primaryRC,
shared_ptr<yg::ResourceManager> const & rm,
double visualScale);
/// destructor.
~TileRenderer();
/// set the primary context. it starts the rendering thread.
void Initialize(shared_ptr<yg::gl::RenderContext> const & primaryContext,
shared_ptr<yg::ResourceManager> const & resourceManager,
double visualScale);
virtual ~TileRenderer();
/// add command to the commands queue.
void AddCommand(Tiler::RectInfo const & rectInfo,
int sequenceID,

View file

@ -14,32 +14,82 @@
#include "window_handle.hpp"
#include "screen_coverage.hpp"
TilingRenderPolicyMT::TilingRenderPolicyMT(shared_ptr<WindowHandle> const & windowHandle,
RenderPolicy::TRenderFn const & renderFn)
: RenderPolicy(windowHandle, renderFn, true),
m_tileRenderer(GetPlatform().SkinName(),
GetPlatform().MaxTilesCount(),
1, //GetPlatform().CpuCores(),
bgColor(),
renderFn),
m_coverageGenerator(GetPlatform().TileSize(),
GetPlatform().ScaleEtalonSize(),
&m_tileRenderer,
windowHandle)
TilingRenderPolicyMT::TilingRenderPolicyMT(VideoTimer * videoTimer,
DrawerYG::Params const & params,
shared_ptr<yg::gl::RenderContext> const & primaryRC)
: RenderPolicy(primaryRC, true)
{
m_resourceManager = make_shared_ptr(new yg::ResourceManager(
50000 * sizeof(yg::gl::Vertex),
100000 * sizeof(unsigned short),
15,
5000 * sizeof(yg::gl::Vertex),
10000 * sizeof(unsigned short),
100,
10 * sizeof(yg::gl::AuxVertex),
10 * sizeof(unsigned short),
50,
512, 256,
10,
512, 256,
5,
"unicode_blocks.txt",
"fonts_whitelist.txt",
"fonts_blacklist.txt",
2 * 1024 * 1024,
GetPlatform().CpuCores() + 2,
yg::Rt8Bpp,
!yg::gl::g_isBufferObjectsSupported));
m_resourceManager->initMultiBlitStorage(500 * sizeof(yg::gl::AuxVertex), 500 * sizeof(unsigned short), 10);
m_resourceManager->initRenderTargets(GetPlatform().TileSize(), GetPlatform().TileSize(), GetPlatform().MaxTilesCount());
m_resourceManager->initStyleCacheTextures(m_resourceManager->fontTextureWidth(), m_resourceManager->fontTextureHeight() * 2, 2);
m_resourceManager->initTinyStorage(300 * sizeof(yg::gl::Vertex), 600 * sizeof(unsigned short), 50);
Platform::FilesList fonts;
GetPlatform().GetFontNames(fonts);
m_resourceManager->addFonts(fonts);
DrawerYG::params_t p = params;
p.m_resourceManager = m_resourceManager;
p.m_dynamicPagesCount = 2;
p.m_textPagesCount = 2;
p.m_glyphCacheID = m_resourceManager->guiThreadGlyphCacheID();
p.m_skinName = GetPlatform().SkinName();
p.m_visualScale = GetPlatform().VisualScale();
p.m_useTinyStorage = true;
p.m_isSynchronized = false;
m_drawer.reset(new DrawerYG(p));
m_windowHandle.reset(new WindowHandle());
m_windowHandle->setUpdatesEnabled(false);
m_windowHandle->setVideoTimer(make_shared_ptr(videoTimer));
m_windowHandle->setRenderContext(primaryRC);
}
void TilingRenderPolicyMT::Initialize(shared_ptr<yg::gl::RenderContext> const & primaryContext,
shared_ptr<yg::ResourceManager> const & resourceManager)
void TilingRenderPolicyMT::SetRenderFn(TRenderFn renderFn)
{
RenderPolicy::Initialize(primaryContext, resourceManager);
RenderPolicy::SetRenderFn(renderFn);
resourceManager->initRenderTargets(GetPlatform().TileSize(), GetPlatform().TileSize(), GetPlatform().MaxTilesCount());
resourceManager->initStyleCacheTextures(resourceManager->fontTextureWidth(), resourceManager->fontTextureHeight() * 2, 2);
m_tileRenderer.reset(new TileRenderer(GetPlatform().SkinName(),
GetPlatform().MaxTilesCount(),
1, //GetPlatform().CpuCores(),
m_bgColor,
renderFn,
m_primaryRC,
m_resourceManager,
GetPlatform().VisualScale()));
m_tileRenderer.Initialize(primaryContext, resourceManager, GetPlatform().VisualScale());
m_coverageGenerator.Initialize(primaryContext, resourceManager);
m_coverageGenerator.reset(new CoverageGenerator(GetPlatform().TileSize(),
GetPlatform().ScaleEtalonSize(),
m_tileRenderer.get(),
m_windowHandle,
m_primaryRC,
m_resourceManager
));
}
void TilingRenderPolicyMT::BeginFrame(shared_ptr<PaintEvent> const & e, ScreenBase const & s)
@ -48,29 +98,29 @@ void TilingRenderPolicyMT::BeginFrame(shared_ptr<PaintEvent> const & e, ScreenBa
void TilingRenderPolicyMT::EndFrame(shared_ptr<PaintEvent> const & e, ScreenBase const & s)
{
ScreenCoverage * curCvg = &m_coverageGenerator.CurrentCoverage();
ScreenCoverage * curCvg = &m_coverageGenerator->CurrentCoverage();
curCvg->EndFrame(e->drawer()->screen().get());
m_coverageGenerator.Mutex().Unlock();
m_coverageGenerator->Mutex().Unlock();
}
void TilingRenderPolicyMT::DrawFrame(shared_ptr<PaintEvent> const & e, ScreenBase const & currentScreen)
{
DrawerYG * pDrawer = e->drawer();
pDrawer->screen()->clear(bgColor());
pDrawer->screen()->clear(m_bgColor);
m_coverageGenerator.AddCoverScreenTask(currentScreen);
m_coverageGenerator->AddCoverScreenTask(currentScreen);
m_coverageGenerator.Mutex().Lock();
m_coverageGenerator->Mutex().Lock();
ScreenCoverage * curCvg = &m_coverageGenerator.CurrentCoverage();
ScreenCoverage * curCvg = &m_coverageGenerator->CurrentCoverage();
curCvg->Draw(pDrawer->screen().get(), currentScreen);
}
TileRenderer & TilingRenderPolicyMT::GetTileRenderer()
{
return m_tileRenderer;
return *m_tileRenderer.get();
}
void TilingRenderPolicyMT::StartScale()
@ -82,3 +132,8 @@ void TilingRenderPolicyMT::StopScale()
{
m_isScaling = false;
}
bool TilingRenderPolicyMT::IsTiling() const
{
return true;
}

View file

@ -7,6 +7,7 @@
#include "screen_coverage.hpp"
#include "../yg/info_layer.hpp"
#include "../std/scoped_ptr.hpp"
namespace yg
{
@ -23,9 +24,9 @@ class TilingRenderPolicyMT : public RenderPolicy
{
private:
TileRenderer m_tileRenderer;
scoped_ptr<TileRenderer> m_tileRenderer;
CoverageGenerator m_coverageGenerator;
scoped_ptr<CoverageGenerator> m_coverageGenerator;
ScreenBase m_currentScreen;
@ -39,11 +40,9 @@ protected:
public:
TilingRenderPolicyMT(shared_ptr<WindowHandle> const & windowHandle,
RenderPolicy::TRenderFn const & renderFn);
void Initialize(shared_ptr<yg::gl::RenderContext> const & renderContext,
shared_ptr<yg::ResourceManager> const & resourceManager);
TilingRenderPolicyMT(VideoTimer * videoTimer,
DrawerYG::Params const & params,
shared_ptr<yg::gl::RenderContext> const & primaryRC);
void BeginFrame(shared_ptr<PaintEvent> const & ev, ScreenBase const & s);
void DrawFrame(shared_ptr<PaintEvent> const & ev, ScreenBase const & s);
@ -51,4 +50,8 @@ public:
virtual void StartScale();
virtual void StopScale();
bool IsTiling() const;
void SetRenderFn(TRenderFn renderFn);
};

View file

@ -10,43 +10,83 @@
#include "../yg/renderbuffer.hpp"
#include "../yg/resource_manager.hpp"
#include "../yg/base_texture.hpp"
#include "../yg/internal/opengl.hpp"
#include "../platform/platform.hpp"
TilingRenderPolicyST::TilingRenderPolicyST(shared_ptr<WindowHandle> const & windowHandle,
RenderPolicy::TRenderFn const & renderFn)
: RenderPolicy(windowHandle, renderFn, false),
TilingRenderPolicyST::TilingRenderPolicyST(VideoTimer * videoTimer,
DrawerYG::Params const & params,
shared_ptr<yg::gl::RenderContext> const & primaryRC)
: RenderPolicy(primaryRC, true),
m_tileCache(GetPlatform().MaxTilesCount() - 1),
m_tiler(GetPlatform().TileSize(), GetPlatform().ScaleEtalonSize())
{}
void TilingRenderPolicyST::Initialize(shared_ptr<yg::gl::RenderContext> const & primaryContext,
shared_ptr<yg::ResourceManager> const & rm)
{
RenderPolicy::Initialize(primaryContext, rm);
m_resourceManager = make_shared_ptr(new yg::ResourceManager(
50000 * sizeof(yg::gl::Vertex),
100000 * sizeof(unsigned short),
15,
5000 * sizeof(yg::gl::Vertex),
10000 * sizeof(unsigned short),
100,
10 * sizeof(yg::gl::AuxVertex),
10 * sizeof(unsigned short),
50,
512, 256,
10,
512, 256,
5,
"unicode_blocks.txt",
"fonts_whitelist.txt",
"fonts_blacklist.txt",
2 * 1024 * 1024,
GetPlatform().CpuCores() + 2,
yg::Rt8Bpp,
!yg::gl::g_isBufferObjectsSupported));
rm->initRenderTargets(GetPlatform().TileSize(), GetPlatform().TileSize(), GetPlatform().MaxTilesCount());
m_resourceManager->initMultiBlitStorage(500 * sizeof(yg::gl::AuxVertex), 500 * sizeof(unsigned short), 10);
m_resourceManager->initRenderTargets(GetPlatform().TileSize(), GetPlatform().TileSize(), GetPlatform().MaxTilesCount());
Platform::FilesList fonts;
GetPlatform().GetFontNames(fonts);
m_resourceManager->addFonts(fonts);
DrawerYG::params_t p = params;
p.m_resourceManager = m_resourceManager;
p.m_dynamicPagesCount = 2;
p.m_textPagesCount = 2;
p.m_glyphCacheID = m_resourceManager->guiThreadGlyphCacheID();
p.m_skinName = GetPlatform().SkinName();
p.m_visualScale = GetPlatform().VisualScale();
p.m_isSynchronized = true;
m_drawer.reset(new DrawerYG(p));
m_windowHandle.reset(new WindowHandle());
m_windowHandle->setUpdatesEnabled(false);
m_windowHandle->setVideoTimer(make_shared_ptr(videoTimer));
m_windowHandle->setRenderContext(primaryRC);
/// render single tile on the same thread
shared_ptr<yg::gl::FrameBuffer> frameBuffer(new yg::gl::FrameBuffer());
unsigned tileWidth = resourceManager()->tileTextureWidth();
unsigned tileHeight = resourceManager()->tileTextureHeight();
unsigned tileWidth = m_resourceManager->tileTextureWidth();
unsigned tileHeight = m_resourceManager->tileTextureHeight();
shared_ptr<yg::gl::RenderBuffer> depthBuffer(new yg::gl::RenderBuffer(tileWidth, tileHeight, true));
frameBuffer->setDepthBuffer(depthBuffer);
DrawerYG::params_t params;
p = DrawerYG::Params();
params.m_resourceManager = resourceManager();
params.m_frameBuffer = frameBuffer;
params.m_glyphCacheID = resourceManager()->guiThreadGlyphCacheID();
params.m_threadID = 0;
params.m_skinName = GetPlatform().SkinName();
params.m_visualScale = GetPlatform().VisualScale();
p.m_resourceManager = m_resourceManager;
p.m_frameBuffer = frameBuffer;
p.m_glyphCacheID = m_resourceManager->guiThreadGlyphCacheID();
p.m_threadID = 0;
p.m_skinName = GetPlatform().SkinName();
p.m_visualScale = GetPlatform().VisualScale();
m_tileDrawer = make_shared_ptr(new DrawerYG(params));
m_tileDrawer = make_shared_ptr(new DrawerYG(p));
m_tileDrawer->onSize(tileWidth, tileHeight);
m2::RectI renderRect(1, 1, tileWidth - 1, tileWidth - 1);
@ -57,7 +97,7 @@ void TilingRenderPolicyST::DrawFrame(shared_ptr<PaintEvent> const & e, ScreenBas
{
DrawerYG * pDrawer = e->drawer();
pDrawer->screen()->clear(bgColor());
pDrawer->screen()->clear(m_bgColor);
m_infoLayer.clear();
@ -93,7 +133,7 @@ void TilingRenderPolicyST::DrawFrame(shared_ptr<PaintEvent> const & e, ScreenBas
{
m_tileCache.readUnlock();
shared_ptr<PaintEvent> paintEvent(new PaintEvent(m_tileDrawer.get()));
shared_ptr<yg::gl::BaseTexture> tileTarget = resourceManager()->renderTargets()->Reserve();
shared_ptr<yg::gl::BaseTexture> tileTarget = m_resourceManager->renderTargets()->Reserve();
shared_ptr<yg::InfoLayer> tileInfoLayer(new yg::InfoLayer());
@ -102,10 +142,10 @@ void TilingRenderPolicyST::DrawFrame(shared_ptr<PaintEvent> const & e, ScreenBas
m_tileDrawer->beginFrame();
yg::Color c = bgColor();
yg::Color c = m_bgColor;
m_tileDrawer->clear(yg::Color(c.r, c.g, c.b, 0));
m2::RectI renderRect(1, 1, resourceManager()->tileTextureWidth() - 1, resourceManager()->tileTextureHeight() - 1);
m2::RectI renderRect(1, 1, m_resourceManager->tileTextureWidth() - 1, m_resourceManager->tileTextureHeight() - 1);
m_tileDrawer->screen()->setClipRect(renderRect);
m_tileDrawer->clear(c);
@ -119,18 +159,18 @@ void TilingRenderPolicyST::DrawFrame(shared_ptr<PaintEvent> const & e, ScreenBas
m_tileScreen.PtoG(m2::RectD(renderRect), selectRect);
m_tileScreen.PtoG(m2::Inflate(m2::RectD(renderRect), inflationSize, inflationSize), clipRect);
renderFn()(paintEvent,
m_tileScreen,
selectRect,
clipRect,
ri.m_drawScale);
m_renderFn(paintEvent,
m_tileScreen,
selectRect,
clipRect,
ri.m_drawScale);
m_tileDrawer->endFrame();
m_tileDrawer->screen()->resetInfoLayer();
Tile tile(tileTarget, tileInfoLayer, m_tileScreen, ri, 0);
m_tileCache.writeLock();
m_tileCache.addTile(ri, TileCache::Entry(tile, resourceManager()));
m_tileCache.addTile(ri, TileCache::Entry(tile, m_resourceManager));
m_tileCache.writeUnlock();
m_tileCache.readLock();
@ -146,7 +186,12 @@ void TilingRenderPolicyST::DrawFrame(shared_ptr<PaintEvent> const & e, ScreenBas
m2::RectI(0, 0, tileWidth - 2, tileHeight - 2),
m2::RectU(1, 1, tileWidth - 1, tileHeight - 1));
windowHandle()->invalidate();
m_windowHandle->invalidate();
}
}
}
bool TilingRenderPolicyST::IsTiling() const
{
return true;
}

View file

@ -1,6 +1,7 @@
#pragma once
#include "render_policy.hpp"
#include "drawer_yg.hpp"
#include "tiler.hpp"
#include "tile_cache.hpp"
@ -10,8 +11,16 @@
#include "../geometry/screenbase.hpp"
class DrawerYG;
class WindowHandle;
class VideoTimer;
namespace yg
{
namespace gl
{
class RenderContext;
}
}
class TilingRenderPolicyST : public RenderPolicy
{
@ -27,11 +36,11 @@ private:
public:
TilingRenderPolicyST(shared_ptr<WindowHandle> const & windowHandle,
RenderPolicy::TRenderFn const & renderFn);
void Initialize(shared_ptr<yg::gl::RenderContext> const & renderContext,
shared_ptr<yg::ResourceManager> const & resourceManager);
TilingRenderPolicyST(VideoTimer * videoTimer,
DrawerYG::Params const & params,
shared_ptr<yg::gl::RenderContext> const & primaryRC);
void DrawFrame(shared_ptr<PaintEvent> const & paintEvent, ScreenBase const & screenBase);
bool IsTiling() const;
};

View file

@ -7,7 +7,7 @@
#include <QtGui/QMouseEvent>
#include "../map/framework_factory.hpp"
#include "../map/render_policy.hpp"
using namespace storage;
@ -45,33 +45,21 @@ namespace qt
}
DrawWidget::DrawWidget(QWidget * pParent)
: base_type(pParent),
m_handle(new WindowHandle()),
: QGLWidget(pParent),
m_isInitialized(false),
m_isTimerStarted(false),
m_framework(FrameworkFactory<model_t>::CreateFramework(m_handle, 0)),
m_framework(FrameworkFactory<model_t>::CreateFramework()),
m_isDrag(false),
m_isRotate(false),
m_redrawInterval(100),
m_pScale(0)
{
m_timer = new QTimer(this);
m_handle->setUpdatesEnabled(false);
#ifdef OMIM_OS_MAC
m_videoTimer.reset(CreateAppleVideoTimer(bind(&DrawWidget::DrawFrame, this)));
#else
m_videoTimer.reset(new QtVideoTimer(this, bind(&DrawWidget::DrawFrame, this)));
#endif
m_handle->setVideoTimer(m_videoTimer);
connect(m_timer, SIGNAL(timeout()), this, SLOT(ScaleTimerElapsed()));
}
void DrawWidget::PrepareShutdown()
{
m_videoTimer->stop();
m_framework->PrepareToShutdown();
}
@ -84,7 +72,7 @@ namespace qt
void DrawWidget::UpdateNow()
{
m_framework->Invalidate();
update();
}
void DrawWidget::UpdateAfterSettingsChanged()
@ -98,7 +86,7 @@ namespace qt
if (!Settings::Get("DrawWidgetSize", widthAndHeight))
return false;
m_framework->OnSize(widthAndHeight.first, widthAndHeight.second);
m_framework->OnSize(widthAndHeight.first, widthAndHeight.second);
if (!m_framework->LoadState())
return false;
@ -116,11 +104,6 @@ namespace qt
m_framework->SaveState();
}
//void DrawWidget::ShowFeature(Feature const & p)
//{
// m_framework.ShowFeature(p);
//}
void DrawWidget::MoveLeft()
{
m_framework->Move(math::pi, 0.5);
@ -185,6 +168,15 @@ namespace qt
m_framework->Invalidate();
}
VideoTimer * DrawWidget::CreateVideoTimer()
{
#ifdef OMIM_OS_MAC
return CreateAppleVideoTimer(bind(&DrawWidget::DrawFrame, this));
#else
return new QtVideoTimer(this, bind(&DrawWidget::DrawFrame, this));
#endif
}
void DrawWidget::ScaleChanged(int action)
{
if (action != QAbstractSlider::SliderNoAction)
@ -200,10 +192,49 @@ namespace qt
void DrawWidget::initializeGL()
{
widget_type::initializeGL();
m_handle->setRenderContext(renderContext());
m_framework->InitializeGL(renderContext(), resourceManager());
m_isInitialized = true;
#ifdef OMIM_OS_WINDOWS
win32::InitOpenGL();
#endif
/// we'll perform swap by ourselves, see issue #333
setAutoBufferSwap(false);
if (!m_isInitialized)
{
VideoTimer * videoTimer = CreateVideoTimer();
DrawerYG::Params params;
params.m_frameBuffer = make_shared_ptr(new yg::gl::FrameBuffer(true));
shared_ptr<qt::gl::RenderContext> primaryRC(new qt::gl::RenderContext(this));
m_framework->SetRenderPolicy(CreateRenderPolicy(videoTimer, params, primaryRC));
m_isInitialized = true;
}
}
void DrawWidget::resizeGL(int w, int h)
{
m_framework->OnSize(w, h);
m_framework->Invalidate();
if (m_isInitialized && m_isTimerStarted)
DrawFrame();
UpdateScaleControl();
emit ViewportChanged();
}
void DrawWidget::paintGL()
{
if ((m_isInitialized) && (!m_isTimerStarted))
{
/// timer should be started upon the first repaint
/// request to fully initialized GLWidget.
m_isTimerStarted = true;
m_framework->SetUpdatesEnabled(true);
}
m_framework->Invalidate();
}
void DrawWidget::DrawFrame()
@ -213,7 +244,7 @@ namespace qt
makeCurrent();
m_framework->SetNeedRedraw(false);
shared_ptr<PaintEvent> paintEvent(new PaintEvent(GetDrawer().get()));
shared_ptr<PaintEvent> paintEvent(new PaintEvent(m_framework->GetRenderPolicy()->GetDrawer().get()));
m_framework->BeginPaint(paintEvent);
m_framework->DoPaint(paintEvent);
@ -226,30 +257,6 @@ namespace qt
}
}
void DrawWidget::DoDraw(shared_ptr<screen_t> p)
{
if ((m_isInitialized) && (!m_isTimerStarted))
{
/// timer should be started upon the first repaint
/// request to fully initialized GLWidget.
m_isTimerStarted = true;
m_handle->setUpdatesEnabled(true);
m_handle->invalidate();
}
m_framework->Invalidate();
}
void DrawWidget::DoResize(int w, int h)
{
m_framework->OnSize(w, h);
m_framework->Invalidate();
if (m_isInitialized && m_isTimerStarted)
DrawFrame();
UpdateScaleControl();
emit ViewportChanged();
}
namespace
{
DragEvent get_drag_event(QMouseEvent * e)
@ -266,7 +273,7 @@ namespace qt
void DrawWidget::mousePressEvent(QMouseEvent * e)
{
base_type::mousePressEvent(e);
QGLWidget::mousePressEvent(e);
if (e->button() == Qt::LeftButton)
{
@ -290,7 +297,7 @@ namespace qt
void DrawWidget::mouseDoubleClickEvent(QMouseEvent * e)
{
base_type::mouseDoubleClickEvent(e);
QGLWidget::mouseDoubleClickEvent(e);
if (e->button() == Qt::LeftButton)
{
@ -305,7 +312,7 @@ namespace qt
void DrawWidget::mouseMoveEvent(QMouseEvent * e)
{
base_type::mouseMoveEvent(e);
QGLWidget::mouseMoveEvent(e);
if (m_isDrag)
m_framework->DoDrag(get_drag_event(e));
@ -316,7 +323,7 @@ namespace qt
void DrawWidget::mouseReleaseEvent(QMouseEvent * e)
{
base_type::mouseReleaseEvent(e);
QGLWidget::mouseReleaseEvent(e);
StopDragging(e);
StopRotating(e);
@ -326,7 +333,7 @@ namespace qt
void DrawWidget::keyReleaseEvent(QKeyEvent * e)
{
base_type::keyReleaseEvent(e);
QGLWidget::keyReleaseEvent(e);
StopRotating(e);

View file

@ -17,9 +17,6 @@ namespace qt
{
class QScaleSlider;
/// Replace this to set a draw widget kernel.
typedef GLDrawWidget widget_type;
class DrawWidget;
class QtVideoTimer : public ::VideoTimer
@ -40,22 +37,15 @@ namespace qt
void stop();
};
class DrawWidget : public widget_type
class DrawWidget : public QGLWidget
{
typedef widget_type base_type;
typedef model::FeaturesFetcher model_t;
shared_ptr<WindowHandle> m_handle;
shared_ptr<drawer_t> m_drawer;
bool m_isInitialized;
bool m_isTimerStarted;
typedef model::FeaturesFetcher model_t;
scoped_ptr<Framework<model_t> > m_framework;
shared_ptr<VideoTimer> m_videoTimer;
bool m_isDrag;
bool m_isRotate;
@ -105,14 +95,18 @@ namespace qt
Framework<model_t> & GetFramework() { return *m_framework.get(); }
protected:
VideoTimer * CreateVideoTimer();
static const uint32_t ini_file_version = 0;
protected:
/// @name Overriden from base_type.
//@{
virtual void initializeGL();
virtual void DoDraw(shared_ptr<screen_t> p);
virtual void DoResize(int w, int h);
virtual void resizeGL(int w, int h);
virtual void paintGL();
//@}
void DrawFrame();

View file

@ -5,6 +5,7 @@
#include "../yg/resource_manager.hpp"
class DrawerYG;
class VideoTimer;
namespace yg
{
@ -19,10 +20,12 @@ namespace qt
/// Widget uses yg for drawing.
class GLDrawWidget : public GLDrawWidgetT<DrawerYG>
{
typedef GLDrawWidgetT<DrawerYG> base_type;
shared_ptr<yg::gl::RenderContext> m_renderContext;
protected:
shared_ptr<yg::ResourceManager> m_resourceManager;
public:

View file

@ -88,10 +88,10 @@ namespace yg
shared_ptr<FreeStorage> freeStorage(new FreeStorage());
freeStorage->m_storage = pipeline.m_storage;
if (pipeline.m_hasStorage)
{
freeStorage->m_storage = pipeline.m_storage;
if (pipeline.m_useTinyStorage)
freeStorage->m_storagePool = resourceManager()->tinyStorages();
else
@ -102,9 +102,9 @@ namespace yg
pipeline.m_hasStorage = false;
pipeline.m_storage = Storage();
}
processCommand(freeStorage);
processCommand(freeStorage);
}
}
void GeometryBatcher::setAdditionalSkinPage(shared_ptr<SkinPage> const & p)