Build for windows ==> work with wine

Add mutex and semaphore abstraction
Add basic windows gui starting ==> no input ... as bad as a first think
use generic makefile
add a basic entry point for the zlib
This commit is contained in:
Edouard Dupin 2012-08-15 20:56:16 +02:00
parent 14e7b44650
commit d75f9e97a1
37 changed files with 1012 additions and 142 deletions

3
.gitmodules vendored
View File

@ -28,3 +28,6 @@
[submodule "Sources/libfreetype"]
path = Sources/libfreetype
url = https://github.com/HeeroYui/libfreetype.git
[submodule "Sources/libz/zlib"]
path = Sources/libz/zlib
url = https://github.com/madler/zlib.git

2
Build

@ -1 +1 @@
Subproject commit a4e9c62eeb13e6c08c61953185bfb6b82c543530
Subproject commit 3db5b49b02a5f2fea62b6113d3e01efd5974cc3c

@ -1 +1 @@
Subproject commit d8531a3a7cc0e873b895246d16db9ad6ef15d93b
Subproject commit 375af92e27d48c9d6678be26f11182477a36e77d

View File

@ -1,33 +0,0 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := etk
LOCAL_STATIC_LIBRARIES := libzip
# load the common sources file of the platform
include $(LOCAL_PATH)/file.mk
LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
ifeq ($(DEBUG),1)
LOCAL_CFLAGS := -Wno-write-strings \
-Wall
else
LOCAL_CFLAGS := -Wno-write-strings \
-DMODE_RELEASE
endif
LOCAL_SRC_FILES := $(FILE_LIST)
# Ewol Test Software :
LOCAL_LDLIBS := -lGLESv1_CM -ldl -llog -lz
include $(BUILD_STATIC_LIBRARY)

View File

@ -23,4 +23,6 @@ LOCAL_SRC_FILES := $(FILE_LIST)
include $(BUILD_STATIC_LIBRARY)

View File

@ -80,4 +80,5 @@ etk::logLevel_te g_requestedLevel = etk::LOG_LEVEL_ERROR;
#endif
void GeneralDebugSetLevel(etk::logLevel_te ccc) {
g_requestedLevel = ccc;
}
}

View File

