summaryrefslogtreecommitdiff
path: root/platform/android
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android')
-rw-r--r--platform/android/scripts/generate-style-code.js2
-rwxr-xr-xplatform/android/src/jni.cpp2
-rwxr-xr-xplatform/android/src/native_map_view.cpp34
-rwxr-xr-xplatform/android/src/native_map_view.hpp4
-rw-r--r--platform/android/src/style/layers/custom_layer.cpp2
-rw-r--r--platform/android/src/style/sources/source.hpp2
6 files changed, 20 insertions, 26 deletions
diff --git a/platform/android/scripts/generate-style-code.js b/platform/android/scripts/generate-style-code.js
index 166f102f18..1216bd4cbe 100644
--- a/platform/android/scripts/generate-style-code.js
+++ b/platform/android/scripts/generate-style-code.js
@@ -103,7 +103,7 @@ global.propertyNativeType = function (property) {
if (/-translate-anchor$/.test(property.name)) {
return 'TranslateAnchorType';
}
- if (/-(rotation|pitch)-alignment$/.test(property.name)) {
+ if (/-(rotation|pitch|illumination)-alignment$/.test(property.name)) {
return 'AlignmentType';
}
switch (property.type) {
diff --git a/platform/android/src/jni.cpp b/platform/android/src/jni.cpp
index a145841b47..6dcd177cd6 100755
--- a/platform/android/src/jni.cpp
+++ b/platform/android/src/jni.cpp
@@ -358,7 +358,7 @@ void nativeDestroySurface(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr
void nativeUpdate(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr) {
assert(nativeMapViewPtr != 0);
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
- nativeMapView->getMap().update(mbgl::Update::Repaint);
+ nativeMapView->invalidate();
}
void nativeRender(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr) {
diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp
index fe201ac069..8f594f2c0e 100755
--- a/platform/android/src/native_map_view.cpp
+++ b/platform/android/src/native_map_view.cpp
@@ -17,7 +17,9 @@
#include <mbgl/platform/log.hpp>
#include <mbgl/gl/extension.hpp>
#include <mbgl/gl/gl.hpp>
+#include <mbgl/gl/context.hpp>
#include <mbgl/util/constants.hpp>
+#include <mbgl/util/image.hpp>
namespace mbgl {
namespace android {
@@ -80,7 +82,10 @@ NativeMapView::NativeMapView(JNIEnv *env_, jobject obj_, float pixelRatio, int a
mbgl::android::cachePath + "/mbgl-offline.db",
mbgl::android::apkPath);
- map = std::make_unique<mbgl::Map>(*this, *this, pixelRatio, *fileSource, threadPool, MapMode::Continuous);
+ map = std::make_unique<mbgl::Map>(
+ *this,
+ std::array<uint16_t, 2>{{ static_cast<uint16_t>(width), static_cast<uint16_t>(height) }},
+ pixelRatio, *fileSource, threadPool, MapMode::Continuous);
float zoomFactor = map->getMaxZoom() - map->getMinZoom() + 1;
float cpuFactor = availableProcessors;
@@ -112,16 +117,14 @@ NativeMapView::~NativeMapView() {
vm = nullptr;
}
-void NativeMapView::bind() {
- MBGL_CHECK_ERROR(glBindFramebuffer(GL_FRAMEBUFFER, 0));
-}
-
-std::array<uint16_t, 2> NativeMapView::getSize() const {
- return {{ static_cast<uint16_t>(width), static_cast<uint16_t>(height) }};
+void NativeMapView::updateViewBinding() {
+ getContext().bindFramebuffer.setCurrentValue(0);
+ getContext().viewport.setCurrentValue({ 0, 0, static_cast<uint16_t>(fbWidth), static_cast<uint16_t>(fbHeight) });
}
-std::array<uint16_t, 2> NativeMapView::getFramebufferSize() const {
- return {{ static_cast<uint16_t>(fbWidth), static_cast<uint16_t>(fbHeight) }};
+void NativeMapView::bind() {
+ getContext().bindFramebuffer = 0;
+ getContext().viewport = { 0, 0, static_cast<uint16_t>(fbWidth), static_cast<uint16_t>(fbHeight) };
}
void NativeMapView::activate() {
@@ -189,12 +192,8 @@ void NativeMapView::invalidate() {
void NativeMapView::render() {
activate();
- if(sizeChanged){
- sizeChanged = false;
- glViewport(0, 0, fbWidth, fbHeight);
- }
-
- map->render();
+ updateViewBinding();
+ map->render(*this);
if(snapshot){
snapshot = false;
@@ -719,14 +718,13 @@ void NativeMapView::updateFps() {
void NativeMapView::resizeView(int w, int h) {
width = w;
height = h;
- sizeChanged = true;
- map->update(mbgl::Update::Dimensions);
+ map->setSize({{ static_cast<uint16_t>(width), static_cast<uint16_t>(height) }});
}
void NativeMapView::resizeFramebuffer(int w, int h) {
fbWidth = w;
fbHeight = h;
- map->update(mbgl::Update::Repaint);
+ invalidate();
}
void NativeMapView::setInsets(mbgl::EdgeInsets insets_) {
diff --git a/platform/android/src/native_map_view.hpp b/platform/android/src/native_map_view.hpp
index 42a9a10ad4..43fb0c1ccd 100755
--- a/platform/android/src/native_map_view.hpp
+++ b/platform/android/src/native_map_view.hpp
@@ -20,10 +20,9 @@ public:
NativeMapView(JNIEnv *env, jobject obj, float pixelRatio, int availableProcessors, size_t totalMemory);
virtual ~NativeMapView();
+ void updateViewBinding();
void bind() override;
- std::array<uint16_t, 2> getSize() const override;
- std::array<uint16_t, 2> getFramebufferSize() const override;
void activate() override;
void deactivate() override;
void invalidate() override;
@@ -83,7 +82,6 @@ private:
bool firstTime = false;
bool fpsEnabled = false;
- bool sizeChanged = false;
bool snapshot = false;
double fps = 0.0;
diff --git a/platform/android/src/style/layers/custom_layer.cpp b/platform/android/src/style/layers/custom_layer.cpp
index aeabb4e19d..6568455c67 100644
--- a/platform/android/src/style/layers/custom_layer.cpp
+++ b/platform/android/src/style/layers/custom_layer.cpp
@@ -26,7 +26,7 @@ namespace android {
void CustomLayer::update(jni::JNIEnv&) {
Log::Debug(mbgl::Event::JNI, "Updating map");
if (map) {
- map->update(mbgl::Update::Repaint);
+ map->triggerRepaint();
} else {
Log::Error(mbgl::Event::JNI, "No map reference, cannot update");
}
diff --git a/platform/android/src/style/sources/source.hpp b/platform/android/src/style/sources/source.hpp
index 5794cd4e62..0785e4d4e0 100644
--- a/platform/android/src/style/sources/source.hpp
+++ b/platform/android/src/style/sources/source.hpp
@@ -40,11 +40,9 @@ public:
std::unique_ptr<mbgl::style::Source> releaseCoreSource();
protected:
-
std::unique_ptr<mbgl::style::Source> ownedSource;
mbgl::style::Source& source;
mbgl::Map* map;
-
};
} //android