Bug 1520851 - Fix wrench / reftests / examples.
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 17 Jan 2019 19:29:17 +0100
changeset 511440 49edd076512c9875f853d37695ab3f5abcdb8c6d
parent 511439 18b2eba81b2b0e50188b29f97bacaac2132716ae
child 511441 471d9fab61b34671f974dfa349e7972c200faa2b
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1520851
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1520851 - Fix wrench / reftests / examples. This fixes stuff for both refence frame changes. Differential Revision: https://phabricator.services.mozilla.com/D16883
gfx/wr/examples/animation.rs
gfx/wr/examples/iframe.rs
gfx/wr/webrender/src/clip_scroll_tree.rs
gfx/wr/wrench/reftests/snap/preserve-3d.yaml
gfx/wr/wrench/reftests/split/ordering.yaml
gfx/wr/wrench/reftests/split/same-plane.yaml
gfx/wr/wrench/reftests/transforms/perspective-shadow.yaml
gfx/wr/wrench/src/scene.rs
gfx/wr/wrench/src/yaml_frame_reader.rs
gfx/wr/wrench/src/yaml_frame_writer.rs
--- a/gfx/wr/examples/animation.rs
+++ b/gfx/wr/examples/animation.rs
@@ -54,18 +54,18 @@ impl App {
                 vec![]
             }
         };
 
         let spatial_id = builder.push_reference_frame(
             &LayoutRect::new(bounds.origin, LayoutSize::zero()),
             SpatialId::root_scroll_node(pipeline_id),
             TransformStyle::Flat,
-            Some(PropertyBinding::Binding(property_key, LayoutTransform::identity())),
-            None,
+            PropertyBinding::Binding(property_key, LayoutTransform::identity()),
+            ReferenceFrameKind::Transform,
         );
 
         builder.push_stacking_context(
             &LayoutPrimitiveInfo::new(LayoutRect::zero()),
             spatial_id,
             None,
             TransformStyle::Flat,
             MixBlendMode::Normal,
--- a/gfx/wr/examples/iframe.rs
+++ b/gfx/wr/examples/iframe.rs
@@ -61,18 +61,18 @@ impl Example for App {
             true,
         );
         api.send_transaction(document_id, txn);
 
         space_and_clip.spatial_id = builder.push_reference_frame(
             &sub_bounds,
             space_and_clip.spatial_id,
             TransformStyle::Flat,
-            Some(PropertyBinding::Binding(PropertyBindingKey::new(42), LayoutTransform::identity())),
-            None,
+            PropertyBinding::Binding(PropertyBindingKey::new(42), LayoutTransform::identity()),
+            ReferenceFrameKind::Transform,
         );
 
         // And this is for the root pipeline
         let info = LayoutPrimitiveInfo::new(sub_bounds);
         builder.push_stacking_context(
             &info,
             space_and_clip.spatial_id,
             None,
--- a/gfx/wr/webrender/src/clip_scroll_tree.rs
+++ b/gfx/wr/webrender/src/clip_scroll_tree.rs
@@ -499,18 +499,18 @@ fn add_reference_frame(
     cst: &mut ClipScrollTree,
     parent: Option<SpatialNodeIndex>,
     transform: LayoutTransform,
     origin_in_parent_reference_frame: LayoutVector2D,
 ) -> SpatialNodeIndex {
     cst.add_reference_frame(
         parent,
         TransformStyle::Preserve3D,
-        Some(PropertyBinding::Value(transform)),
-        None,
+        PropertyBinding::Value(transform),
+        ReferenceFrameKind::Perspective,
         origin_in_parent_reference_frame,
         PipelineId::dummy(),
     )
 }
 
 #[cfg(test)]
 fn test_pt(
     px: f32,
--- a/gfx/wr/wrench/reftests/snap/preserve-3d.yaml
+++ b/gfx/wr/wrench/reftests/snap/preserve-3d.yaml
@@ -4,17 +4,16 @@ root:
     -
       bounds: [293, 139, 500, 500]
       type: reference-frame
       transform: scale(0.7)
       items:
         -
           bounds: [0, 0, 500, 500]
           type: stacking-context
-          transform: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]
           perspective: [1, 0, 0, 0, 0, 1, 0, 0, -0.25416666, -0.23866667, 1, -0.00083333335, 0, 0, 0, 1]
           "transform-style": preserve-3d
           items:
             -
               bounds: [0, 0, 0, 0]
               type: stacking-context
               transform: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -110, 0, 0, 1]
               items:
--- a/gfx/wr/wrench/reftests/split/ordering.yaml
+++ b/gfx/wr/wrench/reftests/split/ordering.yaml
@@ -1,21 +1,25 @@
 ---
 root:
   items:
     -
       type: "stacking-context"
       transform: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 15, 15, 0, 1]
       "transform-style": "preserve-3d"
