diff options
author | Sven Gothel <[email protected]> | 2019-09-07 18:48:42 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2019-09-07 18:48:42 +0200 |
commit | 125e4bd1c8e0a8f4b434209b155e6cd0d8f09092 (patch) | |
tree | b221b78623c891af56453b3d8eaff521d22ce0df /src | |
parent | 7f6d030ba91060aa4dedbf4311290c5cf5f61c4a (diff) |
Bug 1392: Simplify CapabilitiesFilter: Criteria -> Test, remove RemovalCriteria as all Test definitions may be used for anything.
Diffstat (limited to 'src')
3 files changed, 28 insertions, 31 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/GLCapabilitiesFilter.java b/src/jogl/classes/com/jogamp/opengl/GLCapabilitiesFilter.java index d2479f47d..0d713d33b 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLCapabilitiesFilter.java +++ b/src/jogl/classes/com/jogamp/opengl/GLCapabilitiesFilter.java @@ -39,18 +39,18 @@ import com.jogamp.nativewindow.CapabilitiesFilter; public class GLCapabilitiesFilter extends CapabilitiesFilter { protected GLCapabilitiesFilter() {} - public static class RemoveLessDepthBits<C extends GLCapabilitiesImmutable> implements RemovalCriteria<C> { + public static class TestLessDepthBits<C extends GLCapabilitiesImmutable> implements Test<C> { final int minDepthBits; - public RemoveLessDepthBits(final int minDepthBits) { + public TestLessDepthBits(final int minDepthBits) { this.minDepthBits = minDepthBits; } public final boolean match(final C cap) { return cap.getDepthBits() < minDepthBits; } } - public static class RemoveMoreDepthBits<C extends GLCapabilitiesImmutable> implements RemovalCriteria<C> { + public static class TestMoreDepthBits<C extends GLCapabilitiesImmutable> implements Test<C> { final int maxDepthBits; - public RemoveMoreDepthBits(final int maxDepthBits) { + public TestMoreDepthBits(final int maxDepthBits) { this.maxDepthBits = maxDepthBits; } public final boolean match(final C cap) { @@ -66,8 +66,8 @@ public class GLCapabilitiesFilter extends CapabilitiesFilter { */ public static <C extends GLCapabilitiesImmutable> ArrayList<C> removeLessDepthBits(final ArrayList<C> availableCaps, final int minDepthBits) { - final ArrayList<RemovalCriteria<C>> criteria = new ArrayList<RemovalCriteria<C>>(); - criteria.add(new RemoveLessDepthBits<C>(minDepthBits)); + final ArrayList<Test<C>> criteria = new ArrayList<Test<C>>(); + criteria.add(new TestLessDepthBits<C>(minDepthBits)); return CapabilitiesFilter.removeMatching(availableCaps, criteria); } } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java index 98d16a0d2..929be16e3 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java @@ -48,7 +48,7 @@ import com.jogamp.nativewindow.CapabilitiesImmutable; import com.jogamp.nativewindow.GraphicsConfigurationFactory; import com.jogamp.nativewindow.NativeWindowFactory; import com.jogamp.nativewindow.VisualIDHolder; -import com.jogamp.nativewindow.CapabilitiesFilter.RemovalCriteria; +import com.jogamp.nativewindow.CapabilitiesFilter.Test; import com.jogamp.nativewindow.VisualIDHolder.VIDType; import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLCapabilitiesChooser; @@ -440,16 +440,16 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact } // Filter availableCaps { - final ArrayList<RemovalCriteria<GLCapabilitiesImmutable>> criteria = new ArrayList<RemovalCriteria<GLCapabilitiesImmutable>>(); + final ArrayList<Test<GLCapabilitiesImmutable>> criteria = new ArrayList<Test<GLCapabilitiesImmutable>>(); if( !skipCapsChooser && isPBufferOrBitmap && GLRendererQuirks.exist(glrq, GLRendererQuirks.No10BitColorCompOffscreen) ) { - criteria.add(new CapabilitiesFilter.RemoveMoreColorCompBits<GLCapabilitiesImmutable>(8)); + criteria.add(new CapabilitiesFilter.TestMoreColorCompBits<GLCapabilitiesImmutable>(8)); } if( VisualIDHolder.VID_UNDEFINED != nativeVisualID) { - criteria.add(new CapabilitiesFilter.RemoveUnmatchedNativeVisualID<GLCapabilitiesImmutable>(nativeVisualID)); + criteria.add(new CapabilitiesFilter.TestUnmatchedNativeVisualID<GLCapabilitiesImmutable>(nativeVisualID)); } if( 0 < capsChosen.getDepthBits() ) { // Hack for HiSilicon/Vivante/Immersion.16 Renderer .. - criteria.add(new GLCapabilitiesFilter.RemoveLessDepthBits<GLCapabilitiesImmutable>(1)); + criteria.add(new GLCapabilitiesFilter.TestLessDepthBits<GLCapabilitiesImmutable>(1)); } if( criteria.size() > 0 ) { final ArrayList<GLCapabilitiesImmutable> removedCaps = CapabilitiesFilter.removeMatching(availableCaps, criteria); diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/CapabilitiesFilter.java b/src/nativewindow/classes/com/jogamp/nativewindow/CapabilitiesFilter.java index d7785bc48..17bab355e 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/CapabilitiesFilter.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/CapabilitiesFilter.java @@ -40,16 +40,13 @@ public class CapabilitiesFilter { protected CapabilitiesFilter() {} /** Generic filter criteria */ - public static interface Criteria<C extends CapabilitiesImmutable> { + public static interface Test<C extends CapabilitiesImmutable> { public boolean match(final C cap); } - /** Filter {@link Criteria} for removal */ - public static interface RemovalCriteria<C extends CapabilitiesImmutable> extends Criteria<C> { - } - public static class RemoveLessColorCompBits<C extends CapabilitiesImmutable> implements RemovalCriteria<C> { + public static class TestLessColorCompBits<C extends CapabilitiesImmutable> implements Test<C> { final int minColorCompBits; - public RemoveLessColorCompBits(final int minColorCompBits) { + public TestLessColorCompBits(final int minColorCompBits) { this.minColorCompBits = minColorCompBits; } public final boolean match(final C cap) { @@ -59,9 +56,9 @@ public class CapabilitiesFilter { cap.getAlphaBits() < minColorCompBits; } } - public static class RemoveMoreColorCompBits<C extends CapabilitiesImmutable> implements RemovalCriteria<C> { + public static class TestMoreColorCompBits<C extends CapabilitiesImmutable> implements Test<C> { final int maxColorCompBits; - public RemoveMoreColorCompBits(final int maxColorCompBits) { + public TestMoreColorCompBits(final int maxColorCompBits) { this.maxColorCompBits = maxColorCompBits; } public final boolean match(final C cap) { @@ -71,9 +68,9 @@ public class CapabilitiesFilter { cap.getAlphaBits() > maxColorCompBits; } } - public static class RemoveUnmatchedNativeVisualID<C extends CapabilitiesImmutable> implements RemovalCriteria<C> { + public static class TestUnmatchedNativeVisualID<C extends CapabilitiesImmutable> implements Test<C> { final int requiredNativeVisualID; - public RemoveUnmatchedNativeVisualID(final int requiredNativeVisualID) { + public TestUnmatchedNativeVisualID(final int requiredNativeVisualID) { this.requiredNativeVisualID = requiredNativeVisualID; } public final boolean match(final C cap) { @@ -82,12 +79,12 @@ public class CapabilitiesFilter { } /** - * Removing all {@link CapabilitiesImmutable} derived elements matching the given {@code criteria} {@link RemovalCriteria} list. + * Removing all {@link CapabilitiesImmutable} derived elements matching the given {@code criteria} {@link Test} list. * @param availableCaps {@link CapabilitiesImmutable} derived list to be filtered - * @param criteria {@link RemovalCriteria} list run on all non-removed {@link CapabilitiesImmutable} derived elements + * @param criteria {@link Test} list run on all non-removed {@link CapabilitiesImmutable} derived elements * @return the list of removed {@link CapabilitiesImmutable} derived elements, might be of size 0 if none were removed. */ - public static <C extends CapabilitiesImmutable> ArrayList<C> removeMatching(final ArrayList<C> availableCaps, final List<RemovalCriteria<C>> criteria) { + public static <C extends CapabilitiesImmutable> ArrayList<C> removeMatching(final ArrayList<C> availableCaps, final List<Test<C>> criteria) { final ArrayList<C> removedCaps = new ArrayList<C>(); for(int i=0; i<availableCaps.size(); ) { final C cap = availableCaps.get(i); @@ -120,8 +117,8 @@ public class CapabilitiesFilter { if( VisualIDHolder.VID_UNDEFINED == requiredNativeVisualID) { return new ArrayList<C>(); } - final ArrayList<RemovalCriteria<C>> criteria = new ArrayList<RemovalCriteria<C>>(); - criteria.add(new CapabilitiesFilter.RemoveUnmatchedNativeVisualID<C>(requiredNativeVisualID)); + final ArrayList<Test<C>> criteria = new ArrayList<Test<C>>(); + criteria.add(new CapabilitiesFilter.TestUnmatchedNativeVisualID<C>(requiredNativeVisualID)); return removeMatching(availableCaps, criteria); } @@ -133,8 +130,8 @@ public class CapabilitiesFilter { */ public static <C extends CapabilitiesImmutable> ArrayList<C> removeMoreColorComps(final ArrayList<C> availableCaps, final int maxColorCompBits) { - final ArrayList<RemovalCriteria<C>> criteria = new ArrayList<RemovalCriteria<C>>(); - criteria.add(new CapabilitiesFilter.RemoveMoreColorCompBits<C>(maxColorCompBits)); + final ArrayList<Test<C>> criteria = new ArrayList<Test<C>>(); + criteria.add(new CapabilitiesFilter.TestMoreColorCompBits<C>(maxColorCompBits)); return removeMatching(availableCaps, criteria); } @@ -153,10 +150,10 @@ public class CapabilitiesFilter { */ public static <C extends CapabilitiesImmutable> ArrayList<C> removeMoreColorCompsAndUnmatchingNativeVisualID(final ArrayList<C> availableCaps, final int maxColorCompBits, final int requiredNativeVisualID) { - final ArrayList<RemovalCriteria<C>> criteria = new ArrayList<RemovalCriteria<C>>(); - criteria.add(new CapabilitiesFilter.RemoveMoreColorCompBits<C>(maxColorCompBits)); + final ArrayList<Test<C>> criteria = new ArrayList<Test<C>>(); + criteria.add(new CapabilitiesFilter.TestMoreColorCompBits<C>(maxColorCompBits)); if( VisualIDHolder.VID_UNDEFINED != requiredNativeVisualID) { - criteria.add(new CapabilitiesFilter.RemoveUnmatchedNativeVisualID<C>(requiredNativeVisualID)); + criteria.add(new CapabilitiesFilter.TestUnmatchedNativeVisualID<C>(requiredNativeVisualID)); } return removeMatching(availableCaps, criteria); } |