| Index: android_webview/java/src/org/chromium/android_webview/AwContents.java
|
| diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java
|
| index 657f1f81078f37d1e287cf283edd36d3969ee06c..a2f4d4d4757e5f9fd90a4e8c596e9150b4df91ff 100644
|
| --- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
|
| +++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
|
| @@ -220,6 +220,7 @@ public class AwContents implements SmartClipProvider,
|
| private long mNativeAwContents;
|
| private final AwBrowserContext mBrowserContext;
|
| private ViewGroup mContainerView;
|
| + private AwGLFunctor mAwGLFunctor;
|
| private final Context mContext;
|
| private final int mAppTargetSdkVersion;
|
| private ContentViewCore mContentViewCore;
|
| @@ -318,10 +319,13 @@ public class AwContents implements SmartClipProvider,
|
| // Hold onto a reference to the window (via its wrapper), so that it is not destroyed
|
| // until we are done here.
|
| private final WindowAndroidWrapper mWindowAndroid;
|
| + private final AwGLFunctor mAwGLFunctor;
|
|
|
| - private DestroyRunnable(long nativeAwContents, WindowAndroidWrapper windowAndroid) {
|
| + private DestroyRunnable(long nativeAwContents, WindowAndroidWrapper windowAndroid,
|
| + AwGLFunctor awGLFunctor) {
|
| mNativeAwContents = nativeAwContents;
|
| mWindowAndroid = windowAndroid;
|
| + mAwGLFunctor = awGLFunctor;
|
| }
|
| @Override
|
| public void run() {
|
| @@ -637,6 +641,9 @@ public class AwContents implements SmartClipProvider,
|
| ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| @Override
|
| public void run() {
|
| + if (level >= 60) { // XXX: TRIM_MEMORY_MODERATE
|
| + mAwGLFunctor.deleteHardwareRenderer();
|
| + }
|
| nativeTrimMemory(mNativeAwContents, level, visible);
|
| }
|
| });
|
| @@ -865,6 +872,7 @@ public class AwContents implements SmartClipProvider,
|
| mAwPdfExporter.setContainerView(mContainerView);
|
| }
|
| mWebContentsDelegate.setContainerView(mContainerView);
|
| + mAwGLFunctor.setContainerView(mContainerView);
|
|
|
| onContainerViewChanged();
|
| }
|
| @@ -967,6 +975,9 @@ public class AwContents implements SmartClipProvider,
|
| mContentViewCore = createAndInitializeContentViewCore(mContainerView, mContext,
|
| mInternalAccessAdapter, webContents, new AwGestureStateListener(),
|
| mContentViewClient, mZoomControls, mWindowAndroid.getWindowAndroid());
|
| + mAwGLFunctor = new AwGLFunctor(mNativeGLDelegate);
|
| + mAwGLFunctor.setContainerView(mContainerView);
|
| + nativeSetAwGLFunctor(mNativeAwContents, mAwGLFunctor.getNativeAwGLFunctor());
|
| nativeSetJavaPeers(mNativeAwContents, this, mWebContentsDelegate, mContentsClientBridge,
|
| mIoThreadClient, mInterceptNavigationDelegate);
|
| mWebContents = mContentViewCore.getWebContents();
|
| @@ -978,8 +989,8 @@ public class AwContents implements SmartClipProvider,
|
|
|
| // The native side object has been bound to this java instance, so now is the time to
|
| // bind all the native->java relationships.
|
| - mCleanupReference =
|
| - new CleanupReference(this, new DestroyRunnable(mNativeAwContents, mWindowAndroid));
|
| + mCleanupReference = new CleanupReference(
|
| + this, new DestroyRunnable(mNativeAwContents, mWindowAndroid, mAwGLFunctor));
|
| }
|
|
|
| private void installWebContentsObserver() {
|
| @@ -1183,7 +1194,7 @@ public class AwContents implements SmartClipProvider,
|
| }
|
|
|
| public static long getAwDrawGLFunction() {
|
| - return nativeGetAwDrawGLFunction();
|
| + return AwGLFunctor.getAwDrawGLFunction();
|
| }
|
|
|
| public static void setShouldDownloadFavicons() {
|
| @@ -1216,10 +1227,7 @@ public class AwContents implements SmartClipProvider,
|
| // Only called during early construction, so client should not have had a chance to
|
| // call destroy yet.
|
| assert !isDestroyed(NO_WARN);
|
| -
|
| - // Using the native pointer as the returned viewContext. This is matched by the
|
| - // reinterpret_cast back to BrowserViewRenderer pointer in the native DrawGLFunction.
|
| - return nativeGetAwDrawGLViewContext(mNativeAwContents);
|
| + return mAwGLFunctor.getAwDrawGLViewContext();
|
| }
|
|
|
| // This is only to avoid heap allocations inside getGlobalVisibleRect. It should treated
|
| @@ -2695,11 +2703,6 @@ public class AwContents implements SmartClipProvider,
|
| }
|
|
|
| @CalledByNative
|
| - private boolean requestDrawGL(boolean waitForCompletion) {
|
| - return mNativeGLDelegate.requestDrawGL(null, waitForCompletion, mContainerView);
|
| - }
|
| -
|
| - @CalledByNative
|
| private void postInvalidateOnAnimation() {
|
| if (!mWindowAndroid.getWindowAndroid().isInsideVSync()) {
|
| mContainerView.postInvalidateOnAnimation();
|
| @@ -2708,14 +2711,6 @@ public class AwContents implements SmartClipProvider,
|
| }
|
| }
|
|
|
| - // Call postInvalidateOnAnimation for invalidations. This is only used to synchronize
|
| - // draw functor destruction.
|
| - @CalledByNative
|
| - private void detachFunctorFromView() {
|
| - mNativeGLDelegate.detachGLFunctor();
|
| - mContainerView.invalidate();
|
| - }
|
| -
|
| @CalledByNative
|
| private int[] getLocationOnScreen() {
|
| int[] result = new int[2];
|
| @@ -2922,7 +2917,7 @@ public class AwContents implements SmartClipProvider,
|
| canvas.isHardwareAccelerated(), scrollX, scrollY, globalVisibleRect.left,
|
| globalVisibleRect.top, globalVisibleRect.right, globalVisibleRect.bottom);
|
| if (did_draw && canvas.isHardwareAccelerated() && !FORCE_AUXILIARY_BITMAP_RENDERING) {
|
| - did_draw = mNativeGLDelegate.requestDrawGL(canvas, false, mContainerView);
|
| + did_draw = mAwGLFunctor.requestDrawGL(canvas, false);
|
| }
|
| if (did_draw) {
|
| int scrollXDiff = mContainerView.getScrollX() - scrollX;
|
| @@ -3090,6 +3085,7 @@ public class AwContents implements SmartClipProvider,
|
| }
|
| mIsAttachedToWindow = false;
|
| hideAutofillPopup();
|
| + mAwGLFunctor.deleteHardwareRenderer();
|
| nativeOnDetachedFromWindow(mNativeAwContents);
|
|
|
| mContentViewCore.onDetachedFromWindow();
|
| @@ -3222,7 +3218,6 @@ public class AwContents implements SmartClipProvider,
|
| boolean forceAuxiliaryBitmapRendering);
|
| private static native void nativeSetAwDrawSWFunctionTable(long functionTablePointer);
|
| private static native void nativeSetAwDrawGLFunctionTable(long functionTablePointer);
|
| - private static native long nativeGetAwDrawGLFunction();
|
| private static native int nativeGetNativeInstanceCount();
|
| private static native void nativeSetShouldDownloadFavicons();
|
| private static native void nativeSetLocale(String locale);
|
| @@ -3233,6 +3228,7 @@ public class AwContents implements SmartClipProvider,
|
| AwContentsIoThreadClient ioThreadClient,
|
| InterceptNavigationDelegate navigationInterceptionDelegate);
|
| private native WebContents nativeGetWebContents(long nativeAwContents);
|
| + private native void nativeSetAwGLFunctor(long nativeAwContents, long nativeAwGLFunctor);
|
|
|
| private native void nativeDocumentHasImages(long nativeAwContents, Message message);
|
| private native void nativeGenerateMHTML(
|
| @@ -3278,7 +3274,6 @@ public class AwContents implements SmartClipProvider,
|
| private native void nativeFocusFirstNode(long nativeAwContents);
|
| private native void nativeSetBackgroundColor(long nativeAwContents, int color);
|
|
|
| - private native long nativeGetAwDrawGLViewContext(long nativeAwContents);
|
| private native long nativeCapturePicture(long nativeAwContents, int width, int height);
|
| private native void nativeEnableOnNewPicture(long nativeAwContents, boolean enabled);
|
| private native void nativeInsertVisualStateCallback(
|
|
|