summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkevin <kevin.li@mapbox.com>2020-03-20 15:28:57 +0800
committerkevin <kevin.li@mapbox.com>2020-03-24 10:39:43 +0800
commit2453335adff65bd6a5116639e4c3ab4f50dcc16d (patch)
treef7dac49b2e98309d359176b47c078376f9856f11
parentb817e0f58d6b62a6d8fc445be0e1bfaf1ef29d03 (diff)
downloadqtlocation-mapboxgl-2453335adff65bd6a5116639e4c3ab4f50dcc16d.tar.gz
format codes
-rw-r--r--platform/android/src/snapshotter/map_snapshotter.cpp37
-rw-r--r--platform/android/src/snapshotter/map_snapshotter.hpp1
2 files changed, 19 insertions, 19 deletions
diff --git a/platform/android/src/snapshotter/map_snapshotter.cpp b/platform/android/src/snapshotter/map_snapshotter.cpp
index 844d6481da..c72d657fc5 100644
--- a/platform/android/src/snapshotter/map_snapshotter.cpp
+++ b/platform/android/src/snapshotter/map_snapshotter.cpp
@@ -1,12 +1,11 @@
#include "map_snapshotter.hpp"
+#include <mapbox/weak.hpp>
+#include <mbgl/actor/scheduler.hpp>
#include <mbgl/renderer/renderer.hpp>
#include <mbgl/style/style.hpp>
#include <mbgl/util/logging.hpp>
#include <mbgl/util/string.hpp>
-#include <mbgl/actor/scheduler.hpp>
-
-#include <mapbox/weak.hpp>
#include "../attach_env.hpp"
#include "map_snapshot.hpp"
@@ -15,14 +14,14 @@ namespace mbgl {
namespace android {
MapSnapshotter::DeleteOnThread::DeleteOnThread() = default;
-MapSnapshotter::DeleteOnThread::DeleteOnThread(mapbox::base::WeakPtr<mbgl::Scheduler> weakScheduler_) : weakScheduler(weakScheduler_) {}
+MapSnapshotter::DeleteOnThread::DeleteOnThread(mapbox::base::WeakPtr<mbgl::Scheduler> weakScheduler_)
+ : weakScheduler(weakScheduler_) {}
void MapSnapshotter::DeleteOnThread::operator()(mbgl::MapSnapshotter* p) const {
auto guard = weakScheduler.lock();
if (weakScheduler && weakScheduler.get() != mbgl::Scheduler::GetCurrent()) {
- weakScheduler->schedule([ptr = std::shared_ptr<mbgl::MapSnapshotter>(p, DeleteOnThread(weakScheduler))] {
- (void)ptr;
- });
+ weakScheduler->schedule(
+ [ptr = std::shared_ptr<mbgl::MapSnapshotter>(p, DeleteOnThread(weakScheduler))] { (void)ptr; });
} else {
delete p;
}
@@ -55,13 +54,14 @@ MapSnapshotter::MapSnapshotter(jni::JNIEnv& _env,
showLogo = _showLogo;
// Create the core snapshotter
- snapshotter = std::unique_ptr<mbgl::MapSnapshotter, DeleteOnThread>(new mbgl::MapSnapshotter(
- size,
- pixelRatio,
- mbgl::android::FileSource::getSharedResourceOptions(_env, _jFileSource),
- *this,
- _localIdeographFontFamily ? jni::Make<std::string>(_env, _localIdeographFontFamily) : optional<std::string>{}),
- DeleteOnThread(mbgl::Scheduler::GetCurrent()->makeWeakPtr()));
+ snapshotter = std::unique_ptr<mbgl::MapSnapshotter, DeleteOnThread>(
+ new mbgl::MapSnapshotter(size,
+ pixelRatio,
+ mbgl::android::FileSource::getSharedResourceOptions(_env, _jFileSource),
+ *this,
+ _localIdeographFontFamily ? jni::Make<std::string>(_env, _localIdeographFontFamily)
+ : optional<std::string>{}),
+ DeleteOnThread(mbgl::Scheduler::GetCurrent()->makeWeakPtr()));
if (position) {
snapshotter->setCameraOptions(CameraPosition::getCameraOptions(_env, position, pixelRatio));
@@ -196,7 +196,7 @@ void MapSnapshotter::onStyleImageMissing(const std::string& imageName) {
void MapSnapshotter::addLayerAt(JNIEnv& env, jlong nativeLayerPtr, jni::jint index) {
assert(nativeLayerPtr != 0);
auto layers = snapshotter->getStyle().getLayers();
- Layer* layer = reinterpret_cast<Layer*>(nativeLayerPtr);
+ auto* layer = reinterpret_cast<Layer*>(nativeLayerPtr);
// Check index
int numLayers = layers.size() - 1;
if (index > numLayers || index < 0) {
@@ -217,7 +217,7 @@ void MapSnapshotter::addLayerAt(JNIEnv& env, jlong nativeLayerPtr, jni::jint ind
void MapSnapshotter::addLayerBelow(JNIEnv& env, jlong nativeLayerPtr, const jni::String& below) {
assert(nativeLayerPtr != 0);
- Layer* layer = reinterpret_cast<Layer*>(nativeLayerPtr);
+ auto* layer = reinterpret_cast<Layer*>(nativeLayerPtr);
try {
layer->addToStyle(
snapshotter->getStyle(),
@@ -230,7 +230,7 @@ void MapSnapshotter::addLayerBelow(JNIEnv& env, jlong nativeLayerPtr, const jni:
void MapSnapshotter::addLayerAbove(JNIEnv& env, jlong nativeLayerPtr, const jni::String& above) {
assert(nativeLayerPtr != 0);
- Layer* layer = reinterpret_cast<Layer*>(nativeLayerPtr);
+ auto* layer = reinterpret_cast<Layer*>(nativeLayerPtr);
// Find the sibling
auto layers = snapshotter->getStyle().getLayers();
@@ -251,7 +251,6 @@ void MapSnapshotter::addLayerAbove(JNIEnv& env, jlong nativeLayerPtr, const jni:
jni::ThrowNew(env,
jni::FindClass(env, "com/mapbox/mapboxsdk/style/layers/CannotAddLayerException"),
std::string("Could not find layer: ").append(siblingId).c_str());
- return;
} else if (index + 1 < layers.size()) {
// Place before the sibling
before = {layers.at(index + 1)->getID()};
@@ -269,7 +268,7 @@ void MapSnapshotter::addLayerAbove(JNIEnv& env, jlong nativeLayerPtr, const jni:
void MapSnapshotter::addSource(JNIEnv& env, const jni::Object<Source>& obj, jlong sourcePtr) {
assert(sourcePtr != 0);
- Source* source = reinterpret_cast<Source*>(sourcePtr);
+ auto* source = reinterpret_cast<Source*>(sourcePtr);
try {
source->addToStyle(env, obj, snapshotter->getStyle());
} catch (const std::runtime_error& error) {
diff --git a/platform/android/src/snapshotter/map_snapshotter.hpp b/platform/android/src/snapshotter/map_snapshotter.hpp
index e6f543649f..99c8b6d2df 100644
--- a/platform/android/src/snapshotter/map_snapshotter.hpp
+++ b/platform/android/src/snapshotter/map_snapshotter.hpp
@@ -67,6 +67,7 @@ private:
DeleteOnThread();
explicit DeleteOnThread(mapbox::base::WeakPtr<mbgl::Scheduler>);
void operator()(mbgl::MapSnapshotter* p) const;
+
private:
mapbox::base::WeakPtr<mbgl::Scheduler> weakScheduler;
};