Skip to content

Commit 5bd0584

Browse files
authored
Merge pull request microsoft#239327 from microsoft/tyriar/r1_97_239326
[release/1.97] Revert: Editor GPU: Pass content width through to scroll bar
2 parents b45a34d + 219cdbb commit 5bd0584

File tree

7 files changed

+12
-29
lines changed

7 files changed

+12
-29
lines changed

src/vs/editor/browser/gpu/gpu.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ export interface IGpuRenderStrategy extends IDisposable {
3636
* Resets the render strategy, clearing all data and setting up for a new frame.
3737
*/
3838
reset(): void;
39-
update(viewportData: ViewportData, viewLineOptions: ViewLineOptions): IGpuRenderStrategyUpdateResult;
39+
update(viewportData: ViewportData, viewLineOptions: ViewLineOptions): number;
4040
draw(pass: GPURenderPassEncoder, viewportData: ViewportData): void;
4141
}
42-
43-
export interface IGpuRenderStrategyUpdateResult {
44-
localContentWidth: number;
45-
}

src/vs/editor/browser/gpu/renderStrategy/baseRenderStrategy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { ViewEventHandler } from '../../../common/viewEventHandler.js';
77
import type { ViewportData } from '../../../common/viewLayout/viewLinesViewportData.js';
88
import type { ViewContext } from '../../../common/viewModel/viewContext.js';
99
import type { ViewLineOptions } from '../../viewParts/viewLines/viewLineOptions.js';
10-
import type { IGpuRenderStrategy, IGpuRenderStrategyUpdateResult } from '../gpu.js';
10+
import type { IGpuRenderStrategy } from '../gpu.js';
1111
import { GlyphRasterizer } from '../raster/glyphRasterizer.js';
1212
import type { ViewGpuContext } from '../viewGpuContext.js';
1313

@@ -31,6 +31,6 @@ export abstract class BaseRenderStrategy extends ViewEventHandler implements IGp
3131
}
3232

3333
abstract reset(): void;
34-
abstract update(viewportData: ViewportData, viewLineOptions: ViewLineOptions): IGpuRenderStrategyUpdateResult;
34+
abstract update(viewportData: ViewportData, viewLineOptions: ViewLineOptions): number;
3535
abstract draw(pass: GPURenderPassEncoder, viewportData: ViewportData): void;
3636
}

src/vs/editor/browser/gpu/renderStrategy/fullFileRenderStrategy.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import type { ViewLineOptions } from '../../viewParts/viewLines/viewLineOptions.
1616
import type { ITextureAtlasPageGlyph } from '../atlas/atlas.js';
1717
import { createContentSegmenter, type IContentSegmenter } from '../contentSegmenter.js';
1818
import { fullFileRenderStrategyWgsl } from './fullFileRenderStrategy.wgsl.js';
19-
import { BindingId, type IGpuRenderStrategyUpdateResult } from '../gpu.js';
19+
import { BindingId } from '../gpu.js';
2020
import { GPULifecycle } from '../gpuDisposable.js';
2121
import { quadVertices } from '../gpuUtils.js';
2222
import { GlyphRasterizer } from '../raster/glyphRasterizer.js';
@@ -232,7 +232,7 @@ export class FullFileRenderStrategy extends BaseRenderStrategy {
232232
this._finalRenderedLine = 0;
233233
}
234234

