| OLD | NEW |
| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "cc/animation/layer_animation_value_provider.h" | 22 #include "cc/animation/layer_animation_value_provider.h" |
| 23 #include "cc/base/cc_export.h" | 23 #include "cc/base/cc_export.h" |
| 24 #include "cc/base/region.h" | 24 #include "cc/base/region.h" |
| 25 #include "cc/debug/frame_timing_request.h" | 25 #include "cc/debug/frame_timing_request.h" |
| 26 #include "cc/debug/micro_benchmark.h" | 26 #include "cc/debug/micro_benchmark.h" |
| 27 #include "cc/input/input_handler.h" | 27 #include "cc/input/input_handler.h" |
| 28 #include "cc/layers/layer_lists.h" | 28 #include "cc/layers/layer_lists.h" |
| 29 #include "cc/layers/layer_position_constraint.h" | 29 #include "cc/layers/layer_position_constraint.h" |
| 30 #include "cc/layers/paint_properties.h" | 30 #include "cc/layers/paint_properties.h" |
| 31 #include "cc/output/filter_operations.h" | 31 #include "cc/output/filter_operations.h" |
| 32 #include "cc/trees/layer_tree_host.h" |
| 32 #include "cc/trees/property_tree.h" | 33 #include "cc/trees/property_tree.h" |
| 33 #include "skia/ext/refptr.h" | 34 #include "skia/ext/refptr.h" |
| 34 #include "third_party/skia/include/core/SkColor.h" | 35 #include "third_party/skia/include/core/SkColor.h" |
| 35 #include "third_party/skia/include/core/SkImageFilter.h" | 36 #include "third_party/skia/include/core/SkImageFilter.h" |
| 36 #include "third_party/skia/include/core/SkPicture.h" | 37 #include "third_party/skia/include/core/SkPicture.h" |
| 37 #include "third_party/skia/include/core/SkXfermode.h" | 38 #include "third_party/skia/include/core/SkXfermode.h" |
| 38 #include "ui/gfx/geometry/point3_f.h" | 39 #include "ui/gfx/geometry/point3_f.h" |
| 39 #include "ui/gfx/geometry/rect.h" | 40 #include "ui/gfx/geometry/rect.h" |
| 40 #include "ui/gfx/geometry/rect_f.h" | 41 #include "ui/gfx/geometry/rect_f.h" |
| 41 #include "ui/gfx/geometry/scroll_offset.h" | 42 #include "ui/gfx/geometry/scroll_offset.h" |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 void ToLayerNodeProto(proto::LayerNode* proto) const; | 391 void ToLayerNodeProto(proto::LayerNode* proto) const; |
| 391 | 392 |
| 392 // Recursively iterate over the given LayerNode proto and read the structure | 393 // Recursively iterate over the given LayerNode proto and read the structure |
| 393 // into this node and its children. The |layer_map| should be used to look | 394 // into this node and its children. The |layer_map| should be used to look |
| 394 // for previously existing Layers, since they should be re-used between each | 395 // for previously existing Layers, since they should be re-used between each |
| 395 // hierarchy update. | 396 // hierarchy update. |
| 396 void FromLayerNodeProto(const proto::LayerNode& proto, | 397 void FromLayerNodeProto(const proto::LayerNode& proto, |
| 397 const LayerIdMap& layer_map); | 398 const LayerIdMap& layer_map); |
| 398 | 399 |
| 399 // This method is similar to PushPropertiesTo, but instead of pushing to | 400 // This method is similar to PushPropertiesTo, but instead of pushing to |
| 400 // a LayerImpl, it pushes the properties to proto::LayerProperties. It adds | 401 // a LayerImpl, it pushes the properties to proto::LayerProperties. It is |
| 401 // this layer to the proto::LayerUpdate if it or any of its descendants | 402 // called only on layers that have changed properties. The properties |
| 402 // have changed properties. If this layer contains changed properties, the | 403 // themselves are pushed to proto::LayerProperties. |
| 403 // properties themselves will also be pushed the proto::LayerProperties. | 404 void ToLayerPropertiesProto(proto::LayerUpdate* layer_update); |
| 404 // Similarly to PushPropertiesTo, this method also resets | |
| 405 // |needs_push_properties_| and |num_dependents_need_push_properties_|. | |
| 406 // Returns whether any of the descendants have changed properties. | |
| 407 bool ToLayerPropertiesProto(proto::LayerUpdate* layer_update); | |
| 408 | 405 |
| 409 // Read all property values from the given LayerProperties object and update | 406 // Read all property values from the given LayerProperties object and update |
| 410 // the current layer. The values for |needs_push_properties_| and | 407 // the current layer. The values for |needs_push_properties_| and |
| 411 // |num_dependents_need_push_properties_| are always updated, but the rest | 408 // |num_dependents_need_push_properties_| are always updated, but the rest |
| 412 // of |proto| is only read if |needs_push_properties_| is set. | 409 // of |proto| is only read if |needs_push_properties_| is set. |
| 413 void FromLayerPropertiesProto(const proto::LayerProperties& proto); | 410 void FromLayerPropertiesProto(const proto::LayerProperties& proto); |
| 414 | 411 |
| 415 LayerTreeHost* layer_tree_host() { return layer_tree_host_; } | 412 LayerTreeHost* layer_tree_host() { return layer_tree_host_; } |
| 416 const LayerTreeHost* layer_tree_host() const { return layer_tree_host_; } | 413 const LayerTreeHost* layer_tree_host() const { return layer_tree_host_; } |
| 417 | 414 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 448 bool NeedsDisplayForTesting() const { return !update_rect_.IsEmpty(); } | 445 bool NeedsDisplayForTesting() const { return !update_rect_.IsEmpty(); } |
| 449 void ResetNeedsDisplayForTesting() { update_rect_ = gfx::Rect(); } | 446 void ResetNeedsDisplayForTesting() { update_rect_ = gfx::Rect(); } |
| 450 | 447 |
| 451 RenderingStatsInstrumentation* rendering_stats_instrumentation() const; | 448 RenderingStatsInstrumentation* rendering_stats_instrumentation() const; |
| 452 | 449 |
| 453 const PaintProperties& paint_properties() const { | 450 const PaintProperties& paint_properties() const { |
| 454 return paint_properties_; | 451 return paint_properties_; |
| 455 } | 452 } |
| 456 | 453 |
| 457 void SetNeedsPushProperties(); | 454 void SetNeedsPushProperties(); |
| 458 bool needs_push_properties() const { return needs_push_properties_; } | |
| 459 bool descendant_needs_push_properties() const { | |
| 460 return num_dependents_need_push_properties_ > 0; | |
| 461 } | |
| 462 void reset_needs_push_properties_for_testing() { | 455 void reset_needs_push_properties_for_testing() { |
| 463 needs_push_properties_ = false; | 456 layer_tree_host()->RemoveLayerShouldPushProperties(this); |
| 464 } | 457 } |
| 465 | 458 |
| 466 virtual void RunMicroBenchmark(MicroBenchmark* benchmark); | 459 virtual void RunMicroBenchmark(MicroBenchmark* benchmark); |
| 467 | 460 |
| 468 void Set3dSortingContextId(int id); | 461 void Set3dSortingContextId(int id); |
| 469 int sorting_context_id() const { return sorting_context_id_; } | 462 int sorting_context_id() const { return sorting_context_id_; } |
| 470 | 463 |
| 471 void set_property_tree_sequence_number(int sequence_number) { | 464 void set_property_tree_sequence_number(int sequence_number) { |
| 472 property_tree_sequence_number_ = sequence_number; | 465 property_tree_sequence_number_ = sequence_number; |
| 473 } | 466 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 // Will recalculate whether the layer draws content and set draws_content_ | 588 // Will recalculate whether the layer draws content and set draws_content_ |
| 596 // appropriately. | 589 // appropriately. |
| 597 void UpdateDrawsContent(bool has_drawable_content); | 590 void UpdateDrawsContent(bool has_drawable_content); |
| 598 virtual bool HasDrawableContent() const; | 591 virtual bool HasDrawableContent() const; |
| 599 | 592 |
| 600 // Called when the layer's number of drawable descendants changes. | 593 // Called when the layer's number of drawable descendants changes. |
| 601 void AddDrawableDescendants(int num); | 594 void AddDrawableDescendants(int num); |
| 602 | 595 |
| 603 void AddDependentNeedsPushProperties(); | 596 void AddDependentNeedsPushProperties(); |
| 604 void RemoveDependentNeedsPushProperties(); | 597 void RemoveDependentNeedsPushProperties(); |
| 605 bool parent_should_know_need_push_properties() const { | |
| 606 return needs_push_properties() || descendant_needs_push_properties(); | |
| 607 } | |
| 608 | 598 |
| 609 bool IsPropertyChangeAllowed() const; | 599 bool IsPropertyChangeAllowed() const; |
| 610 | 600 |
| 611 // Serialize all the necessary properties to be able to reconstruct this Layer | 601 // Serialize all the necessary properties to be able to reconstruct this Layer |
| 612 // into proto::LayerProperties. This function must not set values for | 602 // into proto::LayerProperties. This method is not marked as const |
| 613 // |needs_push_properties_| or |num_dependents_need_push_properties_| as they | |
| 614 // are dealt with at a higher level. This is only called if | |
| 615 // |needs_push_properties_| is set. For descendants of Layer, implementations | |
| 616 // must first call their parent class. This method is not marked as const | |
| 617 // as some implementations need reset member fields, similarly to | 603 // as some implementations need reset member fields, similarly to |
| 618 // PushPropertiesTo(). | 604 // PushPropertiesTo(). |
| 619 virtual void LayerSpecificPropertiesToProto(proto::LayerProperties* proto); | 605 virtual void LayerSpecificPropertiesToProto(proto::LayerProperties* proto); |
| 620 | 606 |
| 621 // Deserialize all the necessary properties from proto::LayerProperties into | 607 // Deserialize all the necessary properties from proto::LayerProperties into |
| 622 // this Layer. This function must not set values for |needs_push_properties_| | 608 // this Layer. |
| 623 // or |num_dependents_need_push_properties_| as they are dealt with at a | |
| 624 // higher level. This is only called if |needs_push_properties_| is set. For | |
| 625 // descendants of Layer, implementations must first call their parent class. | |
| 626 virtual void FromLayerSpecificPropertiesProto( | 609 virtual void FromLayerSpecificPropertiesProto( |
| 627 const proto::LayerProperties& proto); | 610 const proto::LayerProperties& proto); |
| 628 | 611 |
| 629 // This flag is set when the layer needs to push properties to the impl | |
| 630 // side. | |
| 631 bool needs_push_properties_; | |
| 632 | |
| 633 // The number of direct children or dependent layers that need to be recursed | |
| 634 // to in order for them or a descendent of them to push properties to the impl | |
| 635 // side. | |
| 636 int num_dependents_need_push_properties_; | |
| 637 | |
| 638 // The update rect is the region of the compositor resource that was | 612 // The update rect is the region of the compositor resource that was |
| 639 // actually updated by the compositor. For layers that may do updating | 613 // actually updated by the compositor. For layers that may do updating |
| 640 // outside the compositor's control (i.e. plugin layers), this information | 614 // outside the compositor's control (i.e. plugin layers), this information |
| 641 // is not available and the update rect will remain empty. | 615 // is not available and the update rect will remain empty. |
| 642 // Note this rect is in layer space (not content space). | 616 // Note this rect is in layer space (not content space). |
| 643 gfx::Rect update_rect_; | 617 gfx::Rect update_rect_; |
| 644 | 618 |
| 645 scoped_refptr<Layer> mask_layer_; | 619 scoped_refptr<Layer> mask_layer_; |
| 646 | 620 |
| 647 int layer_id_; | 621 int layer_id_; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 | 747 |
| 774 std::vector<FrameTimingRequest> frame_timing_requests_; | 748 std::vector<FrameTimingRequest> frame_timing_requests_; |
| 775 bool frame_timing_requests_dirty_; | 749 bool frame_timing_requests_dirty_; |
| 776 | 750 |
| 777 DISALLOW_COPY_AND_ASSIGN(Layer); | 751 DISALLOW_COPY_AND_ASSIGN(Layer); |
| 778 }; | 752 }; |
| 779 | 753 |
| 780 } // namespace cc | 754 } // namespace cc |
| 781 | 755 |
| 782 #endif // CC_LAYERS_LAYER_H_ | 756 #endif // CC_LAYERS_LAYER_H_ |
| OLD | NEW |