Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include "cc/layers/layer_impl.h" | 5 #include "cc/layers/layer_impl.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/debug/trace_event_argument.h" | 8 #include "base/debug/trace_event_argument.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 double_sided_(true), | 53 double_sided_(true), |
| 54 should_flatten_transform_(true), | 54 should_flatten_transform_(true), |
| 55 layer_property_changed_(false), | 55 layer_property_changed_(false), |
| 56 masks_to_bounds_(false), | 56 masks_to_bounds_(false), |
| 57 contents_opaque_(false), | 57 contents_opaque_(false), |
| 58 is_root_for_isolated_group_(false), | 58 is_root_for_isolated_group_(false), |
| 59 use_parent_backface_visibility_(false), | 59 use_parent_backface_visibility_(false), |
| 60 draw_checkerboard_for_missing_tiles_(false), | 60 draw_checkerboard_for_missing_tiles_(false), |
| 61 draws_content_(false), | 61 draws_content_(false), |
| 62 hide_layer_and_subtree_(false), | 62 hide_layer_and_subtree_(false), |
| 63 force_render_surface_(false), | |
| 64 transform_is_invertible_(true), | 63 transform_is_invertible_(true), |
| 65 is_container_for_fixed_position_layers_(false), | 64 is_container_for_fixed_position_layers_(false), |
| 66 background_color_(0), | 65 background_color_(0), |
| 67 opacity_(1.0), | 66 opacity_(1.0), |
| 68 blend_mode_(SkXfermode::kSrcOver_Mode), | 67 blend_mode_(SkXfermode::kSrcOver_Mode), |
| 69 num_descendants_that_draw_content_(0), | 68 num_descendants_that_draw_content_(0), |
| 70 draw_depth_(0.f), | 69 draw_depth_(0.f), |
| 71 needs_push_properties_(false), | 70 needs_push_properties_(false), |
| 72 num_dependents_need_push_properties_(0), | 71 num_dependents_need_push_properties_(0), |
| 73 sorting_context_id_(0), | 72 sorting_context_id_(0), |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 195 } | 194 } |
| 196 | 195 |
| 197 void LayerImpl::SetClipChildren(std::set<LayerImpl*>* children) { | 196 void LayerImpl::SetClipChildren(std::set<LayerImpl*>* children) { |
| 198 if (clip_children_.get() == children) | 197 if (clip_children_.get() == children) |
| 199 return; | 198 return; |
| 200 clip_children_.reset(children); | 199 clip_children_.reset(children); |
| 201 SetNeedsPushProperties(); | 200 SetNeedsPushProperties(); |
| 202 } | 201 } |
| 203 | 202 |
| 204 void LayerImpl::PassCopyRequests(ScopedPtrVector<CopyOutputRequest>* requests) { | 203 void LayerImpl::PassCopyRequests(ScopedPtrVector<CopyOutputRequest>* requests) { |
| 205 if (requests->empty()) | 204 if (requests->empty()) |
|
danakj
2014/09/25 16:02:12
can this DCHECK the layer has a render surface (re
awoloszyn
2014/11/25 15:48:46
Done.
| |
| 206 return; | 205 return; |
| 207 | 206 |
| 208 bool was_empty = copy_requests_.empty(); | 207 bool was_empty = copy_requests_.empty(); |
| 209 copy_requests_.insert_and_take(copy_requests_.end(), requests); | 208 copy_requests_.insert_and_take(copy_requests_.end(), requests); |
| 210 requests->clear(); | 209 requests->clear(); |
| 211 | 210 |
| 212 if (was_empty && layer_tree_impl()->IsActiveTree()) | 211 if (was_empty && layer_tree_impl()->IsActiveTree()) |
| 213 layer_tree_impl()->AddLayerWithCopyOutputRequest(this); | 212 layer_tree_impl()->AddLayerWithCopyOutputRequest(this); |
| 214 NoteLayerPropertyChangedForSubtree(); | 213 NoteLayerPropertyChangedForSubtree(); |
| 215 } | 214 } |
| 216 | 215 |
| 217 void LayerImpl::TakeCopyRequestsAndTransformToTarget( | 216 void LayerImpl::TakeCopyRequestsAndTransformToTarget( |
| 218 ScopedPtrVector<CopyOutputRequest>* requests) { | 217 ScopedPtrVector<CopyOutputRequest>* requests) { |
| 219 DCHECK(!copy_requests_.empty()); | 218 DCHECK(!copy_requests_.empty()); |
|
danakj
2014/09/25 16:02:12
can this dcheck that the render target is itself?
awoloszyn
2014/11/25 15:48:46
Done.
| |
| 220 DCHECK(layer_tree_impl()->IsActiveTree()); | 219 DCHECK(layer_tree_impl()->IsActiveTree()); |
| 221 | 220 |
| 222 size_t first_inserted_request = requests->size(); | 221 size_t first_inserted_request = requests->size(); |
| 223 requests->insert_and_take(requests->end(), ©_requests_); | 222 requests->insert_and_take(requests->end(), ©_requests_); |
| 224 copy_requests_.clear(); | 223 copy_requests_.clear(); |
| 225 | 224 |
| 226 for (size_t i = first_inserted_request; i < requests->size(); ++i) { | 225 for (size_t i = first_inserted_request; i < requests->size(); ++i) { |
| 227 CopyOutputRequest* request = requests->at(i); | 226 CopyOutputRequest* request = requests->at(i); |
| 228 if (!request->has_area()) | 227 if (!request->has_area()) |
| 229 continue; | 228 continue; |
| 230 | 229 |
| 231 gfx::Rect request_in_layer_space = request->area(); | 230 gfx::Rect request_in_layer_space = request->area(); |
| 232 gfx::Rect request_in_content_space = | 231 gfx::Rect request_in_content_space = |
| 233 LayerRectToContentRect(request_in_layer_space); | 232 LayerRectToContentRect(request_in_layer_space); |
| 234 request->set_area(MathUtil::MapEnclosingClippedRect( | 233 request->set_area(MathUtil::MapEnclosingClippedRect( |
| 235 draw_properties_.target_space_transform, request_in_content_space)); | 234 draw_properties_.target_space_transform, request_in_content_space)); |
| 236 } | 235 } |
| 237 | 236 |
| 238 layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this); | 237 layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this); |
| 239 } | 238 } |
| 240 | 239 |
| 241 void LayerImpl::CreateRenderSurface() { | |
| 242 DCHECK(!draw_properties_.render_surface); | |
| 243 draw_properties_.render_surface = | |
| 244 make_scoped_ptr(new RenderSurfaceImpl(this)); | |
| 245 draw_properties_.render_target = this; | |
| 246 } | |
| 247 | |
| 248 void LayerImpl::ClearRenderSurface() { | |
| 249 draw_properties_.render_surface.reset(); | |
| 250 } | |
| 251 | |
| 252 void LayerImpl::ClearRenderSurfaceLayerList() { | 240 void LayerImpl::ClearRenderSurfaceLayerList() { |
| 253 if (draw_properties_.render_surface) | 241 if (render_surface_) |
| 254 draw_properties_.render_surface->layer_list().clear(); | 242 render_surface_->layer_list().clear(); |
| 255 } | 243 } |
| 256 | 244 |
| 257 void LayerImpl::PopulateSharedQuadState(SharedQuadState* state) const { | 245 void LayerImpl::PopulateSharedQuadState(SharedQuadState* state) const { |
| 258 state->SetAll(draw_properties_.target_space_transform, | 246 state->SetAll(draw_properties_.target_space_transform, |
| 259 draw_properties_.content_bounds, | 247 draw_properties_.content_bounds, |
| 260 draw_properties_.visible_content_rect, | 248 draw_properties_.visible_content_rect, |
| 261 draw_properties_.clip_rect, | 249 draw_properties_.clip_rect, |
| 262 draw_properties_.is_clipped, | 250 draw_properties_.is_clipped, |
| 263 draw_properties_.opacity, | 251 draw_properties_.opacity, |
| 264 blend_mode_, | 252 blend_mode_, |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 503 | 491 |
| 504 void LayerImpl::PushPropertiesTo(LayerImpl* layer) { | 492 void LayerImpl::PushPropertiesTo(LayerImpl* layer) { |
| 505 layer->SetTransformOrigin(transform_origin_); | 493 layer->SetTransformOrigin(transform_origin_); |
| 506 layer->SetBackgroundColor(background_color_); | 494 layer->SetBackgroundColor(background_color_); |
| 507 layer->SetBounds(bounds_); | 495 layer->SetBounds(bounds_); |
| 508 layer->SetContentBounds(content_bounds()); | 496 layer->SetContentBounds(content_bounds()); |
| 509 layer->SetContentsScale(contents_scale_x(), contents_scale_y()); | 497 layer->SetContentsScale(contents_scale_x(), contents_scale_y()); |
| 510 layer->SetDoubleSided(double_sided_); | 498 layer->SetDoubleSided(double_sided_); |
| 511 layer->SetDrawCheckerboardForMissingTiles( | 499 layer->SetDrawCheckerboardForMissingTiles( |
| 512 draw_checkerboard_for_missing_tiles_); | 500 draw_checkerboard_for_missing_tiles_); |
| 513 layer->SetForceRenderSurface(force_render_surface_); | |
| 514 layer->SetDrawsContent(DrawsContent()); | 501 layer->SetDrawsContent(DrawsContent()); |
| 515 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); | 502 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); |
| 516 layer->SetFilters(filters()); | 503 layer->SetFilters(filters()); |
| 517 layer->SetBackgroundFilters(background_filters()); | 504 layer->SetBackgroundFilters(background_filters()); |
| 518 layer->SetMasksToBounds(masks_to_bounds_); | 505 layer->SetMasksToBounds(masks_to_bounds_); |
| 519 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_); | 506 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_); |
| 520 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); | 507 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); |
| 521 layer->SetHaveScrollEventHandlers(have_scroll_event_handlers_); | 508 layer->SetHaveScrollEventHandlers(have_scroll_event_handlers_); |
| 522 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); | 509 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); |
| 523 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); | 510 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 535 | 522 |
| 536 layer->SetScrollClipLayer(scroll_clip_layer_ ? scroll_clip_layer_->id() | 523 layer->SetScrollClipLayer(scroll_clip_layer_ ? scroll_clip_layer_->id() |
| 537 : Layer::INVALID_ID); | 524 : Layer::INVALID_ID); |
| 538 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); | 525 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); |
| 539 layer->set_user_scrollable_vertical(user_scrollable_vertical_); | 526 layer->set_user_scrollable_vertical(user_scrollable_vertical_); |
| 540 layer->SetScrollOffsetAndDelta( | 527 layer->SetScrollOffsetAndDelta( |
| 541 scroll_offset_, layer->ScrollDelta() - layer->sent_scroll_delta()); | 528 scroll_offset_, layer->ScrollDelta() - layer->sent_scroll_delta()); |
| 542 layer->SetSentScrollDelta(gfx::Vector2d()); | 529 layer->SetSentScrollDelta(gfx::Vector2d()); |
| 543 layer->Set3dSortingContextId(sorting_context_id_); | 530 layer->Set3dSortingContextId(sorting_context_id_); |
| 544 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_); | 531 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_); |
| 532 layer->SetHasRenderSurface(!!render_surface()); | |
| 545 | 533 |
| 546 LayerImpl* scroll_parent = NULL; | 534 LayerImpl* scroll_parent = NULL; |
| 547 if (scroll_parent_) { | 535 if (scroll_parent_) { |
| 548 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); | 536 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); |
| 549 DCHECK(scroll_parent); | 537 DCHECK(scroll_parent); |
| 550 } | 538 } |
| 551 | 539 |
| 552 layer->SetScrollParent(scroll_parent); | 540 layer->SetScrollParent(scroll_parent); |
| 553 if (scroll_children_) { | 541 if (scroll_children_) { |
| 554 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>; | 542 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>; |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 711 const char* LayerImpl::LayerTypeAsString() const { | 699 const char* LayerImpl::LayerTypeAsString() const { |
| 712 return "cc::LayerImpl"; | 700 return "cc::LayerImpl"; |
| 713 } | 701 } |
| 714 | 702 |
| 715 void LayerImpl::ResetAllChangeTrackingForSubtree() { | 703 void LayerImpl::ResetAllChangeTrackingForSubtree() { |
| 716 layer_property_changed_ = false; | 704 layer_property_changed_ = false; |
| 717 | 705 |
| 718 update_rect_ = gfx::RectF(); | 706 update_rect_ = gfx::RectF(); |
| 719 damage_rect_ = gfx::RectF(); | 707 damage_rect_ = gfx::RectF(); |
| 720 | 708 |
| 721 if (draw_properties_.render_surface) | 709 if (render_surface_) |
| 722 draw_properties_.render_surface->ResetPropertyChangedFlag(); | 710 render_surface_->ResetPropertyChangedFlag(); |
| 723 | 711 |
| 724 if (mask_layer_) | 712 if (mask_layer_) |
| 725 mask_layer_->ResetAllChangeTrackingForSubtree(); | 713 mask_layer_->ResetAllChangeTrackingForSubtree(); |
| 726 | 714 |
| 727 if (replica_layer_) { | 715 if (replica_layer_) { |
| 728 // This also resets the replica mask, if it exists. | 716 // This also resets the replica mask, if it exists. |
| 729 replica_layer_->ResetAllChangeTrackingForSubtree(); | 717 replica_layer_->ResetAllChangeTrackingForSubtree(); |
| 730 } | 718 } |
| 731 | 719 |
| 732 for (size_t i = 0; i < children_.size(); ++i) | 720 for (size_t i = 0; i < children_.size(); ++i) |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 894 } | 882 } |
| 895 if (SkColorGetA(color) != 255) | 883 if (SkColorGetA(color) != 255) |
| 896 color = layer_tree_impl()->background_color(); | 884 color = layer_tree_impl()->background_color(); |
| 897 if (SkColorGetA(color) != 255) | 885 if (SkColorGetA(color) != 255) |
| 898 color = SkColorSetA(color, 255); | 886 color = SkColorSetA(color, 255); |
| 899 } | 887 } |
| 900 return color; | 888 return color; |
| 901 } | 889 } |
| 902 | 890 |
| 903 void LayerImpl::SetFilters(const FilterOperations& filters) { | 891 void LayerImpl::SetFilters(const FilterOperations& filters) { |
| 904 if (filters_ == filters) | 892 if (filters_ == filters) |
|
danakj
2014/09/25 16:02:12
can this DCHECK that the layer has a surface?
awoloszyn
2014/11/25 15:48:46
Done.
| |
| 905 return; | 893 return; |
| 906 | 894 |
| 907 filters_ = filters; | 895 filters_ = filters; |
| 908 NoteLayerPropertyChangedForSubtree(); | 896 NoteLayerPropertyChangedForSubtree(); |
| 909 } | 897 } |
| 910 | 898 |
| 911 bool LayerImpl::FilterIsAnimating() const { | 899 bool LayerImpl::FilterIsAnimating() const { |
| 912 return layer_animation_controller_->IsAnimatingProperty(Animation::Filter); | 900 return layer_animation_controller_->IsAnimatingProperty(Animation::Filter); |
| 913 } | 901 } |
| 914 | 902 |
| 915 bool LayerImpl::FilterIsAnimatingOnImplOnly() const { | 903 bool LayerImpl::FilterIsAnimatingOnImplOnly() const { |
| 916 Animation* filter_animation = | 904 Animation* filter_animation = |
| 917 layer_animation_controller_->GetAnimation(Animation::Filter); | 905 layer_animation_controller_->GetAnimation(Animation::Filter); |
| 918 return filter_animation && filter_animation->is_impl_only(); | 906 return filter_animation && filter_animation->is_impl_only(); |
| 919 } | 907 } |
| 920 | 908 |
| 921 void LayerImpl::SetBackgroundFilters( | 909 void LayerImpl::SetBackgroundFilters( |
| 922 const FilterOperations& filters) { | 910 const FilterOperations& filters) { |
| 923 if (background_filters_ == filters) | 911 if (background_filters_ == filters) |
|
danakj
2014/09/25 16:02:12
and this?
awoloszyn
2014/11/25 15:48:46
Done.
| |
| 924 return; | 912 return; |
| 925 | 913 |
| 926 background_filters_ = filters; | 914 background_filters_ = filters; |
| 927 NoteLayerPropertyChanged(); | 915 NoteLayerPropertyChanged(); |
| 928 } | 916 } |
| 929 | 917 |
| 930 void LayerImpl::SetMasksToBounds(bool masks_to_bounds) { | 918 void LayerImpl::SetMasksToBounds(bool masks_to_bounds) { |
| 931 if (masks_to_bounds_ == masks_to_bounds) | 919 if (masks_to_bounds_ == masks_to_bounds) |
| 932 return; | 920 return; |
| 933 | 921 |
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1537 return num_descendants_that_draw_content_; | 1525 return num_descendants_that_draw_content_; |
| 1538 } | 1526 } |
| 1539 | 1527 |
| 1540 void LayerImpl::NotifyAnimationFinished( | 1528 void LayerImpl::NotifyAnimationFinished( |
| 1541 base::TimeTicks monotonic_time, | 1529 base::TimeTicks monotonic_time, |
| 1542 Animation::TargetProperty target_property) { | 1530 Animation::TargetProperty target_property) { |
| 1543 if (target_property == Animation::ScrollOffset) | 1531 if (target_property == Animation::ScrollOffset) |
| 1544 layer_tree_impl_->InputScrollAnimationFinished(); | 1532 layer_tree_impl_->InputScrollAnimationFinished(); |
| 1545 } | 1533 } |
| 1546 | 1534 |
| 1535 void LayerImpl::SetHasRenderSurface(bool should_have_render_surface) { | |
| 1536 if (!!render_surface() == should_have_render_surface) | |
| 1537 return; | |
| 1538 | |
| 1539 if (should_have_render_surface) { | |
| 1540 render_surface_ = make_scoped_ptr(new RenderSurfaceImpl(this)); | |
| 1541 return; | |
| 1542 } | |
| 1543 render_surface_.reset(); | |
| 1544 } | |
| 1545 | |
| 1547 } // namespace cc | 1546 } // namespace cc |
| OLD | NEW |