From 2453335adff65bd6a5116639e4c3ab4f50dcc16d Mon Sep 17 00:00:00 2001 From: kevin Date: Fri, 20 Mar 2020 15:28:57 +0800 Subject: format codes --- .../android/src/snapshotter/map_snapshotter.cpp | 37 +++++++++++----------- .../android/src/snapshotter/map_snapshotter.hpp | 1 + 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 +#include #include #include #include #include -#include - -#include #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 weakScheduler_) : weakScheduler(weakScheduler_) {} +MapSnapshotter::DeleteOnThread::DeleteOnThread(mapbox::base::WeakPtr 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(p, DeleteOnThread(weakScheduler))] { - (void)ptr; - }); + weakScheduler->schedule( + [ptr = std::shared_ptr(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(new mbgl::MapSnapshotter( - size, - pixelRatio, - mbgl::android::FileSource::getSharedResourceOptions(_env, _jFileSource), - *this, - _localIdeographFontFamily ? jni::Make(_env, _localIdeographFontFamily) : optional{}), - DeleteOnThread(mbgl::Scheduler::GetCurrent()->makeWeakPtr())); + snapshotter = std::unique_ptr( + new mbgl::MapSnapshotter(size, + pixelRatio, + mbgl::android::FileSource::getSharedResourceOptions(_env, _jFileSource), + *this, + _localIdeographFontFamily ? jni::Make(_env, _localIdeographFontFamily) + : optional{}), + 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(nativeLayerPtr); + auto* layer = reinterpret_cast(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(nativeLayerPtr); + auto* layer = reinterpret_cast(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(nativeLayerPtr); + auto* layer = reinterpret_cast(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& obj, jlong sourcePtr) { assert(sourcePtr != 0); - Source* source = reinterpret_cast(sourcePtr); + auto* source = reinterpret_cast(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); void operator()(mbgl::MapSnapshotter* p) const; + private: mapbox::base::WeakPtr weakScheduler; }; -- cgit v1.2.1