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,332 @@
/*
* 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.loops;
import java.awt.Composite;
import java.awt.CompositeContext;
import java.awt.RenderingHints;
import java.awt.image.ColorModel;
import java.awt.image.Raster;
import java.awt.image.WritableRaster;
import java.lang.ref.WeakReference;
import sun.java2d.loops.GraphicsPrimitive;
import sun.java2d.SurfaceData;
import sun.java2d.pipe.Region;
import sun.java2d.pipe.SpanIterator;
/**
* Blit
* 1) copies rectangle of pixels from one surface to another
* 2) performs compositing of colors based upon a Composite
* parameter
*
* precise behavior is undefined if the source surface
* and the destination surface are the same surface
* with overlapping regions of pixels
*/
public class Blit extends GraphicsPrimitive
{
public static final String methodSignature = "Blit(...)".toString();
public static final int primTypeID = makePrimTypeID();
private static RenderCache blitcache = new RenderCache(20);
public static Blit locate(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
return (Blit)
GraphicsPrimitiveMgr.locate(primTypeID,
srctype, comptype, dsttype);
}
public static Blit getFromCache(SurfaceType src,
CompositeType comp,
SurfaceType dst)
{
Object o = blitcache.get(src, comp, dst);
if (o != null) {
return (Blit) o;
}
Blit blit = locate(src, comp, dst);
if (blit == null) {
System.out.println("blit loop not found for:");
System.out.println("src: "+src);
System.out.println("comp: "+comp);
System.out.println("dst: "+dst);
} else {
blitcache.put(src, comp, dst, blit);
}
return blit;
}
protected Blit(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(methodSignature, primTypeID, srctype, comptype, dsttype);
}
public Blit(long pNativePrim,
SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(pNativePrim, methodSignature, primTypeID, srctype, comptype, dsttype);
}
/**
* All Blit implementors must have this invoker method
*/
public native void Blit(SurfaceData src, SurfaceData dst,
Composite comp, Region clip,
int srcx, int srcy,
int dstx, int dsty,
int width, int height);
static {
GraphicsPrimitiveMgr.registerGeneral(new Blit(null, null, null));
}
public GraphicsPrimitive makePrimitive(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
/*
System.out.println("Constructing general blit for:");
System.out.println("src: "+srctype);
System.out.println("comp: "+comptype);
System.out.println("dst: "+dsttype);
*/
if (comptype.isDerivedFrom(CompositeType.Xor)) {
GeneralXorBlit gxb = new GeneralXorBlit(srctype,
comptype,
dsttype);
setupGeneralBinaryOp(gxb);
return gxb;
} else if (comptype.isDerivedFrom(CompositeType.AnyAlpha)) {
return new GeneralMaskBlit(srctype, comptype, dsttype);
} else {
return AnyBlit.instance;
}
}
private static class AnyBlit extends Blit {
public static AnyBlit instance = new AnyBlit();
public AnyBlit() {
super(SurfaceType.Any, CompositeType.Any, SurfaceType.Any);
}
public void Blit(SurfaceData srcData,
SurfaceData dstData,
Composite comp,
Region clip,
int srcx, int srcy,
int dstx, int dsty,
int width, int height)
{
ColorModel srcCM = srcData.getColorModel();
ColorModel dstCM = dstData.getColorModel();
// REMIND: Should get RenderingHints from sg2d
CompositeContext ctx = comp.createContext(srcCM, dstCM,
new RenderingHints(null));
Raster srcRas = srcData.getRaster(srcx, srcy, width, height);
WritableRaster dstRas =
(WritableRaster) dstData.getRaster(dstx, dsty, width, height);
if (clip == null) {
clip = Region.getInstanceXYWH(dstx, dsty, width, height);
}
int span[] = {dstx, dsty, dstx+width, dsty+height};
SpanIterator si = clip.getSpanIterator(span);
srcx -= dstx;
srcy -= dsty;
while (si.nextSpan(span)) {
int w = span[2] - span[0];
int h = span[3] - span[1];
Raster tmpSrcRas = srcRas.createChild(srcx + span[0], srcy + span[1],
w, h, 0, 0, null);
WritableRaster tmpDstRas = dstRas.createWritableChild(span[0], span[1],
w, h, 0, 0, null);
ctx.compose(tmpSrcRas, tmpDstRas, tmpDstRas);
}
ctx.dispose();
}
}
private static class GeneralMaskBlit extends Blit {
MaskBlit performop;
public GeneralMaskBlit(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(srctype, comptype, dsttype);
performop = MaskBlit.locate(srctype, comptype, dsttype);
}
public void Blit(SurfaceData srcData,
SurfaceData dstData,
Composite comp,
Region clip,
int srcx, int srcy,
int dstx, int dsty,
int width, int height)
{
performop.MaskBlit(srcData, dstData, comp, clip,
srcx, srcy, dstx, dsty,
width, height,
null, 0, 0);
}
}
private static class GeneralXorBlit
extends Blit
implements GeneralBinaryOp
{
Blit convertsrc;
Blit convertdst;
Blit performop;
Blit convertresult;
WeakReference srcTmp;
WeakReference dstTmp;
public GeneralXorBlit(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(srctype, comptype, dsttype);
}
public void setPrimitives(Blit srcconverter,
Blit dstconverter,
GraphicsPrimitive genericop,
Blit resconverter)
{
this.convertsrc = srcconverter;
this.convertdst = dstconverter;
this.performop = (Blit) genericop;
this.convertresult = resconverter;
}
public synchronized void Blit(SurfaceData srcData,
SurfaceData dstData,
Composite comp,
Region clip,
int srcx, int srcy,
int dstx, int dsty,
int width, int height)
{
SurfaceData src, dst;
Region opclip;
int sx, sy, dx, dy;
if (convertsrc == null) {
src = srcData;
sx = srcx;
sy = srcy;
} else {
SurfaceData cachedSrc = null;
if (srcTmp != null) {
cachedSrc = (SurfaceData) srcTmp.get();
}
src = convertFrom(convertsrc, srcData, srcx, srcy,
width, height, cachedSrc);
sx = 0;
sy = 0;
if (src != cachedSrc) {
srcTmp = new WeakReference(src);
}
}
if (convertdst == null) {
dst = dstData;
dx = dstx;
dy = dsty;
opclip = clip;
} else {
// assert: convertresult != null
SurfaceData cachedDst = null;
if (dstTmp != null) {
cachedDst = (SurfaceData) dstTmp.get();
}
dst = convertFrom(convertdst, dstData, dstx, dsty,
width, height, cachedDst);
dx = 0;
dy = 0;
opclip = null;
if (dst != cachedDst) {
dstTmp = new WeakReference(dst);
}
}
performop.Blit(src, dst, comp, opclip,
sx, sy, dx, dy,
width, height);
if (convertresult != null) {
// assert: convertdst != null
convertTo(convertresult, dst, dstData, clip,
dstx, dsty, width, height);
}
}
}
public GraphicsPrimitive traceWrap() {
return new TraceBlit(this);
}
private static class TraceBlit extends Blit {
Blit target;
public TraceBlit(Blit target) {
super(target.getSourceType(),
target.getCompositeType(),
target.getDestType());
this.target = target;
}
public GraphicsPrimitive traceWrap() {
return this;
}
public void Blit(SurfaceData src, SurfaceData dst,
Composite comp, Region clip,
int srcx, int srcy, int dstx, int dsty,
int width, int height)
{
tracePrimitive(target);
target.Blit(src, dst, comp, clip,
srcx, srcy, dstx, dsty, width, height);
}
}
}

View File

@@ -0,0 +1,217 @@
/*
* 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.loops;
import java.awt.Font;
import java.awt.Color;
import java.awt.Composite;
import java.awt.AlphaComposite;
import java.awt.Transparency;
import java.awt.image.ColorModel;
import java.awt.image.WritableRaster;
import java.awt.image.BufferedImage;
import sun.awt.image.BufImgSurfaceData;
import sun.java2d.loops.GraphicsPrimitive;
import sun.java2d.SurfaceData;
import sun.java2d.SunGraphics2D;
import sun.java2d.pipe.Region;
/**
* BlitBg
* 1) copies rectangle of pixels from one surface to another
* 2) performs compositing of colors based upon a Composite
* parameter
* 3) assumes that non-opaque pixels are to be blended with
* the indicated Bg color before compositing with the
* destination
*
* precise behavior is undefined if the source surface
* and the destination surface are the same surface
* with overlapping regions of pixels
*/
public class BlitBg extends GraphicsPrimitive
{
public static final String methodSignature = "BlitBg(...)".toString();
public static final int primTypeID = makePrimTypeID();
private static RenderCache blitcache = new RenderCache(20);
public static BlitBg locate(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
return (BlitBg)
GraphicsPrimitiveMgr.locate(primTypeID,
srctype, comptype, dsttype);
}
public static BlitBg getFromCache(SurfaceType src,
CompositeType comp,
SurfaceType dst)
{
Object o = blitcache.get(src, comp, dst);
if (o != null) {
return (BlitBg) o;
}
BlitBg blit = locate(src, comp, dst);
if (blit == null) {
System.out.println("blitbg loop not found for:");
System.out.println("src: "+src);
System.out.println("comp: "+comp);
System.out.println("dst: "+dst);
} else {
blitcache.put(src, comp, dst, blit);
}
return blit;
}
protected BlitBg(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(methodSignature, primTypeID, srctype, comptype, dsttype);
}
public BlitBg(long pNativePrim,
SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(pNativePrim, methodSignature, primTypeID, srctype, comptype, dsttype);
}
/**
* All BlitBg implementors must have this invoker method
*/
public native void BlitBg(SurfaceData src, SurfaceData dst,
Composite comp, Region clip,
int bgColor,
int srcx, int srcy,
int dstx, int dsty,
int width, int height);
static {
GraphicsPrimitiveMgr.registerGeneral(new BlitBg(null, null, null));
}
public GraphicsPrimitive makePrimitive(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
/*
System.out.println("Constructing general blitbg for:");
System.out.println("src: "+srctype);
System.out.println("comp: "+comptype);
System.out.println("dst: "+dsttype);
*/
return new General(srctype, comptype, dsttype);
}
private static class General extends BlitBg {
CompositeType compositeType;
public General(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(srctype, comptype, dsttype);
compositeType = comptype;
}
@Override
public void BlitBg(SurfaceData srcData,
SurfaceData dstData,
Composite comp,
Region clip,
int bgArgb,
int srcx, int srcy,
int dstx, int dsty,
int width, int height)
{
ColorModel dstModel = dstData.getColorModel();
boolean bgHasAlpha = (bgArgb >>> 24) != 0xff;
if (!dstModel.hasAlpha() && bgHasAlpha) {
dstModel = ColorModel.getRGBdefault();
}
WritableRaster wr =
dstModel.createCompatibleWritableRaster(width, height);
boolean isPremult = dstModel.isAlphaPremultiplied();
BufferedImage bimg =
new BufferedImage(dstModel, wr, isPremult, null);
SurfaceData tmpData = BufImgSurfaceData.createData(bimg);
Color bgColor = new Color(bgArgb, bgHasAlpha);
SunGraphics2D sg2d = new SunGraphics2D(tmpData, bgColor, bgColor,
defaultFont);
FillRect fillop = FillRect.locate(SurfaceType.AnyColor,
CompositeType.SrcNoEa,
tmpData.getSurfaceType());
Blit combineop = Blit.getFromCache(srcData.getSurfaceType(),
CompositeType.SrcOverNoEa,
tmpData.getSurfaceType());
Blit blitop = Blit.getFromCache(tmpData.getSurfaceType(), compositeType,
dstData.getSurfaceType());
fillop.FillRect(sg2d, tmpData, 0, 0, width, height);
combineop.Blit(srcData, tmpData, AlphaComposite.SrcOver, null,
srcx, srcy, 0, 0, width, height);
blitop.Blit(tmpData, dstData, comp, clip,
0, 0, dstx, dsty, width, height);
}
private static Font defaultFont = new Font("Dialog", Font.PLAIN, 12);
}
public GraphicsPrimitive traceWrap() {
return new TraceBlitBg(this);
}
private static class TraceBlitBg extends BlitBg {
BlitBg target;
public TraceBlitBg(BlitBg target) {
super(target.getSourceType(),
target.getCompositeType(),
target.getDestType());
this.target = target;
}
public GraphicsPrimitive traceWrap() {
return this;
}
@Override
public void BlitBg(SurfaceData src, SurfaceData dst,
Composite comp, Region clip,
int bgColor,
int srcx, int srcy, int dstx, int dsty,
int width, int height)
{
tracePrimitive(target);
target.BlitBg(src, dst, comp, clip, bgColor,
srcx, srcy, dstx, dsty, width, height);
}
}
}

View File

