Chromium Code Reviews| Index: android_webview/glue/java/src/com/android/webview/chromium/DrawGLFunctor.java |
| diff --git a/android_webview/glue/java/src/com/android/webview/chromium/DrawGLFunctor.java b/android_webview/glue/java/src/com/android/webview/chromium/DrawGLFunctor.java |
| index c618b1a1f8918e8e0d04fc9d07d0eb3a000bbe6f..694bb17c22277554d77c21dcf4e2d3e6e0e0a155 100644 |
| --- a/android_webview/glue/java/src/com/android/webview/chromium/DrawGLFunctor.java |
| +++ b/android_webview/glue/java/src/com/android/webview/chromium/DrawGLFunctor.java |
| @@ -10,6 +10,7 @@ import android.view.View; |
| import com.android.webview.chromium.WebViewDelegateFactory.WebViewDelegate; |
| +import org.chromium.android_webview.AwContents; |
| import org.chromium.content.common.CleanupReference; |
| /** |
| @@ -18,7 +19,7 @@ import org.chromium.content.common.CleanupReference; |
| * and then drawn and detached from the view tree any number of times (using requestDrawGL and |
| * detach respectively). |
| */ |
| -class DrawGLFunctor { |
| +class DrawGLFunctor implements AwContents.NativeDrawGLFunctor { |
| private static final String TAG = DrawGLFunctor.class.getSimpleName(); |
| // Pointer to native side instance |
| @@ -35,38 +36,28 @@ class DrawGLFunctor { |
| mWebViewDelegate = webViewDelegate; |
| } |
| + @Override |
| public void detach() { |
| if (mWebViewDelegate != null && mContainerView != null) { |
| mWebViewDelegate.detachDrawGlFunctor(mContainerView, mNativeDrawGLFunctor); |
| } |
| } |
| - private static final boolean sSupportFunctorReleasedCallback = |
| - (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) || "N".equals(Build.VERSION.CODENAME); |
| - public boolean requestDrawGL(Canvas canvas, View containerView, boolean waitForCompletion, |
| - Runnable releasedCallback) { |
| + private static final boolean sSupportFunctorReleasedCallback = (Build.VERSION.SDK_INT |
| + > Build.VERSION_CODES.M); // || "N".equals(Build.VERSION.CODENAME); |
| + |
| + @Override |
| + public boolean requestDrawGL(View containerView, Canvas canvas, Runnable releasedCallback) { |
| + assert canvas != null; |
| + |
| if (mDestroyRunnable.mNativeDrawGLFunctor == 0) { |
| throw new RuntimeException("requested DrawGL on already destroyed DrawGLFunctor"); |
| } |
| - if (canvas != null && waitForCompletion) { |
| - throw new IllegalArgumentException( |
| - "requested a blocking DrawGL with a not null canvas."); |
| - } |
| - |
| if (!mWebViewDelegate.canInvokeDrawGlFunctor(containerView)) { |
|
boliu
2016/04/20 15:38:32
yeah, don't need this check here :)
Tobias Sargeant
2016/04/20 16:00:31
The name kind of gave it away, but it *was* done i
boliu
2016/04/20 16:01:25
You can replace this check on the chromium side wi
|
| return false; |
| } |
| - mContainerView = containerView; |
| - |
| - if (canvas == null) { |
| - assert releasedCallback == null; |
| - mWebViewDelegate.invokeDrawGlFunctor( |
| - containerView, mDestroyRunnable.mNativeDrawGLFunctor, waitForCompletion); |
| - return true; |
| - } |
| - |
| if (sSupportFunctorReleasedCallback) { |
| assert releasedCallback != null; |
| mWebViewDelegate.callDrawGlFunction( |
| @@ -78,7 +69,25 @@ class DrawGLFunctor { |
| return true; |
| } |
| - public static boolean supportsDrawGLFunctorReleasedCallback() { |
| + @Override |
| + public boolean requestDrawGL(View containerView, boolean waitForCompletion) { |
| + if (mDestroyRunnable.mNativeDrawGLFunctor == 0) { |
| + throw new RuntimeException("requested DrawGL on already destroyed DrawGLFunctor"); |
| + } |
| + |
| + if (!mWebViewDelegate.canInvokeDrawGlFunctor(containerView)) { |
|
boliu
2016/04/20 16:01:25
We can actually remove this on N, ie where sSuppor
|
| + return false; |
| + } |
| + |
| + mContainerView = containerView; |
| + |
| + mWebViewDelegate.invokeDrawGlFunctor( |
| + containerView, mDestroyRunnable.mNativeDrawGLFunctor, waitForCompletion); |
| + return true; |
| + } |
| + |
| + @Override |
| + public boolean supportsDrawGLFunctorReleasedCallback() { |
| return sSupportFunctorReleasedCallback; |
| } |