blob: 6b906eb9c0b51003ad2c611b9fdfcd8c6632297f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#pragma once
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/map/map.hpp>
#include <mbgl/style/source.hpp>
#include "../value.hpp"
#include "../../android_renderer_frontend.hpp"
#include <jni/jni.hpp>
namespace mbgl {
namespace android {
class Source : private mbgl::util::noncopyable {
public:
static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/sources/Source"; };
static jni::Class<Source> javaClass;
static void registerNative(jni::JNIEnv&);
static jni::Object<Source> peerForCoreSource(jni::JNIEnv&, mbgl::style::Source&, AndroidRendererFrontend&);
/*
* Called when a Java object is created for a core source that belongs to a map.
*/
Source(jni::JNIEnv&, mbgl::style::Source&, jni::Object<Source>, AndroidRendererFrontend&);
/*
* Called when a Java object is created for a new core source that does not belong to a map.
*/
Source(jni::JNIEnv&, std::unique_ptr<mbgl::style::Source>);
virtual ~Source();
virtual void addToMap(JNIEnv&, jni::Object<Source>, mbgl::Map&, AndroidRendererFrontend&);
virtual bool removeFromMap(JNIEnv&, jni::Object<Source>, mbgl::Map&);
void releaseJavaPeer();
jni::String getId(jni::JNIEnv&);
jni::String getAttribution(jni::JNIEnv&);
protected:
// Set on newly created sources until added to the map.
std::unique_ptr<mbgl::style::Source> ownedSource;
// Raw pointer that is valid at all times.
mbgl::style::Source& source;
// Set when the source is added to a map.
jni::UniqueObject<Source> javaPeer;
// RendererFrontend pointer is valid only when added to the map.
AndroidRendererFrontend* rendererFrontend { nullptr };
};
} // namespace android
} // namespace mbgl
|