diff --git a/iphone/Maps/Classes/EAGLView.h b/iphone/Maps/Classes/EAGLView.h index 59781fa9ef..4a24c4e958 100644 --- a/iphone/Maps/Classes/EAGLView.h +++ b/iphone/Maps/Classes/EAGLView.h @@ -4,9 +4,12 @@ #import #import #import "MapViewController.h" + #include "../../std/shared_ptr.hpp" #include "../../map/drawer_yg.hpp" -#include"RenderBuffer.hpp" +#include "../../map/framework.hpp" +#include "../../map/feature_vec_model.hpp" +#include "RenderBuffer.hpp" namespace iphone { @@ -23,6 +26,8 @@ namespace yg } } +typedef Framework framework_t; + // This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass. // The view content is basically an EAGL surface you render your OpenGL scene into. // Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel. @@ -45,7 +50,7 @@ namespace yg - (void)drawViewOnMainThread; @property (nonatomic, assign) CADisplayLink * displayLink; -@property (nonatomic, assign) MapViewController * controller; +@property (nonatomic, assign) framework_t * framework; @property (nonatomic, assign) shared_ptr windowHandle; @property (nonatomic, assign) shared_ptr drawer; @property (nonatomic, assign) shared_ptr renderContext; diff --git a/iphone/Maps/Classes/EAGLView.mm b/iphone/Maps/Classes/EAGLView.mm index cf0cb9f7ad..cfc3804590 100644 --- a/iphone/Maps/Classes/EAGLView.mm +++ b/iphone/Maps/Classes/EAGLView.mm @@ -18,7 +18,7 @@ bool _inRepaint = false; @implementation EAGLView -@synthesize controller; +@synthesize framework; @synthesize windowHandle; @synthesize drawer; @synthesize renderContext; @@ -157,6 +157,7 @@ bool _inRepaint = false; - (void)onSize:(int)width withHeight:(int)height { + framework->OnSize(width, height); /// free old video memory frameBuffer->resetRenderTarget(); renderBuffer.reset(); @@ -168,7 +169,6 @@ bool _inRepaint = false; frameBuffer->onSize(width, height); drawer->onSize(width, height); - drawer->screen()->beginFrame(); drawer->screen()->clear(); drawer->screen()->endFrame(); @@ -176,15 +176,15 @@ bool _inRepaint = false; - (void)drawView { - [controller drawFrame]; - /*if (windowHandle->needRedraw()) + shared_ptr pe(new PaintEvent(drawer.get())); + if (windowHandle->needRedraw()) { windowHandle->setNeedRedraw(false); - [controller beginPaint]; - [controller doPaint]; - renderBuffer->present(); - [controller endPaint]; - }*/ + framework->BeginPaint(pe); + framework->DoPaint(pe); + renderBuffer->present(); + framework->EndPaint(pe); + } } - (void)drawViewThunk:(id)obj @@ -201,7 +201,6 @@ bool _inRepaint = false; { CGFloat const scale = self.contentScaleFactor; CGSize const s = self.frame.size; - [controller onResize:s.width * scale withHeight:s.height * scale]; [self onSize:s.width * scale withHeight:s.height * scale]; } diff --git a/iphone/Maps/Classes/MapViewController.h b/iphone/Maps/Classes/MapViewController.h index c4efc7e25e..392db6822e 100644 --- a/iphone/Maps/Classes/MapViewController.h +++ b/iphone/Maps/Classes/MapViewController.h @@ -29,9 +29,6 @@ - (void) ZoomToRect: (m2::RectD const &) rect; -- (void) onResize: (GLint)width withHeight: (GLint)height; -- (void) drawFrame; - - (void) SetupMeasurementSystem; // called when app is terminated by system diff --git a/iphone/Maps/Classes/MapViewController.mm b/iphone/Maps/Classes/MapViewController.mm index 34ea370a84..53072cb65f 100644 --- a/iphone/Maps/Classes/MapViewController.mm +++ b/iphone/Maps/Classes/MapViewController.mm @@ -118,13 +118,17 @@ storage::Storage m_storage; { if ((self = [super initWithCoder:coder])) { - [(EAGLView*)self.view setController : self]; + // 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 = [(EAGLView*)self.view windowHandle]; shared_ptr resourceManager = [(EAGLView*)self.view resourceManager]; m_framework = FrameworkFactory::CreateFramework(windowHandle, 40); m_framework->InitStorage(m_storage); + v.framework = m_framework; + m_StickyThreshold = 10; m_CurrentAction = NOTHING; @@ -143,11 +147,6 @@ storage::Storage m_storage; return self; } -- (void)onResize:(GLint) width withHeight:(GLint) height -{ - m_framework->OnSize(width, height); -} - NSInteger compareAddress(id l, id r, void * context) { return l < r; @@ -281,24 +280,6 @@ NSInteger compareAddress(id l, id r, void * context) m_framework->Scale(0.5); } -- (void)drawFrame -{ - EAGLView * v = (EAGLView*)self.view; - boost::shared_ptr wh = [v windowHandle]; - boost::shared_ptr rb = [v renderBuffer]; - shared_ptr drawer = [v drawer]; - shared_ptr pe(new PaintEvent(drawer.get())); - - if (wh->needRedraw()) - { - wh->setNeedRedraw(false); - m_framework->BeginPaint(pe); - m_framework->DoPaint(pe); - rb->present(); - m_framework->EndPaint(pe); - } -} - - (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation { return YES; // We support all orientations