@@ -0,0 +1,295 @@
/*
* Copyright (c) 1999, 2010, 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.loops;
import java.awt.image.BufferedImage;
import java.awt.AlphaComposite;
import java.util.HashMap;
/**
* A CompositeType object provides a chained description of a type of
* algorithm for color compositing. The object will provide a single
* String constant descriptor which is one way of describing a particular
* compositing algorithm as well as a pointer to another CompositeType
* which describes a more general algorithm for achieving the same result.
* <p>
* A description of a more specific algorithm is considered a "subtype"
* and a description of a more general algorithm is considered a "supertype".
* Thus, the deriveSubType method provides a way to create a new CompositeType
* that is related to but more specific than an existing CompositeType and
* the getSuperType method provides a way to ask a given CompositeType
* for a more general algorithm to achieve the same result.
* <p>
* Note that you cannot construct a brand new root for a chain since
* the constructor is private. Every chain of types must at some point
* derive from the Any node provided here using the deriveSubType()
* method. The presence of this common Any node on every chain
* ensures that all chains end with the DESC_ANY descriptor so that
* a suitable General GraphicsPrimitive object can be obtained for
* the indicated algorithm if all of the more specific searches fail.
*/
public final class CompositeType {
private static int unusedUID = 1;
private static final HashMap<String,Integer> compositeUIDMap =
new HashMap<String,Integer>(100);
/*
* CONSTANTS USED BY ALL PRIMITIVES TO DESCRIBE THE COMPOSITING
* ALGORITHMS THEY CAN PERFORM
*/
/**
* algorithm is a general algorithm that uses a CompositeContext
* to do the rendering.
*/
public static final String DESC_ANY = "Any CompositeContext";
/**
* constant used to describe the Graphics.setXORMode() algorithm
*/
public static final String DESC_XOR = "XOR mode";
/**
* constants used to describe the various AlphaComposite
* algorithms.
*/
public static final String DESC_CLEAR = "Porter-Duff Clear";
public static final String DESC_SRC = "Porter-Duff Src";
public static final String DESC_DST = "Porter-Duff Dst";
public static final String DESC_SRC_OVER = "Porter-Duff Src Over Dst";
public static final String DESC_DST_OVER = "Porter-Duff Dst Over Src";
public static final String DESC_SRC_IN = "Porter-Duff Src In Dst";
public static final String DESC_DST_IN = "Porter-Duff Dst In Src";
public static final String DESC_SRC_OUT = "Porter-Duff Src HeldOutBy Dst";
public static final String DESC_DST_OUT = "Porter-Duff Dst HeldOutBy Src";
public static final String DESC_SRC_ATOP = "Porter-Duff Src Atop Dst";
public static final String DESC_DST_ATOP = "Porter-Duff Dst Atop Src";
public static final String DESC_ALPHA_XOR = "Porter-Duff Xor";
/**
* constants used to describe the two common cases of
* AlphaComposite algorithms that are simpler if there
* is not extraAlpha.
*/
public static final String
DESC_SRC_NO_EA = "Porter-Duff Src, No Extra Alpha";
public static final String
DESC_SRC_OVER_NO_EA = "Porter-Duff SrcOverDst, No Extra Alpha";
/**
* constant used to describe an algorithm that implements all 8 of
* the Porter-Duff rules in one Primitive.
*/
public static final String DESC_ANY_ALPHA = "Any AlphaComposite Rule";
/*
* END OF COMPOSITE ALGORITHM TYPE CONSTANTS
*/
/**
* The root CompositeType object for all chains of algorithm descriptions.
*/
public static final CompositeType
Any = new CompositeType(null, DESC_ANY);
/*
* START OF CompositeeType OBJECTS FOR THE VARIOUS CONSTANTS
*/
public static final CompositeType
General = Any;
public static final CompositeType
AnyAlpha = General.deriveSubType(DESC_ANY_ALPHA);
public static final CompositeType
Xor = General.deriveSubType(DESC_XOR);
public static final CompositeType
Clear = AnyAlpha.deriveSubType(DESC_CLEAR);
public static final CompositeType
Src = AnyAlpha.deriveSubType(DESC_SRC);
public static final CompositeType
Dst = AnyAlpha.deriveSubType(DESC_DST);
public static final CompositeType
SrcOver = AnyAlpha.deriveSubType(DESC_SRC_OVER);
public static final CompositeType
DstOver = AnyAlpha.deriveSubType(DESC_DST_OVER);
public static final CompositeType
SrcIn = AnyAlpha.deriveSubType(DESC_SRC_IN);
public static final CompositeType
DstIn = AnyAlpha.deriveSubType(DESC_DST_IN);
public static final CompositeType
SrcOut = AnyAlpha.deriveSubType(DESC_SRC_OUT);
public static final CompositeType
DstOut = AnyAlpha.deriveSubType(DESC_DST_OUT);
public static final CompositeType
SrcAtop = AnyAlpha.deriveSubType(DESC_SRC_ATOP);
public static final CompositeType
DstAtop = AnyAlpha.deriveSubType(DESC_DST_ATOP);
public static final CompositeType
AlphaXor = AnyAlpha.deriveSubType(DESC_ALPHA_XOR);
public static final CompositeType
SrcNoEa = Src.deriveSubType(DESC_SRC_NO_EA);
public static final CompositeType
SrcOverNoEa = SrcOver.deriveSubType(DESC_SRC_OVER_NO_EA);
/*
* A special CompositeType for the case where we are filling in
* SrcOverNoEa mode with an opaque color. In that case then the
* best loop for us to use would be a SrcNoEa loop, but what if
* there is no such loop? In that case then we would end up
* backing off to a Src loop (which should still be fine) or an
* AnyAlpha loop which would be slower than a SrcOver loop in
* most cases.
* The fix is to use the following chain which looks for loops
* in the following order:
* SrcNoEa, Src, SrcOverNoEa, SrcOver, AnyAlpha
*/
public static final CompositeType
OpaqueSrcOverNoEa = SrcOverNoEa.deriveSubType(DESC_SRC)
.deriveSubType(DESC_SRC_NO_EA);
/*
* END OF CompositeType OBJECTS FOR THE VARIOUS CONSTANTS
*/
/**
* Return a new CompositeType object which uses this object as its
* more general "supertype" descriptor. If no operation can be
* found that implements the algorithm described more exactly
* by desc, then this object will define the more general
* compositing algorithm that can be used instead.
*/
public CompositeType deriveSubType(String desc) {
return new CompositeType(this, desc);
}
/**
* Return a CompositeType object for the specified AlphaComposite
* rule.
*/
public static CompositeType forAlphaComposite(AlphaComposite ac) {
switch (ac.getRule()) {
case AlphaComposite.CLEAR:
return Clear;
case AlphaComposite.SRC:
if (ac.getAlpha() >= 1.0f) {
return SrcNoEa;
} else {
return Src;
}
case AlphaComposite.DST:
return Dst;
case AlphaComposite.SRC_OVER:
if (ac.getAlpha() >= 1.0f) {
return SrcOverNoEa;
} else {
return SrcOver;
}
case AlphaComposite.DST_OVER:
return DstOver;
case AlphaComposite.SRC_IN:
return SrcIn;
case AlphaComposite.DST_IN:
return DstIn;
case AlphaComposite.SRC_OUT:
return SrcOut;
case AlphaComposite.DST_OUT:
return DstOut;
case AlphaComposite.SRC_ATOP:
return SrcAtop;
case AlphaComposite.DST_ATOP:
return DstAtop;
case AlphaComposite.XOR:
return AlphaXor;
default:
throw new InternalError("Unrecognized alpha rule");
}
}
private int uniqueID;
private String desc;
private CompositeType next;
private CompositeType(CompositeType parent, String desc) {
next = parent;
this.desc = desc;
this.uniqueID = makeUniqueID(desc);
}
public synchronized static final int makeUniqueID(String desc) {
Integer i = compositeUIDMap.get(desc);
if (i == null) {
if (unusedUID > 255) {
throw new InternalError("composite type id overflow");
}
i = unusedUID++;
compositeUIDMap.put(desc, i);
}
return i;
}
public int getUniqueID() {
return uniqueID;
}
public String getDescriptor() {
return desc;
}
public CompositeType getSuperType() {
return next;
}
public int hashCode() {
return desc.hashCode();
}
public boolean isDerivedFrom(CompositeType other) {
CompositeType comptype = this;
do {
if (comptype.desc == other.desc) {
return true;
}
comptype = comptype.next;
} while (comptype != null);
return false;
}
public boolean equals(Object o) {
if (o instanceof CompositeType) {
return (((CompositeType) o).uniqueID == this.uniqueID);
}
return false;
}
public String toString() {
return desc;
}
}

View File

@@ -0,0 +1,329 @@
/*
* Copyright (c) 1997, 2007, 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.
*/
/*
* @author Charlton Innovations, Inc.
* @author Jim Graham
*/
package sun.java2d.loops;
import java.awt.Composite;
import java.awt.Rectangle;
import java.awt.image.ColorModel;
import java.awt.image.DataBuffer;
import java.awt.image.Raster;
import java.awt.image.WritableRaster;
import sun.awt.image.IntegerComponentRaster;
import sun.java2d.SurfaceData;
import sun.java2d.pipe.Region;
import sun.java2d.pipe.SpanIterator;
/**
* CustomComponent, collection of GraphicsPrimitive
* Basically, this collection of components performs conversion from
* ANY to ANY via opaque copy
*/
public final class CustomComponent {
public static void register() {
// REMIND: This does not work for all destinations yet since
// the screen SurfaceData objects do not implement getRaster
Class owner = CustomComponent.class;
GraphicsPrimitive[] primitives = {
new GraphicsPrimitiveProxy(owner, "OpaqueCopyAnyToArgb",
Blit.methodSignature,
Blit.primTypeID,
SurfaceType.Any,
CompositeType.SrcNoEa,
SurfaceType.IntArgb),
new GraphicsPrimitiveProxy(owner, "OpaqueCopyArgbToAny",
Blit.methodSignature,
Blit.primTypeID,
SurfaceType.IntArgb,
CompositeType.SrcNoEa,
SurfaceType.Any),
new GraphicsPrimitiveProxy(owner, "XorCopyArgbToAny",
Blit.methodSignature,
Blit.primTypeID,
SurfaceType.IntArgb,
CompositeType.Xor,
SurfaceType.Any),
};
GraphicsPrimitiveMgr.register(primitives);
}
public static Region getRegionOfInterest(SurfaceData src, SurfaceData dst,
Region clip,
int srcx, int srcy,
int dstx, int dsty,
int w, int h)
{
/*
* Intersect all of:
* - operation area (dstx, dsty, w, h)
* - destination bounds
* - (translated) src bounds
* - supplied clip (may be non-rectangular)
* Intersect the rectangular regions first since those are
* simpler operations.
*/
Region ret = Region.getInstanceXYWH(dstx, dsty, w, h);
ret = ret.getIntersection(dst.getBounds());
Rectangle r = src.getBounds();
// srcxy in src space maps to dstxy in dst space
r.translate(dstx - srcx, dsty - srcy);
ret = ret.getIntersection(r);
if (clip != null) {
// Intersect with clip last since it may be non-rectangular
ret = ret.getIntersection(clip);
}
return ret;
}
}
/**
* ANY format to ARGB format Blit
*/
class OpaqueCopyAnyToArgb extends Blit {
OpaqueCopyAnyToArgb() {
super(SurfaceType.Any,
CompositeType.SrcNoEa,
SurfaceType.IntArgb);
}
public void Blit(SurfaceData src, SurfaceData dst,
Composite comp, Region clip,
int srcx, int srcy, int dstx, int dsty, int w, int h)
{
Raster srcRast = src.getRaster(srcx, srcy, w, h);
ColorModel srcCM = src.getColorModel();
Raster dstRast = dst.getRaster(dstx, dsty, w, h);
IntegerComponentRaster icr = (IntegerComponentRaster) dstRast;
int[] dstPix = icr.getDataStorage();
Region roi = CustomComponent.getRegionOfInterest(src, dst, clip,
srcx, srcy,
dstx, dsty, w, h);
SpanIterator si = roi.getSpanIterator();
Object srcPix = null;
int dstScan = icr.getScanlineStride();
// assert(icr.getPixelStride() == 1);
srcx -= dstx;
srcy -= dsty;
int span[] = new int[4];
while (si.nextSpan(span)) {
int rowoff = icr.getDataOffset(0) + span[1] * dstScan + span[0];
for (int y = span[1]; y < span[3]; y++) {
int off = rowoff;
for (int x = span[0]; x < span[2]; x++) {
srcPix = srcRast.getDataElements(x+srcx, y+srcy, srcPix);
dstPix[off++] = srcCM.getRGB(srcPix);
}
rowoff += dstScan;
}
}
// Pixels in the dest were modified directly, we must
// manually notify the raster that it was modified
icr.markDirty();
// REMIND: We need to do something to make sure that dstRast
// is put back to the destination (as in the native Release
// function)
// src.releaseRaster(srcRast); // NOP?
// dst.releaseRaster(dstRast);
}
}
/**
* ARGB format to ANY format Blit
*/
class OpaqueCopyArgbToAny extends Blit {
OpaqueCopyArgbToAny() {
super(SurfaceType.IntArgb,
CompositeType.SrcNoEa,
SurfaceType.Any);
}
public void Blit(SurfaceData src, SurfaceData dst,
Composite comp, Region clip,
int srcx, int srcy, int dstx, int dsty, int w, int h)
{
Raster srcRast = src.getRaster(srcx, srcy, w, h);
IntegerComponentRaster icr = (IntegerComponentRaster) srcRast;
int[] srcPix = icr.getDataStorage();
WritableRaster dstRast =
(WritableRaster) dst.getRaster(dstx, dsty, w, h);
ColorModel dstCM = dst.getColorModel();
Region roi = CustomComponent.getRegionOfInterest(src, dst, clip,
srcx, srcy,
dstx, dsty, w, h);
SpanIterator si = roi.getSpanIterator();
Object dstPix = null;
int srcScan = icr.getScanlineStride();
// assert(icr.getPixelStride() == 1);
srcx -= dstx;
srcy -= dsty;
int span[] = new int[4];
while (si.nextSpan(span)) {
int rowoff = (icr.getDataOffset(0) +
(srcy + span[1]) * srcScan +
(srcx + span[0]));
for (int y = span[1]; y < span[3]; y++) {
int off = rowoff;
for (int x = span[0]; x < span[2]; x++) {
dstPix = dstCM.getDataElements(srcPix[off++], dstPix);
dstRast.setDataElements(x, y, dstPix);
}
rowoff += srcScan;
}
}
// REMIND: We need to do something to make sure that dstRast
// is put back to the destination (as in the native Release
// function)
// src.releaseRaster(srcRast); // NOP?
// dst.releaseRaster(dstRast);
}
}
/**
* ARGB format to ANY format Blit (pixels are XORed together with XOR pixel)
*/
class XorCopyArgbToAny extends Blit {
XorCopyArgbToAny() {
super(SurfaceType.IntArgb,
CompositeType.Xor,
SurfaceType.Any);
}
public void Blit(SurfaceData src, SurfaceData dst,
Composite comp, Region clip,
int srcx, int srcy, int dstx, int dsty, int w, int h)
{
Raster srcRast = src.getRaster(srcx, srcy, w, h);
IntegerComponentRaster icr = (IntegerComponentRaster) srcRast;
int[] srcPix = icr.getDataStorage();
WritableRaster dstRast =
(WritableRaster) dst.getRaster(dstx, dsty, w, h);
ColorModel dstCM = dst.getColorModel();
Region roi = CustomComponent.getRegionOfInterest(src, dst, clip,
srcx, srcy,
dstx, dsty, w, h);
SpanIterator si = roi.getSpanIterator();
int xorrgb = ((XORComposite)comp).getXorColor().getRGB();
Object xorPixel = dstCM.getDataElements(xorrgb, null);
Object srcPixel = null;
Object dstPixel = null;
int srcScan = icr.getScanlineStride();
// assert(icr.getPixelStride() == 1);
srcx -= dstx;
srcy -= dsty;
int span[] = new int[4];
while (si.nextSpan(span)) {
int rowoff = (icr.getDataOffset(0) +
(srcy + span[1]) * srcScan +
(srcx + span[0]));
for (int y = span[1]; y < span[3]; y++) {
int off = rowoff;
for (int x = span[0]; x < span[2]; x++) {
// REMIND: alpha bits of the destination pixel are
// currently altered by the XOR operation, but
// should be left untouched
srcPixel = dstCM.getDataElements(srcPix[off++], srcPixel);
dstPixel = dstRast.getDataElements(x, y, dstPixel);
switch (dstCM.getTransferType()) {
case DataBuffer.TYPE_BYTE:
byte[] bytesrcarr = (byte[]) srcPixel;
byte[] bytedstarr = (byte[]) dstPixel;
byte[] bytexorarr = (byte[]) xorPixel;
for (int i = 0; i < bytedstarr.length; i++) {
bytedstarr[i] ^= bytesrcarr[i] ^ bytexorarr[i];
}
break;
case DataBuffer.TYPE_SHORT:
case DataBuffer.TYPE_USHORT:
short[] shortsrcarr = (short[]) srcPixel;
short[] shortdstarr = (short[]) dstPixel;
short[] shortxorarr = (short[]) xorPixel;
for (int i = 0; i < shortdstarr.length; i++) {
shortdstarr[i] ^= shortsrcarr[i] ^ shortxorarr[i];
}
break;
case DataBuffer.TYPE_INT:
int[] intsrcarr = (int[]) srcPixel;
int[] intdstarr = (int[]) dstPixel;
int[] intxorarr = (int[]) xorPixel;
for (int i = 0; i < intdstarr.length; i++) {
intdstarr[i] ^= intsrcarr[i] ^ intxorarr[i];
}
break;
case DataBuffer.TYPE_FLOAT:
float[] floatsrcarr = (float[]) srcPixel;
float[] floatdstarr = (float[]) dstPixel;
float[] floatxorarr = (float[]) xorPixel;
for (int i = 0; i < floatdstarr.length; i++) {
int v = (Float.floatToIntBits(floatdstarr[i]) ^
Float.floatToIntBits(floatsrcarr[i]) ^
Float.floatToIntBits(floatxorarr[i]));
floatdstarr[i] = Float.intBitsToFloat(v);
}
break;
case DataBuffer.TYPE_DOUBLE:
double[] doublesrcarr = (double[]) srcPixel;
double[] doubledstarr = (double[]) dstPixel;
double[] doublexorarr = (double[]) xorPixel;
for (int i = 0; i < doubledstarr.length; i++) {
long v = (Double.doubleToLongBits(doubledstarr[i]) ^
Double.doubleToLongBits(doublesrcarr[i]) ^
Double.doubleToLongBits(doublexorarr[i]));
doubledstarr[i] = Double.longBitsToDouble(v);
}
break;
default:
throw new InternalError("Unsupported XOR pixel type");
}
dstRast.setDataElements(x, y, dstPixel);
}
rowoff += srcScan;
}
}
// REMIND: We need to do something to make sure that dstRast
// is put back to the destination (as in the native Release
// function)
// src.releaseRaster(srcRast); // NOP?
// dst.releaseRaster(dstRast);
}
}

View File