-      perspective: [1, 0, 0, 0, 0, 1, 0, 0, -0.05, -0.1, 1, -0.00066666666, 0, 0, 0, 1]
       items:
         -
-          bounds: [0, 0, 150, 300]
-          type: rect
-          color: 255 0 0 1.0000
+          perspective: [1, 0, 0, 0, 0, 1, 0, 0, -0.05, -0.1, 1, -0.00066666666, 0, 0, 0, 1]
+          type: "stacking-context"
+          "transform-style": "preserve-3d"
+          items:
+            -
+              bounds: [0, 0, 150, 300]
+              type: rect
+              color: 255 0 0 1.0000
     -
       bounds: [203, 15, 150, 300]
       type: rect
       color: 255 0 0 1.0000
     -
       bounds: [0, 0, 450, 150]
       type: rect
       color: 0 0 0 0.6667
--- a/gfx/wr/wrench/reftests/split/same-plane.yaml
+++ b/gfx/wr/wrench/reftests/split/same-plane.yaml
@@ -1,33 +1,33 @@
 # This test has a number of rectangles placed on the same transformed preserve3d plane.
 # The expected result is that the rectangles are rendered in the order they are listed.
 # This can fail if the primitives are considered outside of the main plane due
 # to floating point precision issues in plane-splitting and transformation.
 ---
 root:
   items:
-    -
-      type: "stacking-context"
+    - type: "stacking-context"
+      transform-style: preserve-3d
       transform: rotate-y(30) rotate-x(75) translate(-100, 100, 0)
-      transform-style: preserve-3d
-      perspective: 400
       items:
-        -
-          bounds: [0, 0, 450, 300]
-          type: rect
-          color: 0 255 0 1.0000
-        - type: stacking-context
-          bounds: [0, 0, 600, 600]
-          transform: translate(200, 0, 0)
+        - type: "stacking-context"
+          perspective: 400
+          transform-style: preserve-3d
           items:
-            -
-              bounds: [-200, 0, 150, 300]
-              type: rect
-              color: 255 0 0 1.0000
-        - type: stacking-context
-          bounds: [0, 0, 600, 600]
-          transform: rotate-z(90)
-          items:
-            -
-              bounds: [0, 200, 150, 200]
-              type: rect
-              color: 0 0 255 1.0000
+            - type: rect
+              bounds: [0, 0, 450, 300]
+              color: 0 255 0 1.0000
+            - type: stacking-context
+              bounds: [0, 0, 600, 600]
+              transform: translate(200, 0, 0)
+              items:
+                - type: rect
+                  bounds: [-200, 0, 150, 300]
+                  color: 255 0 0 1.0000
+            - type: stacking-context
+              bounds: [0, 0, 600, 600]
+              transform: rotate-z(90)
+              items:
+                -
+                  bounds: [0, 200, 150, 200]
+                  type: rect
+                  color: 0 0 255 1.0000
--- a/gfx/wr/wrench/reftests/transforms/perspective-shadow.yaml
+++ b/gfx/wr/wrench/reftests/transforms/perspective-shadow.yaml
@@ -1,23 +1,27 @@
 ---
 root:
   items:
     -
       type: stacking-context
       bounds: [0, 0, 0, 0]
       transform: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 139, 0, 1]
-      perspective: [1, 0, 0, 0, 0, 1, 0, 0, -299, -250, 1, -0.5, 0, 0, 0, 1]
       items:
         -
+          type: stacking-context
           bounds: [0, 0, 0, 0]
-          type: stacking-context
-          transform: [10, 0, 0, 0, 0, 10, 0, 0, 0, 0, 1, 0, -5382, -3222, -18, 1]
+          perspective: [1, 0, 0, 0, 0, 1, 0, 0, -299, -250, 1, -0.5, 0, 0, 0, 1]
           items:
             -
