Skip to content

Commit

Permalink
Merge branch 'master' into pr/profiling-crate
Browse files Browse the repository at this point in the history
# Conflicts:
#	Cargo.toml
  • Loading branch information
teddemunnik committed Oct 27, 2024
2 parents a6dc835 + 5b846b4 commit b7dbd7a
Show file tree
Hide file tree
Showing 60 changed files with 1,493 additions and 42 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
* text=auto eol=lf
Cargo.lock linguist-generated=false
**/tests/snapshots/**/*.png filter=lfs diff=lfs merge=lfs -text
41 changes: 35 additions & 6 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
lfs: true

- uses: dtolnay/rust-toolchain@master
with:
Expand Down Expand Up @@ -60,18 +62,12 @@ jobs:
- name: cargo check -p test_egui_extras_compilation
run: cargo check -p test_egui_extras_compilation

- name: Test doc-tests
run: cargo test --doc --all-features

- name: cargo doc --lib
run: cargo doc --lib --no-deps --all-features

- name: cargo doc --document-private-items
run: cargo doc --document-private-items --no-deps --all-features

- name: Test
run: cargo test --all-features

- name: clippy
run: cargo clippy --all-targets --all-features -- -D warnings

Expand Down Expand Up @@ -222,3 +218,36 @@ jobs:

- name: Check hello_world
run: cargo check -p hello_world

# ---------------------------------------------------------------------------

tests:
name: Run tests
# We run the tests on macOS because it will run with a actual GPU
runs-on: macos-latest

steps:
- uses: actions/checkout@v4
with:
lfs: true
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.76.0

- name: Set up cargo cache
uses: Swatinem/rust-cache@v2

- name: Run tests
# TODO(lucasmerlin): Enable --all-features (currently this breaks the rendering in the tests because of the `unity` feature)
run: cargo test

- name: Run doc-tests
# TODO(lucasmerlin): Enable --all-features (currently this breaks the rendering in the tests because of the `unity` feature)
run: cargo test --doc