@@ -0,0 +1,161 @@
/*
* Copyright (c) 2000, 2003, 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.loops;
import sun.java2d.loops.GraphicsPrimitive;
import sun.java2d.pipe.Region;
import sun.java2d.SunGraphics2D;
import sun.java2d.SurfaceData;
import sun.font.GlyphList;
/**
* DrawGlyphList - loops for SolidTextRenderer pipe.
* 1) draw solid color text onto destination surface
* 2) must accept output area [x, y, dx, dy]
* from within the surface description data for clip rect
*/
public class DrawGlyphList extends GraphicsPrimitive {
public final static String methodSignature = "DrawGlyphList(...)".toString();
public final static int primTypeID = makePrimTypeID();
public static DrawGlyphList locate(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
return (DrawGlyphList)
GraphicsPrimitiveMgr.locate(primTypeID,
srctype, comptype, dsttype);
}
protected DrawGlyphList(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(methodSignature, primTypeID, srctype, comptype, dsttype);
}
public DrawGlyphList(long pNativePrim,
SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(pNativePrim, methodSignature, primTypeID, srctype, comptype, dsttype);
}
public native void DrawGlyphList(SunGraphics2D sg2d, SurfaceData dest,
GlyphList srcData);
// This instance is used only for lookup.
static {
GraphicsPrimitiveMgr.registerGeneral(
new DrawGlyphList(null, null, null));
}
public GraphicsPrimitive makePrimitive(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype) {
return new General(srctype, comptype, dsttype);
}
private static class General extends DrawGlyphList {
MaskFill maskop;
public General(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(srctype, comptype, dsttype);
maskop = MaskFill.locate(srctype, comptype, dsttype);
}
public void DrawGlyphList(SunGraphics2D sg2d, SurfaceData dest,
GlyphList gl) {
int strbounds[] = gl.getBounds(); // Don't delete, bug 4895493
int num = gl.getNumGlyphs();
Region clip = sg2d.getCompClip();
int cx1 = clip.getLoX();
int cy1 = clip.getLoY();
int cx2 = clip.getHiX();
int cy2 = clip.getHiY();
for (int i = 0; i < num; i++) {
gl.setGlyphIndex(i);
int metrics[] = gl.getMetrics();
int gx1 = metrics[0];
int gy1 = metrics[1];
int w = metrics[2];
int gx2 = gx1 + w;
int gy2 = gy1 + metrics[3];
int off = 0;
if (gx1 < cx1) {
off = cx1 - gx1;
gx1 = cx1;
}
if (gy1 < cy1) {
off += (cy1 - gy1) * w;
gy1 = cy1;
}
if (gx2 > cx2) gx2 = cx2;
if (gy2 > cy2) gy2 = cy2;
if (gx2 > gx1 && gy2 > gy1) {
byte alpha[] = gl.getGrayBits();
maskop.MaskFill(sg2d, dest, sg2d.composite,
gx1, gy1, gx2 - gx1, gy2 - gy1,
alpha, off, w);
}
}
}
}
public GraphicsPrimitive traceWrap() {
return new TraceDrawGlyphList(this);
}
private static class TraceDrawGlyphList extends DrawGlyphList {
DrawGlyphList target;
public TraceDrawGlyphList(DrawGlyphList target) {
super(target.getSourceType(),
target.getCompositeType(),
target.getDestType());
this.target = target;
}
public GraphicsPrimitive traceWrap() {
return this;
}
public void DrawGlyphList(SunGraphics2D sg2d, SurfaceData dest,
GlyphList glyphs)
{
tracePrimitive(target);
target.DrawGlyphList(sg2d, dest, glyphs);
}
}
}

View File

@@ -0,0 +1,159 @@
/*
* Copyright (c) 2000, 2004, 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.loops;
import sun.java2d.loops.GraphicsPrimitive;
import sun.java2d.pipe.Region;
import sun.java2d.SunGraphics2D;
import sun.java2d.SurfaceData;
import sun.font.GlyphList;
/**
* DrawGlyphListAA - loops for AATextRenderer pipe
* 1) draw anti-aliased text onto destination surface
* 2) must accept output area [x, y, dx, dy]
* from within the surface description data for clip rect
*/
public class DrawGlyphListAA extends GraphicsPrimitive {
public final static String methodSignature = "DrawGlyphListAA(...)".toString();
public final static int primTypeID = makePrimTypeID();
public static DrawGlyphListAA locate(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
return (DrawGlyphListAA)
GraphicsPrimitiveMgr.locate(primTypeID,
srctype, comptype, dsttype);
}
protected DrawGlyphListAA(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(methodSignature, primTypeID, srctype, comptype, dsttype);
}
public DrawGlyphListAA(long pNativePrim,
SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(pNativePrim, methodSignature, primTypeID, srctype, comptype, dsttype);
}
public native void DrawGlyphListAA(SunGraphics2D sg2d, SurfaceData dest,
GlyphList srcData);
static {
GraphicsPrimitiveMgr.registerGeneral(
new DrawGlyphListAA(null, null, null));
}
public GraphicsPrimitive makePrimitive(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype) {
return new General(srctype, comptype, dsttype);
}
public static class General extends DrawGlyphListAA {
MaskFill maskop;
public General(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(srctype, comptype, dsttype);
maskop = MaskFill.locate(srctype, comptype, dsttype);
}
public void DrawGlyphListAA(SunGraphics2D sg2d, SurfaceData dest,
GlyphList gl)
{
gl.getBounds(); // Don't delete, bug 4895493
int num = gl.getNumGlyphs();
Region clip = sg2d.getCompClip();
int cx1 = clip.getLoX();
int cy1 = clip.getLoY();
int cx2 = clip.getHiX();
int cy2 = clip.getHiY();
for (int i = 0; i < num; i++) {
gl.setGlyphIndex(i);
int metrics[] = gl.getMetrics();
int gx1 = metrics[0];
int gy1 = metrics[1];
int w = metrics[2];
int gx2 = gx1 + w;
int gy2 = gy1 + metrics[3];
int off = 0;
if (gx1 < cx1) {
off = cx1 - gx1;
gx1 = cx1;
}
if (gy1 < cy1) {
off += (cy1 - gy1) * w;
gy1 = cy1;
}
if (gx2 > cx2) gx2 = cx2;
if (gy2 > cy2) gy2 = cy2;
if (gx2 > gx1 && gy2 > gy1) {
byte alpha[] = gl.getGrayBits();
maskop.MaskFill(sg2d, dest, sg2d.composite,
gx1, gy1, gx2 - gx1, gy2 - gy1,
alpha, off, w);
}
}
}
}
public GraphicsPrimitive traceWrap() {
return new TraceDrawGlyphListAA(this);
}
private static class TraceDrawGlyphListAA extends DrawGlyphListAA {
DrawGlyphListAA target;
public TraceDrawGlyphListAA(DrawGlyphListAA target) {
super(target.getSourceType(),
target.getCompositeType(),
target.getDestType());
this.target = target;
}
public GraphicsPrimitive traceWrap() {
return this;
}
public void DrawGlyphListAA(SunGraphics2D sg2d, SurfaceData dest,
GlyphList glyphs)
{
tracePrimitive(target);
target.DrawGlyphListAA(sg2d, dest, glyphs);
}
}
}

View File

@@ -0,0 +1,117 @@
/*
* Copyright (c) 2005, 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.loops;
import sun.java2d.loops.GraphicsPrimitive;
import sun.java2d.pipe.Region;
import sun.java2d.SunGraphics2D;
import sun.java2d.SurfaceData;
import sun.font.GlyphList;
/**
* DrawGlyphListLCD- loops for LCDTextRenderer pipe
* 1) draw LCD anti-aliased text onto destination surface
* 2) must accept output area [x, y, dx, dy]
* from within the surface description data for clip rect
*/
public class DrawGlyphListLCD extends GraphicsPrimitive {
public final static String
methodSignature = "DrawGlyphListLCD(...)".toString();
public final static int primTypeID = makePrimTypeID();
public static DrawGlyphListLCD locate(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
return (DrawGlyphListLCD)
GraphicsPrimitiveMgr.locate(primTypeID,
srctype, comptype, dsttype);
}
protected DrawGlyphListLCD(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(methodSignature, primTypeID, srctype, comptype, dsttype);
}
public DrawGlyphListLCD(long pNativePrim,
SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(pNativePrim, methodSignature, primTypeID,
srctype, comptype, dsttype);
}
public native void DrawGlyphListLCD(SunGraphics2D sg2d, SurfaceData dest,
GlyphList srcData);
static {
GraphicsPrimitiveMgr.registerGeneral(
new DrawGlyphListLCD(null, null, null));
}
public GraphicsPrimitive makePrimitive(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype) {
/* Do not return a General loop. SunGraphics2D determines whether
* to use LCD or standard AA text based on whether there is an
* installed loop.
* This can be uncommented once there is a General loop which can
* handle one byte per colour component masks properly.
*/
return null;
}
public GraphicsPrimitive traceWrap() {
return new TraceDrawGlyphListLCD(this);
}
private static class TraceDrawGlyphListLCD extends DrawGlyphListLCD {
DrawGlyphListLCD target;
public TraceDrawGlyphListLCD(DrawGlyphListLCD target) {
super(target.getSourceType(),
target.getCompositeType(),
target.getDestType());
this.target = target;
}
public GraphicsPrimitive traceWrap() {
return this;
}
public void DrawGlyphListLCD(SunGraphics2D sg2d, SurfaceData dest,
GlyphList glyphs)
{
tracePrimitive(target);
target.DrawGlyphListLCD(sg2d, dest, glyphs);
}
}
}

View File

@@ -0,0 +1,114 @@
/*
* Copyright (c) 1997, 2002, 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.
*/
/*
* @author Charlton Innovations, Inc.
*/
package sun.java2d.loops;
import sun.java2d.loops.GraphicsPrimitive;
import java.awt.Color;
import java.awt.image.ColorModel;
import java.awt.image.Raster;
import sun.java2d.SunGraphics2D;
import sun.java2d.SurfaceData;
/**
* DrawLine
* 1) draw solid color single width line onto destination surface
* 2) must accept output area [x, y, dx, dy]
* from within the surface description data for clip rect
*/
public class DrawLine extends GraphicsPrimitive
{
public final static String methodSignature = "DrawLine(...)".toString();
public final static int primTypeID = makePrimTypeID();
public static DrawLine locate(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
return (DrawLine) GraphicsPrimitiveMgr.locate(primTypeID,
srctype, comptype, dsttype);
}
protected DrawLine(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(methodSignature, primTypeID, srctype, comptype, dsttype);
}
public DrawLine(long pNativePrim,
SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(pNativePrim, methodSignature, primTypeID, srctype, comptype, dsttype);
}
/**
* All DrawLine implementors must have this invoker method
*/
public native void DrawLine(SunGraphics2D sg2d, SurfaceData dest,
int x1, int y1, int x2, int y2);
public GraphicsPrimitive makePrimitive(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
// REMIND: use FillSpans or converter object?
throw new InternalError("DrawLine not implemented for "+
srctype+" with "+comptype);
}
public GraphicsPrimitive traceWrap() {
return new TraceDrawLine(this);
}
private static class TraceDrawLine extends DrawLine {
DrawLine target;
public TraceDrawLine(DrawLine target) {
super(target.getSourceType(),
target.getCompositeType(),
target.getDestType());
this.target = target;
}
public GraphicsPrimitive traceWrap() {
return this;
}
public void DrawLine(SunGraphics2D sg2d, SurfaceData dest,
int x1, int y1, int x2, int y2)
{
tracePrimitive(target);
target.DrawLine(sg2d, dest, x1, y1, x2, y2);
}
}
}

View File

@@ -0,0 +1,123 @@
/*
* Copyright (c) 2008, 2010, 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.
*/
/*
* @author Jim Graham
*/
package sun.java2d.loops;
import sun.java2d.loops.GraphicsPrimitive;
import sun.java2d.SunGraphics2D;
import sun.java2d.SurfaceData;
/**
* DrawParallelogram
* 1) fill the area between the 4 edges of an outer parallelogram
* (as specified by an origin and 2 delta vectors)
* but also outside the 4 edges of an inner parallelogram
* (as specified by proportional amounts of the outer delta vectors)
*/
public class DrawParallelogram extends GraphicsPrimitive
{
public final static String methodSignature =
"DrawParallelogram(...)".toString();
public final static int primTypeID = makePrimTypeID();
public static DrawParallelogram locate(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
return (DrawParallelogram)
GraphicsPrimitiveMgr.locate(primTypeID,
srctype, comptype, dsttype);
}
protected DrawParallelogram(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(methodSignature, primTypeID,
srctype, comptype, dsttype);
}
public DrawParallelogram(long pNativePrim,
SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(pNativePrim, methodSignature, primTypeID,
srctype, comptype, dsttype);
}
/**
* All DrawParallelogram implementors must have this invoker method
*/
public native void DrawParallelogram(SunGraphics2D sg, SurfaceData dest,
double x, double y,
double dx1, double dy1,
double dx2, double dy2,
double lw1, double lw2);
public GraphicsPrimitive makePrimitive(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
// REMIND: iterate with a FillRect primitive?
throw new InternalError("DrawParallelogram not implemented for "+
srctype+" with "+comptype);
}
public GraphicsPrimitive traceWrap() {
return new TraceDrawParallelogram(this);
}
private static class TraceDrawParallelogram extends DrawParallelogram {
DrawParallelogram target;
public TraceDrawParallelogram(DrawParallelogram target) {
super(target.getSourceType(),
target.getCompositeType(),
target.getDestType());
this.target = target;
}
public GraphicsPrimitive traceWrap() {
return this;
}
public void DrawParallelogram(SunGraphics2D sg2d, SurfaceData dest,
double x, double y,
double dx1, double dy1,
double dx2, double dy2,
double lw1, double lw2)
{
tracePrimitive(target);
target.DrawParallelogram(sg2d, dest,
x, y, dx1, dy1, dx2, dy2, lw1, lw2);
}
}
}

View File

@@ -0,0 +1,114 @@
/*
* Copyright (c) 2005, 2006, 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.loops;
import sun.java2d.loops.GraphicsPrimitive;
import sun.java2d.SunGraphics2D;
import sun.java2d.SurfaceData;
import java.awt.geom.Path2D;
/**
* DrawPath
* 1. draw single-width line path onto destination surface
* 2. must accept output area [x, y, dx, dy]
* from within the surface description data for clip rect
*/
public class DrawPath extends GraphicsPrimitive {
public final static String methodSignature =
"DrawPath(...)".toString();
public final static int primTypeID = makePrimTypeID();
public static DrawPath locate(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
return (DrawPath)
GraphicsPrimitiveMgr.locate(primTypeID,
srctype, comptype, dsttype);
}
protected DrawPath(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(methodSignature, primTypeID,
srctype, comptype, dsttype);
}
public DrawPath(long pNativePrim,
SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(pNativePrim, methodSignature, primTypeID,
srctype, comptype, dsttype);
}
/**
* All DrawPath implementors must have this invoker method
*/
public native void DrawPath(SunGraphics2D sg2d, SurfaceData sData,
int transX, int transY,
Path2D.Float p2df);
public GraphicsPrimitive makePrimitive(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
throw new InternalError("DrawPath not implemented for "+
srctype+" with "+comptype);
}
public GraphicsPrimitive traceWrap() {
return new TraceDrawPath(this);
}
private static class TraceDrawPath extends DrawPath {
DrawPath target;
public TraceDrawPath(DrawPath target) {
super(target.getSourceType(),
target.getCompositeType(),
target.getDestType());
this.target = target;
}
public GraphicsPrimitive traceWrap() {
return this;
}
public void DrawPath(SunGraphics2D sg2d, SurfaceData sData,
int transX, int transY,
Path2D.Float p2df)
{
tracePrimitive(target);
target.DrawPath(sg2d, sData, transX, transY, p2df);
}
}
}

View File

@@ -0,0 +1,120 @@
/*
* Copyright (c) 1997, 2002, 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.
*/
/*
* @author Charlton Innovations, Inc.
*/
package sun.java2d.loops;
import sun.java2d.loops.GraphicsPrimitive;
import sun.java2d.SunGraphics2D;
import sun.java2d.SurfaceData;
/**
* DrawPolygons
* 1) draw single-width line polygons onto destination surface
* 2) must accept output area [x, y, dx, dy]
* from within the surface description data for clip rect
*/
public class DrawPolygons extends GraphicsPrimitive
{
public final static String methodSignature = "DrawPolygons(...)".toString();
public final static int primTypeID = makePrimTypeID();
public static DrawPolygons locate(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
return (DrawPolygons)
GraphicsPrimitiveMgr.locate(primTypeID,
srctype, comptype, dsttype);
}
protected DrawPolygons(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(methodSignature, primTypeID, srctype, comptype, dsttype);
}
public DrawPolygons(long pNativePrim,
SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(pNativePrim, methodSignature, primTypeID, srctype, comptype, dsttype);
}
/**
* All DrawPolygon implementors must have this invoker method
*/
public native void DrawPolygons(SunGraphics2D sg2d, SurfaceData sData,
int xPoints[], int yPoints[],
int nPoints[], int numPolys,
int transX, int transY,
boolean close);
public GraphicsPrimitive makePrimitive(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
// REMIND: use FillSpans or converter object?
throw new InternalError("DrawPolygons not implemented for "+
srctype+" with "+comptype);
}
public GraphicsPrimitive traceWrap() {
return new TraceDrawPolygons(this);
}
private static class TraceDrawPolygons extends DrawPolygons {
DrawPolygons target;
public TraceDrawPolygons(DrawPolygons target) {
super(target.getSourceType(),
target.getCompositeType(),
target.getDestType());
this.target = target;
}
public GraphicsPrimitive traceWrap() {
return this;
}
public void DrawPolygons(SunGraphics2D sg2d, SurfaceData sData,
int xPoints[], int yPoints[],
int nPoints[], int numPolys,
int transX, int transY,
boolean close)
{
tracePrimitive(target);
target.DrawPolygons(sg2d, sData,
xPoints, yPoints, nPoints, numPolys,
transX, transY, close);
}
}
}

