001: /*
002: * Copyright 2001-2006 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package sun.java2d.x11;
027:
028: import sun.awt.SunToolkit;
029: import sun.java2d.loops.GraphicsPrimitive;
030: import sun.java2d.loops.GraphicsPrimitiveMgr;
031: import sun.java2d.loops.CompositeType;
032: import sun.java2d.loops.SurfaceType;
033: import sun.java2d.loops.BlitBg;
034: import sun.java2d.SurfaceData;
035: import sun.java2d.pipe.Region;
036: import java.awt.Color;
037: import java.awt.Composite;
038:
039: /**
040: * X11PMBlitBgLoops
041: *
042: * This class accelerates Blits between two surfaces of types *PM. Since
043: * the onscreen surface is of that type and some of the offscreen surfaces
044: * may be of that type (if they were created via X11OffScreenImage), then
045: * this type of BlitBg will accelerated double-buffer copies between those
046: * two surfaces.
047: */
048: public class X11PMBlitBgLoops extends BlitBg {
049:
050: public static void register() {
051: GraphicsPrimitive[] primitives = {
052: new X11PMBlitBgLoops(X11SurfaceData.IntBgrX11_BM,
053: X11SurfaceData.IntBgrX11),
054: new X11PMBlitBgLoops(X11SurfaceData.IntRgbX11_BM,
055: X11SurfaceData.IntRgbX11),
056: new X11PMBlitBgLoops(X11SurfaceData.ThreeByteBgrX11_BM,
057: X11SurfaceData.ThreeByteBgrX11),
058: new X11PMBlitBgLoops(X11SurfaceData.ThreeByteRgbX11_BM,
059: X11SurfaceData.ThreeByteRgbX11),
060: new X11PMBlitBgLoops(X11SurfaceData.ByteIndexedX11_BM,
061: X11SurfaceData.ByteIndexedOpaqueX11),
062: new X11PMBlitBgLoops(X11SurfaceData.ByteGrayX11_BM,
063: X11SurfaceData.ByteGrayX11),
064: new X11PMBlitBgLoops(X11SurfaceData.Index8GrayX11_BM,
065: X11SurfaceData.Index8GrayX11),
066: new X11PMBlitBgLoops(X11SurfaceData.UShort555RgbX11_BM,
067: X11SurfaceData.UShort555RgbX11),
068: new X11PMBlitBgLoops(X11SurfaceData.UShort565RgbX11_BM,
069: X11SurfaceData.UShort565RgbX11),
070: new X11PMBlitBgLoops(
071: X11SurfaceData.UShortIndexedX11_BM,
072: X11SurfaceData.UShortIndexedX11), };
073: GraphicsPrimitiveMgr.register(primitives);
074: }
075:
076: public X11PMBlitBgLoops(SurfaceType srcType, SurfaceType dstType) {
077: super (srcType, CompositeType.SrcNoEa, dstType);
078: }
079:
080: public void BlitBg(SurfaceData src, SurfaceData dst,
081: Composite comp, Region clip, Color bgColor, int sx, int sy,
082: int dx, int dy, int w, int h) {
083: SunToolkit.awtLock();
084: try {
085: int pixel = dst.pixelFor(bgColor.getRGB());
086: X11SurfaceData x11sd = (X11SurfaceData) dst;
087: // use false for needExposures since we clip to the pixmap
088: long xgc = x11sd.getBlitGC(clip, false);
089: nativeBlitBg(src.getNativeOps(), dst.getNativeOps(), xgc,
090: pixel, sx, sy, dx, dy, w, h);
091: } finally {
092: SunToolkit.awtUnlock();
093: }
094: }
095:
096: /**
097: * This native method is where all of the work happens in the
098: * accelerated Blit.
099: */
100: private native void nativeBlitBg(long srcData, long dstData,
101: long xgc, int pixel, int sx, int sy, int dx, int dy, int w,
102: int h);
103: }
|