diff --git a/CMakeLists.txt b/CMakeLists.txt index b77ba20..0bce3d7 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -233,7 +233,7 @@ if(EMSCRIPTEN) endif() target_compile_options(infinipaint PRIVATE -Wall -sUSE_HARFBUZZ=1 -fdiagnostics-color -sUSE_SDL=0 -include functional -fexceptions -pthread) - target_link_options(infinipaint PRIVATE --emrun -sUSE_HARFBUZZ=1 -sUSE_SDL=0 -sFULL_ES2 -sUSE_WEBGL2=1 -sFETCH --embed-file data -sALLOW_MEMORY_GROWTH=1 -sEXPORTED_RUNTIME_METHODS=ccall -sEXPORTED_FUNCTIONS=[_main,_malloc,_free] -sMAXIMUM_MEMORY=4GB -sSINGLE_FILE -lidbfs.js -fexceptions -pthread) # -sINITIAL_MEMORY=67108864 + target_link_options(infinipaint PRIVATE --emrun -sUSE_HARFBUZZ=1 -sUSE_SDL=0 -sFULL_ES2 -sUSE_WEBGL2=1 -sFETCH --embed-file data -sALLOW_MEMORY_GROWTH=1 -sEXPORTED_RUNTIME_METHODS=ccall,HEAPU8 -sEXPORTED_FUNCTIONS=[_main,_malloc,_free] -sMAXIMUM_MEMORY=4GB -sSINGLE_FILE -lidbfs.js -fexceptions -pthread) # -sINITIAL_MEMORY=67108864 set(CMAKE_EXECUTABLE_SUFFIX ".js") message("In Emscripten Mode") endif() diff --git a/include/EmscriptenHelpers/emscripten_browser_file.h b/include/EmscriptenHelpers/emscripten_browser_file.h index 7019883..82e87ad 100644 --- a/include/EmscriptenHelpers/emscripten_browser_file.h +++ b/include/EmscriptenHelpers/emscripten_browser_file.h @@ -86,11 +86,15 @@ inline void upload(std::string const &accept_types, upload_handler callback, voi #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wmissing-variable-declarations" -EM_JS_INLINE(void, download, (char const *filename, char const *mime_type, void const *buffer, size_t buffer_size), { +EM_JS_INLINE(void, download, (char const *filename, char const *mime_type, void const *b, size_t buffer_size), { + // Fix copied from: https://github.com/Armchair-Software/emscripten-browser-file/issues/1 /// Offer a buffer in memory as a file to download, specifying download filename and mime type var a = document.createElement('a'); a.download = UTF8ToString(filename); - a.href = URL.createObjectURL(new Blob([new Uint8Array(Module["HEAPU8"].buffer, buffer, buffer_size)], {type: UTF8ToString(mime_type)})); + var bufferCopy = new ArrayBuffer(buffer_size); + var uint8Array = new Uint8Array(bufferCopy); + uint8Array.set(new Uint8Array(Module["HEAPU8"].buffer, b, buffer_size)); + a.href = URL.createObjectURL(new Blob([uint8Array], {type: UTF8ToString(mime_type)})); a.click(); }); #pragma GCC diagnostic pop diff --git a/src/DrawingProgram/Tools/LineDrawTool.hpp b/src/DrawingProgram/Tools/LineDrawTool.hpp index adcbf34..fc1cf62 100644 --- a/src/DrawingProgram/Tools/LineDrawTool.hpp +++ b/src/DrawingProgram/Tools/LineDrawTool.hpp @@ -19,6 +19,5 @@ class LineDrawTool : public DrawingProgramToolBase { private: void commit(); - Vector2f startAt; CanvasComponentContainer::ObjInfo* objInfoBeingEdited = nullptr; }; diff --git a/src/DrawingProgram/Tools/TextBoxTool.hpp b/src/DrawingProgram/Tools/TextBoxTool.hpp index 2a121a2..796f5d0 100644 --- a/src/DrawingProgram/Tools/TextBoxTool.hpp +++ b/src/DrawingProgram/Tools/TextBoxTool.hpp @@ -21,6 +21,5 @@ class TextBoxTool : public DrawingProgramToolBase { Vector2f startAt; Vector2f endAt; - int drawStage = 0; CanvasComponentContainer::ObjInfo* objInfoBeingEdited = nullptr; }; diff --git a/src/MainProgram.hpp b/src/MainProgram.hpp index 0d16a56..db1cbcb 100644 --- a/src/MainProgram.hpp +++ b/src/MainProgram.hpp @@ -50,6 +50,8 @@ class MainProgram { bool applyDisplayScale = true; #endif + bool disableGraphicsDriverWorkarounds = false; + int defaultMSAASampleCount = 0; SkSurfaceProps defaultMSAASurfaceProps; diff --git a/src/Toolbar.cpp b/src/Toolbar.cpp index 0223d7b..776a98a 100644 --- a/src/Toolbar.cpp +++ b/src/Toolbar.cpp @@ -252,6 +252,7 @@ nlohmann::json Toolbar::get_config_json() { toRet["keybinds"] = jKeybinds; toRet["guiScale"] = guiScale; toRet["jumpTransitionTime"] = jumpTransitionTime; + toRet["disableGraphicsDriverWorkarounds"] = main.window.disableGraphicsDriverWorkarounds; toRet["dragZoomSpeed"] = dragZoomSpeed; toRet["scrollZoomSpeed"] = scrollZoomSpeed; toRet["vsync"] = main.window.vsyncValue; @@ -330,6 +331,8 @@ void Toolbar::set_config_json(const nlohmann::json& j, VersionNumber version) { try{j.at("applyDisplayScale").get_to(main.window.applyDisplayScale);} catch(...) {} #endif try{j.at("guiScale").get_to(guiScale);} catch(...) {} + try{j.at("jumpTransitionTime").get_to(jumpTransitionTime);} catch(...) {} + try{j.at("disableGraphicsDriverWorkarounds").get_to(main.window.disableGraphicsDriverWorkarounds);} catch(...) {} try{j.at("useNativeFilePicker").get_to(useNativeFilePicker);} catch(...) {} try{j.at("themeInUse").get_to(themeData.themeCurrentlyLoaded);} catch(...) {} if(version >= VersionNumber(0, 3, 0)) @@ -1701,6 +1704,7 @@ void Toolbar::options_menu() { gui.slider_scalar_field("scroll zoom slider", "Scroll zoom speed", &scrollZoomSpeed, 0.0, 1.0, 3); gui.checkbox_field("flip zoom tool direction", "Flip zoom tool direction", &flipZoomToolDirection); gui.checkbox_field("make all tools share same size", "Make all tools share size", &main.toolConfig.globalConf.useGlobalRelativeWidth); + gui.checkbox_field("disable graphics driver workarounds", "Disable graphics driver workarounds (enabling or disabling this might fix some graphical glitches, requires restart)", &main.window.disableGraphicsDriverWorkarounds); gui.input_scalar_field("jump transition time", "Jump transition time", &jumpTransitionTime, 0.01f, 1000.0f, 2); gui.input_scalar_field("Max GUI Scale", "Max GUI Scale", &guiScale, 0.5f, 5.0f, 1); diff --git a/src/main.cpp b/src/main.cpp index 385d7f9..850fe54 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -490,7 +490,7 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv) { GrContextOptions opts; opts.fSuppressPrints = true; - opts.fDisableDriverCorrectnessWorkarounds = true; // Driver workarounds causing glitches in windows drivers + opts.fDisableDriverCorrectnessWorkarounds = mS.m->window.disableGraphicsDriverWorkarounds; // Driver workarounds causing glitches on intel drivers on windows, but are required in the Emscripten version. Good idea to have a toggle for it mS.ctx = GrDirectContexts::MakeGL(iface, opts); if(!mS.ctx)