View File

@@ -0,0 +1,115 @@
/*
* Copyright (c) 1997, 2002, 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.
*/
/*
* @author Charlton Innovations, Inc.
*/
package sun.java2d.loops;
import sun.java2d.loops.GraphicsPrimitive;
import java.awt.Color;
import java.awt.image.ColorModel;
import java.awt.image.Raster;
import sun.java2d.SunGraphics2D;
import sun.java2d.SurfaceData;
/**
* DrawRect
* 1) draw single-width line rectangle onto destination surface
* 2) must accept output area [x, y, dx, dy]
* from within the surface description data for clip rect
*/
public class DrawRect extends GraphicsPrimitive
{
public final static String methodSignature = "DrawRect(...)".toString();
public final static int primTypeID = makePrimTypeID();
public static DrawRect locate(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
return (DrawRect)
GraphicsPrimitiveMgr.locate(primTypeID,
srctype, comptype, dsttype);
}
protected DrawRect(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(methodSignature, primTypeID, srctype, comptype, dsttype);
}
public DrawRect(long pNativePrim,
SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(pNativePrim, methodSignature, primTypeID, srctype, comptype, dsttype);
}
/**
* All DrawRect implementors must have this invoker method
*/
public native void DrawRect(SunGraphics2D sg2d, SurfaceData dest,
int x1, int y1, int w, int h);
public GraphicsPrimitive makePrimitive(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
// REMIND: use FillSpans or converter object?
throw new InternalError("DrawRect not implemented for "+
srctype+" with "+comptype);
}
public GraphicsPrimitive traceWrap() {
return new TraceDrawRect(this);
}
private static class TraceDrawRect extends DrawRect {
DrawRect target;
public TraceDrawRect(DrawRect target) {
super(target.getSourceType(),
target.getCompositeType(),
target.getDestType());
this.target = target;
}
public GraphicsPrimitive traceWrap() {
return this;
}
public void DrawRect(SunGraphics2D sg2d, SurfaceData dest,
int x1, int y1, int w, int h)
{
tracePrimitive(target);
target.DrawRect(sg2d, dest, x1, y1, w, h);
}
}
}

View File

@@ -0,0 +1,118 @@
/*
* Copyright (c) 2008, 2010, 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.
*/
/*
* @author Jim Graham
*/
package sun.java2d.loops;
import sun.java2d.loops.GraphicsPrimitive;
import sun.java2d.SunGraphics2D;
import sun.java2d.SurfaceData;
/**
* FillParallelogram
* 1) fill the area between the 4 edges of a parallelogram
* (as specified by an origin and 2 delta vectors)
*/
public class FillParallelogram extends GraphicsPrimitive
{
public final static String methodSignature =
"FillParallelogram(...)".toString();
public final static int primTypeID = makePrimTypeID();
public static FillParallelogram locate(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
return (FillParallelogram)
GraphicsPrimitiveMgr.locate(primTypeID,
srctype, comptype, dsttype);
}
protected FillParallelogram(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(methodSignature, primTypeID,
srctype, comptype, dsttype);
}
public FillParallelogram(long pNativePrim,
SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(pNativePrim, methodSignature, primTypeID,
srctype, comptype, dsttype);
}
/**
* All FillParallelogram implementors must have this invoker method
*/
public native void FillParallelogram(SunGraphics2D sg2d, SurfaceData dest,
double x0, double y0,
double dx1, double dy1,
double dx2, double dy2);
public GraphicsPrimitive makePrimitive(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
// REMIND: iterate with a FillRect primitive?
throw new InternalError("FillParallelogram not implemented for "+
srctype+" with "+comptype);
}
public GraphicsPrimitive traceWrap() {
return new TraceFillParallelogram(this);
}
private static class TraceFillParallelogram extends FillParallelogram {
FillParallelogram target;
public TraceFillParallelogram(FillParallelogram target) {
super(target.getSourceType(),
target.getCompositeType(),
target.getDestType());
this.target = target;
}
public GraphicsPrimitive traceWrap() {
return this;
}
public void FillParallelogram(SunGraphics2D sg2d, SurfaceData dest,
double x0, double y0,
double dx1, double dy1,
double dx2, double dy2)
{
tracePrimitive(target);
target.FillParallelogram(sg2d, dest, x0, y0, dx1, dy1, dx2, dy2);
}
}
}

View File

@@ -0,0 +1,114 @@
/*
* Copyright (c) 2005, 2006, 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.loops;
import sun.java2d.loops.GraphicsPrimitive;
import sun.java2d.SunGraphics2D;
import sun.java2d.SurfaceData;
import java.awt.geom.Path2D;
/**
* FillPath
* 1. fill path onto destination surface
* 2. must accept output area [x, y, dx, dy]
* from within the surface description data for clip rect
*/
public class FillPath extends GraphicsPrimitive {
public final static String methodSignature =
"FillPath(...)".toString();
public final static int primTypeID = makePrimTypeID();
public static FillPath locate(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
return (FillPath)
GraphicsPrimitiveMgr.locate(primTypeID,
srctype, comptype, dsttype);
}
protected FillPath(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(methodSignature, primTypeID,
srctype, comptype, dsttype);
}
public FillPath(long pNativePrim,
SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(pNativePrim, methodSignature, primTypeID,
srctype, comptype, dsttype);
}
/**
* All FillPath implementors must have this invoker method
*/
public native void FillPath(SunGraphics2D sg2d, SurfaceData sData,
int transX, int transY,
Path2D.Float p2df);
public GraphicsPrimitive makePrimitive(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
throw new InternalError("FillPath not implemented for "+
srctype+" with "+comptype);
}
public GraphicsPrimitive traceWrap() {
return new TraceFillPath(this);
}
private static class TraceFillPath extends FillPath {
FillPath target;
public TraceFillPath(FillPath target) {
super(target.getSourceType(),
target.getCompositeType(),
target.getDestType());
this.target = target;
}
public GraphicsPrimitive traceWrap() {
return this;
}
public void FillPath(SunGraphics2D sg2d, SurfaceData sData,
int transX, int transY,
Path2D.Float p2df)
{
tracePrimitive(target);
target.FillPath(sg2d, sData, transX, transY, p2df);
}
}
}

View File

@@ -0,0 +1,135 @@
/*
* Copyright (c) 1997, 2002, 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.
*/
/*
* @author Charlton Innovations, Inc.
*/
package sun.java2d.loops;
import sun.java2d.loops.GraphicsPrimitive;
import java.awt.Color;
import java.awt.image.ColorModel;
import java.awt.image.Raster;
import sun.java2d.SunGraphics2D;
import sun.java2d.SurfaceData;
/**
* FillRect
* 1) draw solid color rectangle onto destination surface
* 2) must accept output area [x, y, dx, dy]
* from within the surface description data for clip rect
*/
public class FillRect extends GraphicsPrimitive
{
public final static String methodSignature = "FillRect(...)".toString();
public final static int primTypeID = makePrimTypeID();
public static FillRect locate(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
return (FillRect)
GraphicsPrimitiveMgr.locate(primTypeID,
srctype, comptype, dsttype);
}
protected FillRect(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(methodSignature, primTypeID, srctype, comptype, dsttype);
}
public FillRect(long pNativePrim,
SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(pNativePrim, methodSignature, primTypeID, srctype, comptype, dsttype);
}
/**
* All FillRect implementors must have this invoker method
*/
public native void FillRect(SunGraphics2D sg2d, SurfaceData dest,
int x, int y, int w, int h);
static {
GraphicsPrimitiveMgr.registerGeneral(new FillRect(null, null, null));
}
public GraphicsPrimitive makePrimitive(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
return new General(srctype, comptype, dsttype);
}
public static class General extends FillRect {
public MaskFill fillop;
public General(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(srctype, comptype, dsttype);
fillop = MaskFill.locate(srctype, comptype, dsttype);
}
public void FillRect(SunGraphics2D sg2d, SurfaceData dest,
int x, int y, int w, int h)
{
fillop.MaskFill(sg2d, dest, sg2d.composite, x, y, w, h, null, 0, 0);
}
}
public GraphicsPrimitive traceWrap() {
return new TraceFillRect(this);
}
private static class TraceFillRect extends FillRect {
FillRect target;
public TraceFillRect(FillRect target) {
super(target.getSourceType(),
target.getCompositeType(),
target.getDestType());
this.target = target;
}
public GraphicsPrimitive traceWrap() {
return this;
}
public void FillRect(SunGraphics2D sg2d, SurfaceData dest,
int x, int y, int w, int h)
{
tracePrimitive(target);
target.FillRect(sg2d, dest, x, y, w, h);
}
}
}

View File

@@ -0,0 +1,122 @@
/*
* Copyright (c) 1998, 2002, 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.
*/
/*
* @author Jim Graham
* @author Charlton Innovations, Inc.
*/
package sun.java2d.loops;
import sun.java2d.loops.GraphicsPrimitive;
import sun.java2d.pipe.SpanIterator;
import java.awt.Color;
import java.awt.image.ColorModel;
import java.awt.image.Raster;
import sun.java2d.SunGraphics2D;
import sun.java2d.SurfaceData;
/**
* FillSpans
* 1) draw solid color onto destination surface
* 2) rectangular areas to fill come from SpanIterator
*/
public class FillSpans extends GraphicsPrimitive
{
public final static String methodSignature = "FillSpans(...)".toString();
public final static int primTypeID = makePrimTypeID();
public static FillSpans locate(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
return (FillSpans)
GraphicsPrimitiveMgr.locate(primTypeID,
srctype, comptype, dsttype);
}
protected FillSpans(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(methodSignature, primTypeID, srctype, comptype, dsttype);
}
public FillSpans(long pNativePrim,
SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(pNativePrim, methodSignature, primTypeID, srctype, comptype, dsttype);
}
private native void FillSpans(SunGraphics2D sg2d, SurfaceData dest,
int pixel, long pIterator, SpanIterator si);
/**
* All FillSpan implementors must have this invoker method
*/
public void FillSpans(SunGraphics2D sg2d, SurfaceData dest,
SpanIterator si)
{
FillSpans(sg2d, dest, sg2d.pixel, si.getNativeIterator(), si);
}
public GraphicsPrimitive makePrimitive(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
// REMIND: iterate with a FillRect primitive?
throw new InternalError("FillSpans not implemented for "+
srctype+" with "+comptype);
}
public GraphicsPrimitive traceWrap() {
return new TraceFillSpans(this);
}
private static class TraceFillSpans extends FillSpans {
FillSpans target;
public TraceFillSpans(FillSpans target) {
super(target.getSourceType(),
target.getCompositeType(),
target.getDestType());
this.target = target;
}
public GraphicsPrimitive traceWrap() {
return this;
}
public void FillSpans(SunGraphics2D sg2d, SurfaceData dest,
SpanIterator si)
{
tracePrimitive(target);
target.FillSpans(sg2d, dest, si);
}
}
}

View File

