< prev index next >

src/java.desktop/unix/classes/sun/java2d/xr/XRSurfaceData.java

Print this page




  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.java2d.xr;
  27 
  28 import java.awt.*;
  29 import java.awt.geom.*;
  30 import java.awt.image.*;
  31 import sun.awt.*;
  32 import sun.java2d.InvalidPipeException;
  33 import sun.java2d.SunGraphics2D;
  34 import sun.java2d.SurfaceData;
  35 import sun.java2d.SurfaceDataProxy;
  36 import sun.java2d.jules.*;
  37 import sun.java2d.loops.*;
  38 import sun.java2d.pipe.*;
  39 import sun.java2d.x11.*;
  40 import sun.font.FontManagerNativeLibrary;
  41 
  42 public abstract class XRSurfaceData extends XSurfaceData {
  43     X11ComponentPeer peer;
  44     XRGraphicsConfig graphicsConfig;
  45     XRBackend renderQueue;
  46 
  47     private RenderLoops solidloops;
  48 
  49     protected int depth;
  50 
  51     private static native void initIDs();
  52 
  53     protected native void XRInitSurface(int depth, int width, int height,
  54                                         long drawable, int pictFormat);
  55 
  56     native void initXRPicture(long xsdo, int pictForm);


 129         XRRenderer nonTxPipe = null;
 130 
 131         /*
 132          * TODO: Can we rely on the GC for ARGB32 surfaces?
 133          */
 134         if (sg2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON) {
 135             if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR) {
 136                 if (sg2d.compositeState <= SunGraphics2D.COMP_XOR) {
 137                     txPipe = xrtxpipe;
 138                     nonTxPipe = xrpipe;
 139                 }
 140             } else if (sg2d.compositeState <= SunGraphics2D.COMP_ALPHA) {
 141                 if (XRPaints.isValid(sg2d)) {
 142                     txPipe = xrtxpipe;
 143                     nonTxPipe = xrpipe;
 144                 }
 145                 // custom paints handled by super.validatePipe() below
 146             }
 147         }
 148 
 149         if (sg2d.antialiasHint == SunHints.INTVAL_ANTIALIAS_ON &&
 150             JulesPathBuf.isCairoAvailable())
 151         {
 152             sg2d.shapepipe = aaShapePipe;
 153             sg2d.drawpipe = aaPixelToShapeConv;
 154             sg2d.fillpipe = aaPixelToShapeConv;
 155         } else {
 156             if (txPipe != null) {
 157                 if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
 158                     sg2d.drawpipe = txPipe;
 159                     sg2d.fillpipe = txPipe;
 160                 } else if (sg2d.strokeState != SunGraphics2D.STROKE_THIN) {
 161                     sg2d.drawpipe = txPipe;
 162                     sg2d.fillpipe = nonTxPipe;
 163                 } else {
 164                     sg2d.drawpipe = nonTxPipe;
 165                     sg2d.fillpipe = nonTxPipe;
 166                 }
 167                 sg2d.shapepipe = nonTxPipe;
 168             } else {
 169                 if (!validated) {
 170                     super.validatePipe(sg2d);
 171                 }
 172             }
 173         }
 174 
 175         // install the text pipe based on our earlier decision
 176         sg2d.textpipe = textpipe;
 177 
 178         // always override the image pipe with the specialized XRender pipe
 179         sg2d.imagepipe = xrDrawImage;
 180     }
 181 
 182     protected TextPipe getTextPipe(SunGraphics2D sg2d) {
 183         boolean supportedPaint = sg2d.compositeState <= SunGraphics2D.COMP_ALPHA
 184                 && (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR || sg2d.composite == null);
 185 
 186         boolean supportedCompOp = false;
 187         if (sg2d.composite instanceof AlphaComposite) {
 188             int compRule = ((AlphaComposite) sg2d.composite).getRule();
 189             supportedCompOp = XRUtils.isMaskEvaluated(XRUtils.j2dAlphaCompToXR(compRule))
 190                     || (compRule == AlphaComposite.SRC
 191                                 && sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR);
 192         }
 193 


 511             if (updateGCClip) {
 512                 renderQueue.setGCClipRectangles(xgc, clip);
 513             }
 514         }
 515     }
 516 
 517     public synchronized void makePipes() { /*
 518                                             * TODO: Why is this synchronized,
 519                                             * but access not?
 520                                             */
 521         if (xrpipe == null) {
 522             try {
 523                 SunToolkit.awtLock();
 524                 xgc = XCreateGC(getNativeOps());
 525 
 526                 xrpipe = new XRRenderer(maskBuffer.getMaskBuffer());
 527                 xrtxpipe = new PixelToShapeConverter(xrpipe);
 528                 xrtextpipe = maskBuffer.getTextRenderer();
 529                 xrDrawImage = new XRDrawImage();
 530 
 531                 if (JulesPathBuf.isCairoAvailable()) {
 532                     aaShapePipe =
 533                        new JulesShapePipe(XRCompositeManager.getInstance(this));
 534                     aaPixelToShapeConv = new PixelToShapeConverter(aaShapePipe);
 535                 }
 536             } finally {
 537                 SunToolkit.awtUnlock();
 538             }
 539         }
 540     }
 541 
 542     public static class XRWindowSurfaceData extends XRSurfaceData {
 543 
 544         protected final int scale;
 545 
 546         public XRWindowSurfaceData(X11ComponentPeer peer,
 547                                    XRGraphicsConfig gc, SurfaceType sType) {
 548             super(peer, gc, sType, peer.getColorModel(),
 549                   peer.getColorModel().getPixelSize(), Transparency.OPAQUE);
 550 
 551             this.scale = gc.getScale();
 552 
 553             if (isXRDrawableValid()) {
 554                 // If we have a 32 bit color model for the window it needs
 555                 // alpha to support translucency of the window so we need




  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.java2d.xr;
  27 
  28 import java.awt.*;
  29 import java.awt.geom.*;
  30 import java.awt.image.*;
  31 import sun.awt.*;
  32 import sun.java2d.InvalidPipeException;
  33 import sun.java2d.SunGraphics2D;
  34 import sun.java2d.SurfaceData;
  35 import sun.java2d.SurfaceDataProxy;

  36 import sun.java2d.loops.*;
  37 import sun.java2d.pipe.*;
  38 import sun.java2d.x11.*;
  39 import sun.font.FontManagerNativeLibrary;
  40 
  41 public abstract class XRSurfaceData extends XSurfaceData {
  42     X11ComponentPeer peer;
  43     XRGraphicsConfig graphicsConfig;
  44     XRBackend renderQueue;
  45 
  46     private RenderLoops solidloops;
  47 
  48     protected int depth;
  49 
  50     private static native void initIDs();
  51 
  52     protected native void XRInitSurface(int depth, int width, int height,
  53                                         long drawable, int pictFormat);
  54 
  55     native void initXRPicture(long xsdo, int pictForm);


 128         XRRenderer nonTxPipe = null;
 129 
 130         /*
 131          * TODO: Can we rely on the GC for ARGB32 surfaces?
 132          */
 133         if (sg2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON) {
 134             if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR) {
 135                 if (sg2d.compositeState <= SunGraphics2D.COMP_XOR) {
 136                     txPipe = xrtxpipe;
 137                     nonTxPipe = xrpipe;
 138                 }
 139             } else if (sg2d.compositeState <= SunGraphics2D.COMP_ALPHA) {
 140                 if (XRPaints.isValid(sg2d)) {
 141                     txPipe = xrtxpipe;
 142                     nonTxPipe = xrpipe;
 143                 }
 144                 // custom paints handled by super.validatePipe() below
 145             }
 146         }
 147 







 148         if (txPipe != null) {
 149             if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
 150                 sg2d.drawpipe = txPipe;
 151                 sg2d.fillpipe = txPipe;
 152             } else if (sg2d.strokeState != SunGraphics2D.STROKE_THIN) {
 153                 sg2d.drawpipe = txPipe;
 154                 sg2d.fillpipe = nonTxPipe;
 155             } else {
 156                 sg2d.drawpipe = nonTxPipe;
 157                 sg2d.fillpipe = nonTxPipe;
 158             }
 159             sg2d.shapepipe = nonTxPipe;
 160         } else {
 161             if (!validated) {
 162                 super.validatePipe(sg2d);
 163             }
 164         }

 165 
 166         // install the text pipe based on our earlier decision
 167         sg2d.textpipe = textpipe;
 168 
 169         // always override the image pipe with the specialized XRender pipe
 170         sg2d.imagepipe = xrDrawImage;
 171     }
 172 
 173     protected TextPipe getTextPipe(SunGraphics2D sg2d) {
 174         boolean supportedPaint = sg2d.compositeState <= SunGraphics2D.COMP_ALPHA
 175                 && (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR || sg2d.composite == null);
 176 
 177         boolean supportedCompOp = false;
 178         if (sg2d.composite instanceof AlphaComposite) {
 179             int compRule = ((AlphaComposite) sg2d.composite).getRule();
 180             supportedCompOp = XRUtils.isMaskEvaluated(XRUtils.j2dAlphaCompToXR(compRule))
 181                     || (compRule == AlphaComposite.SRC
 182                                 && sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR);
 183         }
 184 


 502             if (updateGCClip) {
 503                 renderQueue.setGCClipRectangles(xgc, clip);
 504             }
 505         }
 506     }
 507 
 508     public synchronized void makePipes() { /*
 509                                             * TODO: Why is this synchronized,
 510                                             * but access not?
 511                                             */
 512         if (xrpipe == null) {
 513             try {
 514                 SunToolkit.awtLock();
 515                 xgc = XCreateGC(getNativeOps());
 516 
 517                 xrpipe = new XRRenderer(maskBuffer.getMaskBuffer());
 518                 xrtxpipe = new PixelToShapeConverter(xrpipe);
 519                 xrtextpipe = maskBuffer.getTextRenderer();
 520                 xrDrawImage = new XRDrawImage();
 521 





 522             } finally {
 523                 SunToolkit.awtUnlock();
 524             }
 525         }
 526     }
 527 
 528     public static class XRWindowSurfaceData extends XRSurfaceData {
 529 
 530         protected final int scale;
 531 
 532         public XRWindowSurfaceData(X11ComponentPeer peer,
 533                                    XRGraphicsConfig gc, SurfaceType sType) {
 534             super(peer, gc, sType, peer.getColorModel(),
 535                   peer.getColorModel().getPixelSize(), Transparency.OPAQUE);
 536 
 537             this.scale = gc.getScale();
 538 
 539             if (isXRDrawableValid()) {
 540                 // If we have a 32 bit color model for the window it needs
 541                 // alpha to support translucency of the window so we need


< prev index next >