OLD | NEW |
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 #include "android_webview/native/aw_gl_functor.h" | 5 #include "android_webview/native/aw_gl_functor.h" |
6 | 6 |
7 #include "android_webview/public/browser/draw_gl.h" | 7 #include "android_webview/public/browser/draw_gl.h" |
8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
9 #include "jni/AwGLFunctor_jni.h" | 9 #include "jni/AwGLFunctor_jni.h" |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 44 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
45 --g_instance_count; | 45 --g_instance_count; |
46 } | 46 } |
47 | 47 |
48 bool AwGLFunctor::RequestInvokeGL(bool wait_for_completion) { | 48 bool AwGLFunctor::RequestInvokeGL(bool wait_for_completion) { |
49 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 49 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
50 JNIEnv* env = AttachCurrentThread(); | 50 JNIEnv* env = AttachCurrentThread(); |
51 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 51 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
52 if (obj.is_null()) | 52 if (obj.is_null()) |
53 return false; | 53 return false; |
54 return Java_AwGLFunctor_requestInvokeGL(env, obj.obj(), wait_for_completion); | 54 return Java_AwGLFunctor_requestInvokeGL(env, obj, wait_for_completion); |
55 } | 55 } |
56 | 56 |
57 void AwGLFunctor::DetachFunctorFromView() { | 57 void AwGLFunctor::DetachFunctorFromView() { |
58 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 58 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
59 JNIEnv* env = AttachCurrentThread(); | 59 JNIEnv* env = AttachCurrentThread(); |
60 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 60 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
61 if (!obj.is_null()) | 61 if (!obj.is_null()) |
62 Java_AwGLFunctor_detachFunctorFromView(env, obj.obj()); | 62 Java_AwGLFunctor_detachFunctorFromView(env, obj); |
63 } | 63 } |
64 | 64 |
65 void AwGLFunctor::Destroy(JNIEnv* env, | 65 void AwGLFunctor::Destroy(JNIEnv* env, |
66 const base::android::JavaParamRef<jobject>& obj) { | 66 const base::android::JavaParamRef<jobject>& obj) { |
67 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 67 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
68 java_ref_.reset(); | 68 java_ref_.reset(); |
69 delete this; | 69 delete this; |
70 } | 70 } |
71 | 71 |
72 void AwGLFunctor::DeleteHardwareRenderer( | 72 void AwGLFunctor::DeleteHardwareRenderer( |
(...skipping 25 matching lines...) Expand all Loading... |
98 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 98 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
99 return reinterpret_cast<intptr_t>( | 99 return reinterpret_cast<intptr_t>( |
100 new AwGLFunctor(JavaObjectWeakGlobalRef(env, obj))); | 100 new AwGLFunctor(JavaObjectWeakGlobalRef(env, obj))); |
101 } | 101 } |
102 | 102 |
103 bool RegisterAwGLFunctor(JNIEnv* env) { | 103 bool RegisterAwGLFunctor(JNIEnv* env) { |
104 return RegisterNativesImpl(env); | 104 return RegisterNativesImpl(env); |
105 } | 105 } |
106 | 106 |
107 } // namespace android_webview | 107 } // namespace android_webview |
OLD | NEW |