changeset 8941:4fe1830bc1d6

8130136, PR3162: Swing window sometimes fails to repaint partially when it becomes exposed Reviewed-by: alexp, serb
author aivanov
date Wed, 26 Oct 2016 16:05:53 +0100
parents 14a416fcd6b4
children a9509bcc915f
files src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.cpp src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.h src/windows/native/sun/windows/awt_Component.cpp src/windows/native/sun/windows/awt_Component.h
diffstat 4 files changed, 17 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.cpp	Thu Oct 15 09:33:03 2015 +0100
+++ b/src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.cpp	Wed Oct 26 16:05:53 2016 +0100
@@ -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
@@ -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/src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.h	Thu Oct 15 09:33:03 2015 +0100
+++ b/src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.h	Wed Oct 26 16:05:53 2016 +0100
@@ -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/src/windows/native/sun/windows/awt_Component.cpp	Thu Oct 15 09:33:03 2015 +0100
+++ b/src/windows/native/sun/windows/awt_Component.cpp	Wed Oct 26 16:05:53 2016 +0100
@@ -1370,7 +1370,7 @@
       case WM_AWT_RELEASEDC:
       {
             HDC hDC = (HDC)wParam;
-            MoveDCToPassiveList(hDC);
+            MoveDCToPassiveList(hDC, GetHWnd());
             ReleaseDCList(GetHWnd(), passiveDCList);
             mr = mrConsume;
             break;
@@ -7103,8 +7103,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
@@ -7112,14 +7112,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;
         }
@@ -7173,9 +7173,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/src/windows/native/sun/windows/awt_Component.h	Thu Oct 15 09:33:03 2015 +0100
+++ b/src/windows/native/sun/windows/awt_Component.h	Wed Oct 26 16:05:53 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2012, 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
@@ -901,13 +901,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);
 
 namespace TimeHelper{
     jlong getMessageTimeUTC();