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/layer_impl.h" | 5 #include "cc/layer_impl.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "cc/animation_registrar.h" | 10 #include "cc/animation_registrar.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
49 , m_drawsContent(false) | 49 , m_drawsContent(false) |
50 , m_forceRenderSurface(false) | 50 , m_forceRenderSurface(false) |
51 , m_isContainerForFixedPositionLayers(false) | 51 , m_isContainerForFixedPositionLayers(false) |
52 , m_fixedToContainerLayer(false) | 52 , m_fixedToContainerLayer(false) |
53 , m_drawDepth(0) | 53 , m_drawDepth(0) |
54 #ifndef NDEBUG | 54 #ifndef NDEBUG |
55 , m_betweenWillDrawAndDidDraw(false) | 55 , m_betweenWillDrawAndDidDraw(false) |
56 #endif | 56 #endif |
57 , m_horizontalScrollbarLayer(0) | 57 , m_horizontalScrollbarLayer(0) |
58 , m_verticalScrollbarLayer(0) | 58 , m_verticalScrollbarLayer(0) |
59 , m_horizontalPinchZoomScrollbarLayer(0) | |
60 , m_verticalPinchZoomScrollbarLayer(0) | |
59 { | 61 { |
60 DCHECK(m_layerId > 0); | 62 DCHECK(m_layerId > 0); |
61 DCHECK(m_layerTreeImpl); | 63 DCHECK(m_layerTreeImpl); |
62 m_layerTreeImpl->RegisterLayer(this); | 64 m_layerTreeImpl->RegisterLayer(this); |
63 AnimationRegistrar* registrar = m_layerTreeImpl->animationRegistrar(); | 65 AnimationRegistrar* registrar = m_layerTreeImpl->animationRegistrar(); |
64 m_layerAnimationController = registrar->GetAnimationControllerForId(m_layerI d); | 66 m_layerAnimationController = registrar->GetAnimationControllerForId(m_layerI d); |
65 m_layerAnimationController->addObserver(this); | 67 m_layerAnimationController->addObserver(this); |
66 } | 68 } |
67 | 69 |
68 LayerImpl::~LayerImpl() | 70 LayerImpl::~LayerImpl() |
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
829 if (m_horizontalScrollbarLayer) { | 831 if (m_horizontalScrollbarLayer) { |
830 m_horizontalScrollbarLayer->setCurrentPos(currentOffset.x()); | 832 m_horizontalScrollbarLayer->setCurrentPos(currentOffset.x()); |
831 m_horizontalScrollbarLayer->setTotalSize(m_bounds.width()); | 833 m_horizontalScrollbarLayer->setTotalSize(m_bounds.width()); |
832 m_horizontalScrollbarLayer->setMaximum(m_maxScrollOffset.x()); | 834 m_horizontalScrollbarLayer->setMaximum(m_maxScrollOffset.x()); |
833 } | 835 } |
834 if (m_verticalScrollbarLayer) { | 836 if (m_verticalScrollbarLayer) { |
835 m_verticalScrollbarLayer->setCurrentPos(currentOffset.y()); | 837 m_verticalScrollbarLayer->setCurrentPos(currentOffset.y()); |
836 m_verticalScrollbarLayer->setTotalSize(m_bounds.height()); | 838 m_verticalScrollbarLayer->setTotalSize(m_bounds.height()); |
837 m_verticalScrollbarLayer->setMaximum(m_maxScrollOffset.y()); | 839 m_verticalScrollbarLayer->setMaximum(m_maxScrollOffset.y()); |
838 } | 840 } |
841 if (m_horizontalPinchZoomScrollbarLayer) { | |
842 m_horizontalPinchZoomScrollbarLayer->setCurrentPos(currentOffset.x()); | |
843 m_horizontalPinchZoomScrollbarLayer->setTotalSize(m_bounds.width()); | |
844 m_horizontalPinchZoomScrollbarLayer->setMaximum(m_maxScrollOffset.x()); | |
845 } | |
846 if (m_verticalPinchZoomScrollbarLayer) { | |
847 m_verticalPinchZoomScrollbarLayer->setCurrentPos(currentOffset.y()); | |
848 m_verticalPinchZoomScrollbarLayer->setTotalSize(m_bounds.height()); | |
849 m_verticalPinchZoomScrollbarLayer->setMaximum(m_maxScrollOffset.y()); | |
850 } | |
839 | 851 |
840 if (currentOffset == m_lastScrollOffset) | 852 if (currentOffset == m_lastScrollOffset) |
841 return; | 853 return; |
842 m_lastScrollOffset = currentOffset; | 854 m_lastScrollOffset = currentOffset; |
843 | 855 |
844 if (m_scrollbarAnimationController) | 856 if (m_scrollbarAnimationController) |
845 m_scrollbarAnimationController->didUpdateScrollOffset(base::TimeTicks::N ow()); | 857 m_scrollbarAnimationController->didUpdateScrollOffset(base::TimeTicks::N ow()); |
846 | 858 |
847 // Get the m_currentOffset.y() value for a sanity-check on scrolling | 859 // Get the m_currentOffset.y() value for a sanity-check on scrolling |
848 // benchmark metrics. Specifically, we want to make sure | 860 // benchmark metrics. Specifically, we want to make sure |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
882 } | 894 } |
883 | 895 |
884 m_scrollDelta = scrollDelta; | 896 m_scrollDelta = scrollDelta; |
885 noteLayerPropertyChangedForSubtree(); | 897 noteLayerPropertyChangedForSubtree(); |
886 | 898 |
887 updateScrollbarPositions(); | 899 updateScrollbarPositions(); |
888 } | 900 } |
889 | 901 |
890 void LayerImpl::setImplTransform(const gfx::Transform& transform) | 902 void LayerImpl::setImplTransform(const gfx::Transform& transform) |
891 { | 903 { |
892 if (m_implTransform == transform) | 904 // TODO(wjmaclean) - do not commit the changes in this function |
905 // yet! I've included them in this patch to show the eventual | |
906 // mechanism I propose for mainframe scrollbar scaling, | |
907 // but the transforms cannot be finalized until the | |
908 // desktop compatibility viewport lands. | |
909 | |
910 // We should never have just one pinch-zoom scrollbar. | |
911 DCHECK((m_horizontalPinchZoomScrollbarLayer && m_verticalPinchZoomScrollbarL ayer) || | |
912 (!m_horizontalPinchZoomScrollbarLayer && !m_verticalPinchZoomScrollba rLayer)); | |
913 | |
914 bool hasPinchZoomScrollbars = m_horizontalPinchZoomScrollbarLayer && m_verti calPinchZoomScrollbarLayer; | |
915 | |
916 if (!hasPinchZoomScrollbars && (m_implTransform == transform)) | |
893 return; | 917 return; |
894 | 918 |
895 m_implTransform = transform; | 919 bool redirectedToClipLayer = false; |
896 noteLayerPropertyChangedForSubtree(); | 920 if (hasPinchZoomScrollbars) { |
921 gfx::Transform scrollbarTransformHorizontal(transform); | |
922 // TODO(wjmaclean) This is the wrong translation, need to | |
923 // know the offset of the desktop compatibility viewport. | |
aelias_OOO_until_Jul13
2013/02/06 19:02:45
I gather you're trying to make the scrollbars visi
| |
924 scrollbarTransformHorizontal.Translate(0, -layerTreeImpl()->device_scale _factor() * scrollOffset().y()); | |
925 if (m_horizontalScrollbarLayer) | |
926 m_horizontalScrollbarLayer->setImplTransform(scrollbarTransformHoriz ontal); | |
927 | |
928 gfx::Transform scrollbarTransformVertical(transform); | |
929 // TODO(wjmaclean) Same comment as above. | |
930 scrollbarTransformVertical.Translate(-layerTreeImpl()->device_scale_fact or() * scrollOffset().x(), 0); | |
931 if (m_verticalScrollbarLayer) | |
932 m_verticalScrollbarLayer->setImplTransform(scrollbarTransformVertica l); | |
933 // If we're using pinch-zoom scrollbars, we don't want them | |
934 // clipped to the untransformed bounds, so we re-direct | |
935 // the implTransform to the clip layer instead. | |
936 if (parent()) { | |
937 parent()->setImplTransform(transform); | |
938 redirectedToClipLayer = true; | |
939 } | |
940 } | |
941 | |
942 if (!redirectedToClipLayer && m_implTransform != transform) { | |
943 m_implTransform = transform; | |
944 noteLayerPropertyChangedForSubtree(); | |
945 } | |
897 } | 946 } |
898 | 947 |
899 void LayerImpl::setDoubleSided(bool doubleSided) | 948 void LayerImpl::setDoubleSided(bool doubleSided) |
900 { | 949 { |
901 if (m_doubleSided == doubleSided) | 950 if (m_doubleSided == doubleSided) |
902 return; | 951 return; |
903 | 952 |
904 m_doubleSided = doubleSided; | 953 m_doubleSided = doubleSided; |
905 noteLayerPropertyChangedForSubtree(); | 954 noteLayerPropertyChangedForSubtree(); |
906 } | 955 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
962 m_horizontalScrollbarLayer->setScrollLayerId(id()); | 1011 m_horizontalScrollbarLayer->setScrollLayerId(id()); |
963 } | 1012 } |
964 | 1013 |
965 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) | 1014 void LayerImpl::setVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbarLayer) |
966 { | 1015 { |
967 m_verticalScrollbarLayer = scrollbarLayer; | 1016 m_verticalScrollbarLayer = scrollbarLayer; |
968 if (m_verticalScrollbarLayer) | 1017 if (m_verticalScrollbarLayer) |
969 m_verticalScrollbarLayer->setScrollLayerId(id()); | 1018 m_verticalScrollbarLayer->setScrollLayerId(id()); |
970 } | 1019 } |
971 | 1020 |
1021 void LayerImpl::setHorizontalPinchZoomScrollbarLayer(ScrollbarLayerImpl* scrollb arLayer) | |
1022 { | |
1023 m_horizontalPinchZoomScrollbarLayer = scrollbarLayer; | |
1024 } | |
1025 | |
1026 void LayerImpl::setVerticalPinchZoomScrollbarLayer(ScrollbarLayerImpl* scrollbar Layer) | |
1027 { | |
1028 m_verticalPinchZoomScrollbarLayer = scrollbarLayer; | |
1029 } | |
1030 | |
972 } // namespace cc | 1031 } // namespace cc |
OLD | NEW |