Compare commits

..
Author SHA1 Message Date
Dennis Kobert 9de7e39431 Add implementations to node registry 2025-09-23 10:27:03 +02:00
Dennis Kobert 198a352280 Implement conversion to gpu for different renderable types 2025-09-20 12:54:30 +02:00
Dennis Kobert 6843e3db89 Only rasterize data within bounds 2025-09-20 11:28:02 +02:00
Dennis Kobert 547cbee448 Fix transform 2025-09-19 21:06:46 +02:00
Dennis Kobert 9795704dce Make texture size not 1x1 2025-09-19 20:52:04 +02:00
Dennis Kobert cc33aa6427 Prototype vector to raster conversion 2025-09-19 12:19:46 +02:00
Dennis Kobert 90fd674627 Improve perf by initializing protonodes as non value 2025-09-18 22:07:34 +02:00
Dennis Kobert 09017cdc6a Cleanup 2025-09-18 22:07:33 +02:00
Dennis Kobert 683720a1ad Remove redundant stable id generation 2025-09-18 22:07:33 +02:00
Dennis Kobert c3589b6c89 Fix compilation for compile benchmarks 2025-09-18 22:07:32 +02:00
Dennis Kobert 35f4e0c43f Integrate type checking into context dependency analysis 2025-09-18 22:07:18 +02:00
Timon Schelling fd41c925e6 Download wgpu textures aligned 2025-09-18 15:45:22 +00:00
Dennis Kobert adc1ec774a Cleanup texture upload / download 2025-09-18 13:50:32 +02:00
Dennis Kobert d4cb09d144 Add footprint to convert trait 2025-09-18 13:04:47 +02:00
Dennis Kobert 431aa27a66 Add gpu texture download implementation 2025-09-18 12:56:49 +02:00
Dennis Kobert e3ef519908 Make convert trait use explicit converter 2025-09-18 12:56:49 +02:00
Dennis Kobert eb86348ed0 Add upload texture trait 2025-09-18 12:56:48 +02:00
276 changed files with 5079 additions and 9585 deletions

No files matched your search

