| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "cc/animation/animation_registrar.h" | 9 #include "cc/animation/animation_registrar.h" |
| 10 #include "cc/animation/scrollbar_animation_controller.h" | 10 #include "cc/animation/scrollbar_animation_controller.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 mask_layer_id_(-1), | 35 mask_layer_id_(-1), |
| 36 replica_layer_id_(-1), | 36 replica_layer_id_(-1), |
| 37 layer_id_(id), | 37 layer_id_(id), |
| 38 layer_tree_impl_(tree_impl), | 38 layer_tree_impl_(tree_impl), |
| 39 anchor_point_(0.5f, 0.5f), | 39 anchor_point_(0.5f, 0.5f), |
| 40 anchor_point_z_(0.f), | 40 anchor_point_z_(0.f), |
| 41 scroll_offset_delegate_(NULL), | 41 scroll_offset_delegate_(NULL), |
| 42 scrollable_(false), | 42 scrollable_(false), |
| 43 should_scroll_on_main_thread_(false), | 43 should_scroll_on_main_thread_(false), |
| 44 have_wheel_event_handlers_(false), | 44 have_wheel_event_handlers_(false), |
| 45 user_scrollable_horizontal_(true), |
| 46 user_scrollable_vertical_(true), |
| 45 background_color_(0), | 47 background_color_(0), |
| 46 stacking_order_changed_(false), | 48 stacking_order_changed_(false), |
| 47 double_sided_(true), | 49 double_sided_(true), |
| 48 layer_property_changed_(false), | 50 layer_property_changed_(false), |
| 49 masks_to_bounds_(false), | 51 masks_to_bounds_(false), |
| 50 contents_opaque_(false), | 52 contents_opaque_(false), |
| 51 opacity_(1.0), | 53 opacity_(1.0), |
| 52 preserves_3d_(false), | 54 preserves_3d_(false), |
| 53 use_parent_backface_visibility_(false), | 55 use_parent_backface_visibility_(false), |
| 54 draw_checkerboard_for_missing_tiles_(false), | 56 draw_checkerboard_for_missing_tiles_(false), |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 DCHECK(layer_tree_impl()->IsActiveTree()); | 336 DCHECK(layer_tree_impl()->IsActiveTree()); |
| 335 | 337 |
| 336 if (sent_scroll_delta_ == sent_scroll_delta) | 338 if (sent_scroll_delta_ == sent_scroll_delta) |
| 337 return; | 339 return; |
| 338 | 340 |
| 339 sent_scroll_delta_ = sent_scroll_delta; | 341 sent_scroll_delta_ = sent_scroll_delta; |
| 340 } | 342 } |
| 341 | 343 |
| 342 gfx::Vector2dF LayerImpl::ScrollBy(gfx::Vector2dF scroll) { | 344 gfx::Vector2dF LayerImpl::ScrollBy(gfx::Vector2dF scroll) { |
| 343 DCHECK(scrollable()); | 345 DCHECK(scrollable()); |
| 346 gfx::Vector2dF scroll_hidden; |
| 347 if (!user_scrollable_horizontal_) { |
| 348 scroll_hidden.set_x(scroll.x()); |
| 349 scroll.set_x(0.f); |
| 350 } |
| 351 if (!user_scrollable_vertical_) { |
| 352 scroll_hidden.set_y(scroll.y()); |
| 353 scroll.set_y(0.f); |
| 354 } |
| 344 | 355 |
| 345 gfx::Vector2dF min_delta = -scroll_offset_; | 356 gfx::Vector2dF min_delta = -scroll_offset_; |
| 346 gfx::Vector2dF max_delta = max_scroll_offset_ - scroll_offset_; | 357 gfx::Vector2dF max_delta = max_scroll_offset_ - scroll_offset_; |
| 347 // Clamp new_delta so that position + delta stays within scroll bounds. | 358 // Clamp new_delta so that position + delta stays within scroll bounds. |
| 348 gfx::Vector2dF new_delta = (ScrollDelta() + scroll); | 359 gfx::Vector2dF new_delta = (ScrollDelta() + scroll); |
| 349 new_delta.SetToMax(min_delta); | 360 new_delta.SetToMax(min_delta); |
| 350 new_delta.SetToMin(max_delta); | 361 new_delta.SetToMin(max_delta); |
| 351 gfx::Vector2dF unscrolled = ScrollDelta() + scroll - new_delta; | 362 gfx::Vector2dF unscrolled = |
| 363 ScrollDelta() + scroll + scroll_hidden - new_delta; |
| 352 SetScrollDelta(new_delta); | 364 SetScrollDelta(new_delta); |
| 353 return unscrolled; | 365 return unscrolled; |
| 354 } | 366 } |
| 355 | 367 |
| 356 void LayerImpl::ApplySentScrollDeltasFromAbortedCommit() { | 368 void LayerImpl::ApplySentScrollDeltasFromAbortedCommit() { |
| 357 // Pending tree never has sent scroll deltas | 369 // Pending tree never has sent scroll deltas |
| 358 DCHECK(layer_tree_impl()->IsActiveTree()); | 370 DCHECK(layer_tree_impl()->IsActiveTree()); |
| 359 | 371 |
| 360 // Apply sent scroll deltas to scroll position / scroll delta as if the | 372 // Apply sent scroll deltas to scroll position / scroll delta as if the |
| 361 // main thread had applied them and then committed those values. | 373 // main thread had applied them and then committed those values. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 return InputHandler::ScrollIgnored; | 454 return InputHandler::ScrollIgnored; |
| 443 } | 455 } |
| 444 | 456 |
| 445 if (max_scroll_offset_.x() <= 0 && max_scroll_offset_.y() <= 0) { | 457 if (max_scroll_offset_.x() <= 0 && max_scroll_offset_.y() <= 0) { |
| 446 TRACE_EVENT0("cc", | 458 TRACE_EVENT0("cc", |
| 447 "LayerImpl::tryScroll: Ignored. Technically scrollable," | 459 "LayerImpl::tryScroll: Ignored. Technically scrollable," |
| 448 " but has no affordance in either direction."); | 460 " but has no affordance in either direction."); |
| 449 return InputHandler::ScrollIgnored; | 461 return InputHandler::ScrollIgnored; |
| 450 } | 462 } |
| 451 | 463 |
| 464 if (!user_scrollable_horizontal_ && !user_scrollable_vertical_) { |
| 465 TRACE_EVENT0("cc", |
| 466 "LayerImpl::TryScroll: Ignored. User gesture is not allowed" |
| 467 " to scroll this layer."); |
| 468 return InputHandler::ScrollIgnored; |
| 469 } |
| 470 |
| 452 return InputHandler::ScrollStarted; | 471 return InputHandler::ScrollStarted; |
| 453 } | 472 } |
| 454 | 473 |
| 455 bool LayerImpl::DrawCheckerboardForMissingTiles() const { | 474 bool LayerImpl::DrawCheckerboardForMissingTiles() const { |
| 456 return draw_checkerboard_for_missing_tiles_ && | 475 return draw_checkerboard_for_missing_tiles_ && |
| 457 !layer_tree_impl()->settings().background_color_instead_of_checkerboard; | 476 !layer_tree_impl()->settings().background_color_instead_of_checkerboard; |
| 458 } | 477 } |
| 459 | 478 |
| 460 gfx::Rect LayerImpl::LayerRectToContentRect( | 479 gfx::Rect LayerImpl::LayerRectToContentRect( |
| 461 const gfx::RectF& layer_rect) const { | 480 const gfx::RectF& layer_rect) const { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 layer->SetIsContainerForFixedPositionLayers( | 526 layer->SetIsContainerForFixedPositionLayers( |
| 508 is_container_for_fixed_position_layers_); | 527 is_container_for_fixed_position_layers_); |
| 509 layer->SetFixedContainerSizeDelta(fixed_container_size_delta_); | 528 layer->SetFixedContainerSizeDelta(fixed_container_size_delta_); |
| 510 layer->SetPositionConstraint(position_constraint_); | 529 layer->SetPositionConstraint(position_constraint_); |
| 511 layer->SetPreserves3d(preserves_3d()); | 530 layer->SetPreserves3d(preserves_3d()); |
| 512 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); | 531 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); |
| 513 layer->SetSublayerTransform(sublayer_transform_); | 532 layer->SetSublayerTransform(sublayer_transform_); |
| 514 layer->SetTransform(transform_); | 533 layer->SetTransform(transform_); |
| 515 | 534 |
| 516 layer->SetScrollable(scrollable_); | 535 layer->SetScrollable(scrollable_); |
| 536 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); |
| 537 layer->set_user_scrollable_vertical(user_scrollable_vertical_); |
| 517 layer->SetScrollOffsetAndDelta( | 538 layer->SetScrollOffsetAndDelta( |
| 518 scroll_offset_, layer->ScrollDelta() - layer->sent_scroll_delta()); | 539 scroll_offset_, layer->ScrollDelta() - layer->sent_scroll_delta()); |
| 519 layer->SetSentScrollDelta(gfx::Vector2d()); | 540 layer->SetSentScrollDelta(gfx::Vector2d()); |
| 520 | 541 |
| 521 layer->SetMaxScrollOffset(max_scroll_offset_); | 542 layer->SetMaxScrollOffset(max_scroll_offset_); |
| 522 | 543 |
| 523 LayerImpl* scroll_parent = NULL; | 544 LayerImpl* scroll_parent = NULL; |
| 524 if (scroll_parent_) | 545 if (scroll_parent_) |
| 525 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); | 546 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); |
| 526 | 547 |
| (...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1305 | 1326 |
| 1306 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; } | 1327 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; } |
| 1307 | 1328 |
| 1308 scoped_ptr<base::Value> LayerImpl::AsValue() const { | 1329 scoped_ptr<base::Value> LayerImpl::AsValue() const { |
| 1309 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 1330 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
| 1310 AsValueInto(state.get()); | 1331 AsValueInto(state.get()); |
| 1311 return state.PassAs<base::Value>(); | 1332 return state.PassAs<base::Value>(); |
| 1312 } | 1333 } |
| 1313 | 1334 |
| 1314 } // namespace cc | 1335 } // namespace cc |
| OLD | NEW |