Skip to content

Commit 8748db9

Browse files
committed
Bug 1945041 - restore the previous surface size limiting logic and add a profiler marker r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D236984
1 parent 3fd4647 commit 8748db9

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

webrender/src/picture.rs

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ use crate::tile_cache::{SliceDebugInfo, TileDebugInfo, DirtyTileDebugInfo};
147147
use crate::visibility::{PrimitiveVisibilityFlags, FrameVisibilityContext};
148148
use crate::visibility::{VisibilityState, FrameVisibilityState};
149149
use crate::scene_building::SliceFlags;
150+
use core::time::Duration;
150151

151152
// Maximum blur radius for blur filter (different than box-shadow blur).
152153
// Taken from FilterNodeSoftware.cpp in Gecko.
@@ -8065,7 +8066,7 @@ fn get_surface_rects(
80658066
// We need to put the clipped, unclipped and source rects in the chosen
80668067
// raster spatial node if possible, so that it will be rendered at the
80678068
// proper pixel scale with antialiasing, otherwise it would be blurry.
8068-
let (mut clipped, mut unclipped, mut source) = if surface.raster_spatial_node_index != surface.surface_spatial_node_index {
8069+
let (clipped, unclipped, source) = if surface.raster_spatial_node_index != surface.surface_spatial_node_index {
80698070
// Transform surface into the chosen raster spatial node
80708071
assert_eq!(surface.device_pixel_scale.0, 1.0);
80718072

@@ -8105,14 +8106,16 @@ fn get_surface_rects(
81058106
//
81068107
// If you change this, test with:
81078108
// ./mach crashtest layout/svg/crashtests/387290-1.svg
8109+
let clipped_snapped = clipped.round_out();
8110+
let source_snapped = source.round_out();
81088111
let max_dimension =
8109-
clipped.width().max(
8110-
clipped.height().max(
8111-
source.width().max(
8112-
source.height()
8112+
clipped_snapped.width().max(
8113+
clipped_snapped.height().max(
8114+
source_snapped.width().max(
8115+
source_snapped.height()
81138116
))).ceil();
8114-
let max_allowed_dimension = max_surface_size - 4.0;
8115-
if max_dimension > max_allowed_dimension {
8117+
let max_allowed_dimension = max_surface_size;
8118+
let (clipped, unclipped, source, clipped_snapped) = if max_dimension > max_allowed_dimension {
81168119
// We have to recalculate max_dimension for the local space we'll be using
81178120
let max_dimension =
81188121
clipped_local.width().max(
@@ -8124,13 +8127,24 @@ fn get_surface_rects(
81248127
surface.device_pixel_scale = Scale::new(max_allowed_dimension / max_dimension);
81258128
surface.local_scale = (1.0, 1.0);
81268129

8127-
clipped = clipped_local.cast_unit() * surface.device_pixel_scale;
8128-
unclipped = unclipped_local.cast_unit() * surface.device_pixel_scale;
8129-
source = source_local.cast_unit() * surface.device_pixel_scale;
8130-
}
8130+
let new_clipped = clipped_local.cast_unit() * surface.device_pixel_scale;
8131+
let new_unclipped = unclipped_local.cast_unit() * surface.device_pixel_scale;
8132+
let new_source = source_local.cast_unit() * surface.device_pixel_scale;
8133+
8134+
let add_markers = profiler::thread_is_being_profiled();
8135+
if add_markers {
8136+
profiler::add_text_marker("SurfaceSizeLimited",
8137+
format!("Surface reduced from raster {:?} (source {:?}) to local {:?} (source {:?})",
8138+
clipped.size(), source.size(),
8139+
new_clipped.size(), new_source.size()).as_str(),
8140+
Duration::from_secs_f32(new_clipped.width() * new_clipped.height() / 1000000000.0));
8141+
}
8142+
8143+
(new_clipped, new_unclipped, new_source.round(), new_clipped.round())
8144+
} else {
8145+
(clipped, unclipped, source.round_out(), clipped.round_out())
8146+
};
81318147

8132-
let source = source.round_out();
8133-
let clipped_snapped = clipped.round_out();
81348148
let task_size = clipped_snapped.size().to_i32();
81358149
assert!(
81368150
task_size.width <= max_surface_size as i32 &&

0 commit comments

Comments
 (0)