Bug 1712871 - Move max_update_rects into CompositorCapabilities r=lsalzman,gfx-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D115954
This commit is contained in:
Glenn Watson 2021-05-26 20:09:58 +00:00
Родитель 2a9ca0fe16
Коммит f459eaca0d
13 изменённых файлов: 25 добавлений и 35 удалений

Просмотреть файл

@ -219,6 +219,15 @@ RenderCompositor::~RenderCompositor() = default;
bool RenderCompositor::MakeCurrent() { return gl()->MakeCurrent(); }
void RenderCompositor::GetCompositorCapabilities(
CompositorCapabilities* aCaps) {
if (StaticPrefs::gfx_webrender_compositor_max_update_rects_AtStartup() > 0) {
aCaps->max_update_rects = 1;
} else {
aCaps->max_update_rects = 0;
}
}
GLenum RenderCompositor::IsContextLost(bool aForce) {
auto* glc = gl();
// GetGraphicsResetStatus may trigger an implicit MakeCurrent if robustness

Просмотреть файл

@ -113,7 +113,6 @@ class RenderCompositor {
virtual bool SupportAsyncScreenshot() { return true; }
virtual bool ShouldUseNativeCompositor() { return false; }
virtual uint32_t GetMaxUpdateRects() { return 0; }
// Interface for wr::Compositor
virtual void CompositorBeginFrame() {}
@ -151,7 +150,7 @@ class RenderCompositor {
virtual void DeInit() {}
// Overrides any of the default compositor capabilities for behavior this
// compositor might require.
virtual void GetCompositorCapabilities(CompositorCapabilities* aCaps) {}
virtual void GetCompositorCapabilities(CompositorCapabilities* aCaps);
// Interface for partial present
virtual bool UsePartialPresent() { return false; }

Просмотреть файл

@ -878,14 +878,6 @@ bool RenderCompositorANGLE::ShouldUseNativeCompositor() {
return UseCompositor();
}
uint32_t RenderCompositorANGLE::GetMaxUpdateRects() {
if (UseCompositor() &&
StaticPrefs::gfx_webrender_compositor_max_update_rects_AtStartup() > 0) {
return 1;
}
return 0;
}
void RenderCompositorANGLE::CompositorBeginFrame() {
mDCLayerTree->CompositorBeginFrame();
}
@ -942,6 +934,8 @@ void RenderCompositorANGLE::AddSurface(
void RenderCompositorANGLE::GetCompositorCapabilities(
CompositorCapabilities* aCaps) {
RenderCompositor::GetCompositorCapabilities(aCaps);
aCaps->virtual_surface_size = VIRTUAL_SURFACE_SIZE;
}

Просмотреть файл

@ -77,7 +77,6 @@ class RenderCompositorANGLE : public RenderCompositor {
bool SupportAsyncScreenshot() override;
bool ShouldUseNativeCompositor() override;
uint32_t GetMaxUpdateRects() override;
// Interface for wr::Compositor
void CompositorBeginFrame() override;

Просмотреть файл

@ -211,14 +211,6 @@ bool RenderCompositorNative::MaybeProcessScreenshotQueue() {
return true;
}
uint32_t RenderCompositorNative::GetMaxUpdateRects() {
if (ShouldUseNativeCompositor() &&
StaticPrefs::gfx_webrender_compositor_max_update_rects_AtStartup() > 0) {
return 1;
}
return 0;
}
void RenderCompositorNative::CompositorBeginFrame() {
mAddedLayers.Clear();
mAddedTilePixelCount = 0;

Просмотреть файл

@ -44,7 +44,6 @@ class RenderCompositorNative : public RenderCompositor {
LayoutDeviceIntSize GetBufferSize() override;
bool ShouldUseNativeCompositor() override;
uint32_t GetMaxUpdateRects() override;
bool SurfaceOriginIsTopLeft() override { return true; }

Просмотреть файл

@ -259,6 +259,8 @@ LayoutDeviceIntSize RenderCompositorSWGL::GetBufferSize() {
void RenderCompositorSWGL::GetCompositorCapabilities(
CompositorCapabilities* aCaps) {
RenderCompositor::GetCompositorCapabilities(aCaps);
// When the window contents may be damaged, we need to force a full redraw.
aCaps->redraw_on_invalidation = true;
}

Просмотреть файл

@ -162,7 +162,7 @@ class NewRenderer : public RendererEvent {
aRenderThread.ThreadPoolLP().Raw(), &WebRenderMallocSizeOf,
&WebRenderMallocEnclosingSizeOf, 0, compositor.get(),
compositor->ShouldUseNativeCompositor(),
compositor->GetMaxUpdateRects(), compositor->UsePartialPresent(),
compositor->UsePartialPresent(),
compositor->GetMaxPartialPresentRects(),
compositor->ShouldDrawPreviousPartialPresentRegions(), mDocHandle,
&wrRenderer, mMaxTextureSize, &errorMessage,

Просмотреть файл

@ -1483,7 +1483,6 @@ pub extern "C" fn wr_window_new(
document_id: u32,
compositor: *mut c_void,
use_native_compositor: bool,
max_update_rects: usize,
use_partial_present: bool,
max_partial_present_rects: usize,
draw_previous_partial_present_regions: bool,
@ -1552,7 +1551,6 @@ pub extern "C" fn wr_window_new(
let compositor_config = if software {
CompositorConfig::Native {
max_update_rects: 1,
compositor: Box::new(SwCompositor::new(
sw_gl.unwrap(),
Box::new(WrCompositor(compositor)),
@ -1561,7 +1559,6 @@ pub extern "C" fn wr_window_new(
}
} else if use_native_compositor {
CompositorConfig::Native {
max_update_rects,
compositor: Box::new(WrCompositor(compositor)),
}
} else {

Просмотреть файл

@ -422,7 +422,6 @@ fn main() {
let debug_flags = DebugFlags::empty();
let compositor_config = if enable_compositor {
webrender::CompositorConfig::Native {
max_update_rects: 1,
compositor: Box::new(DirectCompositeInterface::new(window)),
}
} else {

Просмотреть файл

@ -258,10 +258,6 @@ pub enum CompositorConfig {
/// the Compositor trait, but can be significantly more power efficient on operating
/// systems that support it.
Native {
/// The maximum number of dirty rects that can be provided per compositor
/// surface update. If this is zero, the entire compositor surface for
/// a given tile will be drawn if it's dirty.
max_update_rects: usize,
/// A client provided interface to a native / OS compositor.
compositor: Box<dyn Compositor>,
}
@ -319,8 +315,6 @@ pub enum CompositorKind {
},
/// Native OS compositor.
Native {
/// Maximum dirty rects per compositor surface.
max_update_rects: usize,
/// The capabilities of the underlying platform.
capabilities: CompositorCapabilities,
},
@ -929,6 +923,10 @@ pub struct CompositorCapabilities {
pub virtual_surface_size: i32,
/// Whether the compositor requires redrawing on invalidation.
pub redraw_on_invalidation: bool,
/// The maximum number of dirty rects that can be provided per compositor
/// surface update. If this is zero, the entire compositor surface for
/// a given tile will be drawn if it's dirty.
pub max_update_rects: usize,
}
impl Default for CompositorCapabilities {
@ -940,6 +938,9 @@ impl Default for CompositorCapabilities {
CompositorCapabilities {
virtual_surface_size: 0,
redraw_on_invalidation: false,
// Assume compositors can do at least partial update of surfaces. If not,
// the native compositor should override this to be 0.
max_update_rects: 1,
}
}
}

Просмотреть файл

@ -1300,8 +1300,8 @@ impl Tile {
CompositorKind::Draw { .. } => {
(frame_context.config.gpu_supports_render_target_partial_update, true)
}
CompositorKind::Native { max_update_rects, .. } => {
(max_update_rects > 0, false)
CompositorKind::Native { capabilities, .. } => {
(capabilities.max_update_rects > 0, false)
}
};

Просмотреть файл

@ -1105,11 +1105,10 @@ impl Renderer {
CompositorConfig::Draw { max_partial_present_rects, draw_previous_partial_present_regions, .. } => {
CompositorKind::Draw { max_partial_present_rects, draw_previous_partial_present_regions }
}
CompositorConfig::Native { ref compositor, max_update_rects, .. } => {
CompositorConfig::Native { ref compositor } => {
let capabilities = compositor.get_capabilities();
CompositorKind::Native {
max_update_rects,
capabilities,
}
}