1use std::mem::size_of;
2use std::rc::Rc;
3
4use cranpose_core::NodeId;
5use cranpose_foundation::PointerEvent;
6use cranpose_ui::text::AnnotatedString;
7use cranpose_ui::{
8 GraphicsLayer, Point, Rect, RenderEffect, RoundedCornerShape, TextLayoutOptions, TextStyle,
9};
10use cranpose_ui_graphics::{BlendMode, ColorFilter, DrawPrimitive, ShadowPrimitive};
11
12use crate::raster_cache::LayerRasterCacheHashes;
13
14#[derive(Clone, Copy, Debug, PartialEq)]
15pub struct ProjectiveTransform {
16 matrix: [[f32; 3]; 3],
17}
18
19impl ProjectiveTransform {
20 pub const fn identity() -> Self {
21 Self {
22 matrix: [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]],
23 }
24 }
25
26 pub fn translation(tx: f32, ty: f32) -> Self {
27 Self {
28 matrix: [[1.0, 0.0, tx], [0.0, 1.0, ty], [0.0, 0.0, 1.0]],
29 }
30 }
31
32 pub fn uniform_scale(scale: f32) -> Self {
35 Self {
36 matrix: [[scale, 0.0, 0.0], [0.0, scale, 0.0], [0.0, 0.0, 1.0]],
37 }
38 }
39
40 pub fn from_rect_to_quad(rect: Rect, quad: [[f32; 2]; 4]) -> Self {
41 if rect.width.abs() <= f32::EPSILON || rect.height.abs() <= f32::EPSILON {
42 return Self::translation(quad[0][0], quad[0][1]);
43 }
44
45 if let Some(axis_aligned) = axis_aligned_rect_from_quad(quad) {
46 let scale_x = axis_aligned.width / rect.width;
47 let scale_y = axis_aligned.height / rect.height;
48 return Self {
49 matrix: [
50 [scale_x, 0.0, axis_aligned.x - rect.x * scale_x],
51 [0.0, scale_y, axis_aligned.y - rect.y * scale_y],
52 [0.0, 0.0, 1.0],
53 ],
54 };
55 }
56
57 let source = [
58 [rect.x, rect.y],
59 [rect.x + rect.width, rect.y],
60 [rect.x, rect.y + rect.height],
61 [rect.x + rect.width, rect.y + rect.height],
62 ];
63 let Some(coefficients) = solve_homography(source, quad) else {
64 return Self::identity();
65 };
66
67 Self {
68 matrix: [
69 [coefficients[0], coefficients[1], coefficients[2]],
70 [coefficients[3], coefficients[4], coefficients[5]],
71 [coefficients[6], coefficients[7], 1.0],
72 ],
73 }
74 }
75
76 pub fn then(self, next: Self) -> Self {
78 Self {
79 matrix: multiply_matrices(next.matrix, self.matrix),
80 }
81 }
82
83 pub fn inverse(self) -> Option<Self> {
84 let m = self.matrix;
85 let a = m[0][0];
86 let b = m[0][1];
87 let c = m[0][2];
88 let d = m[1][0];
89 let e = m[1][1];
90 let f = m[1][2];
91 let g = m[2][0];
92 let h = m[2][1];
93 let i = m[2][2];
94
95 let cofactor00 = e * i - f * h;
96 let cofactor01 = -(d * i - f * g);
97 let cofactor02 = d * h - e * g;
98 let cofactor10 = -(b * i - c * h);
99 let cofactor11 = a * i - c * g;
100 let cofactor12 = -(a * h - b * g);
101 let cofactor20 = b * f - c * e;
102 let cofactor21 = -(a * f - c * d);
103 let cofactor22 = a * e - b * d;
104
105 let determinant = a * cofactor00 + b * cofactor01 + c * cofactor02;
106 if determinant.abs() <= f32::EPSILON {
107 return None;
108 }
109 let inverse_determinant = 1.0 / determinant;
110
111 Some(Self {
112 matrix: [
113 [
114 cofactor00 * inverse_determinant,
115 cofactor10 * inverse_determinant,
116 cofactor20 * inverse_determinant,
117 ],
118 [
119 cofactor01 * inverse_determinant,
120 cofactor11 * inverse_determinant,
121 cofactor21 * inverse_determinant,
122 ],
123 [
124 cofactor02 * inverse_determinant,
125 cofactor12 * inverse_determinant,
126 cofactor22 * inverse_determinant,
127 ],
128 ],
129 })
130 }
131
132 pub fn matrix(self) -> [[f32; 3]; 3] {
133 self.matrix
134 }
135
136 pub fn map_point(self, point: Point) -> Point {
137 let x = point.x;
138 let y = point.y;
139 let w = self.matrix[2][0] * x + self.matrix[2][1] * y + self.matrix[2][2];
140 let safe_w = if w.abs() <= f32::EPSILON { 1.0 } else { w };
141
142 Point {
143 x: (self.matrix[0][0] * x + self.matrix[0][1] * y + self.matrix[0][2]) / safe_w,
144 y: (self.matrix[1][0] * x + self.matrix[1][1] * y + self.matrix[1][2]) / safe_w,
145 }
146 }
147
148 pub fn map_rect(self, rect: Rect) -> [[f32; 2]; 4] {
149 [
150 self.map_point(Point {
151 x: rect.x,
152 y: rect.y,
153 }),
154 self.map_point(Point {
155 x: rect.x + rect.width,
156 y: rect.y,
157 }),
158 self.map_point(Point {
159 x: rect.x,
160 y: rect.y + rect.height,
161 }),
162 self.map_point(Point {
163 x: rect.x + rect.width,
164 y: rect.y + rect.height,
165 }),
166 ]
167 .map(|point| [point.x, point.y])
168 }
169
170 pub fn bounds_for_rect(self, rect: Rect) -> Rect {
171 quad_bounds(self.map_rect(rect))
172 }
173}
174
175fn axis_aligned_rect_from_quad(quad: [[f32; 2]; 4]) -> Option<Rect> {
176 let top_left = quad[0];
177 let top_right = quad[1];
178 let bottom_left = quad[2];
179 let bottom_right = quad[3];
180 let x_epsilon = 1e-4;
181 let y_epsilon = 1e-4;
182
183 if (top_left[1] - top_right[1]).abs() > y_epsilon
184 || (bottom_left[1] - bottom_right[1]).abs() > y_epsilon
185 || (top_left[0] - bottom_left[0]).abs() > x_epsilon
186 || (top_right[0] - bottom_right[0]).abs() > x_epsilon
187 {
188 return None;
189 }
190
191 Some(Rect {
192 x: top_left[0],
193 y: top_left[1],
194 width: top_right[0] - top_left[0],
195 height: bottom_left[1] - top_left[1],
196 })
197}
198
199impl Default for ProjectiveTransform {
200 fn default() -> Self {
201 Self::identity()
202 }
203}
204
205#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
206pub struct IsolationReasons {
207 pub explicit_offscreen: bool,
208 pub shape_clip: bool,
209 pub effect: bool,
210 pub backdrop: bool,
211 pub group_opacity: bool,
212 pub blend_mode: bool,
213}
214
215impl IsolationReasons {
216 pub fn has_any(self) -> bool {
217 self.explicit_offscreen
218 || self.shape_clip
219 || self.effect
220 || self.backdrop
221 || self.group_opacity
222 || self.blend_mode
223 }
224}
225
226#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
227pub enum CachePolicy {
228 #[default]
229 None,
230 Auto,
231}
232
233#[derive(Clone)]
234pub struct HitTestNode {
235 pub shape: Option<RoundedCornerShape>,
236 pub click_actions: Vec<Rc<dyn Fn(Point)>>,
237 pub pointer_inputs: Vec<Rc<dyn Fn(PointerEvent)>>,
238 pub clip: Option<Rect>,
239}
240
241#[derive(Clone, Debug, PartialEq)]
242pub struct DrawPrimitiveNode {
243 pub primitive: DrawPrimitive,
244 pub clip: Option<Rect>,
245}
246
247#[derive(Clone, Debug, PartialEq)]
248pub struct TextPrimitiveNode {
249 pub node_id: NodeId,
250 pub rect: Rect,
251 pub text: AnnotatedString,
252 pub text_style: TextStyle,
253 pub font_size: f32,
254 pub layout_options: TextLayoutOptions,
255 pub clip: Option<Rect>,
256}
257
258#[derive(Clone, Copy, Debug, PartialEq, Eq)]
259pub enum PrimitivePhase {
260 BeforeChildren,
261 AfterChildren,
262}
263
264#[derive(Clone, Debug, PartialEq)]
265pub enum PrimitiveNode {
266 Draw(DrawPrimitiveNode),
267 Text(Box<TextPrimitiveNode>),
268}
269
270#[derive(Clone, Debug, PartialEq)]
271pub struct PrimitiveEntry {
272 pub phase: PrimitivePhase,
273 pub node: PrimitiveNode,
274}
275
276#[derive(Clone)]
277pub struct LayerNode {
278 pub node_id: Option<NodeId>,
279 pub local_bounds: Rect,
280 pub transform_to_parent: ProjectiveTransform,
281 pub content_offset: Point,
282 pub motion_context_animated: bool,
283 pub translated_content_context: bool,
284 pub translated_content_offset: Point,
285 pub graphics_layer: GraphicsLayer,
286 pub clip_to_bounds: bool,
287 pub shadow_clip: Option<Rect>,
288 pub hit_test: Option<HitTestNode>,
289 pub has_hit_targets: bool,
290 pub isolation: IsolationReasons,
291 pub cache_policy: CachePolicy,
292 pub cache_hashes: LayerRasterCacheHashes,
293 pub cache_hashes_valid: bool,
294 pub children: Vec<RenderNode>,
295}
296
297impl LayerNode {
298 pub fn clip_rect(&self) -> Option<Rect> {
299 (self.clip_to_bounds || self.graphics_layer.clip).then_some(self.local_bounds)
300 }
301
302 pub fn effect(&self) -> Option<&RenderEffect> {
303 self.graphics_layer.render_effect.as_ref()
304 }
305
306 pub fn backdrop(&self) -> Option<&RenderEffect> {
307 self.graphics_layer.backdrop_effect.as_ref()
308 }
309
310 pub fn opacity(&self) -> f32 {
311 self.graphics_layer.alpha
312 }
313
314 pub fn blend_mode(&self) -> BlendMode {
315 self.graphics_layer.blend_mode
316 }
317
318 pub fn color_filter(&self) -> Option<ColorFilter> {
319 self.graphics_layer.color_filter
320 }
321
322 pub fn target_content_hash(&self) -> u64 {
323 if self.cache_hashes_valid {
324 self.cache_hashes.target_content
325 } else {
326 crate::graph_hash::layer_raster_cache_hashes(self).target_content
327 }
328 }
329
330 pub fn motion_source_content_hash(&self) -> u64 {
331 crate::graph_hash::layer_motion_source_content_hash(self)
332 }
333
334 pub fn effect_hash(&self) -> u64 {
335 if self.cache_hashes_valid {
336 self.cache_hashes.effect
337 } else {
338 crate::graph_hash::layer_raster_cache_hashes(self).effect
339 }
340 }
341
342 pub fn recompute_raster_cache_hashes(&mut self) {
343 crate::graph_hash::recompute_layer_raster_cache_hashes(self);
344 }
345}
346
347#[derive(Clone)]
348pub enum RenderNode {
349 Primitive(PrimitiveEntry),
350 Layer(Box<LayerNode>),
351}
352
353#[derive(Clone)]
354pub struct RenderGraph {
355 pub root: LayerNode,
356}
357
358impl RenderGraph {
359 pub fn new(mut root: LayerNode) -> Self {
360 root.recompute_raster_cache_hashes();
361 Self { root }
362 }
363
364 pub fn node_count(&self) -> usize {
365 fn count_layer(layer: &LayerNode) -> usize {
366 1 + layer
367 .children
368 .iter()
369 .map(|child| match child {
370 RenderNode::Primitive(_) => 1,
371 RenderNode::Layer(child_layer) => count_layer(child_layer),
372 })
373 .sum::<usize>()
374 }
375
376 count_layer(&self.root)
377 }
378
379 pub fn heap_bytes(&self) -> usize {
380 layer_heap_bytes(&self.root)
381 }
382}
383
384fn layer_heap_bytes(layer: &LayerNode) -> usize {
385 layer.hit_test.as_ref().map_or(0, hit_test_heap_bytes)
386 + size_of::<RenderNode>() * layer.children.capacity()
387 + layer
388 .children
389 .iter()
390 .map(render_node_heap_bytes)
391 .sum::<usize>()
392}
393
394fn render_node_heap_bytes(node: &RenderNode) -> usize {
395 match node {
396 RenderNode::Primitive(entry) => primitive_entry_heap_bytes(entry),
397 RenderNode::Layer(layer) => size_of::<LayerNode>() + layer_heap_bytes(layer),
398 }
399}
400
401fn primitive_entry_heap_bytes(entry: &PrimitiveEntry) -> usize {
402 match &entry.node {
403 PrimitiveNode::Draw(draw) => draw_primitive_heap_bytes(&draw.primitive),
404 PrimitiveNode::Text(text) => {
405 size_of::<TextPrimitiveNode>() + annotated_string_heap_bytes(&text.text)
406 }
407 }
408}
409
410fn draw_primitive_heap_bytes(primitive: &DrawPrimitive) -> usize {
411 match primitive {
412 DrawPrimitive::Content | DrawPrimitive::Rect { .. } | DrawPrimitive::RoundRect { .. } => 0,
413 DrawPrimitive::Blend { primitive, .. } => {
414 size_of::<DrawPrimitive>() + draw_primitive_heap_bytes(primitive)
415 }
416 DrawPrimitive::Image { .. } => 0,
417 DrawPrimitive::Shadow(shadow) => shadow_primitive_heap_bytes(shadow),
418 }
419}
420
421fn shadow_primitive_heap_bytes(shadow: &ShadowPrimitive) -> usize {
422 match shadow {
423 ShadowPrimitive::Drop { shape, .. } => {
424 size_of::<DrawPrimitive>() + draw_primitive_heap_bytes(shape)
425 }
426 ShadowPrimitive::Inner { fill, cutout, .. } => {
427 size_of::<DrawPrimitive>() * 2
428 + draw_primitive_heap_bytes(fill)
429 + draw_primitive_heap_bytes(cutout)
430 }
431 }
432}
433
434fn annotated_string_heap_bytes(text: &AnnotatedString) -> usize {
435 text.text.capacity()
436 + text.span_styles.capacity() * size_of::<usize>() * 2
437 + text.paragraph_styles.capacity() * size_of::<usize>() * 2
438 + text.string_annotations.capacity() * size_of::<usize>() * 2
439 + text.link_annotations.capacity() * size_of::<usize>() * 2
440 + text
441 .string_annotations
442 .iter()
443 .map(|annotation| {
444 annotation.item.tag.capacity() + annotation.item.annotation.capacity()
445 })
446 .sum::<usize>()
447 + text
448 .link_annotations
449 .iter()
450 .map(|annotation| match &annotation.item {
451 cranpose_ui::text::LinkAnnotation::Url(url) => url.capacity(),
452 cranpose_ui::text::LinkAnnotation::Clickable { tag, .. } => tag.capacity(),
453 })
454 .sum::<usize>()
455}
456
457fn hit_test_heap_bytes(hit_test: &HitTestNode) -> usize {
458 hit_test.click_actions.capacity() * size_of::<Rc<dyn Fn(Point)>>()
459 + hit_test.pointer_inputs.capacity() * size_of::<Rc<dyn Fn(PointerEvent)>>()
460}
461
462pub fn quad_bounds(quad: [[f32; 2]; 4]) -> Rect {
463 let mut min_x = f32::INFINITY;
464 let mut min_y = f32::INFINITY;
465 let mut max_x = f32::NEG_INFINITY;
466 let mut max_y = f32::NEG_INFINITY;
467
468 for [x, y] in quad {
469 min_x = min_x.min(x);
470 min_y = min_y.min(y);
471 max_x = max_x.max(x);
472 max_y = max_y.max(y);
473 }
474
475 Rect {
476 x: min_x,
477 y: min_y,
478 width: (max_x - min_x).max(0.0),
479 height: (max_y - min_y).max(0.0),
480 }
481}
482
483fn multiply_matrices(lhs: [[f32; 3]; 3], rhs: [[f32; 3]; 3]) -> [[f32; 3]; 3] {
484 let mut out = [[0.0; 3]; 3];
485 for row in 0..3 {
486 for col in 0..3 {
487 out[row][col] =
488 lhs[row][0] * rhs[0][col] + lhs[row][1] * rhs[1][col] + lhs[row][2] * rhs[2][col];
489 }
490 }
491 out
492}
493
494fn solve_homography(source: [[f32; 2]; 4], target: [[f32; 2]; 4]) -> Option<[f32; 8]> {
495 let mut matrix = [[0.0f32; 9]; 8];
496 for (index, (src, dst)) in source.into_iter().zip(target).enumerate() {
497 let row = index * 2;
498 let x = src[0];
499 let y = src[1];
500 let u = dst[0];
501 let v = dst[1];
502
503 matrix[row] = [x, y, 1.0, 0.0, 0.0, 0.0, -u * x, -u * y, u];
504 matrix[row + 1] = [0.0, 0.0, 0.0, x, y, 1.0, -v * x, -v * y, v];
505 }
506
507 for pivot in 0..8 {
508 let mut pivot_row = pivot;
509 let mut pivot_value = matrix[pivot][pivot].abs();
510 let mut candidate = pivot + 1;
511 while candidate < 8 {
512 let candidate_value = matrix[candidate][pivot].abs();
513 if candidate_value > pivot_value {
514 pivot_row = candidate;
515 pivot_value = candidate_value;
516 }
517 candidate += 1;
518 }
519
520 if pivot_value <= f32::EPSILON {
521 return None;
522 }
523
524 if pivot_row != pivot {
525 matrix.swap(pivot, pivot_row);
526 }
527
528 let divisor = matrix[pivot][pivot];
529 let mut col = pivot;
530 while col < 9 {
531 matrix[pivot][col] /= divisor;
532 col += 1;
533 }
534
535 for row in 0..8 {
536 if row == pivot {
537 continue;
538 }
539 let factor = matrix[row][pivot];
540 if factor.abs() <= f32::EPSILON {
541 continue;
542 }
543 let mut col = pivot;
544 while col < 9 {
545 matrix[row][col] -= factor * matrix[pivot][col];
546 col += 1;
547 }
548 }
549 }
550
551 let mut solution = [0.0f32; 8];
552 for index in 0..8 {
553 solution[index] = matrix[index][8];
554 }
555 Some(solution)
556}
557
558#[cfg(test)]
559mod tests {
560 use super::*;
561 use crate::raster_cache::LayerRasterCacheHashes;
562 use cranpose_ui_graphics::{Brush, Color, DrawPrimitive};
563
564 fn test_layer(local_bounds: Rect, children: Vec<RenderNode>) -> LayerNode {
565 LayerNode {
566 node_id: None,
567 local_bounds,
568 transform_to_parent: ProjectiveTransform::identity(),
569 content_offset: Point::default(),
570 motion_context_animated: false,
571 translated_content_context: false,
572 translated_content_offset: Point::default(),
573 graphics_layer: GraphicsLayer::default(),
574 clip_to_bounds: false,
575 shadow_clip: None,
576 hit_test: None,
577 has_hit_targets: false,
578 isolation: IsolationReasons::default(),
579 cache_policy: CachePolicy::None,
580 cache_hashes: LayerRasterCacheHashes::default(),
581 cache_hashes_valid: false,
582 children,
583 }
584 }
585
586 #[test]
587 fn projective_transform_translation_maps_points() {
588 let transform = ProjectiveTransform::translation(7.0, -3.5);
589 let mapped = transform.map_point(Point { x: 2.0, y: 4.0 });
590 assert!((mapped.x - 9.0).abs() < 1e-6);
591 assert!((mapped.y - 0.5).abs() < 1e-6);
592 }
593
594 #[test]
595 fn projective_transform_then_composes_in_parent_order() {
596 let child = ProjectiveTransform::translation(4.0, 2.0);
597 let parent = ProjectiveTransform::translation(10.0, -1.0);
598 let composed = child.then(parent);
599 let mapped = composed.map_point(Point { x: 1.0, y: 1.0 });
600 assert!((mapped.x - 15.0).abs() < 1e-6);
601 assert!((mapped.y - 2.0).abs() < 1e-6);
602 }
603
604 #[test]
605 fn homography_maps_rect_corners_to_target_quad() {
606 let rect = Rect {
607 x: 0.0,
608 y: 0.0,
609 width: 20.0,
610 height: 10.0,
611 };
612 let quad = [[5.0, 7.0], [25.0, 6.0], [7.0, 20.0], [28.0, 21.0]];
613 let transform = ProjectiveTransform::from_rect_to_quad(rect, quad);
614 let mapped = transform.map_rect(rect);
615 for (expected, actual) in quad.into_iter().zip(mapped) {
616 assert!((expected[0] - actual[0]).abs() < 1e-4);
617 assert!((expected[1] - actual[1]).abs() < 1e-4);
618 }
619 }
620
621 #[test]
622 fn axis_aligned_rect_to_quad_keeps_exact_affine_matrix() {
623 let rect = Rect {
624 x: 2.0,
625 y: 3.0,
626 width: 20.0,
627 height: 10.0,
628 };
629 let quad = [[12.0, 9.0], [32.0, 9.0], [12.0, 19.0], [32.0, 19.0]];
630 let transform = ProjectiveTransform::from_rect_to_quad(rect, quad);
631
632 assert_eq!(
633 transform.matrix(),
634 [[1.0, 0.0, 10.0], [0.0, 1.0, 6.0], [0.0, 0.0, 1.0]]
635 );
636 }
637
638 #[test]
639 fn axis_aligned_rect_to_quad_keeps_exact_axis_aligned_scale() {
640 let rect = Rect {
641 x: 4.0,
642 y: 6.0,
643 width: 10.0,
644 height: 8.0,
645 };
646 let quad = [[20.0, 18.0], [50.0, 18.0], [20.0, 42.0], [50.0, 42.0]];
647 let transform = ProjectiveTransform::from_rect_to_quad(rect, quad);
648
649 assert_eq!(
650 transform.matrix(),
651 [[3.0, 0.0, 8.0], [0.0, 3.0, 0.0], [0.0, 0.0, 1.0]]
652 );
653 }
654
655 #[test]
656 fn render_graph_new_recomputes_manual_layer_hashes() {
657 let primitive = PrimitiveEntry {
658 phase: PrimitivePhase::BeforeChildren,
659 node: PrimitiveNode::Draw(DrawPrimitiveNode {
660 primitive: DrawPrimitive::Rect {
661 rect: Rect {
662 x: 1.0,
663 y: 2.0,
664 width: 8.0,
665 height: 6.0,
666 },
667 brush: Brush::solid(Color::WHITE),
668 },
669 clip: None,
670 }),
671 };
672 let mut root = test_layer(
673 Rect {
674 x: 0.0,
675 y: 0.0,
676 width: 20.0,
677 height: 20.0,
678 },
679 vec![RenderNode::Primitive(primitive)],
680 );
681 root.graphics_layer.render_effect = Some(RenderEffect::blur(3.0));
682 let mut expected = root.clone();
683 expected.recompute_raster_cache_hashes();
684
685 let graph = RenderGraph::new(root);
686 assert_eq!(
687 graph.root.target_content_hash(),
688 expected.target_content_hash()
689 );
690 assert_eq!(graph.root.effect_hash(), expected.effect_hash());
691 }
692
693 #[test]
694 fn motion_source_content_hash_ignores_translated_content_offset() {
695 let primitive = PrimitiveEntry {
696 phase: PrimitivePhase::BeforeChildren,
697 node: PrimitiveNode::Draw(DrawPrimitiveNode {
698 primitive: DrawPrimitive::Rect {
699 rect: Rect {
700 x: 1.0,
701 y: 2.0,
702 width: 8.0,
703 height: 6.0,
704 },
705 brush: Brush::solid(Color::WHITE),
706 },
707 clip: None,
708 }),
709 };
710 let mut base = test_layer(
711 Rect {
712 x: 0.0,
713 y: 0.0,
714 width: 20.0,
715 height: 20.0,
716 },
717 vec![RenderNode::Primitive(primitive)],
718 );
719 base.translated_content_context = true;
720 base.translated_content_offset = Point::new(0.0, -24.0);
721 base.recompute_raster_cache_hashes();
722
723 let mut moved = base.clone();
724 moved.translated_content_offset = Point::new(0.0, -72.0);
725 moved.recompute_raster_cache_hashes();
726
727 assert_ne!(base.target_content_hash(), moved.target_content_hash());
728 assert_eq!(
729 base.motion_source_content_hash(),
730 moved.motion_source_content_hash()
731 );
732 }
733}