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

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: Created 6 years, 3 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),
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
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
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 801 matching lines...) Expand 10 before | Expand all | Expand 10 after
1534 return num_descendants_that_draw_content_; 1522 return num_descendants_that_draw_content_;
1535 } 1523 }
1536 1524
1537 void LayerImpl::NotifyAnimationFinished( 1525 void LayerImpl::NotifyAnimationFinished(
1538 base::TimeTicks monotonic_time, 1526 base::TimeTicks monotonic_time,
1539 Animation::TargetProperty target_property) { 1527 Animation::TargetProperty target_property) {
1540 if (target_property == Animation::ScrollOffset) 1528 if (target_property == Animation::ScrollOffset)
1541 layer_tree_impl_->InputScrollAnimationFinished(); 1529 layer_tree_impl_->InputScrollAnimationFinished();
1542 } 1530 }
1543 1531
1532 void LayerImpl::SetHasRenderSurface(bool should_have_render_surface) {
1533 if (!!render_surface() == should_have_render_surface) {
danakj 2014/09/03 19:30:33 nit: no {}
awoloszyn 2014/09/09 15:31:35 Done.
1534 return;
1535 }
1536 if (should_have_render_surface) {
1537 render_surface_ = make_scoped_ptr(new RenderSurfaceImpl(this));
1538 return;
1539 }
1540 render_surface_.reset();
1541 }
1542
1544 } // namespace cc 1543 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698