[ion/web] Fix screenshots

This commit is contained in:
Léa Saviot
2020-01-24 13:43:28 +01:00
parent 50f1ee9721
commit 244c7b31eb
3 changed files with 11 additions and 1 deletions

View File

@@ -5,6 +5,7 @@ LD = emcc
EMSCRIPTEN_ASYNC_SYMBOLS = \
SAFE_HEAP_LOAD \
SAFE_HEAP_STORE \
_IonDisplayForceRefresh\
_IonEventsEmscriptenKeyDown \
_IonEventsEmscriptenKeyUp \
_IonEventsEmscriptenPushEvent \
@@ -121,4 +122,4 @@ EMSCRIPTEN_INIT_FILE ?= 0
LDFLAGS += --memory-init-file $(EMSCRIPTEN_INIT_FILE)
SFLAGS += $(EMFLAGS)
LDFLAGS += $(EMFLAGS) -Oz -s EXPORTED_FUNCTIONS='["_main", "_IonSimulatorKeyboardKeyDown", "_IonSimulatorKeyboardKeyUp", "_IonSimulatorEventsPushEvent", "_IonSoftwareVersion", "_IonPatchLevel"]' -s EXTRA_EXPORTED_RUNTIME_METHODS='["UTF8ToString"]'
LDFLAGS += $(EMFLAGS) -Oz -s EXPORTED_FUNCTIONS='["_main", "_IonSimulatorKeyboardKeyDown", "_IonSimulatorKeyboardKeyUp", "_IonSimulatorEventsPushEvent", "_IonSoftwareVersion", "_IonPatchLevel", "_IonDisplayForceRefresh"]' -s EXTRA_EXPORTED_RUNTIME_METHODS='["UTF8ToString"]'

View File

@@ -1,4 +1,5 @@
#include <ion.h>
#include "../shared/main.h"
extern "C" const char * IonSoftwareVersion() {
return Ion::softwareVersion();
@@ -7,3 +8,8 @@ extern "C" const char * IonSoftwareVersion() {
extern "C" const char * IonPatchLevel() {
return Ion::patchLevel();
}
extern "C" void IonDisplayForceRefresh() {
Ion::Simulator::Main::setNeedsRefresh();
Ion::Simulator::Main::refresh();
}

View File

@@ -261,6 +261,9 @@ Epsilon(Module);
</script>
<script>
function screenshot() {
<!--toDataURL needs the canvas to be refreshed-->
Module._IonDisplayForceRefresh();
var canvas = document.querySelector('.screen');
var link = document.createElement('a');
link.download = 'screenshot.png';