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

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: 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..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;
}

Powered by Google App Engine
This is Rietveld 408576698