From 69da2a817d28868dae9fdb6f099e337a4da0f74f Mon Sep 17 00:00:00 2001 From: Alexey Ivanov Date: Tue, 20 Oct 2015 16:55:08 +0300 Subject: [PATCH] 8130136: Swing window sometimes fails to repaint partially when it becomes exposed Reviewed-by: alexp, serb --- .../libawt/java2d/windows/GDIWindowSurfaceData.cpp | 8 +++++--- .../libawt/java2d/windows/GDIWindowSurfaceData.h | 3 ++- .../native/libawt/windows/awt_Component.cpp | 14 +++++++------- .../windows/native/libawt/windows/awt_Component.h | 6 +++--- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/jdk/src/java.desktop/windows/native/libawt/java2d/windows/GDIWindowSurfaceData.cpp b/jdk/src/java.desktop/windows/native/libawt/java2d/windows/GDIWindowSurfaceData.cpp index b52dce038a0..95e737340fb 100644 --- a/jdk/src/java.desktop/windows/native/libawt/java2d/windows/GDIWindowSurfaceData.cpp +++ b/jdk/src/java.desktop/windows/native/libawt/java2d/windows/GDIWindowSurfaceData.cpp @@ -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 @@ void SetupThreadGraphicsInfo(JNIEnv *env, GDIWinSDOps *wsdo) { // 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 @@ void SetupThreadGraphicsInfo(JNIEnv *env, GDIWinSDOps *wsdo) { // 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 @@ void DisposeThreadGraphicsInfo(JNIEnv *env, jlong tgi) { 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) { diff --git a/jdk/src/java.desktop/windows/native/libawt/java2d/windows/GDIWindowSurfaceData.h b/jdk/src/java.desktop/windows/native/libawt/java2d/windows/GDIWindowSurfaceData.h index 3dfaa161c02..a954874e9c8 100644 --- a/jdk/src/java.desktop/windows/native/libawt/java2d/windows/GDIWindowSurfaceData.h +++ b/jdk/src/java.desktop/windows/native/libawt/java2d/windows/GDIWindowSurfaceData.h @@ -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 @@ extern "C" { */ typedef struct { HDC hDC; + HWND hWnd; GDIWinSDOps *wsdo; LONG wsdoTimeStamp; // wsdo creation time stamp. // Other threads may deallocate wsdo diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp index 6b1c1255319..b234ec0221b 100644 --- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp +++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp @@ -1382,7 +1382,7 @@ LRESULT AwtComponent::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) case WM_AWT_RELEASEDC: { HDC hDC = (HDC)wParam; - MoveDCToPassiveList(hDC); + MoveDCToPassiveList(hDC, GetHWnd()); ReleaseDCList(GetHWnd(), passiveDCList); mr = mrConsume; break; @@ -7165,8 +7165,8 @@ void DCList::AddDCItem(DCItem *newItem) } /** - * 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 @@ void DCList::AddDCItem(DCItem *newItem) * 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 @@ void DCList::RealizePalettes(int screen) 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); } } diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.h b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.h index 9fe2754142b..f09b41f5b54 100644 --- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.h +++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.h @@ -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 @@ public: 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"