DirectFB把内容同时输出到主副surface

一直忙项目,很长时间没有更新博客了。

近期碰到一个问题, 就是设定了DirectFB的主Surface输出到高清接口,比如HDMI, 而副Surface的内容则要输出到标清接口,比如CVBS。

我不想一条语句调用两次,分别向不同的Surface画, 研究了一下, Directfb是可以做到在输出到主Surface的同时,flip一份到副Surface的。

具体代码如下:




#include <stdio.h>
#include <directfb.h>

 
static IDirectFB *dfb = NULL;
static IDirectFBSurface *primary = NULL;
static IDirectFBDisplayLayer* secondaryLayer = NULL;
static IDirectFBSurface* secondarySurface = 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 );\
	}\
}
 
int main(int argc, char **argv)
{
	DFBSurfaceDescription dsc;
	DFBDisplayLayerConfig layerCfg;
	 
	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->SetColor (primary, 0xff, 0x00, 0x00, 0xff));
	DFBCHECK (primary->GetSize (primary, &screen_width, &screen_height));
	DFBCHECK (primary->FillRectangle (primary, 0, 0, screen_width, screen_height));
	 
	DFBCHECK (primary->SetColor (primary, 0x80, 0x80, 0xff, 0xff));
	DFBCHECK (primary->DrawLine (primary,
		0, screen_height / 6,
	screen_width - 1, screen_height / 6));
	DFBCHECK (primary->Flip (primary, NULL, 0));

	dfb->GetDisplayLayer(dfb, DLID_PRIMARY+1, &secondaryLayer);
	secondaryLayer->SetCooperativeLevel(secondaryLayer, DLSCL_ADMINISTRATIVE);

	
    layerCfg.flags = DLCONF_SOURCE;
    layerCfg.source = DLSID_SURFACE;
	secondaryLayer->SetConfiguration(secondaryLayer, &layerCfg);

	
	secondaryLayer->GetSurface(secondaryLayer, &secondarySurface);
	secondarySurface->Flip(secondarySurface, NULL, DSFLIP_NONE);

        sleep(10);
	secondaryLayer->Release( secondaryLayer );
	secondarySurface->Release( secondarySurface );
	primary->Release(primary);
	dfb->Release(dfb);
	return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值