一、简介
DirectFB是一个轻量级的提供硬件图形加速,输入设备处理和抽象的图形库,它集成了支持半透明的视窗系统以及在LinuxFramebuffer驱动之上的多层显示。它是一个用软件封装当前硬件无法支持的图形算法来完成硬件加速的层。DirectFB是为嵌入式系统而设计。它是以最小的资源开销来实现最高的硬件加速性能。
DirectFB中的重要术语
1、Blitting
Blitting是在拷贝图像数据的进程中所引用。举一个最简单的例子就是当两个Surface有相同的大,颜色深度和像素格式时Blitting其中一个Surface到另一个Surface。在这个过程中内存只被复制而没有被处理(就像复制其他任何类型的数据一样)。???alpha通道的传输,或者从一种像素格式到另一种像素格式的传输。许多图形显卡包含了一个硬件Blitting来完成多种格式的传输。
2、Surface
Surface是内存中一个图像以一种具体的像素格式被保存的一块保留区域。一个Surface可以位于视频和/或系统内存中。可以在一个Surface上进行画图操作或者把一个Surface Blitting到另一个。(见1.21节)
在全屏模式下时,屏幕中的可视区表示为”主Surface”,所以可以直接在屏幕的可视区完成图形操作。
每个Surface都可以选择双缓冲,图形操作将首先在辅助缓冲区中执行然后在Flip()被调用之后变得合法。在许多情况下建议在主Surface中使用双缓冲来防止闪烁。
3、SubSurface
SubSurface使用和正规Surface相同的接口。它代表父类Surface的一个部分并且没有为自己分配任何系统或视频存储空间。
4、Layer
依靠于图形硬件可以有一个或者多个显示层。一个标准的PC显卡只有一个层,但是??就像机顶盒就可能支持2个或更多的层。不同的层在显存中占据着不同的区域,通常通过alpha混合来组合,这由显示硬件自动完成。如果最底层的内容发生了改变将不会被重绘,上一层的内容保持不变。今天,许多PC显卡也支持额外的可以缩放可以从YUV转为RGB的层(视频层)。这个层不能进行颜色混合和设置成保持完全的不透明。variosDirectFB图形驱动支持视频层。
5、Window / Windowstack
通常一个层的surface的内容受控于集成的窗体系统,这意味着属于这个层的窗体在一个可配置的背景上。每个窗体有它自己的一个 surface 这个surface 被窗体系统用来生成构成重叠窗体的图像。
二、编译与安装
1、资源下载
需下载如下资源
DirectFB:DirectFB-1.6.1.tar.gz, Fusion: linux-fusion-8.10.2.tar.gz Example: DirectFB-examples-1.6.0.tar.gz
DirectFB 提供3种形式的下载方式: git, cvs 和压缩包。
地址:http://directfb.org/
或 :git clone git://git.directfb.org/git/directfb/core/DirectFB.git
git clone git://git.directfb.org/git/directfb/core/linux-fusion.git
2、编译和安装Fusion
# tar zxf linux-fusion-8.10.2.tar.gz # cd linux-fusion-8.10.2 # make # make install
注意:
1) Run ‘make‘ and ‘make install‘. It builds and installs the module for the running kernel version as reported by ‘uname -r‘. If you want to build for another kernel, edit the Makefile. 2) Either run ‘modprobe fusion‘ manually or add "fusion" to "/etc/modules". 3) Create the fusion device(s) if not using devfs or udev: mkdir /dev/fusion mknod /dev/fusion/0 c 250 0 ...if you need more than one session mknod /dev/fusion/1 c 250 1 mknod /dev/fusion/2 c 250 2 ...and so on (currently limited to eight sessions) 4) Add udev rules to /etc/udev/rules.d/40-fusion.rules if using udev: KERNEL=="fusion[0-9]*", NAME="fusion/%n", GROUP="video", MODE="0660" ...customize to suit your needs
3、编译和安装DirectFB
# tar zxf DirectFB-1.6.1.tar.gz # cd DirectFB-1.6.1 # ./configure --enable-x11 --enable-multi --enable-debug --enable-trace # make # make install
注意:为使pkg-config能够找到DirectFB,需要添加寻索路径:/usr/local/lib/,有两种方式
方式1:
首先执行:vi /etc/ld.so.conf.d/qt-i386.conf ,并添加如下内容
/usr/local/lib/
然后执行:
ldconfig
方式2:
首先执行:
cd DirectFB-1.6.1 find . -name "*.pc"
然后将搜索出的“*.pc”文件copy至目录/usr/lib/pkgconfig,执行:
4、编译和安装Example
# tar -zxvf DirectFB-examples-1.6.0.tar.gz # cd DirectFB-examples-1.6.0 # ./configure --enable-debug # make # make install
三、运行示例
# depmod -a # modprobe fusion # 安装 fusion 内核模块 # cd /usr/local/bin # ./df_window
报错如下:
~~~~~~~~~~~~~~~~~~~~~~~~~~| DirectFB 1.6.1 |~~~~~~~~~~~~~~~~~~~~~~~~~~ (c) 2001-2012 The world wide DirectFB Open Source Community (c) 2000-2004 Convergence (integrated media) GmbH ---------------------------------------------------------------- (*) DirectFB/Core: Multi Application Core. (2015-03-22 11:51) [ DEBUG ][ TRACE ] (*) Fusion/SHM: Using MADV_REMOVE (2.6.32.0 >= 2.6.19.2) (*) Direct/Thread: Started ‘Fusion Dispatch‘ (-1) [MESSAGING OTHER/OTHER 0/0] <10485760>... (*) Direct/Thread: Started ‘Fusion Deferred‘ (-1) [MESSAGING OTHER/OTHER 0/0] <10485760>... (!) Direct/Util: Opening ‘/dev/fb0‘ failed! --> The requested operation or an argument is (currently) not supported (-) [ 3047: -STACK- ] #0 0x00e431c3 in direct_try_open () from /usr/local/lib/libdirect-1.6.so.0 [0xe19000] #1 0x0044aa61 in dfb_fbdev_open () from /usr/local/lib/directfb-1.6-0/systems/libdirectfb_fbdev.so [0x447000] #2 0x0044b2e7 in system_initialize () from /usr/local/lib/directfb-1.6-0/systems/libdirectfb_fbdev.so [0x447000] #3 0x007a6178 in dfb_system_core_initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000] #4 0x00737d5c in dfb_core_part_initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000] #5 0x00734987 in dfb_core_initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000] #6 0x006f41aa in DirectFB::ICore_Real::Initialize() () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000] #7 0x006f106e in CoreDFB_Initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000] #8 0x007351ea in dfb_core_arena_initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000] #9 0x0072e303 in dfb_core_create () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000] #10 0x006efb00 in DirectFBCreate () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000] (!) DirectFB/FBDev: Error opening framebuffer device! (-) [ 3047: -STACK- ] #0 0x0044aa61 in dfb_fbdev_open () from /usr/local/lib/directfb-1.6-0/systems/libdirectfb_fbdev.so [0x447000] #1 0x0044b2e7 in system_initialize () from /usr/local/lib/directfb-1.6-0/systems/libdirectfb_fbdev.so [0x447000] #2 0x007a6178 in dfb_system_core_initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000] #3 0x00737d5c in dfb_core_part_initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000] #4 0x00734987 in dfb_core_initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000] #5 0x006f41aa in DirectFB::ICore_Real::Initialize() () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000] #6 0x006f106e in CoreDFB_Initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000] #7 0x007351ea in dfb_core_arena_initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000] #8 0x0072e303 in dfb_core_create () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000] #9 0x006efb00 in DirectFBCreate () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000] (!) DirectFB/FBDev: Use ‘fbdev‘ option or set FRAMEBUFFER environment variable. (-) [ 3047: -STACK- ] #0 0x0044aa61 in dfb_fbdev_open () from /usr/local/lib/directfb-1.6-0/systems/libdirectfb_fbdev.so [0x447000] #1 0x0044b2e7 in system_initialize () from /usr/local/lib/directfb-1.6-0/systems/libdirectfb_fbdev.so [0x447000] #2 0x007a6178 in dfb_system_core_initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000] #3 0x00737d5c in dfb_core_part_initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000] #4 0x00734987 in dfb_core_initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000] #5 0x006f41aa in DirectFB::ICore_Real::Initialize() () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000] #6 0x006f106e in CoreDFB_Initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000] #7 0x007351ea in dfb_core_arena_initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000] #8 0x0072e303 in dfb_core_create () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000] #9 0x006efb00 in DirectFBCreate () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000] (!) DirectFB/Core: Could not initialize ‘system_core‘ core! --> A general initialization error occured (-) [ 3047: -STACK- ] #0 0x00737d5c in dfb_core_part_initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000] #1 0x00734987 in dfb_core_initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000] #2 0x006f41aa in DirectFB::ICore_Real::Initialize() () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000] #3 0x006f106e in CoreDFB_Initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000] #4 0x007351ea in dfb_core_arena_initialize () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000] #5 0x0072e303 in dfb_core_create () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000] #6 0x006efb00 in DirectFBCreate () from /usr/local/lib/libdirectfb-1.6.so.0 [0x6bd000] df_window.c <136>: (#) DirectFBError [DirectFBCreate( &dfb )]: A general initialization error occured
解决方法:
执行:vi /etc/grub.conf
修改 kernel /vmlinuz-2.6.15-1.2054_FC5 ro root=LABEL=/ rhgb quiet 为: kernel /vmlinuz-2.6.15-1.2054_FC5 ro root=LABEL=/ rhgb quiet vga= 788
再次运行:
# ./df_window
效果如下
原文:http://www.cnblogs.com/274914765qq/p/4358088.html