[android] Move includes to platform subdirectory

This commit is contained in:
John Firebaugh
2015-12-11 12:22:30 -08:00
parent c23e8cc748
commit 0db9f229f2
5 changed files with 6 additions and 0 deletions

View File

@@ -0,0 +1,118 @@
#ifndef MBGL_ANDROID_JNI
#define MBGL_ANDROID_JNI
#include <string>
#include <vector>
// Forward definition of JNI types
typedef class _jclass* jclass;
typedef class _jstring* jstring;
typedef class _jobject* jobject;
typedef class _jlongArray* jlongArray;
typedef struct _jmethodID* jmethodID;
typedef struct _jfieldID* jfieldID;
struct _JavaVM;
typedef _JavaVM JavaVM;
struct _JNIEnv;
typedef _JNIEnv JNIEnv;
namespace mbgl {
namespace android {
extern JavaVM* theJVM;
extern std::string cachePath;
extern std::string dataPath;
extern std::string apkPath;
extern std::string androidRelease;
extern jmethodID onInvalidateId;
extern jmethodID onMapChangedId;
extern jmethodID onFpsChangedId;
extern jclass latLngClass;
extern jmethodID latLngConstructorId;
extern jfieldID latLngLatitudeId;
extern jfieldID latLngLongitudeId;
extern jclass latLngZoomClass;
extern jmethodID latLngZoomConstructorId;
extern jfieldID latLngZoomLatitudeId;
extern jfieldID latLngZoomLongitudeId;
extern jfieldID latLngZoomZoomId;
extern jclass bboxClass;
extern jmethodID bboxConstructorId;
extern jfieldID bboxLatNorthId;
extern jfieldID bboxLatSouthId;
extern jfieldID bboxLonEastId;
extern jfieldID bboxLonWestId;
extern jclass spriteClass;
extern jfieldID spriteIdId;
extern jclass markerClass;
extern jfieldID markerPositionId;
extern jfieldID markerIconId;
extern jclass polylineClass;
extern jfieldID polylineAlphaId;
extern jfieldID polylineColorId;
extern jfieldID polylineWidthId;
extern jfieldID polylinePointsId;
extern jclass polygonClass;
extern jfieldID polygonAlphaId;
extern jfieldID polygonFillColorId;
extern jfieldID polygonStrokeColorId;
extern jfieldID polygonPointsId;
extern jclass runtimeExceptionClass;
extern jclass nullPointerExceptionClass;
extern jmethodID listToArrayId;
extern jclass arrayListClass;
extern jmethodID arrayListConstructorId;
extern jmethodID arrayListAddId;
extern jclass projectedMetersClass;
extern jmethodID projectedMetersConstructorId;
extern jfieldID projectedMetersNorthingId;
extern jfieldID projectedMetersEastingId;
extern jclass pointFClass;
extern jmethodID pointFConstructorId;
extern jfieldID pointFXId;
extern jfieldID pointFYId;
extern jclass rectFClass;
extern jmethodID rectFConstructorId;
extern jfieldID rectFLeftId;
extern jfieldID rectFTopId;
extern jfieldID rectFRightId;
extern jfieldID rectFBottomId;
extern jclass httpContextClass;
extern jmethodID httpContextGetInstanceId;
extern jmethodID httpContextCreateRequestId;
extern jclass httpRequestClass;
extern jmethodID httpRequestStartId;
extern jmethodID httpRequestCancelId;
extern bool throw_jni_error(JNIEnv *env, const char *msg);
extern bool attach_jni_thread(JavaVM* vm, JNIEnv** env, std::string threadName);
extern void detach_jni_thread(JavaVM* vm, JNIEnv** env, bool detach);
extern std::string std_string_from_jstring(JNIEnv *env, jstring jstr);
extern jstring std_string_to_jstring(JNIEnv *env, std::string str);
extern std::vector<std::string> std_vector_string_from_jobject(JNIEnv *env, jobject jlist);
extern jobject std_vector_string_to_jobject(JNIEnv *env, std::vector<std::string> vector);
extern jlongArray std_vector_uint_to_jobject(JNIEnv *env, std::vector<uint32_t> vector);
}
}
#endif

View File

@@ -0,0 +1,101 @@
#ifndef MBGL_ANDROID_NATIVE_MAP_VIEW
#define MBGL_ANDROID_NATIVE_MAP_VIEW
#include <mbgl/map/map.hpp>
#include <mbgl/map/view.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/storage/sqlite_cache.hpp>
#include <mbgl/storage/default_file_source.hpp>
#include <string>
#include <jni.h>
#include <android/native_window.h>
#include <EGL/egl.h>
namespace mbgl {
namespace android {
class NativeMapView : public mbgl::View, private mbgl::util::noncopyable {
public:
NativeMapView(JNIEnv *env, jobject obj, float pixelRatio, int availableProcessors, size_t totalMemory);
virtual ~NativeMapView();
float getPixelRatio() const override;
std::array<uint16_t, 2> getSize() const override;
std::array<uint16_t, 2> getFramebufferSize() const override;
void activate() override;
void deactivate() override;
void notify() override;
void invalidate() override;
void beforeRender() override;
void afterRender() override;
void notifyMapChange(mbgl::MapChange) override;
mbgl::Map &getMap();
mbgl::DefaultFileSource &getFileSource();
void initializeDisplay();
void terminateDisplay();
void initializeContext();
void terminateContext();
void createSurface(ANativeWindow *window);
void destroySurface();
void resume();
void pause();
void enableFps(bool enable);
void updateFps();
void resizeView(int width, int height);
void resizeFramebuffer(int width, int height);
private:
EGLConfig chooseConfig(const EGLConfig configs[], EGLint numConfigs);
bool inEmulator();
private:
JavaVM *vm = nullptr;
jweak obj = nullptr;
ANativeWindow *window = nullptr;
EGLDisplay display = EGL_NO_DISPLAY;
EGLSurface surface = EGL_NO_SURFACE;
EGLContext context = EGL_NO_CONTEXT;
EGLConfig config = nullptr;
EGLint format = -1;
std::string styleUrl;
std::string apiKey;
bool firstTime = false;
bool fpsEnabled = false;
double fps = 0.0;
int width = 0;
int height = 0;
int fbWidth = 0;
int fbHeight = 0;
const float pixelRatio;
int availableProcessors = 0;
size_t totalMemory = 0;
jboolean renderDetach = false;
JNIEnv *renderEnv = nullptr;
// Ensure these are initialised last
std::shared_ptr<mbgl::SQLiteCache> fileCache;
std::unique_ptr<mbgl::DefaultFileSource> fileSource;
std::unique_ptr<mbgl::Map> map;
};
}
}
#endif