ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / ui / ozone / platform / dri / screen_manager.h
blobbf8fed9a25210646cdad7648c855939c962c5a8f
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;
17 namespace gfx {
18 class Point;
19 class Rect;
20 class Size;
21 } // namespace gfx
23 namespace ui {
25 class DrmDevice;
26 class ScanoutBufferGenerator;
28 // Responsible for keeping track of active displays and configuring them.
29 class OZONE_EXPORT ScreenManager {
30 public:
31 ScreenManager(ScanoutBufferGenerator* surface_generator);
32 virtual ~ScreenManager();
34 // Register a display controller. This must be called before trying to
35 // configure it.
36 void AddDisplayController(const scoped_refptr<DrmDevice>& drm,
37 uint32_t crtc,
38 uint32_t connector);
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,
43 uint32_t crtc);
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,
48 uint32_t crtc,
49 uint32_t connector,
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,
56 uint32_t crtc);
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);
66 private:
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,
73 uint32_t crtc);
75 // Returns an iterator into |controllers_| for the controller located at
76 // |origin|.
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,
91 uint32_t crtc,
92 uint32_t connector);
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);
103 } // namespace ui
105 #endif // UI_OZONE_PLATFORM_DRI_SCREEN_MANAGER_H_