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

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

Issue 872403006: aw: Make repeated detachGLFunctor work (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 34348b79a1a78dba8feefb4889341b6b7b4a7de7..b12cb048e85eba15fdbfa6cde9be3c934be7c034 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
@@ -24,10 +24,13 @@ class DrawGLFunctor {
// Pointer to native side instance
private CleanupReference mCleanupReference;
private DestroyRunnable mDestroyRunnable;
+ private final long mNativeDrawGLFunctor;
private WebViewDelegate mWebViewDelegate;
+ View mContainerView;
public DrawGLFunctor(long viewContext, WebViewDelegate webViewDelegate) {
- mDestroyRunnable = new DestroyRunnable(nativeCreateGLFunctor(viewContext), webViewDelegate);
+ mNativeDrawGLFunctor = nativeCreateGLFunctor(viewContext);
+ mDestroyRunnable = new DestroyRunnable(mNativeDrawGLFunctor);
mCleanupReference = new CleanupReference(this, mDestroyRunnable);
mWebViewDelegate = webViewDelegate;
}
@@ -39,11 +42,14 @@ class DrawGLFunctor {
mCleanupReference = null;
mDestroyRunnable = null;
mWebViewDelegate = null;
+ mContainerView = null;
}
}
public void detach() {
- mDestroyRunnable.detachNativeFunctor();
+ if (mWebViewDelegate != null && mContainerView != null) {
+ mWebViewDelegate.detachDrawGlFunctor(mContainerView, mNativeDrawGLFunctor);
+ }
}
public boolean requestDrawGL(Canvas canvas, View containerView, boolean waitForCompletion) {
@@ -60,7 +66,7 @@ class DrawGLFunctor {
return false;
}
- mDestroyRunnable.mContainerView = containerView;
+ mContainerView = containerView;
if (canvas == null) {
mWebViewDelegate.invokeDrawGlFunctor(
@@ -80,29 +86,19 @@ class DrawGLFunctor {
// IMPORTANT: this class must not hold any reference back to the outer DrawGLFunctor
// instance, as that will defeat GC of that object.
private static final class DestroyRunnable implements Runnable {
- private WebViewDelegate mWebViewDelegate;
- View mContainerView;
- long mNativeDrawGLFunctor;
- DestroyRunnable(long nativeDrawGLFunctor, WebViewDelegate webViewDelegate) {
+ private long mNativeDrawGLFunctor;
+ DestroyRunnable(long nativeDrawGLFunctor) {
mNativeDrawGLFunctor = nativeDrawGLFunctor;
- mWebViewDelegate = webViewDelegate;
+ assert mNativeDrawGLFunctor != 0;
}
// Called when the outer DrawGLFunctor instance has been GC'ed, i.e this is its finalizer.
@Override
public void run() {
- detachNativeFunctor();
+ assert mNativeDrawGLFunctor != 0;
nativeDestroyGLFunctor(mNativeDrawGLFunctor);
mNativeDrawGLFunctor = 0;
}
-
- void detachNativeFunctor() {
- if (mNativeDrawGLFunctor != 0 && mContainerView != null && mWebViewDelegate != null) {
- mWebViewDelegate.detachDrawGlFunctor(mContainerView, mNativeDrawGLFunctor);
- }
- mContainerView = null;
- mWebViewDelegate = null;
- }
}
private static native long nativeCreateGLFunctor(long viewContext);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698