[PR #9665] dx: add support for inverting all types of cursor #27694

Open
opened 2026-01-31 09:23:34 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/9665

State: closed
Merged: Yes


This commit introduces support for inverting all types of cursor.

To invert the display without re-rendering any text, we draw the cursor
into a command list and then compose the command list with the existing
renderer using the MASK_INVERT composition flag.

This wouldn't normally work with our renderer because there is no
background color to invert in some cases (such as when acrylic is in
use.)

To work around that, we're taking advantage of @zadjii-msft's two-pass
cursor renderer.

To properly invert the cursor over a transparent background:
(Examples are given below for two cursor types, but this applies to all
of them.)

First, we'll draw a "backplate" in the user's requested background color
(with the alpha channel set to 0xFF). (firstPass == true)

EMPTY BOX  FILLED BOX
=====      =====
=   =      =====
=   =      =====
=   =      =====
=====      =====

Second, the glyph is drawn (outside of the cursor renderer).

EMPTY BOX  FILLED BOX
==A==      ==A==
=A A=      =A=A=
AAAAA      AAAAA
A   A      A===A
A===A      A===A

Last, we'll draw the cursor again in all white and use that as the
mask for inverting the already-drawn pixels. (firstPass == false) (#
= mask, a = inverted A)

EMPTY BOX  FILLED BOX
##a##      ##a##
#A A#      #a#a#
aAAAa      aaaaa
a   a      a###a
a###a      a###a

Related to #9610

Validation Steps Performed

Manual visual validation in all configurations.

**Original Pull Request:** https://github.com/microsoft/terminal/pull/9665 **State:** closed **Merged:** Yes --- This commit introduces support for inverting all types of cursor. To invert the display without re-rendering any text, we draw the cursor into a command list and then compose the command list with the existing renderer using the MASK_INVERT composition flag. This wouldn't normally work with our renderer because there is no _background_ color to invert in some cases (such as when acrylic is in use.) To work around that, we're taking advantage of @zadjii-msft's two-pass cursor renderer. To properly invert the cursor over a transparent background: (Examples are given below for two cursor types, but this applies to all of them.) First, we'll draw a "backplate" in the user's requested background color (with the alpha channel set to 0xFF). (`firstPass` == true) EMPTY BOX FILLED BOX ===== ===== = = ===== = = ===== = = ===== ===== ===== Second, the glyph is drawn (outside of the cursor renderer). EMPTY BOX FILLED BOX ==A== ==A== =A A= =A=A= AAAAA AAAAA A A A===A A===A A===A Last, we'll draw the cursor again in all white and use that as the *mask* for inverting the already-drawn pixels. (`firstPass` == false) (# = mask, a = inverted A) EMPTY BOX FILLED BOX ##a## ##a## #A A# #a#a# aAAAa aaaaa a a a###a a###a a###a Related to #9610 ## Validation Steps Performed Manual visual validation in all configurations.
claunia added the pull-request label 2026-01-31 09:23:34 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#27694