Add clang-format (#1086)

Co-authored-by: mwilsnd <mwilsnd@gmail.com>
This commit is contained in:
Bart Louwers
2023-05-01 16:57:37 +02:00
committed by GitHub
parent 403a12bd1b
commit 71f6da2722
1018 changed files with 27876 additions and 25862 deletions

View File

@@ -9,10 +9,9 @@ namespace mbgl {
namespace android {
MapSnapshot::MapSnapshot(float pixelRatio_, MapSnapshot::PointForFn pointForFn_, MapSnapshot::LatLngForFn latLngForFn_)
: pixelRatio(pixelRatio_)
, pointForFn(std::move(pointForFn_))
, latLngForFn(std::move(latLngForFn_)) {
}
: pixelRatio(pixelRatio_),
pointForFn(std::move(pointForFn_)),
latLngForFn(std::move(latLngForFn_)) {}
MapSnapshot::~MapSnapshot() = default;
@@ -28,20 +27,26 @@ jni::Local<jni::Object<LatLng>> MapSnapshot::latLngForPixel(jni::JNIEnv& env, jn
// Static methods //
jni::Local<jni::Object<MapSnapshot>> MapSnapshot::New(JNIEnv& env,
PremultipliedImage&& image,
float pixelRatio,
std::vector<std::string> attributions,
bool showLogo,
mbgl::MapSnapshotter::PointForFn pointForFn,
mbgl::MapSnapshotter::LatLngForFn latLngForFn) {
PremultipliedImage&& image,
float pixelRatio,
std::vector<std::string> attributions,
bool showLogo,
mbgl::MapSnapshotter::PointForFn pointForFn,
mbgl::MapSnapshotter::LatLngForFn latLngForFn) {
// Create the bitmap
auto bitmap = Bitmap::CreateBitmap(env, std::move(image));
// Create the Mapsnapshot peers
static auto& javaClass = jni::Class<MapSnapshot>::Singleton(env);
static auto constructor = javaClass.GetConstructor<jni::jlong, jni::Object<Bitmap>, jni::Array<jni::String>, jni::jboolean>(env);
static auto constructor =
javaClass.GetConstructor<jni::jlong, jni::Object<Bitmap>, jni::Array<jni::String>, jni::jboolean>(env);
auto nativePeer = std::make_unique<MapSnapshot>(pixelRatio, pointForFn, latLngForFn);
return javaClass.New(env, constructor, reinterpret_cast<jlong>(nativePeer.release()), bitmap, conversion::toArray(env, attributions), (jni::jboolean) showLogo);
return javaClass.New(env,
constructor,
reinterpret_cast<jlong>(nativePeer.release()),
bitmap,
conversion::toArray(env, attributions),
(jni::jboolean)showLogo);
}
void MapSnapshot::registerNative(jni::JNIEnv& env) {
@@ -51,14 +56,14 @@ void MapSnapshot::registerNative(jni::JNIEnv& env) {
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
// Register the peer
jni::RegisterNativePeer<MapSnapshot>(env, javaClass,
"nativePtr",
std::make_unique<MapSnapshot, JNIEnv&>,
"initialize",
"finalize",
METHOD(&MapSnapshot::latLngForPixel, "latLngForPixel"),
METHOD(&MapSnapshot::pixelForLatLng, "pixelForLatLng")
);
jni::RegisterNativePeer<MapSnapshot>(env,
javaClass,
"nativePtr",
std::make_unique<MapSnapshot, JNIEnv&>,
"initialize",
"finalize",
METHOD(&MapSnapshot::latLngForPixel, "latLngForPixel"),
METHOD(&MapSnapshot::pixelForLatLng, "pixelForLatLng"));
}
} // namespace android

View File

@@ -15,7 +15,6 @@ namespace android {
class MapSnapshot {
public:
using PointForFn = mbgl::MapSnapshotter::PointForFn;
using LatLngForFn = mbgl::MapSnapshotter::LatLngForFn;
@@ -24,14 +23,14 @@ public:
static void registerNative(jni::JNIEnv&);
static jni::Local<jni::Object<MapSnapshot>> New(JNIEnv& env,
PremultipliedImage&& image,
float pixelRatio,
std::vector<std::string> attributions,
bool showLogo,
PointForFn pointForFn,
LatLngForFn latLngForFn);
PremultipliedImage&& image,
float pixelRatio,
std::vector<std::string> attributions,
bool showLogo,
PointForFn pointForFn,
LatLngForFn latLngForFn);
MapSnapshot(jni::JNIEnv&) {};
MapSnapshot(jni::JNIEnv&){};
MapSnapshot(float pixelRatio, PointForFn, LatLngForFn);
~MapSnapshot();

View File

@@ -25,9 +25,8 @@ MapSnapshotter::MapSnapshotter(jni::JNIEnv& _env,
const jni::Object<CameraPosition>& position,
jni::jboolean _showLogo,
const jni::String& _localIdeographFontFamily)
: javaPeer(_env, _obj)
, pixelRatio(_pixelRatio) {
: javaPeer(_env, _obj),
pixelRatio(_pixelRatio) {
// Get a reference to the JavaVM for callbacks
if (_env.GetJavaVM(&vm) < 0) {
_env.ExceptionDescribe();
@@ -37,7 +36,7 @@ MapSnapshotter::MapSnapshotter(jni::JNIEnv& _env,
weakScheduler = mbgl::Scheduler::GetCurrent()->makeWeakPtr();
jFileSource = FileSource::getNativePeer(_env, _jFileSource);
auto size = mbgl::Size { static_cast<uint32_t>(width), static_cast<uint32_t>(height) };
auto size = mbgl::Size{static_cast<uint32_t>(width), static_cast<uint32_t>(height)};
showLogo = _showLogo;
@@ -48,7 +47,8 @@ MapSnapshotter::MapSnapshotter(jni::JNIEnv& _env,
mbgl::android::FileSource::getSharedResourceOptions(_env, _jFileSource),
mbgl::android::FileSource::getSharedClientOptions(_env, _jFileSource),
*this,
_localIdeographFontFamily ? jni::Make<std::string>(_env, _localIdeographFontFamily) : std::optional<std::string>{});
_localIdeographFontFamily ? jni::Make<std::string>(_env, _localIdeographFontFamily)
: std::optional<std::string>{});
if (position) {
snapshotter->setCameraOptions(CameraPosition::getCameraOptions(_env, position, pixelRatio));
@@ -91,17 +91,18 @@ void MapSnapshotter::start(JNIEnv& env) {
if (err) {
// error handler callback
static auto onSnapshotFailed = javaClass.GetMethod<void (jni::String)>(*_env, "onSnapshotFailed");
static auto onSnapshotFailed = javaClass.GetMethod<void(jni::String)>(*_env, "onSnapshotFailed");
auto weakReference = javaPeer.get(*_env);
if (weakReference) {
weakReference.Call(*_env, onSnapshotFailed, jni::Make<jni::String>(*_env, util::toString(err)));
}
} else {
// Create the wrapper
auto mapSnapshot = android::MapSnapshot::New(*_env, std::move(image), pixelRatio, attributions, showLogo, pointForFn, latLngForFn);
auto mapSnapshot = android::MapSnapshot::New(
*_env, std::move(image), pixelRatio, attributions, showLogo, pointForFn, latLngForFn);
// invoke callback
static auto onSnapshotReady = javaClass.GetMethod<void (jni::Object<MapSnapshot>)>(*_env, "onSnapshotReady");
static auto onSnapshotReady = javaClass.GetMethod<void(jni::Object<MapSnapshot>)>(*_env, "onSnapshotReady");
auto weakReference = javaPeer.get(*_env);
if (weakReference) {
weakReference.Call(*_env, onSnapshotReady, mapSnapshot);
@@ -127,7 +128,7 @@ void MapSnapshotter::setStyleJson(JNIEnv& env, const jni::String& styleJSON) {
}
void MapSnapshotter::setSize(JNIEnv&, jni::jint width, jni::jint height) {
auto size = mbgl::Size { static_cast<uint32_t>(width), static_cast<uint32_t>(height) };
auto size = mbgl::Size{static_cast<uint32_t>(width), static_cast<uint32_t>(height)};
snapshotter->setSize(size);
}

View File

@@ -19,7 +19,6 @@ namespace android {
class MapSnapshotter final : public mbgl::MapSnapshotterObserver {
public:
static constexpr auto Name() { return "com/mapbox/mapboxsdk/snapshotter/MapSnapshotter"; };
static void registerNative(jni::JNIEnv&);
@@ -69,13 +68,13 @@ public:
private:
MBGL_STORE_THREAD(tid);
JavaVM *vm = nullptr;
JavaVM* vm = nullptr;
jni::WeakReference<jni::Object<MapSnapshotter>, jni::EnvAttachingDeleter> javaPeer;
float pixelRatio;
bool showLogo;
FileSource *jFileSource;
FileSource* jFileSource;
void activateFilesource(JNIEnv&);
void deactivateFilesource(JNIEnv&);
bool activatedFilesource = false;