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

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 947033002: CC Animations: Establish AnimationHost, AnimationTimeline and AnimationPlayer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove kEnableNewCompositorAnimations. Created 5 years, 9 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
OLDNEW
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_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/containers/hash_tables.h" 11 #include "base/containers/hash_tables.h"
12 #include "base/json/json_writer.h" 12 #include "base/json/json_writer.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
16 #include "base/trace_event/trace_event_argument.h" 16 #include "base/trace_event/trace_event_argument.h"
17 #include "cc/animation/animation_id_provider.h" 17 #include "cc/animation/animation_id_provider.h"
18 #include "cc/animation/animation_timeline.h"
18 #include "cc/animation/scroll_offset_animation_curve.h" 19 #include "cc/animation/scroll_offset_animation_curve.h"
19 #include "cc/animation/scrollbar_animation_controller.h" 20 #include "cc/animation/scrollbar_animation_controller.h"
20 #include "cc/animation/timing_function.h" 21 #include "cc/animation/timing_function.h"
21 #include "cc/base/latency_info_swap_promise_monitor.h" 22 #include "cc/base/latency_info_swap_promise_monitor.h"
22 #include "cc/base/math_util.h" 23 #include "cc/base/math_util.h"
23 #include "cc/base/util.h" 24 #include "cc/base/util.h"
24 #include "cc/debug/benchmark_instrumentation.h" 25 #include "cc/debug/benchmark_instrumentation.h"
25 #include "cc/debug/debug_rect_history.h" 26 #include "cc/debug/debug_rect_history.h"
26 #include "cc/debug/devtools_instrumentation.h" 27 #include "cc/debug/devtools_instrumentation.h"
27 #include "cc/debug/frame_rate_counter.h" 28 #include "cc/debug/frame_rate_counter.h"
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 926
926 void LayerTreeHostImpl::DidAnimateScrollOffset() { 927 void LayerTreeHostImpl::DidAnimateScrollOffset() {
927 client_->SetNeedsCommitOnImplThread(); 928 client_->SetNeedsCommitOnImplThread();
928 client_->RenewTreePriority(); 929 client_->RenewTreePriority();
929 } 930 }
930 931
931 void LayerTreeHostImpl::SetViewportDamage(const gfx::Rect& damage_rect) { 932 void LayerTreeHostImpl::SetViewportDamage(const gfx::Rect& damage_rect) {
932 viewport_damage_rect_.Union(damage_rect); 933 viewport_damage_rect_.Union(damage_rect);
933 } 934 }
934 935
936 void LayerTreeHostImpl::SetAnimationTimeline(
937 scoped_refptr<AnimationTimeline> timeline) {
938 if (animation_timeline_.get() == timeline.get())
939 return;
940
941 if (animation_timeline_.get())
942 animation_timeline_->SetLayerTreeMutatorsClient(nullptr);
943 animation_timeline_ = timeline;
944 if (animation_timeline_.get())
945 animation_timeline_->SetLayerTreeMutatorsClient(this);
946 }
947
935 static inline RenderPass* FindRenderPassById( 948 static inline RenderPass* FindRenderPassById(
936 RenderPassId render_pass_id, 949 RenderPassId render_pass_id,
937 const LayerTreeHostImpl::FrameData& frame) { 950 const LayerTreeHostImpl::FrameData& frame) {
938 RenderPassIdHashMap::const_iterator it = 951 RenderPassIdHashMap::const_iterator it =
939 frame.render_passes_by_id.find(render_pass_id); 952 frame.render_passes_by_id.find(render_pass_id);
940 return it != frame.render_passes_by_id.end() ? it->second : NULL; 953 return it != frame.render_passes_by_id.end() ? it->second : NULL;
941 } 954 }
942 955
943 static void RemoveRenderPassesRecursive(RenderPassId remove_render_pass_id, 956 static void RemoveRenderPassesRecursive(RenderPassId remove_render_pass_id,
944 LayerTreeHostImpl::FrameData* frame) { 957 LayerTreeHostImpl::FrameData* frame) {
(...skipping 2521 matching lines...) Expand 10 before | Expand all | Expand 10 after
3466 new_target.SetToMax(gfx::ScrollOffset()); 3479 new_target.SetToMax(gfx::ScrollOffset());
3467 new_target.SetToMin(layer_impl->MaxScrollOffset()); 3480 new_target.SetToMin(layer_impl->MaxScrollOffset());
3468 3481
3469 curve->UpdateTarget( 3482 curve->UpdateTarget(
3470 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) 3483 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time)
3471 .InSecondsF(), 3484 .InSecondsF(),
3472 new_target); 3485 new_target);
3473 3486
3474 return true; 3487 return true;
3475 } 3488 }
3489
3490 AnimationRegistrar* LayerTreeHostImpl::GetAnimationRegistrar() const {
3491 return animation_registrar_.get();
3492 }
3493
3494 bool LayerTreeHostImpl::IsLayerInActiveTree(int layer_id) const {
3495 return active_tree() ? active_tree()->LayerById(layer_id) != nullptr : false;
3496 }
3497
3498 bool LayerTreeHostImpl::IsLayerInPendingTree(int layer_id) const {
3499 if (pending_tree() && pending_tree()->LayerById(layer_id))
3500 return true;
3501 if (recycle_tree() && recycle_tree()->LayerById(layer_id))
3502 return true;
3503
3504 return false;
3505 }
3506
3507 void LayerTreeHostImpl::SetMutatorsNeedCommit() {
3508 SetNeedsCommit();
3509 }
3510
3511 void LayerTreeHostImpl::SetTreeLayerFilterMutated(
3512 int layer_id,
3513 LayerTreeImpl* tree,
3514 const FilterOperations& filters) {
3515 LayerAnimationValueObserver* layer = tree->LayerById(layer_id);
3516 if (layer)
3517 layer->OnFilterAnimated(filters);
3518 }
3519
3520 void LayerTreeHostImpl::SetTreeLayerOpacityMutated(int layer_id,
3521 LayerTreeImpl* tree,
3522 float opacity) {
3523 LayerAnimationValueObserver* layer = tree->LayerById(layer_id);
3524 if (layer)
3525 layer->OnOpacityAnimated(opacity);
3526 }
3527
3528 void LayerTreeHostImpl::SetTreeLayerTransformMutated(
3529 int layer_id,
3530 LayerTreeImpl* tree,
3531 const gfx::Transform& transform) {
3532 if (!tree)
3533 return;
3534
3535 LayerAnimationValueObserver* layer = tree->LayerById(layer_id);
3536 if (layer)
3537 layer->OnTransformAnimated(transform);
3538 }
3539
3540 void LayerTreeHostImpl::SetLayerFilterMutated(int layer_id,
3541 bool affects_active_tree,
3542 const FilterOperations& filters) {
3543 if (affects_active_tree) {
3544 SetTreeLayerFilterMutated(layer_id, active_tree(), filters);
3545 } else {
3546 SetTreeLayerFilterMutated(layer_id, pending_tree(), filters);
3547 SetTreeLayerFilterMutated(layer_id, recycle_tree(), filters);
3548 }
3549 }
3550
3551 void LayerTreeHostImpl::SetLayerOpacityMutated(int layer_id,
3552 bool affects_active_tree,
3553 float opacity) {
3554 if (affects_active_tree) {
3555 SetTreeLayerOpacityMutated(layer_id, active_tree(), opacity);
3556 } else {
3557 SetTreeLayerOpacityMutated(layer_id, pending_tree(), opacity);
3558 SetTreeLayerOpacityMutated(layer_id, recycle_tree(), opacity);
3559 }
3560 }
3561
3562 void LayerTreeHostImpl::SetLayerTransformMutated(
3563 int layer_id,
3564 bool affects_active_tree,
3565 const gfx::Transform& transform) {
3566 if (affects_active_tree) {
3567 SetTreeLayerTransformMutated(layer_id, active_tree(), transform);
3568 } else {
3569 SetTreeLayerTransformMutated(layer_id, pending_tree(), transform);
3570 SetTreeLayerTransformMutated(layer_id, recycle_tree(), transform);
3571 }
3572 }
3573
3476 } // namespace cc 3574 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698