@@ -147,6 +147,7 @@ use crate::tile_cache::{SliceDebugInfo, TileDebugInfo, DirtyTileDebugInfo};
147
147
use crate :: visibility:: { PrimitiveVisibilityFlags , FrameVisibilityContext } ;
148
148
use crate :: visibility:: { VisibilityState , FrameVisibilityState } ;
149
149
use crate :: scene_building:: SliceFlags ;
150
+ use core:: time:: Duration ;
150
151
151
152
// Maximum blur radius for blur filter (different than box-shadow blur).
152
153
// Taken from FilterNodeSoftware.cpp in Gecko.
@@ -8065,7 +8066,7 @@ fn get_surface_rects(
8065
8066
// We need to put the clipped, unclipped and source rects in the chosen
8066
8067
// raster spatial node if possible, so that it will be rendered at the
8067
8068
// 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 {
8069
8070
// Transform surface into the chosen raster spatial node
8070
8071
assert_eq ! ( surface. device_pixel_scale. 0 , 1.0 ) ;
8071
8072
@@ -8105,14 +8106,16 @@ fn get_surface_rects(
8105
8106
//
8106
8107
// If you change this, test with:
8107
8108
// ./mach crashtest layout/svg/crashtests/387290-1.svg
8109
+ let clipped_snapped = clipped. round_out ( ) ;
8110
+ let source_snapped = source. round_out ( ) ;
8108
8111
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 ( )
8113
8116
) ) ) . 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 {
8116
8119
// We have to recalculate max_dimension for the local space we'll be using
8117
8120
let max_dimension =
8118
8121
clipped_local. width ( ) . max (
@@ -8124,13 +8127,24 @@ fn get_surface_rects(
8124
8127
surface. device_pixel_scale = Scale :: new ( max_allowed_dimension / max_dimension) ;
8125
8128
surface. local_scale = ( 1.0 , 1.0 ) ;
8126
8129
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
+ } ;
8131
8147
8132
- let source = source. round_out ( ) ;
8133
- let clipped_snapped = clipped. round_out ( ) ;
8134
8148
let task_size = clipped_snapped. size ( ) . to_i32 ( ) ;
8135
8149
assert ! (
8136
8150
task_size. width <= max_surface_size as i32 &&
0 commit comments