add frame caching
This commit is contained in:
parent
38d3c80483
commit
ec1ae7d951
1 changed files with 14 additions and 0 deletions
14
renderlib.py
14
renderlib.py
|
@ -7,6 +7,7 @@ import glob
|
||||||
import math
|
import math
|
||||||
import shutil
|
import shutil
|
||||||
import errno
|
import errno
|
||||||
|
import shutil
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
from xml.sax.saxutils import escape as xmlescape
|
from xml.sax.saxutils import escape as xmlescape
|
||||||
import cssutils
|
import cssutils
|
||||||
|
@ -87,11 +88,24 @@ def rendertask(task):
|
||||||
|
|
||||||
# iterate through the animation seqence frame by frame
|
# iterate through the animation seqence frame by frame
|
||||||
# frame is a ... tbd
|
# frame is a ... tbd
|
||||||
|
cache = {}
|
||||||
for frame in task.sequence(task.parameters):
|
for frame in task.sequence(task.parameters):
|
||||||
# print a line for each and every frame generated
|
# print a line for each and every frame generated
|
||||||
if debug:
|
if debug:
|
||||||
print("frameNr {0:3d} => {1}".format(frameNr, frame))
|
print("frameNr {0:3d} => {1}".format(frameNr, frame))
|
||||||
|
|
||||||
|
frame = tuple(frame)
|
||||||
|
if frame in cache:
|
||||||
|
print("cache hit, reusing frame {0}".format(cache[frame]))
|
||||||
|
|
||||||
|
framedir = task.workdir + "/.frames/"
|
||||||
|
shutil.copyfile("{0}/{1:04d}.png".format(framedir, cache[frame]), "{0}/{1:04d}.png".format(framedir, frameNr))
|
||||||
|
|
||||||
|
frameNr += 1
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
cache[frame] = frameNr
|
||||||
|
|
||||||
# open the output-file (named ".gen.svg" in the workdir)
|
# open the output-file (named ".gen.svg" in the workdir)
|
||||||
with open(os.path.join(task.workdir, '.gen.svg'), 'w') as fp:
|
with open(os.path.join(task.workdir, '.gen.svg'), 'w') as fp:
|
||||||
# apply the replace-pairs to the input text, by finding the specified xml-elements by thier id and modify thier css-parameter the correct value
|
# apply the replace-pairs to the input text, by finding the specified xml-elements by thier id and modify thier css-parameter the correct value
|
||||||
|
|
Loading…
Add table
Reference in a new issue