diff options
-rw-r--r-- | package.json | 2 | ||||
-rwxr-xr-x | platform/android/src/native_map_view.cpp | 46 | ||||
-rwxr-xr-x | platform/android/src/native_map_view.hpp | 2 |
3 files changed, 29 insertions, 21 deletions
diff --git a/package.json b/package.json index bd5b67b663..c598a9472d 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "ejs": "^2.4.1", "express": "^4.11.1", "lodash": "^4.16.4", - "mapbox-gl-shaders": "mapbox/mapbox-gl-shaders#7f1c3bef3692f1d044035a22e65c8758b7630333", + "mapbox-gl-shaders": "mapbox/mapbox-gl-shaders#ec891ce5360e488d81f60991f95d2038b83c4e3c", "mapbox-gl-style-spec": "mapbox/mapbox-gl-style-spec#7f62a4fc9f21e619824d68abbc4b03cbc1685572", "mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#af9ee275f19e81f839a2733e6906c3fac272620e", "mkdirp": "^0.5.1", diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp index f570f7e68e..984fe9d382 100755 --- a/platform/android/src/native_map_view.cpp +++ b/platform/android/src/native_map_view.cpp @@ -222,13 +222,6 @@ mbgl::Map &NativeMapView::getMap() { return *map; } mbgl::DefaultFileSource &NativeMapView::getFileSource() { return *fileSource; } -bool NativeMapView::inEmulator() { - // Detect if we are in emulator - char prop[PROP_VALUE_MAX]; - __system_property_get("ro.kernel.qemu", prop); - return strtol(prop, nullptr, 0) == 1; -} - void NativeMapView::initializeDisplay() { mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::initializeDisplay"); @@ -258,22 +251,39 @@ void NativeMapView::initializeDisplay() { log_egl_string(display, EGL_CLIENT_APIS, "Client APIs"); log_egl_string(display, EGL_EXTENSIONS, "Client Extensions"); - // Detect if we are in emulator - if (inEmulator()) { + // Detect if we are in emulator. + const bool inEmulator = []() { + char prop[PROP_VALUE_MAX]; + __system_property_get("ro.kernel.qemu", prop); + return strtol(prop, nullptr, 0) == 1; + }(); + + if (inEmulator) { + // XXX https://code.google.com/p/android/issues/detail?id=78977 mbgl::Log::Warning(mbgl::Event::Android, "In emulator! Enabling hacks :-("); } + if (!eglBindAPI(EGL_OPENGL_ES_API)) { + mbgl::Log::Error(mbgl::Event::OpenGL, "eglBindAPI(EGL_OPENGL_ES_API) returned error %d", eglGetError()); + throw std::runtime_error("eglBindAPI() failed"); + } + // Get all configs at least RGB 565 with 16 depth and 8 stencil EGLint configAttribs[] = { - EGL_CONFIG_CAVEAT, EGL_NONE, EGL_RENDERABLE_TYPE, - EGL_OPENGL_ES2_BIT, EGL_SURFACE_TYPE, EGL_WINDOW_BIT, - EGL_BUFFER_SIZE, 16, EGL_RED_SIZE, - 5, EGL_GREEN_SIZE, 6, - EGL_BLUE_SIZE, 5, EGL_DEPTH_SIZE, - 16, EGL_STENCIL_SIZE, 8, - (inEmulator() ? EGL_NONE : EGL_CONFORMANT), EGL_OPENGL_ES2_BIT, // Ugly hack - (inEmulator() ? EGL_NONE : EGL_COLOR_BUFFER_TYPE), EGL_RGB_BUFFER, // Ugly hack - EGL_NONE}; + EGL_CONFIG_CAVEAT, EGL_NONE, + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, + EGL_BUFFER_SIZE, 16, + EGL_RED_SIZE, 5, + EGL_GREEN_SIZE, 6, + EGL_BLUE_SIZE, 5, + EGL_DEPTH_SIZE, 16, + EGL_STENCIL_SIZE, 8, + (inEmulator ? EGL_NONE : EGL_CONFORMANT), EGL_OPENGL_ES2_BIT, + (inEmulator ? EGL_NONE : EGL_COLOR_BUFFER_TYPE), EGL_RGB_BUFFER, + EGL_NONE + }; + EGLint numConfigs; if (!eglChooseConfig(display, configAttribs, nullptr, 0, &numConfigs)) { mbgl::Log::Error(mbgl::Event::OpenGL, "eglChooseConfig(NULL) returned error %d", diff --git a/platform/android/src/native_map_view.hpp b/platform/android/src/native_map_view.hpp index 18f9ebc144..14b9842c72 100755 --- a/platform/android/src/native_map_view.hpp +++ b/platform/android/src/native_map_view.hpp @@ -57,8 +57,6 @@ public: private: EGLConfig chooseConfig(const EGLConfig configs[], EGLint numConfigs); - bool inEmulator(); - private: JavaVM *vm = nullptr; JNIEnv *env = nullptr; |