@@ -0,0 +1,89 @@
/*
* Copyright (c) 1999, 2005, 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.loops;
import java.awt.Font;
import java.awt.geom.AffineTransform;
import sun.font.Font2D;
import sun.font.FontStrike;
import sun.font.FontStrikeDesc;
/*
* A FontInfo object holds all calculated or derived data needed
* to handle rendering operations based on a particular set of
* Graphics2D rendering attributes.
* Note that this does not use a Font2DHandle, and also has a reference
* to the strike which also references the Font2D.
* So presently, until SG2D objects no longer reference this FontInfo,
* there is still some potential for a bad Font2D to be used for a short
* time. I am reluctant to add the overhead of that machinery here without
* a proven benefit.
*/
public class FontInfo implements Cloneable {
public Font font;
public Font2D font2D;
public FontStrike fontStrike;
public double[] devTx;
public double[] glyphTx;
public int pixelHeight;
public float originX;
public float originY;
public int aaHint;
public boolean lcdRGBOrder;
/* lcdSubPixPos is used if FM is ON for HRGB/HBGR LCD text mode */
public boolean lcdSubPixPos;
public String mtx(double[] matrix) {
return ("["+
matrix[0]+", "+
matrix[1]+", "+
matrix[2]+", "+
matrix[3]+
"]");
}
public Object clone() {
try {
return super.clone();
} catch (CloneNotSupportedException e) {
return null;
}
}
public String toString() {
return ("FontInfo["+
"font="+font+", "+
"devTx="+mtx(devTx)+", "+
"glyphTx="+mtx(glyphTx)+", "+
"pixelHeight="+pixelHeight+", "+
"origin=("+originX+","+originY+"), "+
"aaHint="+aaHint+", "+
"lcdRGBOrder="+(lcdRGBOrder ? "RGB" : "BGR")+
"lcdSubPixPos="+lcdSubPixPos+
"]");
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,623 @@
/*
* Copyright (c) 1997, 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.
*/
/*
* @author Charlton Innovations, Inc.
*/
package sun.java2d.loops;
import java.awt.image.BufferedImage;
import java.awt.AlphaComposite;
import java.awt.Rectangle;
import sun.awt.image.BufImgSurfaceData;
import sun.java2d.SurfaceData;
import sun.java2d.pipe.Region;
import java.lang.reflect.Field;
import java.util.StringTokenizer;
import java.util.Iterator;
import java.util.HashMap;
import java.util.Map;
import java.io.PrintStream;
import java.io.OutputStream;
import java.io.FileOutputStream;
import java.io.FileNotFoundException;
import java.security.AccessController;
import java.security.PrivilegedAction;
import sun.security.action.GetPropertyAction;
/**
* defines interface for primitives which can be placed into
* the graphic component manager framework
*/
public abstract class GraphicsPrimitive {
protected static interface GeneralBinaryOp {
/**
* This method allows the setupGeneralBinaryOp method to set
* the converters into the General version of the Primitive.
*/
public void setPrimitives(Blit srcconverter,
Blit dstconverter,
GraphicsPrimitive genericop,
Blit resconverter);
/**
* These 4 methods are implemented automatically for any
* GraphicsPrimitive. They are used by setupGeneralBinaryOp
* to retrieve the information needed to find the right
* converter primitives.
*/
public SurfaceType getSourceType();
public CompositeType getCompositeType();
public SurfaceType getDestType();
public String getSignature();
public int getPrimTypeID();
}
protected static interface GeneralUnaryOp {
/**
* This method allows the setupGeneralUnaryOp method to set
* the converters into the General version of the Primitive.
*/
public void setPrimitives(Blit dstconverter,
GraphicsPrimitive genericop,
Blit resconverter);
/**
* These 3 methods are implemented automatically for any
* GraphicsPrimitive. They are used by setupGeneralUnaryOp
* to retrieve the information needed to find the right
* converter primitives.
*/
public CompositeType getCompositeType();
public SurfaceType getDestType();
public String getSignature();
public int getPrimTypeID();
}
/**
* INSTANCE DATA MEMBERS DESCRIBING CHARACTERISTICS OF THIS PRIMITIVE
**/
// Making these be instance data members (instead of virtual methods
// overridden by subclasses) is actually cheaper, since each class
// is a singleton. As instance data members with final accessors,
// accesses can be inlined.
private String methodSignature;
private int uniqueID;
private static int unusedPrimID = 1;
private SurfaceType sourceType;
private CompositeType compositeType;
private SurfaceType destType;
private long pNativePrim; // Native blit loop info
public synchronized static final int makePrimTypeID() {
if (unusedPrimID > 255) {
throw new InternalError("primitive id overflow");
}
return unusedPrimID++;
}
public synchronized static final int makeUniqueID(int primTypeID,
SurfaceType src,
CompositeType cmp,
SurfaceType dst)
{
return (primTypeID << 24) |
(dst.getUniqueID() << 16) |
(cmp.getUniqueID() << 8) |
(src.getUniqueID());
}
/**
* Create a new GraphicsPrimitive with all of the required
* descriptive information.
*/
protected GraphicsPrimitive(String methodSignature,
int primTypeID,
SurfaceType sourceType,
CompositeType compositeType,
SurfaceType destType)
{
this.methodSignature = methodSignature;
this.sourceType = sourceType;
this.compositeType = compositeType;
this.destType = destType;
if(sourceType == null || compositeType == null || destType == null) {
this.uniqueID = primTypeID << 24;
} else {
this.uniqueID = GraphicsPrimitive.makeUniqueID(primTypeID,
sourceType,
compositeType,
destType);
}
}
/**
* Create a new GraphicsPrimitive for native invocation
* with all of the required descriptive information.
*/
protected GraphicsPrimitive(long pNativePrim,
String methodSignature,
int primTypeID,
SurfaceType sourceType,
CompositeType compositeType,
SurfaceType destType)
{
this.pNativePrim = pNativePrim;
this.methodSignature = methodSignature;
this.sourceType = sourceType;
this.compositeType = compositeType;
this.destType = destType;
if(sourceType == null || compositeType == null || destType == null) {
this.uniqueID = primTypeID << 24;
} else {
this.uniqueID = GraphicsPrimitive.makeUniqueID(primTypeID,
sourceType,
compositeType,
destType);
}
}
/**
* METHODS TO DESCRIBE THE SURFACES PRIMITIVES
* CAN OPERATE ON AND THE FUNCTIONALITY THEY IMPLEMENT
**/
/**
* Gets instance ID of this graphics primitive.
*
* Instance ID is comprised of four distinct ids (ORed together)
* that uniquely identify each instance of a GraphicsPrimitive
* object. The four ids making up instance ID are:
* 1. primitive id - identifier shared by all primitives of the
* same type (eg. all Blits have the same primitive id)
* 2. sourcetype id - identifies source surface type
* 3. desttype id - identifies destination surface type
* 4. compositetype id - identifies composite used
*
* @return instance ID
*/
public final int getUniqueID() {
return uniqueID;
}
/**
*/
public final String getSignature() {
return methodSignature;
}
/**
* Gets unique id for this GraphicsPrimitive type.
*
* This id is used to identify the TYPE of primitive (Blit vs. BlitBg)
* as opposed to INSTANCE of primitive.
*
* @return primitive ID
*/
public final int getPrimTypeID() {
return uniqueID >>> 24;
}
/**
*/
public final long getNativePrim() {
return pNativePrim;
}
/**
*/
public final SurfaceType getSourceType() {
return sourceType;
}
/**
*/
public final CompositeType getCompositeType() {
return compositeType;
}
/**
*/
public final SurfaceType getDestType() {
return destType;
}
/**
* Return true if this primitive can be used for the given signature
* surfaces, and composite.
*
* @param signature The signature of the given operation. Must be
* == (not just .equals) the signature string given by the
* abstract class that declares the operation.
* @param srctype The surface type for the source of the operation
* @param comptype The composite type for the operation
* @param dsttype The surface type for the destination of the operation
*/
public final boolean satisfies(String signature,
SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
if (signature != methodSignature) {
return false;
}
while (true) {
if (srctype == null) {
return false;
}
if (srctype.equals(sourceType)) {
break;
}
srctype = srctype.getSuperType();
}
while (true) {
if (comptype == null) {
return false;
}
if (comptype.equals(compositeType)) {
break;
}
comptype = comptype.getSuperType();
}
while (true) {
if (dsttype == null) {
return false;
}
if (dsttype.equals(destType)) {
break;
}
dsttype = dsttype.getSuperType();
}
return true;
}
//
// A version of satisfies used for regression testing
//
final boolean satisfiesSameAs(GraphicsPrimitive other) {
return (methodSignature == other.methodSignature &&
sourceType.equals(other.sourceType) &&
compositeType.equals(other.compositeType) &&
destType.equals(other.destType));
}
public abstract GraphicsPrimitive makePrimitive(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype);
public abstract GraphicsPrimitive traceWrap();
static HashMap traceMap;
public static int traceflags;
public static String tracefile;
public static PrintStream traceout;
public static final int TRACELOG = 1;
public static final int TRACETIMESTAMP = 2;
public static final int TRACECOUNTS = 4;
static {
GetPropertyAction gpa = new GetPropertyAction("sun.java2d.trace");
String trace = AccessController.doPrivileged(gpa);
if (trace != null) {
boolean verbose = false;
int traceflags = 0;
StringTokenizer st = new StringTokenizer(trace, ",");
while (st.hasMoreTokens()) {
String tok = st.nextToken();
if (tok.equalsIgnoreCase("count")) {
traceflags |= GraphicsPrimitive.TRACECOUNTS;
} else if (tok.equalsIgnoreCase("log")) {
traceflags |= GraphicsPrimitive.TRACELOG;
} else if (tok.equalsIgnoreCase("timestamp")) {
traceflags |= GraphicsPrimitive.TRACETIMESTAMP;
} else if (tok.equalsIgnoreCase("verbose")) {
verbose = true;
} else if (tok.regionMatches(true, 0, "out:", 0, 4)) {
tracefile = tok.substring(4);
} else {
if (!tok.equalsIgnoreCase("help")) {
System.err.println("unrecognized token: "+tok);
}
System.err.println("usage: -Dsun.java2d.trace="+
"[log[,timestamp]],[count],"+
"[out:<filename>],[help],[verbose]");
}
}
if (verbose) {
System.err.print("GraphicsPrimitive logging ");
if ((traceflags & GraphicsPrimitive.TRACELOG) != 0) {
System.err.println("enabled");
System.err.print("GraphicsPrimitive timetamps ");
if ((traceflags & GraphicsPrimitive.TRACETIMESTAMP) != 0) {
System.err.println("enabled");
} else {
System.err.println("disabled");
}
} else {
System.err.println("[and timestamps] disabled");
}
System.err.print("GraphicsPrimitive invocation counts ");
if ((traceflags & GraphicsPrimitive.TRACECOUNTS) != 0) {
System.err.println("enabled");
} else {
System.err.println("disabled");
}
System.err.print("GraphicsPrimitive trace output to ");
if (tracefile == null) {
System.err.println("System.err");
} else {
System.err.println("file '"+tracefile+"'");
}
}
GraphicsPrimitive.traceflags = traceflags;
}
}
public static boolean tracingEnabled() {
return (traceflags != 0);
}
private static PrintStream getTraceOutputFile() {
if (traceout == null) {
if (tracefile != null) {
FileOutputStream o = AccessController.doPrivileged(
new PrivilegedAction<FileOutputStream>() {
public FileOutputStream run() {
try {
return new FileOutputStream(tracefile);
} catch (FileNotFoundException e) {
return null;
}
}
});
if (o != null) {
traceout = new PrintStream(o);
} else {
traceout = System.err;
}
} else {
traceout = System.err;
}
}
return traceout;
}
public static class TraceReporter extends Thread {
public static void setShutdownHook() {
AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Void run() {
TraceReporter t = new TraceReporter();
t.setContextClassLoader(null);
Runtime.getRuntime().addShutdownHook(t);
return null;
}
});
}
public void run() {
PrintStream ps = getTraceOutputFile();
Iterator iterator = traceMap.entrySet().iterator();
long total = 0;
int numprims = 0;
while (iterator.hasNext()) {
Map.Entry me = (Map.Entry) iterator.next();
Object prim = me.getKey();
int[] count = (int[]) me.getValue();
if (count[0] == 1) {
ps.print("1 call to ");
} else {
ps.print(count[0]+" calls to ");
}
ps.println(prim);
numprims++;
total += count[0];
}
if (numprims == 0) {
ps.println("No graphics primitives executed");
} else if (numprims > 1) {
ps.println(total+" total calls to "+
numprims+" different primitives");
}
}
}
public synchronized static void tracePrimitive(Object prim) {
if ((traceflags & TRACECOUNTS) != 0) {
if (traceMap == null) {
traceMap = new HashMap();
TraceReporter.setShutdownHook();
}
Object o = traceMap.get(prim);
if (o == null) {
o = new int[1];
traceMap.put(prim, o);
}
((int[]) o)[0]++;
}
if ((traceflags & TRACELOG) != 0) {
PrintStream ps = getTraceOutputFile();
if ((traceflags & TRACETIMESTAMP) != 0) {
ps.print(System.currentTimeMillis()+": ");
}
ps.println(prim);
}
}
protected void setupGeneralBinaryOp(GeneralBinaryOp gbo) {
int primID = gbo.getPrimTypeID();
String methodSignature = gbo.getSignature();
SurfaceType srctype = gbo.getSourceType();
CompositeType comptype = gbo.getCompositeType();
SurfaceType dsttype = gbo.getDestType();
Blit convertsrc, convertdst, convertres;
GraphicsPrimitive performop;
convertsrc = createConverter(srctype, SurfaceType.IntArgb);
performop = GraphicsPrimitiveMgr.locatePrim(primID,
SurfaceType.IntArgb,
comptype, dsttype);
if (performop != null) {
convertdst = null;
convertres = null;
} else {
performop = getGeneralOp(primID, comptype);
if (performop == null) {
throw new InternalError("Cannot construct general op for "+
methodSignature+" "+comptype);
}
convertdst = createConverter(dsttype, SurfaceType.IntArgb);
convertres = createConverter(SurfaceType.IntArgb, dsttype);
}
gbo.setPrimitives(convertsrc, convertdst, performop, convertres);
}
protected void setupGeneralUnaryOp(GeneralUnaryOp guo) {
int primID = guo.getPrimTypeID();
String methodSignature = guo.getSignature();
CompositeType comptype = guo.getCompositeType();
SurfaceType dsttype = guo.getDestType();
Blit convertdst = createConverter(dsttype, SurfaceType.IntArgb);
GraphicsPrimitive performop = getGeneralOp(primID, comptype);
Blit convertres = createConverter(SurfaceType.IntArgb, dsttype);
if (convertdst == null || performop == null || convertres == null) {
throw new InternalError("Cannot construct binary op for "+
comptype+" "+dsttype);
}
guo.setPrimitives(convertdst, performop, convertres);
}
protected static Blit createConverter(SurfaceType srctype,
SurfaceType dsttype)
{
if (srctype.equals(dsttype)) {
return null;
}
Blit cv = Blit.getFromCache(srctype, CompositeType.SrcNoEa, dsttype);
if (cv == null) {
throw new InternalError("Cannot construct converter for "+
srctype+"=>"+dsttype);
}
return cv;
}
protected static SurfaceData convertFrom(Blit ob, SurfaceData srcData,
int srcX, int srcY, int w, int h,
SurfaceData dstData)
{
return convertFrom(ob, srcData,
srcX, srcY, w, h, dstData,
BufferedImage.TYPE_INT_ARGB);
}
protected static SurfaceData convertFrom(Blit ob, SurfaceData srcData,
int srcX, int srcY, int w, int h,
SurfaceData dstData, int type)
{
if (dstData != null) {
Rectangle r = dstData.getBounds();
if (w > r.width || h > r.height) {
dstData = null;
}
}
if (dstData == null) {
BufferedImage dstBI = new BufferedImage(w, h, type);
dstData = BufImgSurfaceData.createData(dstBI);
}
ob.Blit(srcData, dstData, AlphaComposite.Src, null,
srcX, srcY, 0, 0, w, h);
return dstData;
}
protected static void convertTo(Blit ob,
SurfaceData srcImg, SurfaceData dstImg,
Region clip,
int dstX, int dstY, int w, int h)
{
if (ob != null) {
ob.Blit(srcImg, dstImg, AlphaComposite.Src, clip,
0, 0, dstX, dstY, w, h);
}
}
protected static GraphicsPrimitive getGeneralOp(int primID,
CompositeType comptype)
{
return GraphicsPrimitiveMgr.locatePrim(primID,
SurfaceType.IntArgb,
comptype,
SurfaceType.IntArgb);
}
public static String simplename(Field[] fields, Object o) {
for (int i = 0; i < fields.length; i++) {
Field f = fields[i];
try {
if (o == f.get(null)) {
return f.getName();
}
} catch (Exception e) {
}
}
return "\""+o.toString()+"\"";
}
public static String simplename(SurfaceType st) {
return simplename(SurfaceType.class.getDeclaredFields(), st);
}
public static String simplename(CompositeType ct) {
return simplename(CompositeType.class.getDeclaredFields(), ct);
}
private String cachedname;
public String toString() {
if (cachedname == null) {
String sig = methodSignature;
int index = sig.indexOf('(');
if (index >= 0) {
sig = sig.substring(0, index);
}
cachedname = (getClass().getName()+"::"+
sig+"("+
simplename(sourceType)+", "+
simplename(compositeType)+", "+
simplename(destType)+")");
}
return cachedname;
}
}

View File

