| 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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 void ToLayerNodeProto(proto::LayerNode* proto) const; | 377 void ToLayerNodeProto(proto::LayerNode* proto) const; |
| 378 | 378 |
| 379 // Recursively iterate over the given LayerNode proto and read the structure | 379 // Recursively iterate over the given LayerNode proto and read the structure |
| 380 // into this node and its children. The |layer_map| should be used to look | 380 // into this node and its children. The |layer_map| should be used to look |
| 381 // for previously existing Layers, since they should be re-used between each | 381 // for previously existing Layers, since they should be re-used between each |
| 382 // hierarchy update. | 382 // hierarchy update. |
| 383 void FromLayerNodeProto(const proto::LayerNode& proto, | 383 void FromLayerNodeProto(const proto::LayerNode& proto, |
| 384 const LayerIdMap& layer_map); | 384 const LayerIdMap& layer_map); |
| 385 | 385 |
| 386 // This method is similar to PushPropertiesTo, but instead of pushing to | 386 // This method is similar to PushPropertiesTo, but instead of pushing to |
| 387 // a LayerImpl, it pushes the properties to proto::LayerProperties. It adds | 387 // a LayerImpl, it pushes the properties to proto::LayerProperties. It is |
| 388 // this layer to the proto::LayerUpdate if it or any of its descendants | 388 // called only on layers that have changed properties. The properties |
| 389 // have changed properties. If this layer contains changed properties, the | 389 // themselves are pushed to proto::LayerProperties. |
| 390 // properties themselves will also be pushed the proto::LayerProperties. | 390 void ToLayerPropertiesProto(proto::LayerUpdate* layer_update); |
| 391 // Similarly to PushPropertiesTo, this method also resets | |
| 392 // |needs_push_properties_| and |num_dependents_need_push_properties_|. | |
| 393 // Returns whether any of the descendants have changed properties. | |
| 394 bool ToLayerPropertiesProto(proto::LayerUpdate* layer_update); | |
| 395 | 391 |
| 396 // Read all property values from the given LayerProperties object and update | 392 // Read all property values from the given LayerProperties object and update |
| 397 // the current layer. The values for |needs_push_properties_| and | 393 // the current layer. The values for |needs_push_properties_| and |
| 398 // |num_dependents_need_push_properties_| are always updated, but the rest | 394 // |num_dependents_need_push_properties_| are always updated, but the rest |
| 399 // of |proto| is only read if |needs_push_properties_| is set. | 395 // of |proto| is only read if |needs_push_properties_| is set. |
| 400 void FromLayerPropertiesProto(const proto::LayerProperties& proto); | 396 void FromLayerPropertiesProto(const proto::LayerProperties& proto); |
| 401 | 397 |
| 402 LayerTreeHost* layer_tree_host() { return layer_tree_host_; } | 398 LayerTreeHost* layer_tree_host() { return layer_tree_host_; } |
| 403 const LayerTreeHost* layer_tree_host() const { return layer_tree_host_; } | 399 const LayerTreeHost* layer_tree_host() const { return layer_tree_host_; } |
| 404 | 400 |
| 405 virtual ScrollbarLayerInterface* ToScrollbarLayer(); | 401 virtual ScrollbarLayerInterface* ToScrollbarLayer(); |
| 406 | 402 |
| 407 virtual skia::RefPtr<SkPicture> GetPicture() const; | 403 virtual skia::RefPtr<SkPicture> GetPicture() const; |
| 408 | 404 |
| 409 // Constructs a LayerImpl of the correct runtime type for this Layer type. | 405 // Constructs a LayerImpl of the correct runtime type for this Layer type. |
| 410 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl); | 406 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl); |
| 411 | 407 |
| 412 bool NeedsDisplayForTesting() const { return !update_rect_.IsEmpty(); } | 408 bool NeedsDisplayForTesting() const { return !update_rect_.IsEmpty(); } |
| 413 void ResetNeedsDisplayForTesting() { update_rect_ = gfx::Rect(); } | 409 void ResetNeedsDisplayForTesting() { update_rect_ = gfx::Rect(); } |
| 414 | 410 |
| 415 RenderingStatsInstrumentation* rendering_stats_instrumentation() const; | 411 RenderingStatsInstrumentation* rendering_stats_instrumentation() const; |
| 416 | 412 |
| 417 const PaintProperties& paint_properties() const { | 413 const PaintProperties& paint_properties() const { |
| 418 return paint_properties_; | 414 return paint_properties_; |
| 419 } | 415 } |
| 420 | 416 |
| 421 void SetNeedsPushProperties(); | 417 void SetNeedsPushProperties(); |
| 422 bool needs_push_properties() const { return needs_push_properties_; } | 418 void ResetNeedsPushPropertiesForTesting(); |
| 423 bool descendant_needs_push_properties() const { | |
| 424 return num_dependents_need_push_properties_ > 0; | |
| 425 } | |
| 426 void reset_needs_push_properties_for_testing() { | |
| 427 needs_push_properties_ = false; | |
| 428 } | |
| 429 | 419 |
| 430 virtual void RunMicroBenchmark(MicroBenchmark* benchmark); | 420 virtual void RunMicroBenchmark(MicroBenchmark* benchmark); |
| 431 | 421 |
| 432 void Set3dSortingContextId(int id); | 422 void Set3dSortingContextId(int id); |
| 433 int sorting_context_id() const { return sorting_context_id_; } | 423 int sorting_context_id() const { return sorting_context_id_; } |
| 434 | 424 |
| 435 void set_property_tree_sequence_number(int sequence_number) { | 425 void set_property_tree_sequence_number(int sequence_number) { |
| 436 property_tree_sequence_number_ = sequence_number; | 426 property_tree_sequence_number_ = sequence_number; |
| 437 } | 427 } |
| 438 int property_tree_sequence_number() { return property_tree_sequence_number_; } | 428 int property_tree_sequence_number() { return property_tree_sequence_number_; } |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 // Will recalculate whether the layer draws content and set draws_content_ | 545 // Will recalculate whether the layer draws content and set draws_content_ |
| 556 // appropriately. | 546 // appropriately. |
| 557 void UpdateDrawsContent(bool has_drawable_content); | 547 void UpdateDrawsContent(bool has_drawable_content); |
| 558 virtual bool HasDrawableContent() const; | 548 virtual bool HasDrawableContent() const; |
| 559 | 549 |
| 560 // Called when the layer's number of drawable descendants changes. | 550 // Called when the layer's number of drawable descendants changes. |
| 561 void AddDrawableDescendants(int num); | 551 void AddDrawableDescendants(int num); |
| 562 | 552 |
| 563 void AddDependentNeedsPushProperties(); | 553 void AddDependentNeedsPushProperties(); |
| 564 void RemoveDependentNeedsPushProperties(); | 554 void RemoveDependentNeedsPushProperties(); |
| 565 bool parent_should_know_need_push_properties() const { | |
| 566 return needs_push_properties() || descendant_needs_push_properties(); | |
| 567 } | |
| 568 | 555 |
| 569 bool IsPropertyChangeAllowed() const; | 556 bool IsPropertyChangeAllowed() const; |
| 570 | 557 |
| 571 // Serialize all the necessary properties to be able to reconstruct this Layer | 558 // Serialize all the necessary properties to be able to reconstruct this Layer |
| 572 // into proto::LayerProperties. This function must not set values for | 559 // into proto::LayerProperties. This method is not marked as const |
| 573 // |needs_push_properties_| or |num_dependents_need_push_properties_| as they | |
| 574 // are dealt with at a higher level. This is only called if | |
| 575 // |needs_push_properties_| is set. For descendants of Layer, implementations | |
| 576 // must first call their parent class. This method is not marked as const | |
| 577 // as some implementations need reset member fields, similarly to | 560 // as some implementations need reset member fields, similarly to |
| 578 // PushPropertiesTo(). | 561 // PushPropertiesTo(). |
| 579 virtual void LayerSpecificPropertiesToProto(proto::LayerProperties* proto); | 562 virtual void LayerSpecificPropertiesToProto(proto::LayerProperties* proto); |
| 580 | 563 |
| 581 // Deserialize all the necessary properties from proto::LayerProperties into | 564 // Deserialize all the necessary properties from proto::LayerProperties into |
| 582 // this Layer. This function must not set values for |needs_push_properties_| | 565 // this Layer. |
| 583 // or |num_dependents_need_push_properties_| as they are dealt with at a | |
| 584 // higher level. This is only called if |needs_push_properties_| is set. For | |
| 585 // descendants of Layer, implementations must first call their parent class. | |
| 586 virtual void FromLayerSpecificPropertiesProto( | 566 virtual void FromLayerSpecificPropertiesProto( |
| 587 const proto::LayerProperties& proto); | 567 const proto::LayerProperties& proto); |
| 588 | 568 |
| 589 // This flag is set when the layer needs to push properties to the impl | |
| 590 // side. | |
| 591 bool needs_push_properties_; | |
| 592 | |
| 593 // The number of direct children or dependent layers that need to be recursed | |
| 594 // to in order for them or a descendent of them to push properties to the impl | |
| 595 // side. | |
| 596 int num_dependents_need_push_properties_; | |
| 597 | |
| 598 // The update rect is the region of the compositor resource that was | 569 // The update rect is the region of the compositor resource that was |
| 599 // actually updated by the compositor. For layers that may do updating | 570 // actually updated by the compositor. For layers that may do updating |
| 600 // outside the compositor's control (i.e. plugin layers), this information | 571 // outside the compositor's control (i.e. plugin layers), this information |
| 601 // is not available and the update rect will remain empty. | 572 // is not available and the update rect will remain empty. |
| 602 // Note this rect is in layer space (not content space). | 573 // Note this rect is in layer space (not content space). |
| 603 gfx::Rect update_rect_; | 574 gfx::Rect update_rect_; |
| 604 | 575 |
| 605 scoped_refptr<Layer> mask_layer_; | 576 scoped_refptr<Layer> mask_layer_; |
| 606 | 577 |
| 607 int layer_id_; | 578 int layer_id_; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 | 701 |
| 731 std::vector<FrameTimingRequest> frame_timing_requests_; | 702 std::vector<FrameTimingRequest> frame_timing_requests_; |
| 732 bool frame_timing_requests_dirty_; | 703 bool frame_timing_requests_dirty_; |
| 733 | 704 |
| 734 DISALLOW_COPY_AND_ASSIGN(Layer); | 705 DISALLOW_COPY_AND_ASSIGN(Layer); |
| 735 }; | 706 }; |
| 736 | 707 |
| 737 } // namespace cc | 708 } // namespace cc |
| 738 | 709 |
| 739 #endif // CC_LAYERS_LAYER_H_ | 710 #endif // CC_LAYERS_LAYER_H_ |
| OLD | NEW |