0

Dump assets and "initial" data before rendering starts

Now does preprocessing off of main() instead of in the dispatcher
initializer.
This commit is contained in:
Andrew Brown
2012-02-25 19:33:35 -05:00
parent d1f13cadc5
commit f48f0445d1
4 changed files with 39 additions and 8 deletions

View File

@@ -380,6 +380,12 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
tset = tileset.TileSet(rset, assetMrg, tex, tileSetOpts, tileset_dir)
tilesets.append(tset)
# Do tileset preprocessing here, before we start dispatching jobs
for ts in tilesets:
ts.do_preprocessing()
# Output initial static data and configuration
assetMrg.initialize(tilesets)
# multiprocessing dispatcher
if config['processes'] == 1:

View File

@@ -72,7 +72,23 @@ directory.
# TODO based on the type, so something
POI[regionset.name].append
def finalize(self, tilesets):
def initialize(self, tilesets):
"""Similar to finalize() but calls the tilesets' get_initial_data()
instead of get_persistent_data() to compile the generated javascript
config.
"""
return self.finalize(tilesets, True)
def finalize(self, tilesets, initial=False):
"""Called to output the generated javascript and all static files to
the output directory
"""
if not initial:
get_data = lambda tileset: tileset.get_persistent_data()
else:
get_data = lambda tileset: tileset.get_initial_data()
# dictionary to hold the overviewerConfig.js settings that we will dumps
dump = dict()
@@ -94,7 +110,7 @@ directory.
# based on the tilesets we have, group them by worlds
worlds = []
for tileset in tilesets:
full_name = tileset.get_persistent_data()['world']
full_name = get_data(tileset)['world']
if full_name not in worlds:
worlds.append(full_name)
@@ -120,7 +136,7 @@ directory.
for tileset in tilesets:
dump['tilesets'].append(tileset.get_persistent_data())
dump['tilesets'].append(get_data(tileset))
# write a blank image
blank = Image.new("RGBA", (1,1), tileset.options.get('bgcolor'))

View File

@@ -49,14 +49,9 @@ class Dispatcher(object):
"""
# TODO use status callback
# preprocessing
for tileset in tilesetlist:
tileset.do_preprocessing()
# setup tilesetlist
self.setup_tilesets(tilesetlist)
# iterate through all possible phases
num_phases = [tileset.get_num_phases() for tileset in tilesetlist]
for phase in xrange(max(num_phases)):

View File

@@ -382,6 +382,20 @@ class TileSet(object):
name = str(tilepath[-1])
self._render_compositetile(dest, name)
def get_initial_data(self):
"""This is called similarly to get_persistent_data, but is called after
do_preprocessing but before any work is acutally done.
"""
d = self.get_persistent_data()
# This is basically the same as get_persistent_data() with the
# following exceptions:
# * last_rendertime is not changed
# * A key "render_in_progress" is set to True
d['last_rendertime'] = self.last_rendertime
d['render_in_progress'] = True
return d
def get_persistent_data(self):
"""Returns a dictionary representing the persistent data of this
TileSet. Typically this is called by AssetManager