| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 in_composite_and_readback_(false), | 51 in_composite_and_readback_(false), |
| 52 manage_tiles_pending_(false), | 52 manage_tiles_pending_(false), |
| 53 weak_factory_on_impl_thread_(this), | 53 weak_factory_on_impl_thread_(this), |
| 54 weak_factory_(this), | 54 weak_factory_(this), |
| 55 begin_frame_completion_event_on_impl_thread_(NULL), | 55 begin_frame_completion_event_on_impl_thread_(NULL), |
| 56 readback_request_on_impl_thread_(NULL), | 56 readback_request_on_impl_thread_(NULL), |
| 57 commit_completion_event_on_impl_thread_(NULL), | 57 commit_completion_event_on_impl_thread_(NULL), |
| 58 completion_event_for_commit_held_on_tree_activation_(NULL), | 58 completion_event_for_commit_held_on_tree_activation_(NULL), |
| 59 texture_acquisition_completion_event_on_impl_thread_(NULL), | 59 texture_acquisition_completion_event_on_impl_thread_(NULL), |
| 60 next_frame_is_newly_committed_frame_on_impl_thread_(false), | 60 next_frame_is_newly_committed_frame_on_impl_thread_(false), |
| 61 render_vsync_enabled_(layer_tree_host->settings().render_vsync_enabled), | 61 throttle_frame_production_( |
| 62 render_vsync_notification_enabled_( | 62 layer_tree_host->settings().throttle_frame_production), |
| 63 layer_tree_host->settings().render_vsync_notification_enabled), | 63 render_begin_frame_notification_enabled_( |
| 64 synchronously_disable_vsync_( | 64 layer_tree_host->settings().render_begin_frame_notification_enabled), |
| 65 layer_tree_host->settings().synchronously_disable_vsync), | 65 using_synchronous_renderer_compositor_( |
| 66 layer_tree_host->settings().using_synchronous_renderer_compositor), |
| 66 vsync_client_(NULL), | 67 vsync_client_(NULL), |
| 67 inside_draw_(false), | 68 inside_draw_(false), |
| 68 defer_commits_(false), | 69 defer_commits_(false), |
| 69 renew_tree_priority_on_impl_thread_pending_(false) { | 70 renew_tree_priority_on_impl_thread_pending_(false) { |
| 70 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); | 71 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); |
| 71 DCHECK(IsMainThread()); | 72 DCHECK(IsMainThread()); |
| 72 DCHECK(layer_tree_host_); | 73 DCHECK(layer_tree_host_); |
| 73 } | 74 } |
| 74 | 75 |
| 75 ThreadProxy::~ThreadProxy() { | 76 ThreadProxy::~ThreadProxy() { |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 DCHECK(IsImplThread()); | 320 DCHECK(IsImplThread()); |
| 320 TRACE_EVENT2("cc", | 321 TRACE_EVENT2("cc", |
| 321 "ThreadProxy::OnVSyncParametersChanged", | 322 "ThreadProxy::OnVSyncParametersChanged", |
| 322 "timebase", | 323 "timebase", |
| 323 (timebase - base::TimeTicks()).InMilliseconds(), | 324 (timebase - base::TimeTicks()).InMilliseconds(), |
| 324 "interval", | 325 "interval", |
| 325 interval.InMilliseconds()); | 326 interval.InMilliseconds()); |
| 326 scheduler_on_impl_thread_->SetTimebaseAndInterval(timebase, interval); | 327 scheduler_on_impl_thread_->SetTimebaseAndInterval(timebase, interval); |
| 327 } | 328 } |
| 328 | 329 |
| 329 void ThreadProxy::DidVSync(base::TimeTicks frame_time) { | 330 void ThreadProxy::DidBeginFrame(base::TimeTicks frame_time) { |
| 330 DCHECK(IsImplThread()); | 331 DCHECK(IsImplThread()); |
| 331 TRACE_EVENT0("cc", "ThreadProxy::DidVSync"); | 332 TRACE_EVENT0("cc", "ThreadProxy::DidBeginFrame"); |
| 332 if (vsync_client_) | 333 if (vsync_client_) |
| 333 vsync_client_->DidVSync(frame_time); | 334 vsync_client_->DidVSync(frame_time); |
| 334 } | 335 } |
| 335 | 336 |
| 336 void ThreadProxy::RequestVSyncNotification(VSyncClient* client) { | 337 void ThreadProxy::RequestVSyncNotification(VSyncClient* client) { |
| 337 DCHECK(IsImplThread()); | 338 DCHECK(IsImplThread()); |
| 338 TRACE_EVENT1( | 339 TRACE_EVENT1( |
| 339 "cc", "ThreadProxy::RequestVSyncNotification", "enable", !!client); | 340 "cc", "ThreadProxy::RequestVSyncNotification", "enable", !!client); |
| 340 vsync_client_ = client; | 341 vsync_client_ = client; |
| 341 layer_tree_host_impl_->EnableVSyncNotification(!!client); | 342 layer_tree_host_impl_->EnableBeginFrameNotification(!!client); |
| 342 } | 343 } |
| 343 | 344 |
| 344 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) { | 345 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) { |
| 345 DCHECK(IsImplThread()); | 346 DCHECK(IsImplThread()); |
| 346 TRACE_EVENT1( | 347 TRACE_EVENT1( |
| 347 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); | 348 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); |
| 348 scheduler_on_impl_thread_->SetCanDraw(can_draw); | 349 scheduler_on_impl_thread_->SetCanDraw(can_draw); |
| 349 layer_tree_host_impl_->UpdateBackgroundAnimateTicking( | 350 layer_tree_host_impl_->UpdateBackgroundAnimateTicking( |
| 350 !scheduler_on_impl_thread_->WillDrawIfNeeded()); | 351 !scheduler_on_impl_thread_->WillDrawIfNeeded()); |
| 351 } | 352 } |
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 if (layer_tree_host_impl_->PrepareToDraw(&frame, readback_rect) || | 935 if (layer_tree_host_impl_->PrepareToDraw(&frame, readback_rect) || |
| 935 forced_draw) | 936 forced_draw) |
| 936 draw_frame = true; | 937 draw_frame = true; |
| 937 else | 938 else |
| 938 start_ready_animations = false; | 939 start_ready_animations = false; |
| 939 } | 940 } |
| 940 | 941 |
| 941 if (draw_frame) { | 942 if (draw_frame) { |
| 942 layer_tree_host_impl_->DrawLayers( | 943 layer_tree_host_impl_->DrawLayers( |
| 943 &frame, | 944 &frame, |
| 944 scheduler_on_impl_thread_->LastVSyncTime()); | 945 scheduler_on_impl_thread_->LastBeginFrameTime()); |
| 945 result.did_draw = true; | 946 result.did_draw = true; |
| 946 } | 947 } |
| 947 layer_tree_host_impl_->DidDrawAllLayers(frame); | 948 layer_tree_host_impl_->DidDrawAllLayers(frame); |
| 948 | 949 |
| 949 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); | 950 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); |
| 950 | 951 |
| 951 // Check for a pending CompositeAndReadback. | 952 // Check for a pending CompositeAndReadback. |
| 952 if (readback_request_on_impl_thread_) { | 953 if (readback_request_on_impl_thread_) { |
| 953 readback_request_on_impl_thread_->success = false; | 954 readback_request_on_impl_thread_->success = false; |
| 954 if (draw_frame) { | 955 if (draw_frame) { |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1103 CompletionEvent* completion, | 1104 CompletionEvent* completion, |
| 1104 InputHandlerClient* input_handler_client) { | 1105 InputHandlerClient* input_handler_client) { |
| 1105 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread"); | 1106 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread"); |
| 1106 DCHECK(IsImplThread()); | 1107 DCHECK(IsImplThread()); |
| 1107 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); | 1108 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); |
| 1108 const base::TimeDelta display_refresh_interval = | 1109 const base::TimeDelta display_refresh_interval = |
| 1109 base::TimeDelta::FromMicroseconds( | 1110 base::TimeDelta::FromMicroseconds( |
| 1110 base::Time::kMicrosecondsPerSecond / | 1111 base::Time::kMicrosecondsPerSecond / |
| 1111 layer_tree_host_->settings().refresh_rate); | 1112 layer_tree_host_->settings().refresh_rate); |
| 1112 scoped_ptr<FrameRateController> frame_rate_controller; | 1113 scoped_ptr<FrameRateController> frame_rate_controller; |
| 1113 if (render_vsync_enabled_) { | 1114 if (throttle_frame_production_) { |
| 1114 if (render_vsync_notification_enabled_) { | 1115 if (render_begin_frame_notification_enabled_) { |
| 1115 frame_rate_controller.reset( | 1116 frame_rate_controller.reset( |
| 1116 new FrameRateController(VSyncTimeSource::Create( | 1117 new FrameRateController(VSyncTimeSource::Create( |
| 1117 this, | 1118 this, |
| 1118 synchronously_disable_vsync_ ? | 1119 using_synchronous_renderer_compositor_ ? |
| 1119 VSyncTimeSource::DISABLE_SYNCHRONOUSLY : | 1120 VSyncTimeSource::DISABLE_SYNCHRONOUSLY : |
| 1120 VSyncTimeSource::DISABLE_ON_NEXT_TICK))); | 1121 VSyncTimeSource::DISABLE_ON_NEXT_TICK))); |
| 1121 } else { | 1122 } else { |
| 1122 frame_rate_controller.reset( | 1123 frame_rate_controller.reset( |
| 1123 new FrameRateController(DelayBasedTimeSource::Create( | 1124 new FrameRateController(DelayBasedTimeSource::Create( |
| 1124 display_refresh_interval, Proxy::ImplThread()))); | 1125 display_refresh_interval, Proxy::ImplThread()))); |
| 1125 } | 1126 } |
| 1126 } else { | 1127 } else { |
| 1127 frame_rate_controller.reset(new FrameRateController(Proxy::ImplThread())); | 1128 frame_rate_controller.reset(new FrameRateController(Proxy::ImplThread())); |
| 1128 } | 1129 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1199 if (layer_tree_host_impl_->resource_provider()) | 1200 if (layer_tree_host_impl_->resource_provider()) |
| 1200 layer_tree_host_impl_->resource_provider()->Finish(); | 1201 layer_tree_host_impl_->resource_provider()->Finish(); |
| 1201 completion->Signal(); | 1202 completion->Signal(); |
| 1202 } | 1203 } |
| 1203 | 1204 |
| 1204 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { | 1205 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { |
| 1205 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); | 1206 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); |
| 1206 DCHECK(IsImplThread()); | 1207 DCHECK(IsImplThread()); |
| 1207 layer_tree_host_->DeleteContentsTexturesOnImplThread( | 1208 layer_tree_host_->DeleteContentsTexturesOnImplThread( |
| 1208 layer_tree_host_impl_->resource_provider()); | 1209 layer_tree_host_impl_->resource_provider()); |
| 1209 layer_tree_host_impl_->EnableVSyncNotification(false); | 1210 layer_tree_host_impl_->EnableBeginFrameNotification(false); |
| 1210 input_handler_client_on_impl_thread_.reset(); | 1211 input_handler_client_on_impl_thread_.reset(); |
| 1211 scheduler_on_impl_thread_.reset(); | 1212 scheduler_on_impl_thread_.reset(); |
| 1212 layer_tree_host_impl_.reset(); | 1213 layer_tree_host_impl_.reset(); |
| 1213 weak_factory_on_impl_thread_.InvalidateWeakPtrs(); | 1214 weak_factory_on_impl_thread_.InvalidateWeakPtrs(); |
| 1214 vsync_client_ = NULL; | 1215 vsync_client_ = NULL; |
| 1215 completion->Signal(); | 1216 completion->Signal(); |
| 1216 } | 1217 } |
| 1217 | 1218 |
| 1218 size_t ThreadProxy::MaxPartialTextureUpdates() const { | 1219 size_t ThreadProxy::MaxPartialTextureUpdates() const { |
| 1219 return ResourceUpdateController::MaxPartialTextureUpdates(); | 1220 return ResourceUpdateController::MaxPartialTextureUpdates(); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1361 base::Bind(&ThreadProxy::StartScrollbarAnimationOnImplThread, | 1362 base::Bind(&ThreadProxy::StartScrollbarAnimationOnImplThread, |
| 1362 impl_thread_weak_ptr_), | 1363 impl_thread_weak_ptr_), |
| 1363 delay); | 1364 delay); |
| 1364 } | 1365 } |
| 1365 | 1366 |
| 1366 void ThreadProxy::StartScrollbarAnimationOnImplThread() { | 1367 void ThreadProxy::StartScrollbarAnimationOnImplThread() { |
| 1367 layer_tree_host_impl_->StartScrollbarAnimation( | 1368 layer_tree_host_impl_->StartScrollbarAnimation( |
| 1368 layer_tree_host_impl_->CurrentFrameTimeTicks()); | 1369 layer_tree_host_impl_->CurrentFrameTimeTicks()); |
| 1369 } | 1370 } |
| 1370 | 1371 |
| 1371 void ThreadProxy::DidReceiveLastInputEventForVSync( | 1372 void ThreadProxy::DidReceiveLastInputEventForBeginFrame( |
| 1372 base::TimeTicks frame_time) { | 1373 base::TimeTicks frame_time) { |
| 1373 if (render_vsync_notification_enabled_) { | 1374 if (render_begin_frame_notification_enabled_) { |
| 1374 TRACE_EVENT0("cc", "ThreadProxy::DidReceiveLastInputEventForVSync"); | 1375 TRACE_EVENT0("cc", "ThreadProxy::DidReceiveLastInputEventForBeginFrame"); |
| 1375 DidVSync(frame_time); | 1376 DidBeginFrame(frame_time); |
| 1376 } | 1377 } |
| 1377 } | 1378 } |
| 1378 | 1379 |
| 1379 void ThreadProxy::DidActivatePendingTree() { | 1380 void ThreadProxy::DidActivatePendingTree() { |
| 1380 DCHECK(IsImplThread()); | 1381 DCHECK(IsImplThread()); |
| 1381 TRACE_EVENT0("cc", "ThreadProxy::DidActivatePendingTreeOnImplThread"); | 1382 TRACE_EVENT0("cc", "ThreadProxy::DidActivatePendingTreeOnImplThread"); |
| 1382 | 1383 |
| 1383 if (completion_event_for_commit_held_on_tree_activation_ && | 1384 if (completion_event_for_commit_held_on_tree_activation_ && |
| 1384 !layer_tree_host_impl_->pending_tree()) { | 1385 !layer_tree_host_impl_->pending_tree()) { |
| 1385 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation", | 1386 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation", |
| 1386 TRACE_EVENT_SCOPE_THREAD); | 1387 TRACE_EVENT_SCOPE_THREAD); |
| 1387 DCHECK(layer_tree_host_impl_->settings().impl_side_painting); | 1388 DCHECK(layer_tree_host_impl_->settings().impl_side_painting); |
| 1388 completion_event_for_commit_held_on_tree_activation_->Signal(); | 1389 completion_event_for_commit_held_on_tree_activation_->Signal(); |
| 1389 completion_event_for_commit_held_on_tree_activation_ = NULL; | 1390 completion_event_for_commit_held_on_tree_activation_ = NULL; |
| 1390 } | 1391 } |
| 1391 } | 1392 } |
| 1392 | 1393 |
| 1393 } // namespace cc | 1394 } // namespace cc |
| OLD | NEW |