OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "mojo/examples/aura_demo/root_window_host_mojo.h" | 5 #include "mojo/examples/aura_demo/root_window_host_mojo.h" |
6 | 6 |
7 #include "mojo/examples/aura_demo/demo_context_factory.h" | 7 #include "mojo/examples/aura_demo/demo_context_factory.h" |
8 #include "mojo/examples/compositor_app/gles2_client_impl.h" | 8 #include "mojo/examples/compositor_app/gles2_client_impl.h" |
9 #include "mojo/public/gles2/gles2.h" | 9 #include "mojo/public/gles2/gles2.h" |
10 #include "ui/aura/env.h" | 10 #include "ui/aura/env.h" |
11 #include "ui/aura/window.h" | 11 #include "ui/aura/window.h" |
12 #include "ui/aura/window_tree_host_delegate.h" | 12 #include "ui/aura/window_tree_host_delegate.h" |
13 #include "ui/compositor/compositor.h" | 13 #include "ui/compositor/compositor.h" |
14 #include "ui/gfx/geometry/insets.h" | 14 #include "ui/gfx/geometry/insets.h" |
15 #include "ui/gfx/geometry/rect.h" | 15 #include "ui/gfx/geometry/rect.h" |
16 | 16 |
17 namespace mojo { | 17 namespace mojo { |
18 namespace examples { | 18 namespace examples { |
19 | 19 |
20 // static | 20 // static |
21 ui::ContextFactory* RootWindowHostMojo::context_factory_ = NULL; | 21 ui::ContextFactory* WindowTreeHostMojo::context_factory_ = NULL; |
22 | 22 |
23 //////////////////////////////////////////////////////////////////////////////// | 23 //////////////////////////////////////////////////////////////////////////////// |
24 // RootWindowHostMojo, public: | 24 // WindowTreeHostMojo, public: |
25 | 25 |
26 RootWindowHostMojo::RootWindowHostMojo( | 26 WindowTreeHostMojo::WindowTreeHostMojo( |
27 ScopedMessagePipeHandle viewport_handle, | 27 ScopedMessagePipeHandle viewport_handle, |
28 const base::Callback<void()>& compositor_created_callback) | 28 const base::Callback<void()>& compositor_created_callback) |
29 : native_viewport_(viewport_handle.Pass(), this), | 29 : native_viewport_(viewport_handle.Pass(), this), |
30 compositor_created_callback_(compositor_created_callback) { | 30 compositor_created_callback_(compositor_created_callback) { |
31 native_viewport_->Open(); | 31 native_viewport_->Open(); |
32 | 32 |
33 ScopedMessagePipeHandle gles2_handle; | 33 ScopedMessagePipeHandle gles2_handle; |
34 ScopedMessagePipeHandle gles2_client_handle; | 34 ScopedMessagePipeHandle gles2_client_handle; |
35 CreateMessagePipe(&gles2_handle, &gles2_client_handle); | 35 CreateMessagePipe(&gles2_handle, &gles2_client_handle); |
36 | 36 |
37 // The ContextFactory must exist before any Compositors are created. | 37 // The ContextFactory must exist before any Compositors are created. |
38 if (!context_factory_) { | 38 if (!context_factory_) { |
39 scoped_ptr<DemoContextFactory> cf(new DemoContextFactory(this)); | 39 scoped_ptr<DemoContextFactory> cf(new DemoContextFactory(this)); |
40 if (cf->Initialize()) | 40 if (cf->Initialize()) |
41 context_factory_ = cf.release(); | 41 context_factory_ = cf.release(); |
42 ui::ContextFactory::SetInstance(context_factory_); | 42 ui::ContextFactory::SetInstance(context_factory_); |
43 } | 43 } |
44 CHECK(context_factory_) << "No GL bindings."; | 44 CHECK(context_factory_) << "No GL bindings."; |
45 | 45 |
46 gles2_client_.reset(new GLES2ClientImpl( | 46 gles2_client_.reset(new GLES2ClientImpl( |
47 gles2_handle.Pass(), | 47 gles2_handle.Pass(), |
48 base::Bind(&RootWindowHostMojo::DidCreateContext, | 48 base::Bind(&WindowTreeHostMojo::DidCreateContext, |
49 base::Unretained(this)))); | 49 base::Unretained(this)))); |
50 native_viewport_->CreateGLES2Context(gles2_client_handle.Pass()); | 50 native_viewport_->CreateGLES2Context(gles2_client_handle.Pass()); |
51 } | 51 } |
52 | 52 |
53 RootWindowHostMojo::~RootWindowHostMojo() {} | 53 WindowTreeHostMojo::~WindowTreeHostMojo() {} |
54 | 54 |
55 //////////////////////////////////////////////////////////////////////////////// | 55 //////////////////////////////////////////////////////////////////////////////// |
56 // RootWindowHostMojo, aura::RootWindowHost implementation: | 56 // WindowTreeHostMojo, aura::WindowTreeHost implementation: |
57 | 57 |
58 aura::RootWindow* RootWindowHostMojo::GetRootWindow() { | 58 aura::RootWindow* WindowTreeHostMojo::GetRootWindow() { |
59 return delegate_->AsRootWindow(); | 59 return delegate_->AsRootWindow(); |
60 } | 60 } |
61 | 61 |
62 gfx::AcceleratedWidget RootWindowHostMojo::GetAcceleratedWidget() { | 62 gfx::AcceleratedWidget WindowTreeHostMojo::GetAcceleratedWidget() { |
63 NOTIMPLEMENTED(); | 63 NOTIMPLEMENTED(); |
64 return gfx::kNullAcceleratedWidget; | 64 return gfx::kNullAcceleratedWidget; |
65 } | 65 } |
66 | 66 |
67 void RootWindowHostMojo::Show() { | 67 void WindowTreeHostMojo::Show() { |
68 NOTIMPLEMENTED(); | 68 NOTIMPLEMENTED(); |
69 } | 69 } |
70 | 70 |
71 void RootWindowHostMojo::Hide() { | 71 void WindowTreeHostMojo::Hide() { |
72 NOTIMPLEMENTED(); | 72 NOTIMPLEMENTED(); |
73 } | 73 } |
74 | 74 |
75 void RootWindowHostMojo::ToggleFullScreen() { | 75 void WindowTreeHostMojo::ToggleFullScreen() { |
76 NOTIMPLEMENTED(); | 76 NOTIMPLEMENTED(); |
77 } | 77 } |
78 | 78 |
79 gfx::Rect RootWindowHostMojo::GetBounds() const { | 79 gfx::Rect WindowTreeHostMojo::GetBounds() const { |
80 NOTIMPLEMENTED(); | 80 NOTIMPLEMENTED(); |
81 return gfx::Rect(500, 500); | 81 return gfx::Rect(500, 500); |
82 } | 82 } |
83 | 83 |
84 void RootWindowHostMojo::SetBounds(const gfx::Rect& bounds) { | 84 void WindowTreeHostMojo::SetBounds(const gfx::Rect& bounds) { |
85 NOTIMPLEMENTED(); | 85 NOTIMPLEMENTED(); |
86 } | 86 } |
87 | 87 |
88 gfx::Insets RootWindowHostMojo::GetInsets() const { | 88 gfx::Insets WindowTreeHostMojo::GetInsets() const { |
89 NOTIMPLEMENTED(); | 89 NOTIMPLEMENTED(); |
90 return gfx::Insets(); | 90 return gfx::Insets(); |
91 } | 91 } |
92 | 92 |
93 void RootWindowHostMojo::SetInsets(const gfx::Insets& insets) { | 93 void WindowTreeHostMojo::SetInsets(const gfx::Insets& insets) { |
94 NOTIMPLEMENTED(); | 94 NOTIMPLEMENTED(); |
95 } | 95 } |
96 | 96 |
97 gfx::Point RootWindowHostMojo::GetLocationOnNativeScreen() const { | 97 gfx::Point WindowTreeHostMojo::GetLocationOnNativeScreen() const { |
98 return gfx::Point(0, 0); | 98 return gfx::Point(0, 0); |
99 } | 99 } |
100 | 100 |
101 void RootWindowHostMojo::SetCapture() { | 101 void WindowTreeHostMojo::SetCapture() { |
102 NOTIMPLEMENTED(); | 102 NOTIMPLEMENTED(); |
103 } | 103 } |
104 | 104 |
105 void RootWindowHostMojo::ReleaseCapture() { | 105 void WindowTreeHostMojo::ReleaseCapture() { |
106 NOTIMPLEMENTED(); | 106 NOTIMPLEMENTED(); |
107 } | 107 } |
108 | 108 |
109 void RootWindowHostMojo::SetCursor(gfx::NativeCursor cursor) { | 109 void WindowTreeHostMojo::SetCursor(gfx::NativeCursor cursor) { |
110 NOTIMPLEMENTED(); | 110 NOTIMPLEMENTED(); |
111 } | 111 } |
112 | 112 |
113 bool RootWindowHostMojo::QueryMouseLocation(gfx::Point* location_return) { | 113 bool WindowTreeHostMojo::QueryMouseLocation(gfx::Point* location_return) { |
114 NOTIMPLEMENTED(); | 114 NOTIMPLEMENTED(); |
115 return false; | 115 return false; |
116 } | 116 } |
117 | 117 |
118 bool RootWindowHostMojo::ConfineCursorToRootWindow() { | 118 bool WindowTreeHostMojo::ConfineCursorToRootWindow() { |
119 NOTIMPLEMENTED(); | 119 NOTIMPLEMENTED(); |
120 return false; | 120 return false; |
121 } | 121 } |
122 | 122 |
123 void RootWindowHostMojo::UnConfineCursor() { | 123 void WindowTreeHostMojo::UnConfineCursor() { |
124 NOTIMPLEMENTED(); | 124 NOTIMPLEMENTED(); |
125 } | 125 } |
126 | 126 |
127 void RootWindowHostMojo::OnCursorVisibilityChanged(bool show) { | 127 void WindowTreeHostMojo::OnCursorVisibilityChanged(bool show) { |
128 NOTIMPLEMENTED(); | 128 NOTIMPLEMENTED(); |
129 } | 129 } |
130 | 130 |
131 void RootWindowHostMojo::MoveCursorTo(const gfx::Point& location) { | 131 void WindowTreeHostMojo::MoveCursorTo(const gfx::Point& location) { |
132 NOTIMPLEMENTED(); | 132 NOTIMPLEMENTED(); |
133 } | 133 } |
134 | 134 |
135 void RootWindowHostMojo::PostNativeEvent( | 135 void WindowTreeHostMojo::PostNativeEvent( |
136 const base::NativeEvent& native_event) { | 136 const base::NativeEvent& native_event) { |
137 NOTIMPLEMENTED(); | 137 NOTIMPLEMENTED(); |
138 } | 138 } |
139 | 139 |
140 void RootWindowHostMojo::OnDeviceScaleFactorChanged(float device_scale_factor) { | 140 void WindowTreeHostMojo::OnDeviceScaleFactorChanged(float device_scale_factor) { |
141 NOTIMPLEMENTED(); | 141 NOTIMPLEMENTED(); |
142 } | 142 } |
143 | 143 |
144 void RootWindowHostMojo::PrepareForShutdown() { | 144 void WindowTreeHostMojo::PrepareForShutdown() { |
145 NOTIMPLEMENTED(); | 145 NOTIMPLEMENTED(); |
146 } | 146 } |
147 | 147 |
148 //////////////////////////////////////////////////////////////////////////////// | 148 //////////////////////////////////////////////////////////////////////////////// |
149 // RootWindowHostMojo, NativeViewportClient implementation: | 149 // WindowTreeHostMojo, NativeViewportClient implementation: |
150 | 150 |
151 void RootWindowHostMojo::OnCreated() { | 151 void WindowTreeHostMojo::OnCreated() { |
152 } | 152 } |
153 | 153 |
154 void RootWindowHostMojo::OnDestroyed() { | 154 void WindowTreeHostMojo::OnDestroyed() { |
155 base::MessageLoop::current()->Quit(); | 155 base::MessageLoop::current()->Quit(); |
156 } | 156 } |
157 | 157 |
158 void RootWindowHostMojo::OnEvent(const Event& event) { | 158 void WindowTreeHostMojo::OnEvent(const Event& event) { |
159 if (!event.location().is_null()) | 159 if (!event.location().is_null()) |
160 native_viewport_->AckEvent(event); | 160 native_viewport_->AckEvent(event); |
161 | 161 |
162 // TODO(beng): fwd to rootwindow. | 162 // TODO(beng): fwd to rootwindow. |
163 }; | 163 }; |
164 | 164 |
165 //////////////////////////////////////////////////////////////////////////////// | 165 //////////////////////////////////////////////////////////////////////////////// |
166 // RootWindowHostMojo, private: | 166 // WindowTreeHostMojo, private: |
167 | 167 |
168 void RootWindowHostMojo::DidCreateContext(gfx::Size viewport_size) { | 168 void WindowTreeHostMojo::DidCreateContext(gfx::Size viewport_size) { |
169 CreateCompositor(GetAcceleratedWidget()); | 169 CreateCompositor(GetAcceleratedWidget()); |
170 compositor_created_callback_.Run(); | 170 compositor_created_callback_.Run(); |
171 NotifyHostResized(viewport_size); | 171 NotifyHostResized(viewport_size); |
172 } | 172 } |
173 | 173 |
174 } // namespace examples | 174 } // namespace examples |
175 } // namespace mojo | 175 } // namespace mojo |
OLD | NEW |