Bug 1509643 - Add a wrench test. r=kats
authorNicolas Silva <nsilva@mozilla.com>
Tue, 12 Feb 2019 10:34:19 +0100
changeset 458698 b716914a3375
parent 458697 1559889f35e7
child 458699 9f3a8e9d5915
push id35544
push userccoroiu@mozilla.com
push dateTue, 12 Feb 2019 16:29:08 +0000
treeherdermozilla-central@c849fb69e2e7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1509643
milestone67.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 1509643 - Add a wrench test. r=kats Differential Revision: https://phabricator.services.mozilla.com/D18948
gfx/wr/wrench/src/rawtest.rs
gfx/wr/wrench/src/wrench.rs
--- a/gfx/wr/wrench/src/rawtest.rs
+++ b/gfx/wr/wrench/src/rawtest.rs
@@ -37,16 +37,17 @@ impl<'a> RawtestHarness<'a> {
             wrench,
             rx,
             window,
         }
     }
 
     pub fn run(mut self) {
         self.test_hit_testing();
+        self.test_resize_image();
         self.test_retained_blob_images_test();
         self.test_blob_update_test();
         self.test_blob_update_epoch_test();
         self.test_tile_decomposition();
         self.test_very_large_blob();
         self.test_insufficient_blob_visible_area();
         self.test_offscreen_blob();
         self.test_save_restore();
@@ -82,16 +83,112 @@ impl<'a> RawtestHarness<'a> {
             false,
         );
         epoch.0 += 1;
 
         txn.generate_frame();
         self.wrench.api.send_transaction(self.wrench.document_id, txn);
     }
 
+    fn test_resize_image(&mut self) {
+        println!("\tresize image...");
+        // This test changes the size of an image to make it go switch back and forth
+        // between tiled and non-tiled.
+        // The resource cache should be able to handle this without crashing.
+
+        let layout_size = LayoutSize::new(800., 800.);
+
+        let mut txn = Transaction::new();
+        let img = self.wrench.api.generate_image_key();
+
+        // Start with a non-tiled image.
+        txn.add_image(
+            img,
+            ImageDescriptor::new(64, 64, ImageFormat::BGRA8, true, false),
+            ImageData::new(vec![255; 64 * 64 * 4]),
+            None,
+        );
+
+        let mut builder = DisplayListBuilder::new(self.wrench.root_pipeline_id, layout_size);
+        let info = LayoutPrimitiveInfo::new(rect(0.0, 0.0, 64.0, 64.0));
+
+        builder.push_image(
+            &info,
+            &SpaceAndClipInfo::root_scroll(self.wrench.root_pipeline_id),
+            size(64.0, 64.0),
+            size(64.0, 64.0),
+            ImageRendering::Auto,
+            AlphaType::PremultipliedAlpha,
+            img,
+            ColorF::WHITE,
+        );
+
+        let mut epoch = Epoch(0);
+
+        self.submit_dl(&mut epoch, layout_size, builder, &txn.resource_updates);
+        self.rx.recv().unwrap();
+        self.wrench.render();
+
+        let mut txn = Transaction::new();
+        // Resize the image to something bigger than the max texture size (8196) to force tiling.
+        txn.update_image(
+            img,
+            ImageDescriptor::new(8200, 32, ImageFormat::BGRA8, true, false),
+            ImageData::new(vec![255; 8200 * 32 * 4]),
+            &DirtyRect::All,
+        );
+
+        let mut builder = DisplayListBuilder::new(self.wrench.root_pipeline_id, layout_size);
+        let info = LayoutPrimitiveInfo::new(rect(0.0, 0.0, 1024.0, 1024.0));
+
+        builder.push_image(
+            &info,
+            &SpaceAndClipInfo::root_scroll(self.wrench.root_pipeline_id),
+            size(1024.0, 1024.0),
+            size(1024.0, 1024.0),
+            ImageRendering::Auto,
+            AlphaType::PremultipliedAlpha,
+            img,
+            ColorF::WHITE,
+        );
+
+        self.submit_dl(&mut epoch, layout_size, builder, &txn.resource_updates);
+        self.rx.recv().unwrap();
+        self.wrench.render();
+
+        // Resize back to something doesn't require tiling.
+        txn.update_image(
+            img,
+            ImageDescriptor::new(64, 64, ImageFormat::BGRA8, true, false),
+            ImageData::new(vec![64; 64 * 64 * 4]),
+            &DirtyRect::All,
+        );
+
+        let mut builder = DisplayListBuilder::new(self.wrench.root_pipeline_id, layout_size);
+        let info = LayoutPrimitiveInfo::new(rect(0.0, 0.0, 1024.0, 1024.0));
+
+        builder.push_image(
+            &info,
+            &SpaceAndClipInfo::root_scroll(self.wrench.root_pipeline_id),
+            size(1024.0, 1024.0),
+            size(1024.0, 1024.0),
+            ImageRendering::Auto,
+            AlphaType::PremultipliedAlpha,
+            img,
+            ColorF::WHITE,
+        );
+
+        self.submit_dl(&mut epoch, layout_size, builder, &txn.resource_updates);
+        self.rx.recv().unwrap();
+        self.wrench.render();
+
+        txn = Transaction::new();
+        txn.delete_image(img);
+        self.wrench.api.update_resources(txn.resource_updates);
+    }
 
     fn test_tile_decomposition(&mut self) {
         println!("\ttile decomposition...");
         // This exposes a crash in tile decomposition
         let layout_size = LayoutSize::new(800., 800.);
         let mut txn = Transaction::new();
 
         let blob_img = self.wrench.api.generate_blob_image_key();
--- a/gfx/wr/wrench/src/wrench.rs
+++ b/gfx/wr/wrench/src/wrench.rs
@@ -217,16 +217,17 @@ impl Wrench {
             enable_clear_scissor: !no_scissor,
             max_recorded_profiles: 16,
             precache_flags,
             blob_image_handler: Some(Box::new(blob::CheckerboardRenderer::new(callbacks.clone()))),
             disable_dual_source_blending,
             chase_primitive,
             enable_picture_caching: true,
             testing: true,
+            max_texture_size: Some(8196), // Needed for rawtest::test_resize_image.
             ..Default::default()
         };
 
         // put an Awakened event into the queue to kick off the first frame
         if let Some(ref elp) = proxy {
             #[cfg(not(target_os = "android"))]
             let _ = elp.wakeup();
         }