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 #include "cc/layers/layer.h" | 5 #include "cc/layers/layer.h" |
6 | 6 |
7 #include "cc/animation/animation.h" | 7 #include "cc/animation/animation.h" |
8 #include "cc/animation/animation_events.h" | 8 #include "cc/animation/animation_events.h" |
9 #include "cc/animation/layer_animation_controller.h" | 9 #include "cc/animation/layer_animation_controller.h" |
10 #include "cc/layers/layer_impl.h" | 10 #include "cc/layers/layer_impl.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 parent_(NULL), | 32 parent_(NULL), |
33 layer_tree_host_(NULL), | 33 layer_tree_host_(NULL), |
34 scrollable_(false), | 34 scrollable_(false), |
35 should_scroll_on_main_thread_(false), | 35 should_scroll_on_main_thread_(false), |
36 have_wheel_event_handlers_(false), | 36 have_wheel_event_handlers_(false), |
37 anchor_point_(0.5f, 0.5f), | 37 anchor_point_(0.5f, 0.5f), |
38 background_color_(0), | 38 background_color_(0), |
39 opacity_(1.f), | 39 opacity_(1.f), |
40 anchor_point_z_(0.f), | 40 anchor_point_z_(0.f), |
41 is_container_for_fixed_position_layers_(false), | 41 is_container_for_fixed_position_layers_(false), |
42 fixed_to_container_layer_(false), | |
43 is_drawable_(false), | 42 is_drawable_(false), |
44 masks_to_bounds_(false), | 43 masks_to_bounds_(false), |
45 contents_opaque_(false), | 44 contents_opaque_(false), |
46 double_sided_(true), | 45 double_sided_(true), |
47 preserves_3d_(false), | 46 preserves_3d_(false), |
48 use_parent_backface_visibility_(false), | 47 use_parent_backface_visibility_(false), |
49 draw_checkerboard_for_missing_tiles_(false), | 48 draw_checkerboard_for_missing_tiles_(false), |
50 force_render_surface_(false), | 49 force_render_surface_(false), |
51 replica_layer_(NULL), | 50 replica_layer_(NULL), |
52 raster_scale_(1.f), | 51 raster_scale_(1.f), |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 SetNeedsCommit(); | 406 SetNeedsCommit(); |
408 } | 407 } |
409 | 408 |
410 void Layer::SetPosition(gfx::PointF position) { | 409 void Layer::SetPosition(gfx::PointF position) { |
411 if (position_ == position) | 410 if (position_ == position) |
412 return; | 411 return; |
413 position_ = position; | 412 position_ = position; |
414 SetNeedsCommit(); | 413 SetNeedsCommit(); |
415 } | 414 } |
416 | 415 |
| 416 bool Layer::is_container_for_fixed_position_layers() const { |
| 417 if (!transform_.IsIdentityOrTranslation()) |
| 418 return true; |
| 419 if (parent_ && !parent_->sublayer_transform_.IsIdentityOrTranslation()) |
| 420 return true; |
| 421 return is_container_for_fixed_position_layers_; |
| 422 } |
| 423 |
417 void Layer::SetSublayerTransform(const gfx::Transform& sublayer_transform) { | 424 void Layer::SetSublayerTransform(const gfx::Transform& sublayer_transform) { |
418 if (sublayer_transform_ == sublayer_transform) | 425 if (sublayer_transform_ == sublayer_transform) |
419 return; | 426 return; |
420 sublayer_transform_ = sublayer_transform; | 427 sublayer_transform_ = sublayer_transform; |
421 SetNeedsCommit(); | 428 SetNeedsCommit(); |
422 } | 429 } |
423 | 430 |
424 void Layer::SetTransform(const gfx::Transform& transform) { | 431 void Layer::SetTransform(const gfx::Transform& transform) { |
425 if (transform_ == transform) | 432 if (transform_ == transform) |
426 return; | 433 return; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 | 531 |
525 // Simply mark the contents as dirty. For non-root layers, the call to | 532 // Simply mark the contents as dirty. For non-root layers, the call to |
526 // SetNeedsCommit will schedule a fresh compositing pass. | 533 // SetNeedsCommit will schedule a fresh compositing pass. |
527 // For the root layer, SetNeedsCommit has no effect. | 534 // For the root layer, SetNeedsCommit has no effect. |
528 if (DrawsContent() && !update_rect_.IsEmpty()) | 535 if (DrawsContent() && !update_rect_.IsEmpty()) |
529 SetNeedsCommit(); | 536 SetNeedsCommit(); |
530 } | 537 } |
531 | 538 |
532 bool Layer::DescendantIsFixedToContainerLayer() const { | 539 bool Layer::DescendantIsFixedToContainerLayer() const { |
533 for (size_t i = 0; i < children_.size(); ++i) { | 540 for (size_t i = 0; i < children_.size(); ++i) { |
534 if (children_[i]->fixed_to_container_layer() || | 541 if (children_[i]->position_constraint_.is_fixed_position() || |
535 children_[i]->DescendantIsFixedToContainerLayer()) | 542 children_[i]->DescendantIsFixedToContainerLayer()) |
536 return true; | 543 return true; |
537 } | 544 } |
538 return false; | 545 return false; |
539 } | 546 } |
540 | 547 |
541 void Layer::SetIsContainerForFixedPositionLayers(bool container) { | 548 void Layer::SetIsContainerForFixedPositionLayers(bool container) { |
542 if (is_container_for_fixed_position_layers_ == container) | 549 if (is_container_for_fixed_position_layers_ == container) |
543 return; | 550 return; |
544 is_container_for_fixed_position_layers_ = container; | 551 is_container_for_fixed_position_layers_ = container; |
545 | 552 |
546 if (layer_tree_host_ && layer_tree_host_->CommitRequested()) | 553 if (layer_tree_host_ && layer_tree_host_->CommitRequested()) |
547 return; | 554 return; |
548 | 555 |
549 // Only request a commit if we have a fixed positioned descendant. | 556 // Only request a commit if we have a fixed positioned descendant. |
550 if (DescendantIsFixedToContainerLayer()) | 557 if (DescendantIsFixedToContainerLayer()) |
551 SetNeedsCommit(); | 558 SetNeedsCommit(); |
552 } | 559 } |
553 | 560 |
554 void Layer::SetFixedToContainerLayer(bool fixed_to_container_layer) { | 561 void Layer::SetPositionConstraint(const LayerPositionConstraint& constraint) { |
555 if (fixed_to_container_layer_ == fixed_to_container_layer) | 562 if (position_constraint_ == constraint) |
556 return; | 563 return; |
557 fixed_to_container_layer_ = fixed_to_container_layer; | 564 position_constraint_ = constraint; |
558 SetNeedsCommit(); | 565 SetNeedsCommit(); |
559 } | 566 } |
560 | 567 |
561 void Layer::PushPropertiesTo(LayerImpl* layer) { | 568 void Layer::PushPropertiesTo(LayerImpl* layer) { |
562 layer->SetAnchorPoint(anchor_point_); | 569 layer->SetAnchorPoint(anchor_point_); |
563 layer->SetAnchorPointZ(anchor_point_z_); | 570 layer->SetAnchorPointZ(anchor_point_z_); |
564 layer->SetBackgroundColor(background_color_); | 571 layer->SetBackgroundColor(background_color_); |
565 layer->SetBounds(bounds_); | 572 layer->SetBounds(bounds_); |
566 layer->SetContentBounds(content_bounds()); | 573 layer->SetContentBounds(content_bounds()); |
567 layer->SetContentsScale(contents_scale_x(), contents_scale_y()); | 574 layer->SetContentsScale(contents_scale_x(), contents_scale_y()); |
568 layer->SetDebugName(debug_name_); | 575 layer->SetDebugName(debug_name_); |
(...skipping 10 matching lines...) Expand all Loading... |
579 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); | 586 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); |
580 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); | 587 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); |
581 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); | 588 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); |
582 layer->SetContentsOpaque(contents_opaque_); | 589 layer->SetContentsOpaque(contents_opaque_); |
583 if (!layer->OpacityIsAnimatingOnImplOnly()) | 590 if (!layer->OpacityIsAnimatingOnImplOnly()) |
584 layer->SetOpacity(opacity_); | 591 layer->SetOpacity(opacity_); |
585 DCHECK(!(OpacityIsAnimating() && layer->OpacityIsAnimatingOnImplOnly())); | 592 DCHECK(!(OpacityIsAnimating() && layer->OpacityIsAnimatingOnImplOnly())); |
586 layer->SetPosition(position_); | 593 layer->SetPosition(position_); |
587 layer->SetIsContainerForFixedPositionLayers( | 594 layer->SetIsContainerForFixedPositionLayers( |
588 is_container_for_fixed_position_layers_); | 595 is_container_for_fixed_position_layers_); |
589 layer->SetFixedToContainerLayer(fixed_to_container_layer_); | 596 layer->SetFixedContainerSizeDelta(gfx::Vector2dF()); |
| 597 layer->SetPositionConstraint(position_constraint_); |
590 layer->SetPreserves3d(preserves_3d()); | 598 layer->SetPreserves3d(preserves_3d()); |
591 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); | 599 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); |
592 layer->SetSublayerTransform(sublayer_transform_); | 600 layer->SetSublayerTransform(sublayer_transform_); |
593 if (!layer->TransformIsAnimatingOnImplOnly()) | 601 if (!layer->TransformIsAnimatingOnImplOnly()) |
594 layer->SetTransform(transform_); | 602 layer->SetTransform(transform_); |
595 DCHECK(!(TransformIsAnimating() && layer->TransformIsAnimatingOnImplOnly())); | 603 DCHECK(!(TransformIsAnimating() && layer->TransformIsAnimatingOnImplOnly())); |
596 | 604 |
597 layer->SetScrollable(scrollable_); | 605 layer->SetScrollable(scrollable_); |
598 layer->SetScrollOffset(scroll_offset_); | 606 layer->SetScrollOffset(scroll_offset_); |
599 layer->SetMaxScrollOffset(max_scroll_offset_); | 607 layer->SetMaxScrollOffset(max_scroll_offset_); |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 if (contents_opaque()) | 816 if (contents_opaque()) |
809 return visible_content_rect(); | 817 return visible_content_rect(); |
810 return Region(); | 818 return Region(); |
811 } | 819 } |
812 | 820 |
813 ScrollbarLayer* Layer::ToScrollbarLayer() { | 821 ScrollbarLayer* Layer::ToScrollbarLayer() { |
814 return NULL; | 822 return NULL; |
815 } | 823 } |
816 | 824 |
817 } // namespace cc | 825 } // namespace cc |
OLD | NEW |