feat(jdk8): move files to new folder to avoid resources compiled.

This commit is contained in:
2025-09-07 15:25:52 +08:00
parent 3f0047bf6f
commit 8c35cfb1c0
17415 changed files with 217 additions and 213 deletions

View File

@@ -0,0 +1,146 @@
/*
* Copyright (c) 2002, 2008, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.java2d.windows;
import java.awt.Composite;
import sun.java2d.loops.GraphicsPrimitive;
import sun.java2d.loops.GraphicsPrimitiveMgr;
import sun.java2d.loops.CompositeType;
import sun.java2d.loops.SurfaceType;
import sun.java2d.loops.Blit;
import sun.java2d.pipe.Region;
import sun.java2d.SurfaceData;
/**
* GDIBlitLoops
*
* This class accelerates Blits between certain surfaces and the
* screen, using GDI. The reason for these loops is to find
* a way of copying to the screen without using DDraw locking
* that is faster than our current fallback (which creates
* a temporary GDI DIB)
*/
public class GDIBlitLoops extends Blit {
// Store these values to be passed to native code
int rmask, gmask, bmask;
// Needs lookup table (for indexed color image copies)
boolean indexed = false;
/**
* Note that we do not register loops to 8-byte destinations. This
* is due to faster processing of dithering through our software
* loops than through GDI StretchBlt processing.
*/
public static void register()
{
GraphicsPrimitive[] primitives = {
new GDIBlitLoops(SurfaceType.IntRgb,
GDIWindowSurfaceData.AnyGdi),
new GDIBlitLoops(SurfaceType.Ushort555Rgb,
GDIWindowSurfaceData.AnyGdi,
0x7C00, 0x03E0, 0x001F),
new GDIBlitLoops(SurfaceType.Ushort565Rgb,
GDIWindowSurfaceData.AnyGdi,
0xF800, 0x07E0, 0x001F),
new GDIBlitLoops(SurfaceType.ThreeByteBgr,
GDIWindowSurfaceData.AnyGdi),
new GDIBlitLoops(SurfaceType.ByteIndexedOpaque,
GDIWindowSurfaceData.AnyGdi,
true),
new GDIBlitLoops(SurfaceType.Index8Gray,
GDIWindowSurfaceData.AnyGdi,
true),
new GDIBlitLoops(SurfaceType.ByteGray,
GDIWindowSurfaceData.AnyGdi),
};
GraphicsPrimitiveMgr.register(primitives);
}
/**
* This constructor exists for srcTypes that have no need of
* component masks. GDI only expects masks for 2- and 4-byte
* DIBs, so all 1- and 3-byte srcTypes can skip the mask setting.
*/
public GDIBlitLoops(SurfaceType srcType, SurfaceType dstType) {
this(srcType, dstType, 0, 0, 0);
}
/**
* This constructor exists for srcTypes that need lookup tables
* during image copying.
*/
public GDIBlitLoops(SurfaceType srcType, SurfaceType dstType,
boolean indexed)
{
this(srcType, dstType, 0, 0, 0);
this.indexed = indexed;
}
/**
* This constructor sets mask for this primitive which can be
* retrieved in native code to set the appropriate values for GDI.
*/
public GDIBlitLoops(SurfaceType srcType, SurfaceType dstType,
int rmask, int gmask, int bmask)
{
super(srcType, CompositeType.SrcNoEa, dstType);
this.rmask = rmask;
this.gmask = gmask;
this.bmask = bmask;
}
/**
* nativeBlit
* This native method is where all of the work happens in the
* accelerated Blit.
*/
public native void nativeBlit(SurfaceData src, SurfaceData dst,
Region clip,
int sx, int sy, int dx, int dy,
int w, int h,
int rmask, int gmask, int bmask,
boolean needLut);
/**
* Blit
* This method wraps the nativeBlit call, sending in additional
* info on whether the native method needs to get LUT info
* from the source image. Note that we do not pass in the
* Composite data because we only register these loops for
* SrcNoEa composite operations.
*/
public void Blit(SurfaceData src, SurfaceData dst,
Composite comp, Region clip,
int sx, int sy, int dx, int dy, int w, int h)
{
nativeBlit(src, dst, clip, sx, sy, dx, dy, w, h,
rmask, gmask, bmask, indexed);
}
}

View File

