1365 DCX_CLIPSIBLINGS);
1366 if (hDC != NULL) {
1367 // Add new DC to list of DC's associated with this Component
1368 activeDCList.AddDC(hDC, GetHWnd());
1369 } else {
1370 // Creation failed; decrement counter in AwtGDIObject
1371 AwtGDIObject::Decrement();
1372 }
1373 } else {
1374 hDC = NULL;
1375 returnStruct->gdiLimitReached = TRUE;
1376 }
1377 returnStruct->hDC = hDC;
1378 retValue = (LRESULT)returnStruct;
1379 mr = mrConsume;
1380 break;
1381 }
1382 case WM_AWT_RELEASEDC:
1383 {
1384 HDC hDC = (HDC)wParam;
1385 MoveDCToPassiveList(hDC);
1386 ReleaseDCList(GetHWnd(), passiveDCList);
1387 mr = mrConsume;
1388 break;
1389 }
1390 case WM_AWT_RELEASE_ALL_DCS:
1391 {
1392 // Called during Component destruction. Gets current list of
1393 // DC's associated with Component and releases each DC.
1394 ReleaseDCList(GetHWnd(), activeDCList);
1395 ReleaseDCList(GetHWnd(), passiveDCList);
1396 mr = mrConsume;
1397 break;
1398 }
1399 case WM_AWT_SHOWCURSOR:
1400 ::ShowCursor(TRUE);
1401 break;
1402 case WM_AWT_HIDECURSOR:
1403 ::ShowCursor(FALSE);
1404 break;
1405 case WM_CREATE: mr = WmCreate(); break;
7157 }
7158
7159 void DCList::AddDCItem(DCItem *newItem)
7160 {
7161 listLock.Enter();
7162 newItem->next = head;
7163 head = newItem;
7164 listLock.Leave();
7165 }
7166
7167 /**
7168 * Given a DC, remove it from the DC list and return
7169 * TRUE if it exists on the current list. Otherwise
7170 * return FALSE.
7171 * A DC may not exist on the list because it has already
7172 * been released elsewhere (for example, the window
7173 * destruction process may release a DC while a rendering
7174 * thread may also want to release a DC when it notices that
7175 * its DC is obsolete for the current window).
7176 */
7177 DCItem *DCList::RemoveDC(HDC hDC)
7178 {
7179 listLock.Enter();
7180 DCItem **prevPtrPtr = &head;
7181 DCItem *listPtr = head;
7182 while (listPtr) {
7183 DCItem *nextPtr = listPtr->next;
7184 if (listPtr->hDC == hDC) {
7185 *prevPtrPtr = nextPtr;
7186 break;
7187 }
7188 prevPtrPtr = &listPtr->next;
7189 listPtr = nextPtr;
7190 }
7191 listLock.Leave();
7192 return listPtr;
7193 }
7194
7195 /**
7196 * Remove all DCs from the DC list which are associated with
7197 * the same window as hWnd. Return the list of those
7198 * DC's to the caller (which will then probably want to
7199 * call ReleaseDC() for the returned DCs).
7200 */
7201 DCItem *DCList::RemoveAllDCs(HWND hWnd)
7202 {
7203 listLock.Enter();
7204 DCItem **prevPtrPtr = &head;
7218 }
7219 listLock.Leave();
7220 return newListPtr;
7221 }
7222
7223
7224 /**
7225 * Realize palettes of all existing HDC objects
7226 */
7227 void DCList::RealizePalettes(int screen)
7228 {
7229 listLock.Enter();
7230 DCItem *listPtr = head;
7231 while (listPtr) {
7232 AwtWin32GraphicsDevice::RealizePalette(listPtr->hDC, screen);
7233 listPtr = listPtr->next;
7234 }
7235 listLock.Leave();
7236 }
7237
7238 void MoveDCToPassiveList(HDC hDC) {
7239 DCItem *removedDC;
7240 if ((removedDC = activeDCList.RemoveDC(hDC)) != NULL) {
7241 passiveDCList.AddDCItem(removedDC);
7242 }
7243 }
7244
7245 void ReleaseDCList(HWND hwnd, DCList &list) {
7246 DCItem *removedDCs = list.RemoveAllDCs(hwnd);
7247 while (removedDCs) {
7248 DCItem *tmpDCList = removedDCs;
7249 DASSERT(::GetObjectType(tmpDCList->hDC) == OBJ_DC);
7250 int retValue = ::ReleaseDC(tmpDCList->hWnd, tmpDCList->hDC);
7251 VERIFY(retValue != 0);
7252 if (retValue != 0) {
7253 // Valid ReleaseDC call; need to decrement GDI object counter
7254 AwtGDIObject::Decrement();
7255 }
7256 removedDCs = removedDCs->next;
7257 delete tmpDCList;
7258 }
7259 }
7260
|
1365 DCX_CLIPSIBLINGS);
1366 if (hDC != NULL) {
1367 // Add new DC to list of DC's associated with this Component
1368 activeDCList.AddDC(hDC, GetHWnd());
1369 } else {
1370 // Creation failed; decrement counter in AwtGDIObject
1371 AwtGDIObject::Decrement();
1372 }
1373 } else {
1374 hDC = NULL;
1375 returnStruct->gdiLimitReached = TRUE;
1376 }
1377 returnStruct->hDC = hDC;
1378 retValue = (LRESULT)returnStruct;
1379 mr = mrConsume;
1380 break;
1381 }
1382 case WM_AWT_RELEASEDC:
1383 {
1384 HDC hDC = (HDC)wParam;
1385 MoveDCToPassiveList(hDC, GetHWnd());
1386 ReleaseDCList(GetHWnd(), passiveDCList);
1387 mr = mrConsume;
1388 break;
1389 }
1390 case WM_AWT_RELEASE_ALL_DCS:
1391 {
1392 // Called during Component destruction. Gets current list of
1393 // DC's associated with Component and releases each DC.
1394 ReleaseDCList(GetHWnd(), activeDCList);
1395 ReleaseDCList(GetHWnd(), passiveDCList);
1396 mr = mrConsume;
1397 break;
1398 }
1399 case WM_AWT_SHOWCURSOR:
1400 ::ShowCursor(TRUE);
1401 break;
1402 case WM_AWT_HIDECURSOR:
1403 ::ShowCursor(FALSE);
1404 break;
1405 case WM_CREATE: mr = WmCreate(); break;
7157 }
7158
7159 void DCList::AddDCItem(DCItem *newItem)
7160 {
7161 listLock.Enter();
7162 newItem->next = head;
7163 head = newItem;
7164 listLock.Leave();
7165 }
7166
7167 /**
7168 * Given a DC, remove it from the DC list and return
7169 * TRUE if it exists on the current list. Otherwise
7170 * return FALSE.
7171 * A DC may not exist on the list because it has already
7172 * been released elsewhere (for example, the window
7173 * destruction process may release a DC while a rendering
7174 * thread may also want to release a DC when it notices that
7175 * its DC is obsolete for the current window).
7176 */
7177 DCItem *DCList::RemoveDC(HDC hDC, HWND hWnd)
7178 {
7179 listLock.Enter();
7180 DCItem **prevPtrPtr = &head;
7181 DCItem *listPtr = head;
7182 while (listPtr) {
7183 DCItem *nextPtr = listPtr->next;
7184 if (listPtr->hDC == hDC && listPtr->hWnd == hWnd) {
7185 *prevPtrPtr = nextPtr;
7186 break;
7187 }
7188 prevPtrPtr = &listPtr->next;
7189 listPtr = nextPtr;
7190 }
7191 listLock.Leave();
7192 return listPtr;
7193 }
7194
7195 /**
7196 * Remove all DCs from the DC list which are associated with
7197 * the same window as hWnd. Return the list of those
7198 * DC's to the caller (which will then probably want to
7199 * call ReleaseDC() for the returned DCs).
7200 */
7201 DCItem *DCList::RemoveAllDCs(HWND hWnd)
7202 {
7203 listLock.Enter();
7204 DCItem **prevPtrPtr = &head;
7218 }
7219 listLock.Leave();
7220 return newListPtr;
7221 }
7222
7223
7224 /**
7225 * Realize palettes of all existing HDC objects
7226 */
7227 void DCList::RealizePalettes(int screen)
7228 {
7229 listLock.Enter();
7230 DCItem *listPtr = head;
7231 while (listPtr) {
7232 AwtWin32GraphicsDevice::RealizePalette(listPtr->hDC, screen);
7233 listPtr = listPtr->next;
7234 }
7235 listLock.Leave();
7236 }
7237
7238 void MoveDCToPassiveList(HDC hDC, HWND hWnd) {
7239 DCItem *removedDC;
7240 if ((removedDC = activeDCList.RemoveDC(hDC, hWnd)) != NULL) {
7241 passiveDCList.AddDCItem(removedDC);
7242 }
7243 }
7244
7245 void ReleaseDCList(HWND hwnd, DCList &list) {
7246 DCItem *removedDCs = list.RemoveAllDCs(hwnd);
7247 while (removedDCs) {
7248 DCItem *tmpDCList = removedDCs;
7249 DASSERT(::GetObjectType(tmpDCList->hDC) == OBJ_DC);
7250 int retValue = ::ReleaseDC(tmpDCList->hWnd, tmpDCList->hDC);
7251 VERIFY(retValue != 0);
7252 if (retValue != 0) {
7253 // Valid ReleaseDC call; need to decrement GDI object counter
7254 AwtGDIObject::Decrement();
7255 }
7256 removedDCs = removedDCs->next;
7257 delete tmpDCList;
7258 }
7259 }
7260
|