-3
View File
@@ -10,6 +10,3 @@ rustflags = [
"link-arg=--max-memory=4294967296",
"--cfg=web_sys_unstable_apis",
]
[env]
CARGO_WORKSPACE_DIR = { value = "", relative = true }
@@ -1,11 +1,7 @@
name: Profiling Changes
on:
pull_request:
paths:
- 'node-graph/**'
- 'Cargo.toml'
- 'Cargo.lock'
pull_request: {}
env:
CARGO_TERM_COLOR: always
@@ -54,23 +50,14 @@ jobs:
id: master-sha
run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Get CPU info
id: cpu-info
run: |
# Get CPU model and create a short hash for cache key
CPU_MODEL=$(cat /proc/cpuinfo | grep "model name" | head -1 | cut -d: -f2 | xargs)
CPU_HASH=$(echo "$CPU_MODEL" | sha256sum | cut -c1-8)
echo "cpu-hash=$CPU_HASH" >> $GITHUB_OUTPUT
echo "CPU: $CPU_MODEL (hash: $CPU_HASH)"
- name: Cache benchmark baselines
id: cache-benchmark-baselines
uses: actions/cache@v4
with:
path: target/iai
key: ${{ runner.os }}-${{ runner.arch }}-${{ steps.cpu-info.outputs.cpu-hash }}-benchmark-baselines-master-${{ steps.master-sha.outputs.sha }}
key: ${{ runner.os }}-benchmark-baselines-master-${{ steps.master-sha.outputs.sha }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-${{ steps.cpu-info.outputs.cpu-hash }}-benchmark-baselines-master-
${{ runner.os }}-benchmark-baselines-master-
- name: Run baseline benchmarks
if: steps.cache-benchmark-baselines.outputs.cache-hit != 'true'
@@ -98,8 +85,6 @@ jobs:
cargo bench --bench run_cached_iai -- --baseline=master --output-format=json | jq -sc | sed 's/\\"//g' > /tmp/run_cached_output.json
- name: Make old comments collapsed by default
# Only run if we have write permissions (not a fork)
if: github.event.pull_request.head.repo.full_name == github.repository
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
@@ -124,67 +109,7 @@ jobs:
});
}
- name: Analyze profiling changes
id: analyze
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
function isSignificantChange(diffPct, absoluteChange, benchmarkType) {
const meetsPercentageThreshold = Math.abs(diffPct) > 5;
const meetsAbsoluteThreshold = absoluteChange > 200000;
const isCachedExecution = benchmarkType === 'run_cached' ||
benchmarkType.includes('Cached Execution');
return isCachedExecution
? (meetsPercentageThreshold && meetsAbsoluteThreshold)
: meetsPercentageThreshold;
}
const allOutputs = [
JSON.parse(fs.readFileSync('/tmp/compile_output.json', 'utf8')),
JSON.parse(fs.readFileSync('/tmp/update_output.json', 'utf8')),
JSON.parse(fs.readFileSync('/tmp/run_once_output.json', 'utf8')),
JSON.parse(fs.readFileSync('/tmp/run_cached_output.json', 'utf8'))
];
const outputNames = ['compile', 'update', 'run_once', 'run_cached'];
const sectionTitles = ['Compilation', 'Update', 'Run Once', 'Cached Execution'];
let hasSignificantChanges = false;
let regressionDetails = [];
for (let i = 0; i < allOutputs.length; i++) {
const benchmarkOutput = allOutputs[i];
const outputName = outputNames[i];
const sectionTitle = sectionTitles[i];
for (const benchmark of benchmarkOutput) {
if (benchmark.profiles?.[0]?.summaries?.parts?.[0]?.metrics_summary?.Callgrind?.Ir?.diffs?.diff_pct) {
const diffPct = parseFloat(benchmark.profiles[0].summaries.parts[0].metrics_summary.Callgrind.Ir.diffs.diff_pct);
const oldValue = benchmark.profiles[0].summaries.parts[0].metrics_summary.Callgrind.Ir.metrics.Both[1].Int;
const newValue = benchmark.profiles[0].summaries.parts[0].metrics_summary.Callgrind.Ir.metrics.Both[0].Int;
const absoluteChange = Math.abs(newValue - oldValue);
if (isSignificantChange(diffPct, absoluteChange, outputName)) {
hasSignificantChanges = true;
regressionDetails.push({
module_path: benchmark.module_path,
id: benchmark.id,
diffPct,
absoluteChange,
sectionTitle
});
}
}
}
}
core.setOutput('has-significant-changes', hasSignificantChanges);
core.setOutput('regression-details', JSON.stringify(regressionDetails));
- name: Comment PR
if: github.event.pull_request.head.repo.full_name == github.repository
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
@@ -196,7 +121,7 @@ jobs:
const runOnceOutput = JSON.parse(fs.readFileSync('/tmp/run_once_output.json', 'utf8'));
const runCachedOutput = JSON.parse(fs.readFileSync('/tmp/run_cached_output.json', 'utf8'));
const hasSignificantChanges = '${{ steps.analyze.outputs.has-significant-changes }}' === 'true';
let significantChanges = false;
let commentBody = "";
function formatNumber(num) {
@@ -220,17 +145,6 @@ jobs:
let sectionBody = "";
let hasResults = false;
let hasSignificantChanges = false;
function isSignificantChange(diffPct, absoluteChange, benchmarkType) {
const meetsPercentageThreshold = Math.abs(diffPct) > 5;
const meetsAbsoluteThreshold = absoluteChange > 200000;
const isCachedExecution = benchmarkType === 'run_cached' ||
benchmarkType.includes('Cached Execution');
return isCachedExecution
? (meetsPercentageThreshold && meetsAbsoluteThreshold)
: meetsPercentageThreshold;
}
for (const benchmark of benchmarkOutput) {
if (benchmark.profiles && benchmark.profiles.length > 0) {
@@ -267,8 +181,8 @@ jobs:
}
sectionBody += "```\n</details>\n\n";
if (isSignificantChange(irDiff.diff_pct, Math.abs(irDiff.new - irDiff.old), sectionTitle)) {
if (Math.abs(irDiff.diff_pct) > 5) {
significantChanges = true;
hasSignificantChanges = true;
}
@@ -318,7 +232,7 @@ jobs:
if (commentBody.length > 0) {
const output = `<details open>\n<summary>Performance Benchmark Results</summary>\n\n${commentBody}\n</details>`;
if (hasSignificantChanges) {
if (significantChanges) {
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
@@ -332,13 +246,3 @@ jobs:
} else {
console.log("No benchmark results to display.");
}
- name: Fail on significant regressions
if: steps.analyze.outputs.has-significant-changes == 'true'
uses: actions/github-script@v7
with:
script: |
const regressionDetails = JSON.parse('${{ steps.analyze.outputs.regression-details }}');
const firstRegression = regressionDetails[0];
core.setFailed(`Significant performance regression detected: ${firstRegression.module_path} ${firstRegression.id} increased by ${firstRegression.absoluteChange.toLocaleString()} instructions (${firstRegression.diffPct.toFixed(2)}%)`);
+1 -10
View File
@@ -26,14 +26,6 @@ jobs:
- name: 📥 Clone and checkout repository
uses: actions/checkout@v3
# We can remove this step once `ubuntu-latest` has Node.js 22 or newer for its native TypeScript support. See:
# https://github.com/actions/runner-images?tab=readme-ov-file#available-images
# https://nodejs.org/en/learn/typescript/run-natively
- name: 📦 Install the latest Node.js
uses: actions/setup-node@v4
with:
node-version: "latest"
- name: 🕸 Install Zola
uses: taiki-e/install-action@v2
with:
@@ -85,8 +77,7 @@ jobs:
MODE: prod
run: |
cd website
npm ci
npm run lint
npm run install-fonts
zola --config config.toml build --minify
- name: 📤 Publish to Cloudflare Pages
-1
View File
@@ -1,5 +1,4 @@
target/
result/
*.spv
*.exrc
perf.data*
-26
View File
@@ -1,26 +0,0 @@
{ pkgs }:
let
libcef = pkgs.libcef.overrideAttrs (_: _: {
postInstall = ''
strip $out/lib/*
'';
});
cefPath = pkgs.runCommand "cef-path" {} ''
mkdir -p $out
ln -s ${libcef}/include $out/include
find ${libcef}/lib -type f -name "*" -exec ln -s {} $out/ \;
find ${libcef}/libexec -type f -name "*" -exec ln -s {} $out/ \;
cp -r ${libcef}/share/cef/* $out/
echo '${builtins.toJSON {
type = "minimal";
name = builtins.baseNameOf libcef.src.url;
sha1 = "";
}}' > $out/archive.json
'';
in
{
CEF_PATH = cefPath;
}
+6 -6
View File
@@ -34,11 +34,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1762363567,
"narHash": "sha256-YRqMDEtSMbitIMj+JLpheSz0pwEr0Rmy5mC7myl17xs=",
"lastModified": 1754214453,
"narHash": "sha256-Q/I2xJn/j1wpkGhWkQnm20nShYnG7TI99foDBpXm1SY=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "ae814fd3904b621d8ab97418f1d0f2eb0d3716f4",
"rev": "5b09dc45f24cf32316283e62aec81ffee3c3e376",
"type": "github"
},
"original": {
@@ -63,11 +63,11 @@
]
},
"locked": {
"lastModified": 1762569282,
"narHash": "sha256-vINZAJpXQTZd5cfh06Rcw7hesH7sGSvi+Tn+HUieJn8=",
"lastModified": 1753238793,
"narHash": "sha256-jmQeEpgX+++MEgrcikcwoSiI7vDZWLP0gci7XiWb9uQ=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "a35a6144b976f70827c2fe2f5c89d16d8f9179d8",
"rev": "0ad7ab4ca8e83febf147197e65c006dff60623ab",
"type": "github"
},
"original": {
+105 -98
View File
@@ -12,6 +12,8 @@
# - Development shell: `nix develop .nix` from the project root
# - Run in dev shell with direnv: add `use flake` to .envrc
{
description = "Development environment and build configuration";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
rust-overlay = {
@@ -28,7 +30,9 @@
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs { inherit system overlays; };
pkgs = import nixpkgs {
inherit system overlays;
};
rustExtensions = [ "rust-src" "rust-analyzer" "clippy" "cargo" ];
rust = pkgs.rust-bin.stable.latest.default.override {
@@ -36,124 +40,127 @@
extensions = rustExtensions;
};
# Shared build inputs; libraries that need to be in LD_LIBRARY_PATH
buildInputs = [
pkgs.wayland
pkgs.openssl
pkgs.vulkan-loader
pkgs.libraw
pkgs.libGL
rustGPUToolchainPkg = pkgs.rust-bin.nightly."2025-06-23".default.override {
extensions = rustExtensions ++ [ "rustc-dev" "llvm-tools" ];
};
rustGPUToolchainRustPlatform = pkgs.makeRustPlatform {
cargo = rustGPUToolchainPkg;
rustc = rustGPUToolchainPkg;
};
rustc_codegen_spirv = rustGPUToolchainRustPlatform.buildRustPackage (finalAttrs: {
pname = "rustc_codegen_spirv";
version = "0-unstable-2025-08-04";
src = pkgs.fetchFromGitHub {
owner = "Rust-GPU";
repo = "rust-gpu";
rev = "c12f216121820580731440ee79ebc7403d6ea04f";
hash = "sha256-rG1cZvOV0vYb1dETOzzbJ0asYdE039UZImobXZfKIno=";
};
cargoHash = "sha256-AEigcEc5wiBd3zLqWN/2HSbkfOVFneAqNvg9HsouZf4=";
cargoBuildFlags = [ "-p" "rustc_codegen_spirv" "--features=use-compiled-tools" "--no-default-features" ];
doCheck = false;
});
rustGpuCargo = pkgs.writeShellScriptBin "cargo" ''
#!${pkgs.lib.getExe pkgs.bash}
filtered_args=()
for arg in "$@"; do
case "$arg" in
+nightly|+nightly-*) ;;
*) filtered_args+=("$arg") ;;
esac
done
exec ${rustGPUToolchainPkg}/bin/cargo ${"\${filtered_args[@]}"}
'';
rustGpuPathOverride = "${rustGpuCargo}/bin:${rustGPUToolchainPkg}/bin";
libcef = pkgs.libcef.overrideAttrs (finalAttrs: previousAttrs: {
version = "139.0.17";
gitRevision = "6c347eb";
chromiumVersion = "139.0.7258.31";
srcHash = "sha256-kRMO8DP4El1qytDsAZBdHvR9AAHXce90nPdyfJailBg=";
__intentionallyOverridingVersion = true;
postInstall = ''
strip $out/lib/*
'';
});
libcefPath = pkgs.runCommand "libcef-path" {} ''
mkdir -p $out
ln -s ${libcef}/include $out/include
find ${libcef}/lib -type f -name "*" -exec ln -s {} $out/ \;
find ${libcef}/libexec -type f -name "*" -exec ln -s {} $out/ \;
cp -r ${libcef}/share/cef/* $out/
echo '${builtins.toJSON {
type = "minimal";
name = builtins.baseNameOf libcef.src.url;
sha1 = "";
}}' > $out/archive.json
'';
# Shared build inputs - system libraries that need to be in LD_LIBRARY_PATH
buildInputs = with pkgs; [
# System libraries
wayland
openssl
vulkan-loader
libraw
libGL
# X11 libraries, not needed on wayland! Remove when x11 is finally dead
pkgs.libxkbcommon
pkgs.xorg.libXcursor
pkgs.xorg.libxcb
pkgs.xorg.libX11
libxkbcommon
xorg.libXcursor
xorg.libxcb
xorg.libX11
];
# Packages needed to build the package
buildTools = [
# Development tools that don't need to be in LD_LIBRARY_PATH
buildTools = [
rust
pkgs.nodejs
pkgs.nodePackages.npm
pkgs.binaryen
pkgs.wasm-bindgen-cli_0_2_100
pkgs.wasm-bindgen-cli
pkgs.wasm-pack
pkgs.pkg-config
pkgs.cargo-about
];
# Development tools; not needed to build the package
devTools = [
pkgs.git
pkgs.cargo-watch
pkgs.cargo-nextest
pkgs.cargo-expand
pkgs.cargo-about
# Linker
pkgs.mold
];
# Development tools that don't need to be in LD_LIBRARY_PATH
devTools = with pkgs; [
cargo-watch
cargo-nextest
cargo-expand
# Profiling tools
pkgs.gnuplot
pkgs.samply
pkgs.cargo-flamegraph
gnuplot
samply
cargo-flamegraph
];
cefEnv = import ./cef.nix { inherit pkgs; };
rustGPUEnv = import ./rust-gpu.nix { inherit pkgs; };
libPath = "${pkgs.lib.makeLibraryPath buildInputs}:${cefEnv.CEF_PATH}";
in {
devShells.default = pkgs.mkShell ({
in
{
# Development shell configuration
devShells.default = pkgs.mkShell {
packages = buildInputs ++ buildTools ++ devTools;
LD_LIBRARY_PATH = libPath;
XDG_DATA_DIRS =
"${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}:${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}:$XDG_DATA_DIRS";
LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath buildInputs}:${libcefPath}";
CEF_PATH = libcefPath;
XDG_DATA_DIRS="${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}:${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}:$XDG_DATA_DIRS";
RUST_GPU_PATH_OVERRIDE = rustGpuPathOverride;
RUSTC_CODEGEN_SPIRV_PATH = "${rustc_codegen_spirv}/lib/librustc_codegen_spirv.so";
shellHook = ''
alias cargo='mold --run cargo'
'';
} // cefEnv // rustGPUEnv);
packages.default = pkgs.rustPlatform.buildRustPackage (finalAttrs: {
pname = "graphite-editor";
version = "unstable";
src = pkgs.lib.cleanSource ./..;
cargoLock = {
lockFile = ../Cargo.lock;
allowBuiltinFetchGit = true;
};
# TODO: Remove the need for this hash by using individual package resolutions and hashes from package-lock.json
npmDeps = pkgs.fetchNpmDeps {
inherit (finalAttrs) pname version;
src = "${finalAttrs.src}/frontend";
hash = "sha256-UWuJpKNYj2Xn34rpMDZ75pzMYUOLQjPeGuJ/QlPbX9A=";
};
npmRoot = "frontend";
npmConfigScript = "setup";
makeCacheWritable = true;
buildInputs = buildInputs;
nativeBuildInputs = buildTools ++ [
pkgs.rustPlatform.cargoSetupHook
pkgs.npmHooks.npmConfigHook
pkgs.makeWrapper
];
env = cefEnv // rustGPUEnv;
buildPhase = ''
export HOME="$TMPDIR"
pushd frontend
npm run build-native
popd
cargo build -r -p graphite-desktop
'';
installPhase = ''
mkdir -p $out/bin
cp target/release/graphite-desktop $out/bin/graphite-editor
mkdir -p $out/share/applications
cp $src/desktop/assets/*.desktop $out/share/applications/
mkdir -p $out/share/icons/hicolor/scalable/apps
cp $src/desktop/assets/graphite-icon-color.svg $out/share/icons/hicolor/scalable/apps/
'';
doCheck = false;
postFixup = ''
wrapProgram "$out/bin/graphite-editor" \
--prefix LD_LIBRARY_PATH : "${libPath}" \
--set CEF_PATH "${cefEnv.CEF_PATH}"
'';
});
});
};
}
);
}
-47
View File
@@ -1,47 +0,0 @@
{ pkgs }:
let
toolchainPkg = pkgs.rust-bin.nightly."2025-06-23".default.override {
extensions =
[ "rust-src" "rust-analyzer" "clippy" "cargo" "rustc-dev" "llvm-tools" ];
};
toolchainRustPlatform = pkgs.makeRustPlatform {
cargo = toolchainPkg;
rustc = toolchainPkg;
};
rustc_codegen_spirv = toolchainRustPlatform.buildRustPackage (finalAttrs: {
pname = "rustc_codegen_spirv";
version = "0-unstable-2025-08-04";
src = pkgs.fetchFromGitHub {
owner = "Firestar99";
repo = "rust-gpu-new";
rev = "c12f216121820580731440ee79ebc7403d6ea04f";
hash = "sha256-rG1cZvOV0vYb1dETOzzbJ0asYdE039UZImobXZfKIno=";
};
cargoHash = "sha256-AEigcEc5wiBd3zLqWN/2HSbkfOVFneAqNvg9HsouZf4=";
cargoBuildFlags = [
"-p"
"rustc_codegen_spirv"
"--features=use-compiled-tools"
"--no-default-features"
];
doCheck = false;
});
cargoWrapper = pkgs.writeShellScriptBin "cargo" ''
#!${pkgs.lib.getExe pkgs.bash}
filtered_args=()
for arg in "$@"; do
case "$arg" in
+nightly|+nightly-*) ;;
*) filtered_args+=("$arg") ;;
esac
done
exec ${toolchainPkg}/bin/cargo ${"\${filtered_args[@]}"}
'';
in {
RUST_GPU_PATH_OVERRIDE = "${cargoWrapper}/bin:${toolchainPkg}/bin";
RUSTC_CODEGEN_SPIRV_PATH =
"${rustc_codegen_spirv}/lib/librustc_codegen_spirv.so";
}
Generated
+181 -400
View File
File diff suppressed because it is too large. Load diff
+13 -19
View File
@@ -3,10 +3,6 @@ members = [
"desktop",
"desktop/wrapper",
"desktop/embedded-resources",
"desktop/bundle",
"desktop/platform/linux",
"desktop/platform/mac",
"desktop/platform/win",
"editor",
"frontend/wasm",
"libraries/dyn-any",
@@ -32,6 +28,8 @@ members = [
"proc-macros",
]
default-members = [
"desktop",
"desktop/wrapper",
"editor",
"frontend/wasm",
"libraries/dyn-any",
@@ -106,7 +104,7 @@ quote = "1.0"
chrono = "0.4"
ron = "0.11"
fastnoise-lite = "1.1"
wgpu = { version = "27.0", features = [
wgpu = { version = "25.0", features = [
# We don't have wgpu on multiple threads (yet) https://github.com/gfx-rs/wgpu/blob/trunk/CHANGELOG.md#wgpu-types-now-send-sync-on-wasm
"fragile-send-sync-non-atomic-wasm",
"spirv",
@@ -134,12 +132,11 @@ web-sys = { version = "=0.3.77", features = [
"HtmlImageElement",
"ImageBitmapRenderingContext",
] }
winit = { git = "https://github.com/rust-windowing/winit.git" }
keyboard-types = "0.8"
winit = { git = "https://github.com/rust-windowing/winit.git", rev = "66283a79bddd034c45fb0e72c84fa5cd4e5f82fb" }
url = "2.5"
tokio = { version = "1.29", features = ["fs", "macros", "io-std", "rt"] }
vello = { git = "https://github.com/linebender/vello" }
vello_encoding = { git = "https://github.com/linebender/vello" }
vello = { git = "https://github.com/linebender/vello.git", rev = "87cc5bee6d3a34d15017dbbb58634ddc7f33ff9b" } # TODO switch back to stable when a release is made
vello_encoding = { git = "https://github.com/linebender/vello.git", rev = "87cc5bee6d3a34d15017dbbb58634ddc7f33ff9b" } # TODO switch back to stable when a release is made
resvg = "0.45"
usvg = "0.45"
rand = { version = "0.9", default-features = false, features = ["std_rng"] }
@@ -178,7 +175,7 @@ syn = { version = "2.0", default-features = false, features = [
"extra-traits",
"proc-macro",
] }
kurbo = { version = "0.12", features = ["serde"] }
kurbo = { version = "0.11", features = ["serde"] }
lyon_geom = "1.0"
petgraph = { version = "0.7", default-features = false, features = ["graphmap"] }
half = { version = "2.4", default-features = false, features = ["bytemuck"] }
@@ -188,18 +185,18 @@ iai-callgrind = { version = "0.16" }
ndarray = "0.16"
strum = { version = "0.27", features = ["derive"] }
dirs = "6.0"
cef = { version = "141", features = ["accelerated_osr"] }
cef-dll-sys = "141"
cef = "=139.0.1"
cef-dll-sys = "=139.0.1"
include_dir = "0.7"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
tracing = "0.1"
rfd = "0.15"
open = "5.3"
polycool = "0.4"
poly-cool = "0.3"
spin = "0.10"
clap = "4.5"
spirv-std = { git = "https://github.com/Firestar99/rust-gpu-new", rev = "c12f216121820580731440ee79ebc7403d6ea04f", features = ["bytemuck"] }
cargo-gpu = { git = "https://github.com/Firestar99/cargo-gpu", rev = "3952a22d16edbd38689f3a876e417899f21e1fe7", default-features = false }
spirv-std = { git = "https://github.com/rust-gpu/rust-gpu", rev = "c12f216121820580731440ee79ebc7403d6ea04f", features = ["bytemuck"] }
cargo-gpu = { git = "https://github.com/rust-gpu/cargo-gpu", rev = "f969528e87baa17a7d48eecf4a6fcfdcaaf30566" }
[workspace.lints.rust]
unexpected_cfgs = { level = "allow", check-cfg = ['cfg(target_arch, values("spirv"))'] }
@@ -210,6 +207,7 @@ opt-level = 1
[profile.dev.package]
graphite-editor = { opt-level = 1 }
graphene-core-shaders = { opt-level = 1 }
graphene-core = { opt-level = 1 }
graphene-std = { opt-level = 1 }
interpreted-executor = { opt-level = 1 } # This is a mitigation for https://github.com/rustwasm/wasm-pack/issues/981 which is needed because the node_registry function is too large
graphite-proc-macros = { opt-level = 1 }
@@ -226,7 +224,3 @@ debug = true
[profile.profiling]
inherits = "release"
debug = true
[patch.crates-io]
# Force cargo to use only one version of the dpi crate (vendoring breaks without this)
dpi = { git = "https://github.com/rust-windowing/winit.git" }
+1 -1
View File
@@ -1 +1 @@
{"network_interface":{"network":{"exports":[{"Node":{"node_id":3143874172491239000,"output_index":0}}],"nodes":[[10316247453530667000,{"inputs":[{"Node":{"node_id":9079109751490757000,"output_index":0}},{"Node":{"node_id":1250460246919467000,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":4,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::ToGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::ExtendNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3,{"inputs":[{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[2,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::SourceNodeIdNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::WrapGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":false,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[7954638344846060000,{"inputs":[{"Node":{"node_id":5991296268862790000,"output_index":0}},{"Value":{"tagged_value":{"Fill":{"Solid":{"red":0.1875,"green":0.0,"blue":0.0,"alpha":0.203125}}},"exposed":false}},{"Value":{"tagged_value":{"Color":{"element":[{"red":0.19140625,"green":0.0,"blue":0.0,"alpha":0.203125}],"transform":[[1.0,0.0,0.0,1.0,0.0,0.0]],"alpha_blending":[{"blend_mode":"Normal","opacity":1.0,"fill":1.0,"clip":false}],"source_node_id":[null]}},"exposed":false}},{"Value":{"tagged_value":{"Gradient":{"stops":[[0.0,{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0}],[1.0,{"red":1.0,"green":1.0,"blue":1.0,"alpha":1.0}]],"gradient_type":"Linear","start":[0.0,0.5],"end":[1.0,0.5]}},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::vector::FillNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[17021405646895729000,{"inputs":[{"Value":{"tagged_value":"None","exposed":false}},{"Value":{"tagged_value":{"GradientStops":[[0.0,{"red":1.0,"green":0.31764707,"blue":0.15686275,"alpha":1.0}],[0.5,{"red":1.0,"green":0.5686275,"blue":0.25490198,"alpha":1.0}],[1.0,{"red":1.0,"green":0.7294118,"blue":0.16078432,"alpha":1.0}]]},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphene_math_nodes::GradientValueNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[8366826746721323000,{"inputs":[{"Node":{"node_id":5591755359500854000,"output_index":0}},{"Node":{"node_id":13846904447064916285,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":4,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::ToGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::ExtendNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3,{"inputs":[{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"imLine truncated
{"network_interface":{"network":{"exports":[{"Node":{"node_id":3143874172491239000,"output_index":0}}],"nodes":[[10316247453530667000,{"inputs":[{"Node":{"node_id":9079109751490757000,"output_index":0}},{"Node":{"node_id":1250460246919467000,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":4,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::ToGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::ExtendNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3,{"inputs":[{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[2,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::SourceNodeIdNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::WrapGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":false,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[7954638344846060000,{"inputs":[{"Node":{"node_id":5991296268862790000,"output_index":0}},{"Value":{"tagged_value":{"Fill":{"Solid":{"red":0.1875,"green":0.0,"blue":0.0,"alpha":0.203125}}},"exposed":false}},{"Value":{"tagged_value":{"Color":{"element":[{"red":0.19140625,"green":0.0,"blue":0.0,"alpha":0.203125}],"transform":[[1.0,0.0,0.0,1.0,0.0,0.0]],"alpha_blending":[{"blend_mode":"Normal","opacity":1.0,"fill":1.0,"clip":false}],"source_node_id":[null]}},"exposed":false}},{"Value":{"tagged_value":{"Gradient":{"stops":[[0.0,{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0}],[1.0,{"red":1.0,"green":1.0,"blue":1.0,"alpha":1.0}]],"gradient_type":"Linear","start":[0.0,0.5],"end":[1.0,0.5]}},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::vector::FillNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[17021405646895729000,{"inputs":[{"Value":{"tagged_value":"None","exposed":false}},{"Value":{"tagged_value":{"GradientStops":[[0.0,{"red":1.0,"green":0.31764707,"blue":0.15686275,"alpha":1.0}],[0.5,{"red":1.0,"green":0.5686275,"blue":0.25490198,"alpha":1.0}],[1.0,{"red":1.0,"green":0.7294118,"blue":0.16078432,"alpha":1.0}]]},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphene_math_nodes::GradientValueNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[8366826746721323000,{"inputs":[{"Node":{"node_id":5591755359500854000,"output_index":0}},{"Node":{"node_id":13846904447064916285,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":4,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::ToGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::ExtendNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3,{"inputs":[{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"imLine truncated
+1 -1
View File
@@ -1 +1 @@
{"network_interface":{"network":{"exports":[{"Node":{"node_id":15709488322180832347,"output_index":0}}],"nodes":[[10507084483235320484,{"inputs":[{"Node":{"node_id":9157963288496356916,"output_index":0}},{"Node":{"node_id":1396768435017101055,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":4,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::ToGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::ExtendNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3,{"inputs":[{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[2,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::SourceNodeIdNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::WrapGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4741515246389989284,{"inputs":[{"Node":{"node_id":14255588039347536657,"output_index":0}},{"Value":{"tagged_value":{"DVec2":[-261.2435565297001,-70.0]},"exposed":false}},{"Value":{"tagged_value":{"F64":0.0},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[1.0,1.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":1,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Import":{"import_type":{"Concrete":{"name":"glam::f64::dvec2::DVec2","alias":null}},"import_index":1}},{"Import":{"import_type":{"Concrete":{"name":"f64","alias":null}},"import_index":2}},{"Import":{"import_type":{"Concrete":{"name":"glam::f64::dvec2::DVec2","alias":null}},"import_index":3}},{"Import":{"import_type":{"Concrete":{"name":"glam::f64::dvec2::DVec2","alias":null}},"import_index":4}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::transform_nodes::TransformNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4105329493214975815,{"inputs":[{"Node":{"node_id":12931264630175648107,"output_index":0}},{"Value":{"tagged_value":{"DVec2":[-261.24355652969916,-70.0]},"exposed":false}},{"Value":{"tagged_value":{"F64":0.0},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[1.0,1.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":1,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Import":{"import_type":{"Line truncated
{"network_interface":{"network":{"exports":[{"Node":{"node_id":15709488322180832347,"output_index":0}}],"nodes":[[10507084483235320484,{"inputs":[{"Node":{"node_id":9157963288496356916,"output_index":0}},{"Node":{"node_id":1396768435017101055,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":4,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::ToGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::ExtendNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3,{"inputs":[{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[2,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::SourceNodeIdNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::WrapGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4741515246389989284,{"inputs":[{"Node":{"node_id":14255588039347536657,"output_index":0}},{"Value":{"tagged_value":{"DVec2":[-261.2435565297001,-70.0]},"exposed":false}},{"Value":{"tagged_value":{"F64":0.0},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[1.0,1.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":1,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Import":{"import_type":{"Concrete":{"name":"glam::f64::dvec2::DVec2","alias":null}},"import_index":1}},{"Import":{"import_type":{"Concrete":{"name":"f64","alias":null}},"import_index":2}},{"Import":{"import_type":{"Concrete":{"name":"glam::f64::dvec2::DVec2","alias":null}},"import_index":3}},{"Import":{"import_type":{"Concrete":{"name":"glam::f64::dvec2::DVec2","alias":null}},"import_index":4}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::transform_nodes::TransformNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4105329493214975815,{"inputs":[{"Node":{"node_id":12931264630175648107,"output_index":0}},{"Value":{"tagged_value":{"DVec2":[-261.24355652969916,-70.0]},"exposed":false}},{"Value":{"tagged_value":{"F64":0.0},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[1.0,1.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":1,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Import":{"import_type":{"Line truncated
+1 -1
View File
@@ -1 +1 @@
{"network_interface":{"network":{"exports":[{"Node":{"node_id":12241147352993594415,"output_index":0}}],"nodes":[[4388711862172196665,{"inputs":[],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphene_raster_nodes::std_nodes::MandelbrotNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"FOOTPRINT","inject":""}}],[3606681156406984991,{"inputs":[{"Node":{"node_id":6323350524796370485,"output_index":0}},{"Value":{"tagged_value":{"GradientStops":[[0.0,{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0}],[0.3237704918032787,{"red":0.23828125,"green":0.0,"blue":0.08377075,"alpha":1.0}],[0.5655737704918032,{"red":0.92578125,"green":0.8676921,"blue":0.5569153,"alpha":1.0}],[0.8155737704918032,{"red":0.17333984,"green":0.625,"blue":0.625,"alpha":1.0}],[1.0,{"red":0.106292725,"green":0.3359375,"blue":0.3359375,"alpha":1.0}]]},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_raster_nodes::gradient_map::GradientMapNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[6029481207635803402,{"inputs":[{"Node":{"node_id":4388711862172196665,"output_index":0}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"F64":0.0},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[1000.0,1000.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":1,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Import":{"import_type":{"Concrete":{"name":"glam::f64::dvec2::DVec2","alias":null}},"import_index":1}},{"Import":{"import_type":{"Concrete":{"name":"f64","alias":null}},"import_index":2}},{"Import":{"import_type":{"Concrete":{"name":"glam::f64::dvec2::DVec2","alias":null}},"import_index":3}},{"Import":{"import_type":{"Concrete":{"name":"glam::f64::dvec2::DVec2","alias":null}},"import_index":4}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::transform_nodes::TransformNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[7624113397561636853,{"inputs":[{"Value":{"tagged_value":{"Graphic":{"element":[],"transform":[],"alpha_blending":[],"source_node_id":[]}},"exposed":true}},{"Node":{"node_id":3606681156406984991,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":4,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::ToGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::ExtendNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3,{"inputs":[{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[2,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::SourceNodeIdNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProLine truncated
{"network_interface":{"network":{"exports":[{"Node":{"node_id":12241147352993594415,"output_index":0}}],"nodes":[[4388711862172196665,{"inputs":[],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphene_raster_nodes::std_nodes::MandelbrotNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"FOOTPRINT","inject":""}}],[3606681156406984991,{"inputs":[{"Node":{"node_id":6323350524796370485,"output_index":0}},{"Value":{"tagged_value":{"GradientStops":[[0.3237704918032787,{"red":1.0,"green":0.0,"blue":1.0,"alpha":0.1}],[0.5655737704918032,{"red":0.8901961,"green":0.8117647,"blue":0.39215687,"alpha":1.0}],[0.8155737704918032,{"red":0.0,"green":1.0,"blue":1.0,"alpha":0.5}]]},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_raster_nodes::gradient_map::GradientMapNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[6029481207635803402,{"inputs":[{"Node":{"node_id":4388711862172196665,"output_index":0}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"F64":0.0},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[1000.0,1000.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":1,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Import":{"import_type":{"Concrete":{"name":"glam::f64::dvec2::DVec2","alias":null}},"import_index":1}},{"Import":{"import_type":{"Concrete":{"name":"f64","alias":null}},"import_index":2}},{"Import":{"import_type":{"Concrete":{"name":"glam::f64::dvec2::DVec2","alias":null}},"import_index":3}},{"Import":{"import_type":{"Concrete":{"name":"glam::f64::dvec2::DVec2","alias":null}},"import_index":4}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::transform_nodes::TransformNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[7624113397561636853,{"inputs":[{"Value":{"tagged_value":{"Graphic":{"element":[],"transform":[],"alpha_blending":[],"source_node_id":[]}},"exposed":true}},{"Node":{"node_id":3606681156406984991,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":4,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::ToGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::ExtendNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3,{"inputs":[{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[2,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::SourceNodeIdNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::WrapGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],Line truncated
+1 -1
View File
@@ -1 +1 @@
{"network_interface":{"network":{"exports":[{"Node":{"node_id":392274448837115448,"output_index":0}}],"nodes":[[13353438235848911576,{"inputs":[{"Value":{"tagged_value":{"Vector":{"element":[{"style":{"stroke":{"color":{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0},"weight":0.0,"dash_lengths":[],"dash_offset":0.0,"cap":"Butt","join":"Miter","join_miter_limit":4.0,"align":"Center","transform":[1.0,0.0,0.0,1.0,0.0,0.0],"non_scaling":false,"paint_order":"StrokeAbove"},"fill":"None"},"colinear_manipulators":[],"point_domain":{"id":[],"position":[]},"segment_domain":{"id":[],"start_point":[],"end_point":[],"handles":[],"stroke":[]},"region_domain":{"id":[],"segment_range":[],"fill":[]},"upstream_nested_layers":null}],"transform":[[1.0,0.0,0.0,1.0,0.0,0.0]],"alpha_blending":[{"blend_mode":"Normal","opacity":1.0,"fill":1.0,"clip":false}],"source_node_id":[null]}},"exposed":true}},{"Value":{"tagged_value":{"VectorModification":{"points":{"add":[6379137305818664393,18442321214082298093,18118267825025549699,6351696498298648253,17863574903157697896,4691860614575868200,301778328144628917,10625296323957562985,533731991408535384,13357220652574593654,15992617814592812350],"remove":[],"delta":[[533731991408535384,[501.6296296296296,175.40740740740742]],[17863574903157697896,[606.8148151308641,95.19407372365433]],[18118267825025549699,[642.0740740740741,0.0]],[18442321214082298093,[565.6296296296297,122.96296296296298]],[15992617814592812350,[621.0370370370368,0.0]],[13357220652574593654,[574.2222222222222,108.44444444444449]],[301778328144628917,[493.5149940383244,200.29629629629628]],[10625296323957562985,[473.4814814814815,272.5925925925926]],[4691860614575868200,[528.2962962962963,283.8518518518518]],[6351696498298648253,[646.8148148148149,0.0]],[6379137305818664393,[625.4814814814813,0.0]]]},"segments":{"add":[13662059715350867364,3384102572540409881,12035095010819582754,10146665273368938971,318560030360358929,8462655819889292900,3303411878775644985,8661113083384527971,2035327810332855521,11346538709718766144,3710133387837274291],"remove":[],"start_point":[[3303411878775644985,301778328144628917],[318560030360358929,17863574903157697896],[3384102572540409881,18442321214082298093],[12035095010819582754,18118267825025549699],[13662059715350867364,6379137305818664393],[11346538709718766144,13357220652574593654],[8462655819889292900,4691860614575868200],[2035327810332855521,533731991408535384],[3710133387837274291,15992617814592812350],[10146665273368938971,6351696498298648253],[8661113083384527971,10625296323957562985]],"end_point":[[8661113083384527971,533731991408535384],[12035095010819582754,6351696498298648253],[10146665273368938971,17863574903157697896],[2035327810332855521,13357220652574593654],[8462655819889292900,301778328144628917],[3384102572540409881,18118267825025549699],[3303411878775644985,10625296323957562985],[318560030360358929,4691860614575868200],[3710133387837274291,6379137305818664393],[13662059715350867364,18442321214082298093],[11346538709718766144,15992617814592812350]],"handle_primary":[[3384102572540409881,[0.0,0.0]],[8462655819889292900,[0.0,0.0]],[3710133387837274291,[0.0,0.0]],[12035095010819582754,[0.0,0.0]],[10146665273368938971,[0.0,0.0]],[2035327810332855521,[42.96296296296293,-41.7777777777778]],[3303411878775644985,[0.0,0.0]],[13662059715350867364,[0.0,0.0]],[8661113083384527971,[0.2962962962963047,0.2962962962963047]],[318560030360358929,[-46.95465552079859,46.40007297527743]],[11346538709718766144,[9.925839724176626,-9.951533978271286]]],"handle_end":[[318560030360358929,[-97.48148148148152,-81.18518518518522]],[13662059715350867364,[68.68148181185177,-54.8859262904691]],[11346538709718766144,[1.1377781018271662,63.71555518874077]],[3384102572540409881,[0.5807410754567854,77.36888852918523]],[2035327810332855521,[-8.299214014278164,8.32069754812484]],[8462655819889292900,[-21.74426522093495,47.99999999999997]],[3303411878775644985,[-6.2222222222222285,-40.59259259259261]],[3710133387837274291,[0.0,0.0]],[12035095010819582754,[0.0,0.0]],[8661113083384527971,[-42.34888386913234,41.180638796880466]],[10146665273368938971,[48.16592595101224,-47.597037061827145]]],"stroke":[[318560030360358929,0],[3303411878775644985,0],[8661113083384527971,0],[13662059715350867364,0],[12035095010819582754,0],[11346538709718766144,0],[8462655819889292900,0],[3710133387837274291,0],[10146665273368938971,0],[3384102572540409881,0],[2035327810332855521,0]]},"regions":{"add":[],"remove":[],"segment_range":[],"fill":[]},"add_g1_continuous":[[{"ty":"End","segment":10146665273368938971},{"ty":"Primary","segment":318560030360358929}],[{"ty":"End","segment":12035095010819582754},{"ty":"Primary","segment":10146665273368938971}],[{"ty":"Primary","segment":11346538709718766144},{"ty":"End","segment":2035327810332855521}],[{"ty":"End","segment":8661113083384527971},{"ty":"Primary","segment":2035327810332855521}]],"remove_g1_continuous":[]}},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":Line truncated
{"network_interface":{"network":{"exports":[{"Node":{"node_id":392274448837115448,"output_index":0}}],"nodes":[[13353438235848911576,{"inputs":[{"Value":{"tagged_value":{"Vector":{"element":[{"style":{"stroke":{"color":{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0},"weight":0.0,"dash_lengths":[],"dash_offset":0.0,"cap":"Butt","join":"Miter","join_miter_limit":4.0,"align":"Center","transform":[1.0,0.0,0.0,1.0,0.0,0.0],"non_scaling":false,"paint_order":"StrokeAbove"},"fill":"None"},"colinear_manipulators":[],"point_domain":{"id":[],"position":[]},"segment_domain":{"id":[],"start_point":[],"end_point":[],"handles":[],"stroke":[]},"region_domain":{"id":[],"segment_range":[],"fill":[]},"upstream_nested_layers":null}],"transform":[[1.0,0.0,0.0,1.0,0.0,0.0]],"alpha_blending":[{"blend_mode":"Normal","opacity":1.0,"fill":1.0,"clip":false}],"source_node_id":[null]}},"exposed":true}},{"Value":{"tagged_value":{"VectorModification":{"points":{"add":[6379137305818664393,18442321214082298093,18118267825025549699,6351696498298648253,17863574903157697896,4691860614575868200,301778328144628917,10625296323957562985,533731991408535384,13357220652574593654,15992617814592812350],"remove":[],"delta":[[18118267825025549699,[642.0740740740741,0.0]],[6379137305818664393,[625.4814814814813,0.0]],[18442321214082298093,[565.6296296296297,122.96296296296298]],[17863574903157697896,[606.8148151308641,95.19407372365433]],[6351696498298648253,[646.8148148148149,0.0]],[10625296323957562985,[473.4814814814815,272.5925925925926]],[13357220652574593654,[574.2222222222222,108.44444444444449]],[301778328144628917,[493.5149940383244,200.29629629629628]],[15992617814592812350,[621.0370370370368,0.0]],[4691860614575868200,[528.2962962962963,283.8518518518518]],[533731991408535384,[501.6296296296296,175.40740740740742]]]},"segments":{"add":[13662059715350867364,3384102572540409881,12035095010819582754,10146665273368938971,318560030360358929,8462655819889292900,3303411878775644985,8661113083384527971,2035327810332855521,11346538709718766144,3710133387837274291],"remove":[],"start_point":[[318560030360358929,17863574903157697896],[11346538709718766144,13357220652574593654],[13662059715350867364,6379137305818664393],[3710133387837274291,15992617814592812350],[12035095010819582754,18118267825025549699],[2035327810332855521,533731991408535384],[3303411878775644985,301778328144628917],[8661113083384527971,10625296323957562985],[10146665273368938971,6351696498298648253],[3384102572540409881,18442321214082298093],[8462655819889292900,4691860614575868200]],"end_point":[[11346538709718766144,15992617814592812350],[3303411878775644985,10625296323957562985],[8661113083384527971,533731991408535384],[3384102572540409881,18118267825025549699],[12035095010819582754,6351696498298648253],[2035327810332855521,13357220652574593654],[8462655819889292900,301778328144628917],[318560030360358929,4691860614575868200],[10146665273368938971,17863574903157697896],[13662059715350867364,18442321214082298093],[3710133387837274291,6379137305818664393]],"handle_primary":[[11346538709718766144,[9.925839724176626,-9.951533978271286]],[8462655819889292900,[0.0,0.0]],[12035095010819582754,[0.0,0.0]],[2035327810332855521,[42.96296296296293,-41.7777777777778]],[8661113083384527971,[0.2962962962963047,0.2962962962963047]],[3303411878775644985,[0.0,0.0]],[10146665273368938971,[0.0,0.0]],[318560030360358929,[-46.95465552079859,46.40007297527743]],[3384102572540409881,[0.0,0.0]],[3710133387837274291,[0.0,0.0]],[13662059715350867364,[0.0,0.0]]],"handle_end":[[8661113083384527971,[-42.34888386913234,41.180638796880466]],[12035095010819582754,[0.0,0.0]],[2035327810332855521,[-8.299214014278164,8.32069754812484]],[3303411878775644985,[-6.2222222222222285,-40.59259259259261]],[11346538709718766144,[1.1377781018271662,63.71555518874077]],[318560030360358929,[-97.48148148148152,-81.18518518518522]],[10146665273368938971,[48.16592595101224,-47.597037061827145]],[8462655819889292900,[-21.74426522093495,47.99999999999997]],[3710133387837274291,[0.0,0.0]],[13662059715350867364,[68.68148181185177,-54.8859262904691]],[3384102572540409881,[0.5807410754567854,77.36888852918523]]],"stroke":[[8661113083384527971,0],[2035327810332855521,0],[13662059715350867364,0],[12035095010819582754,0],[11346538709718766144,0],[318560030360358929,0],[8462655819889292900,0],[3710133387837274291,0],[3303411878775644985,0],[10146665273368938971,0],[3384102572540409881,0]]},"regions":{"add":[],"remove":[],"segment_range":[],"fill":[]},"add_g1_continuous":[[{"ty":"End","segment":12035095010819582754},{"ty":"Primary","segment":10146665273368938971}],[{"ty":"Primary","segment":11346538709718766144},{"ty":"End","segment":2035327810332855521}],[{"ty":"End","segment":10146665273368938971},{"ty":"Primary","segment":318560030360358929}],[{"ty":"End","segment":8661113083384527971},{"ty":"Primary","segment":2035327810332855521}]],"remove_g1_continuous":[]}},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":Line truncated
+1 -1
View File
@@ -1 +1 @@
{"network_interface":{"network":{"exports":[{"Node":{"node_id":4445985685181725042,"output_index":0}}],"nodes":[[17154757625902243313,{"inputs":[{"Value":{"tagged_value":"None","exposed":true}},{"Value":{"tagged_value":{"Color":{"element":[{"red":0.23529412,"green":0.23529412,"blue":0.24313726,"alpha":1.0}],"transform":[[1.0,0.0,0.0,1.0,0.0,0.0]],"alpha_blending":[{"blend_mode":"Normal","opacity":1.0,"fill":1.0,"clip":false}],"source_node_id":[null]}},"exposed":false}},{"Value":{"tagged_value":{"F64":1670.79570439},"exposed":false}},{"Value":{"tagged_value":{"F64":24.0},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":2288754089236120499,"output_index":0}}],"nodes":[[11731553664207576737,{"inputs":[{"Node":{"node_id":757876048866560520,"output_index":0}},{"Value":{"tagged_value":{"F64":48.900000000000006},"exposed":false}},{"Node":{"node_id":7828034197076821310,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::vector::JitterPointsNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[14158287945315818946,{"inputs":[{"Node":{"node_id":16943732999059587742,"output_index":0}},{"Node":{"node_id":14577956936089455769,"output_index":0}},{"Value":{"tagged_value":{"F64":0.0},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.6181095265062186,3.496297826945966]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":1,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Import":{"import_type":{"Concrete":{"name":"glam::f64::dvec2::DVec2","alias":null}},"import_index":1}},{"Import":{"import_type":{"Concrete":{"name":"f64","alias":null}},"import_index":2}},{"Import":{"import_type":{"Concrete":{"name":"glam::f64::dvec2::DVec2","alias":null}},"import_index":3}},{"Import":{"import_type":{"Concrete":{"name":"glam::f64::dvec2::DVec2","alias":null}},"import_index":4}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::transform_nodes::TransformNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[2288754089236120499,{"inputs":[{"Node":{"node_id":14158287945315818946,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::vector::SplineNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[7828034197076821310,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":3}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphene_math_nodes::ToU32Node"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[640915213983348287,{"inputs":[{"Value":{"tagged_value":"None","exposed":false}},{"Value":{"tagged_value":{"F64":4000.0},"exposed":false}},{"Value":{"tagged_value":{"F64":500.0},"exposed":false}},{"Value":{"tagged_value":{"Bool":false},"exposed":false}},{"Value":{"tagged_value":{"F64":0.0},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::vector::generator_nodes::RectangleNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1791308547102433540,{"inputs":[{"Node":{"node_id":640915213983348287,"output_index":0}},{"Import":{"import_type":{"Generic":"T"},"import_index":1}},{"Value":{"tagged_value":{"Color":{"element":[{"red":0.99607843,"green":0.827451,"blue":0.65882355,"alpha":1.0}],"transform":[[1.0,0.0,0.0,1.0,0.0,0.0]],"alpha_blending":[{"blend_mode":"Normal","opacity":1.0,"fill":1.0,"clip":false}],"source_node_id":[null]}},"exposed":false}},{"Value":{"tagged_value":{"Gradient":{"stops":[[0.0,{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0}],[1.0,{"red":1.0,"green":1.0,"blue":1.0,"alpha":1.0}]],"gradient_type":"Linear","start":Line truncated
{"network_interface":{"network":{"exports":[{"Node":{"node_id":4445985685181725042,"output_index":0}}],"nodes":[[17154757625902243313,{"inputs":[{"Value":{"tagged_value":"None","exposed":true}},{"Value":{"tagged_value":{"Color":{"element":[{"red":0.23529412,"green":0.23529412,"blue":0.24313726,"alpha":1.0}],"transform":[[1.0,0.0,0.0,1.0,0.0,0.0]],"alpha_blending":[{"blend_mode":"Normal","opacity":1.0,"fill":1.0,"clip":false}],"source_node_id":[null]}},"exposed":false}},{"Value":{"tagged_value":{"F64":1670.79570439},"exposed":false}},{"Value":{"tagged_value":{"F64":24.0},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":2288754089236120499,"output_index":0}}],"nodes":[[11731553664207576737,{"inputs":[{"Node":{"node_id":757876048866560520,"output_index":0}},{"Value":{"tagged_value":{"F64":48.900000000000006},"exposed":false}},{"Node":{"node_id":7828034197076821310,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::vector::JitterPointsNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[14158287945315818946,{"inputs":[{"Node":{"node_id":16943732999059587742,"output_index":0}},{"Node":{"node_id":14577956936089455769,"output_index":0}},{"Value":{"tagged_value":{"F64":0.0},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.6181095265062186,3.496297826945966]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":1,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Import":{"import_type":{"Concrete":{"name":"glam::f64::dvec2::DVec2","alias":null}},"import_index":1}},{"Import":{"import_type":{"Concrete":{"name":"f64","alias":null}},"import_index":2}},{"Import":{"import_type":{"Concrete":{"name":"glam::f64::dvec2::DVec2","alias":null}},"import_index":3}},{"Import":{"import_type":{"Concrete":{"name":"glam::f64::dvec2::DVec2","alias":null}},"import_index":4}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::transform_nodes::TransformNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[2288754089236120499,{"inputs":[{"Node":{"node_id":14158287945315818946,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::vector::SplineNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[7828034197076821310,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":3}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphene_math_nodes::ToU32Node"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[640915213983348287,{"inputs":[{"Value":{"tagged_value":"None","exposed":false}},{"Value":{"tagged_value":{"F64":4000.0},"exposed":false}},{"Value":{"tagged_value":{"F64":500.0},"exposed":false}},{"Value":{"tagged_value":{"Bool":false},"exposed":false}},{"Value":{"tagged_value":{"F64":0.0},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::vector::generator_nodes::RectangleNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1791308547102433540,{"inputs":[{"Node":{"node_id":640915213983348287,"output_index":0}},{"Import":{"import_type":{"Generic":"T"},"import_index":1}},{"Value":{"tagged_value":{"Color":{"element":[{"red":0.99607843,"green":0.827451,"blue":0.65882355,"alpha":1.0}],"transform":[[1.0,0.0,0.0,1.0,0.0,0.0]],"alpha_blending":[{"blend_mode":"Normal","opacity":1.0,"fill":1.0,"clip":false}],"source_node_id":[null]}},"exposed":false}},{"Value":{"tagged_value":{"Gradient":{"stops":[[0.0,{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0}],[1.0,{"red":1.0,"green":1.0,"blue":1.0,"alpha":1.0}]],"gradient_type":"Linear","start":Line truncated
+1 -1
View File
@@ -1 +1 @@
{"network_interface":{"network":{"exports":[{"Node":{"node_id":14972365039974885000,"output_index":0}}],"nodes":[[183562335973647870,{"inputs":[{"Node":{"node_id":4248875763694880300,"output_index":0}},{"Node":{"node_id":2181148486404191200,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":4,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::ToGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::ExtendNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3,{"inputs":[{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[2,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::SourceNodeIdNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::WrapGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[665049002420596400,{"inputs":[{"Value":{"tagged_value":{"Vector":{"element":[{"style":{"stroke":{"color":{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0},"weight":0.0,"dash_lengths":[],"dash_offset":0.0,"cap":"Butt","join":"Miter","join_miter_limit":4.0,"align":"Center","transform":[1.0,0.0,0.0,1.0,0.0,0.0],"non_scaling":false,"paint_order":"StrokeAbove"},"fill":"None"},"colinear_manipulators":[],"point_domain":{"id":[],"position":[]},"segment_domain":{"id":[],"start_point":[],"end_point":[],"handles":[],"stroke":[]},"region_domain":{"id":[],"segment_range":[],"fill":[]},"upstream_nested_layers":null}],"transform":[[1.0,0.0,0.0,1.0,0.0,0.0]],"alpha_blending":[{"blend_mode":"Normal","opacity":1.0,"fill":1.0,"clip":false}],"source_node_id":[null]}},"exposed":true}},{"Value":{"tagged_value":{"VectorModification":{"points":{"add":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34],"remove":[],"delta":[[18,[145.77777777777777,-97.7777777777778]],[15,[111.11111111111114,-60.888888888888914]],[32,[9.333333333333314,38.66666666666663]],[27,[-11.111111111111144,-72.00000000000003]],[17,[123.99999999999994,-84.00000000000003]],[29,[-32.888888888888914,-14.666666666666686]],[30,[-9.333333333333371,0.0]],[14,[183.11111111111103,-19.111111111111143]],[19,[90.66666666666664,-129.33333333333334]],[1,[-103.55555555555554,126.66666666666664]],[25,[0.8888888888888573,-94.66666666666669]],[33,[-78.22222222222223,75.55555555555554]],[5,[66.22222222222223,152.88888888888886]],[3,[45.77777777777777,145.33333333333331]],[23,[19.555555555555543,-139.55555555555557]],[26,[22.66666666666663,-81.33333333333337]],[34,[-5.333333333333371,99.11111111111109]],[13,[153.77777777777777,-1.3333333333333712]],[8,[252.4444444444444,124.88888888888886]],[31,[-53.33333333333337,13.777777777777771]],[10,[216.4444444444444,72.4444444444444]],[12,[199.5555555555555,10.666666666666629]],[6,[123.99999999999994,148.4444444444444]],[24,[57.77777777777777,-129.33333333333334]],[7,[229.33333333333331,152.4444444444444]],[11,[136.88888888888886,39.111111111111086]],[20,[128.4444444444444,-142.22222222222223]],[28,[39.111111111111086,-58.22222222222226]],[4,[18.66666666666663,157.77777777777771]],[22,[71.11111111111109,-201.7777777777778]],[9,[156.4444444444444,97.33333333333331]],[21,[76.0,-202.22222222222223]],[16,[159.5555555555555,-75.55555555555557]],[2,[-67.55555555555554,158.22222222222217]]]},"segments":{"add":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34],"remove":[],"start_point":[[16,16],[29,29],[7,7],[14,14],[22,22],[20,20],[24,24],[25,25],[32,32],[23,23],[33,33],[26,26],[2,2],[13,13],[18,18],[8,8],Line truncated
{"network_interface":{"network":{"exports":[{"Node":{"node_id":14972365039974885000,"output_index":0}}],"nodes":[[183562335973647870,{"inputs":[{"Node":{"node_id":4248875763694880300,"output_index":0}},{"Node":{"node_id":2181148486404191200,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":4,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::ToGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[4,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Node":{"node_id":3,"output_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::ExtendNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[3,{"inputs":[{"Node":{"node_id":2,"output_index":0}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[2,{"inputs":[{"Node":{"node_id":1,"output_index":0}},{"Reflection":"DocumentNodePath"}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::SourceNodeIdNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":1}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::graphic::WrapGraphicNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[665049002420596400,{"inputs":[{"Value":{"tagged_value":{"Vector":{"element":[{"style":{"stroke":{"color":{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0},"weight":0.0,"dash_lengths":[],"dash_offset":0.0,"cap":"Butt","join":"Miter","join_miter_limit":4.0,"align":"Center","transform":[1.0,0.0,0.0,1.0,0.0,0.0],"non_scaling":false,"paint_order":"StrokeAbove"},"fill":"None"},"colinear_manipulators":[],"point_domain":{"id":[],"position":[]},"segment_domain":{"id":[],"start_point":[],"end_point":[],"handles":[],"stroke":[]},"region_domain":{"id":[],"segment_range":[],"fill":[]},"upstream_nested_layers":null}],"transform":[[1.0,0.0,0.0,1.0,0.0,0.0]],"alpha_blending":[{"blend_mode":"Normal","opacity":1.0,"fill":1.0,"clip":false}],"source_node_id":[null]}},"exposed":true}},{"Value":{"tagged_value":{"VectorModification":{"points":{"add":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34],"remove":[],"delta":[[1,[-103.55555555555554,126.66666666666664]],[18,[145.77777777777777,-97.7777777777778]],[12,[199.5555555555555,10.666666666666629]],[22,[71.11111111111109,-201.7777777777778]],[19,[90.66666666666664,-129.33333333333334]],[4,[18.66666666666663,157.77777777777771]],[15,[111.11111111111114,-60.888888888888914]],[17,[123.99999999999994,-84.00000000000003]],[11,[136.88888888888886,39.111111111111086]],[20,[128.4444444444444,-142.22222222222223]],[16,[159.5555555555555,-75.55555555555557]],[5,[66.22222222222223,152.88888888888886]],[24,[57.77777777777777,-129.33333333333334]],[33,[-78.22222222222223,75.55555555555554]],[10,[216.4444444444444,72.4444444444444]],[8,[252.4444444444444,124.88888888888886]],[9,[156.4444444444444,97.33333333333331]],[3,[45.77777777777777,145.33333333333331]],[32,[9.333333333333314,38.66666666666663]],[28,[39.111111111111086,-58.22222222222226]],[7,[229.33333333333331,152.4444444444444]],[26,[22.66666666666663,-81.33333333333337]],[31,[-53.33333333333337,13.777777777777771]],[27,[-11.111111111111144,-72.00000000000003]],[14,[183.11111111111103,-19.111111111111143]],[6,[123.99999999999994,148.4444444444444]],[23,[19.555555555555543,-139.55555555555557]],[30,[-9.333333333333371,0.0]],[29,[-32.888888888888914,-14.666666666666686]],[25,[0.8888888888888573,-94.66666666666669]],[34,[-5.333333333333371,99.11111111111109]],[21,[76.0,-202.22222222222223]],[2,[-67.55555555555554,158.22222222222217]],[13,[153.77777777777777,-1.3333333333333712]]]},"segments":{"add":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34],"remove":[],"start_point":[[7,7],[3,3],[8,8],[10,10],[13,13],[11,11],[31,31],[25,25],[18,18],[34,34],[27,27],[12,12],[22,22],[19,19],[32,32],[5,5],[3Line truncated
+1 -1
View File
@@ -1 +1 @@
{"network_interface":{"network":{"exports":[{"Node":{"node_id":2394762731964337494,"output_index":0}}],"nodes":[[10127467043900015225,{"inputs":[{"Value":{"tagged_value":{"Vector":{"element":[{"style":{"stroke":{"color":{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0},"weight":0.0,"dash_lengths":[],"dash_offset":0.0,"cap":"Butt","join":"Miter","join_miter_limit":4.0,"align":"Center","transform":[1.0,0.0,0.0,1.0,0.0,0.0],"non_scaling":false,"paint_order":"StrokeAbove"},"fill":"None"},"colinear_manipulators":[],"point_domain":{"id":[],"position":[]},"segment_domain":{"id":[],"start_point":[],"end_point":[],"handles":[],"stroke":[]},"region_domain":{"id":[],"segment_range":[],"fill":[]},"upstream_nested_layers":null}],"transform":[[1.0,0.0,0.0,1.0,0.0,0.0]],"alpha_blending":[{"blend_mode":"Normal","opacity":1.0,"fill":1.0,"clip":false}],"source_node_id":[null]}},"exposed":true}},{"Value":{"tagged_value":{"VectorModification":{"points":{"add":[1,2],"remove":[],"delta":[[2,[644.0,726.6666666666666]],[1,[258.00000000000006,994.6666666666664]]]},"segments":{"add":[1],"remove":[],"start_point":[[1,1]],"end_point":[[1,2]],"handle_primary":[[1,[0.0,0.0]]],"handle_end":[[1,[-328.66666666666674,129.33333333333337]]],"stroke":[[1,0]]},"regions":{"add":[],"remove":[],"segment_range":[],"fill":[]},"add_g1_continuous":[],"remove_g1_continuous":[]}},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":1,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Concrete":{"name":"graphene_core::table::Table<graphene_core::vector::vector_types::Vector>","alias":null}},"import_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Import":{"import_type":{"Concrete":{"name":"graphene_core::vector::vector_modification::VectorModification","alias":null}},"import_index":1}},{"Reflection":"DocumentNodePath"}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphene_core::vector::vector_modification::PathModifyNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[15961046538654083626,{"inputs":[{"Node":{"node_id":1889157037801767612,"output_index":0}},{"Node":{"node_id":4332145463108161926,"output_index":0}},{"Value":{"tagged_value":{"F64":0.5},"exposed":false}},{"Value":{"tagged_value":{"F64":10.0},"exposed":false}},{"Value":{"tagged_value":{"F64":0.0},"exposed":false}},{"Value":{"tagged_value":{"U32":0},"exposed":false}},{"Value":{"tagged_value":{"F64":0.0},"exposed":false}},{"Value":{"tagged_value":{"U32":0},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::vector::CopyToPointsNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[17378885078543074499,{"inputs":[{"Value":{"tagged_value":{"Vector":{"element":[{"style":{"stroke":{"color":{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0},"weight":0.0,"dash_lengths":[],"dash_offset":0.0,"cap":"Butt","join":"Miter","join_miter_limit":4.0,"align":"Center","transform":[1.0,0.0,0.0,1.0,0.0,0.0],"non_scaling":false,"paint_order":"StrokeAbove"},"fill":"None"},"colinear_manipulators":[],"point_domain":{"id":[],"position":[]},"segment_domain":{"id":[],"start_point":[],"end_point":[],"handles":[],"stroke":[]},"region_domain":{"id":[],"segment_range":[],"fill":[]},"upstream_nested_layers":null}],"transform":[[1.0,0.0,0.0,1.0,0.0,0.0]],"alpha_blending":[{"blend_mode":"Normal","opacity":1.0,"fill":1.0,"clip":false}],"source_node_id":[null]}},"exposed":true}},{"Value":{"tagged_value":{"VectorModification":{"points":{"add":[1,2,3,4,5,6,7,8],"remove":[],"delta":[[7,[727.5555555555554,1026.6666666666663]],[3,[707.5,1026.5]],[5,[740.4444444444443,857.1111111111111]],[1,[823.2222222222221,660.4444444444445]],[8,[746.0000000000001,842.9999999999999]],[6,[725.7777777777779,1026.370370370371]],[4,[709.5555555555554,1026.6666666666667]],[2,[745.5,826.0]]]},"segments":{"add":[1,2,3,4,5,6,7,8],"remove":[],"start_point":[[8,8],[5,5],[1,1],[7,7],[2,2],[3,3],[6,6],[4,4]],"end_point":[[6,7],[7,8],[4,5],[5,6],[3,4],[1,2],[8,1],[2,3]],"handle_primary":[[3,[0.0,0.0]],[2,[-24.5,85.0]],[5,[0.0,0.0]],[4,[0.0,0.0]],[1,[0.0,0.0]],[6,[0.0,0.0]],[7,[0.0,0.0]],[8,[17.33333333333337,-84.99999999999989]]],"handle_end":[[8,[1.772016460905547,0.9591220850479658]],[2,[0.0,0.0]],[3,[0.0,0.0]],[7,[-26.8034437596026,131.4399645903585]],[5,[-7.555555555555884,-59.25925925925992]],[1,[24.5,-85.0]],[6,[0.0,0.0]],[4,[-23.11111111111109,90.44444444444456]]],"stroke":[[1,0],[7,0],[3,0],[8,0Line truncated
{"network_interface":{"network":{"exports":[{"Node":{"node_id":2394762731964337494,"output_index":0}}],"nodes":[[10127467043900015225,{"inputs":[{"Value":{"tagged_value":{"Vector":{"element":[{"style":{"stroke":{"color":{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0},"weight":0.0,"dash_lengths":[],"dash_offset":0.0,"cap":"Butt","join":"Miter","join_miter_limit":4.0,"align":"Center","transform":[1.0,0.0,0.0,1.0,0.0,0.0],"non_scaling":false,"paint_order":"StrokeAbove"},"fill":"None"},"colinear_manipulators":[],"point_domain":{"id":[],"position":[]},"segment_domain":{"id":[],"start_point":[],"end_point":[],"handles":[],"stroke":[]},"region_domain":{"id":[],"segment_range":[],"fill":[]},"upstream_nested_layers":null}],"transform":[[1.0,0.0,0.0,1.0,0.0,0.0]],"alpha_blending":[{"blend_mode":"Normal","opacity":1.0,"fill":1.0,"clip":false}],"source_node_id":[null]}},"exposed":true}},{"Value":{"tagged_value":{"VectorModification":{"points":{"add":[1,2],"remove":[],"delta":[[2,[644.0,726.6666666666666]],[1,[258.00000000000006,994.6666666666664]]]},"segments":{"add":[1],"remove":[],"start_point":[[1,1]],"end_point":[[1,2]],"handle_primary":[[1,[0.0,0.0]]],"handle_end":[[1,[-328.66666666666674,129.33333333333337]]],"stroke":[[1,0]]},"regions":{"add":[],"remove":[],"segment_range":[],"fill":[]},"add_g1_continuous":[],"remove_g1_continuous":[]}},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":1,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Concrete":{"name":"graphene_core::table::Table<graphene_core::vector::vector_types::Vector>","alias":null}},"import_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Import":{"import_type":{"Concrete":{"name":"graphene_core::vector::vector_modification::VectorModification","alias":null}},"import_index":1}},{"Reflection":"DocumentNodePath"}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphene_core::vector::vector_modification::PathModifyNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[15961046538654083626,{"inputs":[{"Node":{"node_id":1889157037801767612,"output_index":0}},{"Node":{"node_id":4332145463108161926,"output_index":0}},{"Value":{"tagged_value":{"F64":0.5},"exposed":false}},{"Value":{"tagged_value":{"F64":10.0},"exposed":false}},{"Value":{"tagged_value":{"F64":0.0},"exposed":false}},{"Value":{"tagged_value":{"U32":0},"exposed":false}},{"Value":{"tagged_value":{"F64":0.0},"exposed":false}},{"Value":{"tagged_value":{"U32":0},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::vector::CopyToPointsNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[17378885078543074499,{"inputs":[{"Value":{"tagged_value":{"Vector":{"element":[{"style":{"stroke":{"color":{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0},"weight":0.0,"dash_lengths":[],"dash_offset":0.0,"cap":"Butt","join":"Miter","join_miter_limit":4.0,"align":"Center","transform":[1.0,0.0,0.0,1.0,0.0,0.0],"non_scaling":false,"paint_order":"StrokeAbove"},"fill":"None"},"colinear_manipulators":[],"point_domain":{"id":[],"position":[]},"segment_domain":{"id":[],"start_point":[],"end_point":[],"handles":[],"stroke":[]},"region_domain":{"id":[],"segment_range":[],"fill":[]},"upstream_nested_layers":null}],"transform":[[1.0,0.0,0.0,1.0,0.0,0.0]],"alpha_blending":[{"blend_mode":"Normal","opacity":1.0,"fill":1.0,"clip":false}],"source_node_id":[null]}},"exposed":true}},{"Value":{"tagged_value":{"VectorModification":{"points":{"add":[1,2,3,4,5,6,7,8],"remove":[],"delta":[[1,[823.2222222222221,660.4444444444445]],[8,[746.0000000000001,842.9999999999999]],[2,[745.5,826.0]],[3,[707.5,1026.5]],[6,[725.7777777777779,1026.370370370371]],[4,[709.5555555555554,1026.6666666666667]],[5,[740.4444444444443,857.1111111111111]],[7,[727.5555555555554,1026.6666666666663]]]},"segments":{"add":[1,2,3,4,5,6,7,8],"remove":[],"start_point":[[4,4],[3,3],[1,1],[2,2],[7,7],[5,5],[8,8],[6,6]],"end_point":[[4,5],[8,1],[5,6],[7,8],[6,7],[2,3],[3,4],[1,2]],"handle_primary":[[4,[0.0,0.0]],[7,[0.0,0.0]],[1,[0.0,0.0]],[2,[-24.5,85.0]],[6,[0.0,0.0]],[8,[17.33333333333337,-84.99999999999989]],[5,[0.0,0.0]],[3,[0.0,0.0]]],"handle_end":[[5,[-7.555555555555884,-59.25925925925992]],[8,[1.772016460905547,0.9591220850479658]],[2,[0.0,0.0]],[4,[-23.11111111111109,90.44444444444456]],[7,[-26.8034437596026,131.4399645903585]],[1,[24.5,-85.0]],[6,[0.0,0.0]],[3,[0.0,0.0]]],"stroke":[[3,0],[5,0],[2,0],[4,0Line truncated
+1 -1
View File
@@ -1 +1 @@
{"network_interface":{"network":{"exports":[{"Node":{"node_id":16815500381887058038,"output_index":0}}],"nodes":[[202,{"inputs":[{"Node":{"node_id":206,"output_index":0}},{"Value":{"tagged_value":{"Fill":{"Solid":{"red":0.5058824,"green":0.26666668,"blue":0.20392157,"alpha":1.0}}},"exposed":false}},{"Value":{"tagged_value":{"Color":{"element":[{"red":0.5058824,"green":0.26666668,"blue":0.20392157,"alpha":1.0}],"transform":[[1.0,0.0,0.0,1.0,0.0,0.0]],"alpha_blending":[{"blend_mode":"Normal","opacity":1.0,"fill":1.0,"clip":false}],"source_node_id":[null]}},"exposed":false}},{"Value":{"tagged_value":{"Gradient":{"stops":[[0.0,{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0}],[1.0,{"red":1.0,"green":1.0,"blue":1.0,"alpha":1.0}]],"gradient_type":"Linear","start":[0.0,0.5],"end":[1.0,0.5]}},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::vector::FillNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[404,{"inputs":[{"Node":{"node_id":402,"output_index":0}},{"Value":{"tagged_value":{"Color":{"element":[{"red":0.24313726,"green":0.18431373,"blue":0.19215687,"alpha":1.0}],"transform":[[1.0,0.0,0.0,1.0,0.0,0.0]],"alpha_blending":[{"blend_mode":"Normal","opacity":1.0,"fill":1.0,"clip":false}],"source_node_id":[null]}},"exposed":false}},{"Value":{"tagged_value":{"F64":2.0},"exposed":false}},{"Value":{"tagged_value":{"StrokeAlign":"Center"},"exposed":false}},{"Value":{"tagged_value":{"StrokeCap":"Butt"},"exposed":false}},{"Value":{"tagged_value":{"StrokeJoin":"Miter"},"exposed":false}},{"Value":{"tagged_value":{"F64":4.0},"exposed":false}},{"Value":{"tagged_value":{"PaintOrder":"StrokeAbove"},"exposed":false}},{"Value":{"tagged_value":{"VecF64":[]},"exposed":false}},{"Value":{"tagged_value":{"F64":0.0},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::vector::StrokeNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[93,{"inputs":[{"Node":{"node_id":94,"output_index":0}},{"Value":{"tagged_value":{"DVec2":[851.1666666666667,668.5377104806669]},"exposed":false}},{"Value":{"tagged_value":{"F64":0.0},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[39.677869315599935,39.67786931560005]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":1,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Import":{"import_type":{"Concrete":{"name":"glam::f64::dvec2::DVec2","alias":null}},"import_index":1}},{"Import":{"import_type":{"Concrete":{"name":"f64","alias":null}},"import_index":2}},{"Import":{"import_type":{"Concrete":{"name":"glam::f64::dvec2::DVec2","alias":null}},"import_index":3}},{"Import":{"import_type":{"Concrete":{"name":"glam::f64::dvec2::DVec2","alias":null}},"import_index":4}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::transform_nodes::TransformNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[155,{"inputs":[{"Node":{"node_id":159,"output_index":0}},{"Value":{"tagged_value":{"Fill":{"Gradient":{"stops":[[0.0,{"red":0.7529412,"green":0.34117648,"blue":0.2,"alpha":1.0}],[1.0,{"red":0.6431373,"green":0.31764707,"blue":0.21176471,"alpha":1.0}]],"gradient_type":"Linear","start":[0.9001916129448388,0.7881778212017586],"end":[0.8902470335613286,0.6662432828529555]}}},"exposed":false}},{"Value":{"tagged_value":{"Color":{"element":[{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0}],"transform":[[1.0,0.0,0.0,1.0,0.0,0.0]],"alpha_blending":[{"blend_mode":"Normal","opacity":1.0,"fill":1.0,"clip":false}],"source_node_id":[null]}},"exposed":false}},{"Value":{"tagged_value":{"Gradient":{"stops":[[0.0,{"red":0.7529412,"green":0.34117648,"blue":0.2,"alpha":1.0}],[1.0,{"red":0.6431373,"green":0.31764707,"blue":0.21176471,"alpha":1.0}]],"gradient_type":"Linear","start":[0.9001916129448388,0.7881778212017586],"end":[0.8902470335613286,0.6662432828529555]}},"exposed":false}}],"call_argument":{"ConcretLine truncated
{"network_interface":{"network":{"exports":[{"Node":{"node_id":16815500381887058038,"output_index":0}}],"nodes":[[202,{"inputs":[{"Node":{"node_id":206,"output_index":0}},{"Value":{"tagged_value":{"Fill":{"Solid":{"red":0.5058824,"green":0.26666668,"blue":0.20392157,"alpha":1.0}}},"exposed":false}},{"Value":{"tagged_value":{"Color":{"element":[{"red":0.5058824,"green":0.26666668,"blue":0.20392157,"alpha":1.0}],"transform":[[1.0,0.0,0.0,1.0,0.0,0.0]],"alpha_blending":[{"blend_mode":"Normal","opacity":1.0,"fill":1.0,"clip":false}],"source_node_id":[null]}},"exposed":false}},{"Value":{"tagged_value":{"Gradient":{"stops":[[0.0,{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0}],[1.0,{"red":1.0,"green":1.0,"blue":1.0,"alpha":1.0}]],"gradient_type":"Linear","start":[0.0,0.5],"end":[1.0,0.5]}},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::vector::FillNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[404,{"inputs":[{"Node":{"node_id":402,"output_index":0}},{"Value":{"tagged_value":{"Color":{"element":[{"red":0.24313726,"green":0.18431373,"blue":0.19215687,"alpha":1.0}],"transform":[[1.0,0.0,0.0,1.0,0.0,0.0]],"alpha_blending":[{"blend_mode":"Normal","opacity":1.0,"fill":1.0,"clip":false}],"source_node_id":[null]}},"exposed":false}},{"Value":{"tagged_value":{"F64":2.0},"exposed":false}},{"Value":{"tagged_value":{"StrokeAlign":"Center"},"exposed":false}},{"Value":{"tagged_value":{"StrokeCap":"Butt"},"exposed":false}},{"Value":{"tagged_value":{"StrokeJoin":"Miter"},"exposed":false}},{"Value":{"tagged_value":{"F64":4.0},"exposed":false}},{"Value":{"tagged_value":{"PaintOrder":"StrokeAbove"},"exposed":false}},{"Value":{"tagged_value":{"VecF64":[]},"exposed":false}},{"Value":{"tagged_value":{"F64":0.0},"exposed":false}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::vector::StrokeNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[93,{"inputs":[{"Node":{"node_id":94,"output_index":0}},{"Value":{"tagged_value":{"DVec2":[851.1666666666667,668.5377104806669]},"exposed":false}},{"Value":{"tagged_value":{"F64":0.0},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[39.677869315599935,39.67786931560005]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"Bool":true},"exposed":false}}],"call_argument":{"Generic":"T"},"implementation":{"Network":{"exports":[{"Node":{"node_id":1,"output_index":0}}],"nodes":[[0,{"inputs":[{"Import":{"import_type":{"Generic":"T"},"import_index":0}}],"call_argument":{"Generic":"T"},"implementation":{"ProtoNode":{"name":"graphene_core::memo::MonitorNode"}},"visible":true,"skip_deduplication":true,"context_features":{"extract":"","inject":""}}],[1,{"inputs":[{"Node":{"node_id":0,"output_index":0}},{"Import":{"import_type":{"Concrete":{"name":"glam::f64::dvec2::DVec2","alias":null}},"import_index":1}},{"Import":{"import_type":{"Concrete":{"name":"f64","alias":null}},"import_index":2}},{"Import":{"import_type":{"Concrete":{"name":"glam::f64::dvec2::DVec2","alias":null}},"import_index":3}},{"Import":{"import_type":{"Concrete":{"name":"glam::f64::dvec2::DVec2","alias":null}},"import_index":4}}],"call_argument":{"Concrete":{"name":"core::option::Option<alloc::sync::Arc<graphene_core::context::OwnedContextImpl>>","alias":null}},"implementation":{"ProtoNode":{"name":"graphene_core::transform_nodes::TransformNode"}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}]],"scope_injections":[]}},"visible":true,"skip_deduplication":false,"context_features":{"extract":"","inject":""}}],[155,{"inputs":[{"Node":{"node_id":159,"output_index":0}},{"Value":{"tagged_value":{"Fill":{"Gradient":{"stops":[[0.0,{"red":0.7529412,"green":0.34117648,"blue":0.2,"alpha":1.0}],[1.0,{"red":0.6431373,"green":0.31764707,"blue":0.21176471,"alpha":1.0}]],"gradient_type":"Linear","start":[0.9001916129448388,0.7881778212017586],"end":[0.8902470335613286,0.6662432828529555]}}},"exposed":false}},{"Value":{"tagged_value":{"Color":{"element":[{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0}],"transform":[[1.0,0.0,0.0,1.0,0.0,0.0]],"alpha_blending":[{"blend_mode":"Normal","opacity":1.0,"fill":1.0,"clip":false}],"source_node_id":[null]}},"exposed":false}},{"Value":{"tagged_value":{"Gradient":{"stops":[[0.0,{"red":0.7529412,"green":0.34117648,"blue":0.2,"alpha":1.0}],[1.0,{"red":0.6431373,"green":0.31764707,"blue":0.21176471,"alpha":1.0}]],"gradient_type":"Linear","start":[0.9001916129448388,0.7881778212017586],"end":[0.8902470335613286,0.6662432828529555]}},"exposed":false}}],"call_argument":{"ConcretLine truncated
+6 -9
View File
@@ -18,7 +18,7 @@ gpu = ["graphite-desktop-wrapper/gpu"]
accelerated_paint = ["accelerated_paint_dmabuf", "accelerated_paint_d3d11", "accelerated_paint_iosurface"]
accelerated_paint_dmabuf = ["libc", "ash"]
accelerated_paint_d3d11 = ["windows", "ash"]
accelerated_paint_iosurface = ["metal", "objc", "core-foundation"]
accelerated_paint_iosurface = ["objc2-io-surface", "objc2-metal", "core-foundation"]
[dependencies]
# Local dependencies
@@ -26,7 +26,7 @@ graphite-desktop-wrapper = { path = "wrapper" }
graphite-desktop-embedded-resources = { path = "embedded-resources", optional = true }
wgpu = { workspace = true }
winit = { workspace = true, features = [ "wayland-csd-adwaita-notitlebar", "serde" ] }
winit = { workspace = true, features = [ "serde" ] }
thiserror = { workspace = true }
futures = { workspace = true }
cef = { workspace = true }
@@ -43,13 +43,12 @@ rfd = { workspace = true }
open = { workspace = true }
rand = { workspace = true, features = ["thread_rng"] }
serde = { workspace = true }
clap = { workspace = true, features = ["derive"] }
# Hardware acceleration dependencies
ash = { version = "0.38", optional = true }
# Windows-specific dependencies
[target.'cfg(target_os = "windows")'.dependencies]
[target.'cfg(windows)'.dependencies]
windows = { version = "0.58.0", features = [
"Win32_Foundation",
"Win32_Graphics_Direct3D11",
@@ -61,15 +60,13 @@ windows = { version = "0.58.0", features = [
"Win32_System_LibraryLoader",
"Win32_UI_Controls",
"Win32_UI_WindowsAndMessaging",
"Win32_UI_HiDpi",
], optional = true }
# macOS-specific dependencies
[target.'cfg(target_os = "macos")'.dependencies]
muda = { git = "https://github.com/tauri-apps/muda.git", rev = "3f460b8fbaed59cda6d95ceea6904f000f093f15", default-features = false }
metal = { version = "0.31.0", optional = true }
objc = { version = "0.2", optional = true }
core-foundation = { version = "0.10", optional = true }
objc2-io-surface = { version = "0.3", optional = true }
objc2-metal = { version = "0.3", optional = true }
core-foundation = { version = "0.9", optional = true }
# Linux-specific dependencies
[target.'cfg(target_os = "linux")'.dependencies]
Binary file not shown.

Before

Width:  |  Height:  |  Size: 310 KiB

-16
View File
@@ -1,16 +0,0 @@
[package]
name = "graphite-desktop-bundle"
version = "0.0.0"
description = "Graphite Desktop Bundle"
authors = ["Graphite Authors <[email protected]>"]
license = "Apache-2.0"
repository = ""
edition = "2024"
rust-version = "1.87"
[dependencies]
cef-dll-sys = { workspace = true }
[target.'cfg(target_os = "macos")'.dependencies]
serde = { workspace = true }
plist = { version = "*" }
-10
View File
@@ -1,10 +0,0 @@
fn main() {
println!("cargo:rerun-if-env-changed=CARGO_PROFILE");
println!("cargo:rerun-if-env-changed=PROFILE");
let profile = std::env::var("CARGO_PROFILE").or_else(|_| std::env::var("PROFILE")).unwrap();
println!("cargo:rustc-env=CARGO_PROFILE={profile}");
println!("cargo:rerun-if-env-changed=DEP_CEF_DLL_WRAPPER_CEF_DIR");
let cef_dir = std::env::var("DEP_CEF_DLL_WRAPPER_CEF_DIR").unwrap();
println!("cargo:rustc-env=CEF_PATH={cef_dir}");
}
-66
View File
@@ -1,66 +0,0 @@
use std::error::Error;
use std::fs;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
pub(crate) const APP_NAME: &str = "Graphite";
fn profile_name() -> &'static str {
let mut profile = env!("CARGO_PROFILE");
if profile == "debug" {
profile = "dev";
}
profile
}
pub(crate) fn profile_path() -> PathBuf {
PathBuf::from(env!("CARGO_WORKSPACE_DIR")).join(format!("target/{}", env!("CARGO_PROFILE")))
}
pub(crate) fn cef_path() -> PathBuf {
PathBuf::from(env!("CEF_PATH"))
}
pub(crate) fn build_bin(package: &str, bin: Option<&str>) -> Result<PathBuf, Box<dyn Error>> {
let profile = &profile_name();
let mut args = vec!["build", "--package", package, "--profile", profile];
if let Some(bin) = bin {
args.push("--bin");
args.push(bin);
}
run_command("cargo", &args)?;
let profile_path = profile_path();
let mut bin_path = if let Some(bin) = bin { profile_path.join(bin) } else { profile_path.join(package) };
if cfg!(target_os = "windows") {
bin_path.set_extension("exe");
}
Ok(bin_path)
}
pub(crate) fn run_command(program: &str, args: &[&str]) -> Result<(), Box<dyn std::error::Error>> {
let status = Command::new(program).args(args).stdout(Stdio::inherit()).stderr(Stdio::inherit()).status()?;
if !status.success() {
std::process::exit(1);
}
Ok(())
}
pub(crate) fn clean_dir(dir: &Path) {
if dir.exists() {
fs::remove_dir_all(dir).unwrap();
}
fs::create_dir_all(dir).unwrap();
}
pub(crate) fn copy_dir(src: &Path, dst: &Path) {
fs::create_dir_all(dst).unwrap();
for entry in fs::read_dir(src).unwrap() {
let entry = entry.unwrap();
let dst_path = dst.join(entry.file_name());
if entry.file_type().unwrap().is_dir() {
copy_dir(&entry.path(), &dst_path);
} else {
fs::copy(entry.path(), &dst_path).unwrap();
}
}
}
-23
View File
@@ -1,23 +0,0 @@
use std::error::Error;
use crate::common::*;
const PACKAGE: &str = "graphite-desktop-platform-linux";
pub fn main() -> Result<(), Box<dyn Error>> {
let app_bin = build_bin(PACKAGE, None)?;
// TODO: Implement bundling for linux
// TODO: Consider adding more useful cli
if std::env::args().any(|a| a == "open") {
run_command(&app_bin.to_string_lossy(), &[]).expect("failed to open app");
} else {
println!("Binary built and placed at {}", app_bin.to_string_lossy());
eprintln!("Bundling for Linux is not yet implemented.");
eprintln!("You can still start the app with the `open` subcommand. `cargo run -p graphite-desktop-bundle -- open`");
std::process::exit(1);
}
Ok(())
}
-130
View File
@@ -1,130 +0,0 @@
use std::collections::HashMap;
use std::error::Error;
use std::fs;
use std::path::{Path, PathBuf};
use crate::common::*;
const APP_ID: &str = "rs.graphite.GraphiteEditor";
const PACKAGE: &str = "graphite-desktop-platform-mac";
const HELPER_BIN: &str = "graphite-desktop-platform-mac-helper";
const EXEC_PATH: &str = "Contents/MacOS";
const FRAMEWORKS_PATH: &str = "Contents/Frameworks";
const FRAMEWORK: &str = "Chromium Embedded Framework.framework";
pub fn main() -> Result<(), Box<dyn Error>> {
let app_bin = build_bin(PACKAGE, None)?;
let helper_bin = build_bin(PACKAGE, Some(HELPER_BIN))?;
let profile_path = profile_path();
let app_dir = bundle(&profile_path, &app_bin, &helper_bin);
// TODO: Consider adding more useful cli
if std::env::args().any(|a| a == "open") {
let executable_path = app_dir.join(EXEC_PATH).join(APP_NAME);
run_command(&executable_path.to_string_lossy(), &[]).expect("failed to open app");
}
Ok(())
}
fn bundle(out_dir: &Path, app_bin: &Path, helper_bin: &Path) -> PathBuf {
let app_dir = out_dir.join(APP_NAME).with_extension("app");
clean_dir(&app_dir);
create_app(&app_dir, APP_ID, APP_NAME, app_bin, false);
for helper_type in [None, Some("GPU"), Some("Renderer"), Some("Plugin"), Some("Alerts")] {
let helper_id_suffix = helper_type.map(|t| format!(".{t}")).unwrap_or_default();
let helper_id = format!("{APP_ID}.helper{helper_id_suffix}");
let helper_name_suffix = helper_type.map(|t| format!(" ({t})")).unwrap_or_default();
let helper_name = format!("{APP_NAME} Helper{helper_name_suffix}");
let helper_app_dir = app_dir.join(FRAMEWORKS_PATH).join(&helper_name).with_extension("app");
create_app(&helper_app_dir, &helper_id, &helper_name, helper_bin, true);
}
copy_dir(&cef_path().join(FRAMEWORK), &app_dir.join(FRAMEWORKS_PATH).join(FRAMEWORK));
app_dir
}
fn create_app(app_dir: &Path, id: &str, name: &str, bin: &Path, is_helper: bool) {
fs::create_dir_all(app_dir.join(EXEC_PATH)).unwrap();
let app_contents_dir: &Path = &app_dir.join("Contents");
create_info_plist(app_contents_dir, id, name, is_helper).unwrap();
fs::copy(bin, app_dir.join(EXEC_PATH).join(name)).unwrap();
}
fn create_info_plist(dir: &Path, id: &str, exec_name: &str, is_helper: bool) -> Result<(), Box<dyn std::error::Error>> {
let info = InfoPlist {
cf_bundle_development_region: "en".to_string(),
cf_bundle_display_name: exec_name.to_string(),
cf_bundle_executable: exec_name.to_string(),
cf_bundle_identifier: id.to_string(),
cf_bundle_info_dictionary_version: "6.0".to_string(),
cf_bundle_name: exec_name.to_string(),
cf_bundle_package_type: "APPL".to_string(),
cf_bundle_signature: "????".to_string(),
cf_bundle_version: "0.0.0".to_string(),
cf_bundle_short_version_string: "0.0".to_string(),
ls_environment: [("MallocNanoZone".to_string(), "0".to_string())].iter().cloned().collect(),
ls_file_quarantine_enabled: true,
ls_minimum_system_version: "11.0".to_string(),
ls_ui_element: if is_helper { Some("1".to_string()) } else { None },
ns_bluetooth_always_usage_description: exec_name.to_string(),
ns_supports_automatic_graphics_switching: true,
ns_web_browser_publickey_credential_usage_description: exec_name.to_string(),
ns_camera_usage_description: exec_name.to_string(),
ns_microphone_usage_description: exec_name.to_string(),
};
let plist_file = dir.join("Info.plist");
plist::to_file_xml(plist_file, &info)?;
Ok(())
}
#[derive(serde::Serialize)]
struct InfoPlist {
#[serde(rename = "CFBundleDevelopmentRegion")]
cf_bundle_development_region: String,
#[serde(rename = "CFBundleDisplayName")]
cf_bundle_display_name: String,
#[serde(rename = "CFBundleExecutable")]
cf_bundle_executable: String,
#[serde(rename = "CFBundleIdentifier")]
cf_bundle_identifier: String,
#[serde(rename = "CFBundleInfoDictionaryVersion")]
cf_bundle_info_dictionary_version: String,
#[serde(rename = "CFBundleName")]
cf_bundle_name: String,
#[serde(rename = "CFBundlePackageType")]
cf_bundle_package_type: String,
#[serde(rename = "CFBundleSignature")]
cf_bundle_signature: String,
#[serde(rename = "CFBundleVersion")]
cf_bundle_version: String,
#[serde(rename = "CFBundleShortVersionString")]
cf_bundle_short_version_string: String,
#[serde(rename = "LSEnvironment")]
ls_environment: HashMap<String, String>,
#[serde(rename = "LSFileQuarantineEnabled")]
ls_file_quarantine_enabled: bool,
#[serde(rename = "LSMinimumSystemVersion")]
ls_minimum_system_version: String,
#[serde(rename = "LSUIElement")]
ls_ui_element: Option<String>,
#[serde(rename = "NSBluetoothAlwaysUsageDescription")]
ns_bluetooth_always_usage_description: String,
#[serde(rename = "NSSupportsAutomaticGraphicsSwitching")]
ns_supports_automatic_graphics_switching: bool,
#[serde(rename = "NSWebBrowserPublicKeyCredentialUsageDescription")]
ns_web_browser_publickey_credential_usage_description: String,
#[serde(rename = "NSCameraUsageDescription")]
ns_camera_usage_description: String,
#[serde(rename = "NSMicrophoneUsageDescription")]
ns_microphone_usage_description: String,
}
-17
View File
@@ -1,17 +0,0 @@
mod common;
#[cfg(target_os = "linux")]
mod linux;
#[cfg(target_os = "macos")]
mod mac;
#[cfg(target_os = "windows")]
mod win;
fn main() {
#[cfg(target_os = "linux")]
linux::main().unwrap();
#[cfg(target_os = "macos")]
mac::main().unwrap();
#[cfg(target_os = "windows")]
win::main().unwrap();
}
-35
View File
@@ -1,35 +0,0 @@
use std::error::Error;
use std::fs;
use std::path::{Path, PathBuf};
use crate::common::*;
const PACKAGE: &str = "graphite-desktop-platform-win";
const EXECUTABLE: &str = "graphite-editor.exe";
pub fn main() -> Result<(), Box<dyn Error>> {
let app_bin = build_bin(PACKAGE, None)?;
let executable = bundle(&profile_path(), &app_bin);
// TODO: Consider adding more useful cli
if std::env::args().any(|a| a == "open") {
let executable_path = executable.to_string_lossy();
run_command(&executable_path, &[]).expect("failed to open app")
}
Ok(())
}
fn bundle(out_dir: &Path, app_bin: &Path) -> PathBuf {
let app_dir = out_dir.join(APP_NAME);
clean_dir(&app_dir);
copy_dir(&cef_path(), &app_dir);
let bin_path = app_dir.join(EXECUTABLE);
fs::copy(app_bin, &bin_path).unwrap();
bin_path
}
-12
View File
@@ -1,12 +0,0 @@
[package]
name = "graphite-desktop-platform-linux"
version = "0.0.0"
description = "Graphite Desktop Platform Linux"
authors = ["Graphite Authors <[email protected]>"]
license = "Apache-2.0"
repository = ""
edition = "2024"
rust-version = "1.87"
[dependencies]
graphite-desktop = { path = "../.." }
-3
View File
@@ -1,3 +0,0 @@
fn main() {
graphite_desktop::start();
}
-16
View File
@@ -1,16 +0,0 @@
[package]
name = "graphite-desktop-platform-mac"
version = "0.0.0"
description = "Graphite Desktop Platform Mac"
authors = ["Graphite Authors <[email protected]>"]
license = "Apache-2.0"
repository = ""
edition = "2024"
rust-version = "1.87"
[[bin]]
name = "graphite-desktop-platform-mac-helper"
path = "src/helper.rs"
[dependencies]
graphite-desktop = { path = "../.." }
-3
View File
@@ -1,3 +0,0 @@
fn main() {
graphite_desktop::start_helper();
}
-3
View File
@@ -1,3 +0,0 @@
fn main() {
graphite_desktop::start();
}
-15
View File
@@ -1,15 +0,0 @@
[package]
name = "graphite-desktop-platform-win"
version = "0.0.0"
description = "Graphite Desktop Platform Windows"
authors = ["Graphite Authors <[email protected]>"]
license = "Apache-2.0"
repository = ""
edition = "2024"
rust-version = "1.87"
[dependencies]
graphite-desktop = { path = "../.." }
[target.'cfg(target_os = "windows")'.build-dependencies]
winres = "0.1"
-8
View File
@@ -1,8 +0,0 @@
fn main() {
#[cfg(target_os = "windows")]
{
let mut res = winres::WindowsResource::new();
res.set_icon("../../assets/graphite-icon-color.ico");
res.compile().expect("Failed to compile Windows resources");
}
}
-4
View File
@@ -1,4 +0,0 @@
#![windows_subsystem = "windows"]
fn main() {
graphite_desktop::start();
}
+49 -102
View File
@@ -1,6 +1,5 @@
use rfd::AsyncFileDialog;
use std::fs;
use std::path::PathBuf;
use std::sync::Arc;
use std::sync::mpsc::Receiver;
use std::sync::mpsc::Sender;
use std::sync::mpsc::SyncSender;
@@ -8,27 +7,27 @@ use std::thread;
use std::time::Duration;
use std::time::Instant;
use winit::application::ApplicationHandler;
use winit::dpi::PhysicalSize;
use winit::event::WindowEvent;
use winit::event_loop::ActiveEventLoop;
use winit::event_loop::ControlFlow;
use winit::window::Window;
use winit::window::WindowId;
use crate::cef;
use crate::consts::CEF_MESSAGE_LOOP_MAX_ITERATIONS;
use crate::event::{AppEvent, AppEventScheduler};
use crate::native_window;
use crate::persist::PersistentData;
use crate::render::GraphicsState;
use crate::window::Window;
use crate::wrapper::messages::{DesktopFrontendMessage, DesktopWrapperMessage, Platform};
use crate::wrapper::{DesktopWrapper, NodeGraphExecutionResult, WgpuContext, serialize_frontend_messages};
use graphite_desktop_wrapper::messages::{DesktopFrontendMessage, DesktopWrapperMessage, Platform};
use graphite_desktop_wrapper::{DesktopWrapper, NodeGraphExecutionResult, WgpuContext, serialize_frontend_messages};
pub(crate) struct App {
cef_context: Box<dyn cef::CefContext>,
window: Option<Window>,
window_scale: f64,
window: Option<Arc<dyn Window>>,
native_window: native_window::NativeWindowHandle,
cef_schedule: Option<Instant>,
cef_view_info_sender: Sender<cef::ViewInfoUpdate>,
cef_window_size_sender: Sender<cef::WindowSize>,
graphics_state: Option<GraphicsState>,
wgpu_context: WgpuContext,
app_event_receiver: Receiver<AppEvent>,
@@ -40,17 +39,15 @@ pub(crate) struct App {
web_communication_initialized: bool,
web_communication_startup_buffer: Vec<Vec<u8>>,
persistent_data: PersistentData,
launch_documents: Vec<PathBuf>,
}
impl App {
pub(crate) fn new(
cef_context: Box<dyn cef::CefContext>,
cef_view_info_sender: Sender<cef::ViewInfoUpdate>,
window_size_sender: Sender<cef::WindowSize>,
wgpu_context: WgpuContext,
app_event_receiver: Receiver<AppEvent>,
app_event_scheduler: AppEventScheduler,
launch_documents: Vec<PathBuf>,
) -> Self {
let rendering_app_event_scheduler = app_event_scheduler.clone();
let (start_render_sender, start_render_receiver) = std::sync::mpsc::sync_channel(1);
@@ -68,10 +65,9 @@ impl App {
Self {
cef_context,
window: None,
window_scale: 1.0,
cef_schedule: Some(Instant::now()),
graphics_state: None,
cef_view_info_sender,
cef_window_size_sender: window_size_sender,
wgpu_context,
app_event_receiver,
app_event_scheduler,
@@ -82,11 +78,11 @@ impl App {
web_communication_initialized: false,
web_communication_startup_buffer: Vec::new(),
persistent_data,
launch_documents,
native_window: Default::default(),
}
}
fn handle_desktop_frontend_message(&mut self, message: DesktopFrontendMessage, responses: &mut Vec<DesktopWrapperMessage>) {
fn handle_desktop_frontend_message(&mut self, message: DesktopFrontendMessage) {
match message {
DesktopFrontendMessage::ToWeb(messages) => {
let Some(bytes) = serialize_frontend_messages(messages) else {
@@ -106,7 +102,7 @@ impl App {
let show_dialog = async move { dialog.pick_file().await.map(|f| f.path().to_path_buf()) };
if let Some(path) = futures::executor::block_on(show_dialog)
&& let Ok(content) = fs::read(&path)
&& let Ok(content) = std::fs::read(&path)
{
let message = DesktopWrapperMessage::OpenFileDialogResult { path, content, context };
app_event_scheduler.schedule(AppEvent::DesktopWrapperMessage(message));
@@ -139,7 +135,7 @@ impl App {
});
}
DesktopFrontendMessage::WriteFile { path, content } => {
if let Err(e) = fs::write(&path, content) {
if let Err(e) = std::fs::write(&path, content) {
tracing::error!("Failed to write file {}: {}", path.display(), e);
}
}
@@ -150,19 +146,19 @@ impl App {
}
});
}
DesktopFrontendMessage::UpdateViewportPhysicalBounds { x, y, width, height } => {
DesktopFrontendMessage::UpdateViewportBounds { x, y, width, height } => {
if let Some(graphics_state) = &mut self.graphics_state
&& let Some(window) = &self.window
{
let window_size = window.surface_size();
let viewport_offset_x = x / window_size.width as f64;
let viewport_offset_y = y / window_size.height as f64;
graphics_state.set_viewport_offset([viewport_offset_x as f32, viewport_offset_y as f32]);
let viewport_offset_x = x / window_size.width as f32;
let viewport_offset_y = y / window_size.height as f32;
graphics_state.set_viewport_offset([viewport_offset_x, viewport_offset_y]);
let viewport_scale_x = if width != 0.0 { window_size.width as f64 / width } else { 1.0 };
let viewport_scale_y = if height != 0.0 { window_size.height as f64 / height } else { 1.0 };
graphics_state.set_viewport_scale([viewport_scale_x as f32, viewport_scale_y as f32]);
let viewport_scale_x = if width != 0.0 { window_size.width as f32 / width } else { 1.0 };
let viewport_scale_y = if height != 0.0 { window_size.height as f32 / height } else { 1.0 };
graphics_state.set_viewport_scale([viewport_scale_x, viewport_scale_y]);
}
}
DesktopFrontendMessage::UpdateOverlays(scene) => {
@@ -170,19 +166,15 @@ impl App {
graphics_state.set_overlays_scene(scene);
}
}
DesktopFrontendMessage::MinimizeWindow => {
DesktopFrontendMessage::UpdateWindowState { maximized, minimized } => {
if let Some(window) = &self.window {
window.minimize();
}
}
DesktopFrontendMessage::MaximizeWindow => {
if let Some(window) = &self.window {
window.toggle_maximize();
window.set_maximized(maximized);
window.set_minimized(minimized);
}
}
DesktopFrontendMessage::DragWindow => {
if let Some(window) = &self.window {
window.start_drag();
let _ = window.drag_window();
}
}
DesktopFrontendMessage::CloseWindow => {
@@ -200,14 +192,6 @@ impl App {
DesktopFrontendMessage::PersistenceUpdateDocumentsList { ids } => {
self.persistent_data.set_document_order(ids);
}
DesktopFrontendMessage::PersistenceWritePreferences { preferences } => {
self.persistent_data.write_preferences(preferences);
}
DesktopFrontendMessage::PersistenceLoadPreferences => {
let preferences = self.persistent_data.load_preferences();
let message = DesktopWrapperMessage::LoadPreferences { preferences };
responses.push(message);
}
DesktopFrontendMessage::PersistenceLoadCurrentDocument => {
if let Some((id, document)) = self.persistent_data.current_document() {
let message = DesktopWrapperMessage::LoadDocument {
@@ -216,7 +200,7 @@ impl App {
to_front: false,
select_after_open: true,
};
responses.push(message);
self.dispatch_desktop_wrapper_message(message);
}
}
DesktopFrontendMessage::PersistenceLoadRemainingDocuments => {
@@ -227,7 +211,7 @@ impl App {
to_front: true,
select_after_open: false,
};
responses.push(message);
self.dispatch_desktop_wrapper_message(message);
}
for (id, document) in self.persistent_data.documents_after_current() {
let message = DesktopWrapperMessage::LoadDocument {
@@ -236,46 +220,28 @@ impl App {
to_front: false,
select_after_open: false,
};
responses.push(message);
self.dispatch_desktop_wrapper_message(message);
}
if let Some(id) = self.persistent_data.current_document_id() {
let message = DesktopWrapperMessage::SelectDocument { id };
responses.push(message);
self.dispatch_desktop_wrapper_message(message);
}
}
DesktopFrontendMessage::OpenLaunchDocuments => {
if self.launch_documents.is_empty() {
return;
}
let app_event_scheduler = self.app_event_scheduler.clone();
let launch_documents = std::mem::take(&mut self.launch_documents);
let _ = thread::spawn(move || {
for path in launch_documents {
tracing::info!("Opening file from command line: {}", path.display());
if let Ok(content) = fs::read(&path) {
let message = DesktopWrapperMessage::OpenFile { path, content };
app_event_scheduler.schedule(AppEvent::DesktopWrapperMessage(message));
} else {
tracing::error!("Failed to read file: {}", path.display());
}
}
});
DesktopFrontendMessage::PersistenceWritePreferences { preferences } => {
self.persistent_data.write_preferences(preferences);
}
DesktopFrontendMessage::UpdateMenu { entries } => {
if let Some(window) = &self.window {
window.update_menu(entries);
DesktopFrontendMessage::PersistenceLoadPreferences => {
if let Some(preferences) = self.persistent_data.load_preferences() {
let message = DesktopWrapperMessage::LoadPreferences { preferences };
self.dispatch_desktop_wrapper_message(message);
}
}
}
}
fn handle_desktop_frontend_messages(&mut self, messages: Vec<DesktopFrontendMessage>) {
let mut responses = Vec::new();
for message in messages {
self.handle_desktop_frontend_message(message, &mut responses);
}
for message in responses {
self.dispatch_desktop_wrapper_message(message);
self.handle_desktop_frontend_message(message);
}
}
@@ -335,37 +301,30 @@ impl App {
self.cef_schedule = Some(instant);
}
}
AppEvent::CursorChange(cursor) => {
if let Some(window) = &self.window {
window.set_cursor(cursor);
}
}
AppEvent::CloseWindow => {
// TODO: Implement graceful shutdown
tracing::info!("Exiting main event loop");
event_loop.exit();
}
AppEvent::MenuEvent { id } => {
self.dispatch_desktop_wrapper_message(DesktopWrapperMessage::MenuEvent { id });
}
}
}
}
impl ApplicationHandler for App {
fn can_create_surfaces(&mut self, event_loop: &dyn ActiveEventLoop) {
let window = Window::new(event_loop, self.app_event_scheduler.clone());
let window_attributes = self.native_window.build(event_loop);
self.window_scale = window.scale_factor();
let _ = self.cef_view_info_sender.send(cef::ViewInfoUpdate::Scale(self.window_scale));
self.cef_context.notify_view_info_changed();
let window: Arc<dyn Window> = Arc::from(event_loop.create_window(window_attributes).unwrap());
self.native_window.setup(window.as_ref());
let graphics_state = GraphicsState::new(window.clone(), self.wgpu_context.clone());
self.window = Some(window);
let graphics_state = GraphicsState::new(self.window.as_ref().unwrap(), self.wgpu_context.clone());
self.graphics_state = Some(graphics_state);
tracing::info!("Winit window created and ready");
self.desktop_wrapper.init(self.wgpu_context.clone());
#[cfg(target_os = "windows")]
@@ -390,27 +349,15 @@ impl ApplicationHandler for App {
WindowEvent::CloseRequested => {
self.app_event_scheduler.schedule(AppEvent::CloseWindow);
}
WindowEvent::SurfaceResized(PhysicalSize { width, height }) => {
let _ = self.cef_view_info_sender.send(cef::ViewInfoUpdate::Size {
width: width as usize,
height: height as usize,
});
self.cef_context.notify_view_info_changed();
if let Some(window) = &self.window {
let maximized = window.is_maximized();
self.app_event_scheduler.schedule(AppEvent::DesktopWrapperMessage(DesktopWrapperMessage::UpdateMaximized { maximized }));
}
}
WindowEvent::ScaleFactorChanged { scale_factor, .. } => {
self.window_scale = scale_factor;
let _ = self.cef_view_info_sender.send(cef::ViewInfoUpdate::Scale(self.window_scale));
self.cef_context.notify_view_info_changed();
WindowEvent::SurfaceResized(size) => {
let _ = self.cef_window_size_sender.send(size.into());
self.cef_context.notify_of_resize();
}
WindowEvent::RedrawRequested => {
let Some(ref mut graphics_state) = self.graphics_state else { return };
// Only rerender once we have a new UI texture to display
if let Some(window) = &self.window {
match graphics_state.render(window) {
match graphics_state.render(window.as_ref()) {
Ok(_) => {}
Err(wgpu::SurfaceError::Lost) => {
tracing::warn!("lost surface");
@@ -425,7 +372,7 @@ impl ApplicationHandler for App {
}
WindowEvent::DragDropped { paths, .. } => {
for path in paths {
match fs::read(&path) {
match std::fs::read(&path) {
Ok(content) => {
let message = DesktopWrapperMessage::OpenFile { path, content };
self.app_event_scheduler.schedule(AppEvent::DesktopWrapperMessage(message));
+36 -76
View File
@@ -14,7 +14,7 @@
use crate::event::{AppEvent, AppEventScheduler};
use crate::render::FrameBufferRef;
use crate::wrapper::{WgpuContext, deserialize_editor_message};
use graphite_desktop_wrapper::{WgpuContext, deserialize_editor_message};
use std::fs::File;
use std::io::{Cursor, Read};
use std::path::PathBuf;
@@ -32,70 +32,41 @@ mod platform;
mod utility;
#[cfg(feature = "accelerated_paint")]
use cef::osr_texture_import::SharedTextureHandle;
mod texture_import;
#[cfg(feature = "accelerated_paint")]
use texture_import::SharedTextureHandle;
pub(crate) use context::{CefContext, CefContextBuilder, InitError};
pub(crate) trait CefEventHandler: Send + Sync + 'static {
fn view_info(&self) -> ViewInfo;
pub(crate) trait CefEventHandler: Clone + Send + Sync + 'static {
fn window_size(&self) -> WindowSize;
fn draw<'a>(&self, frame_buffer: FrameBufferRef<'a>);
#[cfg(feature = "accelerated_paint")]
fn draw_gpu(&self, shared_texture: SharedTextureHandle);
fn load_resource(&self, path: PathBuf) -> Option<Resource>;
fn cursor_change(&self, cursor: winit::cursor::Cursor);
/// Schedule the main event loop to run the CEF event loop after the timeout.
/// See [`_cef_browser_process_handler_t::on_schedule_message_pump_work`] for more documentation.
fn schedule_cef_message_loop_work(&self, scheduled_time: Instant);
fn initialized_web_communication(&self);
fn receive_web_message(&self, message: &[u8]);
fn duplicate(&self) -> Self
where
Self: Sized;
}
#[derive(Clone, Copy)]
pub(crate) struct ViewInfo {
width: usize,
height: usize,
scale: f64,
pub(crate) struct WindowSize {
pub(crate) width: usize,
pub(crate) height: usize,
}
impl ViewInfo {
pub(crate) fn new() -> Self {
Self { width: 1, height: 1, scale: 1. }
}
pub(crate) fn apply_update(&mut self, update: ViewInfoUpdate) {
match update {
ViewInfoUpdate::Size { width, height } if width > 0 && height > 0 => {
self.width = width;
self.height = height;
}
ViewInfoUpdate::Scale(scale) if scale > 0. => {
self.scale = scale;
}
_ => {}
}
}
pub(crate) fn zoom(&self) -> f64 {
self.scale.ln() / 1.2_f64.ln()
}
pub(crate) fn width(&self) -> usize {
self.width
}
pub(crate) fn height(&self) -> usize {
self.height
impl WindowSize {
pub(crate) fn new(width: usize, height: usize) -> Self {
Self { width, height }
}
}
impl Default for ViewInfo {
fn default() -> Self {
Self::new()
impl From<winit::dpi::PhysicalSize<u32>> for WindowSize {
fn from(size: winit::dpi::PhysicalSize<u32>) -> Self {
Self::new(size.width as usize, size.height as usize)
}
}
pub(crate) enum ViewInfoUpdate {
Size { width: usize, height: usize },
Scale(f64),
}
#[derive(Clone)]
pub(crate) struct Resource {
pub(crate) reader: ResourceReader,
@@ -117,33 +88,34 @@ impl Read for ResourceReader {
}
}
#[derive(Clone)]
pub(crate) struct CefHandler {
wgpu_context: WgpuContext,
app_event_scheduler: AppEventScheduler,
view_info_receiver: Arc<Mutex<ViewInfoReceiver>>,
window_size_receiver: Arc<Mutex<WindowSizeReceiver>>,
}
impl CefHandler {
pub(crate) fn new(wgpu_context: WgpuContext, app_event_scheduler: AppEventScheduler, view_info_receiver: Receiver<ViewInfoUpdate>) -> Self {
pub(crate) fn new(wgpu_context: WgpuContext, app_event_scheduler: AppEventScheduler, window_size_receiver: Receiver<WindowSize>) -> Self {
Self {
wgpu_context,
app_event_scheduler,
view_info_receiver: Arc::new(Mutex::new(ViewInfoReceiver::new(view_info_receiver))),
window_size_receiver: Arc::new(Mutex::new(WindowSizeReceiver::new(window_size_receiver))),
}
}
}
impl CefEventHandler for CefHandler {
fn view_info(&self) -> ViewInfo {
let Ok(mut guard) = self.view_info_receiver.lock() else {
tracing::error!("Failed to lock view_info_receiver");
return ViewInfo::new();
fn window_size(&self) -> WindowSize {
let Ok(mut guard) = self.window_size_receiver.lock() else {
tracing::error!("Failed to lock window_size_receiver");
return WindowSize::new(1, 1);
};
let ViewInfoReceiver { receiver, view_info } = &mut *guard;
for update in receiver.try_iter() {
view_info.apply_update(update);
let WindowSizeReceiver { receiver, window_size } = &mut *guard;
for new_window_size in receiver.try_iter() {
*window_size = new_window_size;
}
*view_info
*window_size
}
fn draw<'a>(&self, frame_buffer: FrameBufferRef<'a>) {
let width = frame_buffer.width() as u32;
@@ -252,10 +224,6 @@ impl CefEventHandler for CefHandler {
None
}
fn cursor_change(&self, cursor: winit::cursor::Cursor) {
self.app_event_scheduler.schedule(AppEvent::CursorChange(cursor));
}
fn schedule_cef_message_loop_work(&self, scheduled_time: std::time::Instant) {
self.app_event_scheduler.schedule(AppEvent::ScheduleBrowserWork(scheduled_time));
}
@@ -271,25 +239,17 @@ impl CefEventHandler for CefHandler {
};
self.app_event_scheduler.schedule(AppEvent::DesktopWrapperMessage(desktop_wrapper_message));
}
}
fn duplicate(&self) -> Self
where
Self: Sized,
{
struct WindowSizeReceiver {
window_size: WindowSize,
receiver: Receiver<WindowSize>,
}
impl WindowSizeReceiver {
fn new(window_size_receiver: Receiver<WindowSize>) -> Self {
Self {
wgpu_context: self.wgpu_context.clone(),
app_event_scheduler: self.app_event_scheduler.clone(),
view_info_receiver: self.view_info_receiver.clone(),
window_size: WindowSize { width: 1, height: 1 },
receiver: window_size_receiver,
}
}
}
struct ViewInfoReceiver {
view_info: ViewInfo,
receiver: Receiver<ViewInfoUpdate>,
}
impl ViewInfoReceiver {
fn new(receiver: Receiver<ViewInfoUpdate>) -> Self {
Self { view_info: ViewInfo::new(), receiver }
}
}
-2
View File
@@ -8,7 +8,5 @@ pub(crate) const SCROLL_LINE_WIDTH: usize = 40;
pub(crate) const SCROLL_SPEED_X: f32 = 3.0;
pub(crate) const SCROLL_SPEED_Y: f32 = 3.0;
pub(crate) const PINCH_ZOOM_SPEED: f64 = 300.0;
pub(crate) const MULTICLICK_TIMEOUT: Duration = Duration::from_millis(500);
pub(crate) const MULTICLICK_ALLOWED_TRAVEL: usize = 4;
+1 -2
View File
@@ -1,4 +1,3 @@
#[cfg(not(target_os = "macos"))]
mod multithreaded;
mod singlethreaded;
@@ -10,7 +9,7 @@ pub(crate) trait CefContext {
fn handle_window_event(&mut self, event: &winit::event::WindowEvent);
fn notify_view_info_changed(&self);
fn notify_of_resize(&self);
fn send_web_message(&self, message: Vec<u8>);
}
+22 -49
View File
@@ -1,9 +1,9 @@
use std::path::{Path, PathBuf};
use std::path::PathBuf;
use cef::args::Args;
use cef::sys::{CEF_API_VERSION_LAST, cef_resultcode_t};
use cef::{
App, BrowserSettings, CefString, Client, DictionaryValue, ImplCommandLine, ImplRequestContext, RequestContextSettings, SchemeHandlerFactory, Settings, WindowInfo, api_hash,
App, BrowserSettings, CefString, Client, DictionaryValue, ImplCommandLine, ImplRequestContext, RenderHandler, RequestContextSettings, SchemeHandlerFactory, Settings, WindowInfo, api_hash,
browser_host_create_browser_sync, execute_process,
};
@@ -13,7 +13,7 @@ use crate::cef::CefEventHandler;
use crate::cef::consts::{RESOURCE_DOMAIN, RESOURCE_SCHEME};
use crate::cef::dirs::create_instance_dir;
use crate::cef::input::InputState;
use crate::cef::internal::{BrowserProcessAppImpl, BrowserProcessClientImpl, RenderProcessAppImpl, SchemeHandlerFactoryImpl};
use crate::cef::internal::{BrowserProcessAppImpl, BrowserProcessClientImpl, RenderHandlerImpl, RenderProcessAppImpl, SchemeHandlerFactoryImpl};
pub(crate) struct CefContextBuilder<H: CefEventHandler> {
pub(crate) args: Args,
@@ -25,23 +25,12 @@ unsafe impl<H: CefEventHandler> Send for CefContextBuilder<H> {}
impl<H: CefEventHandler> CefContextBuilder<H> {
pub(crate) fn new() -> Self {
Self::new_inner(false)
}
pub(crate) fn new_helper() -> Self {
Self::new_inner(true)
}
fn new_inner(helper: bool) -> Self {
#[cfg(target_os = "macos")]
let _loader = {
let loader = cef::library_loader::LibraryLoader::new(&std::env::current_exe().unwrap(), helper);
let loader = library_loader::LibraryLoader::new(&std::env::current_exe().unwrap(), false);
assert!(loader.load());
loader
};
#[cfg(not(target_os = "macos"))]
let _ = helper;
let _ = api_hash(CEF_API_VERSION_LAST, 0);
let args = Args::new();
@@ -73,48 +62,39 @@ impl<H: CefEventHandler> CefContextBuilder<H> {
}
}
fn common_settings(instance_dir: &Path) -> Settings {
Settings {
windowless_rendering_enabled: 1,
root_cache_path: instance_dir.to_str().map(CefString::from).unwrap(),
cache_path: CefString::from(""),
disable_signal_handlers: 1,
..Default::default()
}
}
#[cfg(target_os = "macos")]
pub(crate) fn initialize(self, event_handler: H, disable_gpu_acceleration: bool) -> Result<impl CefContext, InitError> {
pub(crate) fn initialize(self, event_handler: H) -> Result<impl CefContext, InitError> {
let instance_dir = create_instance_dir();
let exe = std::env::current_exe().expect("cannot get current exe path");
let app_root = exe.parent().and_then(|p| p.parent()).expect("bad path structure").parent().expect("bad path structure");
let settings = Settings {
main_bundle_path: CefString::from(app_root.to_str().unwrap()),
windowless_rendering_enabled: 1,
multi_threaded_message_loop: 0,
external_message_pump: 1,
no_sandbox: 1, // GPU helper crashes when running with sandbox
..Self::common_settings(&instance_dir)
root_cache_path: instance_dir.to_str().map(CefString::from).unwrap(),
cache_path: CefString::from(""),
..Default::default()
};
self.initialize_inner(&event_handler, settings)?;
create_browser(event_handler, instance_dir, disable_gpu_acceleration)
create_browser(event_handler, instance_dir)
}
#[cfg(not(target_os = "macos"))]
pub(crate) fn initialize(self, event_handler: H, disable_gpu_acceleration: bool) -> Result<impl CefContext, InitError> {
pub(crate) fn initialize(self, event_handler: H) -> Result<impl CefContext, InitError> {
let instance_dir = create_instance_dir();
let settings = Settings {
windowless_rendering_enabled: 1,
multi_threaded_message_loop: 1,
..Self::common_settings(&instance_dir)
root_cache_path: instance_dir.to_str().map(CefString::from).unwrap(),
cache_path: CefString::from(""),
..Default::default()
};
self.initialize_inner(&event_handler, settings)?;
super::multithreaded::run_on_ui_thread(move || match create_browser(event_handler, instance_dir, disable_gpu_acceleration) {
super::multithreaded::run_on_ui_thread(move || match create_browser(event_handler, instance_dir) {
Ok(context) => {
super::multithreaded::CONTEXT.with(|b| {
*b.borrow_mut() = Some(context);
@@ -131,7 +111,7 @@ impl<H: CefEventHandler> CefContextBuilder<H> {
fn initialize_inner(self, event_handler: &H, settings: Settings) -> Result<(), InitError> {
// Attention! Wrapping this in an extra App is necessary, otherwise the program still compiles but segfaults
let mut cef_app = App::new(BrowserProcessAppImpl::new(event_handler.duplicate()));
let mut cef_app = App::new(BrowserProcessAppImpl::new(event_handler.clone()));
let result = cef::initialize(Some(self.args.as_main_args()), Some(&settings), Some(&mut cef_app), std::ptr::null_mut());
if result != 1 {
@@ -145,20 +125,14 @@ impl<H: CefEventHandler> CefContextBuilder<H> {
}
}
fn create_browser<H: CefEventHandler>(event_handler: H, instance_dir: PathBuf, disable_gpu_acceleration: bool) -> Result<SingleThreadedCefContext, InitError> {
let mut client = Client::new(BrowserProcessClientImpl::new(&event_handler));
#[cfg(feature = "accelerated_paint")]
let use_accelerated_paint = if disable_gpu_acceleration {
false
} else {
crate::cef::platform::should_enable_hardware_acceleration()
};
fn create_browser<H: CefEventHandler>(event_handler: H, instance_dir: PathBuf) -> Result<SingleThreadedCefContext, InitError> {
let render_handler = RenderHandler::new(RenderHandlerImpl::new(event_handler.clone()));
let mut client = Client::new(BrowserProcessClientImpl::new(render_handler, event_handler.clone()));
let window_info = WindowInfo {
windowless_rendering_enabled: 1,
#[cfg(feature = "accelerated_paint")]
shared_texture_enabled: use_accelerated_paint as i32,
shared_texture_enabled: if crate::cef::platform::should_enable_hardware_acceleration() { 1 } else { 0 },
..Default::default()
};
@@ -179,7 +153,7 @@ fn create_browser<H: CefEventHandler>(event_handler: H, instance_dir: PathBuf, d
return Err(InitError::RequestContextCreationFailed);
};
let mut scheme_handler_factory = SchemeHandlerFactory::new(SchemeHandlerFactoryImpl::new(event_handler.duplicate()));
let mut scheme_handler_factory = SchemeHandlerFactory::new(SchemeHandlerFactoryImpl::new(event_handler.clone()));
incognito_request_context.clear_scheme_handler_factories();
incognito_request_context.register_scheme_handler_factory(Some(&CefString::from(RESOURCE_SCHEME)), Some(&CefString::from(RESOURCE_DOMAIN)), Some(&mut scheme_handler_factory));
@@ -196,7 +170,6 @@ fn create_browser<H: CefEventHandler>(event_handler: H, instance_dir: PathBuf, d
if let Some(browser) = browser {
Ok(SingleThreadedCefContext {
event_handler: Box::new(event_handler),
browser,
input_state: InputState::default(),
instance_dir,
+2 -2
View File
@@ -30,11 +30,11 @@ impl CefContext for MultiThreadedCefContextProxy {
});
}
fn notify_view_info_changed(&self) {
fn notify_of_resize(&self) {
run_on_ui_thread(move || {
CONTEXT.with(|b| {
if let Some(context) = b.borrow_mut().as_mut() {
context.notify_view_info_changed();
context.notify_of_resize();
}
});
});
+4 -8
View File
@@ -1,14 +1,13 @@
use cef::{Browser, ImplBrowser, ImplBrowserHost};
use winit::event::WindowEvent;
use crate::cef::input;
use crate::cef::input::InputState;
use crate::cef::ipc::{MessageType, SendMessage};
use crate::cef::{CefEventHandler, input};
use super::CefContext;
pub(super) struct SingleThreadedCefContext {
pub(super) event_handler: Box<dyn CefEventHandler>,
pub(super) browser: Browser,
pub(super) input_state: InputState,
pub(super) instance_dir: std::path::PathBuf,
@@ -20,14 +19,11 @@ impl CefContext for SingleThreadedCefContext {
}
fn handle_window_event(&mut self, event: &WindowEvent) {
input::handle_window_event(&self.browser, &mut self.input_state, event);
input::handle_window_event(&self.browser, &mut self.input_state, event)
}
fn notify_view_info_changed(&self) {
let view_info = self.event_handler.view_info();
let host = self.browser.host().unwrap();
host.set_zoom_level(view_info.zoom());
host.was_resized();
fn notify_of_resize(&self) {
self.browser.host().unwrap().was_resized();
}
fn send_web_message(&self, message: Vec<u8>) {
+47 -77
View File
@@ -7,24 +7,18 @@ use winit::event::{ButtonSource, ElementState, MouseButton, MouseScrollDelta, Wi
mod keymap;
use keymap::{ToNativeKeycode, ToVKBits};
use super::consts::{MULTICLICK_ALLOWED_TRAVEL, MULTICLICK_TIMEOUT, PINCH_ZOOM_SPEED, SCROLL_LINE_HEIGHT, SCROLL_LINE_WIDTH, SCROLL_SPEED_X, SCROLL_SPEED_Y};
use super::consts::{MULTICLICK_ALLOWED_TRAVEL, MULTICLICK_TIMEOUT, SCROLL_LINE_HEIGHT, SCROLL_LINE_WIDTH, SCROLL_SPEED_X, SCROLL_SPEED_Y};
pub(crate) fn handle_window_event(browser: &Browser, input_state: &mut InputState, event: &WindowEvent) {
match event {
WindowEvent::PointerMoved { position, .. } | WindowEvent::PointerEntered { position, .. } => {
input_state.cursor_move(&position);
WindowEvent::PointerMoved { position, .. } => {
input_state.cursor_move(position);
let Some(host) = browser.host() else { return };
let Some(host) = browser.host() else {
return;
};
host.send_mouse_move_event(Some(&input_state.into()), 0);
}
WindowEvent::PointerLeft { position, .. } => {
if let Some(position) = position {
input_state.cursor_move(&position);
}
let Some(host) = browser.host() else { return };
host.send_mouse_move_event(Some(&input_state.into()), 1);
}
WindowEvent::PointerButton { state, button, .. } => {
let mouse_button = match button {
ButtonSource::Mouse(mouse_button) => mouse_button,
@@ -45,7 +39,9 @@ pub(crate) fn handle_window_event(browser: &Browser, input_state: &mut InputStat
_ => return, //TODO: Handle Forward and Back button
};
let Some(host) = browser.host() else { return };
let Some(host) = browser.host() else {
return;
};
host.send_mouse_click_event(Some(&input_state.into()), cef_button, cef_mouse_up, cef_click_count);
}
WindowEvent::MouseWheel { delta, phase: _, device_id: _, .. } => {
@@ -57,7 +53,9 @@ pub(crate) fn handle_window_event(browser: &Browser, input_state: &mut InputStat
delta_x *= SCROLL_SPEED_X;
delta_y *= SCROLL_SPEED_Y;
let Some(host) = browser.host() else { return };
let Some(host) = browser.host() else {
return;
};
host.send_mouse_wheel_event(Some(&mouse_event), delta_x as i32, delta_y as i32);
}
WindowEvent::ModifiersChanged(modifiers) => {
@@ -97,7 +95,9 @@ pub(crate) fn handle_window_event(browser: &Browser, input_state: &mut InputStat
key_event.native_key_code = native_key_code;
let Some(host) = browser.host() else { return };
let Some(host) = browser.host() else {
return;
};
match event.state {
ElementState::Pressed => {
@@ -129,20 +129,6 @@ pub(crate) fn handle_window_event(browser: &Browser, input_state: &mut InputStat
}
}
}
WindowEvent::PinchGesture { delta, .. } => {
if !delta.is_normal() {
return;
}
let Some(host) = browser.host() else { return };
let mut mouse_event: MouseEvent = input_state.into();
mouse_event.modifiers |= cef_event_flags_t::EVENTFLAG_CONTROL_DOWN as u32;
mouse_event.modifiers |= cef_event_flags_t::EVENTFLAG_PRECISION_SCROLLING_DELTA as u32;
let delta = (delta * PINCH_ZOOM_SPEED).round() as i32;
host.send_mouse_wheel_event(Some(&mouse_event), 0, delta);
}
_ => {}
}
}
@@ -165,7 +151,7 @@ impl InputState {
fn mouse_input(&mut self, button: &MouseButton, state: &ElementState) -> ClickCount {
self.mouse_state.update(button, state);
self.mouse_click_tracker.input(button, state, self.mouse_position)
self.mouse_click_tracker.input(button, state, &self.mouse_position)
}
fn cef_modifiers(&self, location: &winit::keyboard::KeyLocation, is_repeat: bool) -> CefModifiers {
@@ -201,7 +187,7 @@ impl From<&mut InputState> for MouseEvent {
}
}
#[derive(Default, Clone, Copy)]
#[derive(Default, Clone)]
pub(crate) struct MousePosition {
x: usize,
y: usize,
@@ -247,7 +233,7 @@ struct ClickTracker {
right: Option<ClickRecord>,
}
impl ClickTracker {
fn input(&mut self, button: &MouseButton, state: &ElementState, position: MousePosition) -> ClickCount {
fn input(&mut self, button: &MouseButton, state: &ElementState, position: &MousePosition) -> ClickCount {
let record = match button {
MouseButton::Left => &mut self.left,
MouseButton::Right => &mut self.right,
@@ -255,57 +241,53 @@ impl ClickTracker {
_ => return ClickCount::Single,
};
let now = Instant::now();
let Some(record) = record else {
*record = Some(ClickRecord { position, ..Default::default() });
*record = Some(ClickRecord {
time: now,
position: position.clone(),
down_count: ClickCount::Single,
up_count: ClickCount::Single,
});
return ClickCount::Single;
};
let prev_time = record.time;
let prev_position = record.position;
let now = Instant::now();
record.time = now;
record.position = position;
match state {
ElementState::Pressed if record.down_count == ClickCount::Double => {
*record = ClickRecord {
down_count: ClickCount::Single,
..*record
};
return ClickCount::Single;
}
ElementState::Released if record.up_count == ClickCount::Double => {
*record = ClickRecord {
up_count: ClickCount::Single,
..*record
};
return ClickCount::Single;
}
_ => {}
}
let dx = position.x.abs_diff(prev_position.x);
let dy = position.y.abs_diff(prev_position.y);
let dx = position.x.abs_diff(record.position.x);
let dy = position.y.abs_diff(record.position.y);
let within_dist = dx <= MULTICLICK_ALLOWED_TRAVEL && dy <= MULTICLICK_ALLOWED_TRAVEL;
let within_time = now.saturating_duration_since(prev_time) <= MULTICLICK_TIMEOUT;
let within_time = now.saturating_duration_since(record.time) <= MULTICLICK_TIMEOUT;
let count = if within_time && within_dist { ClickCount::Double } else { ClickCount::Single };
*record = match state {
ElementState::Pressed => ClickRecord { down_count: count, ..*record },
ElementState::Released => ClickRecord { up_count: count, ..*record },
ElementState::Pressed => ClickRecord {
time: now,
position: position.clone(),
down_count: count.clone(),
up_count: record.up_count.clone(),
},
ElementState::Released => ClickRecord {
time: now,
position: position.clone(),
down_count: record.down_count.clone(),
up_count: count.clone(),
},
};
count
}
}
#[derive(Clone, Copy, PartialEq, Default)]
#[derive(Clone)]
enum ClickCount {
#[default]
Single,
Double,
}
impl Default for ClickCount {
fn default() -> Self {
Self::Single
}
}
impl From<ClickCount> for i32 {
fn from(count: ClickCount) -> i32 {
match count {
@@ -315,7 +297,6 @@ impl From<ClickCount> for i32 {
}
}
#[derive(Clone, Copy)]
struct ClickRecord {
time: Instant,
position: MousePosition,
@@ -323,17 +304,6 @@ struct ClickRecord {
up_count: ClickCount,
}
impl Default for ClickRecord {
fn default() -> Self {
Self {
time: Instant::now(),
position: Default::default(),
down_count: Default::default(),
up_count: Default::default(),
}
}
}
struct CefModifiers(u32);
impl CefModifiers {
fn new(input_state: &InputState, location: &winit::keyboard::KeyLocation, is_repeat: bool) -> Self {
+1 -5
View File
@@ -2,7 +2,6 @@ mod browser_process_app;
mod browser_process_client;
mod browser_process_handler;
mod browser_process_life_span_handler;
mod browser_process_load_handler;
mod render_process_app;
mod render_process_handler;
@@ -11,14 +10,11 @@ mod render_process_v8_handler;
mod resource_handler;
mod scheme_handler_factory;
mod display_handler;
pub(super) mod render_handler;
#[cfg(not(target_os = "macos"))]
pub(super) mod task;
pub(super) use browser_process_app::BrowserProcessAppImpl;
pub(super) use browser_process_client::BrowserProcessClientImpl;
pub(super) use render_handler::RenderHandlerImpl;
pub(super) use render_process_app::RenderProcessAppImpl;
pub(super) use scheme_handler_factory::SchemeHandlerFactoryImpl;
@@ -13,7 +13,7 @@ pub(crate) struct BrowserProcessAppImpl<H: CefEventHandler> {
object: *mut RcImpl<_cef_app_t, Self>,
event_handler: H,
}
impl<H: CefEventHandler> BrowserProcessAppImpl<H> {
impl<H: CefEventHandler + Clone> BrowserProcessAppImpl<H> {
pub(crate) fn new(event_handler: H) -> Self {
Self {
object: std::ptr::null_mut(),
@@ -22,9 +22,9 @@ impl<H: CefEventHandler> BrowserProcessAppImpl<H> {
}
}
impl<H: CefEventHandler> ImplApp for BrowserProcessAppImpl<H> {
impl<H: CefEventHandler + Clone> ImplApp for BrowserProcessAppImpl<H> {
fn browser_process_handler(&self) -> Option<BrowserProcessHandler> {
Some(BrowserProcessHandler::new(BrowserProcessHandlerImpl::new(self.event_handler.duplicate())))
Some(BrowserProcessHandler::new(BrowserProcessHandlerImpl::new(self.event_handler.clone())))
}
fn on_register_custom_schemes(&self, registrar: Option<&mut SchemeRegistrar>) {
@@ -66,12 +66,6 @@ impl<H: CefEventHandler> ImplApp for BrowserProcessAppImpl<H> {
cmd.append_switch_with_value(Some(&CefString::from("ozone-platform")), Some(&CefString::from("wayland")));
}
}
#[cfg(target_os = "macos")]
{
// Hide user prompt asking for keychain access
cmd.append_switch(Some(&CefString::from("use-mock-keychain")));
}
}
}
@@ -80,7 +74,7 @@ impl<H: CefEventHandler> ImplApp for BrowserProcessAppImpl<H> {
}
}
impl<H: CefEventHandler> Clone for BrowserProcessAppImpl<H> {
impl<H: CefEventHandler + Clone> Clone for BrowserProcessAppImpl<H> {
fn clone(&self) -> Self {
unsafe {
let rc_impl = &mut *self.object;
@@ -88,7 +82,7 @@ impl<H: CefEventHandler> Clone for BrowserProcessAppImpl<H> {
}
Self {
object: self.object,
event_handler: self.event_handler.duplicate(),
event_handler: self.event_handler.clone(),
}
}
}
@@ -100,7 +94,7 @@ impl<H: CefEventHandler> Rc for BrowserProcessAppImpl<H> {
}
}
}
impl<H: CefEventHandler> WrapApp for BrowserProcessAppImpl<H> {
impl<H: CefEventHandler + Clone> WrapApp for BrowserProcessAppImpl<H> {
fn wrap_rc(&mut self, object: *mut RcImpl<_cef_app_t, Self>) {
self.object = object;
}
@@ -1,30 +1,23 @@
use cef::rc::{Rc, RcImpl};
use cef::sys::{_cef_client_t, cef_base_ref_counted_t};
use cef::{DisplayHandler, ImplClient, LifeSpanHandler, LoadHandler, RenderHandler, WrapClient};
use cef::{ImplClient, LifeSpanHandler, RenderHandler, WrapClient};
use crate::cef::CefEventHandler;
use crate::cef::ipc::{MessageType, UnpackMessage, UnpackedMessage};
use super::browser_process_life_span_handler::BrowserProcessLifeSpanHandlerImpl;
use super::browser_process_load_handler::LoadHandlerImpl;
use super::display_handler::DisplayHandlerImpl;
use super::render_handler::RenderHandlerImpl;
pub(crate) struct BrowserProcessClientImpl<H: CefEventHandler> {
object: *mut RcImpl<_cef_client_t, Self>,
event_handler: H,
load_handler: LoadHandler,
render_handler: RenderHandler,
display_handler: DisplayHandler,
event_handler: H,
}
impl<H: CefEventHandler> BrowserProcessClientImpl<H> {
pub(crate) fn new(event_handler: &H) -> Self {
pub(crate) fn new(render_handler: RenderHandler, event_handler: H) -> Self {
Self {
object: std::ptr::null_mut(),
event_handler: event_handler.duplicate(),
load_handler: LoadHandler::new(LoadHandlerImpl::new(event_handler.duplicate())),
render_handler: RenderHandler::new(RenderHandlerImpl::new(event_handler.duplicate())),
display_handler: DisplayHandler::new(DisplayHandlerImpl::new(event_handler.duplicate())),
render_handler,
event_handler,
}
}
}
@@ -56,10 +49,6 @@ impl<H: CefEventHandler> ImplClient for BrowserProcessClientImpl<H> {
1
}
fn load_handler(&self) -> Option<cef::LoadHandler> {
Some(self.load_handler.clone())
}
fn render_handler(&self) -> Option<RenderHandler> {
Some(self.render_handler.clone())
}
@@ -68,10 +57,6 @@ impl<H: CefEventHandler> ImplClient for BrowserProcessClientImpl<H> {
Some(LifeSpanHandler::new(BrowserProcessLifeSpanHandlerImpl::new()))
}
fn display_handler(&self) -> Option<cef::DisplayHandler> {
Some(self.display_handler.clone())
}
fn get_raw(&self) -> *mut _cef_client_t {
self.object.cast()
}
@@ -85,10 +70,8 @@ impl<H: CefEventHandler> Clone for BrowserProcessClientImpl<H> {
}
Self {
object: self.object,
event_handler: self.event_handler.duplicate(),
load_handler: self.load_handler.clone(),
render_handler: self.render_handler.clone(),
display_handler: self.display_handler.clone(),
event_handler: self.event_handler.clone(),
}
}
}
@@ -19,7 +19,7 @@ impl<H: CefEventHandler> BrowserProcessHandlerImpl<H> {
}
}
impl<H: CefEventHandler> ImplBrowserProcessHandler for BrowserProcessHandlerImpl<H> {
impl<H: CefEventHandler + Clone> ImplBrowserProcessHandler for BrowserProcessHandlerImpl<H> {
fn on_schedule_message_pump_work(&self, delay_ms: i64) {
self.event_handler.schedule_cef_message_loop_work(Instant::now() + Duration::from_millis(delay_ms as u64));
}
@@ -33,7 +33,7 @@ impl<H: CefEventHandler> ImplBrowserProcessHandler for BrowserProcessHandlerImpl
}
}
impl<H: CefEventHandler> Clone for BrowserProcessHandlerImpl<H> {
impl<H: CefEventHandler + Clone> Clone for BrowserProcessHandlerImpl<H> {
fn clone(&self) -> Self {
unsafe {
let rc_impl = &mut *self.object;
@@ -41,7 +41,7 @@ impl<H: CefEventHandler> Clone for BrowserProcessHandlerImpl<H> {
}
Self {
object: self.object,
event_handler: self.event_handler.duplicate(),
event_handler: self.event_handler.clone(),
}
}
}
@@ -53,7 +53,7 @@ impl<H: CefEventHandler> Rc for BrowserProcessHandlerImpl<H> {
}
}
}
impl<H: CefEventHandler> WrapBrowserProcessHandler for BrowserProcessHandlerImpl<H> {
impl<H: CefEventHandler + Clone> WrapBrowserProcessHandler for BrowserProcessHandlerImpl<H> {
fn wrap_rc(&mut self, object: *mut RcImpl<_cef_browser_process_handler_t, Self>) {
self.object = object;
}
@@ -23,7 +23,7 @@ impl ImplLifeSpanHandler for BrowserProcessLifeSpanHandlerImpl {
_user_gesture: ::std::os::raw::c_int,
_popup_features: Option<&cef::PopupFeatures>,
_window_info: Option<&mut cef::WindowInfo>,
_client: Option<&mut Option<cef::Client>>,
_client: Option<&mut Option<impl cef::ImplClient>>,
_settings: Option<&mut cef::BrowserSettings>,
_extra_info: Option<&mut Option<cef::DictionaryValue>>,
_no_javascript_access: Option<&mut ::std::os::raw::c_int>,
@@ -1,60 +0,0 @@
use cef::rc::{Rc, RcImpl};
use cef::sys::{_cef_load_handler_t, cef_base_ref_counted_t, cef_load_handler_t};
use cef::{ImplBrowser, ImplBrowserHost, ImplLoadHandler, WrapLoadHandler};
use crate::cef::CefEventHandler;
pub(crate) struct LoadHandlerImpl<H: CefEventHandler> {
object: *mut RcImpl<cef_load_handler_t, Self>,
event_handler: H,
}
impl<H: CefEventHandler> LoadHandlerImpl<H> {
pub(crate) fn new(event_handler: H) -> Self {
Self {
object: std::ptr::null_mut(),
event_handler,
}
}
}
impl<H: CefEventHandler> ImplLoadHandler for LoadHandlerImpl<H> {
fn on_loading_state_change(&self, browser: Option<&mut cef::Browser>, is_loading: ::std::os::raw::c_int, _can_go_back: ::std::os::raw::c_int, _can_go_forward: ::std::os::raw::c_int) {
let view_info = self.event_handler.view_info();
if let Some(browser) = browser
&& is_loading == 0
{
browser.host().unwrap().set_zoom_level(view_info.zoom());
}
}
fn get_raw(&self) -> *mut _cef_load_handler_t {
self.object.cast()
}
}
impl<H: CefEventHandler> Clone for LoadHandlerImpl<H> {
fn clone(&self) -> Self {
unsafe {
let rc_impl = &mut *self.object;
rc_impl.interface.add_ref();
}
Self {
object: self.object,
event_handler: self.event_handler.duplicate(),
}
}
}
impl<H: CefEventHandler> Rc for LoadHandlerImpl<H> {
fn as_base(&self) -> &cef_base_ref_counted_t {
unsafe {
let base = &*self.object;
std::mem::transmute(&base.cef_object)
}
}
}
impl<H: CefEventHandler> WrapLoadHandler for LoadHandlerImpl<H> {
fn wrap_rc(&mut self, object: *mut RcImpl<_cef_load_handler_t, Self>) {
self.object = object;
}
}
-141
View File
@@ -1,141 +0,0 @@
use cef::rc::{Rc, RcImpl};
use cef::sys::{_cef_display_handler_t, cef_base_ref_counted_t, cef_cursor_type_t::*, cef_log_severity_t::*};
use cef::{CefString, ImplDisplayHandler, WrapDisplayHandler};
use winit::cursor::CursorIcon;
use crate::cef::CefEventHandler;
pub(crate) struct DisplayHandlerImpl<H: CefEventHandler> {
object: *mut RcImpl<_cef_display_handler_t, Self>,
event_handler: H,
}
impl<H: CefEventHandler> DisplayHandlerImpl<H> {
pub fn new(event_handler: H) -> Self {
Self {
object: std::ptr::null_mut(),
event_handler,
}
}
}
#[cfg(not(target_os = "macos"))]
type CefCursorHandle = cef::CursorHandle;
#[cfg(target_os = "macos")]
type CefCursorHandle = *mut u8;
impl<H: CefEventHandler> ImplDisplayHandler for DisplayHandlerImpl<H> {
fn on_cursor_change(&self, _browser: Option<&mut cef::Browser>, _cursor: CefCursorHandle, cursor_type: cef::CursorType, _custom_cursor_info: Option<&cef::CursorInfo>) -> ::std::os::raw::c_int {
let cursor = match cursor_type.into() {
CT_POINTER => CursorIcon::Default,
CT_CROSS => CursorIcon::Crosshair,
CT_HAND => CursorIcon::Pointer,
CT_IBEAM => CursorIcon::Text,
CT_WAIT => CursorIcon::Wait,
CT_HELP => CursorIcon::Help,
CT_EASTRESIZE => CursorIcon::EResize,
CT_NORTHRESIZE => CursorIcon::NResize,
CT_NORTHEASTRESIZE => CursorIcon::NeResize,
CT_NORTHWESTRESIZE => CursorIcon::NwResize,
CT_SOUTHRESIZE => CursorIcon::SResize,
CT_SOUTHEASTRESIZE => CursorIcon::SeResize,
CT_SOUTHWESTRESIZE => CursorIcon::SwResize,
CT_WESTRESIZE => CursorIcon::WResize,
CT_NORTHSOUTHRESIZE => CursorIcon::NsResize,
CT_EASTWESTRESIZE => CursorIcon::EwResize,
CT_NORTHEASTSOUTHWESTRESIZE => CursorIcon::NeswResize,
CT_NORTHWESTSOUTHEASTRESIZE => CursorIcon::NwseResize,
CT_COLUMNRESIZE => CursorIcon::ColResize,
CT_ROWRESIZE => CursorIcon::RowResize,
CT_MIDDLEPANNING => CursorIcon::AllScroll,
CT_EASTPANNING => CursorIcon::AllScroll,
CT_NORTHPANNING => CursorIcon::AllScroll,
CT_NORTHEASTPANNING => CursorIcon::AllScroll,
CT_NORTHWESTPANNING => CursorIcon::AllScroll,
CT_SOUTHPANNING => CursorIcon::AllScroll,
CT_SOUTHEASTPANNING => CursorIcon::AllScroll,
CT_SOUTHWESTPANNING => CursorIcon::AllScroll,
CT_WESTPANNING => CursorIcon::AllScroll,
CT_MOVE => CursorIcon::Move,
CT_VERTICALTEXT => CursorIcon::VerticalText,
CT_CELL => CursorIcon::Cell,
CT_CONTEXTMENU => CursorIcon::ContextMenu,
CT_ALIAS => CursorIcon::Alias,
CT_PROGRESS => CursorIcon::Progress,
CT_NODROP => CursorIcon::NoDrop,
CT_COPY => CursorIcon::Copy,
CT_NONE => CursorIcon::Default,
CT_NOTALLOWED => CursorIcon::NotAllowed,
CT_ZOOMIN => CursorIcon::ZoomIn,
CT_ZOOMOUT => CursorIcon::ZoomOut,
CT_GRAB => CursorIcon::Grab,
CT_GRABBING => CursorIcon::Grabbing,
CT_MIDDLE_PANNING_VERTICAL => CursorIcon::AllScroll,
CT_MIDDLE_PANNING_HORIZONTAL => CursorIcon::AllScroll,
CT_CUSTOM => CursorIcon::Default,
CT_DND_NONE => CursorIcon::Default,
CT_DND_MOVE => CursorIcon::Move,
CT_DND_COPY => CursorIcon::Copy,
CT_DND_LINK => CursorIcon::Alias,
CT_NUM_VALUES => CursorIcon::Default,
_ => CursorIcon::Default,
};
self.event_handler.cursor_change(cursor.into());
1 // We handled the cursor change.
}
fn on_console_message(
&self,
_browser: Option<&mut cef::Browser>,
level: cef::LogSeverity,
message: Option<&CefString>,
source: Option<&CefString>,
line: ::std::os::raw::c_int,
) -> ::std::os::raw::c_int {
let message = message.map(|m| m.to_string()).unwrap_or_default();
let source = source.map(|s| s.to_string()).unwrap_or_default();
let line = line as i64;
let browser_source = format!("{source}:{line}");
static BROWSER: &str = "browser";
match level.as_ref() {
LOGSEVERITY_FATAL | LOGSEVERITY_ERROR => tracing::error!(target: BROWSER, "{browser_source} {message}"),
LOGSEVERITY_WARNING => tracing::warn!(target: BROWSER, "{browser_source} {message}"),
LOGSEVERITY_INFO => tracing::info!(target: BROWSER, "{browser_source} {message}"),
LOGSEVERITY_DEFAULT | LOGSEVERITY_VERBOSE => tracing::debug!(target: BROWSER, "{browser_source} {message}"),
_ => tracing::trace!(target: BROWSER, "{browser_source} {message}"),
}
0
}
fn get_raw(&self) -> *mut _cef_display_handler_t {
self.object.cast()
}
}
impl<H: CefEventHandler> Clone for DisplayHandlerImpl<H> {
fn clone(&self) -> Self {
unsafe {
let rc_impl = &mut *self.object;
rc_impl.interface.add_ref();
}
Self {
object: self.object,
event_handler: self.event_handler.duplicate(),
}
}
}
impl<H: CefEventHandler> Rc for DisplayHandlerImpl<H> {
fn as_base(&self) -> &cef_base_ref_counted_t {
unsafe {
let base = &*self.object;
std::mem::transmute(&base.cef_object)
}
}
}
impl<H: CefEventHandler> WrapDisplayHandler for DisplayHandlerImpl<H> {
fn wrap_rc(&mut self, object: *mut RcImpl<_cef_display_handler_t, Self>) {
self.object = object;
}
}
+5 -5
View File
@@ -21,12 +21,12 @@ impl<H: CefEventHandler> RenderHandlerImpl<H> {
impl<H: CefEventHandler> ImplRenderHandler for RenderHandlerImpl<H> {
fn view_rect(&self, _browser: Option<&mut Browser>, rect: Option<&mut Rect>) {
if let Some(rect) = rect {
let view_info = self.event_handler.view_info();
let view = self.event_handler.window_size();
*rect = Rect {
x: 0,
y: 0,
width: view_info.width() as i32,
height: view_info.height() as i32,
width: view.width as i32,
height: view.height as i32,
};
}
}
@@ -50,7 +50,7 @@ impl<H: CefEventHandler> ImplRenderHandler for RenderHandlerImpl<H> {
#[cfg(feature = "accelerated_paint")]
fn on_accelerated_paint(&self, _browser: Option<&mut Browser>, type_: PaintElementType, _dirty_rect_count: usize, _dirty_rects: Option<&Rect>, info: Option<&cef::AcceleratedPaintInfo>) {
use cef::osr_texture_import::SharedTextureHandle;
use crate::cef::texture_import::shared_texture_handle::SharedTextureHandle;
if type_ != PaintElementType::default() {
return;
@@ -78,7 +78,7 @@ impl<H: CefEventHandler> Clone for RenderHandlerImpl<H> {
}
Self {
object: self.object,
event_handler: self.event_handler.duplicate(),
event_handler: self.event_handler.clone(),
}
}
}
@@ -55,7 +55,7 @@ impl<H: CefEventHandler> Clone for SchemeHandlerFactoryImpl<H> {
}
Self {
object: self.object,
event_handler: self.event_handler.duplicate(),
event_handler: self.event_handler.clone(),
}
}
}
+99
View File
@@ -0,0 +1,99 @@
//! Common utilities and traits for texture import across platforms
use crate::cef::texture_import::*;
use ash::vk;
use cef::sys::cef_color_type_t;
use wgpu::Device;
/// Common format conversion utilities
pub mod format {
use super::*;
/// Convert CEF color type to wgpu texture format
pub fn cef_to_wgpu(format: cef_color_type_t) -> Result<wgpu::TextureFormat, TextureImportError> {
match format {
cef_color_type_t::CEF_COLOR_TYPE_BGRA_8888 => Ok(wgpu::TextureFormat::Bgra8UnormSrgb),
cef_color_type_t::CEF_COLOR_TYPE_RGBA_8888 => Ok(wgpu::TextureFormat::Rgba8UnormSrgb),
_ => Err(TextureImportError::UnsupportedFormat { format }),
}
}
#[cfg(not(target_os = "macos"))]
/// Convert CEF color type to Vulkan format
pub fn cef_to_vulkan(format: cef_color_type_t) -> Result<vk::Format, TextureImportError> {
match format {
cef_color_type_t::CEF_COLOR_TYPE_BGRA_8888 => Ok(vk::Format::B8G8R8A8_UNORM),
cef_color_type_t::CEF_COLOR_TYPE_RGBA_8888 => Ok(vk::Format::R8G8B8A8_UNORM),
_ => Err(TextureImportError::UnsupportedFormat { format }),
}
}
}
/// Common texture creation utilities
pub mod texture {
use super::*;
/// Create a fallback CPU texture with the given dimensions and format
pub fn create_fallback(device: &Device, width: u32, height: u32, format: cef_color_type_t, label: &str) -> TextureImportResult {
let wgpu_format = format::cef_to_wgpu(format)?;
let texture = device.create_texture(&wgpu::TextureDescriptor {
label: Some(label),
size: wgpu::Extent3d {
width,
height,
depth_or_array_layers: 1,
},
mip_level_count: 1,
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: wgpu_format,
usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST,
view_formats: &[],
});
tracing::warn!(
"Using fallback CPU texture for CEF rendering ({}x{}, {:?}) - hardware acceleration failed or unavailable. Consider checking GPU driver support.",
width,
height,
format
);
Ok(texture)
}
}
/// Common Vulkan utilities
pub mod vulkan {
use super::*;
/// Find a suitable memory type index for Vulkan allocation
pub fn find_memory_type_index(type_filter: u32, properties: vk::MemoryPropertyFlags, mem_properties: &vk::PhysicalDeviceMemoryProperties) -> Option<u32> {
(0..mem_properties.memory_type_count).find(|&i| (type_filter & (1 << i)) != 0 && mem_properties.memory_types[i as usize].property_flags.contains(properties))
}
/// Check if the wgpu device is using Vulkan backend
#[cfg(not(target_os = "macos"))]
pub fn is_vulkan_backend(device: &Device) -> bool {
use wgpu::hal::api;
let mut is_vulkan = false;
unsafe {
device.as_hal::<api::Vulkan, _, _>(|device| {
is_vulkan = device.is_some();
});
}
is_vulkan
}
/// Check if the wgpu device is using D3D12 backend
#[cfg(target_os = "windows")]
pub fn is_d3d12_backend(device: &Device) -> bool {
use wgpu::hal::api;
let mut is_d3d12 = false;
unsafe {
device.as_hal::<api::Dx12, _, _>(|device| {
is_d3d12 = device.is_some();
});
}
is_d3d12
}
}
+289
View File
@@ -0,0 +1,289 @@
//! Windows D3D11 shared texture import implementation
use super::common::{format, texture, vulkan};
use super::{TextureImportError, TextureImportResult, TextureImporter};
use ash::vk;
use cef::{AcceleratedPaintInfo, sys::cef_color_type_t};
use std::os::raw::c_void;
use wgpu::hal::api;
pub struct D3D11Importer {
pub handle: *mut c_void,
pub format: cef_color_type_t,
pub width: u32,
pub height: u32,
}
impl TextureImporter for D3D11Importer {
fn new(info: &AcceleratedPaintInfo) -> Self {
Self {
handle: info.shared_texture_handle,
format: *info.format.as_ref(),
width: info.extra.coded_size.width as u32,
height: info.extra.coded_size.height as u32,
}
}
fn import_to_wgpu(&self, device: &wgpu::Device) -> TextureImportResult {
// Try hardware acceleration first
if self.supports_hardware_acceleration(device) {
// Try D3D12 first (most efficient on Windows)
if vulkan::is_d3d12_backend(device) {
match self.import_via_d3d12(device) {
Ok(texture) => {
tracing::info!("Successfully imported D3D11 shared texture via D3D12");
return Ok(texture);
}
Err(e) => {
tracing::warn!("Failed to import D3D11 via D3D12: {}, trying Vulkan fallback", e);
}
}
}
// Try Vulkan as fallback
if vulkan::is_vulkan_backend(device) {
match self.import_via_vulkan(device) {
Ok(texture) => {
tracing::info!("Successfully imported D3D11 shared texture via Vulkan");
return Ok(texture);
}
Err(e) => {
tracing::warn!("Failed to import D3D11 via Vulkan: {}, falling back to CPU texture", e);
}
}
}
}
// Fallback to CPU texture
texture::create_fallback(device, self.width, self.height, self.format, "CEF D3D11 Texture (fallback)")
}
fn supports_hardware_acceleration(&self, device: &wgpu::Device) -> bool {
// Check if handle is valid
if self.handle.is_null() {
return false;
}
// Check if wgpu is using D3D12 or Vulkan backend
vulkan::is_d3d12_backend(device) || vulkan::is_vulkan_backend(device)
}
}
impl D3D11Importer {
fn import_via_d3d12(&self, device: &wgpu::Device) -> TextureImportResult {
// Get wgpu's D3D12 device
use wgpu::hal::api;
let hal_texture = unsafe {
device.as_hal::<api::Dx12, _, _>(|device| {
let Some(device) = device else {
return Err(TextureImportError::HardwareUnavailable {
reason: "Device is not using D3D12 backend".to_string(),
});
};
// Import D3D11 shared handle directly into D3D12 resource
let d3d12_resource = self.import_d3d11_handle_to_d3d12(device)?;
// Wrap D3D12 resource in wgpu-hal texture
let hal_texture = <api::Dx12 as wgpu::hal::Api>::Device::texture_from_raw(
d3d12_resource,
format::cef_to_wgpu(self.format)?,
wgpu::TextureDimension::D2,
wgpu::Extent3d {
width: self.width,
height: self.height,
depth_or_array_layers: 1,
},
1, // mip_level_count
1, // sample_count
);
Ok(hal_texture)
})
}?;
// Import hal texture into wgpu
let texture = unsafe {
device.create_texture_from_hal::<api::Dx12>(
hal_texture,
&wgpu::TextureDescriptor {
label: Some("CEF D3D11→D3D12 Shared Texture"),
size: wgpu::Extent3d {
width: self.width,
height: self.height,
depth_or_array_layers: 1,
},
mip_level_count: 1,
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: format::cef_to_wgpu(self.format)?,
usage: wgpu::TextureUsages::TEXTURE_BINDING,
view_formats: &[],
},
)
};
Ok(texture)
}
fn import_via_vulkan(&self, device: &wgpu::Device) -> TextureImportResult {
// Get wgpu's Vulkan instance and device
use wgpu::{TextureUses, wgc::api::Vulkan};
let hal_texture = unsafe {
device.as_hal::<api::Vulkan, _, _>(|device| {
let Some(device) = device else {
return Err(TextureImportError::HardwareUnavailable {
reason: "Device is not using Vulkan backend".to_string(),
});
};
// Import D3D11 shared handle into Vulkan
let vk_image = self.import_d3d11_handle_to_vulkan(device)?;
// Wrap VkImage in wgpu-hal texture
let hal_texture = <api::Vulkan as wgpu::hal::Api>::Device::texture_from_raw(
vk_image,
&wgpu::hal::TextureDescriptor {
label: Some("CEF D3D11 Shared Texture"),
size: wgpu::Extent3d {
width: self.width,
height: self.height,
depth_or_array_layers: 1,
},
mip_level_count: 1,
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: format::cef_to_wgpu(self.format)?,
usage: TextureUses::COPY_DST | TextureUses::RESOURCE,
memory_flags: wgpu::hal::MemoryFlags::empty(),
view_formats: vec![],
},
None, // drop_callback
);
Ok(hal_texture)
})
}?;
// Import hal texture into wgpu
let texture = unsafe {
device.create_texture_from_hal::<Vulkan>(
hal_texture,
&wgpu::TextureDescriptor {
label: Some("CEF D3D11 Shared Texture"),
size: wgpu::Extent3d {
width: self.width,
height: self.height,
depth_or_array_layers: 1,
},
mip_level_count: 1,
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: format::cef_to_wgpu(self.format)?,
usage: wgpu::TextureUsages::TEXTURE_BINDING,
view_formats: &[],
},
)
};
Ok(texture)
}
fn import_d3d11_handle_to_vulkan(&self, hal_device: &<api::Vulkan as wgpu::hal::Api>::Device) -> Result<vk::Image, TextureImportError> {
// Get raw Vulkan handles
let device = hal_device.raw_device();
let _instance = hal_device.shared_instance().raw_instance();
// Validate dimensions
if self.width == 0 || self.height == 0 {
return Err(TextureImportError::InvalidHandle("Invalid D3D11 texture dimensions".to_string()));
}
// Create external memory image info
let mut external_memory_info = vk::ExternalMemoryImageCreateInfo::default().handle_types(vk::ExternalMemoryHandleTypeFlags::D3D11_TEXTURE);
// Create image create info
let image_create_info = vk::ImageCreateInfo::default()
.image_type(vk::ImageType::TYPE_2D)
.format(format::cef_to_vulkan(self.format)?)
.extent(vk::Extent3D {
width: self.width,
height: self.height,
depth: 1,
})
.mip_levels(1)
.array_layers(1)
.samples(vk::SampleCountFlags::TYPE_1)
.tiling(vk::ImageTiling::OPTIMAL)
.usage(vk::ImageUsageFlags::SAMPLED | vk::ImageUsageFlags::COLOR_ATTACHMENT)
.sharing_mode(vk::SharingMode::EXCLUSIVE)
.push_next(&mut external_memory_info);
// Create the image
let image = unsafe {
device.create_image(&image_create_info, None).map_err(|e| TextureImportError::VulkanError {
operation: format!("Failed to create Vulkan image: {:?}", e),
})?
};
// Get memory requirements
let memory_requirements = unsafe { device.get_image_memory_requirements(image) };
// Import D3D11 handle
let mut import_memory_win32 = vk::ImportMemoryWin32HandleInfoKHR::default()
.handle_type(vk::ExternalMemoryHandleTypeFlags::D3D11_TEXTURE)
.handle(self.handle as isize);
// Find a suitable memory type
let memory_properties = unsafe { hal_device.shared_instance().raw_instance().get_physical_device_memory_properties(hal_device.raw_physical_device()) };
let memory_type_index =
vulkan::find_memory_type_index(memory_requirements.memory_type_bits, vk::MemoryPropertyFlags::empty(), &memory_properties).ok_or_else(|| TextureImportError::VulkanError {
operation: "Failed to find suitable memory type for D3D11 texture".to_string(),
})?;
let allocate_info = vk::MemoryAllocateInfo::default()
.allocation_size(memory_requirements.size)
.memory_type_index(memory_type_index)
.push_next(&mut import_memory_win32);
let device_memory = unsafe {
device.allocate_memory(&allocate_info, None).map_err(|e| TextureImportError::VulkanError {
operation: format!("Failed to allocate memory for D3D11 texture: {:?}", e),
})?
};
// Bind memory to image
unsafe {
device.bind_image_memory(image, device_memory, 0).map_err(|e| TextureImportError::VulkanError {
operation: format!("Failed to bind memory to image: {:?}", e),
})?;
}
Ok(image)
}
fn import_d3d11_handle_to_d3d12(&self, hal_device: &<wgpu::hal::api::Dx12 as wgpu::hal::Api>::Device) -> Result<windows::Win32::Graphics::Direct3D12::ID3D12Resource, TextureImportError> {
use windows::Win32::Graphics::Direct3D12::*;
// Get D3D12 device from wgpu-hal
let d3d12_device = hal_device.raw_device();
// Validate dimensions
if self.width == 0 || self.height == 0 {
return Err(TextureImportError::InvalidHandle("Invalid D3D11 texture dimensions".to_string()));
}
// Open D3D11 shared handle on D3D12 device
unsafe {
let mut shared_resource: Option<ID3D12Resource> = None;
d3d12_device
.OpenSharedHandle(windows::Win32::Foundation::HANDLE(self.handle), &mut shared_resource)
.map_err(|e| TextureImportError::PlatformError {
message: format!("Failed to open D3D11 shared handle on D3D12: {:?}", e),
})?;
shared_resource.ok_or_else(|| TextureImportError::InvalidHandle("Failed to get D3D12 resource from shared handle".to_string()))
}
}
}
+273
View File
@@ -0,0 +1,273 @@
//! Linux DMA-BUF texture import implementation
use super::common::{format, texture, vulkan};
use super::{TextureImportError, TextureImportResult, TextureImporter};
use ash::vk;
use cef::{AcceleratedPaintInfo, sys::cef_color_type_t};
use wgpu::hal::api;
pub(crate) struct DmaBufImporter {
fds: Vec<std::os::fd::RawFd>,
format: cef_color_type_t,
modifier: u64,
width: u32,
height: u32,
strides: Vec<u32>,
offsets: Vec<u32>,
}
impl TextureImporter for DmaBufImporter {
fn new(info: &AcceleratedPaintInfo) -> Self {
Self {
fds: extract_fds_from_info(info),
format: *info.format.as_ref(),
modifier: info.modifier,
width: info.extra.coded_size.width as u32,
height: info.extra.coded_size.height as u32,
strides: extract_strides_from_info(info),
offsets: extract_offsets_from_info(info),
}
}
fn import_to_wgpu(&self, device: &wgpu::Device) -> TextureImportResult {
// Try hardware acceleration first
if self.supports_hardware_acceleration(device) {
match self.import_via_vulkan(device) {
Ok(texture) => {
tracing::info!("Successfully imported DMA-BUF texture via Vulkan");
return Ok(texture);
}
Err(e) => {
tracing::warn!("Failed to import DMA-BUF via Vulkan: {}, falling back to CPU texture", e);
}
}
}
// Fallback to CPU texture
texture::create_fallback(device, self.width, self.height, self.format, "CEF DMA-BUF Texture (fallback)")
}
fn supports_hardware_acceleration(&self, device: &wgpu::Device) -> bool {
// Check if we have valid file descriptors
if self.fds.is_empty() {
return false;
}
for &fd in &self.fds {
if fd < 0 {
return false;
}
// Check if file descriptor is valid
let flags = unsafe { libc::fcntl(fd, libc::F_GETFD) };
if flags == -1 {
return false;
}
}
// Check if wgpu is using Vulkan backend
vulkan::is_vulkan_backend(device)
}
}
impl DmaBufImporter {
fn import_via_vulkan(&self, device: &wgpu::Device) -> TextureImportResult {
// Get wgpu's Vulkan instance and device
use wgpu::{TextureUses, wgc::api::Vulkan};
let hal_texture = unsafe {
device.as_hal::<api::Vulkan, _, _>(|device| {
let Some(device) = device else {
return Err(TextureImportError::HardwareUnavailable {
reason: "Device is not using Vulkan backend".to_string(),
});
};
// Create VkImage from DMA-BUF using external memory
let vk_image = self.create_vulkan_image_from_dmabuf(device)?;
// Wrap VkImage in wgpu-hal texture
let hal_texture = <api::Vulkan as wgpu::hal::Api>::Device::texture_from_raw(
vk_image,
&wgpu::hal::TextureDescriptor {
label: Some("CEF DMA-BUF Texture"),
size: wgpu::Extent3d {
width: self.width,
height: self.height,
depth_or_array_layers: 1,
},
mip_level_count: 1,
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: format::cef_to_wgpu(self.format)?,
usage: TextureUses::COPY_DST | TextureUses::RESOURCE,
memory_flags: wgpu::hal::MemoryFlags::empty(),
view_formats: vec![],
},
None, // drop_callback
);
Ok(hal_texture)
})
}?;
// Import hal texture into wgpu
let texture = unsafe {
device.create_texture_from_hal::<Vulkan>(
hal_texture,
&wgpu::TextureDescriptor {
label: Some("CEF DMA-BUF Texture"),
size: wgpu::Extent3d {
width: self.width,
height: self.height,
depth_or_array_layers: 1,
},
mip_level_count: 1,
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: format::cef_to_wgpu(self.format)?,
usage: wgpu::TextureUsages::TEXTURE_BINDING,
view_formats: &[],
},
)
};
Ok(texture)
}
fn create_vulkan_image_from_dmabuf(&self, hal_device: &<api::Vulkan as wgpu::hal::Api>::Device) -> Result<vk::Image, TextureImportError> {
// Get raw Vulkan handles
let device = hal_device.raw_device();
let _instance = hal_device.shared_instance().raw_instance();
// Validate dimensions
if self.width == 0 || self.height == 0 {
return Err(TextureImportError::InvalidHandle("Invalid DMA-BUF dimensions".to_string()));
}
// Create external memory image
let image_create_info = vk::ImageCreateInfo::default()
.image_type(vk::ImageType::TYPE_2D)
.format(format::cef_to_vulkan(self.format)?)
.extent(vk::Extent3D {
width: self.width,
height: self.height,
depth: 1,
})
.mip_levels(1)
.array_layers(1)
.samples(vk::SampleCountFlags::TYPE_1)
.tiling(vk::ImageTiling::DRM_FORMAT_MODIFIER_EXT)
.usage(vk::ImageUsageFlags::SAMPLED | vk::ImageUsageFlags::COLOR_ATTACHMENT)
.sharing_mode(vk::SharingMode::EXCLUSIVE);
// Set up DRM format modifier
let plane_layouts = self.create_subresource_layouts()?;
let mut drm_format_modifier = vk::ImageDrmFormatModifierExplicitCreateInfoEXT::default()
.drm_format_modifier(self.modifier)
.plane_layouts(&plane_layouts);
let image_create_info = image_create_info.push_next(&mut drm_format_modifier);
// Create the image
let image = unsafe {
device.create_image(&image_create_info, None).map_err(|e| TextureImportError::VulkanError {
operation: format!("Failed to create Vulkan image: {e:?}"),
})?
};
// Import memory from DMA-BUF
let memory_requirements = unsafe { device.get_image_memory_requirements(image) };
// Duplicate the file descriptor to avoid ownership issues
let dup_fd = unsafe { libc::dup(self.fds[0]) };
if dup_fd == -1 {
return Err(TextureImportError::PlatformError {
message: "Failed to duplicate DMA-BUF file descriptor".to_string(),
});
}
let mut import_memory_fd = vk::ImportMemoryFdInfoKHR::default().handle_type(vk::ExternalMemoryHandleTypeFlags::DMA_BUF_EXT).fd(dup_fd);
// Find a suitable memory type
let memory_properties = unsafe { hal_device.shared_instance().raw_instance().get_physical_device_memory_properties(hal_device.raw_physical_device()) };
let memory_type_index =
vulkan::find_memory_type_index(memory_requirements.memory_type_bits, vk::MemoryPropertyFlags::empty(), &memory_properties).ok_or_else(|| TextureImportError::VulkanError {
operation: "Failed to find suitable memory type for DMA-BUF".to_string(),
})?;
let allocate_info = vk::MemoryAllocateInfo::default()
.allocation_size(memory_requirements.size)
.memory_type_index(memory_type_index)
.push_next(&mut import_memory_fd);
let device_memory = unsafe {
device.allocate_memory(&allocate_info, None).map_err(|e| TextureImportError::VulkanError {
operation: format!("Failed to allocate memory for DMA-BUF: {e:?}"),
})?
};
// Bind memory to image
unsafe {
device.bind_image_memory(image, device_memory, 0).map_err(|e| TextureImportError::VulkanError {
operation: format!("Failed to bind memory to image: {e:?}"),
})?;
}
Ok(image)
}
fn create_subresource_layouts(&self) -> Result<Vec<vk::SubresourceLayout>, TextureImportError> {
let mut layouts = Vec::new();
for i in 0..self.fds.len() {
layouts.push(vk::SubresourceLayout {
offset: self.offsets.get(i).copied().unwrap_or(0) as u64,
size: 0, // Will be calculated by driver
row_pitch: self.strides.get(i).copied().unwrap_or(0) as u64,
array_pitch: 0,
depth_pitch: 0,
});
}
Ok(layouts)
}
}
fn extract_fds_from_info(info: &cef::AcceleratedPaintInfo) -> Vec<std::os::fd::RawFd> {
let plane_count = info.plane_count as usize;
let mut fds = Vec::with_capacity(plane_count);
for i in 0..plane_count {
if let Some(plane) = info.planes.get(i) {
fds.push(plane.fd);
}
}
fds
}
fn extract_strides_from_info(info: &cef::AcceleratedPaintInfo) -> Vec<u32> {
let plane_count = info.plane_count as usize;
let mut strides = Vec::with_capacity(plane_count);
for i in 0..plane_count {
if let Some(plane) = info.planes.get(i) {
strides.push(plane.stride);
}
}
strides
}
fn extract_offsets_from_info(info: &cef::AcceleratedPaintInfo) -> Vec<u32> {
let plane_count = info.plane_count as usize;
let mut offsets = Vec::with_capacity(plane_count);
for i in 0..plane_count {
if let Some(plane) = info.planes.get(i) {
offsets.push(plane.offset as u32);
}
}
offsets
}
+182
View File
@@ -0,0 +1,182 @@
//! macOS IOSurface texture import implementation
use super::common::{format, texture};
use super::{TextureImportError, TextureImportResult, TextureImporter};
use cef::{AcceleratedPaintInfo, sys::cef_color_type_t};
use core_foundation::base::{CFType, TCFType};
use objc2_io_surface::{IOSurface, IOSurfaceRef};
use objc2_metal::{MTLDevice, MTLPixelFormat, MTLTexture, MTLTextureDescriptor, MTLTextureType, MTLTextureUsage};
use std::os::raw::c_void;
use wgpu::hal::api;
pub struct IOSurfaceImporter {
pub handle: *mut c_void,
pub format: cef_color_type_t,
pub width: u32,
pub height: u32,
}
impl TextureImporter for IOSurfaceImporter {
fn new(info: &AcceleratedPaintInfo) -> Self {
Self {
handle: info.shared_texture_handle,
format: *info.format.as_ref(),
width: info.extra.coded_size.width as u32,
height: info.extra.coded_size.height as u32,
}
}
fn import_to_wgpu(&self, device: &wgpu::Device) -> TextureImportResult {
// Try hardware acceleration first
if self.supports_hardware_acceleration(device) {
match self.import_via_metal(device) {
Ok(texture) => {
tracing::trace!("Successfully imported IOSurface texture via Metal");
return Ok(texture);
}
Err(e) => {
tracing::warn!("Failed to import IOSurface via Metal: {}, falling back to CPU texture", e);
}
}
}
// Fallback to CPU texture
texture::create_fallback(device, self.width, self.height, self.format, "CEF IOSurface Texture (fallback)")
}
fn supports_hardware_acceleration(&self, device: &wgpu::Device) -> bool {
// Check if handle is valid
if self.handle.is_null() {
return false;
}
// Check if wgpu is using Metal backend
self.is_metal_backend(device)
}
}
impl IOSurfaceImporter {
fn import_via_metal(&self, device: &wgpu::Device) -> TextureImportResult {
// Get wgpu's Metal device
use wgpu::{hal::Api, wgc::api::Metal};
let hal_texture = unsafe {
device.as_hal::<api::Metal, _, _>(|device| {
let Some(device) = device else {
return Err(TextureImportError::HardwareUnavailable {
reason: "Device is not using Metal backend".to_string(),
});
};
// Import IOSurface handle into Metal texture
let metal_texture = self.import_iosurface_to_metal(device)?;
// Wrap Metal texture in wgpu-hal texture
let hal_texture = <api::Metal as wgpu::hal::Api>::Device::texture_from_raw(
metal_texture,
&wgpu::hal::TextureDescriptor {
label: Some("CEF IOSurface Texture"),
size: wgpu::Extent3d {
width: self.width,
height: self.height,
depth_or_array_layers: 1,
},
mip_level_count: 1,
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: format::cef_to_wgpu(self.format)?,
usage: wgpu::hal::TextureUses::RESOURCE,
memory_flags: wgpu::hal::MemoryFlags::empty(),
view_formats: vec![],
},
None, // drop_callback
);
Ok(hal_texture)
})
}?;
// Import hal texture into wgpu
let texture = unsafe {
device.create_texture_from_hal::<Metal>(
hal_texture,
&wgpu::TextureDescriptor {
label: Some("CEF IOSurface Texture"),
size: wgpu::Extent3d {
width: self.width,
height: self.height,
depth_or_array_layers: 1,
},
mip_level_count: 1,
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: format::cef_to_wgpu(self.format)?,
usage: wgpu::TextureUsages::TEXTURE_BINDING,
view_formats: &[],
},
)
};
Ok(texture)
}
fn import_iosurface_to_metal(&self, hal_device: &<api::Metal as wgpu::hal::Api>::Device) -> Result<<api::Metal as wgpu::hal::Api>::Texture, TextureImportError> {
// Validate dimensions
if self.width == 0 || self.height == 0 {
return Err(TextureImportError::InvalidHandle("Invalid IOSurface texture dimensions".to_string()));
}
// Convert handle to IOSurface
let iosurface = unsafe {
let cf_type = CFType::wrap_under_get_rule(self.handle as IOSurfaceRef);
IOSurface::from(cf_type)
};
// Get the Metal device from wgpu-hal
let metal_device = hal_device.raw_device();
// Convert CEF format to Metal pixel format
let metal_format = self.cef_to_metal_format(self.format)?;
// Create Metal texture descriptor
let texture_descriptor = MTLTextureDescriptor::new();
texture_descriptor.setTextureType(MTLTextureType::Type2D);
texture_descriptor.setPixelFormat(metal_format);
texture_descriptor.setWidth(self.width as usize);
texture_descriptor.setHeight(self.height as usize);
texture_descriptor.setDepth(1);
texture_descriptor.setMipmapLevelCount(1);
texture_descriptor.setSampleCount(1);
texture_descriptor.setUsage(MTLTextureUsage::ShaderRead);
// Create Metal texture from IOSurface
let metal_texture = unsafe { metal_device.newTextureWithDescriptor_iosurface_plane(&texture_descriptor, &iosurface, 0) };
let Some(metal_texture) = metal_texture else {
return Err(TextureImportError::PlatformError {
message: "Failed to create Metal texture from IOSurface".to_string(),
});
};
tracing::trace!("Successfully created Metal texture from IOSurface");
Ok(metal_texture)
}
fn cef_to_metal_format(&self, format: cef_color_type_t) -> Result<MTLPixelFormat, TextureImportError> {
match format {
cef_color_type_t::CEF_COLOR_TYPE_BGRA_8888 => Ok(MTLPixelFormat::BGRA8Unorm_sRGB),
cef_color_type_t::CEF_COLOR_TYPE_RGBA_8888 => Ok(MTLPixelFormat::RGBA8Unorm_sRGB),
_ => Err(TextureImportError::UnsupportedFormat { format }),
}
}
fn is_metal_backend(&self, device: &wgpu::Device) -> bool {
use wgpu::hal::api;
let mut is_metal = false;
unsafe {
device.as_hal::<api::Metal, _, _>(|device| {
is_metal = device.is_some();
});
}
is_metal
}
}
+75
View File
@@ -0,0 +1,75 @@
//! Unified texture import system for CEF hardware acceleration
//!
//! This module provides a platform-agnostic interface for importing shared textures
//! from CEF into wgpu, with automatic fallback to CPU textures when hardware
//! acceleration is not available.
//!
//! # Supported Platforms
//!
//! - **Linux**: DMA-BUF via Vulkan external memory
//! - **Windows**: D3D11 shared textures via Vulkan interop
//! - **macOS**: IOSurface via Metal native API
//!
//! # Usage
//!
//! ```no_run
//! // Import texture with automatic platform detection
//! let texture = shared_handle.import_texture(&device)?;
//! ```
//!
//! # Features
//!
//! - `accelerated_paint` - Base feature for texture import
//! - `accelerated_paint_dmabuf` - Linux DMA-BUF support
//! - `accelerated_paint_d3d11` - Windows D3D11 support
//! - `accelerated_paint_iosurface` - macOS IOSurface support
pub(crate) mod common;
pub(crate) mod shared_texture_handle;
pub(crate) use shared_texture_handle::SharedTextureHandle;
#[cfg(target_os = "linux")]
pub(crate) mod dmabuf;
#[cfg(target_os = "windows")]
pub(crate) mod d3d11;
#[cfg(target_os = "macos")]
pub(crate) mod iosurface;
/// Result type for texture import operations
pub type TextureImportResult = Result<wgpu::Texture, TextureImportError>;
/// Errors that can occur during texture import
#[derive(Debug, thiserror::Error)]
pub enum TextureImportError {
#[error("Invalid texture handle: {0}")]
InvalidHandle(String),
#[error("Unsupported texture format: {format:?}")]
UnsupportedFormat { format: cef::sys::cef_color_type_t },
#[error("Hardware acceleration not available: {reason}")]
HardwareUnavailable { reason: String },
#[error("Vulkan operation failed: {operation}")]
VulkanError { operation: String },
#[error("Platform-specific error: {message}")]
PlatformError { message: String },
#[error("Unsupported platform for texture import")]
UnsupportedPlatform,
}
/// Trait for platform-specific texture importers
pub trait TextureImporter {
fn new(info: &cef::AcceleratedPaintInfo) -> Self;
/// Import the texture into wgpu, with automatic fallback to CPU texture
fn import_to_wgpu(&self, device: &wgpu::Device) -> TextureImportResult;
/// Check if hardware acceleration is available for this texture
fn supports_hardware_acceleration(&self, device: &wgpu::Device) -> bool;
}
@@ -0,0 +1,45 @@
use cef::AcceleratedPaintInfo;
use super::{TextureImportError, TextureImportResult, TextureImporter};
pub(crate) enum SharedTextureHandle {
#[cfg(target_os = "linux")]
DmaBuf(super::dmabuf::DmaBufImporter),
#[cfg(target_os = "windows")]
D3D11(super::d3d11::D3D11Importer),
#[cfg(target_os = "macos")]
IOSurface(super::iosurface::IOSurfaceImporter),
Unsupported,
}
impl SharedTextureHandle {
pub(crate) fn new(info: &AcceleratedPaintInfo) -> Self {
// Extract DMA-BUF information
#[cfg(target_os = "linux")]
return Self::DmaBuf(super::dmabuf::DmaBufImporter::new(info));
// Extract D3D11 shared handle with texture metadata
#[cfg(target_os = "windows")]
return Self::D3D11(super::d3d11::D3D11Importer::new(info));
// Extract IOSurface handle with texture metadata
#[cfg(target_os = "macos")]
return Self::IOSurface(super::iosurface::IOSurfaceImporter::new(info));
#[allow(unreachable_code)]
Self::Unsupported
}
/// Import a texture using the appropriate platform-specific importer
pub(crate) fn import_texture(self, device: &wgpu::Device) -> TextureImportResult {
match self {
#[cfg(target_os = "linux")]
SharedTextureHandle::DmaBuf(importer) => importer.import_to_wgpu(device),
#[cfg(target_os = "windows")]
SharedTextureHandle::D3D11(importer) => importer.import_to_wgpu(device),
#[cfg(target_os = "macos")]
SharedTextureHandle::IOSurface(importer) => importer.import_to_wgpu(device),
SharedTextureHandle::Unsupported => Err(TextureImportError::UnsupportedPlatform),
}
}
}
-9
View File
@@ -1,9 +0,0 @@
#[derive(clap::Parser)]
#[clap(name = "graphite-editor", version)]
pub struct Cli {
#[arg(help = "Files to open on startup")]
pub files: Vec<std::path::PathBuf>,
#[arg(long, action = clap::ArgAction::SetTrue, help = "Disable hardware accelerated UI rendering")]
pub disable_ui_acceleration: bool,
}
+6 -6
View File
@@ -1,10 +1,10 @@
pub(crate) const APP_NAME: &str = "Graphite";
pub(crate) const APP_ID: &str = "rs.graphite.GraphiteEditor";
pub(crate) static APP_NAME: &str = "Graphite";
pub(crate) static APP_ID: &str = "rs.graphite.GraphiteEditor";
pub(crate) const APP_DIRECTORY_NAME: &str = "graphite-editor";
pub(crate) const APP_STATE_FILE_NAME: &str = "state.ron";
pub(crate) const APP_PREFERENCES_FILE_NAME: &str = "preferences.ron";
pub(crate) const APP_DOCUMENTS_DIRECTORY_NAME: &str = "documents";
pub(crate) static APP_DIRECTORY_NAME: &str = "graphite-editor";
pub(crate) static APP_STATE_FILE_NAME: &str = "state.ron";
pub(crate) static APP_PREFERENCES_FILE_NAME: &str = "preferences.ron";
pub(crate) static APP_DOCUMENTS_DIRECTORY_NAME: &str = "documents";
// CEF configuration constants
pub(crate) const CEF_WINDOWLESS_FRAME_RATE: i32 = 60;
+2 -4
View File
@@ -1,15 +1,13 @@
use crate::wrapper::NodeGraphExecutionResult;
use crate::wrapper::messages::DesktopWrapperMessage;
use graphite_desktop_wrapper::NodeGraphExecutionResult;
use graphite_desktop_wrapper::messages::DesktopWrapperMessage;
pub(crate) enum AppEvent {
UiUpdate(wgpu::Texture),
CursorChange(winit::cursor::Cursor),
ScheduleBrowserWork(std::time::Instant),
WebCommunicationInitialized,
DesktopWrapperMessage(DesktopWrapperMessage),
NodeGraphExecutionResult(NodeGraphExecutionResult),
CloseWindow,
MenuEvent { id: u64 },
}
#[derive(Clone)]
-23
View File
@@ -1,23 +0,0 @@
use crate::wrapper::{WgpuContext, WgpuContextBuilder, WgpuFeatures};
pub(super) async fn create_wgpu_context() -> WgpuContext {
let wgpu_context_builder = WgpuContextBuilder::new().with_features(WgpuFeatures::PUSH_CONSTANTS);
// TODO: add a cli flag to list adapters and exit instead of always printing
println!("\nAvailable WGPU adapters:\n{}", wgpu_context_builder.available_adapters_fmt().await);
// TODO: make this configurable via cli flags instead
let wgpu_context = match std::env::var("GRAPHITE_WGPU_ADAPTER").ok().and_then(|s| s.parse().ok()) {
None => wgpu_context_builder.build().await,
Some(adapter_index) => {
tracing::info!("Overriding WGPU adapter selection with adapter index {adapter_index}");
wgpu_context_builder.build_with_adapter_selection(|_| Some(adapter_index)).await
}
}
.expect("Failed to create WGPU context");
// TODO: add a cli flag to list adapters and exit instead of always printing
println!("Using WGPU adapter: {:?}", wgpu_context.adapter.get_info());
wgpu_context
}
-82
View File
@@ -1,82 +0,0 @@
use clap::Parser;
use std::process::exit;
use tracing_subscriber::EnvFilter;
use winit::event_loop::EventLoop;
pub(crate) mod consts;
mod app;
mod cef;
mod cli;
mod dirs;
mod event;
mod persist;
mod render;
mod window;
mod gpu_context;
pub(crate) use graphite_desktop_wrapper as wrapper;
use app::App;
use cef::CefHandler;
use cli::Cli;
use event::CreateAppEventSchedulerEventLoopExt;
pub fn start() {
tracing_subscriber::fmt().with_env_filter(EnvFilter::from_default_env()).init();
let cef_context_builder = cef::CefContextBuilder::<CefHandler>::new();
if cef_context_builder.is_sub_process() {
// We are in a CEF subprocess
// This will block until the CEF subprocess quits
let error = cef_context_builder.execute_sub_process();
tracing::warn!("Cef subprocess failed with error: {error}");
return;
}
let cli = Cli::parse();
let wgpu_context = futures::executor::block_on(gpu_context::create_wgpu_context());
let event_loop = EventLoop::new().unwrap();
let (app_event_sender, app_event_receiver) = std::sync::mpsc::channel();
let app_event_scheduler = event_loop.create_app_event_scheduler(app_event_sender);
let (cef_view_info_sender, cef_view_info_receiver) = std::sync::mpsc::channel();
let cef_handler = cef::CefHandler::new(wgpu_context.clone(), app_event_scheduler.clone(), cef_view_info_receiver);
let cef_context = match cef_context_builder.initialize(cef_handler, cli.disable_ui_acceleration) {
Ok(c) => {
tracing::info!("CEF initialized successfully");
c
}
Err(cef::InitError::AlreadyRunning) => {
tracing::error!("Another instance is already running, Exiting.");
exit(0);
}
Err(cef::InitError::InitializationFailed(code)) => {
tracing::error!("Cef initialization failed with code: {code}");
exit(1);
}
Err(cef::InitError::BrowserCreationFailed) => {
tracing::error!("Failed to create CEF browser");
exit(1);
}
Err(cef::InitError::RequestContextCreationFailed) => {
tracing::error!("Failed to create CEF request context");
exit(1);
}
};
let mut app = App::new(Box::new(cef_context), cef_view_info_sender, wgpu_context, app_event_receiver, app_event_scheduler, cli.files);
event_loop.run_app(&mut app).unwrap();
}
pub fn start_helper() {
let cef_context_builder = cef::CefContextBuilder::<CefHandler>::new_helper();
assert!(cef_context_builder.is_sub_process());
cef_context_builder.execute_sub_process();
}
+67 -1
View File
@@ -1,3 +1,69 @@
use std::process::exit;
use tracing_subscriber::EnvFilter;
use winit::event_loop::EventLoop;
use graphite_desktop_wrapper::WgpuContext;
pub(crate) mod consts;
mod app;
mod cef;
mod dirs;
mod event;
mod native_window;
mod persist;
mod render;
use app::App;
use cef::CefHandler;
use event::CreateAppEventSchedulerEventLoopExt;
fn main() {
graphite_desktop::start();
tracing_subscriber::fmt().with_env_filter(EnvFilter::from_default_env()).init();
let cef_context_builder = cef::CefContextBuilder::<CefHandler>::new();
if cef_context_builder.is_sub_process() {
// We are in a CEF subprocess
// This will block until the CEF subprocess quits
let error = cef_context_builder.execute_sub_process();
tracing::error!("Cef subprocess failed with error: {error}");
return;
}
let wgpu_context = futures::executor::block_on(WgpuContext::new()).unwrap();
let event_loop = EventLoop::new().unwrap();
let (app_event_sender, app_event_receiver) = std::sync::mpsc::channel();
let app_event_scheduler = event_loop.create_app_event_scheduler(app_event_sender);
let (window_size_sender, window_size_receiver) = std::sync::mpsc::channel();
let cef_handler = cef::CefHandler::new(wgpu_context.clone(), app_event_scheduler.clone(), window_size_receiver);
let cef_context = match cef_context_builder.initialize(cef_handler) {
Ok(c) => {
tracing::info!("CEF initialized successfully");
c
}
Err(cef::InitError::AlreadyRunning) => {
tracing::error!("Another instance is already running, Exiting.");
exit(0);
}
Err(cef::InitError::InitializationFailed(code)) => {
tracing::error!("Cef initialization failed with code: {code}");
exit(1);
}
Err(cef::InitError::BrowserCreationFailed) => {
tracing::error!("Failed to create CEF browser");
exit(1);
}
Err(cef::InitError::RequestContextCreationFailed) => {
tracing::error!("Failed to create CEF request context");
exit(1);
}
};
let mut app = App::new(Box::new(cef_context), window_size_sender, wgpu_context, app_event_receiver, app_event_scheduler);
event_loop.run_app(&mut app).unwrap();
}
+52
View File
@@ -0,0 +1,52 @@
use winit::event_loop::ActiveEventLoop;
use winit::window::{Window, WindowAttributes};
use crate::consts::APP_NAME;
#[cfg(target_os = "windows")]
mod windows;
pub(crate) enum NativeWindowHandle {
#[cfg(target_os = "windows")]
#[expect(private_interfaces, dead_code)]
Windows(windows::WindowsNativeWindowHandle),
None,
}
impl Default for NativeWindowHandle {
fn default() -> Self {
Self::None
}
}
impl NativeWindowHandle {
#[allow(unused_variables)]
pub(super) fn build(&mut self, event_loop: &dyn ActiveEventLoop) -> WindowAttributes {
let mut window = WindowAttributes::default()
.with_title(APP_NAME)
.with_min_surface_size(winit::dpi::LogicalSize::new(400, 300))
.with_surface_size(winit::dpi::LogicalSize::new(1200, 800))
.with_resizable(true);
#[cfg(target_os = "linux")]
{
use crate::consts::{APP_ID, APP_NAME};
use winit::platform::wayland::ActiveEventLoopExtWayland;
use winit::platform::wayland::WindowAttributesWayland;
use winit::platform::x11::WindowAttributesX11;
window = if event_loop.is_wayland() {
let wayland_window = WindowAttributesWayland::default().with_name(APP_ID, "");
window.with_platform_attributes(Box::new(wayland_window))
} else {
let x11_window = WindowAttributesX11::default().with_name(APP_ID, APP_NAME);
window.with_platform_attributes(Box::new(x11_window))
}
}
window
}
#[allow(unused_variables)]
pub(crate) fn setup(&mut self, window: &dyn Window) {
#[cfg(target_os = "windows")]
{
*self = NativeWindowHandle::Windows(windows::WindowsNativeWindowHandle::new(window));
}
}
}
@@ -12,23 +12,36 @@
use std::sync::OnceLock;
use wgpu::rwh::{HasWindowHandle, RawWindowHandle};
use windows::Win32::Foundation::*;
use windows::Win32::Graphics::Dwm::*;
use windows::Win32::Graphics::Gdi::*;
use windows::Win32::Graphics::{Dwm::*, Gdi::HBRUSH};
use windows::Win32::System::LibraryLoader::GetModuleHandleW;
use windows::Win32::UI::Controls::MARGINS;
use windows::Win32::UI::HiDpi::*;
use windows::Win32::UI::WindowsAndMessaging::*;
use windows::core::PCWSTR;
use winit::window::Window;
pub(super) struct WindowsNativeWindowHandle {
inner: WindowsNativeWindowHandleInner,
}
impl WindowsNativeWindowHandle {
pub(super) fn new(window: &dyn Window) -> Self {
let inner = WindowsNativeWindowHandleInner::new(window);
WindowsNativeWindowHandle { inner }
}
}
impl Drop for WindowsNativeWindowHandle {
fn drop(&mut self) {
self.inner.destroy();
}
}
#[derive(Clone)]
pub(super) struct NativeWindowHandle {
struct WindowsNativeWindowHandleInner {
main: HWND,
helper: HWND,
prev_window_message_handler: isize,
}
impl NativeWindowHandle {
pub(super) fn new(window: &dyn Window) -> NativeWindowHandle {
impl WindowsNativeWindowHandleInner {
fn new(window: &dyn Window) -> WindowsNativeWindowHandleInner {
// Extract Win32 HWND from winit.
let hwnd = match window.window_handle().expect("No window handle").as_raw() {
RawWindowHandle::Win32(h) => HWND(h.hwnd.get() as *mut std::ffi::c_void),
@@ -70,7 +83,7 @@ impl NativeWindowHandle {
panic!("SetWindowLongPtrW failed");
}
let inner = NativeWindowHandle {
let inner = WindowsNativeWindowHandleInner {
main: hwnd,
helper,
prev_window_message_handler,
@@ -100,7 +113,7 @@ impl NativeWindowHandle {
inner
}
pub(super) fn destroy(&self) {
fn destroy(&self) {
registry::remove_by_main(self.main);
// Undo subclassing and destroy the helper window.
@@ -115,13 +128,13 @@ mod registry {
use std::cell::RefCell;
use windows::Win32::Foundation::HWND;
use super::NativeWindowHandle;
use crate::native_window::windows::WindowsNativeWindowHandleInner;
thread_local! {
static STORE: RefCell<Vec<NativeWindowHandle>> = RefCell::new(Vec::new());
static STORE: RefCell<Vec<WindowsNativeWindowHandleInner>> = RefCell::new(Vec::new());
}
pub(super) fn find_by_main(main: HWND) -> Option<NativeWindowHandle> {
pub(super) fn find_by_main(main: HWND) -> Option<WindowsNativeWindowHandleInner> {
STORE.with_borrow(|vec| vec.iter().find(|h| h.main == main).cloned())
}
pub(super) fn remove_by_main(main: HWND) {
@@ -129,7 +142,7 @@ mod registry {
vec.retain(|h| h.main != main);
});
}
pub(super) fn insert(handle: &NativeWindowHandle) {
pub(super) fn insert(handle: &WindowsNativeWindowHandleInner) {
STORE.with_borrow_mut(|vec| {
vec.push(handle.clone());
});
@@ -160,24 +173,11 @@ unsafe fn ensure_helper_class() {
// Main window message handler, called on the UI thread for every message the main window receives.
unsafe extern "system" fn main_window_handle_message(hwnd: HWND, msg: u32, wparam: WPARAM, lparam: LPARAM) -> LRESULT {
if msg == WM_NCCALCSIZE && wparam.0 != 0 {
// When maximized, shrink to visible frame so content doesn't extend beyond it.
if unsafe { IsZoomed(hwnd).as_bool() } {
let params = unsafe { &mut *(lparam.0 as *mut NCCALCSIZE_PARAMS) };
let dpi = unsafe { GetDpiForWindow(hwnd) };
let size = unsafe { GetSystemMetricsForDpi(SM_CXSIZEFRAME, dpi) };
let pad = unsafe { GetSystemMetricsForDpi(SM_CXPADDEDBORDER, dpi) };
let inset = (size + pad) as i32;
params.rgrc[0].left += inset;
params.rgrc[0].top += inset;
params.rgrc[0].right -= inset;
params.rgrc[0].bottom -= inset;
if msg == WM_NCCALCSIZE {
if wparam.0 != 0 {
// Return 0 to to tell Windows to skip the default non-client area calculation and drawing.
return LRESULT(0);
}
// Return 0 to to tell Windows to skip the default non-client area calculation and drawing.
return LRESULT(0);
}
let Some(handle) = registry::find_by_main(hwnd) else {
+5 -4
View File
@@ -1,4 +1,4 @@
use crate::wrapper::messages::{Document, DocumentId, Preferences};
use graphite_desktop_wrapper::messages::{Document, DocumentId, Preferences};
#[derive(Default, serde::Serialize, serde::Deserialize)]
pub(crate) struct PersistentData {
@@ -6,13 +6,14 @@ pub(crate) struct PersistentData {
current_document: Option<DocumentId>,
#[serde(skip)]
document_order: Option<Vec<DocumentId>>,
preferences: Option<Preferences>,
}
impl PersistentData {
pub(crate) fn write_document(&mut self, id: DocumentId, document: Document) {
self.documents.write(id, document);
if let Some(order) = &self.document_order {
self.documents.force_order(order);
self.documents.force_order(order.clone());
}
self.flush();
}
@@ -170,10 +171,10 @@ impl DocumentStore {
})
}
fn force_order(&mut self, desired_order: &Vec<DocumentId>) {
fn force_order(&mut self, desired_order: Vec<DocumentId>) {
let mut ordered_prefix_len = 0;
for id in desired_order {
if let Some(offset) = self.0[ordered_prefix_len..].iter().position(|meta| meta.id == *id) {
if let Some(offset) = self.0[ordered_prefix_len..].iter().position(|meta| meta.id == id) {
let found_index = ordered_prefix_len + offset;
if found_index != ordered_prefix_len {
self.0[ordered_prefix_len..=found_index].rotate_right(1);
+9 -3
View File
@@ -8,9 +8,15 @@ fn vs_main(@builtin(vertex_index) vertex_index: u32) -> VertexOutput {
var out: VertexOutput;
let pos = array(
vec2f( -1.0, -1.0),
vec2f( 3.0, -1.0),
vec2f( -1.0, 3.0),
// 1st triangle
vec2f( -1.0, -1.0), // center
vec2f( 1.0, -1.0), // right, center
vec2f( -1.0, 1.0), // center, top
// 2nd triangle
vec2f( -1.0, 1.0), // center, top
vec2f( 1.0, -1.0), // right, center
vec2f( 1.0, 1.0), // right, top
);
let xy = pos[vertex_index];
out.clip_position = vec4f(xy , 0.0, 1.0);
+7 -6
View File
@@ -1,6 +1,7 @@
use crate::window::Window;
use std::sync::Arc;
use winit::window::Window;
use crate::wrapper::{Color, WgpuContext, WgpuExecutor};
use graphite_desktop_wrapper::{Color, WgpuContext, WgpuExecutor};
#[derive(derivative::Derivative)]
#[derivative(Debug)]
@@ -23,9 +24,10 @@ pub(crate) struct GraphicsState {
}
impl GraphicsState {
pub(crate) fn new(window: &Window, context: WgpuContext) -> Self {
pub(crate) fn new(window: Arc<dyn Window>, context: WgpuContext) -> Self {
let size = window.surface_size();
let surface = window.create_surface(context.instance.clone());
let surface = context.instance.create_surface(window).unwrap();
let surface_caps = surface.get_capabilities(&context.adapter);
let surface_format = surface_caps.formats.iter().find(|f| f.is_srgb()).copied().unwrap_or(surface_caps.formats[0]);
@@ -230,7 +232,7 @@ impl GraphicsState {
self.bind_overlays_texture(texture);
}
pub(crate) fn render(&mut self, window: &Window) -> Result<(), wgpu::SurfaceError> {
pub(crate) fn render(&mut self, window: &dyn Window) -> Result<(), wgpu::SurfaceError> {
if let Some(scene) = self.overlays_scene.take() {
self.render_overlays(scene);
}
@@ -250,7 +252,6 @@ impl GraphicsState {
load: wgpu::LoadOp::Clear(wgpu::Color { r: 0.01, g: 0.01, b: 0.01, a: 1.0 }),
store: wgpu::StoreOp::Store,
},
depth_slice: None,
})],
depth_stencil_attachment: None,
occlusion_query_set: None,
-98
View File
@@ -1,98 +0,0 @@
use std::sync::Arc;
use winit::event_loop::ActiveEventLoop;
use winit::window::{Window as WinitWindow, WindowAttributes};
use crate::consts::APP_NAME;
use crate::event::AppEventScheduler;
use crate::wrapper::messages::MenuItem;
pub(crate) trait NativeWindow {
fn configure(attributes: WindowAttributes, event_loop: &dyn ActiveEventLoop) -> WindowAttributes;
fn new(window: &dyn WinitWindow, app_event_scheduler: AppEventScheduler) -> Self;
fn update_menu(&self, _entries: Vec<MenuItem>) {}
}
#[cfg(target_os = "linux")]
mod linux;
#[cfg(target_os = "linux")]
use linux as native;
#[cfg(target_os = "macos")]
mod mac;
#[cfg(target_os = "macos")]
use mac as native;
#[cfg(target_os = "windows")]
mod win;
#[cfg(target_os = "windows")]
use win as native;
pub(crate) struct Window {
winit_window: Arc<dyn winit::window::Window>,
#[allow(dead_code)]
native_handle: native::NativeWindowImpl,
}
impl Window {
pub(crate) fn new(event_loop: &dyn ActiveEventLoop, app_event_scheduler: AppEventScheduler) -> Self {
let mut attributes = WindowAttributes::default()
.with_title(APP_NAME)
.with_min_surface_size(winit::dpi::LogicalSize::new(400, 300))
.with_surface_size(winit::dpi::LogicalSize::new(1200, 800))
.with_resizable(true)
.with_theme(Some(winit::window::Theme::Dark));
attributes = native::NativeWindowImpl::configure(attributes, event_loop);
let winit_window = event_loop.create_window(attributes).unwrap();
let native_handle = native::NativeWindowImpl::new(winit_window.as_ref(), app_event_scheduler);
Self {
winit_window: winit_window.into(),
native_handle,
}
}
pub(crate) fn request_redraw(&self) {
self.winit_window.request_redraw();
}
pub(crate) fn create_surface(&self, instance: Arc<wgpu::Instance>) -> wgpu::Surface<'static> {
instance.create_surface(self.winit_window.clone()).unwrap()
}
pub(crate) fn pre_present_notify(&self) {
self.winit_window.pre_present_notify();
}
pub(crate) fn surface_size(&self) -> winit::dpi::PhysicalSize<u32> {
self.winit_window.surface_size()
}
pub(crate) fn scale_factor(&self) -> f64 {
self.winit_window.scale_factor()
}
pub(crate) fn minimize(&self) {
self.winit_window.set_minimized(true);
}
pub(crate) fn toggle_maximize(&self) {
self.winit_window.set_maximized(!self.winit_window.is_maximized());
}
pub(crate) fn is_maximized(&self) -> bool {
self.winit_window.is_maximized()
}
pub(crate) fn start_drag(&self) {
let _ = self.winit_window.drag_window();
}
pub(crate) fn set_cursor(&self, cursor: winit::cursor::Cursor) {
self.winit_window.set_cursor(cursor);
}
pub(crate) fn update_menu(&self, entries: Vec<MenuItem>) {
self.native_handle.update_menu(entries);
}
}
-26
View File
@@ -1,26 +0,0 @@
use winit::event_loop::ActiveEventLoop;
use winit::platform::wayland::ActiveEventLoopExtWayland;
use winit::platform::wayland::WindowAttributesWayland;
use winit::platform::x11::WindowAttributesX11;
use winit::window::{Window, WindowAttributes};
use crate::consts::{APP_ID, APP_NAME};
use crate::event::AppEventScheduler;
pub(super) struct NativeWindowImpl {}
impl super::NativeWindow for NativeWindowImpl {
fn configure(attributes: WindowAttributes, event_loop: &dyn ActiveEventLoop) -> WindowAttributes {
if event_loop.is_wayland() {
let wayland_attributes = WindowAttributesWayland::default().with_name(APP_ID, "").with_prefer_csd(true);
attributes.with_platform_attributes(Box::new(wayland_attributes))
} else {
let x11_attributes = WindowAttributesX11::default().with_name(APP_ID, APP_NAME);
attributes.with_platform_attributes(Box::new(x11_attributes))
}
}
fn new(_window: &dyn Window, _app_event_scheduler: AppEventScheduler) -> Self {
NativeWindowImpl {}
}
}
-32
View File
@@ -1,32 +0,0 @@
use winit::event_loop::ActiveEventLoop;
use winit::window::{Window, WindowAttributes};
use crate::consts::APP_NAME;
use crate::event::AppEventScheduler;
use crate::wrapper::messages::MenuItem;
pub(super) struct NativeWindowImpl {
menu: menu::Menu,
}
impl super::NativeWindow for NativeWindowImpl {
fn configure(attributes: WindowAttributes, _event_loop: &dyn ActiveEventLoop) -> WindowAttributes {
let mac_window = winit::platform::macos::WindowAttributesMacOS::default()
.with_titlebar_transparent(true)
.with_fullsize_content_view(true)
.with_title_hidden(true);
attributes.with_platform_attributes(Box::new(mac_window))
}
fn new(_window: &dyn Window, app_event_scheduler: AppEventScheduler) -> Self {
let menu = menu::Menu::new(app_event_scheduler, APP_NAME);
NativeWindowImpl { menu }
}
fn update_menu(&self, entries: Vec<MenuItem>) {
self.menu.update(entries);
}
}
mod menu;
-156
View File
@@ -1,156 +0,0 @@
use muda::Menu as MudaMenu;
use muda::accelerator::Accelerator;
use muda::{AboutMetadataBuilder, CheckMenuItem, IsMenuItem, MenuEvent, MenuId, MenuItem, MenuItemKind, PredefinedMenuItem, Result, Submenu};
use crate::event::{AppEvent, AppEventScheduler};
use crate::wrapper::messages::MenuItem as WrapperMenuItem;
pub(super) struct Menu {
inner: MudaMenu,
}
impl Menu {
pub(super) fn new(event_scheduler: AppEventScheduler, app_name: &str) -> Self {
let about = PredefinedMenuItem::about(None, Some(AboutMetadataBuilder::new().name(Some(app_name)).build()));
let hide = PredefinedMenuItem::hide(None);
let hide_others = PredefinedMenuItem::hide_others(None);
let show_all = PredefinedMenuItem::show_all(None);
let quit = PredefinedMenuItem::quit(None);
let app_submenu = Submenu::with_items(
"",
true,
&[&about, &PredefinedMenuItem::separator(), &hide, &hide_others, &show_all, &PredefinedMenuItem::separator(), &quit],
)
.unwrap();
let menu = MudaMenu::new();
menu.prepend(&app_submenu).unwrap();
menu.init_for_nsapp();
MenuEvent::set_event_handler(Some(move |event: MenuEvent| {
if let Some(id) = menu_id_to_u64(event.id()) {
event_scheduler.schedule(AppEvent::MenuEvent { id });
}
}));
Menu { inner: menu }
}
pub(super) fn update(&self, entries: Vec<WrapperMenuItem>) {
let new_entries = menu_items_from_wrapper(entries);
let existing_entries = self.inner.items();
let mut new_entries_iter = new_entries.iter();
let mut existing_entries_iter = existing_entries.iter().skip(1); // Skip first menu (app menu)
let incremental_update_ok = std::iter::from_fn(move || match (existing_entries_iter.next(), new_entries_iter.next()) {
(Some(MenuItemKind::Submenu(old)), Some(MenuItemKind::Submenu(new))) if old.text() == new.text() => {
replace_children(old, 0, new.items());
Some(true)
}
(None, None) => None,
_ => Some(false),
})
.all(|b| b);
if !incremental_update_ok {
// Fallback to full replace
replace_children(&self.inner, 1, new_entries); // Skip first menu (app menu)
}
}
}
fn menu_items_from_wrapper(entries: Vec<WrapperMenuItem>) -> Vec<MenuItemKind> {
let mut menu_items: Vec<MenuItemKind> = Vec::new();
for entry in entries {
match entry {
WrapperMenuItem::Action { id, text, enabled, shortcut } => {
let id = u64_to_menu_id(id);
let accelerator = shortcut.map(|s| Accelerator::new(Some(s.modifiers), s.key));
let item = MenuItem::with_id(id, text, enabled, accelerator);
menu_items.push(MenuItemKind::MenuItem(item));
}
WrapperMenuItem::Checkbox { id, text, enabled, shortcut, checked } => {
let id = u64_to_menu_id(id);
let accelerator = shortcut.map(|s| Accelerator::new(Some(s.modifiers), s.key));
let check = CheckMenuItem::with_id(id, text, enabled, checked, accelerator);
menu_items.push(MenuItemKind::Check(check));
}
WrapperMenuItem::SubMenu { text: name, items, .. } => {
let items = menu_items_from_wrapper(items);
let items = items.iter().map(|item| menu_item_kind_to_dyn(item)).collect::<Vec<&dyn IsMenuItem>>();
let submenu = Submenu::with_items(name, true, &items).unwrap();
menu_items.push(MenuItemKind::Submenu(submenu));
}
WrapperMenuItem::Separator => {
let separator = PredefinedMenuItem::separator();
menu_items.push(MenuItemKind::Predefined(separator));
}
}
}
menu_items
}
fn menu_item_kind_to_dyn(item: &MenuItemKind) -> &dyn IsMenuItem {
match item {
MenuItemKind::MenuItem(i) => i,
MenuItemKind::Submenu(i) => i,
MenuItemKind::Predefined(i) => i,
MenuItemKind::Check(i) => i,
MenuItemKind::Icon(i) => i,
}
}
fn u64_to_menu_id(id: u64) -> String {
format!("{id:08x}")
}
fn menu_id_to_u64(id: &MenuId) -> Option<u64> {
u64::from_str_radix(&id.0, 16).ok()
}
fn replace_children<'a, T: Into<MenuContainer<'a>>>(menu: T, skip: usize, new_items: Vec<MenuItemKind>) {
let menu: MenuContainer = menu.into();
let items = menu.items();
for item in items.iter().skip(skip) {
menu.remove(menu_item_kind_to_dyn(item)).unwrap();
}
let items = new_items.iter().map(|item| menu_item_kind_to_dyn(item)).collect::<Vec<&dyn IsMenuItem>>();
menu.append_items(items.as_ref()).unwrap();
}
enum MenuContainer<'a> {
Menu(&'a MudaMenu),
Submenu(&'a Submenu),
}
impl<'a> MenuContainer<'a> {
fn items(&self) -> Vec<MenuItemKind> {
match self {
MenuContainer::Menu(menu) => menu.items(),
MenuContainer::Submenu(submenu) => submenu.items(),
}
}
fn remove(&self, item: &dyn IsMenuItem) -> Result<()> {
match self {
MenuContainer::Menu(menu) => menu.remove(item),
MenuContainer::Submenu(submenu) => submenu.remove(item),
}
}
fn append_items(&self, items: &[&dyn IsMenuItem]) -> Result<()> {
match self {
MenuContainer::Menu(menu) => menu.append_items(items),
MenuContainer::Submenu(submenu) => submenu.append_items(items),
}
}
}
impl<'a> From<&'a MudaMenu> for MenuContainer<'a> {
fn from(menu: &'a MudaMenu) -> Self {
MenuContainer::Menu(menu)
}
}
impl<'a> From<&'a Submenu> for MenuContainer<'a> {
fn from(submenu: &'a Submenu) -> Self {
MenuContainer::Submenu(submenu)
}
}
-32
View File
@@ -1,32 +0,0 @@
use winit::event_loop::ActiveEventLoop;
use winit::window::{Window, WindowAttributes};
use crate::event::AppEventScheduler;
pub(super) struct NativeWindowImpl {
native_handle: native_handle::NativeWindowHandle,
}
impl super::NativeWindow for NativeWindowImpl {
fn configure(attributes: WindowAttributes, _event_loop: &dyn ActiveEventLoop) -> WindowAttributes {
if let Ok(win_icon) = winit::platform::windows::WinIcon::from_resource(1, None) {
let icon = winit::icon::Icon(std::sync::Arc::new(win_icon));
attributes.with_window_icon(Some(icon))
} else {
attributes
}
}
fn new(window: &dyn Window, _app_event_scheduler: AppEventScheduler) -> Self {
let native_handle = native_handle::NativeWindowHandle::new(window);
NativeWindowImpl { native_handle }
}
}
impl Drop for NativeWindowImpl {
fn drop(&mut self) {
self.native_handle.destroy();
}
}
mod native_handle;
-2
View File
@@ -31,5 +31,3 @@ ron = { workspace = true}
vello = { workspace = true }
image = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
keyboard-types = { workspace = true }
@@ -1,9 +1,7 @@
use graphene_std::Color;
use graphene_std::raster::Image;
use graphite_editor::messages::app_window::app_window_message_handler::AppWindowPlatform;
use graphite_editor::messages::layout::LayoutMessage;
use graphite_editor::messages::prelude::*;
use graphite_editor::messages::tool::tool_messages::tool_prelude::{LayoutTarget, WidgetId};
use graphite_editor::messages::prelude::{AppWindowMessage, DocumentMessage, PortfolioMessage, PreferencesMessage};
use crate::messages::Platform;
@@ -57,7 +55,7 @@ pub(super) fn handle_desktop_wrapper_message(dispatcher: &mut DesktopWrapperMess
document_path: Some(path),
document_serialized_content: content,
};
dispatcher.queue_editor_message(message);
dispatcher.queue_editor_message(message.into());
}
DesktopWrapperMessage::ImportFile { path, content } => {
let extension = path.extension().and_then(|s| s.to_str()).unwrap_or_default().to_lowercase();
@@ -82,7 +80,7 @@ pub(super) fn handle_desktop_wrapper_message(dispatcher: &mut DesktopWrapperMess
mouse: None,
parent_and_insert_index: None,
};
dispatcher.queue_editor_message(message);
dispatcher.queue_editor_message(message.into());
}
DesktopWrapperMessage::ImportImage { path, content } => {
let name = path.file_stem().and_then(|s| s.to_str()).map(|s| s.to_string());
@@ -108,7 +106,7 @@ pub(super) fn handle_desktop_wrapper_message(dispatcher: &mut DesktopWrapperMess
mouse: None,
parent_and_insert_index: None,
};
dispatcher.queue_editor_message(message);
dispatcher.queue_editor_message(message.into());
}
DesktopWrapperMessage::PollNodeGraphEvaluation => dispatcher.poll_node_graph_evaluation(),
DesktopWrapperMessage::UpdatePlatform(platform) => {
@@ -118,11 +116,7 @@ pub(super) fn handle_desktop_wrapper_message(dispatcher: &mut DesktopWrapperMess
Platform::Linux => AppWindowPlatform::Linux,
};
let message = AppWindowMessage::AppWindowUpdatePlatform { platform };
dispatcher.queue_editor_message(message);
}
DesktopWrapperMessage::UpdateMaximized { maximized } => {
let message = FrontendMessage::UpdateMaximized { maximized };
dispatcher.queue_editor_message(message);
dispatcher.queue_editor_message(message.into());
}
DesktopWrapperMessage::LoadDocument {
id,
@@ -140,23 +134,15 @@ pub(super) fn handle_desktop_wrapper_message(dispatcher: &mut DesktopWrapperMess
to_front,
select_after_open,
};
dispatcher.queue_editor_message(message);
dispatcher.queue_editor_message(message.into());
}
DesktopWrapperMessage::SelectDocument { id } => {
let message = PortfolioMessage::SelectDocument { document_id: id };
dispatcher.queue_editor_message(message);
dispatcher.queue_editor_message(message.into());
}
DesktopWrapperMessage::LoadPreferences { preferences } => {
let message = PreferencesMessage::Load { preferences };
dispatcher.queue_editor_message(message);
}
DesktopWrapperMessage::MenuEvent { id } => {
let message = LayoutMessage::WidgetValueUpdate {
layout_target: LayoutTarget::MenuBar,
widget_id: WidgetId(id),
value: serde_json::Value::Bool(true),
};
dispatcher.queue_editor_message(message);
dispatcher.queue_editor_message(message.into());
}
}
}
@@ -1,7 +1,23 @@
use super::DesktopWrapperMessageDispatcher;
use super::messages::EditorMessage;
use graphite_editor::messages::prelude::InputPreprocessorMessage;
pub(super) fn intercept_editor_message(_dispatcher: &mut DesktopWrapperMessageDispatcher, message: EditorMessage) -> Option<EditorMessage> {
// TODO: remove it turns out to be unnecessary
Some(message)
use super::DesktopWrapperMessageDispatcher;
use super::messages::{DesktopFrontendMessage, EditorMessage};
pub(super) fn intercept_editor_message(dispatcher: &mut DesktopWrapperMessageDispatcher, message: EditorMessage) -> Option<EditorMessage> {
match message {
EditorMessage::InputPreprocessor(message) => {
if let InputPreprocessorMessage::BoundsOfViewports { bounds_of_viewports } = &message {
let top_left = bounds_of_viewports[0].top_left;
let bottom_right = bounds_of_viewports[0].bottom_right;
dispatcher.respond(DesktopFrontendMessage::UpdateViewportBounds {
x: top_left.x as f32,
y: top_left.y as f32,
width: (bottom_right.x - top_left.x) as f32,
height: (bottom_right.y - top_left.y) as f32,
});
}
Some(EditorMessage::InputPreprocessor(message))
}
m => Some(m),
}
}
@@ -1,12 +1,9 @@
use std::path::PathBuf;
use graphite_editor::messages::input_mapper::utility_types::input_keyboard::{Key, LayoutKey, LayoutKeysGroup};
use graphite_editor::messages::input_mapper::utility_types::misc::ActionKeys;
use graphite_editor::messages::layout::utility_types::widgets::menu_widgets::MenuBarEntry;
use graphite_editor::messages::prelude::FrontendMessage;
use super::DesktopWrapperMessageDispatcher;
use super::messages::{DesktopFrontendMessage, Document, FileFilter, KeyCode, MenuItem, Modifiers, OpenFileDialogContext, SaveFileDialogContext, Shortcut};
use super::messages::{DesktopFrontendMessage, Document, FileFilter, OpenFileDialogContext, SaveFileDialogContext};
pub(super) fn intercept_frontend_message(dispatcher: &mut DesktopWrapperMessageDispatcher, message: FrontendMessage) -> Option<FrontendMessage> {
match message {
@@ -67,27 +64,24 @@ pub(super) fn intercept_frontend_message(dispatcher: &mut DesktopWrapperMessageD
FrontendMessage::TriggerVisitLink { url } => {
dispatcher.respond(DesktopFrontendMessage::OpenUrl(url));
}
FrontendMessage::UpdateWindowState { maximized, minimized } => {
dispatcher.respond(DesktopFrontendMessage::UpdateWindowState { maximized, minimized });
// Forward this to update the UI
return Some(message);
}
FrontendMessage::DragWindow => {
dispatcher.respond(DesktopFrontendMessage::DragWindow);
}
FrontendMessage::CloseWindow => {
dispatcher.respond(DesktopFrontendMessage::CloseWindow);
}
FrontendMessage::TriggerMinimizeWindow => {
dispatcher.respond(DesktopFrontendMessage::MinimizeWindow);
}
FrontendMessage::TriggerMaximizeWindow => {
dispatcher.respond(DesktopFrontendMessage::MaximizeWindow);
}
FrontendMessage::UpdateViewportPhysicalBounds { x, y, width, height } => {
dispatcher.respond(DesktopFrontendMessage::UpdateViewportPhysicalBounds { x, y, width, height });
}
FrontendMessage::TriggerPersistenceWriteDocument { document_id, document, details } => {
dispatcher.respond(DesktopFrontendMessage::PersistenceWriteDocument {
id: document_id,
document: Document {
name: details.name,
path: details.path,
path: None,
content: document,
is_saved: details.is_saved,
},
@@ -116,213 +110,13 @@ pub(super) fn intercept_frontend_message(dispatcher: &mut DesktopWrapperMessageD
FrontendMessage::TriggerLoadRestAutoSaveDocuments => {
dispatcher.respond(DesktopFrontendMessage::PersistenceLoadRemainingDocuments);
}
FrontendMessage::TriggerOpenLaunchDocuments => {
dispatcher.respond(DesktopFrontendMessage::OpenLaunchDocuments);
}
FrontendMessage::TriggerSavePreferences { preferences } => {
dispatcher.respond(DesktopFrontendMessage::PersistenceWritePreferences { preferences });
}
FrontendMessage::TriggerLoadPreferences => {
dispatcher.respond(DesktopFrontendMessage::PersistenceLoadPreferences);
}
FrontendMessage::UpdateMenuBarLayout { layout_target, layout } => {
let entries = convert_menu_bar_entries_to_menu_items(&layout);
dispatcher.respond(DesktopFrontendMessage::UpdateMenu { entries });
return Some(FrontendMessage::UpdateMenuBarLayout { layout, layout_target });
}
m => return Some(m),
}
None
}
fn convert_menu_bar_entries_to_menu_items(layout: &[MenuBarEntry]) -> Vec<MenuItem> {
layout.iter().filter_map(convert_menu_bar_entry_to_menu_item).collect()
}
fn convert_menu_bar_entry_to_menu_item(
MenuBarEntry {
label,
icon,
shortcut,
action,
children,
disabled,
}: &MenuBarEntry,
) -> Option<MenuItem> {
let id = action.widget_id.0;
let text = if label.is_empty() {
return None;
} else {
label.clone()
};
let enabled = !*disabled;
if !children.0.is_empty() {
let items = convert_menu_bar_entry_children_to_menu_items(&children.0);
return Some(MenuItem::SubMenu { id, text, enabled, items });
}
let shortcut = match shortcut {
Some(ActionKeys::Keys(LayoutKeysGroup(keys))) => convert_layout_keys_to_shortcut(keys),
_ => None,
};
// TODO: Find a better way to determine if this is a checkbox
match icon.as_deref() {
Some("CheckboxChecked") => {
return Some(MenuItem::Checkbox {
id,
text,
enabled,
shortcut,
checked: true,
});
}
Some("CheckboxUnchecked") => {
return Some(MenuItem::Checkbox {
id,
text,
enabled,
shortcut,
checked: false,
});
}
_ => {}
}
Some(MenuItem::Action { id, text, shortcut, enabled })
}
fn convert_menu_bar_entry_children_to_menu_items(children: &[Vec<MenuBarEntry>]) -> Vec<MenuItem> {
let mut items = Vec::new();
for (i, section) in children.iter().enumerate() {
for entry in section.iter() {
if let Some(item) = convert_menu_bar_entry_to_menu_item(entry) {
items.push(item);
}
}
if i != children.len() - 1 {
items.push(MenuItem::Separator);
}
}
items
}
fn convert_layout_keys_to_shortcut(layout_keys: &Vec<LayoutKey>) -> Option<Shortcut> {
let mut key: Option<KeyCode> = None;
let mut modifiers = Modifiers::default();
for layout_key in layout_keys {
match layout_key.key {
Key::Shift => modifiers |= Modifiers::SHIFT,
Key::Control => modifiers |= Modifiers::CONTROL,
Key::Alt => modifiers |= Modifiers::ALT,
Key::Meta => modifiers |= Modifiers::META,
Key::Command => modifiers |= Modifiers::ALT,
Key::Accel => modifiers |= Modifiers::META,
Key::Digit0 => key = Some(KeyCode::Digit0),
Key::Digit1 => key = Some(KeyCode::Digit1),
Key::Digit2 => key = Some(KeyCode::Digit2),
Key::Digit3 => key = Some(KeyCode::Digit3),
Key::Digit4 => key = Some(KeyCode::Digit4),
Key::Digit5 => key = Some(KeyCode::Digit5),
Key::Digit6 => key = Some(KeyCode::Digit6),
Key::Digit7 => key = Some(KeyCode::Digit7),
Key::Digit8 => key = Some(KeyCode::Digit8),
Key::Digit9 => key = Some(KeyCode::Digit9),
Key::KeyA => key = Some(KeyCode::KeyA),
Key::KeyB => key = Some(KeyCode::KeyB),
Key::KeyC => key = Some(KeyCode::KeyC),
Key::KeyD => key = Some(KeyCode::KeyD),
Key::KeyE => key = Some(KeyCode::KeyE),
Key::KeyF => key = Some(KeyCode::KeyF),
Key::KeyG => key = Some(KeyCode::KeyG),
Key::KeyH => key = Some(KeyCode::KeyH),
Key::KeyI => key = Some(KeyCode::KeyI),
Key::KeyJ => key = Some(KeyCode::KeyJ),
Key::KeyK => key = Some(KeyCode::KeyK),
Key::KeyL => key = Some(KeyCode::KeyL),
Key::KeyM => key = Some(KeyCode::KeyM),
Key::KeyN => key = Some(KeyCode::KeyN),
Key::KeyO => key = Some(KeyCode::KeyO),
Key::KeyP => key = Some(KeyCode::KeyP),
Key::KeyQ => key = Some(KeyCode::KeyQ),
Key::KeyR => key = Some(KeyCode::KeyR),
Key::KeyS => key = Some(KeyCode::KeyS),
Key::KeyT => key = Some(KeyCode::KeyT),
Key::KeyU => key = Some(KeyCode::KeyU),
Key::KeyV => key = Some(KeyCode::KeyV),
Key::KeyW => key = Some(KeyCode::KeyW),
Key::KeyX => key = Some(KeyCode::KeyX),
Key::KeyY => key = Some(KeyCode::KeyY),
Key::KeyZ => key = Some(KeyCode::KeyZ),
Key::Backquote => key = Some(KeyCode::Backquote),
Key::Backslash => key = Some(KeyCode::Backslash),
Key::BracketLeft => key = Some(KeyCode::BracketLeft),
Key::BracketRight => key = Some(KeyCode::BracketRight),
Key::Comma => key = Some(KeyCode::Comma),
Key::Equal => key = Some(KeyCode::Equal),
Key::Minus => key = Some(KeyCode::Minus),
Key::Period => key = Some(KeyCode::Period),
Key::Quote => key = Some(KeyCode::Quote),
Key::Semicolon => key = Some(KeyCode::Semicolon),
Key::Slash => key = Some(KeyCode::Slash),
Key::Backspace => key = Some(KeyCode::Backspace),
Key::CapsLock => key = Some(KeyCode::CapsLock),
Key::ContextMenu => key = Some(KeyCode::ContextMenu),
Key::Enter => key = Some(KeyCode::Enter),
Key::Space => key = Some(KeyCode::Space),
Key::Tab => key = Some(KeyCode::Tab),
Key::Delete => key = Some(KeyCode::Delete),
Key::End => key = Some(KeyCode::End),
Key::Help => key = Some(KeyCode::Help),
Key::Home => key = Some(KeyCode::Home),
Key::Insert => key = Some(KeyCode::Insert),
Key::PageDown => key = Some(KeyCode::PageDown),
Key::PageUp => key = Some(KeyCode::PageUp),
Key::ArrowDown => key = Some(KeyCode::ArrowDown),
Key::ArrowLeft => key = Some(KeyCode::ArrowLeft),
Key::ArrowRight => key = Some(KeyCode::ArrowRight),
Key::ArrowUp => key = Some(KeyCode::ArrowUp),
Key::NumLock => key = Some(KeyCode::NumLock),
Key::NumpadAdd => key = Some(KeyCode::NumpadAdd),
Key::NumpadHash => key = Some(KeyCode::NumpadHash),
Key::NumpadMultiply => key = Some(KeyCode::NumpadMultiply),
Key::NumpadParenLeft => key = Some(KeyCode::NumpadParenLeft),
Key::NumpadParenRight => key = Some(KeyCode::NumpadParenRight),
Key::Escape => key = Some(KeyCode::Escape),
Key::F1 => key = Some(KeyCode::F1),
Key::F2 => key = Some(KeyCode::F2),
Key::F3 => key = Some(KeyCode::F3),
Key::F4 => key = Some(KeyCode::F4),
Key::F5 => key = Some(KeyCode::F5),
Key::F6 => key = Some(KeyCode::F6),
Key::F7 => key = Some(KeyCode::F7),
Key::F8 => key = Some(KeyCode::F8),
Key::F9 => key = Some(KeyCode::F9),
Key::F10 => key = Some(KeyCode::F10),
Key::F11 => key = Some(KeyCode::F11),
Key::F12 => key = Some(KeyCode::F12),
Key::F13 => key = Some(KeyCode::F13),
Key::F14 => key = Some(KeyCode::F14),
Key::F15 => key = Some(KeyCode::F15),
Key::F16 => key = Some(KeyCode::F16),
Key::F17 => key = Some(KeyCode::F17),
Key::F18 => key = Some(KeyCode::F18),
Key::F19 => key = Some(KeyCode::F19),
Key::F20 => key = Some(KeyCode::F20),
Key::F21 => key = Some(KeyCode::F21),
Key::F22 => key = Some(KeyCode::F22),
Key::F23 => key = Some(KeyCode::F23),
Key::F24 => key = Some(KeyCode::F24),
Key::Fn => key = Some(KeyCode::Fn),
Key::FnLock => key = Some(KeyCode::FnLock),
Key::PrintScreen => key = Some(KeyCode::PrintScreen),
Key::ScrollLock => key = Some(KeyCode::ScrollLock),
Key::Pause => key = Some(KeyCode::Pause),
Key::Unidentified => key = Some(KeyCode::Unidentified),
_ => key = None,
}
}
key.map(|key| Shortcut { key, modifiers })
}
+1 -3
View File
@@ -5,10 +5,8 @@ use graphite_editor::messages::prelude::{FrontendMessage, Message};
// TODO: Remove usage of this reexport in desktop create and remove this line
pub use graphene_std::Color;
pub use wgpu_executor::WgpuContext;
pub use wgpu_executor::WgpuContextBuilder;
pub use wgpu_executor::Context as WgpuContext;
pub use wgpu_executor::WgpuExecutor;
pub use wgpu_executor::WgpuFeatures;
pub mod messages;
use messages::{DesktopFrontendMessage, DesktopWrapperMessage};
+3 -5
View File
@@ -32,8 +32,8 @@ impl<'a> DesktopWrapperMessageDispatcher<'a> {
self.desktop_wrapper_message_queue.push_back(message);
}
pub(super) fn queue_editor_message<T: Into<EditorMessage>>(&mut self, message: T) {
if let Some(message) = intercept_editor_message(self, message.into()) {
pub(super) fn queue_editor_message(&mut self, message: EditorMessage) {
if let Some(message) = intercept_editor_message(self, message) {
self.editor_message_queue.push(message);
}
}
@@ -71,8 +71,6 @@ impl<'a> DesktopWrapperMessageDispatcher<'a> {
frontend_messages.extend(current_frontend_messages);
}
if !frontend_messages.is_empty() {
self.respond(DesktopFrontendMessage::ToWeb(frontend_messages));
}
self.respond(DesktopFrontendMessage::ToWeb(frontend_messages));
}
}
+12 -48
View File
@@ -1,13 +1,13 @@
pub use graphite_editor::messages::prelude::DocumentId;
use graphite_editor::messages::prelude::FrontendMessage;
use std::path::PathBuf;
pub(crate) use graphite_editor::messages::prelude::Message as EditorMessage;
pub use graphite_editor::messages::prelude::DocumentId;
pub use graphite_editor::messages::prelude::PreferencesMessageHandler as Preferences;
pub enum DesktopFrontendMessage {
ToWeb(Vec<FrontendMessage>),
OpenLaunchDocuments,
OpenFileDialog {
title: String,
filters: Vec<FileFilter>,
@@ -25,15 +25,17 @@ pub enum DesktopFrontendMessage {
content: Vec<u8>,
},
OpenUrl(String),
UpdateViewportPhysicalBounds {
x: f64,
y: f64,
width: f64,
height: f64,
UpdateViewportBounds {
x: f32,
y: f32,
width: f32,
height: f32,
},
UpdateOverlays(vello::Scene),
MinimizeWindow,
MaximizeWindow,
UpdateWindowState {
maximized: bool,
minimized: bool,
},
DragWindow,
CloseWindow,
PersistenceWriteDocument {
@@ -55,9 +57,6 @@ pub enum DesktopFrontendMessage {
preferences: Preferences,
},
PersistenceLoadPreferences,
UpdateMenu {
entries: Vec<MenuItem>,
},
}
pub enum DesktopWrapperMessage {
@@ -93,9 +92,6 @@ pub enum DesktopWrapperMessage {
},
PollNodeGraphEvaluation,
UpdatePlatform(Platform),
UpdateMaximized {
maximized: bool,
},
LoadDocument {
id: DocumentId,
document: Document,
@@ -106,10 +102,7 @@ pub enum DesktopWrapperMessage {
id: DocumentId,
},
LoadPreferences {
preferences: Option<Preferences>,
},
MenuEvent {
id: u64,
preferences: Preferences,
},
}
@@ -141,32 +134,3 @@ pub enum Platform {
Mac,
Linux,
}
pub enum MenuItem {
Action {
id: u64,
text: String,
enabled: bool,
shortcut: Option<Shortcut>,
},
Checkbox {
id: u64,
text: String,
enabled: bool,
shortcut: Option<Shortcut>,
checked: bool,
},
SubMenu {
id: u64,
text: String,
enabled: bool,
items: Vec<MenuItem>,
},
Separator,
}
pub use keyboard_types::{Code as KeyCode, Modifiers};
pub struct Shortcut {
pub key: KeyCode,
pub modifiers: Modifiers,
}
-1
View File
@@ -45,7 +45,6 @@ web-sys = { workspace = true }
vello = { workspace = true }
base64 = { workspace = true }
spin = { workspace = true }
image = { workspace = true }
# Optional local dependencies
wgpu-executor = { workspace = true, optional = true }
+9 -42
View File
@@ -8,7 +8,6 @@ use crate::messages::prelude::*;
pub struct Dispatcher {
message_queues: Vec<VecDeque<Message>>,
pub responses: Vec<FrontendMessage>,
pub frontend_update_messages: Vec<Message>,
pub message_handlers: DispatcherMessageHandlers,
}
@@ -27,7 +26,6 @@ pub struct DispatcherMessageHandlers {
pub portfolio_message_handler: PortfolioMessageHandler,
preferences_message_handler: PreferencesMessageHandler,
tool_message_handler: ToolMessageHandler,
viewport_message_handler: ViewportMessageHandler,
}
impl DispatcherMessageHandlers {
@@ -43,24 +41,19 @@ impl DispatcherMessageHandlers {
/// The last occurrence of the message in the message queue is sufficient to ensure correct behavior.
/// In addition, these messages do not change any state in the backend (aside from caches).
const SIDE_EFFECT_FREE_MESSAGES: &[MessageDiscriminant] = &[
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::PropertiesPanel(
PropertiesPanelMessageDiscriminant::Refresh,
))),
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::DocumentStructureChanged)),
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::Overlays(OverlaysMessageDiscriminant::Draw))),
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::NodeGraph(
NodeGraphMessageDiscriminant::RunDocumentGraph,
))),
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::SubmitActiveGraphRender),
MessageDiscriminant::Frontend(FrontendMessageDiscriminant::TriggerFontLoad),
];
/// Since we don't need to update the frontend multiple times per frame,
/// we have a set of messages which we will buffer until the next frame is requested.
const FRONTEND_UPDATE_MESSAGES: &[MessageDiscriminant] = &[
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::PropertiesPanel(
PropertiesPanelMessageDiscriminant::Refresh,
))),
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::UpdateDocumentWidgets),
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::Overlays(OverlaysMessageDiscriminant::Draw))),
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::RenderRulers)),
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::RenderScrollbars)),
MessageDiscriminant::Frontend(FrontendMessageDiscriminant::UpdateDocumentLayerStructure),
MessageDiscriminant::Frontend(FrontendMessageDiscriminant::TriggerFontLoad),
];
const DEBUG_MESSAGE_BLOCK_LIST: &[MessageDiscriminant] = &[
MessageDiscriminant::Broadcast(BroadcastMessageDiscriminant::TriggerEvent(EventMessageDiscriminant::AnimationFrame)),
@@ -111,19 +104,6 @@ impl Dispatcher {
while let Some(message) = self.message_queues.last_mut().and_then(VecDeque::pop_front) {
// Skip processing of this message if it will be processed later (at the end of the shallowest level queue)
if FRONTEND_UPDATE_MESSAGES.contains(&message.to_discriminant()) {
let already_in_queue = self.message_queues.first().is_some_and(|queue| queue.contains(&message));
if already_in_queue {
self.cleanup_queues(false);
continue;
} else if self.message_queues.len() > 1 {
if !self.frontend_update_messages.contains(&message) {
self.frontend_update_messages.push(message);
}
self.cleanup_queues(false);
continue;
}
}
if SIDE_EFFECT_FREE_MESSAGES.contains(&message.to_discriminant()) {
let already_in_queue = self.message_queues.first().filter(|queue| queue.contains(&message)).is_some();
if already_in_queue {
@@ -147,9 +127,6 @@ impl Dispatcher {
// Process the action by forwarding it to the relevant message handler, or saving the FrontendMessage to be sent to the frontend
match message {
Message::Animation(message) => {
if let AnimationMessage::IncrementFrameCounter = &message {
self.message_queues[0].extend(self.frontend_update_messages.drain(..));
}
self.message_handlers.animation_message_handler.process_message(message, &mut queue, ());
}
Message::AppWindow(message) => {
@@ -169,6 +146,7 @@ impl Dispatcher {
let context = DialogMessageContext {
portfolio: &self.message_handlers.portfolio_message_handler,
preferences: &self.message_handlers.preferences_message_handler,
viewport_bounds: &self.message_handlers.input_preprocessor_message_handler.viewport_bounds,
};
self.message_handlers.dialog_message_handler.process_message(message, &mut queue, context);
}
@@ -191,14 +169,9 @@ impl Dispatcher {
Message::InputPreprocessor(message) => {
let keyboard_platform = GLOBAL_PLATFORM.get().copied().unwrap_or_default().as_keyboard_platform_layout();
self.message_handlers.input_preprocessor_message_handler.process_message(
message,
&mut queue,
InputPreprocessorMessageContext {
keyboard_platform,
viewport: &self.message_handlers.viewport_message_handler,
},
);
self.message_handlers
.input_preprocessor_message_handler
.process_message(message, &mut queue, InputPreprocessorMessageContext { keyboard_platform });
}
Message::KeyMapping(message) => {
let input = &self.message_handlers.input_preprocessor_message_handler;
@@ -222,7 +195,6 @@ impl Dispatcher {
let reset_node_definitions_on_open = self.message_handlers.portfolio_message_handler.reset_node_definitions_on_open;
let timing_information = self.message_handlers.animation_message_handler.timing_information();
let animation = &self.message_handlers.animation_message_handler;
let viewport = &self.message_handlers.viewport_message_handler;
self.message_handlers.portfolio_message_handler.process_message(
message,
@@ -235,7 +207,6 @@ impl Dispatcher {
reset_node_definitions_on_open,
timing_information,
animation,
viewport,
},
);
}
@@ -259,14 +230,10 @@ impl Dispatcher {
persistent_data: &self.message_handlers.portfolio_message_handler.persistent_data,
node_graph: &self.message_handlers.portfolio_message_handler.executor,
preferences: &self.message_handlers.preferences_message_handler,
viewport: &self.message_handlers.viewport_message_handler,
};
self.message_handlers.tool_message_handler.process_message(message, &mut queue, context);
}
Message::Viewport(message) => {
self.message_handlers.viewport_message_handler.process_message(message, &mut queue, ());
}
Message::NoOp => {}
Message::Batched { messages } => {
messages.into_iter().for_each(|message| self.handle_message(message, false));
@@ -5,6 +5,8 @@ use graphite_proc_macros::{ExtractField, message_handler_data};
#[derive(Debug, Clone, Default, ExtractField)]
pub struct AppWindowMessageHandler {
platform: AppWindowPlatform,
maximized: bool,
minimized: bool,
}
#[message_handler_data]
@@ -12,10 +14,18 @@ impl MessageHandler<AppWindowMessage, ()> for AppWindowMessageHandler {
fn process_message(&mut self, message: AppWindowMessage, responses: &mut std::collections::VecDeque<Message>, _: ()) {
match message {
AppWindowMessage::AppWindowMaximize => {
responses.add(FrontendMessage::TriggerMaximizeWindow);
self.maximized = !self.maximized;
responses.add(FrontendMessage::UpdateWindowState {
maximized: self.maximized,
minimized: self.minimized,
});
}
AppWindowMessage::AppWindowMinimize => {
responses.add(FrontendMessage::TriggerMinimizeWindow);
self.minimized = !self.minimized;
responses.add(FrontendMessage::UpdateWindowState {
maximized: self.maximized,
minimized: self.minimized,
});
}
AppWindowMessage::AppWindowUpdatePlatform { platform } => {
self.platform = platform;
@@ -1,11 +1,14 @@
use super::new_document_dialog::NewDocumentDialogMessageContext;
use super::simple_dialogs::{self, AboutGraphiteDialog, ComingSoonDialog, DemoArtworkDialog, LicensesDialog};
use crate::messages::dialog::simple_dialogs::LicensesThirdPartyDialog;
use crate::messages::input_mapper::utility_types::input_mouse::ViewportBounds;
use crate::messages::layout::utility_types::widget_prelude::*;
use crate::messages::prelude::*;
#[derive(ExtractField)]
pub struct DialogMessageContext<'a> {
pub portfolio: &'a PortfolioMessageHandler,
pub viewport_bounds: &'a ViewportBounds,
pub preferences: &'a PreferencesMessageHandler,
}
@@ -20,11 +23,15 @@ pub struct DialogMessageHandler {
#[message_handler_data]
impl MessageHandler<DialogMessage, DialogMessageContext<'_>> for DialogMessageHandler {
fn process_message(&mut self, message: DialogMessage, responses: &mut VecDeque<Message>, context: DialogMessageContext) {
let DialogMessageContext { portfolio, preferences } = context;
let DialogMessageContext {
portfolio,
preferences,
viewport_bounds,
} = context;
match message {
DialogMessage::ExportDialog(message) => self.export_dialog.process_message(message, responses, ExportDialogMessageContext { portfolio }),
DialogMessage::NewDocumentDialog(message) => self.new_document_dialog.process_message(message, responses, ()),
DialogMessage::NewDocumentDialog(message) => self.new_document_dialog.process_message(message, responses, NewDocumentDialogMessageContext { viewport_bounds }),
DialogMessage::PreferencesDialog(message) => self.preferences_dialog.process_message(message, responses, PreferencesDialogMessageContext { preferences }),
DialogMessage::CloseAllDocumentsWithConfirmation => {
@@ -4,4 +4,4 @@ mod new_document_dialog_message_handler;
#[doc(inline)]
pub use new_document_dialog_message::{NewDocumentDialogMessage, NewDocumentDialogMessageDiscriminant};
#[doc(inline)]
pub use new_document_dialog_message_handler::NewDocumentDialogMessageHandler;
pub use new_document_dialog_message_handler::{NewDocumentDialogMessageContext, NewDocumentDialogMessageHandler};
@@ -1,8 +1,13 @@
use crate::messages::layout::utility_types::widget_prelude::*;
use crate::messages::prelude::*;
use crate::messages::{input_mapper::utility_types::input_mouse::ViewportBounds, layout::utility_types::widget_prelude::*};
use glam::{IVec2, UVec2};
use graph_craft::document::NodeId;
#[derive(ExtractField)]
pub struct NewDocumentDialogMessageContext<'a> {
pub viewport_bounds: &'a ViewportBounds,
}
/// A dialog to allow users to set some initial options about a new document.
#[derive(Debug, Clone, Default, ExtractField)]
pub struct NewDocumentDialogMessageHandler {
@@ -12,8 +17,8 @@ pub struct NewDocumentDialogMessageHandler {
}
#[message_handler_data]
impl<'a> MessageHandler<NewDocumentDialogMessage, ()> for NewDocumentDialogMessageHandler {
fn process_message(&mut self, message: NewDocumentDialogMessage, responses: &mut VecDeque<Message>, _: ()) {
impl<'a> MessageHandler<NewDocumentDialogMessage, NewDocumentDialogMessageContext<'a>> for NewDocumentDialogMessageHandler {
fn process_message(&mut self, message: NewDocumentDialogMessage, responses: &mut VecDeque<Message>, context: NewDocumentDialogMessageContext<'a>) {
match message {
NewDocumentDialogMessage::Name { name } => self.name = name,
NewDocumentDialogMessage::Infinite { infinite } => self.infinite = infinite,
@@ -30,9 +35,12 @@ impl<'a> MessageHandler<NewDocumentDialogMessage, ()> for NewDocumentDialogMessa
});
responses.add(NavigationMessage::CanvasPan { delta: self.dimensions.as_dvec2() });
responses.add(NodeGraphMessage::RunDocumentGraph);
responses.add(ViewportMessage::RepropagateUpdate);
// If we already have bounds, we won't receive a viewport bounds update so we just fabricate one ourselves
if *context.viewport_bounds != ViewportBounds::default() {
responses.add(InputPreprocessorMessage::BoundsOfViewports {
bounds_of_viewports: vec![context.viewport_bounds.clone()],
});
}
responses.add(DeferMessage::AfterNavigationReady {
messages: vec![DocumentMessage::ZoomCanvasToFitAll.into(), DocumentMessage::DeselectAllLayers.into()],
});
@@ -102,7 +102,6 @@ pub enum FrontendMessage {
},
TriggerLoadFirstAutoSaveDocument,
TriggerLoadRestAutoSaveDocuments,
TriggerOpenLaunchDocuments,
TriggerLoadPreferences,
TriggerOpenDocument,
TriggerPaste,
@@ -121,8 +120,6 @@ pub enum FrontendMessage {
TriggerVisitLink {
url: String,
},
TriggerMinimizeWindow,
TriggerMaximizeWindow,
// Update prefix: give the frontend a new value or state for it to use
UpdateActiveDocument {
@@ -342,20 +339,15 @@ pub enum FrontendMessage {
UpdatePlatform {
platform: AppWindowPlatform,
},
UpdateMaximized {
UpdateWindowState {
maximized: bool,
minimized: bool,
},
DragWindow,
CloseWindow,
UpdateViewportHolePunch {
active: bool,
},
UpdateViewportPhysicalBounds {
x: f64,
y: f64,
width: f64,
height: f64,
},
#[cfg(not(target_family = "wasm"))]
RenderOverlays {
#[serde(skip, default = "OverlayContext::default")]
@@ -1,5 +1,3 @@
use std::path::PathBuf;
use crate::messages::portfolio::document::utility_types::document_metadata::LayerNodeIdentifier;
use crate::messages::prelude::*;
@@ -12,7 +10,6 @@ pub struct OpenDocument {
#[derive(PartialEq, Eq, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
pub struct DocumentDetails {
pub name: String,
pub path: Option<PathBuf>,
#[serde(rename = "isSaved")]
pub is_saved: bool,
#[serde(rename = "isAutoSaved")]
@@ -304,13 +304,16 @@ impl fmt::Display for Key {
impl From<Key> for LayoutKey {
fn from(key: Key) -> Self {
Self { key, label: key.to_string() }
Self {
key: format!("{key:?}"),
label: key.to_string(),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize, specta::Type)]
pub struct LayoutKey {
pub key: Key,
struct LayoutKey {
key: String,
label: String,
}
@@ -356,7 +359,7 @@ impl From<KeysGroup> for String {
}
#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize, specta::Type)]
pub struct LayoutKeysGroup(pub Vec<LayoutKey>);
pub struct LayoutKeysGroup(Vec<LayoutKey>);
impl From<KeysGroup> for LayoutKeysGroup {
fn from(keys_group: KeysGroup) -> Self {
@@ -3,13 +3,41 @@ use crate::messages::prelude::*;
use bitflags::bitflags;
use glam::DVec2;
use std::collections::VecDeque;
use std::hash::{Hash, Hasher};
// Origin is top left
pub type DocumentPosition = DVec2;
pub type ViewportPosition = DVec2;
pub type EditorPosition = DVec2;
#[derive(PartialEq, Clone, Debug, Default, serde::Serialize, serde::Deserialize)]
pub struct ViewportBounds {
pub top_left: DVec2,
pub bottom_right: DVec2,
}
impl ViewportBounds {
pub fn from_slice(slice: &[f64]) -> Self {
Self {
top_left: DVec2::from_slice(&slice[0..2]),
bottom_right: DVec2::from_slice(&slice[2..4]),
}
}
pub fn size(&self) -> DVec2 {
(self.bottom_right - self.top_left).ceil()
}
pub fn center(&self) -> DVec2 {
(self.bottom_right - self.top_left).ceil() / 2.
}
pub fn in_bounds(&self, position: ViewportPosition) -> bool {
position.x >= 0. && position.y >= 0. && position.x <= self.bottom_right.x && position.y <= self.bottom_right.y
}
}
use std::hash::{Hash, Hasher};
#[derive(Debug, Copy, Clone, Default, serde::Serialize, serde::Deserialize)]
pub struct ScrollDelta {
pub x: f64,
@@ -85,9 +113,9 @@ impl EditorMouseState {
}
}
pub fn to_mouse_state(&self, viewport: &ViewportMessageHandler) -> MouseState {
pub fn to_mouse_state(&self, active_viewport_bounds: &ViewportBounds) -> MouseState {
MouseState {
position: (viewport.logical(self.editor_position) - viewport.offset()).into(),
position: self.editor_position - active_viewport_bounds.top_left,
mouse_keys: self.mouse_keys,
scroll_delta: self.scroll_delta,
}
@@ -1,10 +1,11 @@
use crate::messages::input_mapper::utility_types::input_keyboard::{Key, ModifierKeys};
use crate::messages::input_mapper::utility_types::input_mouse::EditorMouseState;
use crate::messages::input_mapper::utility_types::input_mouse::{EditorMouseState, ViewportBounds};
use crate::messages::prelude::*;
#[impl_message(Message, InputPreprocessor)]
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub enum InputPreprocessorMessage {
BoundsOfViewports { bounds_of_viewports: Vec<ViewportBounds> },
DoubleClick { editor_mouse_state: EditorMouseState, modifier_keys: ModifierKeys },
KeyDown { key: Key, key_repeat: bool, modifier_keys: ModifierKeys },
KeyUp { key: Key, key_repeat: bool, modifier_keys: ModifierKeys },
@@ -1,14 +1,14 @@
use crate::messages::input_mapper::utility_types::input_keyboard::{Key, KeyStates, ModifierKeys};
use crate::messages::input_mapper::utility_types::input_mouse::{MouseButton, MouseKeys, MouseState};
use crate::messages::input_mapper::utility_types::input_mouse::{MouseButton, MouseKeys, MouseState, ViewportBounds};
use crate::messages::input_mapper::utility_types::misc::FrameTimeInfo;
use crate::messages::portfolio::utility_types::KeyboardPlatformLayout;
use crate::messages::prelude::*;
use glam::DVec2;
use std::time::Duration;
#[derive(ExtractField)]
pub struct InputPreprocessorMessageContext<'a> {
pub struct InputPreprocessorMessageContext {
pub keyboard_platform: KeyboardPlatformLayout,
pub viewport: &'a ViewportMessageHandler,
}
#[derive(Debug, Default, ExtractField)]
@@ -17,18 +17,38 @@ pub struct InputPreprocessorMessageHandler {
pub time: u64,
pub keyboard: KeyStates,
pub mouse: MouseState,
pub viewport_bounds: ViewportBounds,
}
#[message_handler_data]
impl<'a> MessageHandler<InputPreprocessorMessage, InputPreprocessorMessageContext<'a>> for InputPreprocessorMessageHandler {
fn process_message(&mut self, message: InputPreprocessorMessage, responses: &mut VecDeque<Message>, context: InputPreprocessorMessageContext<'a>) {
let InputPreprocessorMessageContext { keyboard_platform, viewport } = context;
impl MessageHandler<InputPreprocessorMessage, InputPreprocessorMessageContext> for InputPreprocessorMessageHandler {
fn process_message(&mut self, message: InputPreprocessorMessage, responses: &mut VecDeque<Message>, context: InputPreprocessorMessageContext) {
let InputPreprocessorMessageContext { keyboard_platform } = context;
match message {
InputPreprocessorMessage::BoundsOfViewports { bounds_of_viewports } => {
assert_eq!(bounds_of_viewports.len(), 1, "Only one viewport is currently supported");
for bounds in bounds_of_viewports {
// TODO: Extend this to multiple viewports instead of setting it to the value of this last loop iteration
self.viewport_bounds = bounds;
responses.add(NavigationMessage::CanvasPan { delta: DVec2::ZERO });
responses.add(NodeGraphMessage::SetGridAlignedEdges);
}
responses.add(DeferMessage::AfterGraphRun {
messages: vec![
DeferMessage::AfterGraphRun {
messages: vec![DeferMessage::TriggerNavigationReady.into()],
}
.into(),
],
});
}
InputPreprocessorMessage::DoubleClick { editor_mouse_state, modifier_keys } => {
self.update_states_of_modifier_keys(modifier_keys, keyboard_platform, responses);
let mouse_state = editor_mouse_state.to_mouse_state(viewport);
let mouse_state = editor_mouse_state.to_mouse_state(&self.viewport_bounds);
self.mouse.position = mouse_state.position;
for key in mouse_state.mouse_keys {
@@ -61,7 +81,7 @@ impl<'a> MessageHandler<InputPreprocessorMessage, InputPreprocessorMessageContex
InputPreprocessorMessage::PointerDown { editor_mouse_state, modifier_keys } => {
self.update_states_of_modifier_keys(modifier_keys, keyboard_platform, responses);
let mouse_state = editor_mouse_state.to_mouse_state(viewport);
let mouse_state = editor_mouse_state.to_mouse_state(&self.viewport_bounds);
self.mouse.position = mouse_state.position;
self.translate_mouse_event(mouse_state, true, responses);
@@ -69,7 +89,7 @@ impl<'a> MessageHandler<InputPreprocessorMessage, InputPreprocessorMessageContex
InputPreprocessorMessage::PointerMove { editor_mouse_state, modifier_keys } => {
self.update_states_of_modifier_keys(modifier_keys, keyboard_platform, responses);
let mouse_state = editor_mouse_state.to_mouse_state(viewport);
let mouse_state = editor_mouse_state.to_mouse_state(&self.viewport_bounds);
self.mouse.position = mouse_state.position;
responses.add(InputMapperMessage::PointerMove);
@@ -80,7 +100,7 @@ impl<'a> MessageHandler<InputPreprocessorMessage, InputPreprocessorMessageContex
InputPreprocessorMessage::PointerUp { editor_mouse_state, modifier_keys } => {
self.update_states_of_modifier_keys(modifier_keys, keyboard_platform, responses);
let mouse_state = editor_mouse_state.to_mouse_state(viewport);
let mouse_state = editor_mouse_state.to_mouse_state(&self.viewport_bounds);
self.mouse.position = mouse_state.position;
self.translate_mouse_event(mouse_state, false, responses);
@@ -88,7 +108,7 @@ impl<'a> MessageHandler<InputPreprocessorMessage, InputPreprocessorMessageContex
InputPreprocessorMessage::PointerShake { editor_mouse_state, modifier_keys } => {
self.update_states_of_modifier_keys(modifier_keys, keyboard_platform, responses);
let mouse_state = editor_mouse_state.to_mouse_state(viewport);
let mouse_state = editor_mouse_state.to_mouse_state(&self.viewport_bounds);
self.mouse.position = mouse_state.position;
responses.add(InputMapperMessage::PointerShake);
@@ -101,7 +121,7 @@ impl<'a> MessageHandler<InputPreprocessorMessage, InputPreprocessorMessageContex
InputPreprocessorMessage::WheelScroll { editor_mouse_state, modifier_keys } => {
self.update_states_of_modifier_keys(modifier_keys, keyboard_platform, responses);
let mouse_state = editor_mouse_state.to_mouse_state(viewport);
let mouse_state = editor_mouse_state.to_mouse_state(&self.viewport_bounds);
self.mouse.position = mouse_state.position;
self.mouse.scroll_delta = mouse_state.scroll_delta;
@@ -182,6 +202,11 @@ impl InputPreprocessorMessageHandler {
responses.add(InputMapperMessage::KeyDown(key));
}
}
pub fn document_bounds(&self) -> [DVec2; 2] {
// IPP bounds are relative to the entire application
[(0., 0.).into(), self.viewport_bounds.bottom_right - self.viewport_bounds.top_left]
}
}
#[cfg(test)]
@@ -207,7 +232,6 @@ mod test {
let context = InputPreprocessorMessageContext {
keyboard_platform: KeyboardPlatformLayout::Standard,
viewport: &ViewportMessageHandler::default(),
};
input_preprocessor.process_message(message, &mut responses, context);
@@ -227,7 +251,6 @@ mod test {
let context = InputPreprocessorMessageContext {
keyboard_platform: KeyboardPlatformLayout::Standard,
viewport: &ViewportMessageHandler::default(),
};
input_preprocessor.process_message(message, &mut responses, context);
@@ -247,7 +270,6 @@ mod test {
let context = InputPreprocessorMessageContext {
keyboard_platform: KeyboardPlatformLayout::Standard,
viewport: &ViewportMessageHandler::default(),
};
input_preprocessor.process_message(message, &mut responses, context);
@@ -269,7 +291,6 @@ mod test {
let context = InputPreprocessorMessageContext {
keyboard_platform: KeyboardPlatformLayout::Standard,
viewport: &ViewportMessageHandler::default(),
};
input_preprocessor.process_message(message, &mut responses, context);
@@ -290,7 +311,6 @@ mod test {
let context = InputPreprocessorMessageContext {
keyboard_platform: KeyboardPlatformLayout::Standard,
viewport: &ViewportMessageHandler::default(),
};
input_preprocessor.process_message(message, &mut responses, context);
@@ -484,19 +484,13 @@ impl LayoutGroup {
}
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, specta::Type)]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)]
pub struct WidgetHolder {
#[serde(rename = "widgetId")]
pub widget_id: WidgetId,
pub widget: Widget,
}
impl PartialEq for WidgetHolder {
fn eq(&self, other: &Self) -> bool {
self.widget == other.widget
}
}
impl WidgetHolder {
#[deprecated(since = "0.0.0", note = "Please use the builder pattern, e.g. TextLabel::new(\"hello\").widget_holder()")]
pub fn new(widget: Widget) -> Self {
@@ -508,25 +502,6 @@ impl WidgetHolder {
/// Diffing updates self (where self is old) based on new, updating the list of modifications as it does so.
pub fn diff(&mut self, new: Self, widget_path: &mut [usize], widget_diffs: &mut Vec<WidgetDiff>) {
if let (Widget::PopoverButton(button1), Widget::PopoverButton(button2)) = (&mut self.widget, &new.widget) {
if button1.disabled == button2.disabled
&& button1.style == button2.style
&& button1.menu_direction == button2.menu_direction
&& button1.icon == button2.icon
&& button1.tooltip == button2.tooltip
&& button1.tooltip_shortcut == button2.tooltip_shortcut
&& button1.popover_min_width == button2.popover_min_width
{
let mut new_widget_path = widget_path.to_vec();
for (i, (a, b)) in button1.popover_layout.iter_mut().zip(button2.popover_layout.iter()).enumerate() {
new_widget_path.push(i);
a.diff(b.clone(), &mut new_widget_path, widget_diffs);
new_widget_path.pop();
}
return;
}
}
// If there have been changes to the actual widget (not just the id)
if self.widget != new.widget {
// We should update to the new widget value as well as a new widget id
@@ -19,7 +19,6 @@ pub struct CheckboxInput {
pub tooltip: String,
#[serde(rename = "forLabel")]
#[derivative(Debug = "ignore", PartialEq = "ignore")]
pub for_label: CheckboxId,
#[serde(skip)]
@@ -36,8 +36,7 @@ pub enum SeparatorType {
Section,
}
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Debug, Eq, Default, WidgetBuilder, specta::Type)]
#[derivative(PartialEq)]
#[derive(Clone, serde::Serialize, serde::Deserialize, Derivative, Debug, PartialEq, Eq, Default, WidgetBuilder, specta::Type)]
pub struct TextLabel {
pub disabled: bool,
@@ -63,7 +62,6 @@ pub struct TextLabel {
pub tooltip: String,
#[serde(rename = "forCheckbox")]
#[derivative(PartialEq = "ignore")]
pub for_checkbox: CheckboxId,
// Body
-2
View File
@@ -33,8 +33,6 @@ pub enum Message {
Preferences(PreferencesMessage),
#[child]
Tool(ToolMessage),
#[child]
Viewport(ViewportMessage),
// Messages
Batched {
-1
View File
@@ -16,4 +16,3 @@ pub mod portfolio;
pub mod preferences;
pub mod prelude;
pub mod tool;
pub mod viewport;
@@ -165,7 +165,6 @@ fn generate_layout(introspected_data: &Arc<dyn std::any::Any + Send + Sync + 'st
Table<Raster<GPU>>,
Table<Color>,
Table<GradientStops>,
Vec<String>,
f64,
u32,
u64,
@@ -204,44 +203,12 @@ trait TableRowLayout {
}
}
impl<T: TableRowLayout> TableRowLayout for Vec<T> {
fn type_name() -> &'static str {
"Vec"
}
fn identifier(&self) -> String {
format!("Vec<{}> ({} element{})", T::type_name(), self.len(), if self.len() == 1 { "" } else { "s" })
}
fn element_page(&self, data: &mut LayoutData) -> Vec<LayoutGroup> {
if let Some(index) = data.desired_path.get(data.current_depth).copied() {
if let Some(row) = self.get(index) {
data.current_depth += 1;
let result = row.layout_with_breadcrumb(data);
data.current_depth -= 1;
return result;
} else {
warn!("Desired path truncated");
data.desired_path.truncate(data.current_depth);
}
}
let mut rows = self
.iter()
.enumerate()
.map(|(index, row)| vec![TextLabel::new(format!("{index}")).narrow(true).widget_holder(), row.element_widget(index)])
.collect::<Vec<_>>();
rows.insert(0, column_headings(&["", "element"]));
vec![LayoutGroup::Table { rows }]
}
}
impl<T: TableRowLayout> TableRowLayout for Table<T> {
fn type_name() -> &'static str {
"Table"
}
fn identifier(&self) -> String {
format!("Table<{}> ({} element{})", T::type_name(), self.len(), if self.len() == 1 { "" } else { "s" })
format!("Table<{}> ({} row{})", T::type_name(), self.len(), if self.len() == 1 { "" } else { "s" })
}
fn element_page(&self, data: &mut LayoutData) -> Vec<LayoutGroup> {
if let Some(index) = data.desired_path.get(data.current_depth).copied() {
@@ -628,13 +595,7 @@ impl TableRowLayout for String {
"String"
}
fn identifier(&self) -> String {
// Show the first line, and if there are more, indicate that with an ellipsis
let first_line = self.lines().next().unwrap_or("");
if self.lines().count() > 1 {
format!("\"{} …\"", first_line)
} else {
format!("\"{}\"", first_line)
}
"String".to_string()
}
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
let widgets = vec![TextAreaInput::new(self.to_string()).disabled(true).widget_holder()];
@@ -52,10 +52,10 @@ pub struct DocumentMessageContext<'a> {
pub executor: &'a mut NodeGraphExecutor,
pub current_tool: &'a ToolType,
pub preferences: &'a PreferencesMessageHandler,
pub device_pixel_ratio: f64,
pub data_panel_open: bool,
pub layers_panel_open: bool,
pub properties_panel_open: bool,
pub viewport: &'a ViewportMessageHandler,
}
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, ExtractField)]
@@ -195,9 +195,9 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
ipp,
persistent_data,
executor,
viewport,
current_tool,
preferences,
device_pixel_ratio,
data_panel_open,
layers_panel_open,
properties_panel_open,
@@ -213,7 +213,6 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
document_ptz: &mut self.document_ptz,
graph_view_overlay_open: self.graph_view_overlay_open,
preferences,
viewport,
};
self.navigation_handler.process_message(message, responses, context);
@@ -222,8 +221,15 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
let visibility_settings = self.overlays_visibility_settings;
// Send the overlays message to the overlays message handler
self.overlays_message_handler
.process_message(message, responses, OverlaysMessageContext { visibility_settings, viewport });
self.overlays_message_handler.process_message(
message,
responses,
OverlaysMessageContext {
visibility_settings,
ipp,
device_pixel_ratio,
},
);
}
DocumentMessage::PropertiesPanel(message) => {
let context = PropertiesPanelMessageContext {
@@ -262,7 +268,6 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
navigation_handler: &self.navigation_handler,
preferences,
layers_panel_open,
viewport,
},
);
}
@@ -375,8 +380,8 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
responses.add(NodeGraphMessage::SelectedNodesSet { nodes: vec![] });
self.layer_range_selection_reference = None;
}
DocumentMessage::DocumentHistoryBackward => self.undo_with_history(viewport, responses),
DocumentMessage::DocumentHistoryForward => self.redo_with_history(viewport, responses),
DocumentMessage::DocumentHistoryBackward => self.undo_with_history(ipp, responses),
DocumentMessage::DocumentHistoryForward => self.redo_with_history(ipp, responses),
DocumentMessage::DocumentStructureChanged => {
if layers_panel_open {
self.network_interface.load_structure();
@@ -491,9 +496,6 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
self.node_graph_handler.wire_in_progress_from_connector = None;
self.node_graph_handler.wire_in_progress_to_connector = None;
responses.add(FrontendMessage::UpdateWirePathInProgress { wire_path: None });
} else if !self.breadcrumb_network_path.is_empty() {
// Exit one level up if inside a nested network
responses.add(DocumentMessage::ExitNestedNetwork { steps_back: 1 });
} else {
responses.add(DocumentMessage::GraphViewOverlay { open: false });
}
@@ -831,7 +833,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
let scale = DAffine2::from_scale(enlargement_factor);
let pivot = DAffine2::from_translation(pivot);
let transformation = pivot * scale * pivot.inverse();
let document_to_viewport = self.navigation_handler.calculate_offset_transform(viewport.center_in_viewport_space().into(), &self.document_ptz);
let document_to_viewport = self.navigation_handler.calculate_offset_transform(ipp.viewport_bounds.center(), &self.document_ptz);
for layer in self.network_interface.shallowest_unique_layers(&[]).filter(|layer| can_move(*layer)) {
let to = document_to_viewport.inverse() * self.metadata().downstream_transform_to_viewport(layer);
@@ -856,10 +858,10 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
let image_size = DVec2::new(image.width as f64, image.height as f64);
// Align the layer with the mouse or center of viewport
let viewport_location = mouse.map_or(viewport.center_in_viewport_space().into_dvec2() + viewport.offset().into_dvec2(), |pos| pos.into());
let viewport_location = mouse.map_or(ipp.viewport_bounds.center() + ipp.viewport_bounds.top_left, |pos| pos.into());
let document_to_viewport = self.navigation_handler.calculate_offset_transform(viewport.center_in_viewport_space().into(), &self.document_ptz);
let center_in_viewport = DAffine2::from_translation(document_to_viewport.inverse().transform_point2(viewport_location - viewport.offset().into_dvec2()));
let document_to_viewport = self.navigation_handler.calculate_offset_transform(ipp.viewport_bounds.center(), &self.document_ptz);
let center_in_viewport = DAffine2::from_translation(document_to_viewport.inverse().transform_point2(viewport_location - ipp.viewport_bounds.top_left));
let center_in_viewport_layerspace = center_in_viewport;
// Make layer the size of the image
@@ -908,9 +910,9 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
mouse,
parent_and_insert_index,
} => {
let document_to_viewport = self.navigation_handler.calculate_offset_transform(viewport.center_in_viewport_space().into(), &self.document_ptz);
let viewport_location = mouse.map_or(viewport.center_in_viewport_space().into_dvec2() + viewport.offset().into_dvec2(), |pos| pos.into());
let center_in_viewport = DAffine2::from_translation(document_to_viewport.inverse().transform_point2(viewport_location - viewport.offset().into_dvec2()));
let document_to_viewport = self.navigation_handler.calculate_offset_transform(ipp.viewport_bounds.center(), &self.document_ptz);
let viewport_location = mouse.map_or(ipp.viewport_bounds.center() + ipp.viewport_bounds.top_left, |pos| pos.into());
let center_in_viewport = DAffine2::from_translation(document_to_viewport.inverse().transform_point2(viewport_location - ipp.viewport_bounds.top_left));
let layer_node_id = NodeId::new();
let layer_id = LayerNodeIdentifier::new_unchecked(layer_node_id);
@@ -965,7 +967,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
} else {
&self.document_ptz
};
let document_to_viewport = self.navigation_handler.calculate_offset_transform(viewport.center_in_viewport_space().into(), current_ptz);
let document_to_viewport = self.navigation_handler.calculate_offset_transform(ipp.viewport_bounds.center(), current_ptz);
let ruler_scale = if !self.graph_view_overlay_open {
self.navigation_handler.snapped_zoom(current_ptz.zoom())
@@ -1001,12 +1003,12 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
});
}
DocumentMessage::RenderScrollbars => {
let document_transform_scale = self.navigation_handler.snapped_zoom(self.document_ptz.zoom()) / viewport.scale();
let document_transform_scale = self.navigation_handler.snapped_zoom(self.document_ptz.zoom());
let scale = 0.5 + ASYMPTOTIC_EFFECT + document_transform_scale * SCALE_EFFECT;
let viewport_size = viewport.size().into_dvec2();
let viewport_mid = viewport.center_in_viewport_space().into_dvec2();
let viewport_size = ipp.viewport_bounds.size();
let viewport_mid = ipp.viewport_bounds.center();
let [bounds1, bounds2] = if !self.graph_view_overlay_open {
self.metadata().document_bounds_viewport_space().unwrap_or([viewport_mid; 2])
} else {
@@ -1045,8 +1047,6 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
DocumentMessage::SavedDocument { path } => {
self.path = path;
responses.add(PortfolioMessage::AutoSaveActiveDocument);
// Update the name to match the file stem
let document_name_from_path = self.path.as_ref().and_then(|path| {
if path.extension().is_some_and(|e| e == FILE_EXTENSION) {
@@ -1328,7 +1328,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
}
for _ in 0..undo_count {
self.undo(viewport, responses);
self.undo(ipp, responses);
}
self.network_interface.finish_transaction();
@@ -1478,7 +1478,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
}
DocumentMessage::PTZUpdate => {
if !self.graph_view_overlay_open {
let transform = self.navigation_handler.calculate_offset_transform(viewport.center_in_viewport_space().into(), &self.document_ptz);
let transform = self.navigation_handler.calculate_offset_transform(ipp.viewport_bounds.center(), &self.document_ptz);
self.network_interface.set_document_to_viewport_transform(transform);
// Ensure selection box is kept in sync with the pointer when the PTZ changes
responses.add(SelectToolMessage::PointerMove {
@@ -1497,7 +1497,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
let transform = self
.navigation_handler
.calculate_offset_transform(viewport.center_in_viewport_space().into(), &network_metadata.persistent_metadata.navigation_metadata.node_graph_ptz);
.calculate_offset_transform(ipp.viewport_bounds.center(), &network_metadata.persistent_metadata.navigation_metadata.node_graph_ptz);
self.network_interface.set_transform(transform, &self.breadcrumb_network_path);
responses.add(DocumentMessage::RenderRulers);
@@ -1537,7 +1537,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
.default_node_template();
responses.add(NodeGraphMessage::InsertNode {
node_id,
node_template: Box::new(new_artboard_node),
node_template: new_artboard_node,
});
responses.add(NodeGraphMessage::ShiftNodePosition { node_id, x: 15, y: -3 });
responses.add(GraphOperationMessage::ResizeArtboard {
@@ -1651,30 +1651,29 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
impl DocumentMessageHandler {
/// Runs an intersection test with all layers and a viewport space quad
pub fn intersect_quad<'a>(&'a self, viewport_quad: graphene_std::renderer::Quad, viewport: &ViewportMessageHandler) -> impl Iterator<Item = LayerNodeIdentifier> + use<'a> {
let document_to_viewport = self.navigation_handler.calculate_offset_transform(viewport.center_in_viewport_space().into(), &self.document_ptz);
pub fn intersect_quad<'a>(&'a self, viewport_quad: graphene_std::renderer::Quad, ipp: &InputPreprocessorMessageHandler) -> impl Iterator<Item = LayerNodeIdentifier> + use<'a> {
let document_to_viewport = self.navigation_handler.calculate_offset_transform(ipp.viewport_bounds.center(), &self.document_ptz);
let document_quad = document_to_viewport.inverse() * viewport_quad;
ClickXRayIter::new(&self.network_interface, XRayTarget::Quad(document_quad))
}
/// Runs an intersection test with all layers and a viewport space quad; ignoring artboards
pub fn intersect_quad_no_artboards<'a>(&'a self, viewport_quad: graphene_std::renderer::Quad, viewport: &ViewportMessageHandler) -> impl Iterator<Item = LayerNodeIdentifier> + use<'a> {
self.intersect_quad(viewport_quad, viewport).filter(|layer| !self.network_interface.is_artboard(&layer.to_node(), &[]))
pub fn intersect_quad_no_artboards<'a>(&'a self, viewport_quad: graphene_std::renderer::Quad, ipp: &InputPreprocessorMessageHandler) -> impl Iterator<Item = LayerNodeIdentifier> + use<'a> {
self.intersect_quad(viewport_quad, ipp).filter(|layer| !self.network_interface.is_artboard(&layer.to_node(), &[]))
}
/// Runs an intersection test with all layers and a viewport space subpath
pub fn intersect_polygon<'a>(&'a self, mut viewport_polygon: Subpath<PointId>, viewport: &ViewportMessageHandler) -> impl Iterator<Item = LayerNodeIdentifier> + use<'a> {
let document_to_viewport = self.navigation_handler.calculate_offset_transform(viewport.center_in_viewport_space().into(), &self.document_ptz);
pub fn intersect_polygon<'a>(&'a self, mut viewport_polygon: Subpath<PointId>, ipp: &InputPreprocessorMessageHandler) -> impl Iterator<Item = LayerNodeIdentifier> + use<'a> {
let document_to_viewport = self.navigation_handler.calculate_offset_transform(ipp.viewport_bounds.center(), &self.document_ptz);
viewport_polygon.apply_transform(document_to_viewport.inverse());
ClickXRayIter::new(&self.network_interface, XRayTarget::Polygon(viewport_polygon))
}
/// Runs an intersection test with all layers and a viewport space subpath; ignoring artboards
pub fn intersect_polygon_no_artboards<'a>(&'a self, viewport_polygon: Subpath<PointId>, viewport: &ViewportMessageHandler) -> impl Iterator<Item = LayerNodeIdentifier> + use<'a> {
self.intersect_polygon(viewport_polygon, viewport)
.filter(|layer| !self.network_interface.is_artboard(&layer.to_node(), &[]))
pub fn intersect_polygon_no_artboards<'a>(&'a self, viewport_polygon: Subpath<PointId>, ipp: &InputPreprocessorMessageHandler) -> impl Iterator<Item = LayerNodeIdentifier> + use<'a> {
self.intersect_polygon(viewport_polygon, ipp).filter(|layer| !self.network_interface.is_artboard(&layer.to_node(), &[]))
}
pub fn is_layer_fully_inside(&self, layer: &LayerNodeIdentifier, quad: graphene_std::renderer::Quad) -> bool {
@@ -1700,8 +1699,8 @@ impl DocumentMessageHandler {
layer_left >= quad_left && layer_right <= quad_right && layer_top <= quad_top && layer_bottom >= quad_bottom
}
pub fn is_layer_fully_inside_polygon(&self, layer: &LayerNodeIdentifier, viewport: &ViewportMessageHandler, mut viewport_polygon: Subpath<PointId>) -> bool {
let document_to_viewport = self.navigation_handler.calculate_offset_transform(viewport.center_in_viewport_space().into(), &self.document_ptz);
pub fn is_layer_fully_inside_polygon(&self, layer: &LayerNodeIdentifier, ipp: &InputPreprocessorMessageHandler, mut viewport_polygon: Subpath<PointId>) -> bool {
let document_to_viewport = self.navigation_handler.calculate_offset_transform(ipp.viewport_bounds.center(), &self.document_ptz);
viewport_polygon.apply_transform(document_to_viewport.inverse());
let layer_click_targets = self.network_interface.document_metadata().click_targets(*layer);
@@ -1724,8 +1723,8 @@ impl DocumentMessageHandler {
}
/// Find all of the layers that were clicked on from a viewport space location
pub fn click_xray(&self, ipp: &InputPreprocessorMessageHandler, viewport: &ViewportMessageHandler) -> impl Iterator<Item = LayerNodeIdentifier> + use<'_> {
let document_to_viewport = self.navigation_handler.calculate_offset_transform(viewport.center_in_viewport_space().into(), &self.document_ptz);
pub fn click_xray(&self, ipp: &InputPreprocessorMessageHandler) -> impl Iterator<Item = LayerNodeIdentifier> + use<'_> {
let document_to_viewport = self.navigation_handler.calculate_offset_transform(ipp.viewport_bounds.center(), &self.document_ptz);
let point = document_to_viewport.inverse().transform_point2(ipp.mouse.position);
ClickXRayIter::new(&self.network_interface, XRayTarget::Point(point))
}
@@ -1746,8 +1745,8 @@ impl DocumentMessageHandler {
}
/// Find layers under the location in viewport space that was clicked, listed by their depth in the layer tree hierarchy.
pub fn click_list<'a>(&'a self, ipp: &InputPreprocessorMessageHandler, viewport: &ViewportMessageHandler) -> impl Iterator<Item = LayerNodeIdentifier> + use<'a> {
self.click_xray(ipp, viewport)
pub fn click_list<'a>(&'a self, ipp: &InputPreprocessorMessageHandler) -> impl Iterator<Item = LayerNodeIdentifier> + use<'a> {
self.click_xray(ipp)
.filter(move |&layer| !self.network_interface.is_artboard(&layer.to_node(), &[]))
.skip_while(|&layer| layer == LayerNodeIdentifier::ROOT_PARENT)
.scan(true, |last_had_children, layer| {
@@ -1760,28 +1759,14 @@ impl DocumentMessageHandler {
})
}
/// Find layers (including artboards) under the location in viewport space that was clicked, listed by their depth in the layer tree hierarchy.
pub fn click_list_with_artboards<'a>(&'a self, ipp: &InputPreprocessorMessageHandler, viewport: &ViewportMessageHandler) -> impl Iterator<Item = LayerNodeIdentifier> + use<'a> {
self.click_xray(ipp, viewport)
.skip_while(|&layer| layer == LayerNodeIdentifier::ROOT_PARENT)
.scan(true, |last_had_children, layer| {
if *last_had_children {
*last_had_children = layer.has_children(self.network_interface.document_metadata());
Some(layer)
} else {
None
}
})
}
pub fn click_list_no_parents<'a>(&'a self, ipp: &InputPreprocessorMessageHandler, viewport: &ViewportMessageHandler) -> impl Iterator<Item = LayerNodeIdentifier> + use<'a> {
self.click_xray(ipp, viewport)
pub fn click_list_no_parents<'a>(&'a self, ipp: &InputPreprocessorMessageHandler) -> impl Iterator<Item = LayerNodeIdentifier> + use<'a> {
self.click_xray(ipp)
.filter(move |&layer| !self.network_interface.is_artboard(&layer.to_node(), &[]) && !layer.has_children(self.network_interface.document_metadata()))
}
/// Find the deepest layer that has been clicked on from a location in viewport space.
pub fn click(&self, ipp: &InputPreprocessorMessageHandler, viewport: &ViewportMessageHandler) -> Option<LayerNodeIdentifier> {
self.click_list(ipp, viewport).last()
pub fn click(&self, ipp: &InputPreprocessorMessageHandler) -> Option<LayerNodeIdentifier> {
self.click_list(ipp).last()
}
pub fn click_based_on_position(&self, mouse_snapped_positon: DVec2) -> Option<LayerNodeIdentifier> {
@@ -1939,8 +1924,8 @@ impl DocumentMessageHandler {
structure_section.as_slice().into()
}
pub fn undo_with_history(&mut self, viewport: &ViewportMessageHandler, responses: &mut VecDeque<Message>) {
let Some(previous_network) = self.undo(viewport, responses) else { return };
pub fn undo_with_history(&mut self, ipp: &InputPreprocessorMessageHandler, responses: &mut VecDeque<Message>) {
let Some(previous_network) = self.undo(ipp, responses) else { return };
self.document_redo_history.push_back(previous_network);
if self.document_redo_history.len() > crate::consts::MAX_UNDO_HISTORY_LEN {
@@ -1948,7 +1933,7 @@ impl DocumentMessageHandler {
}
}
pub fn undo(&mut self, viewport: &ViewportMessageHandler, responses: &mut VecDeque<Message>) -> Option<NodeNetworkInterface> {
pub fn undo(&mut self, ipp: &InputPreprocessorMessageHandler, responses: &mut VecDeque<Message>) -> Option<NodeNetworkInterface> {
// If there is no history return and don't broadcast SelectionChanged
let mut network_interface = self.document_undo_history.pop_back()?;
@@ -1957,7 +1942,7 @@ impl DocumentMessageHandler {
std::mem::swap(&mut network_interface.resolved_types, &mut self.network_interface.resolved_types);
//Update the metadata transform based on document PTZ
let transform = self.navigation_handler.calculate_offset_transform(viewport.center_in_viewport_space().into(), &self.document_ptz);
let transform = self.navigation_handler.calculate_offset_transform(ipp.viewport_bounds.center(), &self.document_ptz);
network_interface.set_document_to_viewport_transform(transform);
// Ensure document structure is loaded so that updating the selected nodes has the correct metadata
@@ -1976,9 +1961,9 @@ impl DocumentMessageHandler {
Some(previous_network)
}
pub fn redo_with_history(&mut self, viewport: &ViewportMessageHandler, responses: &mut VecDeque<Message>) {
pub fn redo_with_history(&mut self, ipp: &InputPreprocessorMessageHandler, responses: &mut VecDeque<Message>) {
// Push the UpdateOpenDocumentsList message to the queue in order to update the save status of the open documents
let Some(previous_network) = self.redo(viewport, responses) else { return };
let Some(previous_network) = self.redo(ipp, responses) else { return };
self.document_undo_history.push_back(previous_network);
if self.document_undo_history.len() > crate::consts::MAX_UNDO_HISTORY_LEN {
@@ -1986,7 +1971,7 @@ impl DocumentMessageHandler {
}
}
pub fn redo(&mut self, viewport: &ViewportMessageHandler, responses: &mut VecDeque<Message>) -> Option<NodeNetworkInterface> {
pub fn redo(&mut self, ipp: &InputPreprocessorMessageHandler, responses: &mut VecDeque<Message>) -> Option<NodeNetworkInterface> {
// If there is no history return and don't broadcast SelectionChanged
let mut network_interface = self.document_redo_history.pop_back()?;
@@ -1995,7 +1980,7 @@ impl DocumentMessageHandler {
std::mem::swap(&mut network_interface.resolved_types, &mut self.network_interface.resolved_types);
//Update the metadata transform based on document PTZ
let transform = self.navigation_handler.calculate_offset_transform(viewport.center_in_viewport_space().into(), &self.document_ptz);
let transform = self.navigation_handler.calculate_offset_transform(ipp.viewport_bounds.center(), &self.document_ptz);
network_interface.set_document_to_viewport_transform(transform);
let previous_network = std::mem::replace(&mut self.network_interface, network_interface);
@@ -2041,11 +2026,11 @@ impl DocumentMessageHandler {
}
/// Finds the artboard that bounds the point in viewport space and be the container of any newly added layers.
pub fn new_layer_bounding_artboard(&self, ipp: &InputPreprocessorMessageHandler, viewport: &ViewportMessageHandler) -> LayerNodeIdentifier {
pub fn new_layer_bounding_artboard(&self, ipp: &InputPreprocessorMessageHandler) -> LayerNodeIdentifier {
let container_based_on_selection = self.new_layer_parent(true);
let container_based_on_clicked_artboard = self
.click_xray(ipp, viewport)
.click_xray(ipp)
.find(|layer| self.network_interface.is_artboard(&layer.to_node(), &[]))
.unwrap_or(LayerNodeIdentifier::ROOT_PARENT);
Loaded 100 of 276 files, more files were not shown because too many files have changed in this diff. Show more