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

Side by Side Diff: android_webview/java/src/org/chromium/android_webview/AwGLFunctor.java

Issue 1904453004: Transfer DrawGLFunctor ownership from AwContents to AwGLFunctor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Flow-on renaming 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 org.chromium.android_webview; 5 package org.chromium.android_webview;
6 6
7 import android.graphics.Canvas; 7 import android.graphics.Canvas;
8 import android.view.ViewGroup; 8 import android.view.ViewGroup;
9 9
10 import org.chromium.base.annotations.CalledByNative; 10 import org.chromium.base.annotations.CalledByNative;
(...skipping 17 matching lines...) Expand all
28 } 28 }
29 @Override 29 @Override
30 public void run() { 30 public void run() {
31 nativeDestroy(mNativeAwGLFunctor); 31 nativeDestroy(mNativeAwGLFunctor);
32 } 32 }
33 } 33 }
34 34
35 private final long mNativeAwGLFunctor; 35 private final long mNativeAwGLFunctor;
36 private final DestroyRunnable mDestroyRunnable; 36 private final DestroyRunnable mDestroyRunnable;
37 private final CleanupReference mCleanupReference; 37 private final CleanupReference mCleanupReference;
38 private final AwContents.NativeGLDelegate mNativeGLDelegate; 38 private final AwContents.NativeDrawGLFunctor mNativeDrawGLFunctor;
boliu 2016/04/20 16:49:09 needs a rebase now
39 private final ViewGroup mContainerView; 39 private final ViewGroup mContainerView;
40 private final Runnable mFunctorReleasedCallback; 40 private final Runnable mFunctorReleasedCallback;
41 41
42 public AwGLFunctor(AwContents.NativeGLDelegate nativeGLDelegate, ViewGroup c ontainerView) { 42 public AwGLFunctor(AwContents.NativeDrawGLFunctorFactory nativeDrawGLFunctor Factoy,
43 ViewGroup containerView) {
43 mNativeAwGLFunctor = nativeCreate(this); 44 mNativeAwGLFunctor = nativeCreate(this);
44 mDestroyRunnable = new DestroyRunnable(mNativeAwGLFunctor); 45 mDestroyRunnable = new DestroyRunnable(mNativeAwGLFunctor);
45 mCleanupReference = new CleanupReference(mDestroyRunnable, mDestroyRunna ble); 46 mCleanupReference = new CleanupReference(mDestroyRunnable, mDestroyRunna ble);
46 mNativeGLDelegate = nativeGLDelegate; 47 mNativeDrawGLFunctor = nativeDrawGLFunctorFactoy.createFunctor(getAwDraw GLViewContext());
47 mContainerView = containerView; 48 mContainerView = containerView;
48 if (mNativeGLDelegate.supportsDrawGLFunctorReleasedCallback()) { 49 if (mNativeDrawGLFunctor.supportsDrawGLFunctorReleasedCallback()) {
49 mFunctorReleasedCallback = new Runnable() { 50 mFunctorReleasedCallback = new Runnable() {
50 @Override 51 @Override
51 public void run() { 52 public void run() {
52 // Deliberate no-op. This Runnable is holding a strong refer ence back to the 53 // Deliberate no-op. This Runnable is holding a strong refer ence back to the
53 // AwGLFunctor, which serves its purpose for now. 54 // AwGLFunctor, which serves its purpose for now.
54 } 55 }
55 }; 56 };
56 } else { 57 } else {
57 mFunctorReleasedCallback = null; 58 mFunctorReleasedCallback = null;
58 } 59 }
59 } 60 }
60 61
61 public static long getAwDrawGLFunction() { 62 public static long getAwDrawGLFunction() {
62 return nativeGetAwDrawGLFunction(); 63 return nativeGetAwDrawGLFunction();
63 } 64 }
64 65
65 public long getNativeAwGLFunctor() { 66 public long getNativeAwGLFunctor() {
66 return mNativeAwGLFunctor; 67 return mNativeAwGLFunctor;
67 } 68 }
68 69
69 public Object getNativeLifetimeObject() { 70 public Object getNativeLifetimeObject() {
70 return mDestroyRunnable; 71 return mDestroyRunnable;
71 } 72 }
72 73
73 public boolean requestDrawGLForCanvas(Canvas canvas) { 74 public boolean requestDrawGLForCanvas(Canvas canvas) {
74 return mNativeGLDelegate.requestDrawGL( 75 return mNativeDrawGLFunctor.requestDrawGL(canvas, mFunctorReleasedCallba ck);
75 canvas, false, mContainerView, mFunctorReleasedCallback);
76 } 76 }
77 77
78 @CalledByNative 78 @CalledByNative
79 private boolean requestDrawGL(boolean waitForCompletion) { 79 private boolean requestInvokeGL(boolean waitForCompletion) {
80 return mNativeGLDelegate.requestDrawGL(null, waitForCompletion, mContain erView, null); 80 return mNativeDrawGLFunctor.requestInvokeGL(mContainerView, waitForCompl etion);
81 } 81 }
82 82
83 @CalledByNative 83 @CalledByNative
84 private void detachFunctorFromView() { 84 private void detachFunctorFromView() {
85 mNativeGLDelegate.detachGLFunctor(); 85 mNativeDrawGLFunctor.detach(mContainerView);
86 mContainerView.invalidate(); 86 mContainerView.invalidate();
87 } 87 }
88 88
89 public void deleteHardwareRenderer() { 89 public void deleteHardwareRenderer() {
90 nativeDeleteHardwareRenderer(mNativeAwGLFunctor); 90 nativeDeleteHardwareRenderer(mNativeAwGLFunctor);
91 } 91 }
92 92
93 public long getAwDrawGLViewContext() { 93 public long getAwDrawGLViewContext() {
94 return nativeGetAwDrawGLViewContext(mNativeAwGLFunctor); 94 return nativeGetAwDrawGLViewContext(mNativeAwGLFunctor);
95 } 95 }
96 96
97 private native void nativeDeleteHardwareRenderer(long nativeAwGLFunctor); 97 private native void nativeDeleteHardwareRenderer(long nativeAwGLFunctor);
98 private native long nativeGetAwDrawGLViewContext(long nativeAwGLFunctor); 98 private native long nativeGetAwDrawGLViewContext(long nativeAwGLFunctor);
99 99
100 private static native long nativeGetAwDrawGLFunction(); 100 private static native long nativeGetAwDrawGLFunction();
101 private static native void nativeDestroy(long nativeAwGLFunctor); 101 private static native void nativeDestroy(long nativeAwGLFunctor);
102 private static native long nativeCreate(AwGLFunctor javaProxy); 102 private static native long nativeCreate(AwGLFunctor javaProxy);
103 } 103 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698