@@ -138,7 +138,17 @@ export default class CanvasDrawer extends Mixin {
138138
139139 const decorations = this . minimap . decorationsByTypeThenRows ( firstRow , lastRow )
140140
141- this . updateBackDecorationsLayer ( firstRow , lastRow , lineHeight , charHeight , charWidth , canvasWidth , canvasHeight , editorElement , decorations )
141+ let renderData = {
142+ context : this . backLayer . context ,
143+ canvasWidth,
144+ canvasHeight,
145+ lineHeight,
146+ charWidth,
147+ charHeight,
148+ orders : Main . getPluginsOrder ( )
149+ }
150+
151+ this . updateBackDecorationsLayer ( firstRow , lastRow , renderData , lineHeight , editorElement , decorations )
142152 this . updateFrontDecorationsLayer ( firstRow , lastRow , lineHeight , charHeight , charWidth , canvasWidth , canvasHeight , editorElement , decorations )
143153
144154 this . pendingChanges = [ ]
@@ -223,16 +233,13 @@ export default class CanvasDrawer extends Mixin {
223233 * @param {number } firstRow firstRow the first row of the range to update
224234 * @param {number } lastRow lastRow the last row of the range to update
225235 *
236+ * @param {Object } renderData
226237 * @param {number } lineHeight this.minimap.getLineHeight() * devicePixelRatio
227- * @param {number } charHeight this.minimap.getCharHeight() * devicePixelRatio
228- * @param {number } charWidth this.minimap.getCharWidth() * devicePixelRatio
229- * @param {number } canvasWidth this.tokensLayer.getSize().width
230- * @param {number } canvasHeight this.tokensLayer.getSize().height
231238 * @param {TextEditorElement } editorElement this.minimap.getTextEditorElement()
232239 * @param {Array<Decoration> } decorations
233240 * @access private
234241 */
235- updateBackDecorationsLayer ( firstRow , lastRow , lineHeight , charHeight , charWidth , canvasWidth , canvasHeight , editorElement , decorations ) {
242+ updateBackDecorationsLayer ( firstRow , lastRow , renderData , lineHeight , editorElement , decorations ) {
236243 const intactRanges = computeIntactRanges ( firstRow , lastRow , this . pendingBackDecorationChanges , this . offscreenFirstRow , this . offscreenLastRow )
237244
238245 // NOTE: this method is the hot function of Minimap. Do not refactor. The code is inlined delibarately.
@@ -242,7 +249,7 @@ export default class CanvasDrawer extends Mixin {
242249 this . backLayer . clearCanvas ( )
243250
244251 if ( intactRanges . length === 0 ) {
245- this . drawBackDecorationsForLines ( firstRow , lastRow , 0 , lineHeight , charHeight , charWidth , canvasWidth , canvasHeight , editorElement , decorations )
252+ this . drawBackDecorationsForLines ( firstRow , lastRow , 0 , renderData , lineHeight , editorElement , decorations )
246253 } else {
247254 for ( let j = 0 , len = intactRanges . length ; j < len ; j ++ ) {
248255 const intact = intactRanges [ j ]
@@ -258,12 +265,12 @@ export default class CanvasDrawer extends Mixin {
258265 for ( let i = 0 , len = intactRanges . length ; i < len ; i ++ ) {
259266 const range = intactRanges [ i ]
260267
261- this . drawBackDecorationsForLines ( currentRow , range . start , currentRow - firstRow , lineHeight , charHeight , charWidth , canvasWidth , canvasHeight , editorElement , decorations )
268+ this . drawBackDecorationsForLines ( currentRow , range . start , currentRow - firstRow , renderData , lineHeight , editorElement , decorations )
262269
263270 currentRow = range . end
264271 }
265272 if ( currentRow <= lastRow ) {
266- this . drawBackDecorationsForLines ( currentRow , lastRow , currentRow - firstRow , lineHeight , charHeight , charWidth , canvasWidth , canvasHeight , editorElement , decorations )
273+ this . drawBackDecorationsForLines ( currentRow , lastRow , currentRow - firstRow , renderData , lineHeight , editorElement , decorations )
267274 }
268275 }
269276
@@ -473,28 +480,15 @@ export default class CanvasDrawer extends Mixin {
473480 * @param {number } offsetRow the relative offset to apply to rows when
474481 * rendering them
475482 *
483+ * @param {Object } renderData
476484 * @param {number } lineHeight this.minimap.getLineHeight() * devicePixelRatio
477- * @param {number } charHeight this.minimap.getCharHeight() * devicePixelRatio
478- * @param {number } charWidth this.minimap.getCharWidth() * devicePixelRatio
479- * @param {number } canvasWidth this.tokensLayer.getSize().width
480- * @param {number } canvasHeight this.tokensLayer.getSize().height
481485 * @param {TextEditorElement } editorElement this.minimap.getTextEditorElement()
482486 * @param {Array<Decoration> } decorations
483487 * @access private
484488 */
485- drawBackDecorationsForLines ( firstRow , lastRow , offsetRow , lineHeight , charHeight , charWidth , canvasWidth , canvasHeight , editorElement , decorations ) {
489+ drawBackDecorationsForLines ( firstRow , lastRow , offsetRow , renderData , lineHeight , editorElement , decorations ) {
486490 if ( firstRow > lastRow ) { return }
487491
488- const renderData = {
489- context : this . backLayer . context ,
490- canvasWidth,
491- canvasHeight,
492- lineHeight,
493- charWidth,
494- charHeight,
495- orders : Main . getPluginsOrder ( )
496- }
497-
498492 const drawCustomDecorationLambda = ( decoration , data , decorationColor ) => drawCustomDecoration ( decoration , data , decorationColor , editorElement )
499493 backgroundDecorationDispatcher [ 'background-custom' ] = drawCustomDecorationLambda
500494
@@ -506,7 +500,7 @@ export default class CanvasDrawer extends Mixin {
506500 this . drawDecorations ( screenRow , decorations , renderData , backgroundDecorationDispatcher , editorElement )
507501 }
508502
509- this . backLayer . context . fill ( )
503+ renderData . context . fill ( )
510504 }
511505
512506 /**
@@ -532,16 +526,6 @@ export default class CanvasDrawer extends Mixin {
532526 drawFrontDecorationsForLines ( firstRow , lastRow , offsetRow , lineHeight , charHeight , charWidth , canvasWidth , canvasHeight , editorElement , decorations ) {
533527 if ( firstRow > lastRow ) { return }
534528
535- const renderData = {
536- context : this . frontLayer . context ,
537- canvasWidth,
538- canvasHeight,
539- lineHeight,
540- charWidth,
541- charHeight,
542- orders : Main . getPluginsOrder ( )
543- }
544-
545529 const drawCustomDecorationLambda = ( decoration , data , decorationColor ) => drawCustomDecoration ( decoration , data , decorationColor , editorElement )
546530 frontDecorationDispatcher [ 'foreground-custom' ] = drawCustomDecorationLambda
547531
0 commit comments