Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/java2d/loops/ScaledBlit.java
38918 views
/*1* Copyright (c) 2001, 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.lang.ref.WeakReference;29import sun.java2d.loops.GraphicsPrimitive;30import sun.java2d.SurfaceData;31import sun.java2d.pipe.Region;3233/**34* ScaledBlit35* 1) copies rectangle of pixels from one surface to another36* while scaling the pixels to meet the sizes specified37* 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 ScaledBlit extends GraphicsPrimitive46{47public static final String methodSignature = "ScaledBlit(...)".toString();4849public static final int primTypeID = makePrimTypeID();5051private static RenderCache blitcache = new RenderCache(20);5253public static ScaledBlit locate(SurfaceType srctype,54CompositeType comptype,55SurfaceType dsttype)56{57return (ScaledBlit)58GraphicsPrimitiveMgr.locate(primTypeID,59srctype, comptype, dsttype);60}6162public static ScaledBlit getFromCache(SurfaceType src,63CompositeType comp,64SurfaceType dst)65{66Object o = blitcache.get(src, comp, dst);67if (o != null) {68return (ScaledBlit) o;69}70ScaledBlit blit = locate(src, comp, dst);71if (blit == null) {72/*73System.out.println("blit loop not found for:");74System.out.println("src: "+src);75System.out.println("comp: "+comp);76System.out.println("dst: "+dst);77*/78} else {79blitcache.put(src, comp, dst, blit);80}81return blit;82}8384protected ScaledBlit(SurfaceType srctype,85CompositeType comptype,86SurfaceType dsttype)87{88super(methodSignature, primTypeID, srctype, comptype, dsttype);89}9091public ScaledBlit(long pNativePrim,92SurfaceType srctype,93CompositeType comptype,94SurfaceType dsttype)95{96super(pNativePrim, methodSignature, primTypeID,97srctype, comptype, dsttype);98}99100public native void Scale(SurfaceData src, SurfaceData dst,101Composite comp, Region clip,102int sx1, int sy1,103int sx2, int sy2,104double dx1, double dy1,105double dx2, double dy2);106107static {108GraphicsPrimitiveMgr.registerGeneral(new ScaledBlit(null, null, null));109}110111public GraphicsPrimitive makePrimitive(SurfaceType srctype,112CompositeType comptype,113SurfaceType dsttype)114{115/*116System.out.println("Constructing general blit for:");117System.out.println("src: "+srctype);118System.out.println("comp: "+comptype);119System.out.println("dst: "+dsttype);120*/121return null;122}123124public GraphicsPrimitive traceWrap() {125return new TraceScaledBlit(this);126}127128private static class TraceScaledBlit extends ScaledBlit {129ScaledBlit target;130131public TraceScaledBlit(ScaledBlit target) {132super(target.getSourceType(),133target.getCompositeType(),134target.getDestType());135this.target = target;136}137138public GraphicsPrimitive traceWrap() {139return this;140}141142public void Scale(SurfaceData src, SurfaceData dst,143Composite comp, Region clip,144int sx1, int sy1,145int sx2, int sy2,146double dx1, double dy1,147double dx2, double dy2)148{149tracePrimitive(target);150target.Scale(src, dst, comp, clip,151sx1, sy1, sx2, sy2,152dx1, dy1, dx2, dy2);153}154}155}156157158