diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2019-04-01 16:56:24 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2019-04-05 11:49:17 +0200 |
commit | 66c020034e8260e5e071481e68ab61cd264723ba (patch) | |
tree | b5263772d72175474d91ce2daa9dc037b99fab0d /platform/ios | |
parent | a782a6d15b80dd83105604f3f779f6c83ba222e5 (diff) | |
download | qtlocation-mapboxgl-66c020034e8260e5e071481e68ab61cd264723ba.tar.gz |
[core] refactor RendererBackend
Diffstat (limited to 'platform/ios')
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 41 |
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 |