src/macosx/classes/com/apple/laf/AquaPainter.java
Print this page
*** 146,182 ****
final Rectangle bounds) {
if (bounds.width <= 0 || bounds.height <= 0) {
return;
}
- int scale = 1;
- if (g instanceof SunGraphics2D) {
- scale = ((SunGraphics2D) g).surfaceData.getDefaultScale();
- }
final GraphicsConfiguration config = g.getDeviceConfiguration();
final ImageCache cache = ImageCache.getInstance();
! final int imgW = bounds.width * scale;
! final int imgH = bounds.height * scale;
AquaPixelsKey key = new AquaPixelsKey(config,
! imgW, imgH, scale, controlState);
! BufferedImage img = (BufferedImage) cache.getImage(key);
if (img == null) {
! img = new BufferedImage(imgW, imgH, BufferedImage.TYPE_INT_ARGB_PRE);
if (!controlState.is(JRSUIConstants.Animating.YES)) {
cache.setImage(key, img);
}
final WritableRaster raster = img.getRaster();
final DataBufferInt buffer = (DataBufferInt) raster.getDataBuffer();
control.set(controlState);
control.paint(SunWritableRaster.stealData(buffer, 0),
imgW, imgH, 0, 0, bounds.width, bounds.height);
SunWritableRaster.markDirty(buffer);
! }
!
! g.drawImage(img, bounds.x, bounds.y, bounds.width, bounds.height, null);
}
}
private static class AquaPixelsKey implements ImageCache.PixelsKey {
--- 146,192 ----
final Rectangle bounds) {
if (bounds.width <= 0 || bounds.height <= 0) {
return;
}
final GraphicsConfiguration config = g.getDeviceConfiguration();
final ImageCache cache = ImageCache.getInstance();
! final int width = bounds.width;
! final int height = bounds.height;
AquaPixelsKey key = new AquaPixelsKey(config,
! width, height, bounds, controlState);
! Image img = (BufferedImage) cache.getImage(key);
if (img == null) {
!
! Image baseImage = createImage(width, height, bounds, control,
! controlState);
!
! img = new MultiResolutionBufferedImage(baseImage,
! (rvWidth, rvHeight) -> createImage(rvWidth, rvHeight,
! bounds, control, controlState));
!
if (!controlState.is(JRSUIConstants.Animating.YES)) {
cache.setImage(key, img);
}
+ }
+
+ g.drawImage(img, bounds.x, bounds.y, bounds.width, bounds.height, null);
+ }
+
+ private static Image createImage(int imgW, int imgH, final Rectangle bounds,
+ final JRSUIControl control, JRSUIState controlState) {
+ BufferedImage img = new BufferedImage(imgW, imgH,
+ BufferedImage.TYPE_INT_ARGB_PRE);
final WritableRaster raster = img.getRaster();
final DataBufferInt buffer = (DataBufferInt) raster.getDataBuffer();
control.set(controlState);
control.paint(SunWritableRaster.stealData(buffer, 0),
imgW, imgH, 0, 0, bounds.width, bounds.height);
SunWritableRaster.markDirty(buffer);
! return img;
}
}
private static class AquaPixelsKey implements ImageCache.PixelsKey {
*** 185,205 ****
// key parts
private final GraphicsConfiguration config;
private final int w;
private final int h;
! private final int scale;
private final JRSUIState state;
AquaPixelsKey(final GraphicsConfiguration config,
! final int w, final int h, final int scale,
final JRSUIState state) {
this.pixelCount = w * h;
this.config = config;
this.w = w;
this.h = h;
! this.scale = scale;
this.state = state;
this.hash = hash();
}
public int getPixelCount() {
--- 195,215 ----
// key parts
private final GraphicsConfiguration config;
private final int w;
private final int h;
! private final Rectangle bounds;
private final JRSUIState state;
AquaPixelsKey(final GraphicsConfiguration config,
! final int w, final int h, final Rectangle bounds,
final JRSUIState state) {
this.pixelCount = w * h;
this.config = config;
this.w = w;
this.h = h;
! this.bounds = bounds;
this.state = state;
this.hash = hash();
}
public int getPixelCount() {
*** 208,218 ****
private int hash() {
int hash = config != null ? config.hashCode() : 0;
hash = 31 * hash + w;
hash = 31 * hash + h;
! hash = 31 * hash + scale;
hash = 31 * hash + state.hashCode();
return hash;
}
@Override
--- 218,228 ----
private int hash() {
int hash = config != null ? config.hashCode() : 0;
hash = 31 * hash + w;
hash = 31 * hash + h;
! hash = 31 * hash + bounds.hashCode();
hash = 31 * hash + state.hashCode();
return hash;
}
@Override
*** 223,233 ****
@Override
public boolean equals(Object obj) {
if (obj instanceof AquaPixelsKey) {
AquaPixelsKey key = (AquaPixelsKey) obj;
return config == key.config && w == key.w && h == key.h
! && scale == key.scale && state.equals(key.state);
}
return false;
}
}
--- 233,243 ----
@Override
public boolean equals(Object obj) {
if (obj instanceof AquaPixelsKey) {
AquaPixelsKey key = (AquaPixelsKey) obj;
return config == key.config && w == key.w && h == key.h
! && bounds.equals(key.bounds) && state.equals(key.state);
}
return false;
}
}