Make pixelRatio constant across a Map object lifetime
also moves framebuffer size out of TransformState into its own object
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user