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 package org.chromium.ui.base; | 5 package org.chromium.ui.base; |
6 | 6 |
7 import android.animation.Animator; | 7 import android.animation.Animator; |
8 import android.animation.AnimatorListenerAdapter; | 8 import android.animation.AnimatorListenerAdapter; |
9 import android.annotation.SuppressLint; | 9 import android.annotation.SuppressLint; |
10 import android.annotation.TargetApi; | 10 import android.annotation.TargetApi; |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 mContextRef = new WeakReference<Context>(context); | 174 mContextRef = new WeakReference<Context>(context); |
175 mOutstandingIntents = new SparseArray<IntentCallback>(); | 175 mOutstandingIntents = new SparseArray<IntentCallback>(); |
176 mIntentErrors = new HashMap<Integer, String>(); | 176 mIntentErrors = new HashMap<Integer, String>(); |
177 mVSyncMonitor = new VSyncMonitor(context, mVSyncListener); | 177 mVSyncMonitor = new VSyncMonitor(context, mVSyncListener); |
178 mAccessibilityManager = (AccessibilityManager) mApplicationContext.getSy
stemService( | 178 mAccessibilityManager = (AccessibilityManager) mApplicationContext.getSy
stemService( |
179 Context.ACCESSIBILITY_SERVICE); | 179 Context.ACCESSIBILITY_SERVICE); |
180 mDisplayAndroid = DisplayAndroid.getNonMultiDisplay(context); | 180 mDisplayAndroid = DisplayAndroid.getNonMultiDisplay(context); |
181 } | 181 } |
182 | 182 |
183 @CalledByNative | 183 @CalledByNative |
184 private static long createForTesting(Context context) { | 184 private static WindowAndroid createForTesting(Context context) { |
185 WindowAndroid windowAndroid = new WindowAndroid(context); | 185 return new WindowAndroid(context); |
186 // |windowAndroid.getNativePointer()| creates native WindowAndroid objec
t | |
187 // which stores a global ref to |windowAndroid|. Therefore |windowAndroi
d| | |
188 // is not immediately eligible for gc. | |
189 return windowAndroid.getNativePointer(); | |
190 } | 186 } |
191 | 187 |
192 @CalledByNative | 188 @CalledByNative |
193 private void clearNativePointer() { | 189 private void clearNativePointer() { |
194 mNativeWindowAndroid = 0; | 190 mNativeWindowAndroid = 0; |
195 } | 191 } |
196 | 192 |
197 /** | 193 /** |
198 * Set the delegate that will handle android permissions requests. | 194 * Set the delegate that will handle android permissions requests. |
199 */ | 195 */ |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 } | 526 } |
531 } | 527 } |
532 | 528 |
533 /** | 529 /** |
534 * Returns a pointer to the c++ AndroidWindow object and calls the initializ
er if | 530 * Returns a pointer to the c++ AndroidWindow object and calls the initializ
er if |
535 * the object has not been previously initialized. | 531 * the object has not been previously initialized. |
536 * @return A pointer to the c++ AndroidWindow. | 532 * @return A pointer to the c++ AndroidWindow. |
537 */ | 533 */ |
538 public long getNativePointer() { | 534 public long getNativePointer() { |
539 if (mNativeWindowAndroid == 0) { | 535 if (mNativeWindowAndroid == 0) { |
540 mNativeWindowAndroid = nativeInit(mDisplayAndroid.getSdkDisplayId())
; | 536 mNativeWindowAndroid = nativeInit(); |
541 } | 537 } |
542 return mNativeWindowAndroid; | 538 return mNativeWindowAndroid; |
543 } | 539 } |
544 | 540 |
545 /** | 541 /** |
546 * Set the animation placeholder view, which we set to 'draw' during animati
ons, such that | 542 * Set the animation placeholder view, which we set to 'draw' during animati
ons, such that |
547 * animations aren't clipped by the SurfaceView 'hole'. This can be the Surf
aceView itself | 543 * animations aren't clipped by the SurfaceView 'hole'. This can be the Surf
aceView itself |
548 * or a view directly on top of it. This could be extended to many views if
we ever need it. | 544 * or a view directly on top of it. This could be extended to many views if
we ever need it. |
549 */ | 545 */ |
550 public void setAnimationPlaceholderView(View view) { | 546 public void setAnimationPlaceholderView(View view) { |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 * setWillNotDraw(false) to ensure that the animation is drawn over the Surf
aceView, | 668 * setWillNotDraw(false) to ensure that the animation is drawn over the Surf
aceView, |
673 * and otherwise we call setWillNotDraw(true). | 669 * and otherwise we call setWillNotDraw(true). |
674 */ | 670 */ |
675 private void refreshWillNotDraw() { | 671 private void refreshWillNotDraw() { |
676 boolean willNotDraw = !mIsTouchExplorationEnabled && mAnimationsOverCont
ent.isEmpty(); | 672 boolean willNotDraw = !mIsTouchExplorationEnabled && mAnimationsOverCont
ent.isEmpty(); |
677 if (mAnimationPlaceholderView.willNotDraw() != willNotDraw) { | 673 if (mAnimationPlaceholderView.willNotDraw() != willNotDraw) { |
678 mAnimationPlaceholderView.setWillNotDraw(willNotDraw); | 674 mAnimationPlaceholderView.setWillNotDraw(willNotDraw); |
679 } | 675 } |
680 } | 676 } |
681 | 677 |
682 private native long nativeInit(int displayId); | 678 private native long nativeInit(); |
683 private native void nativeOnVSync(long nativeWindowAndroid, | 679 private native void nativeOnVSync(long nativeWindowAndroid, |
684 long vsyncTimeMicros, | 680 long vsyncTimeMicros, |
685 long vsyncPeriodMicros); | 681 long vsyncPeriodMicros); |
686 private native void nativeOnVisibilityChanged(long nativeWindowAndroid, bool
ean visible); | 682 private native void nativeOnVisibilityChanged(long nativeWindowAndroid, bool
ean visible); |
687 private native void nativeOnActivityStopped(long nativeWindowAndroid); | 683 private native void nativeOnActivityStopped(long nativeWindowAndroid); |
688 private native void nativeOnActivityStarted(long nativeWindowAndroid); | 684 private native void nativeOnActivityStarted(long nativeWindowAndroid); |
689 private native void nativeDestroy(long nativeWindowAndroid); | 685 private native void nativeDestroy(long nativeWindowAndroid); |
690 | 686 |
691 } | 687 } |
OLD | NEW |