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 #3830

Merged
merged 2 commits into from Jan 13, 2020
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

Backed out changeset 7295ca89e880 (bug 1608280) for causing bug 16089…

  • Loading branch information
AndreeaPavel authored and moz-gfx committed Jan 13, 2020
commit ad7c3f8fcf171b5f98761a9b6d346621348b9c55
@@ -122,16 +122,6 @@ pub enum CompositorKind {
},
}

impl CompositorKind {
/// Returns true if this compositor is native (uses OS compositor)
pub fn is_native(&self) -> bool {
match self {
CompositorKind::Draw { .. } => false,
CompositorKind::Native { .. } => true,
}
}
}

impl Default for CompositorKind {
/// Default compositor config is full present without partial present.
fn default() -> Self {
@@ -311,17 +301,8 @@ impl CompositeState {

let device_rect = (tile.world_rect * global_device_pixel_scale).round();
let dirty_rect = (tile.world_dirty_rect * global_device_pixel_scale).round();
let valid_rect = (tile.world_valid_rect * global_device_pixel_scale).round_out();
let surface = tile.surface.as_ref().expect("no tile surface set!");

// When compositing in simple (draw) mode, each tile only needs to write pixels
// where (a) the valid region of the tile is and (b) the overall clip rect of
// the picture cache surface.
let clip_rect = match valid_rect.intersection(&device_clip_rect) {
Some(clip_rect) => clip_rect,
None => continue,
};

let (surface, is_opaque) = match surface {
TileSurface::Color { color } => {
(CompositeTileSurface::Color { color: *color }, true)
@@ -342,7 +323,7 @@ impl CompositeState {
surface,
rect: device_rect,
dirty_rect,
clip_rect,
clip_rect: device_clip_rect,
z_id,
tile_id: tile.id,
};
@@ -338,6 +338,12 @@ pub struct SpatialNodeDependency {

// Immutable context passed to picture cache tiles during pre_update
struct TilePreUpdateContext {
/// The local rect of the overall picture cache
local_rect: PictureRect,

/// The local clip rect (in picture space) of the entire picture cache
local_clip_rect: PictureRect,

/// Maps from picture cache coords -> world space coords.
pic_to_world_mapper: SpaceMapper<PicturePixel, WorldPixel>,

@@ -350,19 +356,10 @@ struct TilePreUpdateContext {

/// The visible part of the screen in world coords.
global_screen_world_rect: WorldRect,

/// The current compositing mode.
compositor_kind: CompositorKind,
}

// Immutable context passed to picture cache tiles during post_update
struct TilePostUpdateContext<'a> {
/// The local rect of the overall picture cache
local_rect: PictureRect,

/// The local clip rect (in picture space) of the entire picture cache
local_clip_rect: PictureRect,

/// The calculated backdrop information for this cache instance.
backdrop: BackdropInfo,

@@ -579,10 +576,8 @@ pub struct Tile {
pub world_rect: WorldRect,
/// The current local rect of this tile.
pub rect: PictureRect,
/// The valid region of this tile (parts of the tile affected by primitives).
pub valid_rect: PictureRect,
/// The world-space valid region of this tile.
pub world_valid_rect: WorldRect,
/// The local rect of the tile clipped to the overall picture local rect.
clipped_rect: PictureRect,
/// Uniquely describes the content of this tile, in a way that can be
/// (reasonably) efficiently hashed and compared.
pub current_descriptor: TileDescriptor,
@@ -628,8 +623,7 @@ impl Tile {
) -> Self {
Tile {
rect: PictureRect::zero(),
valid_rect: PictureRect::zero(),
world_valid_rect: WorldRect::zero(),
clipped_rect: PictureRect::zero(),
world_rect: WorldRect::zero(),
surface: None,
current_descriptor: TileDescriptor::new(),
@@ -745,6 +739,11 @@ impl Tile {
self.rect = rect;
self.invalidation_reason = None;

self.clipped_rect = self.rect
.intersection(&ctx.local_rect)
.and_then(|r| r.intersection(&ctx.local_clip_rect))
.unwrap_or_else(PictureRect::zero);

self.world_rect = ctx.pic_to_world_mapper
.map(&self.rect)
.expect("bug: map local tile rect");
@@ -781,20 +780,6 @@ impl Tile {
);
self.current_descriptor.clear();
self.root.clear(rect);

// Reset which part of the tile contains valid primitives. If the tile
// has a background color, the entire primitive must always be drawn
// composited. Otherwise, we will update the valid region of the tile
// during `add_prim_dependency`. For now, this optimization only applies
// to Draw compositor kinds - native compositors will be implemented
// as a follow up.
let has_background_color = self.background_color.is_some();
let is_native_compositor = ctx.compositor_kind.is_native();
self.valid_rect = if has_background_color || is_native_compositor {
self.rect
} else {
PictureRect::zero()
};
}

/// Add dependencies for a given primitive to this tile.
@@ -808,9 +793,6 @@ impl Tile {
return;
}

// Update the picture space valid region of this tile.
self.valid_rect = self.valid_rect.union(&info.prim_clip_rect);

// Include any image keys this tile depends on.
self.current_descriptor.images.extend_from_slice(&info.images);

@@ -916,12 +898,7 @@ impl Tile {
// Check if this tile can be considered opaque. Opacity state must be updated only
// after all early out checks have been performed. Otherwise, we might miss updating
// the native surface next time this tile becomes visible.
let clipped_rect = self.rect
.intersection(&ctx.local_rect)
.and_then(|r| r.intersection(&ctx.local_clip_rect))
.and_then(|r| r.intersection(&self.valid_rect))
.unwrap_or_else(PictureRect::zero);
self.is_opaque = ctx.backdrop.rect.contains_rect(&clipped_rect);
self.is_opaque = ctx.backdrop.rect.contains_rect(&self.clipped_rect);

// Check if the selected composite mode supports dirty rect updates. For Draw composite
// mode, we can always update the content with smaller dirty rects. For native composite
@@ -1878,11 +1855,12 @@ impl TileCacheInstance {
mem::swap(&mut self.tiles, &mut self.old_tiles);

let ctx = TilePreUpdateContext {
local_rect: self.local_rect,
local_clip_rect: self.local_clip_rect,
pic_to_world_mapper,
fract_offset: self.fract_offset,
background_color: self.background_color,
global_screen_world_rect: frame_context.global_screen_world_rect,
compositor_kind: frame_state.composite_state.compositor_kind,
};

self.tiles.clear();
@@ -2346,8 +2324,6 @@ impl TileCacheInstance {
}

let ctx = TilePostUpdateContext {
local_rect: self.local_rect,
local_clip_rect: self.local_clip_rect,
backdrop: self.backdrop,
spatial_nodes: &self.spatial_nodes,
opacity_bindings: &self.opacity_bindings,
@@ -3677,7 +3653,6 @@ impl PicturePrimitive {
tile.root.draw_debug_rects(
&map_pic_to_world,
tile.is_opaque,
&tile.valid_rect,
scratch,
frame_context.global_device_pixel_scale,
);
@@ -3729,9 +3704,8 @@ impl PicturePrimitive {
}
}

// Update the world space dirty and valid rects
// Update the world dirty rect
tile.world_dirty_rect = map_pic_to_world.map(&tile.dirty_rect).expect("bug");
tile.world_valid_rect = map_pic_to_world.map(&tile.valid_rect).expect("bug");

if tile.is_valid {
continue;
@@ -3810,28 +3784,15 @@ impl PicturePrimitive {

// Get a task-local scissor rect for the dirty region of this
// picture cache task.
let dirty_rect = tile.world_dirty_rect
.translate(-tile.world_rect.origin.to_vector());
let dirty_rect = (dirty_rect * device_pixel_scale).round();

// The valid rect isn't guaranteed to be aligned to the device pixel
// grid. To ensure we don't skip any valid pixels, round this out, and
// then intersect it with the dirty rect (which _is_ device pixel
// aligned) below when creating the true scissor rect.
let valid_rect = tile.world_valid_rect
.translate(-tile.world_rect.origin.to_vector());
let valid_rect = (valid_rect * device_pixel_scale).round_out();

let scissor_rect = tile.world_dirty_rect.translate(
-tile.world_rect.origin.to_vector()
);
// The world rect is guaranteed to be device pixel aligned, by the tile
// sizing code in tile::pre_update. However, there might be some
// small floating point accuracy issues (these were observed on ARM
// CPUs). Round the rect here before casting to integer device pixels
// to ensure the scissor rect is correct.
let scissor_rect = dirty_rect
.intersection(&valid_rect)
.unwrap_or(DeviceRect::zero())
.round();

let scissor_rect = (scissor_rect * device_pixel_scale).round();
let surface = descriptor.resolve(
frame_state.resource_cache,
tile_cache.current_tile_size,
@@ -4920,7 +4881,6 @@ impl TileNode {
&self,
pic_to_world_mapper: &SpaceMapper<PicturePixel, WorldPixel>,
is_opaque: bool,
valid_rect: &PictureRect,
scratch: &mut PrimitiveScratchBuffer,
global_device_pixel_scale: DevicePixelScale,
) {
@@ -4934,26 +4894,22 @@ impl TileNode {
debug_colors::YELLOW
};

let local_rect = self.rect.intersection(valid_rect);
if let Some(local_rect) = local_rect {
let world_rect = pic_to_world_mapper.map(&local_rect).unwrap();
let device_rect = world_rect * global_device_pixel_scale;

let outer_color = color.scale_alpha(0.3);
let inner_color = outer_color.scale_alpha(0.5);
scratch.push_debug_rect(
device_rect.inflate(-3.0, -3.0),
outer_color,
inner_color
);
}
let world_rect = pic_to_world_mapper.map(&self.rect).unwrap();
let device_rect = world_rect * global_device_pixel_scale;

let outer_color = color.scale_alpha(0.3);
let inner_color = outer_color.scale_alpha(0.5);
scratch.push_debug_rect(
device_rect.inflate(-3.0, -3.0),
outer_color,
inner_color
);
}
TileNodeKind::Node { ref children, .. } => {
for child in children.iter() {
child.draw_debug_rects(
pic_to_world_mapper,
is_opaque,
valid_rect,
scratch,
global_device_pixel_scale,
);
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.