Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/java2d/loops/TransformBlit.java
38918 views
/*1* Copyright (c) 2003, 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* TransformBlit36* 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*/4546public class TransformBlit extends GraphicsPrimitive47{48public static final String methodSignature =49"TransformBlit(...)".toString();5051public static final int primTypeID = makePrimTypeID();5253private static RenderCache blitcache = new RenderCache(10);5455public static TransformBlit locate(SurfaceType srctype,56CompositeType comptype,57SurfaceType dsttype)58{59return (TransformBlit)60GraphicsPrimitiveMgr.locate(primTypeID,61srctype, comptype, dsttype);62}6364public static TransformBlit getFromCache(SurfaceType src,65CompositeType comp,66SurfaceType dst)67{68Object o = blitcache.get(src, comp, dst);69if (o != null) {70return (TransformBlit) o;71}72TransformBlit blit = locate(src, comp, dst);73if (blit == null) {74/*75System.out.println("blit loop not found for:");76System.out.println("src: "+src);77System.out.println("comp: "+comp);78System.out.println("dst: "+dst);79*/80} else {81blitcache.put(src, comp, dst, blit);82}83return blit;84}8586protected TransformBlit(SurfaceType srctype,87CompositeType comptype,88SurfaceType dsttype)89{90super(methodSignature, primTypeID, srctype, comptype, dsttype);91}9293public TransformBlit(long pNativePrim,94SurfaceType srctype,95CompositeType comptype,96SurfaceType dsttype)97{98super(pNativePrim, methodSignature, primTypeID,99srctype, comptype, dsttype);100}101102public native void Transform(SurfaceData src, SurfaceData dst,103Composite comp, Region clip,104AffineTransform at, int hint,105int srcx, int srcy, int dstx, int dsty,106int width, int height);107108// REMIND: do we have a general loop?109static {110GraphicsPrimitiveMgr.registerGeneral(new TransformBlit(null, null,111null));112}113114public GraphicsPrimitive makePrimitive(SurfaceType srctype,115CompositeType comptype,116SurfaceType dsttype)117{118/*119System.out.println("Constructing general blit for:");120System.out.println("src: "+srctype);121System.out.println("comp: "+comptype);122System.out.println("dst: "+dsttype);123*/124return null;125}126127public GraphicsPrimitive traceWrap() {128return new TraceTransformBlit(this);129}130131private static class TraceTransformBlit extends TransformBlit {132TransformBlit target;133134public TraceTransformBlit(TransformBlit target) {135super(target.getSourceType(),136target.getCompositeType(),137target.getDestType());138this.target = target;139}140141public GraphicsPrimitive traceWrap() {142return this;143}144145public void Transform(SurfaceData src, SurfaceData dst,146Composite comp, Region clip,147AffineTransform at, int hint,148int srcx, int srcy, int dstx, int dsty,149int width, int height)150{151tracePrimitive(target);152target.Transform(src, dst, comp, clip, at, hint,153srcx, srcy, dstx, dsty, width, height);154}155}156}157158159