@ -399,7 +399,11 @@ void etk::File::SetCompleateName(etk::UString &newFilename, etk::FileType_te typ
TK_VERBOSE("3 : Get file Name : " << destFilename );
if (true == needUnpack) {
// Get the real Path of the current File
ok = realpath(destFilename.c_str(), buf);
#ifdef __TARGET_OS__Windows
ok = 0;
#else
ok = realpath(destFilename.c_str(), buf);
#endif
if (!ok) {
int32_t lastPos = destFilename.FindBack('/');
if (-1 != lastPos) {
@ -407,7 +411,11 @@ void etk::File::SetCompleateName(etk::UString &newFilename, etk::FileType_te typ
etk::UString tmpFilename = destFilename.Extract(lastPos+1);
destFilename.Remove(lastPos, destFilename.Size() - lastPos);
TK_VERBOSE("try to find :\"" << destFilename << "\" / \"" << tmpFilename << "\" ");
ok = realpath(destFilename.c_str(), buf);
#ifdef __TARGET_OS__Windows
ok = 0;
#else
ok = realpath(destFilename.c_str(), buf);
#endif
if (!ok) {
TK_VERBOSE("Can not find real Path name of \"" << destFilename << "\"");
m_shortFilename = tmpFilename;

View File

@ -0,0 +1,60 @@
/**
*******************************************************************************
* @file etk/Mutex.Generic.cpp
* @brief Ewol Tool Kit : basic mutex system (Sources) ==> Pthread implementation
* @author Edouard DUPIN
* @date 15/08/2012
* @par Project
* Ewol TK
*
* @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 <etk/Mutex.h>
#include <etk/DebugInternal.h>
etk::Mutex::Mutex(void)
{
// create interface mutex :
int ret = pthread_mutex_init(&m_mutex, NULL);
TK_ASSERT(ret == 0, "Error creating Mutex ...");
}
etk::Mutex::~Mutex(void)
{
// Remove mutex
int ret = pthread_mutex_destroy(&m_mutex);
TK_ASSERT(ret == 0, "Error destroying Mutex ...");
}
void etk::Mutex::Lock(void)
{
pthread_mutex_lock(&m_mutex);
}
bool etk::Mutex::TryLock(void)
{
return pthread_mutex_trylock(&m_mutex) != 0;
}
void etk::Mutex::UnLock(void)
{
pthread_mutex_unlock(&m_mutex);
}

View File

@ -0,0 +1,55 @@
/**
*******************************************************************************
* @file etk/Mutex.Windows.cpp
* @brief Ewol Tool Kit : basic mutex system (Sources) ==> windows implementation
* @author Edouard DUPIN
* @date 15/08/2012
* @par Project
* Ewol TK
*
* @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 <etk/Mutex.h>
etk::Mutex::Mutex(void)
{
InitializeCriticalSection(&m_mutex);
}
etk::Mutex::~Mutex(void)
{
DeleteCriticalSection(&m_mutex);
}
void etk::Mutex::Lock(void)
{
EnterCriticalSection(&m_mutex);
}
bool etk::Mutex::TryLock(void)
{
return TryEnterCriticalSection(&m_mutex) != 0;
}
void etk::Mutex::UnLock(void)
{
LeaveCriticalSection(&m_mutex);
}

View File

@ -0,0 +1,56 @@
/**
*******************************************************************************
* @file etk/Mutex.h
* @brief Ewol Tool Kit : basic mutex system (header)
* @author Edouard DUPIN
* @date 15/08/2012
* @par Project
* Ewol TK
*
* @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 __ETK_MUTEX_H__
#define __ETK_MUTEX_H__
#include <etk/Types.h>
#ifdef __TARGET_OS__Windows
#include <windows.h>
#else
#include <pthread.h>
#endif
namespace etk
{
class Mutex
{
private:
#ifdef __TARGET_OS__Windows
CRITICAL_SECTION m_mutex;
#else
pthread_mutex_t m_mutex;
#endif
public:
Mutex(void);
~Mutex(void);
void Lock(void);
bool TryLock(void);
void UnLock(void);
};
};
#endif

View File

@ -0,0 +1,111 @@
/**
*******************************************************************************
* @file etk/Semaphore.Generic.cpp
* @brief Ewol Tool Kit : basic semaphore system (Sources) ==> Pthread implementation
* @author Edouard DUPIN
* @date 15/08/2012
* @par Project
* Ewol TK
*
* @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 <etk/Semaphore.h>
#include <etk/DebugInternal.h>
#include <sys/time.h>
etk::Semaphore::Semaphore(uint32_t nbBasicElement, uint32_t nbMessageMax)
{
// create interface mutex :
int ret = pthread_mutex_init(&m_mutex, NULL);
TK_ASSERT(ret == 0, "Error creating Mutex ...");
// create contition :
ret = pthread_cond_init(&m_condition, NULL);
TK_ASSERT(ret == 0, "Error creating Condition ...");
if (ret != 0) {
ret = pthread_mutex_destroy(&m_mutex);
TK_ASSERT(ret == 0, "Error destroying Mutex ...");
}
m_maximum = nbMessageMax;
m_data = nbBasicElement;
}
etk::Semaphore::~Semaphore(void)
{
// Remove condition
int ret = pthread_cond_destroy(&m_condition);
TK_ASSERT(ret == 0, "Error destroying Condition ...");
// Remove Mutex
ret = pthread_mutex_destroy(&m_mutex);
TK_ASSERT(ret == 0, "Error destroying Mutex ...");
}
uint32_t etk::Semaphore::GetCount(void)
{
int32_t tmpData = 0;
pthread_mutex_lock(&m_mutex);
tmpData = m_data;
pthread_mutex_unlock(&m_mutex);
return tmpData;
}
void etk::Semaphore::Post(void)
{
pthread_mutex_lock(&m_mutex);
if (m_data>=m_maximum) {
m_data = m_maximum;
} else {
m_data++;
}
// send message
pthread_cond_broadcast(&m_condition);
pthread_mutex_unlock(&m_mutex);
}
void etk::Semaphore::Wait(void)
{
pthread_mutex_lock(&m_mutex);
while(m_data == 0) {
pthread_cond_wait(&m_condition, &m_mutex);
}
m_data--;
pthread_mutex_unlock(&m_mutex);
}
bool etk::Semaphore::Wait(uint32_t timeOutInUs)
{
pthread_mutex_lock(&m_mutex);
if(m_data == 0) {
struct timeval tp;
struct timespec ts;
gettimeofday(&tp,NULL);
uint64_t totalTimeUS = tp.tv_sec * 1000000 + tp.tv_usec;
totalTimeUS += timeOutInUs;
ts.tv_sec = totalTimeUS / 1000000;
ts.tv_nsec = (totalTimeUS%1000000) * 1000;
int ret = pthread_cond_timedwait(&m_condition, &m_mutex, &ts);
if (ret !=0) { //== ETIMEOUT) {
pthread_mutex_unlock(&m_mutex);
return false;
}
}
m_data--;
pthread_mutex_unlock(&m_mutex);
return true;
}

View File

@ -0,0 +1,70 @@
/**
*******************************************************************************
* @file etk/Semaphore.Generic.cpp
* @brief Ewol Tool Kit : basic semaphore system (Sources) ==> Pthread implementation
* @author Edouard DUPIN
* @date 15/08/2012
* @par Project
* Ewol TK
*
* @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 <etk/Semaphore.h>
#include <etk/DebugInternal.h>
etk::Semaphore::Semaphore(uint32_t nbBasicElement, uint32_t nbMessageMax)
{
// create interface mutex :
m_semaphore = CreateSemaphore(NULL, nbBasicElement, nbMessageMax, NULL);
TK_ASSERT(m_semaphore != 0, "Error creating SEMAPHORE ...");
}
etk::Semaphore::~Semaphore(void)
{
CloseHandle(m_semaphore);
}
uint32_t etk::Semaphore::GetCount(void)
{
LONG tmpData = 0;
ReleaseSemaphore(m_semaphore, 0, &tmpData);
return tmpData;
}
void etk::Semaphore::Post(void)
{
ReleaseSemaphore(m_semaphore, 1, NULL);
}
void etk::Semaphore::Wait(void)
{
WaitForSingleObject(m_semaphore, INFINITE);
}
bool etk::Semaphore::Wait(uint32_t timeOutInUs)
{
DWORD result = WaitForSingleObject(m_semaphore, timeOutInUs);
if (result == WAIT_FAILED) {
TK_ERROR("Failed to wait for semaphore ");
return false;
} else {
return result == WAIT_OBJECT_0;
}
}

View File

View File

@ -0,0 +1,61 @@
/**
*******************************************************************************
* @file etk/Semaphore.h
* @brief Ewol Tool Kit : basic semaphore system (header)
* @author Edouard DUPIN
* @date 15/08/2012
* @par Project
* Ewol TK
*
* @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 __ETK_SEMAPHORE_H__
#define __ETK_SEMAPHORE_H__
#include <etk/Types.h>
#ifdef __TARGET_OS__Windows
#include <windows.h>
#else
#include <pthread.h>
#endif
namespace etk
{
class Semaphore
{
private:
#ifdef __TARGET_OS__Windows
HANDLE m_semaphore;
#else
pthread_mutex_t m_mutex;
pthread_cond_t m_condition;
uint32_t m_data;
uint32_t m_maximum;
#endif
public:
Semaphore(uint32_t nbBasicElement=0, uint32_t nbMessageMax=1);
~Semaphore(void);
uint32_t GetCount(void);
void Post(void);
void Wait(void);
// wait with a timeout in us; return true if get the semaphore
bool Wait(uint32_t timeOutInUs);
};
};
#endif

View File

@ -29,8 +29,8 @@
//#include <cstdio>
//#include <typeinfo>
#include <string.h>
#include <pthread.h>
#include <etk/Types.h>
#include <etk/Mutex.h>
#if defined(__TARGET_OS__Android)
# include <android/log.h>
@ -95,15 +95,14 @@ namespace etk{
bool hex;
char m_tmpChar[MAX_LOG_SIZE+1];
char tmp[MAX_LOG_SIZE_TMP];
pthread_mutex_t m_mutex;
etk::Mutex m_mutex;
public:
CCout(){
hex=false;
memset(m_tmpChar, 0, (MAX_LOG_SIZE+1)*sizeof(char));
pthread_mutex_init(&m_mutex, NULL);
};
~CCout() {
pthread_mutex_destroy(&m_mutex);
};
CCout& operator << (int t) {
@ -193,7 +192,7 @@ namespace etk{
return *this;
}
CCout& operator << (CStart ccc) {
pthread_mutex_lock(&m_mutex);
m_mutex.Lock();
return *this;
}
CCout& operator << (logLevel_te ccc) {
@ -239,7 +238,7 @@ namespace etk{
printf("%s", m_tmpChar);
#endif
memset(m_tmpChar, 0, (MAX_LOG_SIZE+1)*sizeof(char));
pthread_mutex_unlock(&m_mutex);
m_mutex.UnLock();
return *this;
}
};

View File

@ -13,4 +13,10 @@ FILE_LIST = \
etk/Color.cpp \
etk/tool.cpp
ifeq ("$(TARGET_OS)","Windows")
FILE_LIST += etk/Mutex.Windows.cpp
FILE_LIST += etk/Semaphore.Windows.cpp
else
FILE_LIST += etk/Mutex.Generic.cpp
FILE_LIST += etk/Semaphore.Generic.cpp
endif

View File

@ -0,0 +1,36 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
# name of the librairy
LOCAL_MODULE := ewol
# get the tag of the current project :
LOCAL_VERSION_TAG=$(shell cd $(LOCAL_PATH) ; git describe --tags)
LOCAL_VERSION_TAG_SHORT=$(shell cd $(LOCAL_PATH) ; git describe --tags --abbrev=0)
$(info $(LOCAL_MODULE) version TAG : $(LOCAL_VERSION_TAG))
# name of the dependency
LOCAL_STATIC_LIBRARIES := etk freetype tinyxml libzip libpng agg parsersvg lua zlib
LOCAL_C_INCLUDES :=
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
LOCAL_EXPORT_LDLIBS := -lopengl32 -lgdi32
LOCAL_CFLAGS := -Wno-write-strings \
-DEWOL_VERSION_TAG_NAME="\"$(LOCAL_VERSION_TAG_SHORT)-$(BUILD_DIRECTORY_MODE)\"" \
-DLUA_COMPAT_ALL \
-Wall
# load the common sources file of the platform
include $(LOCAL_PATH)/file.mk
LOCAL_SRC_FILES := $(FILE_LIST) ewol/base/guiWindows.cpp
# Ewol Test Software :
LOCAL_LDLIBS :=
include $(BUILD_STATIC_LIBRARY)

View File

@ -133,10 +133,10 @@ void guiAbstraction::SendKeyboardEventMove(bool isDown, ewol::eventKbMoveType_te
static int64_t startTime = -1;
static int64_t nbCallTime = 0;
static int64_t nbDisplayTime = 0;
static int64_t min = 99999999999999;
static int64_t min = 99999999999999LL;
static int64_t avg = 0;
static int64_t max = 0;
static int64_t min2 = 99999999999999;
static int64_t min2 = 99999999999999LL;
static int64_t avg2 = 0;
static int64_t max2 = 0;
// display every second ...
@ -282,8 +282,8 @@ void EWOL_GenericDraw(bool everyTime)
<< (float)((float)max2 / 1000.0) << "ms ");
max2 = 0;
max = 0;
min = 99999999999999;
min2 = 99999999999999;
min = 99999999999999LL;
min2 = 99999999999999LL;
avg=0;
avg2=0;

View File

@ -0,0 +1,389 @@
/**
*******************************************************************************
* @file guiWindows.cpp
* @brief Gui abstraction layer for windows (Sources)
* @author Edouard DUPIN
* @date 20/10/2011
* @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/Debug.h>
#include <ewol/ewol.h>
#include <etk/UString.h>
#include <etk/unicode.h>
#include <ewol/WidgetManager.h>
#include <ewol/base/gui.h>
#include <ewol/Texture.h>
#include <ewol/Texture/TextureBMP.h>
#include <ewol/base/MainThread.h>
#include <ewol/threadMsg.h>
#include <ewol/importgl.h>
int32_t separateClickTime = 300000;
int32_t offsetMoveClicked = 10000;
int32_t offsetMoveClickedDouble = 20000;
void ewol::SetTitle(etk::UString title)
{
// TODO ...
}
void EWOL_NativeRender(void)
{
EWOL_GenericDraw(false);
glFlush();
}
static etk::Vector<etk::UString*> listArgs;
int32_t ewol::CmdLineNb(void)
{
return listArgs.Size();
}
etk::UString ewol::CmdLineGet(int32_t id)
{
if (id<0 && id>=listArgs.Size()) {
return "";
}
if (NULL == listArgs[id]) {
return "";
}
return *listArgs[id];
}
#undef __class__
#define __class__ "guiAbstraction"
bool m_run = true;
void guiAbstraction::Stop(void)
{
m_run = false;
}
void guiAbstraction::KeyboardShow(ewol::keyboardMode_te mode)
{
// nothing to do : No keyboard on computer ...
}
void guiAbstraction::KeyboardHide(void)
{
// nothing to do : No keyboard on computer ...
}
void guiAbstraction::ChangeSize(int32_t w, int32_t h)
{
}
void guiAbstraction::ChangePos(int32_t x, int32_t y)
{
}
void guiAbstraction::GetAbsPos(int32_t & x, int32_t & y)
{
}
bool guiAbstraction::IsPressedInput(int32_t inputID)
{
return false;
}
// ClipBoard AREA :
etk::UString l_clipBoardStd("");
etk::UString l_clipBoardPrimary("");
void guiAbstraction::ClipBoardGet(etk::UString &newData, clipBoardMode_te mode)
{
#ifdef DEBUG_X11_EVENT
EWOL_INFO("Request Get of a clipboard : " << mode << " size=" << newData.Size() );
#endif
newData = "";
switch (mode)
{
case CLIPBOARD_MODE_PRIMARY:
// get our own buffer ...
newData = l_clipBoardPrimary;
break;
case CLIPBOARD_MODE_STD:
// get our own buffer ...
newData = l_clipBoardStd;
break;
default:
EWOL_ERROR("Request an unknow ClipBoard ...");
break;
}
}
void guiAbstraction::ClipBoardSet(etk::UString &newData, clipBoardMode_te mode)
{
#ifdef DEBUG_X11_EVENT
EWOL_INFO("Request set of a clipboard : " << mode << " size=" << newData.Size() );
#endif
switch (mode)
{
case CLIPBOARD_MODE_PRIMARY:
if (newData.Size() > 0) {
// copy it ...
l_clipBoardPrimary = newData;
}
break;
case CLIPBOARD_MODE_STD:
if (newData.Size() > 0) {
// copy it ...
l_clipBoardStd = newData;
}
break;
default:
EWOL_ERROR("Request an unknow ClipBoard ...");
break;
}
}
// might be declared by the application ....
etk::File APP_Icon(void);
#include <windows.h>
#include <windowsx.h>
// Function Declarations
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
void EnableOpenGL(HWND hWnd, HDC * hDC, HGLRC * hRC);
void DisableOpenGL(HWND hWnd, HDC hDC, HGLRC hRC);
int plop(void);
int main(int argc, char *argv[])
{
for( int32_t i=1 ; i<argc; i++) {
EWOL_INFO("CmdLine : \"" << argv[i] << "\"" );
if (0==strncmp("-l0", argv[i], 256)) {
GeneralDebugSetLevel(etk::LOG_LEVEL_NONE);
} else if (0==strncmp("-l1", argv[i], 256)) {
GeneralDebugSetLevel(etk::LOG_LEVEL_CRITICAL);
} else if (0==strncmp("-l2", argv[i], 256)) {
GeneralDebugSetLevel(etk::LOG_LEVEL_ERROR);
} else if (0==strncmp("-l3", argv[i], 256)) {
GeneralDebugSetLevel(etk::LOG_LEVEL_WARNING);
} else if (0==strncmp("-l4", argv[i], 256)) {
GeneralDebugSetLevel(etk::LOG_LEVEL_INFO);
} else if (0==strncmp("-l5", argv[i], 256)) {
GeneralDebugSetLevel(etk::LOG_LEVEL_DEBUG);
} else if (0==strncmp("-l6", argv[i], 256)) {
GeneralDebugSetLevel(etk::LOG_LEVEL_VERBOSE);
} else {
etk::UString* tmpString = new etk::UString(argv[i]);
if (NULL != tmpString) {
listArgs.PushBack(tmpString);
}
}
}
// start X11 thread ...
// TODO : ...
//start the basic thread :
guiSystem::Init();
// get the icon file :
etk::File myIcon = APP_Icon();
//SetIcon(myIcon);
// Run ...
plop();
// close X11 :
guiAbstraction::Stop();
// uninit ALL :
guiSystem::UnInit();
for (int32_t iii=0; iii<listArgs.Size(); iii++) {
if (NULL != listArgs[iii]) {
delete listArgs[iii];
listArgs[iii] = NULL;
}
}
listArgs.Clear();
return 0;
}
// WinMain
int plop(void)
{
HINSTANCE hInstance = 0;
HINSTANCE hPrevInstance = 0;
WNDCLASS wc;
HWND hWnd;
HDC hDC;
HGLRC hRC;
MSG msg;
BOOL quit = FALSE;
float theta = 0.0f;
// register window class
wc.style = CS_OWNDC;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );
wc.hCursor = LoadCursor( NULL, IDC_ARROW );
wc.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH );
wc.lpszMenuName = NULL;
wc.lpszClassName = "EwolMainWindows";
RegisterClass( &wc );
// create main window
hWnd = CreateWindow( "EwolMainWindows", "Ewol ... TODO Title",
WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE | WS_SIZEBOX,
0, 0, 800, 600,
NULL, NULL, hInstance, NULL );
guiSystem::event::Resize(800, 600-25);
// enable OpenGL for the window
EnableOpenGL( hWnd, &hDC, &hRC );
// program main loop
while(true == m_run) {
// check for messages
if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE )) {
// handle or dispatch messages
if ( msg.message == WM_QUIT ) {
m_run = false;
} else {
TranslateMessage( &msg );
DispatchMessage( &msg );
}
} else {
EWOL_DEBUG("DRAW ... ");
guiSystem::Draw();
SwapBuffers( hDC );
}
}
// shutdown OpenGL
DisableOpenGL( hWnd, hDC, hRC );
// destroy the window explicitly
DestroyWindow( hWnd );
return msg.wParam;
}
// Window Procedure
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_CREATE:
EWOL_DEBUG("WM_CREATE");
return 0;
case WM_CLOSE:
EWOL_DEBUG("WM_CLOSE");
PostQuitMessage( 0 );
return 0;
case WM_DESTROY:
EWOL_DEBUG("WM_DESTROY");
return 0;
case WM_KEYDOWN:
EWOL_DEBUG("WM_KEYDOWN");
switch ( wParam ) {
case VK_ESCAPE:
PostQuitMessage(0);
return 0;
}
return 0;
case WM_MOVE:
EWOL_DEBUG("WM_MOVE");
return 0;
case WM_SIZE:
EWOL_DEBUG("WM_SIZE");
return 0;
case WM_MOUSEMOVE:
{
int32_t posX = GET_X_LPARAM(lParam);
int32_t posY = GET_Y_LPARAM(lParam);
EWOL_DEBUG("WM_MOUSEMOVE : (" << posX << "," << posY << ")");
}
return 0;
default:
EWOL_DEBUG("event ..." << message );
return DefWindowProc( hWnd, message, wParam, lParam );
}
}
// Enable OpenGL
void EnableOpenGL(HWND hWnd, HDC * hDC, HGLRC * hRC)
{
PIXELFORMATDESCRIPTOR pfd;
int format;
// get the device context (DC)
*hDC = GetDC( hWnd );
// set the pixel format for the DC
ZeroMemory( &pfd, sizeof( pfd ) );
pfd.nSize = sizeof( pfd );
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 24;
pfd.cDepthBits = 16;
pfd.iLayerType = PFD_MAIN_PLANE;
format = ChoosePixelFormat( *hDC, &pfd );
SetPixelFormat( *hDC, format, &pfd );
// create and enable the render context (RC)
*hRC = wglCreateContext( *hDC );
wglMakeCurrent( *hDC, *hRC );
}
// Disable OpenGL
void DisableOpenGL(HWND hWnd, HDC hDC, HGLRC hRC)
{
wglMakeCurrent( NULL, NULL );
wglDeleteContext( hRC );
ReleaseDC( hWnd, hDC );
}

View File

@ -436,6 +436,9 @@ void X11_Init(void)
#ifdef DEBUG_X11_EVENT
EWOL_INFO("X11:INIT");
#endif
if (m_doubleBuffered) {
glXSwapBuffers(m_display, WindowHandle);
}
m_visual = NULL;
m_previousBouttonId = 0;
m_previousDown_x = -1;
@ -1231,7 +1234,6 @@ int main(int argc, char *argv[])
X11_Init();
//start the basic thread :
guiSystem::Init();
usleep(500);
// get the icon file :
etk::File myIcon = APP_Icon();
SetIcon(myIcon);

View File

@ -81,7 +81,9 @@ namespace ewol {
etk::UString GetVersion(void);
};
// get current time in ms...
int64_t GetCurrentTime(void);
#ifndef __TARGET_OS__Windows
int64_t GetCurrentTime(void);
#endif
#else

View File

@ -12,7 +12,7 @@ extern "C" {
#elif defined(__TARGET_OS__Android)
#include <GLES/gl.h>
#elif defined(__TARGET_OS__Windows)
#include <GL/gl.h>
#elif defined(__TARGET_OS__MacOs)
#elif defined(__TARGET_OS__IOs)

View File

@ -30,21 +30,10 @@
void ewol::threadMsg::Init(ewol::threadMsg::threadMsg_ts& messageData)
{
// create interface mutex :
int ret = pthread_mutex_init(&messageData.mutex, NULL);
EWOL_ASSERT(ret == 0, "Error creating Mutex ...");
// create contition :
ret = pthread_cond_init(&messageData.condition, NULL);
EWOL_ASSERT(ret == 0, "Error creating Condition ...");
if (ret != 0) {
ret = pthread_mutex_destroy(&messageData.mutex);
EWOL_ASSERT(ret == 0, "Error destroying Mutex ...");
} else {
for (int32_t iii=0; MSG_PRIO_NUMBER>iii; iii++) {
messageData.nbMessages[iii] = 0;
for (int32_t jjj=0; NUMBER_OF_ELEMENT_IN_THE_FIFO>jjj; jjj++) {
messageData.listOfMessages[iii][jjj].isActive = false;
}
for (int32_t iii=0; MSG_PRIO_NUMBER>iii; iii++) {
messageData.nbMessages[iii] = 0;
for (int32_t jjj=0; NUMBER_OF_ELEMENT_IN_THE_FIFO>jjj; jjj++) {
messageData.listOfMessages[iii][jjj].isActive = false;
}
}
messageData.isInit = true;
@ -53,12 +42,6 @@ void ewol::threadMsg::Init(ewol::threadMsg::threadMsg_ts& messageData)
void ewol::threadMsg::UnInit(ewol::threadMsg::threadMsg_ts& messageData)
{
if (true == messageData.isInit) {
// Remove Mutex
int ret = pthread_cond_destroy(&messageData.condition);
EWOL_ASSERT(ret == 0, "Error destroying Condition ...");
// Remove condition
ret = pthread_mutex_destroy(&messageData.mutex);
EWOL_ASSERT(ret == 0, "Error destroying Mutex ...");
// remove data ????
messageData.isInit = false;
}
@ -69,7 +52,7 @@ bool ewol::threadMsg::WaitMessage(ewol::threadMsg::threadMsg_ts& messageData, ew
if (false == messageData.isInit) {
return false;
}
pthread_mutex_lock(&messageData.mutex);
messageData.m_mutex.Lock();
bool findAnOtherMessageInStack = false;
for (int32_t iii=0; MSG_PRIO_NUMBER>iii; iii++) {
if (0 < messageData.nbMessages[iii]) {
@ -77,7 +60,9 @@ bool ewol::threadMsg::WaitMessage(ewol::threadMsg::threadMsg_ts& messageData, ew
}
}
if (false == findAnOtherMessageInStack) {
pthread_cond_wait(&messageData.condition, &messageData.mutex);
messageData.m_mutex.UnLock();
messageData.m_semaphore.Wait();
messageData.m_mutex.Lock();
}
// find the message :
for (int32_t iii=0; MSG_PRIO_NUMBER>iii; iii++) {
@ -114,7 +99,7 @@ bool ewol::threadMsg::WaitMessage(ewol::threadMsg::threadMsg_ts& messageData, ew
break;
}
}
pthread_mutex_unlock(&messageData.mutex);
messageData.m_mutex.UnLock();
return true;
}
@ -131,7 +116,7 @@ bool ewol::threadMsg::SendMessage(ewol::threadMsg::threadMsg_ts& messageData, ui
EWOL_ERROR("Send message with an biger size than predictible " << size << " > " << MAX_MSG_DATA_SIZE);
return false;
}
pthread_mutex_lock(&messageData.mutex);
messageData.m_mutex.Lock();
int32_t lastNbMessage = messageData.nbMessages[prio];
for (int32_t jjj=0; NUMBER_OF_ELEMENT_IN_THE_FIFO>jjj; jjj++) {
if (messageData.listOfMessages[prio][jjj].isActive == false) {
@ -161,8 +146,8 @@ bool ewol::threadMsg::SendMessage(ewol::threadMsg::threadMsg_ts& messageData, ui
EWOL_ERROR("Send message Add error");
returnValue = false;
}
pthread_cond_broadcast(&messageData.condition);
pthread_mutex_unlock(&messageData.mutex);
messageData.m_semaphore.Post();
messageData.m_mutex.UnLock();
return returnValue;
}
@ -171,12 +156,12 @@ int32_t ewol::threadMsg::WaitingMessage(threadMsg_ts& messageData)
if (false == messageData.isInit) {
return false;
}
pthread_mutex_lock(&messageData.mutex);
messageData.m_mutex.Lock();
int32_t nbMessage = 0;
for (int32_t iii=0; MSG_PRIO_NUMBER>iii; iii++) {
nbMessage += messageData.nbMessages[iii];
}
pthread_mutex_unlock(&messageData.mutex);
messageData.m_mutex.UnLock();
return nbMessage;
}
@ -193,10 +178,10 @@ void ewol::threadMsg::SendDisplayDone(threadMsg_ts& messageData)
if (false == messageData.isInit) {
return;
}
pthread_mutex_lock(&messageData.mutex);
messageData.m_mutex.Lock();
messageData.displayHasDone = true;
pthread_cond_broadcast(&messageData.condition);
pthread_mutex_unlock(&messageData.mutex);
messageData.m_semaphore.Post();
messageData.m_mutex.UnLock();
}
@ -207,10 +192,10 @@ bool ewol::threadMsg::HasDisplayDone(threadMsg_ts& messageData)
return false;
}
bool state = false;
pthread_mutex_lock(&messageData.mutex);
messageData.m_mutex.Lock();
state = messageData.displayHasDone;
messageData.displayHasDone = false;;
pthread_mutex_unlock(&messageData.mutex);
messageData.m_mutex.UnLock();
return state;
}
@ -222,30 +207,13 @@ bool ewol::threadMsg::HasDisplayDone(threadMsg_ts& messageData)
void ewol::simpleMsg::Init(ewol::simpleMsg::simpleMsg_ts& handle)
{
// create interface mutex :
int ret = pthread_mutex_init(&handle.mutex, NULL);
EWOL_ASSERT(ret == 0, "Error creating Mutex ...");
// create contition :
ret = pthread_cond_init(&handle.condition, NULL);
EWOL_ASSERT(ret == 0, "Error creating Condition ...");
if (ret != 0) {
ret = pthread_mutex_destroy(&handle.mutex);
EWOL_ASSERT(ret == 0, "Error destroying Mutex ...");
} else {
handle.messageValue = 0;
}
handle.messageValue = 0;
handle.isInit = true;
}
void ewol::simpleMsg::UnInit(ewol::simpleMsg::simpleMsg_ts& handle)
{
if (true == handle.isInit) {
// Remove Mutex
int ret = pthread_cond_destroy(&handle.condition);
EWOL_ASSERT(ret == 0, "Error destroying Condition ...");
// Remove condition
ret = pthread_mutex_destroy(&handle.mutex);
EWOL_ASSERT(ret == 0, "Error destroying Mutex ...");
// remove data ????
handle.isInit = false;
}
@ -256,26 +224,21 @@ uint32_t ewol::simpleMsg::WaitingMessage(ewol::simpleMsg::simpleMsg_ts& handle,
if (false == handle.isInit) {
return 0;
}
pthread_mutex_lock(&handle.mutex);
handle.m_mutex.Lock();
if (0 == handle.messageValue) {
if (timeOut == 0) {
pthread_cond_wait(&handle.condition, &handle.mutex);
} else {
struct timeval now;
struct timespec timeout;
gettimeofday(&now, NULL);
timeout.tv_sec = now.tv_sec + timeOut/1000;
timeout.tv_nsec = now.tv_usec * 1000 + timeOut%1000;
pthread_cond_timedwait(&handle.condition, &handle.mutex, &timeout);
handle.m_mutex.UnLock();
if (handle.m_semaphore.Wait(timeOut)==false) {
return false;
}
handle.m_mutex.Lock();
}
// copy message
int32_t messageCopy = handle.messageValue;
// reset it ...
handle.messageValue = 0;
pthread_mutex_unlock(&handle.mutex);
handle.m_mutex.UnLock();
return messageCopy;
}
@ -284,10 +247,10 @@ void ewol::simpleMsg::SendMessage(ewol::simpleMsg::simpleMsg_ts& handle, uint32_
if (false == handle.isInit) {
return;
}
pthread_mutex_lock(&handle.mutex);
handle.m_mutex.Lock();
handle.messageValue = message;
pthread_cond_broadcast(&handle.condition);
pthread_mutex_unlock(&handle.mutex);
handle.m_semaphore.Post();
handle.m_mutex.UnLock();
}
@ -296,15 +259,13 @@ void ewol::simpleMsg::Clear(simpleMsg_ts& handle)
if (false == handle.isInit) {
return;
}
pthread_mutex_lock(&handle.mutex);
handle.m_mutex.Lock();
if (handle.messageValue !=0) {
struct timespec timeout;
timeout.tv_sec = 0;
timeout.tv_nsec = 0;
pthread_cond_timedwait(&handle.condition, &handle.mutex, &timeout);
handle.m_mutex.UnLock();
handle.m_semaphore.Wait();
return;
}
pthread_mutex_unlock(&handle.mutex);
handle.m_mutex.UnLock();
}

View File

@ -27,7 +27,8 @@
#ifndef __EWOL_TREAD_MSG_H__
#define __EWOL_TREAD_MSG_H__
#include <pthread.h>
#include <etk/Mutex.h>
#include <etk/Semaphore.h>
namespace ewol {
namespace threadMsg {
@ -51,8 +52,8 @@ namespace ewol {
typedef struct {
bool isInit;
pthread_mutex_t mutex;
pthread_cond_t condition;
etk::Mutex m_mutex;
etk::Semaphore m_semaphore;
//etk::Vector<threadMsgContent_ts>
threadMsgContent_ts listOfMessages[MSG_PRIO_NUMBER][NUMBER_OF_ELEMENT_IN_THE_FIFO];
int32_t nbMessages[MSG_PRIO_NUMBER];
@ -72,8 +73,8 @@ namespace ewol {
namespace simpleMsg {
typedef struct {
bool isInit;
pthread_mutex_t mutex;
pthread_cond_t condition;
etk::Mutex m_mutex;
etk::Semaphore m_semaphore;
uint32_t messageValue;
} simpleMsg_ts;

View File

@ -91,6 +91,13 @@ etk::Color ewol::ListFileSystem::GetBasicBG(void) {
return bg;
}
typedef enum {
DIRECTORY_TYPE_NONE,
DIRECTORY_TYPE_FILE,
DIRECTORY_TYPE_LINK,
DIRECTORY_TYPE_FOLDER,
DIRECTORY_TYPE_OTHER,
} typeDiretoryLocal_te;
void ewol::ListFileSystem::RegenerateView(void)
{
@ -130,8 +137,26 @@ void ewol::ListFileSystem::RegenerateView(void)
if (dir != NULL) {
// for each element in the drectory...
while ((ent = readdir(dir)) != NULL) {
typeDiretoryLocal_te localType = DIRECTORY_TYPE_NONE;
#ifdef __TARGET_OS__Windows
if (strchr(ent->d_name, '.') == NULL) {
localType = DIRECTORY_TYPE_FOLDER;
} else {
localType = DIRECTORY_TYPE_FILE;
}
#else
switch(ent->d_type)
{
case DT_DIR:
localType = DIRECTORY_TYPE_FOLDER;
break;
case DT_REG:
localType = DIRECTORY_TYPE_FILE;
break;
}
#endif
if( true==m_showFile
&& DT_REG==ent->d_type) {
&& DIRECTORY_TYPE_FILE==localType) {
if (ent->d_name != NULL) {
etk::UString tmpString(ent->d_name);
if( false==tmpString.StartWith(".")
@ -145,7 +170,7 @@ void ewol::ListFileSystem::RegenerateView(void)
}
}
if( true==m_showFolder
&& DT_DIR==ent->d_type) {
&& DIRECTORY_TYPE_FOLDER==localType) {
if (ent->d_name != NULL) {
etk::UString tmpString(ent->d_name);
//EWOL_DEBUG(" find Folder : \"" << tmpString << "\"(" << tmpString.Size() << ") ?= \"" << ent->d_name << "\"(" << strlen(ent->d_name) );

View File

@ -353,8 +353,11 @@ void ewol::FileChooser::OnReceiveMessage(ewol::EObject * CallerObject, const cha
memset(buf, 0, MAX_FILE_NAME);
char * ok;
EWOL_DEBUG("new PATH : \"" << m_folder << "\"");
ok = realpath(m_folder.c_str(), buf);
#ifdef __TARGET_OS__Windows
ok = 0;
#else
ok = realpath(m_folder.c_str(), buf);
#endif
if (!ok) {
EWOL_ERROR("Error to get the real path");
m_folder = "/";
@ -387,7 +390,11 @@ void ewol::FileChooser::OnReceiveMessage(ewol::EObject * CallerObject, const cha
char * ok;
EWOL_DEBUG("new PATH : \"" << tmpUserFolder << "\"");
ok = realpath(tmpUserFolder.c_str(), buf);
#ifdef __TARGET_OS__Windows
ok = 0;
#else
ok = realpath(tmpUserFolder.c_str(), buf);
#endif
if (!ok) {
EWOL_ERROR("Error to get the real path");
m_folder = "/";

@ -1 +1 @@
Subproject commit 327fc37b923c529f1a8464beb11189e1024524ba
Subproject commit 01864817805c5a43c937753e569ebb15be4f71a5

@ -1 +1 @@
Subproject commit c620bdd5c4d0d42d7f316ccea1623accf56da157
Subproject commit fa4bf3927867e835c7d14d56602f007b39517ad9

@ -1 +1 @@
Subproject commit a65eac6764ec40d4d61ea25c9c80eb32dcdf33a3
Subproject commit 8fadc04e607fccf3550a200545ffc008cfe2f811

@ -1 +1 @@
Subproject commit e2597ef3153d850c3f5e9f0b4a58e86141c56693
Subproject commit 70c27fedadc92931598f52d34903d76078fd5ae3

@ -1 +1 @@
Subproject commit 99e6413c795826d718199b174eec6e79bb7fc8de
Subproject commit c45bed1333b3524fe62dfc2f093eeede80bd4477

@ -1 +1 @@
Subproject commit 4bce0f4864a83963028215282c02422e448fb554
Subproject commit 296634cfe883f1dd3ecc0d1905add999c44e872d

10
Sources/libz/Generic.mk Normal file
View File

@ -0,0 +1,10 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := zlib
LOCAL_LDLIBS := -lz
include $(EXTERN_LIBRARY)

19
Sources/libz/Windows.mk Normal file
View File

@ -0,0 +1,19 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := zlib
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/zlib
LOCAL_CFLAGS := -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN
# load the common sources file of the platform
include $(LOCAL_PATH)/file.mk
LOCAL_SRC_FILES := $(FILE_LIST)
LOCAL_LDLIBS :=
include $(BUILD_STATIC_LIBRARY)

18
Sources/libz/file.mk Normal file
View File

@ -0,0 +1,18 @@
FILE_LIST = zlib/adler32.c \
zlib/crc32.c \
zlib/deflate.c \
zlib/infback.c \
zlib/inffast.c \
zlib/inflate.c \
zlib/inftrees.c \
zlib/trees.c \
zlib/zutil.c \
zlib/compress.c \
zlib/uncompr.c \
zlib/gzclose.c \
zlib/gzlib.c \
zlib/gzread.c \
zlib/gzwrite.c

1
Sources/libz/zlib Submodule

@ -0,0 +1 @@
Subproject commit 30a1c7065dc1dc2c2ed68ed403792b660bfdd805

@ -1 +1 @@
Subproject commit 8735a891b3d2cea043ae6e0c79890d9950f2a8a8
Subproject commit 2e64a66b5f269c15cc2381d921419da68e1f5f3f