29package com.jogamp.opengl.test.junit.jogl.util.texture;
32import com.jogamp.common.util.IOUtil;
33import com.jogamp.opengl.test.junit.util.UITestCase;
35import javax.imageio.ImageIO;
36import com.jogamp.opengl.GL;
37import com.jogamp.opengl.GLProfile;
39import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes;
40import com.jogamp.opengl.util.texture.TextureData;
41import com.jogamp.opengl.util.texture.awt.AWTTextureData;
42import com.jogamp.opengl.util.texture.spi.JPEGImage;
44import java.awt.image.BufferedImage;
45import java.io.IOException;
46import java.io.InputStream;
47import java.net.URLConnection;
48import java.nio.Buffer;
51import org.junit.FixMethodOrder;
52import org.junit.runners.MethodSorters;
54@FixMethodOrder(MethodSorters.NAME_ASCENDING)
56 static boolean showFPS =
false;
57 static String fname =
"j1-baseline.jpg";
61 benchmarkImpl(100, fname);
63 void benchmarkImpl(
final int loops,
final String fname)
throws IOException {
65 final long t0 = System.currentTimeMillis();
66 for(
int i = 0; i< loops; i++ ) {
67 final URLConnection urlConn = IOUtil.getResource(fname, this.getClass().getClassLoader(), this.getClass());
68 final InputStream istream = urlConn.getInputStream();
81 if(0==i || loops-1==i) {
82 System.err.println(i+
": "+image.
toString());
83 System.err.println(i+
": "+texData+
", buffer "+texData.getBuffer());
87 final long t1 = System.currentTimeMillis();
88 final long dt = t1 - t0;
89 final float msPl = (float)dt / (
float)loops ;
90 System.err.println(
"JOGL.RGB Loops "+loops+
", dt "+dt+
" ms, "+msPl+
" ms/l");
93 final long t0 = System.currentTimeMillis();
94 for(
int i = 0; i< loops; i++ ) {
95 final URLConnection urlConn = IOUtil.getResource(fname, this.getClass().getClassLoader(), this.getClass());
96 final InputStream istream = urlConn.getInputStream();
97 final JPEGImage image = JPEGImage.
read(istream, TextureData.ColorSpace.YCbCr);
103 new GLPixelAttributes(image.getGLFormat(), image.getGLType()),
109 if(0==i || loops-1==i) {
110 System.err.println(i+
": "+image.toString());
111 System.err.println(i+
": "+texData+
", buffer "+texData.getBuffer());
115 final long t1 = System.currentTimeMillis();
116 final long dt = t1 - t0;
117 final float msPl = (float)dt / (
float)loops ;
118 System.err.println(
"JOGL.YUV Loops "+loops+
", dt "+dt+
" ms, "+msPl+
" ms/l");
121 final long t0 = System.currentTimeMillis();
122 for(
int i = 0; i< loops; i++ ) {
123 final URLConnection urlConn = IOUtil.getResource(fname, this.getClass().getClassLoader(), this.getClass());
124 final InputStream istream = urlConn.getInputStream();
127 final BufferedImage img = ImageIO.read(istream);
128 final AWTTextureData texData =
new AWTTextureData(GLProfile.getGL2ES2(), 0, 0,
false, img);
129 data = texData.getBuffer();
130 if(0==i || loops-1==i) {
131 System.err.println(i+
": "+texData+
", buffer "+data);
133 }
catch (
final Exception e) {
134 System.err.println(
"AWT ImageIO failure w/ file "+fname+
": "+e.getMessage());
138 final long t1 = System.currentTimeMillis();
139 final long dt = t1 - t0;
140 final float msPl = (float)dt / (
float)loops ;
141 System.err.println(
"AWT..... Loops "+loops+
", dt "+dt+
" ms, "+msPl+
" ms/l");
145 public static void main(
final String args[])
throws IOException {
146 for(
int i=0; i<args.length; i++) {
147 if(args[i].equals(
"-file")) {
Specifies the the OpenGL profile.
static GLProfile getGL2ES2(final AbstractGraphicsDevice device)
Returns the GL2ES2 profile implementation, hence compatible w/ GL2ES2.
static void main(final String args[])
Represents the data for an OpenGL texture.
ByteBuffer getData()
Returns the raw data for this texture in the correct (bottom-to-top) order for calls to glTexImage2D.
int getBytesPerPixel()
Returns the bytes per pixel.
int getGLFormat()
Returns the OpenGL format for this texture; e.g.
int getWidth()
Returns the width of the image.
int getHeight()
Returns the height of the image.
int getGLType()
Returns the OpenGL data type: GL.GL_UNSIGNED_BYTE.
static JPEGImage read(final InputStream in, final ColorSpace cs)
Reads a JPEG image from the specified InputStream, using the given color space for storage.
static final int GL_RGB
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_RGB" with expression ...
static final int GL_RGBA
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_RGBA" with expression...