modules/graphics/src/main/java/com/sun/glass/ui/Window.java
Print this page
@@ -204,12 +204,16 @@
private int x = 0;
private int y = 0;
private int width = 0;
private int height = 0;
private float alpha = 1.0f;
- private float platformScale = 1.0f;
- private float renderScale = 1.0f;
+ private float platformScaleX = 1.0f;
+ private float platformScaleY = 1.0f;
+ private float outputScaleX = 1.0f;
+ private float outputScaleY = 1.0f;
+ private float renderScaleX = 1.0f;
+ private float renderScaleY = 1.0f;
// This is a workaround for RT-15970: as for embedded windows we don't
// receive any MOVE notifications from the native platform, we poll
// the window location on screen from timer and post synthetic events
// if it has changed
@@ -267,10 +271,16 @@
this.parent = 0L;
this.styleMask = styleMask;
this.isDecorated = (this.styleMask & Window.TITLED) != 0;
this.screen = screen != null ? screen : Screen.getMainScreen();
+ if (PrismSettings.allowHiDPIScaling) {
+ this.platformScaleX = this.screen.getPlatformScaleX();
+ this.platformScaleY = this.screen.getPlatformScaleY();
+ this.outputScaleX = this.screen.getRecommendedOutputScaleX();
+ this.outputScaleY = this.screen.getRecommendedOutputScaleY();
+ }
this.ptr = _createWindow(owner != null ? owner.getNativeHandle() : 0L,
this.screen.getNativeScreen(), this.styleMask);
if (this.ptr == 0L) {
throw new RuntimeException("could not create platform window");
@@ -464,42 +474,71 @@
checkNotClosed();
_maximize(ptr, maximize, isMaximized());
return isMaximized();
}
- public void setPlatformScale(float platformScale) {
+ protected void notifyScaleChanged(float platformScaleX, float platformScaleY,
+ float outputScaleX, float outputScaleY)
+ {
if (!PrismSettings.allowHiDPIScaling) return;
- this.platformScale = platformScale;
+ this.platformScaleX = platformScaleX;
+ this.platformScaleY = platformScaleY;
+ this.outputScaleX = outputScaleX;
+ this.outputScaleY = outputScaleY;
+ notifyRescale();
}
/**
- * Return the scale used to communicate window locations, sizes, and event
- * coordinates to/from the platform.
- * @return the platform scaling for screen locations
+ * Return the horizontal scale used to communicate window locations,
+ * sizes, and event coordinates to/from the platform.
+ * @return the horizontal platform scaling for screen locations
*/
- public final float getPlatformScale() {
- return platformScale;
+ public final float getPlatformScaleX() {
+ return platformScaleX;
+ }
+
+ /**
+ * Return the vertical scale used to communicate window locations,
+ * sizes, and event coordinates to/from the platform.
+ * @return the vertical platform scaling for screen locations
+ */
+ public final float getPlatformScaleY() {
+ return platformScaleY;
+ }
+
+ public void setRenderScaleX(float renderScaleX) {
+ if (!PrismSettings.allowHiDPIScaling) return;
+ this.renderScaleX = renderScaleX;
}
- public void setRenderScale(float renderScale) {
+ public void setRenderScaleY(float renderScaleY) {
if (!PrismSettings.allowHiDPIScaling) return;
- this.renderScale = renderScale;
+ this.renderScaleY = renderScaleY;
}
/**
- * Return the scale that should be used to render content on this window.
- * This is usually similar to the platform scale, but may be different
- * depending on how the platform manages events vs. rendering buffers
- * and/or whether the system can handle non-integer rendering scales.
- * @return the pixel scaling to be used during rendering
+ * Return the horizontal scale used for rendering the back buffer.
+ * @return the horizontal scaling for rendering
*/
- public final float getRenderScale() {
- return renderScale;
+ public final float getRenderScaleX() {
+ return renderScaleX;
}
- public float getOutputScale() {
- return platformScale;
+ /**
+ * Return the vertical scale used for rendering to the back buffer.
+ * @return the vertical scaling for rendering
+ */
+ public final float getRenderScaleY() {
+ return renderScaleY;
+ }
+
+ public float getOutputScaleX() {
+ return outputScaleX;
+ }
+
+ public float getOutputScaleY() {
+ return outputScaleY;
}
protected abstract int _getEmbeddedX(long ptr);
protected abstract int _getEmbeddedY(long ptr);
@@ -1192,10 +1231,14 @@
this.x = x;
this.y = y;
handleWindowEvent(System.nanoTime(), WindowEvent.MOVE);
}
+ protected void notifyRescale() {
+ handleWindowEvent(System.nanoTime(), WindowEvent.RESCALE);
+ }
+
protected void notifyMoveToAnotherScreen(Screen newScreen) {
setScreen(newScreen);
}
/**