@@ -0,0 +1,450 @@
/*
* Copyright (c) 1999, 2011, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.java2d.windows;
import java.awt.Composite;
import java.awt.Shape;
import java.awt.geom.Path2D;
import java.awt.geom.PathIterator;
import sun.java2d.InvalidPipeException;
import sun.java2d.SunGraphics2D;
import sun.java2d.SurfaceData;
import sun.java2d.pipe.Region;
import sun.java2d.pipe.PixelDrawPipe;
import sun.java2d.pipe.PixelFillPipe;
import sun.java2d.pipe.ShapeDrawPipe;
import sun.java2d.pipe.SpanIterator;
import sun.java2d.pipe.ShapeSpanIterator;
import sun.java2d.pipe.LoopPipe;
import sun.java2d.loops.GraphicsPrimitive;
public class GDIRenderer implements
PixelDrawPipe,
PixelFillPipe,
ShapeDrawPipe
{
native void doDrawLine(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x1, int y1, int x2, int y2);
public void drawLine(SunGraphics2D sg2d,
int x1, int y1, int x2, int y2)
{
int transx = sg2d.transX;
int transy = sg2d.transY;
try {
doDrawLine((GDIWindowSurfaceData)sg2d.surfaceData,
sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
x1+transx, y1+transy, x2+transx, y2+transy);
} catch (ClassCastException e) {
throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
}
}
native void doDrawRect(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x, int y, int w, int h);
public void drawRect(SunGraphics2D sg2d,
int x, int y, int width, int height)
{
try {
doDrawRect((GDIWindowSurfaceData)sg2d.surfaceData,
sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
x+sg2d.transX, y+sg2d.transY, width, height);
} catch (ClassCastException e) {
throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
}
}
native void doDrawRoundRect(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x, int y, int w, int h,
int arcW, int arcH);
public void drawRoundRect(SunGraphics2D sg2d,
int x, int y, int width, int height,
int arcWidth, int arcHeight)
{
try {
doDrawRoundRect((GDIWindowSurfaceData)sg2d.surfaceData,
sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
x+sg2d.transX, y+sg2d.transY, width, height,
arcWidth, arcHeight);
} catch (ClassCastException e) {
throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
}
}
native void doDrawOval(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x, int y, int w, int h);
public void drawOval(SunGraphics2D sg2d,
int x, int y, int width, int height)
{
try {
doDrawOval((GDIWindowSurfaceData)sg2d.surfaceData,
sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
x+sg2d.transX, y+sg2d.transY, width, height);
} catch (ClassCastException e) {
throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
}
}
native void doDrawArc(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x, int y, int w, int h,
int angleStart, int angleExtent);
public void drawArc(SunGraphics2D sg2d,
int x, int y, int width, int height,
int startAngle, int arcAngle)
{
try {
doDrawArc((GDIWindowSurfaceData)sg2d.surfaceData,
sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
x+sg2d.transX, y+sg2d.transY, width, height,
startAngle, arcAngle);
} catch (ClassCastException e) {
throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
}
}
native void doDrawPoly(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int transx, int transy,
int[] xpoints, int[] ypoints,
int npoints, boolean isclosed);
public void drawPolyline(SunGraphics2D sg2d,
int xpoints[], int ypoints[],
int npoints)
{
try {
doDrawPoly((GDIWindowSurfaceData)sg2d.surfaceData,
sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
sg2d.transX, sg2d.transY, xpoints, ypoints, npoints, false);
} catch (ClassCastException e) {
throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
}
}
public void drawPolygon(SunGraphics2D sg2d,
int xpoints[], int ypoints[],
int npoints)
{
try {
doDrawPoly((GDIWindowSurfaceData)sg2d.surfaceData,
sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
sg2d.transX, sg2d.transY, xpoints, ypoints, npoints, true);
} catch (ClassCastException e) {
throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
}
}
native void doFillRect(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x, int y, int w, int h);
public void fillRect(SunGraphics2D sg2d,
int x, int y, int width, int height)
{
try {
doFillRect((GDIWindowSurfaceData)sg2d.surfaceData,
sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
x+sg2d.transX, y+sg2d.transY, width, height);
} catch (ClassCastException e) {
throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
}
}
native void doFillRoundRect(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x, int y, int w, int h,
int arcW, int arcH);
public void fillRoundRect(SunGraphics2D sg2d,
int x, int y, int width, int height,
int arcWidth, int arcHeight)
{
try {
doFillRoundRect((GDIWindowSurfaceData)sg2d.surfaceData,
sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
x+sg2d.transX, y+sg2d.transY, width, height,
arcWidth, arcHeight);
} catch (ClassCastException e) {
throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
}
}
native void doFillOval(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x, int y, int w, int h);
public void fillOval(SunGraphics2D sg2d,
int x, int y, int width, int height)
{
try {
doFillOval((GDIWindowSurfaceData)sg2d.surfaceData,
sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
x+sg2d.transX, y+sg2d.transY, width, height);
} catch (ClassCastException e) {
throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
}
}
native void doFillArc(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x, int y, int w, int h,
int angleStart, int angleExtent);
public void fillArc(SunGraphics2D sg2d,
int x, int y, int width, int height,
int startAngle, int arcAngle)
{
try {
doFillArc((GDIWindowSurfaceData)sg2d.surfaceData,
sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
x+sg2d.transX, y+sg2d.transY, width, height,
startAngle, arcAngle);
} catch (ClassCastException e) {
throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
}
}
native void doFillPoly(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int transx, int transy,
int[] xpoints, int[] ypoints,
int npoints);
public void fillPolygon(SunGraphics2D sg2d,
int xpoints[], int ypoints[],
int npoints)
{
try {
doFillPoly((GDIWindowSurfaceData)sg2d.surfaceData,
sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
sg2d.transX, sg2d.transY, xpoints, ypoints, npoints);
} catch (ClassCastException e) {
throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
}
}
native void doShape(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int transX, int transY,
Path2D.Float p2df, boolean isfill);
void doShape(SunGraphics2D sg2d, Shape s, boolean isfill) {
Path2D.Float p2df;
int transX;
int transY;
if (sg2d.transformState <= sg2d.TRANSFORM_INT_TRANSLATE) {
if (s instanceof Path2D.Float) {
p2df = (Path2D.Float)s;
} else {
p2df = new Path2D.Float(s);
}
transX = sg2d.transX;
transY = sg2d.transY;
} else {
p2df = new Path2D.Float(s, sg2d.transform);
transX = 0;
transY = 0;
}
try {
doShape((GDIWindowSurfaceData)sg2d.surfaceData,
sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
transX, transY, p2df, isfill);
} catch (ClassCastException e) {
throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
}
}
// REMIND: This is just a hack to get WIDE lines to honor the
// necessary hinted pixelization rules. This should be replaced
// by a native FillSpans method or a getHintedStrokeGeneralPath()
// method that could be filled by the doShape method more quickly.
public void doFillSpans(SunGraphics2D sg2d, SpanIterator si) {
int box[] = new int[4];
GDIWindowSurfaceData sd;
try {
sd = (GDIWindowSurfaceData)sg2d.surfaceData;
} catch (ClassCastException e) {
throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
}
Region clip = sg2d.getCompClip();
Composite comp = sg2d.composite;
int eargb = sg2d.eargb;
while (si.nextSpan(box)) {
doFillRect(sd, clip, comp, eargb,
box[0], box[1], box[2]-box[0], box[3]-box[1]);
}
}
public void draw(SunGraphics2D sg2d, Shape s) {
if (sg2d.strokeState == sg2d.STROKE_THIN) {
doShape(sg2d, s, false);
} else if (sg2d.strokeState < sg2d.STROKE_CUSTOM) {
ShapeSpanIterator si = LoopPipe.getStrokeSpans(sg2d, s);
try {
doFillSpans(sg2d, si);
} finally {
si.dispose();
}
} else {
doShape(sg2d, sg2d.stroke.createStrokedShape(s), true);
}
}
public void fill(SunGraphics2D sg2d, Shape s) {
doShape(sg2d, s, true);
}
public native void devCopyArea(GDIWindowSurfaceData sData,
int srcx, int srcy,
int dx, int dy,
int w, int h);
public GDIRenderer traceWrap() {
return new Tracer();
}
public static class Tracer extends GDIRenderer {
void doDrawLine(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x1, int y1, int x2, int y2)
{
GraphicsPrimitive.tracePrimitive("GDIDrawLine");
super.doDrawLine(sData, clip, comp, color, x1, y1, x2, y2);
}
void doDrawRect(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x, int y, int w, int h)
{
GraphicsPrimitive.tracePrimitive("GDIDrawRect");
super.doDrawRect(sData, clip, comp, color, x, y, w, h);
}
void doDrawRoundRect(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x, int y, int w, int h,
int arcW, int arcH)
{
GraphicsPrimitive.tracePrimitive("GDIDrawRoundRect");
super.doDrawRoundRect(sData, clip, comp, color,
x, y, w, h, arcW, arcH);
}
void doDrawOval(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x, int y, int w, int h)
{
GraphicsPrimitive.tracePrimitive("GDIDrawOval");
super.doDrawOval(sData, clip, comp, color, x, y, w, h);
}
void doDrawArc(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x, int y, int w, int h,
int angleStart, int angleExtent)
{
GraphicsPrimitive.tracePrimitive("GDIDrawArc");
super.doDrawArc(sData, clip, comp, color, x, y, w, h,
angleStart, angleExtent);
}
void doDrawPoly(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int transx, int transy,
int[] xpoints, int[] ypoints,
int npoints, boolean isclosed)
{
GraphicsPrimitive.tracePrimitive("GDIDrawPoly");
super.doDrawPoly(sData, clip, comp, color, transx, transy,
xpoints, ypoints, npoints, isclosed);
}
void doFillRect(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x, int y, int w, int h)
{
GraphicsPrimitive.tracePrimitive("GDIFillRect");
super.doFillRect(sData, clip, comp, color, x, y, w, h);
}
void doFillRoundRect(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x, int y, int w, int h,
int arcW, int arcH)
{
GraphicsPrimitive.tracePrimitive("GDIFillRoundRect");
super.doFillRoundRect(sData, clip, comp, color,
x, y, w, h, arcW, arcH);
}
void doFillOval(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x, int y, int w, int h)
{
GraphicsPrimitive.tracePrimitive("GDIFillOval");
super.doFillOval(sData, clip, comp, color, x, y, w, h);
}
void doFillArc(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x, int y, int w, int h,
int angleStart, int angleExtent)
{
GraphicsPrimitive.tracePrimitive("GDIFillArc");
super.doFillArc(sData, clip, comp, color, x, y, w, h,
angleStart, angleExtent);
}
void doFillPoly(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int transx, int transy,
int[] xpoints, int[] ypoints,
int npoints)
{
GraphicsPrimitive.tracePrimitive("GDIFillPoly");
super.doFillPoly(sData, clip, comp, color, transx, transy,
xpoints, ypoints, npoints);
}
void doShape(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int transX, int transY,
Path2D.Float p2df, boolean isfill)
{
GraphicsPrimitive.tracePrimitive(isfill
? "GDIFillShape"
: "GDIDrawShape");
super.doShape(sData, clip, comp, color,
transX, transY, p2df, isfill);
}
public void devCopyArea(GDIWindowSurfaceData sData,
int srcx, int srcy,
int dx, int dy,
int w, int h)
{
GraphicsPrimitive.tracePrimitive("GDICopyArea");
super.devCopyArea(sData, srcx, srcy, dx, dy, w, h);
}
}
}

View File

@@ -0,0 +1,345 @@
/*
* Copyright (c) 1999, 2008, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.java2d.windows;
import java.awt.Rectangle;
import java.awt.GraphicsConfiguration;
import java.awt.color.ColorSpace;
import java.awt.image.ColorModel;
import java.awt.image.ComponentColorModel;
import java.awt.image.DirectColorModel;
import java.awt.image.IndexColorModel;
import java.awt.image.Raster;
import sun.awt.SunHints;
import sun.awt.Win32GraphicsConfig;
import sun.awt.Win32GraphicsDevice;
import sun.awt.windows.WComponentPeer;
import sun.java2d.ScreenUpdateManager;
import sun.java2d.SunGraphics2D;
import sun.java2d.SurfaceData;
import sun.java2d.SurfaceDataProxy;
import sun.java2d.pipe.Region;
import sun.java2d.pipe.PixelToShapeConverter;
import sun.java2d.loops.GraphicsPrimitive;
import sun.java2d.loops.SurfaceType;
import sun.java2d.loops.CompositeType;
import sun.java2d.loops.RenderLoops;
import sun.java2d.loops.XORComposite;
public class GDIWindowSurfaceData extends SurfaceData {
private WComponentPeer peer;
private Win32GraphicsConfig graphicsConfig;
private RenderLoops solidloops;
// GDI onscreen surface type
public static final String
DESC_GDI = "GDI";
// Generic GDI surface type - used for registering all loops
public static final SurfaceType AnyGdi =
SurfaceType.IntRgb.deriveSubType(DESC_GDI);
public static final SurfaceType IntRgbGdi =
SurfaceType.IntRgb.deriveSubType(DESC_GDI);
public static final SurfaceType Ushort565RgbGdi =
SurfaceType.Ushort565Rgb.deriveSubType(DESC_GDI);
public static final SurfaceType Ushort555RgbGdi =
SurfaceType.Ushort555Rgb.deriveSubType(DESC_GDI);
public static final SurfaceType ThreeByteBgrGdi =
SurfaceType.ThreeByteBgr.deriveSubType(DESC_GDI);
private static native void initIDs(Class xorComp);
static {
initIDs(XORComposite.class);
if (WindowsFlags.isGdiBlitEnabled()) {
// Register our gdi Blit loops
GDIBlitLoops.register();
}
}
public static SurfaceType getSurfaceType(ColorModel cm) {
switch (cm.getPixelSize()) {
case 32:
case 24:
if (cm instanceof DirectColorModel) {
if (((DirectColorModel)cm).getRedMask() == 0xff0000) {
return IntRgbGdi;
} else {
return SurfaceType.IntRgbx;
}
} else {
return ThreeByteBgrGdi;
}
case 15:
return Ushort555RgbGdi;
case 16:
if ((cm instanceof DirectColorModel) &&
(((DirectColorModel)cm).getBlueMask() == 0x3e))
{
return SurfaceType.Ushort555Rgbx;
} else {
return Ushort565RgbGdi;
}
case 8:
if (cm.getColorSpace().getType() == ColorSpace.TYPE_GRAY &&
cm instanceof ComponentColorModel) {
return SurfaceType.ByteGray;
} else if (cm instanceof IndexColorModel &&
isOpaqueGray((IndexColorModel)cm)) {
return SurfaceType.Index8Gray;
} else {
return SurfaceType.ByteIndexedOpaque;
}
default:
throw new sun.java2d.InvalidPipeException("Unsupported bit " +
"depth: " +
cm.getPixelSize());
}
}
public static GDIWindowSurfaceData createData(WComponentPeer peer) {
SurfaceType sType = getSurfaceType(peer.getDeviceColorModel());
return new GDIWindowSurfaceData(peer, sType);
}
@Override
public SurfaceDataProxy makeProxyFor(SurfaceData srcData) {
return SurfaceDataProxy.UNCACHED;
}
public Raster getRaster(int x, int y, int w, int h) {
throw new InternalError("not implemented yet");
}
protected static GDIRenderer gdiPipe;
protected static PixelToShapeConverter gdiTxPipe;
static {
gdiPipe = new GDIRenderer();
if (GraphicsPrimitive.tracingEnabled()) {
gdiPipe = gdiPipe.traceWrap();
}
gdiTxPipe = new PixelToShapeConverter(gdiPipe);
}
public void validatePipe(SunGraphics2D sg2d) {
if (sg2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON &&
sg2d.paintState <= sg2d.PAINT_ALPHACOLOR &&
(sg2d.compositeState <= sg2d.COMP_ISCOPY ||
sg2d.compositeState == sg2d.COMP_XOR))
{
if (sg2d.clipState == sg2d.CLIP_SHAPE) {
// Do this to init textpipe correctly; we will override the
// other non-text pipes below
// REMIND: we should clean this up eventually instead of
// having this work duplicated.
super.validatePipe(sg2d);
} else {
switch (sg2d.textAntialiasHint) {
case SunHints.INTVAL_TEXT_ANTIALIAS_DEFAULT:
/* equate DEFAULT to OFF which it is for us */
case SunHints.INTVAL_TEXT_ANTIALIAS_OFF:
sg2d.textpipe = solidTextRenderer;
break;
case SunHints.INTVAL_TEXT_ANTIALIAS_ON:
sg2d.textpipe = aaTextRenderer;
break;
default:
switch (sg2d.getFontInfo().aaHint) {
case SunHints.INTVAL_TEXT_ANTIALIAS_LCD_HRGB:
case SunHints.INTVAL_TEXT_ANTIALIAS_LCD_VRGB:
sg2d.textpipe = lcdTextRenderer;
break;
case SunHints.INTVAL_TEXT_ANTIALIAS_ON:
sg2d.textpipe = aaTextRenderer;
break;
default:
sg2d.textpipe = solidTextRenderer;
}
}
}
sg2d.imagepipe = imagepipe;
if (sg2d.transformState >= sg2d.TRANSFORM_TRANSLATESCALE) {
sg2d.drawpipe = gdiTxPipe;
sg2d.fillpipe = gdiTxPipe;
} else if (sg2d.strokeState != sg2d.STROKE_THIN){
sg2d.drawpipe = gdiTxPipe;
sg2d.fillpipe = gdiPipe;
} else {
sg2d.drawpipe = gdiPipe;
sg2d.fillpipe = gdiPipe;
}
sg2d.shapepipe = gdiPipe;
// This is needed for AA text.
// Note that even a SolidTextRenderer can dispatch AA text
// if a GlyphVector overrides the AA setting.
// We use getRenderLoops() rather than setting solidloops
// directly so that we get the appropriate loops in XOR mode.
if (sg2d.loops == null) {
// assert(some pipe will always be a LoopBasedPipe)
sg2d.loops = getRenderLoops(sg2d);
}
} else {
super.validatePipe(sg2d);
}
}
public RenderLoops getRenderLoops(SunGraphics2D sg2d) {
if (sg2d.paintState <= sg2d.PAINT_ALPHACOLOR &&
sg2d.compositeState <= sg2d.COMP_ISCOPY)
{
return solidloops;
}
return super.getRenderLoops(sg2d);
}
public GraphicsConfiguration getDeviceConfiguration() {
return graphicsConfig;
}
/**
* Initializes the native Ops pointer.
*/
private native void initOps(WComponentPeer peer, int depth, int redMask,
int greenMask, int blueMask, int screen);
private GDIWindowSurfaceData(WComponentPeer peer, SurfaceType sType) {
super(sType, peer.getDeviceColorModel());
ColorModel cm = peer.getDeviceColorModel();
this.peer = peer;
int rMask = 0, gMask = 0, bMask = 0;
int depth;
switch (cm.getPixelSize()) {
case 32:
case 24:
if (cm instanceof DirectColorModel) {
depth = 32;
} else {
depth = 24;
}
break;
default:
depth = cm.getPixelSize();
}
if (cm instanceof DirectColorModel) {
DirectColorModel dcm = (DirectColorModel)cm;
rMask = dcm.getRedMask();
gMask = dcm.getGreenMask();
bMask = dcm.getBlueMask();
}
this.graphicsConfig =
(Win32GraphicsConfig) peer.getGraphicsConfiguration();
this.solidloops = graphicsConfig.getSolidLoops(sType);
Win32GraphicsDevice gd =
(Win32GraphicsDevice)graphicsConfig.getDevice();
initOps(peer, depth, rMask, gMask, bMask, gd.getScreen());
setBlitProxyKey(graphicsConfig.getProxyKey());
}
/**
* {@inheritDoc}
*
* Overridden to use ScreenUpdateManager to obtain the replacement surface.
*
* @see sun.java2d.ScreenUpdateManager#getReplacementScreenSurface
*/
@Override
public SurfaceData getReplacement() {
ScreenUpdateManager mgr = ScreenUpdateManager.getInstance();
return mgr.getReplacementScreenSurface(peer, this);
}
public Rectangle getBounds() {
Rectangle r = peer.getBounds();
r.x = r.y = 0;
return r;
}
public boolean copyArea(SunGraphics2D sg2d,
int x, int y, int w, int h, int dx, int dy)
{
CompositeType comptype = sg2d.imageComp;
if (sg2d.transformState < sg2d.TRANSFORM_TRANSLATESCALE &&
sg2d.clipState != sg2d.CLIP_SHAPE &&
(CompositeType.SrcOverNoEa.equals(comptype) ||
CompositeType.SrcNoEa.equals(comptype)))
{
x += sg2d.transX;
y += sg2d.transY;
int dstx1 = x + dx;
int dsty1 = y + dy;
int dstx2 = dstx1 + w;
int dsty2 = dsty1 + h;
Region clip = sg2d.getCompClip();
if (dstx1 < clip.getLoX()) dstx1 = clip.getLoX();
if (dsty1 < clip.getLoY()) dsty1 = clip.getLoY();
if (dstx2 > clip.getHiX()) dstx2 = clip.getHiX();
if (dsty2 > clip.getHiY()) dsty2 = clip.getHiY();
if (dstx1 < dstx2 && dsty1 < dsty2) {
gdiPipe.devCopyArea(this, dstx1 - dx, dsty1 - dy,
dx, dy,
dstx2 - dstx1, dsty2 - dsty1);
}
return true;
}
return false;
}
private native void invalidateSD();
@Override
public void invalidate() {
if (isValid()) {
invalidateSD();
super.invalidate();
//peer.invalidateBackBuffer();
}
}
/**
* Returns destination Component associated with this SurfaceData.
*/
@Override
public Object getDestination() {
return peer.getTarget();
}
public WComponentPeer getPeer() {
return peer;
}
}

