Start of merging the display system between Android and X11

This commit is contained in:
Edouard Dupin 2012-01-27 12:43:36 +01:00
parent ebac712147
commit d5e64688c7
6 changed files with 281 additions and 235 deletions

View File

@ -193,14 +193,12 @@ class EwolGLSurfaceView extends GLSurfaceView {
nativeEventInputState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0)); nativeEventInputState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0));
InputDown3 = false; InputDown3 = false;
} }
} else {
nativeEventUnknow(tmpActionType);
} }
return true; return true;
} }
public boolean onKeyDown (int keyCode, KeyEvent event){ public boolean onKeyDown (int keyCode, KeyEvent event){
nativeEventUnknow(156); // TODO ...
return true; return true;
} }

View File

@ -33,150 +33,11 @@
// declaration of the ewol android abstraction ... // declaration of the ewol android abstraction ...
void EWOL_NativeInit(void); void EWOL_NativeInit(void);
void EWOL_NativeResize(int w, int h );
void EWOL_NativeDone(void); void EWOL_NativeDone(void);
void EWOL_NativeEventInputMotion(int pointerID, float x, float y );
void EWOL_NativeEventInputState(int pointerID, bool isUp, float x, float y );
void EWOL_NativeEventUnknow(int ID);
void EWOL_NativeParamSetArchiveDir(int mode, const char* str);
void EWOL_NativeApplicationInit(void); void EWOL_NativeApplicationInit(void);
void EWOL_NativeApplicationUnInit(void); void EWOL_NativeApplicationUnInit(void);
void EWOL_NativeRender(void); void EWOL_NativeRender(void);
static ewol::threadMsg::threadMsg_ts androidJniMsg;
static pthread_t androidJniThread;
static pthread_attr_t androidJniThreadAttr;
enum {
JNI_NONE,
JNI_INIT,
JNI_UN_INIT,
JNI_DONE,
JNI_RESIZE,
JNI_INPUT_MOTION,
JNI_INPUT_STATE,
JNI_DATA_ARCHIVE_DIR,
JNI_APP_INIT,
JNI_APP_UN_INIT,
JNI_APP_RENDERER,
};
#include <unistd.h>
typedef struct {
int w;
int h;
} eventResize_ts;
typedef struct {
int pointerID;
float x;
float y;
} eventInputMotion_ts;
typedef struct {
int pointerID;
bool state;
float x;
float y;
} eventInputState_ts;
static void* BaseAppEntry(void* param)
{
bool requestEndProcessing = false;
EDN_DEBUG("start Ewol Basic thread ...");
while(false == requestEndProcessing) {
ewol::threadMsg::threadMsgContent_ts data;
ewol::threadMsg::WaitMessage(androidJniMsg, data);
switch (data.type) {
case JNI_NONE:
EDN_DEBUG("Receive MSG : JNI_NONE");
break;
case JNI_INIT:
EDN_DEBUG("Receive MSG : JNI_INIT");
EWOL_NativeApplicationInit();
break;
case JNI_UN_INIT:
EDN_DEBUG("Receive MSG : JNI_UN_INIT");
EWOL_NativeApplicationUnInit();
requestEndProcessing = true;
break;
case JNI_DONE:
EDN_DEBUG("Receive MSG : JNI_DONE");
break;
case JNI_RESIZE:
EDN_DEBUG("Receive MSG : JNI_RESIZE");
{
eventResize_ts * tmpData = (eventResize_ts*)data.data;
EWOL_NativeResize(tmpData->w, tmpData->h);
EWOL_NativeInit();
}
break;
case JNI_INPUT_MOTION:
EDN_DEBUG("Receive MSG : JNI_INPUT_MOTION");
{
eventInputMotion_ts * tmpData = (eventInputMotion_ts*)data.data;
EWOL_NativeEventInputMotion(tmpData->pointerID, tmpData->x, tmpData->y);
}
break;
case JNI_INPUT_STATE:
EDN_DEBUG("Receive MSG : JNI_INPUT_STATE");
{
eventInputState_ts * tmpData = (eventInputState_ts*)data.data;
EWOL_NativeEventInputState(tmpData->pointerID, tmpData->state, tmpData->x, tmpData->y);
}
break;
case JNI_DATA_ARCHIVE_DIR:
EDN_DEBUG("Receive MSG : JNI_DATA_ARCHIVE_DIR");
break;
case JNI_APP_INIT:
EDN_DEBUG("Receive MSG : JNI_APP_INIT");
break;
case JNI_APP_UN_INIT:
EDN_DEBUG("Receive MSG : JNI_APP_UN_INIT");
break;
case JNI_APP_RENDERER:
EDN_DEBUG("Receive MSG : JNI_APP_RENDERER");
break;
default:
EDN_DEBUG("Receive MSG : UNKNOW");
break;
}
}
EDN_DEBUG("End Ewol Basic thread ...");
pthread_exit(NULL);
}
bool isGlobalSystemInit = false;
void BaseInit(void)
{
if (false == isGlobalSystemInit) {
// create interface mutex :
ewol::threadMsg::Init(androidJniMsg);
// init the thread :
pthread_create(&androidJniThread, NULL, BaseAppEntry, NULL);
isGlobalSystemInit = true;
ewol::threadMsg::SendMessage(androidJniMsg, JNI_INIT, ewol::threadMsg::MSG_PRIO_REAL_TIME);
}
}
void BaseUnInit(void)
{
if (true == isGlobalSystemInit) {
isGlobalSystemInit = false;
ewol::threadMsg::SendMessage(androidJniMsg, JNI_UN_INIT, ewol::threadMsg::MSG_PRIO_REAL_TIME);
EDN_DEBUG("Wait end of the thread ...");
// Wait end of the thread
pthread_join(androidJniThread, NULL);
ewol::threadMsg::UnInit(androidJniMsg);
}
}
extern "C" extern "C"
{ {
@ -186,7 +47,7 @@ extern "C"
{ {
// direct setting of the date in the string system ... // direct setting of the date in the string system ...
const char* str = env->GetStringUTFChars(myString,0); const char* str = env->GetStringUTFChars(myString,0);
EWOL_NativeParamSetArchiveDir(mode, str); EWOL_ThreadSetArchiveDir(mode, str);
//env->ReleaseStringUTFChars(str,myString,0); //env->ReleaseStringUTFChars(str,myString,0);
} }
@ -257,12 +118,6 @@ extern "C"
} }
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE___EwolGLSurfaceView_nativeEventUnknow( JNIEnv* env, jobject thiz, jint ID)
{
//EWOL_NativeEventUnknow(ID);
}
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE___EwolGLSurfaceView_nativeApplicationInit( JNIEnv* env) void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE___EwolGLSurfaceView_nativeApplicationInit( JNIEnv* env)
{ {
ewol::threadMsg::SendMessage(androidJniMsg, JNI_APP_INIT); ewol::threadMsg::SendMessage(androidJniMsg, JNI_APP_INIT);

View File

@ -463,7 +463,7 @@ template<typename MY_TYPE=int32_t> class VectorType
*/ */
void Erase(int32_t pos) void Erase(int32_t pos)
{ {
if (pos>m_size) { if (pos<0 || (uint32_t)pos>m_size) {
TK_ERROR(" can not Erase Element at this position : " << pos << " > " << m_size); TK_ERROR(" can not Erase Element at this position : " << pos << " > " << m_size);
return; return;
} }

View File

@ -0,0 +1,234 @@
/**
*******************************************************************************
* @file MainThread.cpp
* @brief Main Ewol thread for the abstraction of the OS problematics (Sources)
* @author Edouard DUPIN
* @date 27/01/2012
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <ewol/ewol.h>
#include <ewol/Debug.h>
#include <ewol/threadMsg.h>
#include <ewol/base/MainThread.h>
static ewol::threadMsg::threadMsg_ts androidJniMsg;
static pthread_t androidJniThread;
static pthread_attr_t androidJniThreadAttr;
enum {
JNI_NONE,
JNI_INIT,
JNI_UN_INIT,
JNI_DONE,
JNI_RESIZE,
JNI_INPUT_MOTION,
JNI_INPUT_STATE,
JNI_DATA_ARCHIVE_DIR,
JNI_APP_INIT,
JNI_APP_UN_INIT,
JNI_APP_RENDERER,
};
#include <unistd.h>
typedef struct {
int w;
int h;
} eventResize_ts;
typedef struct {
int pointerID;
float x;
float y;
} eventInputMotion_ts;
typedef struct {
int pointerID;
bool state;
float x;
float y;
} eventInputState_ts;
static void* BaseAppEntry(void* param)
{
bool requestEndProcessing = false;
EDN_DEBUG("start Ewol Basic thread ...");
guiAbstraction::Init(0, NULL);
ewol::Init(0, NULL);
APP_Init(0, NULL);
while(false == requestEndProcessing) {
ewol::threadMsg::threadMsgContent_ts data;
ewol::threadMsg::WaitMessage(androidJniMsg, data);
switch (data.type) {
case JNI_NONE:
EDN_DEBUG("Receive MSG : JNI_NONE");
break;
case JNI_INIT:
EDN_DEBUG("Receive MSG : JNI_INIT");
EWOL_NativeApplicationInit();
break;
case JNI_UN_INIT:
EDN_DEBUG("Receive MSG : JNI_UN_INIT");
EWOL_NativeApplicationUnInit();
requestEndProcessing = true;
break;
case JNI_DONE:
EDN_DEBUG("Receive MSG : JNI_DONE");
break;
case JNI_RESIZE:
EDN_DEBUG("Receive MSG : JNI_RESIZE");
{
eventResize_ts * tmpData = (eventResize_ts*)data.data;
EWOL_NativeResize(tmpData->w, tmpData->h);
EWOL_NativeInit();
}
break;
case JNI_INPUT_MOTION:
EDN_DEBUG("Receive MSG : JNI_INPUT_MOTION");
{
eventInputMotion_ts * tmpData = (eventInputMotion_ts*)data.data;
EWOL_NativeEventInputMotion(tmpData->pointerID, tmpData->x, tmpData->y);
}
break;
case JNI_INPUT_STATE:
EDN_DEBUG("Receive MSG : JNI_INPUT_STATE");
{
eventInputState_ts * tmpData = (eventInputState_ts*)data.data;
EWOL_NativeEventInputState(tmpData->pointerID, tmpData->state, tmpData->x, tmpData->y);
}
break;
case JNI_DATA_ARCHIVE_DIR:
EDN_DEBUG("Receive MSG : JNI_DATA_ARCHIVE_DIR");
break;
case JNI_APP_INIT:
EDN_DEBUG("Receive MSG : JNI_APP_INIT");
break;
case JNI_APP_UN_INIT:
EDN_DEBUG("Receive MSG : JNI_APP_UN_INIT");
break;
case JNI_APP_RENDERER:
EDN_DEBUG("Receive MSG : JNI_APP_RENDERER");
break;
default:
EDN_DEBUG("Receive MSG : UNKNOW");
break;
}
}
EDN_DEBUG("End Ewol Basic thread ...");
// unset all windows
ewol::DisplayWindows(NULL);
// call application to uninit
APP_UnInit();
// basic abstraction un-init
guiAbstraction::UnInit();
// uninit Ewol
ewol::UnInit();
pthread_exit(NULL);
}
void EWOL_ThreadSetArchiveDir(int mode, const char* str)
{
switch(mode)
{
case 0:
EWOL_DEBUG("Directory APK : path=" << str);
//if (firstInitDone == false)
{
etk::SetBaseFolderData(str);
}
break;
case 1:
EWOL_DEBUG("Directory mode=FILE path=" << str);
//if (firstInitDone == false)
{
etk::SetBaseFolderDataUser(str);
}
break;
case 2:
EWOL_DEBUG("Directory mode=CACHE path=" << str);
//if (firstInitDone == false)
{
etk::SetBaseFolderCache(str);
}
break;
case 3:
EWOL_DEBUG("Directory mode=EXTERNAL_CACHE path=" << str);
break;
default:
EWOL_DEBUG("Directory mode=???? path=" << str);
break;
}
}
bool isGlobalSystemInit = false;
void EWOL_SystemStart(void)
{
if (false == isGlobalSystemInit) {
// create interface mutex :
ewol::threadMsg::Init(androidJniMsg);
// init the thread :
pthread_create(&androidJniThread, NULL, BaseAppEntry, NULL);
isGlobalSystemInit = true;
ewol::threadMsg::SendMessage(androidJniMsg, JNI_INIT, ewol::threadMsg::MSG_PRIO_REAL_TIME);
}
}
void EWOL_SystemStop(void)
{
if (true == isGlobalSystemInit) {
isGlobalSystemInit = false;
ewol::threadMsg::SendMessage(androidJniMsg, JNI_UN_INIT, ewol::threadMsg::MSG_PRIO_REAL_TIME);
EDN_DEBUG("Wait end of the thread ...");
// Wait end of the thread
pthread_join(androidJniThread, NULL);
ewol::threadMsg::UnInit(androidJniMsg);
}
}
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 )
{
}

View File

@ -0,0 +1,44 @@
/**
*******************************************************************************
* @file MainThread.h
* @brief Main Ewol thread for the abstraction of the OS problematics (Header)
* @author Edouard DUPIN
* @date 27/01/2012
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __EWOL_MAIN_TREAD_H__
#define __EWOL_MAIN_TREAD_H__
#include <pthread.h>
void EWOL_SystemStart(void);
void EWOL_SystemStop(void);
void EWOL_ThreadSetArchiveDir(int mode, const char* str);
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 );
#endif

View File

@ -238,95 +238,10 @@ void EWOL_NativeEventInputState(int pointerID, bool isUp, float x, float y )
} }
} }
void EWOL_NativeEventUnknow(int eventID)
{
EWOL_WARNING("Event : Unknow ID=" << eventID);
}
void EWOL_NativeParamSetArchiveDir(int mode, const char* str)
{
switch(mode)
{
case 0:
EWOL_DEBUG("Directory APK : path=" << str);
//if (firstInitDone == false)
{
etk::SetBaseFolderData(str);
}
break;
case 1:
EWOL_DEBUG("Directory mode=FILE path=" << str);
//if (firstInitDone == false)
{
etk::SetBaseFolderDataUser(str);
}
break;
case 2:
EWOL_DEBUG("Directory mode=CACHE path=" << str);
//if (firstInitDone == false)
{
etk::SetBaseFolderCache(str);
}
break;
case 3:
EWOL_DEBUG("Directory mode=EXTERNAL_CACHE path=" << str);
break;
default:
EWOL_DEBUG("Directory mode=???? path=" << str);
break;
}
}
static bool isAlreadyInit = false;
void EWOL_NativeApplicationInit(void)
{
int64_t time = GetCurrentTime();
EWOL_WARNING("Event : Init Application (start)" << time);
if (false == isAlreadyInit) {
guiAbstraction::Init(0, NULL);
ewol::Init(0, NULL);
APP_Init(0, NULL);
isAlreadyInit = true;
}
time = GetCurrentTime();
EWOL_WARNING("Event : Init Application (end)" << time);
}
void EWOL_NativeApplicationUnInit(void)
{
EWOL_WARNING("Event : UnInit application");
// unset all windows
ewol::DisplayWindows(NULL);
// call application to uninit
APP_UnInit();
// basic abstraction un-init
guiAbstraction::UnInit();
// uninit Ewol
ewol::UnInit();
}
/* Call to render the next GL frame */ /* Call to render the next GL frame */
void EWOL_NativeRender(void) void EWOL_NativeRender(void)
{ {
long curTime;
/* NOTE: if sDemoStopped is TRUE, then we re-render the same frame
* on each iteration.
*/
if (sDemoStopped) {
curTime = sTimeStopped + sTimeOffset;
} else {
curTime =GetCurrentTime() + sTimeOffset;
if (sTimeOffsetInit == 0) {
sTimeOffsetInit = 1;
sTimeOffset = -curTime;
curTime = 0;
}
}
Draw(); Draw();
} }