/** 更新各种图形元素的显示 */ static void LCUIDisplay_Update(void) { int i, n, j, m; LCUI_Rect *p_rect; SurfaceRecord *p_sr; LCUI_DirtyRectList rlist; LCUI_PaintContext paint; DirtyRectList_Init( &rlist ); n = LinkedList_GetTotal( &display.surfaces ); /* 遍历当前的 surface 记录列表 */ for( i=0; i<n; ++i ) { LinkedList_Goto( &display.surfaces, i ); p_sr = (SurfaceRecord*) LinkedList_Get( &display.surfaces ); if( !p_sr->widget || !p_sr->surface || !Surface_IsReady(p_sr->surface) ) { continue; } /* 更新表面 */ Surface_Update( p_sr->surface ); /* 收集无效区域记录 */ Widget_ProcInvalidArea( p_sr->widget, &rlist ); m = LinkedList_GetTotal( &rlist ); DEBUG_MSG("proc invalid area, m = %d\n", m); LinkedList_Goto( &rlist, 0 ); /* 在 surface 上逐个重绘无效区域 */ for( j=0; j<m; ++j ) { p_rect = (LCUI_Rect*)LinkedList_Get( &rlist ); paint = Surface_BeginPaint( p_sr->surface, p_rect ); DEBUG_MSG( "[%s]: render rect: (%d,%d,%d,%d), %d\n", p_sr->widget->type, paint->rect.left, paint->rect.top, paint->rect.w, paint->rect.h, j ); Widget_Render( p_sr->widget, paint ); Surface_EndPaint( p_sr->surface, paint ); LinkedList_Delete( &rlist ); } if( m > 0 ) { Surface_Present( p_sr->surface ); } } LinkedList_Destroy( &rlist ); }
/** 更新各种图形元素的显示 */ static void LCUIDisplay_Update(void) { LinkedList rlist; SurfaceRecord *p_sr; LinkedListNode *sn, *rn; LCUI_PaintContext paint; LinkedList_Init( &rlist ); /* 遍历当前的 surface 记录列表 */ for( LinkedList_Each( sn, &display.surfaces ) ) { p_sr = sn->data; if( !p_sr->widget || !p_sr->surface || !Surface_IsReady(p_sr->surface) ) { continue; } Surface_Update( p_sr->surface ); /* 收集无效区域记录 */ Widget_ProcInvalidArea( p_sr->widget, &rlist ); /* 在 surface 上逐个重绘无效区域 */ for( LinkedList_Each( rn, &rlist ) ) { paint = Surface_BeginPaint( p_sr->surface, rn->data ); if( !paint ) { continue; } DEBUG_MSG( "[%s]: render rect: (%d,%d,%d,%d)\n", p_sr->widget->type, paint->rect.left, paint->rect.top, paint->rect.w, paint->rect.h ); Widget_Render( p_sr->widget, paint ); if( display.show_rect_border ) { DrawBorder( paint ); } Surface_EndPaint( p_sr->surface, paint ); } if( rlist.length > 0 ) { Surface_Present( p_sr->surface ); } RectList_Clear( &rlist ); } RectList_Clear( &rlist ); }