diff options
author | Julian Rex <julian.rex@mapbox.com> | 2019-09-10 11:11:10 -0400 |
---|---|---|
committer | Julian Rex <julian.rex@mapbox.com> | 2019-09-10 11:11:10 -0400 |
commit | c9d2a248db9fe70cdb6982986d1d9035836f03ec (patch) | |
tree | eef2c99809a2cb8d202c88c79c4d07bbd8811598 | |
parent | 2afda968c77d776671db86183c3f6ea3a55ffcb3 (diff) | |
download | qtlocation-mapboxgl-upstream/15342-performance-investigation.tar.gz |
add test controller from ticketupstream/15342-performance-investigation
-rw-r--r-- | platform/ios/app/Main.storyboard | 29 | ||||
-rw-r--r-- | platform/ios/app/bugcontroller.swift | 51 | ||||
-rw-r--r-- | platform/ios/app/iosapp-Bridging-Header.h | 4 | ||||
-rw-r--r-- | platform/ios/ios.xcodeproj/project.pbxproj | 21 |
4 files changed, 96 insertions, 9 deletions
diff --git a/platform/ios/app/Main.storyboard b/platform/ios/app/Main.storyboard index 28316745a1..ca80a6de93 100644 --- a/platform/ios/app/Main.storyboard +++ b/platform/ios/app/Main.storyboard @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> -<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14810.11" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="PSe-Ot-7Ff"> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14865.1" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="tHL-Oi-BpP"> <device id="retina4_7" orientation="portrait" appearance="light"/> <dependencies> <deployment identifier="iOS"/> - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14766.13"/> + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14819.2"/> <capability name="Safe area layout guides" minToolsVersion="9.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> </dependencies> @@ -13,11 +13,11 @@ <objects> <viewController id="WaX-pd-UZQ" userLabel="Map View Controller" customClass="MBXViewController" sceneMemberID="viewController"> <view key="view" contentMode="scaleToFill" id="Z9X-fc-PUC"> - <rect key="frame" x="0.0" y="0.0" width="203" height="33"/> + <rect key="frame" x="0.0" y="0.0" width="375" height="667"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="kNe-zV-9ha" customClass="MGLMapView"> - <rect key="frame" x="0.0" y="0.0" width="203" height="33"/> + <rect key="frame" x="0.0" y="0.0" width="375" height="667"/> <subviews> <button hidden="YES" opaque="NO" userInteractionEnabled="NO" alpha="0.69999999999999996" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="tailTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="58y-pX-YyB"> <rect key="frame" x="8" y="82" width="40" height="20"/> @@ -38,7 +38,7 @@ </userDefinedRuntimeAttributes> </button> <view hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="BHE-Wn-x69" customClass="MBXFrameTimeGraphView"> - <rect key="frame" x="0.0" y="-167" width="203" height="200"/> + <rect key="frame" x="0.0" y="467" width="375" height="200"/> <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <accessibility key="accessibilityConfiguration"> <accessibilityTraits key="traits" notEnabled="YES"/> @@ -83,8 +83,8 @@ <action selector="showSettings:" destination="WaX-pd-UZQ" id="X2C-Ee-Qvt"/> </connections> </barButtonItem> - <button key="titleView" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="KsN-ny-Hou"> - <rect key="frame" x="65" y="5.5" width="203" height="33"/> + <button key="titleView" opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="KsN-ny-Hou"> + <rect key="frame" x="89" y="5.5" width="148" height="33"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <fontDescription key="fontDescription" type="system" weight="medium" pointSize="17"/> <state key="normal" title="Streets"/> @@ -214,6 +214,21 @@ </objects> <point key="canvasLocation" x="2075" y="350"/> </scene> + <!--Test Map Controller--> + <scene sceneID="dw9-U4-WzK"> + <objects> + <viewController id="tHL-Oi-BpP" customClass="TestMapController" customModule="Mapbox_GL" customModuleProvider="target" sceneMemberID="viewController"> + <view key="view" contentMode="scaleToFill" id="94r-fl-IxZ"> + <rect key="frame" x="0.0" y="0.0" width="375" height="667"/> + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> + <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/> + <viewLayoutGuide key="safeArea" id="HbG-cM-FKq"/> + </view> + </viewController> + <placeholder placeholderIdentifier="IBFirstResponder" id="AxF-Wz-euB" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/> + </objects> + <point key="canvasLocation" x="747" y="-474"/> + </scene> <!--Navigation Controller--> <scene sceneID="LFg-oU-zTK"> <objects> diff --git a/platform/ios/app/bugcontroller.swift b/platform/ios/app/bugcontroller.swift new file mode 100644 index 0000000000..85139d9545 --- /dev/null +++ b/platform/ios/app/bugcontroller.swift @@ -0,0 +1,51 @@ +// From https://github.com/mapbox/mapbox-gl-native/issues/15342#issue-478458025 +import Foundation +import Mapbox + +class TestMapController: UIViewController, MGLMapViewDelegate { + + var mapView: MGLMapView! + + override func viewDidLoad() { + super.viewDidLoad() + + mapView = MGLMapView(frame: view.bounds, styleURL: MGLStyle.lightStyleURL) + mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] + mapView.tintColor = .darkGray + mapView.delegate = self + view.addSubview(mapView) + + } + + func mapView(_ mapView: MGLMapView, didFinishLoading style: MGLStyle) { + let source = MGLShapeSource(identifier: "pictures", features: [], options: nil) + let blueBoxImage = TestMapController.singleColoredImage(of: .blue, and: CGSize(width: 50, height: 50)) + style.setImage(blueBoxImage, forName: "picture") + let layer = TestMapController.getLayer(for: source) + style.addSource(source) + style.addLayer(layer) + } + + static func singleColoredImage(of color: UIColor, and size: CGSize) -> UIImage { + let format = UIGraphicsImageRendererFormat() + return UIGraphicsImageRenderer(size: size, format: format).image { (context) in + color.setFill() + context.fill(CGRect(origin: .zero, size: size)) + } + } + + static func getLayer(for source: MGLShapeSource) -> MGLStyleLayer { + let layer = MGLSymbolStyleLayer(identifier: "pictures", source: source) + layer.iconAllowsOverlap = NSExpression(forConstantValue: true) + layer.minimumZoomLevel = 6.0 + let nameOfPictures = "picture" + let matching = "'\(nameOfPictures)', '\(nameOfPictures)'" + let formatImageName = "MGL_MATCH(highlight, \(matching), '\(nameOfPictures)')" + let functionImage = NSExpression(format: formatImageName) + layer.iconImageName = functionImage + layer.keepsIconUpright = NSExpression(forConstantValue: 1) + let formatScale = "mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'exponential', 1, %@)" + layer.iconScale = NSExpression(format: formatScale, [6: 0.3, 11: 0.6, 14: 0.88]) + return layer + } +} diff --git a/platform/ios/app/iosapp-Bridging-Header.h b/platform/ios/app/iosapp-Bridging-Header.h new file mode 100644 index 0000000000..1b2cb5d6d0 --- /dev/null +++ b/platform/ios/app/iosapp-Bridging-Header.h @@ -0,0 +1,4 @@ +// +// Use this file to import your target's public headers that you would like to expose to Swift. +// + diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj index 5a5cb00b49..b39c30009d 100644 --- a/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/ios.xcodeproj/project.pbxproj @@ -516,6 +516,7 @@ CA7766832229C10E0008DE9E /* MGLCompactCalloutView.m in Sources */ = {isa = PBXBuildFile; fileRef = DA8848451CBAFB9800AB86E3 /* MGLCompactCalloutView.m */; }; CA7766842229C11A0008DE9E /* SMCalloutView.m in Sources */ = {isa = PBXBuildFile; fileRef = DA88488A1CBB037E00AB86E3 /* SMCalloutView.m */; }; CA86FF0E22D8D5A0009EB14A /* MGLNetworkConfigurationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CA86FF0D22D8D5A0009EB14A /* MGLNetworkConfigurationTests.m */; }; + CA87D9202327ED3B0060A6FF /* bugcontroller.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA87D91F2327ED3B0060A6FF /* bugcontroller.swift */; }; CA88DC3021C85D900059ED5A /* MGLStyleURLIntegrationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CA88DC2F21C85D900059ED5A /* MGLStyleURLIntegrationTest.m */; }; CA8FBC0921A47BB100D1203C /* MGLRendererConfigurationTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = CA8FBC0821A47BB100D1203C /* MGLRendererConfigurationTests.mm */; }; CAA69DA4206DCD0E007279CD /* Mapbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA4A26961CB6E795000B7809 /* Mapbox.framework */; }; @@ -1201,8 +1202,9 @@ CA55CD3E202C16AA00CE7095 /* MGLCameraChangeReason.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLCameraChangeReason.h; sourceTree = "<group>"; }; CA5E5042209BDC5F001A8A81 /* MGLTestUtility.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = MGLTestUtility.h; path = ../../darwin/test/MGLTestUtility.h; sourceTree = "<group>"; }; CA65C4F721E9BB080068B0D4 /* MGLCluster.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLCluster.h; sourceTree = "<group>"; }; - CA86FF0D22D8D5A0009EB14A /* MGLNetworkConfigurationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLNetworkConfigurationTests.m; sourceTree = "<group>"; }; CA6914B420E67F50002DB0EE /* MGLAnnotationViewIntegrationTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLAnnotationViewIntegrationTests.mm; path = "Annotation Tests/MGLAnnotationViewIntegrationTests.mm"; sourceTree = "<group>"; }; + CA86FF0D22D8D5A0009EB14A /* MGLNetworkConfigurationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLNetworkConfigurationTests.m; sourceTree = "<group>"; }; + CA87D91F2327ED3B0060A6FF /* bugcontroller.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = bugcontroller.swift; sourceTree = "<group>"; }; CA88DC2F21C85D900059ED5A /* MGLStyleURLIntegrationTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLStyleURLIntegrationTest.m; sourceTree = "<group>"; }; CA8FBC0821A47BB100D1203C /* MGLRendererConfigurationTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLRendererConfigurationTests.mm; path = ../../darwin/test/MGLRendererConfigurationTests.mm; sourceTree = "<group>"; }; CAD9D0A922A86D6F001B25EE /* MGLResourceTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLResourceTests.mm; path = ../../darwin/test/MGLResourceTests.mm; sourceTree = "<group>"; }; @@ -1966,6 +1968,7 @@ DA1DC94C1CB6C1C2006E619F /* Demo App */ = { isa = PBXGroup; children = ( + CA87D91F2327ED3B0060A6FF /* bugcontroller.swift */, 3E6465D52065767A00685536 /* LimeGreenStyleLayer.h */, 3E6465D42065767A00685536 /* LimeGreenStyleLayer.m */, DA1DC9501CB6C1C2006E619F /* MBXAppDelegate.h */, @@ -2982,7 +2985,7 @@ DA1DC9491CB6C1C2006E619F = { CreatedOnToolsVersion = 7.3; DevelopmentTeam = GJZR2MEM28; - LastSwiftMigration = 0820; + LastSwiftMigration = 1100; }; DA2E88501CC036F400F24E7B = { CreatedOnToolsVersion = 7.3; @@ -3220,6 +3223,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + CA87D9202327ED3B0060A6FF /* bugcontroller.swift in Sources */, DA1DC9971CB6E046006E619F /* main.m in Sources */, 354B839C1D2E9B48005D9406 /* MBXUserLocationAnnotationView.m in Sources */, 965DF51120F9430500438AAC /* MBXFrameTimeGraphView.m in Sources */, @@ -3949,11 +3953,15 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ANALYZER_LOCALIZABILITY_EMPTY_CONTEXT = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = NO; + CLANG_ENABLE_MODULES = YES; DEVELOPMENT_TEAM = GJZR2MEM28; INFOPLIST_FILE = "$(SRCROOT)/app/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGL; PRODUCT_NAME = "Mapbox GL"; + SWIFT_OBJC_BRIDGING_HEADER = "app/iosapp-Bridging-Header.h"; + SWIFT_VERSION = 5.0; }; name = RelWithDebInfo; }; @@ -4301,11 +4309,16 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ANALYZER_LOCALIZABILITY_EMPTY_CONTEXT = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = NO; + CLANG_ENABLE_MODULES = YES; DEVELOPMENT_TEAM = GJZR2MEM28; INFOPLIST_FILE = "$(SRCROOT)/app/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGL; PRODUCT_NAME = "Mapbox GL"; + SWIFT_OBJC_BRIDGING_HEADER = "app/iosapp-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -4315,11 +4328,15 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ANALYZER_LOCALIZABILITY_EMPTY_CONTEXT = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = NO; + CLANG_ENABLE_MODULES = YES; DEVELOPMENT_TEAM = GJZR2MEM28; INFOPLIST_FILE = "$(SRCROOT)/app/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGL; PRODUCT_NAME = "Mapbox GL"; + SWIFT_OBJC_BRIDGING_HEADER = "app/iosapp-Bridging-Header.h"; + SWIFT_VERSION = 5.0; }; name = Release; }; |