summaryrefslogtreecommitdiffstats
path: root/src/classes/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/classes/com')
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/packrect/RectanglePacker.java3
-rwxr-xr-xsrc/classes/com/sun/opengl/util/j2d/TextRenderer.java40
2 files changed, 42 insertions, 1 deletions
diff --git a/src/classes/com/sun/opengl/impl/packrect/RectanglePacker.java b/src/classes/com/sun/opengl/impl/packrect/RectanglePacker.java
index 6057f7bb9..3a77b3bd1 100755
--- a/src/classes/com/sun/opengl/impl/packrect/RectanglePacker.java
+++ b/src/classes/com/sun/opengl/impl/packrect/RectanglePacker.java
@@ -287,7 +287,8 @@ public class RectanglePacker {
BackingStoreManager. This RectanglePacker may no longer be used
after calling this method. */
public void dispose() {
- manager.deleteBackingStore(backingStore);
+ if (backingStore != null)
+ manager.deleteBackingStore(backingStore);
backingStore = null;
levels = null;
}
diff --git a/src/classes/com/sun/opengl/util/j2d/TextRenderer.java b/src/classes/com/sun/opengl/util/j2d/TextRenderer.java
index 0d3ab73d9..a14918583 100755
--- a/src/classes/com/sun/opengl/util/j2d/TextRenderer.java
+++ b/src/classes/com/sun/opengl/util/j2d/TextRenderer.java
@@ -88,6 +88,12 @@ import com.sun.opengl.util.*;
renderer.endRendering();
</PRE>
+ Unless you are sharing textures and display lists between OpenGL
+ contexts, you do not need to call the {@link #dispose dispose}
+ method of the TextRenderer; the OpenGL resources it uses
+ internally will be cleaned up automatically when the OpenGL
+ context is destroyed. <P>
+
Internally, the renderer uses a rectangle packing algorithm to
pack multiple full Strings' rendering results (which are variable
size) onto a larger OpenGL texture. The internal backing store is
@@ -162,6 +168,14 @@ public class TextRenderer {
private boolean isOrthoMode;
private int beginRenderingWidth;
private int beginRenderingHeight;
+ // For resetting the color after disposal of the old backing store
+ private boolean haveCachedColor;
+ private float cachedR;
+ private float cachedG;
+ private float cachedB;
+ private float cachedA;
+ private Color cachedColor;
+ private boolean needToResetColor;
// For debugging only
private Frame dbgFrame;
@@ -356,6 +370,8 @@ public class TextRenderer {
*/
public void setColor(Color color) throws GLException {
getBackingStore().setColor(color);
+ haveCachedColor = true;
+ cachedColor = color;
}
/** Changes the current color of this TextRenderer to the supplied
@@ -375,6 +391,12 @@ public class TextRenderer {
*/
public void setColor(float r, float g, float b, float a) throws GLException {
getBackingStore().setColor(r, g, b, a);
+ haveCachedColor = true;
+ cachedR = r;
+ cachedG = g;
+ cachedB = b;
+ cachedA = a;
+ cachedColor = null;
}
/** Draws the supplied String at the desired location using the
@@ -576,6 +598,15 @@ public class TextRenderer {
packer.setMaxSize(sz[0], sz[0]);
haveMaxSize = true;
}
+
+ if (needToResetColor && haveCachedColor) {
+ if (cachedColor == null) {
+ getBackingStore().setColor(cachedR, cachedG, cachedB, cachedA);
+ } else {
+ getBackingStore().setColor(cachedColor);
+ }
+ needToResetColor = false;
+ }
}
private void endRendering(boolean ortho) throws GLException {
@@ -788,6 +819,15 @@ public class TextRenderer {
} else {
((TextureRenderer) newBackingStore).begin3DRendering();
}
+ if (haveCachedColor) {
+ if (cachedColor == null) {
+ ((TextureRenderer) newBackingStore).setColor(cachedR, cachedG, cachedB, cachedA);
+ } else {
+ ((TextureRenderer) newBackingStore).setColor(cachedColor);
+ }
+ }
+ } else {
+ needToResetColor = true;
}
}
}