Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[macos] fix animations
Browse files Browse the repository at this point in the history
  • Loading branch information
ivovandongen committed Jul 17, 2017
1 parent f290c6d commit ce3538d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 15 additions & 2 deletions platform/darwin/src/MGLRendererFrontend.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <mbgl/renderer/renderer.hpp>
#include <mbgl/renderer/renderer_frontend.hpp>
#include <mbgl/util/async_task.hpp>
#include <mbgl/util/optional.hpp>


/**
Expand All @@ -9,10 +11,16 @@
class MGLRenderFrontend : public mbgl::RendererFrontend
{
public:
MGLRenderFrontend(std::unique_ptr<mbgl::Renderer> renderer_, MGLMapView* nativeView_, mbgl::View* mbglView_)
MGLRenderFrontend(std::unique_ptr<mbgl::Renderer> renderer_, MGLMapView* nativeView_, mbgl::View* mbglView_, bool async = false)
: renderer(std::move(renderer_))
, nativeView(nativeView_)
, mbglView(mbglView_) {

if (async) {
asyncInvalidate.emplace([&]() {
[nativeView setNeedsGLDisplay];
});
}
}

void reset() override {
Expand All @@ -23,7 +31,11 @@ class MGLRenderFrontend : public mbgl::RendererFrontend

void update(std::shared_ptr<mbgl::UpdateParameters> updateParameters_) override {
updateParameters = std::move(updateParameters_);
[nativeView setNeedsGLDisplay];
if (asyncInvalidate) {
asyncInvalidate->send();
} else {
[nativeView setNeedsGLDisplay];
}
}

void setObserver(mbgl::RendererObserver& observer) override {
Expand Down Expand Up @@ -51,4 +63,5 @@ class MGLRenderFrontend : public mbgl::RendererFrontend
__weak MGLMapView *nativeView = nullptr;
mbgl::View *mbglView = nullptr;
std::shared_ptr<mbgl::UpdateParameters> updateParameters;
mbgl::optional<mbgl::util::AsyncTask> asyncInvalidate;
};
2 changes: 1 addition & 1 deletion platform/macos/src/MGLMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ - (void)commonInit {
_mbglThreadPool = mbgl::sharedThreadPool();

auto renderer = std::make_unique<mbgl::Renderer>(*_mbglView, [NSScreen mainScreen].backingScaleFactor, *mbglFileSource, *_mbglThreadPool, mbgl::GLContextMode::Unique);
_rendererFrontend = std::make_unique<MGLRenderFrontend>(std::move(renderer), self, _mbglView);
_rendererFrontend = std::make_unique<MGLRenderFrontend>(std::move(renderer), self, _mbglView, true);
_mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, self.size, [NSScreen mainScreen].backingScaleFactor, *mbglFileSource, *_mbglThreadPool, mbgl::MapMode::Continuous, mbgl::ConstrainMode::None, mbgl::ViewportMode::Default);

// Install the OpenGL layer. Interface Builder’s synchronous drawing means
Expand Down

0 comments on commit ce3538d

Please sign in to comment.