| 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 "mojo/services/html_viewer/weblayertreeview_impl.h" | 5 #include "mojo/services/html_viewer/weblayertreeview_impl.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop_proxy.h" | 7 #include "base/message_loop/message_loop_proxy.h" |
| 8 #include "cc/blink/web_layer_impl.h" | 8 #include "cc/blink/web_layer_impl.h" |
| 9 #include "cc/layers/layer.h" | 9 #include "cc/layers/layer.h" |
| 10 #include "cc/output/begin_frame_args.h" | 10 #include "cc/output/begin_frame_args.h" |
| 11 #include "cc/scheduler/begin_frame_source.h" | 11 #include "cc/scheduler/begin_frame_source.h" |
| 12 #include "cc/trees/layer_tree_host.h" | 12 #include "cc/trees/layer_tree_host.h" |
| 13 #include "mojo/cc/context_provider_mojo.h" | 13 #include "mojo/cc/context_provider_mojo.h" |
| 14 #include "mojo/cc/output_surface_mojo.h" | 14 #include "mojo/cc/output_surface_mojo.h" |
| 15 #include "mojo/converters/surfaces/surfaces_type_converters.h" | 15 #include "mojo/converters/surfaces/surfaces_type_converters.h" |
| 16 #include "mojo/services/view_manager/public/cpp/view.h" | 16 #include "mojo/services/view_manager/public/cpp/view.h" |
| 17 #include "third_party/WebKit/public/web/WebWidget.h" | 17 #include "third_party/WebKit/public/web/WebWidget.h" |
| 18 | 18 |
| 19 namespace mojo { | 19 namespace html_viewer { |
| 20 | 20 |
| 21 WebLayerTreeViewImpl::WebLayerTreeViewImpl( | 21 WebLayerTreeViewImpl::WebLayerTreeViewImpl( |
| 22 scoped_refptr<base::MessageLoopProxy> compositor_message_loop_proxy, | 22 scoped_refptr<base::MessageLoopProxy> compositor_message_loop_proxy, |
| 23 SurfacesServicePtr surfaces_service, | 23 mojo::SurfacesServicePtr surfaces_service, |
| 24 GpuPtr gpu_service) | 24 mojo::GpuPtr gpu_service) |
| 25 : widget_(NULL), | 25 : widget_(NULL), |
| 26 view_(NULL), | 26 view_(NULL), |
| 27 surfaces_service_(surfaces_service.Pass()), | 27 surfaces_service_(surfaces_service.Pass()), |
| 28 gpu_service_(gpu_service.Pass()), | 28 gpu_service_(gpu_service.Pass()), |
| 29 main_thread_compositor_task_runner_(base::MessageLoopProxy::current()), | 29 main_thread_compositor_task_runner_(base::MessageLoopProxy::current()), |
| 30 weak_factory_(this) { | 30 weak_factory_(this) { |
| 31 main_thread_bound_weak_ptr_ = weak_factory_.GetWeakPtr(); | 31 main_thread_bound_weak_ptr_ = weak_factory_.GetWeakPtr(); |
| 32 surfaces_service_->CreateSurfaceConnection( | 32 surfaces_service_->CreateSurfaceConnection( |
| 33 base::Bind(&WebLayerTreeViewImpl::OnSurfaceConnectionCreated, | 33 base::Bind(&WebLayerTreeViewImpl::OnSurfaceConnectionCreated, |
| 34 main_thread_bound_weak_ptr_)); | 34 main_thread_bound_weak_ptr_)); |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 } | 225 } |
| 226 | 226 |
| 227 bool WebLayerTreeViewImpl::commitRequested() const { | 227 bool WebLayerTreeViewImpl::commitRequested() const { |
| 228 return layer_tree_host_->CommitRequested(); | 228 return layer_tree_host_->CommitRequested(); |
| 229 } | 229 } |
| 230 | 230 |
| 231 void WebLayerTreeViewImpl::finishAllRendering() { | 231 void WebLayerTreeViewImpl::finishAllRendering() { |
| 232 layer_tree_host_->FinishAllRendering(); | 232 layer_tree_host_->FinishAllRendering(); |
| 233 } | 233 } |
| 234 | 234 |
| 235 void WebLayerTreeViewImpl::OnSurfaceConnectionCreated(SurfacePtr surface, | 235 void WebLayerTreeViewImpl::OnSurfaceConnectionCreated(mojo::SurfacePtr surface, |
| 236 uint32_t id_namespace) { | 236 uint32_t id_namespace) { |
| 237 CommandBufferPtr cb; | 237 mojo::CommandBufferPtr cb; |
| 238 gpu_service_->CreateOffscreenGLES2Context(GetProxy(&cb)); | 238 gpu_service_->CreateOffscreenGLES2Context(GetProxy(&cb)); |
| 239 scoped_refptr<cc::ContextProvider> context_provider( | 239 scoped_refptr<cc::ContextProvider> context_provider( |
| 240 new ContextProviderMojo(cb.PassMessagePipe())); | 240 new mojo::ContextProviderMojo(cb.PassMessagePipe())); |
| 241 output_surface_.reset(new OutputSurfaceMojo( | 241 output_surface_.reset(new mojo::OutputSurfaceMojo( |
| 242 this, context_provider, surface.Pass(), id_namespace)); | 242 this, context_provider, surface.Pass(), id_namespace)); |
| 243 layer_tree_host_->SetLayerTreeHostClientReady(); | 243 layer_tree_host_->SetLayerTreeHostClientReady(); |
| 244 } | 244 } |
| 245 | 245 |
| 246 void WebLayerTreeViewImpl::DidCreateSurface(cc::SurfaceId id) { | 246 void WebLayerTreeViewImpl::DidCreateSurface(cc::SurfaceId id) { |
| 247 main_thread_compositor_task_runner_->PostTask( | 247 main_thread_compositor_task_runner_->PostTask( |
| 248 FROM_HERE, | 248 FROM_HERE, |
| 249 base::Bind(&WebLayerTreeViewImpl::DidCreateSurfaceOnMainThread, | 249 base::Bind(&WebLayerTreeViewImpl::DidCreateSurfaceOnMainThread, |
| 250 main_thread_bound_weak_ptr_, | 250 main_thread_bound_weak_ptr_, |
| 251 id)); | 251 id)); |
| 252 } | 252 } |
| 253 | 253 |
| 254 void WebLayerTreeViewImpl::DidCreateSurfaceOnMainThread(cc::SurfaceId id) { | 254 void WebLayerTreeViewImpl::DidCreateSurfaceOnMainThread(cc::SurfaceId id) { |
| 255 view_->SetSurfaceId(SurfaceId::From(id)); | 255 view_->SetSurfaceId(mojo::SurfaceId::From(id)); |
| 256 } | 256 } |
| 257 | 257 |
| 258 } // namespace mojo | 258 } // namespace html_viewer |
| OLD | NEW |