< prev index next >

src/java.desktop/share/classes/sun/java2d/pipe/DrawImage.java

Print this page


   1 /*
   2  * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  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


 910                 // Need a bitmask transparency
 911                 // REMIND: for now, use full transparency since no loops
 912                 // for bitmask
 913                 dstCM = ColorModel.getRGBdefault();
 914             }
 915         }
 916 
 917         return dstCM;
 918     }
 919 
 920     protected void blitSurfaceData(SunGraphics2D sg,
 921                                    Region clipRegion,
 922                                    SurfaceData srcData,
 923                                    SurfaceData dstData,
 924                                    SurfaceType srcType,
 925                                    SurfaceType dstType,
 926                                    int sx, int sy, int dx, int dy,
 927                                    int w, int h,
 928                                    Color bgColor)
 929     {
 930         if (w <= 0 || h <= 0) {
 931             /*
 932              * Fix for bugid 4783274 - BlitBg throws an exception for
 933              * a particular set of anomalous parameters.
 934              * REMIND: The native loops do proper clipping and would
 935              * detect this situation themselves, but the Java loops
 936              * all seem to trust their parameters a little too well
 937              * to the point where they will try to process a negative
 938              * area of pixels and throw exceptions.  The real fix is
 939              * to modify the Java loops to do proper clipping so that
 940              * they can deal with negative dimensions as well as
 941              * improperly large dimensions, but that fix is too risky
 942              * to integrate for Mantis at this point.  In the meantime
 943              * eliminating the negative or zero dimensions here is
 944              * "correct" and saves them from some nasty exceptional
 945              * conditions, one of which is the test case of 4783274.
 946              */
 947             return;
 948         }
 949         CompositeType comp = sg.imageComp;
 950         if (CompositeType.SrcOverNoEa.equals(comp) &&
 951             (srcData.getTransparency() == Transparency.OPAQUE ||
 952              (bgColor != null &&
 953               bgColor.getTransparency() == Transparency.OPAQUE)))
 954         {
 955             comp = CompositeType.SrcNoEa;
 956         }





 957         if (!isBgOperation(srcData, bgColor)) {
 958             Blit blit = Blit.getFromCache(srcType, comp, dstType);
 959             blit.Blit(srcData, dstData, sg.composite, clipRegion,
 960                       sx, sy, dx, dy, w, h);
 961         } else {
 962             BlitBg blit = BlitBg.getFromCache(srcType, comp, dstType);
 963             blit.BlitBg(srcData, dstData, sg.composite, clipRegion,
 964                         bgColor.getRGB(), sx, sy, dx, dy, w, h);
 965         }
 966     }
 967 
 968     protected boolean scaleSurfaceData(SunGraphics2D sg,
 969                                        Region clipRegion,
 970                                        SurfaceData srcData,
 971                                        SurfaceData dstData,
 972                                        SurfaceType srcType,
 973                                        SurfaceType dstType,
 974                                        int sx1, int sy1,
 975                                        int sx2, int sy2,
 976                                        double dx1, double dy1,


   1 /*
   2  * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  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


 910                 // Need a bitmask transparency
 911                 // REMIND: for now, use full transparency since no loops
 912                 // for bitmask
 913                 dstCM = ColorModel.getRGBdefault();
 914             }
 915         }
 916 
 917         return dstCM;
 918     }
 919 
 920     protected void blitSurfaceData(SunGraphics2D sg,
 921                                    Region clipRegion,
 922                                    SurfaceData srcData,
 923                                    SurfaceData dstData,
 924                                    SurfaceType srcType,
 925                                    SurfaceType dstType,
 926                                    int sx, int sy, int dx, int dy,
 927                                    int w, int h,
 928                                    Color bgColor)
 929     {



















 930         CompositeType comp = sg.imageComp;
 931         if (CompositeType.SrcOverNoEa.equals(comp) &&
 932             (srcData.getTransparency() == Transparency.OPAQUE ||
 933              (bgColor != null &&
 934               bgColor.getTransparency() == Transparency.OPAQUE)))
 935         {
 936             comp = CompositeType.SrcNoEa;
 937         }
 938         if (w <= 0 || h <= 0 || srcData == dstData && sx == dx && sy == dy
 939                 && CompositeType.SrcNoEa.equals(comp))
 940         {
 941             return;
 942         }
 943         if (!isBgOperation(srcData, bgColor)) {
 944             Blit blit = Blit.getFromCache(srcType, comp, dstType);
 945             blit.Blit(srcData, dstData, sg.composite, clipRegion,
 946                       sx, sy, dx, dy, w, h);
 947         } else {
 948             BlitBg blit = BlitBg.getFromCache(srcType, comp, dstType);
 949             blit.BlitBg(srcData, dstData, sg.composite, clipRegion,
 950                         bgColor.getRGB(), sx, sy, dx, dy, w, h);
 951         }
 952     }
 953 
 954     protected boolean scaleSurfaceData(SunGraphics2D sg,
 955                                        Region clipRegion,
 956                                        SurfaceData srcData,
 957                                        SurfaceData dstData,
 958                                        SurfaceType srcType,
 959                                        SurfaceType dstType,
 960                                        int sx1, int sy1,
 961                                        int sx2, int sy2,
 962                                        double dx1, double dy1,


< prev index next >