@@ -0,0 +1,330 @@
/*
* Copyright (c) 1997, 2006, 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.
*/
/*
* @author Charlton Innovations, Inc.
*/
package sun.java2d.loops;
import java.util.Comparator;
import java.util.Arrays;
import sun.java2d.SunGraphics2D;
/**
* GraphicsComponentMgr provides services to
* 1. register primitives for later use
* 2. locate an instance of a primitve based on characteristics
*/
public final class GraphicsPrimitiveMgr {
private static final boolean debugTrace = false;
private static GraphicsPrimitive primitives[];
private static GraphicsPrimitive generalPrimitives[];
private static boolean needssort = true;
private static native void initIDs(Class GP, Class ST, Class CT,
Class SG2D, Class Color, Class AT,
Class XORComp, Class AlphaComp,
Class Path2D, Class Path2DFloat,
Class SHints);
private static native void registerNativeLoops();
static {
initIDs(GraphicsPrimitive.class,
SurfaceType.class,
CompositeType.class,
SunGraphics2D.class,
java.awt.Color.class,
java.awt.geom.AffineTransform.class,
XORComposite.class,
java.awt.AlphaComposite.class,
java.awt.geom.Path2D.class,
java.awt.geom.Path2D.Float.class,
sun.awt.SunHints.class);
CustomComponent.register();
GeneralRenderer.register();
registerNativeLoops();
}
private static class PrimitiveSpec {
public int uniqueID;
}
private static Comparator primSorter = new Comparator() {
public int compare(Object o1, Object o2) {
int id1 = ((GraphicsPrimitive) o1).getUniqueID();
int id2 = ((GraphicsPrimitive) o2).getUniqueID();
return (id1 == id2 ? 0 : (id1 < id2 ? -1 : 1));
}
};
private static Comparator primFinder = new Comparator() {
public int compare(Object o1, Object o2) {
int id1 = ((GraphicsPrimitive) o1).getUniqueID();
int id2 = ((PrimitiveSpec) o2).uniqueID;
return (id1 == id2 ? 0 : (id1 < id2 ? -1 : 1));
}
};
/**
* Ensure that noone can instantiate this class.
*/
private GraphicsPrimitiveMgr() {
}
public synchronized static void register(GraphicsPrimitive[] newPrimitives)
{
GraphicsPrimitive[] devCollection = primitives;
int oldSize = 0;
int newSize = newPrimitives.length;
if (debugTrace) {
writeLog("Registering " + newSize + " primitives");
for (int i = 0; i < newSize; i++) {
writeLog(newPrimitives[i].toString());
}
}
if (devCollection != null) {
oldSize = devCollection.length;
}
GraphicsPrimitive[] temp = new GraphicsPrimitive[oldSize + newSize];
if (devCollection != null) {
System.arraycopy(devCollection, 0, temp, 0, oldSize);
}
System.arraycopy(newPrimitives, 0, temp, oldSize, newSize);
needssort = true;
primitives = temp;
}
public synchronized static void registerGeneral(GraphicsPrimitive gen) {
if (generalPrimitives == null) {
generalPrimitives = new GraphicsPrimitive[] {gen};
return;
}
int len = generalPrimitives.length;
GraphicsPrimitive[] newGen = new GraphicsPrimitive[len + 1];
System.arraycopy(generalPrimitives, 0, newGen, 0, len);
newGen[len] = gen;
generalPrimitives = newGen;
}
public synchronized static GraphicsPrimitive locate(int primTypeID,
SurfaceType dsttype)
{
return locate(primTypeID,
SurfaceType.OpaqueColor,
CompositeType.Src,
dsttype);
}
public synchronized static GraphicsPrimitive locate(int primTypeID,
SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
/*
System.out.println("Looking for:");
System.out.println(" method: "+signature);
System.out.println(" from: "+srctype);
System.out.println(" by: "+comptype);
System.out.println(" to: "+dsttype);
*/
GraphicsPrimitive prim = locatePrim(primTypeID,
srctype, comptype, dsttype);
if (prim == null) {
//System.out.println("Trying general loop");
prim = locateGeneral(primTypeID);
if (prim != null) {
prim = prim.makePrimitive(srctype, comptype, dsttype);
if (prim != null && GraphicsPrimitive.traceflags != 0) {
prim = prim.traceWrap();
}
}
}
return prim;
}
public synchronized static GraphicsPrimitive
locatePrim(int primTypeID,
SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
/*
System.out.println("Looking for:");
System.out.println(" method: "+signature);
System.out.println(" from: "+srctype);
System.out.println(" by: "+comptype);
System.out.println(" to: "+dsttype);
*/
SurfaceType src, dst;
CompositeType cmp;
GraphicsPrimitive prim;
PrimitiveSpec spec = new PrimitiveSpec();
for (dst = dsttype; dst != null; dst = dst.getSuperType()) {
for (src = srctype; src != null; src = src.getSuperType()) {
for (cmp = comptype; cmp != null; cmp = cmp.getSuperType()) {
/*
System.out.println("Trying:");
System.out.println(" method: "+spec.methodSignature);
System.out.println(" from: "+spec.sourceType);
System.out.println(" by: "+spec.compType);
System.out.println(" to: "+spec.destType);
*/
spec.uniqueID =
GraphicsPrimitive.makeUniqueID(primTypeID, src, cmp, dst);
prim = locate(spec);
if (prim != null) {
//System.out.println("<GPMgr> Found: " + prim + " in " + i + " steps");
return prim;
}
}
}
}
return null;
}
private static GraphicsPrimitive locateGeneral(int primTypeID) {
if (generalPrimitives == null) {
return null;
}
for (int i = 0; i < generalPrimitives.length; i++) {
GraphicsPrimitive prim = generalPrimitives[i];
if (prim.getPrimTypeID() == primTypeID) {
return prim;
}
}
return null;
//throw new InternalError("No general handler registered for"+signature);
}
private static GraphicsPrimitive locate(PrimitiveSpec spec) {
if (needssort) {
if (GraphicsPrimitive.traceflags != 0) {
for (int i = 0; i < primitives.length; i++) {
primitives[i] = primitives[i].traceWrap();
}
}
Arrays.sort(primitives, primSorter);
needssort = false;
}
GraphicsPrimitive[] devCollection = primitives;
if (devCollection == null) {
return null;
}
int index = Arrays.binarySearch(devCollection, spec, primFinder);
if (index >= 0) {
GraphicsPrimitive prim = devCollection[index];
if (prim instanceof GraphicsPrimitiveProxy) {
prim = ((GraphicsPrimitiveProxy) prim).instantiate();
devCollection[index] = prim;
if (debugTrace) {
writeLog("Instantiated graphics primitive " + prim);
}
}
if (debugTrace) {
writeLog("Lookup found[" + index + "]["+ prim + "]");
}
return prim;
}
if (debugTrace) {
writeLog("Lookup found nothing for:");
writeLog(" " + spec.uniqueID);
}
return null;
}
private static void writeLog(String str) {
if (debugTrace) {
System.err.println(str);
}
}
/**
* Test that all of the GraphicsPrimitiveProxy objects actually
* resolve to something. Throws a RuntimeException if anything
* is wrong, an has no effect if all is well.
*/
// This is only really meant to be called from GraphicsPrimitiveProxyTest
// in the regression tests directory, but it has to be here because
// it needs access to a private data structure. It is not very
// big, though.
public static void testPrimitiveInstantiation() {
testPrimitiveInstantiation(false);
}
public static void testPrimitiveInstantiation(boolean verbose) {
int resolved = 0;
int unresolved = 0;
GraphicsPrimitive[] prims = primitives;
for (int j = 0; j < prims.length; j++) {
GraphicsPrimitive p = prims[j];
if (p instanceof GraphicsPrimitiveProxy) {
GraphicsPrimitive r = ((GraphicsPrimitiveProxy) p).instantiate();
if (!r.getSignature().equals(p.getSignature()) ||
r.getUniqueID() != p.getUniqueID()) {
System.out.println("r.getSignature == "+r.getSignature());
System.out.println("r.getUniqueID == " + r.getUniqueID());
System.out.println("p.getSignature == "+p.getSignature());
System.out.println("p.getUniqueID == " + p.getUniqueID());
throw new RuntimeException("Primitive " + p
+ " returns wrong signature for "
+ r.getClass());
}
// instantiate checks that p.satisfiesSameAs(r)
unresolved++;
p = r;
if (verbose) {
System.out.println(p);
}
} else {
if (verbose) {
System.out.println(p + " (not proxied).");
}
resolved++;
}
}
System.out.println(resolved+
" graphics primitives were not proxied.");
System.out.println(unresolved+
" proxied graphics primitives resolved correctly.");
System.out.println(resolved+unresolved+
" total graphics primitives");
}
public static void main(String argv[]) {
// REMIND: Should trigger loading of platform primitives somehow...
if (needssort) {
Arrays.sort(primitives, primSorter);
needssort = false;
}
testPrimitiveInstantiation(argv.length > 0);
}
}

View File

@@ -0,0 +1,114 @@
/*
* Copyright (c) 1998, 2003, 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.loops;
/**
* GraphicsPrimitiveProxy
*
* Acts as a proxy for instances of GraphicsPrimitive, enabling lazy
* classloading of these primitives. This leads to a substantial
* savings in start-up time and footprint. In the typical case,
* it has been found that a small number of GraphicsPrimitive instance
* actually end up getting instantiated.
* <p>
* Note that the makePrimitive method should never be invoked on
* a GraphicsPrimitiveProxy object since they are instantiated as
* soon as they are found in the primitive list and never returned
* to the caller.
*/
public class GraphicsPrimitiveProxy extends GraphicsPrimitive {
private Class owner;
private String relativeClassName;
/**
* Create a GraphicsPrimitiveProxy for a primitive with a no-argument
* constructor.
*
* @param owner The owner class for this primitive. The primitive
* must be in the same package as this owner.
* @param relativeClassName The name of the class this is a proxy for.
* This should not include the package.
*/
public GraphicsPrimitiveProxy(Class owner, String relativeClassName,
String methodSignature,
int primID,
SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(methodSignature, primID, srctype, comptype, dsttype);
this.owner = owner;
this.relativeClassName = relativeClassName;
}
public GraphicsPrimitive makePrimitive(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype) {
// This should never happen.
throw new InternalError("makePrimitive called on a Proxy!");
}
//
// Come up with the real instance. Called from
// GraphicsPrimitiveMgr.locate()
//
GraphicsPrimitive instantiate() {
String name = getPackageName(owner.getName()) + "."
+ relativeClassName;
try {
Class clazz = Class.forName(name);
GraphicsPrimitive p = (GraphicsPrimitive) clazz.newInstance();
if (!satisfiesSameAs(p)) {
throw new RuntimeException("Primitive " + p
+ " incompatible with proxy for "
+ name);
}
return p;
} catch (ClassNotFoundException ex) {
throw new RuntimeException(ex.toString());
} catch (InstantiationException ex) {
throw new RuntimeException(ex.toString());
} catch (IllegalAccessException ex) {
throw new RuntimeException(ex.toString());
}
// A RuntimeException should never happen in a deployed JDK, because
// the regression test GraphicsPrimitiveProxyTest will catch any
// of these errors.
}
private static String getPackageName(String className) {
int lastDotIdx = className.lastIndexOf('.');
if (lastDotIdx < 0) {
return className;
}
return className.substring(0, lastDotIdx);
}
public GraphicsPrimitive traceWrap() {
return instantiate().traceWrap();
}
}

View File

@@ -0,0 +1,264 @@
/*
* Copyright (c) 1999, 2004, 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.loops;
import java.awt.Composite;
import java.lang.ref.WeakReference;
import sun.java2d.loops.GraphicsPrimitive;
import sun.java2d.SurfaceData;
import sun.java2d.pipe.Region;
/**
* MaskBlit
* 1) copies rectangle of pixels from one surface to another
* 2) performs compositing of colors based upon a Composite
* parameter
* 3) blends result of composite with destination using an
* alpha coverage mask
* 4) the mask may be null in which case it should be treated
* as if it were an array of all opaque values (0xff)
*
* precise behavior is undefined if the source surface
* and the destination surface are the same surface
* with overlapping regions of pixels
*/
public class MaskBlit extends GraphicsPrimitive
{
public static final String methodSignature = "MaskBlit(...)".toString();
public static final int primTypeID = makePrimTypeID();
private static RenderCache blitcache = new RenderCache(20);
public static MaskBlit locate(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
return (MaskBlit)
GraphicsPrimitiveMgr.locate(primTypeID,
srctype, comptype, dsttype);
}
public static MaskBlit getFromCache(SurfaceType src,
CompositeType comp,
SurfaceType dst)
{
Object o = blitcache.get(src, comp, dst);
if (o != null) {
return (MaskBlit) o;
}
MaskBlit blit = locate(src, comp, dst);
if (blit == null) {
System.out.println("mask blit loop not found for:");
System.out.println("src: "+src);
System.out.println("comp: "+comp);
System.out.println("dst: "+dst);
} else {
blitcache.put(src, comp, dst, blit);
}
return blit;
}
protected MaskBlit(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(methodSignature, primTypeID, srctype, comptype, dsttype);
}
public MaskBlit(long pNativePrim,
SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(pNativePrim, methodSignature, primTypeID, srctype, comptype, dsttype);
}
/**
* All MaskBlit implementors must have this invoker method
*/
public native void MaskBlit(SurfaceData src, SurfaceData dst,
Composite comp, Region clip,
int srcx, int srcy,
int dstx, int dsty,
int width, int height,
byte[] mask, int maskoff, int maskscan);
static {
GraphicsPrimitiveMgr.registerGeneral(new MaskBlit(null, null, null));
}
public GraphicsPrimitive makePrimitive(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
/*
new Throwable().printStackTrace();
System.out.println("Constructing general maskblit for:");
System.out.println("src: "+srctype);
System.out.println("comp: "+comptype);
System.out.println("dst: "+dsttype);
*/
if (CompositeType.Xor.equals(comptype)) {
throw new InternalError("Cannot construct MaskBlit for " +
"XOR mode");
}
General ob = new General(srctype, comptype, dsttype);
setupGeneralBinaryOp(ob);
return ob;
}
private static class General
extends MaskBlit
implements GeneralBinaryOp
{
Blit convertsrc;
Blit convertdst;
MaskBlit performop;
Blit convertresult;
WeakReference srcTmp;
WeakReference dstTmp;
public General(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(srctype, comptype, dsttype);
}
public void setPrimitives(Blit srcconverter,
Blit dstconverter,
GraphicsPrimitive genericop,
Blit resconverter)
{
this.convertsrc = srcconverter;
this.convertdst = dstconverter;
this.performop = (MaskBlit) genericop;
this.convertresult = resconverter;
}
public synchronized void MaskBlit(SurfaceData srcData,
SurfaceData dstData,
Composite comp,
Region clip,
int srcx, int srcy,
int dstx, int dsty,
int width, int height,
byte mask[], int offset, int scan)
{
SurfaceData src, dst;
Region opclip;
int sx, sy, dx, dy;
if (convertsrc == null) {
src = srcData;
sx = srcx;
sy = srcy;
} else {
SurfaceData cachedSrc = null;
if (srcTmp != null) {
cachedSrc = (SurfaceData) srcTmp.get();
}
src = convertFrom(convertsrc, srcData, srcx, srcy,
width, height, cachedSrc);
sx = 0;
sy = 0;
if (src != cachedSrc) {
srcTmp = new WeakReference(src);
}
}
if (convertdst == null) {
dst = dstData;
dx = dstx;
dy = dsty;
opclip = clip;
} else {
// assert: convertresult != null
SurfaceData cachedDst = null;
if (dstTmp != null) {
cachedDst = (SurfaceData) dstTmp.get();
}
dst = convertFrom(convertdst, dstData, dstx, dsty,
width, height, cachedDst);
dx = 0;
dy = 0;
opclip = null;
if (dst != cachedDst) {
dstTmp = new WeakReference(dst);
}
}
performop.MaskBlit(src, dst, comp, opclip,
sx, sy, dx, dy, width, height,
mask, offset, scan);
if (convertresult != null) {
// assert: convertdst != null
convertTo(convertresult, dst, dstData, clip,
dstx, dsty, width, height);
}
}
}
public GraphicsPrimitive traceWrap() {
return new TraceMaskBlit(this);
}
private static class TraceMaskBlit extends MaskBlit {
MaskBlit target;
public TraceMaskBlit(MaskBlit target) {
// We need to have the same NativePrim as our
// target in case we are used with a TransformHelper
super(target.getNativePrim(),
target.getSourceType(),
target.getCompositeType(),
target.getDestType());
this.target = target;
}
public GraphicsPrimitive traceWrap() {
return this;
}
public void MaskBlit(SurfaceData src, SurfaceData dst,
Composite comp, Region clip,
int srcx, int srcy, int dstx, int dsty,
int width, int height,
byte[] mask, int maskoff, int maskscan)
{
tracePrimitive(target);
target.MaskBlit(src, dst, comp, clip,
srcx, srcy, dstx, dsty, width, height,
mask, maskoff, maskscan);
}
}
}

View File

