16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-18 14:39:18 +02:00

Merge branch 'milek-dev' into gfx-work

This commit is contained in:
milek7
2019-01-27 21:07:03 +01:00
8 changed files with 152 additions and 128 deletions

View File

@@ -20,9 +20,24 @@ http://mozilla.org/MPL/2.0/.
#endif
void render_task::run() {
// convert provided input to a python dictionary
auto *input = PyDict_New();
if( input == nullptr ) {
cancel();
return;
}
for( auto const &datapair : m_input->floats ) { PyDict_SetItemString( input, datapair.first.c_str(), PyGetFloat( datapair.second ) ); }
for( auto const &datapair : m_input->integers ) { PyDict_SetItemString( input, datapair.first.c_str(), PyGetInt( datapair.second ) ); }
for( auto const &datapair : m_input->bools ) { PyDict_SetItemString( input, datapair.first.c_str(), PyGetBool( datapair.second ) ); }
for( auto const &datapair : m_input->strings ) { PyDict_SetItemString( input, datapair.first.c_str(), PyGetString( datapair.second.c_str() ) ); }
delete m_input;
m_input = nullptr;
// call the renderer
auto *output { PyObject_CallMethod( m_renderer, "render", "O", m_input ) };
Py_DECREF( m_input );
auto *output { PyObject_CallMethod( m_renderer, "render", "O", input ) };
Py_DECREF( input );
if( output != nullptr ) {
auto *outputwidth { PyObject_CallMethod( m_renderer, "get_width", nullptr ) };
@@ -99,7 +114,7 @@ void render_task::upload()
void render_task::cancel() {
Py_DECREF( m_input );
delete m_input;
delete this;
}
@@ -215,11 +230,7 @@ auto python_taskqueue::insert( task_request const &Task ) -> bool {
for( auto &task : m_tasks.data ) {
if( task->target() == Task.target ) {
// replace pending task in the slot with the more recent one
acquire_lock();
{
task->cancel();
}
release_lock();
task->cancel();
task = newtask;
newtaskinserted = true;
break;