| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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()) |
| 206 return; | 205 return; |
| 207 | 206 DCHECK(render_surface()); |
| 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()); |
| 220 DCHECK(layer_tree_impl()->IsActiveTree()); | 219 DCHECK(layer_tree_impl()->IsActiveTree()); |
| 220 DCHECK_EQ(render_target(), this); |
| 221 | 221 |
| 222 size_t first_inserted_request = requests->size(); | 222 size_t first_inserted_request = requests->size(); |
| 223 requests->insert_and_take(requests->end(), ©_requests_); | 223 requests->insert_and_take(requests->end(), ©_requests_); |
| 224 copy_requests_.clear(); | 224 copy_requests_.clear(); |
| 225 | 225 |
| 226 for (size_t i = first_inserted_request; i < requests->size(); ++i) { | 226 for (size_t i = first_inserted_request; i < requests->size(); ++i) { |
| 227 CopyOutputRequest* request = requests->at(i); | 227 CopyOutputRequest* request = requests->at(i); |
| 228 if (!request->has_area()) | 228 if (!request->has_area()) |
| 229 continue; | 229 continue; |
| 230 | 230 |
| 231 gfx::Rect request_in_layer_space = request->area(); | 231 gfx::Rect request_in_layer_space = request->area(); |
| 232 gfx::Rect request_in_content_space = | 232 gfx::Rect request_in_content_space = |
| 233 LayerRectToContentRect(request_in_layer_space); | 233 LayerRectToContentRect(request_in_layer_space); |
| 234 request->set_area(MathUtil::MapEnclosingClippedRect( | 234 request->set_area(MathUtil::MapEnclosingClippedRect( |
| 235 draw_properties_.target_space_transform, request_in_content_space)); | 235 draw_properties_.target_space_transform, request_in_content_space)); |
| 236 } | 236 } |
| 237 | 237 |
| 238 layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this); | 238 layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this); |
| 239 } | 239 } |
| 240 | 240 |
| 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 = nullptr; | |
| 250 } | |
| 251 | |
| 252 void LayerImpl::ClearRenderSurfaceLayerList() { | 241 void LayerImpl::ClearRenderSurfaceLayerList() { |
| 253 if (draw_properties_.render_surface) | 242 if (render_surface_) |
| 254 draw_properties_.render_surface->layer_list().clear(); | 243 render_surface_->ClearLayerLists(); |
| 255 } | 244 } |
| 256 | 245 |
| 257 void LayerImpl::PopulateSharedQuadState(SharedQuadState* state) const { | 246 void LayerImpl::PopulateSharedQuadState(SharedQuadState* state) const { |
| 258 state->SetAll( | 247 state->SetAll( |
| 259 draw_properties_.target_space_transform, draw_properties_.content_bounds, | 248 draw_properties_.target_space_transform, draw_properties_.content_bounds, |
| 260 draw_properties_.visible_content_rect, draw_properties_.clip_rect, | 249 draw_properties_.visible_content_rect, draw_properties_.clip_rect, |
| 261 draw_properties_.is_clipped, draw_properties_.opacity, | 250 draw_properties_.is_clipped, draw_properties_.opacity, |
| 262 draw_properties_.blend_mode, sorting_context_id_); | 251 draw_properties_.blend_mode, sorting_context_id_); |
| 263 } | 252 } |
| 264 | 253 |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 | 501 |
| 513 void LayerImpl::PushPropertiesTo(LayerImpl* layer) { | 502 void LayerImpl::PushPropertiesTo(LayerImpl* layer) { |
| 514 layer->SetTransformOrigin(transform_origin_); | 503 layer->SetTransformOrigin(transform_origin_); |
| 515 layer->SetBackgroundColor(background_color_); | 504 layer->SetBackgroundColor(background_color_); |
| 516 layer->SetBounds(bounds_); | 505 layer->SetBounds(bounds_); |
| 517 layer->SetContentBounds(content_bounds()); | 506 layer->SetContentBounds(content_bounds()); |
| 518 layer->SetContentsScale(contents_scale_x(), contents_scale_y()); | 507 layer->SetContentsScale(contents_scale_x(), contents_scale_y()); |
| 519 layer->SetDoubleSided(double_sided_); | 508 layer->SetDoubleSided(double_sided_); |
| 520 layer->SetDrawCheckerboardForMissingTiles( | 509 layer->SetDrawCheckerboardForMissingTiles( |
| 521 draw_checkerboard_for_missing_tiles_); | 510 draw_checkerboard_for_missing_tiles_); |
| 522 layer->SetForceRenderSurface(force_render_surface_); | |
| 523 layer->SetDrawsContent(DrawsContent()); | 511 layer->SetDrawsContent(DrawsContent()); |
| 524 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); | 512 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); |
| 513 layer->SetHasRenderSurface(!!render_surface()); |
| 525 layer->SetFilters(filters()); | 514 layer->SetFilters(filters()); |
| 526 layer->SetBackgroundFilters(background_filters()); | 515 layer->SetBackgroundFilters(background_filters()); |
| 527 layer->SetMasksToBounds(masks_to_bounds_); | 516 layer->SetMasksToBounds(masks_to_bounds_); |
| 528 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_); | 517 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_); |
| 529 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); | 518 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); |
| 530 layer->SetHaveScrollEventHandlers(have_scroll_event_handlers_); | 519 layer->SetHaveScrollEventHandlers(have_scroll_event_handlers_); |
| 531 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); | 520 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); |
| 532 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); | 521 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); |
| 533 layer->SetContentsOpaque(contents_opaque_); | 522 layer->SetContentsOpaque(contents_opaque_); |
| 534 layer->SetOpacity(opacity_); | 523 layer->SetOpacity(opacity_); |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 const char* LayerImpl::LayerTypeAsString() const { | 722 const char* LayerImpl::LayerTypeAsString() const { |
| 734 return "cc::LayerImpl"; | 723 return "cc::LayerImpl"; |
| 735 } | 724 } |
| 736 | 725 |
| 737 void LayerImpl::ResetAllChangeTrackingForSubtree() { | 726 void LayerImpl::ResetAllChangeTrackingForSubtree() { |
| 738 layer_property_changed_ = false; | 727 layer_property_changed_ = false; |
| 739 | 728 |
| 740 update_rect_ = gfx::Rect(); | 729 update_rect_ = gfx::Rect(); |
| 741 damage_rect_ = gfx::RectF(); | 730 damage_rect_ = gfx::RectF(); |
| 742 | 731 |
| 743 if (draw_properties_.render_surface) | 732 if (render_surface_) |
| 744 draw_properties_.render_surface->ResetPropertyChangedFlag(); | 733 render_surface_->ResetPropertyChangedFlag(); |
| 745 | 734 |
| 746 if (mask_layer_) | 735 if (mask_layer_) |
| 747 mask_layer_->ResetAllChangeTrackingForSubtree(); | 736 mask_layer_->ResetAllChangeTrackingForSubtree(); |
| 748 | 737 |
| 749 if (replica_layer_) { | 738 if (replica_layer_) { |
| 750 // This also resets the replica mask, if it exists. | 739 // This also resets the replica mask, if it exists. |
| 751 replica_layer_->ResetAllChangeTrackingForSubtree(); | 740 replica_layer_->ResetAllChangeTrackingForSubtree(); |
| 752 } | 741 } |
| 753 | 742 |
| 754 for (size_t i = 0; i < children_.size(); ++i) | 743 for (size_t i = 0; i < children_.size(); ++i) |
| (...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1587 } | 1576 } |
| 1588 | 1577 |
| 1589 void LayerImpl::NotifyAnimationFinished( | 1578 void LayerImpl::NotifyAnimationFinished( |
| 1590 base::TimeTicks monotonic_time, | 1579 base::TimeTicks monotonic_time, |
| 1591 Animation::TargetProperty target_property, | 1580 Animation::TargetProperty target_property, |
| 1592 int group) { | 1581 int group) { |
| 1593 if (target_property == Animation::ScrollOffset) | 1582 if (target_property == Animation::ScrollOffset) |
| 1594 layer_tree_impl_->InputScrollAnimationFinished(); | 1583 layer_tree_impl_->InputScrollAnimationFinished(); |
| 1595 } | 1584 } |
| 1596 | 1585 |
| 1586 void LayerImpl::SetHasRenderSurface(bool should_have_render_surface) { |
| 1587 if (!!render_surface() == should_have_render_surface) |
| 1588 return; |
| 1589 |
| 1590 SetNeedsPushProperties(); |
| 1591 layer_tree_impl()->set_needs_update_draw_properties(); |
| 1592 if (should_have_render_surface) { |
| 1593 render_surface_ = make_scoped_ptr(new RenderSurfaceImpl(this)); |
| 1594 return; |
| 1595 } |
| 1596 render_surface_.reset(); |
| 1597 } |
| 1598 |
| 1597 } // namespace cc | 1599 } // namespace cc |
| OLD | NEW |