dfb_core_create接着调用fusion_arena_enter,它会调用dfb_core_arena_initialize,最终调到了dfb_core_initialize
而每个子系统又是如何初始化的,完成了怎样的功能,在下面会再一一讲述.
有几个重要的概念说明:
surface:一块画布区域,绘制操作都在这上面进行.
layer:显卡的物理特性,数量多少由显卡决定,每个层对应显卡中的不同的内存.最终由硬件使用合适的alpha值进行混合,然后显示.
screen:系统中的特定的一块内存,写到这块内存的东西会自动显示到屏幕上,图形系统可以操作这块内存,如x11,framebuffer.
window:可进行窗口管理的surface
下面是来自网上的文档:
1.Surface
A Surface is a reserved area in memory where pixel data for one image is stored in a
specific pixel format. A Surface can reside in video and/or system memory. It is possible
to perform drawing operations on a surface or to Blit the surface to another.
In fullscreen mode, the visible screen is represented by the ”‘Primary Surface”’, so it is
possible to perform graphics operations directly on the visible screen.
Every Surface can optionally use double buffering, graphics operations are then first executed
on a secondary buffer and become valid after Flip() is called. To prevent flickering it is
advised to use Doublebuffering on the primary Surface in most cases.
2.SubSurface
A SubSurface uses the same interface as a regular Surface. It represents a part of a parent
Surface and does not allocate any system or video memory itself.
3.Layer
Depending on the graphics hardware, there are one or more display Layers. A standard
PC graphics card has only one Layer, but sophisticated devices like TV set top boxes may
support two or more layers. Layers occupy different areas in video ram, and are usually
combined by using alpha blending. This in done automatically by the display hardware. If
the content of the lowest Layer changes, no repaint has to be done and the contents of the
above layers remain untouched. Today, most PC graphics cards also support an additional
layer (a ”‘video layer”’), which can be scaled and does color conversion from YUV to RGB.
This layer cannot usually be blended and has to remain fully opaque. Video layers are
supported by varios DirectFB graphics drivers.
4.Window / Windowstack
Normally the contents of a layer’s surface is controlled by the integrated windowing system
that shows the windows belonging to the layer on a configurable background. Each window
has its own surface that is used by the windowing system to produce the composed image of
overlapping windows. Alternatively applications, especially games, can get exclusive access
to the layer. This way the application has direct control over the layer’s surface and it’s
contents, no windows are shown.
关系:
1 IDirectFB (顶层) <--> N 屏幕(Screens)
1 屏幕(Screen) <--> N 层(Layers)
1 层(Layer) <--> 1 主表面(Primary Surface)
1 层(Layer) <--> N 窗口(Windows)
1 窗口(Window) <--> 1 窗口表面(Window Surface)
1 表面(Surface) <--> N 子表面(Subsurfaces)
- static DFBResult dfb_core_initialize( CoreDFB *core )
- {
- int i;
- DFBResult ret;
- CoreDFBShared *shared;
- D_MAGIC_ASSERT( core, CoreDFB );
- shared = core->shared;
- D_MAGIC_ASSERT( shared, CoreDFBShared );
- ret = fusion_shm_pool_create( core->world, "DirectFB Data Pool", 0x1000000,
- fusion_config->debugshm, &shared->shmpool_data );
- if (ret)
- return ret;
- 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 );
- for (i=0; i<D_ARRAY_SIZE(core_parts); i++) {
- DFBResult ret;
- //调用每一个子系统的初始化函数
- if ((ret = dfb_core_part_initialize( core, core_parts[i] ))) {
- dfb_core_shutdown( core, true );
- return ret;
- }
- }
- return DFB_OK;
- }
static DFBResult dfb_core_initialize( CoreDFB *core )
{
int i;
DFBResult ret;
CoreDFBShared *shared;
D_MAGIC_ASSERT( core, CoreDFB );
shared = core->shared;
D_MAGIC_ASSERT( shared, CoreDFBShared );
ret = fusion_shm_pool_create( core->world, "DirectFB Data Pool", 0x1000000,
fusion_config->debugshm, &shared->shmpool_data );
if (ret)
return ret;
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 );
for (i=0; i<D_ARRAY_SIZE(core_parts); i++) {
DFBResult ret;
//调用每一个子系统的初始化函数
if ((ret = dfb_core_part_initialize( core, core_parts[i] ))) {
dfb_core_shutdown( core, true );
return ret;
}
}
return DFB_OK;
}
而这些子系统数组在文件头部:
- static CorePart *core_parts[] = {
- &dfb_clipboard_core,//剪切板
- &dfb_colorhash_core,//颜色hash表
- &dfb_surface_core,//显示
- &dfb_system_core,//输出显示的图形系统
- &dfb_input_core,//各种外设抽象处理
- &dfb_graphics_core,//显卡设备
- &dfb_screen_core,//屏幕的抽象
- &dfb_layer_core,//层
- &dfb_wm_core//窗口管理
- };
static CorePart *core_parts[] = {
&dfb_clipboard_core,//剪切板
&dfb_colorhash_core,//颜色hash表
&dfb_surface_core,//显示
&dfb_system_core,//输出显示的图形系统
&dfb_input_core,//各种外设抽象处理
&dfb_graphics_core,//显卡设备
&dfb_screen_core,//屏幕的抽象
&dfb_layer_core,//层
&dfb_wm_core//窗口管理
};
这些变量是在哪里进行初始化的呢?可以看到在每个子系统中都调用了这么一个宏
- #define DFB_CORE_PART(part,Type) \
- \
- static DFBResult dfb_##part##_initialize( CoreDFB *core, \
- DFB##Type *local, \
- DFB##Type##Shared *shared ); \
- \
- static DFBResult dfb_##part##_join ( CoreDFB *core, \
- DFB##Type *local, \
- DFB##Type##Shared *shared ); \
- \
- static DFBResult dfb_##part##_shutdown ( DFB##Type *local, \
- bool emergency ); \
- \
- static DFBResult dfb_##part##_leave ( DFB##Type *local, \
- bool emergency ); \
- \
- static DFBResult dfb_##part##_suspend ( DFB##Type *local ); \
- \
- static DFBResult dfb_##part##_resume ( DFB##Type *local ); \
- \
- CorePart dfb_##part = { \
- .name = #part, \
- \
- .size_local = sizeof(DFB##Type), \
- .size_shared = sizeof(DFB##Type##Shared), \
- \
- .Initialize = (void*)dfb_##part##_initialize, \
- .Join = (void*)dfb_##part##_join, \
- .Shutdown = (void*)dfb_##part##_shutdown, \
- .Leave = (void*)dfb_##part##_leave, \
- .Suspend = (void*)dfb_##part##_suspend, \
- .Resume = (void*)dfb_##part##_resume, \
- }
#define DFB_CORE_PART(part,Type) \
\
static DFBResult dfb_##part##_initialize( CoreDFB *core, \
DFB##Type *local, \
DFB##Type##Shared *shared ); \
\
static DFBResult dfb_##part##_join ( CoreDFB *core, \
DFB##Type *local, \
DFB##Type##Shared *shared ); \
\
static DFBResult dfb_##part##_shutdown ( DFB##Type *local, \
bool emergency ); \
\
static DFBResult dfb_##part##_leave ( DFB##Type *local, \
bool emergency ); \
\
static DFBResult dfb_##part##_suspend ( DFB##Type *local ); \
\
static DFBResult dfb_##part##_resume ( DFB##Type *local ); \
\
CorePart dfb_##part = { \
.name = #part, \
\
.size_local = sizeof(DFB##Type), \
.size_shared = sizeof(DFB##Type##Shared), \
\
.Initialize = (void*)dfb_##part##_initialize, \
.Join = (void*)dfb_##part##_join, \
.Shutdown = (void*)dfb_##part##_shutdown, \
.Leave = (void*)dfb_##part##_leave, \
.Suspend = (void*)dfb_##part##_suspend, \
.Resume = (void*)dfb_##part##_resume, \
}
这样就完成了各个子系统的初始化.
而每个子系统又是如何初始化的,完成了怎样的功能,在下面会再一一讲述.
有几个重要的概念说明:
surface:一块画布区域,绘制操作都在这上面进行.
layer:显卡的物理特性,数量多少由显卡决定,每个层对应显卡中的不同的内存.最终由硬件使用合适的alpha值进行混合,然后显示.
screen:系统中的特定的一块内存,写到这块内存的东西会自动显示到屏幕上,图形系统可以操作这块内存,如x11,framebuffer.
window:可进行窗口管理的surface
下面是来自网上的文档:
1.Surface
A Surface is a reserved area in memory where pixel data for one image is stored in a
specific pixel format. A Surface can reside in video and/or system memory. It is possible
to perform drawing operations on a surface or to Blit the surface to another.
In fullscreen mode, the visible screen is represented by the ”‘Primary Surface”’, so it is
possible to perform graphics operations directly on the visible screen.
Every Surface can optionally use double buffering, graphics operations are then first executed
on a secondary buffer and become valid after Flip() is called. To prevent flickering it is
advised to use Doublebuffering on the primary Surface in most cases.
2.SubSurface
A SubSurface uses the same interface as a regular Surface. It represents a part of a parent
Surface and does not allocate any system or video memory itself.
3.Layer
Depending on the graphics hardware, there are one or more display Layers. A standard
PC graphics card has only one Layer, but sophisticated devices like TV set top boxes may
support two or more layers. Layers occupy different areas in video ram, and are usually
combined by using alpha blending. This in done automatically by the display hardware. If
the content of the lowest Layer changes, no repaint has to be done and the contents of the
above layers remain untouched. Today, most PC graphics cards also support an additional
layer (a ”‘video layer”’), which can be scaled and does color conversion from YUV to RGB.
This layer cannot usually be blended and has to remain fully opaque. Video layers are
supported by varios DirectFB graphics drivers.
4.Window / Windowstack
Normally the contents of a layer’s surface is controlled by the integrated windowing system
that shows the windows belonging to the layer on a configurable background. Each window
has its own surface that is used by the windowing system to produce the composed image of
overlapping windows. Alternatively applications, especially games, can get exclusive access
to the layer. This way the application has direct control over the layer’s surface and it’s
contents, no windows are shown.
关系:
1 IDirectFB (顶层) <--> N 屏幕(Screens)
1 屏幕(Screen) <--> N 层(Layers)
1 层(Layer) <--> 1 主表面(Primary Surface)
1 层(Layer) <--> N 窗口(Windows)
1 窗口(Window) <--> 1 窗口表面(Window Surface)
1 表面(Surface) <--> N 子表面(Subsurfaces)