J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2001-2006 Sun Microsystems, Inc. All Rights Reserved. |
| 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License version 2 only, as |
| 7 | * published by the Free Software Foundation. Sun designates this |
| 8 | * particular file as subject to the "Classpath" exception as provided |
| 9 | * by Sun in the LICENSE file that accompanied this code. |
| 10 | * |
| 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
| 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 14 | * version 2 for more details (a copy is included in the LICENSE file that |
| 15 | * accompanied this code). |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License version |
| 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
| 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | * |
| 21 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 22 | * CA 95054 USA or visit www.sun.com if you need additional information or |
| 23 | * have any questions. |
| 24 | */ |
| 25 | |
| 26 | package sun.java2d.x11; |
| 27 | |
| 28 | import sun.awt.SunToolkit; |
| 29 | import sun.java2d.loops.GraphicsPrimitive; |
| 30 | import sun.java2d.loops.GraphicsPrimitiveMgr; |
| 31 | import sun.java2d.loops.CompositeType; |
| 32 | import sun.java2d.loops.SurfaceType; |
| 33 | import sun.java2d.loops.BlitBg; |
| 34 | import sun.java2d.SurfaceData; |
| 35 | import sun.java2d.pipe.Region; |
| 36 | import java.awt.Color; |
| 37 | import java.awt.Composite; |
| 38 | |
| 39 | /** |
| 40 | * X11PMBlitBgLoops |
| 41 | * |
| 42 | * This class accelerates Blits between two surfaces of types *PM. Since |
| 43 | * the onscreen surface is of that type and some of the offscreen surfaces |
| 44 | * may be of that type (if they were created via X11OffScreenImage), then |
| 45 | * this type of BlitBg will accelerated double-buffer copies between those |
| 46 | * two surfaces. |
| 47 | */ |
| 48 | public class X11PMBlitBgLoops extends BlitBg { |
| 49 | |
| 50 | public static void register() |
| 51 | { |
| 52 | GraphicsPrimitive[] primitives = { |
| 53 | new X11PMBlitBgLoops(X11SurfaceData.IntBgrX11_BM, |
| 54 | X11SurfaceData.IntBgrX11), |
| 55 | new X11PMBlitBgLoops(X11SurfaceData.IntRgbX11_BM, |
| 56 | X11SurfaceData.IntRgbX11), |
| 57 | new X11PMBlitBgLoops(X11SurfaceData.ThreeByteBgrX11_BM, |
| 58 | X11SurfaceData.ThreeByteBgrX11), |
| 59 | new X11PMBlitBgLoops(X11SurfaceData.ThreeByteRgbX11_BM, |
| 60 | X11SurfaceData.ThreeByteRgbX11), |
| 61 | new X11PMBlitBgLoops(X11SurfaceData.ByteIndexedX11_BM, |
| 62 | X11SurfaceData.ByteIndexedOpaqueX11), |
| 63 | new X11PMBlitBgLoops(X11SurfaceData.ByteGrayX11_BM, |
| 64 | X11SurfaceData.ByteGrayX11), |
| 65 | new X11PMBlitBgLoops(X11SurfaceData.Index8GrayX11_BM, |
| 66 | X11SurfaceData.Index8GrayX11), |
| 67 | new X11PMBlitBgLoops(X11SurfaceData.UShort555RgbX11_BM, |
| 68 | X11SurfaceData.UShort555RgbX11), |
| 69 | new X11PMBlitBgLoops(X11SurfaceData.UShort565RgbX11_BM, |
| 70 | X11SurfaceData.UShort565RgbX11), |
| 71 | new X11PMBlitBgLoops(X11SurfaceData.UShortIndexedX11_BM, |
| 72 | X11SurfaceData.UShortIndexedX11), |
| 73 | }; |
| 74 | GraphicsPrimitiveMgr.register(primitives); |
| 75 | } |
| 76 | |
| 77 | public X11PMBlitBgLoops(SurfaceType srcType, SurfaceType dstType) |
| 78 | { |
| 79 | super(srcType, CompositeType.SrcNoEa, dstType); |
| 80 | } |
| 81 | |
| 82 | public void BlitBg(SurfaceData src, SurfaceData dst, |
| 83 | Composite comp, Region clip, Color bgColor, |
| 84 | int sx, int sy, |
| 85 | int dx, int dy, |
| 86 | int w, int h) |
| 87 | { |
| 88 | SunToolkit.awtLock(); |
| 89 | try { |
| 90 | int pixel = dst.pixelFor(bgColor.getRGB()); |
| 91 | X11SurfaceData x11sd = (X11SurfaceData)dst; |
| 92 | // use false for needExposures since we clip to the pixmap |
| 93 | long xgc = x11sd.getBlitGC(clip, false); |
| 94 | nativeBlitBg(src.getNativeOps(), dst.getNativeOps(), |
| 95 | xgc, pixel, |
| 96 | sx, sy, dx, dy, w, h); |
| 97 | } finally { |
| 98 | SunToolkit.awtUnlock(); |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * This native method is where all of the work happens in the |
| 104 | * accelerated Blit. |
| 105 | */ |
| 106 | private native void nativeBlitBg(long srcData, long dstData, |
| 107 | long xgc, int pixel, |
| 108 | int sx, int sy, |
| 109 | int dx, int dy, |
| 110 | int w, int h); |
| 111 | } |