Skip to content

Commit bac53fc

Browse files
author
Glenn Watson
committed
Bug 1946487 - Fix transparent top level windows with layer compositor r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D237668
1 parent c66f8c3 commit bac53fc

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

webrender/src/composite.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,20 @@ pub struct NativeSurfaceInfo {
11391139
pub fbo_id: u32,
11401140
}
11411141

1142+
#[repr(C)]
1143+
#[derive(Debug, Copy, Clone)]
1144+
pub struct WindowProperties {
1145+
pub is_opaque: bool,
1146+
}
1147+
1148+
impl Default for WindowProperties {
1149+
fn default() -> Self {
1150+
WindowProperties {
1151+
is_opaque: true,
1152+
}
1153+
}
1154+
}
1155+
11421156
#[repr(C)]
11431157
#[derive(Debug, Copy, Clone, PartialEq)]
11441158
#[cfg_attr(feature = "capture", derive(Serialize))]
@@ -1407,6 +1421,9 @@ pub trait LayerCompositor {
14071421

14081422
// Finish compositing this frame - commit the visual tree to the OS
14091423
fn end_frame(&mut self);
1424+
1425+
// Get current information about the window, such as opacity
1426+
fn get_window_properties(&self) -> WindowProperties;
14101427
}
14111428

14121429
/// Information about the underlying data buffer of a mapped tile.

webrender/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ extern crate webrender_build;
169169
pub use crate::composite::{LayerCompositor, CompositorInputConfig, CompositorSurfaceUsage};
170170
pub use crate::composite::{CompositorConfig, Compositor, CompositorCapabilities, CompositorSurfaceTransform};
171171
pub use crate::composite::{NativeSurfaceId, NativeTileId, NativeSurfaceInfo, PartialPresentCompositor};
172-
pub use crate::composite::{MappableCompositor, MappedTileInfo, SWGLCompositeSurfaceInfo, WindowVisibility};
172+
pub use crate::composite::{MappableCompositor, MappedTileInfo, SWGLCompositeSurfaceInfo, WindowVisibility, WindowProperties};
173173
pub use crate::device::{UploadMethod, VertexUsageHint, get_gl_target, get_unoptimized_shader_source};
174174
pub use crate::device::{ProgramBinary, ProgramCache, ProgramCacheObserver, FormatDesc};
175175
pub use crate::device::Device;

webrender/src/renderer/mod.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3454,6 +3454,14 @@ impl Renderer {
34543454
let _gm = self.gpu_profiler.start_marker("framebuffer");
34553455
let _timer = self.gpu_profiler.start_timer(GPU_TAG_COMPOSITE);
34563456

3457+
let window_is_opaque = match self.compositor_config.layer_compositor() {
3458+
Some(ref compositor) => {
3459+
let props = compositor.get_window_properties();
3460+
props.is_opaque
3461+
}
3462+
None => true,
3463+
};
3464+
34573465
let mut input_layers: Vec<CompositorInputLayer> = Vec::new();
34583466
let mut swapchain_layers = Vec::new();
34593467
let cap = composite_state.tiles.len();
@@ -3501,7 +3509,7 @@ impl Renderer {
35013509
match tile.kind {
35023510
TileKind::Opaque | TileKind::Alpha => {
35033511
// Store (index of tile, index of layer) so we can segment them below
3504-
occlusion.add(&rect, is_opaque, idx); // (idx, input_layers.len() - 1));
3512+
occlusion.add(&rect, is_opaque, idx);
35053513
}
35063514
TileKind::Clear => {
35073515
// Clear tiles are specific to how we render the window buttons on
@@ -3590,7 +3598,11 @@ impl Renderer {
35903598
if let Some(new_layer_kind) = new_layer_kind {
35913599
let (offset, clip_rect, is_opaque) = match usage {
35923600
CompositorSurfaceUsage::Content => {
3593-
(DeviceIntPoint::zero(), device_size.into(), input_layers.is_empty())
3601+
(
3602+
DeviceIntPoint::zero(),
3603+
device_size.into(),
3604+
input_layers.is_empty() && window_is_opaque,
3605+
)
35943606
}
35953607
CompositorSurfaceUsage::External { .. } => {
35963608
let rect = composite_state.get_device_rect(

0 commit comments

Comments
 (0)