< prev index next >

src/java.desktop/share/classes/sun/java2d/opengl/OGLSurfaceData.java

Print this page

        

@@ -23,14 +23,11 @@
  * questions.
  */
 
 package sun.java2d.opengl;
 
-import java.awt.AlphaComposite;
-import java.awt.GraphicsEnvironment;
-import java.awt.Rectangle;
-import java.awt.Transparency;
+import java.awt.*;
 import java.awt.image.ColorModel;
 import java.awt.image.Raster;
 import sun.awt.SunHints;
 import sun.awt.image.PixelConverter;
 import sun.java2d.pipe.hw.AccelSurface;

@@ -398,24 +395,33 @@
     }
 
     /**
      * For now, we can only render LCD text if:
      *   - the fragment shader extension is available, and
-     *   - blending is disabled, and
-     *   - the source color is opaque
-     *   - and the destination is opaque
+     *   - the source color is opaque, and
+     *   - blending is SrcOverNoEa or disabled
      *
      * Eventually, we could enhance the native OGL text rendering code
      * and remove the above restrictions, but that would require significantly
      * more code just to support a few uncommon cases.
      */
     public boolean canRenderLCDText(SunGraphics2D sg2d) {
         return
             graphicsConfig.isCapPresent(CAPS_EXT_LCD_SHADER) &&
-            sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY &&
-            sg2d.paintState <= SunGraphics2D.PAINT_OPAQUECOLOR &&
-            sg2d.surfaceData.getTransparency() == Transparency.OPAQUE;
+            sg2d.surfaceData.getTransparency() == Transparency.OPAQUE &&
+            sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR &&
+            (sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY ||
+             (sg2d.compositeState <= SunGraphics2D.COMP_ALPHA && canHandleComposite(sg2d.composite)));
+    }
+
+    private boolean canHandleComposite(Composite c) {
+        if (c instanceof AlphaComposite) {
+            AlphaComposite ac = (AlphaComposite)c;
+
+            return ac.getRule() == AlphaComposite.SRC_OVER && ac.getAlpha() >= 1f;
+        }
+        return false;
     }
 
     public void validatePipe(SunGraphics2D sg2d) {
         TextPipe textpipe;
         boolean validated = false;
< prev index next >