View File

@@ -0,0 +1,338 @@
/*
* Copyright (c) 2003, 2008, 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
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.java2d.windows;
import sun.awt.windows.WToolkit;
import sun.java2d.opengl.WGLGraphicsConfig;
public class WindowsFlags {
/**
* Description of command-line flags. All flags with [true|false]
* values (where both have possible meanings, such as with ddlock)
* have an associated variable that indicates whether this flag
* was set by the user. For example, d3d is on by default, but
* may be disabled at runtime by internal settings unless the user
* has forced it on with d3d=true. These associated variables have
* the same base (eg, d3d) but end in "Set" (eg, d3dEnabled and
* d3dSet).
* ddEnabled: usage: "-Dsun.java2d.noddraw[=false|true]"
* turns on/off all usage of Direct3D
* ddOffscreenEnabled: equivalent of sun.java2d.noddraw
* gdiBlitEnabled: usage: "-Dsun.java2d.gdiblit=false"
* turns off Blit loops that use GDI for copying to
* the screen from certain image types. Copies will,
* instead, happen via ddraw locking or temporary GDI DIB
* creation/copying (depending on OS and other flags)
* d3dEnabled: usage: "-Dsun.java2d.d3d=[true|false]"
* Forces our use of Direct3D on or off. Direct3D is on
* by default, but may be disabled in some situations, such
* as on a card with bad d3d line quality, or on a video card
* that we have had bad experience with (e.g., Trident).
* This flag can force us to use d3d
* anyway in these situations. Or, this flag can force us to
* not use d3d in a situation where we would use it otherwise.
* translAccelEnabled: usage: "-Dsun.java2d.translaccel=true"
* equivalent to sun.java2d.d3d=true
* offscreenSharingEnabled: usage: "-Dsun.java2d.offscreenSharing=true"
* Turns on the ability to share a hardware-accelerated
* offscreen surface through the JAWT interface. See
* src/windows/native/sun/windows/awt_DrawingSurface.* for
* more information. This capability is disabled by default
* pending more testing and time to work out the right
* solution; we do not want to expose more public JAWT api
* without being very sure that we will be willing to support
* that API in the future regardless of other native
* rendering pipeline changes.
* accelReset: usage: "-Dsun.java2d.accelReset"
* This flag tells us to reset any persistent information
* the display device acceleration characteristics so that
* we are forced to retest these characteristics. This flag
* is primarily used for debugging purposes (to allow testing
* of the persistent storage mechanisms) but may also be
* needed by some users if, for example, a driver upgrade
* may change the runtime characteristics and they want the
* tests to be re-run.
* checkRegistry: usage: "-Dsun.java2d.checkRegistry"
* This flag tells us to output the current registry settings
* (after our initialization) to the console.
* disableRegistry: usage: "-Dsun.java2d.disableRegistry"
* This flag tells us to disable all registry-related
* activities. It is mainly here for debugging purposes,
* to allow us to see whether any runtime bugs are caused
* by or related to registry problems.
* magPresent: usage: "-Djavax.accessibility.screen_magnifier_present"
* This flag is set either on the command line or in the
* properties file. It tells Swing whether the user is
* currently using a screen magnifying application. These
* applications tend to conflict with ddraw (which assumes
* it owns the entire display), so the presence of these
* applications implies that we should disable ddraw.
* So if magPresent is true, we set ddEnabled and associated
* variables to false and do not initialize the native
* hardware acceleration for these properties.
* opengl: usage: "-Dsun.java2d.opengl=[true|True]"
* Enables the use of the OpenGL-pipeline. If the
* OpenGL flag is specified and WGL initialization is
* successful, we implicitly disable the use of DirectDraw
* and Direct3D, as those pipelines may interfere with the
* OGL pipeline. (If "True" is specified, a message will
* appear on the console stating whether or not the OGL
* was successfully initialized.)
* setHighDPIAware: Property usage: "-Dsun.java2d.dpiaware=[true|false]"
* This property flag "sun.java2d.dpiaware" is used to
* override the default behavior, which is:
* On Windows Vista, if the java process is launched from a
* known launcher (java, javaw, javaws, etc) - which is
* determined by whether a -Dsun.java.launcher property is set
* to "SUN_STANDARD" - the "high-DPI aware" property will be
* set on the native level prior to initializing the display.
*
*/
private static boolean gdiBlitEnabled;
private static boolean d3dEnabled;
private static boolean d3dVerbose;
private static boolean d3dSet;
private static boolean d3dOnScreenEnabled;
private static boolean oglEnabled;
private static boolean oglVerbose;
private static boolean offscreenSharingEnabled;
private static boolean accelReset;
private static boolean checkRegistry;
private static boolean disableRegistry;
private static boolean magPresent;
private static boolean setHighDPIAware;
private static String javaVersion;
// TODO: other flags, including nopixfmt
static {
// Ensure awt is loaded already. Also, this forces static init
// of WToolkit and Toolkit, which we depend upon.
WToolkit.loadLibraries();
// First, init all Java level flags
initJavaFlags();
// Now, init things on the native side. This may call up through
// JNI to get/set the Java level flags based on native capabilities
// and environment variables
initNativeFlags();
}
private static native boolean initNativeFlags();
// Noop: this method is just here as a convenient calling place when
// we are initialized by Win32GraphicsEnv. Calling this will force
// us to run through the static block below, which is where the
// real work occurs.
public static void initFlags() {}
private static boolean getBooleanProp(String p, boolean defaultVal) {
String propString = System.getProperty(p);
boolean returnVal = defaultVal;
if (propString != null) {
if (propString.equals("true") ||
propString.equals("t") ||
propString.equals("True") ||
propString.equals("T") ||
propString.equals("")) // having the prop name alone
{ // is equivalent to true
returnVal = true;
} else if (propString.equals("false") ||
propString.equals("f") ||
propString.equals("False") ||
propString.equals("F"))
{
returnVal = false;
}
}
return returnVal;
}
private static boolean isBooleanPropTrueVerbose(String p) {
String propString = System.getProperty(p);
if (propString != null) {
if (propString.equals("True") ||
propString.equals("T"))
{
return true;
}
}
return false;
}
private static int getIntProp(String p, int defaultVal) {
String propString = System.getProperty(p);
int returnVal = defaultVal;
if (propString != null) {
try {
returnVal = Integer.parseInt(propString);
} catch (NumberFormatException e) {}
}
return returnVal;
}
private static boolean getPropertySet(String p) {
String propString = System.getProperty(p);
return (propString != null) ? true : false;
}
private static void initJavaFlags() {
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction()
{
public Object run() {
magPresent = getBooleanProp(
"javax.accessibility.screen_magnifier_present", false);
boolean ddEnabled =
!getBooleanProp("sun.java2d.noddraw", magPresent);
boolean ddOffscreenEnabled =
getBooleanProp("sun.java2d.ddoffscreen", ddEnabled);
d3dEnabled = getBooleanProp("sun.java2d.d3d",
ddEnabled && ddOffscreenEnabled);
d3dOnScreenEnabled =
getBooleanProp("sun.java2d.d3d.onscreen", d3dEnabled);
oglEnabled = getBooleanProp("sun.java2d.opengl", false);
if (oglEnabled) {
oglVerbose = isBooleanPropTrueVerbose("sun.java2d.opengl");
if (WGLGraphicsConfig.isWGLAvailable()) {
d3dEnabled = false;
} else {
if (oglVerbose) {
System.out.println(
"Could not enable OpenGL pipeline " +
"(WGL not available)");
}
oglEnabled = false;
}
}
gdiBlitEnabled = getBooleanProp("sun.java2d.gdiBlit", true);
d3dSet = getPropertySet("sun.java2d.d3d");
if (d3dSet) {
d3dVerbose = isBooleanPropTrueVerbose("sun.java2d.d3d");
}
offscreenSharingEnabled =
getBooleanProp("sun.java2d.offscreenSharing", false);
accelReset = getBooleanProp("sun.java2d.accelReset", false);
checkRegistry =
getBooleanProp("sun.java2d.checkRegistry", false);
disableRegistry =
getBooleanProp("sun.java2d.disableRegistry", false);
javaVersion = System.getProperty("java.version");
if (javaVersion == null) {
// Cannot be true, nonetheless...
javaVersion = "default";
} else {
int dashIndex = javaVersion.indexOf('-');
if (dashIndex >= 0) {
// an interim release; use only the part preceding the -
javaVersion = javaVersion.substring(0, dashIndex);
}
}
String dpiOverride = System.getProperty("sun.java2d.dpiaware");
if (dpiOverride != null) {
setHighDPIAware = dpiOverride.equalsIgnoreCase("true");
} else {
String sunLauncherProperty =
System.getProperty("sun.java.launcher", "unknown");
setHighDPIAware =
sunLauncherProperty.equalsIgnoreCase("SUN_STANDARD");
}
/*
// Output info based on some non-default flags:
if (offscreenSharingEnabled) {
System.out.println(
"Warning: offscreenSharing has been enabled. " +
"The use of this capability will change in future " +
"releases and applications that depend on it " +
"may not work correctly");
}
*/
return null;
}
});
/*
System.out.println("WindowsFlags (Java):");
System.out.println(" ddEnabled: " + ddEnabled + "\n" +
" ddOffscreenEnabled: " + ddOffscreenEnabled + "\n" +
" ddVramForced: " + ddVramForced + "\n" +
" ddLockEnabled: " + ddLockEnabled + "\n" +
" ddLockSet: " + ddLockSet + "\n" +
" ddBlitEnabled: " + ddBlitEnabled + "\n" +
" ddScaleEnabled: " + ddScaleEnabled + "\n" +
" d3dEnabled: " + d3dEnabled + "\n" +
" d3dSet: " + d3dSet + "\n" +
" oglEnabled: " + oglEnabled + "\n" +
" oglVerbose: " + oglVerbose + "\n" +
" gdiBlitEnabled: " + gdiBlitEnabled + "\n" +
" translAccelEnabled: " + translAccelEnabled + "\n" +
" offscreenSharingEnabled: " + offscreenSharingEnabled + "\n" +
" accelReset: " + accelReset + "\n" +
" checkRegistry: " + checkRegistry + "\n" +
" disableRegistry: " + disableRegistry + "\n" +
" d3dTexBPP: " + d3dTexBpp);
*/
}
public static boolean isD3DEnabled() {
return d3dEnabled;
}
public static boolean isD3DSet() {
return d3dSet;
}
public static boolean isD3DOnScreenEnabled() {
return d3dOnScreenEnabled;
}
public static boolean isD3DVerbose() {
return d3dVerbose;
}
public static boolean isGdiBlitEnabled() {
return gdiBlitEnabled;
}
public static boolean isTranslucentAccelerationEnabled() {
return d3dEnabled;
}
public static boolean isOffscreenSharingEnabled() {
return offscreenSharingEnabled;
}
public static boolean isMagPresent() {
return magPresent;
}
public static boolean isOGLEnabled() {
return oglEnabled;
}
public static boolean isOGLVerbose() {
return oglVerbose;
}
}