Path: blob/master/src/java.desktop/share/classes/sun/java2d/loops/TransformHelper.java
41159 views
/*1* Copyright (c) 2004, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.java2d.loops;2627import java.awt.Composite;28import java.awt.geom.AffineTransform;2930import sun.java2d.SurfaceData;31import sun.java2d.pipe.Region;3233/**34* TransformHelper35* 1) applies an AffineTransform to a rectangle of pixels while copying36* from one surface to another37* 2) performs compositing of colors based upon a Composite38* parameter39*40* precise behavior is undefined if the source surface41* and the destination surface are the same surface42* with overlapping regions of pixels43*/44public class TransformHelper extends GraphicsPrimitive45{46public static final String methodSignature =47"TransformHelper(...)".toString();4849public static final int primTypeID = makePrimTypeID();5051private static RenderCache helpercache = new RenderCache(10);5253public static TransformHelper locate(SurfaceType srctype) {54return (TransformHelper)55GraphicsPrimitiveMgr.locate(primTypeID,56srctype,57CompositeType.SrcNoEa,58SurfaceType.IntArgbPre);59}6061public static synchronized TransformHelper getFromCache(SurfaceType src) {62Object o = helpercache.get(src, null, null);63if (o != null) {64return (TransformHelper) o;65}66TransformHelper helper = locate(src);67if (helper == null) {68/*69System.out.println("helper loop not found for:");70System.out.println("src: "+src);71*/72} else {73helpercache.put(src, null, null, helper);74}75return helper;76}7778protected TransformHelper(SurfaceType srctype) {79super(methodSignature, primTypeID, srctype,80CompositeType.SrcNoEa,81SurfaceType.IntArgbPre);82}8384public TransformHelper(long pNativePrim, SurfaceType srctype,85CompositeType comptype,86SurfaceType dsttype)87{88super(pNativePrim, methodSignature, primTypeID,89srctype, comptype, dsttype);90}9192public native void Transform(MaskBlit output,93SurfaceData src, SurfaceData dst,94Composite comp, Region clip,95AffineTransform itx, int txtype,96int sx1, int sy1, int sx2, int sy2,97int dx1, int dy1, int dx2, int dy2,98int[] edges, int dxoff, int dyoff);99100public GraphicsPrimitive traceWrap() {101return new TraceTransformHelper(this);102}103104private static class TraceTransformHelper extends TransformHelper {105TransformHelper target;106107public TraceTransformHelper(TransformHelper target) {108super(target.getSourceType());109this.target = target;110}111112public GraphicsPrimitive traceWrap() {113return this;114}115116public void Transform(MaskBlit output,117SurfaceData src, SurfaceData dst,118Composite comp, Region clip,119AffineTransform itx, int txtype,120int sx1, int sy1, int sx2, int sy2,121int dx1, int dy1, int dx2, int dy2,122int[] edges, int dxoff, int dyoff)123{124tracePrimitive(target);125target.Transform(output, src, dst, comp, clip, itx, txtype,126sx1, sy1, sx2, sy2,127dx1, dy1, dx2, dy2,128edges, dxoff, dyoff);129}130}131}132133134