/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
{
private static native void initIDs();
static {
initIDs();
}
// the image associated with this surface
// the image associated with this custom surface
// <rdar://problem/4177639> nio based images use ARGB_PRE
static DirectColorModel dcmBackup = new DirectColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB), 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000, true, DataBuffer.TYPE_INT);
// cached rasters for easy access
// these are extra image types we can handle
// these are for callbacks when pixes have been touched
/*
* if ((bufImg.getWidth() == 32) && (bufImg.getHeight() == 32)) { Thread.dumpStack(); }
*/
// This could be called from multiple threads. We need to synchronized on the image so that
// we can ensure that only one surface data is created per image. (<rdar://4564873>)
// Note: Eventually, we should switch to using the same mechanism (CachingSurfaceManager) that Sun uses
// <rdar://4563741>
synchronized (bufImg) {
// osData.setRasterListener();
return osData;
}
}
throw new InternalError("SurfaceData not implemented for Raster/CM");
}
// REMIND: Check the image type and pick an appropriate subclass
switch (type) {
case BufferedImage.TYPE_INT_BGR:
break;
case BufferedImage.TYPE_INT_RGB:
break;
case BufferedImage.TYPE_INT_ARGB:
break;
break;
case BufferedImage.TYPE_3BYTE_BGR:
break;
case BufferedImage.TYPE_4BYTE_ABGR:
break;
break;
break;
break;
case BufferedImage.TYPE_BYTE_INDEXED: {
switch (cm.getTransparency()) {
case OPAQUE:
} else {
}
break;
case BITMASK:
break;
case TRANSLUCENT:
break;
default:
throw new InternalError("Unrecognized transparency");
}
}
break;
case BufferedImage.TYPE_BYTE_GRAY:
break;
break;
case BufferedImage.TYPE_CUSTOM:
default: {
// we try to fit a custom image into one of the predefined BufferedImages (BufferedImage does that
// first, we further refine it here)
// we can do that because a pointer in C is a pointer (pixel pointer not dependent on DataBuffer type)
if ((numOfComponents == 3) && (cm instanceof ComponentColorModel) && (sm instanceof PixelInterleavedSampleModel)) {
boolean bigendian = (offs[0] == numBands - 3) && (offs[1] == numBands - 2) && (offs[2] == numBands - 1);
boolean littleendian = (offs[0] == numBands - 1) && (offs[1] == numBands - 2) && (offs[2] == numBands - 3);
try {
} catch (ClassCastException e) {
}
try {
} catch (ClassCastException e) {
}
} else if (validsizes && littleendian && cm.hasAlpha() && cm.isAlphaPremultiplied() && sizes[3] == 8) {
try {
} catch (ClassCastException e) {
}
try {
} catch (ClassCastException e) {
}
} else if (validsizes && bigendian) {
try {
} catch (ClassCastException e) {
}
}
try {
} catch (ClassCastException e) {
}
}
try {
} catch (ClassCastException e) {
}
} else if (validsizes && littleendian && cm.hasAlpha() && cm.isAlphaPremultiplied() && sizes[3] == 8) {
try {
} catch (ClassCastException e) {
}
try {
} catch (ClassCastException e) {
}
} else if (validsizes && littleendian) {
try {
} catch (ClassCastException e) {
}
} else if (validsizes && bigendian) {
try {
} catch (ClassCastException e) {
}
}
if (validsizes && bigendian) {
try {
} catch (ClassCastException e) {
}
} else if (validsizes && littleendian) {
try {
} catch (ClassCastException e) {
}
}
if (validsizes && bigendian) {
try {
} catch (ClassCastException e) {
}
} else if (validsizes && littleendian) {
try {
} catch (ClassCastException e) {
}
}
if (validsizes && bigendian) {
try {
} catch (ClassCastException e) {
}
}
if (validsizes && bigendian) {
try {
} catch (ClassCastException e) {
}
}
if (validsizes && bigendian) {
try {
} catch (ClassCastException e) {
}
}
if (validsizes && bigendian) {
try {
} catch (ClassCastException e) {
}
}
}
}
}
break;
}
// we failed to match
// 2004_03_26 cmc: We used to use createCompatibleImage here. Now that createCompatibleImage returns
// an INT_ARGB_PRE instead of an NIO-based image, we need to explicitly create an NIO-based image.
IntegerNIORaster backupRaster = (IntegerNIORaster) IntegerNIORaster.createNIORaster(bufImg.getWidth(), bufImg.getHeight(), dcmBackup.getMasks(), null);
offsd.bimBackup = new BufferedImage(dcmBackup, backupRaster, dcmBackup.isAlphaPremultiplied(), null);
// the trick that makes it work - assign the raster from backup to the surface data of the original image
//offsd.checkIfLazyPixelConversionDisabled();
}
return (OSXOffScreenSurfaceData) sData;
}
null,
// offsd.checkIfLazyPixelConversionDisabled();
return offsd;
}
}
private static SurfaceData createDataSC(BufferedImage bImg, SurfaceType sType, IndexColorModel icm, int iType) {
icm,
//offsd.checkIfLazyPixelConversionDisabled();
return offsd;
}
public static SurfaceData createDataSC(BufferedImage bImg, SurfaceType sType, IndexColorModel icm) {
}
private static SurfaceData createDataBC(BufferedImage bImg, SurfaceType sType, int primaryBank, int iType) {
icm,
return offsd;
}
}
// code!)
icm,
//offsd.checkIfLazyPixelConversionDisabled();
return offsd;
}
protected native void initRaster(Object theArray, int offset, int width, int height, int pixStr, int scanStr, IndexColorModel icm, int type, ByteBuffer graphicsStates, Object graphicsStatesObjects, ByteBuffer imageInfo);
protected native void initCustomRaster(IntBuffer buffer, int width, int height, ByteBuffer graphicsStates, Object graphicsStatesObjects, ByteBuffer imageInfo);
return this.lock;
}
// Makes the constructor package private instead of public.
this.fImageInfoInt.put(kNeedToSyncFromJavaPixelsIndex, 1); // need to sync from Java the very first time
}
/**
* Performs a copyArea within this surface.
*/
// <rdar://problem/4488745> For the Sun2D renderer we should rely on the implementation of the super class.
// BufImageSurfaceData.java doesn't have an implementation of copyArea() and relies on the super class.
int offsetX = 0;
int offsetY = 0;
// reset the clip (this is how it works on windows)
// we actually can handle a case with any clips but windows ignores the light clip
// clip copyArea
if (clippedCopyAreaRect == null) {
// clipped out
return true;
}
// the rectangle returned from clipCopyArea() is in the coordinate space of the surface (image)
// we need to substract the offsetX and offsetY to move it to the coordinate space of the graphics2d.
// sg2d.drawImage expects the destination rect to be in the coord space of the graphics2d. <rdar://3746194>
// (vm)
x = clippedCopyAreaRect.x - offsetX;
y = clippedCopyAreaRect.y - offsetY;
w = clippedCopyAreaRect.width;
// copy (dst coordinates are in the coord space of the graphics2d, and src coordinates are
// in the coordinate space of the image)
sg2d.drawImage(this.bim, x + dx, y + dy, x + dx + w, y + dy + h, x + offsetX, y + offsetY, x + w + offsetX, y + h + offsetY, null);
// restore the clip
return true;
}
/**
* Performs a copyarea from this surface to a buffered image. If null is passed in for the image a new image will be
* created.
*
* Only used by compositor code (private API)
*/
public BufferedImage copyArea(SunGraphics2D sg2d, int x, int y, int w, int h, BufferedImage dstImage) {
// create the destination image if needed
}
// copy
g.dispose();
return dstImage;
}
public boolean xorSurfacePixels(SunGraphics2D sg2d, BufferedImage srcPixels, int x, int y, int w, int h, int colorXOR) {
if ((type == BufferedImage.TYPE_INT_ARGB_PRE) || (type == BufferedImage.TYPE_INT_ARGB) || (type == BufferedImage.TYPE_INT_RGB)) { return xorSurfacePixels(createData(srcPixels), colorXOR, x, y, w, h); }
return false;
}
OSXOffScreenSurfaceData offsd = (OSXOffScreenSurfaceData) (OSXOffScreenSurfaceData.createData(bim));
// offsd.clear();
if (offsd.clearSurfacePixels(w, h) == false) {
g.dispose();
}
}
native boolean clearSurfacePixels(int w, int h);
// 04/06/04 cmc: radr://3612381 Graphics.drawImage ignores bgcolor parameter.
// getCopyWithBgColor returns a new version of an image, drawn with a background
// color. Called by blitImage in OSXSurfaceData.java.
if ((this.copyWithBgColor_cache == null)
|| (this.copyWithBgColor_cache.getWidth() < bimW) || (this.copyWithBgColor_cache.getHeight() < bimH)) {
GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
}
return getSurfaceData(this.copyWithBgColor_cache);
}
/**
* Invoked before the raster's contents are to be read (via one of the modifier methods in Raster such as
* getPixel())
*/
public void rasterRead() {
}
}
/**
* Invoked before the raster's contents are to be written to (via one of the modifier methods in Raster such as
* setPixel())
*/
public void rasterWrite() {
}
}
// /**
// * Invoked when the raster's contents will be taken (via the Raster.getDataBuffer() method)
// */
// public void rasterStolen() {
// fImageInfoInt.put(kImageStolenIndex, 1); // this means we must convert between Java and native pixels every
// // single primitive! (very expensive)
// if (fImageInfoInt.get(kNativePixelsChangedIndex) == 1) {
// syncToJavaPixels();
// }
//
// // we know the pixels have been stolen, no need to listen for changes any more
//// if (this.bufImgSunRaster != null) {
//// this.bufImgSunRaster.setRasterListener(null);
//// }
// }
private native void syncToJavaPixels();
// we need to refer to rasters often, so cache them
if (this.bufImgRaster instanceof SunWritableRaster) {
}
}
// void setRasterListener() {
// if (this.bufImgSunRaster != null) {
// this.bufImgSunRaster.setRasterListener(this);
//
// Raster parentRaster = this.bufImgSunRaster.getParent();
// if (parentRaster != null) {
// if (parentRaster instanceof SunWritableRaster) {
// // mark subimages stolen to turn off lazy pixel conversion (gznote: can we do better here?)
// ((SunWritableRaster) parentRaster).notifyStolen();
// }
// rasterStolen();
// }
// } else {
// // it's a custom image (non-natively supported) and we can not set a raster listener
// // so mark the image as stolen - this will turn off LazyPixelConversion optimization (slow, but correct)
// rasterStolen();
// }
// }
}