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