浅析minigui在fbcon模式FB_SetVideoMode建立surfaces图形可显示矩形区
surfaces是minigui所能操作的图形可显示矩形区,该surfaces有w-宽和h-高,也有mmap之后它位于framebuffer的第几个字节偏移值
surfaces.base,这样该surfaces表征的矩形区就出来了,以surfaces.base开始的w宽,h高的framebuffer内存矩形区间,就是该
surfaces所能操作的图形矩形区间[luther.gliethttp]
实际使用中可以使用CreateMemDC来从surfaces中申请一个具体的小surface矩形区,来由该DC填充图像[luther.gliethttp]
大部分时候surface就是一个临时内存区,比如:CreateCompatibleDC(HDC_SCREEN)他就是由malloc生成,;
[而不是调用video->AllocHWSurface(),从video的framebuffer后面申请内存]用来存放临时显示数据,
而不是直接将数据写到framebuffer中,以减少闪烁[luther.gliethttp]
InitGAL
==> __gal_screen = GAL_SetVideoMode (w, h, depth, GAL_HWPALETTE)
==> 最终调用FB_SetVideoMode
==*>
/* Set up the new mode framebuffer */
current->flags = (GAL_FULLSCREEN|GAL_HWSURFACE);
current->w = vinfo.xres;
current->h = vinfo.yres;
current->pitch = finfo.line_length;
current->pixels = mapped_mem+mapped_offset;
/* Set up the information for hardware surfaces */
surfaces_mem = (char *)current->pixels + // 欲建立的surfaces小区块开始地址,这里计算完之后,
// 等于current->pixels+mapped_memlen
vinfo.yres_virtual*current->pitch;
surfaces_len = (mapped_memlen-(surfaces_mem-mapped_mem)); // 所以这里surfaces_len等于0
FB_FreeHWSurfaces(this);
FB_InitHWSurfaces(this, current, surfaces_mem, surfaces_len);
static int FB_InitHWSurfaces(_THIS, GAL_Surface *screen, char *base, int size)
{
vidmem_bucket *bucket;
// 这里size等于0 [lutehr.gliethttp]
surfaces_memtotal = size;
surfaces_memleft = size;
if ( surfaces_memleft > 0 ) {
bucket = (vidmem_bucket *)malloc(sizeof(*bucket));
if ( bucket == NULL ) {
GAL_OutOfMemory();
return(-1);
}
bucket->prev = &surfaces;
bucket->used = 0;
bucket->dirty = 0;
bucket->base = base;
bucket->size = size;
bucket->next = NULL;
} else {
bucket = NULL;
}
surfaces.prev = NULL;
surfaces.used = 1;
surfaces.dirty = 0;
surfaces.base = screen->pixels; // 由mmap映射的framebuffer首地址[luther.gliethttp]
surfaces.size = (unsigned int)((long)base - (long)surfaces.base); // 明显计算之后大小为mapped_memlen
// 所以该surfaces管理可显示区的是整个lcd屏幕
surfaces.next = bucket; // 该surfaces区块管理的所有具有操作framebuffer缓冲区的bucket小区块[luther.gliethttp]
screen->hwdata = (struct private_hwdata *)&surfaces; // 该screen的硬件framebuffer数据管理区块[luther.gliethttp]
return(0);
}
来看看几个引用实例
#define GAL_AllocSurface GAL_CreateRGBSurface
GAL_CreateRGBSurface
video->AllocHWSurface(this, surface)
FB_AllocHWSurface
FB_RequestHWSurface
libminigui-1.6.10/src/newgdi/gdi.c
CreateMemDC
GAL_CreateRGBSurface
video->AllocHWSurface(this, surface)
FB_AllocHWSurface
FB_RequestHWSurface
#define CreateCompatibleDC(hdc) CreateCompatibleDCEx(hdc, 0, 0);
CreateCompatibleDC(HDC_SCREEN);
GAL_CreateRGBSurface
surface->pixels = malloc(surface->h*surface->pitch);
阅读(3888) | 评论(0) | 转发(0) |