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/memory/weak_ptr.h"
11 #include "ui/ozone/platform/dri/hardware_display_controller.h"
13 typedef struct _drmModeModeInfo drmModeModeInfo;
24 class ScanoutBufferGenerator;
26 // Responsible for keeping track of active displays and configuring them.
29 ScreenManager(DriWrapper* dri, ScanoutBufferGenerator* surface_generator);
30 virtual ~ScreenManager();
32 // Register a display controller. This must be called before trying to
34 void AddDisplayController(uint32_t crtc, uint32_t connector);
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);
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,
44 const gfx::Point& origin,
45 const drmModeModeInfo& mode);
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);
51 // Returns a reference to the display controller configured to display within
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
57 base::WeakPtr<HardwareDisplayController> GetDisplayController(
58 const gfx::Rect& bounds);
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 DISALLOW_COPY_AND_ASSIGN(ScreenManager);
100 #endif // UI_OZONE_PLATFORM_DRI_SCREEN_MANAGER_H_