From 39959c286168416b3493f5f2ebc52ceecb1007ee Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Sun, 31 Jul 2022 15:39:34 -0700 Subject: [PATCH] Don't dim default bg in webgl Fixes #3970 --- addons/xterm-addon-webgl/src/RectangleRenderer.ts | 5 ++++- addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/xterm-addon-webgl/src/RectangleRenderer.ts b/addons/xterm-addon-webgl/src/RectangleRenderer.ts index bc08ad4a..f16fdec0 100644 --- a/addons/xterm-addon-webgl/src/RectangleRenderer.ts +++ b/addons/xterm-addon-webgl/src/RectangleRenderer.ts @@ -12,6 +12,7 @@ import { IColorSet } from 'browser/Types'; import { IRenderDimensions } from 'browser/renderer/Types'; import { RENDER_MODEL_BG_OFFSET, RENDER_MODEL_FG_OFFSET, RENDER_MODEL_INDICIES_PER_CELL } from './RenderModel'; import { Disposable, toDisposable } from 'common/Lifecycle'; +import { DIM_OPACITY } from 'browser/renderer/Constants'; const enum VertexAttribLocations { POSITION = 0, @@ -208,6 +209,7 @@ export class RectangleRenderer extends Disposable { private _updateRectangle(vertices: IVertices, offset: number, fg: number, bg: number, startX: number, endX: number, y: number): void { let rgba: number | undefined; + let isDefault = false; if (fg & FgFlags.INVERSE) { switch (fg & Attributes.CM_MASK) { case Attributes.CM_P16: @@ -233,6 +235,7 @@ export class RectangleRenderer extends Disposable { case Attributes.CM_DEFAULT: default: rgba = this._colors.background.rgba; + isDefault = true; } } @@ -244,7 +247,7 @@ export class RectangleRenderer extends Disposable { const r = ((rgba >> 24) & 0xFF) / 255; const g = ((rgba >> 16) & 0xFF) / 255; const b = ((rgba >> 8 ) & 0xFF) / 255; - const a = bg & BgFlags.DIM ? 0.5 : 1; + const a = (!isDefault && bg & BgFlags.DIM) ? DIM_OPACITY : 1; this._addRectangle(vertices.attributes, offset, x1, y1, (endX - startX) * this._dimensions.scaledCellWidth, this._dimensions.scaledCellHeight, r, g, b, a); } diff --git a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts index b10fd6ec..13dceae6 100644 --- a/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts +++ b/addons/xterm-addon-webgl/src/atlas/WebglCharAtlas.ts @@ -241,7 +241,7 @@ export class WebglCharAtlas implements IDisposable { if (dim) { // Blend here instead of using opacity because transparent colors mess with clipping the // glyph's bounding box - result = color.blend(this._config.colors.background, color.multiplyOpacity(result, 0.5)); + result = color.blend(this._config.colors.background, color.multiplyOpacity(result, DIM_OPACITY)); } return result; @@ -283,7 +283,7 @@ export class WebglCharAtlas implements IDisposable { // Apply dim to the color, opacity is fine to use for the foreground color if (dim) { - result = color.multiplyOpacity(result, 0.5); + result = color.multiplyOpacity(result, DIM_OPACITY); } return result;