| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/ozone/platform/drm/host/drm_window_host.h" | 5 #include "ui/ozone/platform/drm/host/drm_window_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "ui/events/devices/device_data_manager.h" | 8 #include "ui/events/devices/device_data_manager.h" |
| 9 #include "ui/events/event.h" | 9 #include "ui/events/event.h" |
| 10 #include "ui/events/ozone/evdev/event_factory_evdev.h" | 10 #include "ui/events/ozone/evdev/event_factory_evdev.h" |
| 11 #include "ui/events/ozone/events_ozone.h" | 11 #include "ui/events/ozone/events_ozone.h" |
| 12 #include "ui/events/platform/platform_event_source.h" | 12 #include "ui/events/platform/platform_event_source.h" |
| 13 #include "ui/gfx/display.h" | 13 #include "ui/gfx/display.h" |
| 14 #include "ui/ozone/common/gpu/ozone_gpu_messages.h" | |
| 15 #include "ui/ozone/platform/drm/host/drm_cursor.h" | 14 #include "ui/ozone/platform/drm/host/drm_cursor.h" |
| 16 #include "ui/ozone/platform/drm/host/drm_display_host.h" | 15 #include "ui/ozone/platform/drm/host/drm_display_host.h" |
| 17 #include "ui/ozone/platform/drm/host/drm_display_host_manager.h" | 16 #include "ui/ozone/platform/drm/host/drm_display_host_manager.h" |
| 18 #include "ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h" | |
| 19 #include "ui/ozone/platform/drm/host/drm_overlay_manager.h" | 17 #include "ui/ozone/platform/drm/host/drm_overlay_manager.h" |
| 20 #include "ui/ozone/platform/drm/host/drm_window_host_manager.h" | 18 #include "ui/ozone/platform/drm/host/drm_window_host_manager.h" |
| 21 #include "ui/platform_window/platform_window_delegate.h" | 19 #include "ui/platform_window/platform_window_delegate.h" |
| 22 | 20 |
| 23 namespace ui { | 21 namespace ui { |
| 24 | 22 |
| 25 DrmWindowHost::DrmWindowHost(PlatformWindowDelegate* delegate, | 23 DrmWindowHost::DrmWindowHost(PlatformWindowDelegate* delegate, |
| 26 const gfx::Rect& bounds, | 24 const gfx::Rect& bounds, |
| 27 DrmGpuPlatformSupportHost* sender, | 25 GpuThreadAdapter* sender, |
| 28 EventFactoryEvdev* event_factory, | 26 EventFactoryEvdev* event_factory, |
| 29 DrmCursor* cursor, | 27 DrmCursor* cursor, |
| 30 DrmWindowHostManager* window_manager, | 28 DrmWindowHostManager* window_manager, |
| 31 DrmDisplayHostManager* display_manager, | 29 DrmDisplayHostManager* display_manager, |
| 32 DrmOverlayManager* overlay_manager) | 30 DrmOverlayManager* overlay_manager) |
| 33 : delegate_(delegate), | 31 : delegate_(delegate), |
| 34 sender_(sender), | 32 sender_(sender), |
| 35 event_factory_(event_factory), | 33 event_factory_(event_factory), |
| 36 cursor_(cursor), | 34 cursor_(cursor), |
| 37 window_manager_(window_manager), | 35 window_manager_(window_manager), |
| 38 display_manager_(display_manager), | 36 display_manager_(display_manager), |
| 39 overlay_manager_(overlay_manager), | 37 overlay_manager_(overlay_manager), |
| 40 bounds_(bounds), | 38 bounds_(bounds), |
| 41 widget_(window_manager->NextAcceleratedWidget()) { | 39 widget_(window_manager->NextAcceleratedWidget()) { |
| 42 window_manager_->AddWindow(widget_, this); | 40 window_manager_->AddWindow(widget_, this); |
| 43 } | 41 } |
| 44 | 42 |
| 45 DrmWindowHost::~DrmWindowHost() { | 43 DrmWindowHost::~DrmWindowHost() { |
| 46 PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); | 44 PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); |
| 47 window_manager_->RemoveWindow(widget_); | 45 window_manager_->RemoveWindow(widget_); |
| 48 cursor_->OnWindowRemoved(widget_); | 46 cursor_->OnWindowRemoved(widget_); |
| 49 | 47 |
| 50 sender_->RemoveGpuThreadObserver(this); | 48 sender_->RemoveGpuThreadObserver(this); |
| 51 sender_->Send(new OzoneGpuMsg_DestroyWindow(widget_)); | 49 sender_->GpuDestroyWindow(widget_); |
| 52 } | 50 } |
| 53 | 51 |
| 54 void DrmWindowHost::Initialize() { | 52 void DrmWindowHost::Initialize() { |
| 55 sender_->AddGpuThreadObserver(this); | 53 sender_->AddGpuThreadObserver(this); |
| 56 PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); | 54 PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this); |
| 57 cursor_->OnWindowAdded(widget_, bounds_, GetCursorConfinedBounds()); | 55 cursor_->OnWindowAdded(widget_, bounds_, GetCursorConfinedBounds()); |
| 58 delegate_->OnAcceleratedWidgetAvailable(widget_, 1.f); | 56 delegate_->OnAcceleratedWidgetAvailable(widget_, 1.f); |
| 59 } | 57 } |
| 60 | 58 |
| 61 gfx::AcceleratedWidget DrmWindowHost::GetAcceleratedWidget() { | 59 gfx::AcceleratedWidget DrmWindowHost::GetAcceleratedWidget() { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 located_event->set_location_f(location); | 180 located_event->set_location_f(location); |
| 183 located_event->set_root_location_f(location); | 181 located_event->set_root_location_f(location); |
| 184 } | 182 } |
| 185 DispatchEventFromNativeUiEvent( | 183 DispatchEventFromNativeUiEvent( |
| 186 native_event, base::Bind(&PlatformWindowDelegate::DispatchEvent, | 184 native_event, base::Bind(&PlatformWindowDelegate::DispatchEvent, |
| 187 base::Unretained(delegate_))); | 185 base::Unretained(delegate_))); |
| 188 return POST_DISPATCH_STOP_PROPAGATION; | 186 return POST_DISPATCH_STOP_PROPAGATION; |
| 189 } | 187 } |
| 190 | 188 |
| 191 void DrmWindowHost::OnGpuThreadReady() { | 189 void DrmWindowHost::OnGpuThreadReady() { |
| 192 sender_->Send(new OzoneGpuMsg_CreateWindow(widget_)); | 190 sender_->GpuCreateWindow(widget_); |
| 193 SendBoundsChange(); | 191 SendBoundsChange(); |
| 194 } | 192 } |
| 195 | 193 |
| 196 void DrmWindowHost::OnGpuThreadRetired() {} | 194 void DrmWindowHost::OnGpuThreadRetired() {} |
| 197 | 195 |
| 198 void DrmWindowHost::SendBoundsChange() { | 196 void DrmWindowHost::SendBoundsChange() { |
| 199 // Update the cursor before the window so that the cursor stays within the | 197 // Update the cursor before the window so that the cursor stays within the |
| 200 // window bounds when the window size shrinks. | 198 // window bounds when the window size shrinks. |
| 201 cursor_->CommitBoundsChange(widget_, bounds_, GetCursorConfinedBounds()); | 199 cursor_->CommitBoundsChange(widget_, bounds_, GetCursorConfinedBounds()); |
| 202 sender_->Send(new OzoneGpuMsg_WindowBoundsChanged(widget_, bounds_)); | 200 sender_->GpuWindowBoundsChanged(widget_, bounds_); |
| 203 | 201 |
| 204 overlay_manager_->ResetCache(); | 202 overlay_manager_->ResetCache(); |
| 205 } | 203 } |
| 206 | 204 |
| 207 } // namespace ui | 205 } // namespace ui |
| OLD | NEW |