| 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* RootWindowHostMojo::context_factory_ = NULL; |
| 22 | 22 |
| 23 //////////////////////////////////////////////////////////////////////////////// | 23 //////////////////////////////////////////////////////////////////////////////// |
| 24 // RootWindowHostMojo, public: | 24 // RootWindowHostMojo, public: |
| 25 | 25 |
| 26 RootWindowHostMojo::RootWindowHostMojo( | 26 RootWindowHostMojo::RootWindowHostMojo( |
| 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()), | 29 : native_viewport_(viewport_handle.Pass(), this), |
| 30 compositor_created_callback_(compositor_created_callback) { | 30 compositor_created_callback_(compositor_created_callback) { |
| 31 native_viewport_.SetPeer(this); | |
| 32 native_viewport_->Open(); | 31 native_viewport_->Open(); |
| 33 | 32 |
| 34 ScopedMessagePipeHandle gles2_handle; | 33 ScopedMessagePipeHandle gles2_handle; |
| 35 ScopedMessagePipeHandle gles2_client_handle; | 34 ScopedMessagePipeHandle gles2_client_handle; |
| 36 CreateMessagePipe(&gles2_handle, &gles2_client_handle); | 35 CreateMessagePipe(&gles2_handle, &gles2_client_handle); |
| 37 | 36 |
| 38 // The ContextFactory must exist before any Compositors are created. | 37 // The ContextFactory must exist before any Compositors are created. |
| 39 if (!context_factory_) { | 38 if (!context_factory_) { |
| 40 scoped_ptr<DemoContextFactory> cf(new DemoContextFactory(this)); | 39 scoped_ptr<DemoContextFactory> cf(new DemoContextFactory(this)); |
| 41 if (cf->Initialize()) | 40 if (cf->Initialize()) |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 139 |
| 141 void RootWindowHostMojo::OnDeviceScaleFactorChanged(float device_scale_factor) { | 140 void RootWindowHostMojo::OnDeviceScaleFactorChanged(float device_scale_factor) { |
| 142 NOTIMPLEMENTED(); | 141 NOTIMPLEMENTED(); |
| 143 } | 142 } |
| 144 | 143 |
| 145 void RootWindowHostMojo::PrepareForShutdown() { | 144 void RootWindowHostMojo::PrepareForShutdown() { |
| 146 NOTIMPLEMENTED(); | 145 NOTIMPLEMENTED(); |
| 147 } | 146 } |
| 148 | 147 |
| 149 //////////////////////////////////////////////////////////////////////////////// | 148 //////////////////////////////////////////////////////////////////////////////// |
| 150 // RootWindowHostMojo, NativeViewportClientStub implementation: | 149 // RootWindowHostMojo, NativeViewportClient implementation: |
| 151 | 150 |
| 152 void RootWindowHostMojo::OnCreated() { | 151 void RootWindowHostMojo::OnCreated() { |
| 153 } | 152 } |
| 154 | 153 |
| 155 void RootWindowHostMojo::OnDestroyed() { | 154 void RootWindowHostMojo::OnDestroyed() { |
| 156 base::MessageLoop::current()->Quit(); | 155 base::MessageLoop::current()->Quit(); |
| 157 } | 156 } |
| 158 | 157 |
| 159 void RootWindowHostMojo::OnEvent(const Event& event) { | 158 void RootWindowHostMojo::OnEvent(const Event& event) { |
| 160 if (!event.location().is_null()) | 159 if (!event.location().is_null()) |
| 161 native_viewport_->AckEvent(event); | 160 native_viewport_->AckEvent(event); |
| 162 | 161 |
| 163 // TODO(beng): fwd to rootwindow. | 162 // TODO(beng): fwd to rootwindow. |
| 164 }; | 163 }; |
| 165 | 164 |
| 166 //////////////////////////////////////////////////////////////////////////////// | 165 //////////////////////////////////////////////////////////////////////////////// |
| 167 // RootWindowHostMojo, private: | 166 // RootWindowHostMojo, private: |
| 168 | 167 |
| 169 void RootWindowHostMojo::DidCreateContext(gfx::Size viewport_size) { | 168 void RootWindowHostMojo::DidCreateContext(gfx::Size viewport_size) { |
| 170 CreateCompositor(GetAcceleratedWidget()); | 169 CreateCompositor(GetAcceleratedWidget()); |
| 171 compositor_created_callback_.Run(); | 170 compositor_created_callback_.Run(); |
| 172 NotifyHostResized(viewport_size); | 171 NotifyHostResized(viewport_size); |
| 173 } | 172 } |
| 174 | 173 |
| 175 } // namespace examples | 174 } // namespace examples |
| 176 } // namespace mojo | 175 } // namespace mojo |
| OLD | NEW |