Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiraj Modi2018-05-07 02:57:46 -0400
committerNiraj Modi2018-05-07 02:57:46 -0400
commit666356d88ba7544a9cd64a502c564db3e6edb535 (patch)
treeeb7c6b6580a8982bed60adca27009d666d2f1943
parent089ee64f4be07cb1cf1404fd5d249f1cf061cebd (diff)
downloadeclipse.platform.swt-666356d88ba7544a9cd64a502c564db3e6edb535.tar.gz
eclipse.platform.swt-666356d88ba7544a9cd64a502c564db3e6edb535.tar.xz
eclipse.platform.swt-666356d88ba7544a9cd64a502c564db3e6edb535.zip
Bug 532443 - Creating a new Image using SWT.IMAGE_GRAY returns an Image
equal to the old Image - Also fixed the JavaDoc typo in ImageDataProvider.java and ImageFileNameProvider.java Change-Id: I2d40061a256e5feba717b765f7cbe9b3e359e508 Signed-off-by: Niraj Modi <niraj.modi@in.ibm.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java14
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageDataProvider.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageFileNameProvider.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java14
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java14
5 files changed, 37 insertions, 13 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java
index fe7317c754..3fb4ac30df 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -132,6 +132,13 @@ public final class Image extends Resource implements Drawable {
private ImageDataProvider imageDataProvider;
/**
+ * Style flag used to differentiate normal, gray-scale and disabled images based
+ * on image data providers. Without this, a normal and a disabled image of the
+ * same image data provider would be considered equal.
+ */
+ private int styleFlag = SWT.IMAGE_COPY;
+
+ /**
* Alpha information objects for 100%, 200%
*/
private AlphaInfo alphaInfo_100, alphaInfo_200;
@@ -366,6 +373,7 @@ public Image(Device device, Image srcImage, int flag) {
imageFileNameProvider = srcImage.imageFileNameProvider;
imageDataProvider = srcImage.imageDataProvider;
+ this.styleFlag = srcImage.styleFlag | flag;
if (imageFileNameProvider != null || imageDataProvider != null) {
/* If source image has 200% representation then create the 200% representation for the new image & apply flag */
NSBitmapImageRep rep200 = srcImage.getRepresentation_200();
@@ -1102,9 +1110,9 @@ public boolean equals (Object object) {
Image image = (Image)object;
if (device != image.device || alphaInfo_100.transparentPixel != image.alphaInfo_100.transparentPixel) return false;
if (imageDataProvider != null && image.imageDataProvider != null) {
- return imageDataProvider.equals (image.imageDataProvider);
+ return styleFlag == image.styleFlag && imageDataProvider.equals (image.imageDataProvider);
} else if (imageFileNameProvider != null && image.imageFileNameProvider != null) {
- return imageFileNameProvider.equals (image.imageFileNameProvider);
+ return styleFlag == image.styleFlag && imageFileNameProvider.equals (image.imageFileNameProvider);
} else {
return handle == image.handle;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageDataProvider.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageDataProvider.java
index dba352f604..965858893a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageDataProvider.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageDataProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015 IBM Corporation and others.
+ * Copyright (c) 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -28,7 +28,7 @@ public interface ImageDataProvider {
* <p>
* If no image is available for a particular zoom level, this method should
* return <code>null</code>. For <code>zoom == 100</code>, returning
- * <code>null</code> in not allowed, and SWT will throw an exception.
+ * <code>null</code> is not allowed, and SWT will throw an exception.
*
* @param zoom
* The zoom level in % of the standard resolution (which is 1
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageFileNameProvider.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageFileNameProvider.java
index 5781d880bc..93c96464bf 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageFileNameProvider.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageFileNameProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015 IBM Corporation and others.
+ * Copyright (c) 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -27,7 +27,7 @@ public interface ImageFileNameProvider {
* <p>
* If no image is available for a particular zoom level, this method should
* return <code>null</code>. For <code>zoom == 100</code>, returning
- * <code>null</code> in not allowed, and SWT will throw an exception.
+ * <code>null</code> is not allowed, and SWT will throw an exception.
*
* @param zoom
* The zoom level in % of the standard resolution (which is 1
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
index 9533a1155e..d6e493cfb1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -172,6 +172,13 @@ public final class Image extends Resource implements Drawable {
private ImageDataProvider imageDataProvider;
/**
+ * Style flag used to differentiate normal, gray-scale and disabled images based
+ * on image data providers. Without this, a normal and a disabled image of the
+ * same image data provider would be considered equal.
+ */
+ private int styleFlag = SWT.IMAGE_COPY;
+
+ /**
* Attribute to cache current device zoom level
*/
private int currentDeviceZoom = 100;
@@ -276,6 +283,7 @@ public Image(Device device, Image srcImage, int flag) {
this.type = srcImage.type;
this.imageDataProvider = srcImage.imageDataProvider;
this.imageFileNameProvider = srcImage.imageFileNameProvider;
+ this.styleFlag = srcImage.styleFlag | flag;
this.currentDeviceZoom = srcImage.currentDeviceZoom;
if (flag != SWT.IMAGE_DISABLE) transparentPixel = srcImage.transparentPixel;
@@ -1074,9 +1082,9 @@ public boolean equals (Object object) {
Image image = (Image)object;
if (device != image.device || transparentPixel != image.transparentPixel) return false;
if (imageDataProvider != null && image.imageDataProvider != null) {
- return imageDataProvider.equals (image.imageDataProvider);
+ return (styleFlag == image.styleFlag) && imageDataProvider.equals (image.imageDataProvider);
} else if (imageFileNameProvider != null && image.imageFileNameProvider != null) {
- return imageFileNameProvider.equals (image.imageFileNameProvider);
+ return (styleFlag == image.styleFlag) && imageFileNameProvider.equals (image.imageFileNameProvider);
} else {
return surface == image.surface;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java
index c78ec94891..ed69d81b4a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -129,6 +129,13 @@ public final class Image extends Resource implements Drawable {
private ImageDataProvider imageDataProvider;
/**
+ * Style flag used to differentiate normal, gray-scale and disabled images based
+ * on image data providers. Without this, a normal and a disabled image of the
+ * same image data provider would be considered equal.
+ */
+ private int styleFlag = SWT.IMAGE_COPY;
+
+ /**
* Attribute to cache current device zoom level
*/
private int currentDeviceZoom = 100;
@@ -245,6 +252,7 @@ public Image(Device device, Image srcImage, int flag) {
this.type = srcImage.type;
this.imageDataProvider = srcImage.imageDataProvider;
this.imageFileNameProvider = srcImage.imageFileNameProvider;
+ this.styleFlag = srcImage.styleFlag | flag;
this.currentDeviceZoom = srcImage.currentDeviceZoom;
switch (flag) {
case SWT.IMAGE_COPY: {
@@ -1165,9 +1173,9 @@ public boolean equals (Object object) {
Image image = (Image) object;
if (device != image.device || transparentPixel != image.transparentPixel) return false;
if (imageDataProvider != null && image.imageDataProvider != null) {
- return imageDataProvider.equals (image.imageDataProvider);
+ return (styleFlag == image.styleFlag) && imageDataProvider.equals (image.imageDataProvider);
} else if (imageFileNameProvider != null && image.imageFileNameProvider != null) {
- return imageFileNameProvider.equals (image.imageFileNameProvider);
+ return (styleFlag == image.styleFlag) && imageFileNameProvider.equals (image.imageFileNameProvider);
} else {
return handle == image.handle;
}

Back to the top