| 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 164f6dbe612b52972f739ad6a050fdfcdbf6d3eb..b89ec86fa20ce5c1010edd0f77fb4674332f5b67 100644
|
| --- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
|
| +++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
|
| @@ -256,8 +256,11 @@ public class AwContents implements SmartClipProvider,
|
|
|
| private long mNativeAwContents;
|
| private final AwBrowserContext mBrowserContext;
|
| + // mContainerView and mCurrentFunctor form a pair that needs to stay in sync.
|
| private ViewGroup mContainerView;
|
| - private AwGLFunctor mAwGLFunctor;
|
| + private AwGLFunctor mCurrentFunctor;
|
| + private AwGLFunctor mInitialFunctor;
|
| + private AwGLFunctor mFullScreenFunctor; // Only non-null when in fullscreen mode.
|
| private final Context mContext;
|
| private final int mAppTargetSdkVersion;
|
| private ContentViewCore mContentViewCore;
|
| @@ -351,19 +354,27 @@ public class AwContents implements SmartClipProvider,
|
|
|
| private static String sCurrentLocale = "";
|
|
|
| - private static final class DestroyRunnable implements Runnable {
|
| + private static final class AwContentsDestroyRunnable implements Runnable {
|
| private final long mNativeAwContents;
|
| // 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 Object mAwGLFunctorNativeLifetimeObject;
|
| + private final Object mInitialFunctorNativeLifetimeObject;
|
| + private Object mFullScreenFunctorNativeLifetimeObject;
|
|
|
| - private DestroyRunnable(long nativeAwContents, WindowAndroidWrapper windowAndroid,
|
| - AwGLFunctor awGLFunctor) {
|
| + private AwContentsDestroyRunnable(long nativeAwContents, WindowAndroidWrapper windowAndroid,
|
| + AwGLFunctor initialFunctor, AwGLFunctor fullScreenFunctor) {
|
| mNativeAwContents = nativeAwContents;
|
| mWindowAndroid = windowAndroid;
|
| - mAwGLFunctorNativeLifetimeObject = awGLFunctor.getNativeLifetimeObject();
|
| + mInitialFunctorNativeLifetimeObject = initialFunctor.getNativeLifetimeObject();
|
| + setFullScreenFunctor(fullScreenFunctor);
|
| }
|
| +
|
| + public void setFullScreenFunctor(AwGLFunctor fullScreenFunctor) {
|
| + mFullScreenFunctorNativeLifetimeObject =
|
| + fullScreenFunctor != null ? fullScreenFunctor.getNativeLifetimeObject() : null;
|
| + }
|
| +
|
| @Override
|
| public void run() {
|
| nativeDestroy(mNativeAwContents);
|
| @@ -427,6 +438,7 @@ public class AwContents implements SmartClipProvider,
|
| // Reference to the active mNativeAwContents pointer while it is active use
|
| // (ie before it is destroyed).
|
| private CleanupReference mCleanupReference;
|
| + private AwContentsDestroyRunnable mAwContentsDestroyRunnable;
|
|
|
| //--------------------------------------------------------------------------------------------
|
| private class IoThreadClientImpl extends AwContentsIoThreadClient {
|
| @@ -679,7 +691,10 @@ public class AwContents implements SmartClipProvider,
|
| @Override
|
| public void run() {
|
| if (level >= TRIM_MEMORY_MODERATE) {
|
| - mAwGLFunctor.deleteHardwareRenderer();
|
| + mInitialFunctor.deleteHardwareRenderer();
|
| + if (mFullScreenFunctor != null) {
|
| + mFullScreenFunctor.deleteHardwareRenderer();
|
| + }
|
| }
|
| nativeTrimMemory(mNativeAwContents, level, visible);
|
| }
|
| @@ -743,6 +758,8 @@ public class AwContents implements SmartClipProvider,
|
| mAppTargetSdkVersion = mContext.getApplicationInfo().targetSdkVersion;
|
| mInternalAccessAdapter = internalAccessAdapter;
|
| mNativeDrawGLFunctorFactory = nativeDrawGLFunctorFactory;
|
| + mInitialFunctor = new AwGLFunctor(mNativeDrawGLFunctorFactory, mContainerView);
|
| + mCurrentFunctor = mInitialFunctor;
|
| mContentsClient = contentsClient;
|
| mAwViewMethods = new AwViewMethodsImpl();
|
| mFullScreenTransitionsState = new FullScreenTransitionsState(
|
| @@ -838,12 +855,14 @@ public class AwContents implements SmartClipProvider,
|
| if (wasInitialContainerViewFocused) {
|
| fullScreenView.requestFocus();
|
| }
|
| + mFullScreenFunctor = new AwGLFunctor(mNativeDrawGLFunctorFactory, fullScreenView);
|
| + mAwContentsDestroyRunnable.setFullScreenFunctor(mFullScreenFunctor);
|
| mFullScreenTransitionsState.enterFullScreen(fullScreenView, wasInitialContainerViewFocused);
|
| mAwViewMethods = new NullAwViewMethods(this, mInternalAccessAdapter, mContainerView);
|
|
|
| // Associate this AwContents with the FullScreenView.
|
| setInternalAccessAdapter(fullScreenView.getInternalAccessAdapter());
|
| - setContainerView(fullScreenView);
|
| + setContainerView(fullScreenView, mFullScreenFunctor);
|
|
|
| return fullScreenView;
|
| }
|
| @@ -884,13 +903,16 @@ public class AwContents implements SmartClipProvider,
|
|
|
| // Re-associate this AwContents with the WebView.
|
| setInternalAccessAdapter(mFullScreenTransitionsState.getInitialInternalAccessDelegate());
|
| - setContainerView(initialContainerView);
|
| + setContainerView(initialContainerView, mInitialFunctor);
|
|
|
| // Return focus to the WebView.
|
| if (mFullScreenTransitionsState.wasInitialContainerViewFocused()) {
|
| mContainerView.requestFocus();
|
| }
|
| mFullScreenTransitionsState.exitFullScreen();
|
| + // Explicitly destroy the full screen functor now.
|
| + mAwContentsDestroyRunnable.setFullScreenFunctor(null);
|
| + mFullScreenFunctor = null;
|
| }
|
|
|
| private void setInternalAccessAdapter(InternalAccessDelegate internalAccessAdapter) {
|
| @@ -898,11 +920,12 @@ public class AwContents implements SmartClipProvider,
|
| mContentViewCore.setContainerViewInternals(mInternalAccessAdapter);
|
| }
|
|
|
| - private void setContainerView(ViewGroup newContainerView) {
|
| + private void setContainerView(ViewGroup newContainerView, AwGLFunctor currentFunctor) {
|
| // setWillNotDraw(false) is required since WebView draws it's own contents using it's
|
| // container view. If this is ever not the case we should remove this, as it removes
|
| // Android's gatherTransparentRegion optimization for the view.
|
| mContainerView = newContainerView;
|
| + makeFunctorCurrent(currentFunctor);
|
| mContainerView.setWillNotDraw(false);
|
|
|
| mContentViewCore.setContainerView(mContainerView);
|
| @@ -994,6 +1017,16 @@ public class AwContents implements SmartClipProvider,
|
| }
|
| }
|
|
|
| + private void makeFunctorCurrent(AwGLFunctor functor) {
|
| + mCurrentFunctor = functor;
|
| + updateNativeAwGLFunctor();
|
| + }
|
| +
|
| + private void updateNativeAwGLFunctor() {
|
| + nativeSetAwGLFunctor(mNativeAwContents,
|
| + mCurrentFunctor != null ? mCurrentFunctor.getNativeAwGLFunctor() : 0);
|
| + }
|
| +
|
| /* Common initialization routine for adopting a native AwContents instance into this
|
| * java instance.
|
| *
|
| @@ -1011,6 +1044,8 @@ public class AwContents implements SmartClipProvider,
|
| assert mNativeAwContents == 0 && mCleanupReference == null && mContentViewCore == null;
|
|
|
| mNativeAwContents = newAwContentsPtr;
|
| + nativeSetAwGLFunctor(mNativeAwContents, mInitialFunctor.getNativeAwGLFunctor());
|
| + updateNativeAwGLFunctor();
|
| // TODO(joth): when the native and java counterparts of AwBrowserContext are hooked up to
|
| // each other, we should update |mBrowserContext| according to the newly received native
|
| // WebContent's browser context.
|
| @@ -1021,8 +1056,6 @@ public class AwContents implements SmartClipProvider,
|
| mContentViewCore = createAndInitializeContentViewCore(mContainerView, mContext,
|
| mInternalAccessAdapter, webContents, new AwGestureStateListener(),
|
| mContentViewClient, mZoomControls, mWindowAndroid.getWindowAndroid());
|
| - mAwGLFunctor = new AwGLFunctor(mNativeDrawGLFunctorFactory, mContainerView);
|
| - nativeSetAwGLFunctor(mNativeAwContents, mAwGLFunctor.getNativeAwGLFunctor());
|
| nativeSetJavaPeers(mNativeAwContents, this, mWebContentsDelegate, mContentsClientBridge,
|
| mIoThreadClient, mInterceptNavigationDelegate);
|
| mWebContents = mContentViewCore.getWebContents();
|
| @@ -1034,8 +1067,9 @@ 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, mAwGLFunctor));
|
| + mAwContentsDestroyRunnable = new AwContentsDestroyRunnable(
|
| + mNativeAwContents, mWindowAndroid, mInitialFunctor, mFullScreenFunctor);
|
| + mCleanupReference = new CleanupReference(this, mAwContentsDestroyRunnable);
|
| }
|
|
|
| private void installWebContentsObserver() {
|
| @@ -1141,7 +1175,6 @@ public class AwContents implements SmartClipProvider,
|
| // hardware resources.
|
| if (mIsAttachedToWindow) {
|
| Log.w(TAG, "WebView.destroy() called while WebView is still attached to window.");
|
| - mAwGLFunctor.deleteHardwareRenderer();
|
| nativeOnDetachedFromWindow(mNativeAwContents);
|
| }
|
| mIsDestroyed = true;
|
| @@ -1269,13 +1302,6 @@ public class AwContents implements SmartClipProvider,
|
| return nativeGetNativeInstanceCount();
|
| }
|
|
|
| - public long getAwDrawGLViewContext() {
|
| - // Only called during early construction, so client should not have had a chance to
|
| - // call destroy yet.
|
| - assert !isDestroyed(NO_WARN);
|
| - return mAwGLFunctor.getAwDrawGLViewContext();
|
| - }
|
| -
|
| // This is only to avoid heap allocations inside getGlobalVisibleRect. It should treated
|
| // as a local variable in the function and not used anywhere else.
|
| private static final Rect sLocalGlobalVisibleRect = new Rect();
|
| @@ -2966,7 +2992,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 = mAwGLFunctor.requestDrawGLForCanvas(canvas);
|
| + did_draw = mCurrentFunctor.requestDrawGL(canvas);
|
| }
|
| if (did_draw) {
|
| int scrollXDiff = mContainerView.getScrollX() - scrollX;
|
| @@ -3134,7 +3160,6 @@ public class AwContents implements SmartClipProvider,
|
| }
|
| mIsAttachedToWindow = false;
|
| hideAutofillPopup();
|
| - mAwGLFunctor.deleteHardwareRenderer();
|
| nativeOnDetachedFromWindow(mNativeAwContents);
|
|
|
| mContentViewCore.onDetachedFromWindow();
|
|
|