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

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

Issue 862133002: Update from https://crrev.com/312398 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 clear_scroll_delta_at_activation_(false),
63 transform_is_invertible_(true), 64 transform_is_invertible_(true),
64 is_container_for_fixed_position_layers_(false), 65 is_container_for_fixed_position_layers_(false),
65 background_color_(0), 66 background_color_(0),
66 opacity_(1.0), 67 opacity_(1.0),
67 blend_mode_(SkXfermode::kSrcOver_Mode), 68 blend_mode_(SkXfermode::kSrcOver_Mode),
68 num_descendants_that_draw_content_(0), 69 num_descendants_that_draw_content_(0),
69 draw_depth_(0.f), 70 draw_depth_(0.f),
70 needs_push_properties_(false), 71 needs_push_properties_(false),
71 num_dependents_need_push_properties_(0), 72 num_dependents_need_push_properties_(0),
72 sorting_context_id_(0), 73 sorting_context_id_(0),
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 void LayerImpl::SetSentScrollDelta(const gfx::Vector2dF& sent_scroll_delta) { 350 void LayerImpl::SetSentScrollDelta(const gfx::Vector2dF& sent_scroll_delta) {
350 // Pending tree never has sent scroll deltas 351 // Pending tree never has sent scroll deltas
351 DCHECK(layer_tree_impl()->IsActiveTree()); 352 DCHECK(layer_tree_impl()->IsActiveTree());
352 353
353 if (sent_scroll_delta_ == sent_scroll_delta) 354 if (sent_scroll_delta_ == sent_scroll_delta)
354 return; 355 return;
355 356
356 sent_scroll_delta_ = sent_scroll_delta; 357 sent_scroll_delta_ = sent_scroll_delta;
357 } 358 }
358 359
360 void LayerImpl::ClearScrollDeltaAtActivation() {
361 clear_scroll_delta_at_activation_ = true;
362 }
363
359 gfx::Vector2dF LayerImpl::ScrollBy(const gfx::Vector2dF& scroll) { 364 gfx::Vector2dF LayerImpl::ScrollBy(const gfx::Vector2dF& scroll) {
360 gfx::Vector2dF adjusted_scroll = scroll; 365 gfx::Vector2dF adjusted_scroll = scroll;
361 if (layer_tree_impl()->settings().use_pinch_virtual_viewport) { 366 if (layer_tree_impl()->settings().use_pinch_virtual_viewport) {
362 if (!user_scrollable_horizontal_) 367 if (!user_scrollable_horizontal_)
363 adjusted_scroll.set_x(0); 368 adjusted_scroll.set_x(0);
364 if (!user_scrollable_vertical_) 369 if (!user_scrollable_vertical_)
365 adjusted_scroll.set_y(0); 370 adjusted_scroll.set_y(0);
366 } 371 }
367 DCHECK(scrollable()); 372 DCHECK(scrollable());
368 gfx::Vector2dF min_delta = -ScrollOffsetToVector2dF(scroll_offset_); 373 gfx::Vector2dF min_delta = -ScrollOffsetToVector2dF(scroll_offset_);
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 layer->SetTransformAndInvertibility(transform_, transform_is_invertible_); 542 layer->SetTransformAndInvertibility(transform_, transform_is_invertible_);
538 543
539 layer->SetScrollClipLayer(scroll_clip_layer_ ? scroll_clip_layer_->id() 544 layer->SetScrollClipLayer(scroll_clip_layer_ ? scroll_clip_layer_->id()
540 : Layer::INVALID_ID); 545 : Layer::INVALID_ID);
541 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); 546 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_);
542 layer->set_user_scrollable_vertical(user_scrollable_vertical_); 547 layer->set_user_scrollable_vertical(user_scrollable_vertical_);
543 548
544 // Save the difference but clear the sent delta so that we don't subtract 549 // Save the difference but clear the sent delta so that we don't subtract
545 // it again in SetScrollOffsetAndDelta's pending twin mirroring logic. 550 // it again in SetScrollOffsetAndDelta's pending twin mirroring logic.
546 gfx::Vector2dF remaining_delta = 551 gfx::Vector2dF remaining_delta =
547 layer->ScrollDelta() - layer->sent_scroll_delta(); 552 clear_scroll_delta_at_activation_
553 ? gfx::Vector2dF()
554 : layer->ScrollDelta() - layer->sent_scroll_delta();
555 clear_scroll_delta_at_activation_ = false;
556
548 layer->SetSentScrollDelta(gfx::Vector2dF()); 557 layer->SetSentScrollDelta(gfx::Vector2dF());
549 layer->SetScrollOffsetAndDelta(scroll_offset_, remaining_delta); 558 layer->SetScrollOffsetAndDelta(scroll_offset_, remaining_delta);
550 559
551 layer->Set3dSortingContextId(sorting_context_id_); 560 layer->Set3dSortingContextId(sorting_context_id_);
552 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_); 561 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_);
553 562
554 LayerImpl* scroll_parent = nullptr; 563 LayerImpl* scroll_parent = nullptr;
555 if (scroll_parent_) { 564 if (scroll_parent_) {
556 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); 565 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id());
557 DCHECK(scroll_parent); 566 DCHECK(scroll_parent);
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 if (!IsActive()) 784 if (!IsActive())
776 return; 785 return;
777 786
778 SetScrollDelta(scroll_offset.DeltaFrom(scroll_offset_)); 787 SetScrollDelta(scroll_offset.DeltaFrom(scroll_offset_));
779 788
780 layer_tree_impl_->DidAnimateScrollOffset(); 789 layer_tree_impl_->DidAnimateScrollOffset();
781 } 790 }
782 791
783 void LayerImpl::OnAnimationWaitingForDeletion() {} 792 void LayerImpl::OnAnimationWaitingForDeletion() {}
784 793
794 void LayerImpl::OnScrollOffsetAnimationRemoved() {
795 }
796
785 bool LayerImpl::IsActive() const { 797 bool LayerImpl::IsActive() const {
786 return layer_tree_impl_->IsActiveTree(); 798 return layer_tree_impl_->IsActiveTree();
787 } 799 }
788 800
789 gfx::Size LayerImpl::bounds() const { 801 gfx::Size LayerImpl::bounds() const {
790 gfx::Vector2d delta = gfx::ToCeiledVector2d(bounds_delta_); 802 gfx::Vector2d delta = gfx::ToCeiledVector2d(bounds_delta_);
791 return gfx::Size(bounds_.width() + delta.x(), 803 return gfx::Size(bounds_.width() + delta.x(),
792 bounds_.height() + delta.y()); 804 bounds_.height() + delta.y());
793 } 805 }
794 806
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 1167
1156 gfx::Vector2dF LayerImpl::ScrollDelta() const { 1168 gfx::Vector2dF LayerImpl::ScrollDelta() const {
1157 if (scroll_offset_delegate_) { 1169 if (scroll_offset_delegate_) {
1158 return scroll_offset_delegate_->GetTotalScrollOffset().DeltaFrom( 1170 return scroll_offset_delegate_->GetTotalScrollOffset().DeltaFrom(
1159 scroll_offset_); 1171 scroll_offset_);
1160 } 1172 }
1161 return scroll_delta_; 1173 return scroll_delta_;
1162 } 1174 }
1163 1175
1164 void LayerImpl::SetScrollDelta(const gfx::Vector2dF& scroll_delta) { 1176 void LayerImpl::SetScrollDelta(const gfx::Vector2dF& scroll_delta) {
1177 if (!IsActive() && clear_scroll_delta_at_activation_)
1178 return;
1165 SetScrollOffsetAndDelta(scroll_offset_, scroll_delta); 1179 SetScrollOffsetAndDelta(scroll_offset_, scroll_delta);
1166 } 1180 }
1167 1181
1168 gfx::ScrollOffset LayerImpl::TotalScrollOffset() const { 1182 gfx::ScrollOffset LayerImpl::TotalScrollOffset() const {
1169 return ScrollOffsetWithDelta(scroll_offset_, ScrollDelta()); 1183 return ScrollOffsetWithDelta(scroll_offset_, ScrollDelta());
1170 } 1184 }
1171 1185
1172 void LayerImpl::SetDoubleSided(bool double_sided) { 1186 void LayerImpl::SetDoubleSided(bool double_sided) {
1173 if (double_sided_ == double_sided) 1187 if (double_sided_ == double_sided)
1174 return; 1188 return;
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1445 } 1459 }
1446 1460
1447 void LayerImpl::AsValueInto(base::debug::TracedValue* state) const { 1461 void LayerImpl::AsValueInto(base::debug::TracedValue* state) const {
1448 TracedValue::MakeDictIntoImplicitSnapshotWithCategory( 1462 TracedValue::MakeDictIntoImplicitSnapshotWithCategory(
1449 TRACE_DISABLED_BY_DEFAULT("cc.debug"), 1463 TRACE_DISABLED_BY_DEFAULT("cc.debug"),
1450 state, 1464 state,
1451 "cc::LayerImpl", 1465 "cc::LayerImpl",
1452 LayerTypeAsString(), 1466 LayerTypeAsString(),
1453 this); 1467 this);
1454 state->SetInteger("layer_id", id()); 1468 state->SetInteger("layer_id", id());
1455 state->BeginDictionary("bounds"); 1469 MathUtil::AddToTracedValue("bounds", bounds_, state);
1456 MathUtil::AddToTracedValue(bounds_, state);
1457 state->EndDictionary();
1458 1470
1459 state->SetDouble("opacity", opacity()); 1471 state->SetDouble("opacity", opacity());
1460 1472
1461 state->BeginArray("position"); 1473 MathUtil::AddToTracedValue("position", position_, state);
1462 MathUtil::AddToTracedValue(position_, state);
1463 state->EndArray();
1464 1474
1465 state->SetInteger("draws_content", DrawsContent()); 1475 state->SetInteger("draws_content", DrawsContent());
1466 state->SetInteger("gpu_memory_usage", GPUMemoryUsageInBytes()); 1476 state->SetInteger("gpu_memory_usage", GPUMemoryUsageInBytes());
1467 1477
1468 state->BeginArray("scroll_offset"); 1478 MathUtil::AddToTracedValue("scroll_offset", scroll_offset_, state);
1469 MathUtil::AddToTracedValue(scroll_offset_, state); 1479 MathUtil::AddToTracedValue("transform_origin", transform_origin_, state);
1470 state->EndArray();
1471
1472 state->BeginArray("transform_origin");
1473 MathUtil::AddToTracedValue(transform_origin_, state);
1474 state->EndArray();
1475 1480
1476 bool clipped; 1481 bool clipped;
1477 gfx::QuadF layer_quad = MathUtil::MapQuad( 1482 gfx::QuadF layer_quad = MathUtil::MapQuad(
1478 screen_space_transform(), 1483 screen_space_transform(),
1479 gfx::QuadF(gfx::Rect(content_bounds())), 1484 gfx::QuadF(gfx::Rect(content_bounds())),
1480 &clipped); 1485 &clipped);
1481 state->BeginArray("layer_quad"); 1486 MathUtil::AddToTracedValue("layer_quad", layer_quad, state);
1482 MathUtil::AddToTracedValue(layer_quad, state);
1483 state->EndArray();
1484 if (!touch_event_handler_region_.IsEmpty()) { 1487 if (!touch_event_handler_region_.IsEmpty()) {
1485 state->BeginArray("touch_event_handler_region"); 1488 state->BeginArray("touch_event_handler_region");
1486 touch_event_handler_region_.AsValueInto(state); 1489 touch_event_handler_region_.AsValueInto(state);
1487 state->EndArray(); 1490 state->EndArray();
1488 } 1491 }
1489 if (have_wheel_event_handlers_) { 1492 if (have_wheel_event_handlers_) {
1490 gfx::Rect wheel_rect(content_bounds()); 1493 gfx::Rect wheel_rect(content_bounds());
1491 Region wheel_region(wheel_rect); 1494 Region wheel_region(wheel_rect);
1492 state->BeginArray("wheel_event_handler_region"); 1495 state->BeginArray("wheel_event_handler_region");
1493 wheel_region.AsValueInto(state); 1496 wheel_region.AsValueInto(state);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1531 state->SetInteger("clip_parent", clip_parent_->id()); 1534 state->SetInteger("clip_parent", clip_parent_->id());
1532 1535
1533 state->SetBoolean("can_use_lcd_text", can_use_lcd_text()); 1536 state->SetBoolean("can_use_lcd_text", can_use_lcd_text());
1534 state->SetBoolean("contents_opaque", contents_opaque()); 1537 state->SetBoolean("contents_opaque", contents_opaque());
1535 1538
1536 state->SetBoolean( 1539 state->SetBoolean(
1537 "has_animation_bounds", 1540 "has_animation_bounds",
1538 layer_animation_controller()->HasAnimationThatInflatesBounds()); 1541 layer_animation_controller()->HasAnimationThatInflatesBounds());
1539 1542
1540 gfx::BoxF box; 1543 gfx::BoxF box;
1541 if (LayerUtils::GetAnimationBounds(*this, &box)) { 1544 if (LayerUtils::GetAnimationBounds(*this, &box))
1542 state->BeginArray("animation_bounds"); 1545 MathUtil::AddToTracedValue("animation_bounds", box, state);
1543 MathUtil::AddToTracedValue(box, state);
1544 state->EndArray();
1545 }
1546 1546
1547 if (debug_info_.get()) { 1547 if (debug_info_.get()) {
1548 std::string str; 1548 std::string str;
1549 debug_info_->AppendAsTraceFormat(&str); 1549 debug_info_->AppendAsTraceFormat(&str);
1550 base::JSONReader json_reader; 1550 base::JSONReader json_reader;
1551 scoped_ptr<base::Value> debug_info_value(json_reader.ReadToValue(str)); 1551 scoped_ptr<base::Value> debug_info_value(json_reader.ReadToValue(str));
1552 1552
1553 if (debug_info_value->IsType(base::Value::TYPE_DICTIONARY)) { 1553 if (debug_info_value->IsType(base::Value::TYPE_DICTIONARY)) {
1554 base::DictionaryValue* dictionary_value = nullptr; 1554 base::DictionaryValue* dictionary_value = nullptr;
1555 bool converted_to_dictionary = 1555 bool converted_to_dictionary =
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1595 SetNeedsPushProperties(); 1595 SetNeedsPushProperties();
1596 layer_tree_impl()->set_needs_update_draw_properties(); 1596 layer_tree_impl()->set_needs_update_draw_properties();
1597 if (should_have_render_surface) { 1597 if (should_have_render_surface) {
1598 render_surface_ = make_scoped_ptr(new RenderSurfaceImpl(this)); 1598 render_surface_ = make_scoped_ptr(new RenderSurfaceImpl(this));
1599 return; 1599 return;
1600 } 1600 }
1601 render_surface_.reset(); 1601 render_surface_.reset();
1602 } 1602 }
1603 1603
1604 } // namespace cc 1604 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.h ('k') | cc/layers/painted_scrollbar_layer_impl.h » ('j') | shell/BUILD.gn » ('J')

Powered by Google App Engine
This is Rietveld 408576698