[fix] [ios] Added iOS 10.3+ Metal driver handling.

This commit is contained in:
Ilya Grechuhin 2017-06-30 10:32:17 +03:00 committed by Sergey Yershov
parent 2b9e17f4f7
commit 98d8c380ab
3 changed files with 18 additions and 7 deletions

View file

@ -560,7 +560,7 @@ using namespace osm_auth_ios;
auto & f = GetFramework();
// On some devices we have to free all belong-to-graphics memory
// because of new OpenGL driver powered by Metal.
if ([AppInfo sharedInfo].isMetalDriver)
if ([AppInfo sharedInfo].openGLDriver == MWMOpenGLDriverMetalPre103)
{
f.SetRenderingDisabled(true);
f.OnDestroyGLContext();
@ -610,7 +610,7 @@ using namespace osm_auth_ios;
f.SetRenderingEnabled();
// On some devices we have to free all belong-to-graphics memory
// because of new OpenGL driver powered by Metal.
if ([AppInfo sharedInfo].isMetalDriver)
if ([AppInfo sharedInfo].openGLDriver == MWMOpenGLDriverMetalPre103)
{
m2::PointU const size = ((EAGLView *)self.mapViewController.view).pixelSize;
f.OnRecoverGLContext(static_cast<int>(size.x), static_cast<int>(size.y));

View file

@ -1,5 +1,11 @@
#import <Foundation/Foundation.h>
typedef NS_ENUM(NSInteger, MWMOpenGLDriver) {
MWMOpenGLDriverRegular,
MWMOpenGLDriverMetalPre103, // iOS 10..10.3
MWMOpenGLDriverMetal
};
@interface AppInfo : NSObject
+ (instancetype)sharedInfo;
@ -14,6 +20,6 @@
@property(nonatomic, readonly) NSString * twoLetterLanguageId;
@property(nonatomic, readonly) NSDate * buildDate;
@property(nonatomic, readonly) NSString * deviceName;
@property(nonatomic, readonly) BOOL isMetalDriver;
@property(nonatomic, readonly) MWMOpenGLDriver openGLDriver;
@end

View file

@ -242,16 +242,21 @@ NSDictionary * const kDeviceNamesWithMetalDriver = @{
return _deviceName;
}
- (BOOL)isMetalDriver
- (MWMOpenGLDriver)openGLDriver
{
struct utsname systemInfo;
uname(&systemInfo);
NSString * machine = @(systemInfo.machine);
if (kDeviceNamesBeforeMetalDriver[machine] != nil)
return NO;
return MWMOpenGLDriverRegular;
if (kDeviceNamesWithiOS10MetalDriver[machine] != nil)
return !isIOSVersionLessThan(10);
return YES;
{
if (isIOSVersionLessThan(10))
return MWMOpenGLDriverRegular;
else if (isIOSVersionLessThan(@"10.3"))
return MWMOpenGLDriverMetalPre103;
}
return MWMOpenGLDriverMetal;
}
@end