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

Side by Side Diff: android_webview/glue/java/src/com/android/webview/chromium/DrawGLFunctor.java

Issue 1903673003: [Merge M50] aw: Do not destroy functor in destroy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
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 unified diff | Download patch
« no previous file with comments | « no previous file | android_webview/glue/java/src/com/android/webview/chromium/WebViewChromium.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package com.android.webview.chromium; 5 package com.android.webview.chromium;
6 6
7 import android.graphics.Canvas; 7 import android.graphics.Canvas;
8 import android.os.Build; 8 import android.os.Build;
9 import android.view.View; 9 import android.view.View;
10 10
11 import com.android.webview.chromium.WebViewDelegateFactory.WebViewDelegate; 11 import com.android.webview.chromium.WebViewDelegateFactory.WebViewDelegate;
12 12
13 import org.chromium.content.common.CleanupReference; 13 import org.chromium.content.common.CleanupReference;
14 14
15 /** 15 /**
16 * Simple Java abstraction and wrapper for the native DrawGLFunctor flow. 16 * Simple Java abstraction and wrapper for the native DrawGLFunctor flow.
17 * An instance of this class can be constructed, bound to a single view context (i.e. AwContennts) 17 * An instance of this class can be constructed, bound to a single view context (i.e. AwContennts)
18 * and then drawn and detached from the view tree any number of times (using req uestDrawGL and 18 * and then drawn and detached from the view tree any number of times (using req uestDrawGL and
19 * detach respectively). Then when finished with, it can be explicitly released by calling 19 * detach respectively).
20 * destroy() or will clean itself up as required via finalizer / CleanupReferenc e.
21 */ 20 */
22 class DrawGLFunctor { 21 class DrawGLFunctor {
23 private static final String TAG = DrawGLFunctor.class.getSimpleName(); 22 private static final String TAG = DrawGLFunctor.class.getSimpleName();
24 23
25 // Pointer to native side instance 24 // Pointer to native side instance
26 private CleanupReference mCleanupReference; 25 private CleanupReference mCleanupReference;
27 private DestroyRunnable mDestroyRunnable; 26 private DestroyRunnable mDestroyRunnable;
28 private final long mNativeDrawGLFunctor; 27 private final long mNativeDrawGLFunctor;
29 private WebViewDelegate mWebViewDelegate; 28 private WebViewDelegate mWebViewDelegate;
30 View mContainerView; 29 View mContainerView;
31 30
32 public DrawGLFunctor(long viewContext, WebViewDelegate webViewDelegate) { 31 public DrawGLFunctor(long viewContext, WebViewDelegate webViewDelegate) {
33 mNativeDrawGLFunctor = nativeCreateGLFunctor(viewContext); 32 mNativeDrawGLFunctor = nativeCreateGLFunctor(viewContext);
34 mDestroyRunnable = new DestroyRunnable(mNativeDrawGLFunctor); 33 mDestroyRunnable = new DestroyRunnable(mNativeDrawGLFunctor);
35 mCleanupReference = new CleanupReference(this, mDestroyRunnable); 34 mCleanupReference = new CleanupReference(this, mDestroyRunnable);
36 mWebViewDelegate = webViewDelegate; 35 mWebViewDelegate = webViewDelegate;
37 } 36 }
38 37
39 public void destroy() {
40 detach();
41 if (mCleanupReference != null) {
42 mCleanupReference.cleanupNow();
43 mCleanupReference = null;
44 mDestroyRunnable = null;
45 mWebViewDelegate = null;
46 mContainerView = null;
47 }
48 }
49
50 public void detach() { 38 public void detach() {
51 if (mWebViewDelegate != null && mContainerView != null) { 39 if (mWebViewDelegate != null && mContainerView != null) {
52 mWebViewDelegate.detachDrawGlFunctor(mContainerView, mNativeDrawGLFu nctor); 40 mWebViewDelegate.detachDrawGlFunctor(mContainerView, mNativeDrawGLFu nctor);
53 } 41 }
54 } 42 }
55 43
56 private static final boolean sSupportFunctorReleasedCallback = 44 private static final boolean sSupportFunctorReleasedCallback =
57 (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) || "N".equals(Build. VERSION.CODENAME); 45 (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) || "N".equals(Build. VERSION.CODENAME);
58 public boolean requestDrawGL(Canvas canvas, View containerView, boolean wait ForCompletion, 46 public boolean requestDrawGL(Canvas canvas, View containerView, boolean wait ForCompletion,
59 Runnable releasedCallback) { 47 Runnable releasedCallback) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 assert mNativeDrawGLFunctor != 0; 102 assert mNativeDrawGLFunctor != 0;
115 nativeDestroyGLFunctor(mNativeDrawGLFunctor); 103 nativeDestroyGLFunctor(mNativeDrawGLFunctor);
116 mNativeDrawGLFunctor = 0; 104 mNativeDrawGLFunctor = 0;
117 } 105 }
118 } 106 }
119 107
120 private static native long nativeCreateGLFunctor(long viewContext); 108 private static native long nativeCreateGLFunctor(long viewContext);
121 private static native void nativeDestroyGLFunctor(long functor); 109 private static native void nativeDestroyGLFunctor(long functor);
122 private static native void nativeSetChromiumAwDrawGLFunction(long functionPo inter); 110 private static native void nativeSetChromiumAwDrawGLFunction(long functionPo inter);
123 } 111 }
OLDNEW
« no previous file with comments | « no previous file | android_webview/glue/java/src/com/android/webview/chromium/WebViewChromium.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698