src/share/classes/sun/java2d/SunGraphics2D.java

Print this page




2091                 revalidateAll();
2092                 doCopyArea(x, y, w, h, dx, dy);
2093             } catch (InvalidPipeException e2) {
2094                 // Still catching the exception; we are not yet ready to
2095                 // validate the surfaceData correctly.  Fail for now and
2096                 // try again next time around.
2097             }
2098         } finally {
2099             surfaceData.markDirty();
2100         }
2101     }
2102 
2103     private void doCopyArea(int x, int y, int w, int h, int dx, int dy) {
2104         if (w <= 0 || h <= 0) {
2105             return;
2106         }
2107         SurfaceData theData = surfaceData;
2108         if (theData.copyArea(this, x, y, w, h, dx, dy)) {
2109             return;
2110         }
2111         if (transformState >= TRANSFORM_TRANSLATESCALE) {
2112             throw new InternalError("transformed copyArea not implemented yet");
2113         }
2114         // REMIND: This method does not deal with missing data from the
2115         // source object (i.e. it does not send exposure events...)
2116 
2117         Region clip = getCompClip();
2118 
2119         Composite comp = composite;
2120         if (lastCAcomp != comp) {
2121             SurfaceType dsttype = theData.getSurfaceType();
2122             CompositeType comptype = imageComp;
2123             if (CompositeType.SrcOverNoEa.equals(comptype) &&
2124                 theData.getTransparency() == Transparency.OPAQUE)
2125             {
2126                 comptype = CompositeType.SrcNoEa;
2127             }
2128             lastCAblit = Blit.locate(dsttype, comptype, dsttype);
2129             lastCAcomp = comp;
2130         }
2131 
2132         x += transX;
2133         y += transY;

















2134 
2135         Blit ob = lastCAblit;
2136         if (dy == 0 && dx > 0 && dx < w) {
2137             while (w > 0) {
2138                 int partW = Math.min(w, dx);
2139                 w -= partW;
2140                 int sx = x + w;
2141                 ob.Blit(theData, theData, comp, clip,
2142                         sx, y, sx+dx, y+dy, partW, h);
2143             }
2144             return;
2145         }
2146         if (dy > 0 && dy < h && dx > -w && dx < w) {
2147             while (h > 0) {
2148                 int partH = Math.min(h, dy);
2149                 h -= partH;
2150                 int sy = y + h;
2151                 ob.Blit(theData, theData, comp, clip,
2152                         x, sy, x+dx, sy+dy, w, partH);
2153             }




2091                 revalidateAll();
2092                 doCopyArea(x, y, w, h, dx, dy);
2093             } catch (InvalidPipeException e2) {
2094                 // Still catching the exception; we are not yet ready to
2095                 // validate the surfaceData correctly.  Fail for now and
2096                 // try again next time around.
2097             }
2098         } finally {
2099             surfaceData.markDirty();
2100         }
2101     }
2102 
2103     private void doCopyArea(int x, int y, int w, int h, int dx, int dy) {
2104         if (w <= 0 || h <= 0) {
2105             return;
2106         }
2107         SurfaceData theData = surfaceData;
2108         if (theData.copyArea(this, x, y, w, h, dx, dy)) {
2109             return;
2110         }
2111         if (transformState > TRANSFORM_TRANSLATESCALE) {
2112             throw new InternalError("transformed copyArea not implemented yet");
2113         }
2114         // REMIND: This method does not deal with missing data from the
2115         // source object (i.e. it does not send exposure events...)
2116 
2117         Region clip = getCompClip();
2118 
2119         Composite comp = composite;
2120         if (lastCAcomp != comp) {
2121             SurfaceType dsttype = theData.getSurfaceType();
2122             CompositeType comptype = imageComp;
2123             if (CompositeType.SrcOverNoEa.equals(comptype) &&
2124                 theData.getTransparency() == Transparency.OPAQUE)
2125             {
2126                 comptype = CompositeType.SrcNoEa;
2127             }
2128             lastCAblit = Blit.locate(dsttype, comptype, dsttype);
2129             lastCAcomp = comp;
2130         }
2131 
2132         double[] coords = {x, y, x + w, y + h, x + dx, y + dy};
2133         transform.transform(coords, 0, coords, 0, 3);
2134 
2135         x = (int)Math.ceil(coords[0] - 0.5);
2136         y = (int)Math.ceil(coords[1] - 0.5);
2137         w = ((int)Math.ceil(coords[2] - 0.5)) - x;
2138         h = ((int)Math.ceil(coords[3] - 0.5)) - y;
2139         dx = ((int)Math.ceil(coords[4] - 0.5)) - x;
2140         dy = ((int)Math.ceil(coords[5] - 0.5)) - y;
2141         
2142         // In case of negative scale transform, reflect the rect coords.
2143         if (w < 0) {
2144             w *= -1;
2145             x -= w;
2146         }
2147         if (h < 0) {
2148             h *= -1;
2149             y -= h;
2150         }
2151         
2152         Blit ob = lastCAblit;
2153         if (dy == 0 && dx > 0 && dx < w) {
2154             while (w > 0) {
2155                 int partW = Math.min(w, dx);
2156                 w -= partW;
2157                 int sx = x + w;
2158                 ob.Blit(theData, theData, comp, clip,
2159                         sx, y, sx+dx, y+dy, partW, h);
2160             }
2161             return;
2162         }
2163         if (dy > 0 && dy < h && dx > -w && dx < w) {
2164             while (h > 0) {
2165                 int partH = Math.min(h, dy);
2166                 h -= partH;
2167                 int sy = y + h;
2168                 ob.Blit(theData, theData, comp, clip,
2169                         x, sy, x+dx, sy+dy, w, partH);
2170             }