[android][glfw][ios][macos][node][qt] split backend from mapobserver
This commit is contained in:
committed by
Ivo van Dongen
parent
57351c068b
commit
39a732d7ae
@@ -69,7 +69,7 @@ NativeMapView::NativeMapView(jni::JNIEnv& _env,
|
||||
|
||||
// Create the core map
|
||||
map = std::make_unique<mbgl::Map>(
|
||||
*this, mbgl::Size{ static_cast<uint32_t>(width), static_cast<uint32_t>(height) },
|
||||
*this, *this, mbgl::Size{ static_cast<uint32_t>(width), static_cast<uint32_t>(height) },
|
||||
pixelRatio, mbgl::android::FileSource::getDefaultFileSource(_env, jFileSource), *threadPool,
|
||||
MapMode::Continuous, GLContextMode::Unique, ConstrainMode::HeightOnly,
|
||||
ViewportMode::Default, jni::Make<std::string>(_env, _programCacheDir));
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
|
||||
class NativeMapView : public View, public Backend {
|
||||
class NativeMapView : public View, public Backend, public MapObserver {
|
||||
public:
|
||||
|
||||
static constexpr auto Name() { return "com/mapbox/mapboxsdk/maps/NativeMapView"; };
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
struct GLFWwindow;
|
||||
|
||||
class GLFWView : public mbgl::View, public mbgl::Backend {
|
||||
class GLFWView : public mbgl::View, public mbgl::Backend, public mbgl::MapObserver {
|
||||
public:
|
||||
GLFWView(bool fullscreen = false, bool benchmark = false);
|
||||
~GLFWView() override;
|
||||
|
||||
@@ -121,7 +121,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
mbgl::ThreadPool threadPool(4);
|
||||
|
||||
mbgl::Map map(backend, view->getSize(), view->getPixelRatio(), fileSource, threadPool);
|
||||
mbgl::Map map(backend, backend, view->getSize(), view->getPixelRatio(), fileSource, threadPool);
|
||||
|
||||
backend.setMap(&map);
|
||||
|
||||
@@ -200,4 +200,4 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
view = nullptr;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -444,7 +444,7 @@ public:
|
||||
mbgl::DefaultFileSource *mbglFileSource = [MGLOfflineStorage sharedOfflineStorage].mbglFileSource;
|
||||
const float scaleFactor = [UIScreen instancesRespondToSelector:@selector(nativeScale)] ? [[UIScreen mainScreen] nativeScale] : [[UIScreen mainScreen] scale];
|
||||
_mbglThreadPool = mbgl::sharedThreadPool();
|
||||
_mbglMap = new mbgl::Map(*_mbglView, self.size, scaleFactor, *mbglFileSource, *_mbglThreadPool, mbgl::MapMode::Continuous, mbgl::GLContextMode::Unique, mbgl::ConstrainMode::None, mbgl::ViewportMode::Default);
|
||||
_mbglMap = new mbgl::Map(*_mbglView, *_mbglView, self.size, scaleFactor, *mbglFileSource, *_mbglThreadPool, mbgl::MapMode::Continuous, mbgl::GLContextMode::Unique, mbgl::ConstrainMode::None, mbgl::ViewportMode::Default);
|
||||
|
||||
// start paused if in IB
|
||||
if (_isTargetingInterfaceBuilder || background) {
|
||||
@@ -5408,7 +5408,7 @@ public:
|
||||
return _annotationViewReuseQueueByIdentifier[identifier];
|
||||
}
|
||||
|
||||
class MBGLView : public mbgl::View, public mbgl::Backend
|
||||
class MBGLView : public mbgl::View, public mbgl::Backend, public mbgl::MapObserver
|
||||
{
|
||||
public:
|
||||
MBGLView(MGLMapView* nativeView_) : nativeView(nativeView_) {
|
||||
|
||||
@@ -270,7 +270,7 @@ public:
|
||||
mbgl::DefaultFileSource* mbglFileSource = [MGLOfflineStorage sharedOfflineStorage].mbglFileSource;
|
||||
|
||||
_mbglThreadPool = mbgl::sharedThreadPool();
|
||||
_mbglMap = new mbgl::Map(*_mbglView, self.size, [NSScreen mainScreen].backingScaleFactor, *mbglFileSource, *_mbglThreadPool, mbgl::MapMode::Continuous, mbgl::GLContextMode::Unique, mbgl::ConstrainMode::None, mbgl::ViewportMode::Default);
|
||||
_mbglMap = new mbgl::Map(*_mbglView, *_mbglView, self.size, [NSScreen mainScreen].backingScaleFactor, *mbglFileSource, *_mbglThreadPool, mbgl::MapMode::Continuous, mbgl::GLContextMode::Unique, mbgl::ConstrainMode::None, mbgl::ViewportMode::Default);
|
||||
|
||||
// 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.
|
||||
@@ -2756,7 +2756,7 @@ public:
|
||||
}
|
||||
|
||||
/// Adapter responsible for bridging calls from mbgl to MGLMapView and Cocoa.
|
||||
class MGLMapViewImpl : public mbgl::View, public mbgl::Backend {
|
||||
class MGLMapViewImpl : public mbgl::View, public mbgl::Backend, public mbgl::MapObserver {
|
||||
public:
|
||||
MGLMapViewImpl(MGLMapView *nativeView_)
|
||||
: nativeView(nativeView_) {}
|
||||
|
||||
@@ -45,7 +45,7 @@ static const char* releasedMessage() {
|
||||
NodeBackend::NodeBackend()
|
||||
: HeadlessBackend(sharedDisplay()) {}
|
||||
|
||||
void NodeBackend::onDidFailLoadingMap(std::exception_ptr error) {
|
||||
void NodeMapObserver::onDidFailLoadingMap(std::exception_ptr error) {
|
||||
std::rethrow_exception(error);
|
||||
}
|
||||
|
||||
@@ -530,7 +530,7 @@ void NodeMap::Cancel(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
||||
void NodeMap::cancel() {
|
||||
auto style = map->getStyle().getJSON();
|
||||
|
||||
map = std::make_unique<mbgl::Map>(backend, mbgl::Size{ 256, 256 },
|
||||
map = std::make_unique<mbgl::Map>(backend, mapObserver, mbgl::Size{ 256, 256 },
|
||||
pixelRatio, *this, threadpool, mbgl::MapMode::Still);
|
||||
|
||||
// FIXME: Reload the style after recreating the map. We need to find
|
||||
@@ -982,7 +982,9 @@ NodeMap::NodeMap(v8::Local<v8::Object> options)
|
||||
->NumberValue()
|
||||
: 1.0;
|
||||
}()),
|
||||
mapObserver(NodeMapObserver()),
|
||||
map(std::make_unique<mbgl::Map>(backend,
|
||||
mapObserver,
|
||||
mbgl::Size{ 256, 256 },
|
||||
pixelRatio,
|
||||
*this,
|
||||
|
||||
@@ -20,7 +20,10 @@ namespace node_mbgl {
|
||||
class NodeBackend : public mbgl::HeadlessBackend {
|
||||
public:
|
||||
NodeBackend();
|
||||
void onDidFailLoadingMap(std::exception_ptr) final;
|
||||
};
|
||||
|
||||
class NodeMapObserver : public mbgl::MapObserver {
|
||||
void onDidFailLoadingMap(std::exception_ptr) override;
|
||||
};
|
||||
|
||||
class NodeMap : public Nan::ObjectWrap,
|
||||
@@ -71,6 +74,7 @@ public:
|
||||
NodeBackend backend;
|
||||
std::unique_ptr<mbgl::OffscreenView> view;
|
||||
NodeThreadPool threadpool;
|
||||
NodeMapObserver mapObserver;
|
||||
std::unique_ptr<mbgl::Map> map;
|
||||
|
||||
std::exception_ptr error;
|
||||
|
||||
@@ -1498,7 +1498,7 @@ QMapboxGLPrivate::QMapboxGLPrivate(QMapboxGL *q, const QMapboxGLSettings &settin
|
||||
, threadPool(mbgl::sharedThreadPool())
|
||||
{
|
||||
mapObj = std::make_unique<mbgl::Map>(
|
||||
*this, sanitizedSize(size),
|
||||
*this, *this, sanitizedSize(size),
|
||||
pixelRatio, *fileSourceObj, *threadPool,
|
||||
mbgl::MapMode::Continuous,
|
||||
static_cast<mbgl::GLContextMode>(settings.contextMode()),
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <QObject>
|
||||
#include <QSize>
|
||||
|
||||
class QMapboxGLPrivate : public QObject, public mbgl::View, public mbgl::Backend
|
||||
class QMapboxGLPrivate : public QObject, public mbgl::View, public mbgl::Backend, public mbgl::MapObserver
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
Reference in New Issue
Block a user