Make pixelRatio constant across a Map object lifetime

also moves framebuffer size out of TransformState into its own object
This commit is contained in:
Konstantin Käfer
2015-07-01 12:39:21 +02:00
parent 3a07cb2f1e
commit 675ddddee7
40 changed files with 308 additions and 214 deletions

View File

@@ -52,8 +52,9 @@ void log_gl_string(GLenum name, const char *label) {
}
}
NativeMapView::NativeMapView(JNIEnv *env, jobject obj_)
NativeMapView::NativeMapView(JNIEnv *env, jobject obj_, float pixelRatio_)
: mbgl::View(*this),
pixelRatio(pixelRatio_),
fileCache(mbgl::android::cachePath + "/mbgl-cache.db"),
fileSource(&fileCache),
map(*this, fileSource, MapMode::Continuous) {
@@ -98,6 +99,18 @@ NativeMapView::~NativeMapView() {
vm = nullptr;
}
float NativeMapView::getPixelRatio() const {
return pixelRatio;
}
std::array<uint16_t, 2> NativeMapView::getSize() const {
return {{ static_cast<uint16_t>(width), static_cast<uint16_t>(height) }};
}
std::array<uint16_t, 2> NativeMapView::getFramebufferSize() const {
return {{ static_cast<uint16_t>(fbWidth), static_cast<uint16_t>(fbHeight) }};
}
void NativeMapView::activate() {
mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::activate");
if ((display != EGL_NO_DISPLAY) && (surface != EGL_NO_SURFACE) && (context != EGL_NO_CONTEXT)) {
@@ -754,5 +767,16 @@ void NativeMapView::onInvalidate() {
}
}
void NativeMapView::resizeView(int w, int h) {
width = w;
height = h;
map.update(mbgl::Update::Dimensions);
}
void NativeMapView::resizeFramebuffer(int w, int h) {
fbWidth = w;
fbHeight = h;
}
}
}