| 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.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
| 8 import android.app.Activity; | 8 import android.app.Activity; |
| 9 import android.app.PendingIntent; | 9 import android.app.PendingIntent; |
| 10 import android.content.ContentResolver; | 10 import android.content.ContentResolver; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 private final VSyncMonitor.Listener mVSyncListener = new VSyncMonitor.Listen
er() { | 50 private final VSyncMonitor.Listener mVSyncListener = new VSyncMonitor.Listen
er() { |
| 51 @Override | 51 @Override |
| 52 public void onVSync(VSyncMonitor monitor, long vsyncTimeMicros) { | 52 public void onVSync(VSyncMonitor monitor, long vsyncTimeMicros) { |
| 53 if (mNativeWindowAndroid != 0) { | 53 if (mNativeWindowAndroid != 0) { |
| 54 nativeOnVSync(mNativeWindowAndroid, vsyncTimeMicros); | 54 nativeOnVSync(mNativeWindowAndroid, vsyncTimeMicros); |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 /** | 59 /** |
| 60 * @return true if onVSync handler is executing. |
| 61 * @see org.chromium.ui.VSyncMonitor#isInsideVSync(). |
| 62 */ |
| 63 public boolean isInsideVSync() { |
| 64 return mVSyncMonitor.isInsideVSync(); |
| 65 } |
| 66 |
| 67 /** |
| 60 * @param context The application context. | 68 * @param context The application context. |
| 61 */ | 69 */ |
| 62 @SuppressLint("UseSparseArrays") | 70 @SuppressLint("UseSparseArrays") |
| 63 public WindowAndroid(Context context) { | 71 public WindowAndroid(Context context) { |
| 64 assert context == context.getApplicationContext(); | 72 assert context == context.getApplicationContext(); |
| 65 mApplicationContext = context; | 73 mApplicationContext = context; |
| 66 mOutstandingIntents = new SparseArray<IntentCallback>(); | 74 mOutstandingIntents = new SparseArray<IntentCallback>(); |
| 67 mIntentErrors = new HashMap<Integer, String>(); | 75 mIntentErrors = new HashMap<Integer, String>(); |
| 68 mVSyncMonitor = new VSyncMonitor(context, mVSyncListener); | 76 mVSyncMonitor = new VSyncMonitor(context, mVSyncListener); |
| 69 } | 77 } |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 mNativeWindowAndroid = nativeInit(mVSyncMonitor.getVSyncPeriodInMicr
oseconds()); | 285 mNativeWindowAndroid = nativeInit(mVSyncMonitor.getVSyncPeriodInMicr
oseconds()); |
| 278 } | 286 } |
| 279 return mNativeWindowAndroid; | 287 return mNativeWindowAndroid; |
| 280 } | 288 } |
| 281 | 289 |
| 282 private native long nativeInit(long vsyncPeriod); | 290 private native long nativeInit(long vsyncPeriod); |
| 283 private native void nativeOnVSync(long nativeWindowAndroid, long vsyncTimeMi
cros); | 291 private native void nativeOnVSync(long nativeWindowAndroid, long vsyncTimeMi
cros); |
| 284 private native void nativeDestroy(long nativeWindowAndroid); | 292 private native void nativeDestroy(long nativeWindowAndroid); |
| 285 | 293 |
| 286 } | 294 } |
| OLD | NEW |