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/ozone_export.h"
12 #include "ui/ozone/platform/dri/display_change_observer.h"
13 #include "ui/ozone/platform/dri/hardware_display_controller.h"
15 typedef struct _drmModeModeInfo drmModeModeInfo
;
26 class ScanoutBufferGenerator
;
28 // Responsible for keeping track of active displays and configuring them.
29 class OZONE_EXPORT ScreenManager
{
31 ScreenManager(ScanoutBufferGenerator
* surface_generator
);
32 virtual ~ScreenManager();
34 // Register a display controller. This must be called before trying to
36 void AddDisplayController(const scoped_refptr
<DrmDevice
>& drm
,
40 // Remove a display controller from the list of active controllers. The
41 // controller is removed since it was disconnected.
42 void RemoveDisplayController(const scoped_refptr
<DrmDevice
>& drm
,
45 // Configure a display controller. The display controller is identified by
46 // (|crtc|, |connector|) and the controller is modeset using |mode|.
47 bool ConfigureDisplayController(const scoped_refptr
<DrmDevice
>& drm
,
50 const gfx::Point
& origin
,
51 const drmModeModeInfo
& mode
);
53 // Disable the display controller identified by |crtc|. Note, the controller
54 // may still be connected, so this does not remove the controller.
55 bool DisableDisplayController(const scoped_refptr
<DrmDevice
>& drm
,
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
60 // observer to be notified when the controller goes out of scope.
61 HardwareDisplayController
* GetDisplayController(const gfx::Rect
& bounds
);
63 void AddObserver(DisplayChangeObserver
* observer
);
64 void RemoveObserver(DisplayChangeObserver
* observer
);
67 typedef ScopedVector
<HardwareDisplayController
> HardwareDisplayControllers
;
69 // Returns an iterator into |controllers_| for the controller identified by
70 // (|crtc|, |connector|).
71 HardwareDisplayControllers::iterator
FindDisplayController(
72 const scoped_refptr
<DrmDevice
>& drm
,
75 // Returns an iterator into |controllers_| for the controller located at
77 HardwareDisplayControllers::iterator
FindActiveDisplayControllerByLocation(
78 const gfx::Rect
& bounds
);
80 // Perform modesetting in |controller| using |origin| and |mode|.
81 bool ModesetDisplayController(HardwareDisplayController
* controller
,
82 const gfx::Point
& origin
,
83 const drmModeModeInfo
& mode
);
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
87 // controller is currently present.
88 bool HandleMirrorMode(HardwareDisplayControllers::iterator original
,
89 HardwareDisplayControllers::iterator mirror
,
90 const scoped_refptr
<DrmDevice
>& drm
,
94 ScanoutBufferGenerator
* buffer_generator_
; // Not owned.
95 // List of display controllers (active and disabled).
96 HardwareDisplayControllers controllers_
;
98 ObserverList
<DisplayChangeObserver
> observers_
;
100 DISALLOW_COPY_AND_ASSIGN(ScreenManager
);
105 #endif // UI_OZONE_PLATFORM_DRI_SCREEN_MANAGER_H_