[PATCH v2 0/4] ui/cocoa: Add cursor composition

Akihiko Odaki posted 4 patches 5 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20240627-cursor-v2-0-c3cd3ee35616@daynix.com
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Dmitry Fleytman <dmitry.fleytman@gmail.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Thomas Huth <thuth@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Peter Maydell <peter.maydell@linaro.org>, Akihiko Odaki <akihiko.odaki@daynix.com>
meson.build             |   3 +-
include/ui/console.h    |   5 +--
hw/display/ati.c        |   2 +-
hw/display/qxl-render.c |   4 --
hw/display/virtio-gpu.c |   3 +-
hw/display/vmware_vga.c |   8 ++--
ui/console.c            |  18 ++-------
ui/dbus-listener.c      |   2 +-
ui/gtk.c                |   2 +-
ui/sdl2.c               |   4 +-
ui/spice-display.c      |  11 ++---
ui/vnc.c                |   2 +-
ui/cocoa.m              | 104 +++++++++++++++++++++++++++++++++++++++++++++++-
13 files changed, 126 insertions(+), 42 deletions(-)
[PATCH v2 0/4] ui/cocoa: Add cursor composition
Posted by Akihiko Odaki 5 months ago
Add accelerated cursor composition to ui/cocoa. This does not only
improve performance for display devices that exposes the capability to
the guest according to dpy_cursor_define_supported(), but fixes the
cursor display for devices that unconditionally expects the availability
of the capability (e.g., virtio-gpu).

The common pattern to implement accelerated cursor composition is to
replace the cursor and warp it so that the replaced cursor is shown at
the correct position on the guest display for relative pointer devices.
Unfortunately, ui/cocoa cannot do the same because warping the cursor
position interfers with the mouse input so it uses CALayer instead;
although it is not specialized for cursor composition, it still can
compose images with hardware acceleration.

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
Changes in v2:
- Incorporated changes from:
  https://lore.kernel.org/r/20240625134931.92279-2-phil@philjordan.eu
  ("[PATCH v2 1/2] ui/cocoa: Minor fixes to CALayer based cursors")
- Added patch "ui/cocoa: Release CGColorSpace"
- Added patch "ui/console: Convert mouse visibility parameter into bool"
- Noted that the problem with warping is relevant only for relative
  pointer devices.
- Link to v1: https://lore.kernel.org/r/20240318-cursor-v1-0-0bbe6c382217@daynix.com

---
Akihiko Odaki (4):
      ui/cocoa: Release CGColorSpace
      ui/console: Convert mouse visibility parameter into bool
      ui/cocoa: Add cursor composition
      ui/console: Remove dpy_cursor_define_supported()

 meson.build             |   3 +-
 include/ui/console.h    |   5 +--
 hw/display/ati.c        |   2 +-
 hw/display/qxl-render.c |   4 --
 hw/display/virtio-gpu.c |   3 +-
 hw/display/vmware_vga.c |   8 ++--
 ui/console.c            |  18 ++-------
 ui/dbus-listener.c      |   2 +-
 ui/gtk.c                |   2 +-
 ui/sdl2.c               |   4 +-
 ui/spice-display.c      |  11 ++---
 ui/vnc.c                |   2 +-
 ui/cocoa.m              | 104 +++++++++++++++++++++++++++++++++++++++++++++++-
 13 files changed, 126 insertions(+), 42 deletions(-)
---
base-commit: 74abb45dac6979e7ff76172b7f0a24e869405184
change-id: 20240318-cursor-3491b1806582

Best regards,
-- 
Akihiko Odaki <akihiko.odaki@daynix.com>
Re: [PATCH v2 0/4] ui/cocoa: Add cursor composition
Posted by Phil Dennis-Jordan 4 months, 3 weeks ago
On Thu, 27 Jun 2024 at 13:17, Akihiko Odaki <akihiko.odaki@daynix.com>
wrote:

> Add accelerated cursor composition to ui/cocoa. This does not only
> improve performance for display devices that exposes the capability to
> the guest according to dpy_cursor_define_supported(), but fixes the
> cursor display for devices that unconditionally expects the availability
> of the capability (e.g., virtio-gpu).
>
> The common pattern to implement accelerated cursor composition is to
> replace the cursor and warp it so that the replaced cursor is shown at
> the correct position on the guest display for relative pointer devices.
> Unfortunately, ui/cocoa cannot do the same because warping the cursor
> position interfers with the mouse input so it uses CALayer instead;
> although it is not specialized for cursor composition, it still can
> compose images with hardware acceleration.
>
> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
>

After fixing the typo in patch 3/4, the code appears to work as intended.
(Tested on macOS 13 & 14, virtio-gpu with Cocoa UI.)

So, for the whole patch set:

Tested-by: Phil Dennis-Jordan <phil@philjordan.eu>