android: Move PollEvents to OpenGL window

* Vulkan does not need this and it causes problems
This commit is contained in:
GPUCode 2023-08-20 12:49:10 +03:00
parent dd71859818
commit faf6b36f3b
6 changed files with 25 additions and 37 deletions

View file

@ -82,20 +82,6 @@ EmuWindow_Android::~EmuWindow_Android() {
DestroyContext();
}
void EmuWindow_Android::PollEvents() {
if (!render_window) {
return;
}
host_window = render_window;
render_window = nullptr;
DestroyWindowSurface();
CreateWindowSurface();
OnFramebufferSizeChanged();
presenting_state = PresentingState::Initial;
}
void EmuWindow_Android::MakeCurrent() {
core_context->MakeCurrent();
}

View file

@ -21,15 +21,13 @@ public:
/// Handles movement of touch pointer
void OnTouchMoved(int x, int y);
void PollEvents() override;
void MakeCurrent() override;
void DoneCurrent() override;
virtual void TryPresenting() = 0;
virtual void TryPresenting() {}
virtual void StopPresenting() = 0;
virtual void StopPresenting() {}
protected:
void OnFramebufferSizeChanged();
@ -53,11 +51,4 @@ protected:
int window_height{};
std::unique_ptr<Frontend::GraphicsContext> core_context;
enum class PresentingState {
Initial,
Running,
Stopped,
};
PresentingState presenting_state{};
};

View file

@ -177,6 +177,20 @@ std::unique_ptr<Frontend::GraphicsContext> EmuWindow_Android_OpenGL::CreateShare
return std::make_unique<SharedContext_Android>(egl_display, egl_config, egl_context);
}
void EmuWindow_Android_OpenGL::PollEvents() {
if (!render_window) {
return;
}
host_window = render_window;
render_window = nullptr;
DestroyWindowSurface();
CreateWindowSurface();
OnFramebufferSizeChanged();
presenting_state = PresentingState::Initial;
}
void EmuWindow_Android_OpenGL::StopPresenting() {
if (presenting_state == PresentingState::Running) {
eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);

View file

@ -20,6 +20,7 @@ public:
void TryPresenting() override;
void StopPresenting() override;
void PollEvents() override;
std::unique_ptr<GraphicsContext> CreateSharedContext() const override;
@ -33,4 +34,11 @@ private:
EGLSurface egl_surface{};
EGLContext egl_context{};
EGLDisplay egl_display{};
enum class PresentingState {
Initial,
Running,
Stopped,
};
PresentingState presenting_state{};
};

View file

@ -51,13 +51,3 @@ bool EmuWindow_Android_Vulkan::CreateWindowSurface() {
std::unique_ptr<Frontend::GraphicsContext> EmuWindow_Android_Vulkan::CreateSharedContext() const {
return std::make_unique<GraphicsContext_Android>(driver_library);
}
void EmuWindow_Android_Vulkan::StopPresenting() {
presenting_state = PresentingState::Stopped;
}
void EmuWindow_Android_Vulkan::TryPresenting() {
if (presenting_state == PresentingState::Initial) {
presenting_state = PresentingState::Running;
}
}

View file

@ -14,8 +14,7 @@ public:
std::shared_ptr<Common::DynamicLibrary> driver_library);
~EmuWindow_Android_Vulkan() override = default;
void TryPresenting() override;
void StopPresenting() override;
void PollEvents() override {}
std::unique_ptr<GraphicsContext> CreateSharedContext() const override;