Opal backend: make functional again#77
Conversation
…s, lazy surface creation
…face handleExposeRect
|
@gcasa Here is the last PR for what we talked about last month in gnustep meeting. ^^ |
|
@ivucica @fredkiefer Let me know if this is something GNUstep might want or not in the near term. There are still some issues with it I need to work out namely terminal rendering, fonts rendering for menus that I've been stuck on but I've made some progress for terminal. Then there is a delay launching GNUstep apps in non EMWH compliant window managers (that I've fixed in another more experimental fork not here because I don't want to touch code outside of Opal in this PR). A few months ago first I started out tinkering with libs-corebase, libs-opal, libs-quartzcore integration as an idea to facilitate easier application porting for things like texmate. It then extended to an idea for a future display server to replace both X11 and wayland as I learned about this code in libs-back that I've been working on for a few months in parallel.
So I have this WindowServer.app piece somewhat working, not pushed anywhere yet. Ignore the theme issues rendering a double menu and so on (trivial to solve, but is a hack to reparent menus in Menu.app Gershwin uses) I have been working to use some shared components that X or wayland would use such as libinput.
Anyway my goals was to fix the terminal, menu items rendering issue before pivoting back to the display server. But the idea to use a refreshed Opal vs Cairo drawing backend appealed to me for this project as being more architecturally correct over time. So step 1 is fixing opal to be on par with Cairo for X11 (I consider this PR a great first step with a follow up coming in time). Step 2 is finish WindowServer.app. Step 3 is port WindowManager.app to X11.app (think xquartz). The ideas is that there would a fully independent display server model for running GNUstep apps natively only requiring KMS drivers, libinput, and a few EGL related packages. Then I would make a separate application for optional compatibility with X11 applications (mostly I already have it with WIndowManager.app just needs a refactor), and eventually I would make something similar for Wayland applications both as optional bundles. |
| } | ||
|
|
||
| - (void) GSSetDevice: (void *)device | ||
|
|
| unsigned char *srcData = (unsigned char *)CGBitmapContextGetData(tmpCtx); | ||
| if (!srcData) { CGContextRelease(tmpCtx); return nil; } | ||
|
|
||
| // Convert from BGRA premultiplied to RGBA non-premultiplied |
There was a problem hiding this comment.
If I remember correctly, there should be a helper method in our implementation of NSBitmapImage to do this.
There was a problem hiding this comment.
Ah thank you for the tip. I will look into this, and try to get things refactored this week.
| } | ||
| else | ||
| { | ||
| // Fallback for non-RGB colors |
There was a problem hiding this comment.
This seems a bit strange as there are so many different colour spaces, wouldn't it be better to convert directly to RGB?
| CGContextRef ctx = CGCTX; | ||
| if (!ctx || !gradient) return; | ||
|
|
||
| NSInteger stops = [gradient numberOfColorStops]; |
There was a problem hiding this comment.
This duplicates the code from the last method. It would be better to have a shared conversion method or function.
fredkiefer
left a comment
There was a problem hiding this comment.
This looks like a great improvement. The code here is really in a very bd state and I am glad someone is fixing it.
Please feel free to review some of my suggestions but I am willing to merge even without further changes.


Summary
The opal backend in libs-back has been non-functional for years.
This PR is the minimum set of changes to make it usable again.
All changes are confined to
Source/opal/plus one declaration inHeaders/opal/OpalSurface.h.This does require my other PR to be merged:
gnustep/libs-opal#16
What's fixed
OpalSurfaceno longer callsOPX11ContextCreatebefore the X window is mapped (which produceda non-drawing context). A new lazy
-ensureX11Contextcreates theX11 context on first expose; the accessor calls it so every
OpalGState.mconsumer is covered without per-site edits. Resizeis handled for free since
XGServerrecreates the surface.OpalGState.m): filled in missing paths, fixedCTM and clipping around the compositing path.
OpalFontInfo.m): propagate hint settings tocairo font options; correct
_cairo_extents_for_NSGlyph.gradients; mapped NSCompositing operators onto CG blend modes.
NSColorgray values to device-RGBCGColorRefso gray fills/strokes take effect.-handleExposeRect:.Scope
No other backends touched. No shared code (
Source/gsc/,Source/x11/,Source/gui/) touched. Cairo path is unaffected.Building and testing
Verified: opal-backed apps render correctly. Workspace (cairo-backed)