先把dfb_core_create的源码看一下,包含的内容比较多,本篇先介绍大概的情况,下面几篇文章对里面的函数进行详细讲述.
- DFBResult dfb_core_create( CoreDFB **ret_core )
- {
- CoreDFB *core = NULL;
- CoreDFBShared *shared = NULL;
- ret = dfb_system_lookup(); //找到所有显示方式是什么system
- /* Allocate local core structure. */
- core = D_CALLOC( 1, sizeof(CoreDFB) );
- core->refs = 1;
- //注册一个线程处理函数,这个函数的实现什么也没有做
- core->init_handler = direct_thread_add_init_handler( dfb_core_thread_init_handler, core );
- #if FUSION_BUILD_MULTI
- dfb_system_thread_init();//此函数功用和上面注册的线程处理函数一样
- #endif
- direct_find_best_memcpy();//对系统中几个memcpy进行比较,找到最快的一个.
- D_MAGIC_SET( core, CoreDFB );
- core_dfb = core;
- //初始化fusion,fusion是用于进程间通信的机制.用于实现同时运行多个dfb程序
- ret = fusion_enter( dfb_config->session, DIRECTFB_CORE_ABI, FER_ANY, &core->world );
- core->fusion_id = fusion_id( core->world );
- //注册一个信号处理函数,用于处理程序退出时的处理.这边有文章噢!
- direct_signal_handler_add( DIRECT_SIGNAL_ANY, dfb_core_signal_handler, core, &core->signal_handler );
- //共享数据处理
- if (fusion_arena_enter( core->world, "DirectFB/Core",
- dfb_core_arena_initialize, dfb_core_arena_join,
- core, &core->arena, &ret ) || ret){}
- shared = core->shared;
- fusion_skirmish_prevail( &shared->lock );
- if (!core->master) {
- while (!shared->active)
- fusion_skirmish_wait( &shared->lock, 0 );
- }
- fusion_skirmish_dismiss( &shared->lock );
- dfb_font_manager_create( core, &core->font_manager );//字体管理初始化
- *ret_core = core;
- return DFB_OK;
- }