| 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 "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "cc/animation/animation.h" | 8 #include "cc/animation/animation.h" |
| 9 #include "cc/animation/animation_events.h" | 9 #include "cc/animation/animation_events.h" |
| 10 #include "cc/animation/layer_animation_controller.h" | 10 #include "cc/animation/layer_animation_controller.h" |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 return; | 304 return; |
| 305 background_color_ = background_color; | 305 background_color_ = background_color; |
| 306 SetNeedsCommit(); | 306 SetNeedsCommit(); |
| 307 } | 307 } |
| 308 | 308 |
| 309 void Layer::CalculateContentsScale( | 309 void Layer::CalculateContentsScale( |
| 310 float ideal_contents_scale, | 310 float ideal_contents_scale, |
| 311 bool animating_transform_to_screen, | 311 bool animating_transform_to_screen, |
| 312 float* contents_scale_x, | 312 float* contents_scale_x, |
| 313 float* contents_scale_y, | 313 float* contents_scale_y, |
| 314 gfx::Size* contentBounds) { | 314 gfx::Size* content_bounds) { |
| 315 *contents_scale_x = 1; | 315 *contents_scale_x = 1; |
| 316 *contents_scale_y = 1; | 316 *contents_scale_y = 1; |
| 317 *contentBounds = bounds(); | 317 *content_bounds = bounds(); |
| 318 } | 318 } |
| 319 | 319 |
| 320 void Layer::SetMasksToBounds(bool masks_to_bounds) { | 320 void Layer::SetMasksToBounds(bool masks_to_bounds) { |
| 321 if (masks_to_bounds_ == masks_to_bounds) | 321 if (masks_to_bounds_ == masks_to_bounds) |
| 322 return; | 322 return; |
| 323 masks_to_bounds_ = masks_to_bounds; | 323 masks_to_bounds_ = masks_to_bounds; |
| 324 SetNeedsCommit(); | 324 SetNeedsCommit(); |
| 325 } | 325 } |
| 326 | 326 |
| 327 void Layer::SetMaskLayer(Layer* mask_layer) { | 327 void Layer::SetMaskLayer(Layer* mask_layer) { |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 if (!layer->TransformIsAnimatingOnImplOnly()) | 594 if (!layer->TransformIsAnimatingOnImplOnly()) |
| 595 layer->SetTransform(transform_); | 595 layer->SetTransform(transform_); |
| 596 DCHECK(!(TransformIsAnimating() && layer->TransformIsAnimatingOnImplOnly())); | 596 DCHECK(!(TransformIsAnimating() && layer->TransformIsAnimatingOnImplOnly())); |
| 597 | 597 |
| 598 layer->SetScrollable(scrollable_); | 598 layer->SetScrollable(scrollable_); |
| 599 layer->SetScrollOffset(scroll_offset_); | 599 layer->SetScrollOffset(scroll_offset_); |
| 600 layer->SetMaxScrollOffset(max_scroll_offset_); | 600 layer->SetMaxScrollOffset(max_scroll_offset_); |
| 601 | 601 |
| 602 // If the main thread commits multiple times before the impl thread actually | 602 // If the main thread commits multiple times before the impl thread actually |
| 603 // draws, then damage tracking will become incorrect if we simply clobber the | 603 // draws, then damage tracking will become incorrect if we simply clobber the |
| 604 // updateRect here. The LayerImpl's updateRect needs to accumulate (i.e. | 604 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. |
| 605 // union) any update changes that have occurred on the main thread. | 605 // union) any update changes that have occurred on the main thread. |
| 606 update_rect_.Union(layer->update_rect()); | 606 update_rect_.Union(layer->update_rect()); |
| 607 layer->set_update_rect(update_rect_); | 607 layer->set_update_rect(update_rect_); |
| 608 | 608 |
| 609 if (layer->layer_tree_impl()->settings().impl_side_painting) { | 609 if (layer->layer_tree_impl()->settings().impl_side_painting) { |
| 610 DCHECK(layer->layer_tree_impl()->IsPendingTree()); | 610 DCHECK(layer->layer_tree_impl()->IsPendingTree()); |
| 611 LayerImpl* active_twin = | 611 LayerImpl* active_twin = |
| 612 layer->layer_tree_impl()->FindActiveTreeLayerById(id()); | 612 layer->layer_tree_impl()->FindActiveTreeLayerById(id()); |
| 613 // Update the scroll delta from the active layer, which may have | 613 // Update the scroll delta from the active layer, which may have |
| 614 // adjusted its scroll delta prior to this pending layer being created. | 614 // adjusted its scroll delta prior to this pending layer being created. |
| 615 // This code is identical to that in LayerImpl::setScrollDelta. | 615 // This code is identical to that in LayerImpl::SetScrollDelta. |
| 616 if (active_twin) { | 616 if (active_twin) { |
| 617 DCHECK(layer->sent_scroll_delta().IsZero()); | 617 DCHECK(layer->sent_scroll_delta().IsZero()); |
| 618 layer->SetScrollDelta(active_twin->scroll_delta() - | 618 layer->SetScrollDelta(active_twin->scroll_delta() - |
| 619 active_twin->sent_scroll_delta()); | 619 active_twin->sent_scroll_delta()); |
| 620 } | 620 } |
| 621 } else { | 621 } else { |
| 622 layer->SetScrollDelta(layer->scroll_delta() - layer->sent_scroll_delta()); | 622 layer->SetScrollDelta(layer->scroll_delta() - layer->sent_scroll_delta()); |
| 623 layer->SetSentScrollDelta(gfx::Vector2d()); | 623 layer->SetSentScrollDelta(gfx::Vector2d()); |
| 624 } | 624 } |
| 625 | 625 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 void Layer::CreateRenderSurface() { | 695 void Layer::CreateRenderSurface() { |
| 696 DCHECK(!draw_properties_.render_surface); | 696 DCHECK(!draw_properties_.render_surface); |
| 697 draw_properties_.render_surface = make_scoped_ptr(new RenderSurface(this)); | 697 draw_properties_.render_surface = make_scoped_ptr(new RenderSurface(this)); |
| 698 draw_properties_.render_target = this; | 698 draw_properties_.render_target = this; |
| 699 } | 699 } |
| 700 | 700 |
| 701 void Layer::OnOpacityAnimated(float opacity) { | 701 void Layer::OnOpacityAnimated(float opacity) { |
| 702 // This is called due to an ongoing accelerated animation. Since this | 702 // This is called due to an ongoing accelerated animation. Since this |
| 703 // animation is also being run on the impl thread, there is no need to request | 703 // animation is also being run on the impl thread, there is no need to request |
| 704 // a commit to push this value over, so set the value directly rather than | 704 // a commit to push this value over, so set the value directly rather than |
| 705 // calling setOpacity. | 705 // calling SetOpacity. |
| 706 opacity_ = opacity; | 706 opacity_ = opacity; |
| 707 } | 707 } |
| 708 | 708 |
| 709 void Layer::OnTransformAnimated(const gfx::Transform& transform) { | 709 void Layer::OnTransformAnimated(const gfx::Transform& transform) { |
| 710 // This is called due to an ongoing accelerated animation. Since this | 710 // This is called due to an ongoing accelerated animation. Since this |
| 711 // animation is also being run on the impl thread, there is no need to request | 711 // animation is also being run on the impl thread, there is no need to request |
| 712 // a commit to push this value over, so set this value directly rather than | 712 // a commit to push this value over, so set this value directly rather than |
| 713 // calling setTransform. | 713 // calling SetTransform. |
| 714 transform_ = transform; | 714 transform_ = transform; |
| 715 } | 715 } |
| 716 | 716 |
| 717 bool Layer::IsActive() const { | 717 bool Layer::IsActive() const { |
| 718 return true; | 718 return true; |
| 719 } | 719 } |
| 720 | 720 |
| 721 bool Layer::AddAnimation(scoped_ptr <Animation> animation) { | 721 bool Layer::AddAnimation(scoped_ptr <Animation> animation) { |
| 722 if (!layer_animation_controller_->animation_registrar()) | 722 if (!layer_animation_controller_->animation_registrar()) |
| 723 return false; | 723 return false; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 if (contents_opaque()) | 811 if (contents_opaque()) |
| 812 return visible_content_rect(); | 812 return visible_content_rect(); |
| 813 return Region(); | 813 return Region(); |
| 814 } | 814 } |
| 815 | 815 |
| 816 ScrollbarLayer* Layer::ToScrollbarLayer() { | 816 ScrollbarLayer* Layer::ToScrollbarLayer() { |
| 817 return NULL; | 817 return NULL; |
| 818 } | 818 } |
| 819 | 819 |
| 820 } // namespace cc | 820 } // namespace cc |
| OLD | NEW |