Skip to content

Instantly share code, notes, and snippets.

@theuni
Created November 3, 2012 18:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theuni/4008254 to your computer and use it in GitHub Desktop.
Save theuni/4008254 to your computer and use it in GitHub Desktop.
From 0305caa07c0f9532a667d151076e7031d5fa5c40 Mon Sep 17 00:00:00 2001
From: Cory Fields <theuni-nospam-@xbmc.org>
Date: Sat, 3 Nov 2012 14:58:35 -0400
Subject: [PATCH] egl: Android: Add quirk for destroying nativewindow with
surface
Don't count on the driver to realize that the NativeWindow is stale, it may try
to use it and crash. Instead, forcefully kill it when we destroy a window in
order to force recreation later.
---
xbmc/windowing/egl/EGLNativeTypeAndroid.cpp | 3 ++-
xbmc/windowing/egl/EGLNativeTypeAndroid.h | 2 +-
xbmc/windowing/egl/EGLQuirks.h | 1 +
xbmc/windowing/egl/WinSystemEGL.cpp | 5 +++++
4 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/xbmc/windowing/egl/EGLNativeTypeAndroid.cpp b/xbmc/windowing/egl/EGLNativeTypeAndroid.cpp
index d045efe..0c0d355 100644
--- a/xbmc/windowing/egl/EGLNativeTypeAndroid.cpp
+++ b/xbmc/windowing/egl/EGLNativeTypeAndroid.cpp
@@ -76,7 +76,7 @@ bool CEGLNativeTypeAndroid::GetNativeDisplay(XBNativeDisplayType **nativeDisplay
bool CEGLNativeTypeAndroid::GetNativeWindow(XBNativeWindowType **nativeWindow) const
{
- if (!nativeWindow)
+ if (!nativeWindow || !m_nativeWindow)
return false;
*nativeWindow = (XBNativeWindowType*) &m_nativeWindow;
return true;
@@ -89,6 +89,7 @@ bool CEGLNativeTypeAndroid::DestroyNativeDisplay()
bool CEGLNativeTypeAndroid::DestroyNativeWindow()
{
+ m_nativeWindow = NULL;
return true;
}
diff --git a/xbmc/windowing/egl/EGLNativeTypeAndroid.h b/xbmc/windowing/egl/EGLNativeTypeAndroid.h
index ec5a398..ebcbac9 100644
--- a/xbmc/windowing/egl/EGLNativeTypeAndroid.h
+++ b/xbmc/windowing/egl/EGLNativeTypeAndroid.h
@@ -30,7 +30,7 @@ public:
virtual bool CheckCompatibility();
virtual void Initialize();
virtual void Destroy();
- virtual int GetQuirks() { return EGL_QUIRK_NEED_WINDOW_FOR_RES; };
+ virtual int GetQuirks() { return EGL_QUIRK_NEED_WINDOW_FOR_RES | EGL_QUIRK_DESTROY_NATIVE_WINDOW_WITH_SURFACE; };
virtual bool CreateNativeDisplay();
virtual bool CreateNativeWindow();
diff --git a/xbmc/windowing/egl/EGLQuirks.h b/xbmc/windowing/egl/EGLQuirks.h
index 5b4d6b9..57c627a 100644
--- a/xbmc/windowing/egl/EGLQuirks.h
+++ b/xbmc/windowing/egl/EGLQuirks.h
@@ -22,3 +22,4 @@
#define EGL_QUIRK_NONE 0
#define EGL_QUIRK_NEED_WINDOW_FOR_RES 1
+#define EGL_QUIRK_DESTROY_NATIVE_WINDOW_WITH_SURFACE 2
diff --git a/xbmc/windowing/egl/WinSystemEGL.cpp b/xbmc/windowing/egl/WinSystemEGL.cpp
index f089eb5..bff6416 100644
--- a/xbmc/windowing/egl/WinSystemEGL.cpp
+++ b/xbmc/windowing/egl/WinSystemEGL.cpp
@@ -266,6 +266,11 @@ bool CWinSystemEGL::DestroyWindow()
if (m_surface != EGL_NO_SURFACE)
m_egl->DestroySurface(m_surface, m_display);
+ int quirks;
+ m_egl->GetQuirks(&quirks);
+ if (quirks & EGL_QUIRK_DESTROY_NATIVE_WINDOW_WITH_SURFACE)
+ m_egl->DestroyNativeWindow();
+
m_surface = EGL_NO_SURFACE;
m_bWindowCreated = false;
return true;
--
1.8.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment