Make double buffering of Terminal adopt to higher monitor zooms#2473
Open
HeikoKlare wants to merge 1 commit intoeclipse-platform:masterfrom
Open
Make double buffering of Terminal adopt to higher monitor zooms#2473HeikoKlare wants to merge 1 commit intoeclipse-platform:masterfrom
HeikoKlare wants to merge 1 commit intoeclipse-platform:masterfrom
Conversation
c940705 to
0e4de06
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the terminal text rendering path to avoid custom per-line image double buffering (which rendered at 100% scale on some platforms), and instead relies on rendering directly to the control with SWT native double buffering so output stays sharp on HiDPI / fractional scaling (MacOS/Linux).
Changes:
- Remove per-line
Imageback-buffer rendering inTextLineRendererand draw directly to the providedGC. - Enable SWT native double buffering on
TextCanvasviaSWT.DOUBLE_BUFFERED. - Adjust underline drawing API to accept screen offsets (but see comments for a positioning bug).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
terminal/bundles/org.eclipse.terminal.control/src/org/eclipse/terminal/internal/textcanvas/TextLineRenderer.java |
Switches line rendering from manual Image double buffer to direct GC painting; updates underline drawing to use offsets. |
terminal/bundles/org.eclipse.terminal.control/src/org/eclipse/terminal/internal/textcanvas/TextCanvas.java |
Enables SWT native double buffering for the terminal canvas control. |
Comments suppressed due to low confidence (1)
terminal/bundles/org.eclipse.terminal.control/src/org/eclipse/terminal/internal/textcanvas/TextLineRenderer.java:191
drawUnderline(...)uses absolutecolStart/colEndto computex/x2, butdrawLine(...)is often called for a clipped column range (colFirstmay be > 0) wherexis the screen origin forcolFirst. This will misplace the underline whenever the paint clip starts mid-line (andx2also currently ignoresxOffset). Consider computing underline coordinates relative tocolFirst(or passcolFirstintodrawUnderline) and includexOffsetwhen computingx2so the line aligns withdrawText(...)offsets.
private void drawUnderline(GC gc, int xOffset, int yOffset, int colStart, int colEnd) {
int y = yOffset + getCellHeight() - 1;
int x = xOffset + getCellWidth() * colStart;
// x2 is the right side of last column being underlined.
int x2 = (colEnd + 1) * getCellWidth() - 1;
gc.drawLine(x, y, x2, y);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
....eclipse.terminal.control/src/org/eclipse/terminal/internal/textcanvas/TextLineRenderer.java
Show resolved
Hide resolved
The terminal implementation uses a custom double buffering implementation for rendering the current line. On most Platforms (Linux and MacOS) the current implementation will always render the double-buffered image at 100% zoom, even if the target zoom is higher. This change adapts the implementation to directly render into the actual control and enable native double buffering for the control instead. This ensures that the contents are rendered at the actual target zoom, producing sharper results on HiDPI monitors when using MacOS or Linux. Fixes eclipse-platform#2295 Fixes eclipse-platform#2191 # Conflicts: # terminal/bundles/org.eclipse.terminal.control/src/org/eclipse/terminal/internal/textcanvas/TextLineRenderer.java
0e4de06 to
c3d16c9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The terminal implementation uses a custom double buffering implementation for rendering the current line. On most Platforms (Linux and MacOS) the current implementation will always render the double-buffered image at 100% zoom, even if the target zoom is higher.
This change adapts the implementation to directly render into the actual control and enable native double buffering for the control instead. This ensures that the contents are rendered at the actual target zoom, producing sharper results on HiDPI monitors when using MacOS or Linux.
Fixes #2295
Fixes #2191
How to reproduce
MacOS
On MacOS, have a two monitor setup with one high-resolution and one low-resolution monitor. Start the application on the low-resolution monitor and move the window over to the high-resolution monitor.
Without this change:

With this change:

Linux
On Linux, a single monitor setup with a monitor zoom > 100% is sufficient. It also happens with fractional scales. In the following, you see the appearance with 125% monitor zoom.
Without this change:

With this change:
