From e66471103abfc8b9142d895bac93dade67f558c3 Mon Sep 17 00:00:00 2001 From: Bo Liu Date: Fri, 15 Apr 2016 16:28:18 -0700 Subject: [PATCH] Expose DisplayListCanvas.drawGLFunctor to webview BUG: 27709981 Change-Id: If3d2f57bfa50450e5f6834ef3ec2f48e26c294a6 --- api/system-current.txt | 1 + core/java/android/webkit/WebViewDelegate.java | 24 ++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/api/system-current.txt b/api/system-current.txt index 26ea220b4afa8..5b97154b756ea 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -48762,6 +48762,7 @@ package android.webkit { public final class WebViewDelegate { method public void addWebViewAssetPath(android.content.Context); method public void callDrawGlFunction(android.graphics.Canvas, long); + method public void callDrawGlFunction(android.graphics.Canvas, long, java.lang.Runnable); method public boolean canInvokeDrawGlFunctor(android.view.View); method public void detachDrawGlFunctor(android.view.View, long); method public android.app.Application getApplication(); diff --git a/core/java/android/webkit/WebViewDelegate.java b/core/java/android/webkit/WebViewDelegate.java index b6516c85d0949..2b548750246d5 100644 --- a/core/java/android/webkit/WebViewDelegate.java +++ b/core/java/android/webkit/WebViewDelegate.java @@ -107,7 +107,29 @@ public final class WebViewDelegate { throw new IllegalArgumentException(canvas.getClass().getName() + " is not a DisplayList canvas"); } - ((DisplayListCanvas) canvas).callDrawGLFunction2(nativeDrawGLFunctor); + ((DisplayListCanvas) canvas).drawGLFunctor2(nativeDrawGLFunctor, null); + } + + /** + * Calls the function specified with the nativeDrawGLFunctor functor pointer. This + * functionality is used by the WebView for calling into their renderer from the + * framework display lists. + * + * @param canvas a hardware accelerated canvas (see {@link Canvas#isHardwareAccelerated()}) + * @param nativeDrawGLFunctor the pointer to the native functor that implements + * system/core/include/utils/Functor.h + * @param releasedRunnable Called when this nativeDrawGLFunctor is no longer referenced by this + * canvas, so is safe to be destroyed. + * @throws IllegalArgumentException if the canvas is not hardware accelerated + */ + public void callDrawGlFunction(@NonNull Canvas canvas, long nativeDrawGLFunctor, + @Nullable Runnable releasedRunnable) { + if (!(canvas instanceof DisplayListCanvas)) { + // Canvas#isHardwareAccelerated() is only true for subclasses of HardwareCanvas. + throw new IllegalArgumentException(canvas.getClass().getName() + + " is not a DisplayList canvas"); + } + ((DisplayListCanvas) canvas).drawGLFunctor2(nativeDrawGLFunctor, releasedRunnable); } /**