| 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/numerics/safe_conversions.h" | 9 #include "base/numerics/safe_conversions.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 158 |
| 159 void BlimpCompositor::SendWebGestureEvent( | 159 void BlimpCompositor::SendWebGestureEvent( |
| 160 const blink::WebGestureEvent& gesture_event) { | 160 const blink::WebGestureEvent& gesture_event) { |
| 161 client_->SendWebGestureEvent(render_widget_id_, gesture_event); | 161 client_->SendWebGestureEvent(render_widget_id_, gesture_event); |
| 162 } | 162 } |
| 163 | 163 |
| 164 void BlimpCompositor::SetVisibleInternal(bool visible) { | 164 void BlimpCompositor::SetVisibleInternal(bool visible) { |
| 165 if (!host_) | 165 if (!host_) |
| 166 return; | 166 return; |
| 167 | 167 |
| 168 VLOG(1) << "Setting visibility to: " << visible |
| 169 << " for render widget: " << render_widget_id_; |
| 170 |
| 168 if (visible && window_ != gfx::kNullAcceleratedWidget) { | 171 if (visible && window_ != gfx::kNullAcceleratedWidget) { |
| 169 // If we're supposed to be visible and we have a valid | 172 // If we're supposed to be visible and we have a valid |
| 170 // gfx::AcceleratedWidget make our compositor visible. If the compositor | 173 // gfx::AcceleratedWidget make our compositor visible. If the compositor |
| 171 // had an outstanding output surface request, trigger the request again so | 174 // had an outstanding output surface request, trigger the request again so |
| 172 // we build the output surface. | 175 // we build the output surface. |
| 173 host_->SetVisible(true); | 176 host_->SetVisible(true); |
| 174 if (output_surface_request_pending_) | 177 if (output_surface_request_pending_) |
| 175 HandlePendingOutputSurfaceRequest(); | 178 HandlePendingOutputSurfaceRequest(); |
| 176 } else if (!visible) { | 179 } else if (!visible) { |
| 177 // If not visible, hide the compositor and have it drop it's output | 180 // If not visible, hide the compositor and have it drop it's output |
| 178 // surface. | 181 // surface. |
| 179 host_->SetVisible(false); | 182 host_->SetVisible(false); |
| 180 if (!host_->output_surface_lost()) { | 183 if (!host_->output_surface_lost()) { |
| 181 host_->ReleaseOutputSurface(); | 184 host_->ReleaseOutputSurface(); |
| 182 } | 185 } |
| 183 } | 186 } |
| 184 } | 187 } |
| 185 | 188 |
| 186 void BlimpCompositor::CreateLayerTreeHost( | 189 void BlimpCompositor::CreateLayerTreeHost( |
| 187 const cc::proto::InitializeImpl& initialize_message) { | 190 const cc::proto::InitializeImpl& initialize_message) { |
| 188 DCHECK(!host_); | 191 DCHECK(!host_); |
| 192 VLOG(1) << "Creating LayerTreeHost for render widget: " << render_widget_id_; |
| 189 | 193 |
| 190 // Create the LayerTreeHost | 194 // Create the LayerTreeHost |
| 191 cc::LayerTreeHost::InitParams params; | 195 cc::LayerTreeHost::InitParams params; |
| 192 params.client = this; | 196 params.client = this; |
| 193 params.task_graph_runner = client_->GetTaskGraphRunner(); | 197 params.task_graph_runner = client_->GetTaskGraphRunner(); |
| 194 params.gpu_memory_buffer_manager = client_->GetGpuMemoryBufferManager(); | 198 params.gpu_memory_buffer_manager = client_->GetGpuMemoryBufferManager(); |
| 195 params.main_task_runner = base::ThreadTaskRunnerHandle::Get(); | 199 params.main_task_runner = base::ThreadTaskRunnerHandle::Get(); |
| 196 params.image_serialization_processor = | 200 params.image_serialization_processor = |
| 197 client_->GetImageSerializationProcessor(); | 201 client_->GetImageSerializationProcessor(); |
| 198 params.settings = client_->GetLayerTreeSettings(); | 202 params.settings = client_->GetLayerTreeSettings(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 210 DCHECK(!input_manager_); | 214 DCHECK(!input_manager_); |
| 211 input_manager_ = | 215 input_manager_ = |
| 212 BlimpInputManager::Create(this, | 216 BlimpInputManager::Create(this, |
| 213 base::ThreadTaskRunnerHandle::Get(), | 217 base::ThreadTaskRunnerHandle::Get(), |
| 214 compositor_task_runner, | 218 compositor_task_runner, |
| 215 host_->GetInputHandler()); | 219 host_->GetInputHandler()); |
| 216 } | 220 } |
| 217 | 221 |
| 218 void BlimpCompositor::DestroyLayerTreeHost() { | 222 void BlimpCompositor::DestroyLayerTreeHost() { |
| 219 DCHECK(host_); | 223 DCHECK(host_); |
| 224 VLOG(1) << "Destroying LayerTreeHost for render widget: " |
| 225 << render_widget_id_; |
| 220 // Tear down the output surface connection with the old LayerTreeHost | 226 // Tear down the output surface connection with the old LayerTreeHost |
| 221 // instance. | 227 // instance. |
| 222 SetVisibleInternal(false); | 228 SetVisibleInternal(false); |
| 223 | 229 |
| 224 // Destroy the old LayerTreeHost state. | 230 // Destroy the old LayerTreeHost state. |
| 225 host_.reset(); | 231 host_.reset(); |
| 226 | 232 |
| 227 // Destroy the old input manager state. | 233 // Destroy the old input manager state. |
| 228 // It is important to destroy the LayerTreeHost before destroying the input | 234 // It is important to destroy the LayerTreeHost before destroying the input |
| 229 // manager as it has a reference to the cc::InputHandlerClient owned by the | 235 // manager as it has a reference to the cc::InputHandlerClient owned by the |
| (...skipping 20 matching lines...) Expand all Loading... |
| 250 BlimpContextProvider::Create(window_, | 256 BlimpContextProvider::Create(window_, |
| 251 client_->GetGpuMemoryBufferManager()); | 257 client_->GetGpuMemoryBufferManager()); |
| 252 | 258 |
| 253 host_->SetOutputSurface( | 259 host_->SetOutputSurface( |
| 254 make_scoped_ptr(new BlimpOutputSurface(context_provider))); | 260 make_scoped_ptr(new BlimpOutputSurface(context_provider))); |
| 255 output_surface_request_pending_ = false; | 261 output_surface_request_pending_ = false; |
| 256 } | 262 } |
| 257 | 263 |
| 258 } // namespace client | 264 } // namespace client |
| 259 } // namespace blimp | 265 } // namespace blimp |
| OLD | NEW |