ReferencesStack now clears references when popping to avoid keeping buffer references around too long

This commit is contained in:
Elias Naur 2006-07-31 22:37:31 +00:00
parent 552b7ca3fc
commit 7b7ad52f29
3 changed files with 44 additions and 0 deletions

View File

@ -42,4 +42,24 @@ class References {
this.GL20_glVertexAttribPointer_buffer = references.GL20_glVertexAttribPointer_buffer;
this.NV_vertex_program_glVertexAttribPointerNV_buffer = references.NV_vertex_program_glVertexAttribPointerNV_buffer;
}
void clear() {
this.ARB_matrix_palette_glMatrixIndexPointerARB_pPointer = null;
this.ARB_vertex_blend_glWeightPointerARB_pPointer = null;
this.ARB_vertex_program_glVertexAttribPointerARB_buffer = null;
this.ARB_vertex_shader_glVertexAttribPointerARB_buffer = null;
this.ATI_element_array_glElementPointerATI_pPointer = null;
this.EXT_fog_coord_glFogCoordPointerEXT_data = null;
this.EXT_secondary_color_glSecondaryColorPointerEXT_pPointer = null;
this.EXT_vertex_shader_glVariantPointerEXT_pAddr = null;
this.EXT_vertex_weighting_glVertexWeightPointerEXT_pPointer = null;
this.GL11_glColorPointer_pointer = null;
this.GL11_glEdgeFlagPointer_pointer = null;
this.GL11_glNormalPointer_pointer = null;
this.GL11_glSelectBuffer_buffer = null;
this.GL11_glVertexPointer_pointer = null;
this.GL11_glTexCoordPointer_pointer = null;
this.GL14_glFogCoordPointer_data = null;
this.GL20_glVertexAttribPointer_buffer = null;
this.NV_vertex_program_glVertexAttribPointerNV_buffer = null;
}
}

View File

@ -46,6 +46,7 @@ class ReferencesStack {
public References popState() {
References result = references_stack[stack_pos];
references_stack[stack_pos].clear();
stack_pos--;
return result;
}

View File

@ -105,6 +105,17 @@ public class ReferencesGeneratorProcessorFactory implements AnnotationProcessorF
}
}
private static void generateClearsFromParameters(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method) {
for (ParameterDeclaration param : method.getParameters()) {
CachedReference cached_reference_annotation = param.getAnnotation(CachedReference.class);
if (cached_reference_annotation != null) {
Class nio_type = Utils.getNIOBufferType(param.getType());
String reference_name = Utils.getReferenceName(interface_decl, method, param);
writer.println("\t\tthis." + reference_name + " = null;");
}
}
}
private static void generateCopiesFromParameters(PrintWriter writer, InterfaceDeclaration interface_decl, MethodDeclaration method) {
for (ParameterDeclaration param : method.getParameters()) {
CachedReference cached_reference_annotation = param.getAnnotation(CachedReference.class);
@ -117,6 +128,12 @@ public class ReferencesGeneratorProcessorFactory implements AnnotationProcessorF
}
}
private static void generateClearsFromMethods(PrintWriter writer, InterfaceDeclaration interface_decl) {
for (MethodDeclaration method : interface_decl.getMethods()) {
generateClearsFromParameters(writer, interface_decl, method);
}
}
private static void generateCopiesFromMethods(PrintWriter writer, InterfaceDeclaration interface_decl) {
for (MethodDeclaration method : interface_decl.getMethods()) {
generateCopiesFromParameters(writer, interface_decl, method);
@ -163,6 +180,12 @@ public class ReferencesGeneratorProcessorFactory implements AnnotationProcessorF
generateCopiesFromMethods(writer, interface_decl);
}
writer.println("\t}");
writer.println("\tvoid clear() {");
for (TypeDeclaration typedecl : interface_decls) {
InterfaceDeclaration interface_decl = (InterfaceDeclaration)typedecl;
generateClearsFromMethods(writer, interface_decl);
}
writer.println("\t}");
writer.println("}");
writer.close();
}