1)初始化:
dfb_wm_core_initialize( CoreDFB *core,
DFBWMCore *data,
DFBWMCoreShared *shared )
%%%B /* %%%B表示注释开始,%%%E结束/
由dfb_core_part_initialize调用
if (core_part->size_local)
local = D_CALLOC( 1, core_part->size_local );//本地数据system mem
if (core_part->size_shared)
shared = SHCALLOC( pool, 1, core_part->size_shared );//共享数据shared mem
ret = core_part->Initialize( core, local, shared );
其中:
/* Allocate local core structure. */
core 是dfb_core_create( CoreDFB **ret_core )中的
core = D_CALLOC( 1, sizeof(CoreDFB) );
Pool是dfb_core_arena_initialize函数中创建的pool
ret = fusion_shm_pool_create( core->world, "DirectFB Main Pool", 0x400000,
fusion_config->debugshm, &pool ); */
/* Allocate shared structure in the new pool. */
shared = SHCALLOC( pool, 1, sizeof(CoreDFBShared) );
if (!shared) {
fusion_shm_pool_destroy( core->world, pool );
return D_OOSHM();
}
core->shared = shared;
core->master = true;
shared->shmpool = pool;
需要注意下宏:DFB_WINDOW_MANAGER( default )
%%%E
dfb_wm_core_initialize初始化过程:
%%% 给wm的各个指针赋值
data->core = core;
data->shared = shared;
wm_local = data; /* FIXME */
wm_shared = shared; /* FIXME */
%%% wm_shared->shmpool指向Pool
wm_shared->shmpool = dfb_core_shmpool( core );
%%%B
加载libdirectfbwm_default.so (分为:default 和 unique,默认为default)
主要找到相关实现函数 即:funcs
%%%E
/* Load the module. */
ret = load_module( dfb_config->wm );
%%%调用default.c中的函数wm_get_info
/* Query module information. */
wm_local->funcs->GetWMInfo( &wm_shared->info );
/* Store module name in shared memory. */
wm_shared->name = SHSTRDUP( wm_shared->shmpool, wm_local->module->name );
if (!wm_shared->name) {
D_OOSHM();
goto error;
}
/* Allocate shared window manager data. */
if (wm_shared->info.wm_shared_size) {
wm_shared->data = SHCALLOC( wm_shared->shmpool, 1, wm_shared->info.wm_shared_size );
if (!wm_shared->data) {
D_OOSHM();
goto error;
}
}
ret = DFB_NOSYSTEMMEMORY;
/* Allocate local window manager data. */
if (wm_shared->info.wm_data_size) {
wm_local->data = D_CALLOC( 1, wm_shared->info.wm_data_size );
if (!wm_local->data) {
D_OOM();
goto error;
}
}
%%% 调用default中的初始化函数 即 default.c中的wm_initialize
/* Initialize window manager. */
ret = wm_local->funcs->Initialize( core, wm_local->data, wm_shared->data );
if (ret) {
D_DERROR( ret, "DirectFB/Core/WM: Could not initialize window manager!/n" );
goto error;
}
D_MAGIC_SET( data, DFBWMCore );
D_MAGIC_SET( shared, DFBWMCoreShared );
return DFB_OK;
DFBResult
dfb_wm_init_stack( CoreWindowStack *stack )
DFBResult
IDirectFB_Construct( IDirectFB *thiz, CoreDFB *core )
-》dfb_layer_get_primary_context-》dfb_layer_create_context-》dfb_layer_context_init-》
dfb_windowstack_create-》dfb_wm_init_stack
%%%B
CoreLayerContext *
dfb_core_create_layer_context( CoreDFB *core )
{
CoreDFBShared *shared;
D_ASSUME( core != NULL );
if (!core)
core = core_dfb;
D_MAGIC_ASSERT( core, CoreDFB );
shared = core->shared;
D_MAGIC_ASSERT( shared, CoreDFBShared );
D_ASSERT( shared->layer_context_pool != NULL );
return (CoreLayerContext*) fusion_object_create( shared->layer_context_pool, core->world );
}
static DFBResult
dfb_core_initialize( CoreDFB *core )
{
shared->layer_context_pool = dfb_layer_context_pool_create( core->world );
shared->layer_region_pool = dfb_layer_region_pool_create( core->world );
shared->palette_pool = dfb_palette_pool_create( core->world );
shared->surface_pool = dfb_surface_pool_create( core->world );
shared->window_pool = dfb_window_pool_create( core->world );
}
CoreWindowStack*
dfb_windowstack_create( CoreLayerContext *context )
{
/* Allocate window stack data (completely shared) */
stack = (CoreWindowStack*) SHCALLOC( context->shmpool, 1, sizeof(CoreWindowStack) );
if (!stack) {
D_OOSHM();
return NULL;
}
stack->shmpool = context->shmpool;
}
%%%E
#define MAX_UPDATE_REGIONS 8