8130136: Swing window sometimes fails to repaint partially when it becomes exposed

Reviewed-by: alexp, serb
This commit is contained in:
Alexey Ivanov 2015-10-20 16:55:08 +03:00
parent d910e3843f
commit 69da2a817d
4 changed files with 17 additions and 14 deletions

View File

@ -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) {

View File

@ -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

View File

@ -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);
}
}

View File

@ -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"