Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/solaris/classes/sun/java2d/x11/X11PMBlitLoops.java
32288 views
1
/*
2
* Copyright (c) 2000, 2007, Oracle and/or its affiliates. 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. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* 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.GraphicsPrimitiveProxy;
32
import sun.java2d.loops.CompositeType;
33
import sun.java2d.loops.SurfaceType;
34
import sun.java2d.loops.Blit;
35
import sun.java2d.loops.MaskBlit;
36
import sun.java2d.pipe.Region;
37
import sun.java2d.SurfaceData;
38
import java.awt.Composite;
39
import java.awt.image.IndexColorModel;
40
41
/**
42
* X11PMBlitLoops
43
*
44
* This class accelerates Blits between two surfaces of types *PM. Since
45
* the onscreen surface is of that type and some of the offscreen surfaces
46
* may be of that type (if they were created via X11OffScreenImage), then
47
* this type of Blit will accelerated double-buffer copies between those
48
* two surfaces.
49
*/
50
public class X11PMBlitLoops extends Blit {
51
52
public static void register()
53
{
54
GraphicsPrimitive[] primitives = {
55
new X11PMBlitLoops(X11SurfaceData.IntBgrX11,
56
X11SurfaceData.IntBgrX11, false),
57
new X11PMBlitLoops(X11SurfaceData.IntRgbX11,
58
X11SurfaceData.IntRgbX11, false),
59
new X11PMBlitLoops(X11SurfaceData.ThreeByteBgrX11,
60
X11SurfaceData.ThreeByteBgrX11, false),
61
new X11PMBlitLoops(X11SurfaceData.ThreeByteRgbX11,
62
X11SurfaceData.ThreeByteRgbX11, false),
63
new X11PMBlitLoops(X11SurfaceData.ByteIndexedOpaqueX11,
64
X11SurfaceData.ByteIndexedOpaqueX11, false),
65
new X11PMBlitLoops(X11SurfaceData.ByteGrayX11,
66
X11SurfaceData.ByteGrayX11, false),
67
new X11PMBlitLoops(X11SurfaceData.Index8GrayX11,
68
X11SurfaceData.Index8GrayX11, false),
69
new X11PMBlitLoops(X11SurfaceData.UShort555RgbX11,
70
X11SurfaceData.UShort555RgbX11, false),
71
new X11PMBlitLoops(X11SurfaceData.UShort565RgbX11,
72
X11SurfaceData.UShort565RgbX11, false),
73
new X11PMBlitLoops(X11SurfaceData.UShortIndexedX11,
74
X11SurfaceData.UShortIndexedX11, false),
75
76
// 1-bit transparent to opaque loops
77
new X11PMBlitLoops(X11SurfaceData.IntBgrX11_BM,
78
X11SurfaceData.IntBgrX11, true),
79
new X11PMBlitLoops(X11SurfaceData.IntRgbX11_BM,
80
X11SurfaceData.IntRgbX11, true),
81
new X11PMBlitLoops(X11SurfaceData.ThreeByteBgrX11_BM,
82
X11SurfaceData.ThreeByteBgrX11, true),
83
new X11PMBlitLoops(X11SurfaceData.ThreeByteRgbX11_BM,
84
X11SurfaceData.ThreeByteRgbX11, true),
85
new X11PMBlitLoops(X11SurfaceData.ByteIndexedX11_BM,
86
X11SurfaceData.ByteIndexedOpaqueX11, true),
87
new X11PMBlitLoops(X11SurfaceData.ByteGrayX11_BM,
88
X11SurfaceData.ByteGrayX11, true),
89
new X11PMBlitLoops(X11SurfaceData.Index8GrayX11_BM,
90
X11SurfaceData.Index8GrayX11, true),
91
new X11PMBlitLoops(X11SurfaceData.UShort555RgbX11_BM,
92
X11SurfaceData.UShort555RgbX11, true),
93
new X11PMBlitLoops(X11SurfaceData.UShort565RgbX11_BM,
94
X11SurfaceData.UShort565RgbX11, true),
95
new X11PMBlitLoops(X11SurfaceData.UShortIndexedX11_BM,
96
X11SurfaceData.UShortIndexedX11, true),
97
98
new X11PMBlitLoops(X11SurfaceData.IntRgbX11,
99
X11SurfaceData.IntArgbPreX11, true),
100
new X11PMBlitLoops(X11SurfaceData.IntRgbX11,
101
X11SurfaceData.IntArgbPreX11, false),
102
new X11PMBlitLoops(X11SurfaceData.IntRgbX11_BM,
103
X11SurfaceData.IntArgbPreX11, true),
104
105
new X11PMBlitLoops(X11SurfaceData.IntBgrX11,
106
X11SurfaceData.FourByteAbgrPreX11, true),
107
new X11PMBlitLoops(X11SurfaceData.IntBgrX11,
108
X11SurfaceData.FourByteAbgrPreX11, false),
109
new X11PMBlitLoops(X11SurfaceData.IntBgrX11_BM,
110
X11SurfaceData.FourByteAbgrPreX11, true),
111
112
113
114
// delegate loops
115
new DelegateBlitLoop(X11SurfaceData.IntBgrX11_BM,
116
X11SurfaceData.IntBgrX11),
117
new DelegateBlitLoop(X11SurfaceData.IntRgbX11_BM,
118
X11SurfaceData.IntRgbX11),
119
new DelegateBlitLoop(X11SurfaceData.ThreeByteBgrX11_BM,
120
X11SurfaceData.ThreeByteBgrX11),
121
new DelegateBlitLoop(X11SurfaceData.ThreeByteRgbX11_BM,
122
X11SurfaceData.ThreeByteRgbX11),
123
new DelegateBlitLoop(X11SurfaceData.ByteIndexedX11_BM,
124
X11SurfaceData.ByteIndexedOpaqueX11),
125
new DelegateBlitLoop(X11SurfaceData.ByteGrayX11_BM,
126
X11SurfaceData.ByteGrayX11),
127
new DelegateBlitLoop(X11SurfaceData.Index8GrayX11_BM,
128
X11SurfaceData.Index8GrayX11),
129
new DelegateBlitLoop(X11SurfaceData.UShort555RgbX11_BM,
130
X11SurfaceData.UShort555RgbX11),
131
new DelegateBlitLoop(X11SurfaceData.UShort565RgbX11_BM,
132
X11SurfaceData.UShort565RgbX11),
133
new DelegateBlitLoop(X11SurfaceData.UShortIndexedX11_BM,
134
X11SurfaceData.UShortIndexedX11),
135
136
};
137
GraphicsPrimitiveMgr.register(primitives);
138
}
139
140
public X11PMBlitLoops(SurfaceType srcType, SurfaceType dstType,
141
boolean over) {
142
super(srcType,
143
over ? CompositeType.SrcOverNoEa : CompositeType.SrcNoEa,
144
dstType);
145
}
146
147
public void Blit(SurfaceData src, SurfaceData dst,
148
Composite comp, Region clip,
149
int sx, int sy,
150
int dx, int dy,
151
int w, int h)
152
{
153
SunToolkit.awtLock();
154
try {
155
X11SurfaceData x11sd = (X11SurfaceData)dst;
156
// pass null clip region here since we clip manually in native code
157
// also use false for needExposures since we clip to the pixmap
158
long xgc = x11sd.getBlitGC(null, false);
159
nativeBlit(src.getNativeOps(), dst.getNativeOps(), xgc, clip,
160
sx, sy, dx, dy, w, h);
161
} finally {
162
SunToolkit.awtUnlock();
163
}
164
}
165
166
/**
167
* Blit
168
* This native method is where all of the work happens in the
169
* accelerated Blit.
170
*/
171
private native void nativeBlit(long srcData, long dstData,
172
long xgc, Region clip,
173
int sx, int sy, int dx, int dy,
174
int w, int h);
175
176
/**
177
* This loop is used to render from a BITMASK Sw surface data
178
* to the Hw cached copies managed by SurfaceDataProxies.
179
* It first uses a delegate opaque Blit to perform the copy of
180
* the pixel data and then updates the X11 clipping bitmask from
181
* the transparent pixels in the source.
182
*/
183
static class DelegateBlitLoop extends Blit {
184
SurfaceType dstType;
185
186
/**
187
* @param realDstType SurfaceType for which the loop should be
188
* registered
189
* @param delegateDstType SurfaceType which will be used
190
* for finding delegate loop
191
*/
192
public DelegateBlitLoop(SurfaceType realDstType, SurfaceType delegateDstType) {
193
super(SurfaceType.Any, CompositeType.SrcNoEa, realDstType);
194
this.dstType = delegateDstType;
195
}
196
197
public void Blit(SurfaceData src, SurfaceData dst,
198
Composite comp, Region clip,
199
int sx, int sy, int dx, int dy, int w, int h)
200
{
201
Blit blit = Blit.getFromCache(src.getSurfaceType(),
202
CompositeType.SrcNoEa,
203
dstType);
204
blit.Blit(src, dst, comp, clip, sx, sy, dx, dy, w, h);
205
updateBitmask(src, dst,
206
src.getColorModel() instanceof IndexColorModel);
207
}
208
}
209
210
private static native void updateBitmask(SurfaceData src,
211
SurfaceData dst,
212
boolean isICM);
213
}
214
215