1 /* |
1 /* |
2 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
540 boolean validated = false; |
540 boolean validated = false; |
541 |
541 |
542 // REMIND: the D3D pipeline doesn't support XOR!, more |
542 // REMIND: the D3D pipeline doesn't support XOR!, more |
543 // fixes will be needed below. For now we disable D3D rendering |
543 // fixes will be needed below. For now we disable D3D rendering |
544 // for the surface which had any XOR rendering done to. |
544 // for the surface which had any XOR rendering done to. |
545 if (sg2d.compositeState >= sg2d.COMP_XOR) { |
545 if (sg2d.compositeState >= SunGraphics2D.COMP_XOR) { |
546 super.validatePipe(sg2d); |
546 super.validatePipe(sg2d); |
547 sg2d.imagepipe = d3dImagePipe; |
547 sg2d.imagepipe = d3dImagePipe; |
548 disableAccelerationForSurface(); |
548 disableAccelerationForSurface(); |
549 return; |
549 return; |
550 } |
550 } |
555 // canRenderLCDText() has already validated that the mode is |
555 // canRenderLCDText() has already validated that the mode is |
556 // CompositeType.SrcNoEa (opaque color), which will be subsumed |
556 // CompositeType.SrcNoEa (opaque color), which will be subsumed |
557 // by the CompositeType.SrcNoEa (any color) test below.) |
557 // by the CompositeType.SrcNoEa (any color) test below.) |
558 |
558 |
559 if (/* CompositeType.SrcNoEa (any color) */ |
559 if (/* CompositeType.SrcNoEa (any color) */ |
560 (sg2d.compositeState <= sg2d.COMP_ISCOPY && |
560 (sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY && |
561 sg2d.paintState <= sg2d.PAINT_ALPHACOLOR) || |
561 sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR) || |
562 |
562 |
563 /* CompositeType.SrcOver (any color) */ |
563 /* CompositeType.SrcOver (any color) */ |
564 (sg2d.compositeState == sg2d.COMP_ALPHA && |
564 (sg2d.compositeState == SunGraphics2D.COMP_ALPHA && |
565 sg2d.paintState <= sg2d.PAINT_ALPHACOLOR && |
565 sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR && |
566 (((AlphaComposite)sg2d.composite).getRule() == |
566 (((AlphaComposite)sg2d.composite).getRule() == |
567 AlphaComposite.SRC_OVER)) || |
567 AlphaComposite.SRC_OVER)) || |
568 |
568 |
569 /* CompositeType.Xor (any color) */ |
569 /* CompositeType.Xor (any color) */ |
570 (sg2d.compositeState == sg2d.COMP_XOR && |
570 (sg2d.compositeState == SunGraphics2D.COMP_XOR && |
571 sg2d.paintState <= sg2d.PAINT_ALPHACOLOR)) |
571 sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR)) |
572 { |
572 { |
573 textpipe = d3dTextPipe; |
573 textpipe = d3dTextPipe; |
574 } else { |
574 } else { |
575 // do this to initialize textpipe correctly; we will attempt |
575 // do this to initialize textpipe correctly; we will attempt |
576 // to override the non-text pipes below |
576 // to override the non-text pipes below |
581 |
581 |
582 PixelToParallelogramConverter txPipe = null; |
582 PixelToParallelogramConverter txPipe = null; |
583 D3DRenderer nonTxPipe = null; |
583 D3DRenderer nonTxPipe = null; |
584 |
584 |
585 if (sg2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON) { |
585 if (sg2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON) { |
586 if (sg2d.paintState <= sg2d.PAINT_ALPHACOLOR) { |
586 if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR) { |
587 if (sg2d.compositeState <= sg2d.COMP_XOR) { |
587 if (sg2d.compositeState <= SunGraphics2D.COMP_XOR) { |
588 txPipe = d3dTxRenderPipe; |
588 txPipe = d3dTxRenderPipe; |
589 nonTxPipe = d3dRenderPipe; |
589 nonTxPipe = d3dRenderPipe; |
590 } |
590 } |
591 } else if (sg2d.compositeState <= sg2d.COMP_ALPHA) { |
591 } else if (sg2d.compositeState <= SunGraphics2D.COMP_ALPHA) { |
592 if (D3DPaints.isValid(sg2d)) { |
592 if (D3DPaints.isValid(sg2d)) { |
593 txPipe = d3dTxRenderPipe; |
593 txPipe = d3dTxRenderPipe; |
594 nonTxPipe = d3dRenderPipe; |
594 nonTxPipe = d3dRenderPipe; |
595 } |
595 } |
596 // custom paints handled by super.validatePipe() below |
596 // custom paints handled by super.validatePipe() below |
597 } |
597 } |
598 } else { |
598 } else { |
599 if (sg2d.paintState <= sg2d.PAINT_ALPHACOLOR) { |
599 if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR) { |
600 if (graphicsDevice.isCapPresent(CAPS_AA_SHADER) && |
600 if (graphicsDevice.isCapPresent(CAPS_AA_SHADER) && |
601 (sg2d.imageComp == CompositeType.SrcOverNoEa || |
601 (sg2d.imageComp == CompositeType.SrcOverNoEa || |
602 sg2d.imageComp == CompositeType.SrcOver)) |
602 sg2d.imageComp == CompositeType.SrcOver)) |
603 { |
603 { |
604 if (!validated) { |
604 if (!validated) { |
611 1.0/8.0, 0.499, |
611 1.0/8.0, 0.499, |
612 false); |
612 false); |
613 sg2d.drawpipe = aaConverter; |
613 sg2d.drawpipe = aaConverter; |
614 sg2d.fillpipe = aaConverter; |
614 sg2d.fillpipe = aaConverter; |
615 sg2d.shapepipe = aaConverter; |
615 sg2d.shapepipe = aaConverter; |
616 } else if (sg2d.compositeState == sg2d.COMP_XOR) { |
616 } else if (sg2d.compositeState == SunGraphics2D.COMP_XOR) { |
617 // install the solid pipes when AA and XOR are both enabled |
617 // install the solid pipes when AA and XOR are both enabled |
618 txPipe = d3dTxRenderPipe; |
618 txPipe = d3dTxRenderPipe; |
619 nonTxPipe = d3dRenderPipe; |
619 nonTxPipe = d3dRenderPipe; |
620 } |
620 } |
621 } |
621 } |
622 // other cases handled by super.validatePipe() below |
622 // other cases handled by super.validatePipe() below |
623 } |
623 } |
624 |
624 |
625 if (txPipe != null) { |
625 if (txPipe != null) { |
626 if (sg2d.transformState >= sg2d.TRANSFORM_TRANSLATESCALE) { |
626 if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) { |
627 sg2d.drawpipe = txPipe; |
627 sg2d.drawpipe = txPipe; |
628 sg2d.fillpipe = txPipe; |
628 sg2d.fillpipe = txPipe; |
629 } else if (sg2d.strokeState != sg2d.STROKE_THIN) { |
629 } else if (sg2d.strokeState != SunGraphics2D.STROKE_THIN) { |
630 sg2d.drawpipe = txPipe; |
630 sg2d.drawpipe = txPipe; |
631 sg2d.fillpipe = nonTxPipe; |
631 sg2d.fillpipe = nonTxPipe; |
632 } else { |
632 } else { |
633 sg2d.drawpipe = nonTxPipe; |
633 sg2d.drawpipe = nonTxPipe; |
634 sg2d.fillpipe = nonTxPipe; |
634 sg2d.fillpipe = nonTxPipe; |
651 sg2d.imagepipe = d3dImagePipe; |
651 sg2d.imagepipe = d3dImagePipe; |
652 } |
652 } |
653 |
653 |
654 @Override |
654 @Override |
655 protected MaskFill getMaskFill(SunGraphics2D sg2d) { |
655 protected MaskFill getMaskFill(SunGraphics2D sg2d) { |
656 if (sg2d.paintState > sg2d.PAINT_ALPHACOLOR) { |
656 if (sg2d.paintState > SunGraphics2D.PAINT_ALPHACOLOR) { |
657 /* |
657 /* |
658 * We can only accelerate non-Color MaskFill operations if |
658 * We can only accelerate non-Color MaskFill operations if |
659 * all of the following conditions hold true: |
659 * all of the following conditions hold true: |
660 * - there is an implementation for the given paintState |
660 * - there is an implementation for the given paintState |
661 * - the current Paint can be accelerated for this destination |
661 * - the current Paint can be accelerated for this destination |
676 |
676 |
677 @Override |
677 @Override |
678 public boolean copyArea(SunGraphics2D sg2d, |
678 public boolean copyArea(SunGraphics2D sg2d, |
679 int x, int y, int w, int h, int dx, int dy) |
679 int x, int y, int w, int h, int dx, int dy) |
680 { |
680 { |
681 if (sg2d.transformState < sg2d.TRANSFORM_TRANSLATESCALE && |
681 if (sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE && |
682 sg2d.compositeState < sg2d.COMP_XOR) |
682 sg2d.compositeState < SunGraphics2D.COMP_XOR) |
683 { |
683 { |
684 x += sg2d.transX; |
684 x += sg2d.transX; |
685 y += sg2d.transY; |
685 y += sg2d.transY; |
686 |
686 |
687 d3dRenderPipe.copyArea(sg2d, x, y, w, h, dx, dy); |
687 d3dRenderPipe.copyArea(sg2d, x, y, w, h, dx, dy); |
736 { |
736 { |
737 long pData = sd.getNativeOps(); |
737 long pData = sd.getNativeOps(); |
738 D3DRenderQueue rq = D3DRenderQueue.getInstance(); |
738 D3DRenderQueue rq = D3DRenderQueue.getInstance(); |
739 // swapBuffers can be called from the toolkit thread by swing, we |
739 // swapBuffers can be called from the toolkit thread by swing, we |
740 // should detect this and prevent the deadlocks |
740 // should detect this and prevent the deadlocks |
741 if (rq.isRenderQueueThread()) { |
741 if (D3DRenderQueue.isRenderQueueThread()) { |
742 if (!rq.tryLock()) { |
742 if (!rq.tryLock()) { |
743 // if we could not obtain the lock, repaint the area |
743 // if we could not obtain the lock, repaint the area |
744 // that was supposed to be swapped, and no-op this swap |
744 // that was supposed to be swapped, and no-op this swap |
745 final Component target = (Component)sd.getPeer().getTarget(); |
745 final Component target = (Component)sd.getPeer().getTarget(); |
746 SunToolkit.executeOnEventHandlerThread(target, new Runnable() { |
746 SunToolkit.executeOnEventHandlerThread(target, new Runnable() { |