diff --git a/Cargo.lock b/Cargo.lock index 0492d948e1..36c79d5cea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,7 +44,7 @@ name = "app_units" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -53,7 +53,7 @@ name = "approx" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -79,6 +79,11 @@ name = "autocfg" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "autocfg" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "backtrace" version = "0.3.12" @@ -428,7 +433,7 @@ dependencies = [ name = "direct-composition" version = "0.1.0" dependencies = [ - "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.8 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "mozangle 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "webrender 0.61.0", @@ -485,10 +490,10 @@ dependencies = [ [[package]] name = "euclid" -version = "0.20.0" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -745,7 +750,7 @@ dependencies = [ "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "num-iter 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", "num-rational 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "png 0.15.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -822,7 +827,7 @@ name = "line_drawing" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -988,7 +993,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "num-integer 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)", "num-iter 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -996,7 +1001,7 @@ name = "num-integer" version = "0.1.38" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1005,7 +1010,7 @@ version = "0.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "num-integer 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1014,13 +1019,16 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "num-integer 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num-traits" -version = "0.2.4" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "num_cpus" @@ -1048,7 +1056,7 @@ name = "ordered-float" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1097,7 +1105,7 @@ dependencies = [ name = "peek-poke" version = "0.2.0" dependencies = [ - "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.8 (registry+https://github.com/rust-lang/crates.io-index)", "peek-poke-derive 0.2.1", ] @@ -1133,9 +1141,9 @@ version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "binary-space-partition 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.8 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1633,7 +1641,7 @@ dependencies = [ name = "tileview" version = "0.1.0" dependencies = [ - "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.8 (registry+https://github.com/rust-lang/crates.io-index)", "ron 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)", "webrender 0.61.0", @@ -1821,7 +1829,7 @@ dependencies = [ "core-text 13.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "cstr 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "dwrote 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.8 (registry+https://github.com/rust-lang/crates.io-index)", "freetype 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1831,7 +1839,7 @@ dependencies = [ "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "malloc_size_of_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "mozangle 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "plane-split 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "png 0.15.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1856,7 +1864,7 @@ dependencies = [ "app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.8 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "glutin 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1874,7 +1882,7 @@ dependencies = [ "core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "core-graphics 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.8 (registry+https://github.com/rust-lang/crates.io-index)", "malloc_size_of_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "peek-poke 0.2.0", "serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1965,7 +1973,7 @@ name = "wr_malloc_size_of" version = "0.0.1" dependencies = [ "app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1983,7 +1991,7 @@ dependencies = [ "crossbeam 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", "dwrote 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.20.8 (registry+https://github.com/rust-lang/crates.io-index)", "font-loader 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "glutin 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2074,6 +2082,7 @@ dependencies = [ "checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef" "checksum atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2fc4a1aa4c24c0718a250f0681885c1af91419d242f29eb8f2ab28502d80dbd1" "checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" +"checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" "checksum backtrace 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)" = "a2eff3830839471718ef8522b9025b399bfb713e25bc220da721364efb660d7d" "checksum backtrace-sys 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)" = "5b3a000b9c543553af61bc01cbfc403b04b5caa9e421033866f2e98061eb3e61" "checksum base64 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "621fc7ecb8008f86d7fb9b95356cd692ce9514b80a86d85b397f32a22da7b9e2" @@ -2118,7 +2127,7 @@ dependencies = [ "checksum dwrote 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0bd1369e02db5e9b842a9b67bce8a2fcc043beafb2ae8a799dd482d46ea1ff0d" "checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0" "checksum env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0e6e40ebb0e66918a37b38c7acab4e10d299e0463fe2af5d29b9cc86710cfd2a" -"checksum euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2c4786521fec183792e755bf32cd0188e4e7628c6d0fcfd51426435b9081a106" +"checksum euclid 0.20.8 (registry+https://github.com/rust-lang/crates.io-index)" = "57d9ae79e19d69ffb5b47b0a744c4215c115dfed4039314c9ca1b8ddc6c333be" "checksum expat-sys 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c470ccb972f2088549b023db8029ed9da9426f5affbf9b62efff7009ab8ed5b1" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" "checksum font-loader 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fd330f40acb3016432cbfa4c54b3d6e6e893a538df79d8df8fd8c26e21c36aaa" @@ -2180,7 +2189,7 @@ dependencies = [ "checksum num-integer 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)" = "6ac0ea58d64a89d9d6b7688031b3be9358d6c919badcf7fbb0527ccfd891ee45" "checksum num-iter 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "af3fdbbc3291a5464dc57b03860ec37ca6bf915ed6ee385e7c6c052c422b2124" "checksum num-rational 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4e96f040177bb3da242b5b1ecf3f54b5d5af3efbbfb18608977a5d2767b22f10" -"checksum num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "775393e285254d2f5004596d69bb8bc1149754570dcc08cf30cabeba67955e28" +"checksum num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096" "checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30" "checksum objc 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "31d20fd2b37e07cf5125be68357b588672e8cefe9a96f8c17a9d46053b3e590d" "checksum opaque-debug 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "51ecbcb821e1bd256d456fe858aaa7f380b63863eab2eb86eee1bd9f33dd6682" diff --git a/servo-tidy.toml b/servo-tidy.toml index b45489f8d5..42f61bdd26 100644 --- a/servo-tidy.toml +++ b/servo-tidy.toml @@ -6,6 +6,7 @@ check-alphabetical-order = false [ignore] # Ignored packages with duplicated versions packages = [ + "autocfg", "core-graphics", "core-text", "gl_generator", diff --git a/webrender/src/device/gl.rs b/webrender/src/device/gl.rs index e239caff74..66d44b0ade 100644 --- a/webrender/src/device/gl.rs +++ b/webrender/src/device/gl.rs @@ -1171,7 +1171,7 @@ pub enum DrawTarget { impl DrawTarget { pub fn new_default(size: DeviceIntSize, surface_origin_is_top_left: bool) -> Self { - let total_size = FramebufferIntSize::from_untyped(size.to_untyped()); + let total_size = device_size_as_framebuffer_size(size); DrawTarget::Default { rect: total_size.into(), total_size, @@ -1212,15 +1212,15 @@ impl DrawTarget { /// Returns the dimensions of this draw-target. pub fn dimensions(&self) -> DeviceIntSize { match *self { - DrawTarget::Default { total_size, .. } => DeviceIntSize::from_untyped(total_size.to_untyped()), + DrawTarget::Default { total_size, .. } => total_size.cast_unit(), DrawTarget::Texture { dimensions, .. } => dimensions, - DrawTarget::External { size, .. } => DeviceIntSize::from_untyped(size.to_untyped()), + DrawTarget::External { size, .. } => size.cast_unit(), DrawTarget::NativeSurface { dimensions, .. } => dimensions, } } pub fn to_framebuffer_rect(&self, device_rect: DeviceIntRect) -> FramebufferIntRect { - let mut fb_rect = FramebufferIntRect::from_untyped(&device_rect.to_untyped()); + let mut fb_rect = device_rect_as_framebuffer_rect(&device_rect); match *self { DrawTarget::Default { ref rect, surface_origin_is_top_left, .. } => { // perform a Y-flip here @@ -1255,16 +1255,16 @@ impl DrawTarget { .unwrap_or_else(FramebufferIntRect::zero) } DrawTarget::NativeSurface { offset, .. } => { - FramebufferIntRect::from_untyped(&scissor_rect.translate(offset.to_vector()).to_untyped()) + device_rect_as_framebuffer_rect(&scissor_rect.translate(offset.to_vector())) } DrawTarget::Texture { .. } | DrawTarget::External { .. } => { - FramebufferIntRect::from_untyped(&scissor_rect.to_untyped()) + device_rect_as_framebuffer_rect(&scissor_rect) } } None => { FramebufferIntRect::new( FramebufferIntPoint::zero(), - FramebufferIntSize::from_untyped(dimensions.to_untyped()), + device_size_as_framebuffer_size(dimensions), ) } } @@ -1891,7 +1891,7 @@ impl Device { DrawTarget::Texture { dimensions, fbo_id, with_depth, .. } => { let rect = FramebufferIntRect::new( FramebufferIntPoint::zero(), - FramebufferIntSize::from_untyped(dimensions.to_untyped()), + device_size_as_framebuffer_size(dimensions), ); (fbo_id, rect, with_depth) }, @@ -1901,10 +1901,7 @@ impl Device { DrawTarget::NativeSurface { external_fbo_id, offset, dimensions, .. } => { ( FBOId(external_fbo_id), - FramebufferIntRect::new( - FramebufferIntPoint::from_untyped(offset.to_untyped()), - FramebufferIntSize::from_untyped(dimensions.to_untyped()), - ), + device_rect_as_framebuffer_rect(&DeviceIntRect::new(offset, dimensions)), true ) } @@ -2332,7 +2329,7 @@ impl Device { } else { let rect = FramebufferIntRect::new( FramebufferIntPoint::zero(), - FramebufferIntSize::from_untyped(src.get_dimensions().to_untyped()), + device_size_as_framebuffer_size(src.get_dimensions()), ); for layer in 0..src.layer_count.min(dst.layer_count) as LayerIndex { self.blit_render_target( diff --git a/webrender/src/glyph_cache.rs b/webrender/src/glyph_cache.rs index e3629b1d23..faa0d768e9 100644 --- a/webrender/src/glyph_cache.rs +++ b/webrender/src/glyph_cache.rs @@ -39,9 +39,7 @@ impl GlyphCacheEntry { GlyphCacheEntry::Cached(ref glyph) => { texture_cache.get_allocated_size(&glyph.texture_cache_handle) } - GlyphCacheEntry::Pending => Some(0), - // If the cache only has blank glyphs left, just get rid of it. - GlyphCacheEntry::Blank => None, + GlyphCacheEntry::Pending | GlyphCacheEntry::Blank => Some(0), } } diff --git a/webrender/src/picture.rs b/webrender/src/picture.rs index 51c55c10a4..4120b203ed 100644 --- a/webrender/src/picture.rs +++ b/webrender/src/picture.rs @@ -106,7 +106,7 @@ use crate::spatial_tree::{ROOT_SPATIAL_NODE_INDEX, use crate::composite::{CompositorKind, CompositeState, NativeSurfaceId, NativeTileId}; use crate::composite::{ExternalSurfaceDescriptor}; use crate::debug_colors; -use euclid::{vec3, Point2D, Scale, Size2D, Vector2D, Rect, Transform3D}; +use euclid::{vec2, vec3, Point2D, Scale, Size2D, Vector2D, Rect, Transform3D, SideOffsets2D}; use euclid::approxeq::ApproxEq; use crate::filterdata::SFilterData; use crate::frame_builder::{FrameBuilderConfig, FrameVisibilityContext, FrameVisibilityState}; @@ -2395,11 +2395,11 @@ impl TileCacheInstance { self.map_local_to_surface = SpaceMapper::new( self.spatial_node_index, - PictureRect::from_untyped(&pic_rect.to_untyped()), + pic_rect, ); self.map_child_pic_to_surface = SpaceMapper::new( self.spatial_node_index, - PictureRect::from_untyped(&pic_rect.to_untyped()), + pic_rect, ); let pic_to_world_mapper = SpaceMapper::new_with_target( @@ -2430,7 +2430,7 @@ impl TileCacheInstance { ); let clip_chain_instance = frame_state.clip_store.build_clip_chain_instance( - LayoutRect::from_untyped(&pic_rect.to_untyped()), + pic_rect.cast_unit(), &self.map_local_to_surface, &pic_to_world_mapper, frame_context.spatial_tree, @@ -4562,7 +4562,7 @@ impl PicturePrimitive { match self.raster_config { Some(ref mut raster_config) => { - let pic_rect = PictureRect::from_untyped(&self.precise_local_rect.to_untyped()); + let pic_rect = self.precise_local_rect.cast_unit(); let mut device_pixel_scale = frame_state .surfaces[raster_config.surface_index.0] @@ -4572,11 +4572,38 @@ impl PicturePrimitive { .surfaces[raster_config.surface_index.0] .scale_factors; + // If the primitive has a filter that can sample with an offset, the clip rect has + // to take it into account. + let clip_inflation = match raster_config.composite_mode { + PictureCompositeMode::Filter(Filter::DropShadows(ref shadows)) => { + let mut max_offset = vec2(0.0, 0.0); + let mut min_offset = vec2(0.0, 0.0); + for shadow in shadows { + let offset = layout_vector_as_picture_vector(shadow.offset); + max_offset = max_offset.max(offset); + min_offset = min_offset.min(offset); + } + + // Get the shadow offsets in world space. + let raster_min = map_pic_to_raster.map_vector(min_offset); + let raster_max = map_pic_to_raster.map_vector(max_offset); + let world_min = map_raster_to_world.map_vector(raster_min); + let world_max = map_raster_to_world.map_vector(raster_max); + + // Grow the clip in the opposite direction of the shadow's offset. + SideOffsets2D::from_vectors_outer( + -world_max.max(vec2(0.0, 0.0)), + -world_min.min(vec2(0.0, 0.0)), + ) + } + _ => SideOffsets2D::zero(), + }; + let (mut clipped, mut unclipped) = match get_raster_rects( pic_rect, &map_pic_to_raster, &map_raster_to_world, - clipped_prim_bounding_rect, + clipped_prim_bounding_rect.outer_rect(clip_inflation), device_pixel_scale, ) { Some(info) => info, @@ -4736,8 +4763,6 @@ impl PicturePrimitive { PictureCompositeMode::Filter(Filter::DropShadows(ref shadows)) => { let mut max_std_deviation = 0.0; for shadow in shadows { - // TODO(nical) presumably we should compute the clipped rect for each shadow - // and compute the union of them to determine what we need to rasterize and blur? max_std_deviation = f32::max(max_std_deviation, shadow.blur_radius); } max_std_deviation = clamp_blur_radius(max_std_deviation, scale_factors) * device_pixel_scale.0; diff --git a/webrender/src/prim_store/mod.rs b/webrender/src/prim_store/mod.rs index 18e15f95ee..c9c16df149 100644 --- a/webrender/src/prim_store/mod.rs +++ b/webrender/src/prim_store/mod.rs @@ -312,7 +312,7 @@ impl SpaceMapper where F: fmt::Debug { pub fn unmap(&self, rect: &Rect) -> Option> { match self.kind { CoordinateSpaceMapping::Local => { - Some(Rect::from_untyped(&rect.to_untyped())) + Some(rect.cast_unit()) } CoordinateSpaceMapping::ScaleOffset(ref scale_offset) => { Some(scale_offset.unmap_rect(rect)) @@ -326,7 +326,7 @@ impl SpaceMapper where F: fmt::Debug { pub fn map(&self, rect: &Rect) -> Option> { match self.kind { CoordinateSpaceMapping::Local => { - Some(Rect::from_untyped(&rect.to_untyped())) + Some(rect.cast_unit()) } CoordinateSpaceMapping::ScaleOffset(ref scale_offset) => { Some(scale_offset.map_rect(rect)) @@ -344,6 +344,20 @@ impl SpaceMapper where F: fmt::Debug { } } } + + pub fn map_vector(&self, v: Vector2D) -> Vector2D { + match self.kind { + CoordinateSpaceMapping::Local => { + v.cast_unit() + } + CoordinateSpaceMapping::ScaleOffset(ref scale_offset) => { + scale_offset.map_vector(&v) + } + CoordinateSpaceMapping::Transform(ref transform) => { + transform.transform_vector2d(v) + } + } + } } /// For external images, it's not possible to know the @@ -1948,7 +1962,7 @@ impl PrimitiveStore { // relative transforms have changed, which means we need to // re-map the dependencies of any child primitives. world_culling_rect = tile_cache.pre_update( - PictureRect::from_untyped(&pic.estimated_local_rect.to_untyped()), + layout_rect_as_picture_rect(&pic.estimated_local_rect), surface_index, frame_context, frame_state, @@ -4216,7 +4230,8 @@ fn get_clipped_device_rect( let unclipped_raster_rect = { let world_rect = *unclipped * Scale::new(1.0); let raster_rect = world_rect * device_pixel_scale.inv(); - Rect::from_untyped(&raster_rect.to_untyped()) + + raster_rect.cast_unit() }; let unclipped_world_rect = map_to_world.map(&unclipped_raster_rect)?; diff --git a/webrender/src/renderer.rs b/webrender/src/renderer.rs index 00c009c597..4f8fb06395 100644 --- a/webrender/src/renderer.rs +++ b/webrender/src/renderer.rs @@ -6054,7 +6054,7 @@ impl Renderer { let texture_rect = FramebufferIntRect::new( FramebufferIntPoint::zero(), - FramebufferIntSize::from_untyped(source_rect.size.to_untyped()), + source_rect.size.cast_unit(), ); debug_renderer.add_rect( @@ -6193,7 +6193,7 @@ impl Renderer { device.clear_target( Some(tag_color), None, - Some(FramebufferIntRect::from_untyped(&tag_rect.to_untyped())), + Some(tag_rect.cast_unit()), ); // Draw the dimensions onto the tag. @@ -6321,7 +6321,7 @@ impl Renderer { pub fn read_gpu_cache(&mut self) -> (DeviceIntSize, Vec) { let texture = self.gpu_cache_texture.texture.as_ref().unwrap(); - let size = FramebufferIntSize::from_untyped(texture.get_dimensions().to_untyped()); + let size = device_size_as_framebuffer_size(texture.get_dimensions()); let mut texels = vec![0; (size.width * size.height * 16) as usize]; self.device.begin_frame(); self.device.bind_read_target(ReadTarget::from_texture(texture, 0)); @@ -6858,7 +6858,7 @@ impl Renderer { // read from textures directly with `get_tex_image*`. for layer_id in 0 .. texture.get_layer_count() { - let rect = FramebufferIntSize::from_untyped(rect_size.to_untyped()).into(); + let rect = device_size_as_framebuffer_size(rect_size).into(); device.attach_read_texture(texture, layer_id); #[cfg(feature = "png")] diff --git a/webrender/src/screen_capture.rs b/webrender/src/screen_capture.rs index 7eaed714f0..5941f4e8c5 100644 --- a/webrender/src/screen_capture.rs +++ b/webrender/src/screen_capture.rs @@ -290,7 +290,7 @@ impl AsyncScreenshotGrabber { let draw_target_rect = draw_target .to_framebuffer_rect(DeviceIntRect::new(DeviceIntPoint::new(0, 0), dest_size)); - let read_target_rect = FramebufferIntRect::from_untyped(&read_target_rect.to_untyped()); + let read_target_rect = device_rect_as_framebuffer_rect(&read_target_rect); if level == 0 && !device.surface_origin_is_top_left() { device.blit_render_target_invert_y( diff --git a/webrender/src/texture_cache.rs b/webrender/src/texture_cache.rs index bf8311ba91..f177c9f491 100644 --- a/webrender/src/texture_cache.rs +++ b/webrender/src/texture_cache.rs @@ -25,7 +25,6 @@ use std::cmp; use std::mem; use std::time::{Duration, SystemTime}; use std::rc::Rc; -use euclid::size2; /// The size of each region/layer in shared cache texture arrays. pub const TEXTURE_REGION_DIMENSIONS: i32 = 512; @@ -62,13 +61,12 @@ enum EntryDetails { /// The layer index of the texture array. layer_index: usize, }, - Empty, } impl EntryDetails { fn describe(&self) -> (LayerIndex, DeviceIntPoint) { match *self { - EntryDetails::Standalone | EntryDetails::Empty => (0, DeviceIntPoint::zero()), + EntryDetails::Standalone => (0, DeviceIntPoint::zero()), EntryDetails::Picture { layer_index, .. } => (layer_index, DeviceIntPoint::zero()), EntryDetails::Cache { origin, layer_index } => (layer_index, origin), } @@ -82,7 +80,6 @@ impl EntryDetails { EntryDetails::Standalone => EntryKind::Standalone, EntryDetails::Picture { .. } => EntryKind::Picture, EntryDetails::Cache { .. } => EntryKind::Shared, - EntryDetails::Empty => EntryKind::Empty, } } } @@ -93,7 +90,6 @@ enum EntryKind { Standalone, Picture, Shared, - Empty, } #[derive(Debug)] @@ -154,24 +150,6 @@ impl CacheEntry { } } - // Create a new entry for a standalone texture. - fn new_empty(last_access: FrameStamp) -> Self { - CacheEntry { - size: size2(0, 0), - user_data: [0.0; 3], - last_access, - details: EntryDetails::Empty, - texture_id: CacheTextureId(std::u64::MAX), - input_format: ImageFormat::BGRA8, - filter: TextureFilter::Linear, - swizzle: Swizzle::default(), - uv_rect_handle: GpuCacheHandle::new(), - eviction_notice: None, - uv_rect_kind: UvRectKind::Rect, - eviction: Eviction::Auto, - } - } - // Update the GPU cache for this texture cache entry. // This ensures that the UV rect, and texture layer index // are up to date in the GPU cache for vertex shaders @@ -499,8 +477,6 @@ struct EntryHandles { picture: Vec>, /// Handles for each shared texture cache entry. shared: Vec>, - /// Handles for each shared texture cache entry. - empty: Vec>, } impl EntryHandles { @@ -510,7 +486,6 @@ impl EntryHandles { EntryKind::Standalone => &mut self.standalone, EntryKind::Picture => &mut self.picture, EntryKind::Shared => &mut self.shared, - EntryKind::Empty => &mut self.empty, } } } @@ -1302,8 +1277,7 @@ impl TextureCache { } region.free(origin, &mut unit.empty_regions); } - EntryDetails::Empty => {} - } + } } /// Check if we can allocate this entry without growing any of the texture cache arrays. @@ -1407,8 +1381,7 @@ impl TextureCache { // case, add support for storing these in a standalone // texture array. if descriptor.size.width > TEXTURE_REGION_DIMENSIONS || - descriptor.size.height > TEXTURE_REGION_DIMENSIONS || - descriptor.size.is_empty_or_negative() + descriptor.size.height > TEXTURE_REGION_DIMENSIONS { allowed_in_shared_cache = false; } @@ -1469,9 +1442,8 @@ impl TextureCache { &mut self, params: &CacheAllocParams, ) -> CacheEntry { - if params.descriptor.size.is_empty_or_negative() { - return CacheEntry::new_empty(self.now); - } + assert!(!params.descriptor.size.is_empty_or_negative()); + // If this image doesn't qualify to go in the shared (batching) cache, // allocate a standalone entry. if self.is_allowed_in_shared_cache(params.filter, ¶ms.descriptor) { @@ -1510,7 +1482,7 @@ impl TextureCache { let (from, to) = match new_kind { EntryKind::Standalone => (&mut self.doc_data.handles.shared, &mut self.doc_data.handles.standalone), - EntryKind::Picture | EntryKind::Empty => unreachable!(), + EntryKind::Picture => unreachable!(), EntryKind::Shared => (&mut self.doc_data.handles.standalone, &mut self.doc_data.handles.shared), }; diff --git a/webrender_api/src/units.rs b/webrender_api/src/units.rs index 00546acd70..1c4f602026 100644 --- a/webrender_api/src/units.rs +++ b/webrender_api/src/units.rs @@ -299,3 +299,25 @@ impl RectExt for Rect { self.max() } } + +// A few helpers to convert to cast between coordinate spaces that are often equivalent. + +#[inline] +pub fn layout_rect_as_picture_rect(layout_rect: &LayoutRect) -> PictureRect { + layout_rect.cast_unit() +} + +#[inline] +pub fn layout_vector_as_picture_vector(layout_vector: LayoutVector2D) -> PictureVector2D { + layout_vector.cast_unit() +} + +#[inline] +pub fn device_size_as_framebuffer_size(framebuffer_size: DeviceIntSize) -> FramebufferIntSize { + framebuffer_size.cast_unit() +} + +#[inline] +pub fn device_rect_as_framebuffer_rect(framebuffer_rect: &DeviceIntRect) -> FramebufferIntRect { + framebuffer_rect.cast_unit() +} diff --git a/wrench/reftests/filters/filter-drop-shadow-clip-3.png b/wrench/reftests/filters/filter-drop-shadow-clip-3.png new file mode 100644 index 0000000000..36ec7216b0 Binary files /dev/null and b/wrench/reftests/filters/filter-drop-shadow-clip-3.png differ diff --git a/wrench/reftests/filters/filter-drop-shadow-clip-3.yaml b/wrench/reftests/filters/filter-drop-shadow-clip-3.yaml new file mode 100644 index 0000000000..8f6552977f --- /dev/null +++ b/wrench/reftests/filters/filter-drop-shadow-clip-3.yaml @@ -0,0 +1,37 @@ +--- +# WebRender internally clips the stacking context to avoid +# rendering parts that are off-screen. It has to take shadow +# offsets into account. +# This test introduces a 90 degrees rotation to ensure that +# the clip inflation isn't done in the wrong space. +root: + items: + # Rotation inside of the shadowed stacking context. + - type: stacking-context + bounds: [0, -10, 200, 100] + filters: drop-shadow([-10, 200], 5, red) + items: + - type: stacking-context + bounds: [50, -10, 200, 100] + transform: rotate-z(90) + items: + - + bounds: [0, 0, 500, 150] + glyphs: [55, 75, 76, 86] + offsets: [0, 100, 75, 100, 150, 100, 180, 100] + size: 90 + color: blue + font: "../text/VeraBd.ttf" + # Rotation applied to the shadowed stacking context directly. + - type: stacking-context + bounds: [150, 35, 200, 100] + filters: drop-shadow([200, 10], 5, red) + transform: rotate-z(90) + items: + - + bounds: [0, 0, 500, 150] + glyphs: [55, 75, 76, 86] + offsets: [0, 100, 75, 100, 150, 100, 180, 100] + size: 90 + color: blue + font: "../text/VeraBd.ttf" diff --git a/wrench/reftests/filters/reftest.list b/wrench/reftests/filters/reftest.list index 0853d8fbc7..97fdcbc675 100644 --- a/wrench/reftests/filters/reftest.list +++ b/wrench/reftests/filters/reftest.list @@ -35,7 +35,8 @@ platform(linux,mac) == filter-drop-shadow.yaml filter-drop-shadow.png platform(linux,mac) == filter-drop-shadow-on-viewport-edge.yaml filter-drop-shadow-on-viewport-edge.png platform(linux,mac) == blend-clipped.yaml blend-clipped.png platform(linux,mac) == filter-drop-shadow-clip.yaml filter-drop-shadow-clip.png -platform(linux,mac) == filter-drop-shadow-clip-2.yaml filter-drop-shadow-clip-2.png +fuzzy(2,10) platform(linux,mac) == filter-drop-shadow-clip-2.yaml filter-drop-shadow-clip-2.png +platform(linux) == filter-drop-shadow-clip-3.yaml filter-drop-shadow-clip-3.png fuzzy(5,100000) == filter-drop-shadow-scaled.yaml filter-drop-shadow-scaled-ref.yaml == filter-segments.yaml filter-segments-ref.yaml == iframe-dropshadow.yaml iframe-dropshadow-ref.yaml