@@ -36,36 +36,26 @@ impl<'a> RenderStep<'a> {
3636 }
3737 }
3838
39- // (until match_arm_wrapping stabilizes https://github.com/rust-lang/rustfmt/pull/4924 )
40- #[ rustfmt:: skip]
4139 fn to_snapshot (
4240 self ,
4341 snapshot : & gtk:: Snapshot ,
4442 cell_metrics : & CellMetrics ,
4543 line_x : & PixLine ,
46- start_x : f32 ,
44+ start_x : f64 ,
4745 ) {
48- // TODO optimize
4946 let ( start_row, start_col) = self . pos ;
5047 let x = line_x[ start_col] as f64 ;
5148 let y = start_row as f64 * cell_metrics. line_height ;
5249 let len = line_x[ start_col + self . len ] as f64 - x;
53- let x = start_x as f64 + x;
54- let pos = ( x, y) ;
55- match self . kind {
56- RenderStepKind :: Background =>
57- snapshot_bg ( snapshot, cell_metrics, self . color , pos, len) ,
58- RenderStepKind :: Strikethrough =>
59- snapshot_strikethrough ( snapshot, cell_metrics, self . color , pos, len) ,
60- RenderStepKind :: Underline =>
61- snapshot_underline ( snapshot, cell_metrics, self . color , pos, len) ,
62- RenderStepKind :: Underdouble =>
63- snapshot_underdouble ( snapshot, cell_metrics, self . color , pos, len) ,
64- RenderStepKind :: Underdot =>
65- snapshot_underdot ( snapshot, cell_metrics, self . color , pos, len) ,
66- RenderStepKind :: Underdash =>
67- snapshot_underdash ( snapshot, cell_metrics, self . color , pos, len) ,
68- }
50+ let f = match self . kind {
51+ RenderStepKind :: Background => snapshot_bg,
52+ RenderStepKind :: Strikethrough => snapshot_strikethrough,
53+ RenderStepKind :: Underline => snapshot_underline,
54+ RenderStepKind :: Underdouble => snapshot_underdouble,
55+ RenderStepKind :: Underdot => snapshot_underdot,
56+ RenderStepKind :: Underdash => snapshot_underdash,
57+ } ;
58+ f ( snapshot, cell_metrics, self . color , start_x + x, y, len) ;
6959 }
7060
7161 #[ inline]
@@ -163,7 +153,7 @@ fn snapshot_grid(
163153 // optimizing contiguous series of similar drawing operations (source: Company)
164154 let model = ui_model. model ( ) ;
165155
166- let start_x = grid. rect . 0 ;
156+ let start_x = grid. rect . 0 as f64 ;
167157 for ( row, line) in model. iter ( ) . enumerate ( ) {
168158 let mut pending_bg = None ;
169159 let mut pending_strikethrough = None ;
@@ -348,31 +338,34 @@ pub fn snapshot_cursor<T: CursorRedrawCb + 'static>(
348338 }
349339
350340 if cell. hl . strikethrough {
351- snapshot_strikethrough ( snapshot, cell_metrics, & fg, ( x, y) , clip_width) ;
341+ snapshot_strikethrough ( snapshot, cell_metrics, & fg, x, y, clip_width) ;
352342 }
353343
354344 if cell. hl . underdashed {
355345 snapshot_underdash (
356346 snapshot,
357347 cell_metrics,
358348 & underline_color ( cell, hl) . fade ( hl. bg ( ) , fade_percentage) ,
359- ( x, y) ,
349+ x,
350+ y,
360351 clip_width,
361352 ) ;
362353 } else if cell. hl . underdotted {
363354 snapshot_underdot (
364355 snapshot,
365356 cell_metrics,
366357 & underdotted_color ( cell, hl) . fade ( hl. bg ( ) , fade_percentage) ,
367- ( x, y) ,
358+ x,
359+ y,
368360 clip_width,
369361 ) ;
370362 } else if cell. hl . underline {
371363 snapshot_underline (
372364 snapshot,
373365 cell_metrics,
374366 & underline_color ( cell, hl) . fade ( hl. bg ( ) , fade_percentage) ,
375- ( x, y) ,
367+ x,
368+ y,
376369 clip_width,
377370 ) ;
378371 }
@@ -382,7 +375,8 @@ pub fn snapshot_cursor<T: CursorRedrawCb + 'static>(
382375 snapshot,
383376 cell_metrics,
384377 & underline_color ( cell, hl) . fade ( hl. bg ( ) , fade_percentage) ,
385- ( x, y) ,
378+ x,
379+ y,
386380 clip_width,
387381 ) ;
388382 }
@@ -392,7 +386,8 @@ fn snapshot_strikethrough(
392386 snapshot : & gtk:: Snapshot ,
393387 cell_metrics : & CellMetrics ,
394388 color : & color:: Color ,
395- ( x, y) : ( f64 , f64 ) ,
389+ x : f64 ,
390+ y : f64 ,
396391 len : f64 ,
397392) {
398393 snapshot. append_color (
@@ -419,7 +414,8 @@ fn snapshot_underline(
419414 snapshot : & gtk:: Snapshot ,
420415 cell_metrics : & CellMetrics ,
421416 color : & color:: Color ,
422- ( x, y) : ( f64 , f64 ) ,
417+ x : f64 ,
418+ y : f64 ,
423419 len : f64 ,
424420) {
425421 snapshot. append_color ( & color. into ( ) , & underline_rect ( cell_metrics, ( x, y) , len) )
@@ -429,15 +425,16 @@ fn snapshot_underdouble(
429425 snapshot : & gtk:: Snapshot ,
430426 cell_metrics : & CellMetrics ,
431427 color : & color:: Color ,
432- pos : ( f64 , f64 ) ,
428+ x : f64 ,
429+ y : f64 ,
433430 len : f64 ,
434431) {
435432 /* We only need to handle the lower underline, the upper underline will be drawn by
436433 * snapshot_underline()
437434 */
438435 snapshot. append_color (
439436 & color. into ( ) ,
440- & underline_rect ( cell_metrics, pos , len)
437+ & underline_rect ( cell_metrics, ( x , y ) , len)
441438 . offset_r ( 0.0 , ( cell_metrics. underline_thickness * 2.0 ) as f32 ) ,
442439 )
443440}
@@ -446,7 +443,8 @@ fn snapshot_underdot(
446443 snapshot : & gtk:: Snapshot ,
447444 cell_metrics : & CellMetrics ,
448445 color : & color:: Color ,
449- ( x, mut y) : ( f64 , f64 ) ,
446+ x : f64 ,
447+ mut y : f64 ,
450448 len : f64 ,
451449) {
452450 let CellMetrics {
@@ -494,7 +492,8 @@ fn snapshot_underdash(
494492 snapshot : & gtk:: Snapshot ,
495493 cell_metrics : & CellMetrics ,
496494 color : & color:: Color ,
497- ( x, mut y) : ( f64 , f64 ) ,
495+ x : f64 ,
496+ mut y : f64 ,
498497 len : f64 ,
499498) {
500499 let CellMetrics {
@@ -546,9 +545,9 @@ fn plan_and_snapshot_cell_bg<'a>(
546545 hl : & ' a HighlightMap ,
547546 cell : & ' a ui_model:: Cell ,
548547 cell_metrics : & CellMetrics ,
549- ( row , col ) : ( usize , usize ) ,
548+ pos : ( usize , usize ) ,
550549 line_x : & PixLine ,
551- start_x : f32 ,
550+ start_x : f64 ,
552551) {
553552 if let Some ( cell_bg) = hl. cell_bg ( cell) . filter ( |bg| * bg != hl. bg ( ) ) {
554553 if let Some ( cur_pending_bg) = pending_bg {
@@ -557,11 +556,7 @@ fn plan_and_snapshot_cell_bg<'a>(
557556 }
558557 cur_pending_bg. to_snapshot ( snapshot, cell_metrics, line_x, start_x) ;
559558 }
560- * pending_bg = Some ( RenderStep :: new (
561- RenderStepKind :: Background ,
562- cell_bg,
563- ( row, col) ,
564- ) ) ;
559+ * pending_bg = Some ( RenderStep :: new ( RenderStepKind :: Background , cell_bg, pos) ) ;
565560 } else if let Some ( pending_bg) = pending_bg. take ( ) {
566561 pending_bg. to_snapshot ( snapshot, cell_metrics, line_x, start_x) ;
567562 }
@@ -637,7 +632,8 @@ fn snapshot_bg(
637632 snapshot : & gtk:: Snapshot ,
638633 cell_metrics : & CellMetrics ,
639634 color : & color:: Color ,
640- ( x, y) : ( f64 , f64 ) ,
635+ x : f64 ,
636+ y : f64 ,
641637 len : f64 ,
642638) {
643639 snapshot. append_color (
0 commit comments