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

Commit ee34ef16 authored by Bo Liu's avatar Bo Liu
Browse files

Expose setDrawGLFunctionDetachedCallback to webview

Add WebViewDelegate.setDrawGLFunctionDetachedCallback system API that's
used for webview to receive the functor detach callback.

BUG: 27709981
Change-Id: Ie6b5e445c0090a181f94fcd2ec1ea77095c9cb03
parent 6c4af8c9
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -48655,6 +48655,7 @@ package android.webkit {
    method public int getPackageId(android.content.res.Resources, java.lang.String);
    method public void invokeDrawGlFunctor(android.view.View, long, boolean);
    method public boolean isTraceTagEnabled();
    method public java.lang.Runnable setDrawGlFunctionDetachedCallback(android.view.View, java.lang.Runnable);
    method public void setOnTraceEnabledChangeListener(android.webkit.WebViewDelegate.OnTraceEnabledChangeListener);
  }
+15 −0
Original line number Diff line number Diff line
@@ -3890,6 +3890,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * cleanup.
     */
    final RenderNode mRenderNode;
    private Runnable mRenderNodeDetachedCallback;
    /**
     * Set to true when the view is sending hover accessibility events because it
@@ -16013,6 +16014,20 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * @hide
     */
    public void onRenderNodeDetached(RenderNode renderNode) {
        if (renderNode == mRenderNode && mRenderNodeDetachedCallback != null) {
            mRenderNodeDetachedCallback.run();
        }
    }
    /**
     * Set callback for functor detach. Exposed to WebView through WebViewDelegate.
     * Should not be used otherwise.
     * @hide
     */
    public final Runnable setRenderNodeDetachedCallback(@Nullable Runnable callback) {
        Runnable oldCallback = mRenderNodeDetachedCallback;
        mRenderNodeDetachedCallback = callback;
        return oldCallback;
    }
    /**
+20 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.webkit;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.app.ActivityThread;
import android.app.Application;
@@ -108,6 +110,24 @@ public final class WebViewDelegate {
        ((DisplayListCanvas) canvas).callDrawGLFunction2(nativeDrawGLFunctor);
    }

    /**
     * Set the Runnable callback the DrawGlFunction functor is detached and free to be destroyed.
     * This will replace the previous callback, if any.
     *
     * @param view The view to set the callback. Should be the view where onDraw inserted
     *        DrawGLFunctor.
     * @param callback The new callback to set on the view.
     * @throws IllegalArgumentException if view is null.
     * @return The previous callback on this view.
     */
    public Runnable setDrawGlFunctionDetachedCallback(
        @NonNull View view, @Nullable Runnable callback) {
        if (view == null) {
            throw new IllegalArgumentException("View cannot be null");
        }
        return view.setRenderNodeDetachedCallback(callback);
    }

    /**
     * Detaches the draw GL functor.
     *