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

Unified Diff: android_webview/java/src/org/chromium/android_webview/AwGLFunctor.java

Issue 1844343005: WIP - Control the lifetime of RenderThreadManager from Java. (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/java/src/org/chromium/android_webview/AwGLFunctor.java
diff --git a/android_webview/java/src/org/chromium/android_webview/AwGLFunctor.java b/android_webview/java/src/org/chromium/android_webview/AwGLFunctor.java
new file mode 100644
index 0000000000000000000000000000000000000000..3b5077368e280901bd652d45c4f9db6b07d2ba58
--- /dev/null
+++ b/android_webview/java/src/org/chromium/android_webview/AwGLFunctor.java
@@ -0,0 +1,81 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.android_webview;
+
+import org.chromium.base.annotations.CalledByNative;
+import org.chromium.base.annotations.JNINamespace;
+import org.chromium.content.common.CleanupReference;
+
+/**
boliu 2016/04/07 18:14:03 Write some javadoc :)
+ */
+@JNINamespace("android_webview")
+class AwGLFunctor {
+ private static final class DestroyRunnable implements Runnable {
+ private final long mNativeAwGLFunctor;
+
+ private DestroyRunnable(long nativeAwGLFunctor) {
+ mNativeAwGLFunctor = nativeAwGLFunctor;
+ }
+ @Override
+ public void run() {
+ nativeDestroy(mNativeAwGLFunctor);
+ }
+ }
+
+ private long mNativeAwGLFunctor;
+ private CleanupReference mCleanupReference;
+ private AwContents mAwContents;
+
+ public AwGLFunctor(AwContents.NativeGLDelegate nativeGLDelegate) {
boliu 2016/04/07 18:14:03 remove arg
Tobias Sargeant 2016/04/07 21:07:35 Done.
+ mAwContents = null;
boliu 2016/04/07 18:14:03 redundant
Tobias Sargeant 2016/04/07 21:07:35 Done.
+ mNativeAwGLFunctor = nativeCreate(this);
+ mCleanupReference = new CleanupReference(this, new DestroyRunnable(mNativeAwGLFunctor));
+ }
+
+ public void setAwContents(AwContents awContents) {
+ mAwContents = awContents;
+ }
+
+ public void destroy() {
+ if (mCleanupReference != null) {
+ mCleanupReference.cleanupNow();
+ mCleanupReference = null;
boliu 2016/04/07 18:14:03 set mNativeAwGLFunctor to 0 here, then assert mNat
Tobias Sargeant 2016/04/07 21:07:35 Done.
+ }
+ }
+
+ public static long getAwDrawGLFunction() {
+ return nativeGetAwDrawGLFunction();
+ }
+
+ public long getNativeAwGLFunctor() {
+ return mNativeAwGLFunctor;
+ }
+
+ @CalledByNative
+ private boolean requestDrawGL(boolean waitForCompletion) {
+ if (mAwContents == null) return false;
+ return mAwContents.requestDrawGL(waitForCompletion);
+ }
+
+ @CalledByNative
+ private void detachFunctorFromView() {
+ if (mAwContents != null) mAwContents.detachFunctorFromView();
boliu 2016/04/07 18:14:03 the else case deserves a warning log, should never
Tobias Sargeant 2016/04/07 21:07:35 Done.
+ }
+
+ public void deleteHardwareRenderer() {
+ nativeDeleteHardwareRenderer(mNativeAwGLFunctor);
+ }
+
+ public long getAwDrawGLViewContext() {
+ return nativeGetAwDrawGLViewContext(mNativeAwGLFunctor);
+ }
+
+ private native void nativeDeleteHardwareRenderer(long nativeAwGLFunctor);
+ private native long nativeGetAwDrawGLViewContext(long nativeAwGLFunctor);
+
+ private static native long nativeGetAwDrawGLFunction();
+ private static native void nativeDestroy(long nativeAwGLFunctor);
+ private static native long nativeCreate(AwGLFunctor javaProxy);
+}

Powered by Google App Engine
This is Rietveld 408576698