|
楼主 |
发表于 2007-12-20 16:45:05
|
显示全部楼层
static U8 *gdi_layer_allocate_buffer(gdi_color_format cf,S32 width,S32 height,S32 *ret_size)
{
S32 i;
U8 *next_available_ptr;
U8 *tmp_ptr;
S32 size;
size = gdi_sizeof_pixels(cf,width,height);
// allcoate buffer from pool, align buffer_size to 4 byte alignment
size += 3;
size &=~3;
next_available_ptr = (U8*)gdi_layer_buffer_pool; /* point to start of the pool */
/* iterate all layer, find last allocated position */
for(i = 0 ; i < GDI_LAYER_TOTAL_LAYER_COUNT; i++)
{
U32 x = GDI_LAYER_GET_FLAG(&GDI_LAYERS,GDI_LAYER_FLAG_USED|GDI_LAYER_FLAG_USE_OUTSIDE_MEMORY);
if( x == GDI_LAYER_FLAG_USED) // used & !outside memory
{
tmp_ptr = GDI_LAYERS.buf_ptr + GDI_LAYERS.layer_size;
if(tmp_ptr > next_available_ptr) next_available_ptr = tmp_ptr;
if(GDI_LAYER_GET_FLAG(&(GDI_LAYERS),GDI_LAYER_FLAG_DOUBLE_LAYER))
{
tmp_ptr = GDI_LAYERS.buf_ptr1 + GDI_LAYERS.layer_size;
if(tmp_ptr > next_available_ptr) next_available_ptr = tmp_ptr;
}
}
}
if(next_available_ptr + size - 1 > gdi_layer_buf_pool_end_ptr) /* out of valid buffer pool region */
{
/* no more buffer */
/////////////现在追踪到这里,发现是由这个断言引起的复位。怎么改法呢。next_available_ptr 是不是有什么问题
GDI_ASSERT(0);
return(NULL);
}
*ret_size = size;
/* if within valid region, assign buffer */
return(next_available_ptr);
} |
|