blob: 6974ad763b5794d32c040fefc48869a1a6fee808 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
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
26package sun.java2d.x11;
27
28import sun.awt.SunToolkit;
29import sun.java2d.loops.GraphicsPrimitive;
30import sun.java2d.loops.GraphicsPrimitiveMgr;
31import sun.java2d.loops.CompositeType;
32import sun.java2d.loops.SurfaceType;
33import sun.java2d.loops.BlitBg;
34import sun.java2d.SurfaceData;
35import sun.java2d.pipe.Region;
36import java.awt.Color;
37import 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*/
48public 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}