Drawing optimization
This commit is contained in:
190
src/shell.rs
190
src/shell.rs
@@ -679,60 +679,6 @@ fn init_nvim(state_arc: &Arc<UiMutex<State>>) {
|
||||
}
|
||||
}
|
||||
|
||||
//#[inline]
|
||||
//fn get_model_clip(
|
||||
// state: &State,
|
||||
// line_height: f64,
|
||||
// char_width: f64,
|
||||
// clip: (f64, f64, f64, f64),
|
||||
//) -> ModelRect {
|
||||
// let mut model_clip =
|
||||
// ModelRect::from_area(line_height, char_width, clip.0, clip.1, clip.2, clip.3);
|
||||
// // in some cases symbols from previous row affect next row
|
||||
// // for example underscore symbol or 'g'
|
||||
// // also for italic text it is possible that symbol can affect next one
|
||||
// // see deference between logical rect and ink rect
|
||||
// model_clip.extend(1, 0, 1, 0);
|
||||
// state.model.limit_to_model(&mut model_clip);
|
||||
//
|
||||
// model_clip
|
||||
//}
|
||||
//
|
||||
//#[inline]
|
||||
//fn draw_backgound(
|
||||
// state: &State,
|
||||
// draw_bitmap: &ModelBitamp,
|
||||
// ctx: &cairo::Context,
|
||||
// line_height: f64,
|
||||
// char_width: f64,
|
||||
// model_clip: &ModelRect,
|
||||
//) {
|
||||
// let line_x = model_clip.left as f64 * char_width;
|
||||
// let mut line_y: f64 = model_clip.top as f64 * line_height;
|
||||
//
|
||||
// for (line_idx, line) in state.model.clip_model(model_clip) {
|
||||
// ctx.move_to(line_x, line_y);
|
||||
//
|
||||
// for (col_idx, cell) in line.iter() {
|
||||
// let current_point = ctx.get_current_point();
|
||||
//
|
||||
// if !draw_bitmap.get(col_idx, line_idx) {
|
||||
// let (bg, _) = state.colors(cell);
|
||||
//
|
||||
// if &state.bg_color != bg {
|
||||
// ctx.set_source_rgb(bg.0, bg.1, bg.2);
|
||||
// ctx.rectangle(current_point.0, current_point.1, char_width, line_height);
|
||||
// ctx.fill();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// ctx.move_to(current_point.0 + char_width, current_point.1);
|
||||
// }
|
||||
// line_y += line_height;
|
||||
// }
|
||||
//}
|
||||
|
||||
fn draw_initializing(state: &State, ctx: &cairo::Context) {
|
||||
let layout = ctx.create_pango_layout();
|
||||
let desc = state.get_font_desc();
|
||||
@@ -773,142 +719,6 @@ fn draw_initializing(state: &State, ctx: &cairo::Context) {
|
||||
);
|
||||
}
|
||||
|
||||
//fn draw(state: &State, ctx: &cairo::Context) {
|
||||
// let layout = ctx.create_pango_layout();
|
||||
// let mut desc = state.create_pango_font();
|
||||
// let mut buf = String::with_capacity(4);
|
||||
//
|
||||
// let (row, col) = state.model.get_cursor();
|
||||
//
|
||||
// let line_height = state.line_height.unwrap();
|
||||
// let char_width = state.char_width.unwrap();
|
||||
// let mut draw_bitmap = ModelBitamp::new(state.model.columns, state.model.rows);
|
||||
//
|
||||
// ctx.set_source_rgb(state.bg_color.0, state.bg_color.1, state.bg_color.2);
|
||||
// ctx.paint();
|
||||
//
|
||||
// let clip_rects = &ctx.copy_clip_rectangle_list().rectangles;
|
||||
// for clip_idx in 0..clip_rects.len() {
|
||||
// let clip = clip_rects.get(clip_idx).unwrap();
|
||||
//
|
||||
// let model_clip = get_model_clip(state, line_height, char_width, (
|
||||
// clip.x,
|
||||
// clip.y,
|
||||
// clip.x + clip.width,
|
||||
// clip.y + clip.height,
|
||||
// ));
|
||||
//
|
||||
// let line_x = model_clip.left as f64 * char_width;
|
||||
// let mut line_y: f64 = model_clip.top as f64 * line_height;
|
||||
//
|
||||
// draw_backgound(
|
||||
// state,
|
||||
// &draw_bitmap,
|
||||
// ctx,
|
||||
// line_height,
|
||||
// char_width,
|
||||
// &model_clip,
|
||||
// );
|
||||
//
|
||||
// for (line_idx, line) in state.model.clip_model(&model_clip) {
|
||||
//
|
||||
// ctx.move_to(line_x, line_y);
|
||||
//
|
||||
// for (col_idx, cell) in line.iter() {
|
||||
// let current_point = ctx.get_current_point();
|
||||
//
|
||||
// if !draw_bitmap.get(col_idx, line_idx) {
|
||||
// let double_width = line.is_double_width(col_idx);
|
||||
//
|
||||
// let (bg, fg) = state.colors(cell);
|
||||
//
|
||||
// if row == line_idx && col == col_idx {
|
||||
// state.cursor.as_ref().unwrap().draw(
|
||||
// ctx,
|
||||
// state,
|
||||
// char_width,
|
||||
// line_height,
|
||||
// line_y,
|
||||
// double_width,
|
||||
// bg,
|
||||
// );
|
||||
//
|
||||
// ctx.move_to(current_point.0, current_point.1);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// if !cell.ch.is_whitespace() {
|
||||
// update_font_description(&mut desc, &cell.attrs);
|
||||
//
|
||||
// layout.set_font_description(&desc);
|
||||
// buf.clear();
|
||||
// buf.push(cell.ch);
|
||||
// layout.set_text(&buf);
|
||||
//
|
||||
// // correct layout for double_width chars
|
||||
// if double_width {
|
||||
// let (dw_width, dw_height) = layout.get_pixel_size();
|
||||
// let x_offset = (char_width * 2.0 - dw_width as f64) / 2.0;
|
||||
// let y_offset = (line_height - dw_height as f64) / 2.0;
|
||||
// ctx.rel_move_to(x_offset, y_offset);
|
||||
// }
|
||||
//
|
||||
// ctx.set_source_rgb(fg.0, fg.1, fg.2);
|
||||
// ctx.update_pango_layout(&layout);
|
||||
// ctx.show_pango_layout(&layout);
|
||||
// }
|
||||
//
|
||||
// if cell.attrs.underline || cell.attrs.undercurl {
|
||||
// // [TODO]: Current gtk-rs bindings does not provide fontmetrics access
|
||||
// // so it is not possible to find right position for underline or undercurl position
|
||||
// // > update_font_description(&mut desc, &cell.attrs);
|
||||
// // > layout.get_context().unwrap().get_metrics();
|
||||
// let top_offset = line_height * 0.9;
|
||||
//
|
||||
// if cell.attrs.undercurl {
|
||||
// let sp = if let Some(ref sp) = cell.attrs.special {
|
||||
// sp
|
||||
// } else {
|
||||
// &state.sp_color
|
||||
// };
|
||||
// ctx.set_source_rgba(sp.0, sp.1, sp.2, 0.7);
|
||||
// ctx.set_dash(&[4.0, 2.0], 0.0);
|
||||
// ctx.set_line_width(2.0);
|
||||
// ctx.move_to(current_point.0, line_y + top_offset);
|
||||
// ctx.line_to(current_point.0 + char_width, line_y + top_offset);
|
||||
// ctx.stroke();
|
||||
// ctx.set_dash(&[], 0.0);
|
||||
// } else if cell.attrs.underline {
|
||||
// ctx.set_source_rgb(fg.0, fg.1, fg.2);
|
||||
// ctx.set_line_width(1.0);
|
||||
// ctx.move_to(current_point.0, line_y + top_offset);
|
||||
// ctx.line_to(current_point.0 + char_width, line_y + top_offset);
|
||||
// ctx.stroke();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// ctx.move_to(current_point.0 + char_width, current_point.1);
|
||||
// }
|
||||
//
|
||||
// line_y += line_height;
|
||||
// }
|
||||
//
|
||||
// draw_bitmap.fill_from_model(&model_clip);
|
||||
// }
|
||||
//}
|
||||
|
||||
//#[inline]
|
||||
//fn update_font_description(desc: &mut FontDescription, attrs: &Attrs) {
|
||||
// desc.unset_fields(pango::FONT_MASK_STYLE | pango::FONT_MASK_WEIGHT);
|
||||
// if attrs.italic {
|
||||
// desc.set_style(pango::Style::Italic);
|
||||
// }
|
||||
// if attrs.bold {
|
||||
// desc.set_weight(pango::Weight::Bold);
|
||||
// }
|
||||
//}
|
||||
|
||||
fn request_window_resize(state: &mut State) {
|
||||
if !state.request_resize {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user