Skip to content

Commit

Permalink
Switch to Canvas Rendering
Browse files Browse the repository at this point in the history
This switches the rendering of the layout from using HTML and CSS to
using a canvas (technically it's two). This not only should improve the
performance but also brings the rendering in line with our native
renderers, enabling new features such as vertical resizing and
horizontal layouts. This also removes a lot of code specific to the HTML
rendering and thus greatly simplifies the codebase. There is one slight
regression in that the layout editor doesn't allow clicking and dragging
the individual components directly on the layout anymore. This is
however something we can explore directly in `livesplit-core` in the
future, so other frontends can benefit from it as well.
  • Loading branch information
CryZe committed Apr 27, 2024
1 parent 78a668f commit 3e249de
Show file tree
Hide file tree
Showing 37 changed files with 193 additions and 1,880 deletions.
5 changes: 3 additions & 2 deletions buildCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ if (process.argv.some((v) => v === "--nightly")) {
// but it forgets to pass the LTO flag that we specified in the
// Cargo.toml, so the virtual-function-elimination complains that it's
// only compatible with LTO, so we have to specify lto here too.
rustFlags += " -Z virtual-function-elimination -C lto";
// FIXME: Seems to be broken at the moment.
// rustFlags += " -Z virtual-function-elimination -C lto";
}
}

Expand All @@ -55,7 +56,7 @@ execSync(
);

execSync(
`cargo ${toolchain} rustc -p livesplit-core-capi --crate-type cdylib --features wasm-web --target wasm32-unknown-unknown ${cargoFlags}`,
`cargo ${toolchain} rustc -p livesplit-core-capi --crate-type cdylib --features wasm-web,web-rendering --target wasm32-unknown-unknown ${cargoFlags}`,
{
cwd: "livesplit-core",
stdio: "inherit",
Expand Down
2 changes: 1 addition & 1 deletion livesplit-core
Submodule livesplit-core updated 43 files
+1 −1 .github/workflows/before_deploy.sh
+21 −14 .github/workflows/build.yml
+3 −3 .github/workflows/test.sh
+28 −4 Cargo.toml
+2 −2 README.md
+13 −6 benches/scene_management.rs
+104 −0 benches/svg_rendering.rs
+4 −0 capi/Cargo.toml
+1 −1 capi/bind_gen/Cargo.toml
+29 −72 capi/bind_gen/src/wasm_bindgen.rs
+10 −7 capi/src/lib.rs
+45 −0 capi/src/web_rendering.rs
+1 −1 crates/livesplit-auto-splitting/README.md
+1 −1 crates/livesplit-auto-splitting/src/settings/gui.rs
+7 −0 crates/livesplit-auto-splitting/src/settings/map.rs
+4 −1 crates/livesplit-auto-splitting/src/wasi_path.rs
+1 −1 crates/livesplit-hotkey/Cargo.toml
+4 −4 src/component/graph.rs
+2 −8 src/component/title/mod.rs
+1 −1 src/platform/math.rs
+0 −8 src/rendering/default_text_engine/color_font/cpal.rs
+76 −69 src/rendering/default_text_engine/mod.rs
+1 −2 src/rendering/icon.rs
+36 −42 src/rendering/mod.rs
+34 −5 src/rendering/resource/allocation.rs
+15 −4 src/rendering/resource/handles.rs
+1 −1 src/rendering/resource/mod.rs
+46 −28 src/rendering/software.rs
+1,004 −0 src/rendering/svg.rs
+71 −0 src/rendering/web/bindings.rs
+902 −0 src/rendering/web/mod.rs
+2 −2 src/run/parser/llanfair.rs
+2 −2 src/run/parser/llanfair_gered.rs
+11 −9 src/run/saver/livesplit.rs
+11 −57 src/settings/image/shrinking.rs
+66 −0 src/util/image.rs
+2 −0 src/util/mod.rs
+1 −1 src/util/xml/mod.rs
+3 −21 src/util/xml/writer.rs
+158 −0 tests/layout_files/WithBackgroundImage.lsl
+1 −0 tests/layout_files/mod.rs
+22 −22 tests/layout_files/subsplits.lsl
+142 −27 tests/rendering.rs
2 changes: 1 addition & 1 deletion src/assets/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 0 additions & 6 deletions src/css/Abbreviated.scss

This file was deleted.

59 changes: 0 additions & 59 deletions src/css/DetailedTimer.scss

This file was deleted.

3 changes: 0 additions & 3 deletions src/css/Graph.scss

This file was deleted.

59 changes: 0 additions & 59 deletions src/css/KeyValue.scss

This file was deleted.

45 changes: 30 additions & 15 deletions src/css/Layout.scss
Original file line number Diff line number Diff line change
@@ -1,27 +1,42 @@
@import 'variables';
@import 'Font';

.layout {
font-family: "fira", sans-serif;
font-size: $default-font-size;
text-shadow: 2px 2px 2px rgba(0, 0, 0, 0.5);
position: relative;
-webkit-touch-callout: none;
-webkit-user-select: none;
user-select: none;

.resizable-layout {
position: absolute;
z-index: 2;
height: 100% !important;
top: 0;
width: inherit;
height: inherit;

.react-resizable {
width: 0 !important;
height: 0 !important;
}

.resizable-handle {
.resizable-handle-east {
cursor: e-resize;
bottom: -4px;
right: -4px;
right: -10px;
bottom: 10px;
top: 0;
position: absolute;
width: 20px;
}

.resizable-handle-south {
cursor: s-resize;
bottom: -10px;
left: 0;
right: 10px;
position: absolute;
height: 20px;
}

.resizable-handle-south-east {
cursor: se-resize;
bottom: -10px;
right: -10px;
position: absolute;
width: 20px;
height: 100%;
height: 20px;
}
}
}
6 changes: 0 additions & 6 deletions src/css/Separator.scss

This file was deleted.

160 changes: 0 additions & 160 deletions src/css/Splits.scss

This file was deleted.

5 changes: 0 additions & 5 deletions src/css/Time.scss

This file was deleted.

4 changes: 0 additions & 4 deletions src/css/Timer.scss

This file was deleted.

Loading

0 comments on commit 3e249de

Please sign in to comment.