diff options
author | dnicoara <dnicoara@chromium.org> | 2015-02-12 10:45:55 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-12 18:47:17 +0000 |
commit | 3d3619b92b7dca1373e8da3a2dd8c97ecebd2ae1 (patch) | |
tree | df52e52261ce3882eba191e9998ac101fca9442e /ui/ozone/platform | |
parent | c43cb286f8997886a0270944ac082eb5f1d54c72 (diff) | |
download | chromium_src-3d3619b92b7dca1373e8da3a2dd8c97ecebd2ae1.zip chromium_src-3d3619b92b7dca1373e8da3a2dd8c97ecebd2ae1.tar.gz chromium_src-3d3619b92b7dca1373e8da3a2dd8c97ecebd2ae1.tar.bz2 |
[Ozone-Dri] Remove display configuration logic from GpuPlatformSupport
Simplifies the DriGpuPlatformSupport, which will now only deal with
forwarding IPC messages. This also removes the NativeDisplayDelegate
interface from NativeDisplayDelegateDri since we don't need to be bound
by the browser side interface on the GPU.
BUG=none
Review URL: https://codereview.chromium.org/917233002
Cr-Commit-Position: refs/heads/master@{#316010}
Diffstat (limited to 'ui/ozone/platform')
-rw-r--r-- | ui/ozone/platform/dri/dri_gpu_platform_support.cc | 79 | ||||
-rw-r--r-- | ui/ozone/platform/dri/dri_gpu_platform_support.h | 6 | ||||
-rw-r--r-- | ui/ozone/platform/dri/native_display_delegate_dri.cc | 263 | ||||
-rw-r--r-- | ui/ozone/platform/dri/native_display_delegate_dri.h | 88 | ||||
-rw-r--r-- | ui/ozone/platform/dri/ozone_platform_dri.cc | 5 | ||||
-rw-r--r-- | ui/ozone/platform/dri/ozone_platform_gbm.cc | 5 |
6 files changed, 196 insertions, 250 deletions
diff --git a/ui/ozone/platform/dri/dri_gpu_platform_support.cc b/ui/ozone/platform/dri/dri_gpu_platform_support.cc index 010ef8c..3a6724f 100644 --- a/ui/ozone/platform/dri/dri_gpu_platform_support.cc +++ b/ui/ozone/platform/dri/dri_gpu_platform_support.cc @@ -5,19 +5,14 @@ #include "ui/ozone/platform/dri/dri_gpu_platform_support.h" #include "base/bind.h" -#include "base/command_line.h" #include "base/thread_task_runner_handle.h" #include "ipc/ipc_message_macros.h" -#include "ui/display/types/display_mode.h" -#include "ui/display/types/display_snapshot.h" -#include "ui/ozone/common/display_util.h" #include "ui/ozone/common/gpu/ozone_gpu_message_params.h" #include "ui/ozone/common/gpu/ozone_gpu_messages.h" #include "ui/ozone/platform/dri/dri_window_delegate_impl.h" #include "ui/ozone/platform/dri/dri_window_delegate_manager.h" #include "ui/ozone/platform/dri/dri_wrapper.h" #include "ui/ozone/platform/dri/native_display_delegate_dri.h" -#include "ui/ozone/public/ozone_switches.h" namespace ui { @@ -169,18 +164,15 @@ class DriGpuPlatformSupportMessageFilter : public IPC::MessageFilter { } DriGpuPlatformSupport::DriGpuPlatformSupport( - const scoped_refptr<DriWrapper>& drm, DrmDeviceManager* drm_device_manager, DriWindowDelegateManager* window_manager, ScreenManager* screen_manager, scoped_ptr<NativeDisplayDelegateDri> ndd) : sender_(NULL), - drm_(drm), drm_device_manager_(drm_device_manager), window_manager_(window_manager), screen_manager_(screen_manager), ndd_(ndd.Pass()) { - ndd_->AddGraphicsDevice(drm_); filter_ = new DriGpuPlatformSupportMessageFilter( window_manager, base::Bind(&DriGpuPlatformSupport::SetIOTaskRunner, base::Unretained(this)), @@ -273,70 +265,20 @@ void DriGpuPlatformSupport::OnForceDPMSOn() { } void DriGpuPlatformSupport::OnRefreshNativeDisplays() { - std::vector<DisplaySnapshot_Params> displays; - std::vector<DisplaySnapshot*> native_displays = ndd_->GetDisplays(); - - for (size_t i = 0; i < native_displays.size(); ++i) - displays.push_back(GetDisplaySnapshotParams(*native_displays[i])); - - sender_->Send(new OzoneHostMsg_UpdateNativeDisplays(displays)); + sender_->Send(new OzoneHostMsg_UpdateNativeDisplays(ndd_->GetDisplays())); } void DriGpuPlatformSupport::OnConfigureNativeDisplay( int64_t id, const DisplayMode_Params& mode_param, const gfx::Point& origin) { - DisplaySnapshot* display = ndd_->FindDisplaySnapshot(id); - if (!display) { - LOG(ERROR) << "There is no display with ID " << id; - sender_->Send(new OzoneHostMsg_DisplayConfigured(id, false)); - return; - } - - const DisplayMode* mode = NULL; - for (size_t i = 0; i < display->modes().size(); ++i) { - if (mode_param.size == display->modes()[i]->size() && - mode_param.is_interlaced == display->modes()[i]->is_interlaced() && - mode_param.refresh_rate == display->modes()[i]->refresh_rate()) { - mode = display->modes()[i]; - break; - } - } - - // If the display doesn't have the mode natively, then lookup the mode from - // other displays and try using it on the current display (some displays - // support panel fitting and they can use different modes even if the mode - // isn't explicitly declared). - if (!mode) - mode = ndd_->FindDisplayMode(mode_param.size, mode_param.is_interlaced, - mode_param.refresh_rate); - - if (!mode) { - LOG(ERROR) << "Failed to find mode: size=" << mode_param.size.ToString() - << " is_interlaced=" << mode_param.is_interlaced - << " refresh_rate=" << mode_param.refresh_rate; - sender_->Send(new OzoneHostMsg_DisplayConfigured(id, false)); - return; - } - - bool success = ndd_->Configure(*display, mode, origin); - if (success) { - display->set_origin(origin); - display->set_current_mode(mode); - } - - sender_->Send(new OzoneHostMsg_DisplayConfigured(id, success)); + sender_->Send(new OzoneHostMsg_DisplayConfigured( + id, ndd_->ConfigureDisplay(id, mode_param, origin))); } void DriGpuPlatformSupport::OnDisableNativeDisplay(int64_t id) { - DisplaySnapshot* display = ndd_->FindDisplaySnapshot(id); - bool success = false; - if (display) - success = ndd_->Configure(*display, NULL, gfx::Point()); - else - LOG(ERROR) << "There is no display with ID " << id; - - sender_->Send(new OzoneHostMsg_DisplayConfigured(id, success)); + sender_->Send( + new OzoneHostMsg_DisplayConfigured(id, ndd_->DisableDisplay(id))); } void DriGpuPlatformSupport::OnTakeDisplayControl() { @@ -348,11 +290,11 @@ void DriGpuPlatformSupport::OnRelinquishDisplayControl() { } void DriGpuPlatformSupport::OnAddGraphicsDevice(const base::FilePath& path) { - NOTIMPLEMENTED(); + ndd_->AddGraphicsDevice(path); } void DriGpuPlatformSupport::OnRemoveGraphicsDevice(const base::FilePath& path) { - NOTIMPLEMENTED(); + ndd_->RemoveGraphicsDevice(path); } void DriGpuPlatformSupport::RelinquishGpuResources( @@ -362,12 +304,7 @@ void DriGpuPlatformSupport::RelinquishGpuResources( void DriGpuPlatformSupport::SetIOTaskRunner( const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) { - io_task_runner_ = io_task_runner; - base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); - // Only surfaceless path supports async page flips. - if (cmd->HasSwitch(switches::kOzoneUseSurfaceless)) { - drm_->InitializeTaskRunner(io_task_runner_); - } + ndd_->InitializeIOTaskRunner(io_task_runner); } IPC::MessageFilter* DriGpuPlatformSupport::GetMessageFilter() { diff --git a/ui/ozone/platform/dri/dri_gpu_platform_support.h b/ui/ozone/platform/dri/dri_gpu_platform_support.h index 2290955..0858fdc 100644 --- a/ui/ozone/platform/dri/dri_gpu_platform_support.h +++ b/ui/ozone/platform/dri/dri_gpu_platform_support.h @@ -29,7 +29,6 @@ namespace ui { class DriSurfaceFactory; class DriWindowDelegate; class DriWindowDelegateManager; -class DriWrapper; class DrmDeviceManager; class NativeDisplayDelegateDri; class ScreenManager; @@ -39,8 +38,7 @@ struct DisplaySnapshot_Params; class DriGpuPlatformSupport : public GpuPlatformSupport { public: - DriGpuPlatformSupport(const scoped_refptr<DriWrapper>& drm, - DrmDeviceManager* drm_device_manager, + DriGpuPlatformSupport(DrmDeviceManager* drm_device_manager, DriWindowDelegateManager* window_manager, ScreenManager* screen_manager, scoped_ptr<NativeDisplayDelegateDri> ndd); @@ -83,7 +81,6 @@ class DriGpuPlatformSupport : public GpuPlatformSupport { const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); IPC::Sender* sender_; // Not owned. - scoped_refptr<DriWrapper> drm_; DrmDeviceManager* drm_device_manager_; // Not owned. DriWindowDelegateManager* window_manager_; // Not owned. ScreenManager* screen_manager_; // Not owned. @@ -91,7 +88,6 @@ class DriGpuPlatformSupport : public GpuPlatformSupport { scoped_ptr<NativeDisplayDelegateDri> ndd_; ScopedVector<GpuPlatformSupport> handlers_; scoped_refptr<IPC::MessageFilter> filter_; - scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; }; } // namespace ui diff --git a/ui/ozone/platform/dri/native_display_delegate_dri.cc b/ui/ozone/platform/dri/native_display_delegate_dri.cc index 45acb2e..ff55ef4 100644 --- a/ui/ozone/platform/dri/native_display_delegate_dri.cc +++ b/ui/ozone/platform/dri/native_display_delegate_dri.cc @@ -5,13 +5,17 @@ #include "ui/ozone/platform/dri/native_display_delegate_dri.h" #include "base/bind.h" +#include "base/command_line.h" +#include "base/single_thread_task_runner.h" #include "ui/display/types/native_display_observer.h" #include "ui/events/ozone/device/device_event.h" +#include "ui/ozone/common/display_util.h" #include "ui/ozone/platform/dri/display_mode_dri.h" #include "ui/ozone/platform/dri/display_snapshot_dri.h" #include "ui/ozone/platform/dri/dri_util.h" #include "ui/ozone/platform/dri/dri_wrapper.h" #include "ui/ozone/platform/dri/screen_manager.h" +#include "ui/ozone/public/ozone_switches.h" namespace ui { @@ -73,41 +77,102 @@ class DisplaySnapshotComparator { } // namespace NativeDisplayDelegateDri::NativeDisplayDelegateDri( - ScreenManager* screen_manager) + ScreenManager* screen_manager, + const scoped_refptr<DriWrapper>& primary_device) : screen_manager_(screen_manager) { + devices_.push_back(primary_device); } NativeDisplayDelegateDri::~NativeDisplayDelegateDri() { } -DisplaySnapshot* NativeDisplayDelegateDri::FindDisplaySnapshot(int64_t id) { - for (size_t i = 0; i < cached_displays_.size(); ++i) - if (cached_displays_[i]->display_id() == id) - return cached_displays_[i]; +void NativeDisplayDelegateDri::ForceDPMSOn() { + for (size_t i = 0; i < cached_displays_.size(); ++i) { + DisplaySnapshotDri* dri_output = cached_displays_[i]; + if (dri_output->dpms_property()) + dri_output->drm()->SetProperty(dri_output->connector(), + dri_output->dpms_property()->prop_id, + DRM_MODE_DPMS_ON); + } +} - return NULL; +void NativeDisplayDelegateDri::InitializeIOTaskRunner( + const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { + DCHECK(!io_task_runner_); + base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); + // If not surfaceless, there isn't support for async page flips. + if (!cmd->HasSwitch(switches::kOzoneUseSurfaceless)) + return; + + io_task_runner_ = task_runner; + for (const auto& device : devices_) + device->InitializeTaskRunner(io_task_runner_); } -const DisplayMode* NativeDisplayDelegateDri::FindDisplayMode( - const gfx::Size& size, - bool is_interlaced, - float refresh_rate) { - for (size_t i = 0; i < cached_modes_.size(); ++i) - if (cached_modes_[i]->size() == size && - cached_modes_[i]->is_interlaced() == is_interlaced && - cached_modes_[i]->refresh_rate() == refresh_rate) - return cached_modes_[i]; +std::vector<DisplaySnapshot_Params> NativeDisplayDelegateDri::GetDisplays() { + RefreshDisplayList(); - return NULL; -} + std::vector<DisplaySnapshot_Params> displays; + for (size_t i = 0; i < cached_displays_.size(); ++i) + displays.push_back(GetDisplaySnapshotParams(*cached_displays_[i])); -void NativeDisplayDelegateDri::Initialize() { + return displays; } -void NativeDisplayDelegateDri::GrabServer() { +bool NativeDisplayDelegateDri::ConfigureDisplay( + int64_t id, + const DisplayMode_Params& mode_param, + const gfx::Point& origin) { + DisplaySnapshotDri* display = FindDisplaySnapshot(id); + if (!display) { + LOG(ERROR) << "There is no display with ID " << id; + return false; + } + + const DisplayMode* mode = NULL; + for (size_t i = 0; i < display->modes().size(); ++i) { + if (mode_param.size == display->modes()[i]->size() && + mode_param.is_interlaced == display->modes()[i]->is_interlaced() && + mode_param.refresh_rate == display->modes()[i]->refresh_rate()) { + mode = display->modes()[i]; + break; + } + } + + // If the display doesn't have the mode natively, then lookup the mode from + // other displays and try using it on the current display (some displays + // support panel fitting and they can use different modes even if the mode + // isn't explicitly declared). + if (!mode) + mode = FindDisplayMode(mode_param.size, mode_param.is_interlaced, + mode_param.refresh_rate); + + if (!mode) { + LOG(ERROR) << "Failed to find mode: size=" << mode_param.size.ToString() + << " is_interlaced=" << mode_param.is_interlaced + << " refresh_rate=" << mode_param.refresh_rate; + return false; + } + + bool success = + Configure(*display, static_cast<const DisplayModeDri*>(mode), origin); + if (success) { + display->set_origin(origin); + display->set_current_mode(mode); + } + + return success; } -void NativeDisplayDelegateDri::UngrabServer() { +bool NativeDisplayDelegateDri::DisableDisplay(int64_t id) { + DisplaySnapshotDri* display = FindDisplaySnapshot(id); + bool success = false; + if (display) + success = Configure(*display, NULL, gfx::Point()); + else + LOG(ERROR) << "There is no display with ID " << id; + + return success; } bool NativeDisplayDelegateDri::TakeDisplayControl() { @@ -130,23 +195,37 @@ bool NativeDisplayDelegateDri::RelinquishDisplayControl() { return true; } -void NativeDisplayDelegateDri::SyncWithServer() { +void NativeDisplayDelegateDri::AddGraphicsDevice(const base::FilePath& path) { + NOTIMPLEMENTED(); } -void NativeDisplayDelegateDri::SetBackgroundColor(uint32_t color_argb) { +void NativeDisplayDelegateDri::RemoveGraphicsDevice( + const base::FilePath& path) { + NOTIMPLEMENTED(); } -void NativeDisplayDelegateDri::ForceDPMSOn() { - for (size_t i = 0; i < cached_displays_.size(); ++i) { - DisplaySnapshotDri* dri_output = cached_displays_[i]; - if (dri_output->dpms_property()) - dri_output->drm()->SetProperty(dri_output->connector(), - dri_output->dpms_property()->prop_id, - DRM_MODE_DPMS_ON); - } +DisplaySnapshotDri* NativeDisplayDelegateDri::FindDisplaySnapshot(int64_t id) { + for (size_t i = 0; i < cached_displays_.size(); ++i) + if (cached_displays_[i]->display_id() == id) + return cached_displays_[i]; + + return NULL; } -std::vector<DisplaySnapshot*> NativeDisplayDelegateDri::GetDisplays() { +const DisplayModeDri* NativeDisplayDelegateDri::FindDisplayMode( + const gfx::Size& size, + bool is_interlaced, + float refresh_rate) { + for (size_t i = 0; i < cached_modes_.size(); ++i) + if (cached_modes_[i]->size() == size && + cached_modes_[i]->is_interlaced() == is_interlaced && + cached_modes_[i]->refresh_rate() == refresh_rate) + return static_cast<const DisplayModeDri*>(cached_modes_[i]); + + return NULL; +} + +void NativeDisplayDelegateDri::RefreshDisplayList() { ScopedVector<DisplaySnapshotDri> old_displays(cached_displays_.Pass()); ScopedVector<const DisplayMode> old_modes(cached_modes_.Pass()); @@ -175,56 +254,38 @@ std::vector<DisplaySnapshot*> NativeDisplayDelegateDri::GetDisplays() { } NotifyScreenManager(cached_displays_.get(), old_displays.get()); - - std::vector<DisplaySnapshot*> generic_displays(cached_displays_.begin(), - cached_displays_.end()); - return generic_displays; } -void NativeDisplayDelegateDri::GetDisplays( - const GetDisplaysCallback& callback) { - NOTREACHED(); -} - -void NativeDisplayDelegateDri::AddMode(const DisplaySnapshot& output, - const DisplayMode* mode) { -} - -bool NativeDisplayDelegateDri::Configure(const DisplaySnapshot& output, - const DisplayMode* mode, +bool NativeDisplayDelegateDri::Configure(const DisplaySnapshotDri& output, + const DisplayModeDri* mode, const gfx::Point& origin) { - const DisplaySnapshotDri& dri_output = - static_cast<const DisplaySnapshotDri&>(output); - - VLOG(1) << "DRM configuring: device=" - << dri_output.drm()->device_path().value() - << " crtc=" << dri_output.crtc() - << " connector=" << dri_output.connector() + VLOG(1) << "DRM configuring: device=" << output.drm()->device_path().value() + << " crtc=" << output.crtc() << " connector=" << output.connector() << " origin=" << origin.ToString() << " size=" << (mode ? mode->size().ToString() : "0x0"); if (mode) { if (!screen_manager_->ConfigureDisplayController( - dri_output.drm(), dri_output.crtc(), dri_output.connector(), origin, - static_cast<const DisplayModeDri*>(mode)->mode_info())) { + output.drm(), output.crtc(), output.connector(), origin, + mode->mode_info())) { VLOG(1) << "Failed to configure: device=" - << dri_output.drm()->device_path().value() - << " crtc=" << dri_output.crtc() - << " connector=" << dri_output.connector(); + << output.drm()->device_path().value() + << " crtc=" << output.crtc() + << " connector=" << output.connector(); return false; } } else { - if (dri_output.dpms_property()) { - dri_output.drm()->SetProperty(dri_output.connector(), - dri_output.dpms_property()->prop_id, - DRM_MODE_DPMS_OFF); + if (output.dpms_property()) { + output.drm()->SetProperty(output.connector(), + output.dpms_property()->prop_id, + DRM_MODE_DPMS_OFF); } - if (!screen_manager_->DisableDisplayController(dri_output.drm(), - dri_output.crtc())) { + if (!screen_manager_->DisableDisplayController(output.drm(), + output.crtc())) { VLOG(1) << "Failed to disable device=" - << dri_output.drm()->device_path().value() - << " crtc=" << dri_output.crtc(); + << output.drm()->device_path().value() + << " crtc=" << output.crtc(); return false; } } @@ -232,30 +293,17 @@ bool NativeDisplayDelegateDri::Configure(const DisplaySnapshot& output, return true; } -void NativeDisplayDelegateDri::Configure(const DisplaySnapshot& output, - const DisplayMode* mode, - const gfx::Point& origin, - const ConfigureCallback& callback) { - NOTREACHED(); -} - -void NativeDisplayDelegateDri::CreateFrameBuffer(const gfx::Size& size) { -} - -bool NativeDisplayDelegateDri::GetHDCPState(const DisplaySnapshot& output, +bool NativeDisplayDelegateDri::GetHDCPState(const DisplaySnapshotDri& output, HDCPState* state) { - const DisplaySnapshotDri& dri_output = - static_cast<const DisplaySnapshotDri&>(output); - ScopedDrmConnectorPtr connector( - dri_output.drm()->GetConnector(dri_output.connector())); + output.drm()->GetConnector(output.connector())); if (!connector) { - LOG(ERROR) << "Failed to get connector " << dri_output.connector(); + LOG(ERROR) << "Failed to get connector " << output.connector(); return false; } ScopedDrmPropertyPtr hdcp_property( - dri_output.drm()->GetProperty(connector.get(), kContentProtection)); + output.drm()->GetProperty(connector.get(), kContentProtection)); if (!hdcp_property) { LOG(ERROR) << "'" << kContentProtection << "' property doesn't exist."; return false; @@ -278,52 +326,27 @@ bool NativeDisplayDelegateDri::GetHDCPState(const DisplaySnapshot& output, return false; } -bool NativeDisplayDelegateDri::SetHDCPState(const DisplaySnapshot& output, +bool NativeDisplayDelegateDri::SetHDCPState(const DisplaySnapshotDri& output, HDCPState state) { - const DisplaySnapshotDri& dri_output = - static_cast<const DisplaySnapshotDri&>(output); - ScopedDrmConnectorPtr connector( - dri_output.drm()->GetConnector(dri_output.connector())); + output.drm()->GetConnector(output.connector())); if (!connector) { - LOG(ERROR) << "Failed to get connector " << dri_output.connector(); + LOG(ERROR) << "Failed to get connector " << output.connector(); return false; } ScopedDrmPropertyPtr hdcp_property( - dri_output.drm()->GetProperty(connector.get(), kContentProtection)); + output.drm()->GetProperty(connector.get(), kContentProtection)); if (!hdcp_property) { LOG(ERROR) << "'" << kContentProtection << "' property doesn't exist."; return false; } - return dri_output.drm()->SetProperty( - dri_output.connector(), hdcp_property->prop_id, + return output.drm()->SetProperty( + output.connector(), hdcp_property->prop_id, GetContentProtectionValue(hdcp_property.get(), state)); } -std::vector<ui::ColorCalibrationProfile> -NativeDisplayDelegateDri::GetAvailableColorCalibrationProfiles( - const ui::DisplaySnapshot& output) { - NOTIMPLEMENTED(); - return std::vector<ui::ColorCalibrationProfile>(); -} - -bool NativeDisplayDelegateDri::SetColorCalibrationProfile( - const ui::DisplaySnapshot& output, - ui::ColorCalibrationProfile new_profile) { - NOTIMPLEMENTED(); - return false; -} - -void NativeDisplayDelegateDri::AddObserver(NativeDisplayObserver* observer) { - observers_.AddObserver(observer); -} - -void NativeDisplayDelegateDri::RemoveObserver(NativeDisplayObserver* observer) { - observers_.RemoveObserver(observer); -} - void NativeDisplayDelegateDri::NotifyScreenManager( const std::vector<DisplaySnapshotDri*>& new_displays, const std::vector<DisplaySnapshotDri*>& old_displays) const { @@ -351,16 +374,4 @@ void NativeDisplayDelegateDri::NotifyScreenManager( } } -void NativeDisplayDelegateDri::AddGraphicsDevice( - const scoped_refptr<DriWrapper>& drm) { - devices_.push_back(drm); -} - -void NativeDisplayDelegateDri::RemoveGraphicsDevice( - const scoped_refptr<DriWrapper>& drm) { - auto it = std::find(devices_.begin(), devices_.end(), drm); - if (it != devices_.end()) - devices_.erase(it); -} - } // namespace ui diff --git a/ui/ozone/platform/dri/native_display_delegate_dri.h b/ui/ozone/platform/dri/native_display_delegate_dri.h index 6bd3faf..5ddb07a 100644 --- a/ui/ozone/platform/dri/native_display_delegate_dri.h +++ b/ui/ozone/platform/dri/native_display_delegate_dri.h @@ -5,63 +5,67 @@ #ifndef UI_OZONE_PLATFORM_DRI_NATIVE_DISPLAY_DELEGATE_DRI_H_ #define UI_OZONE_PLATFORM_DRI_NATIVE_DISPLAY_DELEGATE_DRI_H_ +#include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/memory/scoped_vector.h" -#include "base/observer_list.h" -#include "ui/display/types/native_display_delegate.h" +#include "ui/ozone/common/gpu/ozone_gpu_message_params.h" + +namespace base { +class FilePath; +class SingleThreadTaskRunner; +} namespace ui { class DeviceManager; class DisplaySnapshotDri; +class DisplayMode; +class DisplayModeDri; class DriWrapper; class ScreenManager; -class NativeDisplayDelegateDri : public NativeDisplayDelegate { +class NativeDisplayDelegateDri { public: - NativeDisplayDelegateDri(ScreenManager* screen_manager); - ~NativeDisplayDelegateDri() override; + NativeDisplayDelegateDri(ScreenManager* screen_manager, + const scoped_refptr<DriWrapper>& primary_device); + ~NativeDisplayDelegateDri(); - DisplaySnapshot* FindDisplaySnapshot(int64_t id); - const DisplayMode* FindDisplayMode(const gfx::Size& size, - bool is_interlaced, - float refresh_rate); + void InitializeIOTaskRunner( + const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); - std::vector<DisplaySnapshot*> GetDisplays(); - bool Configure(const DisplaySnapshot& output, - const DisplayMode* mode, - const gfx::Point& origin); + void ForceDPMSOn(); + + // Returns a list of the connected displays. When this is called the list of + // displays is refreshed. + std::vector<DisplaySnapshot_Params> GetDisplays(); + + bool ConfigureDisplay(int64_t id, + const DisplayMode_Params& mode, + const gfx::Point& origin); + bool DisableDisplay(int64_t id); + + // Takes/releases the control of the DRM devices. + bool TakeDisplayControl(); + bool RelinquishDisplayControl(); - void AddGraphicsDevice(const scoped_refptr<DriWrapper>& dri); - void RemoveGraphicsDevice(const scoped_refptr<DriWrapper>& dri); - - // NativeDisplayDelegate overrides: - void Initialize() override; - void GrabServer() override; - void UngrabServer() override; - bool TakeDisplayControl() override; - bool RelinquishDisplayControl() override; - void SyncWithServer() override; - void SetBackgroundColor(uint32_t color_argb) override; - void ForceDPMSOn() override; - void GetDisplays(const GetDisplaysCallback& callback) override; - void AddMode(const DisplaySnapshot& output, const DisplayMode* mode) override; - void Configure(const DisplaySnapshot& output, - const DisplayMode* mode, - const gfx::Point& origin, - const ConfigureCallback& callback) override; - void CreateFrameBuffer(const gfx::Size& size) override; - bool GetHDCPState(const DisplaySnapshot& output, HDCPState* state) override; - bool SetHDCPState(const DisplaySnapshot& output, HDCPState state) override; - std::vector<ui::ColorCalibrationProfile> GetAvailableColorCalibrationProfiles( - const ui::DisplaySnapshot& output) override; - bool SetColorCalibrationProfile( - const ui::DisplaySnapshot& output, - ui::ColorCalibrationProfile new_profile) override; - void AddObserver(NativeDisplayObserver* observer) override; - void RemoveObserver(NativeDisplayObserver* observer) override; + // Called on DRM hotplug events to add/remove a DRM device. + void AddGraphicsDevice(const base::FilePath& path); + void RemoveGraphicsDevice(const base::FilePath& path); private: + DisplaySnapshotDri* FindDisplaySnapshot(int64_t id); + const DisplayModeDri* FindDisplayMode(const gfx::Size& size, + bool is_interlaced, + float refresh_rate); + + void RefreshDisplayList(); + bool Configure(const DisplaySnapshotDri& output, + const DisplayModeDri* mode, + const gfx::Point& origin); + + bool GetHDCPState(const DisplaySnapshotDri& output, HDCPState* state); + bool SetHDCPState(const DisplaySnapshotDri& output, HDCPState state); + // Notify ScreenManager of all the displays that were present before the // update but are gone after the update. void NotifyScreenManager( @@ -69,12 +73,12 @@ class NativeDisplayDelegateDri : public NativeDisplayDelegate { const std::vector<DisplaySnapshotDri*>& old_displays) const; ScreenManager* screen_manager_; // Not owned. + scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; std::vector<scoped_refptr<DriWrapper>> devices_; // Modes can be shared between different displays, so we need to keep track // of them independently for cleanup. ScopedVector<const DisplayMode> cached_modes_; ScopedVector<DisplaySnapshotDri> cached_displays_; - ObserverList<NativeDisplayObserver> observers_; DISALLOW_COPY_AND_ASSIGN(NativeDisplayDelegateDri); }; diff --git a/ui/ozone/platform/dri/ozone_platform_dri.cc b/ui/ozone/platform/dri/ozone_platform_dri.cc index a78f498..8ffcabe 100644 --- a/ui/ozone/platform/dri/ozone_platform_dri.cc +++ b/ui/ozone/platform/dri/ozone_platform_dri.cc @@ -100,10 +100,9 @@ class OzonePlatformDri : public OzonePlatform { surface_factory_ozone_.reset( new DriSurfaceFactory(&window_delegate_manager_)); scoped_ptr<NativeDisplayDelegateDri> ndd( - new NativeDisplayDelegateDri(screen_manager_.get())); - ndd->Initialize(); + new NativeDisplayDelegateDri(screen_manager_.get(), dri_)); gpu_platform_support_.reset(new DriGpuPlatformSupport( - dri_, drm_device_manager_.get(), &window_delegate_manager_, + drm_device_manager_.get(), &window_delegate_manager_, screen_manager_.get(), ndd.Pass())); gpu_platform_support_host_.reset(new DriGpuPlatformSupportHost()); window_manager_.reset(new DriWindowManager()); diff --git a/ui/ozone/platform/dri/ozone_platform_gbm.cc b/ui/ozone/platform/dri/ozone_platform_gbm.cc index 03c2b22..ade1511 100644 --- a/ui/ozone/platform/dri/ozone_platform_gbm.cc +++ b/ui/ozone/platform/dri/ozone_platform_gbm.cc @@ -171,10 +171,9 @@ class OzonePlatformGbm : public OzonePlatform { surface_factory_ozone_->InitializeGpu(gbm_, drm_device_manager_.get(), window_delegate_manager_.get()); scoped_ptr<NativeDisplayDelegateDri> ndd( - new NativeDisplayDelegateDri(screen_manager_.get())); - ndd->Initialize(); + new NativeDisplayDelegateDri(screen_manager_.get(), gbm_)); gpu_platform_support_.reset(new DriGpuPlatformSupport( - gbm_, drm_device_manager_.get(), window_delegate_manager_.get(), + drm_device_manager_.get(), window_delegate_manager_.get(), screen_manager_.get(), ndd.Pass())); } |