| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_OZONE_PLATFORM_DRI_SCREEN_MANAGER_H_ | 5 #ifndef UI_OZONE_PLATFORM_DRI_SCREEN_MANAGER_H_ |
| 6 #define UI_OZONE_PLATFORM_DRI_SCREEN_MANAGER_H_ | 6 #define UI_OZONE_PLATFORM_DRI_SCREEN_MANAGER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
| 11 #include "ui/ozone/ozone_export.h" | 11 #include "ui/ozone/ozone_export.h" |
| 12 #include "ui/ozone/platform/dri/display_change_observer.h" | 12 #include "ui/ozone/platform/dri/display_change_observer.h" |
| 13 #include "ui/ozone/platform/dri/hardware_display_controller.h" | 13 #include "ui/ozone/platform/dri/hardware_display_controller.h" |
| 14 | 14 |
| 15 typedef struct _drmModeModeInfo drmModeModeInfo; | 15 typedef struct _drmModeModeInfo drmModeModeInfo; |
| 16 | 16 |
| 17 namespace gfx { | 17 namespace gfx { |
| 18 class Point; | 18 class Point; |
| 19 class Rect; | 19 class Rect; |
| 20 class Size; | 20 class Size; |
| 21 } // namespace gfx | 21 } // namespace gfx |
| 22 | 22 |
| 23 namespace ui { | 23 namespace ui { |
| 24 | 24 |
| 25 class DriWrapper; | 25 class DrmDevice; |
| 26 class ScanoutBufferGenerator; | 26 class ScanoutBufferGenerator; |
| 27 | 27 |
| 28 // Responsible for keeping track of active displays and configuring them. | 28 // Responsible for keeping track of active displays and configuring them. |
| 29 class OZONE_EXPORT ScreenManager { | 29 class OZONE_EXPORT ScreenManager { |
| 30 public: | 30 public: |
| 31 ScreenManager(ScanoutBufferGenerator* surface_generator); | 31 ScreenManager(ScanoutBufferGenerator* surface_generator); |
| 32 virtual ~ScreenManager(); | 32 virtual ~ScreenManager(); |
| 33 | 33 |
| 34 // Register a display controller. This must be called before trying to | 34 // Register a display controller. This must be called before trying to |
| 35 // configure it. | 35 // configure it. |
| 36 void AddDisplayController(const scoped_refptr<DriWrapper>& dri, | 36 void AddDisplayController(const scoped_refptr<DrmDevice>& drm, |
| 37 uint32_t crtc, | 37 uint32_t crtc, |
| 38 uint32_t connector); | 38 uint32_t connector); |
| 39 | 39 |
| 40 // Remove a display controller from the list of active controllers. The | 40 // Remove a display controller from the list of active controllers. The |
| 41 // controller is removed since it was disconnected. | 41 // controller is removed since it was disconnected. |
| 42 void RemoveDisplayController(const scoped_refptr<DriWrapper>& dri, | 42 void RemoveDisplayController(const scoped_refptr<DrmDevice>& drm, |
| 43 uint32_t crtc); | 43 uint32_t crtc); |
| 44 | 44 |
| 45 // Configure a display controller. The display controller is identified by | 45 // Configure a display controller. The display controller is identified by |
| 46 // (|crtc|, |connector|) and the controller is modeset using |mode|. | 46 // (|crtc|, |connector|) and the controller is modeset using |mode|. |
| 47 bool ConfigureDisplayController(const scoped_refptr<DriWrapper>& dri, | 47 bool ConfigureDisplayController(const scoped_refptr<DrmDevice>& drm, |
| 48 uint32_t crtc, | 48 uint32_t crtc, |
| 49 uint32_t connector, | 49 uint32_t connector, |
| 50 const gfx::Point& origin, | 50 const gfx::Point& origin, |
| 51 const drmModeModeInfo& mode); | 51 const drmModeModeInfo& mode); |
| 52 | 52 |
| 53 // Disable the display controller identified by |crtc|. Note, the controller | 53 // Disable the display controller identified by |crtc|. Note, the controller |
| 54 // may still be connected, so this does not remove the controller. | 54 // may still be connected, so this does not remove the controller. |
| 55 bool DisableDisplayController(const scoped_refptr<DriWrapper>& dri, | 55 bool DisableDisplayController(const scoped_refptr<DrmDevice>& drm, |
| 56 uint32_t crtc); | 56 uint32_t crtc); |
| 57 | 57 |
| 58 // Returns a reference to the display controller configured to display within | 58 // Returns a reference to the display controller configured to display within |
| 59 // |bounds|. If the caller caches the controller it must also register as an | 59 // |bounds|. If the caller caches the controller it must also register as an |
| 60 // observer to be notified when the controller goes out of scope. | 60 // observer to be notified when the controller goes out of scope. |
| 61 HardwareDisplayController* GetDisplayController(const gfx::Rect& bounds); | 61 HardwareDisplayController* GetDisplayController(const gfx::Rect& bounds); |
| 62 | 62 |
| 63 void AddObserver(DisplayChangeObserver* observer); | 63 void AddObserver(DisplayChangeObserver* observer); |
| 64 void RemoveObserver(DisplayChangeObserver* observer); | 64 void RemoveObserver(DisplayChangeObserver* observer); |
| 65 | 65 |
| 66 private: | 66 private: |
| 67 typedef ScopedVector<HardwareDisplayController> HardwareDisplayControllers; | 67 typedef ScopedVector<HardwareDisplayController> HardwareDisplayControllers; |
| 68 | 68 |
| 69 // Returns an iterator into |controllers_| for the controller identified by | 69 // Returns an iterator into |controllers_| for the controller identified by |
| 70 // (|crtc|, |connector|). | 70 // (|crtc|, |connector|). |
| 71 HardwareDisplayControllers::iterator FindDisplayController( | 71 HardwareDisplayControllers::iterator FindDisplayController( |
| 72 const scoped_refptr<DriWrapper>& drm, | 72 const scoped_refptr<DrmDevice>& drm, |
| 73 uint32_t crtc); | 73 uint32_t crtc); |
| 74 | 74 |
| 75 // Returns an iterator into |controllers_| for the controller located at | 75 // Returns an iterator into |controllers_| for the controller located at |
| 76 // |origin|. | 76 // |origin|. |
| 77 HardwareDisplayControllers::iterator FindActiveDisplayControllerByLocation( | 77 HardwareDisplayControllers::iterator FindActiveDisplayControllerByLocation( |
| 78 const gfx::Rect& bounds); | 78 const gfx::Rect& bounds); |
| 79 | 79 |
| 80 // Perform modesetting in |controller| using |origin| and |mode|. | 80 // Perform modesetting in |controller| using |origin| and |mode|. |
| 81 bool ModesetDisplayController(HardwareDisplayController* controller, | 81 bool ModesetDisplayController(HardwareDisplayController* controller, |
| 82 const gfx::Point& origin, | 82 const gfx::Point& origin, |
| 83 const drmModeModeInfo& mode); | 83 const drmModeModeInfo& mode); |
| 84 | 84 |
| 85 // Tries to set the controller identified by (|crtc|, |connector|) to mirror | 85 // Tries to set the controller identified by (|crtc|, |connector|) to mirror |
| 86 // those in |mirror|. |original| is an iterator to the HDC where the | 86 // those in |mirror|. |original| is an iterator to the HDC where the |
| 87 // controller is currently present. | 87 // controller is currently present. |
| 88 bool HandleMirrorMode(HardwareDisplayControllers::iterator original, | 88 bool HandleMirrorMode(HardwareDisplayControllers::iterator original, |
| 89 HardwareDisplayControllers::iterator mirror, | 89 HardwareDisplayControllers::iterator mirror, |
| 90 const scoped_refptr<DriWrapper>& drm, | 90 const scoped_refptr<DrmDevice>& drm, |
| 91 uint32_t crtc, | 91 uint32_t crtc, |
| 92 uint32_t connector); | 92 uint32_t connector); |
| 93 | 93 |
| 94 ScanoutBufferGenerator* buffer_generator_; // Not owned. | 94 ScanoutBufferGenerator* buffer_generator_; // Not owned. |
| 95 // List of display controllers (active and disabled). | 95 // List of display controllers (active and disabled). |
| 96 HardwareDisplayControllers controllers_; | 96 HardwareDisplayControllers controllers_; |
| 97 | 97 |
| 98 ObserverList<DisplayChangeObserver> observers_; | 98 ObserverList<DisplayChangeObserver> observers_; |
| 99 | 99 |
| 100 DISALLOW_COPY_AND_ASSIGN(ScreenManager); | 100 DISALLOW_COPY_AND_ASSIGN(ScreenManager); |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 } // namespace ui | 103 } // namespace ui |
| 104 | 104 |
| 105 #endif // UI_OZONE_PLATFORM_DRI_SCREEN_MANAGER_H_ | 105 #endif // UI_OZONE_PLATFORM_DRI_SCREEN_MANAGER_H_ |
| OLD | NEW |