< prev index next >

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

Print this page


   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


 384         final double[] coords = new double[8];
 385         /* corner:  UL      UR      LL      LR   */
 386         /* index:  0  1    2  3    4  5    6  7  */
 387         /* coord: (0, 0), (w, 0), (0, h), (w, h) */
 388         coords[2] = coords[6] = sx2 - sx1;
 389         coords[5] = coords[7] = sy2 - sy1;
 390         tx.transform(coords, 0, coords, 0, 4);
 391         double ddx1, ddy1, ddx2, ddy2;
 392         ddx1 = ddx2 = coords[0];
 393         ddy1 = ddy2 = coords[1];
 394         for (int i = 2; i < coords.length; i += 2) {
 395             double d = coords[i];
 396             if (ddx1 > d) ddx1 = d;
 397             else if (ddx2 < d) ddx2 = d;
 398             d = coords[i+1];
 399             if (ddy1 > d) ddy1 = d;
 400             else if (ddy2 < d) ddy2 = d;
 401         }
 402 
 403         Region clip = sg.getCompClip();
 404         final int dx1 = Math.max((int) Math.floor(ddx1), clip.lox);
 405         final int dy1 = Math.max((int) Math.floor(ddy1), clip.loy);
 406         final int dx2 = Math.min((int) Math.ceil(ddx2), clip.hix);
 407         final int dy2 = Math.min((int) Math.ceil(ddy2), clip.hiy);
 408         if (dx2 <= dx1 || dy2 <= dy1) {
 409             // empty destination means no output
 410             return;
 411         }
 412 
 413         final SurfaceData dstData = sg.surfaceData;
 414         SurfaceData srcData = dstData.getSourceSurfaceData(img,
 415                                                            SunGraphics2D.TRANSFORM_GENERIC,
 416                                                            sg.imageComp,
 417                                                            bgColor);
 418 
 419         if (srcData == null) {
 420             img = getBufferedImage(img);
 421             srcData = dstData.getSourceSurfaceData(img,
 422                                                    SunGraphics2D.TRANSFORM_GENERIC,
 423                                                    sg.imageComp,
 424                                                    bgColor);
 425             if (srcData == null) {
 426                 // REMIND: Is this correct?  Can this happen?
 427                 return;


   1 /*
   2  * Copyright (c) 2001, 2016, 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


 384         final double[] coords = new double[8];
 385         /* corner:  UL      UR      LL      LR   */
 386         /* index:  0  1    2  3    4  5    6  7  */
 387         /* coord: (0, 0), (w, 0), (0, h), (w, h) */
 388         coords[2] = coords[6] = sx2 - sx1;
 389         coords[5] = coords[7] = sy2 - sy1;
 390         tx.transform(coords, 0, coords, 0, 4);
 391         double ddx1, ddy1, ddx2, ddy2;
 392         ddx1 = ddx2 = coords[0];
 393         ddy1 = ddy2 = coords[1];
 394         for (int i = 2; i < coords.length; i += 2) {
 395             double d = coords[i];
 396             if (ddx1 > d) ddx1 = d;
 397             else if (ddx2 < d) ddx2 = d;
 398             d = coords[i+1];
 399             if (ddy1 > d) ddy1 = d;
 400             else if (ddy2 < d) ddy2 = d;
 401         }
 402 
 403         Region clip = sg.getCompClip();
 404         final int dx1 = Math.max((int) Math.floor(ddx1), clip.getLoX());
 405         final int dy1 = Math.max((int) Math.floor(ddy1), clip.getLoY());
 406         final int dx2 = Math.min((int) Math.ceil(ddx2), clip.getHiX());
 407         final int dy2 = Math.min((int) Math.ceil(ddy2), clip.getHiY());
 408         if (dx2 <= dx1 || dy2 <= dy1) {
 409             // empty destination means no output
 410             return;
 411         }
 412 
 413         final SurfaceData dstData = sg.surfaceData;
 414         SurfaceData srcData = dstData.getSourceSurfaceData(img,
 415                                                            SunGraphics2D.TRANSFORM_GENERIC,
 416                                                            sg.imageComp,
 417                                                            bgColor);
 418 
 419         if (srcData == null) {
 420             img = getBufferedImage(img);
 421             srcData = dstData.getSourceSurfaceData(img,
 422                                                    SunGraphics2D.TRANSFORM_GENERIC,
 423                                                    sg.imageComp,
 424                                                    bgColor);
 425             if (srcData == null) {
 426                 // REMIND: Is this correct?  Can this happen?
 427                 return;


< prev index next >