OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "cc/trees/thread_proxy.h" | 5 #include "cc/trees/thread_proxy.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "cc/base/thread.h" | 10 #include "cc/base/thread.h" |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 | 229 |
230 OnOutputSurfaceInitializeAttempted(success, capabilities); | 230 OnOutputSurfaceInitializeAttempted(success, capabilities); |
231 } | 231 } |
232 | 232 |
233 void ThreadProxy::OnOutputSurfaceInitializeAttempted( | 233 void ThreadProxy::OnOutputSurfaceInitializeAttempted( |
234 bool success, | 234 bool success, |
235 const RendererCapabilities& capabilities) { | 235 const RendererCapabilities& capabilities) { |
236 DCHECK(IsMainThread()); | 236 DCHECK(IsMainThread()); |
237 DCHECK(layer_tree_host_); | 237 DCHECK(layer_tree_host_); |
238 | 238 |
239 if (success) { | 239 if (success) |
240 renderer_capabilities_main_thread_copy_ = capabilities; | 240 renderer_capabilities_main_thread_copy_ = capabilities; |
241 } | |
242 | 241 |
243 LayerTreeHost::CreateResult result = | 242 LayerTreeHost::CreateResult result = |
244 layer_tree_host_->OnCreateAndInitializeOutputSurfaceAttempted(success); | 243 layer_tree_host_->OnCreateAndInitializeOutputSurfaceAttempted(success); |
245 if (result == LayerTreeHost::CreateFailedButTryAgain) { | 244 if (result == LayerTreeHost::CreateFailedButTryAgain) { |
246 if (!output_surface_creation_callback_.callback().is_null()) { | 245 if (!output_surface_creation_callback_.callback().is_null()) { |
247 Proxy::MainThread()->PostTask( | 246 Proxy::MainThread()->PostTask( |
248 output_surface_creation_callback_.callback()); | 247 output_surface_creation_callback_.callback()); |
249 } | 248 } |
250 } else { | 249 } else { |
251 output_surface_creation_callback_.Cancel(); | 250 output_surface_creation_callback_.Cancel(); |
(...skipping 28 matching lines...) Expand all Loading... |
280 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsCommit"); | 279 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsCommit"); |
281 commit_requested_ = true; | 280 commit_requested_ = true; |
282 | 281 |
283 if (commit_request_sent_to_impl_thread_) | 282 if (commit_request_sent_to_impl_thread_) |
284 return; | 283 return; |
285 commit_request_sent_to_impl_thread_ = true; | 284 commit_request_sent_to_impl_thread_ = true; |
286 Proxy::ImplThread()->PostTask(base::Bind( | 285 Proxy::ImplThread()->PostTask(base::Bind( |
287 &ThreadProxy::SetNeedsCommitOnImplThread, impl_thread_weak_ptr_)); | 286 &ThreadProxy::SetNeedsCommitOnImplThread, impl_thread_weak_ptr_)); |
288 } | 287 } |
289 | 288 |
| 289 void ThreadProxy::DidUpdateCapabilitiesOnImplThread() { |
| 290 DCHECK(IsImplThread()); |
| 291 UpdateCapabilitiesOnImplThread(); |
| 292 Proxy::MainThread()->PostTask( |
| 293 base::Bind(&ThreadProxy::DidUpdateCapabilities, |
| 294 main_thread_weak_ptr_, |
| 295 layer_tree_host_impl_->GetRendererCapabilities())); |
| 296 } |
| 297 |
| 298 void ThreadProxy::DidUpdateCapabilities( |
| 299 const RendererCapabilities& capabilities) { |
| 300 DCHECK(IsMainThread()); |
| 301 renderer_capabilities_main_thread_copy_ = capabilities; |
| 302 layer_tree_host_->DidUpdateCapabilities(); |
| 303 } |
| 304 |
290 void ThreadProxy::DidLoseOutputSurfaceOnImplThread() { | 305 void ThreadProxy::DidLoseOutputSurfaceOnImplThread() { |
291 DCHECK(IsImplThread()); | 306 DCHECK(IsImplThread()); |
292 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurfaceOnImplThread"); | 307 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurfaceOnImplThread"); |
293 Proxy::ImplThread()->PostTask( | 308 Proxy::ImplThread()->PostTask( |
294 base::Bind(&ThreadProxy::CheckOutputSurfaceStatusOnImplThread, | 309 base::Bind(&ThreadProxy::CheckOutputSurfaceStatusOnImplThread, |
295 impl_thread_weak_ptr_)); | 310 impl_thread_weak_ptr_)); |
296 } | 311 } |
297 | 312 |
298 void ThreadProxy::CheckOutputSurfaceStatusOnImplThread() { | 313 void ThreadProxy::CheckOutputSurfaceStatusOnImplThread() { |
299 DCHECK(IsImplThread()); | 314 DCHECK(IsImplThread()); |
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1145 layer_tree_host_->DeleteContentsTexturesOnImplThread( | 1160 layer_tree_host_->DeleteContentsTexturesOnImplThread( |
1146 layer_tree_host_impl_->resource_provider()); | 1161 layer_tree_host_impl_->resource_provider()); |
1147 | 1162 |
1148 *success = layer_tree_host_impl_->InitializeRenderer(output_surface.Pass()); | 1163 *success = layer_tree_host_impl_->InitializeRenderer(output_surface.Pass()); |
1149 | 1164 |
1150 if (offscreen_context_provider) | 1165 if (offscreen_context_provider) |
1151 offscreen_context_provider->BindToCurrentThread(); | 1166 offscreen_context_provider->BindToCurrentThread(); |
1152 | 1167 |
1153 if (*success) { | 1168 if (*success) { |
1154 *capabilities = layer_tree_host_impl_->GetRendererCapabilities(); | 1169 *capabilities = layer_tree_host_impl_->GetRendererCapabilities(); |
1155 scheduler_on_impl_thread_->SetSwapBuffersCompleteSupported( | 1170 UpdateCapabilitiesOnImplThread(); |
1156 capabilities->using_swap_complete_callback); | |
1157 | |
1158 OutputSurface* output_surface_ptr = layer_tree_host_impl_->output_surface(); | |
1159 DCHECK(output_surface_ptr); | |
1160 int max_frames_pending = | |
1161 output_surface_ptr->capabilities().max_frames_pending; | |
1162 if (max_frames_pending <= 0) | |
1163 max_frames_pending = FrameRateController::DEFAULT_MAX_FRAMES_PENDING; | |
1164 if (output_surface_ptr->capabilities().has_parent_compositor) | |
1165 max_frames_pending = 1; | |
1166 | |
1167 scheduler_on_impl_thread_->SetMaxFramesPending(max_frames_pending); | |
1168 | 1171 |
1169 layer_tree_host_impl_->resource_provider()-> | 1172 layer_tree_host_impl_->resource_provider()-> |
1170 set_offscreen_context_provider(offscreen_context_provider); | 1173 set_offscreen_context_provider(offscreen_context_provider); |
1171 | 1174 |
1172 scheduler_on_impl_thread_->DidCreateAndInitializeOutputSurface(); | 1175 scheduler_on_impl_thread_->DidCreateAndInitializeOutputSurface(); |
1173 } else if (offscreen_context_provider) { | 1176 } else if (offscreen_context_provider) { |
1174 offscreen_context_provider->VerifyContexts(); | 1177 offscreen_context_provider->VerifyContexts(); |
1175 } | 1178 } |
1176 | 1179 |
1177 completion->Signal(); | 1180 completion->Signal(); |
1178 } | 1181 } |
1179 | 1182 |
| 1183 void ThreadProxy::UpdateCapabilitiesOnImplThread() { |
| 1184 DCHECK(IsImplThread()); |
| 1185 |
| 1186 RendererCapabilities capabilities = |
| 1187 layer_tree_host_impl_->GetRendererCapabilities(); |
| 1188 scheduler_on_impl_thread_->SetSwapBuffersCompleteSupported( |
| 1189 capabilities.using_swap_complete_callback); |
| 1190 |
| 1191 OutputSurface* output_surface_ptr = layer_tree_host_impl_->output_surface(); |
| 1192 DCHECK(output_surface_ptr); |
| 1193 int max_frames_pending = |
| 1194 output_surface_ptr->capabilities().max_frames_pending; |
| 1195 if (max_frames_pending <= 0) |
| 1196 max_frames_pending = FrameRateController::DEFAULT_MAX_FRAMES_PENDING; |
| 1197 if (output_surface_ptr->capabilities().has_parent_compositor) |
| 1198 max_frames_pending = 1; |
| 1199 |
| 1200 scheduler_on_impl_thread_->SetMaxFramesPending(max_frames_pending); |
| 1201 } |
| 1202 |
1180 void ThreadProxy::FinishGLOnImplThread(CompletionEvent* completion) { | 1203 void ThreadProxy::FinishGLOnImplThread(CompletionEvent* completion) { |
1181 TRACE_EVENT0("cc", "ThreadProxy::FinishGLOnImplThread"); | 1204 TRACE_EVENT0("cc", "ThreadProxy::FinishGLOnImplThread"); |
1182 DCHECK(IsImplThread()); | 1205 DCHECK(IsImplThread()); |
1183 if (layer_tree_host_impl_->resource_provider()) | 1206 if (layer_tree_host_impl_->resource_provider()) |
1184 layer_tree_host_impl_->resource_provider()->Finish(); | 1207 layer_tree_host_impl_->resource_provider()->Finish(); |
1185 completion->Signal(); | 1208 completion->Signal(); |
1186 } | 1209 } |
1187 | 1210 |
1188 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { | 1211 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { |
1189 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); | 1212 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1367 !layer_tree_host_impl_->pending_tree()) { | 1390 !layer_tree_host_impl_->pending_tree()) { |
1368 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation", | 1391 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation", |
1369 TRACE_EVENT_SCOPE_THREAD); | 1392 TRACE_EVENT_SCOPE_THREAD); |
1370 DCHECK(layer_tree_host_impl_->settings().impl_side_painting); | 1393 DCHECK(layer_tree_host_impl_->settings().impl_side_painting); |
1371 completion_event_for_commit_held_on_tree_activation_->Signal(); | 1394 completion_event_for_commit_held_on_tree_activation_->Signal(); |
1372 completion_event_for_commit_held_on_tree_activation_ = NULL; | 1395 completion_event_for_commit_held_on_tree_activation_ = NULL; |
1373 } | 1396 } |
1374 } | 1397 } |
1375 | 1398 |
1376 } // namespace cc | 1399 } // namespace cc |
OLD | NEW |