8214076: Cleanup the code related to GraphicsEnvironment/Device/Configuration

Reviewed-by: aivanov, prr
This commit is contained in:
Sergey Bylokhov 2019-01-28 17:19:54 -08:00
parent 5d8b93bb54
commit df2ad6cdd8
21 changed files with 247 additions and 265 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2019, 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
@ -29,7 +29,6 @@ import java.awt.GraphicsConfiguration;
import java.awt.Rectangle;
import java.awt.Transparency;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import sun.java2d.SurfaceData;
@ -47,11 +46,6 @@ public abstract class CGraphicsConfig extends GraphicsConfiguration
this.device = device;
}
@Override
public BufferedImage createCompatibleImage(int width, int height) {
throw new UnsupportedOperationException("not implemented");
}
@Override
public final Rectangle getBounds() {
return device.getBounds();
@ -65,11 +59,6 @@ public abstract class CGraphicsConfig extends GraphicsConfiguration
return colorModel;
}
@Override
public ColorModel getColorModel(int transparency) {
throw new UnsupportedOperationException("not implemented");
}
@Override
public AffineTransform getDefaultTransform() {
double scaleFactor = device.getScaleFactor();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2019, 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
@ -51,11 +51,7 @@ public final class CGraphicsDevice extends GraphicsDevice
private volatile Rectangle bounds;
private volatile int scale;
// Array of all GraphicsConfig instances for this device
private final GraphicsConfiguration[] configs;
// Default config (temporarily hard coded)
private final int DEFAULT_CONFIG = 0;
private final GraphicsConfiguration config;
private static AWTPermission fullScreenExclusivePermission;
@ -64,9 +60,7 @@ public final class CGraphicsDevice extends GraphicsDevice
public CGraphicsDevice(final int displayID) {
this.displayID = displayID;
configs = new GraphicsConfiguration[] {
CGLGraphicsConfig.getConfig(this, displayID, 0)
};
config = CGLGraphicsConfig.getConfig(this, displayID, 0);
}
/**
@ -74,7 +68,7 @@ public final class CGraphicsDevice extends GraphicsDevice
*/
@Override
public GraphicsConfiguration[] getConfigurations() {
return configs.clone();
return new GraphicsConfiguration[]{config};
}
/**
@ -82,7 +76,7 @@ public final class CGraphicsDevice extends GraphicsDevice
*/
@Override
public GraphicsConfiguration getDefaultConfiguration() {
return configs[DEFAULT_CONFIG];
return config;
}
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2019, 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
@ -185,11 +185,6 @@ public final class CGLGraphicsConfig extends CGraphicsConfig
return pConfigInfo;
}
/**
* {@inheritDoc}
*
* @see sun.java2d.pipe.hw.BufferedContextProvider#getContext
*/
@Override
public OGLContext getContext() {
return context;
@ -395,11 +390,6 @@ public final class CGLGraphicsConfig extends CGraphicsConfig
return vi;
}
/**
* {@inheritDoc}
*
* @see sun.java2d.pipe.hw.AccelGraphicsConfig#getContextCapabilities
*/
@Override
public ContextCapabilities getContextCapabilities() {
return oglCaps;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2019, 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
@ -25,13 +25,15 @@
package sun.lwawt.macosx;
import java.awt.*;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
public class CPrinterDevice extends GraphicsDevice {
GraphicsConfiguration gc;
public final class CPrinterDevice extends GraphicsDevice {
public CPrinterDevice(CPrinterGraphicsConfig gc) {
this.gc = gc;
private final GraphicsConfiguration config;
public CPrinterDevice(final CPrinterGraphicsConfig config) {
this.config = config;
}
/**
@ -42,6 +44,7 @@ public class CPrinterDevice extends GraphicsDevice {
* @see #TYPE_PRINTER
* @see #TYPE_IMAGE_BUFFER
*/
@Override
public int getType() {
return GraphicsDevice.TYPE_PRINTER;
}
@ -52,6 +55,7 @@ public class CPrinterDevice extends GraphicsDevice {
* @return a {@code String} that is the identification
* of this {@code GraphicsDevice}.
*/
@Override
public String getIDstring() {
return ("Printer");
}
@ -63,8 +67,9 @@ public class CPrinterDevice extends GraphicsDevice {
* objects that are associated with this
* {@code GraphicsDevice}.
*/
@Override
public GraphicsConfiguration[] getConfigurations() {
return new GraphicsConfiguration[] { gc };
return new GraphicsConfiguration[]{config};
}
/**
@ -73,7 +78,8 @@ public class CPrinterDevice extends GraphicsDevice {
* @return the default {@code GraphicsConfiguration}
* of this {@code GraphicsDevice}.
*/
@Override
public GraphicsConfiguration getDefaultConfiguration() {
return gc;
return config;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2019, 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
@ -25,21 +25,29 @@
package sun.lwawt.macosx;
import java.awt.*;
import java.awt.geom.*;
import java.awt.image.*;
import java.awt.print.*;
import java.awt.Component;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.Rectangle;
import java.awt.Transparency;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.VolatileImage;
import java.awt.print.PageFormat;
public final class CPrinterGraphicsConfig extends GraphicsConfiguration {
public class CPrinterGraphicsConfig extends GraphicsConfiguration {
public static CPrinterGraphicsConfig getConfig(PageFormat pf) {
return new CPrinterGraphicsConfig(pf);
}
GraphicsDevice gd;
PageFormat pf;
private final GraphicsDevice device;
private final PageFormat pf;
public CPrinterGraphicsConfig(PageFormat pf) {
this.gd = new CPrinterDevice(this);
this.device = new CPrinterDevice(this);
this.pf = pf;
}
@ -53,8 +61,9 @@ public class CPrinterGraphicsConfig extends GraphicsConfiguration {
* @return a {@code GraphicsDevice} object that is
* associated with this {@code GraphicsConfiguration}.
*/
@Override
public GraphicsDevice getDevice() {
return gd;
return device;
}
/**
@ -70,6 +79,7 @@ public class CPrinterGraphicsConfig extends GraphicsConfiguration {
* @return a {@code BufferedImage} whose data layout and color
* model is compatible with this {@code GraphicsConfiguration}.
*/
@Override
public BufferedImage createCompatibleImage(int width, int height) {
return createCompatibleImage(width, height, Transparency.OPAQUE);
}
@ -87,11 +97,13 @@ public class CPrinterGraphicsConfig extends GraphicsConfiguration {
* model is compatible with this {@code GraphicsConfiguration}.
* @see Component#createVolatileImage(int, int)
*/
@Override
public VolatileImage createCompatibleVolatileImage(int width, int height) {
return createCompatibleVolatileImage(width, height, Transparency.OPAQUE);
}
// empty implementation (this should not be called)
@Override
public VolatileImage createCompatibleVolatileImage(int width, int height, int transparency) {
return null;
}
@ -114,6 +126,7 @@ public class CPrinterGraphicsConfig extends GraphicsConfiguration {
* @see Transparency#BITMASK
* @see Transparency#TRANSLUCENT
*/
@Override
public BufferedImage createCompatibleImage(int width, int height, int transparency) {
//+++gdb what to do?
return null;
@ -125,6 +138,7 @@ public class CPrinterGraphicsConfig extends GraphicsConfiguration {
* @return a {@code ColorModel} object that is associated with
* this {@code GraphicsConfiguration}.
*/
@Override
public ColorModel getColorModel() {
return getColorModel(Transparency.OPAQUE);
}
@ -138,6 +152,7 @@ public class CPrinterGraphicsConfig extends GraphicsConfiguration {
* this {@code GraphicsConfiguration} and supports the
* specified transparency.
*/
@Override
public ColorModel getColorModel(int transparency) {
return ColorModel.getRGBdefault();
}
@ -161,6 +176,7 @@ public class CPrinterGraphicsConfig extends GraphicsConfiguration {
* @return the default {@code AffineTransform} for this
* {@code GraphicsConfiguration}.
*/
@Override
public AffineTransform getDefaultTransform() {
return new AffineTransform();
}
@ -192,6 +208,7 @@ public class CPrinterGraphicsConfig extends GraphicsConfiguration {
* default {@code AffineTransform} so that 72 units in user
* space is mapped to 1 inch in device space.
*/
@Override
public AffineTransform getNormalizingTransform() {
return new AffineTransform();
}
@ -205,6 +222,7 @@ public class CPrinterGraphicsConfig extends GraphicsConfiguration {
* {@code GraphicsConfiguration}.
* @since 1.3
*/
@Override
public Rectangle getBounds() {
return new Rectangle(0, 0, (int)pf.getWidth(), (int)pf.getHeight());
}

View File

@ -104,8 +104,6 @@ import sun.awt.image.SunVolatileImage;
* implements the interface for that capability.
*
*/
public abstract class GraphicsConfiguration {
private static BufferCapabilities defaultBufferCaps;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2000, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2019, 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
@ -25,15 +25,15 @@
package sun.awt.image;
import java.awt.GraphicsDevice;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
public class BufferedImageDevice extends GraphicsDevice
{
GraphicsConfiguration gc;
public final class BufferedImageDevice extends GraphicsDevice {
public BufferedImageDevice(BufferedImageGraphicsConfig gc) {
this.gc = gc;
private final GraphicsConfiguration config;
public BufferedImageDevice(final BufferedImageGraphicsConfig config) {
this.config = config;
}
/**
@ -44,6 +44,7 @@ public class BufferedImageDevice extends GraphicsDevice
* @see #TYPE_PRINTER
* @see #TYPE_IMAGE_BUFFER
*/
@Override
public int getType() {
return GraphicsDevice.TYPE_IMAGE_BUFFER;
}
@ -54,6 +55,7 @@ public class BufferedImageDevice extends GraphicsDevice
* @return a {@code String} that is the identification
* of this {@code GraphicsDevice}.
*/
@Override
public String getIDstring() {
return ("BufferedImage");
}
@ -65,8 +67,9 @@ public class BufferedImageDevice extends GraphicsDevice
* objects that are associated with this
* {@code GraphicsDevice}.
*/
@Override
public GraphicsConfiguration[] getConfigurations() {
return new GraphicsConfiguration[] { gc };
return new GraphicsConfiguration[]{config};
}
/**
@ -75,7 +78,8 @@ public class BufferedImageDevice extends GraphicsDevice
* @return the default {@code GraphicsConfiguration}
* of this {@code GraphicsDevice}.
*/
@Override
public GraphicsConfiguration getDefaultConfiguration() {
return gc;
return config;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2019, 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
@ -25,12 +25,10 @@
package sun.awt.image;
import java.awt.AWTException;
import java.awt.Component;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.ImageCapabilities;
import java.awt.Rectangle;
import java.awt.Transparency;
import java.awt.geom.AffineTransform;
@ -38,12 +36,10 @@ import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.DirectColorModel;
import java.awt.image.Raster;
import java.awt.image.VolatileImage;
import java.awt.image.WritableRaster;
public class BufferedImageGraphicsConfig
extends GraphicsConfiguration
{
public final class BufferedImageGraphicsConfig extends GraphicsConfiguration {
private static final int numconfigs = BufferedImage.TYPE_BYTE_BINARY;
private static BufferedImageGraphicsConfig[] standardConfigs =
new BufferedImageGraphicsConfig[numconfigs];
@ -77,24 +73,20 @@ public class BufferedImageGraphicsConfig
return ret;
}
GraphicsDevice gd;
ColorModel model;
Raster raster;
private final GraphicsDevice device;
private final ColorModel model;
private final Raster raster;
private final double scaleX;
private final double scaleY;
public BufferedImageGraphicsConfig(BufferedImage bufImg, Component comp) {
this(bufImg, comp, 1, 1);
}
public BufferedImageGraphicsConfig(BufferedImage bufImg, Component comp,
double scaleX, double scaleY)
{
if (comp == null) {
this.gd = new BufferedImageDevice(this);
device = new BufferedImageDevice(this);
} else {
Graphics2D g2d = (Graphics2D)comp.getGraphics();
this.gd = g2d.getDeviceConfiguration().getDevice();
device = g2d.getDeviceConfiguration().getDevice();
}
this.model = bufImg.getColorModel();
this.raster = bufImg.getRaster().createCompatibleWritableRaster(1, 1);
@ -105,8 +97,9 @@ public class BufferedImageGraphicsConfig
/**
* Return the graphics device associated with this configuration.
*/
@Override
public GraphicsDevice getDevice() {
return gd;
return device;
}
/**
@ -118,6 +111,7 @@ public class BufferedImageGraphicsConfig
* that is closest to this native device configuration and thus
* can be optimally blitted to this device.
*/
@Override
public BufferedImage createCompatibleImage(int width, int height) {
WritableRaster wr = raster.createCompatibleWritableRaster(width, height);
return new BufferedImage(model, wr, model.isAlphaPremultiplied(), null);
@ -126,6 +120,7 @@ public class BufferedImageGraphicsConfig
/**
* Returns the color model associated with this configuration.
*/
@Override
public ColorModel getColorModel() {
return model;
}
@ -134,6 +129,7 @@ public class BufferedImageGraphicsConfig
* Returns the color model associated with this configuration that
* supports the specified transparency.
*/
@Override
public ColorModel getColorModel(int transparency) {
if (model.getTransparency() == transparency) {
@ -160,6 +156,7 @@ public class BufferedImageGraphicsConfig
* increasing to the right and Y coordinates increasing downwards.
* For image buffers, this Transform will be the Identity transform.
*/
@Override
public AffineTransform getDefaultTransform() {
return AffineTransform.getScaleInstance(scaleX, scaleY);
}
@ -183,10 +180,12 @@ public class BufferedImageGraphicsConfig
* For image buffers, this Transform will be the Identity transform,
* since there is no valid distance measurement.
*/
@Override
public AffineTransform getNormalizingTransform() {
return new AffineTransform();
}
@Override
public Rectangle getBounds() {
return new Rectangle(0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2019, 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
@ -25,22 +25,20 @@
package sun.java2d;
import java.awt.GraphicsEnvironment;
import java.awt.GraphicsDevice;
import java.awt.Graphics2D;
import java.awt.HeadlessException;
import java.awt.image.BufferedImage;
import java.awt.Font;
import java.util.Locale;
import sun.awt.FontConfiguration;
import java.awt.Graphics2D;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.HeadlessException;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.util.Locale;
/**
* Headless decorator implementation of a SunGraphicsEnvironment
*/
public class HeadlessGraphicsEnvironment extends GraphicsEnvironment {
public final class HeadlessGraphicsEnvironment extends GraphicsEnvironment {
private GraphicsEnvironment ge;
@ -48,37 +46,41 @@ public class HeadlessGraphicsEnvironment extends GraphicsEnvironment {
this.ge = ge;
}
@Override
public GraphicsDevice[] getScreenDevices()
throws HeadlessException {
throw new HeadlessException();
}
@Override
public GraphicsDevice getDefaultScreenDevice()
throws HeadlessException {
throw new HeadlessException();
}
@Override
public Point getCenterPoint() throws HeadlessException {
throw new HeadlessException();
}
@Override
public Rectangle getMaximumWindowBounds() throws HeadlessException {
throw new HeadlessException();
}
@Override
public Graphics2D createGraphics(BufferedImage img) {
return ge.createGraphics(img); }
@Override
public Font[] getAllFonts() { return ge.getAllFonts(); }
@Override
public String[] getAvailableFontFamilyNames() {
return ge.getAvailableFontFamilyNames(); }
@Override
public String[] getAvailableFontFamilyNames(Locale l) {
return ge.getAvailableFontFamilyNames(l); }
/* Used by FontManager : internal API */
public GraphicsEnvironment getSunGraphicsEnvironment() {
return ge;
return ge.getAvailableFontFamilyNames(l);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2019, 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
@ -27,7 +27,6 @@ package sun.print;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.Rectangle;
import java.awt.Transparency;
import java.awt.geom.AffineTransform;
@ -35,32 +34,35 @@ import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.DirectColorModel;
public class PrinterGraphicsConfig extends GraphicsConfiguration {
public final class PrinterGraphicsConfig extends GraphicsConfiguration {
static ColorModel theModel;
GraphicsDevice gd;
int pageWidth, pageHeight;
AffineTransform deviceTransform;
private final GraphicsDevice device;
private final int pageWidth;
private final int pageHeight;
private final AffineTransform deviceTransform;
public PrinterGraphicsConfig(String printerID, AffineTransform deviceTx,
int pageWid, int pageHgt) {
this.pageWidth = pageWid;
this.pageHeight = pageHgt;
this.deviceTransform = deviceTx;
this.gd = new PrinterGraphicsDevice(this, printerID);
this.device = new PrinterGraphicsDevice(this, printerID);
}
/**
* Return the graphics device associated with this configuration.
*/
@Override
public GraphicsDevice getDevice() {
return gd;
return device;
}
/**
* Returns the color model associated with this configuration.
*/
@Override
public ColorModel getColorModel() {
if (theModel == null) {
BufferedImage bufImg =
@ -75,6 +77,7 @@ public class PrinterGraphicsConfig extends GraphicsConfiguration {
* Returns the color model associated with this configuration that
* supports the specified transparency.
*/
@Override
public ColorModel getColorModel(int transparency) {
switch (transparency) {
case Transparency.OPAQUE:
@ -97,6 +100,7 @@ public class PrinterGraphicsConfig extends GraphicsConfiguration {
* increasing to the right and Y coordinates increasing downwards.
* For image buffers, this Transform will be the Identity transform.
*/
@Override
public AffineTransform getDefaultTransform() {
return new AffineTransform(deviceTransform);
}
@ -120,10 +124,12 @@ public class PrinterGraphicsConfig extends GraphicsConfiguration {
* For image buffers, this Transform will be the Identity transform,
* since there is no valid distance measurement.
*/
@Override
public AffineTransform getNormalizingTransform() {
return new AffineTransform();
}
@Override
public Rectangle getBounds() {
return new Rectangle(0, 0, pageWidth, pageHeight);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2019, 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
@ -23,7 +23,6 @@
* questions.
*/
package sun.print;
import java.awt.GraphicsConfiguration;
@ -32,36 +31,40 @@ import java.awt.Window;
public final class PrinterGraphicsDevice extends GraphicsDevice {
String printerID;
GraphicsConfiguration graphicsConf;
private final String printerID;
private final GraphicsConfiguration config;
protected PrinterGraphicsDevice(GraphicsConfiguration conf, String id) {
PrinterGraphicsDevice(GraphicsConfiguration conf, String id) {
printerID = id;
graphicsConf = conf;
config = conf;
}
@Override
public int getType() {
return TYPE_PRINTER;
}
@Override
public String getIDstring() {
return printerID;
}
@Override
public GraphicsConfiguration[] getConfigurations() {
GraphicsConfiguration[] confs = new GraphicsConfiguration[1];
confs[0] = graphicsConf;
return confs;
return new GraphicsConfiguration[]{config};
}
@Override
public GraphicsConfiguration getDefaultConfiguration() {
return graphicsConf;
return config;
}
@Override
public void setFullScreenWindow(Window w) {
// Do nothing
}
@Override
public Window getFullScreenWindow() {
return null;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2019, 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
@ -28,32 +28,33 @@ package sun.awt;
import java.awt.AWTException;
import java.awt.BufferCapabilities;
import java.awt.Component;
import java.awt.Toolkit;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.Image;
import java.awt.ImageCapabilities;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.Transparency;
import java.awt.image.ColorModel;
import java.awt.color.ColorSpace;
import java.awt.geom.AffineTransform;
import java.awt.image.ColorModel;
import java.awt.image.ComponentColorModel;
import java.awt.image.DirectColorModel;
import java.awt.image.DataBuffer;
import java.awt.image.DirectColorModel;
import java.awt.image.VolatileImage;
import java.awt.image.WritableRaster;
import java.awt.geom.AffineTransform;
import java.awt.Rectangle;
import sun.java2d.Disposer;
import sun.java2d.DisposerRecord;
import sun.java2d.SurfaceData;
import sun.java2d.loops.RenderLoops;
import sun.java2d.loops.SurfaceType;
import sun.java2d.loops.CompositeType;
import sun.java2d.pipe.Region;
import sun.java2d.x11.X11SurfaceData;
import sun.awt.image.OffScreenImage;
import sun.awt.image.SunVolatileImage;
import sun.awt.image.SurfaceManager;
import sun.java2d.Disposer;
import sun.java2d.DisposerRecord;
import sun.java2d.SurfaceData;
import sun.java2d.loops.CompositeType;
import sun.java2d.loops.RenderLoops;
import sun.java2d.loops.SurfaceType;
import sun.java2d.pipe.Region;
import sun.java2d.x11.X11SurfaceData;
/**
* This is an implementation of a GraphicsConfiguration object for a
@ -65,7 +66,7 @@ import sun.awt.image.SurfaceManager;
public class X11GraphicsConfig extends GraphicsConfiguration
implements SurfaceManager.ProxiedGraphicsConfig
{
protected X11GraphicsDevice screen;
private final X11GraphicsDevice device;
protected int visual;
int depth;
int colormap;
@ -116,12 +117,12 @@ public class X11GraphicsConfig extends GraphicsConfiguration
int visualnum, int depth,
int colormap, boolean doubleBuffer)
{
this.screen = device;
this.device = device;
this.visual = visualnum;
this.doubleBuffer = doubleBuffer;
this.depth = depth;
this.colormap = colormap;
init (visualnum, screen.getScreen());
init (visualnum, device.getScreen());
// add a record to the Disposer so that we destroy the native
// AwtGraphicsConfigData when this object goes away (i.e. after a
@ -134,8 +135,9 @@ public class X11GraphicsConfig extends GraphicsConfiguration
/**
* Return the graphics device associated with this configuration.
*/
@Override
public X11GraphicsDevice getDevice() {
return screen;
return device;
}
/**
@ -177,8 +179,9 @@ public class X11GraphicsConfig extends GraphicsConfiguration
return surfaceType;
}
@Override
public Object getProxyKey() {
return screen.getProxyKeyFor(getSurfaceType());
return device.getProxyKeyFor(getSurfaceType());
}
/**
@ -197,6 +200,7 @@ public class X11GraphicsConfig extends GraphicsConfiguration
/**
* Returns the color model associated with this configuration.
*/
@Override
public synchronized ColorModel getColorModel() {
if (colorModel == null) {
// Force SystemColors to be resolved before we create the CM
@ -218,6 +222,7 @@ public class X11GraphicsConfig extends GraphicsConfiguration
* Returns the color model associated with this configuration that
* supports the specified transparency.
*/
@Override
public ColorModel getColorModel(int transparency) {
switch (transparency) {
case Transparency.OPAQUE:
@ -256,6 +261,7 @@ public class X11GraphicsConfig extends GraphicsConfiguration
* increasing to the right and Y coordinates increasing downwards.
* For image buffers, this Transform will be the Identity transform.
*/
@Override
public AffineTransform getDefaultTransform() {
double scale = getScale();
return AffineTransform.getScaleInstance(scale, scale);
@ -292,9 +298,10 @@ public class X11GraphicsConfig extends GraphicsConfiguration
* For image buffers, this Transform will be the Identity transform,
* since there is no valid distance measurement.
*/
@Override
public AffineTransform getNormalizingTransform() {
double xscale = getXResolution(screen.getScreen()) / 72.0;
double yscale = getYResolution(screen.getScreen()) / 72.0;
double xscale = getXResolution(device.getScreen()) / 72.0;
double yscale = getYResolution(device.getScreen()) / 72.0;
return new AffineTransform(xscale, 0.0, 0.0, yscale, 0.0, 0.0);
}
@ -306,7 +313,7 @@ public class X11GraphicsConfig extends GraphicsConfiguration
}
public String toString() {
return ("X11GraphicsConfig[dev="+screen+
return ("X11GraphicsConfig[dev="+device+
",vis=0x"+Integer.toHexString(visual)+
"]");
}
@ -321,8 +328,9 @@ public class X11GraphicsConfig extends GraphicsConfiguration
initIDs ();
}
@Override
public Rectangle getBounds() {
Rectangle rect = pGetBounds(screen.getScreen());
Rectangle rect = pGetBounds(device.getScreen());
if (getScale() != 1) {
rect.x = scaleDown(rect.x);
rect.y = scaleDown(rect.y);
@ -340,6 +348,7 @@ public class X11GraphicsConfig extends GraphicsConfiguration
}
}
@Override
public BufferCapabilities getBufferCapabilities() {
if (bufferCaps == null) {
if (doubleBuffer) {
@ -351,6 +360,7 @@ public class X11GraphicsConfig extends GraphicsConfiguration
return bufferCaps;
}
@Override
public ImageCapabilities getImageCapabilities() {
return imageCaps;
}
@ -366,6 +376,7 @@ public class X11GraphicsConfig extends GraphicsConfiguration
public X11GCDisposerRecord(long x11CfgData) {
this.x11ConfigData = x11CfgData;
}
@Override
public synchronized void dispose() {
if (x11ConfigData != 0L) {
X11GraphicsConfig.dispose(x11ConfigData);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2019, 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
@ -27,23 +27,22 @@ package sun.awt;
import java.awt.AWTPermission;
import java.awt.DisplayMode;
import java.awt.GraphicsEnvironment;
import java.awt.GraphicsDevice;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.awt.Window;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.HashMap;
import sun.java2d.opengl.GLXGraphicsConfig;
import sun.java2d.xr.XRGraphicsConfig;
import sun.java2d.loops.SurfaceType;
import java.util.HashSet;
import sun.awt.util.ThreadGroupUtils;
import sun.java2d.SunGraphicsEnvironment;
import sun.java2d.loops.SurfaceType;
import sun.java2d.opengl.GLXGraphicsConfig;
import sun.java2d.xr.XRGraphicsConfig;
/**
* This is an implementation of a GraphicsDevice object for a single
@ -76,12 +75,6 @@ public final class X11GraphicsDevice extends GraphicsDevice
*/
private static native void initIDs();
static {
if (!GraphicsEnvironment.isHeadless()) {
initIDs();
}
}
/**
* Returns the X11 screen of the device.
*/
@ -113,6 +106,7 @@ public final class X11GraphicsDevice extends GraphicsDevice
* @see #TYPE_PRINTER
* @see #TYPE_IMAGE_BUFFER
*/
@Override
public int getType() {
return TYPE_RASTER_SCREEN;
}
@ -121,6 +115,7 @@ public final class X11GraphicsDevice extends GraphicsDevice
* Returns the identification string associated with this graphics
* device.
*/
@Override
public String getIDstring() {
return ":0."+screen;
}
@ -134,6 +129,7 @@ public final class X11GraphicsDevice extends GraphicsDevice
* Returns all of the graphics
* configurations associated with this graphics device.
*/
@Override
public GraphicsConfiguration[] getConfigurations() {
if (configs == null) {
synchronized (configLock) {
@ -221,6 +217,7 @@ public final class X11GraphicsDevice extends GraphicsDevice
* Returns the default graphics configuration
* associated with this graphics device.
*/
@Override
public GraphicsConfiguration getDefaultConfiguration() {
if (defaultConfig == null) {
synchronized (configLock) {
@ -487,6 +484,7 @@ public final class X11GraphicsDevice extends GraphicsDevice
* From the DisplayChangedListener interface; called from
* X11GraphicsEnvironment when the display mode has been changed.
*/
@Override
public synchronized void displayChanged() {
scale = initScaleFactor();
// On X11 the visuals do not change, and therefore we don't need
@ -501,6 +499,7 @@ public final class X11GraphicsDevice extends GraphicsDevice
* From the DisplayChangedListener interface; devices do not need
* to react to this event.
*/
@Override
public void paletteChanged() {
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2019, 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
@ -41,6 +41,7 @@ import java.awt.image.DataBuffer;
import java.awt.image.DirectColorModel;
import java.awt.image.VolatileImage;
import java.awt.image.WritableRaster;
import sun.awt.X11ComponentPeer;
import sun.awt.X11GraphicsConfig;
import sun.awt.X11GraphicsDevice;
@ -51,15 +52,18 @@ import sun.awt.image.SurfaceManager;
import sun.java2d.SunGraphics2D;
import sun.java2d.Surface;
import sun.java2d.SurfaceData;
import sun.java2d.opengl.GLXSurfaceData.GLXVSyncOffScreenSurfaceData;
import sun.java2d.pipe.hw.AccelSurface;
import sun.java2d.pipe.hw.AccelTypedVolatileImage;
import sun.java2d.pipe.hw.ContextCapabilities;
import static sun.java2d.opengl.OGLSurfaceData.*;
import static sun.java2d.opengl.OGLContext.*;
import static sun.java2d.opengl.OGLContext.OGLContextCaps.*;
import sun.java2d.opengl.GLXSurfaceData.GLXVSyncOffScreenSurfaceData;
public class GLXGraphicsConfig
import static sun.java2d.opengl.OGLContext.OGLContextCaps;
import static sun.java2d.opengl.OGLContext.OGLContextCaps.CAPS_DOUBLEBUFFERED;
import static sun.java2d.opengl.OGLContext.OGLContextCaps.CAPS_EXT_FBOBJECT;
import static sun.java2d.opengl.OGLSurfaceData.FBOBJECT;
import static sun.java2d.opengl.OGLSurfaceData.TEXTURE;
public final class GLXGraphicsConfig
extends X11GraphicsConfig
implements OGLGraphicsConfig
{
@ -172,11 +176,6 @@ public class GLXGraphicsConfig
return pConfigInfo;
}
/**
* {@inheritDoc}
*
* @see sun.java2d.pipe.hw.BufferedContextProvider#getContext
*/
@Override
public final OGLContext getContext() {
return context;
@ -211,7 +210,7 @@ public class GLXGraphicsConfig
}
public String toString() {
return ("GLXGraphicsConfig[dev="+screen+
return ("GLXGraphicsConfig[dev="+getDevice()+
",vis=0x"+Integer.toHexString(visual)+
"]");
}
@ -386,11 +385,6 @@ public class GLXGraphicsConfig
return imageCaps;
}
/**
* {@inheritDoc}
*
* @see sun.java2d.pipe.hw.AccelGraphicsConfig#createCompatibleVolatileImage
*/
@Override
public VolatileImage
createCompatibleVolatileImage(int width, int height,
@ -414,11 +408,6 @@ public class GLXGraphicsConfig
return vi;
}
/**
* {@inheritDoc}
*
* @see sun.java2d.pipe.hw.AccelGraphicsConfig#getContextCapabilities
*/
@Override
public ContextCapabilities getContextCapabilities() {
return oglCaps;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2019, 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
@ -62,12 +62,6 @@ jboolean isXShmAttachFailed();
struct X11GraphicsConfigIDs {
jfieldID aData;
jfieldID bitsPerPixel;
jfieldID screen;
};
/* fieldIDs for X11GraphicsDevice fields that may be accessed from C */
struct X11GraphicsDeviceIDs {
jfieldID screen;
};
#endif /* _AWT_GRAPHICSENV_H_ */

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2019, 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
@ -96,7 +96,6 @@ jboolean awtLockInited = JNI_FALSE;
} while (0)
struct X11GraphicsConfigIDs x11GraphicsConfigIDs;
struct X11GraphicsDeviceIDs x11GraphicsDeviceIDs;
#ifndef HEADLESS
int awtCreateX11Colormap(AwtGraphicsConfigDataPtr adata);
@ -152,32 +151,20 @@ Java_sun_awt_X11GraphicsConfig_initIDs (JNIEnv *env, jclass cls)
{
x11GraphicsConfigIDs.aData = NULL;
x11GraphicsConfigIDs.bitsPerPixel = NULL;
x11GraphicsConfigIDs.screen = NULL;
x11GraphicsConfigIDs.aData = (*env)->GetFieldID (env, cls, "aData", "J");
CHECK_NULL(x11GraphicsConfigIDs.aData);
x11GraphicsConfigIDs.bitsPerPixel = (*env)->GetFieldID (env, cls, "bitsPerPixel", "I");
CHECK_NULL(x11GraphicsConfigIDs.bitsPerPixel);
x11GraphicsConfigIDs.screen = (*env)->GetFieldID (env, cls, "screen", "Lsun/awt/X11GraphicsDevice;");
CHECK_NULL(x11GraphicsConfigIDs.screen);
if (x11GraphicsConfigIDs.aData == NULL ||
x11GraphicsConfigIDs.bitsPerPixel == NULL ||
x11GraphicsConfigIDs.screen == NULL) {
x11GraphicsConfigIDs.bitsPerPixel == NULL) {
JNU_ThrowNoSuchFieldError(env, "Can't find a field");
return;
}
}
JNIEXPORT void JNICALL
Java_sun_awt_X11GraphicsDevice_initIDs (JNIEnv *env, jclass cls)
{
x11GraphicsDeviceIDs.screen = NULL;
x11GraphicsDeviceIDs.screen = (*env)->GetFieldID (env, cls, "screen", "I");
DASSERT(x11GraphicsDeviceIDs.screen);
}
#ifndef HEADLESS
/*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2019, 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
@ -33,28 +33,22 @@ import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Image;
import java.awt.ImageCapabilities;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.Transparency;
import java.awt.Window;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.DirectColorModel;
import java.awt.image.Raster;
import java.awt.image.VolatileImage;
import java.awt.image.WritableRaster;
import sun.awt.windows.WComponentPeer;
import sun.awt.image.OffScreenImage;
import sun.awt.image.SunVolatileImage;
import sun.awt.image.SurfaceManager;
import sun.awt.windows.WComponentPeer;
import sun.java2d.SurfaceData;
import sun.java2d.InvalidPipeException;
import sun.java2d.loops.CompositeType;
import sun.java2d.loops.RenderLoops;
import sun.java2d.loops.SurfaceType;
import sun.java2d.loops.CompositeType;
import sun.java2d.windows.GDIWindowSurfaceData;
/**
@ -67,7 +61,7 @@ import sun.java2d.windows.GDIWindowSurfaceData;
public class Win32GraphicsConfig extends GraphicsConfiguration
implements DisplayChangedListener, SurfaceManager.ProxiedGraphicsConfig
{
protected Win32GraphicsDevice screen;
private final Win32GraphicsDevice device;
protected int visual; //PixelFormatID
protected RenderLoops solidloops;
@ -98,7 +92,7 @@ public class Win32GraphicsConfig extends GraphicsConfiguration
*/
@Deprecated
public Win32GraphicsConfig(GraphicsDevice device, int visualnum) {
this.screen = (Win32GraphicsDevice)device;
this.device = (Win32GraphicsDevice)device;
this.visual = visualnum;
((Win32GraphicsDevice)device).addDisplayChangedListener(this);
}
@ -106,8 +100,9 @@ public class Win32GraphicsConfig extends GraphicsConfiguration
/**
* Return the graphics device associated with this configuration.
*/
@Override
public Win32GraphicsDevice getDevice() {
return screen;
return device;
}
/**
@ -117,8 +112,9 @@ public class Win32GraphicsConfig extends GraphicsConfiguration
return visual;
}
@Override
public Object getProxyKey() {
return screen;
return device;
}
/**
@ -139,8 +135,9 @@ public class Win32GraphicsConfig extends GraphicsConfiguration
/**
* Returns the color model associated with this configuration.
*/
@Override
public synchronized ColorModel getColorModel() {
return screen.getColorModel();
return device.getColorModel();
}
/**
@ -152,13 +149,14 @@ public class Win32GraphicsConfig extends GraphicsConfiguration
* to reflect the new situation.
*/
public ColorModel getDeviceColorModel() {
return screen.getDynamicColorModel();
return device.getDynamicColorModel();
}
/**
* Returns the color model associated with this configuration that
* supports the specified transparency.
*/
@Override
public ColorModel getColorModel(int transparency) {
switch (transparency) {
case Transparency.OPAQUE:
@ -181,9 +179,10 @@ public class Win32GraphicsConfig extends GraphicsConfiguration
* increasing to the right and Y coordinates increasing downwards.
* For image buffers, this Transform will be the Identity transform.
*/
@Override
public AffineTransform getDefaultTransform() {
double scaleX = screen.getDefaultScaleX();
double scaleY = screen.getDefaultScaleY();
double scaleX = device.getDefaultScaleX();
double scaleY = device.getDefaultScaleY();
return AffineTransform.getScaleInstance(scaleX, scaleY);
}
@ -206,6 +205,7 @@ public class Win32GraphicsConfig extends GraphicsConfiguration
* For image buffers, this Transform will be the Identity transform,
* since there is no valid distance measurement.
*/
@Override
public AffineTransform getNormalizingTransform() {
Win32GraphicsEnvironment ge = (Win32GraphicsEnvironment)
GraphicsEnvironment.getLocalGraphicsEnvironment();
@ -215,19 +215,22 @@ public class Win32GraphicsConfig extends GraphicsConfiguration
}
public String toString() {
return (super.toString()+"[dev="+screen+",pixfmt="+visual+"]");
return (super.toString()+"[dev="+device+",pixfmt="+visual+"]");
}
private native Rectangle getBounds(int screen);
@Override
public Rectangle getBounds() {
return getBounds(screen.getScreen());
return getBounds(device.getScreen());
}
@Override
public synchronized void displayChanged() {
solidloops = null;
}
@Override
public void paletteChanged() {}
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2019, 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
@ -26,28 +26,27 @@
package sun.awt;
import java.awt.AWTPermission;
import java.awt.GraphicsDevice;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsEnvironment;
import java.awt.DisplayMode;
import java.awt.EventQueue;
import java.awt.Frame;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.awt.Window;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.awt.geom.Point2D;
import java.awt.image.ColorModel;
import java.awt.peer.WindowPeer;
import java.util.ArrayList;
import java.util.Vector;
import java.awt.peer.WindowPeer;
import java.security.AccessController;
import sun.awt.windows.WWindowPeer;
import sun.java2d.SunGraphicsEnvironment;
import sun.java2d.opengl.WGLGraphicsConfig;
import sun.java2d.windows.WindowsFlags;
import sun.security.action.GetPropertyAction;
import static sun.awt.Win32GraphicsEnvironment.debugScaleX;
import static sun.awt.Win32GraphicsEnvironment.debugScaleY;
@ -131,6 +130,7 @@ public class Win32GraphicsDevice extends GraphicsDevice implements
* @see #TYPE_PRINTER
* @see #TYPE_IMAGE_BUFFER
*/
@Override
public int getType() {
return TYPE_RASTER_SCREEN;
}
@ -189,6 +189,7 @@ public class Win32GraphicsDevice extends GraphicsDevice implements
* Returns the identification string associated with this graphics
* device.
*/
@Override
public String getIDstring() {
return idString;
}
@ -198,6 +199,7 @@ public class Win32GraphicsDevice extends GraphicsDevice implements
* Returns all of the graphics
* configurations associated with this graphics device.
*/
@Override
public GraphicsConfiguration[] getConfigurations() {
if (configs==null) {
if (WindowsFlags.isOGLEnabled() && isDefaultDevice()) {
@ -290,6 +292,7 @@ public class Win32GraphicsDevice extends GraphicsDevice implements
* Returns the default graphics configuration
* associated with this graphics device.
*/
@Override
public GraphicsConfiguration getDefaultConfiguration() {
if (defaultConfig == null) {
// first try to create a WGLGraphicsConfig if OGL is enabled
@ -329,6 +332,7 @@ public class Win32GraphicsDevice extends GraphicsDevice implements
return defaultConfig;
}
@Override
public String toString() {
return valid ? descString + "]" : descString + ", removed]";
}
@ -519,6 +523,7 @@ public class Win32GraphicsDevice extends GraphicsDevice implements
* Called from Win32GraphicsEnvironment when the display settings have
* changed.
*/
@Override
public void displayChanged() {
dynamicColorModel = null;
defaultConfig = null;
@ -532,6 +537,7 @@ public class Win32GraphicsDevice extends GraphicsDevice implements
* Part of the DisplayChangedListener interface: devices
* do not need to react to this event
*/
@Override
public void paletteChanged() {
}
@ -659,6 +665,7 @@ public class Win32GraphicsDevice extends GraphicsDevice implements
// Fix for 6709453. Using invokeLater to avoid listening
// for the events already posted to the queue.
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
w.addWindowListener(fsWindowListener);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2019, 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
@ -49,14 +49,14 @@ import sun.java2d.pipe.hw.ContextCapabilities;
import static sun.java2d.pipe.hw.AccelSurface.*;
import static sun.java2d.d3d.D3DContext.D3DContextCaps.*;
public class D3DGraphicsConfig
public final class D3DGraphicsConfig
extends Win32GraphicsConfig
implements AccelGraphicsConfig
{
private static ImageCapabilities imageCaps = new D3DImageCaps();
private BufferCapabilities bufferCaps;
private D3DGraphicsDevice device;
private final D3DGraphicsDevice device;
@SuppressWarnings("deprecation")
protected D3DGraphicsConfig(D3DGraphicsDevice device) {
@ -107,7 +107,7 @@ public class D3DGraphicsConfig
@Override
public String toString() {
return ("D3DGraphicsConfig[dev="+screen+",pixfmt="+visual+"]");
return ("D3DGraphicsConfig[dev="+device+",pixfmt="+visual+"]");
}
/**
@ -263,21 +263,11 @@ public class D3DGraphicsConfig
return device;
}
/**
* {@inheritDoc}
*
* @see sun.java2d.pipe.hw.BufferedContextProvider#getContext
*/
@Override
public D3DContext getContext() {
return device.getContext();
}
/**
* {@inheritDoc}
*
* @see sun.java2d.pipe.hw.AccelGraphicsConfig#createCompatibleVolatileImage
*/
@Override
public VolatileImage
createCompatibleVolatileImage(int width, int height,
@ -313,11 +303,6 @@ public class D3DGraphicsConfig
return vi;
}
/**
* {@inheritDoc}
*
* @see sun.java2d.pipe.hw.AccelGraphicsConfig#getContextCapabilities
*/
@Override
public ContextCapabilities getContextCapabilities() {
return device.getContextCapabilities();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2019, 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
@ -42,17 +42,19 @@ import sun.awt.AWTAccessor;
import sun.awt.AWTAccessor.ComponentAccessor;
import sun.awt.Win32GraphicsDevice;
import sun.awt.windows.WWindowPeer;
import sun.java2d.d3d.D3DContext.D3DContextCaps;
import sun.java2d.pipe.hw.ContextCapabilities;
import sun.java2d.windows.WindowsFlags;
import static sun.java2d.d3d.D3DContext.D3DContextCaps.*;
import sun.java2d.d3d.D3DContext.D3DContextCaps;
import static sun.java2d.d3d.D3DContext.D3DContextCaps.CAPS_DEVICE_OK;
import static sun.java2d.d3d.D3DContext.D3DContextCaps.CAPS_EMPTY;
/**
* This class implements D3D-specific functionality, such as fullscreen
* exclusive mode and display changes. It is kept separate from
* Win32GraphicsDevice to help avoid overburdening the parent class.
*/
public class D3DGraphicsDevice extends Win32GraphicsDevice {
public final class D3DGraphicsDevice extends Win32GraphicsDevice {
private D3DContext context;
private static boolean d3dAvailable;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2019, 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
@ -38,6 +38,7 @@ import java.awt.image.ColorModel;
import java.awt.image.DataBuffer;
import java.awt.image.DirectColorModel;
import java.awt.image.VolatileImage;
import sun.awt.Win32GraphicsConfig;
import sun.awt.Win32GraphicsDevice;
import sun.awt.image.SunVolatileImage;
@ -48,15 +49,19 @@ import sun.java2d.DisposerRecord;
import sun.java2d.SunGraphics2D;
import sun.java2d.Surface;
import sun.java2d.SurfaceData;
import sun.java2d.opengl.OGLContext.OGLContextCaps;
import sun.java2d.pipe.hw.AccelSurface;
import sun.java2d.pipe.hw.AccelTypedVolatileImage;
import sun.java2d.pipe.hw.ContextCapabilities;
import static sun.java2d.opengl.OGLContext.OGLContextCaps.*;
import static sun.java2d.opengl.WGLSurfaceData.*;
import sun.java2d.opengl.OGLContext.OGLContextCaps;
import sun.java2d.windows.GDIWindowSurfaceData;
public class WGLGraphicsConfig
import static sun.java2d.opengl.OGLContext.OGLContextCaps.CAPS_DOUBLEBUFFERED;
import static sun.java2d.opengl.OGLContext.OGLContextCaps.CAPS_EXT_FBOBJECT;
import static sun.java2d.opengl.WGLSurfaceData.FBOBJECT;
import static sun.java2d.opengl.WGLSurfaceData.TEXTURE;
import static sun.java2d.opengl.WGLSurfaceData.WGLVSyncOffScreenSurfaceData;
public final class WGLGraphicsConfig
extends Win32GraphicsConfig
implements OGLGraphicsConfig
{
@ -93,10 +98,12 @@ public class WGLGraphicsConfig
new WGLGCDisposerRecord(pConfigInfo));
}
@Override
public Object getProxyKey() {
return this;
}
@Override
public SurfaceData createManagedSurface(int w, int h, int transparency) {
return WGLSurfaceData.createData(this, w, h,
getColorModel(transparency),
@ -127,6 +134,7 @@ public class WGLGraphicsConfig
if (cfginfo != 0L) {
OGLContext.setScratchSurface(cfginfo);
rq.flushAndInvokeNow(new Runnable() {
@Override
public void run() {
ids[0] = OGLContext.getOGLIdString();
}
@ -157,6 +165,7 @@ public class WGLGraphicsConfig
this.screen = screen;
this.pixfmt = pixfmt;
}
@Override
public void run() {
cfginfo = getWGLConfigInfo(screen, pixfmt);
}
@ -183,11 +192,6 @@ public class WGLGraphicsConfig
return pConfigInfo;
}
/**
* {@inheritDoc}
*
* @see sun.java2d.pipe.hw.BufferedContextProvider#getContext
*/
@Override
public final OGLContext getContext() {
return context;
@ -198,6 +202,7 @@ public class WGLGraphicsConfig
public WGLGCDisposerRecord(long pCfgInfo) {
this.pCfgInfo = pCfgInfo;
}
@Override
public void dispose() {
if (pCfgInfo != 0) {
OGLRenderQueue.disposeGraphicsConfig(pCfgInfo);
@ -242,7 +247,7 @@ public class WGLGraphicsConfig
@Override
public String toString() {
return ("WGLGraphicsConfig[dev="+screen+",pixfmt="+visual+"]");
return ("WGLGraphicsConfig[dev="+getDevice()+",pixfmt="+visual+"]");
}
/**
@ -388,6 +393,7 @@ public class WGLGraphicsConfig
private WGLImageCaps() {
super(true);
}
@Override
public boolean isTrueVolatile() {
return true;
}
@ -398,11 +404,6 @@ public class WGLGraphicsConfig
return imageCaps;
}
/**
* {@inheritDoc}
*
* @see sun.java2d.pipe.hw.AccelGraphicsConfig#createCompatibleVolatileImage
*/
@Override
public VolatileImage
createCompatibleVolatileImage(int width, int height,
@ -426,11 +427,6 @@ public class WGLGraphicsConfig
return vi;
}
/**
* {@inheritDoc}
*
* @see sun.java2d.pipe.hw.AccelGraphicsConfig#getContextCapabilities
*/
@Override
public ContextCapabilities getContextCapabilities() {
return oglCaps;