CIContext with Software Rendering on Retina Display Causes Incorrect Rendering
| Originator: | gusmueller | ||
| Number: | rdar://14066419 | Date Originated: | 04-Jun-2013 |
| Status: | Open | Resolved: | |
| Product: | OSX | Product Version: | 10.8.4 |
| Classification: | Serious Bug | Reproducible: | Always |
Summary:
Creating a CIContext with the software rendering option turned on causes the output on retina displays to render incorrectly. It looks like the image is being downsampled, and then upsampled incorrectly.
The CGContext being used is from [[NSGraphicsContext currentContext] graphicsPort] in an NSView subclass:
NSDictionary *options = @{kCIContextUseSoftwareRenderer: @(YES)};
_cpuContext = [CIContext contextWithCGContext:[[NSGraphicsContext currentContext] graphicsPort] options:options];
Steps to Reproduce:
Run the enclosed sample on a Retina display. Toggle the button in the window to switch between GPU and CPU rendering.
It's a little hard to see on Retina displays, but if you view the enclosed images "CPURendering.png" and "GPURendering.png" and zoom in, you can see the differences.
Expected Results:
Rendering with a software context would not cause the display artifacts.
Actual Results:
It looks like the software CIContext is scaling down the image, and then scaling it back up, and then drawing it— essentially throwing out 75% of the pixels in the image.
Regression:
This problem does not occur on non-hidpi displays.
Notes:
Creating a CGImageRef from the software cicontext and then drawing that to the CGContextRef from [[NSGraphicsContext currentContext] graphicsPort] will draw things correctly. But, that's a lot of extra work for the CPU to be doing and probably not as fast.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
Sample File
http://gusmueller.com/stuff/CIContextOnCPUWithRetinaBug.zip