summaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-12-06 21:12:18 +0100
committerSven Gothel <[email protected]>2014-12-06 21:12:18 +0100
commita53e87a84c92444e8a3173f25ce86dcfd536d6a8 (patch)
treebd19e9f40e4c67203d579c28b3775a5c17adc106 /src/nativewindow/classes/jogamp
parent241d505749b7d2bd383673a378fdca268989d2fd (diff)
Bug 1107 - Refine PixelFormat, GLPixelBuffer and DirectDataBufferInt/BufferedImageInt
- PixelFormat Refine definition allowing complete format conversion by its attributes instead of static 'knowledge'. - PixelFormat has_a *new* PixelFormat.Composition - PixelFormat.Composition contains all pixel component layout information as required for inspection and conversion. Component names are enumerated via PixelFormat.CType. - PixelFormatUtil.convert(..) utilizes generic conversion based on PixelFormat.Composition rather static type mapping. However, a int32 RGBA static conversion is still supported for performance. Utilizes Bitstream for varying pixel component bit-width. - Complete w/ hashCode() and equals(..) - GLPixelBuffer - Take 'pack' mode into account when determine GLPixelAttributes, i.e. on GLES pack=true (e.g. glReadPixel) only RGBA is guaranteed to work. Hence querying GLPixelAttributes requires the GLProfile, PixelFormat and pack mode. - Complete GLPixelAttributes conversions from PixelFormat or GL format/data-type, while taking GL data-type into account, as well as pack-mode. - Complete w/ hashCode() and equals(..) - SingletonGLPixelBufferProvider queries singleton GLPixelBuffer via - PixelFormat.Composition hostPixelComp, - GLPixelAttributes pixelAttributes, - boolean pack which comprise a unique key, allowing the implementation to utilize a hash map. This is implemented in AWTSingletonGLPixelBufferProvider. This allows distinct singleton GLPixelBuffer for different host PixelFormat (conversion) and GLPixelAttributes (depending on GLProfile). - Removes field 'componentCount' which was 'hacked in' to pass information about an optional host memory layout. Implementations utilizing conversion, e.g. AWTGLPixelBuffer, can implement GLPixelBufferProvider's 'PixelFormat.Composition getHostPixelComp(final GLProfile glp, final int componentCount)' and manage such implementation details, see use-case GLJPanel. - DirectDataBufferInt/BufferedImageInt: Expose underlying NIO ByteBuffer - AWTMisc.createCursor(..) uses DirectDataBufferInt.BufferedImageInt exposed NIO ByteBuffer, allowing to use generic PixelFormatUtil.convert(..).
Diffstat (limited to 'src/nativewindow/classes/jogamp')
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java29
1 files changed, 10 insertions, 19 deletions
diff --git a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java
index b0eda63b6..1dce9218c 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java
@@ -37,6 +37,7 @@ import java.awt.Component;
import java.awt.Container;
import java.awt.Frame;
import java.awt.image.BufferedImage;
+import java.nio.ByteBuffer;
import java.util.HashMap;
import javax.swing.JComponent;
@@ -50,6 +51,8 @@ import javax.media.nativewindow.util.PixelFormat;
import javax.media.nativewindow.util.PixelFormatUtil;
import javax.swing.MenuSelectionManager;
+import com.jogamp.nativewindow.awt.DirectDataBufferInt;
+
import jogamp.nativewindow.jawt.JAWTUtil;
public class AWTMisc {
@@ -210,25 +213,13 @@ public class AWTMisc {
private static synchronized Cursor createCursor(final PixelRectangle pixelrect, final Point hotSpot) {
final int width = pixelrect.getSize().getWidth();
final int height = pixelrect.getSize().getHeight();
- final BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); // PixelFormat.BGRA8888
- final PixelFormatUtil.PixelSink32 imgSink = new PixelFormatUtil.PixelSink32() {
- public void store(final int x, final int y, final int pixel) {
- img.setRGB(x, y, pixel);
- }
- @Override
- public final PixelFormat getPixelformat() {
- return PixelFormat.BGRA8888;
- }
- @Override
- public int getStride() {
- return width*4;
- }
- @Override
- public final boolean isGLOriented() {
- return false;
- }
- };
- PixelFormatUtil.convert32(imgSink, pixelrect);
+ // final BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); // PixelFormat.BGRA8888
+ final DirectDataBufferInt.BufferedImageInt img =
+ DirectDataBufferInt.createBufferedImage(width, height, BufferedImage.TYPE_INT_ARGB,
+ null /* location */, null /* properties */);
+ final ByteBuffer imgBuffer = img.getDataBuffer().getDataBytes();
+ PixelFormatUtil.convert(pixelrect, imgBuffer, PixelFormat.BGRA8888, false /* dst_glOriented */, width*4 /* dst_lineStride */);
+
final Toolkit toolkit = Toolkit.getDefaultToolkit();
return toolkit.createCustomCursor(img, hotSpot, pixelrect.toString());
}