| 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 html_viewer { | 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 mojo::SurfacesServicePtr surfaces_service, | 23 mojo::SurfacePtr surface, |
| 24 mojo::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()), | |
| 28 gpu_service_(gpu_service.Pass()), | |
| 29 main_thread_compositor_task_runner_(base::MessageLoopProxy::current()), | 27 main_thread_compositor_task_runner_(base::MessageLoopProxy::current()), |
| 30 weak_factory_(this) { | 28 weak_factory_(this) { |
| 31 main_thread_bound_weak_ptr_ = weak_factory_.GetWeakPtr(); | 29 main_thread_bound_weak_ptr_ = weak_factory_.GetWeakPtr(); |
| 32 surfaces_service_->CreateSurfaceConnection( | |
| 33 base::Bind(&WebLayerTreeViewImpl::OnSurfaceConnectionCreated, | |
| 34 main_thread_bound_weak_ptr_)); | |
| 35 | 30 |
| 36 cc::LayerTreeSettings settings; | 31 cc::LayerTreeSettings settings; |
| 37 | 32 |
| 38 // For web contents, layer transforms should scale up the contents of layers | 33 // For web contents, layer transforms should scale up the contents of layers |
| 39 // to keep content always crisp when possible. | 34 // to keep content always crisp when possible. |
| 40 settings.layer_transforms_should_scale_layer_contents = true; | 35 settings.layer_transforms_should_scale_layer_contents = true; |
| 41 | 36 |
| 42 cc::SharedBitmapManager* shared_bitmap_manager = NULL; | 37 cc::SharedBitmapManager* shared_bitmap_manager = NULL; |
| 43 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = NULL; | 38 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = NULL; |
| 44 | 39 |
| 45 layer_tree_host_ = | 40 layer_tree_host_ = |
| 46 cc::LayerTreeHost::CreateThreaded(this, | 41 cc::LayerTreeHost::CreateThreaded(this, |
| 47 shared_bitmap_manager, | 42 shared_bitmap_manager, |
| 48 gpu_memory_buffer_manager, | 43 gpu_memory_buffer_manager, |
| 49 settings, | 44 settings, |
| 50 base::MessageLoopProxy::current(), | 45 base::MessageLoopProxy::current(), |
| 51 compositor_message_loop_proxy, | 46 compositor_message_loop_proxy, |
| 52 nullptr); | 47 nullptr); |
| 53 DCHECK(layer_tree_host_); | 48 DCHECK(layer_tree_host_); |
| 49 |
| 50 mojo::CommandBufferPtr cb; |
| 51 gpu_service->CreateOffscreenGLES2Context(GetProxy(&cb)); |
| 52 scoped_refptr<cc::ContextProvider> context_provider( |
| 53 new mojo::ContextProviderMojo(cb.PassMessagePipe())); |
| 54 output_surface_.reset( |
| 55 new mojo::OutputSurfaceMojo(this, context_provider, surface.Pass())); |
| 56 layer_tree_host_->SetLayerTreeHostClientReady(); |
| 54 } | 57 } |
| 55 | 58 |
| 56 WebLayerTreeViewImpl::~WebLayerTreeViewImpl() { | 59 WebLayerTreeViewImpl::~WebLayerTreeViewImpl() { |
| 57 } | 60 } |
| 58 | 61 |
| 59 void WebLayerTreeViewImpl::WillBeginMainFrame(int frame_id) { | 62 void WebLayerTreeViewImpl::WillBeginMainFrame(int frame_id) { |
| 60 } | 63 } |
| 61 | 64 |
| 62 void WebLayerTreeViewImpl::DidBeginMainFrame() { | 65 void WebLayerTreeViewImpl::DidBeginMainFrame() { |
| 63 } | 66 } |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 } | 224 } |
| 222 | 225 |
| 223 bool WebLayerTreeViewImpl::commitRequested() const { | 226 bool WebLayerTreeViewImpl::commitRequested() const { |
| 224 return layer_tree_host_->CommitRequested(); | 227 return layer_tree_host_->CommitRequested(); |
| 225 } | 228 } |
| 226 | 229 |
| 227 void WebLayerTreeViewImpl::finishAllRendering() { | 230 void WebLayerTreeViewImpl::finishAllRendering() { |
| 228 layer_tree_host_->FinishAllRendering(); | 231 layer_tree_host_->FinishAllRendering(); |
| 229 } | 232 } |
| 230 | 233 |
| 231 void WebLayerTreeViewImpl::OnSurfaceConnectionCreated(mojo::SurfacePtr surface, | |
| 232 uint32_t id_namespace) { | |
| 233 mojo::CommandBufferPtr cb; | |
| 234 gpu_service_->CreateOffscreenGLES2Context(GetProxy(&cb)); | |
| 235 scoped_refptr<cc::ContextProvider> context_provider( | |
| 236 new mojo::ContextProviderMojo(cb.PassMessagePipe())); | |
| 237 output_surface_.reset(new mojo::OutputSurfaceMojo( | |
| 238 this, context_provider, surface.Pass(), id_namespace)); | |
| 239 layer_tree_host_->SetLayerTreeHostClientReady(); | |
| 240 } | |
| 241 | |
| 242 void WebLayerTreeViewImpl::DidCreateSurface(cc::SurfaceId id) { | 234 void WebLayerTreeViewImpl::DidCreateSurface(cc::SurfaceId id) { |
| 243 main_thread_compositor_task_runner_->PostTask( | 235 main_thread_compositor_task_runner_->PostTask( |
| 244 FROM_HERE, | 236 FROM_HERE, |
| 245 base::Bind(&WebLayerTreeViewImpl::DidCreateSurfaceOnMainThread, | 237 base::Bind(&WebLayerTreeViewImpl::DidCreateSurfaceOnMainThread, |
| 246 main_thread_bound_weak_ptr_, | 238 main_thread_bound_weak_ptr_, |
| 247 id)); | 239 id)); |
| 248 } | 240 } |
| 249 | 241 |
| 250 void WebLayerTreeViewImpl::DidCreateSurfaceOnMainThread(cc::SurfaceId id) { | 242 void WebLayerTreeViewImpl::DidCreateSurfaceOnMainThread(cc::SurfaceId id) { |
| 251 view_->SetSurfaceId(mojo::SurfaceId::From(id)); | 243 view_->SetSurfaceId(mojo::SurfaceId::From(id)); |
| 252 } | 244 } |
| 253 | 245 |
| 254 } // namespace html_viewer | 246 } // namespace html_viewer |
| OLD | NEW |