#ifndef __CORE__LAYERS_H__ #define __CORE__LAYERS_H__ #include <directfb.h> #include <core/coretypes.h> #include <core/gfxcard.h> #include <core/surface_buffer.h> struct __DFB_CoreLayerRegionConfig { int width; /* width of the source in pixels */ int height; /* height of the source in pixels */ DFBSurfacePixelFormat format; /* pixel format of the source surface */ DFBSurfaceColorSpace colorspace; /* color space of the source surface */ DFBSurfaceCapabilities surface_caps; /* capabilities of the source surface */ DFBDisplayLayerBufferMode buffermode; /* surface buffer configuration */ DFBDisplayLayerOptions options; /* various configuration options */ DFBDisplayLayerSourceID source_id; /* selected source */ DFBRectangle source; /* viewport within source (input) */ DFBRectangle dest; /* viewport on screen (output) */ u8 opacity; /* global region alpha */ DFBColorKey src_key; /* source color key */ DFBColorKey dst_key; /* destination color key */ int parity; /* field parity (for interlaced) */ u8 alpha_ramp[4]; /* alpha values for 1 or 2 bit lookup */ DFBRegion *clips; /* clip regions */ int num_clips; /* number of clip regions */ DFBBoolean positive; /* show or cut out regions */ bool keep_buffers; }; #if D_DEBUG_ENABLED #define DFB_CORE_LAYER_REGION_CONFIG_DEBUG_AT( domain, config ) \ do { \ const CoreLayerRegionConfig *_config = config; \ \ D_DEBUG_AT( domain, " -> size %dx%d\n", _config->width, _config->height ); \ D_DEBUG_AT( domain, " -> format %s\n", dfb_pixelformat_name( _config->format ) ); \ D_DEBUG_AT( domain, " -> color spc %d\n", _config->colorspace ); \ D_DEBUG_AT( domain, " -> surf caps 0x%08x\n", _config->surface_caps ); \ D_DEBUG_AT( domain, " -> buffermode %d\n", _config->buffermode ); \ D_DEBUG_AT( domain, " -> options 0x%08x\n", _config->options ); \ D_DEBUG_AT( domain, " -> source %d,%d-%dx%d\n", DFB_RECTANGLE_VALS(&_config->source) ); \ D_DEBUG_AT( domain, " -> dest %d,%d-%dx%d\n", DFB_RECTANGLE_VALS(&_config->dest) ); \ D_DEBUG_AT( domain, " -> opacity %d\n", _config->opacity ); \ D_DEBUG_AT( domain, " -> src_key %02x%02x%02x (index %d)\n", DFB_COLORKEY_VALS(&_config->src_key) ); \ D_DEBUG_AT( domain, " -> dst_key %02x%02x%02x (index %d)\n", DFB_COLORKEY_VALS(&_config->dst_key) ); \ } while (0) #else #define DFB_CORE_LAYER_REGION_CONFIG_DEBUG_AT( domain, config ) \ do { \ } while (0) #endif typedef enum { CLRCF_NONE = 0x00000000, CLRCF_WIDTH = 0x00000001, CLRCF_HEIGHT = 0x00000002, CLRCF_FORMAT = 0x00000004, CLRCF_SURFACE_CAPS = 0x00000008, CLRCF_BUFFERMODE = 0x00000010, CLRCF_OPTIONS = 0x00000020, CLRCF_SOURCE_ID = 0x00000040, CLRCF_COLORSPACE = 0x00000080, CLRCF_SOURCE = 0x00000100, CLRCF_DEST = 0x00000200, CLRCF_CLIPS = 0x00000400, CLRCF_OPACITY = 0x00001000, CLRCF_ALPHA_RAMP = 0x00002000, CLRCF_SRCKEY = 0x00010000, CLRCF_DSTKEY = 0x00020000, CLRCF_PARITY = 0x00100000, CLRCF_SURFACE = 0x10000000, CLRCF_PALETTE = 0x20000000, CLRCF_FREEZE = 0x80000000, CLRCF_ALL = 0xB01337FF } CoreLayerRegionConfigFlags; typedef struct { /** Driver Control **/ /* * Return size of layer data (shared memory). */ int (*LayerDataSize) ( void ); /* * Return size of region data (shared memory). */ int (*RegionDataSize)( void ); /* * Called once by the master to initialize layer data and reset hardware. * Return layer description, default configuration and color adjustment. */ DFBResult (*InitLayer) ( CoreLayer *layer, void *driver_data, void *layer_data, DFBDisplayLayerDescription *description, DFBDisplayLayerConfig *config, DFBColorAdjustment *adjustment ); /* * Called once by the master to shutdown the layer. * Use this function to free any resources that were taken during init. */ DFBResult (*ShutdownLayer) ( CoreLayer *layer, void *driver_data, void *layer_data ); /* * Called once by the master for each source. * Driver fills description. */ DFBResult (*InitSource) ( CoreLayer *layer, void *driver_data, void *layer_data, int source, DFBDisplayLayerSourceDescription *description ); /** Layer Control **/ /* * Return the currently displayed field (interlaced only). */ DFBResult (*GetCurrentOutputField)( CoreLayer *layer, void *driver_data, void *layer_data, int *field ); /* * Return the z position of the layer. */ DFBResult (*GetLevel) ( CoreLayer *layer, void *driver_data, void *layer_data, int *level ); /* * Move the layer below or on top of others (z position). */ DFBResult (*SetLevel) ( CoreLayer *layer, void *driver_data, void *layer_data, int level ); /** Configuration **/ /* * Adjust brightness, contrast, saturation etc. */ DFBResult (*SetColorAdjustment) ( CoreLayer *layer, void *driver_data, void *layer_data, DFBColorAdjustment *adjustment ); /* * Set the stereo depth for L/R mono and stereo layers. // FIXME: Use SetRegion()! */ DFBResult (*SetStereoDepth) ( CoreLayer *layer, void *driver_data, void *layer_data, bool follow_video, int z ); /** Region Control **/ /* * Check all parameters and return if this region is supported. */ DFBResult (*TestRegion) ( CoreLayer *layer, void *driver_data, void *layer_data, CoreLayerRegionConfig *config, CoreLayerRegionConfigFlags *failed ); /* * Add a new region to the layer, but don't program hardware, yet. */ DFBResult (*AddRegion) ( CoreLayer *layer, void *driver_data, void *layer_data, void *region_data, CoreLayerRegionConfig *config ); /* * Setup hardware, called once after AddRegion() or when parameters * have changed. Surface and palette are only set if updated or new. */ DFBResult (*SetRegion) ( CoreLayer *layer, void *driver_data, void *layer_data, void *region_data, CoreLayerRegionConfig *config, CoreLayerRegionConfigFlags updated, CoreSurface *surface, CorePalette *palette, CoreSurfaceBufferLock *left_lock, CoreSurfaceBufferLock *right_lock ); /* * Remove a region from the layer. */ DFBResult (*RemoveRegion) ( CoreLayer *layer, void *driver_data, void *layer_data, void *region_data ); /* * Flip the surface of the region. */ DFBResult (*FlipRegion) ( CoreLayer *layer, void *driver_data, void *layer_data, void *region_data, CoreSurface *surface, DFBSurfaceFlipFlags flags, CoreSurfaceBufferLock *left_lock, CoreSurfaceBufferLock *right_lock ); /* * Indicate updates to the front buffer content. */ DFBResult (*UpdateRegion) ( CoreLayer *layer, void *driver_data, void *layer_data, void *region_data, CoreSurface *surface, const DFBRegion *left_update, CoreSurfaceBufferLock *left_lock, const DFBRegion *right_update, CoreSurfaceBufferLock *right_lock ); /* * Control hardware deinterlacing. */ DFBResult (*SetInputField)( CoreLayer *layer, void *driver_data, void *layer_data, void *region_data, int field ); /** Override defaults. Subject to change. **/ /* * Allocate the surface of the region. */ DFBResult (*AllocateSurface) ( CoreLayer *layer, void *driver_data, void *layer_data, void *region_data, CoreLayerRegionConfig *config, CoreSurface **ret_surface ); /* * Reallocate the surface of the region. */ DFBResult (*ReallocateSurface)( CoreLayer *layer, void *driver_data, void *layer_data, void *region_data, CoreLayerRegionConfig *config, CoreSurface *surface ); /* * Deallocate the surface of the region. */ DFBResult (*DeallocateSurface)( CoreLayer *layer, void *driver_data, void *layer_data, void *region_data, CoreSurface *surface ); } DisplayLayerFuncs; /* * Add a layer to a graphics device by pointing to a table * containing driver functions. The supplied driver data * will be passed to these functions. */ CoreLayer *dfb_layers_register( CoreScreen *screen, void *driver_data, const DisplayLayerFuncs *funcs ); /* * Replace functions of the primary layer implementation by passing * an alternative driver function table. All non-NULL functions in the new * table replace the functions in the original function table. * The original function table is written to 'primary_funcs' before to allow * drivers to use existing functionality from the original implementation. */ CoreLayer *dfb_layers_hook_primary( CoreGraphicsDevice *device, void *driver_data, DisplayLayerFuncs *funcs, DisplayLayerFuncs *primary_funcs, void **primary_driver_data ); /* * Replace functions of the primary layer implementation completely by passing * an alternative driver function table. */ CoreLayer *dfb_layers_replace_primary( CoreGraphicsDevice *device, void *driver_data, DisplayLayerFuncs *funcs ); typedef DFBEnumerationResult (*DisplayLayerCallback) (CoreLayer *layer, void *ctx); void dfb_layers_enumerate( DisplayLayerCallback callback, void *ctx ); int dfb_layer_num( void ); CoreLayer *dfb_layer_at( DFBDisplayLayerID id ); CoreLayer *dfb_layer_at_translated( DFBDisplayLayerID id ); void dfb_layer_get_description( const CoreLayer *layer, DFBDisplayLayerDescription *desc ); CoreScreen *dfb_layer_screen( const CoreLayer *layer ); CardState *dfb_layer_state( CoreLayer *layer ); DFBDisplayLayerID dfb_layer_id( const CoreLayer *layer ); DFBDisplayLayerID dfb_layer_id_translated( const CoreLayer *layer ); DFBDisplayLayerID dfb_layer_id_translate( DFBDisplayLayerID layer_id ); DFBSurfacePixelFormat dfb_primary_layer_pixelformat( void ); #endif
看文档都知道,关键输出到显示器上在于primarylayer
看下layers.h,知道接口的定义
其实这些封装就是用C写带面向对象思想的代码封装
然后订制system
DFB_CORE_SYSTEM( userdefined ) static void system_get_info( CoreSystemInfo *info ); static DFBResult system_initialize( CoreDFB *core, void **data );
这几个接口比较重要,需要操作
data就是私有数据,用来存放你的system的结构体,用C++思想去想想就很清楚了
其它system类接口可以没操作,但必须给实现,他没继承这个操作,所以没有基类这种东西
static DFBResult system_initialize( CoreDFB *core, void **data ) { char *driver; CoreScreen *screen; /* init */ D_ASSERT( g_dfb_bcm == NULL ); g_dfb_bcm = (DFB_BCM_T*) SHCALLOC( dfb_core_shmpool(core), 1, sizeof(DFB_BCM_T) ); if (!g_dfb_bcm) { D_ERROR( "DirectFB/BCMNEXUS: Couldn't allocate shared memory!\n" ); return D_OOSHM(); } g_dfb_bcm_core = core; InitBcmNexus(); /* Register */ g_dfb_bcm->data_shmpool = dfb_core_shmpool_data( core ); dfb_surface_pool_initialize( core, &bcmSurfacePoolFuncs, &g_dfb_bcm->bcm_pool ); fusion_skirmish_init( &g_dfb_bcm->lock, "BCM System", dfb_core_world(core) ); fusion_call_init( &g_dfb_bcm->call, dfb_bcm_call_handler, NULL, dfb_core_world(core) ); screen = dfb_screens_register( NULL, g_dfb_bcm, g_bcmscreenScreenFuncs ); dfb_layers_register( screen, g_dfb_bcm, g_bcmscreenLayerFuncs ); *data = g_dfb_bcm; return DFB_OK; }
我是基于bcm的板子上做的
typedef struct { /* Private Data */ FusionSkirmish lock; FusionCall call; FusionSHMPoolShared *data_shmpool; CoreSurfacePool *bcm_pool; UpdateScreenData update; }DFB_BCM_T;
/****************************************************************************** Type Declare ******************************************************************************/ typedef struct { int layer_id; void* pBuffer; } BcmLayerData; typedef enum { BCM_UPDATE_SCREEN, } DFBBCMCall; /****************************************************************************** Local Function Declare ******************************************************************************/ /* ScreenFuncs */ static DFBResult bcmscreenInitScreen( CoreScreen *screen, CoreGraphicsDevice *device, void *driver_data, void *screen_data, DFBScreenDescription *description ); static DFBResult bcmscreenGetScreenSize( CoreScreen *screen, void *driver_data, void *screen_data, int *ret_width, int *ret_height ); /* DisplayLayerFuncs */ static int bcmscreenLayerDataSize( void ); static int bcmscreenRegionDataSize( void ); static DFBResult bcmscreenInitLayer( CoreLayer *layer, void *driver_data, void *layer_data, DFBDisplayLayerDescription *description, DFBDisplayLayerConfig *config, DFBColorAdjustment *adjustment ); static DFBResult bcmscreenTestRegion( CoreLayer *layer, void *driver_data, void *layer_data, CoreLayerRegionConfig *config, CoreLayerRegionConfigFlags *failed ); static DFBResult bcmscreenAddRegion( CoreLayer *layer, void *driver_data, void *layer_data, void *region_data, CoreLayerRegionConfig *config ); static DFBResult bcmscreenSetRegion( CoreLayer *layer, void *driver_data, void *layer_data, void *region_data, CoreLayerRegionConfig *config, CoreLayerRegionConfigFlags updated, CoreSurface *surface, CorePalette *palette, CoreSurfaceBufferLock *lock ); static DFBResult bcmscreenRemoveRegion( CoreLayer *layer, void *driver_data, void *layer_data, void *region_data ); static DFBResult bcmscreenFlipRegion( CoreLayer *layer, void *driver_data, void *layer_data, void *region_data, CoreSurface *surface, DFBSurfaceFlipFlags flags, CoreSurfaceBufferLock *lock ); static DFBResult bcmscreenUpdateRegion( CoreLayer *layer, void *driver_data, void *layer_data, void *region_data, CoreSurface *surface, const DFBRegion *left_update, CoreSurfaceBufferLock *left_lock, const DFBRegion *right_update, CoreSurfaceBufferLock *right_lock ); static DFBResult bcmSetStereoDepth( CoreLayer *layer, void *driver_data, void *layer_data, bool follow_video, int z ); /* */ static DFBResult update_screen( const DFBRectangle *clip, CoreSurfaceBufferLock *lock); /****************************************************************************** Variable ******************************************************************************/ static ScreenFuncs bcmscreenScreenFuncs = { .InitScreen = bcmscreenInitScreen, .GetScreenSize = bcmscreenGetScreenSize, }; static DisplayLayerFuncs bcmscreenLayerFuncs = { .LayerDataSize = bcmscreenLayerDataSize, .RegionDataSize = bcmscreenRegionDataSize, .InitLayer = bcmscreenInitLayer, .TestRegion = bcmscreenTestRegion, .AddRegion = bcmscreenAddRegion, .SetRegion = bcmscreenSetRegion, .SetStereoDepth = bcmSetStereoDepth, .RemoveRegion = bcmscreenRemoveRegion, .FlipRegion = bcmscreenFlipRegion, .UpdateRegion = bcmscreenUpdateRegion, }; ScreenFuncs *g_bcmscreenScreenFuncs = &bcmscreenScreenFuncs; DisplayLayerFuncs *g_bcmscreenLayerFuncs = &bcmscreenLayerFuncs; /****************************************************************************** Local Function Implement ******************************************************************************/ /* ScreenFuncs */ static DFBResult bcmscreenInitScreen( CoreScreen *screen, CoreGraphicsDevice *device, void *driver_data, void *screen_data, DFBScreenDescription *description ) { /* Set the screen capabilities. */ /* Set the screen name. */ snprintf( description->name, DFB_SCREEN_DESC_NAME_LENGTH, "Bcm Primary Screen" ); return DFB_OK; } static DFBResult bcmscreenGetScreenSize( CoreScreen *screen, void *driver_data, void *screen_data, int *ret_width, int *ret_height ) { D_ASSERT( g_dfb_bcm != NULL ); if(g_dfb_bcm->primary != NULL) { *ret_width = g_dfb_bcm->bcm_w; *ret_height = g_dfb_bcm->bcm_h; } else { *ret_width = g_dfb_bcm->bcm_w; *ret_height = g_dfb_bcm->bcm_h; } return DFB_OK; } /* DisplayLayerFuncs */ static int bcmscreenLayerDataSize( void ) { return sizeof(BcmLayerData); } static int bcmscreenRegionDataSize( void ) { return 0; } static DFBResult bcmscreenInitLayer( CoreLayer *layer, void *driver_data, void *layer_data, DFBDisplayLayerDescription *description, DFBDisplayLayerConfig *config, DFBColorAdjustment *adjustment ) { /* set capabilities and type */ description->caps = DLCAPS_SURFACE; description->type = DLTF_GRAPHICS; /* set name */ snprintf( description->name, DFB_DISPLAY_LAYER_DESC_NAME_LENGTH, "Bcm Primary Layer" ); /* fill out the default configuration */ config->flags = DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_PIXELFORMAT | DLCONF_BUFFERMODE; config->buffermode = DLBM_FRONTONLY; D_ASSERT( g_dfb_bcm != NULL ); config->width = g_dfb_bcm->bcm_w; config->height = g_dfb_bcm->bcm_h; config->pixelformat = DSPF_ARGB; return DFB_OK; } static DFBResult bcmscreenTestRegion( CoreLayer *layer, void *driver_data, void *layer_data, CoreLayerRegionConfig *config, CoreLayerRegionConfigFlags *failed ) { CoreLayerRegionConfigFlags fail = 0; switch (config->buffermode) { case DLBM_FRONTONLY: case DLBM_BACKSYSTEM: case DLBM_BACKVIDEO: case DLBM_TRIPLE: break; default: fail |= CLRCF_BUFFERMODE; break; } switch (config->format) { case DSPF_LUT8: case DSPF_RGB16: case DSPF_NV16: case DSPF_RGB444: case DSPF_ARGB4444: case DSPF_RGBA4444: case DSPF_RGB555: case DSPF_ARGB1555: case DSPF_RGBA5551: case DSPF_BGR555: case DSPF_RGB24: case DSPF_RGB32: case DSPF_ARGB: case DSPF_ABGR: case DSPF_AYUV: case DSPF_AVYU: case DSPF_VYU: case DSPF_UYVY: case DSPF_ARGB8565: case DSPF_RGBAF88871: case DSPF_YUV444P: case DSPF_YV16: break; default: fail |= CLRCF_FORMAT; break; } if (config->options & ~(DLOP_ALPHACHANNEL | DLOP_LR_MONO | DLOP_STEREO)) fail |= CLRCF_OPTIONS; if (failed) *failed = fail; if (fail) return DFB_UNSUPPORTED; return DFB_OK; } static DFBResult bcmscreenAddRegion( CoreLayer *layer, void *driver_data, void *layer_data, void *region_data, CoreLayerRegionConfig *config ) { return DFB_OK; } static DFBResult bcmscreenSetRegion( CoreLayer *layer, void *driver_data, void *layer_data, void *region_data, CoreLayerRegionConfig *config, CoreLayerRegionConfigFlags updated, CoreSurface *surface, CorePalette *palette, CoreSurfaceBufferLock *lock ) { DFBResult ret; if (surface) g_dfb_bcm->primary = surface; return DFB_OK; } static DFBResult bcmscreenRemoveRegion( CoreLayer *layer, void *driver_data, void *layer_data, void *region_data ) { g_dfb_bcm->primary = NULL; return DFB_UNSUPPORTED; } static DFBResult bcmscreenFlipRegion( CoreLayer *layer, void *driver_data, void *layer_data, void *region_data, CoreSurface *surface, DFBSurfaceFlipFlags flags, CoreSurfaceBufferLock *lock ) { DFBRegion left_region; left_region.x1 = 0; left_region.y1 = 0; left_region.x2 = surface->config.size.w -1; left_region.y2 = surface->config.size.h -1; dfb_surface_flip( surface, false ); int ret; g_dfb_bcm->update.left_lock = *lock; g_dfb_bcm->update.left_region = left_region; if (fusion_call_execute( &g_dfb_bcm->call, FCEF_NONE, BCM_UPDATE_SCREEN, &g_dfb_bcm->update, &ret )) return DFB_FUSION; } static DFBResult bcmscreenUpdateRegion( CoreLayer *layer, void *driver_data, void *layer_data, void *region_data, CoreSurface *surface, const DFBRegion *left_update, CoreSurfaceBufferLock *left_lock, const DFBRegion *right_update, CoreSurfaceBufferLock *right_lock ) { DFBRegion left_region; left_region.x1 = 0; left_region.y1 = 0; left_region.x2 = surface->config.size.w -1; left_region.y2 = surface->config.size.h -1; int ret; g_dfb_bcm->update.left_lock = *left_lock; g_dfb_bcm->update.left_region = left_region; if (fusion_call_execute( &g_dfb_bcm->call, FCEF_NONE, BCM_UPDATE_SCREEN, &g_dfb_bcm->update, &ret )) return DFB_FUSION; return DFB_OK; } static DFBResult bcmSetStereoDepth( CoreLayer *layer, void *driver_data, void *layer_data, bool follow_video, int z ) { return DFB_OK; }
处理screen和layer的操作
typedef struct { }bcmPoolData; typedef struct { void* pBufferPtr; DFB_BCM_T* pBcm; }bcmPoolLocalData; /**********************************************************************************************************************/ static int bcmPoolDataSize( void ) { return sizeof(bcmPoolData); } static int bcmPoolLocalDataSize( void ) { return sizeof(bcmPoolLocalData); } static int bcmAllocationDataSize( void ) { return sizeof(bcmAllocationData); } static DFBResult bcmInitPool( CoreDFB *core, CoreSurfacePool *pool, void *pool_data, void *pool_local, void *system_data, CoreSurfacePoolDescription *ret_desc ) { bcmPoolLocalData *local = pool_local; DFB_BCM_T* pBcm = (DFB_BCM_T*)system_data; local->pBufferPtr = NULL; local->pBcm = pBcm; ret_desc->caps = CSPCAPS_VIRTUAL; ret_desc->access[CSAID_CPU] = CSAF_READ | CSAF_WRITE | CSAF_SHARED; ret_desc->types = CSTF_LAYER | CSTF_WINDOW | CSTF_CURSOR | CSTF_FONT | CSTF_SHARED | CSTF_EXTERNAL; ret_desc->priority = CSPP_DEFAULT; /* For showing our X11 window */ ret_desc->access[CSAID_LAYER0] = CSAF_READ; ret_desc->access[CSAID_LAYER1] = CSAF_READ; ret_desc->access[CSAID_LAYER2] = CSAF_READ; snprintf( ret_desc->name, DFB_SURFACE_POOL_DESC_NAME_LENGTH, "bcm buffer" ); return DFB_OK; } static DFBResult bcmJoinPool( CoreDFB *core, CoreSurfacePool *pool, void *pool_data, void *pool_local, void *system_data ) { return DFB_OK; } static DFBResult bcmDestroyPool( CoreSurfacePool *pool, void *pool_data, void *pool_local ) { bcmPoolLocalData *local = pool_local; if(local->pBufferPtr != NULL) { SHFREE(local->pBcm->data_shmpool, local->pBufferPtr); local->pBufferPtr = NULL; } return DFB_OK; } static DFBResult bcmLeavePool( CoreSurfacePool *pool, void *pool_data, void *pool_local ) { return DFB_OK; } static DFBResult bcmTestConfig( CoreSurfacePool *pool, void *pool_data, void *pool_local, CoreSurfaceBuffer *buffer, const CoreSurfaceConfig *config ) { return DFB_OK; } static DFBResult bcmAllocateBuffer( CoreSurfacePool *pool, void *pool_data, void *pool_local, CoreSurfaceBuffer *buffer, CoreSurfaceAllocation *allocation, void *alloc_data ) { bcmPoolLocalData *local = pool_local; bcmAllocationData* alloc = (bcmAllocationData*)alloc_data; alloc->pitch = ; return DFB_OK; } static DFBResult bcmDeallocateBuffer( CoreSurfacePool *pool, void *pool_data, void *pool_local, CoreSurfaceBuffer *buffer, CoreSurfaceAllocation *allocation, void *alloc_data ) { bcmPoolLocalData *local = pool_local; return DFB_OK; } static DFBResult bcmLock( CoreSurfacePool *pool, void *pool_data, void *pool_local, CoreSurfaceAllocation *allocation, void *alloc_data, CoreSurfaceBufferLock *lock ) { bcmPoolLocalData *local = pool_local; bcmAllocationData* alloc = (bcmAllocationData*)alloc_data; lock->addr = /* Framebuffer addr */ lock->pitch = alloc->pitch; //printf("addr: %p\n", lock->addr); return DFB_OK; } static DFBResult bcmUnlock( CoreSurfacePool *pool, void *pool_data, void *pool_local, CoreSurfaceAllocation *allocation, void *alloc_data, CoreSurfaceBufferLock *lock ) { return DFB_OK; } const SurfacePoolFuncs bcmSurfacePoolFuncs = { .PoolDataSize = bcmPoolDataSize, .PoolLocalDataSize = bcmPoolLocalDataSize, .AllocationDataSize = bcmAllocationDataSize, .InitPool = bcmInitPool, .JoinPool = bcmJoinPool, .DestroyPool = bcmDestroyPool, .LeavePool = bcmLeavePool, .TestConfig = bcmTestConfig, .AllocateBuffer = bcmAllocateBuffer, .DeallocateBuffer = bcmDeallocateBuffer, .Lock = bcmLock, .Unlock = bcmUnlock, };
处理pool的操作
关键点在于lock操作,这里就是传递framebuffer地址的地方
结果图