Call draw_borders() directly from C
This commit is contained in:
parent
8e379df24f
commit
2e0cbb88bb
@ -15,7 +15,7 @@ from .constants import (
|
||||
from .fast_data_types import (
|
||||
GLFW_CURSOR, GLFW_CURSOR_HIDDEN, GLFW_CURSOR_NORMAL, GLFW_MOUSE_BUTTON_1,
|
||||
GLFW_PRESS, GLFW_REPEAT, ChildMonitor, Timers as _Timers,
|
||||
destroy_sprite_map, draw_borders, glfw_post_empty_event, layout_sprite_map,
|
||||
destroy_sprite_map, glfw_post_empty_event, layout_sprite_map,
|
||||
resize_gl_viewport
|
||||
)
|
||||
from .fonts.render import render_cell_wrapper, set_font_family
|
||||
@ -365,7 +365,6 @@ class Boss:
|
||||
self.glfw_window.set_title(self.glfw_window_title)
|
||||
if isosx:
|
||||
cocoa_update_title(self.glfw_window_title)
|
||||
draw_borders()
|
||||
self.tab_manager.render()
|
||||
for window in tab.visible_windows():
|
||||
if not window.needs_layout:
|
||||
|
||||
@ -423,6 +423,7 @@ pyset_iutf8(ChildMonitor *self, PyObject *args) {
|
||||
#undef DECREF_CHILD
|
||||
|
||||
static double last_render_at = -DBL_MAX;
|
||||
draw_borders_func draw_borders = NULL;
|
||||
|
||||
static inline bool
|
||||
render(ChildMonitor *self, double *timeout) {
|
||||
@ -430,6 +431,7 @@ render(ChildMonitor *self, double *timeout) {
|
||||
double now = monotonic();
|
||||
double time_since_last_render = now - last_render_at;
|
||||
if (time_since_last_render > self->repaint_delay) {
|
||||
draw_borders();
|
||||
ret = PyObject_CallFunctionObjArgs(self->render_func, NULL);
|
||||
if (ret == NULL) { PyErr_Print(); return false; }
|
||||
else Py_DECREF(ret);
|
||||
|
||||
@ -311,6 +311,8 @@ extern GlobalState global_state;
|
||||
clear_sprite_position((line)->cells[(at)]); \
|
||||
}
|
||||
|
||||
typedef void (*draw_borders_func)();
|
||||
extern draw_borders_func draw_borders;
|
||||
|
||||
// Global functions
|
||||
Line* alloc_line();
|
||||
|
||||
@ -714,7 +714,7 @@ init_borders_program() {
|
||||
}
|
||||
|
||||
static void
|
||||
draw_borders() {
|
||||
draw_borders_impl() {
|
||||
if (num_border_rects) {
|
||||
bind_program(BORDERS_PROGRAM);
|
||||
bind_vertex_array(border_vertex_array);
|
||||
@ -831,7 +831,6 @@ PYWRAP1(draw_cursor) {
|
||||
}
|
||||
|
||||
NO_ARG(init_borders_program)
|
||||
NO_ARG(draw_borders)
|
||||
PYWRAP1(add_borders_rect) { unsigned int a, b, c, d, e; PA("IIIII", &a, &b, &c, &d, &e); add_borders_rect(a, b, c, d, e); Py_RETURN_NONE; }
|
||||
TWO_INT(send_borders_rects)
|
||||
|
||||
@ -914,7 +913,6 @@ static PyMethodDef module_methods[] = {
|
||||
MW(init_cursor_program, METH_NOARGS),
|
||||
MW(draw_cursor, METH_VARARGS),
|
||||
MW(init_borders_program, METH_NOARGS),
|
||||
MW(draw_borders, METH_NOARGS),
|
||||
MW(add_borders_rect, METH_VARARGS),
|
||||
MW(send_borders_rects, METH_VARARGS),
|
||||
MW(init_cell_program, METH_NOARGS),
|
||||
@ -966,6 +964,7 @@ init_shaders(PyObject *module) {
|
||||
#undef C
|
||||
PyModule_AddObject(module, "GL_VERSION_REQUIRED", Py_BuildValue("II", REQUIRED_VERSION_MAJOR, REQUIRED_VERSION_MINOR));
|
||||
if (PyModule_AddFunctions(module, module_methods) != 0) return false;
|
||||
draw_borders = &draw_borders_impl;
|
||||
return true;
|
||||
}
|
||||
// }}}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user