summaryrefslogtreecommitdiff
path: root/platform/android/src
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-10-06 13:23:50 +0200
committerKonstantin Käfer <mail@kkaefer.com>2016-10-25 13:52:36 -0700
commit5cc390d694fc7510d445310d8eb9e32429a5e67b (patch)
tree7a24706f919ac3e8154be8b4ce33aed5bf42188d /platform/android/src
parent45f4dc0166f2d609d014d2174209fdbe1994c943 (diff)
downloadqtlocation-mapboxgl-5cc390d694fc7510d445310d8eb9e32429a5e67b.tar.gz
[core] separate Backend from View for headless rendering
Diffstat (limited to 'platform/android/src')
-rwxr-xr-xplatform/android/src/native_map_view.cpp12
-rwxr-xr-xplatform/android/src/native_map_view.hpp7
2 files changed, 9 insertions, 10 deletions
diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp
index 5bd2694932..fe201ac069 100755
--- a/platform/android/src/native_map_view.cpp
+++ b/platform/android/src/native_map_view.cpp
@@ -55,10 +55,8 @@ void log_gl_string(GLenum name, const char *label) {
}
}
-NativeMapView::NativeMapView(JNIEnv *env_, jobject obj_, float pixelRatio_, int availableProcessors_, size_t totalMemory_)
- : mbgl::View(*this),
- env(env_),
- pixelRatio(pixelRatio_),
+NativeMapView::NativeMapView(JNIEnv *env_, jobject obj_, float pixelRatio, int availableProcessors_, size_t totalMemory_)
+ : env(env_),
availableProcessors(availableProcessors_),
totalMemory(totalMemory_),
threadPool(4) {
@@ -82,7 +80,7 @@ NativeMapView::NativeMapView(JNIEnv *env_, jobject obj_, float pixelRatio_, int
mbgl::android::cachePath + "/mbgl-offline.db",
mbgl::android::apkPath);
- map = std::make_unique<mbgl::Map>(*this, *fileSource, threadPool, MapMode::Continuous);
+ map = std::make_unique<mbgl::Map>(*this, *this, pixelRatio, *fileSource, threadPool, MapMode::Continuous);
float zoomFactor = map->getMaxZoom() - map->getMinZoom() + 1;
float cpuFactor = availableProcessors;
@@ -114,8 +112,8 @@ NativeMapView::~NativeMapView() {
vm = nullptr;
}
-float NativeMapView::getPixelRatio() const {
- return pixelRatio;
+void NativeMapView::bind() {
+ MBGL_CHECK_ERROR(glBindFramebuffer(GL_FRAMEBUFFER, 0));
}
std::array<uint16_t, 2> NativeMapView::getSize() const {
diff --git a/platform/android/src/native_map_view.hpp b/platform/android/src/native_map_view.hpp
index d42890dae2..42a9a10ad4 100755
--- a/platform/android/src/native_map_view.hpp
+++ b/platform/android/src/native_map_view.hpp
@@ -2,6 +2,7 @@
#include <mbgl/map/map.hpp>
#include <mbgl/map/view.hpp>
+#include <mbgl/map/backend.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/platform/default/thread_pool.hpp>
#include <mbgl/storage/default_file_source.hpp>
@@ -14,12 +15,13 @@
namespace mbgl {
namespace android {
-class NativeMapView : public mbgl::View, private mbgl::util::noncopyable {
+class NativeMapView : public mbgl::View, public mbgl::Backend {
public:
NativeMapView(JNIEnv *env, jobject obj, float pixelRatio, int availableProcessors, size_t totalMemory);
virtual ~NativeMapView();
- float getPixelRatio() const override;
+ void bind() override;
+
std::array<uint16_t, 2> getSize() const override;
std::array<uint16_t, 2> getFramebufferSize() const override;
void activate() override;
@@ -89,7 +91,6 @@ private:
int height = 0;
int fbWidth = 0;
int fbHeight = 0;
- const float pixelRatio;
int availableProcessors = 0;
size_t totalMemory = 0;