Fix blitting
This commit is contained in:
parent
8ff0e868ca
commit
04dc678014
|
@ -55,24 +55,20 @@ window.loadFileAsync = function(fullPath, bitmap, callback) {
|
||||||
// Main loading function
|
// Main loading function
|
||||||
const load = (cb1) => {
|
const load = (cb1) => {
|
||||||
getLazyAsset(iurl, filename, (data) => {
|
getLazyAsset(iurl, filename, (data) => {
|
||||||
// Delete original file if existent
|
|
||||||
try { FS.unlink(path + "/" + filename); } catch (err) {}
|
|
||||||
|
|
||||||
FS.createPreloadedFile(path, filename, new Uint8Array(data), true, true, function() {
|
FS.createPreloadedFile(path, filename, new Uint8Array(data), true, true, function() {
|
||||||
window.fileAsyncCache[fullPath] = 1;
|
window.fileAsyncCache[fullPath] = 1;
|
||||||
if (!bitmap && window.setNotBusy) window.setNotBusy();
|
if (!bitmap && window.setNotBusy) window.setNotBusy();
|
||||||
if (window.fileLoadedAsync) window.fileLoadedAsync(fullPath);
|
if (window.fileLoadedAsync) window.fileLoadedAsync(fullPath);
|
||||||
callback();
|
callback();
|
||||||
if (cb1) cb1();
|
if (cb1) cb1();
|
||||||
}, console.error);
|
}, console.error, false, false, () => {
|
||||||
|
try { FS.unlink(path + "/" + filename); } catch (err) {}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show progress if doing it synchronously only
|
// Show progress if doing it synchronously only
|
||||||
if (bitmap && bitmapSizeMapping[mappingKey]) {
|
if (bitmap && bitmapSizeMapping[mappingKey]) {
|
||||||
// Remove existing file
|
|
||||||
try { FS.unlink(path + "/" + filename); } catch (err) {}
|
|
||||||
|
|
||||||
// Get image
|
// Get image
|
||||||
const sm = bitmapSizeMapping[mappingKey];
|
const sm = bitmapSizeMapping[mappingKey];
|
||||||
generationCanvas.width = sm[0];
|
generationCanvas.width = sm[0];
|
||||||
|
@ -88,7 +84,9 @@ window.loadFileAsync = function(fullPath, bitmap, callback) {
|
||||||
const reloadBitmap = Module.cwrap('reloadBitmap', 'number', ['number'])
|
const reloadBitmap = Module.cwrap('reloadBitmap', 'number', ['number'])
|
||||||
reloadBitmap(bitmap);
|
reloadBitmap(bitmap);
|
||||||
});
|
});
|
||||||
}, console.error);
|
}, console.error, false, false, () => {
|
||||||
|
try { FS.unlink(path + "/" + filename); } catch (err) {}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
if (bitmap) {
|
if (bitmap) {
|
||||||
console.warn('No sizemap for image', mappingKey);
|
console.warn('No sizemap for image', mappingKey);
|
||||||
|
|
|
@ -422,6 +422,13 @@ void Bitmap::stretchBlt(const IntRect &destRect,
|
||||||
if (opacity == 0)
|
if (opacity == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#if __EMSCRIPTEN__
|
||||||
|
if (strlen(source.filename) > 0 && !file_is_cached(source.filename)) {
|
||||||
|
load_file_async_js(source.filename);
|
||||||
|
((Bitmap*)(&source))->loadFromFilename();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
SDL_Surface *srcSurf = source.megaSurface();
|
SDL_Surface *srcSurf = source.megaSurface();
|
||||||
|
|
||||||
if (srcSurf && shState->config().subImageFix)
|
if (srcSurf && shState->config().subImageFix)
|
||||||
|
|
|
@ -12,5 +12,9 @@ EM_JS(void, save_file_async_js, (const char* fullPathC), {
|
||||||
if (window.saveFile) window.saveFile(UTF8ToString(fullPathC));
|
if (window.saveFile) window.saveFile(UTF8ToString(fullPathC));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
EM_JS(int, file_is_cached, (const char* fullPathC), {
|
||||||
|
return window.fileAsyncCache.hasOwnProperty(UTF8ToString(fullPathC)) ? 1 : 0;
|
||||||
|
});
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,8 @@ extern "C" {
|
||||||
void load_file_async_js(const char* fullPathC, int bitmap=0);
|
void load_file_async_js(const char* fullPathC, int bitmap=0);
|
||||||
|
|
||||||
void save_file_async_js(const char* fullPathC);
|
void save_file_async_js(const char* fullPathC);
|
||||||
|
|
||||||
|
int file_is_cached(const char* fullPathC);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue