use of sun.java2d.loops.Blit in project jdk8u_jdk by JetBrains.
the class SunGraphics2D method doCopyArea.
private void doCopyArea(int x, int y, int w, int h, int dx, int dy) {
if (w <= 0 || h <= 0) {
return;
}
SurfaceData theData = surfaceData;
if (theData.copyArea(this, x, y, w, h, dx, dy)) {
return;
}
if (transformState > TRANSFORM_TRANSLATESCALE) {
throw new InternalError("transformed copyArea not implemented yet");
}
// REMIND: This method does not deal with missing data from the
// source object (i.e. it does not send exposure events...)
Region clip = getCompClip();
Composite comp = composite;
if (lastCAcomp != comp) {
SurfaceType dsttype = theData.getSurfaceType();
CompositeType comptype = imageComp;
if (CompositeType.SrcOverNoEa.equals(comptype) && theData.getTransparency() == Transparency.OPAQUE) {
comptype = CompositeType.SrcNoEa;
}
lastCAblit = Blit.locate(dsttype, comptype, dsttype);
lastCAcomp = comp;
}
double[] coords = { x, y, x + w, y + h, x + dx, y + dy };
transform.transform(coords, 0, coords, 0, 3);
x = (int) Math.ceil(coords[0] - 0.5);
y = (int) Math.ceil(coords[1] - 0.5);
w = ((int) Math.ceil(coords[2] - 0.5)) - x;
h = ((int) Math.ceil(coords[3] - 0.5)) - y;
dx = ((int) Math.ceil(coords[4] - 0.5)) - x;
dy = ((int) Math.ceil(coords[5] - 0.5)) - y;
// In case of negative scale transform, reflect the rect coords.
if (w < 0) {
w *= -1;
x -= w;
}
if (h < 0) {
h *= -1;
y -= h;
}
Blit ob = lastCAblit;
if (dy == 0 && dx > 0 && dx < w) {
while (w > 0) {
int partW = Math.min(w, dx);
w -= partW;
int sx = x + w;
ob.Blit(theData, theData, comp, clip, sx, y, sx + dx, y + dy, partW, h);
}
return;
}
if (dy > 0 && dy < h && dx > -w && dx < w) {
while (h > 0) {
int partH = Math.min(h, dy);
h -= partH;
int sy = y + h;
ob.Blit(theData, theData, comp, clip, x, sy, x + dx, sy + dy, w, partH);
}
return;
}
ob.Blit(theData, theData, comp, clip, x, y, x + dx, y + dy, w, h);
}
use of sun.java2d.loops.Blit in project jdk8u_jdk by JetBrains.
the class SunCompositeContext method compose.
/**
* This method composes the two source tiles
* and places the result in the destination tile. Note that
* the destination can be the same object as either
* the first or second source.
* @param src1 The first source tile for the compositing operation.
* @param src2 The second source tile for the compositing operation.
* @param dst The tile where the result of the operation is stored.
*/
public void compose(Raster srcArg, Raster dstIn, WritableRaster dstOut) {
WritableRaster src;
int w;
int h;
if (dstIn != dstOut) {
dstOut.setDataElements(0, 0, dstIn);
}
// BufferedImage.
if (srcArg instanceof WritableRaster) {
src = (WritableRaster) srcArg;
} else {
src = srcArg.createCompatibleWritableRaster();
src.setDataElements(0, 0, srcArg);
}
w = Math.min(src.getWidth(), dstIn.getWidth());
h = Math.min(src.getHeight(), dstIn.getHeight());
BufferedImage srcImg = new BufferedImage(srcCM, src, srcCM.isAlphaPremultiplied(), null);
BufferedImage dstImg = new BufferedImage(dstCM, dstOut, dstCM.isAlphaPremultiplied(), null);
SurfaceData srcData = BufImgSurfaceData.createData(srcImg);
SurfaceData dstData = BufImgSurfaceData.createData(dstImg);
Blit blit = Blit.getFromCache(srcData.getSurfaceType(), comptype, dstData.getSurfaceType());
blit.Blit(srcData, dstData, composite, null, 0, 0, 0, 0, w, h);
}
use of sun.java2d.loops.Blit in project jdk8u_jdk by JetBrains.
the class OGLAnyCompositeBlit method complexClipBlit.
private synchronized void complexClipBlit(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx, int sy, int dx, int dy, int w, int h) {
SurfaceData cachedSrc = null;
if (srcTmp != null) {
// use cached intermediate surface, if available
cachedSrc = srcTmp.get();
}
// We can convert argb_pre data from OpenGL surface in two places:
// - During OpenGL surface -> SW blit
// - During SW -> SW blit
// The first one is faster when we use opaque OGL surface, because in
// this case we simply skip conversion and use color components as is.
// Because of this we align intermediate buffer type with type of
// destination not source.
final int type = typeval == OGLSurfaceData.PF_INT_ARGB_PRE ? BufferedImage.TYPE_INT_ARGB_PRE : BufferedImage.TYPE_INT_ARGB;
src = convertFrom(this, src, sx, sy, w, h, cachedSrc, type);
// copy intermediate SW to destination SW using complex clip
final Blit performop = Blit.getFromCache(src.getSurfaceType(), CompositeType.SrcNoEa, dst.getSurfaceType());
performop.Blit(src, dst, comp, clip, 0, 0, dx, dy, w, h);
if (src != cachedSrc) {
// cache the intermediate surface
srcTmp = new WeakReference<>(src);
}
}
use of sun.java2d.loops.Blit in project jdk8u_jdk by JetBrains.
the class OGLAnyCompositeBlit method register.
static void register() {
Blit blitIntArgbPreToSurface = new OGLSwToSurfaceBlit(SurfaceType.IntArgbPre, OGLSurfaceData.PF_INT_ARGB_PRE);
Blit blitIntArgbPreToTexture = new OGLSwToTextureBlit(SurfaceType.IntArgbPre, OGLSurfaceData.PF_INT_ARGB_PRE);
TransformBlit transformBlitIntArgbPreToSurface = new OGLSwToSurfaceTransform(SurfaceType.IntArgbPre, OGLSurfaceData.PF_INT_ARGB_PRE);
OGLSurfaceToSwBlit blitSurfaceToIntArgbPre = new OGLSurfaceToSwBlit(SurfaceType.IntArgbPre, OGLSurfaceData.PF_INT_ARGB_PRE);
GraphicsPrimitive[] primitives = { // surface->surface ops
new OGLSurfaceToSurfaceBlit(), new OGLSurfaceToSurfaceScale(), new OGLSurfaceToSurfaceTransform(), // render-to-texture surface->surface ops
new OGLRTTSurfaceToSurfaceBlit(), new OGLRTTSurfaceToSurfaceScale(), new OGLRTTSurfaceToSurfaceTransform(), // surface->sw ops
new OGLSurfaceToSwBlit(SurfaceType.IntArgb, OGLSurfaceData.PF_INT_ARGB), blitSurfaceToIntArgbPre, // sw->surface ops
blitIntArgbPreToSurface, new OGLSwToSurfaceBlit(SurfaceType.IntRgb, OGLSurfaceData.PF_INT_RGB), new OGLSwToSurfaceBlit(SurfaceType.IntRgbx, OGLSurfaceData.PF_INT_RGBX), new OGLSwToSurfaceBlit(SurfaceType.IntBgr, OGLSurfaceData.PF_INT_BGR), new OGLSwToSurfaceBlit(SurfaceType.IntBgrx, OGLSurfaceData.PF_INT_BGRX), new OGLSwToSurfaceBlit(SurfaceType.ThreeByteBgr, OGLSurfaceData.PF_3BYTE_BGR), new OGLSwToSurfaceBlit(SurfaceType.Ushort565Rgb, OGLSurfaceData.PF_USHORT_565_RGB), new OGLSwToSurfaceBlit(SurfaceType.Ushort555Rgb, OGLSurfaceData.PF_USHORT_555_RGB), new OGLSwToSurfaceBlit(SurfaceType.Ushort555Rgbx, OGLSurfaceData.PF_USHORT_555_RGBX), new OGLSwToSurfaceBlit(SurfaceType.ByteGray, OGLSurfaceData.PF_BYTE_GRAY), new OGLSwToSurfaceBlit(SurfaceType.UshortGray, OGLSurfaceData.PF_USHORT_GRAY), new OGLGeneralBlit(OGLSurfaceData.OpenGLSurface, CompositeType.AnyAlpha, blitIntArgbPreToSurface), new OGLAnyCompositeBlit(OGLSurfaceData.OpenGLSurface, blitSurfaceToIntArgbPre, blitSurfaceToIntArgbPre, blitIntArgbPreToSurface), new OGLAnyCompositeBlit(SurfaceType.Any, null, blitSurfaceToIntArgbPre, blitIntArgbPreToSurface), new OGLSwToSurfaceScale(SurfaceType.IntRgb, OGLSurfaceData.PF_INT_RGB), new OGLSwToSurfaceScale(SurfaceType.IntRgbx, OGLSurfaceData.PF_INT_RGBX), new OGLSwToSurfaceScale(SurfaceType.IntBgr, OGLSurfaceData.PF_INT_BGR), new OGLSwToSurfaceScale(SurfaceType.IntBgrx, OGLSurfaceData.PF_INT_BGRX), new OGLSwToSurfaceScale(SurfaceType.ThreeByteBgr, OGLSurfaceData.PF_3BYTE_BGR), new OGLSwToSurfaceScale(SurfaceType.Ushort565Rgb, OGLSurfaceData.PF_USHORT_565_RGB), new OGLSwToSurfaceScale(SurfaceType.Ushort555Rgb, OGLSurfaceData.PF_USHORT_555_RGB), new OGLSwToSurfaceScale(SurfaceType.Ushort555Rgbx, OGLSurfaceData.PF_USHORT_555_RGBX), new OGLSwToSurfaceScale(SurfaceType.ByteGray, OGLSurfaceData.PF_BYTE_GRAY), new OGLSwToSurfaceScale(SurfaceType.UshortGray, OGLSurfaceData.PF_USHORT_GRAY), new OGLSwToSurfaceScale(SurfaceType.IntArgbPre, OGLSurfaceData.PF_INT_ARGB_PRE), new OGLSwToSurfaceTransform(SurfaceType.IntRgb, OGLSurfaceData.PF_INT_RGB), new OGLSwToSurfaceTransform(SurfaceType.IntRgbx, OGLSurfaceData.PF_INT_RGBX), new OGLSwToSurfaceTransform(SurfaceType.IntBgr, OGLSurfaceData.PF_INT_BGR), new OGLSwToSurfaceTransform(SurfaceType.IntBgrx, OGLSurfaceData.PF_INT_BGRX), new OGLSwToSurfaceTransform(SurfaceType.ThreeByteBgr, OGLSurfaceData.PF_3BYTE_BGR), new OGLSwToSurfaceTransform(SurfaceType.Ushort565Rgb, OGLSurfaceData.PF_USHORT_565_RGB), new OGLSwToSurfaceTransform(SurfaceType.Ushort555Rgb, OGLSurfaceData.PF_USHORT_555_RGB), new OGLSwToSurfaceTransform(SurfaceType.Ushort555Rgbx, OGLSurfaceData.PF_USHORT_555_RGBX), new OGLSwToSurfaceTransform(SurfaceType.ByteGray, OGLSurfaceData.PF_BYTE_GRAY), new OGLSwToSurfaceTransform(SurfaceType.UshortGray, OGLSurfaceData.PF_USHORT_GRAY), transformBlitIntArgbPreToSurface, new OGLGeneralTransformedBlit(transformBlitIntArgbPreToSurface), // texture->surface ops
new OGLTextureToSurfaceBlit(), new OGLTextureToSurfaceScale(), new OGLTextureToSurfaceTransform(), // sw->texture ops
blitIntArgbPreToTexture, new OGLSwToTextureBlit(SurfaceType.IntRgb, OGLSurfaceData.PF_INT_RGB), new OGLSwToTextureBlit(SurfaceType.IntRgbx, OGLSurfaceData.PF_INT_RGBX), new OGLSwToTextureBlit(SurfaceType.IntBgr, OGLSurfaceData.PF_INT_BGR), new OGLSwToTextureBlit(SurfaceType.IntBgrx, OGLSurfaceData.PF_INT_BGRX), new OGLSwToTextureBlit(SurfaceType.ThreeByteBgr, OGLSurfaceData.PF_3BYTE_BGR), new OGLSwToTextureBlit(SurfaceType.Ushort565Rgb, OGLSurfaceData.PF_USHORT_565_RGB), new OGLSwToTextureBlit(SurfaceType.Ushort555Rgb, OGLSurfaceData.PF_USHORT_555_RGB), new OGLSwToTextureBlit(SurfaceType.Ushort555Rgbx, OGLSurfaceData.PF_USHORT_555_RGBX), new OGLSwToTextureBlit(SurfaceType.ByteGray, OGLSurfaceData.PF_BYTE_GRAY), new OGLSwToTextureBlit(SurfaceType.UshortGray, OGLSurfaceData.PF_USHORT_GRAY), new OGLGeneralBlit(OGLSurfaceData.OpenGLTexture, CompositeType.SrcNoEa, blitIntArgbPreToTexture) };
GraphicsPrimitiveMgr.register(primitives);
}
use of sun.java2d.loops.Blit in project jdk8u_jdk by JetBrains.
the class LWWindowPeer method blitSurfaceData.
private void blitSurfaceData(final SurfaceData src, final SurfaceData dst) {
//TODO blit. proof-of-concept
if (src != dst && src != null && dst != null && !(dst instanceof NullSurfaceData) && !(src instanceof NullSurfaceData) && src.getSurfaceType().equals(dst.getSurfaceType()) && src.getDefaultScaleX() == dst.getDefaultScaleX() && src.getDefaultScaleY() == dst.getDefaultScaleY()) {
final Rectangle size = src.getBounds();
final Blit blit = Blit.locate(src.getSurfaceType(), CompositeType.Src, dst.getSurfaceType());
if (blit != null) {
blit.Blit(src, dst, AlphaComposite.Src, null, 0, 0, 0, 0, size.width, size.height);
}
}
}
Aggregations