Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Unified Diff: ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java

Issue 26129009: Cache DeviceDisplayInfo data in shared structure on native side to avoid frequent JNI calls. (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: Updated patch by review comments. Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/gfx/android/device_display_info.h » ('j') | ui/gfx/android/shared_device_display_info.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java
diff --git a/ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java b/ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java
index 088c9c2476e7f2781572be7a56e1482965716dd3..84501daa2594f3b2f385f81caf82c1a8056de277 100644
--- a/ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java
+++ b/ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java
@@ -5,6 +5,8 @@
package org.chromium.ui.gfx;
import android.content.Context;
+import android.content.ComponentCallbacks;
+import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.os.Build;
import android.util.DisplayMetrics;
@@ -115,6 +117,25 @@ public class DeviceDisplayInfo {
return getMetrics().density;
}
+ public void registerListener() {
Yaron 2013/10/11 10:18:14 private
+ mAppContext.registerComponentCallbacks(
+ new ComponentCallbacks() {
+ @Override
+ public void onConfigurationChanged(Configuration configuration) {
+ updateNativeSharedDisplayInfo();
Yaron 2013/10/11 10:18:14 indent 4 for block-level (other places below too).
+ }
+
+ @Override
+ public void onLowMemory() {
+ }
+ });
+ }
+
+ private void updateNativeSharedDisplayInfo() {
+ nativeUpdateSharedDeviceDisplayInfo(getDisplayHeight(), getDisplayWidth(),
+ getBitsPerPixel(), getBitsPerComponent(), getDIPScale());
+ }
+
private Display getDisplay() {
return mWinManager.getDefaultDisplay();
}
@@ -128,8 +149,19 @@ public class DeviceDisplayInfo {
* @param context A context to use.
* @return DeviceDisplayInfo associated with a given Context.
*/
- @CalledByNative
public static DeviceDisplayInfo create(Context context) {
return new DeviceDisplayInfo(context);
}
+
+ @CalledByNative
+ public static DeviceDisplayInfo createWithListener(Context context) {
Yaron 2013/10/11 10:18:14 Make private. This is unneeded from the java layer
+ DeviceDisplayInfo deviceDisplayInfo = new DeviceDisplayInfo(context);
+ deviceDisplayInfo.registerListener();
+ return deviceDisplayInfo;
+ }
+
+ private native void nativeUpdateSharedDeviceDisplayInfo(int displayHeight,
+ int displayWidth, int bitsPerPixel,
+ int bitsPerComponent, double dipScale);
+
}
« no previous file with comments | « no previous file | ui/gfx/android/device_display_info.h » ('j') | ui/gfx/android/shared_device_display_info.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698