< prev index next >

src/java.desktop/share/classes/sun/java2d/loops/CustomComponent.java

Print this page


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


 118                      int srcx, int srcy, int dstx, int dsty, int w, int h)
 119     {
 120         Raster srcRast = src.getRaster(srcx, srcy, w, h);
 121         ColorModel srcCM = src.getColorModel();
 122 
 123         Raster dstRast = dst.getRaster(dstx, dsty, w, h);
 124         IntegerComponentRaster icr = (IntegerComponentRaster) dstRast;
 125         int[] dstPix = icr.getDataStorage();
 126 
 127         Region roi = CustomComponent.getRegionOfInterest(src, dst, clip,
 128                                                          srcx, srcy,
 129                                                          dstx, dsty, w, h);
 130         SpanIterator si = roi.getSpanIterator();
 131 
 132         Object srcPix = null;
 133 
 134         int dstScan = icr.getScanlineStride();
 135         // assert(icr.getPixelStride() == 1);
 136         srcx -= dstx;
 137         srcy -= dsty;
 138         int span[] = new int[4];
 139         while (si.nextSpan(span)) {
 140             int rowoff = icr.getDataOffset(0) + span[1] * dstScan + span[0];
 141             for (int y = span[1]; y < span[3]; y++) {
 142                 int off = rowoff;
 143                 for (int x = span[0]; x < span[2]; x++) {
 144                     srcPix = srcRast.getDataElements(x+srcx, y+srcy, srcPix);
 145                     dstPix[off++] = srcCM.getRGB(srcPix);
 146                 }
 147                 rowoff += dstScan;
 148             }
 149         }
 150         // Pixels in the dest were modified directly, we must
 151         // manually notify the raster that it was modified
 152         icr.markDirty();
 153         // REMIND: We need to do something to make sure that dstRast
 154         // is put back to the destination (as in the native Release
 155         // function)
 156         // src.releaseRaster(srcRast);  // NOP?
 157         // dst.releaseRaster(dstRast);
 158     }


 174     {
 175         Raster srcRast = src.getRaster(srcx, srcy, w, h);
 176         IntegerComponentRaster icr = (IntegerComponentRaster) srcRast;
 177         int[] srcPix = icr.getDataStorage();
 178 
 179         WritableRaster dstRast =
 180             (WritableRaster) dst.getRaster(dstx, dsty, w, h);
 181         ColorModel dstCM = dst.getColorModel();
 182 
 183         Region roi = CustomComponent.getRegionOfInterest(src, dst, clip,
 184                                                          srcx, srcy,
 185                                                          dstx, dsty, w, h);
 186         SpanIterator si = roi.getSpanIterator();
 187 
 188         Object dstPix = null;
 189 
 190         int srcScan = icr.getScanlineStride();
 191         // assert(icr.getPixelStride() == 1);
 192         srcx -= dstx;
 193         srcy -= dsty;
 194         int span[] = new int[4];
 195         while (si.nextSpan(span)) {
 196             int rowoff = (icr.getDataOffset(0) +
 197                           (srcy + span[1]) * srcScan +
 198                           (srcx + span[0]));
 199             for (int y = span[1]; y < span[3]; y++) {
 200                 int off = rowoff;
 201                 for (int x = span[0]; x < span[2]; x++) {
 202                     dstPix = dstCM.getDataElements(srcPix[off++], dstPix);
 203                     dstRast.setDataElements(x, y, dstPix);
 204                 }
 205                 rowoff += srcScan;
 206             }
 207         }
 208         // REMIND: We need to do something to make sure that dstRast
 209         // is put back to the destination (as in the native Release
 210         // function)
 211         // src.releaseRaster(srcRast);  // NOP?
 212         // dst.releaseRaster(dstRast);
 213     }
 214 }


 233 
 234         WritableRaster dstRast =
 235             (WritableRaster) dst.getRaster(dstx, dsty, w, h);
 236         ColorModel dstCM = dst.getColorModel();
 237 
 238         Region roi = CustomComponent.getRegionOfInterest(src, dst, clip,
 239                                                          srcx, srcy,
 240                                                          dstx, dsty, w, h);
 241         SpanIterator si = roi.getSpanIterator();
 242 
 243         int xorrgb = ((XORComposite)comp).getXorColor().getRGB();
 244         Object xorPixel = dstCM.getDataElements(xorrgb, null);
 245 
 246         Object srcPixel = null;
 247         Object dstPixel = null;
 248 
 249         int srcScan = icr.getScanlineStride();
 250         // assert(icr.getPixelStride() == 1);
 251         srcx -= dstx;
 252         srcy -= dsty;
 253         int span[] = new int[4];
 254         while (si.nextSpan(span)) {
 255             int rowoff = (icr.getDataOffset(0) +
 256                           (srcy + span[1]) * srcScan +
 257                           (srcx + span[0]));
 258             for (int y = span[1]; y < span[3]; y++) {
 259                 int off = rowoff;
 260                 for (int x = span[0]; x < span[2]; x++) {
 261                     // REMIND: alpha bits of the destination pixel are
 262                     // currently altered by the XOR operation, but
 263                     // should be left untouched
 264                     srcPixel = dstCM.getDataElements(srcPix[off++], srcPixel);
 265                     dstPixel = dstRast.getDataElements(x, y, dstPixel);
 266 
 267                     switch (dstCM.getTransferType()) {
 268                     case DataBuffer.TYPE_BYTE:
 269                         byte[] bytesrcarr = (byte[]) srcPixel;
 270                         byte[] bytedstarr = (byte[]) dstPixel;
 271                         byte[] bytexorarr = (byte[]) xorPixel;
 272                         for (int i = 0; i < bytedstarr.length; i++) {
 273                             bytedstarr[i] ^= bytesrcarr[i] ^ bytexorarr[i];


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


 118                      int srcx, int srcy, int dstx, int dsty, int w, int h)
 119     {
 120         Raster srcRast = src.getRaster(srcx, srcy, w, h);
 121         ColorModel srcCM = src.getColorModel();
 122 
 123         Raster dstRast = dst.getRaster(dstx, dsty, w, h);
 124         IntegerComponentRaster icr = (IntegerComponentRaster) dstRast;
 125         int[] dstPix = icr.getDataStorage();
 126 
 127         Region roi = CustomComponent.getRegionOfInterest(src, dst, clip,
 128                                                          srcx, srcy,
 129                                                          dstx, dsty, w, h);
 130         SpanIterator si = roi.getSpanIterator();
 131 
 132         Object srcPix = null;
 133 
 134         int dstScan = icr.getScanlineStride();
 135         // assert(icr.getPixelStride() == 1);
 136         srcx -= dstx;
 137         srcy -= dsty;
 138         int[] span = new int[4];
 139         while (si.nextSpan(span)) {
 140             int rowoff = icr.getDataOffset(0) + span[1] * dstScan + span[0];
 141             for (int y = span[1]; y < span[3]; y++) {
 142                 int off = rowoff;
 143                 for (int x = span[0]; x < span[2]; x++) {
 144                     srcPix = srcRast.getDataElements(x+srcx, y+srcy, srcPix);
 145                     dstPix[off++] = srcCM.getRGB(srcPix);
 146                 }
 147                 rowoff += dstScan;
 148             }
 149         }
 150         // Pixels in the dest were modified directly, we must
 151         // manually notify the raster that it was modified
 152         icr.markDirty();
 153         // REMIND: We need to do something to make sure that dstRast
 154         // is put back to the destination (as in the native Release
 155         // function)
 156         // src.releaseRaster(srcRast);  // NOP?
 157         // dst.releaseRaster(dstRast);
 158     }


 174     {
 175         Raster srcRast = src.getRaster(srcx, srcy, w, h);
 176         IntegerComponentRaster icr = (IntegerComponentRaster) srcRast;
 177         int[] srcPix = icr.getDataStorage();
 178 
 179         WritableRaster dstRast =
 180             (WritableRaster) dst.getRaster(dstx, dsty, w, h);
 181         ColorModel dstCM = dst.getColorModel();
 182 
 183         Region roi = CustomComponent.getRegionOfInterest(src, dst, clip,
 184                                                          srcx, srcy,
 185                                                          dstx, dsty, w, h);
 186         SpanIterator si = roi.getSpanIterator();
 187 
 188         Object dstPix = null;
 189 
 190         int srcScan = icr.getScanlineStride();
 191         // assert(icr.getPixelStride() == 1);
 192         srcx -= dstx;
 193         srcy -= dsty;
 194         int[] span = new int[4];
 195         while (si.nextSpan(span)) {
 196             int rowoff = (icr.getDataOffset(0) +
 197                           (srcy + span[1]) * srcScan +
 198                           (srcx + span[0]));
 199             for (int y = span[1]; y < span[3]; y++) {
 200                 int off = rowoff;
 201                 for (int x = span[0]; x < span[2]; x++) {
 202                     dstPix = dstCM.getDataElements(srcPix[off++], dstPix);
 203                     dstRast.setDataElements(x, y, dstPix);
 204                 }
 205                 rowoff += srcScan;
 206             }
 207         }
 208         // REMIND: We need to do something to make sure that dstRast
 209         // is put back to the destination (as in the native Release
 210         // function)
 211         // src.releaseRaster(srcRast);  // NOP?
 212         // dst.releaseRaster(dstRast);
 213     }
 214 }


 233 
 234         WritableRaster dstRast =
 235             (WritableRaster) dst.getRaster(dstx, dsty, w, h);
 236         ColorModel dstCM = dst.getColorModel();
 237 
 238         Region roi = CustomComponent.getRegionOfInterest(src, dst, clip,
 239                                                          srcx, srcy,
 240                                                          dstx, dsty, w, h);
 241         SpanIterator si = roi.getSpanIterator();
 242 
 243         int xorrgb = ((XORComposite)comp).getXorColor().getRGB();
 244         Object xorPixel = dstCM.getDataElements(xorrgb, null);
 245 
 246         Object srcPixel = null;
 247         Object dstPixel = null;
 248 
 249         int srcScan = icr.getScanlineStride();
 250         // assert(icr.getPixelStride() == 1);
 251         srcx -= dstx;
 252         srcy -= dsty;
 253         int[] span = new int[4];
 254         while (si.nextSpan(span)) {
 255             int rowoff = (icr.getDataOffset(0) +
 256                           (srcy + span[1]) * srcScan +
 257                           (srcx + span[0]));
 258             for (int y = span[1]; y < span[3]; y++) {
 259                 int off = rowoff;
 260                 for (int x = span[0]; x < span[2]; x++) {
 261                     // REMIND: alpha bits of the destination pixel are
 262                     // currently altered by the XOR operation, but
 263                     // should be left untouched
 264                     srcPixel = dstCM.getDataElements(srcPix[off++], srcPixel);
 265                     dstPixel = dstRast.getDataElements(x, y, dstPixel);
 266 
 267                     switch (dstCM.getTransferType()) {
 268                     case DataBuffer.TYPE_BYTE:
 269                         byte[] bytesrcarr = (byte[]) srcPixel;
 270                         byte[] bytedstarr = (byte[]) dstPixel;
 271                         byte[] bytexorarr = (byte[]) xorPixel;
 272                         for (int i = 0; i < bytedstarr.length; i++) {
 273                             bytedstarr[i] ^= bytesrcarr[i] ^ bytexorarr[i];


< prev index next >