From dbfb0e6cdd585db27511f3561694b6fe90d28176 Mon Sep 17 00:00:00 2001 From: Oana Pop Rus Date: Wed, 2 Oct 2019 02:32:26 +0300 Subject: [PATCH] Backed out 3 changesets (bug 1580922) for wrench bustages. on a CLOSED TREE Backed out changeset c6552f7ec6a0 (bug 1580922) Backed out changeset ac6bd19f200a (bug 1580922) Backed out changeset 31d0469993bd (bug 1580922) --- gfx/wr/webrender/src/render_backend.rs | 3 - gfx/wr/webrender/src/resource_cache.rs | 65 ++++------ gfx/wr/wrench/src/rawtest.rs | 172 ------------------------- 3 files changed, 27 insertions(+), 213 deletions(-) diff --git a/gfx/wr/webrender/src/render_backend.rs b/gfx/wr/webrender/src/render_backend.rs index 6221bd8c73dc..a7b4b70c2ef6 100644 --- a/gfx/wr/webrender/src/render_backend.rs +++ b/gfx/wr/webrender/src/render_backend.rs @@ -1692,9 +1692,6 @@ fn get_blob_image_updates(updates: &[ResourceUpdate]) -> Vec { ResourceUpdate::UpdateBlobImage(ref img) => { requests.push(img.key); } - ResourceUpdate::SetBlobImageVisibleArea(key, ..) => { - requests.push(key); - } _ => {} } } diff --git a/gfx/wr/webrender/src/resource_cache.rs b/gfx/wr/webrender/src/resource_cache.rs index 881d8e875df2..728a91954a02 100644 --- a/gfx/wr/webrender/src/resource_cache.rs +++ b/gfx/wr/webrender/src/resource_cache.rs @@ -671,17 +671,18 @@ impl ResourceCache { ); } ResourceUpdate::UpdateBlobImage(ref img) => { - debug_assert_eq!(img.visible_rect.size, img.descriptor.size); self.update_blob_image( img.key, - Some(&img.descriptor), - Some(&img.dirty_rect), - Some(Arc::clone(&img.data)), + &img.descriptor, + &img.dirty_rect, + Arc::clone(&img.data), &img.visible_rect, ); } ResourceUpdate::SetBlobImageVisibleArea(ref key, ref area) => { - self.update_blob_image(*key, None, None, None, area); + if let Some(template) = self.blob_image_templates.get_mut(&key) { + template.visible_rect = *area; + } } _ => {} } @@ -989,7 +990,7 @@ impl ResourceCache { visible_rect: &DeviceIntRect, ) { let max_texture_size = self.max_texture_size(); - tiling = get_blob_tiling(tiling, visible_rect.size, max_texture_size); + tiling = get_blob_tiling(tiling, descriptor, max_texture_size); self.blob_image_handler.as_mut().unwrap().add(key, data, visible_rect, tiling); @@ -1009,15 +1010,12 @@ impl ResourceCache { pub fn update_blob_image( &mut self, key: BlobImageKey, - descriptor: Option<&ImageDescriptor>, - dirty_rect: Option<&BlobDirtyRect>, - data: Option>, + descriptor: &ImageDescriptor, + dirty_rect: &BlobDirtyRect, + data: Arc, visible_rect: &DeviceIntRect, ) { - if let Some(data) = data { - let dirty_rect = dirty_rect.unwrap(); - self.blob_image_handler.as_mut().unwrap().update(key, data, visible_rect, dirty_rect); - } + self.blob_image_handler.as_mut().unwrap().update(key, data, visible_rect, dirty_rect); let max_texture_size = self.max_texture_size(); @@ -1025,6 +1023,8 @@ impl ResourceCache { .get_mut(&key) .expect("Attempt to update non-existent blob image"); + let tiling = get_blob_tiling(image.tiling, descriptor, max_texture_size); + let mut valid_tiles_after_bounds_change = None; if let Some(tile_size) = image.tiling { @@ -1045,23 +1045,13 @@ impl ResourceCache { _ => {} } - let blob_size = visible_rect.size; - - if let Some(descriptor) = descriptor { - image.descriptor = *descriptor; - } else { - // make sure the descriptor size matches the visible rect. - // This might not be necessary but let's stay on the safe side. - image.descriptor.size = blob_size; - } - - if let Some(dirty_rect) = dirty_rect { - image.dirty_rect = image.dirty_rect.union(dirty_rect); - } - - image.tiling = get_blob_tiling(image.tiling, blob_size, max_texture_size);; - image.valid_tiles_after_bounds_change = valid_tiles_after_bounds_change; - image.visible_rect = *visible_rect; + *image = BlobImageTemplate { + descriptor: *descriptor, + tiling, + dirty_rect: dirty_rect.union(&image.dirty_rect), + valid_tiles_after_bounds_change, + visible_rect: *visible_rect, + }; } pub fn delete_image_template(&mut self, image_key: ImageKey) { @@ -1236,7 +1226,7 @@ impl ResourceCache { tile, )) } - None => blob_size(template.visible_rect.size).into(), + None => blob_size(template.descriptor.size).into(), }, format: template.descriptor.format, }; @@ -1411,7 +1401,7 @@ impl ResourceCache { template.dirty_rect }; - assert!(template.visible_rect.size.width > 0 && template.visible_rect.size.height > 0); + assert!(template.descriptor.size.width > 0 && template.descriptor.size.height > 0); blob_request_params.push( BlobImageParams { request: BlobImageRequest { @@ -1419,7 +1409,7 @@ impl ResourceCache { tile: None, }, descriptor: BlobImageDescriptor { - rect: blob_size(template.visible_rect.size).into(), + rect: blob_size(template.descriptor.size).into(), format: template.descriptor.format, }, dirty_rect, @@ -1484,8 +1474,7 @@ impl ResourceCache { fn set_image_visible_rect(&mut self, key: ImageKey, rect: &DeviceIntRect) { if let Some(image) = self.resources.image_templates.get_mut(key) { - image.visible_rect = *rect; - image.descriptor.size = rect.size; + image.visible_rect = * rect; } } @@ -1973,12 +1962,12 @@ impl Drop for ResourceCache { pub fn get_blob_tiling( tiling: Option, - size: DeviceIntSize, + descriptor: &ImageDescriptor, max_texture_size: i32, ) -> Option { if tiling.is_none() && - (size.width > max_texture_size || - size.height > max_texture_size) { + (descriptor.size.width > max_texture_size || + descriptor.size.height > max_texture_size) { return Some(DEFAULT_TILE_SIZE); } diff --git a/gfx/wr/wrench/src/rawtest.rs b/gfx/wr/wrench/src/rawtest.rs index ee9363c8e281..86bfb689d3db 100644 --- a/gfx/wr/wrench/src/rawtest.rs +++ b/gfx/wr/wrench/src/rawtest.rs @@ -40,7 +40,6 @@ impl<'a> RawtestHarness<'a> { self.test_tile_decomposition(); self.test_very_large_blob(); self.test_blob_visible_area(); - self.test_blob_set_visible_area(); self.test_offscreen_blob(); self.test_save_restore(); self.test_blur_cache(); @@ -465,177 +464,6 @@ impl<'a> RawtestHarness<'a> { *self.wrench.callbacks.lock().unwrap() = blob::BlobCallbacks::new(); } - fn test_blob_set_visible_area(&mut self) { - // In this test we first render a blob with a certain visible area, - // then change the visible area without updating the blob image. - - println!("\tblob visible area update..."); - - 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( - FramebufferIntPoint::new(0, window_size.height - test_size.height), - test_size, - ); - let layout_size = LayoutSize::new(800.0, 800.0); - let mut txn = Transaction::new(); - - let blob_img = self.wrench.api.generate_blob_image_key(); - txn.add_blob_image( - blob_img, - ImageDescriptor::new(500, 500, ImageFormat::BGRA8, false, false), - blob::serialize_blob(ColorU::new(50, 50, 150, 255)), - DeviceIntRect { - origin: point2(0, 0), - size: size2(500, 500), - }, - Some(128), - ); - - let mut builder = DisplayListBuilder::new(self.wrench.root_pipeline_id, layout_size); - - 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(0.0, 0.0, 1000.0, 1000.0), - clip_id, - spatial_id: root_space_and_clip.spatial_id, - is_backface_visible: true, - hit_info: None, - }; - - builder.push_repeating_image( - &info, - rect(0.0, 0.0, 500.0, 500.0), - size2(500.0, 500.0), - size2(500.0, 500.0), - ImageRendering::Auto, - AlphaType::PremultipliedAlpha, - blob_img.as_image(), - ColorF::WHITE, - ); - let mut epoch = Epoch(0); - - // Render the first display list. We don't care about the result but we - // want to make sure the next display list updates an already rendered - // state. - self.submit_dl(&mut epoch, layout_size, builder, &txn.resource_updates); - let _ = self.render_and_get_pixels(window_rect); - - // Now render a similar scene with an updated blob visible area. - // In this test we care about the fact that the visible area was updated - // without using update_blob_image. - - let mut txn = Transaction::new(); - - txn.set_blob_image_visible_area(blob_img, DeviceIntRect { - origin: point2(50, 50), - size: size2(400, 400), - }); - - let mut builder = DisplayListBuilder::new(self.wrench.root_pipeline_id, layout_size); - - 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(0.0, 0.0, 1000.0, 1000.0), - clip_id, - spatial_id: root_space_and_clip.spatial_id, - is_backface_visible: true, - hit_info: None, - }; - - builder.push_repeating_image( - &info, - rect(50.0, 50.0, 400.0, 400.0), - size2(400.0, 400.0), - size2(400.0, 400.0), - ImageRendering::Auto, - AlphaType::PremultipliedAlpha, - blob_img.as_image(), - ColorF::WHITE, - ); - - self.submit_dl(&mut epoch, layout_size, builder, &txn.resource_updates); - let resized_pixels = self.render_and_get_pixels(window_rect); - - // Now render the same scene with a new blob image created with the same - // visible area as the previous scene, without going through an update. - - let mut txn = Transaction::new(); - - let blob_img2 = self.wrench.api.generate_blob_image_key(); - txn.add_blob_image( - blob_img2, - ImageDescriptor::new(500, 500, ImageFormat::BGRA8, false, false), - blob::serialize_blob(ColorU::new(50, 50, 150, 255)), - DeviceIntRect { - origin: point2(50, 50), - size: size2(400, 400), - }, - Some(128), - ); - - let mut builder = DisplayListBuilder::new(self.wrench.root_pipeline_id, layout_size); - - 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(0.0, 0.0, 1000.0, 1000.0), - clip_id, - spatial_id: root_space_and_clip.spatial_id, - is_backface_visible: true, - hit_info: None, - }; - - builder.push_repeating_image( - &info, - rect(50.0, 50.0, 400.0, 400.0), - size2(400.0, 400.0), - size2(400.0, 400.0), - ImageRendering::Auto, - AlphaType::PremultipliedAlpha, - blob_img2.as_image(), - ColorF::WHITE, - ); - let mut epoch = Epoch(0); - - self.submit_dl(&mut epoch, layout_size, builder, &txn.resource_updates); - - let reference_pixels = self.render_and_get_pixels(window_rect); - - //use super::png; - //png::save_flipped("resized.png", resized_pixels.clone(), size2(window_rect.size.width, window_rect.size.height)); - //png::save_flipped("reference.png", reference_pixels.clone(), size2(window_rect.size.width, window_rect.size.height)); - - assert_eq!(resized_pixels, reference_pixels); - - txn = Transaction::new(); - txn.delete_blob_image(blob_img); - txn.delete_blob_image(blob_img2); - self.wrench.api.update_resources(txn.resource_updates); - } - fn test_offscreen_blob(&mut self) { println!("\toffscreen blob update...");