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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "cc/layer_impl.h" | 7 #include "cc/layer_impl.h" |
8 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
11 #include "cc/debug_border_draw_quad.h" | 11 #include "cc/debug_border_draw_quad.h" |
| 12 #include "cc/geometry.h" |
12 #include "cc/layer_sorter.h" | 13 #include "cc/layer_sorter.h" |
13 #include "cc/math_util.h" | 14 #include "cc/math_util.h" |
14 #include "cc/proxy.h" | 15 #include "cc/proxy.h" |
15 #include "cc/quad_sink.h" | 16 #include "cc/quad_sink.h" |
16 #include "cc/scrollbar_animation_controller.h" | 17 #include "cc/scrollbar_animation_controller.h" |
17 #include "cc/settings.h" | 18 #include "cc/settings.h" |
18 #include "third_party/skia/include/core/SkImageFilter.h" | 19 #include "third_party/skia/include/core/SkImageFilter.h" |
19 #include "ui/gfx/point_conversions.h" | 20 #include "ui/gfx/point_conversions.h" |
20 #include "ui/gfx/rect_conversions.h" | 21 #include "ui/gfx/rect_conversions.h" |
21 | 22 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 { | 173 { |
173 return RenderPass::Id(0, 0); | 174 return RenderPass::Id(0, 0); |
174 } | 175 } |
175 | 176 |
176 ResourceProvider::ResourceId LayerImpl::contentsResourceId() const | 177 ResourceProvider::ResourceId LayerImpl::contentsResourceId() const |
177 { | 178 { |
178 NOTREACHED(); | 179 NOTREACHED(); |
179 return 0; | 180 return 0; |
180 } | 181 } |
181 | 182 |
182 FloatSize LayerImpl::scrollBy(const FloatSize& scroll) | 183 gfx::Vector2dF LayerImpl::scrollBy(const gfx::Vector2dF& scroll) |
183 { | 184 { |
184 IntSize minDelta = -toSize(m_scrollPosition); | 185 gfx::Vector2dF minDelta = -m_scrollOffset; |
185 IntSize maxDelta = m_maxScrollPosition - toSize(m_scrollPosition); | 186 gfx::Vector2dF maxDelta = m_maxScrollOffset - m_scrollOffset; |
186 // Clamp newDelta so that position + delta stays within scroll bounds. | 187 // Clamp newDelta so that position + delta stays within scroll bounds. |
187 FloatSize newDelta = (m_scrollDelta + scroll).expandedTo(minDelta).shrunkTo(
maxDelta); | 188 gfx::Vector2dF newDelta = (m_scrollDelta + scroll); |
188 FloatSize unscrolled = m_scrollDelta + scroll - newDelta; | 189 newDelta = ClampFromBelow(newDelta, minDelta); |
| 190 newDelta = ClampFromAbove(newDelta, maxDelta); |
| 191 gfx::Vector2dF unscrolled = m_scrollDelta + scroll - newDelta; |
189 | 192 |
190 if (m_scrollDelta == newDelta) | 193 if (m_scrollDelta == newDelta) |
191 return unscrolled; | 194 return unscrolled; |
192 | 195 |
193 m_scrollDelta = newDelta; | 196 m_scrollDelta = newDelta; |
194 if (m_scrollbarAnimationController) | 197 if (m_scrollbarAnimationController) |
195 m_scrollbarAnimationController->updateScrollOffset(this); | 198 m_scrollbarAnimationController->updateScrollOffset(this); |
196 noteLayerPropertyChangedForSubtree(); | 199 noteLayerPropertyChangedForSubtree(); |
197 | 200 |
198 return unscrolled; | 201 return unscrolled; |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 void LayerImpl::setContentsScale(float contentsScaleX, float contentsScaleY) | 619 void LayerImpl::setContentsScale(float contentsScaleX, float contentsScaleY) |
617 { | 620 { |
618 if (m_contentsScaleX == contentsScaleX && m_contentsScaleY == contentsScaleY
) | 621 if (m_contentsScaleX == contentsScaleX && m_contentsScaleY == contentsScaleY
) |
619 return; | 622 return; |
620 | 623 |
621 m_contentsScaleX = contentsScaleX; | 624 m_contentsScaleX = contentsScaleX; |
622 m_contentsScaleY = contentsScaleY; | 625 m_contentsScaleY = contentsScaleY; |
623 m_layerPropertyChanged = true; | 626 m_layerPropertyChanged = true; |
624 } | 627 } |
625 | 628 |
626 void LayerImpl::setScrollPosition(const IntPoint& scrollPosition) | 629 void LayerImpl::setScrollOffset(gfx::Vector2d scrollOffset) |
627 { | 630 { |
628 if (m_scrollPosition == scrollPosition) | 631 if (m_scrollOffset == scrollOffset) |
629 return; | 632 return; |
630 | 633 |
631 m_scrollPosition = scrollPosition; | 634 m_scrollOffset = scrollOffset; |
632 noteLayerPropertyChangedForSubtree(); | 635 noteLayerPropertyChangedForSubtree(); |
633 } | 636 } |
634 | 637 |
635 void LayerImpl::setScrollDelta(const FloatSize& scrollDelta) | 638 void LayerImpl::setScrollDelta(const gfx::Vector2dF& scrollDelta) |
636 { | 639 { |
637 if (m_scrollDelta == scrollDelta) | 640 if (m_scrollDelta == scrollDelta) |
638 return; | 641 return; |
639 | 642 |
640 m_scrollDelta = scrollDelta; | 643 m_scrollDelta = scrollDelta; |
641 noteLayerPropertyChangedForSubtree(); | 644 noteLayerPropertyChangedForSubtree(); |
642 } | 645 } |
643 | 646 |
644 void LayerImpl::setImplTransform(const WebKit::WebTransformationMatrix& transfor
m) | 647 void LayerImpl::setImplTransform(const WebKit::WebTransformationMatrix& transfor
m) |
645 { | 648 { |
(...skipping 17 matching lines...) Expand all Loading... |
663 { | 666 { |
664 if (contentsOpaque()) | 667 if (contentsOpaque()) |
665 return visibleContentRect(); | 668 return visibleContentRect(); |
666 return Region(); | 669 return Region(); |
667 } | 670 } |
668 | 671 |
669 void LayerImpl::didLoseContext() | 672 void LayerImpl::didLoseContext() |
670 { | 673 { |
671 } | 674 } |
672 | 675 |
673 void LayerImpl::setMaxScrollPosition(const IntSize& maxScrollPosition) | 676 void LayerImpl::setMaxScrollOffset(gfx::Vector2d maxScrollOffset) |
674 { | 677 { |
675 m_maxScrollPosition = maxScrollPosition; | 678 m_maxScrollOffset = maxScrollOffset; |
676 | 679 |
677 if (!m_scrollbarAnimationController) | 680 if (!m_scrollbarAnimationController) |
678 return; | 681 return; |
679 m_scrollbarAnimationController->updateScrollOffset(this); | 682 m_scrollbarAnimationController->updateScrollOffset(this); |
680 } | 683 } |
681 | 684 |
682 ScrollbarLayerImpl* LayerImpl::horizontalScrollbarLayer() const | 685 ScrollbarLayerImpl* LayerImpl::horizontalScrollbarLayer() const |
683 { | 686 { |
684 return m_scrollbarAnimationController ? m_scrollbarAnimationController->hori
zontalScrollbarLayer() : 0; | 687 return m_scrollbarAnimationController ? m_scrollbarAnimationController->hori
zontalScrollbarLayer() : 0; |
685 } | 688 } |
(...skipping 13 matching lines...) Expand all Loading... |
699 | 702 |
700 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) | 703 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) |
701 { | 704 { |
702 if (!m_scrollbarAnimationController) | 705 if (!m_scrollbarAnimationController) |
703 m_scrollbarAnimationController = ScrollbarAnimationController::create(th
is); | 706 m_scrollbarAnimationController = ScrollbarAnimationController::create(th
is); |
704 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); | 707 m_scrollbarAnimationController->setVerticalScrollbarLayer(scrollbarLayer); |
705 m_scrollbarAnimationController->updateScrollOffset(this); | 708 m_scrollbarAnimationController->updateScrollOffset(this); |
706 } | 709 } |
707 | 710 |
708 } | 711 } |
OLD | NEW |