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(
} // namespace
// |overlay_candidates| is an object used to answer questions about possible
// overlays configuarations.
// |strategies_string| is a comma-separated string containing all the overaly
// overlays configurations.
// |strategies_string| is a comma-separated string containing all the overlay
// strategies that should be returned by GetStrategies.
// If |strategies_string| is empty "single-on-top,underlay" will be used as
// default.
......
......@@ -273,16 +273,24 @@ CreateOverlayCandidateValidator(
std::unique_ptr<viz::CompositorOverlayCandidateValidator> validator;
#if defined(USE_OZONE)
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kEnableHardwareOverlays)) {
std::string enable_overlay_flag =
command_line->GetSwitchValueASCII(switches::kEnableHardwareOverlays);
std::unique_ptr<ui::OverlayCandidatesOzone> overlay_candidates =
ui::OzonePlatform::GetInstance()
->GetOverlayManager()
->CreateOverlayCandidates(widget);
validator.reset(new viz::CompositorOverlayCandidateValidatorOzone(
std::move(overlay_candidates), enable_overlay_flag));
std::string enable_overlay_flag =
command_line->GetSwitchValueASCII(switches::kEnableHardwareOverlays);
ui::OzonePlatform* ozone_platform = ui::OzonePlatform::GetInstance();
DCHECK(ozone_platform);
ui::OverlayManagerOzone* overlay_manager =
ozone_platform->GetOverlayManager();
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)
// Overlays are only supported through the remote layer API.
if (ui::RemoteLayerAPISupported()) {
......
......@@ -18,4 +18,8 @@ StubOverlayManager::CreateOverlayCandidates(gfx::AcceleratedWidget w) {
return nullptr;
}
bool StubOverlayManager::SupportsOverlays() const {
return false;
}
} // namespace ui
......@@ -19,6 +19,8 @@ class StubOverlayManager : public OverlayManagerOzone {
std::unique_ptr<OverlayCandidatesOzone> CreateOverlayCandidates(
gfx::AcceleratedWidget w) override;
bool SupportsOverlays() const override;
private:
DISALLOW_COPY_AND_ASSIGN(StubOverlayManager);
};
......
......@@ -29,4 +29,8 @@ OverlayManagerCast::CreateOverlayCandidates(gfx::AcceleratedWidget w) {
return std::make_unique<OverlayCandidatesCast>();
}
bool OverlayManagerCast::SupportsOverlays() const {
return false;
}
} // namespace ui
......@@ -21,6 +21,8 @@ class OverlayManagerCast : public OverlayManagerOzone {
std::unique_ptr<OverlayCandidatesOzone> CreateOverlayCandidates(
gfx::AcceleratedWidget w) override;
bool SupportsOverlays() const override;
private:
DISALLOW_COPY_AND_ASSIGN(OverlayManagerCast);
};
......
......@@ -65,8 +65,12 @@ bool DrmDeviceHandle::Initialize(const base::FilePath& dev_path,
sys_path_ = sys_path;
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;
}
// To avoid spamming the logs, hold off before logging a warning (some
// failures are expected at first) and only log a single message.
......
......@@ -22,6 +22,7 @@ class DrmDeviceHandle {
int fd() const { return file_.get(); }
const base::FilePath& sys_path() { return sys_path_; }
bool has_atomic_capabilities() const { return has_atomic_capabilities_; }
bool Initialize(const base::FilePath& dev_path,
const base::FilePath& sys_path);
......@@ -32,6 +33,7 @@ class DrmDeviceHandle {
private:
base::FilePath sys_path_;
base::ScopedFD file_;
bool has_atomic_capabilities_ = false;
DISALLOW_COPY_AND_ASSIGN(DrmDeviceHandle);
};
......
......@@ -133,6 +133,8 @@ DrmDisplayHostManager::DrmDisplayHostManager(
LOG(FATAL) << "Failed to open primary graphics card";
return;
}
overlay_manager->set_supports_overlays(
primary_drm_device_handle_->has_atomic_capabilities());
drm_devices_[primary_graphics_card_path_] =
primary_graphics_card_path_sysfs;
}
......
......@@ -45,6 +45,10 @@ DrmOverlayManager::CreateOverlayCandidates(gfx::AcceleratedWidget w) {
return std::make_unique<DrmOverlayCandidatesHost>(this, w);
}
bool DrmOverlayManager::SupportsOverlays() const {
return supports_overlays_;
}
void DrmOverlayManager::CheckOverlaySupport(
OverlayCandidatesOzone::OverlaySurfaceCandidateList* candidates,
gfx::AcceleratedWidget widget) {
......
......@@ -30,6 +30,8 @@ class DrmOverlayManager : public OverlayManagerOzone {
std::unique_ptr<OverlayCandidatesOzone> CreateOverlayCandidates(
gfx::AcceleratedWidget w) override;
bool SupportsOverlays() const override;
// Invoked on changes to the window (aka display) that require re-populating
// the cache from the DRM thread.
void ResetCache();
......@@ -45,6 +47,8 @@ class DrmOverlayManager : public OverlayManagerOzone {
OverlayCandidatesOzone::OverlaySurfaceCandidateList* candidates,
gfx::AcceleratedWidget widget);
void set_supports_overlays(bool yes) { supports_overlays_ = yes; }
private:
// Value for the request cache, that keeps track of how many times a
// specific validation has been requested, if there is a GPU validation
......@@ -63,6 +67,9 @@ class DrmOverlayManager : public OverlayManagerOzone {
bool CanHandleCandidate(const OverlaySurfaceCandidate& candidate,
gfx::AcceleratedWidget widget) const;
// Whether we have DRM atomic capabilities and we can support HW overlays.
bool supports_overlays_ = false;
GpuThreadAdapter* proxy_; // Not owned.
DrmWindowHostManager* window_manager_; // Not owned.
......
......@@ -22,6 +22,11 @@ class OverlayManagerOzone {
// Get the hal struct to check for overlay support.
virtual std::unique_ptr<OverlayCandidatesOzone> CreateOverlayCandidates(
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
......
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