Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Unified Diff: ui/ozone/platform/dri/screen_manager.cc

Issue 844343002: [Ozone-DRI] Add display observer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update GYP Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/ozone/platform/dri/screen_manager.h ('k') | ui/ozone/platform/dri/screen_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/ozone/platform/dri/screen_manager.cc
diff --git a/ui/ozone/platform/dri/screen_manager.cc b/ui/ozone/platform/dri/screen_manager.cc
index 6305830688da5c1d9d7c7ffb1e3fde280370ed7e..53b397cd85a4c1cb4b483bb88d9e0f8cb3a62694 100644
--- a/ui/ozone/platform/dri/screen_manager.cc
+++ b/ui/ozone/platform/dri/screen_manager.cc
@@ -65,6 +65,7 @@ ScreenManager::ScreenManager(DriWrapper* dri,
}
ScreenManager::~ScreenManager() {
+ DCHECK_EQ(0u, observers_.size());
}
void ScreenManager::AddDisplayController(DriWrapper* dri,
@@ -89,8 +90,11 @@ void ScreenManager::RemoveDisplayController(uint32_t crtc) {
if (it != controllers_.end()) {
bool is_mirrored = (*it)->IsMirrored();
(*it)->RemoveCrtc(crtc);
- if (!is_mirrored)
+ if (!is_mirrored) {
+ FOR_EACH_OBSERVER(DisplayChangeObserver, observers_,
+ OnDisplayRemoved(*it));
controllers_.erase(it);
+ }
}
}
@@ -105,7 +109,6 @@ bool ScreenManager::ConfigureDisplayController(uint32_t crtc,
<< ") doesn't exist.";
HardwareDisplayController* controller = *it;
- controller = *it;
// If nothing changed just enable the controller. Note, we perform an exact
// comparison on the mode since the refresh rate may have changed.
if (SameMode(mode, controller->get_mode()) &&
@@ -119,6 +122,8 @@ bool ScreenManager::ConfigureDisplayController(uint32_t crtc,
return HandleMirrorMode(it, mirror, crtc, connector);
}
+ FOR_EACH_OBSERVER(DisplayChangeObserver, observers_,
+ OnDisplayChanged(controller));
// Just re-enable the controller to re-use the current state.
return controller->Enable();
}
@@ -159,7 +164,7 @@ bool ScreenManager::DisableDisplayController(uint32_t crtc) {
return false;
}
-base::WeakPtr<HardwareDisplayController> ScreenManager::GetDisplayController(
+HardwareDisplayController* ScreenManager::GetDisplayController(
const gfx::Rect& bounds) {
// TODO(dnicoara): Remove hack once TestScreen uses a simple Ozone display
// configuration reader and ScreenManager is called from there to create the
@@ -170,9 +175,17 @@ base::WeakPtr<HardwareDisplayController> ScreenManager::GetDisplayController(
HardwareDisplayControllers::iterator it =
FindActiveDisplayControllerByLocation(bounds);
if (it != controllers_.end())
- return (*it)->AsWeakPtr();
+ return *it;
+
+ return nullptr;
+}
+
+void ScreenManager::AddObserver(DisplayChangeObserver* observer) {
+ observers_.AddObserver(observer);
+}
- return base::WeakPtr<HardwareDisplayController>();
+void ScreenManager::RemoveObserver(DisplayChangeObserver* observer) {
+ observers_.RemoveObserver(observer);
}
ScreenManager::HardwareDisplayControllers::iterator
@@ -244,6 +257,8 @@ bool ScreenManager::ModesetDisplayController(
return false;
}
+ FOR_EACH_OBSERVER(DisplayChangeObserver, observers_,
+ OnDisplayChanged(controller));
return true;
}
@@ -254,6 +269,10 @@ bool ScreenManager::HandleMirrorMode(
uint32_t connector) {
(*mirror)->AddCrtc((*original)->RemoveCrtc(crtc));
if ((*mirror)->Enable()) {
+ FOR_EACH_OBSERVER(DisplayChangeObserver, observers_,
+ OnDisplayRemoved(*original));
+ FOR_EACH_OBSERVER(DisplayChangeObserver, observers_,
+ OnDisplayChanged(*mirror));
controllers_.erase(original);
return true;
}
« no previous file with comments | « ui/ozone/platform/dri/screen_manager.h ('k') | ui/ozone/platform/dri/screen_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698