Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1505)

Unified Diff: android_webview/glue/java/src/com/android/webview/chromium/DrawGLFunctor.java

Issue 1904453004: Transfer DrawGLFunctor ownership from AwContents to AwGLFunctor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Flow-on renaming Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..7b1427b6822664c0b647b837aca046c72c3922fa 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,15 +19,14 @@ 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
- private CleanupReference mCleanupReference;
- private DestroyRunnable mDestroyRunnable;
+ private final CleanupReference mCleanupReference;
+ private final DestroyRunnable mDestroyRunnable;
private final long mNativeDrawGLFunctor;
boliu 2016/04/20 16:49:09 this looks unused
- private WebViewDelegate mWebViewDelegate;
- View mContainerView;
+ private final WebViewDelegate mWebViewDelegate;
public DrawGLFunctor(long viewContext, WebViewDelegate webViewDelegate) {
mNativeDrawGLFunctor = nativeCreateGLFunctor(viewContext);
@@ -35,38 +35,21 @@ class DrawGLFunctor {
mWebViewDelegate = webViewDelegate;
}
- public void detach() {
- if (mWebViewDelegate != null && mContainerView != null) {
- mWebViewDelegate.detachDrawGlFunctor(mContainerView, mNativeDrawGLFunctor);
- }
+ @Override
+ public void detach(View containerView) {
+ mWebViewDelegate.detachDrawGlFunctor(containerView, 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(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)) {
- 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 +61,24 @@ class DrawGLFunctor {
return true;
}
- public static boolean supportsDrawGLFunctorReleasedCallback() {
+ @Override
+ public boolean requestInvokeGL(View containerView, boolean waitForCompletion) {
+ if (mDestroyRunnable.mNativeDrawGLFunctor == 0) {
boliu 2016/04/20 16:49:09 This can't ever happen. There is no explicit destr
+ throw new RuntimeException("requested DrawGL on already destroyed DrawGLFunctor");
+ }
+
+ if (!sSupportFunctorReleasedCallback
+ && !mWebViewDelegate.canInvokeDrawGlFunctor(containerView)) {
+ return false;
+ }
+
+ mWebViewDelegate.invokeDrawGlFunctor(
+ containerView, mDestroyRunnable.mNativeDrawGLFunctor, waitForCompletion);
+ return true;
+ }
+
+ @Override
+ public boolean supportsDrawGLFunctorReleasedCallback() {
return sSupportFunctorReleasedCallback;
}

Powered by Google App Engine
This is Rietveld 408576698