src/share/classes/sun/java2d/opengl/OGLBlitLoops.java

Print this page
rev 9629 : 8038644: Fix raw and unchecked warnings in sun.java2d.*
Reviewed-by:


 711                           int w, int h)
 712     {
 713         OGLBlitLoops.IsoBlit(src, dst,
 714                              null, null,
 715                              comp, clip, at, hint,
 716                              sx, sy, sx+w, sy+h,
 717                              dx, dy, dx+w, dy+h,
 718                              true);
 719     }
 720 }
 721 
 722 /**
 723  * This general Blit implementation converts any source surface to an
 724  * intermediate IntArgbPre surface, and then uses the more specific
 725  * IntArgbPre->OpenGLSurface/Texture loop to get the intermediate
 726  * (premultiplied) surface down to OpenGL.
 727  */
 728 class OGLGeneralBlit extends Blit {
 729 
 730     private Blit performop;
 731     private WeakReference srcTmp;
 732 
 733     OGLGeneralBlit(SurfaceType dstType,
 734                    CompositeType compType,
 735                    Blit performop)
 736     {
 737         super(SurfaceType.Any, compType, dstType);
 738         this.performop = performop;
 739     }
 740 
 741     public synchronized void Blit(SurfaceData src, SurfaceData dst,
 742                                   Composite comp, Region clip,
 743                                   int sx, int sy, int dx, int dy,
 744                                   int w, int h)
 745     {
 746         Blit convertsrc = Blit.getFromCache(src.getSurfaceType(),
 747                                             CompositeType.SrcNoEa,
 748                                             SurfaceType.IntArgbPre);
 749 
 750         SurfaceData cachedSrc = null;
 751         if (srcTmp != null) {
 752             // use cached intermediate surface, if available
 753             cachedSrc = (SurfaceData)srcTmp.get();
 754         }
 755 
 756         // convert source to IntArgbPre
 757         src = convertFrom(convertsrc, src, sx, sy, w, h,
 758                           cachedSrc, BufferedImage.TYPE_INT_ARGB_PRE);
 759 
 760         // copy IntArgbPre intermediate surface to OpenGL surface
 761         performop.Blit(src, dst, comp, clip,
 762                        0, 0, dx, dy, w, h);
 763 
 764         if (src != cachedSrc) {
 765             // cache the intermediate surface
 766             srcTmp = new WeakReference(src);
 767         }
 768     }
 769 }
 770 
 771 class OGLAnyCompositeBlit extends Blit {
 772     private WeakReference<SurfaceData> dstTmp;
 773 
 774     public OGLAnyCompositeBlit(SurfaceType dstType) {
 775         super(SurfaceType.Any, CompositeType.Any, dstType);
 776     }
 777     public synchronized void Blit(SurfaceData src, SurfaceData dst,
 778                                   Composite comp, Region clip,
 779                                   int sx, int sy, int dx, int dy,
 780                                   int w, int h)
 781     {
 782         Blit convertdst = Blit.getFromCache(dst.getSurfaceType(),
 783                                             CompositeType.SrcNoEa,
 784                                             SurfaceType.IntArgbPre);
 785 
 786         SurfaceData cachedDst = null;
 787 
 788         if (dstTmp != null) {
 789             // use cached intermediate surface, if available
 790             cachedDst = dstTmp.get();
 791         }
 792 
 793         // convert source to IntArgbPre
 794         SurfaceData dstBuffer = convertFrom(convertdst, dst, dx, dy, w, h,
 795                           cachedDst, BufferedImage.TYPE_INT_ARGB_PRE);
 796 
 797         Blit performop = Blit.getFromCache(src.getSurfaceType(),
 798                 CompositeType.Any, dstBuffer.getSurfaceType());
 799 
 800         performop.Blit(src, dstBuffer, comp, clip,
 801                        sx, sy, 0, 0, w, h);
 802 
 803         if (dstBuffer != cachedDst) {
 804             // cache the intermediate surface
 805             dstTmp = new WeakReference(dstBuffer);
 806         }
 807 
 808         // now blit the buffer back to the destination
 809         convertdst = Blit.getFromCache(dstBuffer.getSurfaceType(),
 810                                             CompositeType.SrcNoEa,
 811                                             dst.getSurfaceType());
 812         convertdst.Blit(dstBuffer, dst, AlphaComposite.Src,
 813                  clip, 0, 0, dx, dy, w, h);
 814     }
 815 }


 711                           int w, int h)
 712     {
 713         OGLBlitLoops.IsoBlit(src, dst,
 714                              null, null,
 715                              comp, clip, at, hint,
 716                              sx, sy, sx+w, sy+h,
 717                              dx, dy, dx+w, dy+h,
 718                              true);
 719     }
 720 }
 721 
 722 /**
 723  * This general Blit implementation converts any source surface to an
 724  * intermediate IntArgbPre surface, and then uses the more specific
 725  * IntArgbPre->OpenGLSurface/Texture loop to get the intermediate
 726  * (premultiplied) surface down to OpenGL.
 727  */
 728 class OGLGeneralBlit extends Blit {
 729 
 730     private Blit performop;
 731     private WeakReference<SurfaceData> srcTmp;
 732 
 733     OGLGeneralBlit(SurfaceType dstType,
 734                    CompositeType compType,
 735                    Blit performop)
 736     {
 737         super(SurfaceType.Any, compType, dstType);
 738         this.performop = performop;
 739     }
 740 
 741     public synchronized void Blit(SurfaceData src, SurfaceData dst,
 742                                   Composite comp, Region clip,
 743                                   int sx, int sy, int dx, int dy,
 744                                   int w, int h)
 745     {
 746         Blit convertsrc = Blit.getFromCache(src.getSurfaceType(),
 747                                             CompositeType.SrcNoEa,
 748                                             SurfaceType.IntArgbPre);
 749 
 750         SurfaceData cachedSrc = null;
 751         if (srcTmp != null) {
 752             // use cached intermediate surface, if available
 753             cachedSrc = srcTmp.get();
 754         }
 755 
 756         // convert source to IntArgbPre
 757         src = convertFrom(convertsrc, src, sx, sy, w, h,
 758                           cachedSrc, BufferedImage.TYPE_INT_ARGB_PRE);
 759 
 760         // copy IntArgbPre intermediate surface to OpenGL surface
 761         performop.Blit(src, dst, comp, clip,
 762                        0, 0, dx, dy, w, h);
 763 
 764         if (src != cachedSrc) {
 765             // cache the intermediate surface
 766             srcTmp = new WeakReference<>(src);
 767         }
 768     }
 769 }
 770 
 771 class OGLAnyCompositeBlit extends Blit {
 772     private WeakReference<SurfaceData> dstTmp;
 773 
 774     public OGLAnyCompositeBlit(SurfaceType dstType) {
 775         super(SurfaceType.Any, CompositeType.Any, dstType);
 776     }
 777     public synchronized void Blit(SurfaceData src, SurfaceData dst,
 778                                   Composite comp, Region clip,
 779                                   int sx, int sy, int dx, int dy,
 780                                   int w, int h)
 781     {
 782         Blit convertdst = Blit.getFromCache(dst.getSurfaceType(),
 783                                             CompositeType.SrcNoEa,
 784                                             SurfaceType.IntArgbPre);
 785 
 786         SurfaceData cachedDst = null;
 787 
 788         if (dstTmp != null) {
 789             // use cached intermediate surface, if available
 790             cachedDst = dstTmp.get();
 791         }
 792 
 793         // convert source to IntArgbPre
 794         SurfaceData dstBuffer = convertFrom(convertdst, dst, dx, dy, w, h,
 795                           cachedDst, BufferedImage.TYPE_INT_ARGB_PRE);
 796 
 797         Blit performop = Blit.getFromCache(src.getSurfaceType(),
 798                 CompositeType.Any, dstBuffer.getSurfaceType());
 799 
 800         performop.Blit(src, dstBuffer, comp, clip,
 801                        sx, sy, 0, 0, w, h);
 802 
 803         if (dstBuffer != cachedDst) {
 804             // cache the intermediate surface
 805             dstTmp = new WeakReference<>(dstBuffer);
 806         }
 807 
 808         // now blit the buffer back to the destination
 809         convertdst = Blit.getFromCache(dstBuffer.getSurfaceType(),
 810                                             CompositeType.SrcNoEa,
 811                                             dst.getSurfaceType());
 812         convertdst.Blit(dstBuffer, dst, AlphaComposite.Src,
 813                  clip, 0, 0, dx, dy, w, h);
 814     }
 815 }