0N/A/*
2362N/A * Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage sun.java2d.x11;
0N/A
0N/Aimport sun.awt.SunToolkit;
0N/Aimport sun.java2d.loops.GraphicsPrimitive;
0N/Aimport sun.java2d.loops.GraphicsPrimitiveMgr;
0N/Aimport sun.java2d.loops.GraphicsPrimitiveProxy;
0N/Aimport sun.java2d.loops.CompositeType;
0N/Aimport sun.java2d.loops.SurfaceType;
0N/Aimport sun.java2d.loops.Blit;
0N/Aimport sun.java2d.loops.MaskBlit;
0N/Aimport sun.java2d.pipe.Region;
0N/Aimport sun.java2d.SurfaceData;
0N/Aimport java.awt.Composite;
0N/Aimport java.awt.image.IndexColorModel;
0N/A
0N/A/**
0N/A * X11PMBlitLoops
0N/A *
0N/A * This class accelerates Blits between two surfaces of types *PM. Since
0N/A * the onscreen surface is of that type and some of the offscreen surfaces
0N/A * may be of that type (if they were created via X11OffScreenImage), then
0N/A * this type of Blit will accelerated double-buffer copies between those
0N/A * two surfaces.
0N/A*/
0N/Apublic class X11PMBlitLoops extends Blit {
0N/A
0N/A public static void register()
0N/A {
0N/A GraphicsPrimitive[] primitives = {
0N/A new X11PMBlitLoops(X11SurfaceData.IntBgrX11,
0N/A X11SurfaceData.IntBgrX11, false),
0N/A new X11PMBlitLoops(X11SurfaceData.IntRgbX11,
0N/A X11SurfaceData.IntRgbX11, false),
0N/A new X11PMBlitLoops(X11SurfaceData.ThreeByteBgrX11,
0N/A X11SurfaceData.ThreeByteBgrX11, false),
0N/A new X11PMBlitLoops(X11SurfaceData.ThreeByteRgbX11,
0N/A X11SurfaceData.ThreeByteRgbX11, false),
0N/A new X11PMBlitLoops(X11SurfaceData.ByteIndexedOpaqueX11,
0N/A X11SurfaceData.ByteIndexedOpaqueX11, false),
0N/A new X11PMBlitLoops(X11SurfaceData.ByteGrayX11,
0N/A X11SurfaceData.ByteGrayX11, false),
0N/A new X11PMBlitLoops(X11SurfaceData.Index8GrayX11,
0N/A X11SurfaceData.Index8GrayX11, false),
0N/A new X11PMBlitLoops(X11SurfaceData.UShort555RgbX11,
0N/A X11SurfaceData.UShort555RgbX11, false),
0N/A new X11PMBlitLoops(X11SurfaceData.UShort565RgbX11,
0N/A X11SurfaceData.UShort565RgbX11, false),
0N/A new X11PMBlitLoops(X11SurfaceData.UShortIndexedX11,
0N/A X11SurfaceData.UShortIndexedX11, false),
0N/A
0N/A // 1-bit transparent to opaque loops
0N/A new X11PMBlitLoops(X11SurfaceData.IntBgrX11_BM,
0N/A X11SurfaceData.IntBgrX11, true),
0N/A new X11PMBlitLoops(X11SurfaceData.IntRgbX11_BM,
0N/A X11SurfaceData.IntRgbX11, true),
0N/A new X11PMBlitLoops(X11SurfaceData.ThreeByteBgrX11_BM,
0N/A X11SurfaceData.ThreeByteBgrX11, true),
0N/A new X11PMBlitLoops(X11SurfaceData.ThreeByteRgbX11_BM,
0N/A X11SurfaceData.ThreeByteRgbX11, true),
0N/A new X11PMBlitLoops(X11SurfaceData.ByteIndexedX11_BM,
0N/A X11SurfaceData.ByteIndexedOpaqueX11, true),
0N/A new X11PMBlitLoops(X11SurfaceData.ByteGrayX11_BM,
0N/A X11SurfaceData.ByteGrayX11, true),
0N/A new X11PMBlitLoops(X11SurfaceData.Index8GrayX11_BM,
0N/A X11SurfaceData.Index8GrayX11, true),
0N/A new X11PMBlitLoops(X11SurfaceData.UShort555RgbX11_BM,
0N/A X11SurfaceData.UShort555RgbX11, true),
0N/A new X11PMBlitLoops(X11SurfaceData.UShort565RgbX11_BM,
0N/A X11SurfaceData.UShort565RgbX11, true),
0N/A new X11PMBlitLoops(X11SurfaceData.UShortIndexedX11_BM,
0N/A X11SurfaceData.UShortIndexedX11, true),
0N/A
1221N/A new X11PMBlitLoops(X11SurfaceData.IntRgbX11,
1221N/A X11SurfaceData.IntArgbPreX11, true),
1221N/A new X11PMBlitLoops(X11SurfaceData.IntRgbX11,
1221N/A X11SurfaceData.IntArgbPreX11, false),
1221N/A new X11PMBlitLoops(X11SurfaceData.IntRgbX11_BM,
1221N/A X11SurfaceData.IntArgbPreX11, true),
1221N/A
1221N/A new X11PMBlitLoops(X11SurfaceData.IntBgrX11,
1221N/A X11SurfaceData.FourByteAbgrPreX11, true),
1221N/A new X11PMBlitLoops(X11SurfaceData.IntBgrX11,
1221N/A X11SurfaceData.FourByteAbgrPreX11, false),
1221N/A new X11PMBlitLoops(X11SurfaceData.IntBgrX11_BM,
1221N/A X11SurfaceData.FourByteAbgrPreX11, true),
1221N/A
1221N/A
1221N/A
0N/A // delegate loops
0N/A new DelegateBlitLoop(X11SurfaceData.IntBgrX11_BM,
0N/A X11SurfaceData.IntBgrX11),
0N/A new DelegateBlitLoop(X11SurfaceData.IntRgbX11_BM,
0N/A X11SurfaceData.IntRgbX11),
0N/A new DelegateBlitLoop(X11SurfaceData.ThreeByteBgrX11_BM,
0N/A X11SurfaceData.ThreeByteBgrX11),
0N/A new DelegateBlitLoop(X11SurfaceData.ThreeByteRgbX11_BM,
0N/A X11SurfaceData.ThreeByteRgbX11),
0N/A new DelegateBlitLoop(X11SurfaceData.ByteIndexedX11_BM,
0N/A X11SurfaceData.ByteIndexedOpaqueX11),
0N/A new DelegateBlitLoop(X11SurfaceData.ByteGrayX11_BM,
0N/A X11SurfaceData.ByteGrayX11),
0N/A new DelegateBlitLoop(X11SurfaceData.Index8GrayX11_BM,
0N/A X11SurfaceData.Index8GrayX11),
0N/A new DelegateBlitLoop(X11SurfaceData.UShort555RgbX11_BM,
0N/A X11SurfaceData.UShort555RgbX11),
0N/A new DelegateBlitLoop(X11SurfaceData.UShort565RgbX11_BM,
0N/A X11SurfaceData.UShort565RgbX11),
0N/A new DelegateBlitLoop(X11SurfaceData.UShortIndexedX11_BM,
0N/A X11SurfaceData.UShortIndexedX11),
0N/A
0N/A };
0N/A GraphicsPrimitiveMgr.register(primitives);
0N/A }
0N/A
0N/A public X11PMBlitLoops(SurfaceType srcType, SurfaceType dstType,
0N/A boolean over) {
0N/A super(srcType,
0N/A over ? CompositeType.SrcOverNoEa : CompositeType.SrcNoEa,
0N/A dstType);
0N/A }
0N/A
0N/A public void Blit(SurfaceData src, SurfaceData dst,
0N/A Composite comp, Region clip,
0N/A int sx, int sy,
0N/A int dx, int dy,
0N/A int w, int h)
0N/A {
0N/A SunToolkit.awtLock();
0N/A try {
0N/A X11SurfaceData x11sd = (X11SurfaceData)dst;
0N/A // pass null clip region here since we clip manually in native code
0N/A // also use false for needExposures since we clip to the pixmap
0N/A long xgc = x11sd.getBlitGC(null, false);
0N/A nativeBlit(src.getNativeOps(), dst.getNativeOps(), xgc, clip,
0N/A sx, sy, dx, dy, w, h);
0N/A } finally {
0N/A SunToolkit.awtUnlock();
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Blit
0N/A * This native method is where all of the work happens in the
0N/A * accelerated Blit.
0N/A */
0N/A private native void nativeBlit(long srcData, long dstData,
0N/A long xgc, Region clip,
0N/A int sx, int sy, int dx, int dy,
0N/A int w, int h);
0N/A
0N/A /**
0N/A * This loop is used to render from a BITMASK Sw surface data
0N/A * to the Hw cached copies managed by SurfaceDataProxies.
0N/A * It first uses a delegate opaque Blit to perform the copy of
0N/A * the pixel data and then updates the X11 clipping bitmask from
0N/A * the transparent pixels in the source.
0N/A */
0N/A static class DelegateBlitLoop extends Blit {
0N/A SurfaceType dstType;
0N/A
0N/A /**
0N/A * @param realDstType SurfaceType for which the loop should be
0N/A * registered
0N/A * @param delegateDstType SurfaceType which will be used
0N/A * for finding delegate loop
0N/A */
0N/A public DelegateBlitLoop(SurfaceType realDstType, SurfaceType delegateDstType) {
0N/A super(SurfaceType.Any, CompositeType.SrcNoEa, realDstType);
0N/A this.dstType = delegateDstType;
0N/A }
0N/A
0N/A public void Blit(SurfaceData src, SurfaceData dst,
0N/A Composite comp, Region clip,
0N/A int sx, int sy, int dx, int dy, int w, int h)
0N/A {
0N/A Blit blit = Blit.getFromCache(src.getSurfaceType(),
0N/A CompositeType.SrcNoEa,
0N/A dstType);
0N/A blit.Blit(src, dst, comp, clip, sx, sy, dx, dy, w, h);
0N/A updateBitmask(src, dst,
0N/A src.getColorModel() instanceof IndexColorModel);
0N/A }
0N/A }
0N/A
0N/A private static native void updateBitmask(SurfaceData src,
0N/A SurfaceData dst,
0N/A boolean isICM);
0N/A}