diff options
author | Memphiz <memphis@machzwo.de> | 2015-01-30 15:29:10 +0100 |
---|---|---|
committer | Memphiz <memphis@machzwo.de> | 2015-01-30 15:29:10 +0100 |
commit | 599d480cde1d90266fa77d5ee4c6d2926dffdb94 (patch) | |
tree | 48d645e86e8e14f0760753b13a8cc5fe68bb3833 | |
parent | 2be805c56776716d2fc269b5376ebf3f495e7a98 (diff) | |
parent | 975670bc94fced78d473866c6aa4e21e62aa8570 (diff) |
Merge pull request #6297 from bavison/font_cache
Fix for crash on startup on iOS
-rw-r--r-- | xbmc/guilib/GUIFontTTFGL.cpp | 11 | ||||
-rw-r--r-- | xbmc/guilib/GUIFontTTFGL.h | 4 | ||||
-rw-r--r-- | xbmc/windowing/WinSystem.cpp | 11 | ||||
-rw-r--r-- | xbmc/windowing/WinSystem.h | 2 | ||||
-rw-r--r-- | xbmc/windowing/egl/WinSystemEGL.cpp | 15 |
5 files changed, 27 insertions, 16 deletions
diff --git a/xbmc/guilib/GUIFontTTFGL.cpp b/xbmc/guilib/GUIFontTTFGL.cpp index 9c65b2e0f9..79f32ddef1 100644 --- a/xbmc/guilib/GUIFontTTFGL.cpp +++ b/xbmc/guilib/GUIFontTTFGL.cpp @@ -167,7 +167,9 @@ void CGUIFontTTFGL::LastEnd() glBindTexture(GL_TEXTURE_2D, 0); glDisable(GL_TEXTURE_2D); #else - // GLES 2.0 version. Cannot draw quads. Convert to triangles. + // GLES 2.0 version. + CreateStaticVertexBuffers(); + GLint posLoc = g_Windowing.GUIShaderGetPos(); GLint colLoc = g_Windowing.GUIShaderGetCol(); GLint tex0Loc = g_Windowing.GUIShaderGetCoord0(); @@ -394,6 +396,8 @@ void CGUIFontTTFGL::DeleteHardwareTexture() #if HAS_GLES void CGUIFontTTFGL::CreateStaticVertexBuffers(void) { + if (m_staticVertexBufferCreated) + return; // Bind a new buffer to the OpenGL context's GL_ELEMENT_ARRAY_BUFFER binding point glGenBuffers(1, &m_elementArrayHandle); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_elementArrayHandle); @@ -410,14 +414,19 @@ void CGUIFontTTFGL::CreateStaticVertexBuffers(void) } glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof index, index, GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + m_staticVertexBufferCreated = true; } void CGUIFontTTFGL::DestroyStaticVertexBuffers(void) { + if (!m_staticVertexBufferCreated) + return; glDeleteBuffers(1, &m_elementArrayHandle); + m_staticVertexBufferCreated = false; } GLuint CGUIFontTTFGL::m_elementArrayHandle; +bool CGUIFontTTFGL::m_staticVertexBufferCreated; #endif #endif diff --git a/xbmc/guilib/GUIFontTTFGL.h b/xbmc/guilib/GUIFontTTFGL.h index e9c8835dba..bcde308bcd 100644 --- a/xbmc/guilib/GUIFontTTFGL.h +++ b/xbmc/guilib/GUIFontTTFGL.h @@ -76,6 +76,10 @@ private: }; TextureStatus m_textureStatus; + +#if HAS_GLES + static bool m_staticVertexBufferCreated; +#endif }; #endif diff --git a/xbmc/windowing/WinSystem.cpp b/xbmc/windowing/WinSystem.cpp index 3ca567731b..d674f249d0 100644 --- a/xbmc/windowing/WinSystem.cpp +++ b/xbmc/windowing/WinSystem.cpp @@ -24,6 +24,9 @@ #include "settings/lib/Setting.h" #include "settings/Settings.h" #include "utils/StringUtils.h" +#if HAS_GLES +#include "guilib/GUIFontTTFGL.h" +#endif using namespace std; @@ -53,6 +56,14 @@ bool CWinSystemBase::InitWindowSystem() return true; } +bool CWinSystemBase::DestroyWindowSystem() +{ +#if HAS_GLES + CGUIFontTTFGL::DestroyStaticVertexBuffers(); +#endif + return false; +} + void CWinSystemBase::UpdateDesktopResolution(RESOLUTION_INFO& newRes, int screen, int width, int height, float refreshRate, uint32_t dwFlags) { newRes.Overscan.left = 0; diff --git a/xbmc/windowing/WinSystem.h b/xbmc/windowing/WinSystem.h index 67d306702a..b92215613e 100644 --- a/xbmc/windowing/WinSystem.h +++ b/xbmc/windowing/WinSystem.h @@ -59,7 +59,7 @@ public: // windowing interfaces virtual bool InitWindowSystem(); - virtual bool DestroyWindowSystem(){ return false; } + virtual bool DestroyWindowSystem(); virtual bool CreateNewWindow(const std::string& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction) = 0; virtual bool DestroyWindow(){ return false; } virtual bool ResizeWindow(int newWidth, int newHeight, int newLeft, int newTop) = 0; diff --git a/xbmc/windowing/egl/WinSystemEGL.cpp b/xbmc/windowing/egl/WinSystemEGL.cpp index 31b7b3c59d..0151be232e 100644 --- a/xbmc/windowing/egl/WinSystemEGL.cpp +++ b/xbmc/windowing/egl/WinSystemEGL.cpp @@ -31,7 +31,6 @@ #include "settings/DisplaySettings.h" #include "guilib/DispResource.h" #include "threads/SingleLock.h" -#include "guilib/GUIFontTTFGL.h" #include "utils/log.h" #include "EGLWrapper.h" #include "EGLQuirks.h" @@ -208,9 +207,6 @@ bool CWinSystemEGL::CreateWindow(RESOLUTION_INFO &res) return false; } -#if HAS_GLES - bool newContext = false; -#endif if (m_context == EGL_NO_CONTEXT) { if (!m_egl->CreateContext(m_display, m_config, contextAttrs, &m_context)) @@ -218,9 +214,6 @@ bool CWinSystemEGL::CreateWindow(RESOLUTION_INFO &res) CLog::Log(LOGERROR, "%s: Could not create context",__FUNCTION__); return false; } -#if HAS_GLES - newContext = true; -#endif } if (!m_egl->BindContext(m_display, m_surface, m_context)) @@ -229,10 +222,6 @@ bool CWinSystemEGL::CreateWindow(RESOLUTION_INFO &res) return false; } -#if HAS_GLES - if (newContext) - CGUIFontTTFGL::CreateStaticVertexBuffers(); -#endif // for the non-trivial dirty region modes, we need the EGL buffer to be preserved across updates if (g_advancedSettings.m_guiAlgorithmDirtyRegions == DIRTYREGION_SOLVER_COST_REDUCTION || @@ -256,9 +245,6 @@ bool CWinSystemEGL::DestroyWindowSystem() if (m_context != EGL_NO_CONTEXT) { -#if HAS_GLES - CGUIFontTTFGL::DestroyStaticVertexBuffers(); -#endif m_egl->DestroyContext(m_display, m_context); } m_context = EGL_NO_CONTEXT; @@ -275,6 +261,7 @@ bool CWinSystemEGL::DestroyWindowSystem() delete m_egl; m_egl = NULL; + CWinSystemBase::DestroyWindowSystem(); return true; } |