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

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

Issue 1130043003: [Sketch] CC Animations: Torpedo the old intrusive animation system. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@implscroll
Patch Set: Delete more (headers and animation_registrar_ leftover) Created 5 years, 7 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/blink/web_layer_impl.cc ('k') | cc/layers/layer.cc » ('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 #ifndef CC_LAYERS_LAYER_H_ 5 #ifndef CC_LAYERS_LAYER_H_
6 #define CC_LAYERS_LAYER_H_ 6 #define CC_LAYERS_LAYER_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/observer_list.h" 14 #include "base/observer_list.h"
15 #include "cc/animation/layer_animation_controller.h"
16 #include "cc/animation/layer_animation_value_observer.h"
17 #include "cc/animation/layer_animation_value_provider.h"
18 #include "cc/base/cc_export.h" 15 #include "cc/base/cc_export.h"
19 #include "cc/base/region.h" 16 #include "cc/base/region.h"
20 #include "cc/base/scoped_ptr_vector.h" 17 #include "cc/base/scoped_ptr_vector.h"
21 #include "cc/debug/frame_timing_request.h" 18 #include "cc/debug/frame_timing_request.h"
22 #include "cc/debug/micro_benchmark.h" 19 #include "cc/debug/micro_benchmark.h"
23 #include "cc/layers/draw_properties.h" 20 #include "cc/layers/draw_properties.h"
24 #include "cc/layers/layer_lists.h" 21 #include "cc/layers/layer_lists.h"
25 #include "cc/layers/layer_position_constraint.h" 22 #include "cc/layers/layer_position_constraint.h"
26 #include "cc/layers/paint_properties.h" 23 #include "cc/layers/paint_properties.h"
27 #include "cc/layers/render_surface.h" 24 #include "cc/layers/render_surface.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 class RenderingStatsInstrumentation; 63 class RenderingStatsInstrumentation;
67 class ResourceUpdateQueue; 64 class ResourceUpdateQueue;
68 class ScrollbarLayerInterface; 65 class ScrollbarLayerInterface;
69 class SimpleEnclosedRegion; 66 class SimpleEnclosedRegion;
70 struct AnimationEvent; 67 struct AnimationEvent;
71 template <typename LayerType> 68 template <typename LayerType>
72 class OcclusionTracker; 69 class OcclusionTracker;
73 70
74 // Base class for composited layers. Special layer types are derived from 71 // Base class for composited layers. Special layer types are derived from
75 // this class. 72 // this class.
76 class CC_EXPORT Layer : public base::RefCounted<Layer>, 73 class CC_EXPORT Layer : public base::RefCounted<Layer> {
77 public LayerAnimationValueObserver,
78 public LayerAnimationValueProvider {
79 public: 74 public:
80 typedef RenderSurfaceLayerList RenderSurfaceListType; 75 typedef RenderSurfaceLayerList RenderSurfaceListType;
81 typedef LayerList LayerListType; 76 typedef LayerList LayerListType;
82 typedef RenderSurface RenderSurfaceType; 77 typedef RenderSurface RenderSurfaceType;
83 78
84 enum LayerIdLabels { 79 enum LayerIdLabels {
85 INVALID_ID = -1, 80 INVALID_ID = -1,
86 }; 81 };
87 82
88 static scoped_refptr<Layer> Create(); 83 static scoped_refptr<Layer> Create();
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 float* contents_scale_x, 405 float* contents_scale_x,
411 float* contents_scale_y, 406 float* contents_scale_y,
412 gfx::Size* content_bounds); 407 gfx::Size* content_bounds);
413 408
414 LayerTreeHost* layer_tree_host() { return layer_tree_host_; } 409 LayerTreeHost* layer_tree_host() { return layer_tree_host_; }
415 const LayerTreeHost* layer_tree_host() const { return layer_tree_host_; } 410 const LayerTreeHost* layer_tree_host() const { return layer_tree_host_; }
416 411
417 // Set the priority of all desired textures in this layer. 412 // Set the priority of all desired textures in this layer.
418 virtual void SetTexturePriorities(const PriorityCalculator& priority_calc) {} 413 virtual void SetTexturePriorities(const PriorityCalculator& priority_calc) {}
419 414
420 bool AddAnimation(scoped_ptr<Animation> animation);
421 void PauseAnimation(int animation_id, double time_offset);
422 void RemoveAnimation(int animation_id);
423 void RemoveAnimation(int animation_id, Animation::TargetProperty property);
424 LayerAnimationController* layer_animation_controller() const {
425 return layer_animation_controller_.get();
426 }
427 void SetLayerAnimationControllerForTest(
428 scoped_refptr<LayerAnimationController> controller);
429
430 void set_layer_animation_delegate(AnimationDelegate* delegate) {
431 DCHECK(layer_animation_controller_);
432 layer_animation_controller_->set_layer_animation_delegate(delegate);
433 }
434
435 bool HasActiveAnimation() const;
436 void RegisterForAnimations(AnimationRegistrar* registrar,
437 const LayerTreeSettings& settings);
438
439 void AddLayerAnimationEventObserver(
440 LayerAnimationEventObserver* animation_observer);
441 void RemoveLayerAnimationEventObserver(
442 LayerAnimationEventObserver* animation_observer);
443
444 virtual SimpleEnclosedRegion VisibleContentOpaqueRegion() const; 415 virtual SimpleEnclosedRegion VisibleContentOpaqueRegion() const;
445 416
446 virtual ScrollbarLayerInterface* ToScrollbarLayer(); 417 virtual ScrollbarLayerInterface* ToScrollbarLayer();
447 418
448 gfx::Rect LayerRectToContentRect(const gfx::Rect& layer_rect) const; 419 gfx::Rect LayerRectToContentRect(const gfx::Rect& layer_rect) const;
449 420
450 virtual skia::RefPtr<SkPicture> GetPicture() const; 421 virtual skia::RefPtr<SkPicture> GetPicture() const;
451 422
452 // Constructs a LayerImpl of the correct runtime type for this Layer type. 423 // Constructs a LayerImpl of the correct runtime type for this Layer type.
453 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl); 424 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 // Sets new frame timing requests for this layer. 524 // Sets new frame timing requests for this layer.
554 void SetFrameTimingRequests(const std::vector<FrameTimingRequest>& requests); 525 void SetFrameTimingRequests(const std::vector<FrameTimingRequest>& requests);
555 526
556 // Accessor for unit tests 527 // Accessor for unit tests
557 const std::vector<FrameTimingRequest>& FrameTimingRequests() const { 528 const std::vector<FrameTimingRequest>& FrameTimingRequests() const {
558 return frame_timing_requests_; 529 return frame_timing_requests_;
559 } 530 }
560 531
561 void DidBeginTracing(); 532 void DidBeginTracing();
562 533
534 gfx::ScrollOffset ScrollOffsetForAnimation() const;
535 void OnFilterAnimated(const FilterOperations& filters);
536 void OnOpacityAnimated(float opacity);
537 void OnTransformAnimated(const gfx::Transform& transform);
538 void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset);
539
563 protected: 540 protected:
564 friend class LayerImpl; 541 friend class LayerImpl;
565 friend class TreeSynchronizer; 542 friend class TreeSynchronizer;
566 ~Layer() override; 543 virtual ~Layer();
567 544
568 Layer(); 545 Layer();
569 546
570 // These SetNeeds functions are in order of severity of update: 547 // These SetNeeds functions are in order of severity of update:
571 // 548 //
572 // Called when this layer has been modified in some way, but isn't sure 549 // Called when this layer has been modified in some way, but isn't sure
573 // that it needs a commit yet. It needs CalcDrawProperties and UpdateLayers 550 // that it needs a commit yet. It needs CalcDrawProperties and UpdateLayers
574 // before it knows whether or not a commit is required. 551 // before it knows whether or not a commit is required.
575 void SetNeedsUpdate(); 552 void SetNeedsUpdate();
576 // Called when a property has been modified in a way that the layer 553 // Called when a property has been modified in a way that the layer
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 // This should only be called during BeginMainFrame since it does not 626 // This should only be called during BeginMainFrame since it does not
650 // trigger a Commit. 627 // trigger a Commit.
651 void SetHasRenderSurface(bool has_render_surface); 628 void SetHasRenderSurface(bool has_render_surface);
652 629
653 // Returns the index of the child or -1 if not found. 630 // Returns the index of the child or -1 if not found.
654 int IndexOfChild(const Layer* reference); 631 int IndexOfChild(const Layer* reference);
655 632
656 // This should only be called from RemoveFromParent(). 633 // This should only be called from RemoveFromParent().
657 void RemoveChildOrDependent(Layer* child); 634 void RemoveChildOrDependent(Layer* child);
658 635
659 // LayerAnimationValueProvider implementation. 636 bool HasActiveAnimation() const;
660 gfx::ScrollOffset ScrollOffsetForAnimation() const override;
661
662 // LayerAnimationValueObserver implementation.
663 void OnFilterAnimated(const FilterOperations& filters) override;
664 void OnOpacityAnimated(float opacity) override;
665 void OnTransformAnimated(const gfx::Transform& transform) override;
666 void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) override;
667 void OnAnimationWaitingForDeletion() override;
668 bool IsActive() const override;
669 637
670 // If this layer has a scroll parent, it removes |this| from its list of 638 // If this layer has a scroll parent, it removes |this| from its list of
671 // scroll children. 639 // scroll children.
672 void RemoveFromScrollTree(); 640 void RemoveFromScrollTree();
673 641
674 // If this layer has a clip parent, it removes |this| from its list of clip 642 // If this layer has a clip parent, it removes |this| from its list of clip
675 // children. 643 // children.
676 void RemoveFromClipTree(); 644 void RemoveFromClipTree();
677 645
678 LayerList children_; 646 LayerList children_;
679 Layer* parent_; 647 Layer* parent_;
680 648
681 // Layer instances have a weak pointer to their LayerTreeHost. 649 // Layer instances have a weak pointer to their LayerTreeHost.
682 // This pointer value is nil when a Layer is not in a tree and is 650 // This pointer value is nil when a Layer is not in a tree and is
683 // updated via SetLayerTreeHost() if a layer moves between trees. 651 // updated via SetLayerTreeHost() if a layer moves between trees.
684 LayerTreeHost* layer_tree_host_; 652 LayerTreeHost* layer_tree_host_;
685 653
686 scoped_refptr<LayerAnimationController> layer_animation_controller_;
687
688 // Layer properties. 654 // Layer properties.
689 gfx::Size bounds_; 655 gfx::Size bounds_;
690 656
691 gfx::ScrollOffset scroll_offset_; 657 gfx::ScrollOffset scroll_offset_;
692 gfx::Vector2dF scroll_compensation_adjustment_; 658 gfx::Vector2dF scroll_compensation_adjustment_;
693 // This variable indicates which ancestor layer (if any) whose size, 659 // This variable indicates which ancestor layer (if any) whose size,
694 // transformed relative to this layer, defines the maximum scroll offset for 660 // transformed relative to this layer, defines the maximum scroll offset for
695 // this layer. 661 // this layer.
696 int scroll_clip_layer_id_; 662 int scroll_clip_layer_id_;
697 int num_descendants_that_draw_content_; 663 int num_descendants_that_draw_content_;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 727
762 std::vector<FrameTimingRequest> frame_timing_requests_; 728 std::vector<FrameTimingRequest> frame_timing_requests_;
763 bool frame_timing_requests_dirty_; 729 bool frame_timing_requests_dirty_;
764 730
765 DISALLOW_COPY_AND_ASSIGN(Layer); 731 DISALLOW_COPY_AND_ASSIGN(Layer);
766 }; 732 };
767 733
768 } // namespace cc 734 } // namespace cc
769 735
770 #endif // CC_LAYERS_LAYER_H_ 736 #endif // CC_LAYERS_LAYER_H_
OLDNEW
« no previous file with comments | « cc/blink/web_layer_impl.cc ('k') | cc/layers/layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698