[core] Fix performance-unnecessary-value-param errors

As reported by clang-tidy-8.
This commit is contained in:
Thiago Marcos P. Santos
2020-03-20 12:38:09 +02:00
parent 37802eec36
commit d15b9c1f9c
112 changed files with 543 additions and 479 deletions

View File

@@ -36,7 +36,7 @@ public:
void push(std::unique_ptr<Message>);
void receive();
static void maybeReceive(std::weak_ptr<Mailbox>);
static void maybeReceive(const std::weak_ptr<Mailbox>&);
static std::function<void()> makeClosure(std::weak_ptr<Mailbox>);
private:

View File

@@ -10,7 +10,7 @@ namespace platform {
class Collator {
public:
explicit Collator(bool caseSensitive, bool diacriticSensitive, optional<std::string> locale = nullopt);
explicit Collator(bool caseSensitive, bool diacriticSensitive, const optional<std::string>& locale = nullopt);
int compare(const std::string& lhs, const std::string& rhs) const;
std::string resolvedLocale() const;
bool operator==(const Collator& other) const;

View File

@@ -60,17 +60,26 @@ public:
bool isPanning() const;
// Camera
CameraOptions getCameraOptions(optional<EdgeInsets> = {}) const;
CameraOptions getCameraOptions(const optional<EdgeInsets>& = {}) const;
void jumpTo(const CameraOptions&);
void easeTo(const CameraOptions&, const AnimationOptions&);
void flyTo(const CameraOptions&, const AnimationOptions&);
void moveBy(const ScreenCoordinate&, const AnimationOptions& = {});
void scaleBy(double scale, optional<ScreenCoordinate> anchor, const AnimationOptions& animation = {});
void scaleBy(double scale, const optional<ScreenCoordinate>& anchor, const AnimationOptions& animation = {});
void pitchBy(double pitch, const AnimationOptions& animation = {});
void rotateBy(const ScreenCoordinate& first, const ScreenCoordinate& second, const AnimationOptions& = {});
CameraOptions cameraForLatLngBounds(const LatLngBounds&, const EdgeInsets&, optional<double> bearing = {}, optional<double> pitch = {}) const;
CameraOptions cameraForLatLngs(const std::vector<LatLng>&, const EdgeInsets&, optional<double> bearing = {}, optional<double> pitch = {}) const;
CameraOptions cameraForGeometry(const Geometry<double>&, const EdgeInsets&, optional<double> bearing = {}, optional<double> pitch = {}) const;
CameraOptions cameraForLatLngBounds(const LatLngBounds&,
const EdgeInsets&,
const optional<double>& bearing = {},
const optional<double>& pitch = {}) const;
CameraOptions cameraForLatLngs(const std::vector<LatLng>&,
const EdgeInsets&,
const optional<double>& bearing = {},
const optional<double>& pitch = {}) const;
CameraOptions cameraForGeometry(const Geometry<double>&,
const EdgeInsets&,
const optional<double>& bearing = {},
const optional<double>& pitch = {}) const;
LatLngBounds latLngBoundsForCamera(const CameraOptions&) const;
LatLngBounds latLngBoundsForCameraUnwrapped(const CameraOptions&) const;

View File

@@ -26,7 +26,7 @@ public:
// Sets multiple setting values by merging current Settings object
// with provided `values` object.
void set(mapbox::base::ValueObject values) noexcept;
void set(const mapbox::base::ValueObject& values) noexcept;
// Returns setting value for a specified key or NullValue if element
// for specified key is missing.

View File

@@ -23,8 +23,7 @@ class RendererBackend;
class Renderer {
public:
Renderer(gfx::RendererBackend&, float pixelRatio_,
const optional<std::string> localFontFamily = {});
Renderer(gfx::RendererBackend&, float pixelRatio_, const optional<std::string>& localFontFamily = {});
~Renderer();
void markContextLost();

View File

@@ -216,7 +216,7 @@ public:
* executed on the database thread; it is the responsibility of the SDK bindings
* to re-execute a user-provided callback on the main thread.
*/
virtual void deleteOfflineRegion(OfflineRegion, std::function<void(std::exception_ptr)>);
virtual void deleteOfflineRegion(OfflineRegion&, std::function<void(std::exception_ptr)>);
/*
* Invalidate all the tiles from an offline region forcing Mapbox GL to revalidate

View File

@@ -11,7 +11,7 @@ namespace expression {
class Collator {
public:
Collator(bool caseSensitive, bool diacriticSensitive, optional<std::string> locale = {});
Collator(bool caseSensitive, bool diacriticSensitive, const optional<std::string>& locale = {});
bool operator==(const Collator& other) const;

View File

@@ -15,7 +15,7 @@ ParseResult parseComparison(const mbgl::style::conversion::Convertible&, Parsing
class BasicComparison : public Expression {
public:
using CompareFunctionType = bool (*) (Value, Value);
using CompareFunctionType = bool (*)(const Value&, const Value&);
BasicComparison(
std::string op,
@@ -38,7 +38,7 @@ private:
class CollatorComparison : public Expression {
public:
using CompareFunctionType = bool (*) (std::string, std::string, Collator);
using CompareFunctionType = bool (*)(const std::string&, const std::string&, const Collator&);
CollatorComparison(
std::string op,

View File

@@ -46,7 +46,7 @@ protected:
std::vector<std::unique_ptr<Expression>> args;
};
ParseResult parseCompoundExpression(const std::string name,
ParseResult parseCompoundExpression(const std::string& name,
const mbgl::style::conversion::Convertible& value,
ParsingContext& ctx);

View File

@@ -29,13 +29,13 @@ std::unique_ptr<Expression> createExpression(const mbgl::style::conversion::Conv
std::unique_ptr<Expression> error(std::string);
std::unique_ptr<Expression> literal(const char* value);
std::unique_ptr<Expression> literal(Value value);
std::unique_ptr<Expression> literal(const Value& value);
std::unique_ptr<Expression> literal(std::initializer_list<double> value);
std::unique_ptr<Expression> literal(std::initializer_list<const char*> value);
std::unique_ptr<Expression>
assertion(type::Type, std::unique_ptr<Expression>,
std::unique_ptr<Expression> def = nullptr);
std::unique_ptr<Expression> assertion(const type::Type&,
std::unique_ptr<Expression>,
std::unique_ptr<Expression> def = nullptr);
std::unique_ptr<Expression> number(std::unique_ptr<Expression>,
std::unique_ptr<Expression> def = nullptr);
std::unique_ptr<Expression> string(std::unique_ptr<Expression>,

View File

@@ -93,7 +93,7 @@ public:
Parse the given style-spec JSON value as an expression.
*/
ParseResult parseExpression(const mbgl::style::conversion::Convertible& value,
optional<TypeAnnotationOption> = {});
const optional<TypeAnnotationOption>& = {});
/*
Parse the given style-spec JSON value as an expression intended to be used
@@ -108,8 +108,8 @@ public:
ParseResult parse(const mbgl::style::conversion::Convertible&,
std::size_t,
optional<type::Type> = {},
optional<TypeAnnotationOption> = {});
const optional<TypeAnnotationOption>& = {});
/*
Parse a child expression. For use by individual Expression::parse() methods.
*/
@@ -168,9 +168,8 @@ private:
type (either Literal, or the one named in value[0]) and dispatching to the
appropriate ParseXxxx::parse(const V&, ParsingContext) method.
*/
ParseResult parse(const mbgl::style::conversion::Convertible& value,
optional<TypeAnnotationOption> = {});
ParseResult parse(const mbgl::style::conversion::Convertible& value, const optional<TypeAnnotationOption>& = {});
std::string key;
optional<type::Type> expected;
std::shared_ptr<detail::Scope> scope;

View File

@@ -34,7 +34,7 @@ public:
bool sdf,
ImageStretches stretchX = {},
ImageStretches stretchY = {},
optional<ImageContent> content = nullopt);
const optional<ImageContent>& content = nullopt);
Image(std::string id,
PremultipliedImage&& image,
float pixelRatio,

View File

@@ -37,7 +37,7 @@ public:
TileOptions tileOptions;
};
public:
CustomGeometrySource(std::string id, CustomGeometrySource::Options options);
CustomGeometrySource(std::string id, const CustomGeometrySource::Options& options);
~CustomGeometrySource() final;
void loadDescription(FileSource&) final;
void setTileData(const CanonicalTileID&, const GeoJSON&);

View File

@@ -42,7 +42,7 @@ public:
using TileFeatures = mapbox::feature::feature_collection<int16_t>;
using Features = mapbox::feature::feature_collection<double>;
static std::shared_ptr<GeoJSONData> create(const GeoJSON&,
Immutable<GeoJSONOptions> = GeoJSONOptions::defaultOptions(),
const Immutable<GeoJSONOptions>& = GeoJSONOptions::defaultOptions(),
std::shared_ptr<Scheduler> scheduler = nullptr);
virtual ~GeoJSONData() = default;

View File

@@ -65,7 +65,7 @@ inline std::string toString(long double t, bool decimal = false) {
return toString(static_cast<double>(t), decimal);
}
std::string toString(std::exception_ptr);
std::string toString(const std::exception_ptr &);
template <class T>
std::string toString(T) = delete;

View File

