From ebc84206a74e6902cd9034734115a42a143eefd4 Mon Sep 17 00:00:00 2001 From: Nicolas Silva Date: Thu, 12 Sep 2019 15:56:16 +0000 Subject: [PATCH] Bug 1570081 - Wrench rawtest changes. r=jrmuizel Other patches in this series change blob-related coordinate systems which means rawtests have to be adapted since the previous test parameters will now give different results. In addition, the new model for specifying blobs mtaches the visible area to the layout rectangle of the primitive, which means there is no more decorrelation between the item and the portion of it that needs rendering, so one of the test is adapted accordingly. Differential Revision: https://phabricator.services.mozilla.com/D41387 --HG-- extra : moz-landing-system : lando --- gfx/wr/wrench/src/rawtest.rs | 193 +++++++++++++++-------------------- 1 file changed, 83 insertions(+), 110 deletions(-) diff --git a/gfx/wr/wrench/src/rawtest.rs b/gfx/wr/wrench/src/rawtest.rs index dc3cbe55a68e..fa1ed748ac30 100644 --- a/gfx/wr/wrench/src/rawtest.rs +++ b/gfx/wr/wrench/src/rawtest.rs @@ -39,7 +39,7 @@ impl<'a> RawtestHarness<'a> { self.test_blob_update_epoch_test(); self.test_tile_decomposition(); self.test_very_large_blob(); - self.test_insufficient_blob_visible_area(); + self.test_blob_visible_area(); self.test_offscreen_blob(); self.test_save_restore(); self.test_blur_cache(); @@ -301,10 +301,10 @@ impl<'a> RawtestHarness<'a> { let blob_img = self.wrench.api.generate_blob_image_key(); txn.add_blob_image( blob_img, - ImageDescriptor::new(1510, 111256, ImageFormat::BGRA8, false, false), + ImageDescriptor::new(15000, 15000, ImageFormat::BGRA8, false, false), blob::serialize_blob(ColorU::new(50, 50, 150, 255)), - rect(0, 0, 15010, 111256), - Some(31), + rect(0, 0, 15000, 15000), + Some(100), ); let called = Arc::new(AtomicIsize::new(0)); @@ -316,8 +316,6 @@ impl<'a> RawtestHarness<'a> { let mut builder = DisplayListBuilder::new(self.wrench.root_pipeline_id, layout_size); - let image_size = size2(1510., 111256.); - let root_space_and_clip = SpaceAndClipInfo::root_scroll(self.wrench.root_pipeline_id); let clip_id = builder.define_clip( &root_space_and_clip, @@ -327,7 +325,7 @@ impl<'a> RawtestHarness<'a> { ); let info = CommonItemProperties { - clip_rect: rect(0., -9600.0, 1510.000031, 111256.), + clip_rect: rect(0.0, 0.0, 800.0, 800.0), clip_id, spatial_id: root_space_and_clip.spatial_id, is_backface_visible: true, @@ -337,21 +335,14 @@ impl<'a> RawtestHarness<'a> { // setup some malicious image size parameters builder.push_image( &info, - info.clip_rect, - image_size * 2., - image_size, + size2(15000.0, 15000.0).into(), + size2(15000.0, 15000.0), + size2(0.0, 0.0), ImageRendering::Auto, AlphaType::PremultipliedAlpha, blob_img.as_image(), ColorF::WHITE, ); - txn.set_blob_image_visible_area( - blob_img, - DeviceIntRect { - origin: point2(0, 111256 / 30), - size: size2(1510, 111256 / 30), - } - ); let mut epoch = Epoch(0); @@ -362,35 +353,17 @@ impl<'a> RawtestHarness<'a> { // make sure we didn't request too many blobs assert!(called.load(Ordering::SeqCst) < 20); + //use crate::png; + //png::save_flipped("out.png", pixels.clone(), size2(window_rect.size.width, window_rect.size.height)); + // make sure things are in the right spot - assert!( - pixels[(148 + - (window_rect.size.height as usize - 148) * - window_rect.size.width as usize) * 4] == 255 && - pixels[(148 + - (window_rect.size.height as usize - 148) * - window_rect.size.width as usize) * 4 + 1] == 255 && - pixels[(148 + - (window_rect.size.height as usize - 148) * - window_rect.size.width as usize) * 4 + 2] == 255 && - pixels[(148 + - (window_rect.size.height as usize - 148) * - window_rect.size.width as usize) * 4 + 3] == 255 - ); - assert!( - pixels[(132 + - (window_rect.size.height as usize - 148) * - window_rect.size.width as usize) * 4] == 50 && - pixels[(132 + - (window_rect.size.height as usize - 148) * - window_rect.size.width as usize) * 4 + 1] == 50 && - pixels[(132 + - (window_rect.size.height as usize - 148) * - window_rect.size.width as usize) * 4 + 2] == 150 && - pixels[(132 + - (window_rect.size.height as usize - 148) * - window_rect.size.width as usize) * 4 + 3] == 255 - ); + let w = window_rect.size.width as usize; + let h = window_rect.size.height as usize; + let p1 = (40 + (h - 100) * w) * 4; + assert_eq!(pixels[p1 + 0], 50); + assert_eq!(pixels[p1 + 1], 50); + assert_eq!(pixels[p1 + 2], 150); + assert_eq!(pixels[p1 + 3], 255); // Leaving a tiled blob image in the resource cache // confuses the `test_capture`. TODO: remove this @@ -401,82 +374,55 @@ impl<'a> RawtestHarness<'a> { *self.wrench.callbacks.lock().unwrap() = blob::BlobCallbacks::new(); } - fn test_insufficient_blob_visible_area(&mut self) { - println!("\tinsufficient blob visible area..."); + fn test_blob_visible_area(&mut self) { + println!("\tblob visible area..."); - // This test compares two almost identical display lists containing the a blob - // image. The only difference is that one of the display lists specifies a visible - // area for its blob image which is too small, causing frame building to run into - // missing tiles, and forcing it to exercise the code path where missing tiles are - // rendered synchronously on demand. - - assert_eq!(self.wrench.device_pixel_ratio, 1.); + assert_eq!(self.wrench.device_pixel_ratio, 1.0); let window_size = self.window.get_inner_size(); + let test_size = FramebufferIntSize::new(800, 800); + let window_rect = FramebufferIntRect::new( - point2(0, window_size.height - test_size.height), + FramebufferIntPoint::new(0, window_size.height - test_size.height), test_size, ); + let layout_size = LayoutSize::new(800.0, 800.0); - let image_size = size2(800.0, 800.0); - let info = self.make_common_properties(rect(0.0, 0.0, 800.0, 800.0)); - - let mut builder = DisplayListBuilder::new(self.wrench.root_pipeline_id, layout_size); let mut txn = Transaction::new(); - let blob_img1 = self.wrench.api.generate_blob_image_key(); + let blob_img = self.wrench.api.generate_blob_image_key(); txn.add_blob_image( - blob_img1, - ImageDescriptor::new( - image_size.width as i32, - image_size.height as i32, - ImageFormat::BGRA8, - false, - false - ), + blob_img, + ImageDescriptor::new(500, 500, ImageFormat::BGRA8, false, false), blob::serialize_blob(ColorU::new(50, 50, 150, 255)), - rect(0, 0, image_size.width as i32, image_size.height as i32), - Some(100), - ); - - builder.push_image( - &info, - info.clip_rect, - image_size, - image_size, - ImageRendering::Auto, - AlphaType::PremultipliedAlpha, - blob_img1.as_image(), - ColorF::WHITE, - ); - - self.submit_dl(&mut Epoch(0), layout_size, builder, &txn.resource_updates); - let pixels1 = self.render_and_get_pixels(window_rect); - - let mut builder = DisplayListBuilder::new(self.wrench.root_pipeline_id, layout_size); - let mut txn = Transaction::new(); - - let blob_img2 = self.wrench.api.generate_blob_image_key(); - txn.add_blob_image( - blob_img2, - ImageDescriptor::new( - image_size.width as i32, - image_size.height as i32, - ImageFormat::BGRA8, - false, - false - ), - blob::serialize_blob(ColorU::new(50, 50, 150, 255)), - // Set a visible rectangle that is too small. - // This will force sync rasterization of the missing tiles during frame building. DeviceIntRect { - origin: point2(200, 200), - size: size2(80, 80), + origin: point2(50, 20), + size: size2(400, 400), }, Some(100), ); + let mut builder = DisplayListBuilder::new(self.wrench.root_pipeline_id, layout_size); + + let image_size = size2(400.0, 400.0); + + let root_space_and_clip = SpaceAndClipInfo::root_scroll(self.wrench.root_pipeline_id); + let clip_id = builder.define_clip( + &root_space_and_clip, + rect(-1000.0, -1000.0, 2000.0, 2000.0), + vec![], + None, + ); + + let info = CommonItemProperties { + clip_rect: rect(10.0, 10.0, 400.0, 400.0), + clip_id, + spatial_id: root_space_and_clip.spatial_id, + is_backface_visible: true, + hit_info: None, + }; + builder.push_image( &info, info.clip_rect, @@ -484,19 +430,46 @@ impl<'a> RawtestHarness<'a> { image_size, ImageRendering::Auto, AlphaType::PremultipliedAlpha, - blob_img2.as_image(), + blob_img.as_image(), ColorF::WHITE, ); + let mut epoch = Epoch(0); - self.submit_dl(&mut Epoch(1), layout_size, builder, &txn.resource_updates); - let pixels2 = self.render_and_get_pixels(window_rect); + self.submit_dl(&mut epoch, layout_size, builder, &txn.resource_updates); - assert!(pixels1 == pixels2); + let pixels = self.render_and_get_pixels(window_rect); + //use super::png; + //png::save_flipped("out.png", pixels.clone(), size2(window_rect.size.width, window_rect.size.height)); + + // make sure things are in the right spot + let w = window_rect.size.width as usize; + let h = window_rect.size.height as usize; + let p1 = (65 + (h - 15) * w) * 4; + assert_eq!(pixels[p1 + 0], 255); + assert_eq!(pixels[p1 + 1], 255); + assert_eq!(pixels[p1 + 2], 255); + assert_eq!(pixels[p1 + 3], 255); + + let p3 = (15 + (h - 15) * w) * 4; + assert_eq!(pixels[p3 + 0], 50); + assert_eq!(pixels[p3 + 1], 50); + assert_eq!(pixels[p3 + 2], 150); + assert_eq!(pixels[p3 + 3], 255); + + let p2 = (25 + (h - 15) * w) * 4; + assert_eq!(pixels[p2 + 0], 221); + assert_eq!(pixels[p2 + 1], 221); + assert_eq!(pixels[p2 + 2], 221); + assert_eq!(pixels[p2 + 3], 255); + + // Leaving a tiled blob image in the resource cache + // confuses the `test_capture`. TODO: remove this txn = Transaction::new(); - txn.delete_blob_image(blob_img1); - txn.delete_blob_image(blob_img2); + txn.delete_blob_image(blob_img); self.wrench.api.update_resources(txn.resource_updates); + + *self.wrench.callbacks.lock().unwrap() = blob::BlobCallbacks::new(); } fn test_offscreen_blob(&mut self) {