< prev index next >
src/java.desktop/windows/native/libawt/windows/awt_Palette.cpp
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2001, 2017, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 2001, 2020, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 28,39 ****
#include "awt_Component.h"
#include "img_util_md.h"
#include "awt_CustomPaletteDef.h"
#include "Trace.h"
- BOOL AwtPalette::m_useCustomPalette = TRUE;
-
#define ERROR_GRAY (-1)
#define NON_GRAY 0
#define LINEAR_STATIC_GRAY 1
#define NON_LINEAR_STATIC_GRAY 2
--- 28,37 ----
*** 44,55 ****
*/
HPALETTE AwtPalette::Select(HDC hDC)
{
HPALETTE prevPalette = NULL;
if (logicalPalette) {
! BOOL background = !(m_useCustomPalette);
! prevPalette = ::SelectPalette(hDC, logicalPalette, background);
}
return prevPalette;
}
/**
--- 42,52 ----
*/
HPALETTE AwtPalette::Select(HDC hDC)
{
HPALETTE prevPalette = NULL;
if (logicalPalette) {
! prevPalette = ::SelectPalette(hDC, logicalPalette, FALSE);
}
return prevPalette;
}
/**
*** 58,69 ****
* that HDC.
*/
void AwtPalette::Realize(HDC hDC)
{
if (logicalPalette) {
! if (!m_useCustomPalette ||
! AwtComponent::QueryNewPaletteCalled() ||
AwtToolkit::GetInstance().HasDisplayChanged()) {
// Fix for bug 4178909, workaround for Windows bug. Shouldn't
// do a RealizePalette until the first QueryNewPalette message
// has been processed.
// But if we are switching the primary monitor from non-8bpp
--- 55,65 ----
* that HDC.
*/
void AwtPalette::Realize(HDC hDC)
{
if (logicalPalette) {
! if (AwtComponent::QueryNewPaletteCalled() ||
AwtToolkit::GetInstance().HasDisplayChanged()) {
// Fix for bug 4178909, workaround for Windows bug. Shouldn't
// do a RealizePalette until the first QueryNewPalette message
// has been processed.
// But if we are switching the primary monitor from non-8bpp
*** 78,109 ****
}
}
}
/**
- * Disable the use of our custom palette. This method is called
- * during initialization if we detect that we are running inside
- * the plugin; we do not want to clobber our parent application's
- * palette with our own in that situation.
- */
- void AwtPalette::DisableCustomPalette()
- {
- m_useCustomPalette = FALSE;
- }
-
- /**
- * Returns whether we are currently using a custom palette. Used
- * by AwtWin32GraphicsDevice when creating the colorModel of the
- * device.
- */
- BOOL AwtPalette::UseCustomPalette()
- {
- return m_useCustomPalette;
- }
-
-
- /**
* Constructor. Initialize the system and logical palettes.
* used by this object.
*/
AwtPalette::AwtPalette(AwtWin32GraphicsDevice *device)
{
--- 74,83 ----
*** 151,161 ****
delete[] pLogPal;
if ( hPal == 0 ) {
return 0;
}
! hPalOld = ::SelectPalette(hDC, hPal, 1);
if (hPalOld == 0) {
::DeleteObject(hPal);
return 0;
}
::RealizePalette(hDC);
--- 125,135 ----
delete[] pLogPal;
if ( hPal == 0 ) {
return 0;
}
! hPalOld = ::SelectPalette(hDC, hPal, TRUE);
if (hPalOld == 0) {
::DeleteObject(hPal);
return 0;
}
::RealizePalette(hDC);
*** 166,176 ****
pPalEntries[iEntry].peRed = GetRValue(rgb);
pPalEntries[iEntry].peGreen = GetGValue(rgb);
pPalEntries[iEntry].peBlue = GetBValue(rgb);
}
! ::SelectPalette(hDC, hPalOld, 0 );
::DeleteObject(hPal);
::RealizePalette(hDC);
return 256;
}
--- 140,150 ----
pPalEntries[iEntry].peRed = GetRValue(rgb);
pPalEntries[iEntry].peGreen = GetGValue(rgb);
pPalEntries[iEntry].peBlue = GetBValue(rgb);
}
! ::SelectPalette(hDC, hPalOld, FALSE);
::DeleteObject(hPal);
::RealizePalette(hDC);
return 256;
}
< prev index next >