Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/solaris/classes/sun/java2d/x11/X11PMBlitLoops.java
32288 views
/*1* Copyright (c) 2000, 2007, 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.x11;2627import sun.awt.SunToolkit;28import sun.java2d.loops.GraphicsPrimitive;29import sun.java2d.loops.GraphicsPrimitiveMgr;30import sun.java2d.loops.GraphicsPrimitiveProxy;31import sun.java2d.loops.CompositeType;32import sun.java2d.loops.SurfaceType;33import sun.java2d.loops.Blit;34import sun.java2d.loops.MaskBlit;35import sun.java2d.pipe.Region;36import sun.java2d.SurfaceData;37import java.awt.Composite;38import java.awt.image.IndexColorModel;3940/**41* X11PMBlitLoops42*43* This class accelerates Blits between two surfaces of types *PM. Since44* the onscreen surface is of that type and some of the offscreen surfaces45* may be of that type (if they were created via X11OffScreenImage), then46* this type of Blit will accelerated double-buffer copies between those47* two surfaces.48*/49public class X11PMBlitLoops extends Blit {5051public static void register()52{53GraphicsPrimitive[] primitives = {54new X11PMBlitLoops(X11SurfaceData.IntBgrX11,55X11SurfaceData.IntBgrX11, false),56new X11PMBlitLoops(X11SurfaceData.IntRgbX11,57X11SurfaceData.IntRgbX11, false),58new X11PMBlitLoops(X11SurfaceData.ThreeByteBgrX11,59X11SurfaceData.ThreeByteBgrX11, false),60new X11PMBlitLoops(X11SurfaceData.ThreeByteRgbX11,61X11SurfaceData.ThreeByteRgbX11, false),62new X11PMBlitLoops(X11SurfaceData.ByteIndexedOpaqueX11,63X11SurfaceData.ByteIndexedOpaqueX11, false),64new X11PMBlitLoops(X11SurfaceData.ByteGrayX11,65X11SurfaceData.ByteGrayX11, false),66new X11PMBlitLoops(X11SurfaceData.Index8GrayX11,67X11SurfaceData.Index8GrayX11, false),68new X11PMBlitLoops(X11SurfaceData.UShort555RgbX11,69X11SurfaceData.UShort555RgbX11, false),70new X11PMBlitLoops(X11SurfaceData.UShort565RgbX11,71X11SurfaceData.UShort565RgbX11, false),72new X11PMBlitLoops(X11SurfaceData.UShortIndexedX11,73X11SurfaceData.UShortIndexedX11, false),7475// 1-bit transparent to opaque loops76new X11PMBlitLoops(X11SurfaceData.IntBgrX11_BM,77X11SurfaceData.IntBgrX11, true),78new X11PMBlitLoops(X11SurfaceData.IntRgbX11_BM,79X11SurfaceData.IntRgbX11, true),80new X11PMBlitLoops(X11SurfaceData.ThreeByteBgrX11_BM,81X11SurfaceData.ThreeByteBgrX11, true),82new X11PMBlitLoops(X11SurfaceData.ThreeByteRgbX11_BM,83X11SurfaceData.ThreeByteRgbX11, true),84new X11PMBlitLoops(X11SurfaceData.ByteIndexedX11_BM,85X11SurfaceData.ByteIndexedOpaqueX11, true),86new X11PMBlitLoops(X11SurfaceData.ByteGrayX11_BM,87X11SurfaceData.ByteGrayX11, true),88new X11PMBlitLoops(X11SurfaceData.Index8GrayX11_BM,89X11SurfaceData.Index8GrayX11, true),90new X11PMBlitLoops(X11SurfaceData.UShort555RgbX11_BM,91X11SurfaceData.UShort555RgbX11, true),92new X11PMBlitLoops(X11SurfaceData.UShort565RgbX11_BM,93X11SurfaceData.UShort565RgbX11, true),94new X11PMBlitLoops(X11SurfaceData.UShortIndexedX11_BM,95X11SurfaceData.UShortIndexedX11, true),9697new X11PMBlitLoops(X11SurfaceData.IntRgbX11,98X11SurfaceData.IntArgbPreX11, true),99new X11PMBlitLoops(X11SurfaceData.IntRgbX11,100X11SurfaceData.IntArgbPreX11, false),101new X11PMBlitLoops(X11SurfaceData.IntRgbX11_BM,102X11SurfaceData.IntArgbPreX11, true),103104new X11PMBlitLoops(X11SurfaceData.IntBgrX11,105X11SurfaceData.FourByteAbgrPreX11, true),106new X11PMBlitLoops(X11SurfaceData.IntBgrX11,107X11SurfaceData.FourByteAbgrPreX11, false),108new X11PMBlitLoops(X11SurfaceData.IntBgrX11_BM,109X11SurfaceData.FourByteAbgrPreX11, true),110111112113// delegate loops114new DelegateBlitLoop(X11SurfaceData.IntBgrX11_BM,115X11SurfaceData.IntBgrX11),116new DelegateBlitLoop(X11SurfaceData.IntRgbX11_BM,117X11SurfaceData.IntRgbX11),118new DelegateBlitLoop(X11SurfaceData.ThreeByteBgrX11_BM,119X11SurfaceData.ThreeByteBgrX11),120new DelegateBlitLoop(X11SurfaceData.ThreeByteRgbX11_BM,121X11SurfaceData.ThreeByteRgbX11),122new DelegateBlitLoop(X11SurfaceData.ByteIndexedX11_BM,123X11SurfaceData.ByteIndexedOpaqueX11),124new DelegateBlitLoop(X11SurfaceData.ByteGrayX11_BM,125X11SurfaceData.ByteGrayX11),126new DelegateBlitLoop(X11SurfaceData.Index8GrayX11_BM,127X11SurfaceData.Index8GrayX11),128new DelegateBlitLoop(X11SurfaceData.UShort555RgbX11_BM,129X11SurfaceData.UShort555RgbX11),130new DelegateBlitLoop(X11SurfaceData.UShort565RgbX11_BM,131X11SurfaceData.UShort565RgbX11),132new DelegateBlitLoop(X11SurfaceData.UShortIndexedX11_BM,133X11SurfaceData.UShortIndexedX11),134135};136GraphicsPrimitiveMgr.register(primitives);137}138139public X11PMBlitLoops(SurfaceType srcType, SurfaceType dstType,140boolean over) {141super(srcType,142over ? CompositeType.SrcOverNoEa : CompositeType.SrcNoEa,143dstType);144}145146public void Blit(SurfaceData src, SurfaceData dst,147Composite comp, Region clip,148int sx, int sy,149int dx, int dy,150int w, int h)151{152SunToolkit.awtLock();153try {154X11SurfaceData x11sd = (X11SurfaceData)dst;155// pass null clip region here since we clip manually in native code156// also use false for needExposures since we clip to the pixmap157long xgc = x11sd.getBlitGC(null, false);158nativeBlit(src.getNativeOps(), dst.getNativeOps(), xgc, clip,159sx, sy, dx, dy, w, h);160} finally {161SunToolkit.awtUnlock();162}163}164165/**166* Blit167* This native method is where all of the work happens in the168* accelerated Blit.169*/170private native void nativeBlit(long srcData, long dstData,171long xgc, Region clip,172int sx, int sy, int dx, int dy,173int w, int h);174175/**176* This loop is used to render from a BITMASK Sw surface data177* to the Hw cached copies managed by SurfaceDataProxies.178* It first uses a delegate opaque Blit to perform the copy of179* the pixel data and then updates the X11 clipping bitmask from180* the transparent pixels in the source.181*/182static class DelegateBlitLoop extends Blit {183SurfaceType dstType;184185/**186* @param realDstType SurfaceType for which the loop should be187* registered188* @param delegateDstType SurfaceType which will be used189* for finding delegate loop190*/191public DelegateBlitLoop(SurfaceType realDstType, SurfaceType delegateDstType) {192super(SurfaceType.Any, CompositeType.SrcNoEa, realDstType);193this.dstType = delegateDstType;194}195196public void Blit(SurfaceData src, SurfaceData dst,197Composite comp, Region clip,198int sx, int sy, int dx, int dy, int w, int h)199{200Blit blit = Blit.getFromCache(src.getSurfaceType(),201CompositeType.SrcNoEa,202dstType);203blit.Blit(src, dst, comp, clip, sx, sy, dx, dy, w, h);204updateBitmask(src, dst,205src.getColorModel() instanceof IndexColorModel);206}207}208209private static native void updateBitmask(SurfaceData src,210SurfaceData dst,211boolean isICM);212}213214215