summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/gl/Shape.java85
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Button.java2
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/gl/shapes/CrossHair.java2
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Label.java4
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Rectangle.java2
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/gl/shapes/TexSeqButton.java2
6 files changed, 55 insertions, 42 deletions
diff --git a/src/graphui/classes/com/jogamp/graph/ui/gl/Shape.java b/src/graphui/classes/com/jogamp/graph/ui/gl/Shape.java
index 996182708..90a247379 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/gl/Shape.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/gl/Shape.java
@@ -73,11 +73,11 @@ public abstract class Shape {
public static interface Listener {
void run(final Shape shape);
}
- public static final boolean DRAW_DEBUG_BOX = false;
+ protected static final boolean DRAW_DEBUG_BOX = false;
private static final boolean DEBUG = false;
- protected static final int DIRTY_SHAPE = 1 << 0 ;
- protected static final int DIRTY_STATE = 1 << 1 ;
+ private static final int DIRTY_SHAPE = 1 << 0 ;
+ private static final int DIRTY_STATE = 1 << 1 ;
protected final Factory<? extends Vertex> vertexFactory;
private final int renderModes;
@@ -88,17 +88,18 @@ public abstract class Shape {
protected final AffineTransform tempT3 = new AffineTransform();
protected final AffineTransform tempT4 = new AffineTransform();
- protected final float[] position = new float[] { 0f, 0f, 0f };
- protected final Quaternion rotation = new Quaternion();
- protected final float[] rotOrigin = new float[] { 0f, 0f, 0f };
- protected final float[] scale = new float[] { 1f, 1f, 1f };
+ private final float[] position = new float[] { 0f, 0f, 0f };
+ private final Quaternion rotation = new Quaternion();
+ private final float[] rotOrigin = new float[] { 0f, 0f, 0f };
+ private final float[] scale = new float[] { 1f, 1f, 1f };
protected GLRegion region = null;
- protected int regionQuality = Region.MAX_QUALITY;
- protected List<GLRegion> dirtyRegions = new ArrayList<GLRegion>();
+ protected float oshapeSharpness = OutlineShape.DEFAULT_SHARPNESS;
+ private int regionQuality = Region.MAX_QUALITY;
+ private final List<GLRegion> dirtyRegions = new ArrayList<GLRegion>();
- protected int dirty = DIRTY_SHAPE | DIRTY_STATE;
- protected float shapesSharpness = OutlineShape.DEFAULT_SHARPNESS;
+ private volatile int dirty = DIRTY_SHAPE | DIRTY_STATE;
+ private final Object dirtySync = new Object();
/** Default base-color w/o color channel, will be modulated w/ pressed- and toggle color */
protected final float[] rgbaColor = {0.75f, 0.75f, 0.75f, 1.0f};
@@ -247,7 +248,9 @@ public abstract class Shape {
* to recreate the Graph shape and reset the region.
*/
public final void markShapeDirty() {
- dirty |= DIRTY_SHAPE;
+ synchronized ( dirtySync ) {
+ dirty |= DIRTY_SHAPE;
+ }
}
/**
@@ -255,7 +258,9 @@ public abstract class Shape {
* to notify the Graph region to reselect shader and repaint potentially used FBOs.
*/
public final void markStateDirty() {
- dirty |= DIRTY_STATE;
+ synchronized ( dirtySync ) {
+ dirty |= DIRTY_STATE;
+ }
}
private final boolean isShapeDirty() {
@@ -325,7 +330,10 @@ public abstract class Shape {
/** Experimental OpenGL selection draw command used by {@link Scene}. */
public void drawGLSelect(final GL2ES2 gl, final RegionRenderer renderer, final int[] sampleCount) {
- getRegion(gl).draw(gl, renderer, sampleCount);
+ synchronized ( dirtySync ) {
+ validate(gl);
+ region.draw(gl, renderer, sampleCount);
+ }
}
/**
@@ -391,7 +399,10 @@ public abstract class Shape {
}
}
renderer.getRenderState().setColorStatic(r, g, b, a);
- getRegion(gl).draw(gl, renderer, sampleCount);
+ synchronized ( dirtySync ) {
+ validate(gl);
+ region.draw(gl, renderer, sampleCount);
+ }
}
protected GLRegion createGLRegion(final GLProfile glp) {
@@ -420,26 +431,28 @@ public abstract class Shape {
public final void validate(final GLProfile glp) {
validateImpl(glp, null);
}
- private final synchronized void validateImpl(final GLProfile glp, final GL2ES2 gl) {
- if( null != gl ) {
- clearDirtyRegions(gl);
- }
- if( isShapeDirty() || null == region ) {
- box.reset();
- if( null == region ) {
- region = createGLRegion(glp);
- } else if( null == gl ) {
- dirtyRegions.add(region);
- region = createGLRegion(glp);
- } else {
- region.clear(gl);
+ private final void validateImpl(final GLProfile glp, final GL2ES2 gl) {
+ synchronized ( dirtySync ) {
+ if( null != gl ) {
+ clearDirtyRegions(gl);
+ }
+ if( isShapeDirty() || null == region ) {
+ box.reset();
+ if( null == region ) {
+ region = createGLRegion(glp);
+ } else if( null == gl ) {
+ dirtyRegions.add(region);
+ region = createGLRegion(glp);
+ } else {
+ region.clear(gl);
+ }
+ addShapeToRegion();
+ region.setQuality(regionQuality);
+ dirty &= ~(DIRTY_SHAPE|DIRTY_STATE);
+ } else if( isStateDirty() ) {
+ region.markStateDirty();
+ dirty &= ~DIRTY_STATE;
}
- addShapeToRegion();
- region.setQuality(regionQuality);
- dirty &= ~(DIRTY_SHAPE|DIRTY_STATE);
- } else if( isStateDirty() ) {
- region.markStateDirty();
- dirty &= ~DIRTY_STATE;
}
}
@@ -750,11 +763,11 @@ public abstract class Shape {
}
}
public final void setSharpness(final float sharpness) {
- this.shapesSharpness = sharpness;
+ this.oshapeSharpness = sharpness;
markShapeDirty();
}
public final float getSharpness() {
- return shapesSharpness;
+ return oshapeSharpness;
}
/**
diff --git a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Button.java b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Button.java
index 3774b7b1f..b7d392177 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Button.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Button.java
@@ -92,7 +92,7 @@ public class Button extends RoundButton {
createCurvedOutline(shape, twoPassLabelZOffset);
}
shape.setIsQuadraticNurbs();
- shape.setSharpness(shapesSharpness);
+ shape.setSharpness(oshapeSharpness);
region.addOutlineShape(shape, null, rgbaColor);
box.resize(shape.getBounds());
diff --git a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/CrossHair.java b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/CrossHair.java
index ac09ea395..e8ec28d36 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/CrossHair.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/CrossHair.java
@@ -86,7 +86,7 @@ public class CrossHair extends Shape {
shape.closePath();
shape.setIsQuadraticNurbs();
- shape.setSharpness(shapesSharpness);
+ shape.setSharpness(oshapeSharpness);
region.addOutlineShape(shape, null, rgbaColor);
box.resize(shape.getBounds());
diff --git a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Label.java b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Label.java
index 7db220537..e55526fd7 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Label.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Label.java
@@ -88,7 +88,7 @@ public class Label extends Shape {
* @param text the text to be set.
* @return true if text has been updated, false if unchanged.
*/
- public boolean setText(final GL2ES2 gl, final String text) {
+ public boolean setText(final GL2ES2 gl, final String text) {
if( setText(text) ) {
validate(gl);
return true;
@@ -162,7 +162,7 @@ public class Label extends Shape {
private final OutlineShape.Visitor shapeVisitor = new OutlineShape.Visitor() {
@Override
public void visit(final OutlineShape shape, final AffineTransform t) {
- shape.setSharpness(shapesSharpness);
+ shape.setSharpness(oshapeSharpness);
try {
region.addOutlineShape(shape, t, rgbaColor);
} catch ( final Exception ex ) {
diff --git a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Rectangle.java b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Rectangle.java
index ced2a2849..f027d92bc 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Rectangle.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Rectangle.java
@@ -91,7 +91,7 @@ public class Rectangle extends Shape {
shape.closePath();
shape.setIsQuadraticNurbs();
- shape.setSharpness(shapesSharpness);
+ shape.setSharpness(oshapeSharpness);
region.addOutlineShape(shape, null, rgbaColor);
box.resize(shape.getBounds());
diff --git a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/TexSeqButton.java b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/TexSeqButton.java
index 41dd196e0..19d9a228a 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/TexSeqButton.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/TexSeqButton.java
@@ -69,7 +69,7 @@ public abstract class TexSeqButton extends RoundButton {
createCurvedOutline(shape, 0f);
}
shape.setIsQuadraticNurbs();
- shape.setSharpness(shapesSharpness);
+ shape.setSharpness(oshapeSharpness);
region.addOutlineShape(shape, null, rgbaColor);
box.resize(shape.getBounds());