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_HOST_DRM_WINDOW_HOST_H_
6 #define UI_OZONE_PLATFORM_DRM_HOST_DRM_WINDOW_HOST_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "ui/display/types/display_snapshot.h"
10 #include "ui/events/platform/platform_event_dispatcher.h"
11 #include "ui/gfx/geometry/rect.h"
12 #include "ui/gfx/native_widget_types.h"
13 #include "ui/ozone/platform/drm/host/channel_observer.h"
14 #include "ui/platform_window/platform_window.h"
20 class DrmGpuPlatformSupportHost
;
22 class DrmWindowHostManager
;
23 class EventFactoryEvdev
;
25 // Implementation of the platform window. This object and its handle |widget_|
26 // uniquely identify a window. Since the DRI/GBM platform is split into 2
27 // pieces (Browser process and GPU process), internally we need to make sure the
28 // state is synchronized between the 2 processes.
30 // |widget_| is used in both processes to uniquely identify the window. This
31 // means that any state on the browser side needs to be propagated to the GPU.
32 // State propagation needs to happen before the state change is acknowledged to
33 // |delegate_| as |delegate_| is responsible for initializing the surface
34 // associated with the window (the surface is created on the GPU process).
35 class DrmWindowHost
: public PlatformWindow
,
36 public PlatformEventDispatcher
,
37 public ChannelObserver
{
39 DrmWindowHost(PlatformWindowDelegate
* delegate
,
40 const gfx::Rect
& bounds
,
41 DrmGpuPlatformSupportHost
* sender
,
42 EventFactoryEvdev
* event_factory
,
44 DrmWindowHostManager
* window_manager
,
45 DisplayManager
* display_manager
);
46 ~DrmWindowHost() override
;
50 gfx::AcceleratedWidget
GetAcceleratedWidget();
52 gfx::Rect
GetCursorConfinedBounds() const;
57 void Close() override
;
58 void SetBounds(const gfx::Rect
& bounds
) override
;
59 gfx::Rect
GetBounds() override
;
60 void SetCapture() override
;
61 void ReleaseCapture() override
;
62 void ToggleFullscreen() override
;
63 void Maximize() override
;
64 void Minimize() override
;
65 void Restore() override
;
66 void SetCursor(PlatformCursor cursor
) override
;
67 void MoveCursorTo(const gfx::Point
& location
) override
;
68 void ConfineCursorToBounds(const gfx::Rect
& bounds
) override
;
70 // PlatformEventDispatcher:
71 bool CanDispatchEvent(const PlatformEvent
& event
) override
;
72 uint32_t DispatchEvent(const PlatformEvent
& event
) override
;
75 void OnChannelEstablished() override
;
76 void OnChannelDestroyed() override
;
79 void SendBoundsChange();
81 PlatformWindowDelegate
* delegate_
; // Not owned.
82 DrmGpuPlatformSupportHost
* sender_
; // Not owned.
83 EventFactoryEvdev
* event_factory_
; // Not owned.
84 DrmCursor
* cursor_
; // Not owned.
85 DrmWindowHostManager
* window_manager_
; // Not owned.
86 DisplayManager
* display_manager_
; // Not owned.
89 gfx::AcceleratedWidget widget_
;
91 gfx::Rect cursor_confined_bounds_
;
93 DISALLOW_COPY_AND_ASSIGN(DrmWindowHost
);
98 #endif // UI_OZONE_PLATFORM_DRM_HOST_DRM_WINDOW_HOST_H_