core: rename mbgl namespace to mln (#4487)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Bart Louwers
2026-08-14 23:25:20 +02:00
committed by GitHub
parent 836b862984
commit 550f64be22
1970 changed files with 8931 additions and 8967 deletions

View File

@@ -31,7 +31,7 @@
- (MLNMapCamera *)cameraByRotatingToDirection:(CLLocationDirection)degrees
aroundAnchorPoint:(CGPoint)anchorPoint;
- (MLNMapCamera *)cameraByZoomingToZoomLevel:(double)zoom aroundAnchorPoint:(CGPoint)anchorPoint;
- (MLNMapCamera *)cameraForCameraOptions:(const mbgl::CameraOptions &)cameraOptions;
- (MLNMapCamera *)cameraForCameraOptions:(const mln::CameraOptions &)cameraOptions;
@property (nonatomic) UIView<MLNCalloutView> *calloutViewForSelectedAnnotation;
@end
@@ -619,11 +619,11 @@ static const CGPoint kAnnotationRelativeScale = {0.05f, 0.125f};
NSString *activityTitle = [NSString stringWithFormat:@"Zoom to %0.1f", zoom];
[XCTContext runActivityNamed:activityTitle
block:^(id<XCTActivity> _Nonnull activity) {
mbgl::CameraOptions currentCameraOptions;
mln::CameraOptions currentCameraOptions;
currentCameraOptions.bearing = angle;
currentCameraOptions.anchor =
mbgl::ScreenCoordinate{anchor.x, anchor.y};
mln::ScreenCoordinate{anchor.x, anchor.y};
currentCameraOptions.zoom = zoom;
MLNMapCamera *toCamera =
[self.mapView cameraForCameraOptions:currentCameraOptions];

View File

@@ -83,18 +83,18 @@
// MARK: - camera transitions with NaN values
@interface MLNMapView (MLNCameraTransitionFinishNaNTests)
- (mbgl::CameraOptions)cameraOptionsObjectForAnimatingToCamera:(MLNMapCamera *)camera
edgePadding:(UIEdgeInsets)insets;
- (mln::CameraOptions)cameraOptionsObjectForAnimatingToCamera:(MLNMapCamera *)camera
edgePadding:(UIEdgeInsets)insets;
@end
@interface MLNCameraTransitionNaNZoomMapView : MLNMapView
@end
@implementation MLNCameraTransitionNaNZoomMapView
- (mbgl::CameraOptions)cameraOptionsObjectForAnimatingToCamera:(MLNMapCamera *)camera
edgePadding:(UIEdgeInsets)insets {
mbgl::CameraOptions options = [super cameraOptionsObjectForAnimatingToCamera:camera
edgePadding:insets];
- (mln::CameraOptions)cameraOptionsObjectForAnimatingToCamera:(MLNMapCamera *)camera
edgePadding:(UIEdgeInsets)insets {
mln::CameraOptions options = [super cameraOptionsObjectForAnimatingToCamera:camera
edgePadding:insets];
options.zoom = NAN;
return options;
}

View File

@@ -216,9 +216,9 @@
MLNMapViewImpl *mapViewImpl = [self.mapView viewImpl];
CGFloat scaleFactor = [UIScreen mainScreen].scale;
mbgl::Size renderableSize = mapViewImpl->getRendererBackend().getDefaultRenderable().getSize();
mbgl::Size viewSize = {static_cast<uint32_t>(self.mapView.bounds.size.width * scaleFactor),
static_cast<uint32_t>(self.mapView.bounds.size.height * scaleFactor)};
mln::Size renderableSize = mapViewImpl->getRendererBackend().getDefaultRenderable().getSize();
mln::Size viewSize = {static_cast<uint32_t>(self.mapView.bounds.size.width * scaleFactor),
static_cast<uint32_t>(self.mapView.bounds.size.height * scaleFactor)};
// Test that mapView and default renderable have the same size.
XCTAssertTrue(renderableSize == viewSize);

View File

@@ -20,7 +20,7 @@
frameRenderingTime:(double)frameRenderingTime;
@end
class BenchMapObserver : public mbgl::MapObserver {
class BenchMapObserver : public mln::MapObserver {
public:
BenchMapObserver() = delete;
BenchMapObserver(id<BenchMapDelegate> mapDelegate_) : mapDelegate(mapDelegate_) {}
@@ -30,7 +30,7 @@ public:
// NSLog(@"Frame encoding time: %4.1f ms", status.renderingStats.encodingTime * 1e3);
// NSLog(@"Frame rendering time: %4.1f ms", status.renderingStats.renderingTime * 1e3);
bool fullyRendered = status.mode == mbgl::MapObserver::RenderMode::Full;
bool fullyRendered = status.mode == mln::MapObserver::RenderMode::Full;
[mapDelegate mapDidFinishRenderingFrameFullyRendered:fullyRendered
frameEncodingTime:status.renderingStats.encodingTime
frameRenderingTime:status.renderingStats.renderingTime];
@@ -42,8 +42,8 @@ protected:
@interface MBXBenchViewController () <BenchMapDelegate> {
std::unique_ptr<BenchMapObserver> observer;
std::unique_ptr<mbgl::HeadlessFrontend> frontend;
std::unique_ptr<mbgl::Map> map;
std::unique_ptr<mln::HeadlessFrontend> frontend;
std::unique_ptr<mln::Map> map;
}
@property (nonatomic) UIImageView *imageView;
@@ -96,32 +96,32 @@ protected:
UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.view addSubview:self.imageView];
mbgl::Size viewSize = {static_cast<uint32_t>(self.view.bounds.size.width),
static_cast<uint32_t>(self.view.bounds.size.height)};
mln::Size viewSize = {static_cast<uint32_t>(self.view.bounds.size.width),
static_cast<uint32_t>(self.view.bounds.size.height)};
auto pixelRatio = [[UIScreen mainScreen] scale];
observer = std::make_unique<BenchMapObserver>(self);
frontend = std::make_unique<mbgl::HeadlessFrontend>(
viewSize, pixelRatio, mbgl::gfx::HeadlessBackend::SwapBehaviour::Flush,
mbgl::gfx::ContextMode::Unique,
frontend = std::make_unique<mln::HeadlessFrontend>(
viewSize, pixelRatio, mln::gfx::HeadlessBackend::SwapBehaviour::Flush,
mln::gfx::ContextMode::Unique,
/* localFontFamily */ std::nullopt,
/* invalidateOnUpdate */ false);
mbgl::MapOptions mapOptions;
mapOptions.withMapMode(mbgl::MapMode::Continuous)
mln::MapOptions mapOptions;
mapOptions.withMapMode(mln::MapMode::Continuous)
.withSize(viewSize)
.withPixelRatio(pixelRatio)
.withConstrainMode(mbgl::ConstrainMode::None)
.withViewportMode(mbgl::ViewportMode::Default)
.withConstrainMode(mln::ConstrainMode::None)
.withViewportMode(mln::ViewportMode::Default)
.withCrossSourceCollisions(true);
mbgl::TileServerOptions *tileServerOptions =
mln::TileServerOptions *tileServerOptions =
[[MLNSettings sharedSettings] tileServerOptionsInternal];
mbgl::ResourceOptions resourceOptions;
mln::ResourceOptions resourceOptions;
resourceOptions.withCachePath(MLNOfflineStorage.sharedOfflineStorage.databasePath.UTF8String)
.withAssetPath([NSBundle mainBundle].resourceURL.path.UTF8String)
.withTileServerOptions(*tileServerOptions);
mbgl::ClientOptions clientOptions;
mln::ClientOptions clientOptions;
auto apiKey = [[MLNSettings sharedSettings] apiKey];
if (apiKey) {
@@ -129,9 +129,9 @@ protected:
}
map =
std::make_unique<mbgl::Map>(*frontend, *observer, mapOptions, resourceOptions, clientOptions);
std::make_unique<mln::Map>(*frontend, *observer, mapOptions, resourceOptions, clientOptions);
map->setSize(viewSize);
map->setDebug(mbgl::MapDebugOptions::NoDebug);
map->setDebug(mln::MapDebugOptions::NoDebug);
map->getStyle().loadURL([url.absoluteString UTF8String]);
[self startBenchmarkIteration];
@@ -190,12 +190,12 @@ std::vector<std::pair<std::string, std::pair<double, double>>> result;
static const int benchmarkDuration = 5; // seconds
namespace mbgl {
namespace mln {
extern std::size_t uploadCount, uploadBuildCount, uploadVertextAttrsDirty, uploadInvalidSegments;
}
- (void)renderFrame {
mbgl::gfx::BackendScope guard{*(frontend->getBackend())};
mln::gfx::BackendScope guard{*(frontend->getBackend())};
frontend->renderFrame();
@@ -214,20 +214,20 @@ extern std::size_t uploadCount, uploadBuildCount, uploadVertextAttrsDirty, uploa
}
- (void)startBenchmarkIteration {
if (mbgl::bench::locations.size() > idx) {
if (mln::bench::locations.size() > idx) {
if (advancedMetrics == nil) {
advancedMetrics = [[BenchmarkAdvancedMetrics alloc] init];
[advancedMetrics start:1];
}
const auto &location = mbgl::bench::locations[idx];
const auto &location = mln::bench::locations[idx];
mbgl::CameraOptions cameraOptions;
cameraOptions.center = mbgl::LatLng(location.latitude, location.longitude);
mln::CameraOptions cameraOptions;
cameraOptions.center = mln::LatLng(location.latitude, location.longitude);
cameraOptions.zoom = location.zoom;
cameraOptions.bearing = location.bearing;
mbgl::AnimationOptions animationOptions;
animationOptions.duration.emplace(std::chrono::duration_cast<mbgl::Duration>(
mln::AnimationOptions animationOptions;
animationOptions.duration.emplace(std::chrono::duration_cast<mln::Duration>(
std::chrono::duration<NSTimeInterval>(benchmarkDuration)));
map->easeTo(cameraOptions, animationOptions);
@@ -260,10 +260,10 @@ extern std::size_t uploadCount, uploadBuildCount, uploadVertextAttrsDirty, uploa
NSLog(@"Average frame encoding time: %4.2f ms", totalFrameEncodingTime * 1e3 / result.size());
NSLog(@"Average frame rendering time: %4.2f ms", totalFrameRenderingTime * 1e3 / result.size());
// NSLog(@"Total uploads: %zu", mbgl::uploadCount);
// NSLog(@"Total uploads with dirty vattr: %zu", mbgl::uploadVertextAttrsDirty);
// NSLog(@"Total uploads with invalid segs: %zu", mbgl::uploadInvalidSegments);
// NSLog(@"Total uploads with build: %zu", mbgl::uploadBuildCount);
// NSLog(@"Total uploads: %zu", mln::uploadCount);
// NSLog(@"Total uploads with dirty vattr: %zu", mln::uploadVertextAttrsDirty);
// NSLog(@"Total uploads with invalid segs: %zu", mln::uploadInvalidSegments);
// NSLog(@"Total uploads with build: %zu", mln::uploadBuildCount);
[advancedMetrics stop];
@@ -315,7 +315,7 @@ extern std::size_t uploadCount, uploadBuildCount, uploadVertextAttrsDirty, uploa
// Report FPS
const auto frameEncodingTime = static_cast<double>(totalFrameEncodingTime) / frames;
const auto frameRenderingTime = static_cast<double>(totalFrameRenderingTime) / frames;
result.emplace_back(mbgl::bench::locations[idx].name,
result.emplace_back(mln::bench::locations[idx].name,
std::make_pair(frameEncodingTime, frameRenderingTime));
NSLog(@"- Frame encoding time: %.1f ms, Frame rendering time: %.1f ms (%d frames)",
frameEncodingTime * 1e3, frameRenderingTime * 1e3, frames);

View File

@@ -1,6 +1,6 @@
#include "locations.hpp"
namespace mbgl {
namespace mln {
namespace bench {
const std::vector<Location> locations = {
@@ -23,4 +23,4 @@ const std::vector<Location> locations = {
};
}
} // namespace mbgl
} // namespace mln

View File

@@ -3,7 +3,7 @@
#include <string>
#include <vector>
namespace mbgl {
namespace mln {
namespace bench {
struct Location {
@@ -17,4 +17,4 @@ struct Location {
extern const std::vector<Location> locations;
} // namespace bench
} // namespace mbgl
} // namespace mln

View File

@@ -158,8 +158,8 @@
// The pitch intensity represents how much the map view is actually pitched compared to
// what is possible. The value will range from 0% (not pitched at all) to 100% (pitched as much
// as the map view will allow). The map view's maximum pitch is defined in
// `mbgl::util::PITCH_MAX`.
CGFloat pitchIntensity = pitch / MLNDegreesFromRadians(mbgl::util::PITCH_MAX);
// `mln::util::PITCH_MAX`.
CGFloat pitchIntensity = pitch / MLNDegreesFromRadians(mln::util::PITCH_MAX);
// The pitch adjusted scale is the inverse proportion of the maximum possible scale reduction
// multiplied by the pitch intensity. For example, if the maximum scale reduction is 75% and the

View File

@@ -103,7 +103,7 @@
- (void)updateCompassAnimated:(BOOL)animated {
CLLocationDirection direction = self.mapView.direction;
CLLocationDirection plateDirection = mbgl::util::wrap(-direction, 0., 360.);
CLLocationDirection plateDirection = mln::util::wrap(-direction, 0., 360.);
self.transform = CGAffineTransformMakeRotation(MLNRadiansFromDegrees(plateDirection));
self.isAccessibilityElement = direction > 0;

View File

@@ -14,24 +14,24 @@
@end
@implementation MLNMapProjection {
std::unique_ptr<mbgl::MapProjection> _mbglProjection;
std::unique_ptr<mln::MapProjection> _mbglProjection;
}
- (instancetype)initWithMapView:(MLNMapView *)mapView {
if (self = [super init]) {
_mbglProjection = std::make_unique<mbgl::MapProjection>([mapView mbglMap]);
_mbglProjection = std::make_unique<mln::MapProjection>([mapView mbglMap]);
self.mapFrameSize = mapView.frame.size;
}
return self;
}
- (MLNMapCamera *)camera {
mbgl::CameraOptions cameraOptions = _mbglProjection->getCamera();
mln::CameraOptions cameraOptions = _mbglProjection->getCamera();
CLLocationCoordinate2D centerCoordinate =
MLNLocationCoordinate2DFromLatLng(*cameraOptions.center);
double zoomLevel = *cameraOptions.zoom;
CLLocationDirection direction = mbgl::util::wrap(*cameraOptions.bearing, 0., 360.);
CLLocationDirection direction = mln::util::wrap(*cameraOptions.bearing, 0., 360.);
CGFloat pitch = *cameraOptions.pitch;
CLLocationDistance altitude =
MLNAltitudeForZoomLevel(zoomLevel, pitch, centerCoordinate.latitude, self.mapFrameSize);
@@ -42,7 +42,7 @@
}
- (void)setCamera:(MLNMapCamera *_Nonnull)camera withEdgeInsets:(UIEdgeInsets)insets {
mbgl::CameraOptions cameraOptions;
mln::CameraOptions cameraOptions;
if (CLLocationCoordinate2DIsValid(camera.centerCoordinate)) {
cameraOptions.center = MLNLatLngFromLocationCoordinate2D(camera.centerCoordinate);
}
@@ -68,8 +68,8 @@
bounds.ne,
};
mbgl::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(insets);
std::vector<mbgl::LatLng> latLngs;
mln::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(insets);
std::vector<mln::LatLng> latLngs;
latLngs.reserve(4);
for (NSUInteger i = 0; i < 4; i++) {
latLngs.push_back({coordinates[i].latitude, coordinates[i].longitude});
@@ -79,7 +79,7 @@
}
- (CLLocationCoordinate2D)convertPoint:(CGPoint)point {
mbgl::ScreenCoordinate screenCoordinate = mbgl::ScreenCoordinate(point.x, point.y);
mln::ScreenCoordinate screenCoordinate = mln::ScreenCoordinate(point.x, point.y);
return MLNLocationCoordinate2DFromLatLng(
_mbglProjection->latLngForPixel(screenCoordinate).wrapped());
}
@@ -89,15 +89,15 @@
return CGPointMake(NAN, NAN);
}
mbgl::LatLng latLng = MLNLatLngFromLocationCoordinate2D(coordinate);
mbgl::ScreenCoordinate pixel = _mbglProjection->pixelForLatLng(latLng);
mln::LatLng latLng = MLNLatLngFromLocationCoordinate2D(coordinate);
mln::ScreenCoordinate pixel = _mbglProjection->pixelForLatLng(latLng);
return CGPointMake(pixel.x, pixel.y);
}
- (CLLocationDistance)metersPerPoint {
mbgl::CameraOptions cameraOptions = _mbglProjection->getCamera();
return mbgl::Projection::getMetersPerPixelAtLatitude(cameraOptions.center->latitude(),
*cameraOptions.zoom);
mln::CameraOptions cameraOptions = _mbglProjection->getCamera();
return mln::Projection::getMetersPerPixelAtLatitude(cameraOptions.center->latitude(),
*cameraOptions.zoom);
}
@end

View File

@@ -10,14 +10,14 @@
@class MLNMapView;
class MLNMapViewImpl : public mbgl::MapObserver {
class MLNMapViewImpl : public mln::MapObserver {
public:
static std::unique_ptr<MLNMapViewImpl> Create(MLNMapView*);
MLNMapViewImpl(MLNMapView*);
virtual ~MLNMapViewImpl() = default;
virtual mbgl::gfx::RendererBackend& getRendererBackend() = 0;
virtual mln::gfx::RendererBackend& getRendererBackend() = 0;
// Returns a handle to the OpenGL context object if this view is rendered with OpenGL.
virtual EAGLContext* getEAGLContext() { return nullptr; }
@@ -56,37 +56,36 @@ public:
virtual MLNBackendResource* getObject() = 0;
// mbgl::MapObserver implementation
void onCameraWillChange(mbgl::MapObserver::CameraChangeMode) override;
// mln::MapObserver implementation
void onCameraWillChange(mln::MapObserver::CameraChangeMode) override;
void onCameraIsChanging() override;
void onCameraDidChange(mbgl::MapObserver::CameraChangeMode) override;
void onCameraDidChange(mln::MapObserver::CameraChangeMode) override;
void onWillStartLoadingMap() override;
void onDidFinishLoadingMap() override;
void onDidFailLoadingMap(mbgl::MapLoadError mapError, const std::string& what) override;
void onDidFailLoadingMap(mln::MapLoadError mapError, const std::string& what) override;
void onWillStartRenderingFrame() override;
void onDidFinishRenderingFrame(const mbgl::MapObserver::RenderFrameStatus&) override;
void onDidFinishRenderingFrame(const mln::MapObserver::RenderFrameStatus&) override;
void onWillStartRenderingMap() override;
void onDidFinishRenderingMap(mbgl::MapObserver::RenderMode) override;
void onDidFinishRenderingMap(mln::MapObserver::RenderMode) override;
void onDidFinishLoadingStyle() override;
void onSourceChanged(mbgl::style::Source& source) override;
void onSourceChanged(mln::style::Source& source) override;
void onDidBecomeIdle() override;
void onStyleImageMissing(const std::string& imageIdentifier) override;
bool onCanRemoveUnusedStyleImage(const std::string& imageIdentifier) override;
void onRegisterShaders(mbgl::gfx::ShaderRegistry&) override;
void onPreCompileShader(mbgl::shaders::BuiltIn, mbgl::gfx::Backend::Type,
void onRegisterShaders(mln::gfx::ShaderRegistry&) override;
void onPreCompileShader(mln::shaders::BuiltIn, mln::gfx::Backend::Type,
const std::string&) override;
void onPostCompileShader(mbgl::shaders::BuiltIn, mbgl::gfx::Backend::Type,
void onPostCompileShader(mln::shaders::BuiltIn, mln::gfx::Backend::Type,
const std::string&) override;
void onShaderCompileFailed(mbgl::shaders::BuiltIn, mbgl::gfx::Backend::Type,
void onShaderCompileFailed(mln::shaders::BuiltIn, mln::gfx::Backend::Type,
const std::string&) override;
void onGlyphsLoaded(const mbgl::FontStack&, const mbgl::GlyphRange&) override;
void onGlyphsError(const mbgl::FontStack&, const mbgl::GlyphRange&, std::exception_ptr) override;
void onGlyphsRequested(const mbgl::FontStack&, const mbgl::GlyphRange&) override;
void onTileAction(mbgl::TileOperation, const mbgl::OverscaledTileID&,
const std::string&) override;
void onSpriteLoaded(const std::optional<mbgl::style::Sprite>&) override;
void onSpriteError(const std::optional<mbgl::style::Sprite>&, std::exception_ptr) override;
void onSpriteRequested(const std::optional<mbgl::style::Sprite>&) override;
void onGlyphsLoaded(const mln::FontStack&, const mln::GlyphRange&) override;
void onGlyphsError(const mln::FontStack&, const mln::GlyphRange&, std::exception_ptr) override;
void onGlyphsRequested(const mln::FontStack&, const mln::GlyphRange&) override;
void onTileAction(mln::TileOperation, const mln::OverscaledTileID&, const std::string&) override;
void onSpriteLoaded(const std::optional<mln::style::Sprite>&) override;
void onSpriteError(const std::optional<mln::style::Sprite>&, std::exception_ptr) override;
void onSpriteRequested(const std::optional<mln::style::Sprite>&) override;
void onRenderError(std::exception_ptr) override;
protected:

View File

@@ -30,15 +30,15 @@ MLNMapViewImpl::MLNMapViewImpl(MLNMapView* nativeView_) : mapView(nativeView_) {
void MLNMapViewImpl::render() { [mapView renderSync]; }
void MLNMapViewImpl::onCameraWillChange(mbgl::MapObserver::CameraChangeMode mode) {
bool animated = mode == mbgl::MapObserver::CameraChangeMode::Animated;
void MLNMapViewImpl::onCameraWillChange(mln::MapObserver::CameraChangeMode mode) {
bool animated = mode == mln::MapObserver::CameraChangeMode::Animated;
[mapView cameraWillChangeAnimated:animated];
}
void MLNMapViewImpl::onCameraIsChanging() { [mapView cameraIsChanging]; }
void MLNMapViewImpl::onCameraDidChange(mbgl::MapObserver::CameraChangeMode mode) {
bool animated = mode == mbgl::MapObserver::CameraChangeMode::Animated;
void MLNMapViewImpl::onCameraDidChange(mln::MapObserver::CameraChangeMode mode) {
bool animated = mode == mln::MapObserver::CameraChangeMode::Animated;
[mapView cameraDidChangeAnimated:animated];
}
@@ -46,25 +46,25 @@ void MLNMapViewImpl::onWillStartLoadingMap() { [mapView mapViewWillStartLoadingM
void MLNMapViewImpl::onDidFinishLoadingMap() { [mapView mapViewDidFinishLoadingMap]; }
void MLNMapViewImpl::onDidFailLoadingMap(mbgl::MapLoadError mapError, const std::string& what) {
void MLNMapViewImpl::onDidFailLoadingMap(mln::MapLoadError mapError, const std::string& what) {
NSString* description;
MLNErrorCode code;
switch (mapError) {
case mbgl::MapLoadError::StyleParseError:
case mln::MapLoadError::StyleParseError:
code = MLNErrorCodeParseStyleFailed;
description = NSLocalizedStringWithDefaultValue(
@"PARSE_STYLE_FAILED_DESC", nil, nil,
@"The map failed to load because the style is corrupted.",
@"User-friendly error description");
break;
case mbgl::MapLoadError::StyleLoadError:
case mln::MapLoadError::StyleLoadError:
code = MLNErrorCodeLoadStyleFailed;
description = NSLocalizedStringWithDefaultValue(
@"LOAD_STYLE_FAILED_DESC", nil, nil,
@"The map failed to load because the style can’t be loaded.",
@"User-friendly error description");
break;
case mbgl::MapLoadError::NotFoundError:
case mln::MapLoadError::NotFoundError:
code = MLNErrorCodeNotFound;
description = NSLocalizedStringWithDefaultValue(
@"STYLE_NOT_FOUND_DESC", nil, nil,
@@ -89,22 +89,22 @@ void MLNMapViewImpl::onDidFailLoadingMap(mbgl::MapLoadError mapError, const std:
void MLNMapViewImpl::onWillStartRenderingFrame() { [mapView mapViewWillStartRenderingFrame]; }
void MLNMapViewImpl::onDidFinishRenderingFrame(const mbgl::MapObserver::RenderFrameStatus& status) {
const bool fullyRendered = status.mode == mbgl::MapObserver::RenderMode::Full;
void MLNMapViewImpl::onDidFinishRenderingFrame(const mln::MapObserver::RenderFrameStatus& status) {
const bool fullyRendered = status.mode == mln::MapObserver::RenderMode::Full;
[mapView mapViewDidFinishRenderingFrameFullyRendered:fullyRendered
renderingStats:status.renderingStats];
}
void MLNMapViewImpl::onWillStartRenderingMap() { [mapView mapViewWillStartRenderingMap]; }
void MLNMapViewImpl::onDidFinishRenderingMap(mbgl::MapObserver::RenderMode mode) {
bool fullyRendered = mode == mbgl::MapObserver::RenderMode::Full;
void MLNMapViewImpl::onDidFinishRenderingMap(mln::MapObserver::RenderMode mode) {
bool fullyRendered = mode == mln::MapObserver::RenderMode::Full;
[mapView mapViewDidFinishRenderingMapFullyRendered:fullyRendered];
}
void MLNMapViewImpl::onDidFinishLoadingStyle() { [mapView mapViewDidFinishLoadingStyle]; }
void MLNMapViewImpl::onSourceChanged(mbgl::style::Source& source) {
void MLNMapViewImpl::onSourceChanged(mln::style::Source& source) {
NSString* identifier = @(source.getID().c_str());
MLNSource* nativeSource = [mapView.style sourceWithIdentifier:identifier];
[mapView sourceDidChange:nativeSource];
@@ -122,10 +122,10 @@ bool MLNMapViewImpl::onCanRemoveUnusedStyleImage(const std::string& imageIdentif
return [mapView shouldRemoveStyleImage:imageName];
}
void MLNMapViewImpl::onRegisterShaders(mbgl::gfx::ShaderRegistry& shaders) {}
void MLNMapViewImpl::onRegisterShaders(mln::gfx::ShaderRegistry& shaders) {}
void MLNMapViewImpl::onPreCompileShader(mbgl::shaders::BuiltIn shaderID,
mbgl::gfx::Backend::Type backend,
void MLNMapViewImpl::onPreCompileShader(mln::shaders::BuiltIn shaderID,
mln::gfx::Backend::Type backend,
const std::string& defines) {
NSString* definesCopy = [NSString stringWithUTF8String:defines.c_str()];
[mapView shaderWillCompile:static_cast<int>(shaderID)
@@ -133,8 +133,8 @@ void MLNMapViewImpl::onPreCompileShader(mbgl::shaders::BuiltIn shaderID,
defines:definesCopy];
}
void MLNMapViewImpl::onPostCompileShader(mbgl::shaders::BuiltIn shaderID,
mbgl::gfx::Backend::Type backend,
void MLNMapViewImpl::onPostCompileShader(mln::shaders::BuiltIn shaderID,
mln::gfx::Backend::Type backend,
const std::string& defines) {
NSString* definesCopy = [NSString stringWithUTF8String:defines.c_str()];
[mapView shaderDidCompile:static_cast<int>(shaderID)
@@ -142,8 +142,8 @@ void MLNMapViewImpl::onPostCompileShader(mbgl::shaders::BuiltIn shaderID,
defines:definesCopy];
}
void MLNMapViewImpl::onShaderCompileFailed(mbgl::shaders::BuiltIn shaderID,
mbgl::gfx::Backend::Type backend,
void MLNMapViewImpl::onShaderCompileFailed(mln::shaders::BuiltIn shaderID,
mln::gfx::Backend::Type backend,
const std::string& defines) {
NSString* definesCopy = [NSString stringWithUTF8String:defines.c_str()];
[mapView shaderDidFailCompile:static_cast<int>(shaderID)
@@ -151,8 +151,7 @@ void MLNMapViewImpl::onShaderCompileFailed(mbgl::shaders::BuiltIn shaderID,
defines:definesCopy];
}
void MLNMapViewImpl::onGlyphsLoaded(const mbgl::FontStack& fontStack,
const mbgl::GlyphRange& range) {
void MLNMapViewImpl::onGlyphsLoaded(const mln::FontStack& fontStack, const mln::GlyphRange& range) {
NSMutableArray* fontStackCopy = [[NSMutableArray alloc] init];
std::for_each(fontStack.begin(), fontStack.end(), ^(const std::string& str) {
[fontStackCopy addObject:[NSString stringWithUTF8String:str.c_str()]];
@@ -161,7 +160,7 @@ void MLNMapViewImpl::onGlyphsLoaded(const mbgl::FontStack& fontStack,
[mapView glyphsDidLoad:fontStackCopy range:NSMakeRange(range.first, range.second - range.first)];
}
void MLNMapViewImpl::onGlyphsError(const mbgl::FontStack& fontStack, const mbgl::GlyphRange& range,
void MLNMapViewImpl::onGlyphsError(const mln::FontStack& fontStack, const mln::GlyphRange& range,
std::exception_ptr error) {
NSMutableArray* fontStackCopy = [[NSMutableArray alloc] init];
std::for_each(fontStack.begin(), fontStack.end(), ^(const std::string& str) {
@@ -171,8 +170,8 @@ void MLNMapViewImpl::onGlyphsError(const mbgl::FontStack& fontStack, const mbgl:
[mapView glyphsDidError:fontStackCopy range:NSMakeRange(range.first, range.second - range.first)];
}
void MLNMapViewImpl::onGlyphsRequested(const mbgl::FontStack& fontStack,
const mbgl::GlyphRange& range) {
void MLNMapViewImpl::onGlyphsRequested(const mln::FontStack& fontStack,
const mln::GlyphRange& range) {
NSMutableArray* fontStackCopy = [[NSMutableArray alloc] init];
std::for_each(fontStack.begin(), fontStack.end(), ^(const std::string& str) {
[fontStackCopy addObject:[NSString stringWithUTF8String:str.c_str()]];
@@ -181,7 +180,7 @@ void MLNMapViewImpl::onGlyphsRequested(const mbgl::FontStack& fontStack,
[mapView glyphsWillLoad:fontStackCopy range:NSMakeRange(range.first, range.second - range.first)];
}
void MLNMapViewImpl::onTileAction(mbgl::TileOperation operation, const mbgl::OverscaledTileID& tile,
void MLNMapViewImpl::onTileAction(mln::TileOperation operation, const mln::OverscaledTileID& tile,
const std::string& sourceID) {
[mapView tileDidTriggerAction:MLNTileOperation(static_cast<int>(operation))
x:tile.canonical.x
@@ -192,7 +191,7 @@ void MLNMapViewImpl::onTileAction(mbgl::TileOperation operation, const mbgl::Ove
sourceID:[NSString stringWithUTF8String:sourceID.c_str()]];
}
void MLNMapViewImpl::onSpriteLoaded(const std::optional<mbgl::style::Sprite>& spriteID) {
void MLNMapViewImpl::onSpriteLoaded(const std::optional<mln::style::Sprite>& spriteID) {
if (!spriteID.has_value()) {
[mapView spriteDidLoad:nil url:nil];
return;
@@ -202,7 +201,7 @@ void MLNMapViewImpl::onSpriteLoaded(const std::optional<mbgl::style::Sprite>& sp
url:[NSString stringWithUTF8String:spriteID.value().spriteURL.c_str()]];
}
void MLNMapViewImpl::onSpriteError(const std::optional<mbgl::style::Sprite>& spriteID,
void MLNMapViewImpl::onSpriteError(const std::optional<mln::style::Sprite>& spriteID,
std::exception_ptr error) {
if (!spriteID.has_value()) {
[mapView spriteDidError:nil url:nil];
@@ -213,7 +212,7 @@ void MLNMapViewImpl::onSpriteError(const std::optional<mbgl::style::Sprite>& spr
url:[NSString stringWithUTF8String:spriteID.value().spriteURL.c_str()]];
}
void MLNMapViewImpl::onSpriteRequested(const std::optional<mbgl::style::Sprite>& spriteID) {
void MLNMapViewImpl::onSpriteRequested(const std::optional<mln::style::Sprite>& spriteID) {
if (!spriteID.has_value()) {
[mapView spriteWillLoad:nil url:nil];
return;

View File

@@ -8,8 +8,8 @@
/// Adapter responsible for bridging calls from mbgl to MLNMapView and Cocoa.
class MLNMapViewMetalImpl final : public MLNMapViewImpl,
public mbgl::mtl::RendererBackend,
public mbgl::gfx::Renderable {
public mln::mtl::RendererBackend,
public mln::gfx::Renderable {
public:
MLNMapViewMetalImpl(MLNMapView*);
~MLNMapViewMetalImpl() override;
@@ -17,23 +17,23 @@ public:
public:
void restoreFramebufferBinding();
// Implementation of mbgl::gfx::RendererBackend
// Implementation of mln::gfx::RendererBackend
public:
mbgl::gfx::Renderable& getDefaultRenderable() override { return *this; }
mln::gfx::Renderable& getDefaultRenderable() override { return *this; }
private:
void activate() override;
void deactivate() override;
// End implementation of mbgl::gfx::RendererBackend
// End implementation of mln::gfx::RendererBackend
// Implementation of mbgl::gl::RendererBackend
// Implementation of mln::gl::RendererBackend
public:
void updateAssumedState() override;
// End implementation of mbgl::gl::Rendererbackend
// End implementation of mln::gl::Rendererbackend
// Implementation of MLNMapViewImpl
public:
mbgl::gfx::RendererBackend& getRendererBackend() override { return *this; }
mln::gfx::RendererBackend& getRendererBackend() override { return *this; }
void setOpaque(bool) override;
void display() override;

View File

@@ -34,7 +34,7 @@
@end
class MLNMapViewMetalRenderableResource final : public mbgl::mtl::RenderableResource {
class MLNMapViewMetalRenderableResource final : public mln::mtl::RenderableResource {
public:
MLNMapViewMetalRenderableResource(MLNMapViewMetalImpl& backend_)
: backend(backend_), delegate([[MLNMapViewImplDelegate alloc] initWithImpl:&backend]) {}
@@ -50,18 +50,18 @@ public:
}
}
const mbgl::mtl::RendererBackend& getBackend() const override { return backend; }
const mln::mtl::RendererBackend& getBackend() const override { return backend; }
const mbgl::mtl::MTLCommandBufferPtr& getCommandBuffer() const override {
const mln::mtl::MTLCommandBufferPtr& getCommandBuffer() const override {
return commandBufferPtr;
}
virtual mbgl::mtl::MTLBlitPassDescriptorPtr getUploadPassDescriptor() const override {
virtual mln::mtl::MTLBlitPassDescriptorPtr getUploadPassDescriptor() const override {
// Create from render pass descriptor?
return NS::TransferPtr(MTL::BlitPassDescriptor::alloc()->init());
}
const mbgl::mtl::MTLRenderPassDescriptorPtr& getRenderPassDescriptor() const override {
const mln::mtl::MTLRenderPassDescriptorPtr& getRenderPassDescriptor() const override {
if (!cachedRenderPassDescriptor) {
auto* mtlDesc = mtlView.currentRenderPassDescriptor;
cachedRenderPassDescriptor = NS::RetainPtr((__bridge MTL::RenderPassDescriptor*)mtlDesc);
@@ -88,7 +88,7 @@ public:
cachedRenderPassDescriptor.reset();
}
mbgl::Size framebufferSize() {
mln::Size framebufferSize() {
assert(mtlView);
return {static_cast<uint32_t>(mtlView.drawableSize.width),
static_cast<uint32_t>(mtlView.drawableSize.height)};
@@ -96,8 +96,8 @@ public:
private:
MLNMapViewMetalImpl& backend;
mbgl::mtl::MTLCommandBufferPtr commandBufferPtr;
mutable mbgl::mtl::MTLRenderPassDescriptorPtr cachedRenderPassDescriptor;
mln::mtl::MTLCommandBufferPtr commandBufferPtr;
mutable mln::mtl::MTLRenderPassDescriptorPtr cachedRenderPassDescriptor;
public:
MLNMapViewImplDelegate* delegate = nil;
@@ -118,8 +118,8 @@ public:
MLNMapViewMetalImpl::MLNMapViewMetalImpl(MLNMapView* nativeView_)
: MLNMapViewImpl(nativeView_),
mbgl::mtl::RendererBackend(mbgl::gfx::ContextMode::Unique),
mbgl::gfx::Renderable({0, 0}, std::make_unique<MLNMapViewMetalRenderableResource>(*this)) {}
mln::mtl::RendererBackend(mln::gfx::ContextMode::Unique),
mln::gfx::Renderable({0, 0}, std::make_unique<MLNMapViewMetalRenderableResource>(*this)) {}
MLNMapViewMetalImpl::~MLNMapViewMetalImpl() = default;

View File

@@ -8,8 +8,8 @@
/// Adapter responsible for bridging calls from mbgl to MLNMapView and Cocoa.
class MLNMapViewOpenGLImpl final : public MLNMapViewImpl,
public mbgl::gl::RendererBackend,
public mbgl::gfx::Renderable {
public mln::gl::RendererBackend,
public mln::gfx::Renderable {
public:
MLNMapViewOpenGLImpl(MLNMapView*);
~MLNMapViewOpenGLImpl() override;
@@ -22,26 +22,26 @@ private:
void emergencyRecreateGL();
#endif
// Implementation of mbgl::gfx::RendererBackend
// Implementation of mln::gfx::RendererBackend
public:
mbgl::gfx::Renderable& getDefaultRenderable() override { return *this; }
mln::gfx::Renderable& getDefaultRenderable() override { return *this; }
private:
void activate() override;
void deactivate() override;
// End implementation of mbgl::gfx::RendererBackend
// End implementation of mln::gfx::RendererBackend
// Implementation of mbgl::gl::RendererBackend
// Implementation of mln::gl::RendererBackend
public:
void updateAssumedState() override;
private:
mbgl::gl::ProcAddress getExtensionFunctionPointer(const char* name) override;
// End implementation of mbgl::gl::Rendererbackend
mln::gl::ProcAddress getExtensionFunctionPointer(const char* name) override;
// End implementation of mln::gl::Rendererbackend
// Implementation of MLNMapViewImpl
public:
mbgl::gfx::RendererBackend& getRendererBackend() override { return *this; }
mln::gfx::RendererBackend& getRendererBackend() override { return *this; }
EAGLContext* getEAGLContext() override;
void setOpaque(bool) override;

View File

@@ -36,7 +36,7 @@ CGFloat contentScaleFactor() {
}
} // namespace
class MLNMapViewOpenGLRenderableResource final : public mbgl::gl::RenderableResource {
class MLNMapViewOpenGLRenderableResource final : public mln::gl::RenderableResource {
public:
MLNMapViewOpenGLRenderableResource(MLNMapViewOpenGLImpl& backend_)
: backend(backend_),
@@ -46,7 +46,7 @@ public:
void bind() override { backend.restoreFramebufferBinding(); }
mbgl::Size framebufferSize() {
mln::Size framebufferSize() {
assert(glView);
return {static_cast<uint32_t>(glView.drawableWidth),
static_cast<uint32_t>(glView.drawableHeight)};
@@ -68,8 +68,8 @@ public:
MLNMapViewOpenGLImpl::MLNMapViewOpenGLImpl(MLNMapView* nativeView_)
: MLNMapViewImpl(nativeView_),
mbgl::gl::RendererBackend(mbgl::gfx::ContextMode::Unique),
mbgl::gfx::Renderable({0, 0}, std::make_unique<MLNMapViewOpenGLRenderableResource>(*this)) {}
mln::gl::RendererBackend(mln::gfx::ContextMode::Unique),
mln::gfx::Renderable({0, 0}, std::make_unique<MLNMapViewOpenGLRenderableResource>(*this)) {}
MLNMapViewOpenGLImpl::~MLNMapViewOpenGLImpl() {
auto& resource = getResource<MLNMapViewOpenGLRenderableResource>();
@@ -182,13 +182,13 @@ void MLNMapViewOpenGLImpl::emergencyRecreateGL() {
}
#endif
mbgl::gl::ProcAddress MLNMapViewOpenGLImpl::getExtensionFunctionPointer(const char* name) {
mln::gl::ProcAddress MLNMapViewOpenGLImpl::getExtensionFunctionPointer(const char* name) {
static CFBundleRef framework = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengles"));
if (!framework) {
throw std::runtime_error("Failed to load OpenGL framework.");
}
return reinterpret_cast<mbgl::gl::ProcAddress>(CFBundleGetFunctionPointerForName(
return reinterpret_cast<mln::gl::ProcAddress>(CFBundleGetFunctionPointerForName(
framework, (__bridge CFStringRef)[NSString stringWithUTF8String:name]));
}

View File

@@ -6,26 +6,26 @@
/// Adapter responsible for bridging calls from mbgl to MLNMapView and Cocoa (WebGPU backend).
class MLNMapViewWebGPUImpl final : public MLNMapViewImpl,
public mbgl::webgpu::RendererBackend,
public mbgl::gfx::Renderable {
public mln::webgpu::RendererBackend,
public mln::gfx::Renderable {
public:
MLNMapViewWebGPUImpl(MLNMapView*);
~MLNMapViewWebGPUImpl() override;
// Implementation of mbgl::gfx::RendererBackend
// Implementation of mln::gfx::RendererBackend
public:
mbgl::gfx::Renderable& getDefaultRenderable() override { return *this; }
mln::gfx::Renderable& getDefaultRenderable() override { return *this; }
// webgpu::RendererBackend overrides
void* getCurrentTextureView() override;
void* getDepthStencilView() override;
mbgl::Size getFramebufferSize() const override;
mln::Size getFramebufferSize() const override;
void presentSurface();
void markNeedsPresent();
// Implementation of MLNMapViewImpl
public:
mbgl::gfx::RendererBackend& getRendererBackend() override { return *this; }
mln::gfx::RendererBackend& getRendererBackend() override { return *this; }
void setOpaque(bool) override;
void display() override;

View File

@@ -38,7 +38,7 @@
}
@end
class MLNMapViewWebGPURenderableResource final : public mbgl::webgpu::RenderableResource {
class MLNMapViewWebGPURenderableResource final : public mln::webgpu::RenderableResource {
public:
MLNMapViewWebGPURenderableResource(MLNMapViewWebGPUImpl& backend_) : backend(backend_) {}
@@ -46,7 +46,7 @@ public:
void swap() override { backend.markNeedsPresent(); }
const mbgl::webgpu::RendererBackend& getBackend() const override { return backend; }
const mln::webgpu::RendererBackend& getBackend() const override { return backend; }
const WGPUCommandEncoder& getCommandEncoder() const override {
assert(false);
@@ -94,7 +94,7 @@ public:
WGPUTextureView currentTextureView = nullptr;
bool needsPresent = false;
mbgl::Size framebufferSize;
mln::Size framebufferSize;
MLNWebGPUView* webGPUView = nil;
bool presentsWithTransaction = false;
@@ -103,8 +103,8 @@ public:
MLNMapViewWebGPUImpl::MLNMapViewWebGPUImpl(MLNMapView* nativeView_)
: MLNMapViewImpl(nativeView_),
mbgl::webgpu::RendererBackend(mbgl::gfx::ContextMode::Unique),
mbgl::gfx::Renderable({0, 0}, std::make_unique<MLNMapViewWebGPURenderableResource>(*this)),
mln::webgpu::RendererBackend(mln::gfx::ContextMode::Unique),
mln::gfx::Renderable({0, 0}, std::make_unique<MLNMapViewWebGPURenderableResource>(*this)),
impl(std::make_unique<Impl>()) {
#if MLN_WEBGPU_IMPL_DAWN
// Required when not using the monolithic Dawn library.
@@ -127,7 +127,7 @@ MLNMapViewWebGPUImpl::MLNMapViewWebGPUImpl(MLNMapView* nativeView_)
adapters = impl->instance->EnumerateAdapters();
}
if (adapters.empty()) {
mbgl::Log::Error(mbgl::Event::Render, "WebGPU iOS: No adapters found");
mln::Log::Error(mln::Event::Render, "WebGPU iOS: No adapters found");
return;
}
@@ -150,7 +150,7 @@ MLNMapViewWebGPUImpl::MLNMapViewWebGPUImpl(MLNMapView* nativeView_)
wgpu::InstanceDescriptor instanceDesc = {};
impl->instance = wgpu::createInstance(instanceDesc);
if (!impl->instance) {
mbgl::Log::Error(mbgl::Event::Render, "WebGPU iOS: Failed to create instance");
mln::Log::Error(mln::Event::Render, "WebGPU iOS: Failed to create instance");
return;
}
@@ -160,7 +160,7 @@ MLNMapViewWebGPUImpl::MLNMapViewWebGPUImpl(MLNMapView* nativeView_)
impl->adapter = impl->instance.requestAdapter(adapterOpts);
if (!impl->adapter) {
mbgl::Log::Error(mbgl::Event::Render, "WebGPU iOS: No adapter found");
mln::Log::Error(mln::Event::Render, "WebGPU iOS: No adapter found");
return;
}
@@ -202,7 +202,7 @@ MLNMapViewWebGPUImpl::MLNMapViewWebGPUImpl(MLNMapView* nativeView_)
#if MLN_WEBGPU_IMPL_DAWN
WGPUDevice rawDevice = selectedAdapter.CreateDevice(&deviceDesc);
if (!rawDevice) {
mbgl::Log::Error(mbgl::Event::Render, "WebGPU iOS: Failed to create device");
mln::Log::Error(mln::Event::Render, "WebGPU iOS: Failed to create device");
return;
}
@@ -217,7 +217,7 @@ MLNMapViewWebGPUImpl::MLNMapViewWebGPUImpl(MLNMapView* nativeView_)
#elif MLN_WEBGPU_IMPL_WGPU
impl->device = impl->adapter.requestDevice(deviceDesc);
if (!impl->device) {
mbgl::Log::Error(mbgl::Event::Render, "WebGPU iOS: Failed to create device");
mln::Log::Error(mln::Event::Render, "WebGPU iOS: Failed to create device");
return;
}
@@ -354,7 +354,7 @@ void MLNMapViewWebGPUImpl::createSurface() {
#endif
if (!impl->surface) {
mbgl::Log::Error(mbgl::Event::Render, "WebGPU iOS: Failed to create surface");
mln::Log::Error(mln::Event::Render, "WebGPU iOS: Failed to create surface");
}
}
@@ -456,7 +456,7 @@ void MLNMapViewWebGPUImpl::createDepthStencilTexture(uint32_t width, uint32_t he
wgpuDeviceCreateTexture(static_cast<WGPUDevice>(impl->device), &depthDesc);
#endif
if (!impl->depthStencilTexture) {
mbgl::Log::Warning(mbgl::Event::Render, "WebGPU iOS: Failed to create depth/stencil texture");
mln::Log::Warning(mln::Event::Render, "WebGPU iOS: Failed to create depth/stencil texture");
return;
}
@@ -475,7 +475,7 @@ void MLNMapViewWebGPUImpl::createDepthStencilTexture(uint32_t width, uint32_t he
impl->depthStencilView = wgpuTextureCreateView(impl->depthStencilTexture, &viewDesc);
if (!impl->depthStencilView) {
mbgl::Log::Warning(mbgl::Event::Render, "WebGPU iOS: Failed to create depth/stencil view");
mln::Log::Warning(mln::Event::Render, "WebGPU iOS: Failed to create depth/stencil view");
}
}
@@ -557,7 +557,7 @@ void MLNMapViewWebGPUImpl::presentSurface() {
void* MLNMapViewWebGPUImpl::getDepthStencilView() { return impl->depthStencilView; }
mbgl::Size MLNMapViewWebGPUImpl::getFramebufferSize() const { return impl->framebufferSize; }
mln::Size MLNMapViewWebGPUImpl::getFramebufferSize() const { return impl->framebufferSize; }
UIView* MLNMapViewWebGPUImpl::getView() { return impl->webGPUView; }

View File

@@ -332,7 +332,7 @@ typedef std::unordered_map<MLNAnnotationTag, MLNAnnotationContext> MLNAnnotation
/// Mapping from an annotation object to an annotation tag.
typedef std::map<id<MLNAnnotation>, MLNAnnotationTag> MLNAnnotationObjectTagMap;
mbgl::util::UnitBezier MLNUnitBezierForMediaTimingFunction(CAMediaTimingFunction *function) {
mln::util::UnitBezier MLNUnitBezierForMediaTimingFunction(CAMediaTimingFunction *function) {
if (!function) {
function = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
}
@@ -455,7 +455,7 @@ public:
@end
@implementation MLNMapView {
std::unique_ptr<mbgl::Map> _mbglMap;
std::unique_ptr<mln::Map> _mbglMap;
std::unique_ptr<MLNMapViewImpl> _mbglView;
std::unique_ptr<MLNRenderFrontend> _rendererFrontend;
@@ -638,7 +638,7 @@ public:
self.styleURL = styleURL;
}
- (mbgl::Map &)mbglMap {
- (mln::Map &)mbglMap {
if (!_mbglMap) {
[NSException
raise:MLNUnderlyingMapUnavailableException
@@ -647,7 +647,7 @@ public:
return *_mbglMap;
}
- (mbgl::Renderer *)renderer {
- (mln::Renderer *)renderer {
return _rendererFrontend->getRenderer();
}
@@ -698,40 +698,40 @@ public:
config.localFontFamilyName
? std::optional<std::string>(std::string(config.localFontFamilyName.UTF8String))
: std::nullopt;
auto renderer = std::make_unique<mbgl::Renderer>(_mbglView->getRendererBackend(),
config.scaleFactor, localFontFamilyName);
auto renderer = std::make_unique<mln::Renderer>(_mbglView->getRendererBackend(),
config.scaleFactor, localFontFamilyName);
BOOL enableCrossSourceCollisions = !config.perSourceCollisions;
_rendererFrontend = std::make_unique<MLNRenderFrontend>(std::move(renderer), self,
_mbglView->getRendererBackend());
mbgl::MapOptions mapOptions;
mapOptions.withMapMode(mbgl::MapMode::Continuous)
mln::MapOptions mapOptions;
mapOptions.withMapMode(mln::MapMode::Continuous)
.withSize(self.size)
.withPixelRatio(config.scaleFactor)
.withConstrainMode(mbgl::ConstrainMode::None)
.withViewportMode(mbgl::ViewportMode::Default)
.withConstrainMode(mln::ConstrainMode::None)
.withViewportMode(mln::ViewportMode::Default)
.withCrossSourceCollisions(enableCrossSourceCollisions)
.withFastPFOREnabled(mlnMapoptions.fastPFOREnabled);
mbgl::TileServerOptions *tileServerOptions =
mln::TileServerOptions *tileServerOptions =
[[MLNSettings sharedSettings] tileServerOptionsInternal];
mbgl::ResourceOptions resourceOptions;
mln::ResourceOptions resourceOptions;
resourceOptions.withCachePath(MLNOfflineStorage.sharedOfflineStorage.databasePath.UTF8String)
.withAssetPath([NSBundle mainBundle].resourceURL.path.UTF8String)
.withTileServerOptions(*tileServerOptions);
mbgl::ClientOptions clientOptions;
mln::ClientOptions clientOptions;
auto apiKey = [[MLNSettings sharedSettings] apiKey];
if (apiKey) {
resourceOptions.withApiKey([apiKey UTF8String]);
}
const mbgl::util::ActionJournalOptions &actionJournalOptions =
const mln::util::ActionJournalOptions &actionJournalOptions =
[mlnMapoptions.actionJournalOptions getCoreOptions];
NSAssert(!_mbglMap, @"_mbglMap should be NULL");
_mbglMap = std::make_unique<mbgl::Map>(*_rendererFrontend, *_mbglView, mapOptions,
resourceOptions, clientOptions, actionJournalOptions);
_mbglMap = std::make_unique<mln::Map>(*_rendererFrontend, *_mbglView, mapOptions, resourceOptions,
clientOptions, actionJournalOptions);
// start paused if launch into the background
if (background) {
@@ -975,9 +975,9 @@ public:
// set initial position
//
mbgl::CameraOptions options;
options.center = mbgl::LatLng(0, 0);
mbgl::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(self.contentInset);
mln::CameraOptions options;
options.center = mln::LatLng(0, 0);
mln::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(self.contentInset);
options.padding = padding;
options.zoom = 0;
@@ -993,7 +993,7 @@ public:
_dynamicNavigationCameraAnimationDuration = NO;
}
- (mbgl::Size)size {
- (mln::Size)size {
// check for minimum texture size supported by OpenGL ES 2.0
//
CGSize size = CGSizeMake(MAX(self.bounds.size.width, 64), MAX(self.bounds.size.height, 64));
@@ -1005,7 +1005,7 @@ public:
MLNReachability *reachability = [notification object];
if (!_isWaitingForRedundantReachableNotification && [reachability isReachable]) {
mbgl::NetworkStatus::Reachable();
mln::NetworkStatus::Reachable();
}
_isWaitingForRedundantReachableNotification = NO;
}
@@ -1661,8 +1661,8 @@ public:
- (void)validateDisplayLink {
BOOL isVisible = self.superview && self.window;
if (isVisible && !_displayLink) {
if (_mbglMap && self.mbglMap.getMapOptions().constrainMode() == mbgl::ConstrainMode::None) {
self.mbglMap.setConstrainMode(mbgl::ConstrainMode::HeightOnly);
if (_mbglMap && self.mbglMap.getMapOptions().constrainMode() == mln::ConstrainMode::None) {
self.mbglMap.setConstrainMode(mln::ConstrainMode::HeightOnly);
}
_displayLink = [self.window.screen displayLinkWithTarget:self
@@ -1917,8 +1917,8 @@ public:
[self.displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
if (_mbglMap && self.mbglMap.getMapOptions().constrainMode() == mbgl::ConstrainMode::None) {
self.mbglMap.setConstrainMode(mbgl::ConstrainMode::HeightOnly);
if (_mbglMap && self.mbglMap.getMapOptions().constrainMode() == mln::ConstrainMode::None) {
self.mbglMap.setConstrainMode(mln::ConstrainMode::HeightOnly);
}
}
@@ -2283,8 +2283,8 @@ public:
aroundAnchorPoint:centerPoint];
if ([self _shouldChangeFromCamera:oldCamera toCamera:toCamera]) {
self.mbglMap.jumpTo(mbgl::CameraOptions().withZoom(newZoom).withAnchor(
mbgl::ScreenCoordinate{centerPoint.x, centerPoint.y}));
self.mbglMap.jumpTo(mln::CameraOptions().withZoom(newZoom).withAnchor(
mln::ScreenCoordinate{centerPoint.x, centerPoint.y}));
// The gesture recognizer only reports the gesture’s current center
// point, so use the previous center point to anchor the transition.
@@ -2332,8 +2332,8 @@ public:
drift = NO;
} else {
if (drift) {
self.mbglMap.easeTo(mbgl::CameraOptions().withZoom(zoom).withAnchor(
mbgl::ScreenCoordinate{centerPoint.x, centerPoint.y}),
self.mbglMap.easeTo(mln::CameraOptions().withZoom(zoom).withAnchor(
mln::ScreenCoordinate{centerPoint.x, centerPoint.y}),
MLNDurationFromTimeInterval(duration));
}
}
@@ -2401,9 +2401,9 @@ public:
aroundAnchorPoint:centerPoint];
if ([self _shouldChangeFromCamera:oldCamera toCamera:toCamera]) {
self.mbglMap.jumpTo(mbgl::CameraOptions()
self.mbglMap.jumpTo(mln::CameraOptions()
.withBearing(newDegrees)
.withAnchor(mbgl::ScreenCoordinate{centerPoint.x, centerPoint.y}));
.withAnchor(mln::ScreenCoordinate{centerPoint.x, centerPoint.y}));
}
[self cameraIsChanging];
@@ -2440,9 +2440,9 @@ public:
aroundAnchorPoint:centerPoint];
if ([self _shouldChangeFromCamera:oldCamera toCamera:toCamera]) {
self.mbglMap.easeTo(mbgl::CameraOptions()
self.mbglMap.easeTo(mln::CameraOptions()
.withBearing(newDegrees)
.withAnchor(mbgl::ScreenCoordinate{centerPoint.x, centerPoint.y}),
.withAnchor(mln::ScreenCoordinate{centerPoint.x, centerPoint.y}),
MLNDurationFromTimeInterval(decelerationRate));
[self notifyGestureDidEndWithDrift:YES];
@@ -2561,8 +2561,8 @@ public:
MLNMapCamera *toCamera = [self cameraByZoomingToZoomLevel:newZoom aroundAnchorPoint:gesturePoint];
if ([self _shouldChangeFromCamera:oldCamera toCamera:toCamera]) {
mbgl::ScreenCoordinate center(gesturePoint.x, gesturePoint.y);
self.mbglMap.easeTo(mbgl::CameraOptions().withZoom(newZoom).withAnchor(center),
mln::ScreenCoordinate center(gesturePoint.x, gesturePoint.y);
self.mbglMap.easeTo(mln::CameraOptions().withZoom(newZoom).withAnchor(center),
MLNDurationFromTimeInterval(MLNAnimationDuration));
__weak MLNMapView *weakSelf = self;
@@ -2596,8 +2596,8 @@ public:
MLNMapCamera *toCamera = [self cameraByZoomingToZoomLevel:newZoom aroundAnchorPoint:gesturePoint];
if ([self _shouldChangeFromCamera:oldCamera toCamera:toCamera]) {
mbgl::ScreenCoordinate center(gesturePoint.x, gesturePoint.y);
self.mbglMap.easeTo(mbgl::CameraOptions().withZoom(newZoom).withAnchor(center),
mln::ScreenCoordinate center(gesturePoint.x, gesturePoint.y);
self.mbglMap.easeTo(mln::CameraOptions().withZoom(newZoom).withAnchor(center),
MLNDurationFromTimeInterval(MLNAnimationDuration));
__weak MLNMapView *weakSelf = self;
@@ -2638,8 +2638,8 @@ public:
aroundAnchorPoint:centerPoint];
if ([self _shouldChangeFromCamera:oldCamera toCamera:toCamera]) {
self.mbglMap.jumpTo(mbgl::CameraOptions().withZoom(newZoom).withAnchor(
mbgl::ScreenCoordinate{centerPoint.x, centerPoint.y}));
self.mbglMap.jumpTo(mln::CameraOptions().withZoom(newZoom).withAnchor(
mln::ScreenCoordinate{centerPoint.x, centerPoint.y}));
}
[self cameraIsChanging];
@@ -2701,8 +2701,8 @@ public:
MLNMapCamera *toCamera = [self cameraByTiltingToPitch:pitchNew];
if ([self _shouldChangeFromCamera:oldCamera toCamera:toCamera]) {
self.mbglMap.jumpTo(mbgl::CameraOptions().withPitch(pitchNew).withAnchor(
mbgl::ScreenCoordinate{centerPoint.x, centerPoint.y}));
self.mbglMap.jumpTo(mln::CameraOptions().withPitch(pitchNew).withAnchor(
mln::ScreenCoordinate{centerPoint.x, centerPoint.y}));
}
[self cameraIsChanging];
@@ -2731,12 +2731,12 @@ public:
}
- (MLNMapCamera *)cameraByZoomingToZoomLevel:(double)zoom aroundAnchorPoint:(CGPoint)anchorPoint {
mbgl::ScreenCoordinate anchor = mbgl::ScreenCoordinate{anchorPoint.x, anchorPoint.y};
mbgl::EdgeInsets padding =
mbgl::EdgeInsets(anchor.y, anchor.x, self.size.height - anchor.y, self.size.width - anchor.x);
mbgl::CameraOptions currentCameraOptions = self.mbglMap.getCameraOptions(padding);
mln::ScreenCoordinate anchor = mln::ScreenCoordinate{anchorPoint.x, anchorPoint.y};
mln::EdgeInsets padding =
mln::EdgeInsets(anchor.y, anchor.x, self.size.height - anchor.y, self.size.width - anchor.x);
mln::CameraOptions currentCameraOptions = self.mbglMap.getCameraOptions(padding);
currentCameraOptions.zoom = mbgl::util::clamp(zoom, self.minimumZoomLevel, self.maximumZoomLevel);
currentCameraOptions.zoom = mln::util::clamp(zoom, self.minimumZoomLevel, self.maximumZoomLevel);
currentCameraOptions.anchor = anchor;
MLNCoordinateBounds bounds =
MLNCoordinateBoundsFromLatLngBounds(self.mbglMap.latLngBoundsForCamera(currentCameraOptions));
@@ -2746,11 +2746,11 @@ public:
- (MLNMapCamera *)cameraByRotatingToDirection:(CLLocationDirection)degrees
aroundAnchorPoint:(CGPoint)anchorPoint {
mbgl::CameraOptions currentCameraOptions = self.mbglMap.getCameraOptions();
mln::CameraOptions currentCameraOptions = self.mbglMap.getCameraOptions();
MLNMapCamera *camera;
mbgl::ScreenCoordinate anchor = mbgl::ScreenCoordinate{anchorPoint.x, anchorPoint.y};
mln::ScreenCoordinate anchor = mln::ScreenCoordinate{anchorPoint.x, anchorPoint.y};
currentCameraOptions.bearing = degrees;
currentCameraOptions.anchor = anchor;
camera = [self cameraForCameraOptions:currentCameraOptions];
@@ -2759,7 +2759,7 @@ public:
}
- (MLNMapCamera *)cameraByTiltingToPitch:(CGFloat)pitch {
mbgl::CameraOptions currentCameraOptions = self.mbglMap.getCameraOptions();
mln::CameraOptions currentCameraOptions = self.mbglMap.getCameraOptions();
MLNMapCamera *camera;
@@ -2957,7 +2957,7 @@ static void *windowScreenContext = &windowScreenContext;
// match a valid annotation tag, the annotation will be unnecessarily
// but safely updated.
if (annotation == [self annotationWithTag:annotationTag]) {
const mbgl::Point<double> point = MLNPointFromLocationCoordinate2D(annotation.coordinate);
const mln::Point<double> point = MLNPointFromLocationCoordinate2D(annotation.coordinate);
if (annotationTag != MLNAnnotationTagNotFound) {
MLNAnnotationContext &annotationContext =
@@ -2977,7 +2977,7 @@ static void *windowScreenContext = &windowScreenContext;
// disables the view’s animation actions, because it can’t distinguish between moves due to
// the viewport changing and moves due to the annotation’s coordinate changing.
self.mbglMap.updateAnnotation(annotationTag,
mbgl::SymbolAnnotation{point, symbolName.UTF8String});
mln::SymbolAnnotation{point, symbolName.UTF8String});
[self updateCalloutView];
}
}
@@ -3026,21 +3026,21 @@ static void *windowScreenContext = &windowScreenContext;
return self.residualDebugMask;
}
mbgl::MapDebugOptions options = self.mbglMap.getDebug();
mln::MapDebugOptions options = self.mbglMap.getDebug();
MLNMapDebugMaskOptions mask = 0;
if (options & mbgl::MapDebugOptions::TileBorders) {
if (options & mln::MapDebugOptions::TileBorders) {
mask |= MLNMapDebugTileBoundariesMask;
}
if (options & mbgl::MapDebugOptions::ParseStatus) {
if (options & mln::MapDebugOptions::ParseStatus) {
mask |= MLNMapDebugTileInfoMask;
}
if (options & mbgl::MapDebugOptions::Timestamps) {
if (options & mln::MapDebugOptions::Timestamps) {
mask |= MLNMapDebugTimestampsMask;
}
if (options & mbgl::MapDebugOptions::Collision) {
if (options & mln::MapDebugOptions::Collision) {
mask |= MLNMapDebugCollisionBoxesMask;
}
if (options & mbgl::MapDebugOptions::Overdraw) {
if (options & mln::MapDebugOptions::Overdraw) {
mask |= MLNMapDebugOverdrawVisualizationMask;
}
return mask;
@@ -3051,21 +3051,21 @@ static void *windowScreenContext = &windowScreenContext;
return;
}
mbgl::MapDebugOptions options = mbgl::MapDebugOptions::NoDebug;
mln::MapDebugOptions options = mln::MapDebugOptions::NoDebug;
if (debugMask & MLNMapDebugTileBoundariesMask) {
options |= mbgl::MapDebugOptions::TileBorders;
options |= mln::MapDebugOptions::TileBorders;
}
if (debugMask & MLNMapDebugTileInfoMask) {
options |= mbgl::MapDebugOptions::ParseStatus;
options |= mln::MapDebugOptions::ParseStatus;
}
if (debugMask & MLNMapDebugTimestampsMask) {
options |= mbgl::MapDebugOptions::Timestamps;
options |= mln::MapDebugOptions::Timestamps;
}
if (debugMask & MLNMapDebugCollisionBoxesMask) {
options |= mbgl::MapDebugOptions::Collision;
options |= mln::MapDebugOptions::Collision;
}
if (debugMask & MLNMapDebugOverdrawVisualizationMask) {
options |= mbgl::MapDebugOptions::Overdraw;
options |= mln::MapDebugOptions::Overdraw;
}
self.mbglMap.setDebug(options);
}
@@ -3088,9 +3088,9 @@ static void *windowScreenContext = &windowScreenContext;
double pitch = camera.pitch ? *camera.pitch : 0.0;
double bearing = camera.bearing ? *camera.bearing : 0.0;
double zoom = camera.zoom ? *camera.zoom : 0.0;
mbgl::LatLng center = camera.center ? *camera.center : mbgl::LatLng();
mln::LatLng center = camera.center ? *camera.center : mln::LatLng();
CLLocationDirection heading = mbgl::util::wrap(bearing, 0., 360.);
CLLocationDirection heading = mln::util::wrap(bearing, 0., 360.);
CLLocationDistance altitude = MLNAltitudeForZoomLevel(zoom, pitch, 0, self.frame.size);
self.camera =
[MLNMapCamera cameraLookingAtCenterCoordinate:MLNLocationCoordinate2DFromLatLng(center)
@@ -3170,7 +3170,7 @@ static void *windowScreenContext = &windowScreenContext;
}
- (void)setPrefetchesTiles:(BOOL)prefetchesTiles {
self.mbglMap.setPrefetchZoomDelta(prefetchesTiles ? mbgl::util::DEFAULT_PREFETCH_ZOOM_DELTA : 0);
self.mbglMap.setPrefetchZoomDelta(prefetchesTiles ? mln::util::DEFAULT_PREFETCH_ZOOM_DELTA : 0);
}
- (BOOL)prefetchesTiles {
@@ -3764,8 +3764,8 @@ static void *windowScreenContext = &windowScreenContext;
centerPoint = self.userLocationAnnotationViewCenter;
}
double newZoom = round(self.zoomLevel) + log2(scaleFactor);
self.mbglMap.jumpTo(mbgl::CameraOptions().withZoom(newZoom).withAnchor(
mbgl::ScreenCoordinate{centerPoint.x, centerPoint.y}));
self.mbglMap.jumpTo(mln::CameraOptions().withZoom(newZoom).withAnchor(
mln::ScreenCoordinate{centerPoint.x, centerPoint.y}));
[self unrotateIfNeededForGesture];
_accessibilityValueAnnouncementIsPending = YES;
@@ -3855,7 +3855,7 @@ static void *windowScreenContext = &windowScreenContext;
return;
}
mbgl::CameraOptions cameraOptions;
mln::CameraOptions cameraOptions;
cameraOptions.center = MLNLatLngFromLocationCoordinate2D(centerCoordinate);
cameraOptions.padding = MLNEdgeInsetsFromNSEdgeInsets(insets);
cameraOptions.zoom = zoomLevel;
@@ -3863,7 +3863,7 @@ static void *windowScreenContext = &windowScreenContext;
cameraOptions.bearing = direction;
}
mbgl::AnimationOptions animationOptions;
mln::AnimationOptions animationOptions;
if (duration) {
animationOptions.duration.emplace(MLNDurationFromTimeInterval(duration));
animationOptions.easing.emplace(MLNUnitBezierForMediaTimingFunction(function));
@@ -3927,13 +3927,13 @@ static void *windowScreenContext = &windowScreenContext;
CGFloat duration = animated ? MLNAnimationDuration : 0;
self.mbglMap.easeTo(mbgl::CameraOptions().withZoom(zoomLevel),
self.mbglMap.easeTo(mln::CameraOptions().withZoom(zoomLevel),
MLNDurationFromTimeInterval(duration));
}
- (void)setMinimumZoomLevel:(double)minimumZoomLevel {
MLNLogDebug(@"Setting minimumZoomLevel: %f", minimumZoomLevel);
self.mbglMap.setBounds(mbgl::BoundOptions().withMinZoom(minimumZoomLevel));
self.mbglMap.setBounds(mln::BoundOptions().withMinZoom(minimumZoomLevel));
}
- (double)minimumZoomLevel {
@@ -3942,7 +3942,7 @@ static void *windowScreenContext = &windowScreenContext;
- (void)setMaximumZoomLevel:(double)maximumZoomLevel {
MLNLogDebug(@"Setting maximumZoomLevel: %f", maximumZoomLevel);
self.mbglMap.setBounds(mbgl::BoundOptions().withMaxZoom(maximumZoomLevel));
self.mbglMap.setBounds(mln::BoundOptions().withMaxZoom(maximumZoomLevel));
}
- (double)maximumZoomLevel {
@@ -3950,13 +3950,13 @@ static void *windowScreenContext = &windowScreenContext;
}
- (void)setMaximumScreenBounds:(MLNCoordinateBounds)maximumScreenBounds {
mbgl::LatLng sw = {maximumScreenBounds.sw.latitude, maximumScreenBounds.sw.longitude};
mbgl::LatLng ne = {maximumScreenBounds.ne.latitude, maximumScreenBounds.ne.longitude};
mbgl::BoundOptions newBounds =
mbgl::BoundOptions().withLatLngBounds(mbgl::LatLngBounds::hull(sw, ne));
mln::LatLng sw = {maximumScreenBounds.sw.latitude, maximumScreenBounds.sw.longitude};
mln::LatLng ne = {maximumScreenBounds.ne.latitude, maximumScreenBounds.ne.longitude};
mln::BoundOptions newBounds =
mln::BoundOptions().withLatLngBounds(mln::LatLngBounds::hull(sw, ne));
self.mbglMap.setBounds(newBounds);
self.mbglMap.setConstrainMode(mbgl::ConstrainMode::Screen);
self.mbglMap.setConstrainMode(mln::ConstrainMode::Screen);
}
- (MLNCoordinateBounds)maximumScreenBounds {
@@ -3970,7 +3970,7 @@ static void *windowScreenContext = &windowScreenContext;
- (void)setMinimumPitch:(CGFloat)minimumPitch {
MLNLogDebug(@"Setting minimumPitch: %f", minimumPitch);
self.mbglMap.setBounds(mbgl::BoundOptions().withMinPitch(minimumPitch));
self.mbglMap.setBounds(mln::BoundOptions().withMinPitch(minimumPitch));
}
- (CGFloat)maximumPitch {
@@ -3979,7 +3979,7 @@ static void *windowScreenContext = &windowScreenContext;
- (void)setMaximumPitch:(CGFloat)maximumPitch {
MLNLogDebug(@"Setting maximumPitch: %f", maximumPitch);
self.mbglMap.setBounds(mbgl::BoundOptions().withMaxPitch(maximumPitch));
self.mbglMap.setBounds(mln::BoundOptions().withMaxPitch(maximumPitch));
}
- (MLNCoordinateBounds)visibleCoordinateBounds {
@@ -4097,9 +4097,9 @@ static void *windowScreenContext = &windowScreenContext;
return;
}
mbgl::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(insets);
mln::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(insets);
padding += MLNEdgeInsetsFromNSEdgeInsets(self.contentInset);
std::vector<mbgl::LatLng> latLngs;
std::vector<mln::LatLng> latLngs;
latLngs.reserve(count);
for (NSUInteger i = 0; i < count; i++) {
latLngs.push_back({coordinates[i].latitude, coordinates[i].longitude});
@@ -4107,10 +4107,10 @@ static void *windowScreenContext = &windowScreenContext;
CLLocationDirection cameraDirection = direction >= 0 ? direction : self.direction;
mbgl::CameraOptions cameraOptions =
mln::CameraOptions cameraOptions =
self.mbglMap.cameraForLatLngs(latLngs, padding, cameraDirection);
mbgl::AnimationOptions animationOptions;
mln::AnimationOptions animationOptions;
if (duration > 0) {
animationOptions.duration.emplace(MLNDurationFromTimeInterval(duration));
animationOptions.easing.emplace(MLNUnitBezierForMediaTimingFunction(function));
@@ -4157,7 +4157,7 @@ static void *windowScreenContext = &windowScreenContext;
}
- (CLLocationDirection)direction {
return mbgl::util::wrap(*self.mbglMap.getCameraOptions().bearing, 0., 360.);
return mln::util::wrap(*self.mbglMap.getCameraOptions().bearing, 0., 360.);
}
- (void)setDirection:(CLLocationDirection)direction animated:(BOOL)animated {
@@ -4187,15 +4187,15 @@ static void *windowScreenContext = &windowScreenContext;
self.cameraChangeReasonBitmask |= MLNCameraChangeReasonProgrammatic;
if (self.userTrackingMode == MLNUserTrackingModeNone) {
self.mbglMap.easeTo(mbgl::CameraOptions().withBearing(direction),
self.mbglMap.easeTo(mln::CameraOptions().withBearing(direction),
MLNDurationFromTimeInterval(duration));
} else {
CGPoint anchor = self.userLocationAnnotationViewCenter;
mbgl::CameraOptions cameraOptions = mbgl::CameraOptions().withBearing(direction).withAnchor(
mbgl::ScreenCoordinate{anchor.x, anchor.y});
mln::CameraOptions cameraOptions = mln::CameraOptions().withBearing(direction).withAnchor(
mln::ScreenCoordinate{anchor.x, anchor.y});
mbgl::AnimationOptions animationOptions;
mln::AnimationOptions animationOptions;
animationOptions.duration.emplace(MLNDurationFromTimeInterval(duration));
if (CLLocationCoordinate2DIsValid(center)) {
@@ -4227,8 +4227,8 @@ static void *windowScreenContext = &windowScreenContext;
}
- (UIEdgeInsets)cameraEdgeInsets {
mbgl::CameraOptions cameraOptions = self.mbglMap.getCameraOptions();
return NSEdgeInsetsFromMLNEdgeInsets(cameraOptions.padding.value_or(mbgl::EdgeInsets()));
mln::CameraOptions cameraOptions = self.mbglMap.getCameraOptions();
return NSEdgeInsetsFromMLNEdgeInsets(cameraOptions.padding.value_or(mln::EdgeInsets()));
}
- (MLNMapCamera *)camera {
@@ -4294,7 +4294,7 @@ static void *windowScreenContext = &windowScreenContext;
edgePadding = MLNEdgeInsetsInsetEdgeInset(edgePadding, self.contentInset);
mbgl::AnimationOptions animationOptions;
mln::AnimationOptions animationOptions;
if (duration > 0) {
animationOptions.duration.emplace(MLNDurationFromTimeInterval(duration));
animationOptions.easing.emplace(MLNUnitBezierForMediaTimingFunction(function));
@@ -4329,8 +4329,8 @@ static void *windowScreenContext = &windowScreenContext;
self.cameraChangeReasonBitmask |= MLNCameraChangeReasonProgrammatic;
mbgl::CameraOptions cameraOptions = [self cameraOptionsObjectForAnimatingToCamera:camera
edgePadding:edgePadding];
mln::CameraOptions cameraOptions = [self cameraOptionsObjectForAnimatingToCamera:camera
edgePadding:edgePadding];
self.mbglMap.easeTo(cameraOptions, animationOptions);
[self didChangeValueForKey:@"camera"];
}
@@ -4387,7 +4387,7 @@ static void *windowScreenContext = &windowScreenContext;
return;
}
mbgl::AnimationOptions animationOptions;
mln::AnimationOptions animationOptions;
if (duration >= 0) {
animationOptions.duration = MLNDurationFromTimeInterval(duration);
}
@@ -4427,8 +4427,8 @@ static void *windowScreenContext = &windowScreenContext;
self.cameraChangeReasonBitmask |= MLNCameraChangeReasonProgrammatic;
mbgl::CameraOptions cameraOptions = [self cameraOptionsObjectForAnimatingToCamera:camera
edgePadding:insets];
mln::CameraOptions cameraOptions = [self cameraOptionsObjectForAnimatingToCamera:camera
edgePadding:insets];
self.mbglMap.flyTo(cameraOptions, animationOptions);
[self didChangeValueForKey:@"camera"];
}
@@ -4452,9 +4452,9 @@ static void *windowScreenContext = &windowScreenContext;
return self.residualCamera;
}
mbgl::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(insets);
mln::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(insets);
padding += MLNEdgeInsetsFromNSEdgeInsets(self.contentInset);
mbgl::CameraOptions cameraOptions =
mln::CameraOptions cameraOptions =
self.mbglMap.cameraForLatLngBounds(MLNLatLngBoundsFromCoordinateBounds(bounds), padding);
return [self cameraForCameraOptions:cameraOptions];
}
@@ -4466,14 +4466,14 @@ static void *windowScreenContext = &windowScreenContext;
return self.residualCamera;
}
mbgl::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(insets);
mln::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(insets);
padding += MLNEdgeInsetsFromNSEdgeInsets(self.contentInset);
MLNMapCamera *currentCamera = self.camera;
CGFloat pitch = camera.pitch < 0 ? currentCamera.pitch : camera.pitch;
CLLocationDirection direction = camera.heading < 0 ? currentCamera.heading : camera.heading;
mbgl::CameraOptions cameraOptions = self.mbglMap.cameraForLatLngBounds(
mln::CameraOptions cameraOptions = self.mbglMap.cameraForLatLngBounds(
MLNLatLngBoundsFromCoordinateBounds(bounds), padding, direction, pitch);
return [self cameraForCameraOptions:cameraOptions];
}
@@ -4485,14 +4485,14 @@ static void *windowScreenContext = &windowScreenContext;
return self.residualCamera;
}
mbgl::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(insets);
mln::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(insets);
padding += MLNEdgeInsetsFromNSEdgeInsets(self.contentInset);
MLNMapCamera *currentCamera = self.camera;
CGFloat pitch = camera.pitch < 0 ? currentCamera.pitch : camera.pitch;
CLLocationDirection direction = camera.heading < 0 ? currentCamera.heading : camera.heading;
mbgl::CameraOptions cameraOptions =
mln::CameraOptions cameraOptions =
self.mbglMap.cameraForGeometry([shape geometryObject], padding, direction, pitch);
return [self cameraForCameraOptions:cameraOptions];
@@ -4505,26 +4505,26 @@ static void *windowScreenContext = &windowScreenContext;
return self.residualCamera;
}
mbgl::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(insets);
mln::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(insets);
padding += MLNEdgeInsetsFromNSEdgeInsets(self.contentInset);
mbgl::CameraOptions cameraOptions =
mln::CameraOptions cameraOptions =
self.mbglMap.cameraForGeometry([shape geometryObject], padding, direction);
return [self cameraForCameraOptions:cameraOptions];
}
- (MLNMapCamera *)cameraForCameraOptions:(const mbgl::CameraOptions &)cameraOptions {
- (MLNMapCamera *)cameraForCameraOptions:(const mln::CameraOptions &)cameraOptions {
if (!_mbglMap) {
return self.residualCamera;
}
mbgl::CameraOptions mapCamera = self.mbglMap.getCameraOptions();
mln::CameraOptions mapCamera = self.mbglMap.getCameraOptions();
CLLocationCoordinate2D centerCoordinate = MLNLocationCoordinate2DFromLatLng(
cameraOptions.center ? *cameraOptions.center : *mapCamera.center);
double zoomLevel = cameraOptions.zoom ? *cameraOptions.zoom : self.zoomLevel;
CLLocationDirection direction =
cameraOptions.bearing ? mbgl::util::wrap(*cameraOptions.bearing, 0., 360.) : self.direction;
cameraOptions.bearing ? mln::util::wrap(*cameraOptions.bearing, 0., 360.) : self.direction;
CGFloat pitch = cameraOptions.pitch ? *cameraOptions.pitch : *mapCamera.pitch;
CLLocationDistance altitude =
MLNAltitudeForZoomLevel(zoomLevel, pitch, centerCoordinate.latitude, self.frame.size);
@@ -4543,9 +4543,9 @@ static void *windowScreenContext = &windowScreenContext;
/// Returns a CameraOptions object that specifies parameters for animating to
/// the given camera.
- (mbgl::CameraOptions)cameraOptionsObjectForAnimatingToCamera:(MLNMapCamera *)camera
edgePadding:(UIEdgeInsets)insets {
mbgl::CameraOptions options;
- (mln::CameraOptions)cameraOptionsObjectForAnimatingToCamera:(MLNMapCamera *)camera
edgePadding:(UIEdgeInsets)insets {
mln::CameraOptions options;
if (CLLocationCoordinate2DIsValid(camera.centerCoordinate)) {
options.center = MLNLatLngFromLocationCoordinate2D(camera.centerCoordinate);
}
@@ -4567,9 +4567,9 @@ static void *windowScreenContext = &windowScreenContext;
}
/// Converts a point in the view’s coordinate system to a geographic coordinate.
- (mbgl::LatLng)convertPoint:(CGPoint)point toLatLngFromView:(nullable UIView *)view {
- (mln::LatLng)convertPoint:(CGPoint)point toLatLngFromView:(nullable UIView *)view {
CGPoint convertedPoint = [self convertPoint:point fromView:view];
return self.mbglMap.latLngForPixel(mbgl::ScreenCoordinate(convertedPoint.x, convertedPoint.y))
return self.mbglMap.latLngForPixel(mln::ScreenCoordinate(convertedPoint.x, convertedPoint.y))
.wrapped();
}
@@ -4582,8 +4582,8 @@ static void *windowScreenContext = &windowScreenContext;
}
/// Converts a geographic coordinate to a point in the view’s coordinate system.
- (CGPoint)convertLatLng:(mbgl::LatLng)latLng toPointToView:(nullable UIView *)view {
mbgl::ScreenCoordinate pixel = self.mbglMap.pixelForLatLng(latLng);
- (CGPoint)convertLatLng:(mln::LatLng)latLng toPointToView:(nullable UIView *)view {
mln::ScreenCoordinate pixel = self.mbglMap.pixelForLatLng(latLng);
return [self convertPoint:CGPointMake(pixel.x, pixel.y) toView:view];
}
@@ -4597,7 +4597,7 @@ static void *windowScreenContext = &windowScreenContext;
/// Converts a geographic bounding box to a rectangle in the view’s coordinate
/// system.
- (CGRect)convertLatLngBounds:(mbgl::LatLngBounds)bounds toRectToView:(nullable UIView *)view {
- (CGRect)convertLatLngBounds:(mln::LatLngBounds)bounds toRectToView:(nullable UIView *)view {
auto northwest = bounds.northwest();
auto northeast = bounds.northeast();
auto southwest = bounds.southwest();
@@ -4612,7 +4612,7 @@ static void *windowScreenContext = &windowScreenContext;
southwest.unwrapForShortestPath(center);
southeast.unwrapForShortestPath(center);
auto correctedLatLngBounds = mbgl::LatLngBounds::empty();
auto correctedLatLngBounds = mln::LatLngBounds::empty();
correctedLatLngBounds.extend(northwest);
correctedLatLngBounds.extend(northeast);
correctedLatLngBounds.extend(southwest);
@@ -4627,8 +4627,8 @@ static void *windowScreenContext = &windowScreenContext;
/// Converts a rectangle in the given view’s coordinate system to a geographic
/// bounding box.
- (mbgl::LatLngBounds)convertRect:(CGRect)rect toLatLngBoundsFromView:(nullable UIView *)view {
auto bounds = mbgl::LatLngBounds::empty();
- (mln::LatLngBounds)convertRect:(CGRect)rect toLatLngBoundsFromView:(nullable UIView *)view {
auto bounds = mln::LatLngBounds::empty();
auto topLeft = [self convertPoint:{CGRectGetMinX(rect), CGRectGetMinY(rect)}
toLatLngFromView:view];
auto topRight = [self convertPoint:{CGRectGetMaxX(rect), CGRectGetMinY(rect)}
@@ -4656,12 +4656,12 @@ static void *windowScreenContext = &windowScreenContext;
}
- (CLLocationDistance)metersPerPointAtLatitude:(CLLocationDegrees)latitude {
return mbgl::Projection::getMetersPerPixelAtLatitude(latitude, self.zoomLevel);
return mln::Projection::getMetersPerPixelAtLatitude(latitude, self.zoomLevel);
}
- (CLLocationDistance)metersPerPointAtLatitude:(CLLocationDegrees)latitude
zoomLevel:(double)zoomLevel {
return mbgl::Projection::getMetersPerPixelAtLatitude(latitude, zoomLevel);
return mln::Projection::getMetersPerPixelAtLatitude(latitude, zoomLevel);
}
- (MLNMapProjection *)mapProjection {
@@ -4863,7 +4863,7 @@ static void *windowScreenContext = &windowScreenContext;
annotationImagesForAnnotation[annotationValue] = annotationImage;
}
MLNAnnotationTag annotationTag = self.mbglMap.addAnnotation(mbgl::SymbolAnnotation{
MLNAnnotationTag annotationTag = self.mbglMap.addAnnotation(mln::SymbolAnnotation{
MLNPointFromLocationCoordinate2D(annotation.coordinate), symbolName.UTF8String});
MLNAnnotationContext context;
@@ -5010,14 +5010,14 @@ static void *windowScreenContext = &windowScreenContext;
return 1.0;
}
- (mbgl::Color)strokeColorForShapeAnnotation:(MLNShape *)annotation {
- (mln::Color)strokeColorForShapeAnnotation:(MLNShape *)annotation {
UIColor *color = (_delegateHasStrokeColorsForShapeAnnotations
? [self.delegate mapView:self strokeColorForShapeAnnotation:annotation]
: self.tintColor);
return color.mgl_color;
}
- (mbgl::Color)fillColorForPolygonAnnotation:(MLNPolygon *)annotation {
- (mln::Color)fillColorForPolygonAnnotation:(MLNPolygon *)annotation {
UIColor *color = (_delegateHasFillColorsForShapeAnnotations
? [self.delegate mapView:self fillColorForPolygonAnnotation:annotation]
: self.tintColor);
@@ -5864,7 +5864,7 @@ static void *windowScreenContext = &windowScreenContext;
return;
}
mbgl::LatLngBounds bounds = mbgl::LatLngBounds::empty();
mln::LatLngBounds bounds = mln::LatLngBounds::empty();
for (id<MLNAnnotation> annotation in annotations) {
if ([annotation conformsToProtocol:@protocol(MLNOverlay)]) {
@@ -5919,10 +5919,10 @@ static void *windowScreenContext = &windowScreenContext;
toAnnotationsWithImageReuseIdentifier:(NSString *)reuseIdentifier {
for (auto &pair : _annotationContextsByAnnotationTag) {
if ([pair.second.imageReuseIdentifier isEqualToString:reuseIdentifier]) {
const mbgl::Point<double> point =
const mln::Point<double> point =
MLNPointFromLocationCoordinate2D(pair.second.annotation.coordinate);
self.mbglMap.updateAnnotation(pair.first,
mbgl::SymbolAnnotation{point, iconIdentifier.UTF8String ?: ""});
mln::SymbolAnnotation{point, iconIdentifier.UTF8String ?: ""});
}
}
}
@@ -6449,13 +6449,13 @@ static void *windowScreenContext = &windowScreenContext;
CLLocationDirection direction = -1;
if (self.userTrackingMode == MLNUserTrackingModeFollowWithCourse) {
if (CLLocationCoordinate2DIsValid(self.targetCoordinate)) {
mbgl::LatLng userLatLng = MLNLatLngFromLocationCoordinate2D(self.userLocation.coordinate);
mbgl::LatLng targetLatLng = MLNLatLngFromLocationCoordinate2D(self.targetCoordinate);
mbgl::ProjectedMeters userMeters = mbgl::Projection::projectedMetersForLatLng(userLatLng);
mbgl::ProjectedMeters targetMeters = mbgl::Projection::projectedMetersForLatLng(targetLatLng);
mln::LatLng userLatLng = MLNLatLngFromLocationCoordinate2D(self.userLocation.coordinate);
mln::LatLng targetLatLng = MLNLatLngFromLocationCoordinate2D(self.targetCoordinate);
mln::ProjectedMeters userMeters = mln::Projection::projectedMetersForLatLng(userLatLng);
mln::ProjectedMeters targetMeters = mln::Projection::projectedMetersForLatLng(targetLatLng);
double angle = atan2(targetMeters.easting() - userMeters.easting(),
targetMeters.northing() - userMeters.northing());
direction = mbgl::util::wrap(MLNDegreesFromRadians(angle), 0., 360.);
direction = mln::util::wrap(MLNDegreesFromRadians(angle), 0., 360.);
} else {
direction = self.userLocation.location.course;
}
@@ -6623,7 +6623,7 @@ static void *windowScreenContext = &windowScreenContext;
predicate:(NSPredicate *)predicate {
MLNLogDebug(@"Querying visibleFeaturesAtPoint: %@ inStyleLayersWithIdentifiers: %@ predicate: %@",
NSStringFromCGPoint(point), styleLayerIdentifiers, predicate);
mbgl::ScreenCoordinate screenCoordinate = {point.x, point.y};
mln::ScreenCoordinate screenCoordinate = {point.x, point.y};
std::optional<std::vector<std::string>> optionalLayerIDs;
if (styleLayerIdentifiers) {
@@ -6636,12 +6636,12 @@ static void *windowScreenContext = &windowScreenContext;
optionalLayerIDs = layerIDs;
}
std::optional<mbgl::style::Filter> optionalFilter;
std::optional<mln::style::Filter> optionalFilter;
if (predicate) {
optionalFilter = predicate.mgl_filter;
}
std::vector<mbgl::Feature> features = _rendererFrontend->getRenderer()->queryRenderedFeatures(
std::vector<mln::Feature> features = _rendererFrontend->getRenderer()->queryRenderedFeatures(
screenCoordinate, {optionalLayerIDs, optionalFilter});
return MLNFeaturesFromMBGLFeatures(features);
}
@@ -6665,7 +6665,7 @@ static void *windowScreenContext = &windowScreenContext;
predicate:(NSPredicate *)predicate {
MLNLogDebug(@"Querying visibleFeaturesInRect: %@ inStyleLayersWithIdentifiers: %@ predicate: %@",
NSStringFromCGRect(rect), styleLayerIdentifiers, predicate);
mbgl::ScreenBox screenBox = {
mln::ScreenBox screenBox = {
{CGRectGetMinX(rect), CGRectGetMinY(rect)},
{CGRectGetMaxX(rect), CGRectGetMaxY(rect)},
};
@@ -6681,12 +6681,12 @@ static void *windowScreenContext = &windowScreenContext;
optionalLayerIDs = layerIDs;
}
std::optional<mbgl::style::Filter> optionalFilter;
std::optional<mln::style::Filter> optionalFilter;
if (predicate) {
optionalFilter = predicate.mgl_filter;
}
std::vector<mbgl::Feature> features = _rendererFrontend->getRenderer()->queryRenderedFeatures(
std::vector<mln::Feature> features = _rendererFrontend->getRenderer()->queryRenderedFeatures(
screenBox, {optionalLayerIDs, optionalFilter});
return MLNFeaturesFromMBGLFeatures(features);
}
@@ -6882,7 +6882,7 @@ static void *windowScreenContext = &windowScreenContext;
}
- (void)mapViewDidFinishRenderingFrameFullyRendered:(BOOL)fullyRendered
renderingStats:(const mbgl::gfx::RenderingStats &)stats {
renderingStats:(const mln::gfx::RenderingStats &)stats {
if (!_mbglMap) {
return;
}
@@ -7549,35 +7549,35 @@ static void *windowScreenContext = &windowScreenContext;
Adds a plug-in layer that is external to this library
*/
- (void)addPluginLayerType:(Class)pluginLayerClass {
auto layerManager = mbgl::LayerManager::get();
auto darwinLayerManager = (mbgl::LayerManagerDarwin *)layerManager;
auto layerManager = mln::LayerManager::get();
auto darwinLayerManager = (mln::LayerManagerDarwin *)layerManager;
MLNPluginLayerCapabilities *capabilities = [pluginLayerClass layerCapabilities];
std::string layerType = [capabilities.layerID UTF8String];
// Default values
mbgl::style::LayerTypeInfo::Source source = mbgl::style::LayerTypeInfo::Source::NotRequired;
mbgl::style::LayerTypeInfo::TileKind tileKind = mbgl::style::LayerTypeInfo::TileKind::NotRequired;
mbgl::style::LayerTypeInfo::FadingTiles fadingTiles =
mbgl::style::LayerTypeInfo::FadingTiles::NotRequired;
mbgl::style::LayerTypeInfo::Layout layout = mbgl::style::LayerTypeInfo::Layout::NotRequired;
mbgl::style::LayerTypeInfo::CrossTileIndex crossTileIndex =
mbgl::style::LayerTypeInfo::CrossTileIndex::NotRequired;
mln::style::LayerTypeInfo::Source source = mln::style::LayerTypeInfo::Source::NotRequired;
mln::style::LayerTypeInfo::TileKind tileKind = mln::style::LayerTypeInfo::TileKind::NotRequired;
mln::style::LayerTypeInfo::FadingTiles fadingTiles =
mln::style::LayerTypeInfo::FadingTiles::NotRequired;
mln::style::LayerTypeInfo::Layout layout = mln::style::LayerTypeInfo::Layout::NotRequired;
mln::style::LayerTypeInfo::CrossTileIndex crossTileIndex =
mln::style::LayerTypeInfo::CrossTileIndex::NotRequired;
mbgl::style::LayerTypeInfo::Pass3D pass3D = mbgl::style::LayerTypeInfo::Pass3D::NotRequired;
mln::style::LayerTypeInfo::Pass3D pass3D = mln::style::LayerTypeInfo::Pass3D::NotRequired;
if (capabilities.requiresPass3D) {
pass3D = mbgl::style::LayerTypeInfo::Pass3D::Required;
pass3D = mln::style::LayerTypeInfo::Pass3D::Required;
}
auto factory = std::make_unique<mbgl::PluginLayerPeerFactory>(
auto factory = std::make_unique<mln::PluginLayerPeerFactory>(
layerType, source, pass3D, layout, fadingTiles, crossTileIndex, tileKind);
__weak MLNMapView *weakMapView = self;
Class layerClass = pluginLayerClass;
factory->setOnLayerCreatedEvent([layerClass, weakMapView,
pluginLayerClass](mbgl::style::PluginLayer *pluginLayer) {
pluginLayerClass](mln::style::PluginLayer *pluginLayer) {
// NSLog(@"Creating Plugin Layer: %@", layerClass);
MLNPluginLayer *layer = [[layerClass alloc] init];
if (!weakMapView.pluginLayers) {
@@ -7591,25 +7591,25 @@ static void *windowScreenContext = &windowScreenContext;
pluginLayer->_platformReference = (__bridge void *)layer;
MLNPluginLayerCapabilities *capabilities = [pluginLayerClass layerCapabilities];
auto pluginLayerImpl = (mbgl::style::PluginLayer::Impl *)pluginLayer->baseImpl.get();
auto pluginLayerImpl = (mln::style::PluginLayer::Impl *)pluginLayer->baseImpl.get();
auto &pm = pluginLayerImpl->_propertyManager;
for (MLNPluginLayerProperty *property in capabilities.layerProperties) {
mbgl::style::PluginLayerProperty *p = new mbgl::style::PluginLayerProperty();
mln::style::PluginLayerProperty *p = new mln::style::PluginLayerProperty();
switch (property.propertyType) {
case MLNPluginLayerPropertyTypeSingleFloat:
p->_propertyType = mbgl::style::PluginLayerProperty::PropertyType::SingleFloat;
p->_propertyType = mln::style::PluginLayerProperty::PropertyType::SingleFloat;
p->_defaultSingleFloatValue = property.singleFloatDefaultValue;
break;
case MLNPluginLayerPropertyTypeColor: {
p->_propertyType = mbgl::style::PluginLayerProperty::PropertyType::Color;
p->_propertyType = mln::style::PluginLayerProperty::PropertyType::Color;
if (property.colorDefaultValue) {
CGFloat r, g, b, a;
[property.colorDefaultValue getRed:&r green:&g blue:&b alpha:&a];
p->_defaultColorValue = mbgl::Color(r, g, b, a);
p->_defaultColorValue = mln::Color(r, g, b, a);
}
} break;
default:
p->_propertyType = mbgl::style::PluginLayerProperty::PropertyType::Unknown;
p->_propertyType = mln::style::PluginLayerProperty::PropertyType::Unknown;
break;
}
p->_propertyName = [property.propertyName UTF8String];
@@ -7617,10 +7617,10 @@ static void *windowScreenContext = &windowScreenContext;
}
// Set the render function
auto renderFunction = [weakPlugInLayer, weakMapView](mbgl::PaintParameters &paintParameters) {
auto renderFunction = [weakPlugInLayer, weakMapView](mln::PaintParameters &paintParameters) {
#if MLN_RENDER_BACKEND_METAL
const mbgl::mtl::RenderPass &renderPass =
static_cast<mbgl::mtl::RenderPass &>(*paintParameters.renderPass);
const mln::mtl::RenderPass &renderPass =
static_cast<mln::mtl::RenderPass &>(*paintParameters.renderPass);
id encoder = (__bridge id)renderPass.getMetalEncoder().get();
#else
id encoder = nil;
@@ -7628,14 +7628,14 @@ static void *windowScreenContext = &windowScreenContext;
MLNMapView *strongMapView = weakMapView;
const mbgl::TransformState &state = paintParameters.state;
const mln::TransformState &state = paintParameters.state;
MLNPluginLayerDrawingContext drawingContext;
drawingContext.size = CGSizeMake(state.getSize().width, state.getSize().height);
drawingContext.centerCoordinate =
CLLocationCoordinate2DMake(state.getLatLng().latitude(), state.getLatLng().longitude());
drawingContext.zoomLevel = state.getZoom();
drawingContext.direction = mbgl::util::rad2deg(-state.getBearing());
drawingContext.direction = mln::util::rad2deg(-state.getBearing());
drawingContext.pitch = state.getPitch();
drawingContext.fieldOfView = state.getFieldOfView();
drawingContext.projectionMatrix = MLNMatrix4Make(paintParameters.transformParams.projMatrix);
@@ -7650,7 +7650,7 @@ static void *windowScreenContext = &windowScreenContext;
};
// Set the lambdas
// auto pluginLayerImpl = (mbgl::style::PluginLayer::Impl *)pluginLayer->baseImpl.get();
// auto pluginLayerImpl = (mln::style::PluginLayer::Impl *)pluginLayer->baseImpl.get();
pluginLayerImpl->setRenderFunction(renderFunction);
// Set the update properties function

View File

@@ -3,7 +3,7 @@
#import "MLNTileOperation.h"
#import "MLNUserLocationAnnotationView.h"
namespace mbgl {
namespace mln {
class Map;
class Renderer;
@@ -11,7 +11,7 @@ namespace gfx {
struct RenderingStats;
}
} // namespace mbgl
} // namespace mln
class MLNMapViewImpl;
@class MLNSource;
@@ -22,7 +22,7 @@ FOUNDATION_EXTERN const NSTimeInterval MLNAnimationDuration;
/// Minimum size of an annotation’s accessibility element.
FOUNDATION_EXTERN const CGSize MLNAnnotationAccessibilityElementMinimumSize;
/// Indicates that a method (that uses `mbgl::Map`) was called after app termination.
/// Indicates that a method (that uses `mln::Map`) was called after app termination.
FOUNDATION_EXTERN MLN_EXPORT MLNExceptionName const _Nonnull MLNUnderlyingMapUnavailableException;
@interface MLNMapView (Private)
@@ -42,7 +42,7 @@ FOUNDATION_EXTERN MLN_EXPORT MLNExceptionName const _Nonnull MLNUnderlyingMapUna
- (void)mapViewDidFailLoadingMapWithError:(nonnull NSError *)error;
- (void)mapViewWillStartRenderingFrame;
- (void)mapViewDidFinishRenderingFrameFullyRendered:(BOOL)fullyRendered
renderingStats:(const mbgl::gfx::RenderingStats &)stats;
renderingStats:(const mln::gfx::RenderingStats &)stats;
- (void)mapViewWillStartRenderingMap;
- (void)mapViewDidFinishRenderingMapFullyRendered:(BOOL)fullyRendered;
- (void)mapViewDidBecomeIdle;
@@ -84,8 +84,8 @@ FOUNDATION_EXTERN MLN_EXPORT MLNExceptionName const _Nonnull MLNUnderlyingMapUna
/// Synchronously render a frame of the map.
- (BOOL)renderSync;
- (mbgl::Map &)mbglMap;
- (nonnull mbgl::Renderer *)renderer;
- (mln::Map &)mbglMap;
- (nonnull mln::Renderer *)renderer;
/** Returns whether the map view is currently loading or processing any assets required to render
* the map */

View File

@@ -5,13 +5,13 @@
@interface UIColor (MLNAdditions)
- (mbgl::Color)mgl_color;
- (mln::Color)mgl_color;
- (mbgl::style::PropertyValue<mbgl::Color>)mgl_colorPropertyValue;
- (mln::style::PropertyValue<mln::Color>)mgl_colorPropertyValue;
- (mbgl::Color)mgl_colorForPremultipliedValue;
- (mln::Color)mgl_colorForPremultipliedValue;
+ (UIColor *)mgl_colorWithColor:(mbgl::Color)color;
+ (UIColor *)mgl_colorWithColor:(mln::Color)color;
@end

View File

@@ -2,36 +2,36 @@
@implementation UIColor (MLNAdditions)
- (mbgl::Color)mgl_color {
- (mln::Color)mgl_color {
CGFloat r, g, b, a;
[self getRed:&r green:&g blue:&b alpha:&a];
// UIColor provides non-premultiplied color components, so we have to premultiply each
// color component with the alpha value to transform it into a valid
// mbgl::Color which expects premultiplied color components.
// mln::Color which expects premultiplied color components.
return {static_cast<float>(r * a), static_cast<float>(g * a), static_cast<float>(b * a),
static_cast<float>(a)};
}
// Intended to be used when providing colors on the basis of an NSExpression
- (mbgl::Color)mgl_colorForPremultipliedValue {
- (mln::Color)mgl_colorForPremultipliedValue {
CGFloat r, g, b, a;
[self getRed:&r green:&g blue:&b alpha:&a];
return {static_cast<float>(r), static_cast<float>(g), static_cast<float>(b),
static_cast<float>(a)};
}
- (mbgl::style::PropertyValue<mbgl::Color>)mgl_colorPropertyValue {
mbgl::Color color = self.mgl_color;
- (mln::style::PropertyValue<mln::Color>)mgl_colorPropertyValue {
mln::Color color = self.mgl_color;
return {{color.r, color.g, color.b, color.a}};
}
+ (UIColor *)mgl_colorWithColor:(mbgl::Color)color {
+ (UIColor *)mgl_colorWithColor:(mln::Color)color {
// If there is no alpha value, return original color values.
if (color.a == 0.0f) {
return [UIColor colorWithRed:color.r green:color.g blue:color.b alpha:color.a];
}
// mbgl::Color provides premultiplied color components, so we have to convert color
// mln::Color provides premultiplied color components, so we have to convert color
// components to non-premultiplied values to return a valid UIColor object.
float red = static_cast<float>((color.r / color.a));
float green = static_cast<float>((color.g / color.a));

View File

@@ -10,14 +10,14 @@ FOUNDATION_EXTERN MLN_EXPORT MLNExceptionName const MLNResourceNotFoundException
@interface UIImage (MLNAdditions)
- (nullable instancetype)initWithMLNStyleImage:(const mbgl::style::Image &)styleImage;
- (nullable instancetype)initWithMLNStyleImage:(const mln::style::Image &)styleImage;
- (nullable instancetype)initWithMLNPremultipliedImage:(const mbgl::PremultipliedImage &&)mbglImage
- (nullable instancetype)initWithMLNPremultipliedImage:(const mln::PremultipliedImage &&)mbglImage
scale:(CGFloat)scale;
- (std::unique_ptr<mbgl::style::Image>)mgl_styleImageWithIdentifier:(NSString *)identifier;
- (std::unique_ptr<mln::style::Image>)mgl_styleImageWithIdentifier:(NSString *)identifier;
- (mbgl::PremultipliedImage)mgl_premultipliedImage;
- (mln::PremultipliedImage)mgl_premultipliedImage;
+ (UIImage *)mgl_resourceImageNamed:(NSString *)imageName;

View File

@@ -14,7 +14,7 @@ BOOL MLNEdgeInsetsIsZero(UIEdgeInsets edgeInsets) {
@implementation UIImage (MLNAdditions)
- (nullable instancetype)initWithMLNStyleImage:(const mbgl::style::Image &)styleImage {
- (nullable instancetype)initWithMLNStyleImage:(const mln::style::Image &)styleImage {
CGImageRef image = CGImageCreateWithMLNPremultipliedImage(styleImage.getImage().clone());
if (!image) {
return nil;
@@ -45,7 +45,7 @@ BOOL MLNEdgeInsetsIsZero(UIEdgeInsets edgeInsets) {
return self;
}
- (nullable instancetype)initWithMLNPremultipliedImage:(const mbgl::PremultipliedImage &&)mbglImage
- (nullable instancetype)initWithMLNPremultipliedImage:(const mln::PremultipliedImage &&)mbglImage
scale:(CGFloat)scale {
CGImageRef image = CGImageCreateWithMLNPremultipliedImage(mbglImage.clone());
if (!image) {
@@ -58,8 +58,8 @@ BOOL MLNEdgeInsetsIsZero(UIEdgeInsets edgeInsets) {
return self;
}
- (std::unique_ptr<mbgl::style::Image>)mgl_styleImageWithIdentifier:(NSString *)identifier {
mbgl::style::ImageStretches stretchX, stretchY;
- (std::unique_ptr<mln::style::Image>)mgl_styleImageWithIdentifier:(NSString *)identifier {
mln::style::ImageStretches stretchX, stretchY;
if (self.resizingMode == UIImageResizingModeStretch) {
stretchX.push_back({
self.capInsets.left * self.scale,
@@ -71,9 +71,9 @@ BOOL MLNEdgeInsetsIsZero(UIEdgeInsets edgeInsets) {
});
}
std::optional<mbgl::style::ImageContent> imageContent;
std::optional<mln::style::ImageContent> imageContent;
if (!MLNEdgeInsetsIsZero(self.capInsets)) {
imageContent = (mbgl::style::ImageContent){
imageContent = (mln::style::ImageContent){
.left = static_cast<float>(self.capInsets.left * self.scale),
.top = static_cast<float>(self.capInsets.top * self.scale),
.right = static_cast<float>((self.size.width - self.capInsets.right) * self.scale),
@@ -82,12 +82,12 @@ BOOL MLNEdgeInsetsIsZero(UIEdgeInsets edgeInsets) {
}
BOOL isTemplate = self.renderingMode == UIImageRenderingModeAlwaysTemplate;
return std::make_unique<mbgl::style::Image>([identifier UTF8String], self.mgl_premultipliedImage,
static_cast<float>(self.scale), isTemplate, stretchX,
stretchY, imageContent);
return std::make_unique<mln::style::Image>([identifier UTF8String], self.mgl_premultipliedImage,
static_cast<float>(self.scale), isTemplate, stretchX,
stretchY, imageContent);
}
- (mbgl::PremultipliedImage)mgl_premultipliedImage {
- (mln::PremultipliedImage)mgl_premultipliedImage {
return MLNPremultipliedImageFromCGImage(self.CGImage);
}

View File

@@ -91,7 +91,7 @@
for (NSNumber *degrees in
@[ @-999, @-359, @-240, @-180, @-90, @-45, @0, @45, @90, @180, @240, @360, @999 ]) {
self.mapView.direction = [degrees doubleValue];
CGFloat wrappedDirection = mbgl::util::wrap(-self.mapView.direction, 0., 360.);
CGFloat wrappedDirection = mln::util::wrap(-self.mapView.direction, 0., 360.);
CGAffineTransform rotation =
CGAffineTransformMakeRotation(MLNRadiansFromDegrees(wrappedDirection));
XCTAssertTrue(

View File

@@ -41,7 +41,7 @@
for (NSNumber *degrees in
@[ @-999, @-359, @-240, @-180, @-90, @-45, @0, @45, @90, @180, @240, @360, @999 ]) {
double inputDegrees = [degrees doubleValue];
double wrappedDegrees = mbgl::util::wrap(inputDegrees, 0., 360.);
double wrappedDegrees = mln::util::wrap(inputDegrees, 0., 360.);
self.mapView.direction = inputDegrees;
XCTAssertEqualWithAccuracy(self.mapView.direction, wrappedDegrees, 0.001);
@@ -70,7 +70,7 @@
[[UIRotationGestureRecognizerMock alloc] initWithTarget:nil action:nil];
gesture.state = UIGestureRecognizerStateBegan;
gesture.rotation = MLNRadiansFromDegrees(30);
CGFloat wrappedRotation = mbgl::util::wrap(-MLNDegreesFromRadians(gesture.rotation), 0., 360.);
CGFloat wrappedRotation = mln::util::wrap(-MLNDegreesFromRadians(gesture.rotation), 0., 360.);
// Disabled
{
@@ -117,7 +117,7 @@
gesture.state = UIGestureRecognizerStateChanged;
gesture.rotation = MLNRadiansFromDegrees([degrees doubleValue]);
[self.mapView handleRotateGesture:gesture];
CGFloat wrappedRotation = mbgl::util::wrap(-MLNDegreesFromRadians(gesture.rotation), 0., 360.);
CGFloat wrappedRotation = mln::util::wrap(-MLNDegreesFromRadians(gesture.rotation), 0., 360.);
XCTAssertEqualWithAccuracy(self.mapView.direction, wrappedRotation, 0.001,
@"Map direction should match gesture rotation for input of %@°.",
degrees);

View File

@@ -70,7 +70,7 @@
- (void)testHandlePinchGestureContentInset {
UIEdgeInsets contentInset = UIEdgeInsetsMake(1, 1, 1, 1);
self.mapView.contentInset = contentInset;
mbgl::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(self.mapView.contentInset);
mln::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(self.mapView.contentInset);
auto cameraPadding = self.mapView.mbglMap.getCameraOptions().padding;
XCTAssertEqual(padding, cameraPadding,
@"MLNMapView's contentInset property should match camera's padding.");
@@ -94,7 +94,7 @@
[self.mapView handlePinchGesture:pinchGesture];
XCTAssertNotEqual(padding, cameraPadding);
mbgl::EdgeInsets edgePadding = MLNEdgeInsetsFromNSEdgeInsets(contentInset) + padding;
mln::EdgeInsets edgePadding = MLNEdgeInsetsFromNSEdgeInsets(contentInset) + padding;
pinchGesture.state = UIGestureRecognizerStateChanged;
[self.mapView handlePinchGesture:pinchGesture];
@@ -112,7 +112,7 @@
- (void)testHandleRotateGestureContentInset {
UIEdgeInsets contentInset = UIEdgeInsetsMake(1, 1, 1, 1);
self.mapView.contentInset = contentInset;
mbgl::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(self.mapView.contentInset);
mln::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(self.mapView.contentInset);
auto cameraPadding = self.mapView.mbglMap.getCameraOptions().padding;
XCTAssertEqual(padding, cameraPadding,
@"MLNMapView's contentInset property should match camera's padding.");
@@ -136,7 +136,7 @@
[self.mapView handleRotateGesture:rotateGesture];
XCTAssertNotEqual(padding, cameraPadding);
mbgl::EdgeInsets edgePadding = MLNEdgeInsetsFromNSEdgeInsets(contentInset) + padding;
mln::EdgeInsets edgePadding = MLNEdgeInsetsFromNSEdgeInsets(contentInset) + padding;
rotateGesture.state = UIGestureRecognizerStateChanged;
[self.mapView handleRotateGesture:rotateGesture];
@@ -154,7 +154,7 @@
- (void)testHandleDoubleTapGestureContentInset {
UIEdgeInsets contentInset = UIEdgeInsetsMake(1, 1, 1, 1);
self.mapView.contentInset = contentInset;
mbgl::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(self.mapView.contentInset);
mln::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(self.mapView.contentInset);
auto cameraPadding = self.mapView.mbglMap.getCameraOptions().padding;
XCTAssertEqual(padding, cameraPadding,
@"MLNMapView's contentInset property should match camera's padding.");
@@ -176,7 +176,7 @@
doubleTapGesture.mockTappedView = self.mapView;
doubleTapGesture.mockTappedPoint = CGPointMake(1.0, 1.0);
mbgl::EdgeInsets edgePadding = MLNEdgeInsetsFromNSEdgeInsets(contentInset) + padding;
mln::EdgeInsets edgePadding = MLNEdgeInsetsFromNSEdgeInsets(contentInset) + padding;
[self.mapView handleDoubleTapGesture:doubleTapGesture];
_doubleTapExpectation = [self expectationWithDescription:@"Double tap gesture animation."];
@@ -195,7 +195,7 @@
- (void)testHandleTwoFingerTapGesture {
UIEdgeInsets contentInset = UIEdgeInsetsMake(1, 1, 1, 1);
self.mapView.contentInset = contentInset;
mbgl::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(self.mapView.contentInset);
mln::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(self.mapView.contentInset);
auto cameraPadding = self.mapView.mbglMap.getCameraOptions().padding;
XCTAssertEqual(padding, cameraPadding,
@"MLNMapView's contentInset property should match camera's padding.");
@@ -226,7 +226,7 @@
});
[self waitForExpectationsWithTimeout:10 handler:nil];
mbgl::EdgeInsets edgePadding = MLNEdgeInsetsFromNSEdgeInsets(contentInset) + padding;
mln::EdgeInsets edgePadding = MLNEdgeInsetsFromNSEdgeInsets(contentInset) + padding;
cameraPadding = self.mapView.mbglMap.getCameraOptions().padding;
XCTAssertEqual(edgePadding, cameraPadding,
@"When a gesture recognizer is performed camera paddings must not be changed.");
@@ -235,7 +235,7 @@
- (void)testHandleQuickZoomGesture {
UIEdgeInsets contentInset = UIEdgeInsetsMake(1, 1, 1, 1);
self.mapView.contentInset = contentInset;
mbgl::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(self.mapView.contentInset);
mln::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(self.mapView.contentInset);
auto cameraPadding = self.mapView.mbglMap.getCameraOptions().padding;
XCTAssertEqual(padding, cameraPadding,
@"MLNMapView's contentInset property should match camera's padding.");
@@ -270,7 +270,7 @@
});
[self waitForExpectationsWithTimeout:10 handler:nil];
mbgl::EdgeInsets edgePadding = MLNEdgeInsetsFromNSEdgeInsets(contentInset) + padding;
mln::EdgeInsets edgePadding = MLNEdgeInsetsFromNSEdgeInsets(contentInset) + padding;
cameraPadding = self.mapView.mbglMap.getCameraOptions().padding;
XCTAssertEqual(edgePadding, cameraPadding,
@@ -286,7 +286,7 @@
- (void)testHandleTwoFingerDragGesture {
UIEdgeInsets contentInset = UIEdgeInsetsMake(1, 1, 1, 1);
self.mapView.contentInset = contentInset;
mbgl::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(self.mapView.contentInset);
mln::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(self.mapView.contentInset);
auto cameraPadding = self.mapView.mbglMap.getCameraOptions().padding;
XCTAssertEqual(padding, cameraPadding,
@"MLNMapView's contentInset property should match camera's padding.");
@@ -328,7 +328,7 @@
});
[self waitForExpectationsWithTimeout:10 handler:nil];
mbgl::EdgeInsets edgePadding = MLNEdgeInsetsFromNSEdgeInsets(contentInset) + padding;
mln::EdgeInsets edgePadding = MLNEdgeInsetsFromNSEdgeInsets(contentInset) + padding;
cameraPadding = self.mapView.mbglMap.getCameraOptions().padding;
XCTAssertEqual(edgePadding, cameraPadding,

View File

@@ -196,7 +196,7 @@
rotate.rotation = MLNRadiansFromDegrees([degrees doubleValue]);
[self.mapView handleRotateGesture:rotate];
CGFloat wrappedRotation = mbgl::util::wrap(-MLNDegreesFromRadians(rotate.rotation), 0., 360.);
CGFloat wrappedRotation = mln::util::wrap(-MLNDegreesFromRadians(rotate.rotation), 0., 360.);
// Check that the direction property now matches the gesture's rotation.
XCTAssertEqualWithAccuracy(self.mapView.direction, wrappedRotation, 0.001,

View File

@@ -17,13 +17,13 @@ bool TestRunner::startTest(const std::string& basePath) {
argv.push_back(nullptr);
if (chdir(basePath.c_str())) {
mbgl::Log::Error(mbgl::Event::General, "Failed to change the directory to " + basePath);
mln::Log::Error(mln::Event::General, "Failed to change the directory to " + basePath);
return false;
}
mbgl::Log::Info(mbgl::Event::General, "Start TestRunner");
int status = mbgl::runTests(static_cast<uint32_t>(argv.size()), argv.data());
mbgl::Log::Info(mbgl::Event::General, "TestRunner finished with status: '" + std::to_string(status) + "'");
mln::Log::Info(mln::Event::General, "Start TestRunner");
int status = mln::runTests(static_cast<uint32_t>(argv.size()), argv.data());
mln::Log::Info(mln::Event::General, "TestRunner finished with status: '" + std::to_string(status) + "'");
return status == 0;
}