Commit 2a2b64e4 authored by Maggie Chen's avatar Maggie Chen Committed by Commit Bot

Code clean-up in SwapChainPresenter

1. Remove the dead code in ReallocateSwapChain().
2. Handling software protected video separately in
GetSwapChainFormat() gets the same result. Remove it.
3. The purpose of retrying YUV format after swap chain resizing was to
see if it would show a better hardware overlay promotion rate in UMA.
Remove it since we didn't get a better result. It still get a chance to
switch back to YUV if the majority in |presentation_history_| are
overlay mode.

Bug: 1117235
Change-Id: Iff2e5666d3895fefa6e5289fe92b09a56ffd82ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2499324Reviewed-by: default avatarZhenyao Mo <zmo@chromium.org>
Commit-Queue: Maggie Chen <magchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820820}
parent 437e5d9a
...@@ -212,14 +212,6 @@ DXGI_FORMAT SwapChainPresenter::GetSwapChainFormat( ...@@ -212,14 +212,6 @@ DXGI_FORMAT SwapChainPresenter::GetSwapChainFormat(
if (content_is_hdr) if (content_is_hdr)
return DXGI_FORMAT_R10G10B10A2_UNORM; return DXGI_FORMAT_R10G10B10A2_UNORM;
// For software protected video, BGRA swap chain is preferred if hardware
// overlay is not supported for better power efficiency.
// Currently, software protected video is the only case that overlay swap
// chain is used when hardware overlay is not supported.
if (protected_video_type == gfx::ProtectedVideoType::kSoftwareProtected &&
!DirectCompositionSurfaceWin::AreOverlaysSupported())
return DXGI_FORMAT_B8G8R8A8_UNORM;
if (failed_to_create_yuv_swapchain_) if (failed_to_create_yuv_swapchain_)
return DXGI_FORMAT_B8G8R8A8_UNORM; return DXGI_FORMAT_B8G8R8A8_UNORM;
...@@ -786,10 +778,7 @@ bool SwapChainPresenter::PresentToSwapChain( ...@@ -786,10 +778,7 @@ bool SwapChainPresenter::PresentToSwapChain(
} }
bool swap_chain_resized = swap_chain_size_ != swap_chain_size; bool swap_chain_resized = swap_chain_size_ != swap_chain_size;
// Give it another chance to try YUV again when the size changes.
if (swap_chain_resized) {
presentation_history_.Clear();
}
DXGI_FORMAT swap_chain_format = DXGI_FORMAT swap_chain_format =
GetSwapChainFormat(params.protected_video_type, content_is_hdr); GetSwapChainFormat(params.protected_video_type, content_is_hdr);
bool swap_chain_format_changed = swap_chain_format != swap_chain_format_; bool swap_chain_format_changed = swap_chain_format != swap_chain_format_;
...@@ -800,8 +789,7 @@ bool SwapChainPresenter::PresentToSwapChain( ...@@ -800,8 +789,7 @@ bool SwapChainPresenter::PresentToSwapChain(
if (!swap_chain_ || swap_chain_resized || swap_chain_format_changed || if (!swap_chain_ || swap_chain_resized || swap_chain_format_changed ||
toggle_protected_video) { toggle_protected_video) {
if (!ReallocateSwapChain(swap_chain_size, swap_chain_format, if (!ReallocateSwapChain(swap_chain_size, swap_chain_format,
params.protected_video_type, params.z_order, params.protected_video_type)) {
content_is_hdr)) {
ReleaseSwapChainResources(); ReleaseSwapChainResources();
return false; return false;
} }
...@@ -1119,9 +1107,7 @@ void SwapChainPresenter::ReleaseSwapChainResources() { ...@@ -1119,9 +1107,7 @@ void SwapChainPresenter::ReleaseSwapChainResources() {
bool SwapChainPresenter::ReallocateSwapChain( bool SwapChainPresenter::ReallocateSwapChain(
const gfx::Size& swap_chain_size, const gfx::Size& swap_chain_size,
DXGI_FORMAT swap_chain_format, DXGI_FORMAT swap_chain_format,
gfx::ProtectedVideoType protected_video_type, gfx::ProtectedVideoType protected_video_type) {
bool z_order,
bool content_is_hdr) {
bool use_yuv_swap_chain = IsYUVSwapChainFormat(swap_chain_format); bool use_yuv_swap_chain = IsYUVSwapChainFormat(swap_chain_format);
TRACE_EVENT2("gpu", "SwapChainPresenter::ReallocateSwapChain", "size", TRACE_EVENT2("gpu", "SwapChainPresenter::ReallocateSwapChain", "size",
......
...@@ -103,9 +103,7 @@ class SwapChainPresenter : public base::PowerObserver { ...@@ -103,9 +103,7 @@ class SwapChainPresenter : public base::PowerObserver {
// |protected_video_type|. Returns true on success. // |protected_video_type|. Returns true on success.
bool ReallocateSwapChain(const gfx::Size& swap_chain_size, bool ReallocateSwapChain(const gfx::Size& swap_chain_size,
DXGI_FORMAT swap_chain_format, DXGI_FORMAT swap_chain_format,
gfx::ProtectedVideoType protected_video_type, gfx::ProtectedVideoType protected_video_type);
bool z_order,
bool content_is_hdr);
// Returns DXGI format that swap chain uses. // Returns DXGI format that swap chain uses.
// This changes over time based on stats recorded in |presentation_history|. // This changes over time based on stats recorded in |presentation_history|.
......
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