diff options
Diffstat (limited to 'iphone')
-rw-r--r-- | iphone/Maps/Classes/EAGLView.h | 10 | ||||
-rw-r--r-- | iphone/Maps/Classes/EAGLView.mm | 16 | ||||
-rw-r--r-- | iphone/Maps/Classes/iosOGLContext.h | 14 | ||||
-rw-r--r-- | iphone/Maps/Classes/iosOGLContext.mm | 28 | ||||
-rw-r--r-- | iphone/Maps/Classes/iosOGLContextFactory.h | 4 | ||||
-rw-r--r-- | iphone/Maps/Classes/iosOGLContextFactory.mm | 7 |
6 files changed, 59 insertions, 20 deletions
diff --git a/iphone/Maps/Classes/EAGLView.h b/iphone/Maps/Classes/EAGLView.h index 94eaf07698..6387091a5c 100644 --- a/iphone/Maps/Classes/EAGLView.h +++ b/iphone/Maps/Classes/EAGLView.h @@ -1,8 +1,11 @@ #import "MWMMapWidgets.h" -#include "../../std/shared_ptr.hpp" -#include "../../indexer/map_style.hpp" -#include "../../drape/pointers.hpp" +#include "drape/pointers.hpp" +#include "drape/drape_global.hpp" + +#include "indexer/map_style.hpp" + +#include "std/shared_ptr.hpp" namespace dp { @@ -14,6 +17,7 @@ namespace dp // Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel. @interface EAGLView : UIView { + dp::ApiVersion m_apiVersion; drape_ptr<dp::ThreadSafeFactory> m_factory; // Do not call onSize from layoutSubViews when real size wasn't changed. // It's possible when we add/remove subviews (bookmark balloons) and it hangs the map without this check diff --git a/iphone/Maps/Classes/EAGLView.mm b/iphone/Maps/Classes/EAGLView.mm index 0a498b13b6..beac617528 100644 --- a/iphone/Maps/Classes/EAGLView.mm +++ b/iphone/Maps/Classes/EAGLView.mm @@ -59,9 +59,22 @@ double getExactDPI(double contentScaleFactor) return self; } +- (dp::ApiVersion)getSupportedApiVersion +{ + dp::ApiVersion apiVersion = dp::ApiVersion::OpenGLES2; + EAGLContext * tempContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3]; + if (tempContext != nil) + { + tempContext = nil; + apiVersion = dp::ApiVersion::OpenGLES3; + } + return apiVersion; +} + - (void)initialize { lastViewSize = CGRectZero; + m_apiVersion = [self getSupportedApiVersion]; // Setup Layer Properties CAEAGLLayer * eaglLayer = (CAEAGLLayer *)self.layer; @@ -73,7 +86,7 @@ double getExactDPI(double contentScaleFactor) // Correct retina display support in opengl renderbuffer self.contentScaleFactor = [[UIScreen mainScreen] nativeScale]; - m_factory = make_unique_dp<dp::ThreadSafeFactory>(new iosOGLContextFactory(eaglLayer)); + m_factory = make_unique_dp<dp::ThreadSafeFactory>(new iosOGLContextFactory(eaglLayer, m_apiVersion)); } - (void)createDrapeEngineWithWidth:(int)width height:(int)height @@ -81,6 +94,7 @@ double getExactDPI(double contentScaleFactor) LOG(LINFO, ("EAGLView createDrapeEngine Started")); Framework::DrapeCreationParams p; + p.m_apiVersion = m_apiVersion; p.m_surfaceWidth = width; p.m_surfaceHeight = height; p.m_visualScale = dp::VisualScale(getExactDPI(self.contentScaleFactor)); diff --git a/iphone/Maps/Classes/iosOGLContext.h b/iphone/Maps/Classes/iosOGLContext.h index a6e64e8f16..408e041dcf 100644 --- a/iphone/Maps/Classes/iosOGLContext.h +++ b/iphone/Maps/Classes/iosOGLContext.h @@ -1,17 +1,18 @@ #pragma once -#import "drape/oglcontext.hpp" +#include "drape/drape_global.hpp" +#include "drape/oglcontext.hpp" +#include "drape/glIncludes.hpp" #import <QuartzCore/CAEAGLLayer.h> -#import <OpenGLES/ES2/gl.h> -#import <OpenGLES/ES2/glext.h> -#include "std/atomic.hpp" +#include <atomic> class iosOGLContext : public dp::OGLContext { public: - iosOGLContext(CAEAGLLayer * layer, iosOGLContext * contextToShareWith, bool needBuffers = false); + iosOGLContext(CAEAGLLayer * layer, dp::ApiVersion apiVersion, + iosOGLContext * contextToShareWith, bool needBuffers = false); ~iosOGLContext(); virtual void makeCurrent(); @@ -22,6 +23,7 @@ public: void setPresentAvailable(bool available); private: + dp::ApiVersion m_apiVersion; CAEAGLLayer * m_layer; EAGLContext * m_nativeContext; @@ -37,5 +39,5 @@ private: GLuint m_frameBufferId; //@} buffers - atomic<bool> m_presentAvailable; + std::atomic<bool> m_presentAvailable; }; diff --git a/iphone/Maps/Classes/iosOGLContext.mm b/iphone/Maps/Classes/iosOGLContext.mm index 74e81a5cd3..f7e3ee403c 100644 --- a/iphone/Maps/Classes/iosOGLContext.mm +++ b/iphone/Maps/Classes/iosOGLContext.mm @@ -4,8 +4,10 @@ #import "drape/glfunctions.hpp" -iosOGLContext::iosOGLContext(CAEAGLLayer * layer, iosOGLContext * contextToShareWith, bool needBuffers) - : m_layer(layer) +iosOGLContext::iosOGLContext(CAEAGLLayer * layer, dp::ApiVersion apiVersion, + iosOGLContext * contextToShareWith, bool needBuffers) + : m_apiVersion(apiVersion) + , m_layer(layer) , m_nativeContext(NULL) , m_needBuffers(needBuffers) , m_hasBuffers(false) @@ -14,13 +16,21 @@ iosOGLContext::iosOGLContext(CAEAGLLayer * layer, iosOGLContext * contextToShare , m_frameBufferId(0) , m_presentAvailable(true) { + EAGLRenderingAPI api; + if (m_apiVersion == dp::ApiVersion::OpenGLES3) + api = kEAGLRenderingAPIOpenGLES3; + else + api = kEAGLRenderingAPIOpenGLES2; + if (contextToShareWith != NULL) { - m_nativeContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2 + m_nativeContext = [[EAGLContext alloc] initWithAPI:api sharegroup: contextToShareWith->m_nativeContext.sharegroup]; } else - m_nativeContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; + { + m_nativeContext = [[EAGLContext alloc] initWithAPI:api]; + } } iosOGLContext::~iosOGLContext() @@ -47,14 +57,20 @@ void iosOGLContext::present() ASSERT(m_nativeContext != NULL, ()); ASSERT(m_renderBufferId, ()); GLenum const discards[] = { GL_DEPTH_ATTACHMENT, GL_COLOR_ATTACHMENT0 }; - GLCHECK(glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards)); + if (m_apiVersion == dp::ApiVersion::OpenGLES3) + GLCHECK(glInvalidateFramebuffer(GL_FRAMEBUFFER, 1, discards)); + else + GLCHECK(glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards)); glBindRenderbuffer(GL_RENDERBUFFER, m_renderBufferId); if (m_presentAvailable) [m_nativeContext presentRenderbuffer: GL_RENDERBUFFER]; - GLCHECK(glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards + 1)); + if (m_apiVersion == dp::ApiVersion::OpenGLES3) + GLCHECK(glInvalidateFramebuffer(GL_FRAMEBUFFER, 1, discards + 1)); + else + GLCHECK(glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards + 1)); } void iosOGLContext::setDefaultFramebuffer() diff --git a/iphone/Maps/Classes/iosOGLContextFactory.h b/iphone/Maps/Classes/iosOGLContextFactory.h index 385eb63a25..8c0346d856 100644 --- a/iphone/Maps/Classes/iosOGLContextFactory.h +++ b/iphone/Maps/Classes/iosOGLContextFactory.h @@ -3,6 +3,7 @@ #import "iosOGLContext.h" #include "drape/oglcontextfactory.hpp" +#include "drape/drape_global.hpp" #include "std/condition_variable.hpp" #include "std/mutex.hpp" @@ -10,7 +11,7 @@ class iosOGLContextFactory: public dp::OGLContextFactory { public: - iosOGLContextFactory(CAEAGLLayer * layer); + iosOGLContextFactory(CAEAGLLayer * layer, dp::ApiVersion apiVersion); ~iosOGLContextFactory(); dp::OGLContext * getDrawContext() override; @@ -25,6 +26,7 @@ public: private: CAEAGLLayer * m_layer; + dp::ApiVersion m_apiVersion; iosOGLContext * m_drawContext; iosOGLContext * m_uploadContext; diff --git a/iphone/Maps/Classes/iosOGLContextFactory.mm b/iphone/Maps/Classes/iosOGLContextFactory.mm index 23f8cb4a2a..69d0bf8e26 100644 --- a/iphone/Maps/Classes/iosOGLContextFactory.mm +++ b/iphone/Maps/Classes/iosOGLContextFactory.mm @@ -1,7 +1,8 @@ #import "iosOGLContextFactory.h" -iosOGLContextFactory::iosOGLContextFactory(CAEAGLLayer * layer) +iosOGLContextFactory::iosOGLContextFactory(CAEAGLLayer * layer, dp::ApiVersion apiVersion) : m_layer(layer) + , m_apiVersion(apiVersion) , m_drawContext(nullptr) , m_uploadContext(nullptr) , m_isInitialized(false) @@ -16,14 +17,14 @@ iosOGLContextFactory::~iosOGLContextFactory() dp::OGLContext * iosOGLContextFactory::getDrawContext() { if (m_drawContext == nullptr) - m_drawContext = new iosOGLContext(m_layer, m_uploadContext, true); + m_drawContext = new iosOGLContext(m_layer, m_apiVersion, m_uploadContext, true); return m_drawContext; } dp::OGLContext * iosOGLContextFactory::getResourcesUploadContext() { if (m_uploadContext == nullptr) - m_uploadContext = new iosOGLContext(m_layer, m_drawContext, false); + m_uploadContext = new iosOGLContext(m_layer, m_apiVersion, m_drawContext, false); return m_uploadContext; } |