@@ -173,10 +173,8 @@ private:
jni::Global<jni::Object<android::Locale>> locale;
};
Collator::Collator(bool caseSensitive, bool diacriticSensitive, optional<std::string> locale_)
: impl(std::make_shared<Impl>(caseSensitive, diacriticSensitive, std::move(locale_)))
{}
Collator::Collator(bool caseSensitive, bool diacriticSensitive, const optional<std::string>& locale_)
: impl(std::make_shared<Impl>(caseSensitive, diacriticSensitive, locale_)) {}
bool Collator::operator==(const Collator& other) const {
return *impl == *(other.impl);

View File

@@ -111,7 +111,7 @@ void OfflineRegion::getOfflineRegionStatus(jni::JNIEnv& env_, const jni::Object<
void OfflineRegion::deleteOfflineRegion(jni::JNIEnv& env_, const jni::Object<OfflineRegionDeleteCallback>& callback_) {
auto globalCallback = jni::NewGlobal<jni::EnvAttachingDeleter>(env_, callback_);
fileSource->deleteOfflineRegion(std::move(*region),
fileSource->deleteOfflineRegion(*region,
[
// Ensure the object is not gc'd in the meanwhile
callback = std::make_shared<decltype(globalCallback)>(

View File

@@ -16,7 +16,7 @@ public:
std::string resolvedLocale() const { return ""; }
};
Collator::Collator(bool, bool, optional<std::string> locale_) : impl(std::make_shared<Impl>(std::move(locale_))) {}
Collator::Collator(bool, bool, const optional<std::string>& locale_) : impl(std::make_shared<Impl>(locale_)) {}
int Collator::compare(const std::string& lhs, const std::string& rhs) const {
return impl->compare(lhs, rhs);

View File

@@ -89,9 +89,8 @@ private:
android::LocalGlyphRasterizer androidLocalGlyphRasterizer;
};
LocalGlyphRasterizer::LocalGlyphRasterizer(const optional<std::string> fontFamily)
: impl(std::make_unique<Impl>(fontFamily))
{}
LocalGlyphRasterizer::LocalGlyphRasterizer(const optional<std::string>& fontFamily)
: impl(std::make_unique<Impl>(fontFamily)) {}
LocalGlyphRasterizer::~LocalGlyphRasterizer()
{}

View File

@@ -9,7 +9,7 @@ namespace platform {
class Collator::Impl {
public:
Impl(bool caseSensitive, bool diacriticSensitive, optional<std::string> locale_)
Impl(bool caseSensitive, bool diacriticSensitive, const optional<std::string>& locale_)
: options((caseSensitive ? 0 : NSCaseInsensitiveSearch) |
(diacriticSensitive ? 0 : NSDiacriticInsensitiveSearch))
, locale(locale_ ?
@@ -47,8 +47,8 @@ private:
NSLocale* locale;
};
Collator::Collator(bool caseSensitive, bool diacriticSensitive, optional<std::string> locale_)
: impl(std::make_shared<Impl>(caseSensitive, diacriticSensitive, std::move(locale_)))
Collator::Collator(bool caseSensitive, bool diacriticSensitive, const optional<std::string>& locale_)
: impl(std::make_shared<Impl>(caseSensitive, diacriticSensitive, locale_))
{}
bool Collator::operator==(const Collator& other) const {

View File

@@ -88,7 +88,7 @@ private:
CTFontRef fontHandle;
};
LocalGlyphRasterizer::LocalGlyphRasterizer(const optional<std::string> fontFamily)
LocalGlyphRasterizer::LocalGlyphRasterizer(const optional<std::string>& fontFamily)
: impl(std::make_unique<Impl>(fontFamily))
{}

View File

@@ -26,12 +26,12 @@ public:
HeadlessFrontend(float pixelRatio_,
gfx::HeadlessBackend::SwapBehaviour swapBehviour = gfx::HeadlessBackend::SwapBehaviour::NoFlush,
gfx::ContextMode mode = gfx::ContextMode::Unique,
const optional<std::string> localFontFamily = {});
const optional<std::string>& localFontFamily = {});
HeadlessFrontend(Size,
float pixelRatio_,
gfx::HeadlessBackend::SwapBehaviour swapBehviour = gfx::HeadlessBackend::SwapBehaviour::NoFlush,
gfx::ContextMode mode = gfx::ContextMode::Unique,
const optional<std::string> localFontFamily = {});
const optional<std::string>& localFontFamily = {});
~HeadlessFrontend() override;
void reset() override;

View File

@@ -8,6 +8,6 @@ template <typename>
class ActorRef;
class FileSourceRequest;
void requestLocalFile(const std::string&, ActorRef<FileSourceRequest>);
void requestLocalFile(const std::string&, const ActorRef<FileSourceRequest>&);
} // namespace mbgl

View File

@@ -14,14 +14,14 @@ namespace mbgl {
HeadlessFrontend::HeadlessFrontend(float pixelRatio_,
gfx::HeadlessBackend::SwapBehaviour swapBehavior,
const gfx::ContextMode contextMode,
const optional<std::string> localFontFamily)
const optional<std::string>& localFontFamily)
: HeadlessFrontend({256, 256}, pixelRatio_, swapBehavior, contextMode, localFontFamily) {}
HeadlessFrontend::HeadlessFrontend(Size size_,
float pixelRatio_,
gfx::HeadlessBackend::SwapBehaviour swapBehavior,
const gfx::ContextMode contextMode,
const optional<std::string> localFontFamily)
const optional<std::string>& localFontFamily)
: size(size_),
pixelRatio(pixelRatio_),
frameTime(0),
@@ -144,7 +144,7 @@ HeadlessFrontend::RenderResult HeadlessFrontend::render(Map& map) {
HeadlessFrontend::RenderResult result;
std::exception_ptr error;
map.renderStill([&](std::exception_ptr e) {
map.renderStill([&](const std::exception_ptr& e) {
if (e) {
error = e;
} else {

View File

@@ -50,10 +50,8 @@ namespace platform {
class Collator::Impl {
public:
Impl(bool caseSensitive_, bool diacriticSensitive_, optional<std::string>)
: caseSensitive(caseSensitive_)
, diacriticSensitive(diacriticSensitive_)
{}
Impl(bool caseSensitive_, bool diacriticSensitive_, const optional<std::string>&)
: caseSensitive(caseSensitive_), diacriticSensitive(diacriticSensitive_) {}
bool operator==(const Impl& other) const {
return caseSensitive == other.caseSensitive && diacriticSensitive == other.diacriticSensitive;
@@ -94,8 +92,8 @@ std::string Collator::resolvedLocale() const {
return impl->resolvedLocale();
}
Collator::Collator(bool caseSensitive, bool diacriticSensitive, optional<std::string> locale)
: impl(std::make_shared<Impl>(caseSensitive, diacriticSensitive, std::move(locale))) {}
Collator::Collator(bool caseSensitive, bool diacriticSensitive, const optional<std::string>& locale)
: impl(std::make_shared<Impl>(caseSensitive, diacriticSensitive, locale)) {}
} // namespace platform
} // namespace mbgl

View File

@@ -14,6 +14,7 @@
#include <mbgl/util/exception.hpp>
#include <mbgl/util/logging.hpp>
#include <mbgl/util/thread.hpp>
#include <utility>
namespace mbgl {
@@ -49,12 +50,12 @@ private:
class SnapshotterRenderer final : public RendererObserver {
public:
SnapshotterRenderer(Size size, float pixelRatio, optional<std::string> localFontFamily)
SnapshotterRenderer(Size size, float pixelRatio, const optional<std::string>& localFontFamily)
: frontend(size,
pixelRatio,
gfx::HeadlessBackend::SwapBehaviour::NoFlush,
gfx::ContextMode::Unique,
std::move(localFontFamily)) {}
localFontFamily) {}
void reset() {
hasPendingStillImageRequest = false;
@@ -178,11 +179,11 @@ public:
Attributions attributions,
PointForFn pfn,
LatLngForFn latLonFn) {
cb(ptr, std::move(image), std::move(attributions), std::move(pfn), std::move(latLonFn));
cb(std::move(ptr), std::move(image), std::move(attributions), std::move(pfn), std::move(latLonFn));
renderStillCallback.reset();
});
map.renderStill([this, actorRef = renderStillCallback->self()](std::exception_ptr error) {
map.renderStill([this, actorRef = renderStillCallback->self()](const std::exception_ptr& error) {
// Create lambda that captures the current transform state
// and can be used to translate for geographic to screen
// coordinates

View File

@@ -19,11 +19,9 @@ namespace mbgl {
class AssetFileSource::Impl {
public:
Impl(ActorRef<Impl>, std::string root_)
: root(std::move(root_)) {
}
Impl(const ActorRef<Impl>&, std::string root_) : root(std::move(root_)) {}
void request(const std::string& url, ActorRef<FileSourceRequest> req) {
void request(const std::string& url, const ActorRef<FileSourceRequest>& req) {
if (!acceptsURL(url)) {
Response response;
response.error = std::make_unique<Response::Error>(Response::Error::Reason::Other,
@@ -35,7 +33,7 @@ public:
// Cut off the protocol and prefix with path.
const auto path =
root + "/" + mbgl::util::percentDecode(url.substr(std::char_traits<char>::length(util::ASSET_PROTOCOL)));
requestLocalFile(path, std::move(req));
requestLocalFile(path, req);
}
private:

View File

@@ -12,14 +12,15 @@
#include <mbgl/util/thread.hpp>
#include <map>
#include <utility>
namespace mbgl {
class DatabaseFileSourceThread {
public:
DatabaseFileSourceThread(std::shared_ptr<FileSource> onlineFileSource_, std::string cachePath)
: db(std::make_unique<OfflineDatabase>(cachePath)), onlineFileSource(onlineFileSource_) {}
DatabaseFileSourceThread(std::shared_ptr<FileSource> onlineFileSource_, const std::string& cachePath)
: db(std::make_unique<OfflineDatabase>(cachePath)), onlineFileSource(std::move(onlineFileSource_)) {}
void request(const Resource& resource, ActorRef<FileSourceRequest> req) {
void request(const Resource& resource, const ActorRef<FileSourceRequest>& req) {
auto offlineResponse = db->get(resource);
if (!offlineResponse) {
offlineResponse.emplace();
@@ -33,61 +34,63 @@ public:
req.invoke(&FileSourceRequest::setResponse, *offlineResponse);
}
void setDatabasePath(const std::string& path, std::function<void()> callback) {
void setDatabasePath(const std::string& path, const std::function<void()>& callback) {
db->changePath(path);
if (callback) {
callback();
}
}
void forward(const Resource& resource, const Response& response, std::function<void()> callback) {
void forward(const Resource& resource, const Response& response, const std::function<void()>& callback) {
db->put(resource, response);
if (callback) {
callback();
}
}
void resetDatabase(std::function<void(std::exception_ptr)> callback) { callback(db->resetDatabase()); }
void resetDatabase(const std::function<void(std::exception_ptr)>& callback) { callback(db->resetDatabase()); }
void packDatabase(std::function<void(std::exception_ptr)> callback) { callback(db->pack()); }
void packDatabase(const std::function<void(std::exception_ptr)>& callback) { callback(db->pack()); }
void runPackDatabaseAutomatically(bool autopack) { db->runPackDatabaseAutomatically(autopack); }
void put(const Resource& resource, const Response& response) { db->put(resource, response); }
void invalidateAmbientCache(std::function<void(std::exception_ptr)> callback) {
void invalidateAmbientCache(const std::function<void(std::exception_ptr)>& callback) {
callback(db->invalidateAmbientCache());
}
void clearAmbientCache(std::function<void(std::exception_ptr)> callback) { callback(db->clearAmbientCache()); }
void clearAmbientCache(const std::function<void(std::exception_ptr)>& callback) {
callback(db->clearAmbientCache());
}
void setMaximumAmbientCacheSize(uint64_t size, std::function<void(std::exception_ptr)> callback) {
void setMaximumAmbientCacheSize(uint64_t size, const std::function<void(std::exception_ptr)>& callback) {
callback(db->setMaximumAmbientCacheSize(size));
}
void listRegions(std::function<void(expected<OfflineRegions, std::exception_ptr>)> callback) {
void listRegions(const std::function<void(expected<OfflineRegions, std::exception_ptr>)>& callback) {
callback(db->listRegions());
}
void createRegion(const OfflineRegionDefinition& definition,
const OfflineRegionMetadata& metadata,
std::function<void(expected<OfflineRegion, std::exception_ptr>)> callback) {
const std::function<void(expected<OfflineRegion, std::exception_ptr>)>& callback) {
callback(db->createRegion(definition, metadata));
}
void mergeOfflineRegions(const std::string& sideDatabasePath,
std::function<void(expected<OfflineRegions, std::exception_ptr>)> callback) {
const std::function<void(expected<OfflineRegions, std::exception_ptr>)>& callback) {
callback(db->mergeDatabase(sideDatabasePath));
}
void updateMetadata(const int64_t regionID,
const OfflineRegionMetadata& metadata,
std::function<void(expected<OfflineRegionMetadata, std::exception_ptr>)> callback) {
const std::function<void(expected<OfflineRegionMetadata, std::exception_ptr>)>& callback) {
callback(db->updateMetadata(regionID, metadata));
}
void getRegionStatus(int64_t regionID,
std::function<void(expected<OfflineRegionStatus, std::exception_ptr>)> callback) {
const std::function<void(expected<OfflineRegionStatus, std::exception_ptr>)>& callback) {
if (auto download = getDownload(regionID)) {
callback(download.value()->getStatus());
} else {
@@ -95,12 +98,12 @@ public:
}
}
void deleteRegion(OfflineRegion region, std::function<void(std::exception_ptr)> callback) {
void deleteRegion(OfflineRegion region, const std::function<void(std::exception_ptr)>& callback) {
downloads.erase(region.getID());
callback(db->deleteRegion(std::move(region)));
}
void invalidateRegion(int64_t regionID, std::function<void(std::exception_ptr)> callback) {
void invalidateRegion(int64_t regionID, const std::function<void(std::exception_ptr)>& callback) {
callback(db->invalidateRegion(regionID));
}
@@ -223,35 +226,35 @@ void DatabaseFileSource::setMaximumAmbientCacheSize(uint64_t size, std::function
void DatabaseFileSource::listOfflineRegions(
std::function<void(expected<OfflineRegions, std::exception_ptr>)> callback) {
impl->actor().invoke(&DatabaseFileSourceThread::listRegions, callback);
impl->actor().invoke(&DatabaseFileSourceThread::listRegions, std::move(callback));
}
void DatabaseFileSource::createOfflineRegion(
const OfflineRegionDefinition& definition,
const OfflineRegionMetadata& metadata,
std::function<void(expected<OfflineRegion, std::exception_ptr>)> callback) {
impl->actor().invoke(&DatabaseFileSourceThread::createRegion, definition, metadata, callback);
impl->actor().invoke(&DatabaseFileSourceThread::createRegion, definition, metadata, std::move(callback));
}
void DatabaseFileSource::mergeOfflineRegions(
const std::string& sideDatabasePath, std::function<void(expected<OfflineRegions, std::exception_ptr>)> callback) {
impl->actor().invoke(&DatabaseFileSourceThread::mergeOfflineRegions, sideDatabasePath, callback);
impl->actor().invoke(&DatabaseFileSourceThread::mergeOfflineRegions, sideDatabasePath, std::move(callback));
}
void DatabaseFileSource::updateOfflineMetadata(
const int64_t regionID,
const OfflineRegionMetadata& metadata,
std::function<void(expected<OfflineRegionMetadata, std::exception_ptr>)> callback) {
impl->actor().invoke(&DatabaseFileSourceThread::updateMetadata, regionID, metadata, callback);
impl->actor().invoke(&DatabaseFileSourceThread::updateMetadata, regionID, metadata, std::move(callback));
}
void DatabaseFileSource::deleteOfflineRegion(OfflineRegion region, std::function<void(std::exception_ptr)> callback) {
impl->actor().invoke(&DatabaseFileSourceThread::deleteRegion, std::move(region), callback);
void DatabaseFileSource::deleteOfflineRegion(OfflineRegion& region, std::function<void(std::exception_ptr)> callback) {
impl->actor().invoke(&DatabaseFileSourceThread::deleteRegion, region, std::move(callback));
}
void DatabaseFileSource::invalidateOfflineRegion(OfflineRegion& region,
std::function<void(std::exception_ptr)> callback) {
impl->actor().invoke(&DatabaseFileSourceThread::invalidateRegion, region.getID(), callback);
impl->actor().invoke(&DatabaseFileSourceThread::invalidateRegion, region.getID(), std::move(callback));
}
void DatabaseFileSource::setOfflineRegionObserver(OfflineRegion& region,
@@ -265,7 +268,7 @@ void DatabaseFileSource::setOfflineRegionDownloadState(OfflineRegion& region, Of
void DatabaseFileSource::getOfflineRegionStatus(
OfflineRegion& region, std::function<void(expected<OfflineRegionStatus, std::exception_ptr>)> callback) const {
impl->actor().invoke(&DatabaseFileSourceThread::getRegionStatus, region.getID(), callback);
impl->actor().invoke(&DatabaseFileSourceThread::getRegionStatus, region.getID(), std::move(callback));
}
void DatabaseFileSource::setOfflineMapboxTileCountLimit(uint64_t limit) const {

View File

@@ -11,7 +11,7 @@
namespace mbgl {
void requestLocalFile(const std::string& path, ActorRef<FileSourceRequest> req) {
void requestLocalFile(const std::string& path, const ActorRef<FileSourceRequest>& req) {
Response response;
struct stat buf;
int result = stat(path.c_str(), &buf);

View File

@@ -19,9 +19,9 @@ namespace mbgl {
class LocalFileSource::Impl {
public:
Impl(ActorRef<Impl>) {}
Impl(const ActorRef<Impl>&) {}
void request(const std::string& url, ActorRef<FileSourceRequest> req) {
void request(const std::string& url, const ActorRef<FileSourceRequest>& req) {
if (!acceptsURL(url)) {
Response response;
response.error = std::make_unique<Response::Error>(Response::Error::Reason::Other,
@@ -32,7 +32,7 @@ public:
// Cut off the protocol and prefix with path.
const auto path = mbgl::util::percentDecode(url.substr(std::char_traits<char>::length(util::FILE_PROTOCOL)));
requestLocalFile(path, std::move(req));
requestLocalFile(path, req);
}
};

View File

@@ -25,7 +25,7 @@ public:
localFileSource(std::move(localFileSource_)),
onlineFileSource(std::move(onlineFileSource_)) {}
void request(AsyncRequest* req, Resource resource, ActorRef<FileSourceRequest> ref) {
void request(AsyncRequest* req, const Resource& resource, const ActorRef<FileSourceRequest>& ref) {
auto callback = [ref](const Response& res) { ref.invoke(&FileSourceRequest::setResponse, res); };
auto requestFromNetwork = [=](const Resource& res,
@@ -38,7 +38,7 @@ public:
std::shared_ptr<AsyncRequest> parentKeepAlive = std::move(parent);
MBGL_TIMING_START(watch);
return onlineFileSource->request(res, [=, ptr = parentKeepAlive](Response response) {
return onlineFileSource->request(res, [=, ptr = parentKeepAlive](const Response& response) {
if (databaseFileSource) {
databaseFileSource->forward(res, response);
}
@@ -72,7 +72,7 @@ public:
tasks[req] = databaseFileSource->request(resource, callback);
} else {
// Cache request with fallback to network with cache control
tasks[req] = databaseFileSource->request(resource, [=](Response response) {
tasks[req] = databaseFileSource->request(resource, [=](const Response& response) {
Resource res = resource;
// Resource is in the cache

View File

@@ -236,7 +236,7 @@ void OfflineDownload::activateDownload() {
styleResource.setPriority(Resource::Priority::Low);
styleResource.setUsage(Resource::Usage::Offline);
ensureResource(std::move(styleResource), [&](Response styleResponse) {
ensureResource(std::move(styleResource), [&](const Response& styleResponse) {
status.requiredResourceCountIsPrecise = true;
style::Parser parser;
@@ -258,7 +258,7 @@ void OfflineDownload::activateDownload() {
sourceResource.setPriority(Resource::Priority::Low);
sourceResource.setUsage(Resource::Usage::Offline);
ensureResource(std::move(sourceResource), [=](Response sourceResponse) {
ensureResource(std::move(sourceResource), [=](const Response& sourceResponse) {
style::conversion::Error error;
optional<Tileset> tileset = style::conversion::convertJSON<Tileset>(*sourceResponse.data, error);
if (tileset) {
@@ -275,45 +275,45 @@ void OfflineDownload::activateDownload() {
};
switch (type) {
case SourceType::Vector: {
const auto& vectorSource = *source->as<VectorSource>();
handleTiledSource(vectorSource.getURLOrTileset(), util::tileSize);
break;
}
case SourceType::Raster: {
const auto& rasterSource = *source->as<RasterSource>();
handleTiledSource(rasterSource.getURLOrTileset(), rasterSource.getTileSize());
break;
}
case SourceType::RasterDEM: {
const auto& rasterDEMSource = *source->as<RasterDEMSource>();
handleTiledSource(rasterDEMSource.getURLOrTileset(), rasterDEMSource.getTileSize());
break;
}
case SourceType::GeoJSON: {
const auto& geojsonSource = *source->as<GeoJSONSource>();
if (geojsonSource.getURL()) {
queueResource(Resource::source(*geojsonSource.getURL()));
case SourceType::Vector: {
const auto& vectorSource = *source->as<VectorSource>();
handleTiledSource(vectorSource.getURLOrTileset(), util::tileSize);
break;
}
break;
}
case SourceType::Image: {
const auto& imageSource = *source->as<ImageSource>();
auto imageUrl = imageSource.getURL();
if (imageUrl && !imageUrl->empty()) {
queueResource(Resource::image(*imageUrl));
case SourceType::Raster: {
const auto& rasterSource = *source->as<RasterSource>();
handleTiledSource(rasterSource.getURLOrTileset(), rasterSource.getTileSize());
break;
}
break;
}
case SourceType::Video:
case SourceType::Annotations:
case SourceType::CustomVector:
break;
case SourceType::RasterDEM: {
const auto& rasterDEMSource = *source->as<RasterDEMSource>();
handleTiledSource(rasterDEMSource.getURLOrTileset(), rasterDEMSource.getTileSize());
break;
}
case SourceType::GeoJSON: {
const auto& geojsonSource = *source->as<GeoJSONSource>();
if (geojsonSource.getURL()) {
queueResource(Resource::source(*geojsonSource.getURL()));
}
break;
}
case SourceType::Image: {
const auto& imageSource = *source->as<ImageSource>();
auto imageUrl = imageSource.getURL();
if (imageUrl && !imageUrl->empty()) {
queueResource(Resource::image(*imageUrl));
}
break;
}
case SourceType::Video:
case SourceType::Annotations:
case SourceType::CustomVector:
break;
}
}
@@ -481,7 +481,7 @@ void OfflineDownload::ensureResource(Resource&& resource,
}
auto fileRequestsIt = requests.insert(requests.begin(), nullptr);
*fileRequestsIt = onlineFileSource.request(resource, [=](Response onlineResponse) {
*fileRequestsIt = onlineFileSource.request(resource, [=](const Response& onlineResponse) {
if (onlineResponse.error) {
observer->responseError(*onlineResponse.error);
if (onlineResponse.error->reason == Response::Error::Reason::NotFound) {

View File

@@ -24,6 +24,7 @@
#include <cassert>
#include <list>
#include <map>
#include <utility>
namespace mbgl {
@@ -77,7 +78,7 @@ public:
~OnlineFileSourceThread() { NetworkStatus::Unsubscribe(&reachability); }
void request(AsyncRequest* req, Resource resource, ActorRef<FileSourceRequest> ref) {
void request(AsyncRequest* req, Resource resource, const ActorRef<FileSourceRequest>& ref) {
auto callback = [ref](const Response& res) { ref.invoke(&FileSourceRequest::setResponse, res); };
tasks[req] = std::make_unique<OnlineFileRequest>(std::move(resource), std::move(callback), *this);
}
@@ -127,7 +128,7 @@ public:
void queueRequest(OnlineFileRequest* req) { pendingRequests.insert(req); }
void activateRequest(OnlineFileRequest* req) {
auto callback = [=](Response response) {
auto callback = [=](const Response& response) {
activeRequests.erase(req);
req->request.reset();
req->completed(response);
@@ -439,7 +440,7 @@ void OnlineFileRequest::schedule(optional<Timestamp> expires) {
// If we're not being asked for a forced refresh, calculate a timeout that depends on how many
// consecutive errors we've encountered, and on the expiration time, if present.
Duration timeout = std::min(http::errorRetryTimeout(failedRequestReason, failedRequests, retryAfter),
http::expirationTimeout(expires, expiredRequests));
http::expirationTimeout(std::move(expires), expiredRequests));
if (timeout == Duration::max()) {
return;

View File

@@ -5,6 +5,7 @@
#include <unicode/ushape.h>
#include <memory>
#include <utility>
namespace mbgl {
@@ -98,7 +99,7 @@ std::vector<std::u16string> BiDi::processText(const std::u16string& input,
throw std::runtime_error(std::string("BiDi::processText: ") + u_errorName(errorCode));
}
return applyLineBreaking(lineBreakPoints);
return applyLineBreaking(std::move(lineBreakPoints));
}
std::vector<StyledText> BiDi::processStyledText(const StyledText& input, std::set<std::size_t> lineBreakPoints) {

View File

@@ -5,8 +5,7 @@ namespace mbgl {
class LocalGlyphRasterizer::Impl {
};
LocalGlyphRasterizer::LocalGlyphRasterizer(const optional<std::string>)
{}
LocalGlyphRasterizer::LocalGlyphRasterizer(const optional<std::string>&) {}
LocalGlyphRasterizer::~LocalGlyphRasterizer()
{}

View File

@@ -39,6 +39,7 @@
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <utility>
class SnapshotObserver final : public mbgl::MapSnapshotterObserver {
public:
@@ -640,11 +641,11 @@ void GLFWView::makeSnapshot(bool withOverlay) {
auto snapshot = [&] {
snapshotter->setCameraOptions(map->getCameraOptions());
snapshotter->snapshot([](std::exception_ptr ptr,
snapshotter->snapshot([](const std::exception_ptr &ptr,
mbgl::PremultipliedImage image,
mbgl::MapSnapshotter::Attributions,
mbgl::MapSnapshotter::PointForFn,
mbgl::MapSnapshotter::LatLngForFn) {
const mbgl::MapSnapshotter::Attributions &,
const mbgl::MapSnapshotter::PointForFn &,
const mbgl::MapSnapshotter::LatLngForFn &) {
if (!ptr) {
mbgl::Log::Info(mbgl::Event::General,
"Made snapshot './snapshot.png' with size w:%dpx h:%dpx",
@@ -865,7 +866,7 @@ void GLFWView::report(float duration) {
}
void GLFWView::setChangeStyleCallback(std::function<void()> callback) {
changeStyleCallback = callback;
changeStyleCallback = std::move(callback);
}
void GLFWView::setShouldClose() {

View File

@@ -183,7 +183,7 @@ int main(int argc, char *argv[]) {
auto databaseFileSource = std::static_pointer_cast<mbgl::DatabaseFileSource>(std::shared_ptr<mbgl::FileSource>(
mbgl::FileSourceManager::get()->getFileSource(mbgl::FileSourceType::Database, resourceOptions)));
view->setResetCacheCallback([databaseFileSource]() {
databaseFileSource->resetDatabase([](std::exception_ptr ex) {
databaseFileSource->resetDatabase([](const std::exception_ptr& ex) {
if (ex) {
mbgl::Log::Error(mbgl::Event::Database, "Failed to reset cache:: %s", mbgl::util::toString(ex).c_str());
}

View File

@@ -443,7 +443,7 @@ void NodeMap::Render(const Nan::FunctionCallbackInfo<v8::Value>& info) {
assert(!nodeMap->image.data);
nodeMap->req = std::make_unique<RenderRequest>(Nan::To<v8::Function>(info[1]).ToLocalChecked());
nodeMap->startRender(std::move(options));
nodeMap->startRender(options);
} catch (const mbgl::style::conversion::Error& err) {
return Nan::ThrowTypeError(err.message.c_str());
} catch (const mbgl::util::StyleParseException& ex) {
@@ -455,7 +455,7 @@ void NodeMap::Render(const Nan::FunctionCallbackInfo<v8::Value>& info) {
info.GetReturnValue().SetUndefined();
}
void NodeMap::startRender(NodeMap::RenderOptions options) {
void NodeMap::startRender(const NodeMap::RenderOptions& options) {
frontend->setSize(options.size);
map->setSize(options.size);
@@ -472,7 +472,7 @@ void NodeMap::startRender(NodeMap::RenderOptions options) {
map->setProjectionMode(projectionOptions);
map->renderStill(camera, options.debugOptions, [this](const std::exception_ptr eptr) {
map->renderStill(camera, options.debugOptions, [this](const std::exception_ptr& eptr) {
if (eptr) {
error = eptr;
uv_async_send(async);

View File

@@ -70,7 +70,7 @@ public:
static v8::Local<v8::Value> ParseError(const char* msg);
void startRender(RenderOptions options);
void startRender(const RenderOptions& options);
void renderFinished();
void release();

View File

@@ -12,7 +12,7 @@ namespace mbgl {
class LocalGlyphRasterizer::Impl {
public:
Impl(const optional<std::string> fontFamily_);
Impl(const optional<std::string>& fontFamily_);
bool isConfigured() const;
@@ -21,8 +21,7 @@ public:
optional<QFontMetrics> metrics;
};
LocalGlyphRasterizer::Impl::Impl(const optional<std::string> fontFamily_)
: fontFamily(fontFamily_) {
LocalGlyphRasterizer::Impl::Impl(const optional<std::string>& fontFamily_) : fontFamily(fontFamily_) {
if (isConfigured()) {
font.setFamily(QString::fromStdString(*fontFamily));
font.setPixelSize(util::ONE_EM);
@@ -34,9 +33,8 @@ bool LocalGlyphRasterizer::Impl::isConfigured() const {
return fontFamily.operator bool();
}
LocalGlyphRasterizer::LocalGlyphRasterizer(const optional<std::string> fontFamily)
: impl(std::make_unique<Impl>(fontFamily)) {
}
LocalGlyphRasterizer::LocalGlyphRasterizer(const optional<std::string>& fontFamily)
: impl(std::make_unique<Impl>(fontFamily)) {}
LocalGlyphRasterizer::~LocalGlyphRasterizer() {
}

View File

@@ -91,7 +91,7 @@ void Mailbox::receive() {
}
// static
void Mailbox::maybeReceive(std::weak_ptr<Mailbox> mailbox) {
void Mailbox::maybeReceive(const std::weak_ptr<Mailbox>& mailbox) {
if (auto locked = mailbox.lock()) {
locked->receive();
}
@@ -99,7 +99,7 @@ void Mailbox::maybeReceive(std::weak_ptr<Mailbox> mailbox) {
// static
std::function<void()> Mailbox::makeClosure(std::weak_ptr<Mailbox> mailbox) {
return [mailbox]() { maybeReceive(mailbox); };
return [mailbox = std::move(mailbox)]() { maybeReceive(mailbox); };
}
} // namespace mbgl

View File

@@ -128,7 +128,7 @@ bool Map::isPanning() const {
#pragma mark -
CameraOptions Map::getCameraOptions(optional<EdgeInsets> padding) const {
CameraOptions Map::getCameraOptions(const optional<EdgeInsets>& padding) const {
return impl->transform.getCameraOptions(padding);
}
@@ -158,7 +158,7 @@ void Map::pitchBy(double pitch, const AnimationOptions& animation) {
easeTo(CameraOptions().withPitch((impl->transform.getPitch() * util::RAD2DEG) - pitch), animation);
}
void Map::scaleBy(double scale, optional<ScreenCoordinate> anchor, const AnimationOptions& animation) {
void Map::scaleBy(double scale, const optional<ScreenCoordinate>& anchor, const AnimationOptions& animation) {
const double zoom = impl->transform.getZoom() + impl->transform.getState().scaleZoom(scale);
easeTo(CameraOptions().withZoom(zoom).withAnchor(anchor), animation);
}
@@ -169,13 +169,20 @@ void Map::rotateBy(const ScreenCoordinate& first, const ScreenCoordinate& second
impl->onUpdate();
}
CameraOptions Map::cameraForLatLngBounds(const LatLngBounds& bounds, const EdgeInsets& padding, optional<double> bearing, optional<double> pitch) const {
return cameraForLatLngs({
bounds.northwest(),
bounds.southwest(),
bounds.southeast(),
bounds.northeast(),
}, padding, bearing, pitch);
CameraOptions Map::cameraForLatLngBounds(const LatLngBounds& bounds,
const EdgeInsets& padding,
const optional<double>& bearing,
const optional<double>& pitch) const {
return cameraForLatLngs(
{
bounds.northwest(),
bounds.southwest(),
bounds.southeast(),
bounds.northeast(),
},
padding,
bearing,
pitch);
}
CameraOptions cameraForLatLngs(const std::vector<LatLng>& latLngs, const Transform& transform, const EdgeInsets& padding) {
@@ -223,8 +230,10 @@ CameraOptions cameraForLatLngs(const std::vector<LatLng>& latLngs, const Transfo
.withZoom(zoom);
}
CameraOptions Map::cameraForLatLngs(const std::vector<LatLng>& latLngs, const EdgeInsets& padding, optional<double> bearing, optional<double> pitch) const {
CameraOptions Map::cameraForLatLngs(const std::vector<LatLng>& latLngs,
const EdgeInsets& padding,
const optional<double>& bearing,
const optional<double>& pitch) const {
if (!bearing && !pitch) {
return mbgl::cameraForLatLngs(latLngs, impl->transform, padding);
}
@@ -240,8 +249,10 @@ CameraOptions Map::cameraForLatLngs(const std::vector<LatLng>& latLngs, const Ed
.withPitch(transform.getPitch() * util::RAD2DEG);
}
CameraOptions Map::cameraForGeometry(const Geometry<double>& geometry, const EdgeInsets& padding, optional<double> bearing, optional<double> pitch) const {
CameraOptions Map::cameraForGeometry(const Geometry<double>& geometry,
const EdgeInsets& padding,
const optional<double>& bearing,
const optional<double>& pitch) const {
std::vector<LatLng> latLngs;
forEachPoint(geometry, [&](const Point<double>& pt) {
latLngs.emplace_back(pt.y, pt.x);

View File

@@ -11,8 +11,9 @@
#include <mbgl/util/logging.hpp>
#include <mbgl/util/platform.hpp>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <utility>
namespace mbgl {
@@ -66,7 +67,7 @@ void Transform::resize(const Size size) {
#pragma mark - Camera
CameraOptions Transform::getCameraOptions(optional<EdgeInsets> padding) const {
CameraOptions Transform::getCameraOptions(const optional<EdgeInsets>& padding) const {
return state.getCameraOptions(padding);
}
@@ -491,7 +492,7 @@ ProjectionMode Transform::getProjectionMode() const {
void Transform::startTransition(const CameraOptions& camera,
const AnimationOptions& animation,
std::function<void(double)> frame,
const std::function<void(double)>& frame,
const Duration& duration) {
if (transitionFinishFn) {
transitionFinishFn();

View File

@@ -29,7 +29,7 @@ public:
// Camera
/** Returns the current camera options. */
CameraOptions getCameraOptions(optional<EdgeInsets>) const;
CameraOptions getCameraOptions(const optional<EdgeInsets>&) const;
/** Instantaneously, synchronously applies the given camera options. */
void jumpTo(const CameraOptions&);
@@ -117,7 +117,10 @@ private:
MapObserver& observer;
TransformState state;
void startTransition(const CameraOptions&, const AnimationOptions&, std::function<void(double)>, const Duration&);
void startTransition(const CameraOptions&,
const AnimationOptions&,
const std::function<void(double)>&,
const Duration&);
// We don't want to show horizon: limit max pitch based on edge insets.
double getMaxPitchForEdgeInsets(const EdgeInsets &insets) const;

View File

@@ -255,7 +255,7 @@ void TransformState::setViewportMode(ViewportMode val) {
#pragma mark - Camera options
CameraOptions TransformState::getCameraOptions(optional<EdgeInsets> padding) const {
CameraOptions TransformState::getCameraOptions(const optional<EdgeInsets>& padding) const {
return CameraOptions()
.withCenter(getLatLng())
.withPadding(padding ? padding : edgeInsets)

View File

@@ -130,7 +130,7 @@ public:
ViewportMode getViewportMode() const;
void setViewportMode(ViewportMode val);
CameraOptions getCameraOptions(optional<EdgeInsets>) const;
CameraOptions getCameraOptions(const optional<EdgeInsets>&) const;
// EdgeInsects
EdgeInsets getEdgeInsets() const { return edgeInsets; }

View File

@@ -33,7 +33,7 @@ void Settings::set(const std::string& key, mapbox::base::Value value) noexcept {
impl->settings[key] = std::move(value);
}
void Settings::set(mapbox::base::ValueObject values) noexcept {
void Settings::set(const mapbox::base::ValueObject& values) noexcept {
std::lock_guard<std::mutex> lock(impl->mutex);
for (const auto& pair : values) {
impl->settings[pair.first] = pair.second;

View File

@@ -27,11 +27,10 @@ using namespace style;
struct GeometryTooLongException : std::exception {};
FillBucket::FillBucket(const FillBucket::PossiblyEvaluatedLayoutProperties,
FillBucket::FillBucket(const FillBucket::PossiblyEvaluatedLayoutProperties&,
const std::map<std::string, Immutable<style::LayerProperties>>& layerPaintProperties,
const float zoom,
const uint32_t) {
for (const auto& pair : layerPaintProperties) {
paintPropertyBinders.emplace(
std::piecewise_construct,

View File

@@ -20,7 +20,7 @@ public:
~FillBucket() override;
using PossiblyEvaluatedLayoutProperties = style::FillLayoutProperties::PossiblyEvaluated;
FillBucket(const PossiblyEvaluatedLayoutProperties layout,
FillBucket(const PossiblyEvaluatedLayoutProperties& layout,
const std::map<std::string, Immutable<style::LayerProperties>>& layerPaintProperties,
const float zoom,
const uint32_t overscaling);

View File

@@ -10,7 +10,7 @@ namespace mbgl {
using namespace style;
LineBucket::LineBucket(const LineBucket::PossiblyEvaluatedLayoutProperties layout_,
LineBucket::LineBucket(const LineBucket::PossiblyEvaluatedLayoutProperties& layout_,
const std::map<std::string, Immutable<LayerProperties>>& layerPaintProperties,
const float zoom_,
const uint32_t overscaling_)

View File

@@ -19,7 +19,7 @@ class LineBucket final : public Bucket {
public:
using PossiblyEvaluatedLayoutProperties = style::LineLayoutProperties::PossiblyEvaluated;
LineBucket(const PossiblyEvaluatedLayoutProperties layout,
LineBucket(const PossiblyEvaluatedLayoutProperties& layout,
const std::map<std::string, Immutable<style::LayerProperties>>& layerPaintProperties,
const float zoom,
const uint32_t overscaling);

View File

@@ -21,7 +21,7 @@ SymbolBucket::SymbolBucket(Immutable<style::SymbolLayoutProperties::PossiblyEval
float zoom,
bool iconsNeedLinear_,
bool sortFeaturesByY_,
const std::string bucketName_,
const std::string& bucketName_,
const std::vector<SymbolInstance>&& symbolInstances_,
const std::vector<SortKeyRange>&& sortKeyRanges_,
float tilePixelRatio_,

View File

@@ -72,7 +72,7 @@ public:
float zoom,
bool iconsNeedLinear,
bool sortFeaturesByY,
const std::string bucketLeaderID,
const std::string& bucketLeaderID,
const std::vector<SymbolInstance>&&,
const std::vector<SortKeyRange>&&,
const float tilePixelRatio,

View File

@@ -103,9 +103,9 @@ public:
} // namespace
RenderOrchestrator::RenderOrchestrator(bool backgroundLayerAsColor_, optional<std::string> localFontFamily_)
RenderOrchestrator::RenderOrchestrator(bool backgroundLayerAsColor_, const optional<std::string>& localFontFamily_)
: observer(&nullObserver()),
glyphManager(std::make_unique<GlyphManager>(std::make_unique<LocalGlyphRasterizer>(std::move(localFontFamily_)))),
glyphManager(std::make_unique<GlyphManager>(std::make_unique<LocalGlyphRasterizer>(localFontFamily_))),
imageManager(std::make_unique<ImageManager>()),
lineAtlas(std::make_unique<LineAtlas>()),
patternAtlas(std::make_unique<PatternAtlas>()),

View File

@@ -41,9 +41,7 @@ class RenderOrchestrator final : public GlyphManagerObserver,
public ImageManagerObserver,
public RenderSourceObserver {
public:
RenderOrchestrator(
bool backgroundLayerAsColor_,
optional<std::string> localFontFamily_);
RenderOrchestrator(bool backgroundLayerAsColor_, const optional<std::string>& localFontFamily_);
~RenderOrchestrator() override;
void markContextLost() {

View File

@@ -18,7 +18,7 @@ namespace mbgl {
using namespace style;
std::unique_ptr<RenderSource> RenderSource::create(Immutable<Source::Impl> impl) {
std::unique_ptr<RenderSource> RenderSource::create(const Immutable<Source::Impl>& impl) {
switch (impl->type) {
case SourceType::Vector:
return std::make_unique<RenderVectorSource>(staticImmutableCast<VectorSource::Impl>(impl));

View File

@@ -47,7 +47,7 @@ using RenderTiles = std::shared_ptr<const std::vector<std::reference_wrapper<con
class RenderSource : protected TileObserver {
public:
static std::unique_ptr<RenderSource> create(Immutable<style::Source::Impl>);
static std::unique_ptr<RenderSource> create(const Immutable<style::Source::Impl>&);
virtual ~RenderSource();
bool isEnabled() const;

View File

@@ -8,7 +8,7 @@
namespace mbgl {
Renderer::Renderer(gfx::RendererBackend& backend, float pixelRatio_, const optional<std::string> localFontFamily_)
Renderer::Renderer(gfx::RendererBackend& backend, float pixelRatio_, const optional<std::string>& localFontFamily_)
: impl(std::make_unique<Impl>(backend, pixelRatio_, localFontFamily_)) {}
Renderer::~Renderer() {

View File

@@ -24,15 +24,11 @@ static RendererObserver& nullObserver() {
return observer;
}
Renderer::Impl::Impl(gfx::RendererBackend& backend_,
float pixelRatio_,
optional<std::string> localFontFamily_)
: orchestrator(!backend_.contextIsShared(), std::move(localFontFamily_))
, backend(backend_)
, observer(&nullObserver())
, pixelRatio(pixelRatio_) {
}
Renderer::Impl::Impl(gfx::RendererBackend& backend_, float pixelRatio_, const optional<std::string>& localFontFamily_)
: orchestrator(!backend_.contextIsShared(), localFontFamily_),
backend(backend_),
observer(&nullObserver()),
pixelRatio(pixelRatio_) {}
Renderer::Impl::~Impl() {
assert(gfx::BackendScope::exists());

View File

@@ -17,9 +17,7 @@ class RendererBackend;
class Renderer::Impl {
public:
Impl(gfx::RendererBackend&,
float pixelRatio_,
optional<std::string> localFontFamily_);
Impl(gfx::RendererBackend&, float pixelRatio_, const optional<std::string>& localFontFamily_);
~Impl();
private:

View File

@@ -25,12 +25,14 @@ using FeatureExtensionGetterPtr = FeatureExtensionValue (*)(std::shared_ptr<styl
std::uint32_t,
const optional<std::map<std::string, Value>>&);
// NOLINTNEXTLINE(performance-unnecessary-value-param)
FeatureExtensionValue getChildren(std::shared_ptr<style::GeoJSONData> clusterData,
std::uint32_t clusterID,
const optional<std::map<std::string, Value>>&) {
return clusterData->getChildren(clusterID);
}
// NOLINTNEXTLINE(performance-unnecessary-value-param)
FeatureExtensionValue getLeaves(std::shared_ptr<style::GeoJSONData> clusterData,
std::uint32_t clusterID,
const optional<std::map<std::string, Value>>& args) {
@@ -51,6 +53,7 @@ FeatureExtensionValue getLeaves(std::shared_ptr<style::GeoJSONData> clusterData,
return clusterData->getLeaves(clusterID);
}
// NOLINTNEXTLINE(performance-unnecessary-value-param)
FeatureExtensionValue getClusterExpansionZoom(std::shared_ptr<style::GeoJSONData> clusterData,
std::uint32_t clusterID,
const optional<std::map<std::string, Value>>&) {

View File

@@ -25,7 +25,7 @@ std::unique_ptr<style::Image> createStyleImage(const std::string& id,
const bool sdf,
style::ImageStretches&& stretchX,
style::ImageStretches&& stretchY,
optional<style::ImageContent> content) {
const optional<style::ImageContent>& content) {
// Disallow invalid parameter configurations.
if (width <= 0 || height <= 0 || width > 1024 || height > 1024 || ratio <= 0 || ratio > 10 ||
srcX >= image.size.width || srcY >= image.size.height || srcX + width > image.size.width ||
@@ -49,7 +49,7 @@ std::unique_ptr<style::Image> createStyleImage(const std::string& id,
try {
return std::make_unique<style::Image>(
id, std::move(dstImage), ratio, sdf, std::move(stretchX), std::move(stretchY), std::move(content));
id, std::move(dstImage), ratio, sdf, std::move(stretchX), std::move(stretchY), content);
} catch (const util::StyleImageException& ex) {
Log::Error(Event::Sprite, "Can't create image with invalid metadata: %s", ex.what());
return nullptr;
@@ -181,17 +181,8 @@ std::vector<Immutable<style::Image::Impl>> parseSprite(const std::string& encode
style::ImageStretches stretchY = getStretches(value, "stretchY", name.c_str());
optional<style::ImageContent> content = getContent(value, "content", name.c_str());
auto image = createStyleImage(name,
raster,
x,
y,
width,
height,
pixelRatio,
sdf,
std::move(stretchX),
std::move(stretchY),
std::move(content));
auto image = createStyleImage(
name, raster, x, y, width, height, pixelRatio, sdf, std::move(stretchX), std::move(stretchY), content);
if (image) {
images.push_back(std::move(image->baseImpl));
}

View File

@@ -17,7 +17,7 @@ std::unique_ptr<style::Image> createStyleImage(const std::string& id,
bool sdf,
style::ImageStretches&& stretchX = {},
style::ImageStretches&& stretchY = {},
optional<style::ImageContent> content = nullopt);
const optional<style::ImageContent>& content = nullopt);
// Parses an image and an associated JSON file and returns the sprite objects.
std::vector<Immutable<style::Image::Impl>> parseSprite(const std::string& image, const std::string& json);

View File

@@ -1,11 +1,12 @@
#include <mbgl/style/conversion/filter.hpp>
#include <mbgl/style/conversion_impl.hpp>
#include <mbgl/style/expression/literal.hpp>
#include <mbgl/style/expression/expression.hpp>
#include <mbgl/style/expression/type.hpp>
#include <mbgl/style/expression/compound_expression.hpp>
#include <mbgl/style/expression/boolean_operator.hpp>
#include <mbgl/style/expression/compound_expression.hpp>
#include <mbgl/style/expression/expression.hpp>
#include <mbgl/style/expression/literal.hpp>
#include <mbgl/style/expression/type.hpp>
#include <mbgl/util/geometry.hpp>
#include <utility>
namespace mbgl {
namespace style {
@@ -78,7 +79,9 @@ bool isExpression(const Convertible& filter) {
}
}
ParseResult createExpression(std::string op, optional<std::vector<std::unique_ptr<Expression>>> args, Error& error) {
ParseResult createExpression(const std::string& op,
optional<std::vector<std::unique_ptr<Expression>>> args,
Error& error) {
if (!args) return {};
assert(std::all_of(args->begin(), args->end(), [](const std::unique_ptr<Expression> &e) {
return bool(e.get());
@@ -100,7 +103,7 @@ ParseResult createExpression(std::string op, optional<std::vector<std::unique_pt
}
}
ParseResult createExpression(std::string op, ParseResult arg, Error& error) {
ParseResult createExpression(const std::string& op, ParseResult arg, Error& error) {
if (!arg) {
return {};
}
@@ -134,7 +137,9 @@ optional<std::vector<std::unique_ptr<Expression>>> convertLiteralArray(const Con
return {std::move(output)};
}
ParseResult convertLegacyComparisonFilter(const Convertible& values, Error& error, optional<std::string> opOverride = {}) {
ParseResult convertLegacyComparisonFilter(const Convertible& values,
Error& error,
const optional<std::string>& opOverride = {}) {
optional<std::string> op = opOverride ? opOverride : toString(arrayMember(values, 0));
optional<std::string> property = toString(arrayMember(values, 1));

View File

@@ -12,6 +12,7 @@
#include <mbgl/util/string.hpp>
#include <cassert>
#include <utility>
namespace mbgl {
namespace style {
@@ -320,7 +321,7 @@ static optional<std::unique_ptr<Expression>> convertLiteral(type::Type type, con
});
}
static optional<std::map<double, std::unique_ptr<Expression>>> convertStops(type::Type type,
static optional<std::map<double, std::unique_ptr<Expression>>> convertStops(const type::Type& type,
const Convertible& value,
Error& error,
bool convertTokens) {
@@ -382,7 +383,7 @@ static void omitFirstStop(std::map<double, std::unique_ptr<Expression>>& stops)
}
template <class T>
optional<std::map<T, std::unique_ptr<Expression>>> convertBranches(type::Type type,
optional<std::map<T, std::unique_ptr<Expression>>> convertBranches(const type::Type& type,
const Convertible& value,
Error& error) {
auto stopsValue = objectMember(value, "stops");
@@ -447,13 +448,15 @@ static optional<double> convertBase(const Convertible& value, Error& error) {
return *base;
}
static std::unique_ptr<Expression> step(type::Type type, std::unique_ptr<Expression> input, std::map<double, std::unique_ptr<Expression>> stops) {
static std::unique_ptr<Expression> step(const type::Type& type,
std::unique_ptr<Expression> input,
std::map<double, std::unique_ptr<Expression>> stops) {
return std::make_unique<Step>(type, std::move(input), std::move(stops));
}
static std::unique_ptr<Expression> interpolate(type::Type type, Interpolator interpolator, std::unique_ptr<Expression> input, std::map<double, std::unique_ptr<Expression>> stops) {
ParsingContext ctx;
auto result = createInterpolate(type, std::move(interpolator), std::move(input), std::move(stops), ctx);
auto result = createInterpolate(std::move(type), std::move(interpolator), std::move(input), std::move(stops), ctx);
if (!result) {
assert(false);
return {};
@@ -462,7 +465,7 @@ static std::unique_ptr<Expression> interpolate(type::Type type, Interpolator int
}
template <class T>
std::unique_ptr<Expression> categorical(type::Type type,
std::unique_ptr<Expression> categorical(const type::Type& type,
const std::string& property,
std::map<T, std::unique_ptr<Expression>> branches,
std::unique_ptr<Expression> def) {
@@ -477,7 +480,7 @@ std::unique_ptr<Expression> categorical(type::Type type,
}
template <>
std::unique_ptr<Expression> categorical<bool>(type::Type type,
std::unique_ptr<Expression> categorical<bool>(const type::Type& type,
const std::string& property,
std::map<bool, std::unique_ptr<Expression>> branches,
std::unique_ptr<Expression> def) {
@@ -499,7 +502,7 @@ std::unique_ptr<Expression> categorical<bool>(type::Type type,
def ? std::move(def) : error("replaced with default"));
}
static std::unique_ptr<Expression> numberOrDefault(type::Type type,
static std::unique_ptr<Expression> numberOrDefault(const type::Type& type,
std::unique_ptr<Expression> get,
std::unique_ptr<Expression> expr,
std::unique_ptr<Expression> def) {
@@ -513,12 +516,13 @@ static std::unique_ptr<Expression> numberOrDefault(type::Type type,
return std::make_unique<Case>(type, std::move(branches), std::move(def));
}
static optional<std::unique_ptr<Expression>> convertIntervalFunction(type::Type type,
const Convertible& value,
Error& error,
std::function<std::unique_ptr<Expression> (bool)> makeInput,
std::unique_ptr<Expression> def,
bool convertTokens = false) {
static optional<std::unique_ptr<Expression>> convertIntervalFunction(
const type::Type& type,
const Convertible& value,
Error& error,
const std::function<std::unique_ptr<Expression>(bool)>& makeInput,
std::unique_ptr<Expression> def,
bool convertTokens = false) {
auto stops = convertStops(type, value, error, convertTokens);
if (!stops) {
return nullopt;
@@ -531,12 +535,13 @@ static optional<std::unique_ptr<Expression>> convertIntervalFunction(type::Type
std::move(def));
}
static optional<std::unique_ptr<Expression>> convertExponentialFunction(type::Type type,
const Convertible& value,
Error& error,
std::function<std::unique_ptr<Expression> (bool)> makeInput,
std::unique_ptr<Expression> def,
bool convertTokens = false) {
static optional<std::unique_ptr<Expression>> convertExponentialFunction(
const type::Type& type,
const Convertible& value,
Error& error,
const std::function<std::unique_ptr<Expression>(bool)>& makeInput,
std::unique_ptr<Expression> def,
bool convertTokens = false) {
auto stops = convertStops(type, value, error, convertTokens);
if (!stops) {
return nullopt;
@@ -552,7 +557,7 @@ static optional<std::unique_ptr<Expression>> convertExponentialFunction(type::Ty
std::move(def));
}
static optional<std::unique_ptr<Expression>> convertCategoricalFunction(type::Type type,
static optional<std::unique_ptr<Expression>> convertCategoricalFunction(const type::Type& type,
const Convertible& value,
Error& err,
const std::string& property,
@@ -849,9 +854,13 @@ optional<std::unique_ptr<Expression>> convertFunctionToExpression(type::Type typ
if (toBool(*sourceValue)) {
switch (functionType) {
case FunctionType::Categorical:
return composite<bool>(type, value, err, [&] (type::Type type_, double, std::map<bool, std::unique_ptr<Expression>> stops) {
return categorical<bool>(type_, *property, std::move(stops), defaultExpr());
});
return composite<bool>(
type,
value,
err,
[&](const type::Type& type_, double, std::map<bool, std::unique_ptr<Expression>> stops) {
return categorical<bool>(type_, *property, std::move(stops), defaultExpr());
});
default:
err.message = "unsupported function type";
return nullopt;
@@ -861,24 +870,35 @@ optional<std::unique_ptr<Expression>> convertFunctionToExpression(type::Type typ
if (toNumber(*sourceValue)) {
switch (functionType) {
case FunctionType::Interval:
return composite<double>(type, value, err, [&] (type::Type type_, double, std::map<double, std::unique_ptr<Expression>> stops) {
omitFirstStop(stops);
return numberOrDefault(type,
getProperty(false),
step(type_, getProperty(true), std::move(stops)),
defaultExpr());
});
return composite<double>(
type,
value,
err,
[&](const type::Type& type_, double, std::map<double, std::unique_ptr<Expression>> stops) {
omitFirstStop(stops);
return numberOrDefault(
type, getProperty(false), step(type_, getProperty(true), std::move(stops)), defaultExpr());
});
case FunctionType::Exponential:
return composite<double>(type, value, err, [&] (type::Type type_, double base, std::map<double, std::unique_ptr<Expression>> stops) {
return numberOrDefault(type,
getProperty(false),
interpolate(type_, exponential(base), getProperty(true), std::move(stops)),
defaultExpr());
});
return composite<double>(
type,
value,
err,
[&](type::Type type_, double base, std::map<double, std::unique_ptr<Expression>> stops) {
return numberOrDefault(
type,
getProperty(false),
interpolate(std::move(type_), exponential(base), getProperty(true), std::move(stops)),
defaultExpr());
});
case FunctionType::Categorical:
return composite<int64_t>(type, value, err, [&] (type::Type type_, double, std::map<int64_t, std::unique_ptr<Expression>> stops) {
return categorical<int64_t>(type_, *property, std::move(stops), defaultExpr());
});
return composite<int64_t>(
type,
value,
err,
[&](const type::Type& type_, double, std::map<int64_t, std::unique_ptr<Expression>> stops) {
return categorical<int64_t>(type_, *property, std::move(stops), defaultExpr());
});
default:
err.message = "unsupported function type";
return nullopt;
@@ -888,9 +908,13 @@ optional<std::unique_ptr<Expression>> convertFunctionToExpression(type::Type typ
if (toString(*sourceValue)) {
switch (functionType) {
case FunctionType::Categorical:
return composite<std::string>(type, value, err, [&] (type::Type type_, double, std::map<std::string, std::unique_ptr<Expression>> stops) {
return categorical<std::string>(type_, *property, std::move(stops), defaultExpr());
});
return composite<std::string>(
type,
value,
err,
[&](const type::Type& type_, double, std::map<std::string, std::unique_ptr<Expression>> stops) {
return categorical<std::string>(type_, *property, std::move(stops), defaultExpr());
});
default:
err.message = "unsupported function type";
return nullopt;

View File

@@ -10,7 +10,7 @@ CustomTileLoader::CustomTileLoader(const TileFunction& fetchTileFn, const TileFu
cancelTileFunction = cancelTileFn;
}
void CustomTileLoader::fetchTile(const OverscaledTileID& tileID, ActorRef<CustomGeometryTile> tileRef) {
void CustomTileLoader::fetchTile(const OverscaledTileID& tileID, const ActorRef<CustomGeometryTile>& tileRef) {
std::lock_guard<std::mutex> guard(dataMutex);
auto cachedTileData = dataCache.find(tileID.canonical);
if (cachedTileData != dataCache.end()) {

View File

@@ -21,7 +21,7 @@ public:
CustomTileLoader(const TileFunction& fetchTileFn, const TileFunction& cancelTileFn);
void fetchTile(const OverscaledTileID& tileID, ActorRef<CustomGeometryTile> tileRef);
void fetchTile(const OverscaledTileID& tileID, const ActorRef<CustomGeometryTile>& tileRef);
void cancelTile(const OverscaledTileID& tileID);
void removeTile(const OverscaledTileID& tileID);

View File

@@ -1,6 +1,7 @@
#include <mbgl/style/conversion_impl.hpp>
#include <mbgl/style/expression/assertion.hpp>
#include <mbgl/style/expression/check_subtype.hpp>
#include <mbgl/style/conversion_impl.hpp>
#include <utility>
namespace mbgl {
namespace style {
@@ -8,10 +9,8 @@ namespace expression {
using namespace mbgl::style::conversion;
Assertion::Assertion(type::Type type_, std::vector<std::unique_ptr<Expression>> inputs_) :
Expression(Kind::Assertion, type_),
inputs(std::move(inputs_))
{
Assertion::Assertion(type::Type type_, std::vector<std::unique_ptr<Expression>> inputs_)
: Expression(Kind::Assertion, std::move(type_)), inputs(std::move(inputs_)) {
assert(!inputs.empty());
}

View File

@@ -4,8 +4,8 @@ namespace mbgl {
namespace style {
namespace expression {
Collator::Collator(bool caseSensitive, bool diacriticSensitive, optional<std::string> locale)
: collator(platform::Collator(caseSensitive, diacriticSensitive, std::move(locale))) {}
Collator::Collator(bool caseSensitive, bool diacriticSensitive, const optional<std::string>& locale)
: collator(platform::Collator(caseSensitive, diacriticSensitive, locale)) {}
bool Collator::operator==(const Collator& other) const {
return collator == other.collator;

View File

@@ -22,30 +22,34 @@ static bool isComparableType(const std::string& op, const type::Type& type) {
}
}
bool eq(Value a, Value b) { return a == b; }
bool neq(Value a, Value b) { return a != b; }
bool lt(Value lhs, Value rhs) {
bool eq(const Value& a, const Value& b) {
return a == b;
}
bool neq(const Value& a, const Value& b) {
return a != b;
}
bool lt(const Value& lhs, const Value& rhs) {
return lhs.match(
[&](const std::string& a) { return a < rhs.get<std::string>(); },
[&](double a) { return a < rhs.get<double>(); },
[&](const auto&) { assert(false); return false; }
);
}
bool gt(Value lhs, Value rhs) {
bool gt(const Value& lhs, const Value& rhs) {
return lhs.match(
[&](const std::string& a) { return a > rhs.get<std::string>(); },
[&](double a) { return a > rhs.get<double>(); },
[&](const auto&) { assert(false); return false; }
);
}
bool lteq(Value lhs, Value rhs) {
bool lteq(const Value& lhs, const Value& rhs) {
return lhs.match(
[&](const std::string& a) { return a <= rhs.get<std::string>(); },
[&](double a) { return a <= rhs.get<double>(); },
[&](const auto&) { assert(false); return false; }
);
}
bool gteq(Value lhs, Value rhs) {
bool gteq(const Value& lhs, const Value& rhs) {
return lhs.match(
[&](const std::string& a) { return a >= rhs.get<std::string>(); },
[&](double a) { return a >= rhs.get<double>(); },
@@ -53,12 +57,24 @@ bool gteq(Value lhs, Value rhs) {
);
}
bool eqCollate(std::string a, std::string b, Collator c) { return c.compare(a, b) == 0; }
bool neqCollate(std::string a, std::string b, Collator c) { return !eqCollate(a, b, c); }
bool ltCollate(std::string a, std::string b, Collator c) { return c.compare(a, b) < 0; }
bool gtCollate(std::string a, std::string b, Collator c) { return c.compare(a, b) > 0; }
bool lteqCollate(std::string a, std::string b, Collator c) { return c.compare(a, b) <= 0; }
bool gteqCollate(std::string a, std::string b, Collator c) { return c.compare(a, b) >= 0; }
bool eqCollate(const std::string& a, const std::string& b, const Collator& c) {
return c.compare(a, b) == 0;
}
bool neqCollate(const std::string& a, const std::string& b, const Collator& c) {
return !eqCollate(a, b, c);
}
bool ltCollate(const std::string& a, const std::string& b, const Collator& c) {
return c.compare(a, b) < 0;
}
bool gtCollate(const std::string& a, const std::string& b, const Collator& c) {
return c.compare(a, b) > 0;
}
bool lteqCollate(const std::string& a, const std::string& b, const Collator& c) {
return c.compare(a, b) <= 0;
}
bool gteqCollate(const std::string& a, const std::string& b, const Collator& c) {
return c.compare(a, b) >= 0;
}
static BasicComparison::CompareFunctionType getBasicCompareFunction(const std::string& op) {
if (op == "==") return eq;

View File

@@ -84,13 +84,11 @@ struct Signature;
// Simple evaluate function (const T0&, const T1&, ...) -> Result<U>
template <class R, class... Params>
struct Signature<R (Params...)> : SignatureBase {
Signature(R (*evaluate_)(Params...), std::string name_) :
SignatureBase(
valueTypeToExpressionType<std::decay_t<typename R::Value>>(),
std::vector<type::Type> {valueTypeToExpressionType<std::decay_t<Params>>()...},
std::move(name_)
),
evaluate(evaluate_) {}
Signature(R (*evaluate_)(Params...), const std::string& name_)
: SignatureBase(valueTypeToExpressionType<std::decay_t<typename R::Value>>(),
std::vector<type::Type>{valueTypeToExpressionType<std::decay_t<Params>>()...},
name_),
evaluate(evaluate_) {}
EvaluationResult apply(const EvaluationContext& evaluationParameters, const Args& args) const override {
return applyImpl(evaluationParameters, args, std::index_sequence_for<Params...>{});
@@ -116,14 +114,11 @@ private:
// Varargs evaluate function (const Varargs<T>&) -> Result<U>
template <class R, typename T>
struct Signature<R (const Varargs<T>&)> : SignatureBase {
Signature(R (*evaluate_)(const Varargs<T>&), std::string name_) :
SignatureBase(
valueTypeToExpressionType<std::decay_t<typename R::Value>>(),
VarargsType { valueTypeToExpressionType<T>() },
std::move(name_)
),
evaluate(evaluate_)
{}
Signature(R (*evaluate_)(const Varargs<T>&), const std::string& name_)
: SignatureBase(valueTypeToExpressionType<std::decay_t<typename R::Value>>(),
VarargsType{valueTypeToExpressionType<T>()},
name_),
evaluate(evaluate_) {}
EvaluationResult apply(const EvaluationContext& evaluationParameters, const Args& args) const override {
Varargs<T> evaluated;
@@ -145,14 +140,11 @@ struct Signature<R (const Varargs<T>&)> : SignatureBase {
// (const EvaluationParams&, const T0&, const T1&, ...) -> Result<U>
template <class R, class... Params>
struct Signature<R (const EvaluationContext&, Params...)> : SignatureBase {
Signature(R (*evaluate_)(const EvaluationContext&, Params...), std::string name_) :
SignatureBase(
valueTypeToExpressionType<std::decay_t<typename R::Value>>(),
std::vector<type::Type> {valueTypeToExpressionType<std::decay_t<Params>>()...},
std::move(name_)
),
evaluate(evaluate_)
{}
Signature(R (*evaluate_)(const EvaluationContext&, Params...), const std::string& name_)
: SignatureBase(valueTypeToExpressionType<std::decay_t<typename R::Value>>(),
std::vector<type::Type>{valueTypeToExpressionType<std::decay_t<Params>>()...},
name_),
evaluate(evaluate_) {}
EvaluationResult apply(const EvaluationContext& evaluationParameters, const Args& args) const override {
return applyImpl(evaluationParameters, args, std::index_sequence_for<Params...>{});
@@ -179,14 +171,11 @@ private:
// (const EvaluationContext&, const Varargs<T>&) -> Result<U>
template <class R, typename T>
struct Signature<R (const EvaluationContext&, const Varargs<T>&)> : SignatureBase {
Signature(R (*evaluate_)(const EvaluationContext&, const Varargs<T>&), std::string name_) :
SignatureBase(
valueTypeToExpressionType<std::decay_t<typename R::Value>>(),
VarargsType { valueTypeToExpressionType<T>() },
std::move(name_)
),
evaluate(evaluate_)
{}
Signature(R (*evaluate_)(const EvaluationContext&, const Varargs<T>&), const std::string& name_)
: SignatureBase(valueTypeToExpressionType<std::decay_t<typename R::Value>>(),
VarargsType{valueTypeToExpressionType<T>()},
name_),
evaluate(evaluate_) {}
EvaluationResult apply(const EvaluationContext& evaluationParameters, const Args& args) const override {
Varargs<T> evaluated;
@@ -223,7 +212,7 @@ static std::unique_ptr<detail::SignatureBase> makeSignature(std::string name, Fn
} // namespace detail
Value featureIdAsExpressionValue(EvaluationContext params) {
Value featureIdAsExpressionValue(const EvaluationContext& params) {
assert(params.feature);
auto id = params.feature->getID();
if (id.is<NullValue>()) return Null;
@@ -232,7 +221,7 @@ Value featureIdAsExpressionValue(EvaluationContext params) {
});
};
optional<Value> featurePropertyAsExpressionValue(EvaluationContext params, const std::string& key) {
optional<Value> featurePropertyAsExpressionValue(const EvaluationContext& params, const std::string& key) {
assert(params.feature);
auto property = params.feature->getValue(key);
return property ? toExpressionValue(*property) : optional<Value>();
@@ -253,7 +242,7 @@ optional<std::string> featureTypeAsString(FeatureType type) {
}
};
optional<double> featurePropertyAsDouble(EvaluationContext params, const std::string& key) {
optional<double> featurePropertyAsDouble(const EvaluationContext& params, const std::string& key) {
assert(params.feature);
auto property = params.feature->getValue(key);
if (!property) return {};
@@ -265,7 +254,7 @@ optional<double> featurePropertyAsDouble(EvaluationContext params, const std::st
);
};
optional<std::string> featurePropertyAsString(EvaluationContext params, const std::string& key) {
optional<std::string> featurePropertyAsString(const EvaluationContext& params, const std::string& key) {
assert(params.feature);
auto property = params.feature->getValue(key);
if (!property) return {};
@@ -275,7 +264,7 @@ optional<std::string> featurePropertyAsString(EvaluationContext params, const st
);
};
optional<double> featureIdAsDouble(EvaluationContext params) {
optional<double> featureIdAsDouble(const EvaluationContext& params) {
assert(params.feature);
auto id = params.feature->getID();
return id.match(
@@ -286,7 +275,7 @@ optional<double> featureIdAsDouble(EvaluationContext params) {
);
};
optional<std::string> featureIdAsString(EvaluationContext params) {
optional<std::string> featureIdAsString(const EvaluationContext& params) {
assert(params.feature);
auto id = params.feature->getID();
return id.match(
@@ -723,10 +712,12 @@ const auto& filterLessThanNumberCompoundExpression() {
}
const auto& filterLessThanStringCompoundExpression() {
static auto signature = detail::makeSignature("filter-<", [](const EvaluationContext& params, const std::string& key, std::string lhs) -> Result<bool> {
auto rhs = featurePropertyAsString(params, key);
return rhs ? rhs < lhs : false;
});
static auto signature = detail::makeSignature(
"filter-<",
[](const EvaluationContext& params, const std::string& key, const std::string& lhs) -> Result<bool> {
auto rhs = featurePropertyAsString(params, key);
return rhs ? rhs < lhs : false;
});
return signature;
}
@@ -739,10 +730,11 @@ const auto& filterIdLessThanNumberCompoundExpression() {
}
const auto& filterIdLessThanStringCompoundExpression() {
static auto signature = detail::makeSignature("filter-id-<", [](const EvaluationContext& params, std::string lhs) -> Result<bool> {
auto rhs = featureIdAsString(params);
return rhs ? rhs < lhs : false;
});
static auto signature = detail::makeSignature(
"filter-id-<", [](const EvaluationContext& params, const std::string& lhs) -> Result<bool> {
auto rhs = featureIdAsString(params);
return rhs ? rhs < lhs : false;
});
return signature;
}
@@ -755,10 +747,12 @@ const auto& filterMoreThanNumberCompoundExpression() {
}
const auto& filterMoreThanStringCompoundExpression() {
static auto signature = detail::makeSignature("filter->", [](const EvaluationContext& params, const std::string& key, std::string lhs) -> Result<bool> {
auto rhs = featurePropertyAsString(params, key);
return rhs ? rhs > lhs : false;
});
static auto signature = detail::makeSignature(
"filter->",
[](const EvaluationContext& params, const std::string& key, const std::string& lhs) -> Result<bool> {
auto rhs = featurePropertyAsString(params, key);
return rhs ? rhs > lhs : false;
});
return signature;
}
@@ -771,10 +765,11 @@ const auto& filterIdMoreThanNumberCompoundExpression() {
}
const auto& filterIdMoreThanStringCompoundExpression() {
static auto signature = detail::makeSignature("filter-id->", [](const EvaluationContext& params, std::string lhs) -> Result<bool> {
auto rhs = featureIdAsString(params);
return rhs ? rhs > lhs : false;
});
static auto signature = detail::makeSignature(
"filter-id->", [](const EvaluationContext& params, const std::string& lhs) -> Result<bool> {
auto rhs = featureIdAsString(params);
return rhs ? rhs > lhs : false;
});
return signature;
}
@@ -787,10 +782,12 @@ const auto& filterLessOrEqualThanNumberCompoundExpression() {
}
const auto& filterLessOrEqualThanStringCompoundExpression() {
static auto signature = detail::makeSignature("filter-<=", [](const EvaluationContext& params, const std::string& key, std::string lhs) -> Result<bool> {
auto rhs = featurePropertyAsString(params, key);
return rhs ? rhs <= lhs : false;
});
static auto signature = detail::makeSignature(
"filter-<=",
[](const EvaluationContext& params, const std::string& key, const std::string& lhs) -> Result<bool> {
auto rhs = featurePropertyAsString(params, key);
return rhs ? rhs <= lhs : false;
});
return signature;
}
@@ -803,10 +800,11 @@ const auto& filterIdLessOrEqualThanNumberCompoundExpression() {
}
const auto& filterIdLessOrEqualThanStringCompoundExpression() {
static auto signature = detail::makeSignature("filter-id-<=", [](const EvaluationContext& params, std::string lhs) -> Result<bool> {
auto rhs = featureIdAsString(params);
return rhs ? rhs <= lhs : false;
});
static auto signature = detail::makeSignature(
"filter-id-<=", [](const EvaluationContext& params, const std::string& lhs) -> Result<bool> {
auto rhs = featureIdAsString(params);
return rhs ? rhs <= lhs : false;
});
return signature;
}
@@ -819,10 +817,12 @@ const auto& filterGreaterOrEqualThanNumberCompoundExpression() {
}
const auto& filterGreaterOrEqualThanStringCompoundExpression() {
static auto signature = detail::makeSignature("filter->=", [](const EvaluationContext& params, const std::string& key, std::string lhs) -> Result<bool> {
auto rhs = featurePropertyAsString(params, key);
return rhs ? rhs >= lhs : false;
});
static auto signature = detail::makeSignature(
"filter->=",
[](const EvaluationContext& params, const std::string& key, const std::string& lhs) -> Result<bool> {
auto rhs = featurePropertyAsString(params, key);
return rhs ? rhs >= lhs : false;
});
return signature;
}
@@ -835,10 +835,11 @@ const auto& filterIdGreaterOrEqualThanNumberCompoundExpression() {
}
const auto& filterIdGreaterOrEqualThanStringCompoundExpression() {
static auto signature = detail::makeSignature("filter-id->=", [](const EvaluationContext& params, std::string lhs) -> Result<bool> {
auto rhs = featureIdAsString(params);
return rhs ? rhs >= lhs : false;
});
static auto signature = detail::makeSignature(
"filter-id->=", [](const EvaluationContext& params, const std::string& lhs) -> Result<bool> {
auto rhs = featureIdAsString(params);
return rhs ? rhs >= lhs : false;
});
return signature;
}
@@ -1065,7 +1066,7 @@ static ParseResult createCompoundExpression(const Definitions& definitions,
return ParseResult();
}
ParseResult parseCompoundExpression(const std::string name, const Convertible& value, ParsingContext& ctx) {
ParseResult parseCompoundExpression(const std::string& name, const Convertible& value, ParsingContext& ctx) {
assert(isArray(value) && arrayLength(value) > 0);
const auto definitions = compoundExpressionRegistry.equal_range(name.c_str());

View File

@@ -11,9 +11,10 @@
#include <mbgl/style/expression/literal.hpp>
#include <mbgl/style/expression/step.hpp>
#include <rapidjson/document.h>
#include <mapbox/geojsonvt.hpp>
#include <mbgl/style/conversion/json.hpp>
#include <rapidjson/document.h>
#include <utility>
namespace mbgl {
namespace style {
@@ -54,7 +55,7 @@ std::unique_ptr<Expression> literal(const char* value) {
return literal(std::string(value));
}
std::unique_ptr<Expression> literal(Value value) {
std::unique_ptr<Expression> literal(const Value& value) {
return std::make_unique<Literal>(value);
}
@@ -74,7 +75,7 @@ std::unique_ptr<Expression> literal(std::initializer_list<const char *> value) {
return literal(values);
}
std::unique_ptr<Expression> assertion(type::Type type,
std::unique_ptr<Expression> assertion(const type::Type& type,
std::unique_ptr<Expression> value,
std::unique_ptr<Expression> def) {
std::vector<std::unique_ptr<Expression>> v = vec(std::move(value));
@@ -99,7 +100,7 @@ std::unique_ptr<Expression> boolean(std::unique_ptr<Expression> value,
return assertion(type::Boolean, std::move(value), std::move(def));
}
std::unique_ptr<Expression> coercion(type::Type type,
std::unique_ptr<Expression> coercion(const type::Type& type,
std::unique_ptr<Expression> value,
std::unique_ptr<Expression> def) {
std::vector<std::unique_ptr<Expression>> v = vec(std::move(value));
@@ -193,7 +194,7 @@ std::unique_ptr<Expression> interpolate(Interpolator interpolator,
std::map<double, std::unique_ptr<Expression>> stops;
stops[input1] = std::move(output1);
ParsingContext ctx;
ParseResult result = createInterpolate(type, interpolator, std::move(input), std::move(stops), ctx);
ParseResult result = createInterpolate(type, std::move(interpolator), std::move(input), std::move(stops), ctx);
assert(result);
return std::move(*result);
}
@@ -207,7 +208,7 @@ std::unique_ptr<Expression> interpolate(Interpolator interpolator,
stops[input1] = std::move(output1);
stops[input2] = std::move(output2);
ParsingContext ctx;
ParseResult result = createInterpolate(type, interpolator, std::move(input), std::move(stops), ctx);
ParseResult result = createInterpolate(type, std::move(interpolator), std::move(input), std::move(stops), ctx);
assert(result);
return std::move(*result);
}
@@ -223,7 +224,7 @@ std::unique_ptr<Expression> interpolate(Interpolator interpolator,
stops[input2] = std::move(output2);
stops[input3] = std::move(output3);
ParsingContext ctx;
ParseResult result = createInterpolate(type, interpolator, std::move(input), std::move(stops), ctx);
ParseResult result = createInterpolate(type, std::move(interpolator), std::move(input), std::move(stops), ctx);
assert(result);
return std::move(*result);
}

View File

@@ -1,6 +1,7 @@
#include <mbgl/style/expression/expression.hpp>
#include <mbgl/style/expression/compound_expression.hpp>
#include <mbgl/style/expression/expression.hpp>
#include <mbgl/tile/geometry_tile_data.hpp>
#include <utility>
namespace mbgl {
namespace style {
@@ -43,7 +44,7 @@ EvaluationResult Expression::evaluate(optional<float> zoom,
const Feature& feature,
optional<double> colorRampParameter) const {
GeoJSONFeature f(feature);
return this->evaluate(EvaluationContext(zoom, &f, colorRampParameter));
return this->evaluate(EvaluationContext(std::move(zoom), &f, std::move(colorRampParameter)));
}
EvaluationResult Expression::evaluate(optional<float> zoom,
@@ -51,7 +52,8 @@ EvaluationResult Expression::evaluate(optional<float> zoom,
optional<double> colorRampParameter,
const std::set<std::string>& availableImages) const {
GeoJSONFeature f(feature);
return this->evaluate(EvaluationContext(zoom, &f, colorRampParameter).withAvailableImages(&availableImages));
return this->evaluate(
EvaluationContext(std::move(zoom), &f, std::move(colorRampParameter)).withAvailableImages(&availableImages));
}
EvaluationResult Expression::evaluate(optional<float> zoom,
@@ -60,14 +62,14 @@ EvaluationResult Expression::evaluate(optional<float> zoom,
const std::set<std::string>& availableImages,
const CanonicalTileID& canonical) const {
GeoJSONFeature f(feature, canonical);
return this->evaluate(EvaluationContext(zoom, &f, colorRampParameter)
return this->evaluate(EvaluationContext(std::move(zoom), &f, std::move(colorRampParameter))
.withAvailableImages(&availableImages)
.withCanonicalTileID(&canonical));
}
EvaluationResult Expression::evaluate(optional<mbgl::Value> accumulated, const Feature& feature) const {
GeoJSONFeature f(feature);
return this->evaluate(EvaluationContext(accumulated, &f));
return this->evaluate(EvaluationContext(std::move(accumulated), &f));
}
} // namespace expression

View File

@@ -9,20 +9,20 @@ namespace style {
namespace expression {
namespace {
bool isComparableType(type::Type type) {
bool isComparableType(const type::Type& type) {
return type == type::Boolean || type == type::String || type == type::Number || type == type::Null ||
type == type::Value;
}
bool isComparableRuntimeType(type::Type type) {
bool isComparableRuntimeType(const type::Type& type) {
return type == type::Boolean || type == type::String || type == type::Number || type == type::Null;
}
bool isSearchableType(type::Type type) {
bool isSearchableType(const type::Type& type) {
return type == type::String || type.is<type::Array>() || type == type::Null || type == type::Value;
}
bool isSearchableRuntimeType(type::Type type) {
bool isSearchableRuntimeType(const type::Type& type) {
return type == type::String || type.is<type::Array>() || type == type::Null;
}
} // namespace

View File

@@ -11,12 +11,12 @@ using namespace mbgl::style::conversion;
template <typename T>
class InterpolateImpl : public Interpolate {
public:
InterpolateImpl(type::Type type_,
Interpolator interpolator_,
std::unique_ptr<Expression> input_,
std::map<double, std::unique_ptr<Expression>> stops_
) : Interpolate(std::move(type_), std::move(interpolator_), std::move(input_), std::move(stops_))
{
InterpolateImpl(const type::Type& type_,
const Interpolator& interpolator_,
std::unique_ptr<Expression> input_,
// NOLINTNEXTLINE(performance-unnecessary-value-param)
std::map<double, std::unique_ptr<Expression>> stops_)
: Interpolate(type_, interpolator_, std::move(input_), std::move(stops_)) {
static_assert(util::Interpolatable<T>::value, "Interpolate expression requires an interpolatable value type.");
}

View File

@@ -34,6 +34,7 @@
#include <mbgl/util/string.hpp>
#include <mapbox/eternal.hpp>
#include <utility>
namespace mbgl {
namespace style {
@@ -85,7 +86,7 @@ using namespace mbgl::style::conversion;
ParseResult ParsingContext::parse(const Convertible& value,
std::size_t index_,
optional<type::Type> expected_,
optional<TypeAnnotationOption> typeAnnotationOption) {
const optional<TypeAnnotationOption>& typeAnnotationOption) {
ParsingContext child(key + "[" + util::toString(index_) + "]",
errors,
std::move(expected_),
@@ -144,7 +145,8 @@ bool isExpression(const std::string& name) {
return expressionRegistry.contains(name.c_str());
}
ParseResult ParsingContext::parse(const Convertible& value, optional<TypeAnnotationOption> typeAnnotationOption) {
ParseResult ParsingContext::parse(const Convertible& value,
const optional<TypeAnnotationOption>& typeAnnotationOption) {
ParseResult parsed;
if (isArray(value)) {
@@ -179,14 +181,16 @@ ParseResult ParsingContext::parse(const Convertible& value, optional<TypeAnnotat
return parsed;
}
auto annotate = [] (std::unique_ptr<Expression> expression, type::Type type, TypeAnnotationOption typeAnnotation) -> std::unique_ptr<Expression> {
auto annotate = [](std::unique_ptr<Expression> expression,
const type::Type& type,
TypeAnnotationOption typeAnnotation) -> std::unique_ptr<Expression> {
switch (typeAnnotation) {
case TypeAnnotationOption::assert:
return std::make_unique<Assertion>(type, dsl::vec(std::move(expression)));
case TypeAnnotationOption::coerce:
return std::make_unique<Coercion>(type, dsl::vec(std::move(expression)));
case TypeAnnotationOption::omit:
return expression;
case TypeAnnotationOption::assert:
return std::make_unique<Assertion>(type, dsl::vec(std::move(expression)));
case TypeAnnotationOption::coerce:
return std::make_unique<Coercion>(type, dsl::vec(std::move(expression)));
case TypeAnnotationOption::omit:
return expression;
}
// Not reachable, but placate GCC.
@@ -237,7 +241,8 @@ ParseResult ParsingContext::parse(const Convertible& value, optional<TypeAnnotat
return parsed;
}
ParseResult ParsingContext::parseExpression(const Convertible& value, optional<TypeAnnotationOption> typeAnnotationOption) {
ParseResult ParsingContext::parseExpression(const Convertible& value,
const optional<TypeAnnotationOption>& typeAnnotationOption) {
return parse(value, typeAnnotationOption);
}

View File

@@ -11,7 +11,7 @@ Image::Image(std::string id,
bool sdf,
ImageStretches stretchX,
ImageStretches stretchY,
optional<ImageContent> content)
const optional<ImageContent>& content)
: baseImpl(makeMutable<Impl>(
std::move(id), std::move(image), pixelRatio, sdf, std::move(stretchX), std::move(stretchY), content)) {}

View File

@@ -12,6 +12,8 @@
#include <mapbox/eternal.hpp>
#include <utility>
namespace mbgl {
namespace style {
@@ -188,7 +190,7 @@ PropertyValue<LightAnchorType> Light::getAnchor() const {
void Light::setAnchor(PropertyValue<LightAnchorType> property) {
auto impl_ = mutableImpl();
impl_->properties.template get<LightAnchor>().value = property;
impl_->properties.template get<LightAnchor>().value = std::move(property);
impl = std::move(impl_);
observer->onLightChanged(*this);
}
@@ -214,7 +216,7 @@ PropertyValue<Color> Light::getColor() const {
void Light::setColor(PropertyValue<Color> property) {
auto impl_ = mutableImpl();
impl_->properties.template get<LightColor>().value = property;
impl_->properties.template get<LightColor>().value = std::move(property);
impl = std::move(impl_);
observer->onLightChanged(*this);
}
@@ -240,7 +242,7 @@ PropertyValue<float> Light::getIntensity() const {
void Light::setIntensity(PropertyValue<float> property) {
auto impl_ = mutableImpl();
impl_->properties.template get<LightIntensity>().value = property;
impl_->properties.template get<LightIntensity>().value = std::move(property);
impl = std::move(impl_);
observer->onLightChanged(*this);
}
@@ -266,7 +268,7 @@ PropertyValue<Position> Light::getPosition() const {
void Light::setPosition(PropertyValue<Position> property) {
auto impl_ = mutableImpl();
impl_->properties.template get<LightPosition>().value = property;
impl_->properties.template get<LightPosition>().value = std::move(property);
impl = std::move(impl_);
observer->onLightChanged(*this);
}

View File

@@ -15,6 +15,8 @@
#include <mapbox/eternal.hpp>
#include <utility>
namespace mbgl {
namespace style {
@@ -142,7 +144,7 @@ StyleProperty Light::getProperty(const std::string& name) const {
void Light::set<%- camelize(property.name) %>(<%- propertyValueType(property) %> property) {
auto impl_ = mutableImpl();
impl_->properties.template get<Light<%- camelize(property.name) %>>().value = property;
impl_->properties.template get<Light<%- camelize(property.name) %>>().value = std::move(property);
impl = std::move(impl_);
observer->onLightChanged(*this);
}

View File

@@ -14,7 +14,7 @@
namespace mbgl {
namespace style {
CustomGeometrySource::CustomGeometrySource(std::string id, CustomGeometrySource::Options options)
CustomGeometrySource::CustomGeometrySource(std::string id, const CustomGeometrySource::Options& options)
: Source(makeMutable<CustomGeometrySource::Impl>(std::move(id), options)),
loader(std::make_unique<Actor<CustomTileLoader>>(
Scheduler::GetBackground(), options.fetchTileFunction, options.cancelTileFunction)) {}

View File

@@ -4,13 +4,13 @@
namespace mbgl {
namespace style {
CustomGeometrySource::Impl::Impl(std::string id_, CustomGeometrySource::Options options)
CustomGeometrySource::Impl::Impl(std::string id_, const CustomGeometrySource::Options& options)
: Source::Impl(SourceType::CustomVector, std::move(id_)),
tileOptions(makeMutable<CustomGeometrySource::TileOptions>(options.tileOptions)),
zoomRange(options.zoomRange),
loaderRef({}) {}
CustomGeometrySource::Impl::Impl(const Impl& impl, ActorRef<CustomTileLoader> loaderRef_)
CustomGeometrySource::Impl::Impl(const Impl& impl, const ActorRef<CustomTileLoader>& loaderRef_)
: Source::Impl(impl), tileOptions(impl.tileOptions), zoomRange(impl.zoomRange), loaderRef(loaderRef_) {}
bool CustomGeometrySource::Impl::operator!=(const Impl& other) const noexcept {

View File

@@ -10,8 +10,8 @@ namespace style {
class CustomGeometrySource::Impl : public Source::Impl {
public:
Impl(std::string id, CustomGeometrySource::Options options);
Impl(const Impl&, ActorRef<CustomTileLoader>);
Impl(std::string id, const CustomGeometrySource::Options& options);
Impl(const Impl&, const ActorRef<CustomTileLoader>&);
optional<std::string> getAttribution() const final;

View File

@@ -79,7 +79,7 @@ void GeoJSONSource::loadDescription(FileSource& fileSource) {
return;
}
req = fileSource.request(Resource::source(*url), [this](Response res) {
req = fileSource.request(Resource::source(*url), [this](const Response& res) {
if (res.error) {
observer->onSourceError(
*this, std::make_exception_ptr(std::runtime_error(res.error->message)));

View File

@@ -80,7 +80,7 @@ T evaluateFeature(const mapbox::feature::feature<double>& f,
// static
std::shared_ptr<GeoJSONData> GeoJSONData::create(const GeoJSON& geoJSON,
Immutable<GeoJSONOptions> options,
const Immutable<GeoJSONOptions>& options,
std::shared_ptr<Scheduler> scheduler) {
constexpr double scale = util::EXTENT / util::tileSize;
if (options->cluster && geoJSON.is<Features>() && !geoJSON.get<Features>().empty()) {

View File

@@ -64,7 +64,7 @@ void ImageSource::loadDescription(FileSource& fileSource) {
}
const Resource imageResource { Resource::Image, *url, {} };
req = fileSource.request(imageResource, [this](Response res) {
req = fileSource.request(imageResource, [this](const Response& res) {
if (res.error) {
observer->onSourceError(*this, std::make_exception_ptr(std::runtime_error(res.error->message)));
} else if (res.notModified) {

View File

@@ -6,13 +6,13 @@
#include <mbgl/style/sources/raster_source_impl.hpp>
#include <mbgl/tile/tile.hpp>
#include <mbgl/util/mapbox.hpp>
#include <utility>
namespace mbgl {
namespace style {
RasterDEMSource::RasterDEMSource(std::string id, variant<std::string, Tileset> urlOrTileset_, uint16_t tileSize)
: RasterSource(std::move(id), urlOrTileset_, tileSize, SourceType::RasterDEM){
}
: RasterSource(std::move(id), std::move(urlOrTileset_), tileSize, SourceType::RasterDEM) {}
bool RasterDEMSource::supportsLayerType(const mbgl::style::LayerTypeInfo* info) const {
return mbgl::underlying_type(Tile::Kind::RasterDEM) == mbgl::underlying_type(info->tileKind);

View File

@@ -53,7 +53,7 @@ void RasterSource::loadDescription(FileSource& fileSource) {
}
const auto& url = urlOrTileset.get<std::string>();
req = fileSource.request(Resource::source(url), [this, url](Response res) {
req = fileSource.request(Resource::source(url), [this, url](const Response& res) {
if (res.error) {
observer->onSourceError(*this, std::make_exception_ptr(std::runtime_error(res.error->message)));
} else if (res.notModified) {

View File

@@ -52,7 +52,7 @@ void VectorSource::loadDescription(FileSource& fileSource) {
}
const auto& url = urlOrTileset.get<std::string>();
req = fileSource.request(Resource::source(url), [this, url](Response res) {
req = fileSource.request(Resource::source(url), [this, url](const Response& res) {
if (res.error) {
observer->onSourceError(*this, std::make_exception_ptr(std::runtime_error(res.error->message)));
} else if (res.notModified) {

View File

@@ -62,7 +62,7 @@ void Style::Impl::loadURL(const std::string& url_) {
loaded = false;
url = url_;
styleRequest = fileSource->request(Resource::style(url), [this](Response res) {
styleRequest = fileSource->request(Resource::style(url), [this](const Response& res) {
// Don't allow a loaded, mutated style to be overwritten with a new version.
if (mutated && loaded) {
return;
@@ -190,7 +190,7 @@ Layer* Style::Impl::getLayer(const std::string& id) const {
return layers.get(id);
}
Layer* Style::Impl::addLayer(std::unique_ptr<Layer> layer, optional<std::string> before) {
Layer* Style::Impl::addLayer(std::unique_ptr<Layer> layer, const optional<std::string>& before) {
// TODO: verify source
if (Source* source = sources.get(layer->getSourceID())) {
if (!source->supportsLayerType(layer->baseImpl->getTypeInfo())) {

View File

@@ -65,8 +65,7 @@ public:
std::vector<const Layer*> getLayers() const;
Layer* getLayer(const std::string& id) const;
Layer* addLayer(std::unique_ptr<Layer>,
optional<std::string> beforeLayerID = {});
Layer* addLayer(std::unique_ptr<Layer>, const optional<std::string>& beforeLayerID = {});
std::unique_ptr<Layer> removeLayer(const std::string& layerID);
std::string getName() const;

View File

@@ -126,7 +126,7 @@ std::pair<bool, bool> CollisionIndex::placeFeature(
const bool pitchWithMap,
const bool collisionDebug,
const optional<CollisionBoundaries>& avoidEdges,
const optional<std::function<bool(const IndexedSubfeature&)>> collisionGroupPredicate,
const optional<std::function<bool(const IndexedSubfeature&)>>& collisionGroupPredicate,
std::vector<ProjectedCollisionBox>& projectedBoxes) {
assert(projectedBoxes.empty());
if (!feature.alongLine) {
@@ -157,7 +157,7 @@ std::pair<bool, bool> CollisionIndex::placeLineFeature(
const bool pitchWithMap,
const bool collisionDebug,
const optional<CollisionBoundaries>& avoidEdges,
const optional<std::function<bool(const IndexedSubfeature&)>> collisionGroupPredicate,
const optional<std::function<bool(const IndexedSubfeature&)>>& collisionGroupPredicate,
std::vector<ProjectedCollisionBox>& projectedBoxes) {
assert(feature.alongLine);
assert(projectedBoxes.empty());

View File

@@ -39,7 +39,7 @@ public:
const bool pitchWithMap,
const bool collisionDebug,
const optional<CollisionBoundaries>& avoidEdges,
const optional<std::function<bool(const IndexedSubfeature&)>> collisionGroupPredicate,
const optional<std::function<bool(const IndexedSubfeature&)>>& collisionGroupPredicate,
std::vector<ProjectedCollisionBox>& /*out*/);
void insertFeature(const CollisionFeature& feature, const std::vector<ProjectedCollisionBox>&, bool ignorePlacement, uint32_t bucketInstanceId, uint16_t collisionGroupId);
@@ -68,7 +68,7 @@ private:
const bool pitchWithMap,
const bool collisionDebug,
const optional<CollisionBoundaries>& avoidEdges,
const optional<std::function<bool(const IndexedSubfeature&)>> collisionGroupPredicate,
const optional<std::function<bool(const IndexedSubfeature&)>>& collisionGroupPredicate,
std::vector<ProjectedCollisionBox>& /*out*/);
float approximateTileDistance(const TileDistance& tileDistance, const float lastSegmentAngle, const float pixelsToTileUnits, const float cameraToAnchorDistance, const bool pitchWithMap);

View File

@@ -70,9 +70,9 @@ void GlyphManager::requestRange(GlyphRequest& request, const FontStack& fontStac
return;
}
request.req = fileSource.request(Resource::glyphs(glyphURL, fontStack, range), [this, fontStack, range](Response res) {
processResponse(res, fontStack, range);
});
request.req =
fileSource.request(Resource::glyphs(glyphURL, fontStack, range),
[this, fontStack, range](const Response& res) { processResponse(res, fontStack, range); });
}
void GlyphManager::processResponse(const Response& res, const FontStack& fontStack, const GlyphRange& range) {

View File

@@ -33,7 +33,7 @@ namespace mbgl {
class LocalGlyphRasterizer {
public:
virtual ~LocalGlyphRasterizer();
LocalGlyphRasterizer(const optional<std::string> fontFamily = optional<std::string>());
LocalGlyphRasterizer(const optional<std::string>& fontFamily = optional<std::string>());
// virtual so that test harness can override platform-specific behavior
virtual bool canRasterizeGlyph(const FontStack&, GlyphID);

View File

@@ -12,7 +12,7 @@ namespace mbgl {
void TaggedString::addTextSection(const std::u16string& sectionText,
double scale,
FontStack fontStack,
const FontStack& fontStack,
optional<Color> textColor) {
styledText.first += sectionText;
sections.emplace_back(scale, fontStack, std::move(textColor));

View File

@@ -82,7 +82,7 @@ struct TaggedString {
void addTextSection(const std::u16string& text,
double scale,
FontStack fontStack,
const FontStack& fontStack,
optional<Color> textColor_ = nullopt);
void addImageSection(const std::string& imageID);

View File

@@ -17,7 +17,7 @@ CustomGeometryTile::CustomGeometryTile(const OverscaledTileID& overscaledTileID,
const TileParameters& parameters,
Immutable<style::CustomGeometrySource::TileOptions> options_,
ActorRef<style::CustomTileLoader> loader_)
: GeometryTile(overscaledTileID, sourceID_, parameters),
: GeometryTile(overscaledTileID, std::move(sourceID_), parameters),
necessity(TileNecessity::Optional),
options(std::move(options_)),
loader(std::move(loader_)),

View File

@@ -3,13 +3,14 @@
#include <mbgl/style/sources/geojson_source.hpp>
#include <mbgl/tile/geojson_tile.hpp>
#include <mbgl/tile/geojson_tile_data.hpp>
#include <utility>
namespace mbgl {
GeoJSONTile::GeoJSONTile(const OverscaledTileID& overscaledTileID,
std::string sourceID_,
const TileParameters& parameters,
std::shared_ptr<style::GeoJSONData> data_)
: GeometryTile(overscaledTileID, sourceID_, parameters) {
: GeometryTile(overscaledTileID, std::move(sourceID_), parameters) {
updateData(std::move(data_), false /*needsRelayout*/);
}

View File

@@ -22,6 +22,7 @@
#include <mbgl/util/logging.hpp>
#include <mbgl/gfx/upload_pass.hpp>
#include <utility>
namespace mbgl {
@@ -176,7 +177,7 @@ void GeometryTile::markObsolete() {
void GeometryTile::setError(std::exception_ptr err) {
loaded = true;
observer->onTileError(*this, err);
observer->onTileError(*this, std::move(err));
}
void GeometryTile::setData(std::unique_ptr<const GeometryTileData> data_) {
@@ -257,7 +258,7 @@ void GeometryTile::onError(std::exception_ptr err, const uint64_t resultCorrelat
if (resultCorrelationID == correlationID) {
pending = false;
}
observer->onTileError(*this, err);
observer->onTileError(*this, std::move(err));
}
void GeometryTile::onGlyphsAvailable(GlyphMap glyphs) {

View File

@@ -224,7 +224,7 @@ GeometryCollection convertGeometry(const Feature::geometry_type& geometryTileFea
}
return result;
},
[&](const Polygon<double> polygon) -> GeometryCollection {
[&](const Polygon<double>& polygon) -> GeometryCollection {
GeometryCollection result;
result.reserve(polygon.size());
for (const auto& ring : polygon) {
@@ -237,7 +237,7 @@ GeometryCollection convertGeometry(const Feature::geometry_type& geometryTileFea
}
return result;
},
[&](const MultiPolygon<double> polygons) -> GeometryCollection {
[&](const MultiPolygon<double>& polygons) -> GeometryCollection {
GeometryCollection result;
result.reserve(polygons.size());
for (const auto& pg : polygons) {

Some files were not shown because too many files have changed in this diff Show More