Loading core/java/android/app/ActivityThread.java +1 −0 Original line number Original line Diff line number Diff line Loading @@ -5701,6 +5701,7 @@ public final class ActivityThread extends ClientTransactionHandler { configDiff = mConfiguration.updateFrom(config); configDiff = mConfiguration.updateFrom(config); config = applyCompatConfiguration(mCurDefaultDisplayDpi); config = applyCompatConfiguration(mCurDefaultDisplayDpi); HardwareRenderer.sendDeviceConfigurationForDebugging(config); if ((systemTheme.getChangingConfigurations() & configDiff) != 0) { if ((systemTheme.getChangingConfigurations() & configDiff) != 0) { systemTheme.rebase(); systemTheme.rebase(); Loading graphics/java/android/graphics/HardwareRenderer.java +18 −0 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.Nullable; import android.app.Activity; import android.app.Activity; import android.app.ActivityManager; import android.app.ActivityManager; import android.content.res.Configuration; import android.os.IBinder; import android.os.IBinder; import android.os.ParcelFileDescriptor; import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.os.RemoteException; Loading Loading @@ -143,6 +144,8 @@ public class HardwareRenderer { private static final String CACHE_PATH_SHADERS = "com.android.opengl.shaders_cache"; private static final String CACHE_PATH_SHADERS = "com.android.opengl.shaders_cache"; private static final String CACHE_PATH_SKIASHADERS = "com.android.skia.shaders_cache"; private static final String CACHE_PATH_SKIASHADERS = "com.android.skia.shaders_cache"; private static int sDensityDpi = 0; private final long mNativeProxy; private final long mNativeProxy; /** @hide */ /** @hide */ protected RenderNode mRootNode; protected RenderNode mRootNode; Loading Loading @@ -906,6 +909,19 @@ public class HardwareRenderer { nSetIsolatedProcess(isIsolated); nSetIsolatedProcess(isIsolated); } } /** * Sends device configuration changes to the render thread, for rendering profiling views. * * @hide */ public static void sendDeviceConfigurationForDebugging(Configuration config) { if (config.densityDpi != Configuration.DENSITY_DPI_UNDEFINED && config.densityDpi != sDensityDpi) { sDensityDpi = config.densityDpi; nSetDisplayDensityDpi(config.densityDpi); } } /** /** * If set extra graphics debugging abilities will be enabled such as dumping skp * If set extra graphics debugging abilities will be enabled such as dumping skp * * Loading Loading @@ -1189,4 +1205,6 @@ public class HardwareRenderer { private static native void nAllocateBuffers(long nativeProxy); private static native void nAllocateBuffers(long nativeProxy); private static native void nSetForceDark(long nativeProxy, boolean enabled); private static native void nSetForceDark(long nativeProxy, boolean enabled); private static native void nSetDisplayDensityDpi(int densityDpi); } } libs/hwui/DeviceInfo.cpp +2 −1 Original line number Original line Diff line number Diff line Loading @@ -113,11 +113,12 @@ void DeviceInfo::updateDisplayInfo() { mWidth = ADisplayConfig_getWidth(mCurrentConfig); mWidth = ADisplayConfig_getWidth(mCurrentConfig); mHeight = ADisplayConfig_getHeight(mCurrentConfig); mHeight = ADisplayConfig_getHeight(mCurrentConfig); mDensity = ADisplayConfig_getDensity(mCurrentConfig); mVsyncPeriod = static_cast<int64_t>(1000000000 / ADisplayConfig_getFps(mCurrentConfig)); mVsyncPeriod = static_cast<int64_t>(1000000000 / ADisplayConfig_getFps(mCurrentConfig)); mCompositorOffset = ADisplayConfig_getCompositorOffsetNanos(mCurrentConfig); mCompositorOffset = ADisplayConfig_getCompositorOffsetNanos(mCurrentConfig); mAppOffset = ADisplayConfig_getAppVsyncOffsetNanos(mCurrentConfig); mAppOffset = ADisplayConfig_getAppVsyncOffsetNanos(mCurrentConfig); } } std::atomic<float> DeviceInfo::sDensity = 2.0; } /* namespace uirenderer */ } /* namespace uirenderer */ } /* namespace android */ } /* namespace android */ libs/hwui/DeviceInfo.h +9 −2 Original line number Original line Diff line number Diff line Loading @@ -36,10 +36,13 @@ public: static float getMaxRefreshRate() { return get()->mMaxRefreshRate; } static float getMaxRefreshRate() { return get()->mMaxRefreshRate; } static int32_t getWidth() { return get()->mWidth; } static int32_t getWidth() { return get()->mWidth; } static int32_t getHeight() { return get()->mHeight; } static int32_t getHeight() { return get()->mHeight; } static float getDensity() { return get()->mDensity; } // Gets the density in density-independent pixels static float getDensity() { return sDensity.load(); } static int64_t getVsyncPeriod() { return get()->mVsyncPeriod; } static int64_t getVsyncPeriod() { return get()->mVsyncPeriod; } static int64_t getCompositorOffset() { return get()->mCompositorOffset; } static int64_t getCompositorOffset() { return get()->mCompositorOffset; } static int64_t getAppOffset() { return get()->mAppOffset; } static int64_t getAppOffset() { return get()->mAppOffset; } // Sets the density in density-independent pixels static void setDensity(float density) { sDensity.store(density); } // this value is only valid after the GPU has been initialized and there is a valid graphics // this value is only valid after the GPU has been initialized and there is a valid graphics // context or if you are using the HWUI_NULL_GPU // context or if you are using the HWUI_NULL_GPU Loading Loading @@ -68,10 +71,14 @@ private: float mMaxRefreshRate = 60.0; float mMaxRefreshRate = 60.0; int32_t mWidth = 1080; int32_t mWidth = 1080; int32_t mHeight = 1920; int32_t mHeight = 1920; float mDensity = 2.0; int64_t mVsyncPeriod = 16666666; int64_t mVsyncPeriod = 16666666; int64_t mCompositorOffset = 0; int64_t mCompositorOffset = 0; int64_t mAppOffset = 0; int64_t mAppOffset = 0; // Density is not retrieved from the ADisplay apis, so this may potentially // be called on multiple threads. // Unit is density-independent pixels static std::atomic<float> sDensity; }; }; } /* namespace uirenderer */ } /* namespace uirenderer */ Loading libs/hwui/jni/android_graphics_HardwareRenderer.cpp +8 −0 Original line number Original line Diff line number Diff line Loading @@ -593,6 +593,13 @@ static void android_view_ThreadedRenderer_preload(JNIEnv*, jclass) { RenderProxy::preload(); RenderProxy::preload(); } } // Plumbs the display density down to DeviceInfo. static void android_view_ThreadedRenderer_setDisplayDensityDpi(JNIEnv*, jclass, jint densityDpi) { // Convert from dpi to density-independent pixels. const float density = densityDpi / 160.0; DeviceInfo::setDensity(density); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // HardwareRendererObserver // HardwareRendererObserver // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- Loading Loading @@ -697,6 +704,7 @@ static const JNINativeMethod gMethods[] = { { "nSetContextPriority", "(I)V", (void*)android_view_ThreadedRenderer_setContextPriority }, { "nSetContextPriority", "(I)V", (void*)android_view_ThreadedRenderer_setContextPriority }, { "nAllocateBuffers", "(J)V", (void*)android_view_ThreadedRenderer_allocateBuffers }, { "nAllocateBuffers", "(J)V", (void*)android_view_ThreadedRenderer_allocateBuffers }, { "nSetForceDark", "(JZ)V", (void*)android_view_ThreadedRenderer_setForceDark }, { "nSetForceDark", "(JZ)V", (void*)android_view_ThreadedRenderer_setForceDark }, { "nSetDisplayDensityDpi", "(I)V", (void*)android_view_ThreadedRenderer_setDisplayDensityDpi }, { "preload", "()V", (void*)android_view_ThreadedRenderer_preload }, { "preload", "()V", (void*)android_view_ThreadedRenderer_preload }, }; }; Loading Loading
core/java/android/app/ActivityThread.java +1 −0 Original line number Original line Diff line number Diff line Loading @@ -5701,6 +5701,7 @@ public final class ActivityThread extends ClientTransactionHandler { configDiff = mConfiguration.updateFrom(config); configDiff = mConfiguration.updateFrom(config); config = applyCompatConfiguration(mCurDefaultDisplayDpi); config = applyCompatConfiguration(mCurDefaultDisplayDpi); HardwareRenderer.sendDeviceConfigurationForDebugging(config); if ((systemTheme.getChangingConfigurations() & configDiff) != 0) { if ((systemTheme.getChangingConfigurations() & configDiff) != 0) { systemTheme.rebase(); systemTheme.rebase(); Loading
graphics/java/android/graphics/HardwareRenderer.java +18 −0 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.Nullable; import android.app.Activity; import android.app.Activity; import android.app.ActivityManager; import android.app.ActivityManager; import android.content.res.Configuration; import android.os.IBinder; import android.os.IBinder; import android.os.ParcelFileDescriptor; import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.os.RemoteException; Loading Loading @@ -143,6 +144,8 @@ public class HardwareRenderer { private static final String CACHE_PATH_SHADERS = "com.android.opengl.shaders_cache"; private static final String CACHE_PATH_SHADERS = "com.android.opengl.shaders_cache"; private static final String CACHE_PATH_SKIASHADERS = "com.android.skia.shaders_cache"; private static final String CACHE_PATH_SKIASHADERS = "com.android.skia.shaders_cache"; private static int sDensityDpi = 0; private final long mNativeProxy; private final long mNativeProxy; /** @hide */ /** @hide */ protected RenderNode mRootNode; protected RenderNode mRootNode; Loading Loading @@ -906,6 +909,19 @@ public class HardwareRenderer { nSetIsolatedProcess(isIsolated); nSetIsolatedProcess(isIsolated); } } /** * Sends device configuration changes to the render thread, for rendering profiling views. * * @hide */ public static void sendDeviceConfigurationForDebugging(Configuration config) { if (config.densityDpi != Configuration.DENSITY_DPI_UNDEFINED && config.densityDpi != sDensityDpi) { sDensityDpi = config.densityDpi; nSetDisplayDensityDpi(config.densityDpi); } } /** /** * If set extra graphics debugging abilities will be enabled such as dumping skp * If set extra graphics debugging abilities will be enabled such as dumping skp * * Loading Loading @@ -1189,4 +1205,6 @@ public class HardwareRenderer { private static native void nAllocateBuffers(long nativeProxy); private static native void nAllocateBuffers(long nativeProxy); private static native void nSetForceDark(long nativeProxy, boolean enabled); private static native void nSetForceDark(long nativeProxy, boolean enabled); private static native void nSetDisplayDensityDpi(int densityDpi); } }
libs/hwui/DeviceInfo.cpp +2 −1 Original line number Original line Diff line number Diff line Loading @@ -113,11 +113,12 @@ void DeviceInfo::updateDisplayInfo() { mWidth = ADisplayConfig_getWidth(mCurrentConfig); mWidth = ADisplayConfig_getWidth(mCurrentConfig); mHeight = ADisplayConfig_getHeight(mCurrentConfig); mHeight = ADisplayConfig_getHeight(mCurrentConfig); mDensity = ADisplayConfig_getDensity(mCurrentConfig); mVsyncPeriod = static_cast<int64_t>(1000000000 / ADisplayConfig_getFps(mCurrentConfig)); mVsyncPeriod = static_cast<int64_t>(1000000000 / ADisplayConfig_getFps(mCurrentConfig)); mCompositorOffset = ADisplayConfig_getCompositorOffsetNanos(mCurrentConfig); mCompositorOffset = ADisplayConfig_getCompositorOffsetNanos(mCurrentConfig); mAppOffset = ADisplayConfig_getAppVsyncOffsetNanos(mCurrentConfig); mAppOffset = ADisplayConfig_getAppVsyncOffsetNanos(mCurrentConfig); } } std::atomic<float> DeviceInfo::sDensity = 2.0; } /* namespace uirenderer */ } /* namespace uirenderer */ } /* namespace android */ } /* namespace android */
libs/hwui/DeviceInfo.h +9 −2 Original line number Original line Diff line number Diff line Loading @@ -36,10 +36,13 @@ public: static float getMaxRefreshRate() { return get()->mMaxRefreshRate; } static float getMaxRefreshRate() { return get()->mMaxRefreshRate; } static int32_t getWidth() { return get()->mWidth; } static int32_t getWidth() { return get()->mWidth; } static int32_t getHeight() { return get()->mHeight; } static int32_t getHeight() { return get()->mHeight; } static float getDensity() { return get()->mDensity; } // Gets the density in density-independent pixels static float getDensity() { return sDensity.load(); } static int64_t getVsyncPeriod() { return get()->mVsyncPeriod; } static int64_t getVsyncPeriod() { return get()->mVsyncPeriod; } static int64_t getCompositorOffset() { return get()->mCompositorOffset; } static int64_t getCompositorOffset() { return get()->mCompositorOffset; } static int64_t getAppOffset() { return get()->mAppOffset; } static int64_t getAppOffset() { return get()->mAppOffset; } // Sets the density in density-independent pixels static void setDensity(float density) { sDensity.store(density); } // this value is only valid after the GPU has been initialized and there is a valid graphics // this value is only valid after the GPU has been initialized and there is a valid graphics // context or if you are using the HWUI_NULL_GPU // context or if you are using the HWUI_NULL_GPU Loading Loading @@ -68,10 +71,14 @@ private: float mMaxRefreshRate = 60.0; float mMaxRefreshRate = 60.0; int32_t mWidth = 1080; int32_t mWidth = 1080; int32_t mHeight = 1920; int32_t mHeight = 1920; float mDensity = 2.0; int64_t mVsyncPeriod = 16666666; int64_t mVsyncPeriod = 16666666; int64_t mCompositorOffset = 0; int64_t mCompositorOffset = 0; int64_t mAppOffset = 0; int64_t mAppOffset = 0; // Density is not retrieved from the ADisplay apis, so this may potentially // be called on multiple threads. // Unit is density-independent pixels static std::atomic<float> sDensity; }; }; } /* namespace uirenderer */ } /* namespace uirenderer */ Loading
libs/hwui/jni/android_graphics_HardwareRenderer.cpp +8 −0 Original line number Original line Diff line number Diff line Loading @@ -593,6 +593,13 @@ static void android_view_ThreadedRenderer_preload(JNIEnv*, jclass) { RenderProxy::preload(); RenderProxy::preload(); } } // Plumbs the display density down to DeviceInfo. static void android_view_ThreadedRenderer_setDisplayDensityDpi(JNIEnv*, jclass, jint densityDpi) { // Convert from dpi to density-independent pixels. const float density = densityDpi / 160.0; DeviceInfo::setDensity(density); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // HardwareRendererObserver // HardwareRendererObserver // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- Loading Loading @@ -697,6 +704,7 @@ static const JNINativeMethod gMethods[] = { { "nSetContextPriority", "(I)V", (void*)android_view_ThreadedRenderer_setContextPriority }, { "nSetContextPriority", "(I)V", (void*)android_view_ThreadedRenderer_setContextPriority }, { "nAllocateBuffers", "(J)V", (void*)android_view_ThreadedRenderer_allocateBuffers }, { "nAllocateBuffers", "(J)V", (void*)android_view_ThreadedRenderer_allocateBuffers }, { "nSetForceDark", "(JZ)V", (void*)android_view_ThreadedRenderer_setForceDark }, { "nSetForceDark", "(JZ)V", (void*)android_view_ThreadedRenderer_setForceDark }, { "nSetDisplayDensityDpi", "(I)V", (void*)android_view_ThreadedRenderer_setDisplayDensityDpi }, { "preload", "()V", (void*)android_view_ThreadedRenderer_preload }, { "preload", "()V", (void*)android_view_ThreadedRenderer_preload }, }; }; Loading