DRYer sprites
This commit is contained in:
parent
a4580f2126
commit
3072eac222
@ -7,8 +7,8 @@
|
||||
|
||||
#include "data-types.h"
|
||||
#include "modes.h"
|
||||
#include "sprites.h"
|
||||
#include <stddef.h>
|
||||
#include <termios.h>
|
||||
#ifdef WITH_PROFILER
|
||||
#include <gperftools/profiler.h>
|
||||
#endif
|
||||
@ -67,7 +67,6 @@ static PyMethodDef module_methods[] = {
|
||||
{"redirect_std_streams", (PyCFunction)redirect_std_streams, METH_VARARGS, ""},
|
||||
{"wcwidth", (PyCFunction)wcwidth_wrap, METH_O, ""},
|
||||
{"change_wcwidth", (PyCFunction)change_wcwidth_wrap, METH_O, ""},
|
||||
SPRITE_FUNC_WRAPPERS
|
||||
#ifdef WITH_PROFILER
|
||||
{"start_profiler", (PyCFunction)start_profiler, METH_VARARGS, ""},
|
||||
{"stop_profiler", (PyCFunction)stop_profiler, METH_NOARGS, ""},
|
||||
@ -84,7 +83,6 @@ static struct PyModuleDef module = {
|
||||
.m_methods = module_methods
|
||||
};
|
||||
|
||||
#include <termios.h>
|
||||
|
||||
extern bool add_module_gl_constants(PyObject*);
|
||||
extern int init_LineBuf(PyObject *);
|
||||
@ -100,6 +98,7 @@ extern int init_Window(PyObject *);
|
||||
extern bool init_freetype_library(PyObject*);
|
||||
extern bool init_fontconfig_library(PyObject*);
|
||||
extern bool init_glfw(PyObject *m);
|
||||
bool init_sprites(PyObject *module);
|
||||
#ifdef __APPLE__
|
||||
extern int init_CoreText(PyObject *);
|
||||
extern bool init_cocoa(PyObject *module);
|
||||
@ -124,6 +123,7 @@ PyInit_fast_data_types(void) {
|
||||
if (!init_Screen(m)) return NULL;
|
||||
if (!add_module_gl_constants(m)) return NULL;
|
||||
if (!init_glfw(m)) return NULL;
|
||||
if (!init_sprites(m)) return NULL;
|
||||
if (!init_Window(m)) return NULL;
|
||||
#ifdef __APPLE__
|
||||
if (!init_CoreText(m)) return NULL;
|
||||
|
||||
@ -6,9 +6,19 @@
|
||||
*/
|
||||
|
||||
#include "data-types.h"
|
||||
#include "sprites.h"
|
||||
#include <structmember.h>
|
||||
|
||||
typedef struct SpritePosition SpritePosition;
|
||||
struct SpritePosition {
|
||||
SpritePosition *next;
|
||||
sprite_index x, y, z;
|
||||
char_type ch;
|
||||
combining_type cc;
|
||||
bool is_second;
|
||||
bool filled;
|
||||
bool rendered;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
size_t max_array_len, max_texture_size, max_y;
|
||||
unsigned int x, y, z, xnum, ynum;
|
||||
@ -195,3 +205,23 @@ render_dirty_sprites(PyObject UNUSED *s_) {
|
||||
sprite_map.dirty = false;
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
static PyMethodDef module_methods[] = {
|
||||
{"sprite_map_set_limits", (PyCFunction)sprite_map_set_limits, METH_VARARGS, ""}, \
|
||||
{"sprite_map_set_layout", (PyCFunction)sprite_map_set_layout, METH_VARARGS, ""}, \
|
||||
{"sprite_map_current_layout", (PyCFunction)sprite_map_current_layout, METH_NOARGS, ""}, \
|
||||
{"sprite_map_free", (PyCFunction)sprite_map_free, METH_NOARGS, ""}, \
|
||||
{"sprite_map_increment", (PyCFunction)sprite_map_increment, METH_NOARGS, ""}, \
|
||||
{"sprite_position_for", (PyCFunction)sprite_position_for, METH_VARARGS, ""}, \
|
||||
{"render_dirty_sprites", (PyCFunction)render_dirty_sprites, METH_NOARGS, ""}, \
|
||||
|
||||
{NULL, NULL, 0, NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
|
||||
bool
|
||||
init_sprites(PyObject *module) {
|
||||
if (PyModule_AddFunctions(module, module_methods) != 0) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Kovid Goyal <kovid at kovidgoyal.net>
|
||||
*
|
||||
* Distributed under terms of the GPL3 license.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef struct SpritePosition SpritePosition;
|
||||
struct SpritePosition {
|
||||
SpritePosition *next;
|
||||
sprite_index x, y, z;
|
||||
char_type ch;
|
||||
combining_type cc;
|
||||
bool is_second;
|
||||
bool filled;
|
||||
bool rendered;
|
||||
};
|
||||
|
||||
|
||||
PyObject* sprite_map_set_limits(PyObject UNUSED *self, PyObject *args);
|
||||
PyObject* sprite_map_set_layout(PyObject UNUSED *s, PyObject *args);
|
||||
PyObject* sprite_map_current_layout(PyObject UNUSED *s);
|
||||
PyObject* sprite_map_free();
|
||||
PyObject* sprite_map_increment();
|
||||
SpritePosition* sprite_map_position_for(char_type ch, combining_type cc, bool is_second, int *error);
|
||||
PyObject* sprite_position_for(PyObject UNUSED *self, PyObject *args);
|
||||
bool update_cell_range_data(ScreenModes *modes, Line *line, unsigned int xstart, unsigned int xmax, unsigned int *data);
|
||||
PyObject* render_dirty_sprites(PyObject UNUSED *self);
|
||||
|
||||
#define SPRITE_FUNC_WRAPPERS \
|
||||
{"sprite_map_set_limits", (PyCFunction)sprite_map_set_limits, METH_VARARGS, ""}, \
|
||||
{"sprite_map_set_layout", (PyCFunction)sprite_map_set_layout, METH_VARARGS, ""}, \
|
||||
{"sprite_map_current_layout", (PyCFunction)sprite_map_current_layout, METH_NOARGS, ""}, \
|
||||
{"sprite_map_free", (PyCFunction)sprite_map_free, METH_NOARGS, ""}, \
|
||||
{"sprite_map_increment", (PyCFunction)sprite_map_increment, METH_NOARGS, ""}, \
|
||||
{"sprite_position_for", (PyCFunction)sprite_position_for, METH_VARARGS, ""}, \
|
||||
{"render_dirty_sprites", (PyCFunction)render_dirty_sprites, METH_NOARGS, ""}, \
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user