Shave off one ThreadLocal access in StateTracker.push/popAttrib()

This commit is contained in:
Elias Naur 2006-11-19 12:48:57 +00:00
parent 7ca70d8c5e
commit 905aec0877
1 changed files with 15 additions and 9 deletions

View File

@ -33,7 +33,6 @@ package org.lwjgl.opengl;
final class StateTracker { final class StateTracker {
private final ReferencesStack references_stack; private final ReferencesStack references_stack;
private final StateStack attrib_stack; private final StateStack attrib_stack;
StateTracker() { StateTracker() {
@ -42,25 +41,32 @@ final class StateTracker {
} }
static void popAttrib() { static void popAttrib() {
if ((getClientAttribStack().popState() & GL11.GL_CLIENT_VERTEX_ARRAY_BIT) != 0) { getTracker().doPopAttrib();
getReferencesStack().popState(); }
private void doPopAttrib() {
if ((attrib_stack.popState() & GL11.GL_CLIENT_VERTEX_ARRAY_BIT) != 0) {
references_stack.popState();
} }
} }
static void pushAttrib(int mask) { static void pushAttrib(int mask) {
StateStack attrib_stack = getClientAttribStack(); getTracker().doPushAttrib(mask);
}
private void doPushAttrib(int mask) {
attrib_stack.pushState(); attrib_stack.pushState();
attrib_stack.setState(mask); attrib_stack.setState(mask);
if ((mask & GL11.GL_CLIENT_VERTEX_ARRAY_BIT) != 0) { if ((mask & GL11.GL_CLIENT_VERTEX_ARRAY_BIT) != 0) {
getReferencesStack().pushState(); references_stack.pushState();
} }
} }
private static StateTracker getTracker() {
return GLContext.getCapabilities().tracker;
}
static ReferencesStack getReferencesStack() { static ReferencesStack getReferencesStack() {
return GLContext.getCapabilities().tracker.references_stack; return GLContext.getCapabilities().tracker.references_stack;
} }
private static StateStack getClientAttribStack() {
return GLContext.getCapabilities().tracker.attrib_stack;
}
} }