Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync changes from mozilla-central #3819

Merged
merged 2 commits into from Dec 23, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

Bug 1589669 - Fix snapping and rounding errors causing picture cachin…

…g invalidation when zoomed in. r=aosmond,botond

* Fix crash due to shift left causing overflow (debug only)
* Remove rounding of scrolling offsets and snap to view space instead of
world space

Differential Revision: https://phabricator.services.mozilla.com/D57017

[wrupdater] From https://hg.mozilla.org/mozilla-central/rev/6493da33ecacf937e915726cb71f9f1ec3f68da1
  • Loading branch information
Kris Taeleman authored and moz-gfx committed Dec 23, 2019
commit 0974e88ddbdf3cda20abcd0da2669e31ad8346d9
@@ -758,8 +758,8 @@ impl Tile {

// Determine if the fractional offset of the transform is different this frame
// from the currently cached tile set.
let fract_changed = (self.fract_offset.x - ctx.fract_offset.x).abs() > 0.001 ||
(self.fract_offset.y - ctx.fract_offset.y).abs() > 0.001;
let fract_changed = (self.fract_offset.x - ctx.fract_offset.x).abs() > 0.01 ||
(self.fract_offset.y - ctx.fract_offset.y).abs() > 0.01;
if fract_changed {
self.invalidate(None, InvalidationReason::FractionalOffset);
self.fract_offset = ctx.fract_offset;
@@ -3245,9 +3245,9 @@ impl PicturePrimitive {

// Round the scale up to the nearest power of 2, but don't exceed 8.
let scale = scale_factors.0.max(scale_factors.1).min(8.0);
let rounded_up = 1 << scale.log2().ceil() as u32;
let rounded_up = 2.0f32.powf(scale.log2().ceil());

RasterSpace::Local(rounded_up as f32)
RasterSpace::Local(rounded_up)
} else {
self.requested_raster_space
}
@@ -7,9 +7,9 @@ use api::{ExternalScrollId, PipelineId, PropertyBinding, PropertyBindingId, Refe
use api::{TransformStyle, ScrollSensitivity, StickyOffsetBounds};
use api::units::*;
use crate::clip_scroll_tree::{CoordinateSystem, CoordinateSystemId, SpatialNodeIndex, TransformUpdateState};
use euclid::{Scale, SideOffsets2D};
use euclid::{Point2D, Vector2D, SideOffsets2D};
use crate::scene::SceneProperties;
use crate::util::{LayoutFastTransform, MatrixHelpers, ScaleOffset, TransformedRectKind, VectorHelpers};
use crate::util::{LayoutFastTransform, MatrixHelpers, ScaleOffset, TransformedRectKind, PointHelpers};

#[derive(Clone, Debug)]
pub enum SpatialNodeType {
@@ -113,14 +113,18 @@ fn compute_offset_from(
/// where snapping is not important (e.g. has perspective or is not axis
/// aligned), or an edge case (e.g. SVG filters) which we can accept
/// imperfection for now.
fn snap_offset(
offset: LayoutVector2D,
fn snap_offset<OffsetUnits, ScaleUnits>(
offset: Vector2D<f32, OffsetUnits>,
scale: Vector2D<f32, ScaleUnits>,
global_device_pixel_scale: DevicePixelScale,
) -> LayoutVector2D {
let world_offset = offset * Scale::new(1.0);
) -> Vector2D<f32, OffsetUnits> {

debug_assert!(scale.x != 0.0 && scale.y != 0.0);

let world_offset = Point2D::new(offset.x * scale.x, offset.y * scale.y);
let snapped_device_offset = (world_offset * global_device_pixel_scale).snap();
let snapped_world_offset = snapped_device_offset / global_device_pixel_scale;
snapped_world_offset * Scale::new(1.0)
Vector2D::new(snapped_world_offset.x / scale.x, snapped_world_offset.y / scale.y)
}

impl SpatialNode {
@@ -234,8 +238,8 @@ impl SpatialNode {

let origin = LayoutPoint::new(origin.x.max(0.0), origin.y.max(0.0));
LayoutVector2D::new(
(-origin.x).max(-scrollable_width).min(0.0).round(),
(-origin.y).max(-scrollable_height).min(0.0).round(),
(-origin.x).max(-scrollable_width).min(0.0),
(-origin.y).max(-scrollable_height).min(0.0),
)
}
ScrollClamping::NoClamping => LayoutPoint::zero() - *origin,
@@ -349,7 +353,7 @@ impl SpatialNode {
// between our reference frame and this node. Finally, we also include
// whatever local transformation this reference frame provides.
let relative_transform = resolved_transform
.post_translate(snap_offset(state.parent_accumulated_scroll_offset, global_device_pixel_scale))
.post_translate(snap_offset(state.parent_accumulated_scroll_offset, state.coordinate_system_relative_scale_offset.scale, global_device_pixel_scale))
.to_transform()
.with_destination::<LayoutPixel>();

@@ -424,13 +428,13 @@ impl SpatialNode {
// provided by our own sticky positioning.
let accumulated_offset = state.parent_accumulated_scroll_offset + sticky_offset;
self.viewport_transform = state.coordinate_system_relative_scale_offset
.offset(snap_offset(accumulated_offset, global_device_pixel_scale).to_untyped());
.offset(snap_offset(accumulated_offset, state.coordinate_system_relative_scale_offset.scale, global_device_pixel_scale).to_untyped());

// The transformation for any content inside of us is the viewport transformation, plus
// whatever scrolling offset we supply as well.
let added_offset = accumulated_offset + self.scroll_offset();
self.content_transform = state.coordinate_system_relative_scale_offset
.offset(snap_offset(added_offset, global_device_pixel_scale).to_untyped());
.offset(snap_offset(added_offset, state.coordinate_system_relative_scale_offset.scale, global_device_pixel_scale).to_untyped());

if let SpatialNodeType::StickyFrame(ref mut info) = self.node_type {
info.current_offset = sticky_offset;
@@ -631,15 +635,13 @@ impl SpatialNode {
if scrollable_width > 0. {
scrolling.offset.x = (scrolling.offset.x + delta.x)
.min(0.0)
.max(-scrollable_width)
.round();
.max(-scrollable_width);
}

if scrollable_height > 0. {
scrolling.offset.y = (scrolling.offset.y + delta.y)
.min(0.0)
.max(-scrollable_height)
.round();
.max(-scrollable_height);
}

scrolling.offset != original_layer_scroll_offset
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.