mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-11 22:19:43 +00:00
8164811: [hidpi]Tests fail with OpenGL and GDI Rendering 8189257: Enabling Translucent Frame with setBackground disables HiDPI
Reviewed-by: serb, prr, pnarayanan
This commit is contained in:
parent
78226acfd5
commit
f71993d642
@ -26,10 +26,12 @@ package sun.awt.windows;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.Image;
|
||||
import java.awt.Window;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBufferInt;
|
||||
import java.awt.image.VolatileImage;
|
||||
@ -38,6 +40,7 @@ import sun.awt.image.BufImgSurfaceData;
|
||||
import sun.java2d.DestSurfaceProvider;
|
||||
import sun.java2d.InvalidPipeException;
|
||||
import sun.java2d.Surface;
|
||||
import sun.java2d.pipe.Region;
|
||||
import sun.java2d.pipe.RenderQueue;
|
||||
import sun.java2d.pipe.BufferedContext;
|
||||
import sun.java2d.pipe.hw.AccelGraphicsConfig;
|
||||
@ -116,6 +119,12 @@ abstract class TranslucentWindowPainter {
|
||||
*/
|
||||
protected abstract boolean update(Image bb);
|
||||
|
||||
/**
|
||||
* Create (if needed), clears back buffer (if requested) and return
|
||||
* graphics for this class depending upon the buffer type
|
||||
*/
|
||||
protected abstract Graphics getGraphics(boolean clear);
|
||||
|
||||
/**
|
||||
* Flushes the resources associated with the painter. They will be
|
||||
* recreated as needed.
|
||||
@ -130,10 +139,9 @@ abstract class TranslucentWindowPainter {
|
||||
*/
|
||||
public void updateWindow(boolean repaint) {
|
||||
boolean done = false;
|
||||
Image bb = getBackBuffer(repaint);
|
||||
while (!done) {
|
||||
if (repaint) {
|
||||
Graphics2D g = (Graphics2D)bb.getGraphics();
|
||||
Graphics2D g = (Graphics2D) getGraphics(repaint);
|
||||
try {
|
||||
window.paintAll(g);
|
||||
} finally {
|
||||
@ -141,10 +149,9 @@ abstract class TranslucentWindowPainter {
|
||||
}
|
||||
}
|
||||
|
||||
done = update(bb);
|
||||
done = update(getBackBuffer(false));
|
||||
if (!done) {
|
||||
repaint = true;
|
||||
bb = getBackBuffer(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -178,8 +185,12 @@ abstract class TranslucentWindowPainter {
|
||||
|
||||
@Override
|
||||
protected Image getBackBuffer(boolean clear) {
|
||||
int w = window.getWidth();
|
||||
int h = window.getHeight();
|
||||
GraphicsConfiguration gc = peer.getGraphicsConfiguration();
|
||||
AffineTransform transform = gc.getDefaultTransform();
|
||||
int w = Region.clipRound(
|
||||
window.getWidth() * transform.getScaleX());
|
||||
int h = Region.clipRound(
|
||||
window.getHeight() * transform.getScaleY());
|
||||
if (backBuffer == null ||
|
||||
backBuffer.getWidth() != w ||
|
||||
backBuffer.getHeight() != h)
|
||||
@ -236,6 +247,19 @@ abstract class TranslucentWindowPainter {
|
||||
backBuffer = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Graphics getGraphics(boolean clear) {
|
||||
Graphics g = getBackBuffer(clear).getGraphics();
|
||||
/*
|
||||
* This graphics object returned by BuffereImage is not scaled to
|
||||
* graphics configuration, but this graphics object can be used by
|
||||
* components inside this TranslucentWindow. So need to scale this
|
||||
* before returning.
|
||||
*/
|
||||
((Graphics2D)g).transform(peer.getGraphicsConfiguration().getDefaultTransform());
|
||||
return g;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -283,6 +307,11 @@ abstract class TranslucentWindowPainter {
|
||||
viBB = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Graphics getGraphics(boolean clear) {
|
||||
return getBackBuffer(clear).getGraphics();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -717,7 +717,7 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
|
||||
|
||||
public final Graphics getTranslucentGraphics() {
|
||||
synchronized (getStateLock()) {
|
||||
return isOpaque ? null : painter.getBackBuffer(false).getGraphics();
|
||||
return isOpaque ? null : painter.getGraphics(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -25,6 +25,7 @@ import java.awt.*;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8164811
|
||||
* @key headful
|
||||
* @summary Check if a per-pixel translucent window is dragged and resized
|
||||
* by mouse correctly.
|
||||
@ -42,6 +43,7 @@ import java.awt.*;
|
||||
* @library ../../../../lib/testlibrary
|
||||
* @build Common ExtendedRobot
|
||||
* @run main PerPixelTranslucent
|
||||
* @run main/othervm -Dsun.java2d.uiScale=1.5 PerPixelTranslucent
|
||||
*/
|
||||
|
||||
public class PerPixelTranslucent extends Common {
|
||||
|
||||
@ -26,7 +26,7 @@ import java.awt.*;
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @bug 8032644
|
||||
* @bug 8032644 8164811
|
||||
* @summary Check if a per-pixel translucent window is dragged and resized by
|
||||
* mouse correctly
|
||||
* Test Description: Check if PERPIXEL_TRANSLUCENT translucency type is supported
|
||||
@ -44,6 +44,7 @@ import java.awt.*;
|
||||
* @library ../../../../lib/testlibrary
|
||||
* @build Common ExtendedRobot
|
||||
* @run main PerPixelTranslucentGradient
|
||||
* @run main/othervm -Dsun.java2d.uiScale=1.5 PerPixelTranslucentGradient
|
||||
*/
|
||||
|
||||
public class PerPixelTranslucentGradient extends Common {
|
||||
|
||||
@ -26,6 +26,7 @@ import java.awt.*;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8164811
|
||||
* @key headful
|
||||
* @summary Check if a per-pixel translucent window shows only the area having
|
||||
* opaque pixels
|
||||
@ -40,6 +41,7 @@ import java.awt.*;
|
||||
* @library ../../../../lib/testlibrary
|
||||
* @build Common ExtendedRobot
|
||||
* @run main PerPixelTranslucentSwing
|
||||
* @run main/othervm -Dsun.java2d.uiScale=1.5 PerPixelTranslucentSwing
|
||||
*/
|
||||
|
||||
public class PerPixelTranslucentSwing extends Common {
|
||||
|
||||
@ -26,7 +26,7 @@ import java.awt.*;
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @bug 7043845
|
||||
* @bug 7043845 8164811
|
||||
* @summary Check if shaped and per-pixel translucent window is dragged and
|
||||
* resized by mouse correctly.
|
||||
* Test Description: Check if PERPIXEL_TRANSLUCENT and PERPIXEL_TRANSPARENT
|
||||
@ -48,6 +48,7 @@ import java.awt.*;
|
||||
* @library ../../../../lib/testlibrary
|
||||
* @build Common ExtendedRobot
|
||||
* @run main ShapedPerPixelTranslucentGradient
|
||||
* @run main/othervm -Dsun.java2d.uiScale=1.5 ShapedPerPixelTranslucentGradient
|
||||
*/
|
||||
|
||||
public class ShapedPerPixelTranslucentGradient extends Common {
|
||||
|
||||
@ -25,6 +25,7 @@ import java.awt.*;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8164811
|
||||
* @key headful
|
||||
* @summary Check if shaped, translucent and per-pixel translucent window is
|
||||
* dragged and resized by mouse correctly.
|
||||
@ -48,6 +49,7 @@ import java.awt.*;
|
||||
* @library ../../../../lib/testlibrary
|
||||
* @build Common ExtendedRobot
|
||||
* @run main ShapedTranslucentPerPixelTranslucentGradient
|
||||
* @run main/othervm -Dsun.java2d.uiScale=1.5 ShapedTranslucentPerPixelTranslucentGradient
|
||||
*/
|
||||
|
||||
public class ShapedTranslucentPerPixelTranslucentGradient extends Common {
|
||||
|
||||
@ -25,7 +25,7 @@ import java.awt.*;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8144735
|
||||
* @bug 8144735 8164811
|
||||
* @key headful
|
||||
* @summary Check if a per-pixel translucent and translucent window is dragged
|
||||
* and resized by mouse correctly
|
||||
@ -46,6 +46,7 @@ import java.awt.*;
|
||||
* @library ../../../../lib/testlibrary
|
||||
* @build Common ExtendedRobot
|
||||
* @run main TranslucentPerPixelTranslucentGradient
|
||||
* @run main/othervm -Dsun.java2d.uiScale=1.5 TranslucentPerPixelTranslucentGradient
|
||||
*/
|
||||
|
||||
public class TranslucentPerPixelTranslucentGradient extends Common {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user