/**********************************************************************
** Copyright (C) 2010 FreeC ORG. All rights reserved.
** Author: Carlson Lee.
**
** This file is part of FreeC.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://freec.sourceforge.net
**
** Contact CarlsonLee_FreeC@hotmail.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "config.h"
#include "typedef.h"
#include <linux/fb.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
//#include <asm/page.h>
#include <sys/mman.h>
#include <directfb.h>
#include <asm/errno.h>
#include <pthread.h>
#include "errcode.h"
#include "cncui.h"
#include "disp.h"
#include "cncdisplay.h"
#include "cnctask.h"
static IDirectFB *dfb = NULL;
static IDirectFBSurface *primary = NULL;
static IDirectFBDisplayLayer *layer = NULL;
static IDirectFBSurface *imageSurface = NULL;
static IDirectFBEventBuffer *mouse_events = NULL;
static pthread_mutex_t mutex_display = PTHREAD_MUTEX_INITIALIZER;
static UINT8 *pCursorBuf = NULL;
static UINT8 *mouse_bg_data = NULL;
#define DFBCHECK(x...) /
{ /
DFBResult err = x; /
if (err != DFB_OK) /
{ /
printf("%s <%d>:/n/t", __FILE__, __LINE__ ); /
DirectFBErrorFatal( #x, err ); /
goto exit; /
} /
}
#define MOUSE_WIDTH 12
#define MOUSE_HEIGHT 20
/* init framebuffer*/
CNC_RET dispInit(void)
{
DFBSurfaceDescription dsc;
pthread_t key_thread_id;
if(dfb || primary || imageSurface)
return CERR_NONE;
DFBCHECK (DirectFBInit (0, 0));
DFBCHECK (DirectFBCreate (&dfb));
DFBCHECK (dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN));
dsc.flags = DSDESC_CAPS | DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT;
dsc.caps = DSCAPS_PRIMARY;
dsc.width = SCREEN_WIDTH;
dsc.height = SCREEN_HEIGHT;
//#if BYTES_PER_PIXEL==3
// dsc.pixelformat = DSPF_RGB24 ;
//#elif BYTES_PER_PIXEL==4
dsc.pixelformat = DSPF_RGB32 ;
dfb->GetDisplayLayer(dfb, 0, &layer);
layer->EnableCursor(layer, 1);
//#endif
DFBCHECK (dfb->CreateSurface( dfb, &dsc, &primary ));
dsc.flags = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT;
dsc.width = SCREEN_WIDTH;
dsc.height = SCREEN_HEIGHT;
//#if BYTES_PER_PIXEL==3
// dsc.pixelformat = DSPF_RGB24 ;
//#elif BYTES_PER_PIXEL==4
dsc.pixelformat = DSPF_RGB32 ;
//#endif
DFBCHECK(dfb->CreateSurface( dfb, &dsc, &imageSurface));
DFBCHECK(dfb->CreateInputEventBuffer( dfb, DICAPS_ALL,
DFB_FALS
使用 directfb绘制图像(draw image with directfb)
最新推荐文章于 2021-05-17 09:22:58 发布
本文档详细介绍了如何使用DirectFB库在Linux环境下初始化帧缓冲,并创建和管理DirectFB表面,用于在全屏模式下绘制图像。代码示例包括了创建和释放DirectFB对象、设置合作级别、创建输入事件缓冲区、处理鼠标事件以及更新屏幕显示。此外,还展示了如何在屏幕上绘制鼠标光标并处理鼠标移动。
摘要由CSDN通过智能技术生成