@@ -0,0 +1,277 @@
/*
* Copyright (c) 1999, 2013, 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.loops;
import java.awt.Paint;
import java.awt.PaintContext;
import java.awt.Composite;
import java.awt.Rectangle;
import java.awt.image.ColorModel;
import java.awt.image.BufferedImage;
import java.awt.image.WritableRaster;
import sun.awt.image.BufImgSurfaceData;
import sun.java2d.loops.GraphicsPrimitive;
import sun.java2d.SunGraphics2D;
import sun.java2d.SurfaceData;
import sun.java2d.pipe.Region;
/**
* MaskFill
* 1) fills rectangles of pixels on a surface
* 2) performs compositing of colors based upon a Composite
* parameter
* 3) blends result of composite with destination using an
* alpha coverage mask
* 4) the mask may be null in which case it should be treated
* as if it were an array of all opaque values (0xff)
*/
public class MaskFill extends GraphicsPrimitive
{
public static final String methodSignature = "MaskFill(...)".toString();
public static final String fillPgramSignature =
"FillAAPgram(...)".toString();
public static final String drawPgramSignature =
"DrawAAPgram(...)".toString();
public static final int primTypeID = makePrimTypeID();
private static RenderCache fillcache = new RenderCache(10);
public static MaskFill locate(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
return (MaskFill)
GraphicsPrimitiveMgr.locate(primTypeID,
srctype, comptype, dsttype);
}
public static MaskFill locatePrim(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
return (MaskFill)
GraphicsPrimitiveMgr.locatePrim(primTypeID,
srctype, comptype, dsttype);
}
/*
* Note that this uses locatePrim, not locate, so it can return
* null if there is no specific loop to handle this op...
*/
public static MaskFill getFromCache(SurfaceType src,
CompositeType comp,
SurfaceType dst)
{
Object o = fillcache.get(src, comp, dst);
if (o != null) {
return (MaskFill) o;
}
MaskFill fill = locatePrim(src, comp, dst);
if (fill != null) {
fillcache.put(src, comp, dst, fill);
}
return fill;
}
protected MaskFill(String alternateSignature,
SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(alternateSignature, primTypeID, srctype, comptype, dsttype);
}
protected MaskFill(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(methodSignature, primTypeID, srctype, comptype, dsttype);
}
public MaskFill(long pNativePrim,
SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(pNativePrim, methodSignature, primTypeID, srctype, comptype, dsttype);
}
/**
* All MaskFill implementors must have this invoker method
*/
public native void MaskFill(SunGraphics2D sg2d, SurfaceData sData,
Composite comp,
int x, int y, int w, int h,
byte[] mask, int maskoff, int maskscan);
public native void FillAAPgram(SunGraphics2D sg2d, SurfaceData sData,
Composite comp,
double x, double y,
double dx1, double dy1,
double dx2, double dy2);
public native void DrawAAPgram(SunGraphics2D sg2d, SurfaceData sData,
Composite comp,
double x, double y,
double dx1, double dy1,
double dx2, double dy2,
double lw1, double lw2);
public boolean canDoParallelograms() {
return (getNativePrim() != 0);
}
static {
GraphicsPrimitiveMgr.registerGeneral(new MaskFill(null, null, null));
}
public GraphicsPrimitive makePrimitive(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
if (SurfaceType.OpaqueColor.equals(srctype) ||
SurfaceType.AnyColor.equals(srctype))
{
if (CompositeType.Xor.equals(comptype)) {
throw new InternalError("Cannot construct MaskFill for " +
"XOR mode");
} else {
return new General(srctype, comptype, dsttype);
}
} else {
throw new InternalError("MaskFill can only fill with colors");
}
}
private static class General extends MaskFill {
FillRect fillop;
MaskBlit maskop;
public General(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(srctype, comptype, dsttype);
fillop = FillRect.locate(srctype,
CompositeType.SrcNoEa,
SurfaceType.IntArgb);
maskop = MaskBlit.locate(SurfaceType.IntArgb, comptype, dsttype);
}
public void MaskFill(SunGraphics2D sg2d,
SurfaceData sData,
Composite comp,
int x, int y, int w, int h,
byte mask[], int offset, int scan)
{
BufferedImage dstBI =
new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
SurfaceData tmpData = BufImgSurfaceData.createData(dstBI);
// REMIND: This is not pretty. It would be nicer if we
// passed a "FillData" object to the Pixel loops, instead
// of a SunGraphics2D parameter...
Region clip = sg2d.clipRegion;
sg2d.clipRegion = null;
int pixel = sg2d.pixel;
sg2d.pixel = tmpData.pixelFor(sg2d.getColor());
fillop.FillRect(sg2d, tmpData, 0, 0, w, h);
sg2d.pixel = pixel;
sg2d.clipRegion = clip;
maskop.MaskBlit(tmpData, sData, comp, null,
0, 0, x, y, w, h,
mask, offset, scan);
}
}
public GraphicsPrimitive traceWrap() {
return new TraceMaskFill(this);
}
private static class TraceMaskFill extends MaskFill {
MaskFill target;
MaskFill fillPgramTarget;
MaskFill drawPgramTarget;
public TraceMaskFill(MaskFill target) {
super(target.getSourceType(),
target.getCompositeType(),
target.getDestType());
this.target = target;
this.fillPgramTarget = new MaskFill(fillPgramSignature,
target.getSourceType(),
target.getCompositeType(),
target.getDestType());
this.drawPgramTarget = new MaskFill(drawPgramSignature,
target.getSourceType(),
target.getCompositeType(),
target.getDestType());
}
public GraphicsPrimitive traceWrap() {
return this;
}
public void MaskFill(SunGraphics2D sg2d, SurfaceData sData,
Composite comp,
int x, int y, int w, int h,
byte[] mask, int maskoff, int maskscan)
{
tracePrimitive(target);
target.MaskFill(sg2d, sData, comp, x, y, w, h,
mask, maskoff, maskscan);
}
public void FillAAPgram(SunGraphics2D sg2d, SurfaceData sData,
Composite comp,
double x, double y,
double dx1, double dy1,
double dx2, double dy2)
{
tracePrimitive(fillPgramTarget);
target.FillAAPgram(sg2d, sData, comp,
x, y, dx1, dy1, dx2, dy2);
}
public void DrawAAPgram(SunGraphics2D sg2d, SurfaceData sData,
Composite comp,
double x, double y,
double dx1, double dy1,
double dx2, double dy2,
double lw1, double lw2)
{
tracePrimitive(drawPgramTarget);
target.DrawAAPgram(sg2d, sData, comp,
x, y, dx1, dy1, dx2, dy2, lw1, lw2);
}
public boolean canDoParallelograms() {
return target.canDoParallelograms();
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,103 @@
/*
* Copyright (c) 1999, 2004, 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.loops;
public final class RenderCache {
final class Entry {
private SurfaceType src;
private CompositeType comp;
private SurfaceType dst;
private Object value;
public Entry(SurfaceType src,
CompositeType comp,
SurfaceType dst,
Object value)
{
this.src = src;
this.comp = comp;
this.dst = dst;
this.value = value;
}
public boolean matches(SurfaceType src,
CompositeType comp,
SurfaceType dst)
{
// bug 4725045: using equals() causes different SurfaceType
// objects with the same strings to match in the cache, which is
// not the behavior we want. Constrain the match to succeed only
// on object matches instead.
return ((this.src == src) &&
(this.comp == comp) &&
(this.dst == dst));
}
public Object getValue() {
return value;
}
}
private Entry entries[];
public RenderCache(int size) {
entries = new Entry[size];
}
public synchronized Object get(SurfaceType src,
CompositeType comp,
SurfaceType dst)
{
int max = entries.length - 1;
for (int i = max; i >= 0; i--) {
Entry e = entries[i];
if (e == null) {
break;
}
if (e.matches(src, comp, dst)) {
if (i < max - 4) {
System.arraycopy(entries, i+1, entries, i, max - i);
entries[max] = e;
}
return e.getValue();
}
}
return null;
}
public synchronized void put(SurfaceType src,
CompositeType comp,
SurfaceType dst,
Object value)
{
Entry e = new Entry(src, comp, dst, value);
int num = entries.length;
System.arraycopy(entries, 1, entries, 0, num - 1);
entries[num - 1] = e;
}
}

View File

@@ -0,0 +1,55 @@
/*
* Copyright (c) 1999, 2010, 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.loops;
/*
* This class stores the various loops that are used by the
* standard rendering pipelines. The loops for a given instance
* of this class will all share the same destination type and the
* same supported paint and composite operation.
* Each instance of this class should be shared by all graphics
* objects that render onto the same type of destination with the
* same paint and composite combination to reduce the amount of
* time spent looking up loops appropriate for the current fill
* technique.
*/
public class RenderLoops {
public static final int primTypeID = GraphicsPrimitive.makePrimTypeID();
public DrawLine drawLineLoop;
public FillRect fillRectLoop;
public DrawRect drawRectLoop;
public DrawPolygons drawPolygonsLoop;
public DrawPath drawPathLoop;
public FillPath fillPathLoop;
public FillSpans fillSpansLoop;
public FillParallelogram fillParallelogramLoop;
public DrawParallelogram drawParallelogramLoop;
public DrawGlyphList drawGlyphListLoop;
public DrawGlyphListAA drawGlyphListAALoop;
public DrawGlyphListLCD drawGlyphListLCDLoop;
}

View File

@@ -0,0 +1,156 @@
/*
* Copyright (c) 2001, 2004, 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.loops;
import java.awt.Composite;
import java.lang.ref.WeakReference;
import sun.java2d.loops.GraphicsPrimitive;
import sun.java2d.SurfaceData;
import sun.java2d.pipe.Region;
/**
* ScaledBlit
* 1) copies rectangle of pixels from one surface to another
* while scaling the pixels to meet the sizes specified
* 2) performs compositing of colors based upon a Composite
* parameter
*
* precise behavior is undefined if the source surface
* and the destination surface are the same surface
* with overlapping regions of pixels
*/
public class ScaledBlit extends GraphicsPrimitive
{
public static final String methodSignature = "ScaledBlit(...)".toString();
public static final int primTypeID = makePrimTypeID();
private static RenderCache blitcache = new RenderCache(20);
public static ScaledBlit locate(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
return (ScaledBlit)
GraphicsPrimitiveMgr.locate(primTypeID,
srctype, comptype, dsttype);
}
public static ScaledBlit getFromCache(SurfaceType src,
CompositeType comp,
SurfaceType dst)
{
Object o = blitcache.get(src, comp, dst);
if (o != null) {
return (ScaledBlit) o;
}
ScaledBlit blit = locate(src, comp, dst);
if (blit == null) {
/*
System.out.println("blit loop not found for:");
System.out.println("src: "+src);
System.out.println("comp: "+comp);
System.out.println("dst: "+dst);
*/
} else {
blitcache.put(src, comp, dst, blit);
}
return blit;
}
protected ScaledBlit(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(methodSignature, primTypeID, srctype, comptype, dsttype);
}
public ScaledBlit(long pNativePrim,
SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(pNativePrim, methodSignature, primTypeID,
srctype, comptype, dsttype);
}
public native void Scale(SurfaceData src, SurfaceData dst,
Composite comp, Region clip,
int sx1, int sy1,
int sx2, int sy2,
double dx1, double dy1,
double dx2, double dy2);
static {
GraphicsPrimitiveMgr.registerGeneral(new ScaledBlit(null, null, null));
}
public GraphicsPrimitive makePrimitive(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
/*
System.out.println("Constructing general blit for:");
System.out.println("src: "+srctype);
System.out.println("comp: "+comptype);
System.out.println("dst: "+dsttype);
*/
return null;
}
public GraphicsPrimitive traceWrap() {
return new TraceScaledBlit(this);
}
private static class TraceScaledBlit extends ScaledBlit {
ScaledBlit target;
public TraceScaledBlit(ScaledBlit target) {
super(target.getSourceType(),
target.getCompositeType(),
target.getDestType());
this.target = target;
}
public GraphicsPrimitive traceWrap() {
return this;
}
public void Scale(SurfaceData src, SurfaceData dst,
Composite comp, Region clip,
int sx1, int sy1,
int sx2, int sy2,
double dx1, double dy1,
double dx2, double dy2)
{
tracePrimitive(target);
target.Scale(src, dst, comp, clip,
sx1, sy1, sx2, sy2,
dx1, dy1, dx2, dy2);
}
}
}

View File

@@ -0,0 +1,460 @@
/*
* 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.loops;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import sun.awt.image.PixelConverter;
import java.util.HashMap;
/**
* A SurfaceType object provides a chained description of a type of
* drawing surface. The object will provide a single String constant
* descriptor which is one way of viewing or accessing a particular
* drawing surface as well as a pointer to another SurfaceType which
* describes the same drawing surface in a different (typically more
* generalized) way.
* <p>
* A more specific description of a surface is considered a "subtype"
* and a more general description is considered a "supertype". Thus,
* the deriveSubType method provides a way to create a new SurfaceType
* that is related to but more specific than an existing SurfaceType and
* the getSuperType method provides a way to ask a given SurfaceType
* for a more general way to describe the same surface.
* <p>
* Note that you cannot construct a brand new root for a chain since
* the constructor is private. Every chain of types must at some point
* derive from the Any node provided here using the deriveSubType()
* method. The presence of this common Any node on every chain
* ensures that all chains end with the DESC_ANY descriptor so that
* a suitable General GraphicsPrimitive object can be obtained for
* the indicated surface if all of the more specific searches fail.
*/
public final class SurfaceType {
private static int unusedUID = 1;
private static HashMap<String, Integer> surfaceUIDMap = new HashMap<>(100);
/*
* CONSTANTS USED BY ALL PRIMITIVES TO DESCRIBE THE SURFACES
* THEY CAN OPERATE ON
*/
/**
* surface is unknown color model or sample model.
*/
public static final String
DESC_ANY = "Any Surface";
/**
* common surface formats defined in BufferedImage
*/
public static final String
DESC_INT_RGB = "Integer RGB";
public static final String
DESC_INT_ARGB = "Integer ARGB";
public static final String
DESC_INT_ARGB_PRE = "Integer ARGB Premultiplied";
public static final String
DESC_INT_BGR = "Integer BGR";
public static final String
DESC_3BYTE_BGR = "3 Byte BGR";
public static final String
DESC_4BYTE_ABGR = "4 Byte ABGR";
public static final String
DESC_4BYTE_ABGR_PRE = "4 Byte ABGR Premultiplied";
public static final String
DESC_USHORT_565_RGB = "Short 565 RGB";
public static final String
DESC_USHORT_555_RGB = "Short 555 RGB";
public static final String
DESC_USHORT_555_RGBx= "Short 555 RGBx";
public static final String
DESC_USHORT_4444_ARGB= "Short 4444 ARGB";
public static final String
DESC_BYTE_GRAY = "8-bit Gray";
public static final String
DESC_USHORT_INDEXED = "16-bit Indexed";
public static final String
DESC_USHORT_GRAY = "16-bit Gray";
public static final String
DESC_BYTE_BINARY = "Packed Binary Bitmap";
public static final String
DESC_BYTE_INDEXED = "8-bit Indexed";
/**
* wildcard format which indicates that the GraphicsPrimitive
* is independent of the color model on an IntegerComponent
* sample model surface
*/
public static final String DESC_ANY_INT = "Any Discrete Integer";
/**
* wildcard format which indicates that the GraphicsPrimitive
* is independent of the color model on a ShortComponent
* sample model surface
*/
public static final String DESC_ANY_SHORT = "Any Discrete Short";
/**
* wildcard format which indicates that the GraphicsPrimitive
* is independent of the color model on a ByteComponent
* sample model surface
*/
public static final String DESC_ANY_BYTE = "Any Discrete Byte";
/**
* wildcard format which indicates that the GraphicsPrimitive
* operates on a surface with 3 component interleaved Raster and
* sample model and a ComponentColorModel with an arbitrary ordering
* of the RGB channels
*/
public static final String DESC_ANY_3BYTE = "Any 3 Byte Component";
/**
* wildcard format which indicates that the GraphicsPrimitive
* operates on a surface with 4 component interleaved Raster and
* sample model and a ComponentColorModel with an arbitrary ordering
* of the ARGB channels
*/
public static final String DESC_ANY_4BYTE = "Any 4 Byte Component";
/**
* wildcard format which indicates that the GraphicsPrimitive
* operates on a surface with a single component IntegerComponent
* sample model and a DirectColorModel with an arbitrary ordering
* of the RGB channels
*/
public static final String DESC_ANY_INT_DCM = "Any Integer DCM";
/**
* additional IntegerComponent types common on Windows
*/
public static final String DESC_INT_RGBx = "Integer RGBx";
public static final String DESC_INT_BGRx = "Integer BGRx";
/**
* additional 3 byte format common on Windows
*/
public static final String DESC_3BYTE_RGB = "3 Byte RGB";
/**
* common formats for BITMASK transparency.
*/
public static final String DESC_INT_ARGB_BM = "Int ARGB (Bitmask)";
public static final String DESC_BYTE_INDEXED_BM = "8-bit Indexed (Bitmask)";
/**
* Opaque 8-bit indexed images
*/
public static final String
DESC_BYTE_INDEXED_OPAQUE = "8-bit Indexed (Opaque)";
/**
* Special Gray Scale types for rendering loops. Really indexed
* types, but colormap has all gray values.
*/
public static final String DESC_INDEX8_GRAY = "8-bit Palettized Gray";
public static final String DESC_INDEX12_GRAY = "12-bit Palettized Gray";
public static final String
DESC_BYTE_BINARY_1BIT = "Packed Binary 1-bit Bitmap";
public static final String
DESC_BYTE_BINARY_2BIT = "Packed Binary 2-bit Bitmap";
public static final String
DESC_BYTE_BINARY_4BIT = "Packed Binary 4-bit Bitmap";
/**
* Special type for describing the sources of loops that render the
* current foreground color or paint instead of copying colors from
* a source surface.
*/
public static final String DESC_ANY_PAINT = "Paint Object";
public static final String DESC_ANY_COLOR = "Single Color";
public static final String DESC_OPAQUE_COLOR = "Opaque Color";
public static final String
DESC_GRADIENT_PAINT = "Gradient Paint";
public static final String
DESC_OPAQUE_GRADIENT_PAINT = "Opaque Gradient Paint";
public static final String
DESC_TEXTURE_PAINT = "Texture Paint";
public static final String
DESC_OPAQUE_TEXTURE_PAINT = "Opaque Texture Paint";
public static final String
DESC_LINEAR_GRADIENT_PAINT = "Linear Gradient Paint";
public static final String
DESC_OPAQUE_LINEAR_GRADIENT_PAINT = "Opaque Linear Gradient Paint";
public static final String
DESC_RADIAL_GRADIENT_PAINT = "Radial Gradient Paint";
public static final String
DESC_OPAQUE_RADIAL_GRADIENT_PAINT = "Opaque Radial Gradient Paint";
/*
* END OF SURFACE TYPE CONSTANTS
*/
/**
* The root SurfaceType object for all chains of surface descriptions.
* The root uses the default PixelConverter object, which uses a given
* ColorModel object to calculate its pixelFor() values when asked.
* Any SurfaceType objects that are not created with a specific
* PixelConverter object will inherit this behavior from the root.
*/
public static final SurfaceType Any =
new SurfaceType(null, DESC_ANY, PixelConverter.instance);
/*
* START OF SurfaceType OBJECTS FOR THE VARIOUS CONSTANTS
*/
public static final SurfaceType
AnyInt = Any.deriveSubType(DESC_ANY_INT);
public static final SurfaceType
AnyShort = Any.deriveSubType(DESC_ANY_SHORT);
public static final SurfaceType
AnyByte = Any.deriveSubType(DESC_ANY_BYTE);
public static final SurfaceType
AnyByteBinary = Any.deriveSubType(DESC_BYTE_BINARY);
public static final SurfaceType
Any3Byte = Any.deriveSubType(DESC_ANY_3BYTE);
public static final SurfaceType
Any4Byte = Any.deriveSubType(DESC_ANY_4BYTE);
public static final SurfaceType
AnyDcm = AnyInt.deriveSubType(DESC_ANY_INT_DCM);
public static final SurfaceType
Custom = Any;
public static final SurfaceType IntRgb =
AnyDcm.deriveSubType(DESC_INT_RGB, PixelConverter.Xrgb.instance);
public static final SurfaceType IntArgb =
AnyDcm.deriveSubType(DESC_INT_ARGB, PixelConverter.Argb.instance);
public static final SurfaceType IntArgbPre =
AnyDcm.deriveSubType(DESC_INT_ARGB_PRE,
PixelConverter.ArgbPre.instance);
public static final SurfaceType IntBgr =
AnyDcm.deriveSubType(DESC_INT_BGR, PixelConverter.Xbgr.instance);
public static final SurfaceType ThreeByteBgr =
Any3Byte.deriveSubType(DESC_3BYTE_BGR, PixelConverter.Xrgb.instance);
public static final SurfaceType FourByteAbgr =
Any4Byte.deriveSubType(DESC_4BYTE_ABGR, PixelConverter.Rgba.instance);
public static final SurfaceType FourByteAbgrPre =
Any4Byte.deriveSubType(DESC_4BYTE_ABGR_PRE,
PixelConverter.RgbaPre.instance);
public static final SurfaceType Ushort565Rgb =
AnyShort.deriveSubType(DESC_USHORT_565_RGB,
PixelConverter.Ushort565Rgb.instance);
public static final SurfaceType Ushort555Rgb =
AnyShort.deriveSubType(DESC_USHORT_555_RGB,
PixelConverter.Ushort555Rgb.instance);
public static final SurfaceType Ushort555Rgbx =
AnyShort.deriveSubType(DESC_USHORT_555_RGBx,
PixelConverter.Ushort555Rgbx.instance);
public static final SurfaceType Ushort4444Argb =
AnyShort.deriveSubType(DESC_USHORT_4444_ARGB,
PixelConverter.Ushort4444Argb.instance);
public static final SurfaceType UshortIndexed =
AnyShort.deriveSubType(DESC_USHORT_INDEXED);
public static final SurfaceType ByteGray =
AnyByte.deriveSubType(DESC_BYTE_GRAY,
PixelConverter.ByteGray.instance);
public static final SurfaceType UshortGray =
AnyShort.deriveSubType(DESC_USHORT_GRAY,
PixelConverter.UshortGray.instance);
public static final SurfaceType ByteBinary1Bit =
AnyByteBinary.deriveSubType(DESC_BYTE_BINARY_1BIT);
public static final SurfaceType ByteBinary2Bit =
AnyByteBinary.deriveSubType(DESC_BYTE_BINARY_2BIT);
public static final SurfaceType ByteBinary4Bit =
AnyByteBinary.deriveSubType(DESC_BYTE_BINARY_4BIT);
public static final SurfaceType ByteIndexed =
AnyByte.deriveSubType(DESC_BYTE_INDEXED);
public static final SurfaceType IntRgbx =
AnyDcm.deriveSubType(DESC_INT_RGBx, PixelConverter.Rgbx.instance);
public static final SurfaceType IntBgrx =
AnyDcm.deriveSubType(DESC_INT_BGRx, PixelConverter.Bgrx.instance);
public static final SurfaceType ThreeByteRgb =
Any3Byte.deriveSubType(DESC_3BYTE_RGB, PixelConverter.Xbgr.instance);
public static final SurfaceType IntArgbBm =
AnyDcm.deriveSubType(DESC_INT_ARGB_BM, PixelConverter.ArgbBm.instance);
public static final SurfaceType ByteIndexedBm =
ByteIndexed.deriveSubType(DESC_BYTE_INDEXED_BM);
public static final SurfaceType ByteIndexedOpaque =
ByteIndexedBm.deriveSubType(DESC_BYTE_INDEXED_OPAQUE);
public static final SurfaceType Index8Gray =
ByteIndexedOpaque.deriveSubType(DESC_INDEX8_GRAY);
public static final SurfaceType Index12Gray =
Any.deriveSubType(DESC_INDEX12_GRAY);
public static final SurfaceType AnyPaint =
Any.deriveSubType(DESC_ANY_PAINT);
public static final SurfaceType AnyColor =
AnyPaint.deriveSubType(DESC_ANY_COLOR);
public static final SurfaceType OpaqueColor =
AnyColor.deriveSubType(DESC_OPAQUE_COLOR);
public static final SurfaceType GradientPaint =
AnyPaint.deriveSubType(DESC_GRADIENT_PAINT);
public static final SurfaceType OpaqueGradientPaint =
GradientPaint.deriveSubType(DESC_OPAQUE_GRADIENT_PAINT);
public static final SurfaceType LinearGradientPaint =
AnyPaint.deriveSubType(DESC_LINEAR_GRADIENT_PAINT);
public static final SurfaceType OpaqueLinearGradientPaint =
LinearGradientPaint.deriveSubType(DESC_OPAQUE_LINEAR_GRADIENT_PAINT);
public static final SurfaceType RadialGradientPaint =
AnyPaint.deriveSubType(DESC_RADIAL_GRADIENT_PAINT);
public static final SurfaceType OpaqueRadialGradientPaint =
RadialGradientPaint.deriveSubType(DESC_OPAQUE_RADIAL_GRADIENT_PAINT);
public static final SurfaceType TexturePaint =
AnyPaint.deriveSubType(DESC_TEXTURE_PAINT);
public static final SurfaceType OpaqueTexturePaint =
TexturePaint.deriveSubType(DESC_OPAQUE_TEXTURE_PAINT);
/*
* END OF SurfaceType OBJECTS FOR THE VARIOUS CONSTANTS
*/
/**
* Return a new SurfaceType object which uses this object as its
* more general "supertype" descriptor. If no operation can be
* found that manipulates the type of surface described more exactly
* by desc, then this object will define the more relaxed specification
* of the surface that can be used to find a more general operator.
*/
public SurfaceType deriveSubType(String desc) {
return new SurfaceType(this, desc);
}
public SurfaceType deriveSubType(String desc,
PixelConverter pixelConverter) {
return new SurfaceType(this, desc, pixelConverter);
}
private int uniqueID;
private String desc;
private SurfaceType next;
protected PixelConverter pixelConverter;
private SurfaceType(SurfaceType parent, String desc,
PixelConverter pixelConverter) {
next = parent;
this.desc = desc;
this.uniqueID = makeUniqueID(desc);
this.pixelConverter = pixelConverter;
}
private SurfaceType(SurfaceType parent, String desc) {
next = parent;
this.desc = desc;
this.uniqueID = makeUniqueID(desc);
this.pixelConverter = parent.pixelConverter;
}
public synchronized static final int makeUniqueID(String desc) {
Integer i = surfaceUIDMap.get(desc);
if (i == null) {
if (unusedUID > 255) {
throw new InternalError("surface type id overflow");
}
i = Integer.valueOf(unusedUID++);
surfaceUIDMap.put(desc, i);
}
return i.intValue();
}
public int getUniqueID() {
return uniqueID;
}
public String getDescriptor() {
return desc;
}
public SurfaceType getSuperType() {
return next;
}
public PixelConverter getPixelConverter() {
return pixelConverter;
}
public int pixelFor(int rgb, ColorModel cm) {
return pixelConverter.rgbToPixel(rgb, cm);
}
public int rgbFor(int pixel, ColorModel cm) {
return pixelConverter.pixelToRgb(pixel, cm);
}
public int getAlphaMask() {
return pixelConverter.getAlphaMask();
}
public int hashCode() {
return desc.hashCode();
}
public boolean equals(Object o) {
if (o instanceof SurfaceType) {
return (((SurfaceType) o).uniqueID == this.uniqueID);
}
return false;
}
public String toString() {
return desc;
}
}

View File

@@ -0,0 +1,157 @@
/*
* Copyright (c) 2003, 2004, 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.loops;
import java.awt.Composite;
import java.awt.geom.AffineTransform;
import java.lang.ref.WeakReference;
import sun.java2d.SurfaceData;
import sun.java2d.loops.GraphicsPrimitive;
import sun.java2d.pipe.Region;
/**
* TransformBlit
* 1) applies an AffineTransform to a rectangle of pixels while copying
* from one surface to another
* 2) performs compositing of colors based upon a Composite
* parameter
*
* precise behavior is undefined if the source surface
* and the destination surface are the same surface
* with overlapping regions of pixels
*/
public class TransformBlit extends GraphicsPrimitive
{
public static final String methodSignature =
"TransformBlit(...)".toString();
public static final int primTypeID = makePrimTypeID();
private static RenderCache blitcache = new RenderCache(10);
public static TransformBlit locate(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
return (TransformBlit)
GraphicsPrimitiveMgr.locate(primTypeID,
srctype, comptype, dsttype);
}
public static TransformBlit getFromCache(SurfaceType src,
CompositeType comp,
SurfaceType dst)
{
Object o = blitcache.get(src, comp, dst);
if (o != null) {
return (TransformBlit) o;
}
TransformBlit blit = locate(src, comp, dst);
if (blit == null) {
/*
System.out.println("blit loop not found for:");
System.out.println("src: "+src);
System.out.println("comp: "+comp);
System.out.println("dst: "+dst);
*/
} else {
blitcache.put(src, comp, dst, blit);
}
return blit;
}
protected TransformBlit(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(methodSignature, primTypeID, srctype, comptype, dsttype);
}
public TransformBlit(long pNativePrim,
SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(pNativePrim, methodSignature, primTypeID,
srctype, comptype, dsttype);
}
public native void Transform(SurfaceData src, SurfaceData dst,
Composite comp, Region clip,
AffineTransform at, int hint,
int srcx, int srcy, int dstx, int dsty,
int width, int height);
// REMIND: do we have a general loop?
static {
GraphicsPrimitiveMgr.registerGeneral(new TransformBlit(null, null,
null));
}
public GraphicsPrimitive makePrimitive(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
/*
System.out.println("Constructing general blit for:");
System.out.println("src: "+srctype);
System.out.println("comp: "+comptype);
System.out.println("dst: "+dsttype);
*/
return null;
}
public GraphicsPrimitive traceWrap() {
return new TraceTransformBlit(this);
}
private static class TraceTransformBlit extends TransformBlit {
TransformBlit target;
public TraceTransformBlit(TransformBlit target) {
super(target.getSourceType(),
target.getCompositeType(),
target.getDestType());
this.target = target;
}
public GraphicsPrimitive traceWrap() {
return this;
}
public void Transform(SurfaceData src, SurfaceData dst,
Composite comp, Region clip,
AffineTransform at, int hint,
int srcx, int srcy, int dstx, int dsty,
int width, int height)
{
tracePrimitive(target);
target.Transform(src, dst, comp, clip, at, hint,
srcx, srcy, dstx, dsty, width, height);
}
}
}

View File

@@ -0,0 +1,140 @@
/*
* Copyright (c) 2004, 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.loops;
import java.awt.Composite;
import java.awt.geom.AffineTransform;
import java.lang.ref.WeakReference;
import sun.java2d.SurfaceData;
import sun.java2d.loops.GraphicsPrimitive;
import sun.java2d.pipe.Region;
/**
* TransformHelper
* 1) applies an AffineTransform to a rectangle of pixels while copying
* from one surface to another
* 2) performs compositing of colors based upon a Composite
* parameter
*
* precise behavior is undefined if the source surface
* and the destination surface are the same surface
* with overlapping regions of pixels
*/
public class TransformHelper extends GraphicsPrimitive
{
public static final String methodSignature =
"TransformHelper(...)".toString();
public static final int primTypeID = makePrimTypeID();
private static RenderCache helpercache = new RenderCache(10);
public static TransformHelper locate(SurfaceType srctype) {
return (TransformHelper)
GraphicsPrimitiveMgr.locate(primTypeID,
srctype,
CompositeType.SrcNoEa,
SurfaceType.IntArgbPre);
}
public static synchronized TransformHelper getFromCache(SurfaceType src) {
Object o = helpercache.get(src, null, null);
if (o != null) {
return (TransformHelper) o;
}
TransformHelper helper = locate(src);
if (helper == null) {
/*
System.out.println("helper loop not found for:");
System.out.println("src: "+src);
*/
} else {
helpercache.put(src, null, null, helper);
}
return helper;
}
protected TransformHelper(SurfaceType srctype) {
super(methodSignature, primTypeID, srctype,
CompositeType.SrcNoEa,
SurfaceType.IntArgbPre);
}
public TransformHelper(long pNativePrim, SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
super(pNativePrim, methodSignature, primTypeID,
srctype, comptype, dsttype);
}
public native void Transform(MaskBlit output,
SurfaceData src, SurfaceData dst,
Composite comp, Region clip,
AffineTransform itx, int txtype,
int sx1, int sy1, int sx2, int sy2,
int dx1, int dy1, int dx2, int dy2,
int edges[], int dxoff, int dyoff);
public GraphicsPrimitive makePrimitive(SurfaceType srctype,
CompositeType comptype,
SurfaceType dsttype)
{
return null;
}
public GraphicsPrimitive traceWrap() {
return new TraceTransformHelper(this);
}
private static class TraceTransformHelper extends TransformHelper {
TransformHelper target;
public TraceTransformHelper(TransformHelper target) {
super(target.getSourceType());
this.target = target;
}
public GraphicsPrimitive traceWrap() {
return this;
}
public void Transform(MaskBlit output,
SurfaceData src, SurfaceData dst,
Composite comp, Region clip,
AffineTransform itx, int txtype,
int sx1, int sy1, int sx2, int sy2,
int dx1, int dy1, int dx2, int dy2,
int edges[], int dxoff, int dyoff)
{
tracePrimitive(target);
target.Transform(output, src, dst, comp, clip, itx, txtype,
sx1, sy1, sx2, sy2,
dx1, dy1, dx2, dy2,
edges, dxoff, dyoff);
}
}
}

View File

@@ -0,0 +1,72 @@
/*
* Copyright (c) 1998, 2002, 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.loops;
import java.awt.image.ColorModel;
import java.awt.Color;
import java.awt.Composite;
import java.awt.CompositeContext;
import java.awt.RenderingHints;
import sun.java2d.SurfaceData;
import sun.java2d.SunCompositeContext;
/**
* Bitwise XOR Composite class.
*/
public final class XORComposite implements Composite {
Color xorColor;
int xorPixel;
int alphaMask;
public XORComposite(Color xorColor, SurfaceData sd) {
this.xorColor = xorColor;
SurfaceType sType = sd.getSurfaceType();
this.xorPixel = sd.pixelFor(xorColor.getRGB());
this.alphaMask = sType.getAlphaMask();
}
public Color getXorColor() {
return xorColor;
}
public int getXorPixel() {
return xorPixel;
}
public int getAlphaMask() {
return alphaMask;
}
public CompositeContext createContext(ColorModel srcColorModel,
ColorModel dstColorModel,
RenderingHints hints) {
return new SunCompositeContext(this, srcColorModel, dstColorModel);
}
}