| 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/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <stack> | 8 #include <stack> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 | 409 |
| 410 void LayerTreeHost::CommitComplete() { | 410 void LayerTreeHost::CommitComplete() { |
| 411 source_frame_number_++; | 411 source_frame_number_++; |
| 412 client_->DidCommit(); | 412 client_->DidCommit(); |
| 413 if (did_complete_scale_animation_) { | 413 if (did_complete_scale_animation_) { |
| 414 client_->DidCompletePageScaleAnimation(); | 414 client_->DidCompletePageScaleAnimation(); |
| 415 did_complete_scale_animation_ = false; | 415 did_complete_scale_animation_ = false; |
| 416 } | 416 } |
| 417 } | 417 } |
| 418 | 418 |
| 419 void LayerTreeHost::DidCommitAndDrawFrame() { |
| 420 client_->DidCommitAndDrawFrame(); |
| 421 if (animation_host_) |
| 422 animation_host_->ReportAndClearStatsOnFrameEnd(); |
| 423 } |
| 424 |
| 419 void LayerTreeHost::SetOutputSurface(scoped_ptr<OutputSurface> surface) { | 425 void LayerTreeHost::SetOutputSurface(scoped_ptr<OutputSurface> surface) { |
| 420 TRACE_EVENT0("cc", "LayerTreeHost::SetOutputSurface"); | 426 TRACE_EVENT0("cc", "LayerTreeHost::SetOutputSurface"); |
| 421 DCHECK(output_surface_lost_); | 427 DCHECK(output_surface_lost_); |
| 422 DCHECK(surface); | 428 DCHECK(surface); |
| 423 | 429 |
| 424 proxy_->SetOutputSurface(surface.Pass()); | 430 proxy_->SetOutputSurface(surface.Pass()); |
| 425 } | 431 } |
| 426 | 432 |
| 427 void LayerTreeHost::RequestNewOutputSurface() { | 433 void LayerTreeHost::RequestNewOutputSurface() { |
| 428 client_->RequestNewOutputSurface(); | 434 client_->RequestNewOutputSurface(); |
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1179 } | 1185 } |
| 1180 | 1186 |
| 1181 void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) { | 1187 void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) { |
| 1182 if (!settings_.accelerated_animation_enabled) | 1188 if (!settings_.accelerated_animation_enabled) |
| 1183 return; | 1189 return; |
| 1184 | 1190 |
| 1185 AnimationEventsVector events; | 1191 AnimationEventsVector events; |
| 1186 if (animation_host_) { | 1192 if (animation_host_) { |
| 1187 if (animation_host_->AnimateLayers(monotonic_time)) | 1193 if (animation_host_->AnimateLayers(monotonic_time)) |
| 1188 animation_host_->UpdateAnimationState(true, &events); | 1194 animation_host_->UpdateAnimationState(true, &events); |
| 1195 ReportAndClearStatsAfterAnimateLayers(); |
| 1189 } else if (animation_registrar_) { | 1196 } else if (animation_registrar_) { |
| 1190 if (animation_registrar_->AnimateLayers(monotonic_time)) | 1197 if (animation_registrar_->AnimateLayers(monotonic_time)) |
| 1191 animation_registrar_->UpdateAnimationState(true, &events); | 1198 animation_registrar_->UpdateAnimationState(true, &events); |
| 1192 } | 1199 } |
| 1193 | 1200 |
| 1194 if (!events.empty()) | 1201 if (!events.empty()) |
| 1195 property_trees_.needs_rebuild = true; | 1202 property_trees_.needs_rebuild = true; |
| 1196 } | 1203 } |
| 1197 | 1204 |
| 1198 UIResourceId LayerTreeHost::CreateUIResource(UIResourceClient* client) { | 1205 UIResourceId LayerTreeHost::CreateUIResource(UIResourceClient* client) { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1323 const BeginFrameArgs& args) const { | 1330 const BeginFrameArgs& args) const { |
| 1324 client_->SendBeginFramesToChildren(args); | 1331 client_->SendBeginFramesToChildren(args); |
| 1325 } | 1332 } |
| 1326 | 1333 |
| 1327 void LayerTreeHost::SetAuthoritativeVSyncInterval( | 1334 void LayerTreeHost::SetAuthoritativeVSyncInterval( |
| 1328 const base::TimeDelta& interval) { | 1335 const base::TimeDelta& interval) { |
| 1329 proxy_->SetAuthoritativeVSyncInterval(interval); | 1336 proxy_->SetAuthoritativeVSyncInterval(interval); |
| 1330 } | 1337 } |
| 1331 | 1338 |
| 1332 Layer* LayerTreeHost::LayerById(int id) const { | 1339 Layer* LayerTreeHost::LayerById(int id) const { |
| 1340 base::TimeTicks start_time = base::TimeTicks::Now(); |
| 1333 LayerIdMap::const_iterator iter = layer_id_map_.find(id); | 1341 LayerIdMap::const_iterator iter = layer_id_map_.find(id); |
| 1342 find_layer_by_id_stats_ += base::TimeTicks::Now() - start_time; |
| 1334 return iter != layer_id_map_.end() ? iter->second : NULL; | 1343 return iter != layer_id_map_.end() ? iter->second : NULL; |
| 1335 } | 1344 } |
| 1336 | 1345 |
| 1337 void LayerTreeHost::RegisterLayer(Layer* layer) { | 1346 void LayerTreeHost::RegisterLayer(Layer* layer) { |
| 1338 DCHECK(!LayerById(layer->id())); | 1347 DCHECK(!LayerById(layer->id())); |
| 1339 layer_id_map_[layer->id()] = layer; | 1348 layer_id_map_[layer->id()] = layer; |
| 1340 if (animation_host_) | 1349 if (animation_host_) |
| 1341 animation_host_->RegisterLayer(layer->id(), true); | 1350 animation_host_->RegisterLayer(layer->id(), true); |
| 1342 } | 1351 } |
| 1343 | 1352 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1450 bool LayerTreeHost::HasAnyAnimation(const Layer* layer) const { | 1459 bool LayerTreeHost::HasAnyAnimation(const Layer* layer) const { |
| 1451 return animation_host_ ? animation_host_->HasAnyAnimation(layer->id()) | 1460 return animation_host_ ? animation_host_->HasAnyAnimation(layer->id()) |
| 1452 : false; | 1461 : false; |
| 1453 } | 1462 } |
| 1454 | 1463 |
| 1455 bool LayerTreeHost::HasActiveAnimation(const Layer* layer) const { | 1464 bool LayerTreeHost::HasActiveAnimation(const Layer* layer) const { |
| 1456 return animation_host_ ? animation_host_->HasActiveAnimation(layer->id()) | 1465 return animation_host_ ? animation_host_->HasActiveAnimation(layer->id()) |
| 1457 : false; | 1466 : false; |
| 1458 } | 1467 } |
| 1459 | 1468 |
| 1469 void LayerTreeHost::ReportAndClearStatsAfterAnimateLayers() { |
| 1470 LOCAL_HISTOGRAM_CUSTOM_COUNTS("Mutators.FindLayerById", |
| 1471 find_layer_by_id_stats_.InMicroseconds(), 1, |
| 1472 1000, 10); |
| 1473 find_layer_by_id_stats_ = base::TimeDelta(); |
| 1474 } |
| 1475 |
| 1460 } // namespace cc | 1476 } // namespace cc |
| OLD | NEW |