-
Notifications
You must be signed in to change notification settings - Fork 259
Expand file tree
/
Copy pathCGLTextureWrapperSurfaceData.java
More file actions
50 lines (40 loc) · 1.33 KB
/
CGLTextureWrapperSurfaceData.java
File metadata and controls
50 lines (40 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package sun.java2d.opengl;
import sun.java2d.SurfaceData;
import java.awt.*;
import java.awt.image.ColorModel;
import java.util.concurrent.atomic.AtomicBoolean;
public class CGLTextureWrapperSurfaceData extends CGLSurfaceData {
public CGLTextureWrapperSurfaceData(CGLGraphicsConfig gc, Image image, long textureId) {
super(null, gc, gc.getColorModel(TRANSLUCENT), RT_TEXTURE, 0, 0);
OGLRenderQueue rq = OGLRenderQueue.getInstance();
AtomicBoolean success = new AtomicBoolean(false);
rq.lock();
try {
OGLContext.setScratchSurface(gc);
rq.flushAndInvokeNow(() -> success.set(OGLSurfaceDataExt.initWithTexture(this, textureId)));
} finally {
rq.unlock();
}
if (!success.get()) {
throw new IllegalArgumentException("Failed to init the surface data");
}
}
@Override
public SurfaceData getReplacement() {
throw new UnsupportedOperationException();
}
@Override
public Rectangle getBounds() {
return getNativeBounds();
}
@Override
public Object getDestination() {
return null;
}
@Override
public void flush() {
// reset the texture id first to avoid the texture deallocation
OGLSurfaceDataExt.resetTextureId(this);
super.flush();
}
}