- name: Upload artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
path: "**/tests/snapshots"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
**/target
**/target_ra
**/target_wasm
**/tests/snapshots/**/*.diff.png
**/tests/snapshots/**/*.new.png
/.*.json
/.vscode
/media/*
Expand Down
3 changes: 3 additions & 0 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ This contains a bunch of uses of `egui` and looks like the ui code you would wri
Thin wrapper around `egui_demo_lib` so we can compile it to a web site or a native app executable.
Depends on `egui_demo_lib` + `eframe`.

### `egui_kittest`
A test harness for egui based on [kittest](https://github.com/rerun/kittest) and [AccessKit](https://github.com/AccessKit/accesskit/).

### Other integrations

There are also many great integrations for game engines such as `bevy` and `miniquad` which you can find at <https://github.com/emilk/egui#integrations>.
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ For small things, just go ahead an open a PR. For bigger things, please file an
Browse through [`ARCHITECTURE.md`](ARCHITECTURE.md) to get a sense of how all pieces connects.

You can test your code locally by running `./scripts/check.sh`.
There are snapshots test that might need to be updated. Run the tests with `UPDATE_SNAPSHOTS=true` to update them.
For more info about the tests see [egui_kittest](./crates/egui_kittest/README.md).

We use [git-lfs](https://git-lfs.com/) to store big files in the repository.
Make sure you have it installed (running `git lfs ls-files` from the repository root should list some files).
Don't forget to run `git lfs install` after installing the git-lfs binary.

If you see an `InvalidSignature` error when running snapshot tests, it's probably a problem related to git-lfs.

When you have something that works, open a draft PR. You may get some helpful feedback early!
When you feel the PR is ready to go, do a self-review of the code, and then open it for review.
Expand Down
77 changes: 74 additions & 3 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,12 @@ version = "1.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"

[[package]]
name = "byteorder-lite"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495"

[[package]]
name = "bytes"
version = "1.5.0"
Expand Down Expand Up @@ -818,6 +824,16 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"

[[package]]
name = "colored"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8"
dependencies = [
"lazy_static",
"windows-sys 0.48.0",
]

[[package]]
name = "com"
version = "0.6.0"
Expand Down Expand Up @@ -1097,6 +1113,19 @@ dependencies = [
"syn 1.0.109",
]

[[package]]
name = "dify"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11217d469eafa3b809ad84651eb9797ccbb440b4a916d5d85cb1b994e89787f6"
dependencies = [
"anyhow",
"colored",
"getopts",
"image",
"rayon",
]

[[package]]
name = "digest"
version = "0.10.7"
Expand Down Expand Up @@ -1305,9 +1334,12 @@ dependencies = [
"criterion",
"document-features",
"egui",
"egui_demo_lib",
"egui_extras",
"egui_kittest",
"serde",
"unicode_names2",
"wgpu",
]

[[package]]
Expand Down Expand Up @@ -1349,6 +1381,20 @@ dependencies = [
"winit",
]

[[package]]
name = "egui_kittest"
version = "0.29.1"
dependencies = [
"dify",
"document-features",
"egui",
"egui-wgpu",
"image",
"kittest",
"pollster",
"wgpu",
]

[[package]]
name = "ehttp"
version = "0.5.0"
Expand Down Expand Up @@ -1768,6 +1814,15 @@ dependencies = [
"windows-targets 0.48.5",
]

[[package]]
name = "getopts"
version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5"
dependencies = [
"unicode-width",
]

[[package]]
name = "getrandom"
version = "0.2.10"
Expand Down Expand Up @@ -2131,12 +2186,12 @@ dependencies = [

[[package]]
name = "image"
version = "0.25.0"
version = "0.25.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9b4f005360d32e9325029b38ba47ebd7a56f3316df09249368939562d518645"
checksum = "99314c8a2152b8ddb211f924cdae532d8c5e4c8bb54728e12fff1b0cd5963a10"
dependencies = [
"bytemuck",
"byteorder",
"byteorder-lite",
"color_quant",
"gif",
"num-traits",
Expand Down Expand Up @@ -2291,6 +2346,16 @@ version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"

[[package]]
name = "kittest"
version = "0.1.0"
source = "git+https://github.com/rerun-io/kittest?branch=main#1336a504aefd05f7e9aa7c9237ae44ba9e72acdd"
dependencies = [
"accesskit",
"accesskit_consumer",
"parking_lot",
]

[[package]]
name = "kurbo"
version = "0.9.5"
Expand All @@ -2300,6 +2365,12 @@ dependencies = [
"arrayvec",
]

[[package]]
name = "lazy_static"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"

[[package]]
name = "libc"
version = "0.2.155"
Expand Down
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ members = [
"crates/egui_demo_lib",
"crates/egui_extras",
"crates/egui_glow",
"crates/egui_kittest",
"crates/egui-wgpu",
"crates/egui-winit",
"crates/egui",
Expand Down Expand Up @@ -64,6 +65,7 @@ egui_extras = { version = "0.29.1", path = "crates/egui_extras", default-feature
egui-wgpu = { version = "0.29.1", path = "crates/egui-wgpu", default-features = false }
egui_demo_lib = { version = "0.29.1", path = "crates/egui_demo_lib", default-features = false }
egui_glow = { version = "0.29.1", path = "crates/egui_glow", default-features = false }
egui_kittest = { version = "0.29.1", path = "crates/egui_kittest", default-features = false }
eframe = { version = "0.29.1", path = "crates/eframe", default-features = false }

ahash = { version = "0.8.11", default-features = false, features = [
Expand All @@ -73,15 +75,18 @@ ahash = { version = "0.8.11", default-features = false, features = [
backtrace = "0.3"
bytemuck = "1.7.2"
criterion = { version = "0.5.1", default-features = false }
dify = { version = "0.7", default-features = false }
document-features = " 0.2.8"
glow = "0.14"
glutin = "0.32.0"
glutin-winit = "0.5.0"
home = "0.5.9"
image = { version = "0.25", default-features = false }
kittest = { git = "https://github.com/rerun-io/kittest", version = "0.1", branch = "main"}
log = { version = "0.4", features = ["std"] }
nohash-hasher = "0.2"
parking_lot = "0.12"
pollster = "0.3"
profiling = {version = "1.0", default-features = false }
puffin = "0.19"
puffin_http = "0.16"
Expand Down
16 changes: 9 additions & 7 deletions crates/ecolor/src/color32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,17 @@ impl Color32 {
// common-case optimization
255 => Self::from_rgb(r, g, b),
a => {
static LOOKUP_TABLE: OnceLock<[u8; 256 * 256]> = OnceLock::new();
static LOOKUP_TABLE: OnceLock<Box<[u8]>> = OnceLock::new();
let lut = LOOKUP_TABLE.get_or_init(|| {
use crate::{gamma_u8_from_linear_f32, linear_f32_from_gamma_u8};
core::array::from_fn(|i| {
let [value, alpha] = (i as u16).to_ne_bytes();
let value_lin = linear_f32_from_gamma_u8(value);
let alpha_lin = linear_f32_from_linear_u8(alpha);
gamma_u8_from_linear_f32(value_lin * alpha_lin)
})
(0..=u16::MAX)
.map(|i| {
let [value, alpha] = i.to_ne_bytes();
let value_lin = linear_f32_from_gamma_u8(value);
let alpha_lin = linear_f32_from_linear_u8(alpha);
gamma_u8_from_linear_f32(value_lin * alpha_lin)
})
.collect()
});

let [r, g, b] =
Expand Down
9 changes: 8 additions & 1 deletion crates/egui-winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,14 @@ use winit::{
};

pub fn screen_size_in_pixels(window: &Window) -> egui::Vec2 {
let size = window.inner_size();
let size = if cfg!(target_os = "ios") {
// `outer_size` Includes the area behind the "dynamic island".
// It is up to the eframe user to make sure the dynamic island doesn't cover anything important.
// That will be easier once https://github.com/rust-windowing/winit/pull/3890 lands
window.outer_size()
} else {
window.inner_size()
};
egui::vec2(size.width as f32, size.height as f32)
}

Expand Down
Loading

0 comments on commit b7dbd7a

Please sign in to comment.