summaryrefslogtreecommitdiff
path: root/platform/ios/src/MGLMapView.mm
diff options
context:
space:
mode:
Diffstat (limited to 'platform/ios/src/MGLMapView.mm')
-rw-r--r--platform/ios/src/MGLMapView.mm41
1 files changed, 31 insertions, 10 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index f78b2d150c..4cbe839179 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -19,7 +19,8 @@
#include <mbgl/style/layers/custom_layer.hpp>
#include <mbgl/renderer/mode.hpp>
#include <mbgl/renderer/renderer.hpp>
-#include <mbgl/renderer/renderer_backend.hpp>
+#import <mbgl/gl/renderer_backend.hpp>
+#import <mbgl/gl/renderable_resource.hpp>
#include <mbgl/math/wrap.hpp>
#include <mbgl/util/exception.hpp>
#include <mbgl/util/geo.hpp>
@@ -6719,10 +6720,26 @@ public:
return _annotationViewReuseQueueByIdentifier[identifier];
}
-class MBGLView : public mbgl::RendererBackend, public mbgl::MapObserver
-{
+class MBGLView;
+
+class MBGLMapViewRenderable final : public mbgl::gl::RenderableResource {
+public:
+ MBGLMapViewRenderable(MBGLView& backend_) : backend(backend_) {
+ }
+
+ void bind() override;
+
+private:
+ MBGLView& backend;
+};
+
+class MBGLView : public mbgl::gl::RendererBackend,
+ public mbgl::gfx::Renderable,
+ public mbgl::MapObserver {
public:
- MBGLView(MGLMapView* nativeView_) : nativeView(nativeView_) {
+ MBGLView(MGLMapView* nativeView_) : mbgl::gfx::Renderable(
+ nativeView_.framebufferSize,
+ std::make_unique<MBGLMapViewRenderable>(*this)), nativeView(nativeView_) {
}
/// This function is called before we start rendering, when iOS invokes our rendering method.
@@ -6733,7 +6750,7 @@ public:
assumeViewport(0, 0, nativeView.framebufferSize);
}
- void bind() override {
+ void restoreFramebufferBinding() {
if (!implicitFramebufferBound()) {
// Something modified our state, and we need to bind the original drawable again.
// Doing this also sets the viewport to the full framebuffer.
@@ -6747,10 +6764,6 @@ public:
}
}
- mbgl::Size getFramebufferSize() const override {
- return nativeView.framebufferSize;
- }
-
void onCameraWillChange(mbgl::MapObserver::CameraChangeMode mode) override {
bool animated = mode == mbgl::MapObserver::CameraChangeMode::Animated;
[nativeView cameraWillChangeAnimated:animated];
@@ -6855,6 +6868,10 @@ public:
return reinterpret_cast<mbgl::gl::ProcAddress>(symbol);
}
+ mbgl::gfx::Renderable& getDefaultRenderable() override {
+ return *this;
+ }
+
void activate() override
{
if (activationCount++)
@@ -6876,11 +6893,15 @@ public:
}
private:
- __weak MGLMapView *nativeView = nullptr;
+ __weak MGLMapView* nativeView = nullptr;
NSUInteger activationCount = 0;
};
+void MBGLMapViewRenderable::bind() {
+ backend.restoreFramebufferBinding();
+}
+
@end
#pragma mark - IBAdditions methods