sway icon indicating copy to clipboard operation
sway copied to clipboard

Draft: sway/commands/output: Add command to set color profile

Open mstoeckl opened this issue 2 years ago • 11 comments
trafficstars

This PR matches the very WIP wlroots MR 4280.

This requires the Vulkan renderer to be useful. (Use WLR_RENDERER=vulkan ; setting VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation to enable validation layers may be useful for testing.)

Example usage:

swaymsg output '*' color_profile icc /usr/share/color/icc/colord/ProPhotoRGB.icc

Known issues:

  • ~some race condition in which only some frames render correctly; causes flickering~ (fixed)
  • ~Only applies with bit depth 10, at the moment~ (fixed)
  • ~Having to copy the struct wlr_color_transform a number of times is awkward~ (now using reference counting)

mstoeckl avatar Jul 19 '23 00:07 mstoeckl

I think we need to add #ifs (that's a bit cumbersome) and missing deps in CI manifests?

I've added missing dependencies for lcms2, so that the wlroots build (and by extension the sway build) uses color management features.

I have not yet made it possible to build this without lcms2 support, and will update this PR eventually to do that.

mstoeckl avatar May 16 '24 03:05 mstoeckl

Tested it on my Framework 13 AMD. Seems to work as expected :+1:

Just an idea, would it be reasonable to be able to unset a profile as well? By unset, I mean returning to the same state as if I'd never called the color_profile command.

Maybe something like: swaymsg output '*' color_profile unset

GreyXor avatar May 16 '24 12:05 GreyXor

Just an idea, would it be reasonable to be able to unset a profile as well? By unset, I mean returning to the same state as if I'd never called the color_profile command.

The default profile is srgb, and one can go back to it with:

swaymsg output '*' color_profile srgb

mstoeckl avatar May 16 '24 13:05 mstoeckl

Hi, I correctly set my icc profile but when swaylock is triggered from swayidle (via killall -USR1 swayidle or when the swayidle timetout's reached). I see a little square: image

this not happening if I directly start swaylock from terminal (or if i'm not setting the icc profile). Thanks AMA if I can help with this issue

Riptils avatar May 16 '24 17:05 Riptils

I have not yet made it possible to build this without lcms2 support, and will update this PR eventually to do that.

I've been wondering whether we should always make wlr_color_transform available regardless of LCMS availability. I think it depends if we want to base all of our color pipeline on LCMS (Weston-style), or if we want to implement this ourselves.

when I launch swaylock through swayidle I have a smal square around the circle

Weird, the ICC profile should only affect the final post-blending image. Maybe there is a small difference not noticable without the ICC profile applied, which becomes visible once the ICC profile is applied?

emersion avatar May 16 '24 18:05 emersion

I've been wondering whether we should always make wlr_color_transform available regardless of LCMS availability. I think it depends if we want to base all of our color pipeline on LCMS (Weston-style), or if we want to implement this ourselves.

I've also been considering this: 1) one might want to use CICP tags to pick output color profiles (e.g. to work with HDR10) in which case one can do color management without LCMS 2) the use of LCMS in wlroots is already confined to converting ICC file data to wlr_color_transform, and may be a more natural boundary.

mstoeckl avatar May 16 '24 19:05 mstoeckl

Right. AFAIU, Weston plans to translate the CICP stuff into LCMS pipelines (with the float point number transforms that nobody uses in ICC). Other compositors seem to do math in shaders.

emersion avatar May 16 '24 19:05 emersion

Hi, I correctly set my icc profile but when swaylock is triggered from swayidle (via killall -USR1 swayidle or when the swayidle timetout's reached). I see a little square: image

this not happening if I directly start swaylock from terminal (or if i'm not setting the icc profile). Thanks AMA if I can help with this issue

I have the same issue :

recording.webm

and also, it's as if every time I write on the keyboard (i.e. when the circle is modified) the ICC profile is deactivated/activated. Or something like that

GreyXor avatar May 17 '24 08:05 GreyXor

@GreyXor, @Riptils, do you see the issue if you run sway with WLR_SCENE_DISABLE_DIRECT_SCANOUT=1? The color transformation does not apply to direct scanout.

kennylevinsen avatar May 17 '24 10:05 kennylevinsen

@GreyXor, @Riptils, do you see the issue if you run sway with WLR_SCENE_DISABLE_DIRECT_SCANOUT=1? The color transformation does not apply to direct scanout.

Thanks, yes I still have the same issue

GreyXor avatar May 17 '24 10:05 GreyXor

I still have the issue, even with the env var

Riptils avatar May 17 '24 11:05 Riptils

Ref https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4692

emersion avatar May 24 '24 08:05 emersion

Now that the wlroots patch has been merged, just need to guard wlr_color_transform_init_linear_to_icc().

emersion avatar Jun 06 '24 17:06 emersion

just need to guard wlr_color_transform_init_linear_to_icc().

This is already done: wlroots compiles it to a NULL-returning stub, and the code checks for an returns an error on a NULL return value.

mstoeckl avatar Jun 06 '24 20:06 mstoeckl

Oh right, didn't even remember about the patch I wrote.

emersion avatar Jun 06 '24 20:06 emersion

Is there a reason this is still marked as a draft?

No; as this is no longer waiting on wlroots changes I have marked it as ready.

mstoeckl avatar Jun 06 '24 23:06 mstoeckl

Thanks!

emersion avatar Jun 07 '24 17:06 emersion