|
是这样的,项目中有大量的 将一个IMAGE从A位置移动到B位置 这样的操作
目前采用的是WM_MoveChildTo实现移动
看了下它的代码发现这个函数其中有两次分别对新区域和旧区域的无效刷新
- /*********************************************************************
- *
- * WM_MoveChildTo
- */
- void WM_MoveChildTo(WM_HWIN hWin, int x, int y) {
- WM_HWIN hParent;
- WM_Obj * pParent;
- WM_Obj * pWin;
- if (hWin) {
- WM_LOCK();
- hParent = WM_GetParent(hWin);
- if (hParent) {
- pParent = WM_LOCK_H(hParent);
- pWin = WM_LOCK_H(hWin);
- x -= pWin->Rect.x0 - pParent->Rect.x0;
- y -= pWin->Rect.y0 - pParent->Rect.y0;
- GUI_UNLOCK_H(pParent);
- GUI_UNLOCK_H(pWin);
- /*********************************/
- WM__MoveWindow(hWin, x, y);
复制代码
- /*********************************************************************
- *
- * WM__MoveWindow
- */
- void WM__MoveWindow(WM_HWIN hWin, int dx, int dy) {
- WM_Obj * pWin;
- WM_HWIN hFirstChild;
- GUI_RECT r;
- WM_MOVE_INFO Info;
- WM_MESSAGE Msg = {0};
- if ((hWin) && (dx || dy)) {
- pWin = WM_LOCK_H(hWin);
- r = pWin->Rect;
- GUI_MoveRect(&pWin->Rect, dx, dy);
- GUI_MoveRect(&pWin->InvalidRect, dx, dy);
- hFirstChild = pWin->hFirstChild;
- GUI_UNLOCK_H(pWin);
- _MoveDescendents(hFirstChild, dx, dy); // Children need to be moved along
- //
- // Invalidate old and new area
- //
- pWin = WM_LOCK_H(hWin);
- if ((pWin->Status & WM_SF_ISVIS) && (pWin->hParent)) {
复制代码
所以我想
移动窗口既然刷新两次和图片大小相同的区域
和单纯的创建两个不同位置的控件,需要移动时进行Hide、Show的操作相比会不会更耗资源呢
(当然,Show和Hide也会对相应的区域进行一次无效化)
|
|