Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Side by Side Diff: cc/layers/layer_impl.cc

Issue 465853004: Moving RenderSurface creation outside of CalcDrawProps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated unit tests Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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),
74 current_draw_mode_(DRAW_MODE_NONE) { 73 current_draw_mode_(DRAW_MODE_NONE),
74 active_render_surface_(NULL) {
75 DCHECK_GT(layer_id_, 0); 75 DCHECK_GT(layer_id_, 0);
76 DCHECK(layer_tree_impl_); 76 DCHECK(layer_tree_impl_);
77 layer_tree_impl_->RegisterLayer(this); 77 layer_tree_impl_->RegisterLayer(this);
78 AnimationRegistrar* registrar = layer_tree_impl_->animationRegistrar(); 78 AnimationRegistrar* registrar = layer_tree_impl_->animationRegistrar();
79 layer_animation_controller_ = 79 layer_animation_controller_ =
80 registrar->GetAnimationControllerForId(layer_id_); 80 registrar->GetAnimationControllerForId(layer_id_);
81 layer_animation_controller_->AddValueObserver(this); 81 layer_animation_controller_->AddValueObserver(this);
82 if (IsActive()) { 82 if (IsActive()) {
83 layer_animation_controller_->set_value_provider(this); 83 layer_animation_controller_->set_value_provider(this);
84 layer_animation_controller_->set_layer_animation_delegate(this); 84 layer_animation_controller_->set_layer_animation_delegate(this);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
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() { 241 void LayerImpl::CreateRenderSurface() {
242 DCHECK(!draw_properties_.render_surface); 242 DCHECK(!render_surface_);
243 draw_properties_.render_surface = 243 render_surface_ = make_scoped_ptr(new RenderSurfaceImpl(this));
244 make_scoped_ptr(new RenderSurfaceImpl(this));
245 draw_properties_.render_target = this; 244 draw_properties_.render_target = this;
danakj 2014/08/26 18:06:13 Can this move to CalcDrawProps?
awoloszyn 2014/08/28 19:31:43 Done.
245 SetRenderSurfaceActive(true);
246 } 246 }
247 247
248 void LayerImpl::ClearRenderSurface() { 248 void LayerImpl::ClearRenderSurface() {
249 draw_properties_.render_surface.reset(); 249 SetRenderSurfaceActive(false);
250 render_surface_.reset();
250 } 251 }
251 252
252 void LayerImpl::ClearRenderSurfaceLayerList() { 253 void LayerImpl::ClearRenderSurfaceLayerList() {
253 if (draw_properties_.render_surface) 254 if (render_surface_)
254 draw_properties_.render_surface->layer_list().clear(); 255 render_surface_->layer_list().clear();
255 } 256 }
256 257
257 void LayerImpl::PopulateSharedQuadState(SharedQuadState* state) const { 258 void LayerImpl::PopulateSharedQuadState(SharedQuadState* state) const {
258 state->SetAll(draw_properties_.target_space_transform, 259 state->SetAll(draw_properties_.target_space_transform,
259 draw_properties_.content_bounds, 260 draw_properties_.content_bounds,
260 draw_properties_.visible_content_rect, 261 draw_properties_.visible_content_rect,
261 draw_properties_.clip_rect, 262 draw_properties_.clip_rect,
262 draw_properties_.is_clipped, 263 draw_properties_.is_clipped,
263 draw_properties_.opacity, 264 draw_properties_.opacity,
264 blend_mode_, 265 blend_mode_,
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 504
504 void LayerImpl::PushPropertiesTo(LayerImpl* layer) { 505 void LayerImpl::PushPropertiesTo(LayerImpl* layer) {
505 layer->SetTransformOrigin(transform_origin_); 506 layer->SetTransformOrigin(transform_origin_);
506 layer->SetBackgroundColor(background_color_); 507 layer->SetBackgroundColor(background_color_);
507 layer->SetBounds(bounds_); 508 layer->SetBounds(bounds_);
508 layer->SetContentBounds(content_bounds()); 509 layer->SetContentBounds(content_bounds());
509 layer->SetContentsScale(contents_scale_x(), contents_scale_y()); 510 layer->SetContentsScale(contents_scale_x(), contents_scale_y());
510 layer->SetDoubleSided(double_sided_); 511 layer->SetDoubleSided(double_sided_);
511 layer->SetDrawCheckerboardForMissingTiles( 512 layer->SetDrawCheckerboardForMissingTiles(
512 draw_checkerboard_for_missing_tiles_); 513 draw_checkerboard_for_missing_tiles_);
513 layer->SetForceRenderSurface(force_render_surface_);
514 layer->SetDrawsContent(DrawsContent()); 514 layer->SetDrawsContent(DrawsContent());
515 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); 515 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_);
516 layer->SetFilters(filters()); 516 layer->SetFilters(filters());
517 layer->SetBackgroundFilters(background_filters()); 517 layer->SetBackgroundFilters(background_filters());
518 layer->SetMasksToBounds(masks_to_bounds_); 518 layer->SetMasksToBounds(masks_to_bounds_);
519 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_); 519 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_);
520 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); 520 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_);
521 layer->SetHaveScrollEventHandlers(have_scroll_event_handlers_); 521 layer->SetHaveScrollEventHandlers(have_scroll_event_handlers_);
522 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); 522 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_);
523 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); 523 layer->SetTouchEventHandlerRegion(touch_event_handler_region_);
(...skipping 11 matching lines...) Expand all
535 535
536 layer->SetScrollClipLayer(scroll_clip_layer_ ? scroll_clip_layer_->id() 536 layer->SetScrollClipLayer(scroll_clip_layer_ ? scroll_clip_layer_->id()
537 : Layer::INVALID_ID); 537 : Layer::INVALID_ID);
538 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); 538 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_);
539 layer->set_user_scrollable_vertical(user_scrollable_vertical_); 539 layer->set_user_scrollable_vertical(user_scrollable_vertical_);
540 layer->SetScrollOffsetAndDelta( 540 layer->SetScrollOffsetAndDelta(
541 scroll_offset_, layer->ScrollDelta() - layer->sent_scroll_delta()); 541 scroll_offset_, layer->ScrollDelta() - layer->sent_scroll_delta());
542 layer->SetSentScrollDelta(gfx::Vector2d()); 542 layer->SetSentScrollDelta(gfx::Vector2d());
543 layer->Set3dSortingContextId(sorting_context_id_); 543 layer->Set3dSortingContextId(sorting_context_id_);
544 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_); 544 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_);
545 layer->SetShouldHaveRenderSurface(ShouldHaveRenderSurface());
545 546
546 LayerImpl* scroll_parent = NULL; 547 LayerImpl* scroll_parent = NULL;
547 if (scroll_parent_) { 548 if (scroll_parent_) {
548 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); 549 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id());
549 DCHECK(scroll_parent); 550 DCHECK(scroll_parent);
550 } 551 }
551 552
552 layer->SetScrollParent(scroll_parent); 553 layer->SetScrollParent(scroll_parent);
553 if (scroll_children_) { 554 if (scroll_children_) {
554 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>; 555 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 const char* LayerImpl::LayerTypeAsString() const { 712 const char* LayerImpl::LayerTypeAsString() const {
712 return "cc::LayerImpl"; 713 return "cc::LayerImpl";
713 } 714 }
714 715
715 void LayerImpl::ResetAllChangeTrackingForSubtree() { 716 void LayerImpl::ResetAllChangeTrackingForSubtree() {
716 layer_property_changed_ = false; 717 layer_property_changed_ = false;
717 718
718 update_rect_ = gfx::RectF(); 719 update_rect_ = gfx::RectF();
719 damage_rect_ = gfx::RectF(); 720 damage_rect_ = gfx::RectF();
720 721
721 if (draw_properties_.render_surface) 722 if (render_surface_)
722 draw_properties_.render_surface->ResetPropertyChangedFlag(); 723 render_surface_->ResetPropertyChangedFlag();
723 724
724 if (mask_layer_) 725 if (mask_layer_)
725 mask_layer_->ResetAllChangeTrackingForSubtree(); 726 mask_layer_->ResetAllChangeTrackingForSubtree();
726 727
727 if (replica_layer_) { 728 if (replica_layer_) {
728 // This also resets the replica mask, if it exists. 729 // This also resets the replica mask, if it exists.
729 replica_layer_->ResetAllChangeTrackingForSubtree(); 730 replica_layer_->ResetAllChangeTrackingForSubtree();
730 } 731 }
731 732
732 for (size_t i = 0; i < children_.size(); ++i) 733 for (size_t i = 0; i < children_.size(); ++i)
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after
1534 return num_descendants_that_draw_content_; 1535 return num_descendants_that_draw_content_;
1535 } 1536 }
1536 1537
1537 void LayerImpl::NotifyAnimationFinished( 1538 void LayerImpl::NotifyAnimationFinished(
1538 base::TimeTicks monotonic_time, 1539 base::TimeTicks monotonic_time,
1539 Animation::TargetProperty target_property) { 1540 Animation::TargetProperty target_property) {
1540 if (target_property == Animation::ScrollOffset) 1541 if (target_property == Animation::ScrollOffset)
1541 layer_tree_impl_->InputScrollAnimationFinished(); 1542 layer_tree_impl_->InputScrollAnimationFinished();
1542 } 1543 }
1543 1544
1545 void LayerImpl::SetRenderSurfaceActive(bool active) {
1546 if (active == !!active_render_surface_) {
1547 return;
1548 }
1549
1550 if (active) {
1551 active_render_surface_ = render_surface_.get();
danakj 2014/08/26 18:06:13 Can you explain what is going on here, why do you
awoloszyn 2014/08/28 19:31:43 This has been re-worked so that the existence of o
1552 return;
1553 }
1554 if (active_render_surface_) {
1555 active_render_surface_->ClearLayerLists();
1556 }
1557 active_render_surface_ = NULL;
1558 }
1559
1560 void LayerImpl::SetShouldHaveRenderSurface(bool should_have_render_surface) {
1561 if (ShouldHaveRenderSurface() == should_have_render_surface)
1562 return;
1563 if (should_have_render_surface) {
1564 CreateRenderSurface();
1565 return;
1566 }
1567 ClearRenderSurface();
1568 }
1569
1544 } // namespace cc 1570 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698