Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(369)

Side by Side Diff: cc/layers/layer.cc

Issue 1010663002: CC Animations: Redirect all compositor animation requests to AnimationHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@introduce
Patch Set: Rebase. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layers/layer.h ('k') | cc/layers/layer_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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/layers/layer.h" 5 #include "cc/layers/layer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/atomic_sequence_num.h" 9 #include "base/atomic_sequence_num.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 children_[i]->SetLayerTreeHost(host); 149 children_[i]->SetLayerTreeHost(host);
150 150
151 if (mask_layer_.get()) 151 if (mask_layer_.get())
152 mask_layer_->SetLayerTreeHost(host); 152 mask_layer_->SetLayerTreeHost(host);
153 if (replica_layer_.get()) 153 if (replica_layer_.get())
154 replica_layer_->SetLayerTreeHost(host); 154 replica_layer_->SetLayerTreeHost(host);
155 155
156 if (host) 156 if (host)
157 RegisterForAnimations(host->animation_registrar()); 157 RegisterForAnimations(host->animation_registrar());
158 158
159 if (host && layer_animation_controller_->has_any_animation()) 159 bool has_any_animation = false;
160 if (layer_animation_controller_)
161 has_any_animation = layer_animation_controller_->has_any_animation();
162 else if (layer_tree_host_)
163 has_any_animation = layer_tree_host_->HasAnyAnimation(this);
164
165 if (host && has_any_animation)
160 host->SetNeedsCommit(); 166 host->SetNeedsCommit();
161 } 167 }
162 168
163 void Layer::SetNeedsUpdate() { 169 void Layer::SetNeedsUpdate() {
164 if (layer_tree_host_ && !ignore_set_needs_commit_) 170 if (layer_tree_host_ && !ignore_set_needs_commit_)
165 layer_tree_host_->SetNeedsUpdateLayers(); 171 layer_tree_host_->SetNeedsUpdateLayers();
166 } 172 }
167 173
168 void Layer::SetNeedsCommit() { 174 void Layer::SetNeedsCommit() {
169 if (!layer_tree_host_) 175 if (!layer_tree_host_)
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 501
496 void Layer::SetFilters(const FilterOperations& filters) { 502 void Layer::SetFilters(const FilterOperations& filters) {
497 DCHECK(IsPropertyChangeAllowed()); 503 DCHECK(IsPropertyChangeAllowed());
498 if (filters_ == filters) 504 if (filters_ == filters)
499 return; 505 return;
500 filters_ = filters; 506 filters_ = filters;
501 SetNeedsCommit(); 507 SetNeedsCommit();
502 } 508 }
503 509
504 bool Layer::FilterIsAnimating() const { 510 bool Layer::FilterIsAnimating() const {
505 return layer_animation_controller_->IsAnimatingProperty(Animation::FILTER); 511 DCHECK(layer_tree_host_);
512 return layer_animation_controller_
513 ? layer_animation_controller_->IsAnimatingProperty(
514 Animation::FILTER)
515 : layer_tree_host_->IsAnimatingFilterProperty(this);
506 } 516 }
507 517
508 void Layer::SetBackgroundFilters(const FilterOperations& filters) { 518 void Layer::SetBackgroundFilters(const FilterOperations& filters) {
509 DCHECK(IsPropertyChangeAllowed()); 519 DCHECK(IsPropertyChangeAllowed());
510 if (background_filters_ == filters) 520 if (background_filters_ == filters)
511 return; 521 return;
512 background_filters_ = filters; 522 background_filters_ = filters;
513 SetNeedsCommit(); 523 SetNeedsCommit();
514 } 524 }
515 525
516 void Layer::SetOpacity(float opacity) { 526 void Layer::SetOpacity(float opacity) {
517 DCHECK(IsPropertyChangeAllowed()); 527 DCHECK(IsPropertyChangeAllowed());
518 if (opacity_ == opacity) 528 if (opacity_ == opacity)
519 return; 529 return;
520 opacity_ = opacity; 530 opacity_ = opacity;
521 SetNeedsCommit(); 531 SetNeedsCommit();
522 } 532 }
523 533
524 bool Layer::OpacityIsAnimating() const { 534 bool Layer::OpacityIsAnimating() const {
525 return layer_animation_controller_->IsAnimatingProperty(Animation::OPACITY); 535 DCHECK(layer_tree_host_);
536 return layer_animation_controller_
537 ? layer_animation_controller_->IsAnimatingProperty(
538 Animation::OPACITY)
539 : layer_tree_host_->IsAnimatingOpacityProperty(this);
540 }
541
542 bool Layer::HasPotentiallyRunningOpacityAnimation() const {
543 if (layer_animation_controller_) {
544 if (Animation* animation =
545 layer_animation_controller()->GetAnimation(Animation::OPACITY)) {
546 return !animation->is_finished();
547 }
548 return false;
549 } else {
550 DCHECK(layer_tree_host_);
551 return layer_tree_host_->HasPotentiallyRunningOpacityAnimation(this);
552 }
526 } 553 }
527 554
528 bool Layer::OpacityCanAnimateOnImplThread() const { 555 bool Layer::OpacityCanAnimateOnImplThread() const {
529 return false; 556 return false;
530 } 557 }
531 558
532 void Layer::SetBlendMode(SkXfermode::Mode blend_mode) { 559 void Layer::SetBlendMode(SkXfermode::Mode blend_mode) {
533 DCHECK(IsPropertyChangeAllowed()); 560 DCHECK(IsPropertyChangeAllowed());
534 if (blend_mode_ == blend_mode) 561 if (blend_mode_ == blend_mode)
535 return; 562 return;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); 726 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true);
700 SetNeedsCommitNoRebuild(); 727 SetNeedsCommitNoRebuild();
701 return; 728 return;
702 } 729 }
703 } 730 }
704 731
705 SetNeedsCommit(); 732 SetNeedsCommit();
706 } 733 }
707 734
708 bool Layer::AnimationsPreserveAxisAlignment() const { 735 bool Layer::AnimationsPreserveAxisAlignment() const {
709 return layer_animation_controller_->AnimationsPreserveAxisAlignment(); 736 DCHECK(layer_tree_host_);
737 return layer_animation_controller_
738 ? layer_animation_controller_->AnimationsPreserveAxisAlignment()
739 : layer_tree_host_->AnimationsPreserveAxisAlignment(this);
710 } 740 }
711 741
712 bool Layer::TransformIsAnimating() const { 742 bool Layer::TransformIsAnimating() const {
713 return layer_animation_controller_->IsAnimatingProperty(Animation::TRANSFORM); 743 DCHECK(layer_tree_host_);
744 return layer_animation_controller_
745 ? layer_animation_controller_->IsAnimatingProperty(
746 Animation::TRANSFORM)
747 : layer_tree_host_->IsAnimatingTransformProperty(this);
748 }
749
750 bool Layer::HasPotentiallyRunningTransformAnimation() const {
751 if (layer_animation_controller_) {
752 if (Animation* animation =
753 layer_animation_controller()->GetAnimation(Animation::TRANSFORM)) {
754 return !animation->is_finished();
755 }
756 return false;
757 } else {
758 DCHECK(layer_tree_host_);
759 return layer_tree_host_->HasPotentiallyRunningTransformAnimation(this);
760 }
761 }
762
763 bool Layer::ScrollOffsetAnimationWasInterrupted() const {
764 DCHECK(layer_tree_host_);
765 return layer_animation_controller_
766 ? layer_animation_controller_
767 ->scroll_offset_animation_was_interrupted()
768 : layer_tree_host_->ScrollOffsetAnimationWasInterrupted(this);
714 } 769 }
715 770
716 void Layer::SetScrollParent(Layer* parent) { 771 void Layer::SetScrollParent(Layer* parent) {
717 DCHECK(IsPropertyChangeAllowed()); 772 DCHECK(IsPropertyChangeAllowed());
718 if (scroll_parent_ == parent) 773 if (scroll_parent_ == parent)
719 return; 774 return;
720 775
721 if (scroll_parent_) 776 if (scroll_parent_)
722 scroll_parent_->RemoveScrollChild(this); 777 scroll_parent_->RemoveScrollChild(this);
723 778
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 } 1268 }
1214 layer->SetClipChildren(clip_children); 1269 layer->SetClipChildren(clip_children);
1215 } else { 1270 } else {
1216 layer->SetClipChildren(nullptr); 1271 layer->SetClipChildren(nullptr);
1217 } 1272 }
1218 1273
1219 // When a scroll offset animation is interrupted the new scroll position on 1274 // When a scroll offset animation is interrupted the new scroll position on
1220 // the pending tree will clobber any impl-side scrolling occuring on the 1275 // the pending tree will clobber any impl-side scrolling occuring on the
1221 // active tree. To do so, avoid scrolling the pending tree along with it 1276 // active tree. To do so, avoid scrolling the pending tree along with it
1222 // instead of trying to undo that scrolling later. 1277 // instead of trying to undo that scrolling later.
1223 if (layer_animation_controller_->scroll_offset_animation_was_interrupted()) 1278 if (ScrollOffsetAnimationWasInterrupted())
1224 layer->PushScrollOffsetFromMainThreadAndClobberActiveValue(scroll_offset_); 1279 layer->PushScrollOffsetFromMainThreadAndClobberActiveValue(scroll_offset_);
1225 else 1280 else
1226 layer->PushScrollOffsetFromMainThread(scroll_offset_); 1281 layer->PushScrollOffsetFromMainThread(scroll_offset_);
1227 layer->SetScrollCompensationAdjustment(ScrollCompensationAdjustment()); 1282 layer->SetScrollCompensationAdjustment(ScrollCompensationAdjustment());
1228 1283
1229 // Wrap the copy_requests_ in a PostTask to the main thread. 1284 // Wrap the copy_requests_ in a PostTask to the main thread.
1230 bool had_copy_requests = !copy_requests_.empty(); 1285 bool had_copy_requests = !copy_requests_.empty();
1231 ScopedPtrVector<CopyOutputRequest> main_thread_copy_requests; 1286 ScopedPtrVector<CopyOutputRequest> main_thread_copy_requests;
1232 for (ScopedPtrVector<CopyOutputRequest>::iterator it = copy_requests_.begin(); 1287 for (ScopedPtrVector<CopyOutputRequest>::iterator it = copy_requests_.begin();
1233 it != copy_requests_.end(); 1288 it != copy_requests_.end();
(...skipping 19 matching lines...) Expand all
1253 1308
1254 // If the main thread commits multiple times before the impl thread actually 1309 // If the main thread commits multiple times before the impl thread actually
1255 // draws, then damage tracking will become incorrect if we simply clobber the 1310 // draws, then damage tracking will become incorrect if we simply clobber the
1256 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. 1311 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e.
1257 // union) any update changes that have occurred on the main thread. 1312 // union) any update changes that have occurred on the main thread.
1258 update_rect_.Union(layer->update_rect()); 1313 update_rect_.Union(layer->update_rect());
1259 layer->SetUpdateRect(update_rect_); 1314 layer->SetUpdateRect(update_rect_);
1260 1315
1261 layer->SetStackingOrderChanged(stacking_order_changed_); 1316 layer->SetStackingOrderChanged(stacking_order_changed_);
1262 1317
1263 layer_animation_controller_->PushAnimationUpdatesTo( 1318 if (layer->layer_animation_controller() && layer_animation_controller_)
1264 layer->layer_animation_controller()); 1319 layer_animation_controller_->PushAnimationUpdatesTo(
1320 layer->layer_animation_controller());
1265 1321
1266 if (frame_timing_requests_dirty_) { 1322 if (frame_timing_requests_dirty_) {
1267 layer->SetFrameTimingRequests(frame_timing_requests_); 1323 layer->SetFrameTimingRequests(frame_timing_requests_);
1268 frame_timing_requests_dirty_ = false; 1324 frame_timing_requests_dirty_ = false;
1269 } 1325 }
1270 1326
1271 bool is_page_scale_layer = this == layer_tree_host()->page_scale_layer(); 1327 bool is_page_scale_layer = this == layer_tree_host()->page_scale_layer();
1272 bool parent_affected = 1328 bool parent_affected =
1273 layer->parent() && layer->parent()->IsAffectedByPageScale(); 1329 layer->parent() && layer->parent()->IsAffectedByPageScale();
1274 layer->SetIsAffectedByPageScale(is_page_scale_layer || parent_affected); 1330 layer->SetIsAffectedByPageScale(is_page_scale_layer || parent_affected);
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1469 1525
1470 void Layer::RemoveAnimation(int animation_id, 1526 void Layer::RemoveAnimation(int animation_id,
1471 Animation::TargetProperty property) { 1527 Animation::TargetProperty property) {
1472 DCHECK(layer_animation_controller_); 1528 DCHECK(layer_animation_controller_);
1473 layer_animation_controller_->RemoveAnimation(animation_id, property); 1529 layer_animation_controller_->RemoveAnimation(animation_id, property);
1474 SetNeedsCommit(); 1530 SetNeedsCommit();
1475 } 1531 }
1476 1532
1477 void Layer::SetLayerAnimationControllerForTest( 1533 void Layer::SetLayerAnimationControllerForTest(
1478 scoped_refptr<LayerAnimationController> controller) { 1534 scoped_refptr<LayerAnimationController> controller) {
1535 DCHECK(layer_animation_controller_);
1479 layer_animation_controller_->RemoveValueObserver(this); 1536 layer_animation_controller_->RemoveValueObserver(this);
1480 layer_animation_controller_ = controller; 1537 layer_animation_controller_ = controller;
1481 layer_animation_controller_->AddValueObserver(this); 1538 layer_animation_controller_->AddValueObserver(this);
1482 SetNeedsCommit(); 1539 SetNeedsCommit();
1483 } 1540 }
1484 1541
1485 bool Layer::HasActiveAnimation() const { 1542 bool Layer::HasActiveAnimation() const {
1486 DCHECK(layer_animation_controller_); 1543 DCHECK(layer_tree_host_);
1487 return layer_animation_controller_->HasActiveAnimation(); 1544 return layer_animation_controller_
1545 ? layer_animation_controller_->HasActiveAnimation()
1546 : layer_tree_host_->HasActiveAnimation(this);
1488 } 1547 }
1489 1548
1490 void Layer::RegisterForAnimations(AnimationRegistrar* registrar) { 1549 void Layer::RegisterForAnimations(AnimationRegistrar* registrar) {
1491 if (layer_animation_controller_) 1550 if (layer_animation_controller_)
1492 layer_animation_controller_->SetAnimationRegistrar(registrar); 1551 layer_animation_controller_->SetAnimationRegistrar(registrar);
1493 } 1552 }
1494 1553
1495 void Layer::AddLayerAnimationEventObserver( 1554 void Layer::AddLayerAnimationEventObserver(
1496 LayerAnimationEventObserver* animation_observer) { 1555 LayerAnimationEventObserver* animation_observer) {
1497 DCHECK(layer_animation_controller_); 1556 DCHECK(layer_animation_controller_);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1600 ? layer_tree_host()->meta_information_sequence_number() 1659 ? layer_tree_host()->meta_information_sequence_number()
1601 : 0; 1660 : 0;
1602 } 1661 }
1603 1662
1604 bool Layer::sorted_for_recursion() { 1663 bool Layer::sorted_for_recursion() {
1605 return sorted_for_recursion_tracker_ == 1664 return sorted_for_recursion_tracker_ ==
1606 layer_tree_host()->meta_information_sequence_number(); 1665 layer_tree_host()->meta_information_sequence_number();
1607 } 1666 }
1608 1667
1609 } // namespace cc 1668 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer.h ('k') | cc/layers/layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698