Android texture reloading after suspending

This commit is contained in:
Edouard Dupin 2012-02-02 23:22:41 +01:00
parent a4c8558ab7
commit 67ebc4b017
8 changed files with 38 additions and 8 deletions

View File

@ -40,6 +40,7 @@ void EWOL_ThreadResize(int w, int h );
void EWOL_ThreadEventInputMotion(int pointerID, float x, float y);
void EWOL_ThreadEventInputState(int pointerID, bool isUp, float x, float y);
void EWOL_NativeRender(void);
void EWOL_NativeGLDestroy(void);
extern "C"
@ -74,6 +75,9 @@ extern "C"
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE_____PROJECT_NAME___ActivityOnPause( JNIEnv* env )
{
EDN_DEBUG("Activity On Pause");
// All the openGl has been destroyed ...
// TODO : Mark all the texture to be reloaded ...
EWOL_NativeGLDestroy();
}
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE_____PROJECT_NAME___ActivityOnStop( JNIEnv* env )
{

View File

@ -358,6 +358,18 @@ void ewol::texture::UnInit(void)
#undef __class__
#define __class__ "ewol"
void ewol::UpdateTextureContextIsDestroy(void)
{
pthread_mutex_lock(&localMutex);
for (int32_t iii=0; iii < listLoadedTexture.Size(); iii++) {
if( NULL != listLoadedTexture[iii]
&& NULL != listLoadedTexture[iii]->m_data)
{
listLoadedTexture[iii]->m_loaded = false;
}
}
pthread_mutex_unlock(&localMutex);
}
void ewol::UpdateTextureContext(void)
{

View File

@ -49,6 +49,7 @@ namespace ewol
int32_t GetTextureSize(uint32_t textureID);
uint32_t GetTextureGLID(uint32_t textureID);
void UpdateTextureContext(void);
void UpdateTextureContextIsDestroy(void);
void TextureOGLContext(bool enable);
};

View File

@ -39,6 +39,7 @@ static pthread_t androidJniThread;
//static pthread_attr_t androidJniThreadAttr;
enum {
THREAD_INIT,
THREAD_UN_INIT,
THREAD_RESIZE,
THREAD_HIDE,
@ -110,6 +111,9 @@ static void* BaseAppEntry(void* param)
countNbEvent++;
//EWOL_DEBUG("EVENT");
switch (data.type) {
case THREAD_INIT:
EWOL_DEBUG("Receive MSG : THREAD_INIT");
break;
case THREAD_UN_INIT:
EWOL_DEBUG("Receive MSG : THREAD_UN_INIT");
requestEndProcessing = true;
@ -226,6 +230,7 @@ void EWOL_SystemStart(void)
// init the thread :
pthread_create(&androidJniThread, NULL, BaseAppEntry, NULL);
isGlobalSystemInit = true;
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_INIT, ewol::threadMsg::MSG_PRIO_REAL_TIME);
}
}

View File

@ -254,7 +254,7 @@ static int64_t nbDisplayTime = 0;
#define DISPLAY_PERIODE_MS (1000)
void EWOL_GenericDraw(void)
void EWOL_GenericDraw(bool everyTime)
{
bool display = false;
nbCallTime++;
@ -267,7 +267,9 @@ void EWOL_GenericDraw(void)
display = true;
}
ewol::widgetManager::GetDoubleBufferStartDraw();
if (true == ewol::widgetManager::GetDoubleBufferNeedDraw()) {
if( true == ewol::widgetManager::GetDoubleBufferNeedDraw()
|| true == everyTime)
{
nbDisplayTime++;
gui_uniqueWindows->SysDraw();
}
@ -281,4 +283,10 @@ void EWOL_GenericDraw(void)
nbDisplayTime = 0;
startTime = -1;
}
}
}
void EWOL_NativeGLDestroy(void)
{
ewol::UpdateTextureContextIsDestroy();
}

View File

@ -31,7 +31,8 @@
#include <ewol/Windows.h>
void EWOL_NativeResize(int w, int h );
void EWOL_GenericDraw(void);
void EWOL_GenericDraw(bool everyTime);
void EWOL_NativeGLDestroy(void);
namespace guiAbstraction
{

View File

@ -41,7 +41,7 @@
#undef __class__
#define __class__ "AndroidJNI"
int32_t separateClickTime = 200;
int32_t separateClickTime = 800;
int32_t offsetMoveClicked = 40;
int32_t offsetMoveClickedDouble = 300;
@ -178,7 +178,7 @@ void EWOL_NativeRender(void)
glDisable(GL_BLEND);
} else {
EWOL_GenericDraw();
EWOL_GenericDraw(true);
}
glFlush();
}

View File

@ -334,9 +334,8 @@ void EWOL_NativeRender(void)
glColor3f(1., 1., 0.); glVertex3f( .25*(etkFloat_t)gui_width, .75*(etkFloat_t)gui_height, 0.);
glEnd();
} else {
EWOL_GenericDraw();
EWOL_GenericDraw(false);
}
// swap the buffers if we have doublebuffered
glFlush();
if (m_doubleBuffered) {
glXSwapBuffers(m_display, WindowHandle);