opengl pipeline, BufferedImage and binlinear interpolation slowness
I'm writing a video renderer using java2d, and it works fine with either the opengl or the standard pipeline when doing nearest-neighbor scaling. However, when I use the OpenGL pipeline and set the interpolation to bilinear, it slows down to about 1fps.
However, If I draw the BufferedImage into a VolatileImage and then draw that to screen, speed is excellent (about the same speed as opengl with nearest-neighbour interpolation).
Here is how I'm rendering:
1) new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB)
2) load video into the BufferedImage:
int pixels = ((DataBufferInt) bImage.getRaster().getDataBuffer()).getData();
... read video data from native memory into the pixel array ...
3) call repaint() on the JComponent
4) in paintComponent(), draw the image using:
g.drawImage(bImage, 0, 0, getWidth(), getHeight(), null);
Knowing that getting the DataBuffer from the BufferedImage unmanages it, I tried getting a BufferedImage via GraphicsConfiguration.createCompatibleImage(), drawing the video image into that without scaling, and using the compatible image in paintComponent(), but it runs just as slow.
When not scaling, the java2d trace during paintComponent() looks like:
sun.java2d.opengl.OGLSwToSurfaceBlit::Blit(IntRgb, AnyAlpha, "OpenGL Surface")
When scaling, it becomes hundreds of repititions of:
sun.java2d.loops.Blit::Blit(IntArgbPre, SrcNoEa, IntArgb)
sun.java2d.opengl.OGLMaskBlit::MaskBlit(IntArgb, SrcOver, "OpenGL Surface")
sun.java2d.opengl.OGLGeneralBlit::Blit(Any, AnyAlpha, "OpenGL Surface")
sun.java2d.loops.Blit::Blit(IntArgb, SrcNoEa, IntArgbPre)
sun.java2d.loops.MaskBlit$General::MaskBlit(IntArgbPre, SrcOverNoEa, "OpenGL Surface (render-to-texture)")
So the question is: Is that expected behaviour, and its just a trap for the unwary or am I doing something wrong somewhere?