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

Commit d907e5b1 authored by John Reck's avatar John Reck Committed by Android (Google) Code Review
Browse files

Merge "Fix onTrimMemory for HardwareRenderer"

parents 1928aabc f47a594f
Loading
Loading
Loading
Loading
+1 −8
Original line number Diff line number Diff line
@@ -3962,10 +3962,6 @@ public final class ActivityThread {

        ArrayList<ComponentCallbacks2> callbacks = collectComponentCallbacks(false, config);

        // Cleanup hardware accelerated stuff
        // TODO: Do we actually want to do this in response to all config changes?
        WindowManagerGlobal.getInstance().trimLocalMemory();

        freeTextLayoutCachesIfNeeded(configDiff);

        if (callbacks != null) {
@@ -4100,9 +4096,6 @@ public final class ActivityThread {
    final void handleTrimMemory(int level) {
        if (DEBUG_MEMORY_TRIM) Slog.v(TAG, "Trimming memory to level: " + level);

        final WindowManagerGlobal windowManager = WindowManagerGlobal.getInstance();
        windowManager.startTrimMemory(level);

        ArrayList<ComponentCallbacks2> callbacks = collectComponentCallbacks(true, null);

        final int N = callbacks.size();
@@ -4110,7 +4103,7 @@ public final class ActivityThread {
            callbacks.get(i).onTrimMemory(level);
        }

        windowManager.endTrimMemory();
        WindowManagerGlobal.getInstance().trimMemory(level);
    }

    private void setupGraphicsSupport(LoadedApk info, File cacheDir) {
+0 −25
Original line number Diff line number Diff line
@@ -202,31 +202,6 @@ class GLES20Canvas extends HardwareCanvas {

    private static native int nCallDrawGLFunction(long renderer, long drawGLFunction);

    ///////////////////////////////////////////////////////////////////////////
    // Memory
    ///////////////////////////////////////////////////////////////////////////

    /**
     * Must match Caches::FlushMode values
     *
     * @see #flushCaches(int)
     */
    static final int FLUSH_CACHES_LAYERS = 0;

    /**
     * Must match Caches::FlushMode values
     *
     * @see #flushCaches(int)
     */
    static final int FLUSH_CACHES_MODERATE = 1;

    /**
     * Must match Caches::FlushMode values
     *
     * @see #flushCaches(int)
     */
    static final int FLUSH_CACHES_FULL = 2;

    ///////////////////////////////////////////////////////////////////////////
    // Display list
    ///////////////////////////////////////////////////////////////////////////
+11 −29
Original line number Diff line number Diff line
@@ -18,8 +18,6 @@ package android.view;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.graphics.SurfaceTexture;
import android.util.DisplayMetrics;
import android.view.Surface.OutOfResourcesException;

@@ -200,10 +198,8 @@ public abstract class HardwareRenderer {

    /**
     * Destroys the hardware rendering context.
     *
     * @param full If true, destroys all associated resources.
     */
    abstract void destroy(boolean full);
    abstract void destroy();

    /**
     * Initializes the hardware renderer for the specified surface.
@@ -435,28 +431,7 @@ public abstract class HardwareRenderer {
     *              see {@link android.content.ComponentCallbacks}
     */
    static void trimMemory(int level) {
        startTrimMemory(level);
        endTrimMemory();
    }

    /**
     * Starts the process of trimming memory. Usually this call will setup
     * hardware rendering context and reclaim memory.Extra cleanup might
     * be required by calling {@link #endTrimMemory()}.
     *
     * @param level Hint about the amount of memory that should be trimmed,
     *              see {@link android.content.ComponentCallbacks}
     */
    static void startTrimMemory(int level) {
        ThreadedRenderer.startTrimMemory(level);
    }

    /**
     * Finishes the process of trimming memory. This method will usually
     * cleanup special resources used by the memory trimming process.
     */
    static void endTrimMemory() {
        ThreadedRenderer.endTrimMemory();
        ThreadedRenderer.trimMemory(level);
    }

    /**
@@ -502,9 +477,16 @@ public abstract class HardwareRenderer {
     */
    abstract void fence();

    /**
     * Prevents any further drawing until draw() is called. This is a signal
     * that the contents of the RenderNode tree are no longer safe to play back.
     * In practice this usually means that there are Functor pointers in the
     * display list that are no longer valid.
     */
    abstract void stopDrawing();

    /**
     * Called by {@link ViewRootImpl} when a new performTraverals is scheduled.
     */
    public void notifyFramePending() {
    }
    abstract void notifyFramePending();
}
+12 −9
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ public class ThreadedRenderer extends HardwareRenderer {
    }

    @Override
    void destroy(boolean full) {
    void destroy() {
        mInitialized = false;
        updateEnabledState(null);
        nDestroyCanvasAndSurface(mNativeProxy);
@@ -127,7 +127,7 @@ public class ThreadedRenderer extends HardwareRenderer {
    @Override
    void destroyHardwareResources(View view) {
        destroyResources(view);
        nFlushCaches(mNativeProxy, GLES20Canvas.FLUSH_CACHES_LAYERS);
        nDestroyHardwareResources(mNativeProxy);
    }

    private static void destroyResources(View view) {
@@ -290,6 +290,11 @@ public class ThreadedRenderer extends HardwareRenderer {
        nFence(mNativeProxy);
    }

    @Override
    void stopDrawing() {
        nStopDrawing(mNativeProxy);
    }

    @Override
    public void notifyFramePending() {
        nNotifyFramePending(mNativeProxy);
@@ -305,12 +310,8 @@ public class ThreadedRenderer extends HardwareRenderer {
        }
    }

    static void startTrimMemory(int level) {
        // TODO
    }

    static void endTrimMemory() {
        // TODO
    static void trimMemory(int level) {
        nTrimMemory(level);
    }

    private static class AtlasInitializer {
@@ -405,9 +406,11 @@ public class ThreadedRenderer extends HardwareRenderer {
    private static native void nCancelLayerUpdate(long nativeProxy, long layer);
    private static native void nDetachSurfaceTexture(long nativeProxy, long layer);

    private static native void nFlushCaches(long nativeProxy, int flushMode);
    private static native void nDestroyHardwareResources(long nativeProxy);
    private static native void nTrimMemory(int level);

    private static native void nFence(long nativeProxy);
    private static native void nStopDrawing(long nativeProxy);
    private static native void nNotifyFramePending(long nativeProxy);

    private static native void nDumpProfileInfo(long nativeProxy, FileDescriptor fd);
+3 −1
Original line number Diff line number Diff line
@@ -13628,7 +13628,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * @hide
     */
    protected void destroyHardwareResources() {
        resetDisplayList();
        // Intentionally empty. RenderNode's lifecycle is now fully managed
        // by the hardware renderer.
        // However some subclasses (eg, WebView, TextureView) still need this signal
    }
    /**
Loading