Fixed EGL surface not recreated in the right thread
This commit is contained in:
parent
796c87295c
commit
f7561f5fa1
@ -289,12 +289,12 @@ static void onNativeWindowCreated(ANativeActivity* activity, ANativeWindow* wind
|
|||||||
states->window = window;
|
states->window = window;
|
||||||
|
|
||||||
// Notify SFML mechanism
|
// Notify SFML mechanism
|
||||||
states->updated = false;
|
|
||||||
sf::Event event;
|
sf::Event event;
|
||||||
event.type = sf::Event::GainedFocus;
|
event.type = sf::Event::GainedFocus;
|
||||||
states->forwardEvent(event);
|
states->forwardEvent(event);
|
||||||
|
|
||||||
// Wait for the event to be taken into account by SFML
|
// Wait for the event to be taken into account by SFML
|
||||||
|
states->updated = false;
|
||||||
while(!states->updated)
|
while(!states->updated)
|
||||||
{
|
{
|
||||||
states->mutex.unlock();
|
states->mutex.unlock();
|
||||||
@ -314,12 +314,12 @@ static void onNativeWindowDestroyed(ANativeActivity* activity, ANativeWindow* wi
|
|||||||
states->window = NULL;
|
states->window = NULL;
|
||||||
|
|
||||||
// Notify SFML mechanism
|
// Notify SFML mechanism
|
||||||
states->updated = false;
|
|
||||||
sf::Event event;
|
sf::Event event;
|
||||||
event.type = sf::Event::LostFocus;
|
event.type = sf::Event::LostFocus;
|
||||||
states->forwardEvent(event);
|
states->forwardEvent(event);
|
||||||
|
|
||||||
// Wait for the event to be taken into account by SFML
|
// Wait for the event to be taken into account by SFML
|
||||||
|
states->updated = false;
|
||||||
while(!states->updated)
|
while(!states->updated)
|
||||||
{
|
{
|
||||||
states->mutex.unlock();
|
states->mutex.unlock();
|
||||||
|
@ -49,6 +49,8 @@ WindowImplAndroid* WindowImplAndroid::singleInstance = NULL;
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
WindowImplAndroid::WindowImplAndroid(WindowHandle handle)
|
WindowImplAndroid::WindowImplAndroid(WindowHandle handle)
|
||||||
: m_size(0, 0)
|
: m_size(0, 0)
|
||||||
|
, m_windowBeingCreated(false)
|
||||||
|
, m_windowBeingDestroyed(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,6 +58,8 @@ WindowImplAndroid::WindowImplAndroid(WindowHandle handle)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
WindowImplAndroid::WindowImplAndroid(VideoMode mode, const String& title, unsigned long style, const ContextSettings& settings)
|
WindowImplAndroid::WindowImplAndroid(VideoMode mode, const String& title, unsigned long style, const ContextSettings& settings)
|
||||||
: m_size(mode.width, mode.height)
|
: m_size(mode.width, mode.height)
|
||||||
|
, m_windowBeingCreated(false)
|
||||||
|
, m_windowBeingDestroyed(false)
|
||||||
{
|
{
|
||||||
ActivityStates* states = getActivity(NULL);
|
ActivityStates* states = getActivity(NULL);
|
||||||
Lock lock(states->mutex);
|
Lock lock(states->mutex);
|
||||||
@ -94,6 +98,23 @@ void WindowImplAndroid::processEvents()
|
|||||||
{
|
{
|
||||||
// Process incoming OS events
|
// Process incoming OS events
|
||||||
ALooper_pollAll(0, NULL, NULL, NULL);
|
ALooper_pollAll(0, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
ActivityStates* states = getActivity(NULL);
|
||||||
|
sf::Lock lock(states->mutex);
|
||||||
|
|
||||||
|
if (m_windowBeingCreated)
|
||||||
|
{
|
||||||
|
states->context->createSurface(states->window);
|
||||||
|
m_windowBeingCreated = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_windowBeingDestroyed)
|
||||||
|
{
|
||||||
|
states->context->destroySurface();
|
||||||
|
m_windowBeingDestroyed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
states->updated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -164,21 +185,16 @@ void WindowImplAndroid::setKeyRepeatEnabled(bool enabled)
|
|||||||
void WindowImplAndroid::forwardEvent(const Event& event)
|
void WindowImplAndroid::forwardEvent(const Event& event)
|
||||||
{
|
{
|
||||||
ActivityStates* states = getActivity(NULL);
|
ActivityStates* states = getActivity(NULL);
|
||||||
Lock lock(states->mutex);
|
|
||||||
|
|
||||||
if (event.type == Event::GainedFocus)
|
if (event.type == Event::GainedFocus)
|
||||||
{
|
{
|
||||||
states->context->createSurface(states->window);
|
|
||||||
|
|
||||||
WindowImplAndroid::singleInstance->m_size.x = ANativeWindow_getWidth(states->window);
|
WindowImplAndroid::singleInstance->m_size.x = ANativeWindow_getWidth(states->window);
|
||||||
WindowImplAndroid::singleInstance->m_size.y = ANativeWindow_getHeight(states->window);
|
WindowImplAndroid::singleInstance->m_size.y = ANativeWindow_getHeight(states->window);
|
||||||
|
WindowImplAndroid::singleInstance->m_windowBeingCreated = true;
|
||||||
states->updated = true;
|
|
||||||
}
|
}
|
||||||
else if (event.type == Event::LostFocus)
|
else if (event.type == Event::LostFocus)
|
||||||
{
|
{
|
||||||
states->context->destroySurface();
|
WindowImplAndroid::singleInstance->m_windowBeingDestroyed = true;
|
||||||
states->updated = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowImplAndroid::singleInstance->pushEvent(event);
|
WindowImplAndroid::singleInstance->pushEvent(event);
|
||||||
|
@ -205,6 +205,8 @@ private:
|
|||||||
static int getUnicode(AInputEvent* event);
|
static int getUnicode(AInputEvent* event);
|
||||||
|
|
||||||
Vector2u m_size;
|
Vector2u m_size;
|
||||||
|
bool m_windowBeingCreated;
|
||||||
|
bool m_windowBeingDestroyed;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace priv
|
} // namespace priv
|
||||||
|
Loading…
Reference in New Issue
Block a user