Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d4577c0c authored by Romain Guy's avatar Romain Guy Committed by Android (Google) Code Review
Browse files

Merge "Destroy the hardware renderer when ViewRootImpl's die is post-poned Bug #6109035"

parents 660b014d a998dff5
Loading
Loading
Loading
Loading
+19 −35
Original line number Diff line number Diff line
@@ -404,6 +404,7 @@ public final class ActivityThread {
                    try {
                        fd.close();
                    } catch (IOException e) {
                        // Ignore
                    }
                }
                return;
@@ -412,6 +413,7 @@ public final class ActivityThread {
                try {
                    profileFd.close();
                } catch (IOException e) {
                    // Ignore
                }
            }
            profileFile = file;
@@ -843,14 +845,13 @@ public final class ActivityThread {
            FileOutputStream fout = new FileOutputStream(fd);
            PrintWriter pw = new PrintWriter(fout);
            try {
                return dumpMemInfo(pw, checkin, all, args);
                return dumpMemInfo(pw, checkin, all);
            } finally {
                pw.flush();
            }
        }

        private Debug.MemoryInfo dumpMemInfo(PrintWriter pw, boolean checkin, boolean all,
                String[] args) {
        private Debug.MemoryInfo dumpMemInfo(PrintWriter pw, boolean checkin, boolean all) {
            long nativeMax = Debug.getNativeHeapSize() / 1024;
            long nativeAllocated = Debug.getNativeHeapAllocatedSize() / 1024;
            long nativeFree = Debug.getNativeHeapFreeSize() / 1024;
@@ -1458,17 +1459,6 @@ public final class ActivityThread {
        return dm;
    }

    static Configuration applyConfigCompat(Configuration config, CompatibilityInfo compat) {
        if (config == null) {
            return null;
        }
        if (compat != null && !compat.supportsScreen()) {
            config = new Configuration(config);
            compat.applyToConfiguration(config);
        }
        return config;
    }

    private Configuration mMainThreadConfig = new Configuration();
    Configuration applyConfigCompatMainThread(Configuration config, CompatibilityInfo compat) {
        if (config == null) {
@@ -2509,7 +2499,7 @@ public final class ActivityThread {
        return r;
    }

    final void cleanUpPendingRemoveWindows(ActivityClientRecord r) {
    static final void cleanUpPendingRemoveWindows(ActivityClientRecord r) {
        if (r.mPendingRemoveWindow != null) {
            r.mPendingRemoveWindowManager.removeViewImmediate(r.mPendingRemoveWindow);
            IBinder wtoken = r.mPendingRemoveWindow.getWindowToken();
@@ -3437,15 +3427,12 @@ public final class ActivityThread {
                = new ArrayList<ComponentCallbacks2>();

        if (mActivities.size() > 0) {
            Iterator<ActivityClientRecord> it = mActivities.values().iterator();
            while (it.hasNext()) {
                ActivityClientRecord ar = it.next();
            for (ActivityClientRecord ar : mActivities.values()) {
                Activity a = ar.activity;
                if (a != null) {
                    Configuration thisConfig = applyConfigCompatMainThread(newConfig,
                            ar.packageInfo.mCompatibilityInfo.getIfNeeded());
                    if (!ar.activity.mFinished && (allActivities ||
                            (a != null && !ar.paused))) {
                    if (!ar.activity.mFinished && (allActivities || !ar.paused)) {
                        // If the activity is currently resumed, its configuration
                        // needs to change right now.
                        callbacks.add(a);
@@ -3455,24 +3442,24 @@ public final class ActivityThread {
                        // the activity manager may, before then, decide the
                        // activity needs to be destroyed to handle its new
                        // configuration.
                        if (DEBUG_CONFIGURATION) Slog.v(TAG, "Setting activity "
                        if (DEBUG_CONFIGURATION) {
                            Slog.v(TAG, "Setting activity "
                                    + ar.activityInfo.name + " newConfig=" + thisConfig);
                        }
                        ar.newConfig = thisConfig;
                    }
                }
            }
        }
        if (mServices.size() > 0) {
            Iterator<Service> it = mServices.values().iterator();
            while (it.hasNext()) {
                callbacks.add(it.next());
            for (Service service : mServices.values()) {
                callbacks.add(service);
            }
        }
        synchronized (mProviderMap) {
            if (mLocalProviders.size() > 0) {
                Iterator<ProviderClientRecord> it = mLocalProviders.values().iterator();
                while (it.hasNext()) {
                    callbacks.add(it.next().mLocalProvider);
                for (ProviderClientRecord providerClientRecord : mLocalProviders.values()) {
                    callbacks.add(providerClientRecord.mLocalProvider);
                }
            }
        }
@@ -3484,8 +3471,7 @@ public final class ActivityThread {
        return callbacks;
    }

    private final void performConfigurationChanged(
            ComponentCallbacks2 cb, Configuration config) {
    private static void performConfigurationChanged(ComponentCallbacks2 cb, Configuration config) {
        // Only for Activity objects, check that they actually call up to their
        // superclass implementation.  ComponentCallbacks2 is an interface, so
        // we check the runtime type and act accordingly.
@@ -3692,7 +3678,7 @@ public final class ActivityThread {
        }
    }

    final void handleDumpHeap(boolean managed, DumpHeapData dhd) {
    static final void handleDumpHeap(boolean managed, DumpHeapData dhd) {
        if (managed) {
            try {
                Debug.dumpHprofData(dhd.path, dhd.fd.getFileDescriptor());
@@ -4057,9 +4043,7 @@ public final class ActivityThread {
        final ArrayList<IActivityManager.ContentProviderHolder> results =
            new ArrayList<IActivityManager.ContentProviderHolder>();

        Iterator<ProviderInfo> i = providers.iterator();
        while (i.hasNext()) {
            ProviderInfo cpi = i.next();
        for (ProviderInfo cpi : providers) {
            StringBuilder buf = new StringBuilder(128);
            buf.append("Pub ");
            buf.append(cpi.authority);
+2 −2
Original line number Diff line number Diff line
@@ -1121,6 +1121,7 @@ public abstract class HardwareRenderer {
                        GLES20Canvas.terminateCaches();

                        sEgl.eglDestroyContext(sEglDisplay, eglContext);
                        sEglContextStorage.set(null);
                        sEglContextStorage.remove();

                        sEgl.eglDestroySurface(sEglDisplay, sPbuffer);
@@ -1134,7 +1135,6 @@ public abstract class HardwareRenderer {
                        sEglDisplay = null;
                        sEglConfig = null;
                        sPbuffer = null;
                        sEglContextStorage.set(null);
                    }
                }
            }
@@ -1238,7 +1238,7 @@ public abstract class HardwareRenderer {
        }

        private static void destroyHardwareLayer(View view) {
            view.destroyLayer();
            view.destroyLayer(true);

            if (view instanceof ViewGroup) {
                ViewGroup group = (ViewGroup) view;
+1 −1
Original line number Diff line number Diff line
@@ -299,7 +299,7 @@ public class TextureView extends View {
    }

    @Override
    boolean destroyLayer() {
    boolean destroyLayer(boolean valid) {
        return false;
    }

+6 −5
Original line number Diff line number Diff line
@@ -10045,7 +10045,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
        destroyDrawingCache();
        destroyLayer();
        destroyLayer(false);
        if (mAttachInfo != null) {
            if (mDisplayList != null) {
@@ -10421,7 +10421,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
        // Destroy any previous software drawing cache if needed
        switch (mLayerType) {
            case LAYER_TYPE_HARDWARE:
                destroyLayer();
                destroyLayer(false);
                // fall through - non-accelerated views may use software layer mechanism instead
            case LAYER_TYPE_SOFTWARE:
                destroyDrawingCache();
@@ -10559,11 +10559,12 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
     * @see #setLayerType(int, android.graphics.Paint) 
     * @see #LAYER_TYPE_HARDWARE
     */
    boolean destroyLayer() {
    boolean destroyLayer(boolean valid) {
        if (mHardwareLayer != null) {
            AttachInfo info = mAttachInfo;
            if (info != null && info.mHardwareRenderer != null &&
                    info.mHardwareRenderer.isEnabled() && info.mHardwareRenderer.validate()) {
                    info.mHardwareRenderer.isEnabled() &&
                    (valid || info.mHardwareRenderer.validate())) {
                mHardwareLayer.destroy();
                mHardwareLayer = null;
@@ -10587,7 +10588,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
     * @hide
     */
    protected void destroyHardwareResources() {
        destroyLayer();
        destroyLayer(true);
    }
    /**
+1 −1
Original line number Diff line number Diff line
@@ -1820,7 +1820,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
     * Resets the cancel next up flag.
     * Returns true if the flag was previously set.
     */
    private boolean resetCancelNextUpFlag(View view) {
    private static boolean resetCancelNextUpFlag(View view) {
        if ((view.mPrivateFlags & CANCEL_NEXT_UP_EVENT) != 0) {
            view.mPrivateFlags &= ~CANCEL_NEXT_UP_EVENT;
            return true;
Loading