Fix web simulator and binpack build (#114)

This commit is contained in:
Yaya-Cout
2021-12-28 15:12:13 +01:00
committed by GitHub
parent 398e974ccd
commit 70b162e63b
7 changed files with 9 additions and 52 deletions

View File

@@ -140,7 +140,7 @@ jobs:
steps:
- uses: numworks/setup-emscripten@v1
with:
sdk: 1.40.1-fastcomp
sdk: 1.40.1
- uses: actions/checkout@v2
with:
submodules: 'recursive'

View File

@@ -26,4 +26,4 @@ EMSCRIPTEN_MODULARIZE ?= 1
LDFLAGS += -s MODULARIZE=$(EMSCRIPTEN_MODULARIZE) -s 'EXPORT_NAME="Epsilon"' --memory-init-file 0
SFLAGS += $(EMFLAGS)
LDFLAGS += $(EMFLAGS) -Oz -s EXPORTED_FUNCTIONS='["_main", "_IonSimulatorKeyboardKeyDown", "_IonSimulatorKeyboardKeyUp", "_IonSimulatorEventsPushEvent", "_IonSoftwareVersion", "_IonPatchLevel", "_IonDisplayForceRefresh"]' -s EXTRA_EXPORTED_RUNTIME_METHODS='["UTF8ToString"]'
LDFLAGS += $(EMFLAGS) -Oz -s EXPORTED_FUNCTIONS='["_main", "_IonSimulatorKeyboardKeyDown", "_IonSimulatorKeyboardKeyUp", "_IonSimulatorEventsPushEvent", "_IonSoftwareVersion", "_IonPatchLevel", "_IonDisplayForceRefresh"]' -s EXPORTED_RUNTIME_METHODS='["UTF8ToString"]'

View File

@@ -244,7 +244,7 @@ SECTIONS {
*(.rodata._ZL12KDColorWhite*)
*(.rodata._ZL10KDColorRed*)
*(.rodata._ZL12KDColorBlack*)
*(.rodata._ZN4CodeL15BackgroundColorEd*)
*(.rodata._ZN4CodeL15BackgroundColorE*)
*(.rodata._ZN3Ion6Device3SWD6ConfigL4PinsE)
*(.rodata._ZN3Ion6Device7Display6ConfigL8FSMCPinsE)
*(.rodata._ZZN3Ion6Device7Display9initPanelEvE11calibration)

View File

@@ -587,24 +587,13 @@ Emscripten_HandleResize(int eventType, const EmscriptenUiEvent *uiEvent, void *u
double w = window_data->window->w;
double h = window_data->window->h;
if(window_data->external_size) {
emscripten_get_element_css_size(window_data->canvas_id, &w, &h);
}
emscripten_set_canvas_element_size(window_data->canvas_id, w * window_data->pixel_ratio, h * window_data->pixel_ratio);
/* set_canvas_size unsets this */
if (!window_data->external_size && window_data->pixel_ratio != 1.0f) {
emscripten_set_element_css_size(window_data->canvas_id, w, h);
}
if (force) {
/* force the event to trigger, so pixel ratio changes can be handled */
window_data->window->w = 0;
window_data->window->h = 0;
}
SDL_SendWindowEvent(window_data->window, SDL_WINDOWEVENT_RESIZED, w, h);
SDL_SendWindowEvent(window_data->window, SDL_WINDOWEVENT_RESIZED, 320, 240);
}
}

View File

@@ -197,38 +197,12 @@ Emscripten_CreateWindow(_THIS, SDL_Window * window)
}
wdata->canvas_id = SDL_strdup("#canvas");
wdata->pixel_ratio = 320 / 240;
if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
wdata->pixel_ratio = emscripten_get_device_pixel_ratio();
} else {
wdata->pixel_ratio = 1.0f;
}
window->w = 320;
window->h = 240;
scaled_w = SDL_floor(window->w * wdata->pixel_ratio);
scaled_h = SDL_floor(window->h * wdata->pixel_ratio);
/* set a fake size to check if there is any CSS sizing the canvas */
emscripten_set_canvas_element_size(wdata->canvas_id, 1, 1);
emscripten_get_element_css_size(wdata->canvas_id, &css_w, &css_h);
wdata->external_size = SDL_floor(css_w) != 1 || SDL_floor(css_h) != 1;
if ((window->flags & SDL_WINDOW_RESIZABLE) && wdata->external_size) {
/* external css has resized us */
scaled_w = css_w * wdata->pixel_ratio;
scaled_h = css_h * wdata->pixel_ratio;
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, css_w, css_h);
}
emscripten_set_canvas_element_size(wdata->canvas_id, scaled_w, scaled_h);
/* if the size is not being controlled by css, we need to scale down for hidpi */
if (!wdata->external_size) {
if (wdata->pixel_ratio != 1.0f) {
/*scale canvas down*/
emscripten_set_element_css_size(wdata->canvas_id, window->w, window->h);
}
}
emscripten_set_canvas_element_size(wdata->canvas_id, 320, 240);
#if SDL_VIDEO_OPENGL_EGL
if (window->flags & SDL_WINDOW_OPENGL) {

View File

@@ -5,7 +5,6 @@
/* MicroPython configuration options
* We're not listing the default options as defined in mpconfig.h */
#if __EMSCRIPTEN__
// Enable a PyStack where most objects are allocated instead of always using the heap
/* This enables to allocate and free memory in a scope (thus, Python can call
* Python) but also has the collateral effect of removing bugs regarding
@@ -15,8 +14,7 @@
* collecting roots the transpiled C code is denied access to Javascript
* variables that can store pointers to the Python heap. The pointed objects
* are therefore erased prematurely. */
#define MICROPY_ENABLE_PYSTACK (1)
#endif
#define MICROPY_ENABLE_PYSTACK (0)
// Maximum length of a path in the filesystem
#define MICROPY_ALLOC_PATH_MAX (32)

View File

@@ -163,10 +163,6 @@ extern "C" {
}
void MicroPython::init(void * heapStart, void * heapEnd) {
#if __EMSCRIPTEN__
static mp_obj_t pystack[1024];
mp_pystack_init(pystack, &pystack[MP_ARRAY_SIZE(pystack)]);
#endif
/* We delimit the stack part that will be used by Python. The stackTop is the
* address of the first object that can be allocated on Python stack. This
* boundaries are used: