Java2D & Native Buffers
Noya:
Quote from: Frederick
public class DataBufferDirectByte extends DataBuffer
If I remember correctly, instanceof checks the whole inheritance tree. So you could just write "extends DataBufferByte". It's not clean, but hey it should work ;)
tom:
There is a way to access java arrays from JNI c code without the array being copied. There is a special array mehtod you can use from JNI. I think it's called getPrimitiveArrayCritical, or something like that. The VM has to support pinning and a few other restrictions. But you should atleast check it out.
EDIT: http://download.java.net/jdk7/docs/technotes/guides/jni/spec/functions.html (search for GetPrimitiveArrayCritical)
Frederick:
Hey!
Quote
If I remember correctly, instanceof checks the whole inheritance tree. So you could just write "extends DataBufferByte". It's not clean, but hey it should work Wink
I wouldn´t really like that, because I switched to Java because I want to program nice and cleanly ;)
That way I would inherit an array data structure and methods I don´t need - kind of a mess.
Quote
There is a way to access java arrays from JNI c code without the array being copied. There is a special array mehtod you can use from JNI. I think it's called getPrimitiveArrayCritical, or something like that. The VM has to support pinning and a few other restrictions. But you should atleast check it out.
Thanks for the link, I might give that a try. I plan to use only modern VMs so no problem with pinning I hope. Still I would like to use the buffers, but...
Maybe I should file this as a bug report ? I would tend to call it a bug, because it is definetly not a feature *lol* Also it would please me to know, that I can render to any surface I like and the jdk supports this functionality - unfortunately only theoretically.
trembovetski:
It is not a bug. You need to define your own Raster type to handle your DataBuffer.
However, the problem is that even when you make it all work - that is,
create a BufferedImage with your direct data buffer, the only way
Java2D would be able to render to/from it is using get/setElem,
which will be excruciatingly slow - since Java2D doesn't know
how to access your data other than through get/set elem methods.
What we really need is proper support for DataBuffers with out of heap
data placement. I believe there's an RFE somewhere already.
Unfortunately this will have to wait at least until Java 7.
Dmitri
Frederick:
Quote
It is not a bug. You need to define your own Raster type to handle your DataBuffer.
Okay that´s too much work then. I had thought, because the raster has a pluggable DataBuffer it would suffice to exchange it.
Quote
Java2D would be able to render to/from it is using get/setElem,
which will be excruciatingly slow
I really hope the JVM will inline getter/setter methods ?
Quote
What we really need is proper support for DataBuffers with out of heap
data placement.
I would really appreciate stack allocation too, but i don´t understand how it could help in this case. ??? ??? :)
...I think I will stick with toms suggestion - everything else seems to be too complicated...
Navigation
[0] Message Index
[#] Next page
[*] Previous page