From 90befbd9bc599e4d1a63adf7fac3ef5bfc382e37 Mon Sep 17 00:00:00 2001
From: 0hypercube <0hypercube@gmail.com>
Date: Sat, 25 Feb 2023 11:21:35 +0000
Subject: [PATCH] Add vector data type
---
Cargo.lock | 8 +-
document-legacy/src/consts.rs | 6 --
document-legacy/src/layers/mod.rs | 9 ++-
document-legacy/src/layers/render_data.rs | 22 ++++++
editor/Cargo.toml | 2 -
editor/src/application.rs | 25 +-----
node-graph/gcore/Cargo.toml | 2 +
node-graph/gcore/src/consts.rs | 5 ++
node-graph/gcore/src/lib.rs | 2 +
node-graph/gcore/src/raster/color.rs | 2 +-
node-graph/gcore/src/uuid.rs | 38 ++++++++++
node-graph/gcore/src/vector/mod.rs | 12 ++-
.../gcore/src/vector/style.rs | 76 +++++++++----------
node-graph/gcore/src/vector/vector_data.rs | 12 +++
node-graph/gpu-compiler/Cargo.toml | 1 -
node-graph/graph-craft/Cargo.toml | 1 -
node-graph/graph-craft/src/document.rs | 15 +---
node-graph/interpreted-executor/Cargo.toml | 1 -
node-graph/vulkan-executor/Cargo.toml | 1 -
node-graph/wgpu-executor/Cargo.toml | 1 -
20 files changed, 140 insertions(+), 101 deletions(-)
create mode 100644 document-legacy/src/layers/render_data.rs
create mode 100644 node-graph/gcore/src/consts.rs
rename document-legacy/src/layers/style/mod.rs => node-graph/gcore/src/vector/style.rs (93%)
create mode 100644 node-graph/gcore/src/vector/vector_data.rs
diff --git a/Cargo.lock b/Cargo.lock
index e1eb3ede48..4c25face4d 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1629,7 +1629,6 @@ dependencies = [
"graphene-core",
"log",
"num-traits",
- "rand_chacha 0.3.1",
"serde",
"specta",
]
@@ -1647,8 +1646,10 @@ dependencies = [
"log",
"node-macro",
"once_cell",
+ "rand_chacha 0.3.1",
"serde",
"specta",
+ "spin 0.9.4",
"spirv-std",
]
@@ -1738,12 +1739,10 @@ dependencies = [
"kurbo",
"log",
"once_cell",
- "rand_chacha 0.3.1",
"remain",
"serde",
"serde_json",
"specta",
- "spin 0.9.4",
"test-case",
"thiserror",
]
@@ -2173,7 +2172,6 @@ dependencies = [
"log",
"num-traits",
"once_cell",
- "rand_chacha 0.3.1",
"serde",
]
@@ -5122,7 +5120,6 @@ dependencies = [
"graphene-core",
"log",
"num-traits",
- "rand_chacha 0.3.1",
"serde",
"vulkano",
]
@@ -5477,7 +5474,6 @@ dependencies = [
"graphene-core",
"log",
"num-traits",
- "rand_chacha 0.3.1",
"serde",
"spirv",
"wgpu",
diff --git a/document-legacy/src/consts.rs b/document-legacy/src/consts.rs
index 1521cec344..df9c3752d1 100644
--- a/document-legacy/src/consts.rs
+++ b/document-legacy/src/consts.rs
@@ -1,9 +1,3 @@
-use graphene_core::raster::color::Color;
-
-// RENDERING
-pub const LAYER_OUTLINE_STROKE_COLOR: Color = Color::BLACK;
-pub const LAYER_OUTLINE_STROKE_WEIGHT: f64 = 1.;
-
// BOOLEAN OPERATIONS
// Bezier curve intersection algorithm
diff --git a/document-legacy/src/layers/mod.rs b/document-legacy/src/layers/mod.rs
index 94306fa1aa..abd54f1414 100644
--- a/document-legacy/src/layers/mod.rs
+++ b/document-legacy/src/layers/mod.rs
@@ -25,6 +25,13 @@ pub mod layer_info;
pub mod nodegraph_layer;
/// Contains the [ShapeLayer](shape_layer::ShapeLayer) type, a generic SVG element defined using Bezier paths.
pub mod shape_layer;
-pub mod style;
/// Contains the [TextLayer](text_layer::TextLayer) type.
pub mod text_layer;
+
+mod render_data;
+pub use render_data::RenderData;
+
+pub mod style {
+ pub use super::RenderData;
+ pub use graphene_core::vector::style::*;
+}
diff --git a/document-legacy/src/layers/render_data.rs b/document-legacy/src/layers/render_data.rs
new file mode 100644
index 0000000000..804303fe41
--- /dev/null
+++ b/document-legacy/src/layers/render_data.rs
@@ -0,0 +1,22 @@
+use super::style::ViewMode;
+use super::text_layer::FontCache;
+
+use glam::DVec2;
+
+/// Contains metadata for rendering the document as an svg
+#[derive(Debug, Clone, Copy)]
+pub struct RenderData<'a> {
+ pub font_cache: &'a FontCache,
+ pub view_mode: ViewMode,
+ pub culling_bounds: Option<[DVec2; 2]>,
+}
+
+impl<'a> RenderData<'a> {
+ pub fn new(font_cache: &'a FontCache, view_mode: ViewMode, culling_bounds: Option<[DVec2; 2]>) -> Self {
+ Self {
+ font_cache,
+ view_mode,
+ culling_bounds,
+ }
+ }
+}
diff --git a/editor/Cargo.toml b/editor/Cargo.toml
index 361b135052..04684c5379 100644
--- a/editor/Cargo.toml
+++ b/editor/Cargo.toml
@@ -23,8 +23,6 @@ serde_json = { version = "1.0" }
graphite-proc-macros = { path = "../proc-macros" }
bezier-rs = { path = "../libraries/bezier-rs" }
glam = { version="0.22", features = ["serde"] }
-rand_chacha = "0.3.1"
-spin = "0.9.2"
kurbo = { git = "https://github.com/linebender/kurbo.git", features = [
"serde",
] }
diff --git a/editor/src/application.rs b/editor/src/application.rs
index 86621321b8..434ebd41ee 100644
--- a/editor/src/application.rs
+++ b/editor/src/application.rs
@@ -1,15 +1,7 @@
use crate::dispatcher::Dispatcher;
use crate::messages::prelude::*;
-use rand_chacha::rand_core::{RngCore, SeedableRng};
-use rand_chacha::ChaCha20Rng;
-use spin::Mutex;
-use std::cell::Cell;
-
-static RNG: Mutex