src/share/classes/sun/java2d/pipe/DrawImage.java
Print this page
*** 144,154 ****
int txtype = extraAT.getType();
int imgw = img.getWidth(null);
int imgh = img.getHeight(null);
boolean checkfinalxform;
! if (sg.transformState <= sg.TRANSFORM_ANY_TRANSLATE &&
(txtype == AffineTransform.TYPE_IDENTITY ||
txtype == AffineTransform.TYPE_TRANSLATION))
{
// First optimization - both are some kind of translate
--- 144,154 ----
int txtype = extraAT.getType();
int imgw = img.getWidth(null);
int imgh = img.getHeight(null);
boolean checkfinalxform;
! if (sg.transformState <= SunGraphics2D.TRANSFORM_ANY_TRANSLATE &&
(txtype == AffineTransform.TYPE_IDENTITY ||
txtype == AffineTransform.TYPE_TRANSLATION))
{
// First optimization - both are some kind of translate
*** 164,174 ****
{
renderImageCopy(sg, img, null, x+itx, y+ity, 0, 0, imgw, imgh);
return;
}
checkfinalxform = false;
! } else if (sg.transformState <= sg.TRANSFORM_TRANSLATESCALE &&
((txtype & (AffineTransform.TYPE_FLIP |
AffineTransform.TYPE_MASK_ROTATION |
AffineTransform.TYPE_GENERAL_TRANSFORM)) == 0))
{
// Second optimization - both are some kind of translate or scale
--- 164,174 ----
{
renderImageCopy(sg, img, null, x+itx, y+ity, 0, 0, imgw, imgh);
return;
}
checkfinalxform = false;
! } else if (sg.transformState <= SunGraphics2D.TRANSFORM_TRANSLATESCALE &&
((txtype & (AffineTransform.TYPE_FLIP |
AffineTransform.TYPE_MASK_ROTATION |
AffineTransform.TYPE_GENERAL_TRANSFORM)) == 0))
{
// Second optimization - both are some kind of translate or scale
*** 342,359 ****
Color bgColor)
{
Region clip = sg.getCompClip();
SurfaceData dstData = sg.surfaceData;
SurfaceData srcData = dstData.getSourceSurfaceData(img,
! sg.TRANSFORM_GENERIC,
sg.imageComp,
bgColor);
if (srcData == null) {
img = getBufferedImage(img);
srcData = dstData.getSourceSurfaceData(img,
! sg.TRANSFORM_GENERIC,
sg.imageComp,
bgColor);
if (srcData == null) {
// REMIND: Is this correct? Can this happen?
return;
--- 342,359 ----
Color bgColor)
{
Region clip = sg.getCompClip();
SurfaceData dstData = sg.surfaceData;
SurfaceData srcData = dstData.getSourceSurfaceData(img,
! SunGraphics2D.TRANSFORM_GENERIC,
sg.imageComp,
bgColor);
if (srcData == null) {
img = getBufferedImage(img);
srcData = dstData.getSourceSurfaceData(img,
! SunGraphics2D.TRANSFORM_GENERIC,
sg.imageComp,
bgColor);
if (srcData == null) {
// REMIND: Is this correct? Can this happen?
return;
*** 370,380 ****
sx2 -= sx1;
sy2 -= sy1;
sx1 = sy1 = 0;
srcData = dstData.getSourceSurfaceData(img,
! sg.TRANSFORM_GENERIC,
sg.imageComp,
bgColor);
}
SurfaceType srcType = srcData.getSurfaceType();
--- 370,380 ----
sx2 -= sx1;
sy2 -= sy1;
sx1 = sy1 = 0;
srcData = dstData.getSourceSurfaceData(img,
! SunGraphics2D.TRANSFORM_GENERIC,
sg.imageComp,
bgColor);
}
SurfaceType srcType = srcData.getSurfaceType();
*** 396,406 ****
sx2 -= sx1;
sy2 -= sy1;
sx1 = sy1 = 0;
srcData = dstData.getSourceSurfaceData(img,
! sg.TRANSFORM_GENERIC,
sg.imageComp,
null);
srcType = srcData.getSurfaceType();
helper = TransformHelper.getFromCache(srcType);
// assert(helper != null);
--- 396,406 ----
sx2 -= sx1;
sy2 -= sy1;
sx1 = sy1 = 0;
srcData = dstData.getSourceSurfaceData(img,
! SunGraphics2D.TRANSFORM_GENERIC,
sg.imageComp,
null);
srcType = srcData.getSurfaceType();
helper = TransformHelper.getFromCache(srcType);
// assert(helper != null);
*** 447,457 ****
int dy2 = (int) Math.ceil(ddy2);
SurfaceType dstType = dstData.getSurfaceType();
MaskBlit maskblit;
Blit blit;
! if (sg.compositeState <= sg.COMP_ALPHA) {
/* NOTE: We either have, or we can make,
* a MaskBlit for any alpha composite type
*/
maskblit = MaskBlit.getFromCache(SurfaceType.IntArgbPre,
sg.imageComp,
--- 447,457 ----
int dy2 = (int) Math.ceil(ddy2);
SurfaceType dstType = dstData.getSurfaceType();
MaskBlit maskblit;
Blit blit;
! if (sg.compositeState <= SunGraphics2D.COMP_ALPHA) {
/* NOTE: We either have, or we can make,
* a MaskBlit for any alpha composite type
*/
maskblit = MaskBlit.getFromCache(SurfaceType.IntArgbPre,
sg.imageComp,
*** 563,573 ****
// revalidate the surfaceData objects in case of an exception
// and try it once more
while (true) {
SurfaceData srcData =
dstData.getSourceSurfaceData(img,
! sg.TRANSFORM_ISIDENT,
sg.imageComp,
bgColor);
if (srcData == null) {
return false;
}
--- 563,573 ----
// revalidate the surfaceData objects in case of an exception
// and try it once more
while (true) {
SurfaceData srcData =
dstData.getSourceSurfaceData(img,
! SunGraphics2D.TRANSFORM_ISIDENT,
sg.imageComp,
bgColor);
if (srcData == null) {
return false;
}
*** 626,636 ****
// revalidate the surfaceData objects in case of an exception
// and try it once more
while (true) {
SurfaceData srcData =
dstData.getSourceSurfaceData(img,
! sg.TRANSFORM_TRANSLATESCALE,
sg.imageComp,
bgColor);
if (srcData == null || isBgOperation(srcData, bgColor)) {
return false;
--- 626,636 ----
// revalidate the surfaceData objects in case of an exception
// and try it once more
while (true) {
SurfaceData srcData =
dstData.getSourceSurfaceData(img,
! SunGraphics2D.TRANSFORM_TRANSLATESCALE,
sg.imageComp,
bgColor);
if (srcData == null || isBgOperation(srcData, bgColor)) {
return false;
*** 798,812 ****
return (Math.abs(d-i) < MAX_TX_ERROR);
}
public static boolean isSimpleTranslate(SunGraphics2D sg) {
int ts = sg.transformState;
! if (ts <= sg.TRANSFORM_INT_TRANSLATE) {
// Integer translates are always "simple"
return true;
}
! if (ts >= sg.TRANSFORM_TRANSLATESCALE) {
// Scales and beyond are always "not simple"
return false;
}
// non-integer translates are only simple when not interpolating
if (sg.interpolationType == AffineTransformOp.TYPE_NEAREST_NEIGHBOR) {
--- 798,812 ----
return (Math.abs(d-i) < MAX_TX_ERROR);
}
public static boolean isSimpleTranslate(SunGraphics2D sg) {
int ts = sg.transformState;
! if (ts <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
// Integer translates are always "simple"
return true;
}
! if (ts >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
// Scales and beyond are always "not simple"
return false;
}
// non-integer translates are only simple when not interpolating
if (sg.interpolationType == AffineTransformOp.TYPE_NEAREST_NEIGHBOR) {
*** 844,855 ****
if (tx.isIdentity()) {
return dstCM;
}
int type = tx.getType();
boolean needTrans =
! ((type&(tx.TYPE_MASK_ROTATION|tx.TYPE_GENERAL_TRANSFORM)) != 0);
! if (! needTrans && type != tx.TYPE_TRANSLATION && type != tx.TYPE_IDENTITY)
{
double[] mtx = new double[4];
tx.getMatrix(mtx);
// Check out the matrix. A non-integral scale will force ARGB
// since the edge conditions cannot be guaranteed.
--- 844,858 ----
if (tx.isIdentity()) {
return dstCM;
}
int type = tx.getType();
boolean needTrans =
! ((type & (AffineTransform.TYPE_MASK_ROTATION |
! AffineTransform.TYPE_GENERAL_TRANSFORM)) != 0);
! if (! needTrans &&
! type != AffineTransform.TYPE_TRANSLATION &&
! type != AffineTransform.TYPE_IDENTITY)
{
double[] mtx = new double[4];
tx.getMatrix(mtx);
// Check out the matrix. A non-integral scale will force ARGB
// since the edge conditions cannot be guaranteed.
*** 859,869 ****
if (sg.renderHint != SunHints.INTVAL_RENDER_QUALITY) {
if (cm instanceof IndexColorModel) {
Raster raster = bImg.getRaster();
IndexColorModel icm = (IndexColorModel) cm;
// Just need to make sure that we have a transparent pixel
! if (needTrans && cm.getTransparency() == cm.OPAQUE) {
// Fix 4221407
if (raster instanceof sun.awt.image.BytePackedRaster) {
dstCM = ColorModel.getRGBdefault();
}
else {
--- 862,872 ----
if (sg.renderHint != SunHints.INTVAL_RENDER_QUALITY) {
if (cm instanceof IndexColorModel) {
Raster raster = bImg.getRaster();
IndexColorModel icm = (IndexColorModel) cm;
// Just need to make sure that we have a transparent pixel
! if (needTrans && cm.getTransparency() == Transparency.OPAQUE) {
// Fix 4221407
if (raster instanceof sun.awt.image.BytePackedRaster) {
dstCM = ColorModel.getRGBdefault();
}
else {
*** 890,910 ****
}
} /* if (matrix[0] < 1.f ...) */
} /* raster instanceof sun.awt.image.BytePackedRaster */
} /* if (cm.getTransparency() == cm.OPAQUE) */
} /* if (cm instanceof IndexColorModel) */
! else if (needTrans && cm.getTransparency() == cm.OPAQUE) {
// Need a bitmask transparency
// REMIND: for now, use full transparency since no loops
// for bitmask
dstCM = ColorModel.getRGBdefault();
}
} /* if (sg.renderHint == RENDER_QUALITY) */
else {
if (cm instanceof IndexColorModel ||
! (needTrans && cm.getTransparency() == cm.OPAQUE))
{
// Need a bitmask transparency
// REMIND: for now, use full transparency since no loops
// for bitmask
dstCM = ColorModel.getRGBdefault();
--- 893,913 ----
}
} /* if (matrix[0] < 1.f ...) */
} /* raster instanceof sun.awt.image.BytePackedRaster */
} /* if (cm.getTransparency() == cm.OPAQUE) */
} /* if (cm instanceof IndexColorModel) */
! else if (needTrans && cm.getTransparency() == Transparency.OPAQUE) {
// Need a bitmask transparency
// REMIND: for now, use full transparency since no loops
// for bitmask
dstCM = ColorModel.getRGBdefault();
}
} /* if (sg.renderHint == RENDER_QUALITY) */
else {
if (cm instanceof IndexColorModel ||
! (needTrans && cm.getTransparency() == Transparency.OPAQUE))
{
// Need a bitmask transparency
// REMIND: for now, use full transparency since no loops
// for bitmask
dstCM = ColorModel.getRGBdefault();