使用DirectFB库,开发一个应用程序,显示中文“DirectFB 你好!”,然后和视频层一起运行,最后的结果在屏幕上播放视频,然后屏幕视频右上角显示“DirectFB 你好!”,请问我写的程序有什么问题,为什么播放视频时感觉视频和我写的层两者在抢用显卡呢?请问大家是什么问题,真的很感谢大家的回答,谢谢您了!求助!!!!!!!!!!!!!!!!!!
代码如下:
/*************************************************************************
> File Name: df_drawtext.c
> Author:
> Mail:
> Created Time: 2015年03月03日 星期二 14时37分05秒
************************************************************************/
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <directfb.h>
static IDirectFB *dfb = NULL;
static IDirectFBSurface *primary = NULL;
static int screen_width = 0;
static int screen_height = 0;
#define DFBCHECK(x...) \
{ \
DFBResult err = x; \
\
if (err != DFB_OK) \
{ \
fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
DirectFBErrorFatal( #x, err ); \
} \
}
static IDirectFBFont *font = NULL;
static char *text = "DirectFB 你好!";
int main (int argc, char **argv)
{
int i, width;
DFBFontDescription font_dsc;
DFBSurfaceDescription dsc;
DFBCHECK (DirectFBInit (&argc, &argv));
DFBCHECK (DirectFBCreate (&dfb));
DFBCHECK (dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN));
dsc.flags = DSDESC_CAPS;
dsc.caps = DSCAPS_PRIMARY | DSCAPS_FLIPPING;
DFBCHECK (dfb->CreateSurface( dfb, &dsc, &primary ));
DFBCHECK (primary->GetSize (primary, &screen_width, &screen_height));
font_dsc.flags = DFDESC_HEIGHT;
font_dsc.height = 48;
DFBCHECK (dfb->CreateFont (dfb, "factory/fonts/truetype/simhei.ttf", &font_dsc, &font));
DFBCHECK (primary->SetFont (primary, font));
DFBCHECK (font->GetStringWidth (font, text, -1, &width));
printf("screen_width=%d,screen_height=%d",screen_width,screen_height);
for(i = screen_width; i>-width; i--)
// while(1)
{
DFBCHECK (primary->SetColor (primary, 0x0, 0x0, 0x0, 0));
DFBCHECK (primary->FillRectangle (primary, 0, 0, screen_width, screen_height));
DFBCHECK (primary->SetColor (primary, 0xff, 0x0, 0xff, 0xff));
// DFBCHECK (dfb->CreateFont (dfb, "factory/fonts/truetype/simhei.ttf", &font_dsc, &font));
// DFBCHECK (primary->SetFont (primary, font));
DFBCHECK (primary->DrawString (primary, text, -1, i, screen_height / 2, DSTF_LEFT));
// DFBCHECK (primary->DrawString (primary, text, -1, screen_width-100, screen_height/8, DSTF_TOPRIGHT));
//DFBCHECK (primary->Flip (primary, NULL, DSFLIP_WAITFORSYNC));
DFBCHECK (primary->Flip (primary, NULL, 0));
}
sleep(5);
// while(1);
font->Release (font);
primary->Release (primary);
dfb->Release (dfb);
return 0;
}
|