jdk/src/java.desktop/share/classes/sun/java2d/opengl/OGLSurfaceData.java
changeset 31158 062c7363dd12
parent 25859 3317bb8137f4
child 31661 a5cb86f2253b
equal deleted inserted replaced
31157:25a62bb54efa 31158:062c7363dd12
    24  */
    24  */
    25 
    25 
    26 package sun.java2d.opengl;
    26 package sun.java2d.opengl;
    27 
    27 
    28 import java.awt.AlphaComposite;
    28 import java.awt.AlphaComposite;
       
    29 import java.awt.Composite;
    29 import java.awt.GraphicsEnvironment;
    30 import java.awt.GraphicsEnvironment;
    30 import java.awt.Rectangle;
    31 import java.awt.Rectangle;
    31 import java.awt.Transparency;
    32 import java.awt.Transparency;
    32 import java.awt.image.ColorModel;
    33 import java.awt.image.ColorModel;
    33 import java.awt.image.Raster;
    34 import java.awt.image.Raster;
   398     }
   399     }
   399 
   400 
   400     /**
   401     /**
   401      * For now, we can only render LCD text if:
   402      * For now, we can only render LCD text if:
   402      *   - the fragment shader extension is available, and
   403      *   - the fragment shader extension is available, and
   403      *   - blending is disabled, and
   404      *   - the source color is opaque, and
   404      *   - the source color is opaque
   405      *   - blending is SrcOverNoEa or disabled
   405      *   - and the destination is opaque
   406      *   - and the destination is opaque
   406      *
   407      *
   407      * Eventually, we could enhance the native OGL text rendering code
   408      * Eventually, we could enhance the native OGL text rendering code
   408      * and remove the above restrictions, but that would require significantly
   409      * and remove the above restrictions, but that would require significantly
   409      * more code just to support a few uncommon cases.
   410      * more code just to support a few uncommon cases.
   410      */
   411      */
   411     public boolean canRenderLCDText(SunGraphics2D sg2d) {
   412     public boolean canRenderLCDText(SunGraphics2D sg2d) {
   412         return
   413         return
   413             graphicsConfig.isCapPresent(CAPS_EXT_LCD_SHADER) &&
   414             graphicsConfig.isCapPresent(CAPS_EXT_LCD_SHADER) &&
   414             sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY &&
   415             sg2d.surfaceData.getTransparency() == Transparency.OPAQUE &&
   415             sg2d.paintState <= SunGraphics2D.PAINT_OPAQUECOLOR &&
   416             sg2d.paintState <= SunGraphics2D.PAINT_OPAQUECOLOR &&
   416             sg2d.surfaceData.getTransparency() == Transparency.OPAQUE;
   417             (sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY ||
       
   418              (sg2d.compositeState <= SunGraphics2D.COMP_ALPHA && canHandleComposite(sg2d.composite)));
       
   419     }
       
   420 
       
   421     private boolean canHandleComposite(Composite c) {
       
   422         if (c instanceof AlphaComposite) {
       
   423             AlphaComposite ac = (AlphaComposite)c;
       
   424 
       
   425             return ac.getRule() == AlphaComposite.SRC_OVER && ac.getAlpha() >= 1f;
       
   426         }
       
   427         return false;
   417     }
   428     }
   418 
   429 
   419     public void validatePipe(SunGraphics2D sg2d) {
   430     public void validatePipe(SunGraphics2D sg2d) {
   420         TextPipe textpipe;
   431         TextPipe textpipe;
   421         boolean validated = false;
   432         boolean validated = false;