OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 package org.chromium.chrome.browser.compositor.layouts.phone; | 5 package org.chromium.chrome.browser.compositor.layouts.phone; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.graphics.Rect; | 8 import android.graphics.Rect; |
9 import android.graphics.RectF; | 9 import android.graphics.RectF; |
10 import android.os.SystemClock; | 10 import android.os.SystemClock; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 private static final float SWITCH_STACK_FLING_DT = 1.0f / 30.0f; | 75 private static final float SWITCH_STACK_FLING_DT = 1.0f / 30.0f; |
76 | 76 |
77 /** The array of potentially visible stacks. The code works for only 2 stack
s. */ | 77 /** The array of potentially visible stacks. The code works for only 2 stack
s. */ |
78 private final Stack[] mStacks; | 78 private final Stack[] mStacks; |
79 | 79 |
80 /** Rectangles that defines the area where each stack need to be laid out. *
/ | 80 /** Rectangles that defines the area where each stack need to be laid out. *
/ |
81 private final RectF[] mStackRects; | 81 private final RectF[] mStackRects; |
82 | 82 |
83 private int mStackAnimationCount; | 83 private int mStackAnimationCount; |
84 | 84 |
85 private float mFlingSpeed = 0; // pixel/ms | 85 private float mFlingSpeed; // pixel/ms |
86 | 86 |
87 /** Whether the current fling animation is the result of switching stacks. *
/ | 87 /** Whether the current fling animation is the result of switching stacks. *
/ |
88 private boolean mFlingFromModelChange; | 88 private boolean mFlingFromModelChange; |
89 | 89 |
90 private boolean mClicked; | 90 private boolean mClicked; |
91 | 91 |
92 // If not overscroll, then mRenderedScrollIndex == mScrollIndex; | 92 // If not overscroll, then mRenderedScrollIndex == mScrollIndex; |
93 // Otherwise, mRenderedScrollIndex is updated with the actual index passed i
n | 93 // Otherwise, mRenderedScrollIndex is updated with the actual index passed i
n |
94 // from the event handler; and mRenderedScrollIndex is the value we get | 94 // from the event handler; and mRenderedScrollIndex is the value we get |
95 // after map mScrollIndex through a decelerate function. | 95 // after map mScrollIndex through a decelerate function. |
96 // Here we use float as index so we can smoothly animate the transition betw
een stack. | 96 // Here we use float as index so we can smoothly animate the transition betw
een stack. |
97 private float mRenderedScrollOffset = 0.0f; | 97 private float mRenderedScrollOffset; |
98 private float mScrollIndexOffset = 0.0f; | 98 private float mScrollIndexOffset; |
99 | 99 |
100 private final int mMinMaxInnerMargin; | 100 private final int mMinMaxInnerMargin; |
101 private float mInnerMarginPercent; | 101 private float mInnerMarginPercent; |
102 private float mStackOffsetYPercent; | 102 private float mStackOffsetYPercent; |
103 | 103 |
104 private SwipeMode mInputMode = SwipeMode.NONE; | 104 private SwipeMode mInputMode = SwipeMode.NONE; |
105 private float mLastOnDownX; | 105 private float mLastOnDownX; |
106 private float mLastOnDownY; | 106 private float mLastOnDownY; |
107 private long mLastOnDownTimeStamp; | 107 private long mLastOnDownTimeStamp; |
108 private final float mMinShortPressThresholdSqr; // Computed from Android Vie
wConfiguration | 108 private final float mMinShortPressThresholdSqr; // Computed from Android Vie
wConfiguration |
109 private final float mMinDirectionThreshold; // Computed from Android ViewCon
figuration | 109 private final float mMinDirectionThreshold; // Computed from Android ViewCon
figuration |
110 | 110 |
111 // Pre-allocated temporary arrays that store id of visible tabs. | 111 // Pre-allocated temporary arrays that store id of visible tabs. |
112 // They can be used to call populatePriorityVisibilityList. | 112 // They can be used to call populatePriorityVisibilityList. |
113 // We use StackTab[] instead of ArrayList<StackTab> because the sorting func
tion does | 113 // We use StackTab[] instead of ArrayList<StackTab> because the sorting func
tion does |
114 // an allocation to iterate over the elements. | 114 // an allocation to iterate over the elements. |
115 // Do not use out of the context of {@link #updateTabPriority}. | 115 // Do not use out of the context of {@link #updateTabPriority}. |
116 private StackTab[] mSortedPriorityArray = null; | 116 private StackTab[] mSortedPriorityArray; |
117 | 117 |
118 private final ArrayList<Integer> mVisibilityArray = new ArrayList<Integer>()
; | 118 private final ArrayList<Integer> mVisibilityArray = new ArrayList<Integer>()
; |
119 private final VisibilityComparator mVisibilityComparator = new VisibilityCom
parator(); | 119 private final VisibilityComparator mVisibilityComparator = new VisibilityCom
parator(); |
120 private final OrderComparator mOrderComparator = new OrderComparator(); | 120 private final OrderComparator mOrderComparator = new OrderComparator(); |
121 private Comparator<StackTab> mSortingComparator = mVisibilityComparator; | 121 private Comparator<StackTab> mSortingComparator = mVisibilityComparator; |
122 | 122 |
123 private static final int LAYOUTTAB_ASYNCHRONOUS_INITIALIZATION_BATCH_SIZE =
4; | 123 private static final int LAYOUTTAB_ASYNCHRONOUS_INITIALIZATION_BATCH_SIZE =
4; |
124 private boolean mDelayedLayoutTabInitRequired = false; | 124 private boolean mDelayedLayoutTabInitRequired; |
125 | 125 |
126 private Boolean mTemporarySelectedStack; | 126 private Boolean mTemporarySelectedStack; |
127 | 127 |
128 // Orientation Variables | 128 // Orientation Variables |
129 private PortraitViewport mCachedPortraitViewport = null; | 129 private PortraitViewport mCachedPortraitViewport; |
130 private PortraitViewport mCachedLandscapeViewport = null; | 130 private PortraitViewport mCachedLandscapeViewport; |
131 | 131 |
132 private final ViewGroup mViewContainer; | 132 private final ViewGroup mViewContainer; |
133 | 133 |
134 private final TabListSceneLayer mSceneLayer; | 134 private final TabListSceneLayer mSceneLayer; |
135 | 135 |
136 /** | 136 /** |
137 * @param context The current Android's context. | 137 * @param context The current Android's context. |
138 * @param updateHost The {@link LayoutUpdateHost} view for this layout. | 138 * @param updateHost The {@link LayoutUpdateHost} view for this layout. |
139 * @param renderHost The {@link LayoutRenderHost} view for this layout. | 139 * @param renderHost The {@link LayoutRenderHost} view for this layout. |
140 * @param eventFilter The {@link EventFilter} that is needed for this view. | 140 * @param eventFilter The {@link EventFilter} that is needed for this view. |
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1227 protected void updateSceneLayer(RectF viewport, RectF contentViewport, | 1227 protected void updateSceneLayer(RectF viewport, RectF contentViewport, |
1228 LayerTitleCache layerTitleCache, TabContentManager tabContentManager
, | 1228 LayerTitleCache layerTitleCache, TabContentManager tabContentManager
, |
1229 ResourceManager resourceManager, ChromeFullscreenManager fullscreenM
anager) { | 1229 ResourceManager resourceManager, ChromeFullscreenManager fullscreenM
anager) { |
1230 super.updateSceneLayer(viewport, contentViewport, layerTitleCache, tabCo
ntentManager, | 1230 super.updateSceneLayer(viewport, contentViewport, layerTitleCache, tabCo
ntentManager, |
1231 resourceManager, fullscreenManager); | 1231 resourceManager, fullscreenManager); |
1232 assert mSceneLayer != null; | 1232 assert mSceneLayer != null; |
1233 mSceneLayer.pushLayers(getContext(), viewport, contentViewport, this, la
yerTitleCache, | 1233 mSceneLayer.pushLayers(getContext(), viewport, contentViewport, this, la
yerTitleCache, |
1234 tabContentManager, resourceManager, fullscreenManager); | 1234 tabContentManager, resourceManager, fullscreenManager); |
1235 } | 1235 } |
1236 } | 1236 } |
OLD | NEW |