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.
5 #ifndef UI_OZONE_PLATFORM_DRI_SCREEN_MANAGER_H_
6 #define UI_OZONE_PLATFORM_DRI_SCREEN_MANAGER_H_
8 #include "base/macros.h"
9 #include "base/memory/scoped_vector.h"
10 #include "base/observer_list.h"
11 #include "ui/ozone/platform/dri/display_change_observer.h"
12 #include "ui/ozone/platform/dri/hardware_display_controller.h"
14 typedef struct _drmModeModeInfo drmModeModeInfo
;
25 class ScanoutBufferGenerator
;
27 // Responsible for keeping track of active displays and configuring them.
30 ScreenManager(DriWrapper
* dri
, ScanoutBufferGenerator
* surface_generator
);
31 virtual ~ScreenManager();
33 // Register a display controller. This must be called before trying to
35 void AddDisplayController(DriWrapper
* dri
, uint32_t crtc
, uint32_t connector
);
37 // Remove a display controller from the list of active controllers. The
38 // controller is removed since it was disconnected.
39 void RemoveDisplayController(uint32_t crtc
);
41 // Configure a display controller. The display controller is identified by
42 // (|crtc|, |connector|) and the controller is modeset using |mode|.
43 bool ConfigureDisplayController(uint32_t crtc
,
45 const gfx::Point
& origin
,
46 const drmModeModeInfo
& mode
);
48 // Disable the display controller identified by |crtc|. Note, the controller
49 // may still be connected, so this does not remove the controller.
50 bool DisableDisplayController(uint32_t crtc
);
52 // Returns a reference to the display controller configured to display within
53 // |bounds|. If the caller caches the controller it must also register as an
54 // observer to be notified when the controller goes out of scope.
55 HardwareDisplayController
* GetDisplayController(const gfx::Rect
& bounds
);
57 void AddObserver(DisplayChangeObserver
* observer
);
58 void RemoveObserver(DisplayChangeObserver
* observer
);
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();
66 typedef ScopedVector
<HardwareDisplayController
> HardwareDisplayControllers
;
68 // Returns an iterator into |controllers_| for the controller identified by
69 // (|crtc|, |connector|).
70 HardwareDisplayControllers::iterator
FindDisplayController(uint32_t crtc
);
72 // Returns an iterator into |controllers_| for the controller located at
74 HardwareDisplayControllers::iterator
FindActiveDisplayControllerByLocation(
75 const gfx::Rect
& bounds
);
77 // Perform modesetting in |controller| using |origin| and |mode|.
78 bool ModesetDisplayController(HardwareDisplayController
* controller
,
79 const gfx::Point
& origin
,
80 const drmModeModeInfo
& mode
);
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
,
90 DriWrapper
* dri_
; // Not owned.
91 ScanoutBufferGenerator
* buffer_generator_
; // Not owned.
92 // List of display controllers (active and disabled).
93 HardwareDisplayControllers controllers_
;
95 ObserverList
<DisplayChangeObserver
> observers_
;
97 DISALLOW_COPY_AND_ASSIGN(ScreenManager
);
102 #endif // UI_OZONE_PLATFORM_DRI_SCREEN_MANAGER_H_