Commit 6d9583b6 authored by Maggie Chen's avatar Maggie Chen Committed by Commit Bot

Update DC hardware overlay caps when a monitor is plugged in or unplugged

According to Intel, the overlay support caps might change after a
monitor connection change. This CL re-queries the overlay caps when this
event is observed.

Refactor UpdateHardwareOverlaySupport().

Bug: 1042989
Change-Id: I84ef4ff3dca098f3778f8188fdd7157349480144
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2019768Reviewed-by: default avatarZhenyao Mo <zmo@chromium.org>
Commit-Queue: Maggie Chen <magchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735262}
parent 5484383a
......@@ -103,8 +103,6 @@ void UpdateHardwareOverlaySupport() {
return;
}
bool supports_overlays = false;
DXGI_FORMAT overlay_format_used = DXGI_FORMAT_NV12;
unsigned int i = 0;
while (true) {
Microsoft::WRL::ComPtr<IDXGIOutput> output;
......@@ -141,17 +139,17 @@ void UpdateHardwareOverlaySupport() {
// performing an extra scaling Blt before calling the driver. Even when
// scaled overlays aren't actually supported, presentation using the
// overlay path should be relatively efficient.
overlay_format_used = DXGI_FORMAT_NV12;
supports_overlays = true;
g_overlay_format_used = DXGI_FORMAT_NV12;
g_supports_overlays = true;
}
}
if (!supports_overlays &&
if (!g_supports_overlays &&
FlagsSupportsOverlays(g_yuy2_overlay_support_flags)) {
// If NV12 isn't supported, fallback to YUY2 if it's supported.
overlay_format_used = DXGI_FORMAT_YUY2;
supports_overlays = true;
g_overlay_format_used = DXGI_FORMAT_YUY2;
g_supports_overlays = true;
}
if (supports_overlays) {
if (g_supports_overlays) {
DXGI_OUTPUT_DESC monitor_desc = {};
if (SUCCEEDED(output3->GetDesc(&monitor_desc))) {
g_overlay_monitor_size =
......@@ -164,22 +162,19 @@ void UpdateHardwareOverlaySupport() {
// https://docs.microsoft.com/en-us/windows-hardware/drivers/display/multiplane-overlay-hardware-requirements
// TODO(sunnyps): If the above is true, then we can only look at first
// output instead of iterating over all outputs.
if (supports_overlays)
if (g_supports_overlays)
break;
}
g_supports_overlays = supports_overlays;
g_overlay_format_used = overlay_format_used;
if (supports_overlays != prev_supports_overlays ||
overlay_format_used != prev_overlay_format_used) {
if (g_supports_overlays != prev_supports_overlays ||
g_overlay_format_used != prev_overlay_format_used) {
// Record the new histograms
if (supports_overlays) {
if (g_supports_overlays) {
base::UmaHistogramSparse("GPU.DirectComposition.OverlayFormatUsed3",
overlay_format_used);
g_overlay_format_used);
}
UMA_HISTOGRAM_BOOLEAN("GPU.DirectComposition.OverlaysSupported",
supports_overlays);
g_supports_overlays);
}
}
......@@ -762,9 +757,15 @@ void DirectCompositionSurfaceWin::HandleVSyncOnMainThread(
void DirectCompositionSurfaceWin::OnGpuSwitched(
gl::GpuPreference active_gpu_heuristic) {}
void DirectCompositionSurfaceWin::OnDisplayAdded() {}
void DirectCompositionSurfaceWin::OnDisplayAdded() {
InvalidateOverlayCaps();
UpdateHardwareOverlaySupport();
}
void DirectCompositionSurfaceWin::OnDisplayRemoved() {}
void DirectCompositionSurfaceWin::OnDisplayRemoved() {
InvalidateOverlayCaps();
UpdateHardwareOverlaySupport();
}
scoped_refptr<base::TaskRunner>
DirectCompositionSurfaceWin::GetWindowTaskRunnerForTesting() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment