diff options
author | Harvey Harrison <[email protected]> | 2012-01-07 22:54:28 -0800 |
---|---|---|
committer | Harvey Harrison <[email protected]> | 2012-01-07 22:54:28 -0800 |
commit | 483dd25244c25f7fd6345d0ef6499679b9588748 (patch) | |
tree | 0e7996064eeeec3155171ea886bc3369c084d813 | |
parent | a908b3034b996d6ab2e3b1673d920dfa773d8e62 (diff) |
j3dcore: type annotations in ShaderBin and related code
Signed-off-by: Harvey Harrison <[email protected]>
4 files changed, 52 insertions, 54 deletions
diff --git a/src/classes/share/javax/media/j3d/RenderBin.java b/src/classes/share/javax/media/j3d/RenderBin.java index 962cb03..a2f9007 100644 --- a/src/classes/share/javax/media/j3d/RenderBin.java +++ b/src/classes/share/javax/media/j3d/RenderBin.java @@ -337,9 +337,9 @@ ArrayList<OrderedBin> obList = new ArrayList<OrderedBin>(5); private HashSet<RenderAtomListInfo> addDlist = new HashSet<RenderAtomListInfo>(); private HashSet<RenderAtomListInfo> removeDlist = new HashSet<RenderAtomListInfo>(); - // Separate dlists per rinfo that were added/removed in this snapshot - ArrayList addDlistPerRinfo = new ArrayList(5); - ArrayList removeDlistPerRinfo = new ArrayList(5); +// Separate dlists per rinfo that were added/removed in this snapshot +ArrayList<RenderAtomListInfo> addDlistPerRinfo = new ArrayList<RenderAtomListInfo>(5); +ArrayList<RenderAtomListInfo> removeDlistPerRinfo = new ArrayList<RenderAtomListInfo>(5); Locale locale = null; @@ -966,7 +966,7 @@ private HashSet<RenderAtomListInfo> removeDlist = new HashSet<RenderAtomListInfo } size = addDlistPerRinfo.size(); for (i = 0; i < size; i++) { - ra = (RenderAtomListInfo)addDlistPerRinfo.get(i); + ra = addDlistPerRinfo.get(i); if (ra.geometry() != null) { dlistLockList.add(ra.geometry()); } @@ -1199,7 +1199,7 @@ private HashSet<RenderAtomListInfo> removeDlist = new HashSet<RenderAtomListInfo if (size > 0) { for (int j = 0; j < size; j++) { - RenderAtomListInfo rinfo = (RenderAtomListInfo)addDlistPerRinfo.get(j); + RenderAtomListInfo rinfo = addDlistPerRinfo.get(j); if (rinfo.renderAtom.inRenderBin()) { Object[] obj = new Object[2]; obj[0] = rinfo; @@ -1266,7 +1266,7 @@ private HashSet<RenderAtomListInfo> removeDlist = new HashSet<RenderAtomListInfo // Take care of display list that should be freed size = removeDlistPerRinfo.size(); for (int j=0; j < size; j++) { - RenderAtomListInfo ra = (RenderAtomListInfo)removeDlistPerRinfo.get(j); + RenderAtomListInfo ra = removeDlistPerRinfo.get(j); rdr.displayListResourceFreeList.add(new Integer(ra.renderAtom.dlistIds[ra.index])); ra.groupType = 0; ra.renderAtom.dlistIds[ra.index] = -1; @@ -1287,7 +1287,7 @@ private HashSet<RenderAtomListInfo> removeDlist = new HashSet<RenderAtomListInfo int size = addDlistPerRinfo.size(); if (size > 0) { for ( j = 0; j < size; j++) { - RenderAtomListInfo rinfo = (RenderAtomListInfo)addDlistPerRinfo.get(j); + RenderAtomListInfo rinfo = addDlistPerRinfo.get(j); if (rinfo.renderAtom.inRenderBin()) { Object[] obj = new Object[2]; obj[0] = rinfo; @@ -1339,7 +1339,7 @@ private HashSet<RenderAtomListInfo> removeDlist = new HashSet<RenderAtomListInfo // Take care of display list that should be freed size = removeDlistPerRinfo.size(); for (j=0; j < size; j++) { - RenderAtomListInfo ra = (RenderAtomListInfo)removeDlistPerRinfo.get(j); + RenderAtomListInfo ra = removeDlistPerRinfo.get(j); cv.displayListResourceFreeList.add(new Integer(ra.renderAtom.dlistIds[ra.index])); ra.groupType = 0; ra.renderAtom.dlistIds[ra.index] = -1; @@ -4741,7 +4741,7 @@ System.err.println("......tb.soleUser= " + // Check the "to-be-added" list of TextureBins for a match size = shaderBin.addTextureBins.size(); for (i = 0; i < size; i++) { - currentBin = (TextureBin)shaderBin.addTextureBins.get(i); + currentBin = shaderBin.addTextureBins.get(i); if (currentBin.equals(texUnitState, ra)) { //System.err.println("2: Equal"); return(currentBin); diff --git a/src/classes/share/javax/media/j3d/ShaderAttributeSetRetained.java b/src/classes/share/javax/media/j3d/ShaderAttributeSetRetained.java index ab64feb..29207d8 100644 --- a/src/classes/share/javax/media/j3d/ShaderAttributeSetRetained.java +++ b/src/classes/share/javax/media/j3d/ShaderAttributeSetRetained.java @@ -44,7 +44,7 @@ import java.util.Map; class ShaderAttributeSetRetained extends NodeComponentRetained { - private Map attrs = new HashMap(); +private Map<String, ShaderAttributeRetained> attrs = new HashMap<String, ShaderAttributeRetained>(); // Lock used for synchronization of live state Object liveStateLock = new Object(); @@ -98,7 +98,7 @@ class ShaderAttributeSetRetained extends NodeComponentRetained { * not set and this object is part of live or compiled scene graph */ ShaderAttribute get(String attrName) { - return (ShaderAttribute)((ShaderAttributeRetained)attrs.get(attrName)).source; + return (ShaderAttribute)attrs.get(attrName).source; } /** @@ -110,7 +110,7 @@ class ShaderAttributeSetRetained extends NodeComponentRetained { */ void remove(String attrName) { synchronized(liveStateLock) { - ShaderAttributeRetained sAttr = (ShaderAttributeRetained)attrs.get(attrName); + ShaderAttributeRetained sAttr = attrs.get(attrName); attrs.remove(attrName); if (source.isLive()) { sAttr.clearLive(refCount); @@ -157,7 +157,7 @@ class ShaderAttributeSetRetained extends NodeComponentRetained { attrs.clear(); if(source.isLive()) { ShaderAttributeRetained[] sAttrs = new ShaderAttributeRetained[attrs.size()]; - sAttrs = (ShaderAttributeRetained[])attrs.values().toArray(sAttrs); + sAttrs = attrs.values().toArray(sAttrs); for (int i = 0; i < sAttrs.length; i++) { sAttrs[i].clearLive(refCount); sAttrs[i].removeMirrorUsers(this); @@ -177,7 +177,7 @@ class ShaderAttributeSetRetained extends NodeComponentRetained { ShaderAttributeRetained[] sAttrsRetained = new ShaderAttributeRetained[attrs.size()]; ShaderAttribute[] sAttrs = new ShaderAttribute[sAttrsRetained.length]; - sAttrsRetained = (ShaderAttributeRetained[])attrs.values().toArray(sAttrsRetained); + sAttrsRetained = attrs.values().toArray(sAttrsRetained); for(int i=0; i < sAttrsRetained.length; i++) { sAttrs[i] = (ShaderAttribute) sAttrsRetained[i].source; } @@ -200,16 +200,15 @@ class ShaderAttributeSetRetained extends NodeComponentRetained { shaderProgram.setShaderAttributes(cv, this); } - Map getAttrs() { - return attrs; - } - +Map<String, ShaderAttributeRetained> getAttrs() { + return attrs; +} void setLive(boolean backgroundGroup, int refCount) { // System.err.println("ShaderAttributeSetRetained.setLive()"); ShaderAttributeRetained[] sAttrsRetained = new ShaderAttributeRetained[attrs.size()]; - sAttrsRetained = (ShaderAttributeRetained[])attrs.values().toArray(sAttrsRetained); + sAttrsRetained = attrs.values().toArray(sAttrsRetained); for(int i=0; i < sAttrsRetained.length; i++) { sAttrsRetained[i].setLive(backgroundGroup, refCount); } @@ -223,7 +222,7 @@ class ShaderAttributeSetRetained extends NodeComponentRetained { super.addAMirrorUser(shape); ShaderAttributeRetained[] sAttrsRetained = new ShaderAttributeRetained[attrs.size()]; - sAttrsRetained = (ShaderAttributeRetained[])attrs.values().toArray(sAttrsRetained); + sAttrsRetained = attrs.values().toArray(sAttrsRetained); for(int i=0; i < sAttrsRetained.length; i++) { sAttrsRetained[i].addAMirrorUser(shape); } @@ -233,7 +232,7 @@ class ShaderAttributeSetRetained extends NodeComponentRetained { super.removeAMirrorUser(shape); ShaderAttributeRetained[] sAttrsRetained = new ShaderAttributeRetained[attrs.size()]; - sAttrsRetained = (ShaderAttributeRetained[])attrs.values().toArray(sAttrsRetained); + sAttrsRetained = attrs.values().toArray(sAttrsRetained); for(int i=0; i < sAttrsRetained.length; i++) { sAttrsRetained[i].removeAMirrorUser(shape); } @@ -244,7 +243,7 @@ class ShaderAttributeSetRetained extends NodeComponentRetained { super.removeMirrorUsers(node); ShaderAttributeRetained[] sAttrsRetained = new ShaderAttributeRetained[attrs.size()]; - sAttrsRetained = (ShaderAttributeRetained[])attrs.values().toArray(sAttrsRetained); + sAttrsRetained = attrs.values().toArray(sAttrsRetained); for(int i=0; i < sAttrsRetained.length; i++) { sAttrsRetained[i].removeMirrorUsers(node); } @@ -254,7 +253,7 @@ class ShaderAttributeSetRetained extends NodeComponentRetained { super.copyMirrorUsers(node); ShaderAttributeRetained[] sAttrsRetained = new ShaderAttributeRetained[attrs.size()]; - sAttrsRetained = (ShaderAttributeRetained[])attrs.values().toArray(sAttrsRetained); + sAttrsRetained = attrs.values().toArray(sAttrsRetained); for(int i=0; i < sAttrsRetained.length; i++) { sAttrsRetained[i].copyMirrorUsers(node); } @@ -266,7 +265,7 @@ class ShaderAttributeSetRetained extends NodeComponentRetained { super.clearLive(refCount); ShaderAttributeRetained[] sAttrsRetained = new ShaderAttributeRetained[attrs.size()]; - sAttrsRetained = (ShaderAttributeRetained[])attrs.values().toArray(sAttrsRetained); + sAttrsRetained = attrs.values().toArray(sAttrsRetained); for(int i=0; i < sAttrsRetained.length; i++) { sAttrsRetained[i].clearLive(refCount); } @@ -287,7 +286,7 @@ class ShaderAttributeSetRetained extends NodeComponentRetained { void initMirrorObject() { ShaderAttributeRetained[] sAttrs = new ShaderAttributeRetained[attrs.size()]; - sAttrs = (ShaderAttributeRetained[])attrs.values().toArray(sAttrs); + sAttrs = attrs.values().toArray(sAttrs); // Need to copy the mirror attrs for (int i = 0; i < sAttrs.length; i++) { ShaderAttributeRetained mirrorSA = (ShaderAttributeRetained) sAttrs[i].mirror; diff --git a/src/classes/share/javax/media/j3d/ShaderBin.java b/src/classes/share/javax/media/j3d/ShaderBin.java index 7dba9b4..c830805 100644 --- a/src/classes/share/javax/media/j3d/ShaderBin.java +++ b/src/classes/share/javax/media/j3d/ShaderBin.java @@ -32,7 +32,7 @@ package javax.media.j3d; import java.util.ArrayList; -import java.util.HashMap; +import java.util.Map; // XXXX : We should have a common Bin object that all other Bins extend from. @@ -70,10 +70,10 @@ class ShaderBin implements ObjectUpdate { */ TextureBin textureBinList = null; - /** - * The list of TextureBins to be added for the next frame - */ - ArrayList addTextureBins = new ArrayList(); +/** + * The list of TextureBins to be added for the next frame + */ +ArrayList<TextureBin> addTextureBins = new ArrayList<TextureBin>(); boolean onUpdateList = false; @@ -141,7 +141,7 @@ class ShaderBin implements ObjectUpdate { int i; if (addTextureBins.size() > 0) { - t = (TextureBin)addTextureBins.get(0); + t = addTextureBins.get(0); if (textureBinList == null) { textureBinList = t; @@ -151,7 +151,7 @@ class ShaderBin implements ObjectUpdate { insertTextureBin(t); } for (i = 1; i < addTextureBins.size() ; i++) { - t = (TextureBin)addTextureBins.get(i); + t = addTextureBins.get(i); // Look for a TextureBin that has the same texture insertTextureBin(t); @@ -164,7 +164,6 @@ class ShaderBin implements ObjectUpdate { void insertTextureBin(TextureBin t) { TextureBin tb; - int i; TextureRetained texture = null; if (t.texUnitState != null && t.texUnitState.length > 0) { @@ -352,7 +351,7 @@ class ShaderBin implements ObjectUpdate { if ((componentDirty & SHADER_ATTRIBUTE_SET_DIRTY) != 0) { // System.err.println(" - SHADER_ATTRIBUTE_SET_DIRTY"); - HashMap attrs = (HashMap)shaderAttributeSet.getAttrs(); + Map<String, ShaderAttributeRetained> attrs = shaderAttributeSet.getAttrs(); attrs.clear(); if(shaderAppearance.shaderAttributeSet != null) { attrs.putAll(shaderAppearance.shaderAttributeSet.getAttrs()); diff --git a/src/classes/share/javax/media/j3d/ShaderProgramRetained.java b/src/classes/share/javax/media/j3d/ShaderProgramRetained.java index ec30af6..f62a0cd 100644 --- a/src/classes/share/javax/media/j3d/ShaderProgramRetained.java +++ b/src/classes/share/javax/media/j3d/ShaderProgramRetained.java @@ -69,8 +69,8 @@ abstract class ShaderProgramRetained extends NodeComponentRetained { // an array of (uniform) shader attribute names protected String[] shaderAttrNames; - // Set of ShaderAttribute objects for which we have already reported an error - private HashSet shaderAttrErrorSet = null; +// Set of ShaderAttribute objects for which we have already reported an error +private HashSet<ShaderAttribute> shaderAttrErrorSet = null; // need to synchronize access from multiple rendering threads Object resourceLock = new Object(); @@ -98,7 +98,7 @@ abstract class ShaderProgramRetained extends NodeComponentRetained { this.vertexAttrNames = null; } else { - this.vertexAttrNames = (String[])vertexAttrNames.clone(); + this.vertexAttrNames = vertexAttrNames.clone(); } } @@ -115,7 +115,7 @@ abstract class ShaderProgramRetained extends NodeComponentRetained { return null; } - return (String[])vertexAttrNames.clone(); + return vertexAttrNames.clone(); } @@ -137,7 +137,7 @@ abstract class ShaderProgramRetained extends NodeComponentRetained { this.shaderAttrNames = null; } else { - this.shaderAttrNames = (String[])shaderAttrNames.clone(); + this.shaderAttrNames = shaderAttrNames.clone(); } } @@ -155,7 +155,7 @@ abstract class ShaderProgramRetained extends NodeComponentRetained { return null; } - return (String[])shaderAttrNames.clone(); + return shaderAttrNames.clone(); } @@ -471,7 +471,7 @@ abstract class ShaderProgramRetained extends NodeComponentRetained { ((ShaderProgramRetained)mirror).vertexAttrNames = null; } else { - ((ShaderProgramRetained)mirror).vertexAttrNames = (String[])this.vertexAttrNames.clone(); + ((ShaderProgramRetained)mirror).vertexAttrNames = this.vertexAttrNames.clone(); } // Create mirror copy of shader attribute names @@ -479,7 +479,7 @@ abstract class ShaderProgramRetained extends NodeComponentRetained { ((ShaderProgramRetained)mirror).shaderAttrNames = null; } else { - ((ShaderProgramRetained)mirror).shaderAttrNames = (String[])this.shaderAttrNames.clone(); + ((ShaderProgramRetained)mirror).shaderAttrNames = this.shaderAttrNames.clone(); } // Clear shader attribute error set @@ -1073,10 +1073,10 @@ abstract class ShaderProgramRetained extends NodeComponentRetained { ShaderProgramId shaderProgramId = spData.getShaderProgramId(); - Iterator attrs = attributeSet.getAttrs().values().iterator(); + Iterator<ShaderAttributeRetained> attrs = attributeSet.getAttrs().values().iterator(); while (attrs.hasNext()) { ShaderError err = null; - ShaderAttributeRetained saRetained = (ShaderAttributeRetained)attrs.next(); + ShaderAttributeRetained saRetained = attrs.next(); // Lookup attribute info for the specified attrName; null means // that the name does not appear in the ShaderProgram, so we will @@ -1122,9 +1122,9 @@ abstract class ShaderProgramRetained extends NodeComponentRetained { // Before reporting the ShaderAttribute error, check // whether it has already been reported for this ShaderProgram if (shaderAttrErrorSet == null) { - shaderAttrErrorSet = new HashSet(); + shaderAttrErrorSet = new HashSet<ShaderAttribute>(); } - if (shaderAttrErrorSet.add(saRetained.source)) { + if (shaderAttrErrorSet.add((ShaderAttribute) saRetained.source)) { err.setShaderProgram((ShaderProgram)this.source); err.setShaderAttributeSet((ShaderAttributeSet)attributeSet.source); err.setShaderAttribute((ShaderAttribute)saRetained.source); @@ -1147,7 +1147,7 @@ abstract class ShaderProgramRetained extends NodeComponentRetained { private boolean linked = false; // A map of locations for ShaderAttributes. - private HashMap attrNameInfoMap = new HashMap(); +private HashMap<String, AttrNameInfo> attrNameInfoMap = new HashMap<String, AttrNameInfo>(); /** ShaderProgramData Constructor */ ShaderProgramData() { @@ -1184,14 +1184,14 @@ abstract class ShaderProgramRetained extends NodeComponentRetained { return linked; } - void setAttrNameInfo(String shaderAttribute, AttrNameInfo attrNameInfo) { - assert(shaderAttribute != null); - attrNameInfoMap.put(shaderAttribute, attrNameInfo); - } +void setAttrNameInfo(String shaderAttribute, AttrNameInfo attrNameInfo) { + assert (shaderAttribute != null); + attrNameInfoMap.put(shaderAttribute, attrNameInfo); +} - AttrNameInfo getAttrNameInfo(String shaderAttribute) { - return (AttrNameInfo) attrNameInfoMap.get(shaderAttribute); - } +AttrNameInfo getAttrNameInfo(String shaderAttribute) { + return attrNameInfoMap.get(shaderAttribute); +} } |