Loading core/java/android/view/HardwareRenderer.java +89 −41 Original line number Diff line number Diff line Loading @@ -312,6 +312,20 @@ public abstract class HardwareRenderer { */ abstract long getFrameCount(); /** * Loads system properties used by the renderer. This method is invoked * whenever system properties are modified. Implementations can use this * to trigger live updates of the renderer based on properties. * * @param surface The surface to update with the new properties. * Can be null. * * @return True if a property has changed. */ abstract boolean loadSystemProperties(Surface surface); private static native boolean nLoadProperties(); /** * Sets the directory to use as a persistent storage for hardware rendering * resources. Loading Loading @@ -633,13 +647,13 @@ public abstract class HardwareRenderer { boolean mDirtyRegionsEnabled; boolean mUpdateDirtyRegions; final boolean mProfileEnabled; final float[] mProfileData; final ReentrantLock mProfileLock; boolean mProfileEnabled; float[] mProfileData; ReentrantLock mProfileLock; int mProfileCurrentFrame = -PROFILE_FRAME_DATA_COUNT; final boolean mDebugDirtyRegions; final boolean mShowOverdraw; boolean mDebugDirtyRegions; boolean mShowOverdraw; final int mGlVersion; final boolean mTranslucent; Loading @@ -655,18 +669,25 @@ public abstract class HardwareRenderer { mGlVersion = glVersion; mTranslucent = translucent; String property; loadSystemProperties(null); } @Override boolean loadSystemProperties(Surface surface) { boolean changed = false; boolean value = SystemProperties.getBoolean(PROFILE_PROPERTY, false); if (value != mProfileEnabled) { changed = true; mProfileEnabled = value; property = SystemProperties.get(PROFILE_PROPERTY, "false"); mProfileEnabled = "true".equalsIgnoreCase(property); if (mProfileEnabled) { Log.d(LOG_TAG, "Profiling hardware renderer"); } if (mProfileEnabled) { property = SystemProperties.get(PROFILE_MAXFRAMES_PROPERTY, Integer.toString(PROFILE_MAX_FRAMES)); int maxProfileFrames = Integer.valueOf(property); int maxProfileFrames = SystemProperties.getInt(PROFILE_MAXFRAMES_PROPERTY, PROFILE_MAX_FRAMES); mProfileData = new float[maxProfileFrames * PROFILE_FRAME_DATA_COUNT]; for (int i = 0; i < mProfileData.length; i += PROFILE_FRAME_DATA_COUNT) { mProfileData[i] = mProfileData[i + 1] = mProfileData[i + 2] = -1; Loading @@ -677,15 +698,37 @@ public abstract class HardwareRenderer { mProfileData = null; mProfileLock = null; } } value = SystemProperties.getBoolean(DEBUG_DIRTY_REGIONS_PROPERTY, false); if (value != mDebugDirtyRegions) { changed = true; mDebugDirtyRegions = value; property = SystemProperties.get(DEBUG_DIRTY_REGIONS_PROPERTY, "false"); mDebugDirtyRegions = "true".equalsIgnoreCase(property); if (mDebugDirtyRegions) { Log.d(LOG_TAG, "Debugging dirty regions"); } } mShowOverdraw = SystemProperties.getBoolean( value = SystemProperties.getBoolean( HardwareRenderer.DEBUG_SHOW_OVERDRAW_PROPERTY, false); if (value != mShowOverdraw) { changed = true; mShowOverdraw = value; if (surface != null && isEnabled()) { if (validate()) { sEglConfig = loadEglConfig(); invalidate(surface); } } } if (nLoadProperties()) { changed = true; } return changed; } @Override Loading Loading @@ -815,19 +858,7 @@ public abstract class HardwareRenderer { checkEglErrorsForced(); sEglConfig = chooseEglConfig(); if (sEglConfig == null) { // We tried to use EGL_SWAP_BEHAVIOR_PRESERVED_BIT, try again without if (sDirtyRegions) { sDirtyRegions = false; sEglConfig = chooseEglConfig(); if (sEglConfig == null) { throw new RuntimeException("eglConfig not initialized"); } } else { throw new RuntimeException("eglConfig not initialized"); } } sEglConfig = loadEglConfig(); } } Loading @@ -841,6 +872,23 @@ public abstract class HardwareRenderer { } } private EGLConfig loadEglConfig() { EGLConfig eglConfig = chooseEglConfig(); if (eglConfig == null) { // We tried to use EGL_SWAP_BEHAVIOR_PRESERVED_BIT, try again without if (sDirtyRegions) { sDirtyRegions = false; eglConfig = chooseEglConfig(); if (eglConfig == null) { throw new RuntimeException("eglConfig not initialized"); } } else { throw new RuntimeException("eglConfig not initialized"); } } return eglConfig; } abstract ManagedEGLContext createManagedContext(EGLContext eglContext); private EGLConfig chooseEglConfig() { Loading core/java/android/view/ViewRootImpl.java +26 −12 Original line number Diff line number Diff line Loading @@ -382,8 +382,6 @@ public final class ViewRootImpl implements ViewParent, mDensity = context.getResources().getDisplayMetrics().densityDpi; mNoncompatDensity = context.getResources().getDisplayMetrics().noncompatDensityDpi; mFallbackEventHandler = PolicyManager.makeNewFallbackEventHandler(context); mProfileRendering = Boolean.parseBoolean( SystemProperties.get(PROPERTY_PROFILE_RENDERING, "false")); mChoreographer = Choreographer.getInstance(); PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); Loading Loading @@ -2043,13 +2041,13 @@ public final class ViewRootImpl implements ViewParent, mDirty.set(0, 0, mWidth, mHeight); scheduleTraversals(); if (mRenderProfilingEnabled) { Choreographer.getInstance().postFrameCallback(mRenderProfiler); mChoreographer.postFrameCallback(mRenderProfiler); } } }; Choreographer.getInstance().postFrameCallback(mRenderProfiler); mChoreographer.postFrameCallback(mRenderProfiler); } else { Choreographer.getInstance().removeFrameCallback(mRenderProfiler); mChoreographer.removeFrameCallback(mRenderProfiler); mRenderProfiler = null; } } Loading Loading @@ -4182,8 +4180,22 @@ public final class ViewRootImpl implements ViewParent, } public void loadSystemProperties() { boolean layout = SystemProperties.getBoolean( View.DEBUG_LAYOUT_PROPERTY, false); mHandler.post(new Runnable() { @Override public void run() { // Profiling mProfileRendering = SystemProperties.getBoolean(PROPERTY_PROFILE_RENDERING, false); profileRendering(mAttachInfo.mHasWindowFocus); // Hardware rendering if (mAttachInfo.mHardwareRenderer != null) { if (mAttachInfo.mHardwareRenderer.loadSystemProperties(mHolder.getSurface())) { invalidate(); } } // Layout debugging boolean layout = SystemProperties.getBoolean(View.DEBUG_LAYOUT_PROPERTY, false); if (layout != mAttachInfo.mDebugLayout) { mAttachInfo.mDebugLayout = layout; if (!mHandler.hasMessages(MSG_INVALIDATE_WORLD)) { Loading @@ -4191,6 +4203,8 @@ public final class ViewRootImpl implements ViewParent, } } } }); } private void destroyHardwareRenderer() { AttachInfo attachInfo = mAttachInfo; Loading core/jni/android_view_HardwareRenderer.cpp +10 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ #include <EGL/egl_cache.h> #include <Caches.h> #ifdef USE_OPENGL_RENDERER EGLAPI void EGLAPIENTRY eglBeginFrame(EGLDisplay dpy, EGLSurface surface); #endif Loading Loading @@ -88,6 +90,13 @@ static jboolean android_view_HardwareRenderer_isBackBufferPreserved(JNIEnv* env, // Tracing and debugging // ---------------------------------------------------------------------------- static bool android_view_HardwareRenderer_loadProperties(JNIEnv* env, jobject clazz) { if (uirenderer::Caches::hasInstance()) { return uirenderer::Caches::getInstance().initProperties(); } return false; } static void android_view_HardwareRenderer_beginFrame(JNIEnv* env, jobject clazz, jintArray size) { Loading Loading @@ -134,6 +143,7 @@ static JNINativeMethod gMethods[] = { #ifdef USE_OPENGL_RENDERER { "nIsBackBufferPreserved", "()Z", (void*) android_view_HardwareRenderer_isBackBufferPreserved }, { "nPreserveBackBuffer", "()Z", (void*) android_view_HardwareRenderer_preserveBackBuffer }, { "nLoadProperties", "()Z", (void*) android_view_HardwareRenderer_loadProperties }, { "nBeginFrame", "([I)V", (void*) android_view_HardwareRenderer_beginFrame }, #endif Loading libs/hwui/Caches.cpp +7 −1 Original line number Diff line number Diff line Loading @@ -126,7 +126,10 @@ void Caches::initConstraints() { glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize); } void Caches::initProperties() { bool Caches::initProperties() { bool prevDebugLayersUpdates = debugLayersUpdates; bool prevDebugOverdraw = debugOverdraw; char property[PROPERTY_VALUE_MAX]; if (property_get(PROPERTY_DEBUG_LAYERS_UPDATES, property, NULL) > 0) { INIT_LOGD(" Layers updates debug enabled: %s", property); Loading @@ -141,6 +144,9 @@ void Caches::initProperties() { } else { debugOverdraw = false; } return (prevDebugLayersUpdates != debugLayersUpdates) || (prevDebugOverdraw != debugOverdraw); } void Caches::terminate() { Loading libs/hwui/Caches.h +5 −1 Original line number Diff line number Diff line Loading @@ -114,6 +114,11 @@ public: */ void init(); /** * Initialize global system properties. */ bool initProperties(); /** * Flush the cache. * Loading Loading @@ -281,7 +286,6 @@ private: void initFont(); void initExtensions(); void initConstraints(); void initProperties(); static void eventMarkNull(GLsizei length, const GLchar* marker) { } static void startMarkNull(GLsizei length, const GLchar* marker) { } Loading Loading
core/java/android/view/HardwareRenderer.java +89 −41 Original line number Diff line number Diff line Loading @@ -312,6 +312,20 @@ public abstract class HardwareRenderer { */ abstract long getFrameCount(); /** * Loads system properties used by the renderer. This method is invoked * whenever system properties are modified. Implementations can use this * to trigger live updates of the renderer based on properties. * * @param surface The surface to update with the new properties. * Can be null. * * @return True if a property has changed. */ abstract boolean loadSystemProperties(Surface surface); private static native boolean nLoadProperties(); /** * Sets the directory to use as a persistent storage for hardware rendering * resources. Loading Loading @@ -633,13 +647,13 @@ public abstract class HardwareRenderer { boolean mDirtyRegionsEnabled; boolean mUpdateDirtyRegions; final boolean mProfileEnabled; final float[] mProfileData; final ReentrantLock mProfileLock; boolean mProfileEnabled; float[] mProfileData; ReentrantLock mProfileLock; int mProfileCurrentFrame = -PROFILE_FRAME_DATA_COUNT; final boolean mDebugDirtyRegions; final boolean mShowOverdraw; boolean mDebugDirtyRegions; boolean mShowOverdraw; final int mGlVersion; final boolean mTranslucent; Loading @@ -655,18 +669,25 @@ public abstract class HardwareRenderer { mGlVersion = glVersion; mTranslucent = translucent; String property; loadSystemProperties(null); } @Override boolean loadSystemProperties(Surface surface) { boolean changed = false; boolean value = SystemProperties.getBoolean(PROFILE_PROPERTY, false); if (value != mProfileEnabled) { changed = true; mProfileEnabled = value; property = SystemProperties.get(PROFILE_PROPERTY, "false"); mProfileEnabled = "true".equalsIgnoreCase(property); if (mProfileEnabled) { Log.d(LOG_TAG, "Profiling hardware renderer"); } if (mProfileEnabled) { property = SystemProperties.get(PROFILE_MAXFRAMES_PROPERTY, Integer.toString(PROFILE_MAX_FRAMES)); int maxProfileFrames = Integer.valueOf(property); int maxProfileFrames = SystemProperties.getInt(PROFILE_MAXFRAMES_PROPERTY, PROFILE_MAX_FRAMES); mProfileData = new float[maxProfileFrames * PROFILE_FRAME_DATA_COUNT]; for (int i = 0; i < mProfileData.length; i += PROFILE_FRAME_DATA_COUNT) { mProfileData[i] = mProfileData[i + 1] = mProfileData[i + 2] = -1; Loading @@ -677,15 +698,37 @@ public abstract class HardwareRenderer { mProfileData = null; mProfileLock = null; } } value = SystemProperties.getBoolean(DEBUG_DIRTY_REGIONS_PROPERTY, false); if (value != mDebugDirtyRegions) { changed = true; mDebugDirtyRegions = value; property = SystemProperties.get(DEBUG_DIRTY_REGIONS_PROPERTY, "false"); mDebugDirtyRegions = "true".equalsIgnoreCase(property); if (mDebugDirtyRegions) { Log.d(LOG_TAG, "Debugging dirty regions"); } } mShowOverdraw = SystemProperties.getBoolean( value = SystemProperties.getBoolean( HardwareRenderer.DEBUG_SHOW_OVERDRAW_PROPERTY, false); if (value != mShowOverdraw) { changed = true; mShowOverdraw = value; if (surface != null && isEnabled()) { if (validate()) { sEglConfig = loadEglConfig(); invalidate(surface); } } } if (nLoadProperties()) { changed = true; } return changed; } @Override Loading Loading @@ -815,19 +858,7 @@ public abstract class HardwareRenderer { checkEglErrorsForced(); sEglConfig = chooseEglConfig(); if (sEglConfig == null) { // We tried to use EGL_SWAP_BEHAVIOR_PRESERVED_BIT, try again without if (sDirtyRegions) { sDirtyRegions = false; sEglConfig = chooseEglConfig(); if (sEglConfig == null) { throw new RuntimeException("eglConfig not initialized"); } } else { throw new RuntimeException("eglConfig not initialized"); } } sEglConfig = loadEglConfig(); } } Loading @@ -841,6 +872,23 @@ public abstract class HardwareRenderer { } } private EGLConfig loadEglConfig() { EGLConfig eglConfig = chooseEglConfig(); if (eglConfig == null) { // We tried to use EGL_SWAP_BEHAVIOR_PRESERVED_BIT, try again without if (sDirtyRegions) { sDirtyRegions = false; eglConfig = chooseEglConfig(); if (eglConfig == null) { throw new RuntimeException("eglConfig not initialized"); } } else { throw new RuntimeException("eglConfig not initialized"); } } return eglConfig; } abstract ManagedEGLContext createManagedContext(EGLContext eglContext); private EGLConfig chooseEglConfig() { Loading
core/java/android/view/ViewRootImpl.java +26 −12 Original line number Diff line number Diff line Loading @@ -382,8 +382,6 @@ public final class ViewRootImpl implements ViewParent, mDensity = context.getResources().getDisplayMetrics().densityDpi; mNoncompatDensity = context.getResources().getDisplayMetrics().noncompatDensityDpi; mFallbackEventHandler = PolicyManager.makeNewFallbackEventHandler(context); mProfileRendering = Boolean.parseBoolean( SystemProperties.get(PROPERTY_PROFILE_RENDERING, "false")); mChoreographer = Choreographer.getInstance(); PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); Loading Loading @@ -2043,13 +2041,13 @@ public final class ViewRootImpl implements ViewParent, mDirty.set(0, 0, mWidth, mHeight); scheduleTraversals(); if (mRenderProfilingEnabled) { Choreographer.getInstance().postFrameCallback(mRenderProfiler); mChoreographer.postFrameCallback(mRenderProfiler); } } }; Choreographer.getInstance().postFrameCallback(mRenderProfiler); mChoreographer.postFrameCallback(mRenderProfiler); } else { Choreographer.getInstance().removeFrameCallback(mRenderProfiler); mChoreographer.removeFrameCallback(mRenderProfiler); mRenderProfiler = null; } } Loading Loading @@ -4182,8 +4180,22 @@ public final class ViewRootImpl implements ViewParent, } public void loadSystemProperties() { boolean layout = SystemProperties.getBoolean( View.DEBUG_LAYOUT_PROPERTY, false); mHandler.post(new Runnable() { @Override public void run() { // Profiling mProfileRendering = SystemProperties.getBoolean(PROPERTY_PROFILE_RENDERING, false); profileRendering(mAttachInfo.mHasWindowFocus); // Hardware rendering if (mAttachInfo.mHardwareRenderer != null) { if (mAttachInfo.mHardwareRenderer.loadSystemProperties(mHolder.getSurface())) { invalidate(); } } // Layout debugging boolean layout = SystemProperties.getBoolean(View.DEBUG_LAYOUT_PROPERTY, false); if (layout != mAttachInfo.mDebugLayout) { mAttachInfo.mDebugLayout = layout; if (!mHandler.hasMessages(MSG_INVALIDATE_WORLD)) { Loading @@ -4191,6 +4203,8 @@ public final class ViewRootImpl implements ViewParent, } } } }); } private void destroyHardwareRenderer() { AttachInfo attachInfo = mAttachInfo; Loading
core/jni/android_view_HardwareRenderer.cpp +10 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ #include <EGL/egl_cache.h> #include <Caches.h> #ifdef USE_OPENGL_RENDERER EGLAPI void EGLAPIENTRY eglBeginFrame(EGLDisplay dpy, EGLSurface surface); #endif Loading Loading @@ -88,6 +90,13 @@ static jboolean android_view_HardwareRenderer_isBackBufferPreserved(JNIEnv* env, // Tracing and debugging // ---------------------------------------------------------------------------- static bool android_view_HardwareRenderer_loadProperties(JNIEnv* env, jobject clazz) { if (uirenderer::Caches::hasInstance()) { return uirenderer::Caches::getInstance().initProperties(); } return false; } static void android_view_HardwareRenderer_beginFrame(JNIEnv* env, jobject clazz, jintArray size) { Loading Loading @@ -134,6 +143,7 @@ static JNINativeMethod gMethods[] = { #ifdef USE_OPENGL_RENDERER { "nIsBackBufferPreserved", "()Z", (void*) android_view_HardwareRenderer_isBackBufferPreserved }, { "nPreserveBackBuffer", "()Z", (void*) android_view_HardwareRenderer_preserveBackBuffer }, { "nLoadProperties", "()Z", (void*) android_view_HardwareRenderer_loadProperties }, { "nBeginFrame", "([I)V", (void*) android_view_HardwareRenderer_beginFrame }, #endif Loading
libs/hwui/Caches.cpp +7 −1 Original line number Diff line number Diff line Loading @@ -126,7 +126,10 @@ void Caches::initConstraints() { glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize); } void Caches::initProperties() { bool Caches::initProperties() { bool prevDebugLayersUpdates = debugLayersUpdates; bool prevDebugOverdraw = debugOverdraw; char property[PROPERTY_VALUE_MAX]; if (property_get(PROPERTY_DEBUG_LAYERS_UPDATES, property, NULL) > 0) { INIT_LOGD(" Layers updates debug enabled: %s", property); Loading @@ -141,6 +144,9 @@ void Caches::initProperties() { } else { debugOverdraw = false; } return (prevDebugLayersUpdates != debugLayersUpdates) || (prevDebugOverdraw != debugOverdraw); } void Caches::terminate() { Loading
libs/hwui/Caches.h +5 −1 Original line number Diff line number Diff line Loading @@ -114,6 +114,11 @@ public: */ void init(); /** * Initialize global system properties. */ bool initProperties(); /** * Flush the cache. * Loading Loading @@ -281,7 +286,6 @@ private: void initFont(); void initExtensions(); void initConstraints(); void initProperties(); static void eventMarkNull(GLsizei length, const GLchar* marker) { } static void startMarkNull(GLsizei length, const GLchar* marker) { } Loading