mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 00:35:44 +00:00
Bug 1570081 - Wrench rawtest changes. r=jrmuizel
Differential Revision: https://phabricator.services.mozilla.com/D41387 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
e9915eb02b
commit
7b6f30fd89
@ -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();
|
||||
@ -295,10 +295,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));
|
||||
@ -310,8 +310,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,
|
||||
@ -321,7 +319,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,
|
||||
@ -331,21 +329,14 @@ impl<'a> RawtestHarness<'a> {
|
||||
// setup some malicious image size parameters
|
||||
builder.push_repeating_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);
|
||||
|
||||
@ -356,35 +347,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
|
||||
@ -395,82 +368,52 @@ 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_repeating_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_repeating_image(
|
||||
&info,
|
||||
info.clip_rect,
|
||||
@ -478,19 +421,47 @@ 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 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);
|
||||
|
||||
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);
|
||||
|
||||
// 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) {
|
||||
|
Loading…
Reference in New Issue
Block a user