| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 bool LayerImpl::user_scrollable(ScrollbarOrientation orientation) const { | 485 bool LayerImpl::user_scrollable(ScrollbarOrientation orientation) const { |
| 486 return (orientation == HORIZONTAL) ? user_scrollable_horizontal_ | 486 return (orientation == HORIZONTAL) ? user_scrollable_horizontal_ |
| 487 : user_scrollable_vertical_; | 487 : user_scrollable_vertical_; |
| 488 } | 488 } |
| 489 | 489 |
| 490 void LayerImpl::ApplySentScrollDeltasFromAbortedCommit() { | 490 void LayerImpl::ApplySentScrollDeltasFromAbortedCommit() { |
| 491 DCHECK(layer_tree_impl()->IsActiveTree()); | 491 DCHECK(layer_tree_impl()->IsActiveTree()); |
| 492 scroll_offset_->AbortCommit(); | 492 scroll_offset_->AbortCommit(); |
| 493 } | 493 } |
| 494 | 494 |
| 495 InputHandler::ScrollStatus LayerImpl::TryScroll( | |
| 496 const gfx::PointF& screen_space_point, | |
| 497 InputHandler::ScrollInputType type) const { | |
| 498 InputHandler::ScrollStatus scroll_status; | |
| 499 scroll_status.main_thread_scrolling_reasons = | |
| 500 MainThreadScrollingReason::kNotScrollingOnMain; | |
| 501 if (should_scroll_on_main_thread()) { | |
| 502 TRACE_EVENT0("cc", "LayerImpl::TryScroll: Failed ShouldScrollOnMainThread"); | |
| 503 scroll_status.thread = InputHandler::SCROLL_ON_MAIN_THREAD; | |
| 504 scroll_status.main_thread_scrolling_reasons = | |
| 505 main_thread_scrolling_reasons_; | |
| 506 return scroll_status; | |
| 507 } | |
| 508 | |
| 509 gfx::Transform screen_space_transform = ScreenSpaceTransform(); | |
| 510 if (!screen_space_transform.IsInvertible()) { | |
| 511 TRACE_EVENT0("cc", "LayerImpl::TryScroll: Ignored NonInvertibleTransform"); | |
| 512 scroll_status.thread = InputHandler::SCROLL_IGNORED; | |
| 513 scroll_status.main_thread_scrolling_reasons = | |
| 514 MainThreadScrollingReason::kNonInvertibleTransform; | |
| 515 return scroll_status; | |
| 516 } | |
| 517 | |
| 518 if (!non_fast_scrollable_region().IsEmpty()) { | |
| 519 bool clipped = false; | |
| 520 gfx::Transform inverse_screen_space_transform( | |
| 521 gfx::Transform::kSkipInitialization); | |
| 522 if (!screen_space_transform.GetInverse(&inverse_screen_space_transform)) { | |
| 523 // TODO(shawnsingh): We shouldn't be applying a projection if screen space | |
| 524 // transform is uninvertible here. Perhaps we should be returning | |
| 525 // SCROLL_ON_MAIN_THREAD in this case? | |
| 526 } | |
| 527 | |
| 528 gfx::PointF hit_test_point_in_layer_space = MathUtil::ProjectPoint( | |
| 529 inverse_screen_space_transform, screen_space_point, &clipped); | |
| 530 if (!clipped && | |
| 531 non_fast_scrollable_region().Contains( | |
| 532 gfx::ToRoundedPoint(hit_test_point_in_layer_space))) { | |
| 533 TRACE_EVENT0("cc", | |
| 534 "LayerImpl::tryScroll: Failed NonFastScrollableRegion"); | |
| 535 scroll_status.thread = InputHandler::SCROLL_ON_MAIN_THREAD; | |
| 536 scroll_status.main_thread_scrolling_reasons = | |
| 537 MainThreadScrollingReason::kNonFastScrollableRegion; | |
| 538 return scroll_status; | |
| 539 } | |
| 540 } | |
| 541 | |
| 542 if (type == InputHandler::WHEEL || type == InputHandler::ANIMATED_WHEEL) { | |
| 543 EventListenerProperties event_properties = | |
| 544 layer_tree_impl_->event_listener_properties( | |
| 545 EventListenerClass::kMouseWheel); | |
| 546 if (event_properties == EventListenerProperties::kBlocking || | |
| 547 event_properties == EventListenerProperties::kBlockingAndPassive || | |
| 548 (!layer_tree_impl_->settings().use_mouse_wheel_gestures && | |
| 549 event_properties == EventListenerProperties::kPassive)) { | |
| 550 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Failed WheelEventHandlers"); | |
| 551 scroll_status.thread = InputHandler::SCROLL_ON_MAIN_THREAD; | |
| 552 scroll_status.main_thread_scrolling_reasons = | |
| 553 MainThreadScrollingReason::kEventHandlers; | |
| 554 return scroll_status; | |
| 555 } | |
| 556 } | |
| 557 | |
| 558 if (!scrollable()) { | |
| 559 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Ignored not scrollable"); | |
| 560 scroll_status.thread = InputHandler::SCROLL_IGNORED; | |
| 561 scroll_status.main_thread_scrolling_reasons = | |
| 562 MainThreadScrollingReason::kNotScrollable; | |
| 563 return scroll_status; | |
| 564 } | |
| 565 | |
| 566 gfx::ScrollOffset max_scroll_offset = MaxScrollOffset(); | |
| 567 if (max_scroll_offset.x() <= 0 && max_scroll_offset.y() <= 0) { | |
| 568 TRACE_EVENT0("cc", | |
| 569 "LayerImpl::tryScroll: Ignored. Technically scrollable," | |
| 570 " but has no affordance in either direction."); | |
| 571 scroll_status.thread = InputHandler::SCROLL_IGNORED; | |
| 572 scroll_status.main_thread_scrolling_reasons = | |
| 573 MainThreadScrollingReason::kNotScrollable; | |
| 574 return scroll_status; | |
| 575 } | |
| 576 | |
| 577 scroll_status.thread = InputHandler::SCROLL_ON_IMPL_THREAD; | |
| 578 return scroll_status; | |
| 579 } | |
| 580 | |
| 581 skia::RefPtr<SkPicture> LayerImpl::GetPicture() { | 495 skia::RefPtr<SkPicture> LayerImpl::GetPicture() { |
| 582 return skia::RefPtr<SkPicture>(); | 496 return skia::RefPtr<SkPicture>(); |
| 583 } | 497 } |
| 584 | 498 |
| 585 scoped_ptr<LayerImpl> LayerImpl::CreateLayerImpl(LayerTreeImpl* tree_impl) { | 499 scoped_ptr<LayerImpl> LayerImpl::CreateLayerImpl(LayerTreeImpl* tree_impl) { |
| 586 return LayerImpl::Create(tree_impl, layer_id_, scroll_offset_); | 500 return LayerImpl::Create(tree_impl, layer_id_, scroll_offset_); |
| 587 } | 501 } |
| 588 | 502 |
| 589 void LayerImpl::PushPropertiesTo(LayerImpl* layer) { | 503 void LayerImpl::PushPropertiesTo(LayerImpl* layer) { |
| 590 layer->SetTransformOrigin(transform_origin_); | 504 layer->SetTransformOrigin(transform_origin_); |
| (...skipping 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1872 .layer_transforms_should_scale_layer_contents) { | 1786 .layer_transforms_should_scale_layer_contents) { |
| 1873 return default_scale; | 1787 return default_scale; |
| 1874 } | 1788 } |
| 1875 | 1789 |
| 1876 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( | 1790 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( |
| 1877 DrawTransform(), default_scale); | 1791 DrawTransform(), default_scale); |
| 1878 return std::max(transform_scales.x(), transform_scales.y()); | 1792 return std::max(transform_scales.x(), transform_scales.y()); |
| 1879 } | 1793 } |
| 1880 | 1794 |
| 1881 } // namespace cc | 1795 } // namespace cc |
| OLD | NEW |