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

Side by Side Diff: ui/compositor/layer.h

Issue 1749573002: CC Animation: Erase old animation system in UI Compositor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@eraseblink
Patch Set: Exclude histograms.xml Created 4 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
« no previous file with comments | « ui/compositor/compositor_switches.cc ('k') | ui/compositor/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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 UI_COMPOSITOR_LAYER_H_ 5 #ifndef UI_COMPOSITOR_LAYER_H_
6 #define UI_COMPOSITOR_LAYER_H_ 6 #define UI_COMPOSITOR_LAYER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/message_loop/message_loop.h" 17 #include "base/message_loop/message_loop.h"
18 #include "cc/base/region.h" 18 #include "cc/base/region.h"
19 #include "cc/layers/content_layer_client.h" 19 #include "cc/layers/content_layer_client.h"
20 #include "cc/layers/layer_client.h" 20 #include "cc/layers/layer_client.h"
21 #include "cc/layers/surface_layer.h" 21 #include "cc/layers/surface_layer.h"
22 #include "cc/layers/texture_layer_client.h" 22 #include "cc/layers/texture_layer_client.h"
23 #include "cc/resources/texture_mailbox.h" 23 #include "cc/resources/texture_mailbox.h"
24 #include "cc/surfaces/surface_id.h" 24 #include "cc/surfaces/surface_id.h"
25 #include "third_party/skia/include/core/SkColor.h" 25 #include "third_party/skia/include/core/SkColor.h"
26 #include "third_party/skia/include/core/SkRegion.h" 26 #include "third_party/skia/include/core/SkRegion.h"
27 #include "ui/compositor/compositor.h" 27 #include "ui/compositor/compositor.h"
28 #include "ui/compositor/layer_animation_delegate.h" 28 #include "ui/compositor/layer_animation_delegate.h"
29 #include "ui/compositor/layer_delegate.h" 29 #include "ui/compositor/layer_delegate.h"
30 #include "ui/compositor/layer_threaded_animation_delegate.h"
31 #include "ui/compositor/layer_type.h" 30 #include "ui/compositor/layer_type.h"
32 #include "ui/gfx/geometry/rect.h" 31 #include "ui/gfx/geometry/rect.h"
33 #include "ui/gfx/image/image_skia.h" 32 #include "ui/gfx/image/image_skia.h"
34 #include "ui/gfx/transform.h" 33 #include "ui/gfx/transform.h"
35 34
36 class SkCanvas; 35 class SkCanvas;
37 36
38 namespace cc { 37 namespace cc {
39 class ContentLayer; 38 class ContentLayer;
40 class CopyOutputRequest; 39 class CopyOutputRequest;
41 class Layer; 40 class Layer;
42 class NinePatchLayer; 41 class NinePatchLayer;
43 class ResourceUpdateQueue; 42 class ResourceUpdateQueue;
44 class SolidColorLayer; 43 class SolidColorLayer;
45 class SurfaceLayer; 44 class SurfaceLayer;
46 class TextureLayer; 45 class TextureLayer;
47 struct ReturnedResource; 46 struct ReturnedResource;
48 typedef std::vector<ReturnedResource> ReturnedResourceArray; 47 typedef std::vector<ReturnedResource> ReturnedResourceArray;
49 } 48 }
50 49
51 namespace ui { 50 namespace ui {
52 51
53 class Compositor; 52 class Compositor;
54 class LayerAnimator; 53 class LayerAnimator;
55 class LayerOwner; 54 class LayerOwner;
55 class LayerThreadedAnimationDelegate;
56 56
57 // Layer manages a texture, transform and a set of child Layers. Any View that 57 // Layer manages a texture, transform and a set of child Layers. Any View that
58 // has enabled layers ends up creating a Layer to manage the texture. 58 // has enabled layers ends up creating a Layer to manage the texture.
59 // A Layer can also be created without a texture, in which case it renders 59 // A Layer can also be created without a texture, in which case it renders
60 // nothing and is simply used as a node in a hierarchy of layers. 60 // nothing and is simply used as a node in a hierarchy of layers.
61 // Coordinate system used in layers is DIP (Density Independent Pixel) 61 // Coordinate system used in layers is DIP (Density Independent Pixel)
62 // coordinates unless explicitly mentioned as pixel coordinates. 62 // coordinates unless explicitly mentioned as pixel coordinates.
63 // 63 //
64 // NOTE: Unlike Views, each Layer does *not* own its child Layers. If you 64 // NOTE: Unlike Views, each Layer does *not* own its child Layers. If you
65 // delete a Layer and it has children, the parent of each child Layer is set to 65 // delete a Layer and it has children, the parent of each child Layer is set to
66 // NULL, but the children are not deleted. 66 // NULL, but the children are not deleted.
67 class COMPOSITOR_EXPORT Layer 67 class COMPOSITOR_EXPORT Layer
68 : public LayerAnimationDelegate, 68 : public LayerAnimationDelegate,
69 public LayerThreadedAnimationDelegate,
70 NON_EXPORTED_BASE(public cc::ContentLayerClient), 69 NON_EXPORTED_BASE(public cc::ContentLayerClient),
71 NON_EXPORTED_BASE(public cc::TextureLayerClient), 70 NON_EXPORTED_BASE(public cc::TextureLayerClient),
72 NON_EXPORTED_BASE(public cc::LayerClient) { 71 NON_EXPORTED_BASE(public cc::LayerClient) {
73 public: 72 public:
74 Layer(); 73 Layer();
75 explicit Layer(LayerType type); 74 explicit Layer(LayerType type);
76 ~Layer() override; 75 ~Layer() override;
77 76
78 static const cc::LayerSettings& UILayerSettings();
79 static void InitializeUILayerSettings();
80
81 // Retrieves the Layer's compositor. The Layer will walk up its parent chain 77 // Retrieves the Layer's compositor. The Layer will walk up its parent chain
82 // to locate it. Returns NULL if the Layer is not attached to a compositor. 78 // to locate it. Returns NULL if the Layer is not attached to a compositor.
83 Compositor* GetCompositor() { 79 Compositor* GetCompositor() {
84 return const_cast<Compositor*>( 80 return const_cast<Compositor*>(
85 const_cast<const Layer*>(this)->GetCompositor()); 81 const_cast<const Layer*>(this)->GetCompositor());
86 } 82 }
87 const Compositor* GetCompositor() const; 83 const Compositor* GetCompositor() const;
88 84
89 // Called by the compositor when the Layer is set as its root Layer. This can 85 // Called by the compositor when the Layer is set as its root Layer. This can
90 // only ever be called on the root layer. 86 // only ever be called on the root layer.
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 float GetOpacityForAnimation() const override; 395 float GetOpacityForAnimation() const override;
400 bool GetVisibilityForAnimation() const override; 396 bool GetVisibilityForAnimation() const override;
401 float GetBrightnessForAnimation() const override; 397 float GetBrightnessForAnimation() const override;
402 float GetGrayscaleForAnimation() const override; 398 float GetGrayscaleForAnimation() const override;
403 SkColor GetColorForAnimation() const override; 399 SkColor GetColorForAnimation() const override;
404 float GetDeviceScaleFactor() const override; 400 float GetDeviceScaleFactor() const override;
405 cc::Layer* GetCcLayer() const override; 401 cc::Layer* GetCcLayer() const override;
406 LayerThreadedAnimationDelegate* GetThreadedAnimationDelegate() override; 402 LayerThreadedAnimationDelegate* GetThreadedAnimationDelegate() override;
407 LayerAnimatorCollection* GetLayerAnimatorCollection() override; 403 LayerAnimatorCollection* GetLayerAnimatorCollection() override;
408 404
409 // Implementation of LayerThreadedAnimationDelegate.
410 void AddThreadedAnimation(scoped_ptr<cc::Animation> animation) override;
411 void RemoveThreadedAnimation(int animation_id) override;
412
413 // Creates a corresponding composited layer for |type_|. 405 // Creates a corresponding composited layer for |type_|.
414 void CreateCcLayer(); 406 void CreateCcLayer();
415 407
416 // Recomputes and sets to |cc_layer_|. 408 // Recomputes and sets to |cc_layer_|.
417 void RecomputeDrawsContentAndUVRect(); 409 void RecomputeDrawsContentAndUVRect();
418 void RecomputePosition(); 410 void RecomputePosition();
419 411
420 // Set all filters which got applied to the layer. 412 // Set all filters which got applied to the layer.
421 void SetLayerFilters(); 413 void SetLayerFilters();
422 414
423 // Set all filters which got applied to the layer background. 415 // Set all filters which got applied to the layer background.
424 void SetLayerBackgroundFilters(); 416 void SetLayerBackgroundFilters();
425 417
426 // Cleanup |cc_layer_| and replaces it with |new_layer|. 418 // Cleanup |cc_layer_| and replaces it with |new_layer|.
427 void SwitchToLayer(scoped_refptr<cc::Layer> new_layer); 419 void SwitchToLayer(scoped_refptr<cc::Layer> new_layer);
428 420
429 // We cannot send animations to our cc_layer_ until we have been added to a
430 // layer tree. Instead, we hold on to these animations in
431 // pending_threaded_animations_, and expect SendPendingThreadedAnimations to
432 // be called once we have been added to a tree.
433 void SendPendingThreadedAnimations();
434
435 void SetCompositorForAnimatorsInTree(Compositor* compositor); 421 void SetCompositorForAnimatorsInTree(Compositor* compositor);
436 void ResetCompositorForAnimatorsInTree(Compositor* compositor); 422 void ResetCompositorForAnimatorsInTree(Compositor* compositor);
437 423
438 const LayerType type_; 424 const LayerType type_;
439 425
440 Compositor* compositor_; 426 Compositor* compositor_;
441 427
442 Layer* parent_; 428 Layer* parent_;
443 429
444 // This layer's children, in bottom-to-top stacking order. 430 // This layer's children, in bottom-to-top stacking order.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 scoped_ptr<SkRegion> alpha_shape_; 472 scoped_ptr<SkRegion> alpha_shape_;
487 473
488 std::string name_; 474 std::string name_;
489 475
490 LayerDelegate* delegate_; 476 LayerDelegate* delegate_;
491 477
492 LayerOwner* owner_; 478 LayerOwner* owner_;
493 479
494 scoped_refptr<LayerAnimator> animator_; 480 scoped_refptr<LayerAnimator> animator_;
495 481
496 // Animations that are passed to AddThreadedAnimation before this layer is
497 // added to a tree.
498 std::vector<scoped_ptr<cc::Animation>> pending_threaded_animations_;
499
500 // Ownership of the layer is held through one of the strongly typed layer 482 // Ownership of the layer is held through one of the strongly typed layer
501 // pointers, depending on which sort of layer this is. 483 // pointers, depending on which sort of layer this is.
502 scoped_refptr<cc::Layer> content_layer_; 484 scoped_refptr<cc::Layer> content_layer_;
503 scoped_refptr<cc::NinePatchLayer> nine_patch_layer_; 485 scoped_refptr<cc::NinePatchLayer> nine_patch_layer_;
504 scoped_refptr<cc::TextureLayer> texture_layer_; 486 scoped_refptr<cc::TextureLayer> texture_layer_;
505 scoped_refptr<cc::SolidColorLayer> solid_color_layer_; 487 scoped_refptr<cc::SolidColorLayer> solid_color_layer_;
506 scoped_refptr<cc::SurfaceLayer> surface_layer_; 488 scoped_refptr<cc::SurfaceLayer> surface_layer_;
507 cc::Layer* cc_layer_; 489 cc::Layer* cc_layer_;
508 490
509 // A cached copy of |Compositor::device_scale_factor()|. 491 // A cached copy of |Compositor::device_scale_factor()|.
(...skipping 14 matching lines...) Expand all
524 // The size of the frame or texture in DIP, set when SetShowDelegatedContent 506 // The size of the frame or texture in DIP, set when SetShowDelegatedContent
525 // or SetTextureMailbox was called. 507 // or SetTextureMailbox was called.
526 gfx::Size frame_size_in_dip_; 508 gfx::Size frame_size_in_dip_;
527 509
528 DISALLOW_COPY_AND_ASSIGN(Layer); 510 DISALLOW_COPY_AND_ASSIGN(Layer);
529 }; 511 };
530 512
531 } // namespace ui 513 } // namespace ui
532 514
533 #endif // UI_COMPOSITOR_LAYER_H_ 515 #endif // UI_COMPOSITOR_LAYER_H_
OLDNEW
« no previous file with comments | « ui/compositor/compositor_switches.cc ('k') | ui/compositor/layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698