src/share/classes/sun/java2d/pipe/AlphaPaintPipe.java
Print this page
rev 9629 : 8038644: Fix raw and unchecked warnings in sun.java2d.*
Reviewed-by:
*** 46,65 ****
* This class implements a CompositePipe that renders path alpha tiles
* into a destination according to the Composite attribute of a
* SunGraphics2D.
*/
public class AlphaPaintPipe implements CompositePipe {
! static WeakReference cachedLastRaster;
! static WeakReference cachedLastColorModel;
! static WeakReference cachedLastData;
static class TileContext {
SunGraphics2D sunG2D;
PaintContext paintCtxt;
ColorModel paintModel;
! WeakReference lastRaster;
! WeakReference lastData;
MaskBlit lastMask;
Blit lastBlit;
SurfaceData dstData;
public TileContext(SunGraphics2D sg, PaintContext pc) {
--- 46,65 ----
* This class implements a CompositePipe that renders path alpha tiles
* into a destination according to the Composite attribute of a
* SunGraphics2D.
*/
public class AlphaPaintPipe implements CompositePipe {
! static WeakReference<Raster> cachedLastRaster;
! static WeakReference<ColorModel> cachedLastColorModel;
! static WeakReference<SurfaceData> cachedLastData;
static class TileContext {
SunGraphics2D sunG2D;
PaintContext paintCtxt;
ColorModel paintModel;
! WeakReference<Raster> lastRaster;
! WeakReference<SurfaceData> lastData;
MaskBlit lastMask;
Blit lastBlit;
SurfaceData dstData;
public TileContext(SunGraphics2D sg, PaintContext pc) {
*** 103,114 ****
SunGraphics2D sg = context.sunG2D;
SurfaceData dstData = context.dstData;
SurfaceData srcData = null;
Raster lastRas = null;
if (context.lastData != null && context.lastRaster != null) {
! srcData = (SurfaceData) context.lastData.get();
! lastRas = (Raster) context.lastRaster.get();
if (srcData == null || lastRas == null) {
srcData = null;
lastRas = null;
}
}
--- 103,114 ----
SunGraphics2D sg = context.sunG2D;
SurfaceData dstData = context.dstData;
SurfaceData srcData = null;
Raster lastRas = null;
if (context.lastData != null && context.lastRaster != null) {
! srcData = context.lastData.get();
! lastRas = context.lastRaster.get();
if (srcData == null || lastRas == null) {
srcData = null;
lastRas = null;
}
}
*** 125,143 ****
if ((srcRaster.getMinX() != 0) || (srcRaster.getMinY() != 0)) {
srcRaster = srcRaster.createTranslatedChild(0, 0);
}
if (lastRas != srcRaster) {
lastRas = srcRaster;
! context.lastRaster = new WeakReference(lastRas);
// REMIND: This will fail for a non-Writable raster!
BufferedImage bImg =
new BufferedImage(paintModel,
(WritableRaster) srcRaster,
paintModel.isAlphaPremultiplied(),
null);
srcData = BufImgSurfaceData.createData(bImg);
! context.lastData = new WeakReference(srcData);
context.lastMask = null;
context.lastBlit = null;
}
if (atile == null) {
--- 125,143 ----
if ((srcRaster.getMinX() != 0) || (srcRaster.getMinY() != 0)) {
srcRaster = srcRaster.createTranslatedChild(0, 0);
}
if (lastRas != srcRaster) {
lastRas = srcRaster;
! context.lastRaster = new WeakReference<>(lastRas);
// REMIND: This will fail for a non-Writable raster!
BufferedImage bImg =
new BufferedImage(paintModel,
(WritableRaster) srcRaster,
paintModel.isAlphaPremultiplied(),
null);
srcData = BufImgSurfaceData.createData(bImg);
! context.lastData = new WeakReference<>(srcData);
context.lastMask = null;
context.lastBlit = null;
}
if (atile == null) {
*** 195,205 ****
if (cachedLastColorModel == null ||
cachedLastColorModel.get() != context.paintModel)
{
// Avoid creating new WeakReference if possible
cachedLastColorModel =
! new WeakReference(context.paintModel);
}
cachedLastData = context.lastData;
}
}
}
--- 195,205 ----
if (cachedLastColorModel == null ||
cachedLastColorModel.get() != context.paintModel)
{
// Avoid creating new WeakReference if possible
cachedLastColorModel =
! new WeakReference<>(context.paintModel);
}
cachedLastData = context.lastData;
}
}
}