diff options
author | Sven Gothel <[email protected]> | 2014-07-03 16:35:47 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-07-03 16:35:47 +0200 |
commit | a90ee128ce0550cd05f969d0283312c2f42b8254 (patch) | |
tree | dade644101970d8f69ea3845db310499f2b66a76 /src/com/jogamp/opencl/gl/CLGLContext.java | |
parent | a0e0c8a39d0ef41ff6b64d9b40d058f21b786e81 (diff) |
Code Clean-Up based on our Recommended Settings (jogamp-scripting c47bc86ae2ee268a1f38c5580d11f93d7f8d6e74)
- Change non static accesses to static members using declaring type
- Change indirect accesses to static members to direct accesses (accesses through subtypes)
- Add final modifier to private fields
- Add final modifier to method parameters
- Add final modifier to local variables
- Remove unnecessary casts
- Remove unnecessary '$NON-NLS$' tags
- Remove trailing white spaces on all lines
Diffstat (limited to 'src/com/jogamp/opencl/gl/CLGLContext.java')
-rw-r--r-- | src/com/jogamp/opencl/gl/CLGLContext.java | 120 |
1 files changed, 61 insertions, 59 deletions
diff --git a/src/com/jogamp/opencl/gl/CLGLContext.java b/src/com/jogamp/opencl/gl/CLGLContext.java index e99e7ac4..2564a82d 100644 --- a/src/com/jogamp/opencl/gl/CLGLContext.java +++ b/src/com/jogamp/opencl/gl/CLGLContext.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -44,6 +44,8 @@ import com.jogamp.opencl.CLContext; import com.jogamp.opencl.CLDevice; import com.jogamp.opencl.CLMemory.Mem; import com.jogamp.opencl.CLPlatform; +import com.jogamp.opencl.llb.CL; +import com.jogamp.opencl.llb.CLContextBinding; import com.jogamp.opencl.llb.gl.CLGL; /** @@ -55,7 +57,7 @@ public final class CLGLContext extends CLContext { final long glID; private final GLContext glContext; - private CLGLContext(CLPlatform platform, GLContext glContext, long clContextID, long glContextID, ErrorDispatcher dispatcher) { + private CLGLContext(final CLPlatform platform, final GLContext glContext, final long clContextID, final long glContextID, final ErrorDispatcher dispatcher) { super(platform, clContextID, dispatcher); this.glID = glContextID; this.glContext = glContext; @@ -65,7 +67,7 @@ public final class CLGLContext extends CLContext { * Creates a shared context on all available devices (CL_DEVICE_TYPE_ALL). * @see GLContext#makeCurrent() */ - public static CLGLContext create(GLContext glContext) { + public static CLGLContext create(final GLContext glContext) { return create(glContext, (CLPlatform)null, CLDevice.Type.ALL); } @@ -73,7 +75,7 @@ public final class CLGLContext extends CLContext { * Creates a shared context on the specified platform on all available devices (CL_DEVICE_TYPE_ALL). * @see GLContext#makeCurrent() */ - public static CLGLContext create(GLContext glContext, CLPlatform platform) { + public static CLGLContext create(final GLContext glContext, final CLPlatform platform) { return create(glContext, platform, CLDevice.Type.ALL); } @@ -82,7 +84,7 @@ public final class CLGLContext extends CLContext { * device types. * @see GLContext#makeCurrent() */ - public static CLGLContext create(GLContext glContext, CLDevice.Type... deviceTypes) { + public static CLGLContext create(final GLContext glContext, final CLDevice.Type... deviceTypes) { return create(glContext, null, deviceTypes); } @@ -91,16 +93,16 @@ public final class CLGLContext extends CLContext { * device types. * @see GLContext#makeCurrent() */ - public static CLGLContext create(GLContext glContext, CLPlatform platform, CLDevice.Type... deviceTypes) { + public static CLGLContext create(final GLContext glContext, CLPlatform platform, final CLDevice.Type... deviceTypes) { if(platform == null) { platform = CLPlatform.getDefault(); } - long[] glID = new long[1]; - PointerBuffer properties = setupContextProperties(platform, glContext, glID); - ErrorDispatcher dispatcher = createErrorHandler(); - long clID = createContextFromType(platform, dispatcher, properties, toDeviceBitmap(deviceTypes)); + final long[] glID = new long[1]; + final PointerBuffer properties = setupContextProperties(platform, glContext, glID); + final ErrorDispatcher dispatcher = createErrorHandler(); + final long clID = createContextFromType(platform, dispatcher, properties, toDeviceBitmap(deviceTypes)); return new CLGLContext(platform, glContext, clID, glID[0], dispatcher); @@ -111,7 +113,7 @@ public final class CLGLContext extends CLContext { * devices. * @see GLContext#makeCurrent() */ - public static CLGLContext create(GLContext glContext, CLDevice... devices) { + public static CLGLContext create(final GLContext glContext, final CLDevice... devices) { if(devices == null) { throw new IllegalArgumentException("no devices specified"); @@ -119,14 +121,14 @@ public final class CLGLContext extends CLContext { throw new IllegalArgumentException("first device was null"); } - CLPlatform platform = devices[0].getPlatform(); + final CLPlatform platform = devices[0].getPlatform(); - long[] glID = new long[1]; - PointerBuffer properties = setupContextProperties(platform, glContext, glID); - ErrorDispatcher dispatcher = createErrorHandler(); - long clID = createContext(platform, dispatcher, properties, devices); + final long[] glID = new long[1]; + final PointerBuffer properties = setupContextProperties(platform, glContext, glID); + final ErrorDispatcher dispatcher = createErrorHandler(); + final long clID = createContext(platform, dispatcher, properties, devices); - CLGLContext context = new CLGLContext(platform, glContext, clID, glID[0], dispatcher); + final CLGLContext context = new CLGLContext(platform, glContext, clID, glID[0], dispatcher); if(devices != null) { for (int i = 0; i < devices.length; i++) { context.overrideContext(devices[i]); @@ -136,7 +138,7 @@ public final class CLGLContext extends CLContext { } - private static PointerBuffer setupContextProperties(CLPlatform platform, GLContext glContext, long[] glID) { + private static PointerBuffer setupContextProperties(final CLPlatform platform, final GLContext glContext, final long[] glID) { if(platform == null) { throw new RuntimeException("no OpenCL installation found"); @@ -151,7 +153,7 @@ public final class CLGLContext extends CLContext { " creating a OpenCL context for context sharing is not allowed in this situation."); } - GLContextImpl ctxImpl = (GLContextImpl)glContext; + final GLContextImpl ctxImpl = (GLContextImpl)glContext; glID[0] = glContext.getHandle(); PointerBuffer properties; @@ -162,36 +164,36 @@ public final class CLGLContext extends CLContext { // set to the Display handle of the X Window System display used to // create the OpenGL context." properties = PointerBuffer.allocateDirect(7); - long displayHandle = ctxImpl.getDrawableImpl().getNativeSurface().getDisplayHandle(); + final long displayHandle = ctxImpl.getDrawableImpl().getNativeSurface().getDisplayHandle(); properties.put(CLGL.CL_GL_CONTEXT_KHR).put(glID[0]) - .put(CLGL.CL_GLX_DISPLAY_KHR).put(displayHandle) - .put(CLGL.CL_CONTEXT_PLATFORM).put(platform.ID); + .put(CL.CL_GLX_DISPLAY_KHR).put(displayHandle) + .put(CLContextBinding.CL_CONTEXT_PLATFORM).put(platform.ID); }else if(glContext instanceof WindowsWGLContext) { // spec: "When the WGL binding API is supported, the attribute // CL_GL_CONTEXT_KHR should be set to an HGLRC handle to an OpenGL // context, and the attribute CL_WGL_HDC_KHR should be set to the // HDC handle of the display used to create the OpenGL context." properties = PointerBuffer.allocateDirect(7); - long surfaceHandle = ctxImpl.getDrawableImpl().getNativeSurface().getSurfaceHandle(); + final long surfaceHandle = ctxImpl.getDrawableImpl().getNativeSurface().getSurfaceHandle(); properties.put(CLGL.CL_GL_CONTEXT_KHR).put(glID[0]) - .put(CLGL.CL_WGL_HDC_KHR).put(surfaceHandle) - .put(CLGL.CL_CONTEXT_PLATFORM).put(platform.ID); + .put(CL.CL_WGL_HDC_KHR).put(surfaceHandle) + .put(CLContextBinding.CL_CONTEXT_PLATFORM).put(platform.ID); }else if(glContext instanceof MacOSXCGLContext) { // spec: "When the CGL binding API is supported, the attribute // CL_CGL_SHAREGROUP_KHR should be set to a CGLShareGroup handle to // a CGL share group object." /** - * FIXME: For all Mac OSX Versions ??? - * CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE used to specify the GL sharing group ID - * on Mac OSX 10.8.4 works. - * Using the std. CL_CGL_SHAREGROUP_KHR on Mac OSX 10.8.4 causes the context creation + * FIXME: For all Mac OSX Versions ??? + * CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE used to specify the GL sharing group ID + * on Mac OSX 10.8.4 works. + * Using the std. CL_CGL_SHAREGROUP_KHR on Mac OSX 10.8.4 causes the context creation * to throw a CL_INVALID_VALUE error. */ - long cgl = CGL.getCGLContext(glID[0]); - long group = CGL.CGLGetShareGroup(cgl); + final long cgl = CGL.getCGLContext(glID[0]); + final long group = CGL.CGLGetShareGroup(cgl); properties = PointerBuffer.allocateDirect(5); properties.put(CLGL.CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE).put(group) - .put(CLGL.CL_CONTEXT_PLATFORM).put(platform.ID); + .put(CLContextBinding.CL_CONTEXT_PLATFORM).put(platform.ID); }else if(glContext instanceof EGLContext) { // TODO test EGL // spec: "When the EGL binding API is supported, the attribute @@ -200,17 +202,17 @@ public final class CLGLContext extends CLContext { // CL_EGL_DISPLAY_KHR should be set to the EGLDisplay handle of the // display used to create the OpenGL ES or OpenGL context." properties = PointerBuffer.allocateDirect(7); - long displayHandle = ctxImpl.getDrawableImpl().getNativeSurface().getDisplayHandle(); + final long displayHandle = ctxImpl.getDrawableImpl().getNativeSurface().getDisplayHandle(); properties.put(CLGL.CL_GL_CONTEXT_KHR).put(glID[0]) - .put(CLGL.CL_EGL_DISPLAY_KHR).put(displayHandle) - .put(CLGL.CL_CONTEXT_PLATFORM).put(platform.ID); + .put(CL.CL_EGL_DISPLAY_KHR).put(displayHandle) + .put(CLContextBinding.CL_CONTEXT_PLATFORM).put(platform.ID); }else{ throw new RuntimeException("unsupported GLContext: "+glContext); } return properties.put(0).rewind(); // 0 terminated array } - + // Buffers /** * Creates a CLGLBuffer for memory sharing with the specified OpenGL buffer. @@ -218,7 +220,7 @@ public final class CLGLContext extends CLContext { * @param glBufferSize The size of the OpenGL buffer in bytes * @param flags optional flags. */ - public final CLGLBuffer<?> createFromGLBuffer(int glBuffer, long glBufferSize, Mem... flags) { + public final CLGLBuffer<?> createFromGLBuffer(final int glBuffer, final long glBufferSize, final Mem... flags) { return createFromGLBuffer(null, glBuffer, glBufferSize, Mem.flagsToInt(flags)); } @@ -228,7 +230,7 @@ public final class CLGLContext extends CLContext { * @param glBufferSize The size of the OpenGL buffer in bytes * @param flags optional flags. */ - public final CLGLBuffer<?> createFromGLBuffer(int glBuffer, long glBufferSize, int flags) { + public final CLGLBuffer<?> createFromGLBuffer(final int glBuffer, final long glBufferSize, final int flags) { return createFromGLBuffer(null, glBuffer, glBufferSize, flags); } @@ -239,7 +241,7 @@ public final class CLGLContext extends CLContext { * @param glBufferSize The size of the OpenGL buffer in bytes * @param flags optional flags. */ - public final <B extends Buffer> CLGLBuffer<B> createFromGLBuffer(B directBuffer, int glBuffer, long glBufferSize, Mem... flags) { + public final <B extends Buffer> CLGLBuffer<B> createFromGLBuffer(final B directBuffer, final int glBuffer, final long glBufferSize, final Mem... flags) { return createFromGLBuffer(directBuffer, glBuffer, glBufferSize, Mem.flagsToInt(flags)); } @@ -250,65 +252,65 @@ public final class CLGLContext extends CLContext { * @param glBufferSize The size of the OpenGL buffer in bytes * @param flags optional flags. */ - public final <B extends Buffer> CLGLBuffer<B> createFromGLBuffer(B directBuffer, int glBuffer, long glBufferSize, int flags) { - CLGLBuffer<B> buffer = CLGLBuffer.create(this, directBuffer, glBufferSize, flags, glBuffer); + public final <B extends Buffer> CLGLBuffer<B> createFromGLBuffer(final B directBuffer, final int glBuffer, final long glBufferSize, final int flags) { + final CLGLBuffer<B> buffer = CLGLBuffer.create(this, directBuffer, glBufferSize, flags, glBuffer); memoryObjects.add(buffer); return buffer; } // Renderbuffers - public final CLGLImage2d<?> createFromGLRenderbuffer(int glBuffer, Mem... flags) { + public final CLGLImage2d<?> createFromGLRenderbuffer(final int glBuffer, final Mem... flags) { return createFromGLRenderbuffer(null, glBuffer, Mem.flagsToInt(flags)); } - public final CLGLImage2d<?> createFromGLRenderbuffer(int glBuffer, int flags) { + public final CLGLImage2d<?> createFromGLRenderbuffer(final int glBuffer, final int flags) { return createFromGLRenderbuffer(null, glBuffer, flags); } - public final <B extends Buffer> CLGLImage2d<B> createFromGLRenderbuffer(B directBuffer, int glBuffer, Mem... flags) { + public final <B extends Buffer> CLGLImage2d<B> createFromGLRenderbuffer(final B directBuffer, final int glBuffer, final Mem... flags) { return createFromGLRenderbuffer(directBuffer, glBuffer, Mem.flagsToInt(flags)); } - public final <B extends Buffer> CLGLImage2d<B> createFromGLRenderbuffer(B directBuffer, int glBuffer, int flags) { - CLGLImage2d<B> buffer = CLGLImage2d.createFromGLRenderbuffer(this, directBuffer, flags, glBuffer); + public final <B extends Buffer> CLGLImage2d<B> createFromGLRenderbuffer(final B directBuffer, final int glBuffer, final int flags) { + final CLGLImage2d<B> buffer = CLGLImage2d.createFromGLRenderbuffer(this, directBuffer, flags, glBuffer); memoryObjects.add(buffer); return buffer; } //2d Textures - public final CLGLTexture2d<?> createFromGLTexture2d(int target, int texture, int mipmap, Mem... flags) { + public final CLGLTexture2d<?> createFromGLTexture2d(final int target, final int texture, final int mipmap, final Mem... flags) { return createFromGLTexture2d(null, target, texture, mipmap, Mem.flagsToInt(flags)); } - public final CLGLTexture2d<?> createFromGLTexture2d(int target, int texture, int mipmap, int flags) { + public final CLGLTexture2d<?> createFromGLTexture2d(final int target, final int texture, final int mipmap, final int flags) { return createFromGLTexture2d(null, target, texture, mipmap, flags); } - public final <B extends Buffer> CLGLTexture2d<B> createFromGLTexture2d(B directBuffer, int target, int texture, int mipmap, Mem... flags) { + public final <B extends Buffer> CLGLTexture2d<B> createFromGLTexture2d(final B directBuffer, final int target, final int texture, final int mipmap, final Mem... flags) { return createFromGLTexture2d(directBuffer, target, texture, mipmap, Mem.flagsToInt(flags)); } - public final <B extends Buffer> CLGLTexture2d<B> createFromGLTexture2d(B directBuffer, int target, int texture, int mipmap, int flags) { - CLGLTexture2d<B> buffer = CLGLTexture2d.createFromGLTexture2d(this, directBuffer, target, texture, mipmap, flags); + public final <B extends Buffer> CLGLTexture2d<B> createFromGLTexture2d(final B directBuffer, final int target, final int texture, final int mipmap, final int flags) { + final CLGLTexture2d<B> buffer = CLGLTexture2d.createFromGLTexture2d(this, directBuffer, target, texture, mipmap, flags); memoryObjects.add(buffer); return buffer; } //3d Textures - public final CLGLTexture3d<?> createFromGLTexture3d(int target, int texture, int mipmap, Mem... flags) { + public final CLGLTexture3d<?> createFromGLTexture3d(final int target, final int texture, final int mipmap, final Mem... flags) { return createFromGLTexture3d(null, target, texture, mipmap, Mem.flagsToInt(flags)); } - public final CLGLTexture3d<?> createFromGLTexture3d(int target, int texture, int mipmap, int flags) { + public final CLGLTexture3d<?> createFromGLTexture3d(final int target, final int texture, final int mipmap, final int flags) { return createFromGLTexture3d(null, target, texture, mipmap, flags); } - public final <B extends Buffer> CLGLTexture3d<B> createFromGLTexture3d(B directBuffer, int target, int texture, int mipmap, Mem... flags) { + public final <B extends Buffer> CLGLTexture3d<B> createFromGLTexture3d(final B directBuffer, final int target, final int texture, final int mipmap, final Mem... flags) { return createFromGLTexture3d(directBuffer, target, texture, mipmap, Mem.flagsToInt(flags)); } - public final <B extends Buffer> CLGLTexture3d<B> createFromGLTexture3d(B directBuffer, int target, int texture, int mipmap, int flags) { - CLGLTexture3d<B> buffer = CLGLTexture3d.createFromGLTexture3d(this, directBuffer, flags, target, mipmap, texture); + public final <B extends Buffer> CLGLTexture3d<B> createFromGLTexture3d(final B directBuffer, final int target, final int texture, final int mipmap, final int flags) { + final CLGLTexture3d<B> buffer = CLGLTexture3d.createFromGLTexture3d(this, directBuffer, flags, target, mipmap, texture); memoryObjects.add(buffer); return buffer; } |