aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/com/sun/opengl/util
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2007-05-17 18:51:33 +0000
committerKenneth Russel <[email protected]>2007-05-17 18:51:33 +0000
commit86a1f9e7c917b970075de12167efa6222e3a1b46 (patch)
tree4e9e860c36cc9e9416bf28d6787f446c656a2f91 /src/classes/com/sun/opengl/util
parente01fc6a8d55576dc4b0f856a4d77da7eed51652b (diff)
Cleaner version of previous fix. Clarified documentation, made the
default Composite SrcOver, and now save and restore the Composite just to avoid destroying any RenderDelegate's Composite unnecessarily (although there is no guarantee it will be preserved). git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@1249 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes/com/sun/opengl/util')
-rwxr-xr-xsrc/classes/com/sun/opengl/util/j2d/TextRenderer.java25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/classes/com/sun/opengl/util/j2d/TextRenderer.java b/src/classes/com/sun/opengl/util/j2d/TextRenderer.java
index 7d0a8ea2d..c0d292268 100755
--- a/src/classes/com/sun/opengl/util/j2d/TextRenderer.java
+++ b/src/classes/com/sun/opengl/util/j2d/TextRenderer.java
@@ -41,6 +41,7 @@ package com.sun.opengl.util.j2d;
import java.awt.AlphaComposite;
import java.awt.Color;
+import java.awt.Composite;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.Image;
@@ -217,8 +218,8 @@ public class TextRenderer {
supplied Graphics2D instance. The surrounding region will
already have been cleared to the RGB color (0, 0, 0) with zero
alpha. The initial drawing context of the passed Graphics2D
- will be set to use AlphaComposite.Src, the color white, the
- Font specified in the TextRenderer's constructor, and the
+ will be set to use AlphaComposite.SrcOver, the color white,
+ the Font specified in the TextRenderer's constructor, and the
rendering hints specified in the TextRenderer constructor.
Changes made by the end user may be visible in successive
calls to this method, but are not guaranteed to be preserved.
@@ -536,9 +537,10 @@ public class TextRenderer {
int strx = rect.x() + origin.x;
int stry = rect.y() + origin.y;
// Clear out the area we're going to draw into
+ Composite composite = g.getComposite();
g.setComposite(AlphaComposite.Clear);
g.fillRect(rect.x(), rect.y(), rect.w(), rect.h());
- g.setComposite(AlphaComposite.Src);
+ g.setComposite(composite);
// Draw the string
renderDelegate.draw(g, curStr, strx, stry);
// Mark this region of the TextureRenderer as dirty
@@ -654,7 +656,7 @@ public class TextRenderer {
if (cachedGraphics == null) {
cachedGraphics = renderer.createGraphics();
// Set up composite, font and rendering hints
- cachedGraphics.setComposite(AlphaComposite.Src);
+ cachedGraphics.setComposite(AlphaComposite.SrcOver);
cachedGraphics.setColor(Color.WHITE);
cachedGraphics.setFont(font);
cachedGraphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
@@ -780,9 +782,10 @@ public class TextRenderer {
if (DEBUG) {
Graphics2D g = getGraphics2D();
+ Composite composite = g.getComposite();
g.setComposite(AlphaComposite.Clear);
g.fillRect(r.x(), r.y(), r.w(), r.h());
- g.setComposite(AlphaComposite.Src);
+ g.setComposite(composite);
}
}
@@ -873,6 +876,10 @@ public class TextRenderer {
}
TextureRenderer newRenderer = (TextureRenderer) newBackingStore;
g = newRenderer.createGraphics();
+ // This is needed in particular for the case where the
+ // RenderDelegate is using a non-intensity texture and therefore
+ // has an alpha channel
+ g.setComposite(AlphaComposite.Src);
}
public void move(Object oldBackingStore,
@@ -882,14 +889,6 @@ public class TextRenderer {
TextureRenderer oldRenderer = (TextureRenderer) oldBackingStore;
TextureRenderer newRenderer = (TextureRenderer) newBackingStore;
- if (!renderDelegate.intensityOnly()) {
- // Transparent pixels in the source image will not overwrite
- // the contents of the backing store
- g.setComposite(AlphaComposite.Clear);
- g.fillRect(newLocation.x(), newLocation.y(), newLocation.w(), newLocation.h());
- g.setComposite(AlphaComposite.Src);
- }
-
if (oldRenderer == newRenderer) {
// Movement on the same backing store -- easy case
g.copyArea(oldLocation.x(), oldLocation.y(),