stop doing the extra preparation work (decode images, etc.) unless asked to #3785
This commit is contained in:
Родитель
ee95e1333b
Коммит
b08a8a159a
6
emcc
6
emcc
|
@ -413,6 +413,7 @@ try:
|
|||
memory_init_file = None
|
||||
use_preload_cache = False
|
||||
no_heap_copy = False
|
||||
use_preload_plugins = False
|
||||
proxy_to_worker = False
|
||||
default_object_extension = '.o'
|
||||
valid_abspaths = []
|
||||
|
@ -572,6 +573,9 @@ try:
|
|||
elif newargs[i].startswith('--no-heap-copy'):
|
||||
no_heap_copy = True
|
||||
newargs[i] = ''
|
||||
elif newargs[i].startswith('--use-preload-plugins'):
|
||||
use_preload_plugins = True
|
||||
newargs[i] = ''
|
||||
elif newargs[i] == '--ignore-dynamic-linking':
|
||||
ignore_dynamic_linking = True
|
||||
newargs[i] = ''
|
||||
|
@ -1341,6 +1345,8 @@ try:
|
|||
file_args.append('--no-closure')
|
||||
if shared.Settings.LZ4:
|
||||
file_args.append('--lz4')
|
||||
if use_preload_plugins:
|
||||
file_args.append('--use-preload-plugins')
|
||||
file_code = execute([shared.PYTHON, shared.FILE_PACKAGER, unsuffixed(target) + '.data'] + file_args, stdout=PIPE)[0]
|
||||
pre_js = file_code + pre_js
|
||||
|
||||
|
|
|
@ -282,6 +282,9 @@ Options that are modified or new in *emcc* are listed below:
|
|||
``--exclude-file <name>``
|
||||
Files and directories to be excluded from :ref:`--embed-file <emcc-embed-file>` and :ref:`--preload-file <emcc-preload-file>`. Wildcards (*) are supported.
|
||||
|
||||
``--use-preload-plugins``
|
||||
Tells the file packager to run preload plugins on the files as they are loaded. This performs tasks like decoding images and audio using the browser's codecs.
|
||||
|
||||
.. _emcc-shell-file:
|
||||
|
||||
``--shell-file <path>``
|
||||
|
|
|
@ -2151,7 +2151,7 @@ var LibrarySDL = {
|
|||
var raw = callStbImage('stbi_load_from_memory', [rwops.bytes, rwops.count]);
|
||||
if (!raw) return 0;
|
||||
#else
|
||||
Runtime.warnOnce('Only file names that have been preloaded are supported for IMG_Load_RW. Consider using STB_IMAGE=1 if you want synchronous image decoding (see settings.js)');
|
||||
Runtime.warnOnce('Only file names that have been preloaded are supported for IMG_Load_RW. Consider using STB_IMAGE=1 if you want synchronous image decoding (see settings.js), or package files with --use-preload-plugins');
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
@ -2171,7 +2171,7 @@ var LibrarySDL = {
|
|||
if (!raw) return 0;
|
||||
#else
|
||||
Runtime.warnOnce('Cannot find preloaded image ' + filename);
|
||||
Runtime.warnOnce('Cannot find preloaded image ' + filename + '. Consider using STB_IMAGE=1 if you want synchronous image decoding (see settings.js)');
|
||||
Runtime.warnOnce('Cannot find preloaded image ' + filename + '. Consider using STB_IMAGE=1 if you want synchronous image decoding (see settings.js), or package files with --use-preload-plugins');
|
||||
return 0;
|
||||
#endif
|
||||
} else if (Module['freePreloadedMediaOnUse']) {
|
||||
|
|
|
@ -422,7 +422,7 @@ If manually bisecting:
|
|||
('screenshot.jpg@/assets/screenshot.jpg', '/assets', 'screenshot.jpg')]:
|
||||
Popen([
|
||||
PYTHON, EMCC, os.path.join(self.get_dir(), 'sdl_image.c'), '-o', 'page.html', '-O2', '--memory-init-file', str(mem),
|
||||
'--preload-file', dest, '-DSCREENSHOT_DIRNAME="' + dirname + '"', '-DSCREENSHOT_BASENAME="' + basename + '"'
|
||||
'--preload-file', dest, '-DSCREENSHOT_DIRNAME="' + dirname + '"', '-DSCREENSHOT_BASENAME="' + basename + '"', '--use-preload-plugins'
|
||||
]).communicate()
|
||||
self.run_browser('page.html', '', '/report_result?600')
|
||||
|
||||
|
@ -431,7 +431,7 @@ If manually bisecting:
|
|||
open(os.path.join(self.get_dir(), 'sdl_image_jpeg.c'), 'w').write(self.with_report_result(open(path_from_root('tests', 'sdl_image.c')).read()))
|
||||
Popen([
|
||||
PYTHON, EMCC, os.path.join(self.get_dir(), 'sdl_image_jpeg.c'), '-o', 'page.html',
|
||||
'--preload-file', 'screenshot.jpeg', '-DSCREENSHOT_DIRNAME="/"', '-DSCREENSHOT_BASENAME="screenshot.jpeg"'
|
||||
'--preload-file', 'screenshot.jpeg', '-DSCREENSHOT_DIRNAME="/"', '-DSCREENSHOT_BASENAME="screenshot.jpeg"', '--use-preload-plugins'
|
||||
]).communicate()
|
||||
self.run_browser('page.html', '', '/report_result?600')
|
||||
|
||||
|
@ -1047,55 +1047,55 @@ keydown(100);keyup(100); // trigger the end
|
|||
def test_sdl_ogl(self):
|
||||
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
|
||||
self.btest('sdl_ogl.c', reference='screenshot-gray-purple.png', reference_slack=1,
|
||||
args=['-O2', '--minify', '0', '--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1'],
|
||||
args=['-O2', '--minify', '0', '--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1', '--use-preload-plugins'],
|
||||
message='You should see an image with gray at the top.')
|
||||
|
||||
def test_sdl_ogl_defaultmatrixmode(self):
|
||||
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
|
||||
self.btest('sdl_ogl_defaultMatrixMode.c', reference='screenshot-gray-purple.png', reference_slack=1,
|
||||
args=['--minify', '0', '--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1'],
|
||||
args=['--minify', '0', '--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1', '--use-preload-plugins'],
|
||||
message='You should see an image with gray at the top.')
|
||||
|
||||
def test_sdl_ogl_p(self):
|
||||
# Immediate mode with pointers
|
||||
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
|
||||
self.btest('sdl_ogl_p.c', reference='screenshot-gray.png', reference_slack=1,
|
||||
args=['--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1'],
|
||||
args=['--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1', '--use-preload-plugins'],
|
||||
message='You should see an image with gray at the top.')
|
||||
|
||||
def test_sdl_ogl_proc_alias(self):
|
||||
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
|
||||
self.btest('sdl_ogl_proc_alias.c', reference='screenshot-gray-purple.png', reference_slack=1,
|
||||
args=['-O2', '-g2', '-s', 'INLINING_LIMIT=1', '--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1'])
|
||||
args=['-O2', '-g2', '-s', 'INLINING_LIMIT=1', '--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1', '--use-preload-plugins'])
|
||||
|
||||
def test_sdl_fog_simple(self):
|
||||
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
|
||||
self.btest('sdl_fog_simple.c', reference='screenshot-fog-simple.png',
|
||||
args=['-O2', '--minify', '0', '--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1'],
|
||||
args=['-O2', '--minify', '0', '--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1', '--use-preload-plugins'],
|
||||
message='You should see an image with fog.')
|
||||
|
||||
def test_sdl_fog_negative(self):
|
||||
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
|
||||
self.btest('sdl_fog_negative.c', reference='screenshot-fog-negative.png',
|
||||
args=['--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1'],
|
||||
args=['--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1', '--use-preload-plugins'],
|
||||
message='You should see an image with fog.')
|
||||
|
||||
def test_sdl_fog_density(self):
|
||||
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
|
||||
self.btest('sdl_fog_density.c', reference='screenshot-fog-density.png',
|
||||
args=['--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1'],
|
||||
args=['--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1', '--use-preload-plugins'],
|
||||
message='You should see an image with fog.')
|
||||
|
||||
def test_sdl_fog_exp2(self):
|
||||
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
|
||||
self.btest('sdl_fog_exp2.c', reference='screenshot-fog-exp2.png',
|
||||
args=['--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1'],
|
||||
args=['--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1', '--use-preload-plugins'],
|
||||
message='You should see an image with fog.')
|
||||
|
||||
def test_sdl_fog_linear(self):
|
||||
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
|
||||
self.btest('sdl_fog_linear.c', reference='screenshot-fog-linear.png', reference_slack=1,
|
||||
args=['--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1'],
|
||||
args=['--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1', '--use-preload-plugins'],
|
||||
message='You should see an image with fog.')
|
||||
|
||||
def test_glfw(self):
|
||||
|
@ -1371,20 +1371,20 @@ keydown(100);keyup(100); // trigger the end
|
|||
def test_gl_ps(self):
|
||||
# pointers and a shader
|
||||
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
|
||||
self.btest('gl_ps.c', reference='gl_ps.png', args=['--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1'], reference_slack=1)
|
||||
self.btest('gl_ps.c', reference='gl_ps.png', args=['--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1', '--use-preload-plugins'], reference_slack=1)
|
||||
|
||||
def test_gl_ps_packed(self):
|
||||
# packed data that needs to be strided
|
||||
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
|
||||
self.btest('gl_ps_packed.c', reference='gl_ps.png', args=['--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1'], reference_slack=1)
|
||||
self.btest('gl_ps_packed.c', reference='gl_ps.png', args=['--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1', '--use-preload-plugins'], reference_slack=1)
|
||||
|
||||
def test_gl_ps_strides(self):
|
||||
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
|
||||
self.btest('gl_ps_strides.c', reference='gl_ps_strides.png', args=['--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1'])
|
||||
self.btest('gl_ps_strides.c', reference='gl_ps_strides.png', args=['--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1', '--use-preload-plugins'])
|
||||
|
||||
def test_gl_ps_worker(self):
|
||||
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
|
||||
self.btest('gl_ps_worker.c', reference='gl_ps.png', args=['--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1'], reference_slack=1, also_proxied=True)
|
||||
self.btest('gl_ps_worker.c', reference='gl_ps.png', args=['--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1', '--use-preload-plugins'], reference_slack=1, also_proxied=True)
|
||||
|
||||
def test_gl_renderers(self):
|
||||
self.btest('gl_renderers.c', reference='gl_renderers.png', args=['-s', 'GL_UNSAFE_OPTS=0', '-s', 'LEGACY_GL_EMULATION=1'])
|
||||
|
@ -1506,7 +1506,7 @@ void *getBindBuffer() {
|
|||
|
||||
def test_sdl_rotozoom(self):
|
||||
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
|
||||
self.btest('sdl_rotozoom.c', reference='sdl_rotozoom.png', args=['--preload-file', 'screenshot.png'], reference_slack=3)
|
||||
self.btest('sdl_rotozoom.c', reference='sdl_rotozoom.png', args=['--preload-file', 'screenshot.png', '--use-preload-plugins'], reference_slack=3)
|
||||
|
||||
def test_sdl_gfx_primitives(self):
|
||||
self.btest('sdl_gfx_primitives.c', reference='sdl_gfx_primitives.png', reference_slack=1)
|
||||
|
@ -1545,7 +1545,7 @@ void *getBindBuffer() {
|
|||
|
||||
def test_glbegin_points(self):
|
||||
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
|
||||
self.btest('glbegin_points.c', reference='glbegin_points.png', args=['--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1'])
|
||||
self.btest('glbegin_points.c', reference='glbegin_points.png', args=['--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1', '--use-preload-plugins'])
|
||||
|
||||
def test_s3tc(self):
|
||||
shutil.copyfile(path_from_root('tests', 'screenshot.dds'), os.path.join(self.get_dir(), 'screenshot.dds'))
|
||||
|
@ -2094,7 +2094,7 @@ Module['_main'] = function() {
|
|||
('screenshot.jpg@/assets/screenshot.jpg', '/assets', 'screenshot.jpg')]:
|
||||
Popen([
|
||||
PYTHON, EMCC, os.path.join(self.get_dir(), 'sdl2_image.c'), '-o', 'page.html', '-O2', '--memory-init-file', str(mem),
|
||||
'--preload-file', dest, '-DSCREENSHOT_DIRNAME="' + dirname + '"', '-DSCREENSHOT_BASENAME="' + basename + '"', '-s', 'USE_SDL=2', '-s', 'USE_SDL_IMAGE=2'
|
||||
'--preload-file', dest, '-DSCREENSHOT_DIRNAME="' + dirname + '"', '-DSCREENSHOT_BASENAME="' + basename + '"', '-s', 'USE_SDL=2', '-s', 'USE_SDL_IMAGE=2', '--use-preload-plugins'
|
||||
]).communicate()
|
||||
self.run_browser('page.html', '', '/report_result?600')
|
||||
|
||||
|
@ -2103,7 +2103,7 @@ Module['_main'] = function() {
|
|||
open(os.path.join(self.get_dir(), 'sdl2_image_jpeg.c'), 'w').write(self.with_report_result(open(path_from_root('tests', 'sdl2_image.c')).read()))
|
||||
Popen([
|
||||
PYTHON, EMCC, os.path.join(self.get_dir(), 'sdl2_image_jpeg.c'), '-o', 'page.html',
|
||||
'--preload-file', 'screenshot.jpeg', '-DSCREENSHOT_DIRNAME="/"', '-DSCREENSHOT_BASENAME="screenshot.jpeg"', '-s', 'USE_SDL=2', '-s', 'USE_SDL_IMAGE=2'
|
||||
'--preload-file', 'screenshot.jpeg', '-DSCREENSHOT_DIRNAME="/"', '-DSCREENSHOT_BASENAME="screenshot.jpeg"', '-s', 'USE_SDL=2', '-s', 'USE_SDL_IMAGE=2', '--use-preload-plugins'
|
||||
]).communicate()
|
||||
self.run_browser('page.html', '', '/report_result?600')
|
||||
|
||||
|
@ -2371,31 +2371,31 @@ window.close = function() {
|
|||
def test_sdl2_fog_simple(self):
|
||||
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
|
||||
self.btest('sdl2_fog_simple.c', reference='screenshot-fog-simple.png',
|
||||
args=['-s', 'USE_SDL=2', '-s', 'USE_SDL_IMAGE=2','-O2', '--minify', '0', '--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1'],
|
||||
args=['-s', 'USE_SDL=2', '-s', 'USE_SDL_IMAGE=2','-O2', '--minify', '0', '--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1', '--use-preload-plugins'],
|
||||
message='You should see an image with fog.')
|
||||
|
||||
def test_sdl2_fog_negative(self):
|
||||
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
|
||||
self.btest('sdl2_fog_negative.c', reference='screenshot-fog-negative.png',
|
||||
args=['-s', 'USE_SDL=2', '-s', 'USE_SDL_IMAGE=2','--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1'],
|
||||
args=['-s', 'USE_SDL=2', '-s', 'USE_SDL_IMAGE=2','--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1', '--use-preload-plugins'],
|
||||
message='You should see an image with fog.')
|
||||
|
||||
def test_sdl2_fog_density(self):
|
||||
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
|
||||
self.btest('sdl2_fog_density.c', reference='screenshot-fog-density.png',
|
||||
args=['-s', 'USE_SDL=2', '-s', 'USE_SDL_IMAGE=2','--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1'],
|
||||
args=['-s', 'USE_SDL=2', '-s', 'USE_SDL_IMAGE=2','--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1', '--use-preload-plugins'],
|
||||
message='You should see an image with fog.')
|
||||
|
||||
def test_sdl2_fog_exp2(self):
|
||||
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
|
||||
self.btest('sdl2_fog_exp2.c', reference='screenshot-fog-exp2.png',
|
||||
args=['-s', 'USE_SDL=2', '-s', 'USE_SDL_IMAGE=2','--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1'],
|
||||
args=['-s', 'USE_SDL=2', '-s', 'USE_SDL_IMAGE=2','--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1', '--use-preload-plugins'],
|
||||
message='You should see an image with fog.')
|
||||
|
||||
def test_sdl2_fog_linear(self):
|
||||
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
|
||||
self.btest('sdl2_fog_linear.c', reference='screenshot-fog-linear.png', reference_slack=1,
|
||||
args=['-s', 'USE_SDL=2', '-s', 'USE_SDL_IMAGE=2','--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1'],
|
||||
args=['-s', 'USE_SDL=2', '-s', 'USE_SDL_IMAGE=2','--preload-file', 'screenshot.png', '-s', 'LEGACY_GL_EMULATION=1', '--use-preload-plugins'],
|
||||
message='You should see an image with fog.')
|
||||
|
||||
def test_sdl2_unwasteful(self):
|
||||
|
|
|
@ -11,7 +11,7 @@ data downloads.
|
|||
|
||||
Usage:
|
||||
|
||||
file_packager.py TARGET [--preload A [B..]] [--embed C [D..]] [--exclude E [F..]] [--crunch[=X]] [--js-output=OUTPUT.js] [--no-force] [--use-preload-cache] [--no-heap-copy] [--separate-metadata] [--lz4]
|
||||
file_packager.py TARGET [--preload A [B..]] [--embed C [D..]] [--exclude E [F..]] [--crunch[=X]] [--js-output=OUTPUT.js] [--no-force] [--use-preload-cache] [--no-heap-copy] [--separate-metadata] [--lz4] [--use-preload-plugins]
|
||||
|
||||
--preload ,
|
||||
--embed See emcc --help for more details on those options.
|
||||
|
@ -43,6 +43,9 @@ Usage:
|
|||
--lz4 Uses LZ4. This compresses the data using LZ4 when this utility is run, then the client decompresses chunks on the fly, avoiding storing
|
||||
the entire decompressed data in memory at once. See LZ4 in src/settings.js, you must build the main program with that flag.
|
||||
|
||||
--use-preload-plugins Tells the file packager to run preload plugins on the files as they are loaded. This performs tasks like decoding images
|
||||
and audio using the browser's codecs.
|
||||
|
||||
Notes:
|
||||
|
||||
* The file packager generates unix-style file paths. So if you are on windows and a file is accessed at
|
||||
|
@ -100,6 +103,7 @@ no_heap_copy = True
|
|||
# If set to False, the package metadata is stored inside the js-output file which makes js-output file to mutate on each invocation of this packager tool.
|
||||
separate_metadata = False
|
||||
lz4 = False
|
||||
use_preload_plugins = False
|
||||
|
||||
for arg in sys.argv[2:]:
|
||||
if arg == '--preload':
|
||||
|
@ -124,6 +128,9 @@ for arg in sys.argv[2:]:
|
|||
elif arg == '--lz4':
|
||||
lz4 = True
|
||||
leading = ''
|
||||
elif arg == '--use-preload-plugins':
|
||||
use_preload_plugins = True
|
||||
leading = ''
|
||||
elif arg.startswith('--js-output'):
|
||||
jsoutput = arg.split('=')[1] if '=' in arg else None
|
||||
leading = ''
|
||||
|
@ -387,6 +394,22 @@ if has_preloaded:
|
|||
if start > 256*1024*1024:
|
||||
print >> sys.stderr, 'warning: file packager is creating an asset bundle of %d MB. this is very large, and browsers might have trouble loading it. see https://hacks.mozilla.org/2015/02/synchronous-execution-and-filesystem-access-in-emscripten/' % (start/(1024*1024))
|
||||
|
||||
create_preloaded = '''
|
||||
Module['FS_createPreloadedFile'](this.name, null, byteArray, true, true, function() {
|
||||
Module['removeRunDependency']('fp ' + that.name);
|
||||
}, function() {
|
||||
if (that.audio) {
|
||||
Module['removeRunDependency']('fp ' + that.name); // workaround for chromium bug 124926 (still no audio with this, but at least we don't hang)
|
||||
} else {
|
||||
Module.printErr('Preloading file ' + that.name + ' failed');
|
||||
}
|
||||
}, false, true); // canOwn this data in the filesystem, it is a slide into the heap that will never change
|
||||
'''
|
||||
create_data = '''
|
||||
Module['FS_createDataFile'](this.name, null, byteArray, true, true, true); // canOwn this data in the filesystem, it is a slide into the heap that will never change
|
||||
Module['removeRunDependency']('fp ' + that.name);
|
||||
'''
|
||||
|
||||
# Data requests - for getting a block of data out of the big archive - have a similar API to XHRs
|
||||
code += '''
|
||||
function DataRequest(start, end, crunched, audio) {
|
||||
|
@ -411,15 +434,7 @@ if has_preloaded:
|
|||
},
|
||||
finish: function(byteArray) {
|
||||
var that = this;
|
||||
Module['FS_createPreloadedFile'](this.name, null, byteArray, true, true, function() {
|
||||
Module['removeRunDependency']('fp ' + that.name);
|
||||
}, function() {
|
||||
if (that.audio) {
|
||||
Module['removeRunDependency']('fp ' + that.name); // workaround for chromium bug 124926 (still no audio with this, but at least we don't hang)
|
||||
} else {
|
||||
Module.printErr('Preloading file ' + that.name + ' failed');
|
||||
}
|
||||
}, false, true); // canOwn this data in the filesystem, it is a slide into the heap that will never change
|
||||
%s
|
||||
this.requests[this.name] = null;
|
||||
},
|
||||
};
|
||||
|
@ -437,7 +452,7 @@ if has_preloaded:
|
|||
} else {
|
||||
''', '' if not crunch else '''
|
||||
}
|
||||
''', '''
|
||||
''', create_preloaded if use_preload_plugins else create_data, '''
|
||||
var files = metadata.files;
|
||||
for (i = 0; i < files.length; ++i) {
|
||||
new DataRequest(files[i].start, files[i].end, files[i].crunched, files[i].audio).open('GET', files[i].filename);
|
||||
|
|
Загрузка…
Ссылка в новой задаче