Skip to content

Commit e191d8b

Browse files
ArtemStepukgithub-actions[bot]
authored andcommitted
[iOS][Maps] MBXImage instead of __MBXImage (#12742)
GitOrigin-RevId: 5ed75762416aac809f072cfc051d5dd9e730fbd3
1 parent 4ea1162 commit e191d8b

6 files changed

Lines changed: 41 additions & 7 deletions

File tree

LICENSE.md

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Sources/MapboxMaps/Foundation/CoreAliases.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ typealias CoreScreenCoordinate = MapboxCoreMaps_Private.__ScreenCoordinate
2020
typealias CoreScreenBox = MapboxCoreMaps_Private.ScreenBox
2121
typealias CoreEdgeInsets = MapboxCoreMaps_Private.__EdgeInsets
2222
typealias CoreTileCoverOptions = MapboxCoreMaps_Private.TileCoverOptions
23-
typealias CoreMapsImage = MapboxCoreMaps_Private.__MBXImage
23+
typealias CoreMapsImage = MapboxCoreMaps.MBXImage
2424
typealias CoreCustomRasterSourceTileData = MapboxCoreMaps_Private.CustomRasterSourceTileData
2525
typealias CoreStyleManager = MapboxCoreMaps_Private.StyleManager
2626
typealias CoreGeoJSONSourceData = MapboxCoreMaps_Private.GeoJSONSourceData

Sources/MapboxMaps/Snapshot/Snapshotter.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public class Snapshotter: StyleManager {
142142
coordinateForPoint: coordinateForPoint
143143
)
144144
guard let mbmImage = mbmImage,
145-
let uiImage = UIImage(mbmImage: mbmImage, scale: scale) else {
145+
let uiImage = UIImage(mbmImage: MBXImage.Marshaller.toSwift(mbmImage), scale: scale) else {
146146
completion(.failure(.snapshotFailed(reason: "Could not convert internal Image type to UIImage.")))
147147
return
148148
}

Sources/MapboxMaps/Style/ColorTheme.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ extension ColorTheme {
8989
if let base64 {
9090
return .fromStylePropertyValue(StylePropertyValue.Marshaller.toObjc(base64))
9191
} else if let uiimage, let coreImage = CoreMapsImage(uiImage: uiimage) {
92-
return .fromImage(coreImage)
92+
return .fromImage(MBXImage.Marshaller.toObjc(coreImage))
9393
} else {
9494
return nil
9595
}
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
@_spi(Internal) import MapboxCoreMaps
1+
@_implementationOnly import MapboxCoreMaps_Private
2+
@_spi(Marshalling) @_spi(Internal) import MapboxCoreMaps
23
import UIKit
34

45
extension CustomRasterSourceTileData {
56
/// Raster content of the tile. If an empty image is provided then the tile gets removed from the map.
6-
public var image: UIImage? { __image.flatMap { UIImage(mbmImage: $0) } }
7+
public var image: UIImage? { __image.flatMap { UIImage(mbmImage: MBXImage.Marshaller.toSwift($0)) } }
78

89
/// Creates a raster source tile data.
910
/// - Parameters:
1011
/// - tileId: Cannonical tile id.
1112
/// - image: Raster content of the tile.
1213
public convenience init(tileId: CanonicalTileID, image: UIImage?) {
13-
self.init(tileId: tileId, image: image.flatMap { CoreMapsImage(uiImage: $0) })
14+
self.init(tileId: tileId,
15+
image: image
16+
.flatMap { CoreMapsImage(uiImage: $0) }
17+
.flatMap { (image: CoreMapsImage) -> MapboxCoreMaps_Private.__MBXImage in MBXImage.Marshaller.toObjc(image) }
18+
)
1419
}
1520
}

Sources/MapboxMaps/Style/StyleManagerProtocol.swift

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import Foundation
22
@_implementationOnly import MapboxCommon_Private
3+
@_implementationOnly import MapboxCoreMaps_Private
4+
@_spi(Marshalling) import MapboxCoreMaps
35

46
struct RuntimeStylingCallbacks {
57
typealias Action = () -> Void
@@ -231,6 +233,33 @@ internal protocol StyleManagerProtocol {
231233
// MARK: Conformance
232234

233235
extension CoreStyleManager: StyleManagerProtocol {
236+
func getStyleImage(forImageId imageId: String) -> CoreMapsImage? {
237+
let image: MapboxCoreMaps_Private.__MBXImage? = getStyleImage(forImageId: imageId)
238+
return image.flatMap { MBXImage.Marshaller.toSwift($0) }
239+
}
240+
241+
func updateStyleImageSourceImage(forSourceId sourceId: String, image: CoreMapsImage) -> Expected<NSNull, NSString> {
242+
let image: MapboxCoreMaps_Private.__MBXImage = MBXImage.Marshaller.toObjc(image)
243+
return updateStyleImageSourceImage(
244+
forSourceId: sourceId,
245+
image: image
246+
)
247+
}
248+
249+
// swiftlint:disable:next function_parameter_count
250+
func addStyleImage(forImageId imageId: String, scale: Float, image: CoreMapsImage, sdf: Bool, stretchX: [ImageStretches], stretchY: [ImageStretches], content: ImageContent?) -> Expected<NSNull, NSString> {
251+
let image: MapboxCoreMaps_Private.__MBXImage = MBXImage.Marshaller.toObjc(image)
252+
return addStyleImage(
253+
forImageId: imageId,
254+
scale: scale,
255+
image: image,
256+
sdf: sdf,
257+
stretchX: stretchX,
258+
stretchY: stretchY,
259+
content: content
260+
)
261+
}
262+
234263
func setStyleURI(_ uri: String, callbacks: RuntimeStylingCallbacks) {
235264
load(style: uri, isJson: false, callbacks: callbacks)
236265
}

0 commit comments

Comments
 (0)