Commit f634aa2d authored by Daniele Castagna's avatar Daniele Castagna Committed by Commit Bot

ozone: Add overlay strategies with drm atomic

Add overlay strategies single-fullscreen and single-on-top
when the primary DRM device has atomic capabilities.

Bug: 834015
Test: checked on kevin HW overlays are used.
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_layout_ng;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: I06ac101311384baeb49eb31f5fab0d2550fb332e
Reviewed-on: https://chromium-review.googlesource.com/1022872Reviewed-by: default avatarDaniel Nicoara <dnicoara@chromium.org>
Reviewed-by: default avatarRobert Kroeger <rjkroege@chromium.org>
Reviewed-by: default avatarKristian H. Kristensen <hoegsberg@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Daniele Castagna <dcastagna@chromium.org>
Cr-Commit-Position: refs/heads/master@{#554849}
parent d8434146
...@@ -29,8 +29,8 @@ std::unique_ptr<OverlayProcessor::Strategy> MakeOverlayStrategy( ...@@ -29,8 +29,8 @@ std::unique_ptr<OverlayProcessor::Strategy> MakeOverlayStrategy(
} // namespace } // namespace
// |overlay_candidates| is an object used to answer questions about possible // |overlay_candidates| is an object used to answer questions about possible
// overlays configuarations. // overlays configurations.
// |strategies_string| is a comma-separated string containing all the overaly // |strategies_string| is a comma-separated string containing all the overlay
// strategies that should be returned by GetStrategies. // strategies that should be returned by GetStrategies.
// If |strategies_string| is empty "single-on-top,underlay" will be used as // If |strategies_string| is empty "single-on-top,underlay" will be used as
// default. // default.
......
...@@ -273,16 +273,24 @@ CreateOverlayCandidateValidator( ...@@ -273,16 +273,24 @@ CreateOverlayCandidateValidator(
std::unique_ptr<viz::CompositorOverlayCandidateValidator> validator; std::unique_ptr<viz::CompositorOverlayCandidateValidator> validator;
#if defined(USE_OZONE) #if defined(USE_OZONE)
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kEnableHardwareOverlays)) {
std::string enable_overlay_flag = std::string enable_overlay_flag =
command_line->GetSwitchValueASCII(switches::kEnableHardwareOverlays); command_line->GetSwitchValueASCII(switches::kEnableHardwareOverlays);
std::unique_ptr<ui::OverlayCandidatesOzone> overlay_candidates =
ui::OzonePlatform::GetInstance() ui::OzonePlatform* ozone_platform = ui::OzonePlatform::GetInstance();
->GetOverlayManager() DCHECK(ozone_platform);
->CreateOverlayCandidates(widget); ui::OverlayManagerOzone* overlay_manager =
validator.reset(new viz::CompositorOverlayCandidateValidatorOzone( ozone_platform->GetOverlayManager();
std::move(overlay_candidates), enable_overlay_flag)); if (!command_line->HasSwitch(switches::kEnableHardwareOverlays) &&
overlay_manager->SupportsOverlays()) {
enable_overlay_flag = "single-fullscreen,single-on-top";
} }
std::unique_ptr<ui::OverlayCandidatesOzone> overlay_candidates =
ozone_platform->GetOverlayManager()->CreateOverlayCandidates(widget);
validator.reset(new viz::CompositorOverlayCandidateValidatorOzone(
std::move(overlay_candidates), enable_overlay_flag));
#elif defined(OS_MACOSX) #elif defined(OS_MACOSX)
// Overlays are only supported through the remote layer API. // Overlays are only supported through the remote layer API.
if (ui::RemoteLayerAPISupported()) { if (ui::RemoteLayerAPISupported()) {
......
...@@ -18,4 +18,8 @@ StubOverlayManager::CreateOverlayCandidates(gfx::AcceleratedWidget w) { ...@@ -18,4 +18,8 @@ StubOverlayManager::CreateOverlayCandidates(gfx::AcceleratedWidget w) {
return nullptr; return nullptr;
} }
bool StubOverlayManager::SupportsOverlays() const {
return false;
}
} // namespace ui } // namespace ui
...@@ -19,6 +19,8 @@ class StubOverlayManager : public OverlayManagerOzone { ...@@ -19,6 +19,8 @@ class StubOverlayManager : public OverlayManagerOzone {
std::unique_ptr<OverlayCandidatesOzone> CreateOverlayCandidates( std::unique_ptr<OverlayCandidatesOzone> CreateOverlayCandidates(
gfx::AcceleratedWidget w) override; gfx::AcceleratedWidget w) override;
bool SupportsOverlays() const override;
private: private:
DISALLOW_COPY_AND_ASSIGN(StubOverlayManager); DISALLOW_COPY_AND_ASSIGN(StubOverlayManager);
}; };
......
...@@ -29,4 +29,8 @@ OverlayManagerCast::CreateOverlayCandidates(gfx::AcceleratedWidget w) { ...@@ -29,4 +29,8 @@ OverlayManagerCast::CreateOverlayCandidates(gfx::AcceleratedWidget w) {
return std::make_unique<OverlayCandidatesCast>(); return std::make_unique<OverlayCandidatesCast>();
} }
bool OverlayManagerCast::SupportsOverlays() const {
return false;
}
} // namespace ui } // namespace ui
...@@ -21,6 +21,8 @@ class OverlayManagerCast : public OverlayManagerOzone { ...@@ -21,6 +21,8 @@ class OverlayManagerCast : public OverlayManagerOzone {
std::unique_ptr<OverlayCandidatesOzone> CreateOverlayCandidates( std::unique_ptr<OverlayCandidatesOzone> CreateOverlayCandidates(
gfx::AcceleratedWidget w) override; gfx::AcceleratedWidget w) override;
bool SupportsOverlays() const override;
private: private:
DISALLOW_COPY_AND_ASSIGN(OverlayManagerCast); DISALLOW_COPY_AND_ASSIGN(OverlayManagerCast);
}; };
......
...@@ -65,8 +65,12 @@ bool DrmDeviceHandle::Initialize(const base::FilePath& dev_path, ...@@ -65,8 +65,12 @@ bool DrmDeviceHandle::Initialize(const base::FilePath& dev_path,
sys_path_ = sys_path; sys_path_ = sys_path;
num_auth_attempts++; num_auth_attempts++;
if (Authenticate(file_.get())) if (Authenticate(file_.get())) {
struct drm_set_client_cap cap = {DRM_CLIENT_CAP_ATOMIC, 1};
has_atomic_capabilities_ =
!drmIoctl(file_.get(), DRM_IOCTL_SET_CLIENT_CAP, &cap);
break; break;
}
// To avoid spamming the logs, hold off before logging a warning (some // To avoid spamming the logs, hold off before logging a warning (some
// failures are expected at first) and only log a single message. // failures are expected at first) and only log a single message.
......
...@@ -22,6 +22,7 @@ class DrmDeviceHandle { ...@@ -22,6 +22,7 @@ class DrmDeviceHandle {
int fd() const { return file_.get(); } int fd() const { return file_.get(); }
const base::FilePath& sys_path() { return sys_path_; } const base::FilePath& sys_path() { return sys_path_; }
bool has_atomic_capabilities() const { return has_atomic_capabilities_; }
bool Initialize(const base::FilePath& dev_path, bool Initialize(const base::FilePath& dev_path,
const base::FilePath& sys_path); const base::FilePath& sys_path);
...@@ -32,6 +33,7 @@ class DrmDeviceHandle { ...@@ -32,6 +33,7 @@ class DrmDeviceHandle {
private: private:
base::FilePath sys_path_; base::FilePath sys_path_;
base::ScopedFD file_; base::ScopedFD file_;
bool has_atomic_capabilities_ = false;
DISALLOW_COPY_AND_ASSIGN(DrmDeviceHandle); DISALLOW_COPY_AND_ASSIGN(DrmDeviceHandle);
}; };
......
...@@ -133,6 +133,8 @@ DrmDisplayHostManager::DrmDisplayHostManager( ...@@ -133,6 +133,8 @@ DrmDisplayHostManager::DrmDisplayHostManager(
LOG(FATAL) << "Failed to open primary graphics card"; LOG(FATAL) << "Failed to open primary graphics card";
return; return;
} }
overlay_manager->set_supports_overlays(
primary_drm_device_handle_->has_atomic_capabilities());
drm_devices_[primary_graphics_card_path_] = drm_devices_[primary_graphics_card_path_] =
primary_graphics_card_path_sysfs; primary_graphics_card_path_sysfs;
} }
......
...@@ -45,6 +45,10 @@ DrmOverlayManager::CreateOverlayCandidates(gfx::AcceleratedWidget w) { ...@@ -45,6 +45,10 @@ DrmOverlayManager::CreateOverlayCandidates(gfx::AcceleratedWidget w) {
return std::make_unique<DrmOverlayCandidatesHost>(this, w); return std::make_unique<DrmOverlayCandidatesHost>(this, w);
} }
bool DrmOverlayManager::SupportsOverlays() const {
return supports_overlays_;
}
void DrmOverlayManager::CheckOverlaySupport( void DrmOverlayManager::CheckOverlaySupport(
OverlayCandidatesOzone::OverlaySurfaceCandidateList* candidates, OverlayCandidatesOzone::OverlaySurfaceCandidateList* candidates,
gfx::AcceleratedWidget widget) { gfx::AcceleratedWidget widget) {
......
...@@ -30,6 +30,8 @@ class DrmOverlayManager : public OverlayManagerOzone { ...@@ -30,6 +30,8 @@ class DrmOverlayManager : public OverlayManagerOzone {
std::unique_ptr<OverlayCandidatesOzone> CreateOverlayCandidates( std::unique_ptr<OverlayCandidatesOzone> CreateOverlayCandidates(
gfx::AcceleratedWidget w) override; gfx::AcceleratedWidget w) override;
bool SupportsOverlays() const override;
// Invoked on changes to the window (aka display) that require re-populating // Invoked on changes to the window (aka display) that require re-populating
// the cache from the DRM thread. // the cache from the DRM thread.
void ResetCache(); void ResetCache();
...@@ -45,6 +47,8 @@ class DrmOverlayManager : public OverlayManagerOzone { ...@@ -45,6 +47,8 @@ class DrmOverlayManager : public OverlayManagerOzone {
OverlayCandidatesOzone::OverlaySurfaceCandidateList* candidates, OverlayCandidatesOzone::OverlaySurfaceCandidateList* candidates,
gfx::AcceleratedWidget widget); gfx::AcceleratedWidget widget);
void set_supports_overlays(bool yes) { supports_overlays_ = yes; }
private: private:
// Value for the request cache, that keeps track of how many times a // Value for the request cache, that keeps track of how many times a
// specific validation has been requested, if there is a GPU validation // specific validation has been requested, if there is a GPU validation
...@@ -63,6 +67,9 @@ class DrmOverlayManager : public OverlayManagerOzone { ...@@ -63,6 +67,9 @@ class DrmOverlayManager : public OverlayManagerOzone {
bool CanHandleCandidate(const OverlaySurfaceCandidate& candidate, bool CanHandleCandidate(const OverlaySurfaceCandidate& candidate,
gfx::AcceleratedWidget widget) const; gfx::AcceleratedWidget widget) const;
// Whether we have DRM atomic capabilities and we can support HW overlays.
bool supports_overlays_ = false;
GpuThreadAdapter* proxy_; // Not owned. GpuThreadAdapter* proxy_; // Not owned.
DrmWindowHostManager* window_manager_; // Not owned. DrmWindowHostManager* window_manager_; // Not owned.
......
...@@ -22,6 +22,11 @@ class OverlayManagerOzone { ...@@ -22,6 +22,11 @@ class OverlayManagerOzone {
// Get the hal struct to check for overlay support. // Get the hal struct to check for overlay support.
virtual std::unique_ptr<OverlayCandidatesOzone> CreateOverlayCandidates( virtual std::unique_ptr<OverlayCandidatesOzone> CreateOverlayCandidates(
gfx::AcceleratedWidget w) = 0; gfx::AcceleratedWidget w) = 0;
// Whether the underlying platform supports deferring compositing of buffers
// via overlays. In cases where overlays are not supported the promotion and
// validation logics can be skipped client side.
virtual bool SupportsOverlays() const = 0;
}; };
} // namespace ui } // namespace ui
......
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