Community
Participate
Working Groups
Build Identifier: Eclipse SDK 3.6.2 carbon M20110105-0951 GC can not capture screen correctly in MAC 10.7 lion Reproducible: Always Steps to Reproduce: Run the sample, it will capture an area and stored the contents into an image. In MAC 10.7, it can not capture correctly(Both carbon and cocoa has this issue). 10.6 has no problem.
Created attachment 200049 [details] Sample to reproduce the issue Sample to reproduce the issue
I believe we should try to fix this for 3.7.1 I request a MacOSX 10.7 today, hopefully I get it soon and the we will be ready to work on this.
Created attachment 200560 [details] patch This patch uses CGDisplayCreateImage instead of CGDisplayBaseAddress when running in 10.7 and greater. I have run the code in 10.6 (forcing the code to use CGDisplayCreateImage) and it works fine. I still do not have a 10.7 to try it on.
Put the reason about this problem here for reference. This problem is caused by an apple API CGDisplayBaseAddress which is deprecated in Mac OS X v10.6. In the copyArea() method in the GC.java of swt carbon and cocoa, they both called that deprecated API CGDisplayBaseAddress to get the base address in framebuffer memory of an online display. But this API will always return 0 on Mac 10.7. That's why this function both fail in swt carbon and cocoa On Mac 10.7. Apple recommends we should use CGDisplayCreateImage to copy screen data if CGDisplayBaseAddress is deprecated. Quarz display service reference from Apple: http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/Quartz_Services_Ref/Reference/reference.html#//apple_ref/c/func/CGDisplayCreateImage CGDisplayBaseAddress Returns the base address in framebuffer memory of an online display. (Available in Mac OS X v10.0 through Mac OS X v10.6. There is no replacement; because direct access to the raw framebuffer is not necessary, there is no need to retrieve its memory address.) void * CGDisplayBaseAddress ( CGDirectDisplayID display ); Parameters display The identifier of the display to be accessed. Return Value The base address in framebuffer memory of the specified display. If the display ID is invalid, the return value is NULL. Discussion If the display has not been captured, the returned address may refer to read-only memory. Special Considerations This deprecated function returned an address in framebuffer memory. Instead of using the raw framebuffer to draw to the screen, you should instead use a supported drawing engine such as Quartz or OpenGL. While accessing the framebuffer directly has been deprecated, it is possible to copy screen data using CGDisplayCreateImage. Availability Available in Mac OS X v10.0 through Mac OS X v10.6. Deprecated in Mac OS X v10.6. CGDisplayCreateImage Returns an image containing the contents of the specified display. CGImageRef CGDisplayCreateImage( CGDirectDisplayID displayID ); Parameters display The identifier of the display for which an image is being created. Return Value An image containing the contents of the specified display. If the display ID is invalid, the return value is NULL. The caller is responsible for releasing the image created by calling CGImageRelease. Availability Available in Mac OS X v10.6 and later. Declared In CGDirectDisplay.h Declared In CGDirectDisplay.h
I tried this patch on Mac 10.7. It works. We will deliver this changes to resolve this problem. Thanks very much. (In reply to comment #3) > Created attachment 200560 [details] > patch > > This patch uses CGDisplayCreateImage instead of CGDisplayBaseAddress when > running in 10.7 and greater. I have run the code in 10.6 (forcing the code to > use CGDisplayCreateImage) and it works fine. I still do not have a 10.7 to try > it on.
Fixed in master and R3_7_maintenance http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=b74b414065a855cd1f454e71dbb13ea90f41b4d8 http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?h=R3_7_maintenance&id=5e863c9f9ebb193ecaa5102b0d17822c0d159fa8