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

@@ -8,17 +8,17 @@
typedef struct _CGLContextObject* CGLContextObj;
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;
// We need a static image of what was rendered for printing.
virtual mbgl::PremultipliedImage readStillImage() = 0;
virtual mln::PremultipliedImage readStillImage() = 0;
virtual CGLContextObj getCGLContextObj() { return nullptr; }
@@ -32,36 +32,35 @@ public:
// Called by the view delegate when it's time to render.
void render();
// 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;
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;
protected:
/// Cocoa map view that this adapter bridges to.

View File

@@ -25,15 +25,15 @@ void MLNMapViewImpl::render() { [mapView renderSync]; }
void MLNMapViewImpl::display() { [mapView.layer setNeedsDisplay]; }
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];
}
@@ -41,25 +41,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,
@@ -83,16 +83,16 @@ void MLNMapViewImpl::onDidFailLoadingMap(mbgl::MapLoadError mapError, const std:
void MLNMapViewImpl::onWillStartRenderingFrame() { [mapView mapViewWillStartRenderingFrame]; }
void MLNMapViewImpl::onDidFinishRenderingFrame(const mbgl::MapObserver::RenderFrameStatus& status) {
bool fullyRendered = status.mode == mbgl::MapObserver::RenderMode::Full;
void MLNMapViewImpl::onDidFinishRenderingFrame(const mln::MapObserver::RenderFrameStatus& status) {
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];
}
@@ -100,7 +100,7 @@ void MLNMapViewImpl::onDidBecomeIdle() { [mapView mapViewDidBecomeIdle]; }
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];
@@ -111,10 +111,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)
@@ -122,8 +122,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)
@@ -131,8 +131,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)
@@ -140,8 +140,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()]];
@@ -150,7 +149,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) {
@@ -160,8 +159,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()]];
@@ -170,7 +169,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
@@ -181,7 +180,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;
@@ -191,7 +190,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];
@@ -202,7 +201,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,25 +17,25 @@ 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; }
mbgl::PremultipliedImage readStillImage() override;
mln::PremultipliedImage readStillImage() override;
MLNBackendResource* getObject() 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;
@@ -113,8 +113,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)) {
auto& resource = getResource<MLNMapViewMetalRenderableResource>();
if (resource.mtlView) {
return;
@@ -167,7 +167,7 @@ void MLNMapViewMetalImpl::updateAssumedState() {
assumeViewport(0, 0, resource.framebufferSize());
}
mbgl::PremultipliedImage MLNMapViewMetalImpl::readStillImage() {
mln::PremultipliedImage MLNMapViewMetalImpl::readStillImage() {
// return readFramebuffer(mapView.framebufferSize); // TODO: RendererBackend::readFramebuffer
return {};
}

View File

@@ -5,9 +5,7 @@
#include <mbgl/gl/renderer_backend.hpp>
/// Adapter responsible for bridging calls from mbgl to MLNMapView and Cocoa.
class MLNMapViewOpenGLImpl final : public MLNMapViewImpl,
public mbgl::gl::RendererBackend,
public mbgl::gfx::Renderable {
class MLNMapViewOpenGLImpl final : public MLNMapViewImpl, public mln::gl::RendererBackend, public mln::gfx::Renderable {
public:
MLNMapViewOpenGLImpl(MLNMapView*);
~MLNMapViewOpenGLImpl() override = default;
@@ -15,27 +13,27 @@ 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;
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; }
mbgl::PremultipliedImage readStillImage() override;
mln::PremultipliedImage readStillImage() override;
CGLContextObj getCGLContextObj() override;
};

View File

@@ -5,7 +5,7 @@
#import <OpenGL/gl.h>
class MLNMapViewOpenGLRenderableResource final : public mbgl::gl::RenderableResource {
class MLNMapViewOpenGLRenderableResource final : public mln::gl::RenderableResource {
public:
MLNMapViewOpenGLRenderableResource(MLNMapViewOpenGLImpl& backend_) : backend(backend_) {}
@@ -24,21 +24,21 @@ public:
MLNMapViewOpenGLImpl::MLNMapViewOpenGLImpl(MLNMapView* nativeView_)
: MLNMapViewImpl(nativeView_),
mbgl::gl::RendererBackend(mbgl::gfx::ContextMode::Unique),
mbgl::gfx::Renderable(mapView.framebufferSize,
std::make_unique<MLNMapViewOpenGLRenderableResource>(*this)) {
mln::gl::RendererBackend(mln::gfx::ContextMode::Unique),
mln::gfx::Renderable(mapView.framebufferSize,
std::make_unique<MLNMapViewOpenGLRenderableResource>(*this)) {
// Install the OpenGL layer. Interface Builder’s synchronous drawing means
// we can’t display a map, so don’t even bother to have a map layer.
mapView.layer = mapView.isTargetingInterfaceBuilder ? [CALayer layer] : [MLNOpenGLLayer layer];
}
mbgl::gl::ProcAddress MLNMapViewOpenGLImpl::getExtensionFunctionPointer(const char* name) {
mln::gl::ProcAddress MLNMapViewOpenGLImpl::getExtensionFunctionPointer(const char* name) {
static CFBundleRef framework = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl"));
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]));
}
@@ -74,7 +74,7 @@ void MLNMapViewOpenGLImpl::restoreFramebufferBinding() {
setViewport(0, 0, mapView.framebufferSize);
}
mbgl::PremultipliedImage MLNMapViewOpenGLImpl::readStillImage() {
mln::PremultipliedImage MLNMapViewOpenGLImpl::readStillImage() {
return readFramebuffer(mapView.framebufferSize);
}

View File

@@ -129,7 +129,7 @@ NSImage *MLNDefaultMarkerImage() {
}
/// Converts a media timing function into a unit bezier object usable in mbgl.
mbgl::util::UnitBezier MLNUnitBezierForMediaTimingFunction(CAMediaTimingFunction *function) {
mln::util::UnitBezier MLNUnitBezierForMediaTimingFunction(CAMediaTimingFunction *function) {
if (!function) {
function = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
}
@@ -168,7 +168,7 @@ public:
@implementation MLNMapView {
/// Cross-platform map view controller.
std::unique_ptr<mbgl::Map> _mbglMap;
std::unique_ptr<mln::Map> _mbglMap;
std::unique_ptr<MLNMapViewImpl> _mbglView;
std::unique_ptr<MLNRenderFrontend> _rendererFrontend;
@@ -322,41 +322,41 @@ public:
std::optional<std::string> localFontFamilyName =
config.localFontFamilyName ? std::optional(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(), true);
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);
auto tileServerOptions = [[MLNSettings sharedSettings] tileServerOptionsInternal];
mbgl::ResourceOptions resourceOptions;
mln::ResourceOptions resourceOptions;
resourceOptions.withTileServerOptions(*tileServerOptions)
.withCachePath(MLNOfflineStorage.sharedOfflineStorage.databasePath.UTF8String)
.withAssetPath([NSBundle mainBundle].resourceURL.path.UTF8String);
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];
_mbglMap = std::make_unique<mbgl::Map>(*_rendererFrontend, *_mbglView, mapOptions,
resourceOptions, clientOptions, actionJournalOptions);
_mbglMap = std::make_unique<mln::Map>(*_rendererFrontend, *_mbglView, mapOptions, resourceOptions,
clientOptions, actionJournalOptions);
// Notify map object when network reachability status changes.
_reachability = [MLNReachability reachabilityForInternetConnection];
_reachability.reachableBlock = ^(MLNReachability *) {
mbgl::NetworkStatus::Reachable();
mln::NetworkStatus::Reachable();
};
[_reachability startNotifier];
@@ -377,8 +377,8 @@ public:
// Jump to Null Island initially.
self.automaticallyAdjustsContentInsets = YES;
mbgl::CameraOptions options;
options.center = mbgl::LatLng(0, 0);
mln::CameraOptions options;
options.center = mln::LatLng(0, 0);
options.padding = MLNEdgeInsetsFromNSEdgeInsets(self.contentInsets);
options.zoom = *_mbglMap->getBounds().minZoom;
_mbglMap->jumpTo(options);
@@ -386,14 +386,14 @@ public:
_pendingLongitude = NAN;
}
- (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));
return {static_cast<uint32_t>(size.width), static_cast<uint32_t>(size.height)};
}
- (mbgl::Size)framebufferSize {
- (mln::Size)framebufferSize {
NSRect bounds = [self convertRectToBacking:self.bounds];
return {static_cast<uint32_t>(bounds.size.width), static_cast<uint32_t>(bounds.size.height)};
}
@@ -639,11 +639,11 @@ public:
// 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);
MLNAnnotationImage *annotationImage = [self imageOfAnnotationWithTag:annotationTag];
_mbglMap->updateAnnotation(
annotationTag,
mbgl::SymbolAnnotation{point, annotationImage.styleIconIdentifier.UTF8String ?: ""});
mln::SymbolAnnotation{point, annotationImage.styleIconIdentifier.UTF8String ?: ""});
[self updateAnnotationCallouts];
}
} else if ([keyPath isEqualToString:@"coordinates"] &&
@@ -746,7 +746,7 @@ public:
}
- (void)setPrefetchesTiles:(BOOL)prefetchesTiles {
_mbglMap->setPrefetchZoomDelta(prefetchesTiles ? mbgl::util::DEFAULT_PREFETCH_ZOOM_DELTA : 0);
_mbglMap->setPrefetchZoomDelta(prefetchesTiles ? mln::util::DEFAULT_PREFETCH_ZOOM_DELTA : 0);
}
- (BOOL)prefetchesTiles {
@@ -785,7 +785,7 @@ public:
return _mbglMap->getTileLodZoomShift();
}
- (mbgl::Renderer *)renderer {
- (mln::Renderer *)renderer {
return _rendererFrontend->getRenderer();
}
@@ -807,8 +807,8 @@ public:
self.dormant = NO;
}
if (window && _mbglMap->getMapOptions().constrainMode() == mbgl::ConstrainMode::None) {
_mbglMap->setConstrainMode(mbgl::ConstrainMode::HeightOnly);
if (window && _mbglMap->getMapOptions().constrainMode() == mln::ConstrainMode::None) {
_mbglMap->setConstrainMode(mln::ConstrainMode::HeightOnly);
}
[window addObserver:self
@@ -1035,7 +1035,7 @@ public:
}
- (void)mapViewDidFinishRenderingFrameFullyRendered:(BOOL)fullyRendered
renderingStats:(const mbgl::gfx::RenderingStats &)stats {
renderingStats:(const mln::gfx::RenderingStats &)stats {
if (!_mbglMap) {
return;
}
@@ -1277,7 +1277,7 @@ public:
}
- (CLLocationCoordinate2D)centerCoordinate {
mbgl::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(self.contentInsets);
mln::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(self.contentInsets);
return MLNLocationCoordinate2DFromLatLng(*_mbglMap->getCameraOptions(padding).center);
}
@@ -1296,7 +1296,7 @@ public:
completionHandler:(nullable void (^)(void))completion {
MLNLogDebug(@"Setting centerCoordinate: %@ animated: %@",
MLNStringFromCLLocationCoordinate2D(centerCoordinate), MLNStringFromBOOL(animated));
mbgl::AnimationOptions animationOptions =
mln::AnimationOptions animationOptions =
MLNDurationFromTimeInterval(animated ? MLNAnimationDuration : 0);
animationOptions.transitionFinishFn = ^() {
[self didChangeValueForKey:@"centerCoordinate"];
@@ -1308,7 +1308,7 @@ public:
};
[self willChangeValueForKey:@"centerCoordinate"];
_mbglMap->easeTo(mbgl::CameraOptions()
_mbglMap->easeTo(mln::CameraOptions()
.withCenter(MLNLatLngFromLocationCoordinate2D(centerCoordinate))
.withPadding(MLNEdgeInsetsFromNSEdgeInsets(self.contentInsets)),
animationOptions);
@@ -1348,7 +1348,7 @@ public:
}
- (double)zoomLevel {
mbgl::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(self.contentInsets);
mln::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(self.contentInsets);
return *_mbglMap->getCameraOptions(padding).zoom;
}
@@ -1360,7 +1360,7 @@ public:
- (void)setZoomLevel:(double)zoomLevel animated:(BOOL)animated {
MLNLogDebug(@"Setting zoomLevel: %f animated: %@", zoomLevel, MLNStringFromBOOL(animated));
[self willChangeValueForKey:@"zoomLevel"];
_mbglMap->easeTo(mbgl::CameraOptions().withZoom(zoomLevel).withPadding(
_mbglMap->easeTo(mln::CameraOptions().withZoom(zoomLevel).withPadding(
MLNEdgeInsetsFromNSEdgeInsets(self.contentInsets)),
MLNDurationFromTimeInterval(animated ? MLNAnimationDuration : 0));
[self didChangeValueForKey:@"zoomLevel"];
@@ -1370,8 +1370,8 @@ public:
[self willChangeValueForKey:@"centerCoordinate"];
[self willChangeValueForKey:@"zoomLevel"];
MLNMapCamera *oldCamera = self.camera;
mbgl::ScreenCoordinate center(point.x, self.bounds.size.height - point.y);
_mbglMap->easeTo(mbgl::CameraOptions().withZoom(zoomLevel).withAnchor(center),
mln::ScreenCoordinate center(point.x, self.bounds.size.height - point.y);
_mbglMap->easeTo(mln::CameraOptions().withZoom(zoomLevel).withAnchor(center),
MLNDurationFromTimeInterval(animated ? MLNAnimationDuration : 0));
if ([self.delegate respondsToSelector:@selector(mapView:shouldChangeFromCamera:toCamera:)] &&
![self.delegate mapView:self shouldChangeFromCamera:oldCamera toCamera:self.camera]) {
@@ -1383,12 +1383,12 @@ public:
- (void)setMinimumZoomLevel:(double)minimumZoomLevel {
MLNLogDebug(@"Setting minimumZoomLevel: %f", minimumZoomLevel);
_mbglMap->setBounds(mbgl::BoundOptions().withMinZoom(minimumZoomLevel));
_mbglMap->setBounds(mln::BoundOptions().withMinZoom(minimumZoomLevel));
}
- (void)setMaximumZoomLevel:(double)maximumZoomLevel {
MLNLogDebug(@"Setting maximumZoomLevel: %f", maximumZoomLevel);
_mbglMap->setBounds(mbgl::BoundOptions().withMaxZoom(maximumZoomLevel));
_mbglMap->setBounds(mln::BoundOptions().withMaxZoom(maximumZoomLevel));
}
- (double)maximumZoomLevel {
@@ -1420,7 +1420,7 @@ public:
}
- (CLLocationDirection)direction {
return mbgl::util::wrap(*_mbglMap->getCameraOptions().bearing, 0., 360.);
return mln::util::wrap(*_mbglMap->getCameraOptions().bearing, 0., 360.);
}
- (void)setDirection:(CLLocationDirection)direction {
@@ -1431,7 +1431,7 @@ public:
- (void)setDirection:(CLLocationDirection)direction animated:(BOOL)animated {
MLNLogDebug(@"Setting direction: %f animated: %@", direction, MLNStringFromBOOL(animated));
[self willChangeValueForKey:@"direction"];
_mbglMap->easeTo(mbgl::CameraOptions().withBearing(direction).withPadding(
_mbglMap->easeTo(mln::CameraOptions().withBearing(direction).withPadding(
MLNEdgeInsetsFromNSEdgeInsets(self.contentInsets)),
MLNDurationFromTimeInterval(animated ? MLNAnimationDuration : 0));
[self didChangeValueForKey:@"direction"];
@@ -1447,7 +1447,7 @@ public:
- (void)setMinimumPitch:(CGFloat)minimumPitch {
MLNLogDebug(@"Setting minimumPitch: %f", minimumPitch);
_mbglMap->setBounds(mbgl::BoundOptions().withMinPitch(minimumPitch));
_mbglMap->setBounds(mln::BoundOptions().withMinPitch(minimumPitch));
}
- (CGFloat)maximumPitch {
@@ -1456,7 +1456,7 @@ public:
- (void)setMaximumPitch:(CGFloat)maximumPitch {
MLNLogDebug(@"Setting maximumPitch: %f", maximumPitch);
_mbglMap->setBounds(mbgl::BoundOptions().withMaxPitch(maximumPitch));
_mbglMap->setBounds(mln::BoundOptions().withMaxPitch(maximumPitch));
}
+ (NSSet<NSString *> *)keyPathsForValuesAffectingCamera {
@@ -1465,7 +1465,7 @@ public:
}
- (MLNMapCamera *)camera {
mbgl::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(self.contentInsets);
mln::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(self.contentInsets);
return [self cameraForCameraOptions:_mbglMap->getCameraOptions(padding)];
}
@@ -1501,7 +1501,7 @@ public:
edgePadding:(NSEdgeInsets)edgePadding
completionHandler:(nullable void (^)(void))completion {
edgePadding = MLNEdgeInsetsInsetEdgeInset(edgePadding, self.contentInsets);
mbgl::AnimationOptions animationOptions;
mln::AnimationOptions animationOptions;
if (duration > 0) {
animationOptions.duration.emplace(MLNDurationFromTimeInterval(duration));
animationOptions.easing.emplace(MLNUnitBezierForMediaTimingFunction(function));
@@ -1529,8 +1529,8 @@ public:
[self willChangeValueForKey:@"camera"];
_mbglMap->cancelTransitions();
mbgl::CameraOptions cameraOptions = [self cameraOptionsObjectForAnimatingToCamera:camera
edgePadding:edgePadding];
mln::CameraOptions cameraOptions = [self cameraOptionsObjectForAnimatingToCamera:camera
edgePadding:edgePadding];
_mbglMap->easeTo(cameraOptions, animationOptions);
[self didChangeValueForKey:@"camera"];
}
@@ -1554,7 +1554,7 @@ public:
completionHandler:(nullable void (^)(void))completion {
MLNLogDebug(@"Setting flyToCamera: %@ withDuration: %f peakAltitude: %f completionHandler: %@",
camera, duration, peakAltitude, completion);
mbgl::AnimationOptions animationOptions;
mln::AnimationOptions animationOptions;
if (duration >= 0) {
animationOptions.duration = MLNDurationFromTimeInterval(duration);
}
@@ -1588,7 +1588,7 @@ public:
[self willChangeValueForKey:@"camera"];
_mbglMap->cancelTransitions();
mbgl::CameraOptions cameraOptions =
mln::CameraOptions cameraOptions =
[self cameraOptionsObjectForAnimatingToCamera:camera edgePadding:self.contentInsets];
_mbglMap->flyTo(cameraOptions, animationOptions);
[self didChangeValueForKey:@"camera"];
@@ -1596,9 +1596,9 @@ public:
/// Returns a CameraOptions object that specifies parameters for animating to
/// the given camera.
- (mbgl::CameraOptions)cameraOptionsObjectForAnimatingToCamera:(MLNMapCamera *)camera
edgePadding:(NSEdgeInsets)edgePadding {
mbgl::CameraOptions options;
- (mln::CameraOptions)cameraOptionsObjectForAnimatingToCamera:(MLNMapCamera *)camera
edgePadding:(NSEdgeInsets)edgePadding {
mln::CameraOptions options;
options.center = MLNLatLngFromLocationCoordinate2D(camera.centerCoordinate);
options.padding = MLNEdgeInsetsFromNSEdgeInsets(edgePadding);
options.zoom = MLNZoomLevelForAltitude(camera.altitude, camera.pitch,
@@ -1646,11 +1646,11 @@ public:
completionHandler:(nullable void (^)(void))completion {
_mbglMap->cancelTransitions();
mbgl::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(insets);
mln::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(insets);
padding += MLNEdgeInsetsFromNSEdgeInsets(self.contentInsets);
mbgl::CameraOptions cameraOptions =
mln::CameraOptions cameraOptions =
_mbglMap->cameraForLatLngBounds(MLNLatLngBoundsFromCoordinateBounds(bounds), padding);
mbgl::AnimationOptions animationOptions;
mln::AnimationOptions animationOptions;
if (animated) {
animationOptions.duration = MLNDurationFromTimeInterval(MLNAnimationDuration);
}
@@ -1679,9 +1679,9 @@ public:
- (MLNMapCamera *)cameraThatFitsCoordinateBounds:(MLNCoordinateBounds)bounds
edgePadding:(NSEdgeInsets)insets {
mbgl::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(insets);
mln::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(insets);
padding += MLNEdgeInsetsFromNSEdgeInsets(self.contentInsets);
mbgl::CameraOptions cameraOptions =
mln::CameraOptions cameraOptions =
_mbglMap->cameraForLatLngBounds(MLNLatLngBoundsFromCoordinateBounds(bounds), padding);
return [self cameraForCameraOptions:cameraOptions];
}
@@ -1689,14 +1689,14 @@ public:
- (MLNMapCamera *)camera:(MLNMapCamera *)camera
fittingCoordinateBounds:(MLNCoordinateBounds)bounds
edgePadding:(NSEdgeInsets)insets {
mbgl::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(insets);
mln::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(insets);
padding += MLNEdgeInsetsFromNSEdgeInsets(self.contentInsets);
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 = _mbglMap->cameraForLatLngBounds(
mln::CameraOptions cameraOptions = _mbglMap->cameraForLatLngBounds(
MLNLatLngBoundsFromCoordinateBounds(bounds), padding, direction, pitch);
return [self cameraForCameraOptions:cameraOptions];
}
@@ -1704,14 +1704,14 @@ public:
- (MLNMapCamera *)camera:(MLNMapCamera *)camera
fittingShape:(MLNShape *)shape
edgePadding:(NSEdgeInsets)insets {
mbgl::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(insets);
mln::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(insets);
padding += MLNEdgeInsetsFromNSEdgeInsets(self.contentInsets);
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 =
_mbglMap->cameraForGeometry([shape geometryObject], padding, direction, pitch);
return [self cameraForCameraOptions:cameraOptions];
@@ -1720,22 +1720,22 @@ public:
- (MLNMapCamera *)cameraThatFitsShape:(MLNShape *)shape
direction:(CLLocationDirection)direction
edgePadding:(NSEdgeInsets)insets {
mbgl::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(insets);
mln::EdgeInsets padding = MLNEdgeInsetsFromNSEdgeInsets(insets);
padding += MLNEdgeInsetsFromNSEdgeInsets(self.contentInsets);
mbgl::CameraOptions cameraOptions =
mln::CameraOptions cameraOptions =
_mbglMap->cameraForGeometry([shape geometryObject], padding, direction);
return [self cameraForCameraOptions:cameraOptions];
}
- (MLNMapCamera *)cameraForCameraOptions:(const mbgl::CameraOptions &)cameraOptions {
mbgl::CameraOptions mapCamera = _mbglMap->getCameraOptions();
- (MLNMapCamera *)cameraForCameraOptions:(const mln::CameraOptions &)cameraOptions {
mln::CameraOptions mapCamera = _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);
@@ -1862,16 +1862,16 @@ public:
} else if (gestureRecognizer.state == NSGestureRecognizerStateChanged) {
MLNMapCamera *oldCamera = self.camera;
BOOL didChangeCamera = NO;
mbgl::ScreenCoordinate center(startPoint.x, self.bounds.size.height - startPoint.y);
mln::ScreenCoordinate center(startPoint.x, self.bounds.size.height - startPoint.y);
if (self.rotateEnabled) {
CLLocationDirection newDirection = _directionAtBeginningOfGesture - delta.x / 10;
[self willChangeValueForKey:@"direction"];
_mbglMap->jumpTo(mbgl::CameraOptions().withBearing(newDirection).withAnchor(center));
_mbglMap->jumpTo(mln::CameraOptions().withBearing(newDirection).withAnchor(center));
didChangeCamera = YES;
[self didChangeValueForKey:@"direction"];
}
if (self.pitchEnabled) {
_mbglMap->jumpTo(mbgl::CameraOptions()
_mbglMap->jumpTo(mln::CameraOptions()
.withPitch(_pitchAtBeginningOfGesture + delta.y / 5)
.withAnchor(center));
didChangeCamera = YES;
@@ -1916,13 +1916,13 @@ public:
_zoomAtBeginningOfGesture = [self zoomLevel];
} else if (gestureRecognizer.state == NSGestureRecognizerStateChanged) {
NSPoint zoomInPoint = [gestureRecognizer locationInView:self];
mbgl::ScreenCoordinate center(zoomInPoint.x, self.bounds.size.height - zoomInPoint.y);
mln::ScreenCoordinate center(zoomInPoint.x, self.bounds.size.height - zoomInPoint.y);
if (gestureRecognizer.magnification > -1) {
[self willChangeValueForKey:@"zoomLevel"];
[self willChangeValueForKey:@"centerCoordinate"];
MLNMapCamera *oldCamera = self.camera;
_mbglMap->jumpTo(
mbgl::CameraOptions()
mln::CameraOptions()
.withZoom(_zoomAtBeginningOfGesture + log2(1 + gestureRecognizer.magnification))
.withAnchor(center));
if ([self.delegate respondsToSelector:@selector(mapView:shouldChangeFromCamera:toCamera:)] &&
@@ -2007,9 +2007,9 @@ public:
MLNMapCamera *oldCamera = self.camera;
NSPoint rotationPoint = [gestureRecognizer locationInView:self];
mbgl::ScreenCoordinate anchor(rotationPoint.x, self.bounds.size.height - rotationPoint.y);
mln::ScreenCoordinate anchor(rotationPoint.x, self.bounds.size.height - rotationPoint.y);
_mbglMap->jumpTo(
mbgl::CameraOptions()
mln::CameraOptions()
.withBearing(_directionAtBeginningOfGesture + gestureRecognizer.rotationInDegrees)
.withAnchor(anchor));
@@ -2358,7 +2358,7 @@ public:
[self installAnnotationImage:annotationImage];
}
MLNAnnotationTag annotationTag = _mbglMap->addAnnotation(mbgl::SymbolAnnotation{
MLNAnnotationTag annotationTag = _mbglMap->addAnnotation(mln::SymbolAnnotation{
MLNPointFromLocationCoordinate2D(annotation.coordinate), symbolName.UTF8String ?: ""});
MLNAnnotationContext context;
@@ -2862,7 +2862,7 @@ public:
return;
}
mbgl::LatLngBounds bounds = mbgl::LatLngBounds::empty();
mln::LatLngBounds bounds = mln::LatLngBounds::empty();
for (id<MLNAnnotation> annotation in annotations) {
if ([annotation conformsToProtocol:@protocol(MLNOverlay)]) {
@@ -3016,14 +3016,14 @@ public:
return 1.0;
}
- (mbgl::Color)strokeColorForShapeAnnotation:(MLNShape *)annotation {
- (mln::Color)strokeColorForShapeAnnotation:(MLNShape *)annotation {
NSColor *color = (_delegateHasStrokeColorsForShapeAnnotations
? [self.delegate mapView:self strokeColorForShapeAnnotation:annotation]
: [NSColor selectedMenuItemColor]);
return color.mgl_color;
}
- (mbgl::Color)fillColorForPolygonAnnotation:(MLNPolygon *)annotation {
- (mln::Color)fillColorForPolygonAnnotation:(MLNPolygon *)annotation {
NSColor *color = (_delegateHasFillColorsForShapeAnnotations
? [self.delegate mapView:self fillColorForPolygonAnnotation:annotation]
: [NSColor selectedMenuItemColor]);
@@ -3210,7 +3210,7 @@ public:
MLNLogDebug(@"Querying visibleFeaturesAtPoint: %@ inStyleLayersWithIdentifiers: %@ predicate: %@",
NSStringFromPoint(point), styleLayerIdentifiers, predicate);
// Cocoa origin is at the lower-left corner.
mbgl::ScreenCoordinate screenCoordinate = {point.x, NSHeight(self.bounds) - point.y};
mln::ScreenCoordinate screenCoordinate = {point.x, NSHeight(self.bounds) - point.y};
std::optional<std::vector<std::string>> optionalLayerIDs;
if (styleLayerIdentifiers) {
@@ -3223,12 +3223,12 @@ public:
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);
}
@@ -3253,7 +3253,7 @@ public:
MLNLogDebug(@"Querying visibleFeaturesInRect: %@ inStyleLayersWithIdentifiers: %@ predicate: %@",
NSStringFromRect(rect), styleLayerIdentifiers, predicate);
// Cocoa origin is at the lower-left corner.
mbgl::ScreenBox screenBox = {
mln::ScreenBox screenBox = {
{NSMinX(rect), NSHeight(self.bounds) - NSMaxY(rect)},
{NSMaxX(rect), NSHeight(self.bounds) - NSMinY(rect)},
};
@@ -3269,12 +3269,12 @@ public:
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);
}
@@ -3314,8 +3314,8 @@ public:
}
/// Converts a geographic coordinate to a point in the view’s coordinate system.
- (NSPoint)convertLatLng:(mbgl::LatLng)latLng toPointToView:(nullable NSView *)view {
mbgl::ScreenCoordinate pixel = _mbglMap->pixelForLatLng(latLng);
- (NSPoint)convertLatLng:(mln::LatLng)latLng toPointToView:(nullable NSView *)view {
mln::ScreenCoordinate pixel = _mbglMap->pixelForLatLng(latLng);
// Cocoa origin is at the lower-left corner.
pixel.y = NSHeight(self.bounds) - pixel.y;
return [self convertPoint:NSMakePoint(pixel.x, pixel.y) toView:view];
@@ -3326,7 +3326,7 @@ public:
}
/// Converts a point in the view’s coordinate system to a geographic coordinate.
- (mbgl::LatLng)convertPoint:(NSPoint)point toLatLngFromView:(nullable NSView *)view {
- (mln::LatLng)convertPoint:(NSPoint)point toLatLngFromView:(nullable NSView *)view {
NSPoint convertedPoint = [self convertPoint:point fromView:view];
return _mbglMap
->latLngForPixel({
@@ -3343,7 +3343,7 @@ public:
/// Converts a geographic bounding box to a rectangle in the view’s coordinate
/// system.
- (NSRect)convertLatLngBounds:(mbgl::LatLngBounds)bounds toRectToView:(nullable NSView *)view {
- (NSRect)convertLatLngBounds:(mln::LatLngBounds)bounds toRectToView:(nullable NSView *)view {
auto northwest = bounds.northwest();
auto northeast = bounds.northeast();
auto southwest = bounds.southwest();
@@ -3358,7 +3358,7 @@ public:
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);
@@ -3377,8 +3377,8 @@ public:
/// Converts a rectangle in the given view’s coordinate system to a geographic
/// bounding box.
- (mbgl::LatLngBounds)convertRect:(NSRect)rect toLatLngBoundsFromView:(nullable NSView *)view {
auto bounds = mbgl::LatLngBounds::empty();
- (mln::LatLngBounds)convertRect:(NSRect)rect toLatLngBoundsFromView:(nullable NSView *)view {
auto bounds = mln::LatLngBounds::empty();
auto bottomLeft = [self convertPoint:{NSMinX(rect), NSMinY(rect)} toLatLngFromView:view];
auto bottomRight = [self convertPoint:{NSMaxX(rect), NSMinY(rect)} toLatLngFromView:view];
auto topRight = [self convertPoint:{NSMaxX(rect), NSMaxY(rect)} toLatLngFromView:view];
@@ -3401,60 +3401,60 @@ public:
}
- (CLLocationDistance)metersPerPointAtLatitude:(CLLocationDegrees)latitude {
return mbgl::Projection::getMetersPerPixelAtLatitude(latitude, self.zoomLevel);
return mln::Projection::getMetersPerPixelAtLatitude(latitude, self.zoomLevel);
}
// MARK: Debugging
- (MLNMapDebugMaskOptions)debugMask {
mbgl::MapDebugOptions options = _mbglMap->getDebug();
mln::MapDebugOptions options = _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;
}
if (options & mbgl::MapDebugOptions::StencilClip) {
if (options & mln::MapDebugOptions::StencilClip) {
mask |= MLNMapDebugStencilBufferMask;
}
if (options & mbgl::MapDebugOptions::DepthBuffer) {
if (options & mln::MapDebugOptions::DepthBuffer) {
mask |= MLNMapDebugDepthBufferMask;
}
return mask;
}
- (void)setDebugMask:(MLNMapDebugMaskOptions)debugMask {
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;
}
if (debugMask & MLNMapDebugStencilBufferMask) {
options |= mbgl::MapDebugOptions::StencilClip;
options |= mln::MapDebugOptions::StencilClip;
}
if (debugMask & MLNMapDebugDepthBufferMask) {
options |= mbgl::MapDebugOptions::DepthBuffer;
options |= mln::MapDebugOptions::DepthBuffer;
}
_mbglMap->setDebug(options);
}

View File

@@ -3,7 +3,7 @@
#include <mbgl/util/size.hpp>
namespace mbgl {
namespace mln {
class Map;
class Renderer;
@@ -11,7 +11,7 @@ namespace gfx {
struct RenderingStats;
}
} // namespace mbgl
} // namespace mln
@class MLNSource;
@@ -35,7 +35,7 @@ struct RenderingStats;
/// The map view’s OpenGL rendering context, if it is backed by an OpenGL based view.
@property (readonly, nonatomic, nullable) CGLContextObj context;
- (mbgl::Size)framebufferSize;
- (mln::Size)framebufferSize;
/// Map observers
- (void)cameraWillChangeAnimated:(BOOL)animated;
@@ -46,7 +46,7 @@ struct RenderingStats;
- (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;
@@ -85,6 +85,6 @@ struct RenderingStats;
- (BOOL)isTargetingInterfaceBuilder;
- (nonnull mbgl::Renderer *)renderer;
- (nonnull mln::Renderer *)renderer;
@end

View File

@@ -6,18 +6,18 @@
@interface NSColor (MLNAdditions)
/**
Converts the color into an mbgl::Color in sRGB space.
Converts the color into an mln::Color in sRGB space.
*/
- (mbgl::Color)mgl_color;
- (mln::Color)mgl_color;
- (mbgl::Color)mgl_colorForPremultipliedValue;
- (mln::Color)mgl_colorForPremultipliedValue;
/**
Instantiates `NSColor` from an `mbgl::Color`
Instantiates `NSColor` from an `mln::Color`
*/
+ (NSColor *)mgl_colorWithColor:(mbgl::Color)color;
+ (NSColor *)mgl_colorWithColor:(mln::Color)color;
- (mbgl::style::PropertyValue<mbgl::Color>)mgl_colorPropertyValue;
- (mln::style::PropertyValue<mln::Color>)mgl_colorPropertyValue;
@end

View File

@@ -2,7 +2,7 @@
@implementation NSColor (MLNAdditions)
- (mbgl::Color)mgl_color {
- (mln::Color)mgl_color {
CGFloat r, g, b, a;
// The MapLibre Style Spec does not specify a color space, but it is
@@ -17,12 +17,12 @@
// NSColor 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)};
}
- (mbgl::Color)mgl_colorForPremultipliedValue {
- (mln::Color)mgl_colorForPremultipliedValue {
CGFloat r, g, b, a;
// The MapLibre Style Spec does not specify a color space, but it is
@@ -39,7 +39,7 @@
static_cast<float>(a)};
}
+ (NSColor *)mgl_colorWithColor:(mbgl::Color)color {
+ (NSColor *)mgl_colorWithColor:(mln::Color)color {
// If there is no alpha value, return original color values.
if (color.a == 0.0f) {
// macOS 10.12 Sierra and below uses calibrated RGB by default.
@@ -50,7 +50,7 @@
}
}
// 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 NSColor object.
float red = static_cast<float>((color.r / color.a));
float green = static_cast<float>((color.g / color.a));
@@ -64,8 +64,8 @@
}
}
- (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}};
}

View File

@@ -6,13 +6,13 @@ NS_ASSUME_NONNULL_BEGIN
@interface NSImage (MLNAdditions)
- (nullable instancetype)initWithMLNPremultipliedImage:(mbgl::PremultipliedImage &&)image;
- (nullable instancetype)initWithMLNPremultipliedImage:(mln::PremultipliedImage &&)image;
- (nullable instancetype)initWithMLNStyleImage:(const mbgl::style::Image &)image;
- (nullable instancetype)initWithMLNStyleImage:(const mln::style::Image &)image;
- (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;
@end

View File

@@ -9,7 +9,7 @@ BOOL MLNEdgeInsetsIsZero(NSEdgeInsets edgeInsets) {
@implementation NSImage (MLNAdditions)
- (nullable instancetype)initWithMLNPremultipliedImage:(mbgl::PremultipliedImage &&)src {
- (nullable instancetype)initWithMLNPremultipliedImage:(mln::PremultipliedImage &&)src {
CGImageRef image = CGImageCreateWithMLNPremultipliedImage(std::move(src));
if (!image) {
return nil;
@@ -20,7 +20,7 @@ BOOL MLNEdgeInsetsIsZero(NSEdgeInsets edgeInsets) {
return self;
}
- (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;
@@ -48,12 +48,12 @@ BOOL MLNEdgeInsetsIsZero(NSEdgeInsets edgeInsets) {
return self;
}
- (std::unique_ptr<mbgl::style::Image>)mgl_styleImageWithIdentifier:(NSString *)identifier {
mbgl::PremultipliedImage cPremultipliedImage = self.mgl_premultipliedImage;
- (std::unique_ptr<mln::style::Image>)mgl_styleImageWithIdentifier:(NSString *)identifier {
mln::PremultipliedImage cPremultipliedImage = self.mgl_premultipliedImage;
auto imageWidth = cPremultipliedImage.size.width;
float scale = static_cast<float>(imageWidth) / self.size.width;
mbgl::style::ImageStretches stretchX, stretchY;
mln::style::ImageStretches stretchX, stretchY;
if (self.resizingMode == NSImageResizingModeStretch) {
stretchX.push_back({
self.capInsets.left * scale,
@@ -65,9 +65,9 @@ BOOL MLNEdgeInsetsIsZero(NSEdgeInsets 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 * scale),
.top = static_cast<float>(self.capInsets.top * scale),
.right = static_cast<float>((self.size.width - self.capInsets.right) * scale),
@@ -75,12 +75,12 @@ BOOL MLNEdgeInsetsIsZero(NSEdgeInsets edgeInsets) {
};
}
return std::make_unique<mbgl::style::Image>([identifier UTF8String],
std::move(cPremultipliedImage), scale,
[self isTemplate], stretchX, stretchY, imageContent);
return std::make_unique<mln::style::Image>([identifier UTF8String],
std::move(cPremultipliedImage), scale,
[self isTemplate], stretchX, stretchY, imageContent);
}
- (mbgl::PremultipliedImage)mgl_premultipliedImage {
- (mln::PremultipliedImage)mgl_premultipliedImage {
CGImageRef ref = [self CGImageForProposedRect:nullptr context:nullptr hints:nullptr];
return MLNPremultipliedImageFromCGImage(ref);
}