Skip to content

Commit

Permalink
Compilation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ntadej committed Jul 10, 2022
1 parent 65fcf9d commit aeb2e27
Show file tree
Hide file tree
Showing 25 changed files with 71 additions and 43 deletions.
2 changes: 1 addition & 1 deletion bin/cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ int main(int argc, char* argv[]) {

mbgl::util::RunLoop loop;
std::shared_ptr<mbgl::FileSource> dbfs = mbgl::FileSourceManager::get()->getFileSource(
mbgl::FileSourceType::Database, mbgl::ResourceOptions().withCachePath(args::get(cacheValue), mbgl::ClientOptions() ));
mbgl::FileSourceType::Database, mbgl::ResourceOptions().withCachePath(args::get(cacheValue)), mbgl::ClientOptions());
dbfs->forward(resource, response, [&loop] { loop.stop(); });
loop.run();
return 0;
Expand Down
4 changes: 2 additions & 2 deletions bin/offline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ int main(int argc, char *argv[]) {
FileSourceType::Database,
ResourceOptions().withApiKey(apiKey)
.withTileServerOptions(mapTilerConfiguration)
.withCachePath(output)),
ClientOptions()));
.withCachePath(output),
ClientOptions())));

std::unique_ptr<OfflineRegion> region;

Expand Down
3 changes: 1 addition & 2 deletions include/mbgl/storage/database_file_source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

#include <mbgl/storage/file_source.hpp>
#include <mbgl/storage/offline.hpp>
#include <mbgl/util/client_options.hpp>
#include <mbgl/util/expected.hpp>
#include <mbgl/util/optional.hpp>
#include <mbgl/storage/resource_options.hpp>

