Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "blimp/client/feature/compositor/blimp_compositor.h" | 5 #include "blimp/client/feature/compositor/blimp_compositor.h" |
| 6 | 6 |
| 7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 compositor_dependencies_(compositor_dependencies), | 65 compositor_dependencies_(compositor_dependencies), |
| 66 host_should_be_visible_(false), | 66 host_should_be_visible_(false), |
| 67 output_surface_(nullptr), | 67 output_surface_(nullptr), |
| 68 output_surface_request_pending_(false), | 68 output_surface_request_pending_(false), |
| 69 layer_(cc::Layer::Create()), | 69 layer_(cc::Layer::Create()), |
| 70 remote_proto_channel_receiver_(nullptr), | 70 remote_proto_channel_receiver_(nullptr), |
| 71 weak_ptr_factory_(this) { | 71 weak_ptr_factory_(this) { |
| 72 DCHECK(thread_checker_.CalledOnValidThread()); | 72 DCHECK(thread_checker_.CalledOnValidThread()); |
| 73 | 73 |
| 74 surface_id_allocator_ = base::MakeUnique<cc::SurfaceIdAllocator>( | 74 surface_id_allocator_ = base::MakeUnique<cc::SurfaceIdAllocator>( |
| 75 GetEmbedderDeps()->AllocateSurfaceId()); | 75 GetEmbedderDeps()->AllocateSurfaceClientId()); |
| 76 GetEmbedderDeps()->GetSurfaceManager()->RegisterSurfaceClientId( | 76 GetEmbedderDeps()->GetSurfaceManager()->RegisterSurfaceClientId( |
| 77 surface_id_allocator_->client_id()); | 77 surface_id_allocator_->client_id()); |
| 78 } | 78 } |
| 79 | 79 |
| 80 BlimpCompositor::~BlimpCompositor() { | 80 BlimpCompositor::~BlimpCompositor() { |
| 81 DCHECK(thread_checker_.CalledOnValidThread()); | 81 DCHECK(thread_checker_.CalledOnValidThread()); |
| 82 | 82 |
| 83 if (host_) | 83 if (host_) |
| 84 DestroyLayerTreeHost(); | 84 DestroyLayerTreeHost(); |
| 85 | 85 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 97 if (input_manager_) | 97 if (input_manager_) |
| 98 return input_manager_->OnTouchEvent(motion_event); | 98 return input_manager_->OnTouchEvent(motion_event); |
| 99 return false; | 99 return false; |
| 100 } | 100 } |
| 101 | 101 |
| 102 void BlimpCompositor::RequestNewOutputSurface() { | 102 void BlimpCompositor::RequestNewOutputSurface() { |
| 103 DCHECK(!surface_factory_); | 103 DCHECK(!surface_factory_); |
| 104 DCHECK(!output_surface_request_pending_); | 104 DCHECK(!output_surface_request_pending_); |
| 105 | 105 |
| 106 output_surface_request_pending_ = true; | 106 output_surface_request_pending_ = true; |
| 107 GetEmbedderDeps()->GetContextProvider( | 107 GetEmbedderDeps()->GetContextProviders( |
| 108 base::Bind(&BlimpCompositor::OnContextProviderCreated, | 108 base::Bind(&BlimpCompositor::OnContextProviderCreated, |
| 109 weak_ptr_factory_.GetWeakPtr())); | 109 weak_ptr_factory_.GetWeakPtr())); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void BlimpCompositor::DidInitializeOutputSurface() { | 112 void BlimpCompositor::DidInitializeOutputSurface() { |
| 113 output_surface_request_pending_ = false; | 113 output_surface_request_pending_ = false; |
| 114 } | 114 } |
| 115 | 115 |
| 116 void BlimpCompositor::DidCommitAndDrawFrame() { | 116 void BlimpCompositor::DidCommitAndDrawFrame() { |
| 117 BlimpStats::GetInstance()->Add(BlimpStats::COMMIT, 1); | 117 BlimpStats::GetInstance()->Add(BlimpStats::COMMIT, 1); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 break; | 152 break; |
| 153 default: | 153 default: |
| 154 // We should have a receiver if we're getting compositor messages that | 154 // We should have a receiver if we're getting compositor messages that |
| 155 // are not INITIALIZE_IMPL or CLOSE_IMPL. | 155 // are not INITIALIZE_IMPL or CLOSE_IMPL. |
| 156 DCHECK(remote_proto_channel_receiver_); | 156 DCHECK(remote_proto_channel_receiver_); |
| 157 remote_proto_channel_receiver_->OnProtoReceived(std::move(message)); | 157 remote_proto_channel_receiver_->OnProtoReceived(std::move(message)); |
| 158 } | 158 } |
| 159 } | 159 } |
| 160 | 160 |
| 161 void BlimpCompositor::OnContextProviderCreated( | 161 void BlimpCompositor::OnContextProviderCreated( |
| 162 const scoped_refptr<cc::ContextProvider>& provider) { | 162 const blimp::client::CompositorDependencies::ContextProviders& |
| 163 context_providers) { | |
| 163 DCHECK(!surface_factory_) | 164 DCHECK(!surface_factory_) |
| 164 << "Any connection to the old output surface should have been destroyed"; | 165 << "Any connection to the old output surface should have been destroyed"; |
| 165 | 166 |
| 166 // Make sure we still have a host and we're still expecting an output surface. | 167 // Make sure we still have a host and we're still expecting an output surface. |
| 167 // This can happen if the host dies while the request is outstanding and we | 168 // This can happen if the host dies while the request is outstanding and we |
| 168 // build a new one that hasn't asked for a surface yet. | 169 // build a new one that hasn't asked for a surface yet. |
| 169 if (!output_surface_request_pending_) | 170 if (!output_surface_request_pending_) |
| 170 return; | 171 return; |
| 171 | 172 |
| 172 // TODO(khushalsagar): Make a worker context and bind it to the current | 173 // Try again if the context creation failed. |
| 173 // thread: | 174 if (!context_providers.compositor_context_provider) { |
| 174 // Worker context is bound to the main thread in RenderThreadImpl. One day | 175 GetEmbedderDeps()->GetContextProviders( |
| 175 // that will change and then this will have to be removed. | 176 base::Bind(&BlimpCompositor::OnContextProviderCreated, |
| 176 // worker_context_provider->BindToCurrentThread(); | 177 weak_ptr_factory_.GetWeakPtr())); |
|
David Trainor- moved to gerrit
2016/08/31 00:28:58
Return after this?
Khushal
2016/08/31 21:22:50
Good catch. Done.
| |
| 178 } | |
| 179 | |
| 177 std::unique_ptr<DelegatedOutputSurface> delegated_output_surface = | 180 std::unique_ptr<DelegatedOutputSurface> delegated_output_surface = |
| 178 base::MakeUnique<DelegatedOutputSurface>( | 181 base::MakeUnique<DelegatedOutputSurface>( |
| 179 provider, nullptr, base::ThreadTaskRunnerHandle::Get(), | 182 std::move(context_providers.compositor_context_provider), |
| 180 weak_ptr_factory_.GetWeakPtr()); | 183 std::move(context_providers.worker_context_provider), |
| 184 base::ThreadTaskRunnerHandle::Get(), weak_ptr_factory_.GetWeakPtr()); | |
| 181 | 185 |
| 182 host_->SetOutputSurface(std::move(delegated_output_surface)); | 186 host_->SetOutputSurface(std::move(delegated_output_surface)); |
| 183 } | 187 } |
| 184 | 188 |
| 185 void BlimpCompositor::SendWebGestureEvent( | 189 void BlimpCompositor::SendWebGestureEvent( |
| 186 const blink::WebGestureEvent& gesture_event) { | 190 const blink::WebGestureEvent& gesture_event) { |
| 187 client_->SendWebGestureEvent(render_widget_id_, gesture_event); | 191 client_->SendWebGestureEvent(render_widget_id_, gesture_event); |
| 188 } | 192 } |
| 189 | 193 |
| 190 void BlimpCompositor::BindToOutputSurface( | 194 void BlimpCompositor::BindToOutputSurface( |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 313 // Cancel any outstanding OutputSurface requests. That way if we get an async | 317 // Cancel any outstanding OutputSurface requests. That way if we get an async |
| 314 // callback related to the old request we know to drop it. | 318 // callback related to the old request we know to drop it. |
| 315 output_surface_request_pending_ = false; | 319 output_surface_request_pending_ = false; |
| 316 | 320 |
| 317 // Make sure we don't have a receiver at this point. | 321 // Make sure we don't have a receiver at this point. |
| 318 DCHECK(!remote_proto_channel_receiver_); | 322 DCHECK(!remote_proto_channel_receiver_); |
| 319 } | 323 } |
| 320 | 324 |
| 321 } // namespace client | 325 } // namespace client |
| 322 } // namespace blimp | 326 } // namespace blimp |
| OLD | NEW |