Skip to content

Commit f1cdbf0

Browse files
committed
gcore-shaders: move context::Ctx
1 parent 958e810 commit f1cdbf0

3 files changed

Lines changed: 15 additions & 8 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
pub trait Ctx: Clone + Send {}
2+
3+
impl<T: Ctx> Ctx for Option<T> {}
4+
impl<T: Ctx + Sync> Ctx for &T {}
5+
impl Ctx for () {}
6+
7+
pub trait ArcCtx: Send + Sync {}
8+
#[cfg(feature = "std")]
9+
impl<T: ArcCtx> Ctx for std::sync::Arc<T> {}

node-graph/gcore-shaders/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
pub use glam;
2-
31
pub mod blending;
42
pub mod choice_type;
53
pub mod color;
4+
pub mod context;
65
pub mod registry;
76

7+
pub use context::Ctx;
8+
pub use glam;
9+
810
pub trait AsU32 {
911
fn as_u32(&self) -> u32;
1012
}

node-graph/gcore/src/context.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
use crate::transform::Footprint;
2+
pub use graphene_core_shaders::context::{ArcCtx, Ctx};
23
use std::any::Any;
34
use std::borrow::Borrow;
45
use std::panic::Location;
56
use std::sync::Arc;
67

7-
pub trait Ctx: Clone + Send {}
8-
98
pub trait ExtractFootprint {
109
#[track_caller]
1110
fn try_footprint(&self) -> Option<&Footprint>;
@@ -51,9 +50,6 @@ pub enum VarArgsResult {
5150
IndexOutOfBounds,
5251
NoVarArgs,
5352
}
54-
impl<T: Ctx> Ctx for Option<T> {}
55-
impl<T: Ctx + Sync> Ctx for &T {}
56-
impl Ctx for () {}
5753
impl Ctx for Footprint {}
5854
impl ExtractFootprint for () {
5955
fn try_footprint(&self) -> Option<&Footprint> {
@@ -157,7 +153,7 @@ impl<T: CloneVarArgs + Sync> CloneVarArgs for Arc<T> {
157153
}
158154

159155
impl Ctx for ContextImpl<'_> {}
160-
impl Ctx for Arc<OwnedContextImpl> {}
156+
impl ArcCtx for OwnedContextImpl {}
161157

162158
impl ExtractFootprint for ContextImpl<'_> {
163159
fn try_footprint(&self) -> Option<&Footprint> {

0 commit comments

Comments
 (0)