| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 | 322 |
| 323 void ThreadProxy::DidLoseOutputSurfaceOnImplThread() { | 323 void ThreadProxy::DidLoseOutputSurfaceOnImplThread() { |
| 324 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurfaceOnImplThread"); | 324 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurfaceOnImplThread"); |
| 325 DCHECK(IsImplThread()); | 325 DCHECK(IsImplThread()); |
| 326 Proxy::MainThreadTaskRunner()->PostTask( | 326 Proxy::MainThreadTaskRunner()->PostTask( |
| 327 FROM_HERE, | 327 FROM_HERE, |
| 328 base::Bind(&ThreadProxy::DidLoseOutputSurface, main_thread_weak_ptr_)); | 328 base::Bind(&ThreadProxy::DidLoseOutputSurface, main_thread_weak_ptr_)); |
| 329 impl().scheduler->DidLoseOutputSurface(); | 329 impl().scheduler->DidLoseOutputSurface(); |
| 330 } | 330 } |
| 331 | 331 |
| 332 void ThreadProxy::CommitVSyncParameters(base::TimeTicks timebase, | |
| 333 base::TimeDelta interval) { | |
| 334 impl().scheduler->CommitVSyncParameters(timebase, interval); | |
| 335 } | |
| 336 | |
| 337 void ThreadProxy::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { | 332 void ThreadProxy::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { |
| 338 impl().scheduler->SetEstimatedParentDrawTime(draw_time); | 333 impl().scheduler->SetEstimatedParentDrawTime(draw_time); |
| 339 } | 334 } |
| 340 | 335 |
| 341 void ThreadProxy::SetMaxSwapsPendingOnImplThread(int max) { | 336 void ThreadProxy::SetMaxSwapsPendingOnImplThread(int max) { |
| 342 impl().scheduler->SetMaxSwapsPending(max); | 337 impl().scheduler->SetMaxSwapsPending(max); |
| 343 } | 338 } |
| 344 | 339 |
| 345 void ThreadProxy::DidSwapBuffersOnImplThread() { | 340 void ThreadProxy::DidSwapBuffersOnImplThread() { |
| 346 impl().scheduler->DidSwapBuffers(); | 341 impl().scheduler->DidSwapBuffers(); |
| 347 } | 342 } |
| 348 | 343 |
| 349 void ThreadProxy::DidSwapBuffersCompleteOnImplThread() { | 344 void ThreadProxy::DidSwapBuffersCompleteOnImplThread() { |
| 350 TRACE_EVENT0("cc", "ThreadProxy::DidSwapBuffersCompleteOnImplThread"); | 345 TRACE_EVENT0("cc", "ThreadProxy::DidSwapBuffersCompleteOnImplThread"); |
| 351 DCHECK(IsImplThread()); | 346 DCHECK(IsImplThread()); |
| 352 impl().scheduler->DidSwapBuffersComplete(); | 347 impl().scheduler->DidSwapBuffersComplete(); |
| 353 Proxy::MainThreadTaskRunner()->PostTask( | 348 Proxy::MainThreadTaskRunner()->PostTask( |
| 354 FROM_HERE, | 349 FROM_HERE, |
| 355 base::Bind(&ThreadProxy::DidCompleteSwapBuffers, main_thread_weak_ptr_)); | 350 base::Bind(&ThreadProxy::DidCompleteSwapBuffers, main_thread_weak_ptr_)); |
| 356 } | 351 } |
| 357 | 352 |
| 358 BeginFrameSource* ThreadProxy::GetExternalBeginFrameSource() { | |
| 359 return impl().layer_tree_host_impl.get(); | |
| 360 } | |
| 361 | |
| 362 void ThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) { | 353 void ThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) { |
| 363 impl().layer_tree_host_impl->WillBeginImplFrame(args); | 354 impl().layer_tree_host_impl->WillBeginImplFrame(args); |
| 364 } | 355 } |
| 365 | 356 |
| 366 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) { | 357 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) { |
| 367 TRACE_EVENT1( | 358 TRACE_EVENT1( |
| 368 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); | 359 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); |
| 369 DCHECK(IsImplThread()); | 360 DCHECK(IsImplThread()); |
| 370 impl().scheduler->SetCanDraw(can_draw); | 361 impl().scheduler->SetCanDraw(can_draw); |
| 371 UpdateBackgroundAnimateTicking(); | 362 UpdateBackgroundAnimateTicking(); |
| (...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1218 impl().layer_tree_host_impl->resource_provider()); | 1209 impl().layer_tree_host_impl->resource_provider()); |
| 1219 completion->Signal(); | 1210 completion->Signal(); |
| 1220 } | 1211 } |
| 1221 | 1212 |
| 1222 void ThreadProxy::InitializeOutputSurfaceOnImplThread( | 1213 void ThreadProxy::InitializeOutputSurfaceOnImplThread( |
| 1223 scoped_ptr<OutputSurface> output_surface) { | 1214 scoped_ptr<OutputSurface> output_surface) { |
| 1224 TRACE_EVENT0("cc", "ThreadProxy::InitializeOutputSurfaceOnImplThread"); | 1215 TRACE_EVENT0("cc", "ThreadProxy::InitializeOutputSurfaceOnImplThread"); |
| 1225 DCHECK(IsImplThread()); | 1216 DCHECK(IsImplThread()); |
| 1226 | 1217 |
| 1227 LayerTreeHostImpl* host_impl = impl().layer_tree_host_impl.get(); | 1218 LayerTreeHostImpl* host_impl = impl().layer_tree_host_impl.get(); |
| 1219 OutputSurface* output_surface_ptr = output_surface.get(); |
| 1228 bool success = host_impl->InitializeRenderer(output_surface.Pass()); | 1220 bool success = host_impl->InitializeRenderer(output_surface.Pass()); |
| 1229 RendererCapabilities capabilities; | 1221 RendererCapabilities capabilities; |
| 1230 if (success) { | 1222 if (success) { |
| 1231 capabilities = | 1223 capabilities = |
| 1232 host_impl->GetRendererCapabilities().MainThreadCapabilities(); | 1224 host_impl->GetRendererCapabilities().MainThreadCapabilities(); |
| 1233 } | 1225 } |
| 1234 | 1226 |
| 1235 Proxy::MainThreadTaskRunner()->PostTask( | 1227 Proxy::MainThreadTaskRunner()->PostTask( |
| 1236 FROM_HERE, | 1228 FROM_HERE, |
| 1237 base::Bind(&ThreadProxy::DidInitializeOutputSurface, | 1229 base::Bind(&ThreadProxy::DidInitializeOutputSurface, |
| 1238 main_thread_weak_ptr_, | 1230 main_thread_weak_ptr_, |
| 1239 success, | 1231 success, |
| 1240 capabilities)); | 1232 capabilities)); |
| 1241 | 1233 |
| 1242 if (success) | 1234 if (success) |
| 1243 impl().scheduler->DidCreateAndInitializeOutputSurface(); | 1235 impl().scheduler->DidCreateAndInitializeOutputSurface(output_surface_ptr); |
| 1244 } | 1236 } |
| 1245 | 1237 |
| 1246 void ThreadProxy::FinishGLOnImplThread(CompletionEvent* completion) { | 1238 void ThreadProxy::FinishGLOnImplThread(CompletionEvent* completion) { |
| 1247 TRACE_EVENT0("cc", "ThreadProxy::FinishGLOnImplThread"); | 1239 TRACE_EVENT0("cc", "ThreadProxy::FinishGLOnImplThread"); |
| 1248 DCHECK(IsImplThread()); | 1240 DCHECK(IsImplThread()); |
| 1249 if (impl().layer_tree_host_impl->output_surface()) { | 1241 if (impl().layer_tree_host_impl->output_surface()) { |
| 1250 ContextProvider* context_provider = | 1242 ContextProvider* context_provider = |
| 1251 impl().layer_tree_host_impl->output_surface()->context_provider(); | 1243 impl().layer_tree_host_impl->output_surface()->context_provider(); |
| 1252 if (context_provider) | 1244 if (context_provider) |
| 1253 context_provider->ContextGL()->Finish(); | 1245 context_provider->ContextGL()->Finish(); |
| 1254 } | 1246 } |
| 1255 completion->Signal(); | 1247 completion->Signal(); |
| 1256 } | 1248 } |
| 1257 | 1249 |
| 1258 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { | 1250 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { |
| 1259 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); | 1251 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); |
| 1260 DCHECK(IsImplThread()); | 1252 DCHECK(IsImplThread()); |
| 1261 DCHECK(IsMainThreadBlocked()); | 1253 DCHECK(IsMainThreadBlocked()); |
| 1262 layer_tree_host()->DeleteContentsTexturesOnImplThread( | 1254 layer_tree_host()->DeleteContentsTexturesOnImplThread( |
| 1263 impl().layer_tree_host_impl->resource_provider()); | 1255 impl().layer_tree_host_impl->resource_provider()); |
| 1264 impl().current_resource_update_controller.reset(); | 1256 impl().current_resource_update_controller.reset(); |
| 1265 impl().layer_tree_host_impl->SetNeedsBeginFrames(false); | |
| 1266 impl().scheduler.reset(); | 1257 impl().scheduler.reset(); |
| 1267 impl().layer_tree_host_impl.reset(); | 1258 impl().layer_tree_host_impl.reset(); |
| 1268 impl().weak_factory.InvalidateWeakPtrs(); | 1259 impl().weak_factory.InvalidateWeakPtrs(); |
| 1269 // We need to explicitly cancel the notifier, since it isn't using weak ptrs. | 1260 // We need to explicitly cancel the notifier, since it isn't using weak ptrs. |
| 1270 // TODO(vmpstr): We should see if we can make it use weak ptrs and still keep | 1261 // TODO(vmpstr): We should see if we can make it use weak ptrs and still keep |
| 1271 // the convention of having a weak ptr factory initialized last. Alternatively | 1262 // the convention of having a weak ptr factory initialized last. Alternatively |
| 1272 // we should moved the notifier (and RenewTreePriority) to LTHI. See | 1263 // we should moved the notifier (and RenewTreePriority) to LTHI. See |
| 1273 // crbug.com/411972 | 1264 // crbug.com/411972 |
| 1274 impl().smoothness_priority_expiration_notifier.Cancel(); | 1265 impl().smoothness_priority_expiration_notifier.Cancel(); |
| 1275 impl().contents_texture_manager = NULL; | 1266 impl().contents_texture_manager = NULL; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1413 | 1404 |
| 1414 impl().timing_history.DidActivateSyncTree(); | 1405 impl().timing_history.DidActivateSyncTree(); |
| 1415 } | 1406 } |
| 1416 | 1407 |
| 1417 void ThreadProxy::DidManageTiles() { | 1408 void ThreadProxy::DidManageTiles() { |
| 1418 DCHECK(IsImplThread()); | 1409 DCHECK(IsImplThread()); |
| 1419 impl().scheduler->DidManageTiles(); | 1410 impl().scheduler->DidManageTiles(); |
| 1420 } | 1411 } |
| 1421 | 1412 |
| 1422 } // namespace cc | 1413 } // namespace cc |
| OLD | NEW |