Issue #2956 safety checks for GLShadedShapeBase
Change-Id: I7ec226af0de46ee3c7dffc34e82da9cf6846e451 Former-commit-id: 1249c06521c5575960605176dcd46b77cbe1a1bc
This commit is contained in:
parent
ec96b9a261
commit
8b93dffb4f
3 changed files with 47 additions and 11 deletions
|
@ -29,8 +29,8 @@ import com.raytheon.uf.viz.core.exception.VizException;
|
|||
import com.raytheon.viz.core.gl.GLGeometryObject2D.State;
|
||||
|
||||
/**
|
||||
* Separated from GLGeometryObject2D. Added checks on glDrawArrays and
|
||||
* glMultiDrawArrays.
|
||||
* Separated from GLGeometryObject2D. Adds checks on glDrawArrays and
|
||||
* glMultiDrawArrays to ensure valid values are passed in.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -38,7 +38,8 @@ import com.raytheon.viz.core.gl.GLGeometryObject2D.State;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 7, 2011 njensen Initial creation
|
||||
* Jun 07, 2011 njensen Initial creation
|
||||
* Apr 15, 2014 2956 njensen Fixed documentation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -48,6 +49,13 @@ import com.raytheon.viz.core.gl.GLGeometryObject2D.State;
|
|||
|
||||
public class GLGeometryPainter {
|
||||
|
||||
/**
|
||||
* Paints the geometries
|
||||
*
|
||||
* @param gl
|
||||
* @param geoms
|
||||
* @throws VizException
|
||||
*/
|
||||
public static void paintGeometries(GL gl, GLGeometryObject2D... geoms)
|
||||
throws VizException {
|
||||
State state = State.INVALID;
|
||||
|
@ -70,7 +78,7 @@ public class GLGeometryPainter {
|
|||
if (geom.data.mutable == false) {
|
||||
throw new VizException(
|
||||
"Could not paint, geometry was not created "
|
||||
+ "as mutable but in in the mutable state."
|
||||
+ "as mutable but is in the mutable state."
|
||||
+ " Geometry must be compiled before use");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ import org.opengis.referencing.operation.TransformException;
|
|||
import com.raytheon.uf.common.geospatial.TransformFactory;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.viz.core.drawables.IShape;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.viz.core.gl.Activator;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
import com.vividsolutions.jts.geom.LineString;
|
||||
|
@ -56,9 +57,11 @@ import com.vividsolutions.jts.geom.LineString;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Sep 3, 2011 bsteffen Initial creation
|
||||
* Sep 3, 2011 bsteffen Initial creation
|
||||
* Apr 25, 2013 1954 bsteffen Speed up creation of
|
||||
* GLColormapShadedShapes.
|
||||
* Apr 15, 2014 2956 njensen Safety check of buffers before glMultiDrawArray
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -148,6 +151,7 @@ public class GLShadedShapeBase implements IShape {
|
|||
polygons.add(buffers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void compile() {
|
||||
if (polygons.isEmpty()) {
|
||||
return;
|
||||
|
@ -314,7 +318,8 @@ public class GLShadedShapeBase implements IShape {
|
|||
}
|
||||
|
||||
protected synchronized void paint(GL gl,
|
||||
boolean cardSupportsHighEndFeatures, float brightness) {
|
||||
boolean cardSupportsHighEndFeatures, float brightness)
|
||||
throws VizException {
|
||||
if (!polygons.isEmpty()) {
|
||||
compile();
|
||||
}
|
||||
|
@ -353,8 +358,17 @@ public class GLShadedShapeBase implements IShape {
|
|||
contourLengthBuffer.rewind();
|
||||
contourStartBuffer.rewind();
|
||||
if (cardSupportsHighEndFeatures) {
|
||||
gl.glMultiDrawArrays(GL.GL_POLYGON, contourStartBuffer,
|
||||
contourLengthBuffer, contourLengthBuffer.capacity());
|
||||
if (contourStartBuffer.capacity() > 0
|
||||
&& contourLengthBuffer.capacity() > 0) {
|
||||
gl.glMultiDrawArrays(GL.GL_POLYGON, contourStartBuffer,
|
||||
contourLengthBuffer, contourLengthBuffer.capacity());
|
||||
} else {
|
||||
throw new VizException(
|
||||
"Dangerous parameters passed to glMultiDrawArrays: contourStartBufferCapacity="
|
||||
+ contourStartBuffer.capacity()
|
||||
+ ", contourLengthBufferCapacity="
|
||||
+ contourLengthBuffer.capacity());
|
||||
}
|
||||
} else {
|
||||
while (contourLengthBuffer.hasRemaining()) {
|
||||
gl.glDrawArrays(GL.GL_POLYGON, contourStartBuffer.get(),
|
||||
|
@ -368,6 +382,7 @@ public class GLShadedShapeBase implements IShape {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void dispose() {
|
||||
polygons = new ArrayList<FloatBuffer[]>();
|
||||
vertexBuffer = null;
|
||||
|
@ -383,14 +398,17 @@ public class GLShadedShapeBase implements IShape {
|
|||
|
||||
private class Tessellator implements GLUtessellatorCallback {
|
||||
|
||||
@Override
|
||||
public void begin(int arg0) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beginData(int arg0, Object arg1) {
|
||||
// Not necessary for type of tesselation
|
||||
}
|
||||
|
||||
@Override
|
||||
public void combine(double[] coordinates, Object[] v, float[] arg2,
|
||||
Object[] out) {
|
||||
double[] vertex = new double[3];
|
||||
|
@ -400,37 +418,45 @@ public class GLShadedShapeBase implements IShape {
|
|||
out[0] = vertex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void combineData(double[] arg0, Object[] arg1, float[] arg2,
|
||||
Object[] arg3, Object arg4) {
|
||||
// Not necessary for type of tesselation
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void edgeFlag(boolean arg0) {
|
||||
// No operation, but needed to force GL_TRIANGLES
|
||||
}
|
||||
|
||||
@Override
|
||||
public void edgeFlagData(boolean arg0, Object arg1) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void end() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endData(Object arg0) {
|
||||
// Not necessary for type of tesselation
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(int arg0) {
|
||||
System.err.println("Tess Error: " + arg0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void errorData(int arg0, Object arg1) {
|
||||
// Not necessary for type of tesselation
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void vertex(Object data) {
|
||||
if (data instanceof double[]) {
|
||||
if (vertexBuffer.remaining() < 2) {
|
||||
|
@ -448,6 +474,7 @@ public class GLShadedShapeBase implements IShape {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void vertexData(Object arg0, Object arg1) {
|
||||
// Not necessary for type of tesselation
|
||||
}
|
||||
|
|
|
@ -144,6 +144,7 @@ import com.sun.opengl.util.j2d.TextRenderer;
|
|||
* if changed
|
||||
* Apr 04, 2014 2920 bsteffen Allow strings to use mulitple styles.
|
||||
* Apr 08, 2014 2950 bsteffen Reduce oversized colormaps.
|
||||
* Apr 15, 2014 2956 njensen Throw VizException from drawShadedShapesInternal
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -836,7 +837,7 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
|
|||
}
|
||||
|
||||
private void drawShadedShapesInternal(List<GLShadedShape> shapes,
|
||||
float alpha, float brightness) {
|
||||
float alpha, float brightness) throws VizException {
|
||||
brightness = Math.max(brightness, 0.0f);
|
||||
brightness = Math.min(brightness, 1.0f);
|
||||
|
||||
|
@ -1270,9 +1271,9 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
|
|||
}
|
||||
statusHandler.info("Reducing colormap to " + lessColors.size()
|
||||
+ " colors because this graphics card only supports "
|
||||
+ capabilities.maxTextureSize
|
||||
+ capabilities.maxTextureSize
|
||||
+ " colors and the colormap contains "
|
||||
+ glColorMap.getSize() + " colors.");
|
||||
+ glColorMap.getSize() + " colors.");
|
||||
glColorMap = new ColorMap(lessColors.size());
|
||||
for (int i = 0; i < lessColors.size(); i += 1) {
|
||||
glColorMap.setColor(i, lessColors.get(i));
|
||||
|
|
Loading…
Add table
Reference in a new issue