8130136: Swing window sometimes fails to repaint partially when it becomes exposed
Reviewed-by: alexp, serb
--- a/jdk/src/java.desktop/windows/native/libawt/java2d/windows/GDIWindowSurfaceData.cpp Tue Oct 20 15:59:51 2015 +0300
+++ b/jdk/src/java.desktop/windows/native/libawt/java2d/windows/GDIWindowSurfaceData.cpp Tue Oct 20 16:55:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -114,8 +114,9 @@
// which may've been disposed by this time, and we have
// no means of checking against it.
if (oldhDC != NULL) {
- MoveDCToPassiveList(oldhDC);
+ MoveDCToPassiveList(oldhDC, info->hWnd);
info->hDC = NULL;
+ info->hWnd = NULL;
}
if (wsdo->window != NULL){
@@ -150,6 +151,7 @@
// Finally, set these new values in the info for this thread
info->hDC = hDC;
+ info->hWnd = wsdo->window;
}
// cached brush and pen are not associated with any DC, and can be
@@ -187,7 +189,7 @@
if (info->hDC != NULL) {
// move the DC from the active dcs list to
// the passive dc list to be released later
- MoveDCToPassiveList(info->hDC);
+ MoveDCToPassiveList(info->hDC, info->hWnd);
}
if (info->clip != NULL) {
--- a/jdk/src/java.desktop/windows/native/libawt/java2d/windows/GDIWindowSurfaceData.h Tue Oct 20 15:59:51 2015 +0300
+++ b/jdk/src/java.desktop/windows/native/libawt/java2d/windows/GDIWindowSurfaceData.h Tue Oct 20 16:55:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -196,6 +196,7 @@
*/
typedef struct {
HDC hDC;
+ HWND hWnd;
GDIWinSDOps *wsdo;
LONG wsdoTimeStamp; // wsdo creation time stamp.
// Other threads may deallocate wsdo
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp Tue Oct 20 15:59:51 2015 +0300
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp Tue Oct 20 16:55:08 2015 +0300
@@ -1382,7 +1382,7 @@
case WM_AWT_RELEASEDC:
{
HDC hDC = (HDC)wParam;
- MoveDCToPassiveList(hDC);
+ MoveDCToPassiveList(hDC, GetHWnd());
ReleaseDCList(GetHWnd(), passiveDCList);
mr = mrConsume;
break;
@@ -7165,8 +7165,8 @@
}
/**
- * Given a DC, remove it from the DC list and return
- * TRUE if it exists on the current list. Otherwise
+ * Given a DC and window handle, remove the DC from the DC list
+ * and return TRUE if it exists on the current list. Otherwise
* return FALSE.
* A DC may not exist on the list because it has already
* been released elsewhere (for example, the window
@@ -7174,14 +7174,14 @@
* thread may also want to release a DC when it notices that
* its DC is obsolete for the current window).
*/
-DCItem *DCList::RemoveDC(HDC hDC)
+DCItem *DCList::RemoveDC(HDC hDC, HWND hWnd)
{
listLock.Enter();
DCItem **prevPtrPtr = &head;
DCItem *listPtr = head;
while (listPtr) {
DCItem *nextPtr = listPtr->next;
- if (listPtr->hDC == hDC) {
+ if (listPtr->hDC == hDC && listPtr->hWnd == hWnd) {
*prevPtrPtr = nextPtr;
break;
}
@@ -7235,9 +7235,9 @@
listLock.Leave();
}
-void MoveDCToPassiveList(HDC hDC) {
+void MoveDCToPassiveList(HDC hDC, HWND hWnd) {
DCItem *removedDC;
- if ((removedDC = activeDCList.RemoveDC(hDC)) != NULL) {
+ if ((removedDC = activeDCList.RemoveDC(hDC, hWnd)) != NULL) {
passiveDCList.AddDCItem(removedDC);
}
}
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.h Tue Oct 20 15:59:51 2015 +0300
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.h Tue Oct 20 16:55:08 2015 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -900,13 +900,13 @@
void AddDC(HDC hDC, HWND hWnd);
void AddDCItem(DCItem *newItem);
- DCItem *RemoveDC(HDC hDC);
+ DCItem *RemoveDC(HDC hDC, HWND hWnd);
DCItem *RemoveAllDCs(HWND hWnd);
void RealizePalettes(int screen);
};
void ReleaseDCList(HWND hwnd, DCList &list);
-void MoveDCToPassiveList(HDC hDC);
+void MoveDCToPassiveList(HDC hDC, HWND hWnd);
#include "ObjectList.h"