From ee9116f875b75fdfba4a4ca5a3996bbdf8876f20 Mon Sep 17 00:00:00 2001 From: Razvan Maries Date: Wed, 30 Oct 2019 22:05:32 +0200 Subject: [PATCH] Backed out changeset 598b2d26c136 (bug 1591627) as per Glenn's request. CLOSED TREE --- gfx/webrender_bindings/RenderCompositor.cpp | 4 +-- gfx/webrender_bindings/RenderCompositor.h | 4 +-- gfx/webrender_bindings/src/bindings.rs | 3 -- .../compositor-windows/src/lib.cpp | 9 +++-- .../compositor-windows/src/lib.rs | 5 +-- .../example-compositor/compositor/src/main.rs | 9 +---- gfx/wr/webrender/src/composite.rs | 4 --- gfx/wr/webrender/src/picture.rs | 35 ++----------------- gfx/wr/webrender/src/renderer.rs | 3 +- 9 files changed, 14 insertions(+), 62 deletions(-) diff --git a/gfx/webrender_bindings/RenderCompositor.cpp b/gfx/webrender_bindings/RenderCompositor.cpp index 73724230fd40..392e65320bed 100644 --- a/gfx/webrender_bindings/RenderCompositor.cpp +++ b/gfx/webrender_bindings/RenderCompositor.cpp @@ -43,9 +43,9 @@ void wr_compositor_bind(void* aCompositor, wr::NativeSurfaceId aId, } void wr_compositor_create_surface(void* aCompositor, wr::NativeSurfaceId aId, - wr::DeviceIntSize aSize, bool aIsOpaque) { + wr::DeviceIntSize aSize) { RenderCompositor* compositor = static_cast(aCompositor); - compositor->CreateSurface(aId, aSize, aIsOpaque); + compositor->CreateSurface(aId, aSize); } void wr_compositor_destroy_surface(void* aCompositor, NativeSurfaceId aId) { diff --git a/gfx/webrender_bindings/RenderCompositor.h b/gfx/webrender_bindings/RenderCompositor.h index 3000c9a57844..872512e523c4 100644 --- a/gfx/webrender_bindings/RenderCompositor.h +++ b/gfx/webrender_bindings/RenderCompositor.h @@ -70,8 +70,8 @@ class RenderCompositor { virtual void Bind(wr::NativeSurfaceId aId, wr::DeviceIntPoint* aOffset, uint32_t* aFboId, wr::DeviceIntRect aDirtyRect) {} virtual void Unbind() {} - virtual void CreateSurface(wr::NativeSurfaceId aId, wr::DeviceIntSize aSize, - bool aIsOpaque) {} + virtual void CreateSurface(wr::NativeSurfaceId aId, wr::DeviceIntSize aSize) { + } virtual void DestroySurface(NativeSurfaceId aId) {} virtual void AddSurface(wr::NativeSurfaceId aId, wr::DeviceIntPoint aPosition, wr::DeviceIntRect aClipRect) {} diff --git a/gfx/webrender_bindings/src/bindings.rs b/gfx/webrender_bindings/src/bindings.rs index d7fc1566ff3d..5b2629ccf50a 100644 --- a/gfx/webrender_bindings/src/bindings.rs +++ b/gfx/webrender_bindings/src/bindings.rs @@ -1140,7 +1140,6 @@ extern "C" { compositor: *mut c_void, id: NativeSurfaceId, size: DeviceIntSize, - is_opaque: bool, ); fn wr_compositor_destroy_surface( compositor: *mut c_void, @@ -1171,14 +1170,12 @@ impl Compositor for WrCompositor { &mut self, id: NativeSurfaceId, size: DeviceIntSize, - is_opaque: bool, ) { unsafe { wr_compositor_create_surface( self.0, id, size, - is_opaque, ); } } diff --git a/gfx/wr/example-compositor/compositor-windows/src/lib.cpp b/gfx/wr/example-compositor/compositor-windows/src/lib.cpp index fceedaf5a244..58c22907d22d 100644 --- a/gfx/wr/example-compositor/compositor-windows/src/lib.cpp +++ b/gfx/wr/example-compositor/compositor-windows/src/lib.cpp @@ -311,21 +311,20 @@ extern "C" { Window *window, uint64_t id, int width, - int height, - bool is_opaque + int height ) { assert(window->tiles.count(id) == 0); Tile tile; - DXGI_ALPHA_MODE alpha_mode = is_opaque ? DXGI_ALPHA_MODE_IGNORE : DXGI_ALPHA_MODE_PREMULTIPLIED; - // Create the video memory surface. + // TODO(gw): We should set alpha mode appropriately so that DC + // can do opaque composites when possible! HRESULT hr = window->pDCompDevice->CreateSurface( width, height, DXGI_FORMAT_B8G8R8A8_UNORM, - alpha_mode, + DXGI_ALPHA_MODE_PREMULTIPLIED, &tile.pSurface ); assert(SUCCEEDED(hr)); diff --git a/gfx/wr/example-compositor/compositor-windows/src/lib.rs b/gfx/wr/example-compositor/compositor-windows/src/lib.rs index 4ccf780df5df..e9d42ba36137 100644 --- a/gfx/wr/example-compositor/compositor-windows/src/lib.rs +++ b/gfx/wr/example-compositor/compositor-windows/src/lib.rs @@ -33,7 +33,6 @@ extern { id: u64, width: i32, height: i32, - is_opaque: bool, ); fn com_dc_destroy_surface( @@ -98,15 +97,13 @@ pub fn create_surface( id: u64, width: i32, height: i32, - is_opaque: bool, ) { unsafe { com_dc_create_surface( window, id, width, - height, - is_opaque + height ) } } diff --git a/gfx/wr/example-compositor/compositor/src/main.rs b/gfx/wr/example-compositor/compositor/src/main.rs index bab9ac42aab1..71637b365c65 100644 --- a/gfx/wr/example-compositor/compositor/src/main.rs +++ b/gfx/wr/example-compositor/compositor/src/main.rs @@ -42,15 +42,8 @@ impl webrender::Compositor for DirectCompositeInterface { &mut self, id: webrender::NativeSurfaceId, size: DeviceIntSize, - is_opaque: bool, ) { - compositor::create_surface( - self.window, - id.0, - size.width, - size.height, - is_opaque, - ); + compositor::create_surface(self.window, id.0, size.width, size.height); } fn destroy_surface( diff --git a/gfx/wr/webrender/src/composite.rs b/gfx/wr/webrender/src/composite.rs index 1a11c985782c..1cfa1388dcd6 100644 --- a/gfx/wr/webrender/src/composite.rs +++ b/gfx/wr/webrender/src/composite.rs @@ -19,7 +19,6 @@ use crate::picture::{ResolvedSurfaceTexture, SurfaceTextureDescriptor}; pub enum NativeSurfaceOperationDetails { CreateSurface { size: DeviceIntSize, - is_opaque: bool, }, DestroySurface, } @@ -163,14 +162,12 @@ impl CompositeState { &mut self, id: NativeSurfaceId, size: DeviceIntSize, - is_opaque: bool, ) -> SurfaceTextureDescriptor { self.native_surface_updates.push( NativeSurfaceOperation { id, details: NativeSurfaceOperationDetails::CreateSurface { size, - is_opaque, } } ); @@ -234,7 +231,6 @@ pub trait Compositor { &mut self, id: NativeSurfaceId, size: DeviceIntSize, - is_opaque: bool, ); /// Destroy the surface with the specified id. WR may call this diff --git a/gfx/wr/webrender/src/picture.rs b/gfx/wr/webrender/src/picture.rs index 57aed03d63df..b288ffe162f7 100644 --- a/gfx/wr/webrender/src/picture.rs +++ b/gfx/wr/webrender/src/picture.rs @@ -726,9 +726,7 @@ impl Tile { state: &mut TilePostUpdateState, ) -> bool { // Check if this tile can be considered opaque. - let tile_is_opaque = ctx.backdrop.rect.contains_rect(&self.clipped_rect); - let opacity_changed = tile_is_opaque != self.is_opaque; - self.is_opaque = tile_is_opaque; + self.is_opaque = ctx.backdrop.rect.contains_rect(&self.clipped_rect); // Invalidate the tile based on the content changing. self.update_content_validity(ctx, state); @@ -805,34 +803,8 @@ impl Tile { // the tile was previously a color, or not set, then just set // up a new texture cache handle. match self.surface.take() { - Some(TileSurface::Texture { descriptor, visibility_mask }) => { - // If opacity changed, and this is a native OS compositor surface, - // it needs to be recreated. - // TODO(gw): This is a limitation of the DirectComposite APIs. It might - // make sense on other platforms to be able to change this as - // a property on a surface, if we ever see pages where this - // is changing frequently. - if opacity_changed { - if let SurfaceTextureDescriptor::NativeSurface { id, size } = descriptor { - // Reset the dirty rect and tile validity in this case, to - // force the new tile to be completely redrawn. - self.dirty_rect = self.rect; - self.is_valid = false; - - state.composite_state.destroy_surface(id); - state.composite_state.create_surface( - id, - size, - self.is_opaque, - ); - } - } - - // Reuse the existing descriptor and vis mask - TileSurface::Texture { - descriptor, - visibility_mask, - } + Some(old_surface @ TileSurface::Texture { .. }) => { + old_surface } Some(TileSurface::Color { .. }) | Some(TileSurface::Clear) | None => { // This is the case where we are constructing a tile surface that @@ -853,7 +825,6 @@ impl Tile { state.composite_state.create_surface( NativeSurfaceId(self.id.0 as u64), ctx.current_tile_size, - self.is_opaque, ) } }; diff --git a/gfx/wr/webrender/src/renderer.rs b/gfx/wr/webrender/src/renderer.rs index 7419f9e0efa5..8b41ff65a1de 100644 --- a/gfx/wr/webrender/src/renderer.rs +++ b/gfx/wr/webrender/src/renderer.rs @@ -4883,14 +4883,13 @@ impl Renderer { CompositorConfig::Native { ref mut compositor, .. } => { for op in &composite_state.native_surface_updates { match op.details { - NativeSurfaceOperationDetails::CreateSurface { size, is_opaque } => { + NativeSurfaceOperationDetails::CreateSurface { size } => { let _inserted = self.allocated_native_surfaces.insert(op.id); debug_assert!(_inserted, "bug: creating existing surface"); compositor.create_surface( op.id, size, - is_opaque, ); } NativeSurfaceOperationDetails::DestroySurface => {