Fix search results being clipped in app list.
[chromium-blink-merge.git] / ui / ozone / platform / drm / gpu / screen_manager.h
blob2732769f17ad32099cbbd84a5446a9052b683098
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_DRM_GPU_SCREEN_MANAGER_H_
6 #define UI_OZONE_PLATFORM_DRM_GPU_SCREEN_MANAGER_H_
8 #include "base/containers/scoped_ptr_hash_map.h"
9 #include "base/macros.h"
10 #include "base/memory/scoped_vector.h"
11 #include "base/observer_list.h"
12 #include "ui/gfx/native_widget_types.h"
13 #include "ui/ozone/ozone_export.h"
14 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h"
16 typedef struct _drmModeModeInfo drmModeModeInfo;
18 namespace gfx {
19 class Point;
20 class Rect;
21 class Size;
22 } // namespace gfx
24 namespace ui {
26 class DrmDevice;
27 class DrmWindow;
28 class ScanoutBufferGenerator;
30 // Responsible for keeping track of active displays and configuring them.
31 class OZONE_EXPORT ScreenManager {
32 public:
33 ScreenManager(ScanoutBufferGenerator* surface_generator);
34 virtual ~ScreenManager();
36 // Register a display controller. This must be called before trying to
37 // configure it.
38 void AddDisplayController(const scoped_refptr<DrmDevice>& drm,
39 uint32_t crtc,
40 uint32_t connector);
42 // Remove a display controller from the list of active controllers. The
43 // controller is removed since it was disconnected.
44 void RemoveDisplayController(const scoped_refptr<DrmDevice>& drm,
45 uint32_t crtc);
47 // Configure a display controller. The display controller is identified by
48 // (|crtc|, |connector|) and the controller is modeset using |mode|.
49 bool ConfigureDisplayController(const scoped_refptr<DrmDevice>& drm,
50 uint32_t crtc,
51 uint32_t connector,
52 const gfx::Point& origin,
53 const drmModeModeInfo& mode);
55 // Disable the display controller identified by |crtc|. Note, the controller
56 // may still be connected, so this does not remove the controller.
57 bool DisableDisplayController(const scoped_refptr<DrmDevice>& drm,
58 uint32_t crtc);
60 // Returns a reference to the display controller configured to display within
61 // |bounds|. If the caller caches the controller it must also register as an
62 // observer to be notified when the controller goes out of scope.
63 HardwareDisplayController* GetDisplayController(const gfx::Rect& bounds);
65 // Adds a window for |widget|. Note: |widget| should not be associated with a
66 // window when calling this function.
67 void AddWindow(gfx::AcceleratedWidget widget, scoped_ptr<DrmWindow> window);
69 // Removes the window for |widget|. Note: |widget| must have a window
70 // associated with it when calling this function.
71 scoped_ptr<DrmWindow> RemoveWindow(gfx::AcceleratedWidget widget);
73 // Returns the window associated with |widget|. Note: This function should be
74 // called only if a valid window has been associated with |widget|.
75 DrmWindow* GetWindow(gfx::AcceleratedWidget widget);
77 // Updates the mapping between display controllers and windows such that a
78 // controller will be associated with at most one window.
79 void UpdateControllerToWindowMapping();
81 private:
82 typedef ScopedVector<HardwareDisplayController> HardwareDisplayControllers;
84 typedef base::ScopedPtrHashMap<gfx::AcceleratedWidget, DrmWindow>
85 WidgetToWindowMap;
87 // Returns an iterator into |controllers_| for the controller identified by
88 // (|crtc|, |connector|).
89 HardwareDisplayControllers::iterator FindDisplayController(
90 const scoped_refptr<DrmDevice>& drm,
91 uint32_t crtc);
93 bool ActualConfigureDisplayController(const scoped_refptr<DrmDevice>& drm,
94 uint32_t crtc,
95 uint32_t connector,
96 const gfx::Point& origin,
97 const drmModeModeInfo& mode);
99 // Returns an iterator into |controllers_| for the controller located at
100 // |origin|.
101 HardwareDisplayControllers::iterator FindActiveDisplayControllerByLocation(
102 const gfx::Rect& bounds);
104 // Perform modesetting in |controller| using |origin| and |mode|.
105 bool ModesetDisplayController(HardwareDisplayController* controller,
106 const gfx::Point& origin,
107 const drmModeModeInfo& mode);
109 // Tries to set the controller identified by (|crtc|, |connector|) to mirror
110 // those in |mirror|. |original| is an iterator to the HDC where the
111 // controller is currently present.
112 bool HandleMirrorMode(HardwareDisplayControllers::iterator original,
113 HardwareDisplayControllers::iterator mirror,
114 const scoped_refptr<DrmDevice>& drm,
115 uint32_t crtc,
116 uint32_t connector);
118 DrmWindow* FindWindowAt(const gfx::Rect& bounds) const;
120 ScanoutBufferGenerator* buffer_generator_; // Not owned.
121 // List of display controllers (active and disabled).
122 HardwareDisplayControllers controllers_;
124 WidgetToWindowMap window_map_;
126 DISALLOW_COPY_AND_ASSIGN(ScreenManager);
129 } // namespace ui
131 #endif // UI_OZONE_PLATFORM_DRM_GPU_SCREEN_MANAGER_H_