| Summary: | GC can not capture screen correctly in MAC 10.7 lion | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Fan Peng <pfancdl> | ||||||
| Component: | SWT | Assignee: | Silenio Quarti <Silenio_Quarti> | ||||||
| Status: | RESOLVED FIXED | QA Contact: | |||||||
| Severity: | critical | ||||||||
| Priority: | P3 | CC: | cyzhdl, eclipse.felipe, kleind, linyunz, mukund, pfancdl, Silenio_Quarti | ||||||
| Version: | 3.6.2 | ||||||||
| Target Milestone: | 3.7.1 | ||||||||
| Hardware: | Macintosh | ||||||||
| OS: | Mac OS X - Carbon (unsup.) | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
|
Description
Fan Peng
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. |