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, | |
27 mojo::GpuPtr gpu_service) | |
28 : widget_(NULL), | 26 : widget_(NULL), |
29 view_(NULL), | 27 view_(NULL), |
30 main_thread_compositor_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 28 main_thread_compositor_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
31 weak_factory_(this) { | 29 weak_factory_(this) { |
32 main_thread_bound_weak_ptr_ = weak_factory_.GetWeakPtr(); | 30 main_thread_bound_weak_ptr_ = weak_factory_.GetWeakPtr(); |
33 | 31 |
34 cc::LayerTreeSettings settings; | 32 cc::LayerTreeSettings settings; |
35 | 33 |
36 // Must match the value of | 34 // Must match the value of |
37 // blink::RuntimeEnabledFeature::slimmingPaintEnabled() | 35 // blink::RuntimeEnabledFeature::slimmingPaintEnabled() |
(...skipping 17 matching lines...) Expand all Loading... |
55 params.client = this; | 53 params.client = this; |
56 params.shared_bitmap_manager = shared_bitmap_manager; | 54 params.shared_bitmap_manager = shared_bitmap_manager; |
57 params.gpu_memory_buffer_manager = gpu_memory_buffer_manager; | 55 params.gpu_memory_buffer_manager = gpu_memory_buffer_manager; |
58 params.settings = &settings; | 56 params.settings = &settings; |
59 params.task_graph_runner = task_graph_runner; | 57 params.task_graph_runner = task_graph_runner; |
60 params.main_task_runner = main_thread_compositor_task_runner_; | 58 params.main_task_runner = main_thread_compositor_task_runner_; |
61 | 59 |
62 layer_tree_host_ = | 60 layer_tree_host_ = |
63 cc::LayerTreeHost::CreateThreaded(compositor_task_runner, ¶ms); | 61 cc::LayerTreeHost::CreateThreaded(compositor_task_runner, ¶ms); |
64 DCHECK(layer_tree_host_); | 62 DCHECK(layer_tree_host_); |
| 63 } |
65 | 64 |
66 if (surface && gpu_service) { | 65 void WebLayerTreeViewImpl::Initialize(mojo::GpuPtr gpu_service, |
| 66 mojo::View* view, |
| 67 blink::WebWidget* widget) { |
| 68 view_ = view; |
| 69 widget_ = widget; |
| 70 if (gpu_service) { |
67 mojo::CommandBufferPtr cb; | 71 mojo::CommandBufferPtr cb; |
68 gpu_service->CreateOffscreenGLES2Context(GetProxy(&cb)); | 72 gpu_service->CreateOffscreenGLES2Context(GetProxy(&cb)); |
69 scoped_refptr<cc::ContextProvider> context_provider( | 73 scoped_refptr<cc::ContextProvider> context_provider( |
70 new mojo::ContextProviderMojo(cb.PassInterface().PassHandle())); | 74 new mojo::ContextProviderMojo(cb.PassInterface().PassHandle())); |
71 output_surface_.reset( | 75 output_surface_.reset( |
72 new mojo::OutputSurfaceMojo(this, context_provider, | 76 new mojo::OutputSurfaceMojo(context_provider, view_->RequestSurface())); |
73 surface.PassInterface().PassHandle())); | |
74 } | 77 } |
75 layer_tree_host_->SetLayerTreeHostClientReady(); | 78 layer_tree_host_->SetLayerTreeHostClientReady(); |
76 } | 79 } |
77 | 80 |
78 WebLayerTreeViewImpl::~WebLayerTreeViewImpl() { | 81 WebLayerTreeViewImpl::~WebLayerTreeViewImpl() { |
79 // Destroy the LayerTreeHost before anything else as doing so ensures we're | 82 // Destroy the LayerTreeHost before anything else as doing so ensures we're |
80 // not accessed on the compositor thread (we are the LayerTreeHostClient). | 83 // not accessed on the compositor thread (we are the LayerTreeHostClient). |
81 layer_tree_host_.reset(); | 84 layer_tree_host_.reset(); |
82 } | 85 } |
83 | 86 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 } | 243 } |
241 | 244 |
242 void WebLayerTreeViewImpl::setNeedsAnimate() { | 245 void WebLayerTreeViewImpl::setNeedsAnimate() { |
243 layer_tree_host_->SetNeedsAnimate(); | 246 layer_tree_host_->SetNeedsAnimate(); |
244 } | 247 } |
245 | 248 |
246 void WebLayerTreeViewImpl::finishAllRendering() { | 249 void WebLayerTreeViewImpl::finishAllRendering() { |
247 layer_tree_host_->FinishAllRendering(); | 250 layer_tree_host_->FinishAllRendering(); |
248 } | 251 } |
249 | 252 |
250 void WebLayerTreeViewImpl::DidCreateSurface(cc::SurfaceId id) { | |
251 main_thread_compositor_task_runner_->PostTask( | |
252 FROM_HERE, | |
253 base::Bind(&WebLayerTreeViewImpl::DidCreateSurfaceOnMainThread, | |
254 main_thread_bound_weak_ptr_, | |
255 id)); | |
256 } | |
257 | |
258 void WebLayerTreeViewImpl::DidCreateSurfaceOnMainThread(cc::SurfaceId id) { | |
259 view_->SetSurfaceId(mojo::SurfaceId::From(id)); | |
260 } | |
261 | |
262 } // namespace html_viewer | 253 } // namespace html_viewer |
OLD | NEW |