android: emu_window: Fix surface width/height.

- Fixes a bug when resuming the app.
This commit is contained in:
bunnei 2020-03-10 00:17:36 -04:00
parent 71d607040a
commit a79e5f1d4e
2 changed files with 16 additions and 5 deletions

View File

@ -95,7 +95,14 @@ void EmuWindow_Android::OnTouchMoved(int x, int y) {
void EmuWindow_Android::OnFramebufferSizeChanged() {
UpdateLandscapeScreenLayout();
UpdateCurrentFramebufferLayout(window_width, window_height, IsPortraitMode());
const bool is_portrait_mode{IsPortraitMode()};
const int bigger{window_width > window_height ? window_width : window_height};
const int smaller{window_width < window_height ? window_width : window_height};
if (is_portrait_mode) {
UpdateCurrentFramebufferLayout(smaller, bigger, is_portrait_mode);
} else {
UpdateCurrentFramebufferLayout(bigger, smaller, is_portrait_mode);
}
}
EmuWindow_Android::EmuWindow_Android(ANativeWindow* surface) {
@ -126,6 +133,13 @@ EmuWindow_Android::EmuWindow_Android(ANativeWindow* surface) {
CreateWindowSurface();
if (eglQuerySurface(egl_display, egl_surface, EGL_WIDTH, &window_width) != EGL_TRUE) {
return;
}
if (eglQuerySurface(egl_display, egl_surface, EGL_HEIGHT, &window_height) != EGL_TRUE) {
return;
}
if (egl_context = eglCreateContext(egl_display, egl_config, 0, egl_context_attribs.data());
egl_context == EGL_NO_CONTEXT) {
LOG_CRITICAL(Frontend, "eglCreateContext() failed");
@ -164,9 +178,6 @@ bool EmuWindow_Android::CreateWindowSurface() {
EGLint format{};
eglGetConfigAttrib(egl_display, egl_config, EGL_NATIVE_VISUAL_ID, &format);
ANativeWindow_setBuffersGeometry(host_window, 0, 0, format);
window_width = ANativeWindow_getWidth(host_window);
window_height = ANativeWindow_getHeight(host_window);
UpdateCurrentFramebufferLayout(window_width, window_height);
if (egl_surface = eglCreateWindowSurface(egl_display, egl_config, host_window, 0);
egl_surface == EGL_NO_SURFACE) {

View File

@ -26,9 +26,9 @@ public:
void DoneCurrent() override;
private:
EGLDisplay egl_display{};
EGLSurface egl_surface{};
EGLContext egl_context{};
EGLDisplay egl_display{};
};
class EmuWindow_Android : public Frontend::EmuWindow {