Path: blob/master/src/java.desktop/share/classes/sun/java2d/loops/TransformBlit.java
41159 views
/*1* Copyright (c) 2003, 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* TransformBlit35* 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*/4445public class TransformBlit extends GraphicsPrimitive46{47public static final String methodSignature =48"TransformBlit(...)".toString();4950public static final int primTypeID = makePrimTypeID();5152private static RenderCache blitcache = new RenderCache(10);5354public static TransformBlit locate(SurfaceType srctype,55CompositeType comptype,56SurfaceType dsttype)57{58return (TransformBlit)59GraphicsPrimitiveMgr.locate(primTypeID,60srctype, comptype, dsttype);61}6263public static TransformBlit getFromCache(SurfaceType src,64CompositeType comp,65SurfaceType dst)66{67Object o = blitcache.get(src, comp, dst);68if (o != null) {69return (TransformBlit) o;70}71TransformBlit blit = locate(src, comp, dst);72if (blit == null) {73/*74System.out.println("blit loop not found for:");75System.out.println("src: "+src);76System.out.println("comp: "+comp);77System.out.println("dst: "+dst);78*/79} else {80blitcache.put(src, comp, dst, blit);81}82return blit;83}8485protected TransformBlit(SurfaceType srctype,86CompositeType comptype,87SurfaceType dsttype)88{89super(methodSignature, primTypeID, srctype, comptype, dsttype);90}9192public TransformBlit(long pNativePrim,93SurfaceType srctype,94CompositeType comptype,95SurfaceType dsttype)96{97super(pNativePrim, methodSignature, primTypeID,98srctype, comptype, dsttype);99}100101public native void Transform(SurfaceData src, SurfaceData dst,102Composite comp, Region clip,103AffineTransform at, int hint,104int srcx, int srcy, int dstx, int dsty,105int width, int height);106107public GraphicsPrimitive traceWrap() {108return new TraceTransformBlit(this);109}110111private static class TraceTransformBlit extends TransformBlit {112TransformBlit target;113114public TraceTransformBlit(TransformBlit target) {115super(target.getSourceType(),116target.getCompositeType(),117target.getDestType());118this.target = target;119}120121public GraphicsPrimitive traceWrap() {122return this;123}124125public void Transform(SurfaceData src, SurfaceData dst,126Composite comp, Region clip,127AffineTransform at, int hint,128int srcx, int srcy, int dstx, int dsty,129int width, int height)130{131tracePrimitive(target);132target.Transform(src, dst, comp, clip, at, hint,133srcx, srcy, dstx, dsty, width, height);134}135}136}137138139