Skip to content

Commit

Permalink
only initialise FBO once (#303)
Browse files Browse the repository at this point in the history
  • Loading branch information
jabdoa2 committed Feb 9, 2018
1 parent 0001f47 commit 47f8ebb
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions mpfmc/config_players/display_light_player.py
Expand Up @@ -26,10 +26,13 @@ def play_element(self, settings, element, context, calling_context, priority=0,
if not self._scheduled:
self._scheduled = True
Clock.schedule_interval(self._tick, 0)
context_dict[element] = self._setup_fbo(element, settings)
if element not in context_dict:
context_dict[element] = self._setup_fbo(element, settings)
else:
context_dict[element][5] = True
elif settings['action'] == "stop":
try:
del context_dict[element]
context_dict[element][5] = False
except IndexError:
pass
else:
Expand All @@ -54,16 +57,18 @@ def _setup_fbo(self, element, settings):

fbo.add(effect_widget.canvas)

return [fbo, effect_widget, source, settings, True]
return [fbo, effect_widget, source, settings, True, True]

def _tick(self, dt):
del dt
for context, instances in self.instances.items():
for element, instance in instances.items():
if not element[5]:
continue
self._render(instance, element, context)

def _render(self, instance, element, context):
fbo, effect_widget, source, settings, first = instance
fbo, effect_widget, source, settings, first, enabled = instance
instance[4] = False

# detach the widget from the parent
Expand Down

0 comments on commit 47f8ebb

Please sign in to comment.