Beispiel #1
0
/** 初始化程序数据结构体 */
static void LCUIApp_Init(void)
{
	LCUICond_Init( &MainApp.loop_cond );
	LCUIMutex_Init( &MainApp.loop_changed );
	LCUIMutex_Init( &MainApp.loop_mutex );
	LinkedList_Init( &MainApp.loop_list, sizeof(LCUI_MainLoop));
	LinkedList_SetDataNeedFree( &MainApp.loop_list, FALSE );

	LCUIMutex_Init( &MainApp.task_run_mutex );
	LCUIMutex_Init( &MainApp.task_list_mutex );
	LinkedList_Init( &MainApp.task_list, sizeof(LCUI_Task) );
	LinkedList_SetDestroyFunc( &MainApp.task_list, DestroyTask );
}
Beispiel #2
0
/** 初始化键盘输入模块 */
void LCUIModule_Keyboard_Init( void )
{
	LCUIMutex_Init( &record_mutex );
	LinkedList_Init( &key_state_record, sizeof(key_state) );
#ifdef LCUI_KEYBOARD_DRIVER_LINUX
	LCUIDevice_Add( LCUIKeyboard_Init, LCUIKeyboard_Proc, LCUIKeyboard_Exit );
#endif
}
Beispiel #3
0
void LCUI_InitKeyboard(void)
{
	LCUIMutex_Init(&self.mutex);
	RBTree_Init(&self.state_tree);
	RBTree_OnDestroy(&self.state_tree, free);
	LCUI_BindEvent(LCUI_KEYDOWN, OnKeyboardEvent, NULL, NULL);
	LCUI_BindEvent(LCUI_KEYUP, OnKeyboardEvent, NULL, NULL);
}
Beispiel #4
0
LCUI_Worker LCUIWorker_New( void )
{
	LCUI_Worker worker = NEW( LCUI_WorkerRec, 1 );
	LCUIMutex_Init( &worker->mutex );
	LCUICond_Init( &worker->cond );
	LinkedList_Init( &worker->tasks );
	worker->active = FALSE;
	worker->thread = 0;
	return worker;
}
Beispiel #5
0
FrameControl FrameControl_Create( void )
{
	FrameControl ctx;
	ctx = NEW( FrameControlRec, 1 );
	ctx->temp_fps = 0;
	ctx->current_fps = 0;
	ctx->pause_time = 0;
	ctx->one_frame_remain_time = 10;
	ctx->prev_frame_start_time = LCUI_GetTime();
	ctx->prev_fps_update_time = LCUI_GetTime();
	LCUICond_Init( &ctx->cond );
	LCUIMutex_Init( &ctx->mutex );
	return ctx;
}
Beispiel #6
0
StepTimer StepTimer_Create( void )
{
	StepTimer timer;
	timer = NEW( StepTimerRec, 1 );
	timer->temp_fps = 0;
	timer->current_fps = 0;
	timer->pause_time = 0;
	timer->one_frame_remain_time = 10;
	timer->prev_frame_start_time = LCUI_GetTime();
	timer->prev_fps_update_time = LCUI_GetTime();
	LCUICond_Init( &timer->cond );
	LCUIMutex_Init( &timer->mutex );
	return timer;
}
Beispiel #7
0
/** 新建帧数控制实例 */
FrameCtrlCtx FrameControl_Create( void )
{
	FrameCtrlCtx ctx;
	ctx = (FrameCtrlCtx)malloc(sizeof(struct FrameControlContext));
	ctx->temp_fps = 0;
	ctx->current_fps = 0;
	ctx->pause_time = 0;
	ctx->one_frame_remain_time = 10;
	ctx->prev_frame_start_time = LCUI_GetTickCount();
	ctx->prev_fps_update_time = LCUI_GetTickCount();
	LCUICond_Init( &ctx->wait_continue );
	LCUICond_Init( &ctx->wait_pause );
	LCUIMutex_Init( &ctx->mutex );
	LCUIMutex_Lock( &ctx->mutex );
	return ctx;
}
Beispiel #8
0
/** 初始化键盘输入模块 */
int LCUI_InitKeyboard( void )
{
	int ret;
	LCUIMutex_Init( &record_mutex );
	LinkedList_Init( &key_state_record, sizeof(KeyState) );
	nobuff_printf("[keyboard] set event ... ");
	ret = LCUI_AddEvent( "keydown", LCUI_KEYDOWN );
	ret |= LCUI_AddEvent( "keyup", LCUI_KEYUP );
	ret |= LCUI_BindEvent( "keydown", OnKeyboardEvent, NULL, NULL );
	ret |= LCUI_BindEvent( "keyup", OnKeyboardEvent, NULL, NULL );
	nobuff_printf(ret < 0 ? "failed\n":"ok\n");
#ifdef LCUI_KEYBOARD_DRIVER_LINUX
	ret |= LCUIDevice_Add( LCUIKeyboard_Init, LCUIKeyboard_Proc, LCUIKeyboard_Exit );
#endif
	return ret;
}
Beispiel #9
0
LCUI_API void Graph_Init( LCUI_Graph *graph )
{
	if( !graph ) {
		return;
	}
	
	graph->quote		= FALSE; 
	graph->src		= NULL;
	graph->color_type	= COLOR_TYPE_RGB;
	graph->rgba		= NULL;
	graph->alpha		= 255;
	graph->mem_size		= 0;
	graph->x		= 0;
	graph->y		= 0;
	graph->w		= 0;
	graph->h		= 0;
	LCUIMutex_Init( &graph->mutex );
}
Beispiel #10
0
LCUI_API int Graph_Create( LCUI_Graph *graph, int w, int h )
{
	size_t size;

	if(w > 10000 || h > 10000) {
		printf("error: can not allocate too much memory!\n");
		abort();
	}
	if(h <= 0 || w <= 0) {
		Graph_Free( graph );
		return -1; 
	}
	
	size = sizeof(uchar_t)*w*h;
	if( Graph_IsValid(graph) ) {
		/* 如果现有图形尺寸大于要创建的图形的尺寸,直接改尺寸即可 */
		if( graph->mem_size >= size ) {
			graph->w = w;
			graph->h = h;
			return 0;
		}
		Graph_Free( graph );
		LCUIMutex_Init( &graph->mutex );
	}
	graph->mem_size = size;
	if( graph->color_type == COLOR_TYPE_RGBA ) {
		graph->rgba = (uchar_t**)malloc(sizeof(uchar_t*)*4);
	} else {
		graph->rgba = (uchar_t**)malloc(sizeof(uchar_t*)*3);
	}
	if( graph->rgba == NULL ) {
		goto error_exit;
	}
	graph->rgba[0] = (uchar_t*)malloc( graph->mem_size );
	if( graph->rgba[0] == NULL ) {
		free( graph->rgba );
		goto error_exit;
	}
	graph->rgba[1] = (uchar_t*)malloc( graph->mem_size );
	if( graph->rgba[1] == NULL ) {
		free( graph->rgba[0] );
		free( graph->rgba );
		goto error_exit;
	}
	graph->rgba[2] = (uchar_t*)malloc( graph->mem_size );
	if( graph->rgba[2] == NULL ) {
		free( graph->rgba[0] );
		free( graph->rgba[1] );
		free( graph->rgba );
		goto error_exit;
	}
	if( graph->color_type == COLOR_TYPE_RGBA ) {
		graph->rgba[3] = (uchar_t*)malloc( graph->mem_size );
		if( graph->rgba[3] == NULL ) {
			free( graph->rgba[0] );
			free( graph->rgba[1] );
			free( graph->rgba[2] );
			free( graph->rgba );
			goto error_exit;
		}
		/* 默认将alpha通道用0填充 */
		memset( graph->rgba[3], 0, graph->mem_size );
	}
	graph->w = w;
	graph->h = h;
	return 0;
error_exit:
	graph->w = 0;
	graph->h = 0;
	return -1;
}
Beispiel #11
0
static void TestWorker_Init( TestWorker worker )
{	
	LCUIMutex_Init( &worker->mutex );
	LCUICond_Init( &worker->cond );
}