Get rid of no longer needed GPU function indirection

This commit is contained in:
Kovid Goyal 2017-11-09 16:45:02 +05:30
parent e8798b5bf2
commit 8431eef970
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
6 changed files with 19 additions and 35 deletions

View file

@ -437,9 +437,6 @@ pyset_iutf8(ChildMonitor *self, PyObject *args) {
#undef DECREF_CHILD
static double last_render_at = -DBL_MAX;
draw_borders_func draw_borders = NULL;
draw_cells_func draw_cells = NULL;
draw_cursor_func draw_cursor = NULL;
static inline double
cursor_width(double w, bool vert) {

View file

@ -66,19 +66,19 @@ gl_init(PyObject UNUSED *self, PyObject *args) {
Py_RETURN_NONE;
}
static void
update_viewport_size_impl(int w, int h) {
void
update_viewport_size(int w, int h) {
glViewport(0, 0, w, h);
}
static void
free_texture_impl(GLuint *tex_id) {
void
free_texture(GLuint *tex_id) {
glDeleteTextures(1, tex_id);
*tex_id = 0;
}
static void
send_image_to_gpu_impl(GLuint *tex_id, const void* data, GLsizei width, GLsizei height, bool is_opaque, bool is_4byte_aligned) {
void
send_image_to_gpu(GLuint *tex_id, const void* data, GLsizei width, GLsizei height, bool is_opaque, bool is_4byte_aligned) {
if (!(*tex_id)) { glGenTextures(1, tex_id); }
glBindTexture(GL_TEXTURE_2D, *tex_id);
glPixelStorei(GL_UNPACK_ALIGNMENT, is_4byte_aligned ? 4 : 1);

View file

@ -60,7 +60,6 @@ static void update_viewport(GLFWwindow *window) {
// callbacks {{{
static WindowWrapper* the_window = NULL;
update_viewport_size_func update_viewport_size = NULL;
static void
framebuffer_size_callback(GLFWwindow *w, int width, int height) {

View file

@ -64,9 +64,6 @@ free_load_data(LoadData *ld) {
ld->mapped_file = NULL; ld->mapped_file_sz = 0;
}
free_texture_func free_texture = NULL;
send_image_to_gpu_func send_image_to_gpu = NULL;
static inline void
free_image(GraphicsManager *self, Image *img) {
if (img->texture_id) free_texture(&img->texture_id);

View file

@ -361,8 +361,8 @@ draw_cells_interleaved(ssize_t vao_idx, ssize_t gvao_idx, Screen *screen) {
if (screen->grman->num_of_positive_refs) draw_graphics(vao_idx, gvao_idx, screen->grman->render_data, screen->grman->num_of_negative_refs, screen->grman->num_of_positive_refs);
}
static void
draw_cells_impl(ssize_t vao_idx, ssize_t gvao_idx, GLfloat xstart, GLfloat ystart, GLfloat dx, GLfloat dy, Screen *screen, CursorRenderInfo *cursor) {
void
draw_cells(ssize_t vao_idx, ssize_t gvao_idx, GLfloat xstart, GLfloat ystart, GLfloat dx, GLfloat dy, Screen *screen, CursorRenderInfo *cursor) {
GLfloat h = (GLfloat)screen->lines * dy;
#define SCALE(w, x) ((GLfloat)(global_state.viewport_##w) * (GLfloat)(x))
glScissor(
@ -398,8 +398,8 @@ init_cursor_program() {
#undef SET_LOC
}
static void
draw_cursor_impl(CursorRenderInfo *cursor) {
void
draw_cursor(CursorRenderInfo *cursor) {
bind_program(CURSOR_PROGRAM); bind_vertex_array(cursor_vertex_array);
glUniform3f(cursor_uniform_locations[CURSOR_color], ((cursor->color >> 16) & 0xff) / 255.0, ((cursor->color >> 8) & 0xff) / 255.0, (cursor->color & 0xff) / 255.0);
glUniform4f(cursor_uniform_locations[CURSOR_pos], cursor->left, cursor->top, cursor->right, cursor->bottom);
@ -435,8 +435,8 @@ init_borders_program() {
/*size=*/1, /*dtype=*/GL_UNSIGNED_INT, /*stride=*/sizeof(GLuint)*5, /*offset=*/(void*)(sizeof(GLuint)*4), /*divisor=*/1);
}
static void
draw_borders_impl() {
void
draw_borders() {
if (num_border_rects) {
bind_program(BORDERS_PROGRAM);
bind_vertex_array(border_vertex_array);
@ -622,12 +622,6 @@ 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;
update_viewport_size = &update_viewport_size_impl;
draw_borders = &draw_borders_impl;
draw_cells = &draw_cells_impl;
draw_cursor = &draw_cursor_impl;
free_texture = &free_texture_impl;
send_image_to_gpu = &send_image_to_gpu_impl;
return true;
}
// }}}

View file

@ -89,19 +89,16 @@ typedef struct {
color_type color;
} CursorRenderInfo;
bool drag_scroll(Window *);
#define call_boss(name, ...) { \
PyObject *cret_ = PyObject_CallMethod(global_state.boss, #name, __VA_ARGS__); \
if (cret_ == NULL) { PyErr_Print(); } \
else Py_DECREF(cret_); \
}
#define EXTERNAL_FUNC(name, ret, ...) typedef ret (*name##_func)(__VA_ARGS__); extern name##_func name
#define EXTERNAL_FUNC0(name, ret) typedef ret (*name##_func)(); extern name##_func name
EXTERNAL_FUNC0(draw_borders, void);
EXTERNAL_FUNC(draw_cells, void, ssize_t, ssize_t, float, float, float, float, Screen *, CursorRenderInfo *);
EXTERNAL_FUNC(draw_cursor, void, CursorRenderInfo *);
EXTERNAL_FUNC(update_viewport_size, void, int, int);
EXTERNAL_FUNC(free_texture, void, uint32_t*);
EXTERNAL_FUNC(send_image_to_gpu, void, uint32_t*, const void*, int32_t, int32_t, bool, bool);
bool drag_scroll(Window *);
void draw_borders();
void draw_cells(ssize_t, ssize_t, float, float, float, float, Screen *, CursorRenderInfo *);
void draw_cursor(CursorRenderInfo *);
void update_viewport_size(int, int);
void free_texture(uint32_t*);
void send_image_to_gpu(uint32_t*, const void*, int32_t, int32_t, bool, bool);