Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLakshmi Shanmugam2018-04-17 18:57:36 +0000
committerLakshmi Shanmugam2018-04-20 08:14:32 +0000
commit8b51cbe64817820a7dde76d9fae127a66b76941c (patch)
treefc6f5cf8013fa6aafde47a4a332c04ad6c2bfb1a
parent2ebbb153d3d17bc1405e23dafe2256c0b855088d (diff)
downloadeclipse.platform.swt-8b51cbe64817820a7dde76d9fae127a66b76941c.tar.gz
eclipse.platform.swt-8b51cbe64817820a7dde76d9fae127a66b76941c.tar.xz
eclipse.platform.swt-8b51cbe64817820a7dde76d9fae127a66b76941c.zip
Bug 533722: [Mac]Custom cursor without transparency not shown
If ImageData doesn't have alpha, set alpha to false in nsImageRep.initWithBitmapDataPlanes. Change-Id: If2b932e04940869ec0ffbb3de690568d4c287b08
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Cursor.java11
1 files changed, 7 insertions, 4 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Cursor.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Cursor.java
index 6e117c7445..e717e1d53a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Cursor.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Cursor.java
@@ -313,14 +313,14 @@ public Cursor(Device device, ImageData source, ImageData mask, int hotspotX, int
NSAutoreleasePool pool = null;
if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
try {
- createNSCursor(hotspotX, hotspotY, data, source.width, source.height);
+ createNSCursor(hotspotX, hotspotY, data, source.width, source.height, true);
init();
} finally {
if (pool != null) pool.release();
}
}
-void createNSCursor(int hotspotX, int hotspotY, byte[] buffer, int width, int height) {
+void createNSCursor(int hotspotX, int hotspotY, byte[] buffer, int width, int height, boolean hasAlpha) {
NSImage nsImage = (NSImage)new NSImage().alloc();
NSBitmapImageRep nsImageRep = (NSBitmapImageRep)new NSBitmapImageRep().alloc();
handle = (NSCursor)new NSCursor().alloc();
@@ -329,7 +329,7 @@ void createNSCursor(int hotspotX, int hotspotY, byte[] buffer, int width, int he
size.height = height;
nsImage = nsImage.initWithSize(size);
nsImageRep = nsImageRep.initWithBitmapDataPlanes(0, width, height,
- 8, 4, true, false, OS.NSDeviceRGBColorSpace,
+ 8, hasAlpha ? 4 : 3, hasAlpha, false, OS.NSDeviceRGBColorSpace,
OS.NSAlphaFirstBitmapFormat | OS.NSAlphaNonpremultipliedBitmapFormat, width * 4, 32);
C.memmove(nsImageRep.bitmapData(), buffer, buffer.length);
nsImage.addRepresentation(nsImageRep);
@@ -404,6 +404,7 @@ public Cursor(Device device, ImageData source, int hotspotX, int hotspotY) {
data, 32, source.width * 4, ImageData.MSB_FIRST, 0, 0, source.width, source.height, 0xFF0000, 0xFF00, 0xFF,
false, false);
}
+ boolean hasAlpha = true;
if (source.maskData != null || source.transparentPixel != -1) {
ImageData mask = source.getTransparencyMask();
byte[] maskData = mask.data;
@@ -426,11 +427,13 @@ public Cursor(Device device, ImageData source, int hotspotX, int hotspotY) {
for (int i=0; i<data.length; i+=4) {
data[i] = alphaData[i/4];
}
+ } else {
+ hasAlpha = false;
}
NSAutoreleasePool pool = null;
if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
try {
- createNSCursor(hotspotX, hotspotY, data, source.width, source.height);
+ createNSCursor(hotspotX, hotspotY, data, source.width, source.height, hasAlpha);
init();
} finally {
if (pool != null) pool.release();

Back to the top