Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/solaris/classes/sun/java2d/x11/X11PMBlitBgLoops.java
32288 views
/*1* Copyright (c) 2001, 2008, 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.CompositeType;31import sun.java2d.loops.SurfaceType;32import sun.java2d.loops.BlitBg;33import sun.java2d.SurfaceData;34import sun.java2d.pipe.Region;35import java.awt.Color;36import java.awt.Composite;3738/**39* X11PMBlitBgLoops40*41* This class accelerates Blits between two surfaces of types *PM. Since42* the onscreen surface is of that type and some of the offscreen surfaces43* may be of that type (if they were created via X11OffScreenImage), then44* this type of BlitBg will accelerated double-buffer copies between those45* two surfaces.46*/47public class X11PMBlitBgLoops extends BlitBg {4849public static void register()50{51GraphicsPrimitive[] primitives = {52new X11PMBlitBgLoops(X11SurfaceData.IntBgrX11_BM,53X11SurfaceData.IntBgrX11),54new X11PMBlitBgLoops(X11SurfaceData.IntRgbX11_BM,55X11SurfaceData.IntRgbX11),56new X11PMBlitBgLoops(X11SurfaceData.ThreeByteBgrX11_BM,57X11SurfaceData.ThreeByteBgrX11),58new X11PMBlitBgLoops(X11SurfaceData.ThreeByteRgbX11_BM,59X11SurfaceData.ThreeByteRgbX11),60new X11PMBlitBgLoops(X11SurfaceData.ByteIndexedX11_BM,61X11SurfaceData.ByteIndexedOpaqueX11),62new X11PMBlitBgLoops(X11SurfaceData.ByteGrayX11_BM,63X11SurfaceData.ByteGrayX11),64new X11PMBlitBgLoops(X11SurfaceData.Index8GrayX11_BM,65X11SurfaceData.Index8GrayX11),66new X11PMBlitBgLoops(X11SurfaceData.UShort555RgbX11_BM,67X11SurfaceData.UShort555RgbX11),68new X11PMBlitBgLoops(X11SurfaceData.UShort565RgbX11_BM,69X11SurfaceData.UShort565RgbX11),70new X11PMBlitBgLoops(X11SurfaceData.UShortIndexedX11_BM,71X11SurfaceData.UShortIndexedX11),72new X11PMBlitBgLoops(X11SurfaceData.IntRgbX11_BM,73X11SurfaceData.IntArgbPreX11),74new X11PMBlitBgLoops(X11SurfaceData.IntBgrX11_BM,75X11SurfaceData.FourByteAbgrPreX11),76};77GraphicsPrimitiveMgr.register(primitives);78}7980public X11PMBlitBgLoops(SurfaceType srcType, SurfaceType dstType)81{82super(srcType, CompositeType.SrcNoEa, dstType);83}8485@Override86public void BlitBg(SurfaceData src, SurfaceData dst,87Composite comp, Region clip, int bgColor,88int sx, int sy,89int dx, int dy,90int w, int h)91{92SunToolkit.awtLock();93try {94int pixel = dst.pixelFor(bgColor);95X11SurfaceData x11sd = (X11SurfaceData)dst;96// use false for needExposures since we clip to the pixmap97long xgc = x11sd.getBlitGC(clip, false);98nativeBlitBg(src.getNativeOps(), dst.getNativeOps(),99xgc, pixel,100sx, sy, dx, dy, w, h);101} finally {102SunToolkit.awtUnlock();103}104}105106/**107* This native method is where all of the work happens in the108* accelerated Blit.109*/110private native void nativeBlitBg(long srcData, long dstData,111long xgc, int pixel,112int sx, int sy,113int dx, int dy,114int w, int h);115}116117118