diff --git a/graphics/java/android/graphics/HardwareRenderer.java b/graphics/java/android/graphics/HardwareRenderer.java index bfe7443915d54..87060ca57e977 100644 --- a/graphics/java/android/graphics/HardwareRenderer.java +++ b/graphics/java/android/graphics/HardwareRenderer.java @@ -165,6 +165,7 @@ public class HardwareRenderer { * to opaque with no light source configured. */ public HardwareRenderer() { + ProcessInitializer.sInstance.initDisplayInfo(); mRootNode = RenderNode.adopt(nCreateRootRenderNode()); mRootNode.setClipToBounds(false); mNativeProxy = nCreateProxy(!mOpaque, mIsWideGamut, mRootNode.mNativeRenderNode); @@ -1051,6 +1052,7 @@ public class HardwareRenderer { } private boolean mInitialized = false; + private boolean mDisplayInitialized = false; private boolean mIsolated = false; private Context mContext; @@ -1087,7 +1089,6 @@ public class HardwareRenderer { initSched(renderProxy); initGraphicsStats(); - initDisplayInfo(); } private void initSched(long renderProxy) { @@ -1112,7 +1113,8 @@ public class HardwareRenderer { } } - private void initDisplayInfo() { + synchronized void initDisplayInfo() { + if (mDisplayInitialized) return; if (mContext == null) return; // If we're in an isolated sandbox mode then we shouldn't try to communicate with DMS @@ -1120,6 +1122,7 @@ public class HardwareRenderer { // Defensively clear out the context in case we were passed a context that can leak // if we live longer than it, e.g. an activity context. mContext = null; + mDisplayInitialized = true; return; } @@ -1162,6 +1165,7 @@ public class HardwareRenderer { // Defensively clear out the context mContext = null; + mDisplayInitialized = true; } private void rotateBuffer() { diff --git a/libs/hwui/DeviceInfo.h b/libs/hwui/DeviceInfo.h index 191dcd89a0263..27be622699598 100644 --- a/libs/hwui/DeviceInfo.h +++ b/libs/hwui/DeviceInfo.h @@ -95,7 +95,8 @@ private: int32_t mWidth = 1080; int32_t mHeight = 1920; int64_t mVsyncPeriod = 16666666; - int64_t mPresentationDeadlineNanos = 0; + // Magically corresponds with an sf offset of 0 for a sane default. + int64_t mPresentationDeadlineNanos = 17666666; int64_t mAppVsyncOffsetNanos = 0; // Density is not retrieved from the ADisplay apis, so this may potentially