-              type: box-shadow
-              bounds: [548, 200, 100, 100]
-              color: 0 0 0 0.7020
-              blur-radius: 20
-            -
-              bounds: [548, 200, 100, 100]
-              type: rect
-              color: 0 255 0 1.0000
+              bounds: [0, 0, 0, 0]
+              type: stacking-context
+              transform: [10, 0, 0, 0, 0, 10, 0, 0, 0, 0, 1, 0, -5382, -3222, -18, 1]
+              items:
+                -
+                  type: box-shadow
+                  bounds: [548, 200, 100, 100]
+                  color: 0 0 0 0.7020
+                  blur-radius: 20
+                -
+                  bounds: [548, 200, 100, 100]
+                  type: rect
+                  color: 0 255 0 1.0000
--- a/gfx/wr/wrench/src/scene.rs
+++ b/gfx/wr/wrench/src/scene.rs
@@ -31,24 +31,19 @@ impl SceneProperties {
             self.float_properties
                 .insert(property.key.id, property.value);
         }
     }
 
     /// Get the current value for a transform property.
     pub fn resolve_layout_transform(
         &self,
-        property: &Option<PropertyBinding<LayoutTransform>>,
+        property: &PropertyBinding<LayoutTransform>,
     ) -> LayoutTransform {
-        let property = match *property {
-            Some(property) => property,
-            None => return LayoutTransform::identity(),
-        };
-
-        match property {
+        match *property {
             PropertyBinding::Value(matrix) => matrix,
             PropertyBinding::Binding(ref key, v) => self.transform_properties
                 .get(&key.id)
                 .cloned()
                 .unwrap_or(v),
         }
     }
 
--- a/gfx/wr/wrench/src/yaml_frame_reader.rs
+++ b/gfx/wr/wrench/src/yaml_frame_reader.rs
@@ -1662,34 +1662,45 @@ impl YamlFrameReader {
         let transform_origin = yaml["transform-origin"]
             .as_point()
             .unwrap_or(default_transform_origin);
 
         let perspective_origin = yaml["perspective-origin"]
             .as_point()
             .unwrap_or(default_transform_origin);
 
+        assert!(
+            yaml["transform"].is_badvalue() ||
+            yaml["perspective"].is_badvalue(),
+            "Should have one of either transform or perspective"
+        );
+
+        let reference_frame_kind = if !yaml["perspective"].is_badvalue() {
+            ReferenceFrameKind::Perspective
+        } else {
+            ReferenceFrameKind::Transform
+        };
+
         let transform = yaml["transform"]
-            .as_transform(&transform_origin)
-            .map(|transform| transform.into());
+            .as_transform(&transform_origin);
 
         let perspective = match yaml["perspective"].as_f32() {
             Some(value) if value != 0.0 => {
                 Some(make_perspective(perspective_origin, value as f32))
             }
-            Some(_) => None,
+            Some(..) => None,
             _ => yaml["perspective"].as_matrix4d(),
         };
 
         let reference_frame_id = dl.push_reference_frame(
             &bounds,
             *self.spatial_id_stack.last().unwrap(),
             transform_style,
-            transform.into(),
-            perspective,
+            transform.or_else(|| perspective).unwrap_or_default().into(),
+            reference_frame_kind,
         );
 
         let numeric_id = yaml["id"].as_i64();
         if let Some(numeric_id) = numeric_id {
             self.add_spatial_id_mapping(numeric_id as u64, reference_frame_id);
         }
 
         reference_frame_id
--- a/gfx/wr/wrench/src/yaml_frame_writer.rs
+++ b/gfx/wr/wrench/src/yaml_frame_writer.rs
@@ -193,24 +193,23 @@ fn maybe_radius_yaml(radius: &BorderRadi
 fn write_reference_frame(
     parent: &mut Table,
     reference_frame: &ReferenceFrame,
     properties: &SceneProperties,
     clip_id_mapper: &mut ClipIdMapper,
 ) {
     matrix4d_node(
         parent,
-        "transform",
+        match reference_frame.kind {
+            ReferenceFrameKind::Transform => "transform",
+            ReferenceFrameKind::Perspective => "perspective",
+        },
         &properties.resolve_layout_transform(&reference_frame.transform)
     );
 
-    if let Some(perspective) = reference_frame.perspective {
-        matrix4d_node(parent, "perspective", &perspective);
-    }
-
     usize_node(parent, "id", clip_id_mapper.add_spatial_id(reference_frame.id));
 }
 
 fn write_stacking_context(
     parent: &mut Table,
     sc: &StackingContext,
     properties: &SceneProperties,
     filter_iter: AuxIter<FilterOp>,