forked from mirrors/gecko-dev
Backed out changeset d4b3fe2e03c6 (bug 1898621) for wrench failures. CLOSED TREE
This commit is contained in:
parent
cf6f135372
commit
a1aa176cc4
4 changed files with 169 additions and 232 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -6600,7 +6600,6 @@ dependencies = [
|
||||||
"ron",
|
"ron",
|
||||||
"serde",
|
"serde",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"static_prefs",
|
|
||||||
"svg_fmt",
|
"svg_fmt",
|
||||||
"swgl",
|
"swgl",
|
||||||
"time 0.1.45",
|
"time 0.1.45",
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,6 @@ firefox-on-glean = { version = "0.1.0", optional = true }
|
||||||
swgl = { path = "../swgl", optional = true }
|
swgl = { path = "../swgl", optional = true }
|
||||||
topological-sort = "0.1"
|
topological-sort = "0.1"
|
||||||
peek-poke = { version = "0.3", path = "../peek-poke" }
|
peek-poke = { version = "0.3", path = "../peek-poke" }
|
||||||
static_prefs = { path = "../../../modules/libpref/init/static_prefs" }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
mozangle = "0.3.3"
|
mozangle = "0.3.3"
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,6 @@ use crate::spatial_tree::CoordinateSystemId;
|
||||||
use crate::surface::{SurfaceDescriptor, SurfaceTileDescriptor};
|
use crate::surface::{SurfaceDescriptor, SurfaceTileDescriptor};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::{mem, u8, marker, u32};
|
use std::{mem, u8, marker, u32};
|
||||||
use std::fmt::{Display, Error, Formatter};
|
|
||||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||||
use std::collections::hash_map::Entry;
|
use std::collections::hash_map::Entry;
|
||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
|
|
@ -1864,54 +1863,9 @@ pub struct TileCacheInstance {
|
||||||
pub yuv_images_remaining: usize,
|
pub yuv_images_remaining: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
enum SurfacePromotionResult {
|
||||||
enum SurfacePromotionFailure {
|
Failed,
|
||||||
ImageWaitingOnYuvImage,
|
Success,
|
||||||
NotPremultipliedAlpha,
|
|
||||||
OverlaySurfaceLimit,
|
|
||||||
OverlayNeedsMask,
|
|
||||||
UnderlayAlphaBackdrop,
|
|
||||||
UnderlaySurfaceLimit,
|
|
||||||
UnderlayIntersectsOverlay,
|
|
||||||
NotRootTileCache,
|
|
||||||
ComplexTransform,
|
|
||||||
SliceAtomic,
|
|
||||||
SizeTooLarge,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Display for SurfacePromotionFailure {
|
|
||||||
fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
|
|
||||||
write!(
|
|
||||||
f,
|
|
||||||
"{}",
|
|
||||||
match *self {
|
|
||||||
SurfacePromotionFailure::ImageWaitingOnYuvImage => "Image prim waiting for all YuvImage prims to be considered for promotion",
|
|
||||||
SurfacePromotionFailure::NotPremultipliedAlpha => "does not use premultiplied alpha",
|
|
||||||
SurfacePromotionFailure::OverlaySurfaceLimit => "hit the overlay surface limit",
|
|
||||||
SurfacePromotionFailure::OverlayNeedsMask => "overlay not allowed for prim with mask",
|
|
||||||
SurfacePromotionFailure::UnderlayAlphaBackdrop => "underlay requires an opaque backdrop",
|
|
||||||
SurfacePromotionFailure::UnderlaySurfaceLimit => "hit the underlay surface limit",
|
|
||||||
SurfacePromotionFailure::UnderlayIntersectsOverlay => "underlay intersects already-promoted overlay",
|
|
||||||
SurfacePromotionFailure::NotRootTileCache => "is not on a root tile cache",
|
|
||||||
SurfacePromotionFailure::ComplexTransform => "has a complex transform",
|
|
||||||
SurfacePromotionFailure::SliceAtomic => "slice is atomic",
|
|
||||||
SurfacePromotionFailure::SizeTooLarge => "surface is too large for compositor",
|
|
||||||
}.to_owned()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn maybe_report_promotion_failure(result: Result<CompositorSurfaceKind, SurfacePromotionFailure>,
|
|
||||||
rect: PictureRect,
|
|
||||||
reported: &mut bool) {
|
|
||||||
if !static_prefs::pref!("gfx.webrender.compositor.surface-promotion.logging") || result.is_ok() || *reported {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Report this as a warning.
|
|
||||||
// TODO: Find a way to expose this to web authors.
|
|
||||||
warn!("Surface promotion of prim at {:?} failed with: {}.", rect, result.unwrap_err());
|
|
||||||
*reported = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TileCacheInstance {
|
impl TileCacheInstance {
|
||||||
|
|
@ -2519,6 +2473,7 @@ impl TileCacheInstance {
|
||||||
|
|
||||||
fn can_promote_to_surface(
|
fn can_promote_to_surface(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
flags: PrimitiveFlags,
|
||||||
prim_clip_chain: &ClipChainInstance,
|
prim_clip_chain: &ClipChainInstance,
|
||||||
prim_spatial_node_index: SpatialNodeIndex,
|
prim_spatial_node_index: SpatialNodeIndex,
|
||||||
is_root_tile_cache: bool,
|
is_root_tile_cache: bool,
|
||||||
|
|
@ -2526,8 +2481,11 @@ impl TileCacheInstance {
|
||||||
surface_kind: CompositorSurfaceKind,
|
surface_kind: CompositorSurfaceKind,
|
||||||
pic_coverage_rect: PictureRect,
|
pic_coverage_rect: PictureRect,
|
||||||
frame_context: &FrameVisibilityContext,
|
frame_context: &FrameVisibilityContext,
|
||||||
) -> Result<CompositorSurfaceKind, SurfacePromotionFailure> {
|
) -> SurfacePromotionResult {
|
||||||
use crate::picture::SurfacePromotionFailure::*;
|
// Check if this primitive _wants_ to be promoted to a compositor surface.
|
||||||
|
if !flags.contains(PrimitiveFlags::PREFER_COMPOSITOR_SURFACE) {
|
||||||
|
return SurfacePromotionResult::Failed;
|
||||||
|
}
|
||||||
|
|
||||||
// Each strategy has different restrictions on whether we can promote
|
// Each strategy has different restrictions on whether we can promote
|
||||||
match surface_kind {
|
match surface_kind {
|
||||||
|
|
@ -2536,33 +2494,26 @@ impl TileCacheInstance {
|
||||||
// Non-opaque compositor surfaces require sub-slices, as they are drawn
|
// Non-opaque compositor surfaces require sub-slices, as they are drawn
|
||||||
// as overlays.
|
// as overlays.
|
||||||
if sub_slice_index == self.sub_slices.len() - 1 {
|
if sub_slice_index == self.sub_slices.len() - 1 {
|
||||||
return Err(OverlaySurfaceLimit);
|
return SurfacePromotionResult::Failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a complex clip is being applied to this primitive, it can't be
|
// If a complex clip is being applied to this primitive, it can't be
|
||||||
// promoted directly to a compositor surface.
|
// promoted directly to a compositor surface.
|
||||||
if prim_clip_chain.needs_mask {
|
if prim_clip_chain.needs_mask {
|
||||||
return Err(OverlayNeedsMask);
|
return SurfacePromotionResult::Failed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CompositorSurfaceKind::Underlay => {
|
CompositorSurfaceKind::Underlay => {
|
||||||
// If a mask is needed, there are some restrictions.
|
// Underlay strategy relies on the slice being opaque if a mask is needed,
|
||||||
if prim_clip_chain.needs_mask {
|
// and only one underlay can rely on a mask.
|
||||||
// Need an opaque backdrop.
|
if prim_clip_chain.needs_mask && (self.backdrop.kind.is_none() || !self.underlays.is_empty()) {
|
||||||
if self.backdrop.kind.is_none() {
|
return SurfacePromotionResult::Failed;
|
||||||
return Err(UnderlayAlphaBackdrop);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only one masked underlay allowed.
|
|
||||||
if !self.underlays.is_empty() {
|
|
||||||
return Err(UnderlaySurfaceLimit);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Underlays can't appear on top of overlays, because they can't punch
|
// Underlays can't appear on top of overlays, because they can't punch
|
||||||
// through the existing overlay.
|
// through the existing overlay.
|
||||||
if self.overlay_region.intersects(&pic_coverage_rect) {
|
if self.overlay_region.intersects(&pic_coverage_rect) {
|
||||||
return Err(UnderlayIntersectsOverlay);
|
return SurfacePromotionResult::Failed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CompositorSurfaceKind::Blit => unreachable!(),
|
CompositorSurfaceKind::Blit => unreachable!(),
|
||||||
|
|
@ -2571,7 +2522,7 @@ impl TileCacheInstance {
|
||||||
// If not on the root picture cache, it has some kind of
|
// If not on the root picture cache, it has some kind of
|
||||||
// complex effect (such as a filter, mix-blend-mode or 3d transform).
|
// complex effect (such as a filter, mix-blend-mode or 3d transform).
|
||||||
if !is_root_tile_cache {
|
if !is_root_tile_cache {
|
||||||
return Err(NotRootTileCache);
|
return SurfacePromotionResult::Failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mapper : SpaceMapper<PicturePixel, WorldPixel> = SpaceMapper::new_with_target(
|
let mapper : SpaceMapper<PicturePixel, WorldPixel> = SpaceMapper::new_with_target(
|
||||||
|
|
@ -2581,14 +2532,14 @@ impl TileCacheInstance {
|
||||||
&frame_context.spatial_tree);
|
&frame_context.spatial_tree);
|
||||||
let transform = mapper.get_transform();
|
let transform = mapper.get_transform();
|
||||||
if !transform.is_2d_scale_translation() {
|
if !transform.is_2d_scale_translation() {
|
||||||
return Err(ComplexTransform);
|
return SurfacePromotionResult::Failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.slice_flags.contains(SliceFlags::IS_ATOMIC) {
|
if self.slice_flags.contains(SliceFlags::IS_ATOMIC) {
|
||||||
return Err(SliceAtomic);
|
return SurfacePromotionResult::Failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(surface_kind)
|
SurfacePromotionResult::Success
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup_compositor_surfaces_yuv(
|
fn setup_compositor_surfaces_yuv(
|
||||||
|
|
@ -2610,7 +2561,7 @@ impl TileCacheInstance {
|
||||||
color_space: YuvRangedColorSpace,
|
color_space: YuvRangedColorSpace,
|
||||||
format: YuvFormat,
|
format: YuvFormat,
|
||||||
surface_kind: CompositorSurfaceKind,
|
surface_kind: CompositorSurfaceKind,
|
||||||
) -> Result<CompositorSurfaceKind, SurfacePromotionFailure> {
|
) -> bool {
|
||||||
for &key in api_keys {
|
for &key in api_keys {
|
||||||
if key != ImageKey::DUMMY {
|
if key != ImageKey::DUMMY {
|
||||||
// TODO: See comment in setup_compositor_surfaces_rgb.
|
// TODO: See comment in setup_compositor_surfaces_rgb.
|
||||||
|
|
@ -2664,7 +2615,7 @@ impl TileCacheInstance {
|
||||||
image_rendering: ImageRendering,
|
image_rendering: ImageRendering,
|
||||||
is_opaque: bool,
|
is_opaque: bool,
|
||||||
surface_kind: CompositorSurfaceKind,
|
surface_kind: CompositorSurfaceKind,
|
||||||
) -> Result<CompositorSurfaceKind, SurfacePromotionFailure> {
|
) -> bool {
|
||||||
let mut api_keys = [ImageKey::DUMMY; 3];
|
let mut api_keys = [ImageKey::DUMMY; 3];
|
||||||
api_keys[0] = api_key;
|
api_keys[0] = api_key;
|
||||||
|
|
||||||
|
|
@ -2720,9 +2671,7 @@ impl TileCacheInstance {
|
||||||
image_rendering: ImageRendering,
|
image_rendering: ImageRendering,
|
||||||
is_opaque: bool,
|
is_opaque: bool,
|
||||||
surface_kind: CompositorSurfaceKind,
|
surface_kind: CompositorSurfaceKind,
|
||||||
) -> Result<CompositorSurfaceKind, SurfacePromotionFailure> {
|
) -> bool {
|
||||||
use crate::picture::SurfacePromotionFailure::*;
|
|
||||||
|
|
||||||
let map_local_to_picture = SpaceMapper::new_with_target(
|
let map_local_to_picture = SpaceMapper::new_with_target(
|
||||||
self.spatial_node_index,
|
self.spatial_node_index,
|
||||||
prim_spatial_node_index,
|
prim_spatial_node_index,
|
||||||
|
|
@ -2733,12 +2682,12 @@ impl TileCacheInstance {
|
||||||
// Map the primitive local rect into picture space.
|
// Map the primitive local rect into picture space.
|
||||||
let prim_rect = match map_local_to_picture.map(&local_prim_rect) {
|
let prim_rect = match map_local_to_picture.map(&local_prim_rect) {
|
||||||
Some(rect) => rect,
|
Some(rect) => rect,
|
||||||
None => return Ok(surface_kind),
|
None => return true,
|
||||||
};
|
};
|
||||||
|
|
||||||
// If the rect is invalid, no need to create dependencies.
|
// If the rect is invalid, no need to create dependencies.
|
||||||
if prim_rect.is_empty() {
|
if prim_rect.is_empty() {
|
||||||
return Ok(surface_kind);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let pic_to_world_mapper = SpaceMapper::new_with_target(
|
let pic_to_world_mapper = SpaceMapper::new_with_target(
|
||||||
|
|
@ -2754,7 +2703,7 @@ impl TileCacheInstance {
|
||||||
|
|
||||||
let is_visible = world_clip_rect.intersects(&frame_context.global_screen_world_rect);
|
let is_visible = world_clip_rect.intersects(&frame_context.global_screen_world_rect);
|
||||||
if !is_visible {
|
if !is_visible {
|
||||||
return Ok(surface_kind);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let prim_offset = ScaleOffset::from_offset(local_prim_rect.min.to_vector().cast_unit());
|
let prim_offset = ScaleOffset::from_offset(local_prim_rect.min.to_vector().cast_unit());
|
||||||
|
|
@ -2806,7 +2755,7 @@ impl TileCacheInstance {
|
||||||
|
|
||||||
if surface_size.width >= MAX_COMPOSITOR_SURFACES_SIZE ||
|
if surface_size.width >= MAX_COMPOSITOR_SURFACES_SIZE ||
|
||||||
surface_size.height >= MAX_COMPOSITOR_SURFACES_SIZE {
|
surface_size.height >= MAX_COMPOSITOR_SURFACES_SIZE {
|
||||||
return Err(SizeTooLarge);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// When using native compositing, we need to find an existing native surface
|
// When using native compositing, we need to find an existing native surface
|
||||||
|
|
@ -2944,7 +2893,7 @@ impl TileCacheInstance {
|
||||||
CompositorSurfaceKind::Blit => unreachable!(),
|
CompositorSurfaceKind::Blit => unreachable!(),
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(surface_kind)
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Push an estimated rect for an off-screen surface during dependency updates. This is
|
/// Push an estimated rect for an off-screen surface during dependency updates. This is
|
||||||
|
|
@ -3015,8 +2964,6 @@ impl TileCacheInstance {
|
||||||
is_root_tile_cache: bool,
|
is_root_tile_cache: bool,
|
||||||
surfaces: &mut [SurfaceInfo],
|
surfaces: &mut [SurfaceInfo],
|
||||||
) {
|
) {
|
||||||
use crate::picture::SurfacePromotionFailure::*;
|
|
||||||
|
|
||||||
// This primitive exists on the last element on the current surface stack.
|
// This primitive exists on the last element on the current surface stack.
|
||||||
profile_scope!("update_prim_dependencies");
|
profile_scope!("update_prim_dependencies");
|
||||||
let prim_surface_index = surface_stack.last().unwrap().1;
|
let prim_surface_index = surface_stack.last().unwrap().1;
|
||||||
|
|
@ -3156,8 +3103,6 @@ impl TileCacheInstance {
|
||||||
// rect eventually means it doesn't affect that tile).
|
// rect eventually means it doesn't affect that tile).
|
||||||
// TODO(gw): Get picture clips earlier (during the initial picture traversal
|
// TODO(gw): Get picture clips earlier (during the initial picture traversal
|
||||||
// pass) so that we can calculate these correctly.
|
// pass) so that we can calculate these correctly.
|
||||||
let mut promotion_result: Result<CompositorSurfaceKind, SurfacePromotionFailure> = Ok(CompositorSurfaceKind::Blit);
|
|
||||||
let mut promotion_failure_reported = false;
|
|
||||||
match prim_instance.kind {
|
match prim_instance.kind {
|
||||||
PrimitiveInstanceKind::Picture { pic_index,.. } => {
|
PrimitiveInstanceKind::Picture { pic_index,.. } => {
|
||||||
// Pictures can depend on animated opacity bindings.
|
// Pictures can depend on animated opacity bindings.
|
||||||
|
|
@ -3220,61 +3165,63 @@ impl TileCacheInstance {
|
||||||
is_opaque = image_properties.descriptor.is_opaque();
|
is_opaque = image_properties.descriptor.is_opaque();
|
||||||
}
|
}
|
||||||
|
|
||||||
if image_key.common.flags.contains(PrimitiveFlags::PREFER_COMPOSITOR_SURFACE) {
|
let mut promote_to_surface = false;
|
||||||
// Only consider promoting Images if all of our YuvImages have been
|
|
||||||
// processed (whether they were promoted or not).
|
// Only consider promoting Images if all of our YuvImages have been
|
||||||
if self.yuv_images_remaining > 0 {
|
// processed (whether they were promoted or not).
|
||||||
promotion_result = Err(ImageWaitingOnYuvImage);
|
if self.yuv_images_remaining == 0 {
|
||||||
} else {
|
match self.can_promote_to_surface(image_key.common.flags,
|
||||||
promotion_result = self.can_promote_to_surface(prim_clip_chain,
|
prim_clip_chain,
|
||||||
prim_spatial_node_index,
|
prim_spatial_node_index,
|
||||||
is_root_tile_cache,
|
is_root_tile_cache,
|
||||||
sub_slice_index,
|
sub_slice_index,
|
||||||
CompositorSurfaceKind::Overlay,
|
CompositorSurfaceKind::Overlay,
|
||||||
pic_coverage_rect,
|
pic_coverage_rect,
|
||||||
frame_context);
|
frame_context) {
|
||||||
}
|
SurfacePromotionResult::Failed => {
|
||||||
|
}
|
||||||
// Native OS compositors (DC and CA, at least) support premultiplied alpha
|
SurfacePromotionResult::Success => {
|
||||||
// only. If we have an image that's not pre-multiplied alpha, we can't promote it.
|
promote_to_surface = true;
|
||||||
if image_data.alpha_type == AlphaType::Alpha {
|
}
|
||||||
promotion_result = Err(NotPremultipliedAlpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Ok(kind) = promotion_result {
|
|
||||||
promotion_result = self.setup_compositor_surfaces_rgb(
|
|
||||||
sub_slice_index,
|
|
||||||
&mut prim_info,
|
|
||||||
image_key.common.flags,
|
|
||||||
local_prim_rect,
|
|
||||||
prim_spatial_node_index,
|
|
||||||
pic_coverage_rect,
|
|
||||||
frame_context,
|
|
||||||
ImageDependency {
|
|
||||||
key: image_data.key,
|
|
||||||
generation: resource_cache.get_image_generation(image_data.key),
|
|
||||||
},
|
|
||||||
image_data.key,
|
|
||||||
resource_cache,
|
|
||||||
composite_state,
|
|
||||||
gpu_cache,
|
|
||||||
image_data.image_rendering,
|
|
||||||
is_opaque,
|
|
||||||
kind,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(kind) = promotion_result {
|
// Native OS compositors (DC and CA, at least) support premultiplied alpha
|
||||||
*compositor_surface_kind = kind;
|
// only. If we have an image that's not pre-multiplied alpha, we can't promote it.
|
||||||
|
if image_data.alpha_type == AlphaType::Alpha {
|
||||||
if kind == CompositorSurfaceKind::Overlay {
|
promote_to_surface = false;
|
||||||
prim_instance.vis.state = VisibilityState::Culled;
|
}
|
||||||
return;
|
|
||||||
}
|
if promote_to_surface {
|
||||||
|
promote_to_surface = self.setup_compositor_surfaces_rgb(
|
||||||
assert!(kind == CompositorSurfaceKind::Blit, "Image prims should either be overlays or blits.");
|
sub_slice_index,
|
||||||
|
&mut prim_info,
|
||||||
|
image_key.common.flags,
|
||||||
|
local_prim_rect,
|
||||||
|
prim_spatial_node_index,
|
||||||
|
pic_coverage_rect,
|
||||||
|
frame_context,
|
||||||
|
ImageDependency {
|
||||||
|
key: image_data.key,
|
||||||
|
generation: resource_cache.get_image_generation(image_data.key),
|
||||||
|
},
|
||||||
|
image_data.key,
|
||||||
|
resource_cache,
|
||||||
|
composite_state,
|
||||||
|
gpu_cache,
|
||||||
|
image_data.image_rendering,
|
||||||
|
is_opaque,
|
||||||
|
CompositorSurfaceKind::Overlay,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if promote_to_surface {
|
||||||
|
*compositor_surface_kind = CompositorSurfaceKind::Overlay;
|
||||||
|
prim_instance.vis.state = VisibilityState::Culled;
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
*compositor_surface_kind = CompositorSurfaceKind::Blit;
|
||||||
|
|
||||||
prim_info.images.push(ImageDependency {
|
prim_info.images.push(ImageDependency {
|
||||||
key: image_data.key,
|
key: image_data.key,
|
||||||
generation: resource_cache.get_image_generation(image_data.key),
|
generation: resource_cache.get_image_generation(image_data.key),
|
||||||
|
|
@ -3284,103 +3231,106 @@ impl TileCacheInstance {
|
||||||
PrimitiveInstanceKind::YuvImage { data_handle, ref mut compositor_surface_kind, .. } => {
|
PrimitiveInstanceKind::YuvImage { data_handle, ref mut compositor_surface_kind, .. } => {
|
||||||
let prim_data = &data_stores.yuv_image[data_handle];
|
let prim_data = &data_stores.yuv_image[data_handle];
|
||||||
|
|
||||||
if prim_data.common.flags.contains(PrimitiveFlags::PREFER_COMPOSITOR_SURFACE) {
|
// Note if this is one of the YuvImages we were considering for
|
||||||
// Note if this is one of the YuvImages we were considering for
|
// surface promotion. We only care for primitives that were added
|
||||||
// surface promotion. We only care for primitives that were added
|
// to us, indicated by is_root_tile_cache. Those are the only ones
|
||||||
// to us, indicated by is_root_tile_cache. Those are the only ones
|
// that were added to the TileCacheParams that configured the
|
||||||
// that were added to the TileCacheParams that configured the
|
// current scene.
|
||||||
// current scene.
|
if is_root_tile_cache && prim_data.common.flags.contains(PrimitiveFlags::PREFER_COMPOSITOR_SURFACE) {
|
||||||
if is_root_tile_cache {
|
self.yuv_images_remaining -= 1;
|
||||||
self.yuv_images_remaining -= 1;
|
}
|
||||||
}
|
|
||||||
|
let clip_on_top = prim_clip_chain.needs_mask;
|
||||||
let clip_on_top = prim_clip_chain.needs_mask;
|
let prefer_underlay = clip_on_top || !cfg!(target_os = "macos");
|
||||||
let prefer_underlay = clip_on_top || !cfg!(target_os = "macos");
|
let promotion_attempts = if prefer_underlay {
|
||||||
let promotion_attempts = if prefer_underlay {
|
[CompositorSurfaceKind::Underlay, CompositorSurfaceKind::Overlay]
|
||||||
[CompositorSurfaceKind::Underlay, CompositorSurfaceKind::Overlay]
|
} else {
|
||||||
} else {
|
[CompositorSurfaceKind::Overlay, CompositorSurfaceKind::Underlay]
|
||||||
[CompositorSurfaceKind::Overlay, CompositorSurfaceKind::Underlay]
|
};
|
||||||
|
|
||||||
|
let mut promotion_kind = None;
|
||||||
|
for kind in promotion_attempts {
|
||||||
|
let success = match self.can_promote_to_surface(
|
||||||
|
prim_data.common.flags,
|
||||||
|
prim_clip_chain,
|
||||||
|
prim_spatial_node_index,
|
||||||
|
is_root_tile_cache,
|
||||||
|
sub_slice_index,
|
||||||
|
kind,
|
||||||
|
pic_coverage_rect,
|
||||||
|
frame_context) {
|
||||||
|
SurfacePromotionResult::Failed => false,
|
||||||
|
SurfacePromotionResult::Success => true,
|
||||||
};
|
};
|
||||||
|
if success {
|
||||||
for kind in promotion_attempts {
|
promotion_kind = Some(kind);
|
||||||
// Since this might be an attempt after an earlier error, clear the flag
|
break;
|
||||||
// so that we are allowed to report another error.
|
|
||||||
promotion_failure_reported = false;
|
|
||||||
promotion_result = self.can_promote_to_surface(
|
|
||||||
prim_clip_chain,
|
|
||||||
prim_spatial_node_index,
|
|
||||||
is_root_tile_cache,
|
|
||||||
sub_slice_index,
|
|
||||||
kind,
|
|
||||||
pic_coverage_rect,
|
|
||||||
frame_context);
|
|
||||||
if promotion_result.is_ok() {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
maybe_report_promotion_failure(promotion_result, pic_coverage_rect, &mut promotion_failure_reported);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// TODO(gw): When we support RGBA images for external surfaces, we also
|
|
||||||
// need to check if opaque (YUV images are implicitly opaque).
|
// TODO(gw): When we support RGBA images for external surfaces, we also
|
||||||
|
// need to check if opaque (YUV images are implicitly opaque).
|
||||||
// If this primitive is being promoted to a surface, construct an external
|
|
||||||
// surface descriptor for use later during batching and compositing. We only
|
// If this primitive is being promoted to a surface, construct an external
|
||||||
// add the image keys for this primitive as a dependency if this is _not_
|
// surface descriptor for use later during batching and compositing. We only
|
||||||
// a promoted surface, since we don't want the tiles to invalidate when the
|
// add the image keys for this primitive as a dependency if this is _not_
|
||||||
// video content changes, if it's a compositor surface!
|
// a promoted surface, since we don't want the tiles to invalidate when the
|
||||||
if let Ok(kind) = promotion_result {
|
// video content changes, if it's a compositor surface!
|
||||||
// Build dependency for each YUV plane, with current image generation for
|
if let Some(kind) = promotion_kind {
|
||||||
// later detection of when the composited surface has changed.
|
// Build dependency for each YUV plane, with current image generation for
|
||||||
let mut image_dependencies = [ImageDependency::INVALID; 3];
|
// later detection of when the composited surface has changed.
|
||||||
for (key, dep) in prim_data.kind.yuv_key.iter().cloned().zip(image_dependencies.iter_mut()) {
|
let mut image_dependencies = [ImageDependency::INVALID; 3];
|
||||||
*dep = ImageDependency {
|
for (key, dep) in prim_data.kind.yuv_key.iter().cloned().zip(image_dependencies.iter_mut()) {
|
||||||
key,
|
*dep = ImageDependency {
|
||||||
generation: resource_cache.get_image_generation(key),
|
key,
|
||||||
}
|
generation: resource_cache.get_image_generation(key),
|
||||||
}
|
}
|
||||||
|
}
|
||||||
promotion_result = self.setup_compositor_surfaces_yuv(
|
|
||||||
sub_slice_index,
|
let success = self.setup_compositor_surfaces_yuv(
|
||||||
&mut prim_info,
|
sub_slice_index,
|
||||||
prim_data.common.flags,
|
&mut prim_info,
|
||||||
local_prim_rect,
|
prim_data.common.flags,
|
||||||
prim_spatial_node_index,
|
local_prim_rect,
|
||||||
pic_coverage_rect,
|
prim_spatial_node_index,
|
||||||
frame_context,
|
pic_coverage_rect,
|
||||||
&image_dependencies,
|
frame_context,
|
||||||
&prim_data.kind.yuv_key,
|
&image_dependencies,
|
||||||
resource_cache,
|
&prim_data.kind.yuv_key,
|
||||||
composite_state,
|
resource_cache,
|
||||||
gpu_cache,
|
composite_state,
|
||||||
prim_data.kind.image_rendering,
|
gpu_cache,
|
||||||
prim_data.kind.color_depth,
|
prim_data.kind.image_rendering,
|
||||||
prim_data.kind.color_space.with_range(prim_data.kind.color_range),
|
prim_data.kind.color_depth,
|
||||||
prim_data.kind.format,
|
prim_data.kind.color_space.with_range(prim_data.kind.color_range),
|
||||||
kind,
|
prim_data.kind.format,
|
||||||
);
|
kind,
|
||||||
|
);
|
||||||
|
if !success {
|
||||||
|
promotion_kind = None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store on the YUV primitive instance whether this is a promoted surface.
|
// Store on the YUV primitive instance whether this is a promoted surface.
|
||||||
// This is used by the batching code to determine whether to draw the
|
// This is used by the batching code to determine whether to draw the
|
||||||
// image to the content tiles, or just a transparent z-write.
|
// image to the content tiles, or just a transparent z-write.
|
||||||
if let Ok(kind) = promotion_result {
|
if let Some(kind) = promotion_kind {
|
||||||
*compositor_surface_kind = kind;
|
*compositor_surface_kind = kind;
|
||||||
if kind == CompositorSurfaceKind::Overlay {
|
if kind == CompositorSurfaceKind::Overlay {
|
||||||
prim_instance.vis.state = VisibilityState::Culled;
|
prim_instance.vis.state = VisibilityState::Culled;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if kind == CompositorSurfaceKind::Blit {
|
} else {
|
||||||
prim_info.images.extend(
|
*compositor_surface_kind = CompositorSurfaceKind::Blit;
|
||||||
prim_data.kind.yuv_key.iter().map(|key| {
|
|
||||||
ImageDependency {
|
prim_info.images.extend(
|
||||||
key: *key,
|
prim_data.kind.yuv_key.iter().map(|key| {
|
||||||
generation: resource_cache.get_image_generation(*key),
|
ImageDependency {
|
||||||
}
|
key: *key,
|
||||||
})
|
generation: resource_cache.get_image_generation(*key),
|
||||||
);
|
}
|
||||||
}
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PrimitiveInstanceKind::ImageBorder { data_handle, .. } => {
|
PrimitiveInstanceKind::ImageBorder { data_handle, .. } => {
|
||||||
|
|
@ -3481,9 +3431,7 @@ impl TileCacheInstance {
|
||||||
PrimitiveInstanceKind::TextRun { .. } => {
|
PrimitiveInstanceKind::TextRun { .. } => {
|
||||||
// These don't contribute dependencies
|
// These don't contribute dependencies
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
maybe_report_promotion_failure(promotion_result, pic_coverage_rect, &mut promotion_failure_reported);
|
|
||||||
|
|
||||||
// Calculate the screen rect in local space. When we calculate backdrops, we
|
// Calculate the screen rect in local space. When we calculate backdrops, we
|
||||||
// care only that they cover the visible rect (based off the local clip), and
|
// care only that they cover the visible rect (based off the local clip), and
|
||||||
|
|
|
||||||
|
|
@ -6599,15 +6599,6 @@
|
||||||
value: 25
|
value: 25
|
||||||
mirror: once
|
mirror: once
|
||||||
|
|
||||||
# When true, we output warning messages when rejecting surface promotion
|
|
||||||
# when it has been requested. This is important for color correctness of
|
|
||||||
# wide color videos, as well as for GPU performance for all videos.
|
|
||||||
- name: gfx.webrender.compositor.surface-promotion.logging
|
|
||||||
type: RelaxedAtomicBool
|
|
||||||
value: false
|
|
||||||
mirror: always
|
|
||||||
rust: true
|
|
||||||
|
|
||||||
# Number of damage rects we can give to the compositor for a new frame with
|
# Number of damage rects we can give to the compositor for a new frame with
|
||||||
# partial present. This controls whether partial present is used or not.
|
# partial present. This controls whether partial present is used or not.
|
||||||
- name: gfx.webrender.max-partial-present-rects
|
- name: gfx.webrender.max-partial-present-rects
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue