diff options
Diffstat (limited to 'src/jogl/classes')
4 files changed, 77 insertions, 31 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/ImageSequence.java b/src/jogl/classes/com/jogamp/opengl/util/texture/ImageSequence.java index e485e5452..2da2dcbfc 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/ImageSequence.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/ImageSequence.java @@ -153,17 +153,21 @@ public class ImageSequence implements TextureSequence { private String textureLookupFunctionName = "myTexture2D"; @Override - public String getTextureLookupFunctionName(final String desiredFuncName) throws IllegalStateException { + public String setTextureLookupFunctionName(final String texLookupFuncName) throws IllegalStateException { if(useBuildInTexLookup) { - return "texture2D"; - } - if(null != desiredFuncName && desiredFuncName.length()>0) { - textureLookupFunctionName = desiredFuncName; + textureLookupFunctionName = "texture2D"; + } else if(null != texLookupFuncName && texLookupFuncName.length()>0) { + textureLookupFunctionName = texLookupFuncName; } return textureLookupFunctionName; } @Override + public String getTextureLookupFunctionName() throws IllegalStateException { + return textureLookupFunctionName; + } + + @Override public String getTextureLookupFragmentShaderImpl() throws IllegalStateException { if(useBuildInTexLookup) { return ""; diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java index 7147fd61b..2b91f3b1f 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java @@ -226,15 +226,28 @@ public interface TextureSequence { public String getTextureSampler2DType() throws IllegalStateException ; /** - * @param desiredFuncName desired lookup function name. If <code>null</code> or ignored by the implementation, - * a build-in name is returned. - * @return the final lookup function name + * Set the desired shader code's texture lookup function name. * - * @see {@link #getTextureLookupFragmentShaderImpl()} + * @param texLookupFuncName desired lookup function name. If <code>null</code> or ignored by the implementation, + * a build-in name is returned. + * @return the chosen lookup function name * * @throws IllegalStateException if instance is not initialized + * @see #getTextureLookupFunctionName() + * @see #getTextureFragmentShaderHashCode() + * @see #getTextureLookupFragmentShaderImpl() */ - public String getTextureLookupFunctionName(String desiredFuncName) throws IllegalStateException ; + public String setTextureLookupFunctionName(String texLookupFuncName) throws IllegalStateException ; + + /** + * Returns the chosen lookup function name, which can be set via {@link #setTextureLookupFunctionName(String)}. + * + * @throws IllegalStateException if instance is not initialized + * @see #setTextureLookupFunctionName(String) + * @see #getTextureFragmentShaderHashCode() + * @see #getTextureLookupFragmentShaderImpl() + */ + public String getTextureLookupFunctionName() throws IllegalStateException ; /** * Returns the complete texture2D lookup function code of type @@ -245,36 +258,49 @@ public interface TextureSequence { * } * </pre> * <p> - * <i>funcName</i> can be negotiated and queried via {@link #getTextureLookupFunctionName(String)}. + * <i>funcName</i> is set via {@link #setTextureLookupFunctionName(String)} + * and queried via {@link #getTextureLookupFunctionName()}. + * </p> + * <p> + * User shall call {@link #setTextureLookupFunctionName(String)} first if intended. * </p> + * <p> * Note: This function may return an empty string in case a build-in lookup * function is being chosen. If the implementation desires so, - * {@link #getTextureLookupFunctionName(String)} will ignore the desired function name + * {@link #getTextureLookupFunctionName()} will ignore the desired function name * and returns the build-in lookup function name. * </p> - * @see #getTextureLookupFunctionName(String) - * @see #getTextureSampler2DType() - * * @throws IllegalStateException if instance is not initialized + * @see #getTextureLookupFunctionName() + * @see #setTextureLookupFunctionName(String) + * @see #getTextureFragmentShaderHashCode() + * @see #getTextureSampler2DType() */ public String getTextureLookupFragmentShaderImpl() throws IllegalStateException; /** * Returns the hash code of the strings: * <ul> + * <li>{@link #getTextureLookupFunctionName()}</li> * <li>{@link #getTextureLookupFragmentShaderImpl()}</li> * <li>{@link #getTextureSampler2DType()}</li> * </ul> * <p> + * User shall call {@link #setTextureLookupFunctionName(String)} first if intended. + * </p> + * <p> * Returns zero if {@link #isTextureAvailable() texture is not available}. * </p> * The returned hash code allows selection of a matching shader program for this {@link TextureSequence} instance. * <p> * </p> * <p> - * Implementation shall cache the resulting hash code, + * Implementation caches the resulting hash code, * which must be reset to zero if {@link #isTextureAvailable() texture is not available}. * </p> + * @see #setTextureLookupFunctionName(String) + * @see #getTextureLookupFunctionName() + * @see #getTextureLookupFragmentShaderImpl() */ public int getTextureFragmentShaderHashCode(); } diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java index a9e4b5bc3..d94fbb1a7 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java @@ -268,15 +268,29 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } } + protected String textureLookupFunctionName = "texture2D"; + + /** + * {@inheritDoc} + * + * This implementation simply sets and returns the build-in function name of <code>texture2D</code>, + * if not overridden by specialization, e.g. using the ffmpeg implementation. + */ + @Override + public String setTextureLookupFunctionName(final String texLookupFuncName) throws IllegalStateException { + textureLookupFunctionName = "texture2D"; + return textureLookupFunctionName; + } + /** * {@inheritDoc} * * This implementation simply returns the build-in function name of <code>texture2D</code>, - * if not overridden by specialization. + * if not overridden by specialization, e.g. using the ffmpeg implementation. */ @Override - public String getTextureLookupFunctionName(final String desiredFuncName) { - return "texture2D"; + public final String getTextureLookupFunctionName() { + return textureLookupFunctionName; } /** @@ -297,7 +311,8 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { textureFragmentShaderHashCode = 0; return 0; } else if( 0 == textureFragmentShaderHashCode ) { - int hash = 31 + getTextureLookupFragmentShaderImpl().hashCode(); + int hash = 31 + getTextureLookupFunctionName().hashCode(); + hash = ((hash << 5) - hash) + getTextureLookupFragmentShaderImpl().hashCode(); hash = ((hash << 5) - hash) + getTextureSampler2DType().hashCode(); textureFragmentShaderHashCode = hash; } diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java index 91bef005a..fb3e8e4d3 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java @@ -276,7 +276,6 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { // Video // - private String texLookupFuncName = "ffmpegTexture2D"; private boolean usesTexLookupShader = false; private VideoPixelFormat vPixelFmt = null; private int vPlanes = 0; @@ -703,14 +702,16 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { * Otherwise the call is delegated to it's super class. */ @Override - public final String getTextureLookupFunctionName(final String desiredFuncName) { + public String setTextureLookupFunctionName(final String texLookupFuncName) throws IllegalStateException { if( usesTexLookupShader ) { - if(null != desiredFuncName && desiredFuncName.length()>0) { - texLookupFuncName = desiredFuncName; + if(null != texLookupFuncName && texLookupFuncName.length()>0) { + textureLookupFunctionName = texLookupFuncName; + } else { + textureLookupFunctionName = "ffmpegTexture2D"; } - return texLookupFuncName; + return textureLookupFunctionName; } - return super.getTextureLookupFunctionName(desiredFuncName); + return super.getTextureLookupFunctionName(); } /** @@ -729,7 +730,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { case YUVJ420P: case YUV420P: // < planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples) return - "vec4 "+texLookupFuncName+"(in "+getTextureSampler2DType()+" image, in vec2 texCoord) {\n"+ + "vec4 "+getTextureLookupFunctionName()+"(in "+getTextureSampler2DType()+" image, in vec2 texCoord) {\n"+ " const vec2 u_off = vec2("+tc_w_1+", 0.0);\n"+ " const vec2 v_off = vec2("+tc_w_1+", 0.5);\n"+ " vec2 tc_half = texCoord*0.5;\n"+ @@ -750,7 +751,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { case YUVJ422P: case YUV422P: ///< planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples) return - "vec4 "+texLookupFuncName+"(in "+getTextureSampler2DType()+" image, in vec2 texCoord) {\n"+ + "vec4 "+getTextureLookupFunctionName()+"(in "+getTextureSampler2DType()+" image, in vec2 texCoord) {\n"+ " const vec2 u_off = vec2("+tc_w_1+" , 0.0);\n"+ " const vec2 v_off = vec2("+tc_w_1+" * 1.5, 0.0);\n"+ " vec2 tc_halfw = vec2(texCoord.x*0.5, texCoord.y);\n"+ @@ -771,7 +772,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { case YUYV422: // < packed YUV 4:2:2, 2 x 16bpp, [Y0 Cb] [Y1 Cr] // Stuffed into RGBA half width texture return - "vec4 "+texLookupFuncName+"(in "+getTextureSampler2DType()+" image, in vec2 texCoord) {\n"+ + "vec4 "+getTextureLookupFunctionName()+"(in "+getTextureSampler2DType()+" image, in vec2 texCoord) {\n"+ " "+ " float y1,u,y2,v,y,r,g,b;\n"+ " vec2 tc_halfw = vec2(texCoord.x*0.5, texCoord.y);\n"+ @@ -793,7 +794,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { case UYVY422: // < packed YUV 4:2:2, 2 x 16bpp, Cb Y0 Cr Y1 // Stuffed into RGBA half width texture return - "vec4 "+texLookupFuncName+"(in "+getTextureSampler2DType()+" image, in vec2 texCoord) {\n"+ + "vec4 "+getTextureLookupFunctionName()+"(in "+getTextureSampler2DType()+" image, in vec2 texCoord) {\n"+ " "+ " float y1,u,y2,v,y,r,g,b;\n"+ " vec2 tc_halfw = vec2(texCoord.x*0.5, texCoord.y);\n"+ @@ -815,7 +816,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { case BGR24: return - "vec4 "+texLookupFuncName+"(in "+getTextureSampler2DType()+" image, in vec2 texCoord) {\n"+ + "vec4 "+getTextureLookupFunctionName()+"(in "+getTextureSampler2DType()+" image, in vec2 texCoord) {\n"+ " "+ " vec3 bgr = texture2D(image, texCoord).rgb;\n"+ " return vec4(bgr.b, bgr.g, bgr.r, 1);\n"+ /* just swizzle */ |