Chromium Code Reviews| 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); |
| +} |