Files
MapLibreParticleLab/platform/ios/src/MLNMapView+Impl.h
Bart Louwers 2a8ebc4906 core: rename mbgl directories to mln (#4511)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-08-22 20:50:14 +02:00

95 lines
4.0 KiB
Objective-C

#import <mln/gfx/renderer_backend.hpp>
#import <mln/map/map_observer.hpp>
#import <mln/util/image.hpp>
#import "MLNBackendResource.h"
#import <QuartzCore/CALayer.h>
#import <UIKit/UIImage.h>
#import <UIKit/UIView.h>
@class MLNMapView;
class MLNMapViewImpl : public mln::MapObserver {
public:
static std::unique_ptr<MLNMapViewImpl> Create(MLNMapView*);
MLNMapViewImpl(MLNMapView*);
virtual ~MLNMapViewImpl() = default;
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; }
// Gets called when the opaqueness of the view changes.
virtual void setOpaque(bool) = 0;
// Triggers an immediate render of the underlying view.
virtual void display() = 0;
// We update the transaction mode when the user adds annotation views that need to be layered on
// top of the view.
virtual void setPresentsWithTransaction(bool) = 0;
// Called when initially creating the rendering view, and when resuming rendering after returning
// from the background.
virtual void createView() = 0;
// We expose the underlying UIView because we need it in order to add annotation views above it.
virtual UIView* getView() = 0;
// Called when the application goes to the background and we've replaced the interactively
// rendered map view with a static image.
virtual void deleteView() = 0;
// called before the application goes to the background. The resulting image is used as a place
// holder instead of the regular view. This allows us to drop the framebuffers associated with
// the rendering context and reduce memory while in the background.
virtual UIImage* snapshot() = 0;
// Called when UIView's layout has changed.
virtual void layoutChanged() {};
// Called by the view delegate when it's time to render.
void render();
virtual MLNBackendResource* getObject() = 0;
// mln::MapObserver implementation
void onCameraWillChange(mln::MapObserver::CameraChangeMode) override;
void onCameraIsChanging() override;
void onCameraDidChange(mln::MapObserver::CameraChangeMode) override;
void onWillStartLoadingMap() override;
void onDidFinishLoadingMap() override;
void onDidFailLoadingMap(mln::MapLoadError mapError, const std::string& what) override;
void onWillStartRenderingFrame() override;
void onDidFinishRenderingFrame(const mln::MapObserver::RenderFrameStatus&) override;
void onWillStartRenderingMap() override;
void onDidFinishRenderingMap(mln::MapObserver::RenderMode) override;
void onDidFinishLoadingStyle() 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(mln::gfx::ShaderRegistry&) override;
void onPreCompileShader(mln::shaders::BuiltIn, mln::gfx::Backend::Type,
const std::string&) override;
void onPostCompileShader(mln::shaders::BuiltIn, mln::gfx::Backend::Type,
const std::string&) override;
void onShaderCompileFailed(mln::shaders::BuiltIn, mln::gfx::Backend::Type,
const std::string&) 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:
/// Cocoa map view that this adapter bridges to.
__weak MLNMapView* mapView = nullptr;
};