diff options
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/view/View.java | 15 | ||||
| -rw-r--r-- | core/java/android/webkit/WebViewDelegate.java | 20 |
2 files changed, 35 insertions, 0 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 784164d243f1..117faf0b61ed 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -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; } /** diff --git a/core/java/android/webkit/WebViewDelegate.java b/core/java/android/webkit/WebViewDelegate.java index 8104f7d6f50c..b6516c85d094 100644 --- a/core/java/android/webkit/WebViewDelegate.java +++ b/core/java/android/webkit/WebViewDelegate.java @@ -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; @@ -109,6 +111,24 @@ public final class WebViewDelegate { } /** + * 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. * * @param nativeDrawGLFunctor the pointer to the native functor that implements |
