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_
10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h"
12 #include "ui/gfx/native_widget_types.h"
13 #include "ui/ozone/platform/dri/hardware_display_controller.h"
15 typedef struct _drmModeModeInfo drmModeModeInfo
;
26 class ScanoutSurfaceGenerator
;
28 // Responsible for keeping track of active displays and configuring them.
29 class OZONE_EXPORT ScreenManager
{
31 ScreenManager(DriWrapper
* dri
, ScanoutSurfaceGenerator
* surface_generator
);
32 virtual ~ScreenManager();
34 // Remove a display controller from the list of active controllers. The
35 // controller is removed since it was disconnected.
36 void RemoveDisplayController(uint32_t crtc
, uint32_t connector
);
38 // Configure (and add if not present) a display controller. The display
39 // controller is identified by (|crtc|, |connector|) and the controller is
40 // modeset using |mode|.
41 bool ConfigureDisplayController(uint32_t crtc
,
43 const drmModeModeInfo
& mode
);
45 // Disable the display controller identified by (|crtc|, |connector|). Note,
46 // the controller may still be connected, so this does not remove the
48 bool DisableDisplayController(uint32_t crtc
, uint32_t connector
);
50 // Returns a reference to the display controller associated with |widget|.
51 // This returns a weak reference since the display controller may be destroyed
52 // at any point in time, but the changes are propagated to the compositor much
53 // later (Compositor owns SurfaceOzone*, which is responsible for updating the
55 base::WeakPtr
<HardwareDisplayController
> GetDisplayController(
56 gfx::AcceleratedWidget widget
);
59 typedef std::map
<gfx::AcceleratedWidget
, HardwareDisplayController
*>
60 HardwareDisplayControllerMap
;
62 // Returns an iterator into |controllers_| for the controller identified by
63 // (|crtc|, |connector|).
64 HardwareDisplayControllerMap::iterator
FindDisplayController(
65 uint32_t crtc
, uint32_t connector
);
67 // On non CrOS builds there is no display configurator to look-up available
68 // displays and initialize the HDCs. In such cases this is called internally
69 // to initialize a display.
70 virtual void ForceInitializationOfPrimaryDisplay();
72 DriWrapper
* dri_
; // Not owned.
73 ScanoutSurfaceGenerator
* surface_generator_
; // Not owned.
74 // Mapping between an accelerated widget and an active display.
75 HardwareDisplayControllerMap controllers_
;
76 gfx::AcceleratedWidget last_added_widget_
;
78 DISALLOW_COPY_AND_ASSIGN(ScreenManager
);
83 #endif // UI_OZONE_PLATFORM_DRI_SCREEN_MANAGER_H_