| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef UI_OZONE_PLATFORM_DRI_SCREEN_MANAGER_H_ | |
| 6 #define UI_OZONE_PLATFORM_DRI_SCREEN_MANAGER_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "base/memory/scoped_vector.h" | |
| 10 #include "base/memory/weak_ptr.h" | |
| 11 #include "ui/ozone/platform/dri/hardware_display_controller.h" | |
| 12 | |
| 13 typedef struct _drmModeModeInfo drmModeModeInfo; | |
| 14 | |
| 15 namespace gfx { | |
| 16 class Point; | |
| 17 class Rect; | |
| 18 class Size; | |
| 19 } // namespace gfx | |
| 20 | |
| 21 namespace ui { | |
| 22 | |
| 23 class DriWrapper; | |
| 24 class ScanoutBufferGenerator; | |
| 25 | |
| 26 // Responsible for keeping track of active displays and configuring them. | |
| 27 class ScreenManager { | |
| 28 public: | |
| 29 ScreenManager(DriWrapper* dri, ScanoutBufferGenerator* surface_generator); | |
| 30 virtual ~ScreenManager(); | |
| 31 | |
| 32 // Register a display controller. This must be called before trying to | |
| 33 // configure it. | |
| 34 void AddDisplayController(DriWrapper* dri, uint32_t crtc, uint32_t connector); | |
| 35 | |
| 36 // Remove a display controller from the list of active controllers. The | |
| 37 // controller is removed since it was disconnected. | |
| 38 void RemoveDisplayController(uint32_t crtc); | |
| 39 | |
| 40 // Configure a display controller. The display controller is identified by | |
| 41 // (|crtc|, |connector|) and the controller is modeset using |mode|. | |
| 42 bool ConfigureDisplayController(uint32_t crtc, | |
| 43 uint32_t connector, | |
| 44 const gfx::Point& origin, | |
| 45 const drmModeModeInfo& mode); | |
| 46 | |
| 47 // Disable the display controller identified by |crtc|. Note, the controller | |
| 48 // may still be connected, so this does not remove the controller. | |
| 49 bool DisableDisplayController(uint32_t crtc); | |
| 50 | |
| 51 // Returns a reference to the display controller configured to display within | |
| 52 // |bounds|. | |
| 53 // This returns a weak reference since the display controller may be destroyed | |
| 54 // at any point in time, but the changes are propagated to the compositor much | |
| 55 // later (Compositor owns SurfaceOzone*, which is responsible for updating the | |
| 56 // display surface). | |
| 57 base::WeakPtr<HardwareDisplayController> GetDisplayController( | |
| 58 const gfx::Rect& bounds); | |
| 59 | |
| 60 // On non CrOS builds there is no display configurator to look-up available | |
| 61 // displays and initialize the HDCs. In such cases this is called internally | |
| 62 // to initialize a display. | |
| 63 virtual void ForceInitializationOfPrimaryDisplay(); | |
| 64 | |
| 65 private: | |
| 66 typedef ScopedVector<HardwareDisplayController> HardwareDisplayControllers; | |
| 67 | |
| 68 // Returns an iterator into |controllers_| for the controller identified by | |
| 69 // (|crtc|, |connector|). | |
| 70 HardwareDisplayControllers::iterator FindDisplayController(uint32_t crtc); | |
| 71 | |
| 72 // Returns an iterator into |controllers_| for the controller located at | |
| 73 // |origin|. | |
| 74 HardwareDisplayControllers::iterator FindActiveDisplayControllerByLocation( | |
| 75 const gfx::Rect& bounds); | |
| 76 | |
| 77 // Perform modesetting in |controller| using |origin| and |mode|. | |
| 78 bool ModesetDisplayController(HardwareDisplayController* controller, | |
| 79 const gfx::Point& origin, | |
| 80 const drmModeModeInfo& mode); | |
| 81 | |
| 82 // Tries to set the controller identified by (|crtc|, |connector|) to mirror | |
| 83 // those in |mirror|. |original| is an iterator to the HDC where the | |
| 84 // controller is currently present. | |
| 85 bool HandleMirrorMode(HardwareDisplayControllers::iterator original, | |
| 86 HardwareDisplayControllers::iterator mirror, | |
| 87 uint32_t crtc, | |
| 88 uint32_t connector); | |
| 89 | |
| 90 DriWrapper* dri_; // Not owned. | |
| 91 ScanoutBufferGenerator* buffer_generator_; // Not owned. | |
| 92 // List of display controllers (active and disabled). | |
| 93 HardwareDisplayControllers controllers_; | |
| 94 | |
| 95 DISALLOW_COPY_AND_ASSIGN(ScreenManager); | |
| 96 }; | |
| 97 | |
| 98 } // namespace ui | |
| 99 | |
| 100 #endif // UI_OZONE_PLATFORM_DRI_SCREEN_MANAGER_H_ | |
| OLD | NEW |