Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(608)

Side by Side Diff: blimp/client/app/linux/blimp_display_manager.cc

Issue 2363153002: Migrate Linux Blimp client to use BlimpClientContext (Closed)
Patch Set: Move compositor creation into display manager. Pull out BlimpDisplayManagerDelegateMain class from … Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "blimp/client/app/linux/blimp_display_manager.h" 5 #include "blimp/client/app/linux/blimp_display_manager.h"
6 6
7 #include "base/memory/ptr_util.h"
7 #include "blimp/client/app/compositor/browser_compositor.h" 8 #include "blimp/client/app/compositor/browser_compositor.h"
8 #include "blimp/client/core/compositor/blimp_compositor_dependencies.h" 9 #include "blimp/client/public/compositor/compositor_dependencies.h"
9 #include "blimp/client/core/compositor/blimp_compositor_manager.h" 10 #include "blimp/client/public/contents/blimp_contents.h"
10 #include "blimp/client/core/contents/tab_control_feature.h" 11 #include "blimp/client/public/contents/blimp_contents_view.h"
11 #include "blimp/client/core/render_widget/render_widget_feature.h" 12 #include "blimp/client/public/contents/blimp_navigation_controller.h"
12 #include "blimp/client/support/compositor/compositor_dependencies_impl.h"
13 #include "ui/events/event.h" 13 #include "ui/events/event.h"
14 #include "ui/events/gesture_detection/motion_event_generic.h" 14 #include "ui/events/gesture_detection/motion_event_generic.h"
15 #include "ui/events/gestures/motion_event_aura.h" 15 #include "ui/events/gestures/motion_event_aura.h"
16 #include "ui/gfx/geometry/size.h" 16 #include "ui/gfx/geometry/size.h"
17 #include "ui/platform_window/platform_window.h" 17 #include "ui/platform_window/platform_window.h"
18 #include "ui/platform_window/x11/x11_window.h" 18 #include "ui/platform_window/x11/x11_window.h"
19 19
20 namespace blimp { 20 namespace blimp {
21 namespace { 21 namespace {
22 constexpr int kDummyBlimpContentsId = 0;
23 constexpr int kPointer1Id = 0; 22 constexpr int kPointer1Id = 0;
24 constexpr int kPointer2Id = 1; 23 constexpr int kPointer2Id = 1;
25 constexpr int kZoomOffsetMultiplier = 4; 24 constexpr int kZoomOffsetMultiplier = 4;
26 } // namespace 25 } // namespace
27 26
28 namespace client { 27 namespace client {
29 28
30 BlimpDisplayManager::BlimpDisplayManager( 29 BlimpDisplayManager::BlimpDisplayManager(
31 const gfx::Size& window_size, 30 const gfx::Size& window_size,
32 BlimpDisplayManagerDelegate* delegate, 31 BlimpDisplayManagerDelegate* delegate,
33 RenderWidgetFeature* render_widget_feature, 32 CompositorDependencies* compositor_dependencies,
34 TabControlFeature* tab_control_feature) 33 std::unique_ptr<BlimpContents> contents)
35 : device_pixel_ratio_(1.f), 34 : device_pixel_ratio_(1.f),
36 delegate_(delegate), 35 delegate_(delegate),
37 tab_control_feature_(tab_control_feature),
38 platform_window_(new ui::X11Window(this)) { 36 platform_window_(new ui::X11Window(this)) {
37 contents_ = std::move(contents);
David Trainor- moved to gerrit 2016/09/26 20:54:26 Put this in the inline setters: contents_(std::mo
steimel 2016/09/27 17:35:01 Done.
38
39 compositor_ = base::MakeUnique<BrowserCompositor>(compositor_dependencies);
40
39 platform_window_->SetBounds(gfx::Rect(window_size)); 41 platform_window_->SetBounds(gfx::Rect(window_size));
40 42
41 compositor_dependencies_ = base::MakeUnique<BlimpCompositorDependencies>(
42 base::MakeUnique<CompositorDependenciesImpl>());
43
44 compositor_ = base::MakeUnique<BrowserCompositor>(
45 compositor_dependencies_->GetEmbedderDependencies());
46 compositor_->SetSize(platform_window_->GetBounds().size()); 43 compositor_->SetSize(platform_window_->GetBounds().size());
47 44
48 compositor_manager_ = base::MakeUnique<BlimpCompositorManager>( 45 compositor_->SetContentLayer(contents_->GetView()->GetLayer());
49 kDummyBlimpContentsId, render_widget_feature,
50 compositor_dependencies_.get());
51
52 compositor_->SetContentLayer(compositor_manager_->layer());
53 46
54 platform_window_->Show(); 47 platform_window_->Show();
55 48
56 tab_control_feature_->SetSizeAndScale(platform_window_->GetBounds().size(), 49 contents_->GetView()->SetSizeAndScale(platform_window_->GetBounds().size(),
David Trainor- moved to gerrit 2016/09/26 20:54:26 Actually, would it be cleaner to call OnBoundsChan
steimel 2016/09/27 17:35:01 Done.
57 device_pixel_ratio_); 50 device_pixel_ratio_);
58 } 51 }
59 52
60 BlimpDisplayManager::~BlimpDisplayManager() {} 53 BlimpDisplayManager::~BlimpDisplayManager() {}
61 54
62 void BlimpDisplayManager::OnBoundsChanged(const gfx::Rect& new_bounds) { 55 void BlimpDisplayManager::OnBoundsChanged(const gfx::Rect& new_bounds) {
63 compositor_->SetSize(new_bounds.size()); 56 compositor_->SetSize(new_bounds.size());
64 tab_control_feature_->SetSizeAndScale(new_bounds.size(), device_pixel_ratio_); 57 contents_->GetView()->SetSizeAndScale(new_bounds.size(), device_pixel_ratio_);
65 } 58 }
66 59
67 void BlimpDisplayManager::DispatchEvent(ui::Event* event) { 60 void BlimpDisplayManager::DispatchEvent(ui::Event* event) {
68 if (event->IsMouseWheelEvent()) { 61 if (event->IsMouseWheelEvent()) {
69 DispatchMouseWheelEvent(event->AsMouseWheelEvent()); 62 DispatchMouseWheelEvent(event->AsMouseWheelEvent());
70 } else if (event->IsMouseEvent()) { 63 } else if (event->IsMouseEvent()) {
71 DispatchMouseEvent(event->AsMouseEvent()); 64 DispatchMouseEvent(event->AsMouseEvent());
72 } 65 }
73 } 66 }
74 67
75 void BlimpDisplayManager::DispatchMotionEventAura( 68 void BlimpDisplayManager::DispatchMotionEventAura(
76 ui::MotionEventAura* touch_event_stream, 69 ui::MotionEventAura* touch_event_stream,
77 ui::EventType event_type, 70 ui::EventType event_type,
78 int pointer_id, 71 int pointer_id,
79 int pointer_x, 72 int pointer_x,
80 int pointer_y) { 73 int pointer_y) {
81 touch_event_stream->OnTouch( 74 touch_event_stream->OnTouch(
82 ui::TouchEvent(event_type, gfx::Point(pointer_x, pointer_y), pointer_id, 75 ui::TouchEvent(event_type, gfx::Point(pointer_x, pointer_y), pointer_id,
83 base::TimeTicks::Now())); 76 base::TimeTicks::Now()));
84 compositor_manager_->OnTouchEvent(*touch_event_stream); 77 contents_->GetView()->OnTouchEvent(*touch_event_stream);
85 } 78 }
86 79
87 void BlimpDisplayManager::DispatchMouseWheelEvent( 80 void BlimpDisplayManager::DispatchMouseWheelEvent(
88 ui::MouseWheelEvent* wheel_event) { 81 ui::MouseWheelEvent* wheel_event) {
89 // In order to better simulate the Android experience on the Linux client 82 // In order to better simulate the Android experience on the Linux client
90 // we convert mousewheel scrolling events into pinch/zoom events. 83 // we convert mousewheel scrolling events into pinch/zoom events.
91 bool zoom_out = wheel_event->y_offset() < 0; 84 bool zoom_out = wheel_event->y_offset() < 0;
92 Zoom(wheel_event->x(), wheel_event->y(), wheel_event->y_offset(), zoom_out); 85 Zoom(wheel_event->x(), wheel_event->y(), wheel_event->y_offset(), zoom_out);
93 } 86 }
94 87
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 134
142 void BlimpDisplayManager::DispatchMouseEvent(ui::MouseEvent* mouse_event) { 135 void BlimpDisplayManager::DispatchMouseEvent(ui::MouseEvent* mouse_event) {
143 ui::MotionEvent::Action action = MouseEventToAction(mouse_event); 136 ui::MotionEvent::Action action = MouseEventToAction(mouse_event);
144 137
145 if (action != ui::MotionEvent::ACTION_NONE && 138 if (action != ui::MotionEvent::ACTION_NONE &&
146 mouse_event->IsOnlyLeftMouseButton()) { 139 mouse_event->IsOnlyLeftMouseButton()) {
147 ui::PointerProperties mouse_properties(mouse_event->x(), mouse_event->y(), 140 ui::PointerProperties mouse_properties(mouse_event->x(), mouse_event->y(),
148 0); 141 0);
149 ui::MotionEventGeneric motion_event(action, mouse_event->time_stamp(), 142 ui::MotionEventGeneric motion_event(action, mouse_event->time_stamp(),
150 mouse_properties); 143 mouse_properties);
151 compositor_manager_->OnTouchEvent(motion_event); 144 contents_->GetView()->OnTouchEvent(motion_event);
152 } 145 }
153 } 146 }
154 147
155 void BlimpDisplayManager::OnCloseRequest() { 148 void BlimpDisplayManager::OnCloseRequest() {
156 compositor_manager_->SetVisible(false); 149 contents_->Hide();
157 compositor_->SetAcceleratedWidget(gfx::kNullAcceleratedWidget); 150 compositor_->SetAcceleratedWidget(gfx::kNullAcceleratedWidget);
158 platform_window_->Close(); 151 platform_window_->Close();
159 } 152 }
160 153
161 void BlimpDisplayManager::OnClosed() { 154 void BlimpDisplayManager::OnClosed() {
162 if (delegate_) 155 if (delegate_)
163 delegate_->OnClosed(); 156 delegate_->OnClosed();
164 } 157 }
165 158
166 void BlimpDisplayManager::OnAcceleratedWidgetAvailable( 159 void BlimpDisplayManager::OnAcceleratedWidgetAvailable(
167 gfx::AcceleratedWidget widget, 160 gfx::AcceleratedWidget widget,
168 float device_pixel_ratio) { 161 float device_pixel_ratio) {
169 device_pixel_ratio_ = device_pixel_ratio; 162 device_pixel_ratio_ = device_pixel_ratio;
170 tab_control_feature_->SetSizeAndScale(platform_window_->GetBounds().size(), 163 contents_->GetView()->SetSizeAndScale(platform_window_->GetBounds().size(),
171 device_pixel_ratio_); 164 device_pixel_ratio_);
172 165
173 if (widget != gfx::kNullAcceleratedWidget) { 166 if (widget != gfx::kNullAcceleratedWidget) {
174 compositor_manager_->SetVisible(true); 167 contents_->Show();
175 compositor_->SetAcceleratedWidget(widget); 168 compositor_->SetAcceleratedWidget(widget);
176 } 169 }
177 } 170 }
178 171
179 void BlimpDisplayManager::OnAcceleratedWidgetDestroyed() { 172 void BlimpDisplayManager::OnAcceleratedWidgetDestroyed() {
180 compositor_manager_->SetVisible(false); 173 contents_->Hide();
181 compositor_->SetAcceleratedWidget(gfx::kNullAcceleratedWidget); 174 compositor_->SetAcceleratedWidget(gfx::kNullAcceleratedWidget);
182 } 175 }
183 176
184 } // namespace client 177 } // namespace client
185 } // namespace blimp 178 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698