@@ -15,6 +15,7 @@ import { AttributeData } from 'common/buffer/AttributeData';
1515import { IColorSet } from 'browser/Types' ;
1616import { CellData } from 'common/buffer/CellData' ;
1717import { IBufferService , IDecorationService , IOptionsService } from 'common/services/Services' ;
18+ import { ICoreBrowserService } from 'browser/services/Services' ;
1819import { excludeFromContrastRatioDemands , throwIfFalsy } from 'browser/renderer/RendererUtils' ;
1920import { channels , color , rgba } from 'common/Color' ;
2021import { removeElementFromParent } from 'browser/Dom' ;
@@ -60,7 +61,8 @@ export abstract class BaseRenderLayer implements IRenderLayer {
6061 private _rendererId : number ,
6162 protected readonly _bufferService : IBufferService ,
6263 protected readonly _optionsService : IOptionsService ,
63- protected readonly _decorationService : IDecorationService
64+ protected readonly _decorationService : IDecorationService ,
65+ protected readonly _coreBrowserService : ICoreBrowserService
6466 ) {
6567 this . _canvas = document . createElement ( 'canvas' ) ;
6668 this . _canvas . classList . add ( `xterm-${ id } -layer` ) ;
@@ -125,7 +127,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
125127 if ( this . _scaledCharWidth <= 0 && this . _scaledCharHeight <= 0 ) {
126128 return ;
127129 }
128- this . _charAtlas = acquireCharAtlas ( this . _optionsService . rawOptions , this . _rendererId , colorSet , this . _scaledCharWidth , this . _scaledCharHeight ) ;
130+ this . _charAtlas = acquireCharAtlas ( this . _optionsService . rawOptions , this . _rendererId , colorSet , this . _scaledCharWidth , this . _scaledCharHeight , this . _coreBrowserService . dpr ) ;
129131 this . _charAtlas . warmUp ( ) ;
130132 }
131133
@@ -180,9 +182,9 @@ export abstract class BaseRenderLayer implements IRenderLayer {
180182 const cellOffset = Math . ceil ( this . _scaledCellHeight * 0.5 ) ;
181183 this . _ctx . fillRect (
182184 x * this . _scaledCellWidth ,
183- ( y + 1 ) * this . _scaledCellHeight - cellOffset - window . devicePixelRatio ,
185+ ( y + 1 ) * this . _scaledCellHeight - cellOffset - this . _coreBrowserService . dpr ,
184186 width * this . _scaledCellWidth ,
185- window . devicePixelRatio ) ;
187+ this . _coreBrowserService . dpr ) ;
186188 }
187189
188190 /**
@@ -194,23 +196,24 @@ export abstract class BaseRenderLayer implements IRenderLayer {
194196 protected _fillBottomLineAtCells ( x : number , y : number , width : number = 1 , pixelOffset : number = 0 ) : void {
195197 this . _ctx . fillRect (
196198 x * this . _scaledCellWidth ,
197- ( y + 1 ) * this . _scaledCellHeight + pixelOffset - window . devicePixelRatio - 1 /* Ensure it's drawn within the cell */ ,
199+ ( y + 1 ) * this . _scaledCellHeight + pixelOffset - this . _coreBrowserService . dpr - 1 /* Ensure it's drawn within the cell */ ,
198200 width * this . _scaledCellWidth ,
199- window . devicePixelRatio ) ;
201+ this . _coreBrowserService . dpr ) ;
200202 }
201203
202204 protected _curlyUnderlineAtCell ( x : number , y : number , width : number = 1 ) : void {
203205 this . _ctx . save ( ) ;
204206 this . _ctx . beginPath ( ) ;
205207 this . _ctx . strokeStyle = this . _ctx . fillStyle ;
206- this . _ctx . lineWidth = window . devicePixelRatio ;
208+ const lineWidth = this . _coreBrowserService . dpr ;
209+ this . _ctx . lineWidth = lineWidth ;
207210 for ( let xOffset = 0 ; xOffset < width ; xOffset ++ ) {
208211 const xLeft = ( x + xOffset ) * this . _scaledCellWidth ;
209212 const xMid = ( x + xOffset + 0.5 ) * this . _scaledCellWidth ;
210213 const xRight = ( x + xOffset + 1 ) * this . _scaledCellWidth ;
211- const yMid = ( y + 1 ) * this . _scaledCellHeight - window . devicePixelRatio - 1 ;
212- const yMidBot = yMid - window . devicePixelRatio ;
213- const yMidTop = yMid + window . devicePixelRatio ;
214+ const yMid = ( y + 1 ) * this . _scaledCellHeight - lineWidth - 1 ;
215+ const yMidBot = yMid - lineWidth ;
216+ const yMidTop = yMid + lineWidth ;
214217 this . _ctx . moveTo ( xLeft , yMid ) ;
215218 this . _ctx . bezierCurveTo (
216219 xLeft , yMidBot ,
@@ -231,10 +234,11 @@ export abstract class BaseRenderLayer implements IRenderLayer {
231234 this . _ctx . save ( ) ;
232235 this . _ctx . beginPath ( ) ;
233236 this . _ctx . strokeStyle = this . _ctx . fillStyle ;
234- this . _ctx . lineWidth = window . devicePixelRatio ;
235- this . _ctx . setLineDash ( [ window . devicePixelRatio * 2 , window . devicePixelRatio ] ) ;
237+ const lineWidth = this . _coreBrowserService . dpr ;
238+ this . _ctx . lineWidth = lineWidth ;
239+ this . _ctx . setLineDash ( [ lineWidth * 2 , lineWidth ] ) ;
236240 const xLeft = x * this . _scaledCellWidth ;
237- const yMid = ( y + 1 ) * this . _scaledCellHeight - window . devicePixelRatio - 1 ;
241+ const yMid = ( y + 1 ) * this . _scaledCellHeight - lineWidth - 1 ;
238242 this . _ctx . moveTo ( xLeft , yMid ) ;
239243 for ( let xOffset = 0 ; xOffset < width ; xOffset ++ ) {
240244 // const xLeft = x * this._scaledCellWidth;
@@ -250,11 +254,12 @@ export abstract class BaseRenderLayer implements IRenderLayer {
250254 this . _ctx . save ( ) ;
251255 this . _ctx . beginPath ( ) ;
252256 this . _ctx . strokeStyle = this . _ctx . fillStyle ;
253- this . _ctx . lineWidth = window . devicePixelRatio ;
254- this . _ctx . setLineDash ( [ window . devicePixelRatio * 4 , window . devicePixelRatio * 3 ] ) ;
257+ const lineWidth = this . _coreBrowserService . dpr ;
258+ this . _ctx . lineWidth = lineWidth ;
259+ this . _ctx . setLineDash ( [ lineWidth * 4 , lineWidth * 3 ] ) ;
255260 const xLeft = x * this . _scaledCellWidth ;
256261 const xRight = ( x + width ) * this . _scaledCellWidth ;
257- const yMid = ( y + 1 ) * this . _scaledCellHeight - window . devicePixelRatio - 1 ;
262+ const yMid = ( y + 1 ) * this . _scaledCellHeight - lineWidth - 1 ;
258263 this . _ctx . moveTo ( xLeft , yMid ) ;
259264 this . _ctx . lineTo ( xRight , yMid ) ;
260265 this . _ctx . stroke ( ) ;
@@ -272,7 +277,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
272277 this . _ctx . fillRect (
273278 x * this . _scaledCellWidth ,
274279 y * this . _scaledCellHeight ,
275- window . devicePixelRatio * width ,
280+ this . _coreBrowserService . dpr * width ,
276281 this . _scaledCellHeight ) ;
277282 }
278283
@@ -283,12 +288,13 @@ export abstract class BaseRenderLayer implements IRenderLayer {
283288 * @param y The row to fill.
284289 */
285290 protected _strokeRectAtCell ( x : number , y : number , width : number , height : number ) : void {
286- this . _ctx . lineWidth = window . devicePixelRatio ;
291+ const lineWidth = this . _coreBrowserService . dpr ;
292+ this . _ctx . lineWidth = lineWidth ;
287293 this . _ctx . strokeRect (
288- x * this . _scaledCellWidth + window . devicePixelRatio / 2 ,
289- y * this . _scaledCellHeight + ( window . devicePixelRatio / 2 ) ,
290- width * this . _scaledCellWidth - window . devicePixelRatio ,
291- ( height * this . _scaledCellHeight ) - window . devicePixelRatio ) ;
294+ x * this . _scaledCellWidth + lineWidth / 2 ,
295+ y * this . _scaledCellHeight + ( lineWidth / 2 ) ,
296+ width * this . _scaledCellWidth - lineWidth ,
297+ ( height * this . _scaledCellHeight ) - lineWidth ) ;
292298 }
293299
294300 /**
@@ -344,7 +350,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
344350 // Draw custom characters if applicable
345351 let drawSuccess = false ;
346352 if ( this . _optionsService . rawOptions . customGlyphs !== false ) {
347- drawSuccess = tryDrawCustomChar ( this . _ctx , cell . getChars ( ) , x * this . _scaledCellWidth , y * this . _scaledCellHeight , this . _scaledCellWidth , this . _scaledCellHeight , this . _optionsService . rawOptions . fontSize ) ;
353+ drawSuccess = tryDrawCustomChar ( this . _ctx , cell . getChars ( ) , x * this . _scaledCellWidth , y * this . _scaledCellHeight , this . _scaledCellWidth , this . _scaledCellHeight , this . _optionsService . rawOptions . fontSize , this . _coreBrowserService . dpr ) ;
348354 }
349355
350356 // Draw the character
@@ -472,7 +478,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
472478 // Draw custom characters if applicable
473479 let drawSuccess = false ;
474480 if ( this . _optionsService . rawOptions . customGlyphs !== false ) {
475- drawSuccess = tryDrawCustomChar ( this . _ctx , cell . getChars ( ) , x * this . _scaledCellWidth , y * this . _scaledCellHeight , this . _scaledCellWidth , this . _scaledCellHeight , this . _optionsService . rawOptions . fontSize ) ;
481+ drawSuccess = tryDrawCustomChar ( this . _ctx , cell . getChars ( ) , x * this . _scaledCellWidth , y * this . _scaledCellHeight , this . _scaledCellWidth , this . _scaledCellHeight , this . _optionsService . rawOptions . fontSize , this . _coreBrowserService . dpr ) ;
476482 }
477483
478484 // Draw the character
@@ -509,7 +515,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
509515 const fontWeight = isBold ? this . _optionsService . rawOptions . fontWeightBold : this . _optionsService . rawOptions . fontWeight ;
510516 const fontStyle = isItalic ? 'italic' : '' ;
511517
512- return `${ fontStyle } ${ fontWeight } ${ this . _optionsService . rawOptions . fontSize * window . devicePixelRatio } px ${ this . _optionsService . rawOptions . fontFamily } ` ;
518+ return `${ fontStyle } ${ fontWeight } ${ this . _optionsService . rawOptions . fontSize * this . _coreBrowserService . dpr } px ${ this . _optionsService . rawOptions . fontFamily } ` ;
513519 }
514520
515521 private _getContrastColor ( cell : CellData , x : number , y : number ) : IColor | undefined {
0 commit comments