< prev index next >
src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.cpp
Print this page
rev 60071 : 8211999: Window positioning bugs due to overlapping GraphicsDevice bounds (Windows/HiDPI)
Reviewed-by: XXX
@@ -75,10 +75,11 @@
{
this->screen = screen;
this->devicesArray = arr;
this->scaleX = 1;
this->scaleY = 1;
+ disableScaleAutoRefresh = FALSE;
javaDevice = NULL;
colorData = new ImgColorData;
colorData->grayscale = GS_NOTGRAY;
palette = NULL;
cData = NULL;
@@ -631,25 +632,49 @@
int AwtWin32GraphicsDevice::ScaleUpX(int x)
{
return ClipRound(x * scaleX);
}
+int AwtWin32GraphicsDevice::ScaleUpAbsX(int x)
+{
+ LONG screen = pMonitorInfo->rcMonitor.left;
+ return screen + ClipRound((x - screen) * scaleX);
+}
+
int AwtWin32GraphicsDevice::ScaleUpY(int y)
{
return ClipRound(y * scaleY);
}
+int AwtWin32GraphicsDevice::ScaleUpAbsY(int y)
+{
+ LONG screen = pMonitorInfo->rcMonitor.top;
+ return screen + ClipRound((y - screen) * scaleY);
+}
+
int AwtWin32GraphicsDevice::ScaleDownX(int x)
{
return ClipRound(x / scaleX);
}
+int AwtWin32GraphicsDevice::ScaleDownAbsX(int x)
+{
+ LONG screen = pMonitorInfo->rcMonitor.left;
+ return screen + ClipRound((x - screen) / scaleX);
+}
+
int AwtWin32GraphicsDevice::ScaleDownY(int y)
{
return ClipRound(y / scaleY);
}
+int AwtWin32GraphicsDevice::ScaleDownAbsY(int y)
+{
+ LONG screen = pMonitorInfo->rcMonitor.top;
+ return screen + ClipRound((y - screen) / scaleY);
+}
+
int AwtWin32GraphicsDevice::ClipRound(double value)
{
value -= 0.5;
if (value < INT_MIN)
{
@@ -662,18 +687,19 @@
}
return (int)ceil(value);
}
-void AwtWin32GraphicsDevice::InitDesktopScales()
-{
+void AwtWin32GraphicsDevice::InitDesktopScales() {
+ if (!disableScaleAutoRefresh) {
float dpiX = -1.0f;
float dpiY = -1.0f;
GetScreenDpi(GetMonitor(), &dpiX, &dpiY);
if (dpiX > 0 && dpiY > 0) {
SetScale(dpiX / 96, dpiY / 96);
}
+ }
}
float AwtWin32GraphicsDevice::GetScaleX()
{
return scaleX;
@@ -692,10 +718,15 @@
void AwtWin32GraphicsDevice::DisableOffscreenAcceleration()
{
// REMIND: noop for now
}
+void AwtWin32GraphicsDevice::DisableScaleAutoRefresh()
+{
+ disableScaleAutoRefresh = TRUE;
+}
+
/**
* Invalidates the GraphicsDevice object associated with this
* device by disabling offscreen acceleration and calling
* invalidate(defIndex) on the java object.
*/
@@ -752,10 +783,25 @@
::GetMonitorInfo(monitor,
devices->GetDevice(deviceIndex)->pMonitorInfo);
}
}
+/**
+ * This function updates the scale factor for all monitors on the system.
+ */
+void AwtWin32GraphicsDevice::ResetAllDesktopScales()
+{
+ if (!Devices::GetInstance()){
+ return;
+ }
+ Devices::InstanceAccess devices;
+ int devicesNum = devices->GetNumDevices();
+ for (int deviceIndex = 0; deviceIndex < devicesNum; deviceIndex++) {
+ devices->GetDevice(deviceIndex)->InitDesktopScales();
+ }
+}
+
void AwtWin32GraphicsDevice::DisableOffscreenAccelerationForDevice(
HMONITOR hMonitor)
{
Devices::InstanceAccess devices;
if (hMonitor == NULL) {
@@ -1391,10 +1437,11 @@
{
Devices::InstanceAccess devices;
AwtWin32GraphicsDevice *device = devices->GetDevice(screen);
if (device != NULL ) {
+ device->DisableScaleAutoRefresh();
device->SetScale(scaleX, scaleY);
}
}
/*
< prev index next >