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

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: Connect BVR and RTM 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..e892db3123962fec5de21d8f926d951e3bf08b71
--- /dev/null
+++ b/android_webview/java/src/org/chromium/android_webview/AwGLFunctor.java
@@ -0,0 +1,90 @@
+// 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 android.graphics.Canvas;
+import android.view.ViewGroup;
+
+import org.chromium.base.annotations.CalledByNative;
+import org.chromium.base.annotations.JNINamespace;
+import org.chromium.content.common.CleanupReference;
+
+/**
+ */
+@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 ViewGroup mContainerView;
+ private final AwContents.NativeGLDelegate mNativeGLDelegate;
+
+ public AwGLFunctor(AwContents.NativeGLDelegate nativeGLDelegate) {
+ mContainerView = null;
+ mNativeGLDelegate = nativeGLDelegate;
+ mNativeAwGLFunctor = nativeCreate(this);
+ mCleanupReference = new CleanupReference(this, new DestroyRunnable(mNativeAwGLFunctor));
+ }
+
+ public void destroy() {
boliu 2016/04/06 16:09:01 nothing calls this so far
+ if (mCleanupReference != null) {
+ mCleanupReference.cleanupNow();
+ mCleanupReference = null;
+ }
+ }
+
+ public static long getAwDrawGLFunction() {
+ return nativeGetAwDrawGLFunction();
+ }
+
+ public long getNativeAwGLFunctor() {
+ return mNativeAwGLFunctor;
+ }
+
+ public void setContainerView(ViewGroup containerView) {
+ mContainerView = containerView;
+ }
+
+ public boolean requestDrawGL(Canvas canvas, boolean waitForCompletion) {
+ return mNativeGLDelegate.requestDrawGL(canvas, waitForCompletion, mContainerView);
+ }
+
+ @CalledByNative
+ private boolean requestDrawGL(boolean waitForCompletion) {
+ return mNativeGLDelegate.requestDrawGL(null, waitForCompletion, mContainerView);
+ }
+
+ @CalledByNative
+ private void detachFunctorFromView() {
+ mNativeGLDelegate.detachGLFunctor();
+ mContainerView.invalidate();
+ }
+
+ 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