Chromium Code Reviews| 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 "components/html_viewer/web_layer_tree_view_impl.h" | 5 #include "components/html_viewer/web_layer_tree_view_impl.h" |
| 6 | 6 |
| 7 #include "base/thread_task_runner_handle.h" | 7 #include "base/thread_task_runner_handle.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 "components/view_manager/public/cpp/view.h" | 13 #include "components/view_manager/public/cpp/view.h" |
| 14 #include "mojo/cc/context_provider_mojo.h" | 14 #include "mojo/cc/context_provider_mojo.h" |
| 15 #include "mojo/cc/output_surface_mojo.h" | 15 #include "mojo/cc/output_surface_mojo.h" |
| 16 #include "mojo/converters/surfaces/surfaces_type_converters.h" | 16 #include "mojo/converters/surfaces/surfaces_type_converters.h" |
| 17 #include "third_party/WebKit/public/web/WebWidget.h" | 17 #include "third_party/WebKit/public/web/WebWidget.h" |
| 18 #include "ui/gfx/buffer_types.h" | 18 #include "ui/gfx/buffer_types.h" |
| 19 | 19 |
| 20 namespace html_viewer { | 20 namespace html_viewer { |
| 21 | 21 |
| 22 WebLayerTreeViewImpl::WebLayerTreeViewImpl( | 22 WebLayerTreeViewImpl::WebLayerTreeViewImpl( |
| 23 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner, | 23 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner, |
| 24 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 24 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 25 cc::TaskGraphRunner* task_graph_runner, | 25 cc::TaskGraphRunner* task_graph_runner, |
| 26 mojo::SurfacePtr surface, | 26 mojo::CompositorFrameReceiverPtr receiver, |
| 27 mojo::GpuPtr gpu_service) | 27 mojo::GpuPtr gpu_service) |
| 28 : widget_(NULL), | 28 : widget_(NULL), |
| 29 view_(NULL), | 29 view_(NULL), |
| 30 main_thread_compositor_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 30 main_thread_compositor_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 31 weak_factory_(this) { | 31 weak_factory_(this) { |
| 32 main_thread_bound_weak_ptr_ = weak_factory_.GetWeakPtr(); | 32 main_thread_bound_weak_ptr_ = weak_factory_.GetWeakPtr(); |
| 33 | 33 |
| 34 cc::LayerTreeSettings settings; | 34 cc::LayerTreeSettings settings; |
| 35 | 35 |
| 36 // Must match the value of | 36 // Must match the value of |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 54 params.shared_bitmap_manager = shared_bitmap_manager; | 54 params.shared_bitmap_manager = shared_bitmap_manager; |
| 55 params.gpu_memory_buffer_manager = gpu_memory_buffer_manager; | 55 params.gpu_memory_buffer_manager = gpu_memory_buffer_manager; |
| 56 params.settings = &settings; | 56 params.settings = &settings; |
| 57 params.task_graph_runner = task_graph_runner; | 57 params.task_graph_runner = task_graph_runner; |
| 58 params.main_task_runner = main_thread_compositor_task_runner_; | 58 params.main_task_runner = main_thread_compositor_task_runner_; |
| 59 | 59 |
| 60 layer_tree_host_ = | 60 layer_tree_host_ = |
| 61 cc::LayerTreeHost::CreateThreaded(compositor_task_runner, ¶ms); | 61 cc::LayerTreeHost::CreateThreaded(compositor_task_runner, ¶ms); |
| 62 DCHECK(layer_tree_host_); | 62 DCHECK(layer_tree_host_); |
| 63 | 63 |
| 64 if (surface && gpu_service) { | 64 if (receiver && gpu_service) { |
| 65 mojo::CommandBufferPtr cb; | 65 mojo::CommandBufferPtr cb; |
| 66 gpu_service->CreateOffscreenGLES2Context(GetProxy(&cb)); | 66 gpu_service->CreateOffscreenGLES2Context(GetProxy(&cb)); |
| 67 scoped_refptr<cc::ContextProvider> context_provider( | 67 scoped_refptr<cc::ContextProvider> context_provider( |
| 68 new mojo::ContextProviderMojo(cb.PassInterface().PassHandle())); | 68 new mojo::ContextProviderMojo(cb.PassInterface().PassHandle())); |
| 69 output_surface_.reset( | 69 output_surface_.reset( |
| 70 new mojo::OutputSurfaceMojo(this, context_provider, | 70 new mojo::OutputSurfaceMojo(this, context_provider, |
| 71 surface.PassInterface().PassHandle())); | 71 receiver.PassInterface().PassHandle())); |
|
rjkroege
2015/08/19 23:45:44
impl gets it here obviously. but you have an order
Fady Samuel
2015/08/20 16:22:44
As per offline discussion, I think there was some
rjkroege
2015/08/21 18:54:45
yes. this code is running on main and CC will get
Fady Samuel
2015/08/21 21:31:10
Acknowledged.
| |
| 72 } | 72 } |
| 73 layer_tree_host_->SetLayerTreeHostClientReady(); | 73 layer_tree_host_->SetLayerTreeHostClientReady(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 WebLayerTreeViewImpl::~WebLayerTreeViewImpl() { | 76 WebLayerTreeViewImpl::~WebLayerTreeViewImpl() { |
| 77 // Destroy the LayerTreeHost before anything else as doing so ensures we're | 77 // Destroy the LayerTreeHost before anything else as doing so ensures we're |
| 78 // not accessed on the compositor thread (we are the LayerTreeHostClient). | 78 // not accessed on the compositor thread (we are the LayerTreeHostClient). |
| 79 layer_tree_host_.reset(); | 79 layer_tree_host_.reset(); |
| 80 } | 80 } |
| 81 | 81 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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(mojo::SurfaceId::From(id)); | 255 view_->SetSurfaceId(mojo::SurfaceId::From(id)); |
| 256 } | 256 } |
| 257 | 257 |
| 258 } // namespace html_viewer | 258 } // namespace html_viewer |
| OLD | NEW |