Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/java2d/loops/TransformHelper.java
38918 views
/*1* Copyright (c) 2004, 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;29import java.lang.ref.WeakReference;30import sun.java2d.SurfaceData;31import sun.java2d.loops.GraphicsPrimitive;32import sun.java2d.pipe.Region;3334/**35* TransformHelper36* 1) applies an AffineTransform to a rectangle of pixels while copying37* from one surface to another38* 2) performs compositing of colors based upon a Composite39* parameter40*41* precise behavior is undefined if the source surface42* and the destination surface are the same surface43* with overlapping regions of pixels44*/45public class TransformHelper extends GraphicsPrimitive46{47public static final String methodSignature =48"TransformHelper(...)".toString();4950public static final int primTypeID = makePrimTypeID();5152private static RenderCache helpercache = new RenderCache(10);5354public static TransformHelper locate(SurfaceType srctype) {55return (TransformHelper)56GraphicsPrimitiveMgr.locate(primTypeID,57srctype,58CompositeType.SrcNoEa,59SurfaceType.IntArgbPre);60}6162public static synchronized TransformHelper getFromCache(SurfaceType src) {63Object o = helpercache.get(src, null, null);64if (o != null) {65return (TransformHelper) o;66}67TransformHelper helper = locate(src);68if (helper == null) {69/*70System.out.println("helper loop not found for:");71System.out.println("src: "+src);72*/73} else {74helpercache.put(src, null, null, helper);75}76return helper;77}7879protected TransformHelper(SurfaceType srctype) {80super(methodSignature, primTypeID, srctype,81CompositeType.SrcNoEa,82SurfaceType.IntArgbPre);83}8485public TransformHelper(long pNativePrim, SurfaceType srctype,86CompositeType comptype,87SurfaceType dsttype)88{89super(pNativePrim, methodSignature, primTypeID,90srctype, comptype, dsttype);91}9293public native void Transform(MaskBlit output,94SurfaceData src, SurfaceData dst,95Composite comp, Region clip,96AffineTransform itx, int txtype,97int sx1, int sy1, int sx2, int sy2,98int dx1, int dy1, int dx2, int dy2,99int edges[], int dxoff, int dyoff);100101public GraphicsPrimitive makePrimitive(SurfaceType srctype,102CompositeType comptype,103SurfaceType dsttype)104{105return null;106}107108public GraphicsPrimitive traceWrap() {109return new TraceTransformHelper(this);110}111112private static class TraceTransformHelper extends TransformHelper {113TransformHelper target;114115public TraceTransformHelper(TransformHelper target) {116super(target.getSourceType());117this.target = target;118}119120public GraphicsPrimitive traceWrap() {121return this;122}123124public void Transform(MaskBlit output,125SurfaceData src, SurfaceData dst,126Composite comp, Region clip,127AffineTransform itx, int txtype,128int sx1, int sy1, int sx2, int sy2,129int dx1, int dy1, int dx2, int dy2,130int edges[], int dxoff, int dyoff)131{132tracePrimitive(target);133target.Transform(output, src, dst, comp, clip, itx, txtype,134sx1, sy1, sx2, sy2,135dx1, dy1, dx2, dy2,136edges, dxoff, dyoff);137}138}139}140141142