mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Key the element glue on static type projections
This commit is contained in:
@@ -26,6 +26,14 @@ pub struct BrushStampGenerator<P: Pixel + Alpha> {
|
||||
transform: DAffine2,
|
||||
}
|
||||
|
||||
// SAFETY: `Static` is `Self` with `P` at its own static projection.
|
||||
unsafe impl<P: Pixel + Alpha + dyn_any::StaticTypeSized> dyn_any::StaticType for BrushStampGenerator<P>
|
||||
where
|
||||
P::Static: Pixel + Alpha,
|
||||
{
|
||||
type Static = BrushStampGenerator<P::Static>;
|
||||
}
|
||||
|
||||
impl<P: Pixel + Alpha> Transform for BrushStampGenerator<P> {
|
||||
fn transform(&self) -> DAffine2 {
|
||||
self.transform
|
||||
|
||||
@@ -250,7 +250,10 @@ mod tests {
|
||||
EvalScope::new(Some(0.5), None, None, generations, arena)
|
||||
}
|
||||
|
||||
fn element_layout<T: Clone + Send + Sync + 'static>() -> core_types::record::Layout {
|
||||
fn element_layout<T: Clone + Send + Sync + core_types::StaticTypeSized>() -> core_types::record::Layout
|
||||
where
|
||||
T::Static: Clone + Send + Sync,
|
||||
{
|
||||
core_types::record::Layout::default().with_writes(0, core_types::record::element_write::<T>(), &[])
|
||||
}
|
||||
|
||||
@@ -312,6 +315,7 @@ mod tests {
|
||||
#[test]
|
||||
fn memo_copy_out_consults_the_deep_element_clone() {
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(dyn_any::DynAny)]
|
||||
struct Payload(String, u32);
|
||||
unsafe fn deep(ptr: *const u8) -> Box<dyn std::any::Any + Send + Sync> {
|
||||
let value = unsafe { core_types::record::borrow_element::<Payload>(core_types::record::Rec::new(ptr)) };
|
||||
|
||||
@@ -604,7 +604,10 @@ mod tests {
|
||||
node
|
||||
}
|
||||
|
||||
fn lifted_value<T: Clone + Send + Sync + 'static>(value: T) -> (core_types::record::RecordLift<T, ValueNode<T>>, Layout) {
|
||||
fn lifted_value<T: Clone + Send + Sync + core_types::StaticTypeSized + 'static>(value: T) -> (core_types::record::RecordLift<T, ValueNode<T>>, Layout)
|
||||
where
|
||||
T::Static: Clone + Send + Sync,
|
||||
{
|
||||
let lift = core_types::record::RecordLift::<T, _>::new(ValueNode(value));
|
||||
let layout = Node::<ContextImpl>::layout(&lift).clone();
|
||||
(lift, layout)
|
||||
|
||||
@@ -1051,7 +1051,8 @@ mod graphene_test {
|
||||
/// element-only layout for the generated node's constructor.
|
||||
fn lifted<T, N>(node: N) -> (RecordLift<T, N>, Layout)
|
||||
where
|
||||
T: Clone + Send + Sync + 'static,
|
||||
T: Clone + Send + Sync + core_types::StaticTypeSized + 'static,
|
||||
<T as core_types::StaticTypeSized>::Static: Clone + Send + Sync,
|
||||
N: for<'c> Node<ContextImpl<'c>, Output = T>,
|
||||
{
|
||||
let lift = RecordLift::<T, _>::new(node);
|
||||
|
||||
Reference in New Issue
Block a user