summaryrefslogtreecommitdiffstats
path: root/core/java/android/hardware/display
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2012-08-30 18:18:29 -0700
committerJeff Brown <jeffbrown@google.com>2012-08-31 15:42:46 -0700
commit4ed8fe75e1dde1a2b9576f3862aecc5a572c56b5 (patch)
treed51a8657c4ca101b5a82c2592d89d789643d388f /core/java/android/hardware/display
parenta492c3a7b2c18426fd0cb4d017eacbc368195dc5 (diff)
downloadframeworks_base-4ed8fe75e1dde1a2b9576f3862aecc5a572c56b5.zip
frameworks_base-4ed8fe75e1dde1a2b9576f3862aecc5a572c56b5.tar.gz
frameworks_base-4ed8fe75e1dde1a2b9576f3862aecc5a572c56b5.tar.bz2
More improvements to the display manager.
Added more complete support for logical displays with support for mirroring, rotation and scaling. Improved the overlay display adapter's touch interactions. A big change here is that the display manager no longer relies on a single-threaded model to maintain its synchronization invariants. Unfortunately we had to change this so as to play nice with the fact that the window manager wants to own the surface flinger transaction around display and surface manipulations. As a result, the display manager has to be able to update displays from the context of any thread. It would be nice to make this process more cooperative. There are already several components competing to perform surface flinger transactions including the window manager, display manager, electron beam, overlay display window, and mouse pointer. They are not manipulating the same surfaces but they can collide with one another when they make global changes to the displays. Change-Id: I04f448594241f2004f6f3d1a81ccd12c566bf296
Diffstat (limited to 'core/java/android/hardware/display')
-rw-r--r--core/java/android/hardware/display/DisplayManagerGlobal.java51
1 files changed, 38 insertions, 13 deletions
diff --git a/core/java/android/hardware/display/DisplayManagerGlobal.java b/core/java/android/hardware/display/DisplayManagerGlobal.java
index 69c0319..4077964 100644
--- a/core/java/android/hardware/display/DisplayManagerGlobal.java
+++ b/core/java/android/hardware/display/DisplayManagerGlobal.java
@@ -42,6 +42,16 @@ public final class DisplayManagerGlobal {
private static final String TAG = "DisplayManager";
private static final boolean DEBUG = false;
+ // True if display info and display ids should be cached.
+ //
+ // FIXME: The cache is currently disabled because it's unclear whether we have the
+ // necessary guarantees that the caches will always be flushed before clients
+ // attempt to observe their new state. For example, depending on the order
+ // in which the binder transactions take place, we might have a problem where
+ // an application could start processing a configuration change due to a display
+ // orientation change before the display info cache has actually been invalidated.
+ private static final boolean USE_CACHE = false;
+
public static final int EVENT_DISPLAY_ADDED = 1;
public static final int EVENT_DISPLAY_CHANGED = 2;
public static final int EVENT_DISPLAY_REMOVED = 3;
@@ -91,21 +101,27 @@ public final class DisplayManagerGlobal {
public DisplayInfo getDisplayInfo(int displayId) {
try {
synchronized (mLock) {
- DisplayInfo info = mDisplayInfoCache.get(displayId);
- if (info != null) {
- return info;
+ DisplayInfo info;
+ if (USE_CACHE) {
+ info = mDisplayInfoCache.get(displayId);
+ if (info != null) {
+ return info;
+ }
}
info = mDm.getDisplayInfo(displayId);
if (info == null) {
return null;
}
+
+ if (USE_CACHE) {
+ mDisplayInfoCache.put(displayId, info);
+ }
+ registerCallbackIfNeededLocked();
+
if (DEBUG) {
Log.d(TAG, "getDisplayInfo: displayId=" + displayId + ", info=" + info);
}
-
- mDisplayInfoCache.put(displayId, info);
- registerCallbackIfNeededLocked();
return info;
}
} catch (RemoteException ex) {
@@ -122,11 +138,18 @@ public final class DisplayManagerGlobal {
public int[] getDisplayIds() {
try {
synchronized (mLock) {
- if (mDisplayIdCache == null) {
- mDisplayIdCache = mDm.getDisplayIds();
- registerCallbackIfNeededLocked();
+ if (USE_CACHE) {
+ if (mDisplayIdCache != null) {
+ return mDisplayIdCache;
+ }
+ }
+
+ int[] displayIds = mDm.getDisplayIds();
+ if (USE_CACHE) {
+ mDisplayIdCache = displayIds;
}
- return mDisplayIdCache;
+ registerCallbackIfNeededLocked();
+ return displayIds;
}
} catch (RemoteException ex) {
Log.e(TAG, "Could not get display ids from display manager.", ex);
@@ -215,10 +238,12 @@ public final class DisplayManagerGlobal {
private void handleDisplayEvent(int displayId, int event) {
synchronized (mLock) {
- mDisplayInfoCache.remove(displayId);
+ if (USE_CACHE) {
+ mDisplayInfoCache.remove(displayId);
- if (event == EVENT_DISPLAY_ADDED || event == EVENT_DISPLAY_REMOVED) {
- mDisplayIdCache = null;
+ if (event == EVENT_DISPLAY_ADDED || event == EVENT_DISPLAY_REMOVED) {
+ mDisplayIdCache = null;
+ }
}
final int numListeners = mDisplayListeners.size();