--- a/jdk/src/share/classes/java/awt/MediaTracker.java Thu Jan 09 12:47:01 2014 +0400
+++ b/jdk/src/share/classes/java/awt/MediaTracker.java Thu Jan 09 18:04:31 2014 +0400
@@ -28,6 +28,7 @@
import java.awt.Component;
import java.awt.Image;
import java.awt.image.ImageObserver;
+import sun.awt.image.MultiResolutionToolkitImage;
/**
* The <code>MediaTracker</code> class is a utility class to track
@@ -222,10 +223,17 @@
* @param h the height at which the image is rendered
*/
public synchronized void addImage(Image image, int id, int w, int h) {
+ addImageImpl(image, id, w, h);
+ Image rvImage = getResolutionVariant(image);
+ if (rvImage != null) {
+ addImageImpl(rvImage, id, 2 * w, 2 * h);
+ }
+ }
+
+ private void addImageImpl(Image image, int id, int w, int h) {
head = MediaEntry.insert(head,
new ImageMediaEntry(this, image, id, w, h));
}
-
/**
* Flag indicating that media is currently being loaded.
* @see java.awt.MediaTracker#statusAll
@@ -719,6 +727,15 @@
* @since JDK1.1
*/
public synchronized void removeImage(Image image) {
+ removeImageImpl(image);
+ Image rvImage = getResolutionVariant(image);
+ if (rvImage != null) {
+ removeImageImpl(rvImage);
+ }
+ notifyAll(); // Notify in case remaining images are "done".
+ }
+
+ private void removeImageImpl(Image image) {
MediaEntry cur = head;
MediaEntry prev = null;
while (cur != null) {
@@ -735,7 +752,6 @@
}
cur = next;
}
- notifyAll(); // Notify in case remaining images are "done".
}
/**
@@ -750,6 +766,15 @@
* @since JDK1.1
*/
public synchronized void removeImage(Image image, int id) {
+ removeImageImpl(image, id);
+ Image rvImage = getResolutionVariant(image);
+ if (rvImage != null) {
+ removeImageImpl(rvImage, id);
+ }
+ notifyAll(); // Notify in case remaining images are "done".
+ }
+
+ private void removeImageImpl(Image image, int id) {
MediaEntry cur = head;
MediaEntry prev = null;
while (cur != null) {
@@ -766,7 +791,6 @@
}
cur = next;
}
- notifyAll(); // Notify in case remaining images are "done".
}
/**
@@ -783,6 +807,16 @@
*/
public synchronized void removeImage(Image image, int id,
int width, int height) {
+ removeImageImpl(image, id, width, height);
+ Image rvImage = getResolutionVariant(image);
+ if (rvImage != null) {
+ removeImageImpl(rvImage, id, 2 * width, 2 * height);
+
+ }
+ notifyAll(); // Notify in case remaining images are "done".
+ }
+
+ private void removeImageImpl(Image image, int id, int width, int height) {
MediaEntry cur = head;
MediaEntry prev = null;
while (cur != null) {
@@ -801,12 +835,18 @@
}
cur = next;
}
- notifyAll(); // Notify in case remaining images are "done".
}
synchronized void setDone() {
notifyAll();
}
+
+ private static Image getResolutionVariant(Image image) {
+ if (image instanceof MultiResolutionToolkitImage) {
+ return ((MultiResolutionToolkitImage) image).getResolutionVariant();
+ }
+ return null;
+ }
}
abstract class MediaEntry {