namespace mbgl {

class ClientOptions;
class ResourceOptions;

// TODO: Split DatabaseFileSource into Ambient cache and Database interfaces.
Expand Down
1 change: 1 addition & 0 deletions include/mbgl/storage/file_source_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

namespace mbgl {

class ClientOptions;
class ResourceOptions;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,13 @@ void AssetManagerFileSource::setResourceOptions(ResourceOptions options) {
ResourceOptions AssetManagerFileSource::getResourceOptions() {
return impl->actor().ask(&Impl::getResourceOptions).get();
}

void AssetManagerFileSource::setClientOptions(ClientOptions options) {
impl->actor().invoke(&Impl::setClientOptions, options.clone());
}

ClientOptions AssetManagerFileSource::getClientOptions() {
return impl->actor().ask(&Impl::getClientOptions).get();
}

} // namespace mbgl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class AssetManagerFileSource : public FileSource {
ResourceOptions getResourceOptions() override;

void setClientOptions(ClientOptions options) override;
ClientOptions setClientOptions() override;
ClientOptions getClientOptions() override;

private:
class Impl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ FileSource::FileSource(jni::JNIEnv& _env, const jni::String& apiKey, const jni::
mapbox::sqlite::setTempPath(path);

mbgl::FileSourceManager::get()->registerFileSourceFactory(
mbgl::FileSourceType::Asset, [](const mbgl::ResourceOptions& resourceOptions, mbgl::ClientOptions& clientOptions) {
mbgl::FileSourceType::Asset, [](const mbgl::ResourceOptions& resourceOptions, const mbgl::ClientOptions& clientOptions) {
auto env{android::AttachEnv()};
std::unique_ptr<mbgl::FileSource> assetFileSource;
if (android::Mapbox::hasInstance(*env)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ MapSnapshotter::MapSnapshotter(jni::JNIEnv& _env,
size,
pixelRatio,
mbgl::android::FileSource::getSharedResourceOptions(_env, _jFileSource),
mbgl::android::FileSource::getSharedClientOptions(_env, _jFileSource),
*this,
_localIdeographFontFamily ? jni::Make<std::string>(_env, _localIdeographFontFamily) : optional<std::string>{});

Expand Down
4 changes: 3 additions & 1 deletion platform/default/include/mbgl/map/map_snapshotter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace mbgl {

struct CameraOptions;
class ClientOptions;
class LatLngBounds;
class ResourceOptions;

Expand All @@ -34,10 +35,11 @@ class MapSnapshotter {
MapSnapshotter(Size size,
float pixelRatio,
const ResourceOptions&,
const ClientOptions&,
MapSnapshotterObserver&,
optional<std::string> localFontFamily = nullopt);

MapSnapshotter(Size size, float pixelRatio, const ResourceOptions&);
MapSnapshotter(Size size, float pixelRatio, const ResourceOptions&, const ClientOptions&);

~MapSnapshotter();

Expand Down
12 changes: 8 additions & 4 deletions platform/default/src/mbgl/map/map_snapshotter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <mbgl/renderer/update_parameters.hpp>
#include <mbgl/storage/resource_options.hpp>
#include <mbgl/style/style.hpp>
#include <mbgl/util/client_options.hpp>
#include <mbgl/util/event.hpp>
#include <mbgl/util/exception.hpp>
#include <mbgl/util/logging.hpp>
Expand Down Expand Up @@ -151,14 +152,16 @@ class MapSnapshotter::Impl final : public MapObserver {
Impl(Size size,
float pixelRatio,
const ResourceOptions& resourceOptions,
const ClientOptions& clientOptions,
MapSnapshotterObserver& observer_,
optional<std::string> localFontFamily)
: observer(observer_),
frontend(size, pixelRatio, std::move(localFontFamily)),
map(frontend,
*this,
MapOptions().withMapMode(MapMode::Static).withSize(size).withPixelRatio(pixelRatio),
resourceOptions) {}
resourceOptions,
clientOptions) {}

void setRegion(const LatLngBounds& region) {
mbgl::EdgeInsets insets{0, 0, 0, 0};
Expand Down Expand Up @@ -252,13 +255,14 @@ class MapSnapshotter::Impl final : public MapObserver {
MapSnapshotter::MapSnapshotter(Size size,
float pixelRatio,
const ResourceOptions& resourceOptions,
const ClientOptions& clientOptions,
MapSnapshotterObserver& observer,
optional<std::string> localFontFamily)
: impl(std::make_unique<MapSnapshotter::Impl>(
size, pixelRatio, resourceOptions, observer, std::move(localFontFamily))) {}
size, pixelRatio, resourceOptions, clientOptions, observer, std::move(localFontFamily))) {}

MapSnapshotter::MapSnapshotter(Size size, float pixelRatio, const ResourceOptions& resourceOptions)
: MapSnapshotter(size, pixelRatio, resourceOptions, MapSnapshotterObserver::nullObserver()) {}
MapSnapshotter::MapSnapshotter(Size size, float pixelRatio, const ResourceOptions& resourceOptions, const ClientOptions& clientOptions)
: MapSnapshotter(size, pixelRatio, resourceOptions, clientOptions, MapSnapshotterObserver::nullObserver()) {}

MapSnapshotter::~MapSnapshotter() = default;

Expand Down
8 changes: 4 additions & 4 deletions platform/default/src/mbgl/storage/database_file_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,14 @@ class DatabaseFileSourceThread {

class DatabaseFileSource::Impl {
public:
Impl(std::shared_ptr<FileSource> onlineFileSource, const ResourceOptions& resourceOptions, const ClientOptions& clientOptions) :
Impl(std::shared_ptr<FileSource> onlineFileSource, const ResourceOptions& resourceOpts, const ClientOptions& clientOpts) :
thread(std::make_unique<util::Thread<DatabaseFileSourceThread>>(
util::makeThreadPrioritySetter(platform::EXPERIMENTAL_THREAD_PRIORITY_DATABASE),
"DatabaseFileSource",
std::move(onlineFileSource),
resourceOptions.cachePath())),
resourceOptions(resourceOptions.clone()),
clientOptions(clientOptions.clone()) {}
resourceOpts.cachePath())),
resourceOptions(resourceOpts.clone()),
clientOptions(clientOpts.clone()) {}

ActorRef<DatabaseFileSourceThread> actor() const { return thread->actor(); }

Expand Down
7 changes: 4 additions & 3 deletions platform/glfw/glfw_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,12 @@ void glfwError(int error, const char *description) {
mbgl::Log::Error(mbgl::Event::OpenGL, "GLFW error (%i): %s", error, description);
}

GLFWView::GLFWView(bool fullscreen_, bool benchmark_, const mbgl::ResourceOptions &options)
GLFWView::GLFWView(bool fullscreen_, bool benchmark_, const mbgl::ResourceOptions &resourceOptions, const mbgl::ClientOptions &clientOptions)
: fullscreen(fullscreen_),
benchmark(benchmark_),
snapshotterObserver(std::make_unique<SnapshotObserver>()),
mapResourceOptions(options.clone()) {
mapResourceOptions(resourceOptions.clone()),
mapClientOptions(clientOptions.clone()) {
glfwSetErrorCallback(glfwError);

std::srand(static_cast<unsigned int>(std::time(nullptr)));
Expand Down Expand Up @@ -726,7 +727,7 @@ void GLFWView::popAnnotation() {
void GLFWView::makeSnapshot(bool withOverlay) {
if (!snapshotter || snapshotter->getStyleURL() != map->getStyle().getURL()) {
snapshotter = std::make_unique<mbgl::MapSnapshotter>(
map->getMapOptions().size(), map->getMapOptions().pixelRatio(), mapResourceOptions, *snapshotterObserver);
map->getMapOptions().size(), map->getMapOptions().pixelRatio(), mapResourceOptions, mapClientOptions, *snapshotterObserver);
snapshotter->setStyleURL(map->getStyle().getURL());
}

Expand Down
3 changes: 2 additions & 1 deletion platform/glfw/glfw_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class RendererBackend;

class GLFWView : public mbgl::MapObserver {
public:
GLFWView(bool fullscreen, bool benchmark, const mbgl::ResourceOptions &options);
GLFWView(bool fullscreen, bool benchmark, const mbgl::ResourceOptions &resourceOptions, const mbgl::ClientOptions &clientOptions);
~GLFWView() override;

float getPixelRatio() const;
Expand Down Expand Up @@ -152,6 +152,7 @@ class GLFWView : public mbgl::MapObserver {
std::unique_ptr<mbgl::MapSnapshotter> snapshotter;
std::unique_ptr<SnapshotObserver> snapshotterObserver;
mbgl::ResourceOptions mapResourceOptions;
mbgl::ClientOptions mapClientOptions;

#if defined(MBGL_RENDER_BACKEND_OPENGL) && !defined(MBGL_LAYER_CUSTOM_DISABLE_ALL)
bool puckFollowsCameraCenter = false;
Expand Down
4 changes: 2 additions & 2 deletions platform/glfw/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ int main(int argc, char *argv[]) {

auto mapTilerConfiguration = mbgl::TileServerOptions::MapTilerConfiguration();
mbgl::ResourceOptions resourceOptions;
mbgl::ClientOptions clientOptions;
resourceOptions.withCachePath(cacheDB).withApiKey(apikey).withTileServerOptions(mapTilerConfiguration);
mbgl::ClientOptions clientOptions;
auto orderedStyles = mapTilerConfiguration.defaultStyles();

GLFWView backend(fullscreen, benchmark, resourceOptions);
GLFWView backend(fullscreen, benchmark, resourceOptions, clientOptions);
view = &backend;

std::shared_ptr<mbgl::FileSource> onlineFileSource =
Expand Down
5 changes: 4 additions & 1 deletion platform/ios/platform/darwin/src/MGLMapSnapshotter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#import <mbgl/map/map_snapshotter.hpp>
#import <mbgl/map/camera.hpp>
#import <mbgl/storage/resource_options.hpp>
#import <mbgl/util/client_options.hpp>
#import <mbgl/util/string.hpp>

#import "MGLOfflineStorage_Private.h"
Expand Down Expand Up @@ -718,6 +719,8 @@ - (void)configureWithOptions:(MGLMapSnapshotOptions *)options {
.withTileServerOptions(*tileServerOptions)
.withCachePath(MGLOfflineStorage.sharedOfflineStorage.databasePath.UTF8String)
.withAssetPath(NSBundle.mainBundle.resourceURL.path.UTF8String);
mbgl::ClientOptions clientOptions;

auto apiKey = [[MGLSettings sharedSettings] apiKey];
if (apiKey) {
resourceOptions.withApiKey([apiKey UTF8String]);
Expand All @@ -727,7 +730,7 @@ - (void)configureWithOptions:(MGLMapSnapshotOptions *)options {
auto localFontFamilyName = config.localFontFamilyName ? std::string(config.localFontFamilyName.UTF8String) : nullptr;
_delegateHost = std::make_unique<MGLMapSnapshotterDelegateHost>(self);
_mbglMapSnapshotter = std::make_unique<mbgl::MapSnapshotter>(
size, pixelRatio, resourceOptions, *_delegateHost, localFontFamilyName);
size, pixelRatio, resourceOptions, clientOptions, *_delegateHost, localFontFamilyName);

_mbglMapSnapshotter->setStyleURL(std::string(options.styleURL.absoluteString.UTF8String));

Expand Down
6 changes: 4 additions & 2 deletions platform/ios/platform/ios/src/MGLMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <mbgl/gl/custom_layer.hpp>
#include <mbgl/renderer/renderer.hpp>
#include <mbgl/math/wrap.hpp>
#include <mbgl/util/client_options.hpp>
#include <mbgl/util/exception.hpp>
#include <mbgl/util/geo.hpp>
#include <mbgl/util/constants.hpp>
Expand Down Expand Up @@ -499,14 +500,15 @@ - (void)commonInit
resourceOptions.withCachePath(MGLOfflineStorage.sharedOfflineStorage.databasePath.UTF8String)
.withAssetPath([NSBundle mainBundle].resourceURL.path.UTF8String)
.withTileServerOptions(*tileServerOptions);

mbgl::ClientOptions clientOptions;

auto apiKey = [[MGLSettings sharedSettings] apiKey];
if (apiKey) {
resourceOptions.withApiKey([apiKey UTF8String]);
}

NSAssert(!_mbglMap, @"_mbglMap should be NULL");
_mbglMap = std::make_unique<mbgl::Map>(*_rendererFrontend, *_mbglView, mapOptions, resourceOptions);
_mbglMap = std::make_unique<mbgl::Map>(*_rendererFrontend, *_mbglView, mapOptions, resourceOptions, clientOptions);

// start paused if launch into the background
if (background) {
Expand Down
6 changes: 4 additions & 2 deletions platform/ios/platform/macos/src/MGLMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#import <mbgl/storage/network_status.hpp>
#import <mbgl/storage/resource_options.hpp>
#import <mbgl/math/wrap.hpp>
#import <mbgl/util/client_options.hpp>
#import <mbgl/util/constants.hpp>
#import <mbgl/util/chrono.hpp>
#import <mbgl/util/exception.hpp>
Expand Down Expand Up @@ -298,13 +299,14 @@ - (void)commonInit {
resourceOptions.withTileServerOptions(*tileServerOptions)
.withCachePath(MGLOfflineStorage.sharedOfflineStorage.databasePath.UTF8String)
.withAssetPath([NSBundle mainBundle].resourceURL.path.UTF8String);

mbgl::ClientOptions clientOptions;

auto apiKey = [[MGLSettings sharedSettings] apiKey];
if (apiKey) {
resourceOptions.withApiKey([apiKey UTF8String]);
}

_mbglMap = std::make_unique<mbgl::Map>(*_rendererFrontend, *_mbglView, mapOptions, resourceOptions);
_mbglMap = std::make_unique<mbgl::Map>(*_rendererFrontend, *_mbglView, mapOptions, resourceOptions, clientOptions);

// Notify map object when network reachability status changes.
_reachability = [MGLReachability reachabilityForInternetConnection];
Expand Down
2 changes: 1 addition & 1 deletion platform/node/src/node_map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ struct NodeFileSource : public mbgl::FileSource {
bool canRequest(const mbgl::Resource&) const override;
void setResourceOptions(mbgl::ResourceOptions) override;
mbgl::ResourceOptions getResourceOptions() override;
void setResourceOptions(mbgl::ClientOptions) override;
void setClientOptions(mbgl::ClientOptions) override;
mbgl::ClientOptions getClientOptions() override;
NodeMap* nodeMap;
mbgl::ResourceOptions _resourceOptions;
Expand Down
7 changes: 4 additions & 3 deletions render-test/file_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ std::atomic_size_t transferredSize{0};
std::atomic_bool active{false};
std::atomic_bool offline{true};

ProxyFileSource::ProxyFileSource(std::shared_ptr<FileSource> defaultResourceLoader_, const ResourceOptions& resourceOptions, const ClientOptions& clientOptions)
: defaultResourceLoader(std::move(defaultResourceLoader_)) {
ProxyFileSource::ProxyFileSource(std::shared_ptr<FileSource> defaultResourceLoader_, const ResourceOptions& resourceOpts, const ClientOptions& clientOpts)
: defaultResourceLoader(std::move(defaultResourceLoader_)),
resourceOptions(resourceOpts.clone()), clientOptions(clientOpts.clone()) {
assert(defaultResourceLoader);
if (offline) {
std::shared_ptr<FileSource> dbfs = FileSourceManager::get()->getFileSource(FileSourceType::Database, resourceOptions, clientOptions);
std::shared_ptr<FileSource> dbfs = FileSourceManager::get()->getFileSource(FileSourceType::Database, resourceOpts, clientOpts);
dbfs->setProperty(READ_ONLY_MODE_KEY, true);
}
}
Expand Down
3 changes: 2 additions & 1 deletion render-test/file_source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

namespace mbgl {

class ClientOptions;
class ResourceOptions;

class ProxyFileSource : public FileSource {
public:
ProxyFileSource(std::shared_ptr<FileSource>, const ResourceOptions&);
ProxyFileSource(std::shared_ptr<FileSource>, const ResourceOptions&, const ClientOptions&);
~ProxyFileSource();

std::unique_ptr<AsyncRequest> request(const Resource&, Callback) override;
Expand Down
3 changes: 2 additions & 1 deletion render-test/runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,8 @@ void TestRunner::run(TestMetadata& metadata) {
if (maps.find(key) == maps.end()) {
maps[key] = std::make_unique<TestRunner::Impl>(
metadata,
mbgl::ResourceOptions().withCachePath(manifest.getCachePath()).withApiKey(manifest.getApiKey()));
mbgl::ResourceOptions().withCachePath(manifest.getCachePath()).withApiKey(manifest.getApiKey()),
mbgl::ClientOptions());
}

ctx.runnerImpl = maps[key].get();
Expand Down
2 changes: 1 addition & 1 deletion src/mbgl/storage/http_file_source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

#include <mbgl/storage/file_source.hpp>
#include <mbgl/storage/resource.hpp>
#include <mbgl/storage/resource_options.hpp>

namespace mbgl {

class ClientOptions;
class ResourceOptions;

class HTTPFileSource : public FileSource {
Expand Down
3 changes: 1 addition & 2 deletions src/mbgl/storage/main_resource_loader.hpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#pragma once

#include <mbgl/storage/file_source.hpp>
#include <mbgl/storage/resource_options.hpp>
#include <mbgl/util/client_options.hpp>

namespace mbgl {

class ClientOptions;
class ResourceTransform;
class ResourceOptions;

Expand Down
Loading

0 comments on commit aeb2e27

Please sign in to comment.