235-
update(viewportData: ViewportData, viewLineOptions: ViewLineOptions): IGpuRenderStrategyUpdateResult {
235+
update(viewportData: ViewportData, viewLineOptions: ViewLineOptions): number {
236236
// IMPORTANT: This is a hot function. Variables are pre-allocated and shared within the
237237
// loop. This is done so we don't need to trust the JIT compiler to do this optimization to
238238
// avoid potential additional blocking time in garbage collector which is a common cause of
@@ -501,9 +501,7 @@ export class FullFileRenderStrategy extends BaseRenderStrategy {
501501

502502
this._visibleObjectCount = visibleObjectCount;
503503

504-
return {
505-
localContentWidth: absoluteOffsetX
506-
};
504+
return visibleObjectCount;
507505
}
508506

509507
draw(pass: GPURenderPassEncoder, viewportData: ViewportData): void {

src/vs/editor/browser/gpu/renderStrategy/viewportRenderStrategy.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import type { ViewContext } from '../../../common/viewModel/viewContext.js';
1616
import type { ViewLineOptions } from '../../viewParts/viewLines/viewLineOptions.js';
1717
import type { ITextureAtlasPageGlyph } from '../atlas/atlas.js';
1818
import { createContentSegmenter, type IContentSegmenter } from '../contentSegmenter.js';
19-
import { BindingId, type IGpuRenderStrategyUpdateResult } from '../gpu.js';
19+
import { BindingId } from '../gpu.js';
2020
import { GPULifecycle } from '../gpuDisposable.js';
2121
import { quadVertices } from '../gpuUtils.js';
2222
import { GlyphRasterizer } from '../raster/glyphRasterizer.js';
@@ -184,7 +184,7 @@ export class ViewportRenderStrategy extends BaseRenderStrategy {
184184
}
185185
}
186186

187-
update(viewportData: ViewportData, viewLineOptions: ViewLineOptions): IGpuRenderStrategyUpdateResult {
187+
update(viewportData: ViewportData, viewLineOptions: ViewLineOptions): number {
188188
// IMPORTANT: This is a hot function. Variables are pre-allocated and shared within the
189189
// loop. This is done so we don't need to trust the JIT compiler to do this optimization to
190190
// avoid potential additional blocking time in garbage collector which is a common cause of
@@ -394,9 +394,8 @@ export class ViewportRenderStrategy extends BaseRenderStrategy {
394394
this._activeDoubleBufferIndex = this._activeDoubleBufferIndex ? 0 : 1;
395395

396396
this._visibleObjectCount = visibleObjectCount;
397-
return {
398-
localContentWidth: absoluteOffsetX
399-
};
397+
398+
return visibleObjectCount;
400399
}
401400

402401
draw(pass: GPURenderPassEncoder, viewportData: ViewportData): void {

src/vs/editor/browser/gpu/viewGpuContext.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ export class ViewGpuContext extends Disposable {
3333
readonly maxGpuCols = ViewportRenderStrategy.maxSupportedColumns;
3434

3535
readonly canvas: FastDomNode<HTMLCanvasElement>;
36-
readonly scrollWidthElement: FastDomNode<HTMLElement>;
3736
readonly ctx: GPUCanvasContext;
3837

3938
static device: Promise<GPUDevice>;
@@ -88,7 +87,6 @@ export class ViewGpuContext extends Disposable {
8887

8988
this.canvas = createFastDomNode(document.createElement('canvas'));
9089
this.canvas.setClassName('editorCanvas');
91-
this.scrollWidthElement = createFastDomNode(document.createElement('div'));
9290

9391
// Adjust the canvas size to avoid drawing under the scroll bar
9492
this._register(Event.runAndSubscribe(configurationService.onDidChangeConfiguration, e => {

src/vs/editor/browser/view.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ export class View extends ViewEventHandler {
256256
this._overflowGuardContainer.appendChild(this._scrollbar.getDomNode());
257257
if (this._viewGpuContext) {
258258
this._overflowGuardContainer.appendChild(this._viewGpuContext.canvas);
259-
this._linesContent.appendChild(this._viewGpuContext.scrollWidthElement);
260259
}
261260
this._overflowGuardContainer.appendChild(scrollDecoration.getDomNode());
262261
this._overflowGuardContainer.appendChild(this._overlayWidgets.getDomNode());

src/vs/editor/browser/viewParts/viewLinesGpu/viewLinesGpu.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ export class ViewLinesGpu extends ViewPart implements IViewLines {
4949
private _initViewportData?: ViewportData[];
5050
private _lastViewportData?: ViewportData;
5151
private _lastViewLineOptions?: ViewLineOptions;
52-
private _maxLocalContentWidthSoFar = 0;
5352

5453
private _device!: GPUDevice;
5554
private _renderPassDescriptor!: GPURenderPassDescriptor;
@@ -430,6 +429,7 @@ export class ViewLinesGpu extends ViewPart implements IViewLines {
430429
override onCursorStateChanged(e: viewEvents.ViewCursorStateChangedEvent): boolean { return true; }
431430
override onDecorationsChanged(e: viewEvents.ViewDecorationsChangedEvent): boolean { return true; }
432431
override onFlushed(e: viewEvents.ViewFlushedEvent): boolean { return true; }
432+
433433
override onLinesChanged(e: viewEvents.ViewLinesChangedEvent): boolean { return true; }
434434
override onLinesDeleted(e: viewEvents.ViewLinesDeletedEvent): boolean { return true; }
435435
override onLinesInserted(e: viewEvents.ViewLinesInsertedEvent): boolean { return true; }
@@ -473,14 +473,7 @@ export class ViewLinesGpu extends ViewPart implements IViewLines {
473473

474474
const options = new ViewLineOptions(this._context.configuration, this._context.theme.type);
475475

476-
const { localContentWidth } = this._renderStrategy.value!.update(viewportData, options);
477-
478-
// Track the largest local content width so far in this session and use it as the scroll
479-
// width. This is how the DOM renderer works as well, so you may not be able to scroll to
480-
// the right in a file with long lines until you scroll down.
481-
this._maxLocalContentWidthSoFar = Math.max(this._maxLocalContentWidthSoFar, localContentWidth / this._viewGpuContext.devicePixelRatio.get());
482-
this._context.viewModel.viewLayout.setMaxLineWidth(this._maxLocalContentWidthSoFar);
483-
this._viewGpuContext.scrollWidthElement.setWidth(this._context.viewLayout.getScrollWidth());
476+
this._renderStrategy.value!.update(viewportData, options);
484477

485478
this._updateAtlasStorageBufferAndTexture();
486479

0 commit comments

Comments
 (0)