OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/app/android/child_process_service_impl.h" | 5 #include "content/app/android/child_process_service_impl.h" |
6 | 6 |
7 #include <android/native_window_jni.h> | 7 #include <android/native_window_jni.h> |
8 #include <cpu-features.h> | 8 #include <cpu-features.h> |
9 | 9 |
10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
11 #include "base/android/library_loader/library_loader_hooks.h" | 11 #include "base/android/library_loader/library_loader_hooks.h" |
12 #include "base/android/memory_pressure_listener_android.h" | 12 #include "base/android/memory_pressure_listener_android.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/posix/global_descriptors.h" | 15 #include "base/posix/global_descriptors.h" |
16 #include "content/child/child_thread_impl.h" | 16 #include "content/child/child_thread_impl.h" |
17 #include "content/public/common/content_descriptors.h" | 17 #include "content/public/common/content_descriptors.h" |
18 #include "gpu/ipc/common/android/surface_texture_manager.h" | 18 #include "gpu/ipc/common/android/surface_texture_manager.h" |
19 #include "gpu/ipc/common/android/surface_texture_peer.h" | 19 #include "gpu/ipc/common/android/surface_texture_peer.h" |
| 20 #include "gpu/ipc/common/dialog_surface_lookup.h" |
20 #include "gpu/ipc/common/gpu_surface_lookup.h" | 21 #include "gpu/ipc/common/gpu_surface_lookup.h" |
21 #include "ipc/ipc_descriptors.h" | 22 #include "ipc/ipc_descriptors.h" |
22 #include "jni/ChildProcessServiceImpl_jni.h" | 23 #include "jni/ChildProcessServiceImpl_jni.h" |
23 #include "ui/gl/android/scoped_java_surface.h" | 24 #include "ui/gl/android/scoped_java_surface.h" |
24 | 25 |
25 using base::android::AttachCurrentThread; | 26 using base::android::AttachCurrentThread; |
26 using base::android::CheckException; | 27 using base::android::CheckException; |
27 using base::android::JavaIntArrayToIntVector; | 28 using base::android::JavaIntArrayToIntVector; |
28 | 29 |
29 namespace content { | 30 namespace content { |
30 | 31 |
31 namespace { | 32 namespace { |
32 | 33 |
33 // TODO(sievers): Use two different implementations of this depending on if | 34 // TODO(sievers): Use two different implementations of this depending on if |
34 // we're in a renderer or gpu process. | 35 // we're in a renderer or gpu process. |
35 class SurfaceTextureManagerImpl : public gpu::SurfaceTextureManager, | 36 class SurfaceTextureManagerImpl : public gpu::SurfaceTextureManager, |
36 public gpu::SurfaceTexturePeer, | 37 public gpu::SurfaceTexturePeer, |
37 public gpu::GpuSurfaceLookup { | 38 public gpu::GpuSurfaceLookup, |
| 39 public gpu::DialogSurfaceLookup { |
38 public: | 40 public: |
39 // |service impl| is the instance of | 41 // |service impl| is the instance of |
40 // org.chromium.content.app.ChildProcessServiceImpl. | 42 // org.chromium.content.app.ChildProcessServiceImpl. |
41 explicit SurfaceTextureManagerImpl( | 43 explicit SurfaceTextureManagerImpl( |
42 const base::android::JavaRef<jobject>& service_impl) | 44 const base::android::JavaRef<jobject>& service_impl) |
43 : service_impl_(service_impl) { | 45 : service_impl_(service_impl) { |
44 SurfaceTexturePeer::InitInstance(this); | 46 SurfaceTexturePeer::InitInstance(this); |
45 gpu::GpuSurfaceLookup::InitInstance(this); | 47 gpu::GpuSurfaceLookup::InitInstance(this); |
| 48 gpu::DialogSurfaceLookup::InitInstance(this); |
46 } | 49 } |
47 ~SurfaceTextureManagerImpl() override { | 50 ~SurfaceTextureManagerImpl() override { |
48 SurfaceTexturePeer::InitInstance(NULL); | 51 SurfaceTexturePeer::InitInstance(NULL); |
49 gpu::GpuSurfaceLookup::InitInstance(NULL); | 52 gpu::GpuSurfaceLookup::InitInstance(NULL); |
| 53 gpu::DialogSurfaceLookup::InitInstance(NULL); |
50 } | 54 } |
51 | 55 |
52 // Overridden from SurfaceTextureManager: | 56 // Overridden from SurfaceTextureManager: |
53 void RegisterSurfaceTexture(int surface_texture_id, | 57 void RegisterSurfaceTexture(int surface_texture_id, |
54 int client_id, | 58 int client_id, |
55 gl::SurfaceTexture* surface_texture) override { | 59 gl::SurfaceTexture* surface_texture) override { |
56 JNIEnv* env = base::android::AttachCurrentThread(); | 60 JNIEnv* env = base::android::AttachCurrentThread(); |
57 Java_ChildProcessServiceImpl_createSurfaceTextureSurface( | 61 Java_ChildProcessServiceImpl_createSurfaceTextureSurface( |
58 env, | 62 env, |
59 service_impl_.obj(), | 63 service_impl_.obj(), |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 } | 128 } |
125 | 129 |
126 // Overridden from GpuSurfaceLookup: | 130 // Overridden from GpuSurfaceLookup: |
127 gl::ScopedJavaSurface AcquireJavaSurface(int surface_id) override { | 131 gl::ScopedJavaSurface AcquireJavaSurface(int surface_id) override { |
128 JNIEnv* env = base::android::AttachCurrentThread(); | 132 JNIEnv* env = base::android::AttachCurrentThread(); |
129 return gl::ScopedJavaSurface( | 133 return gl::ScopedJavaSurface( |
130 content::Java_ChildProcessServiceImpl_getViewSurface( | 134 content::Java_ChildProcessServiceImpl_getViewSurface( |
131 env, service_impl_.obj(), surface_id)); | 135 env, service_impl_.obj(), surface_id)); |
132 } | 136 } |
133 | 137 |
| 138 // Overridden from DialogSurfaceLookup: |
| 139 base::android::ScopedJavaLocalRef<jobject> GetDialogSurfaceManager() |
| 140 override { |
| 141 JNIEnv* env = base::android::AttachCurrentThread(); |
| 142 return base::android::ScopedJavaLocalRef<jobject>( |
| 143 content::Java_ChildProcessServiceImpl_getDialogSurfaceManager( |
| 144 env, service_impl_.obj())); |
| 145 } |
| 146 |
134 private: | 147 private: |
135 // The instance of org.chromium.content.app.ChildProcessServiceImpl. | 148 // The instance of org.chromium.content.app.ChildProcessServiceImpl. |
136 base::android::ScopedJavaGlobalRef<jobject> service_impl_; | 149 base::android::ScopedJavaGlobalRef<jobject> service_impl_; |
137 | 150 |
138 DISALLOW_COPY_AND_ASSIGN(SurfaceTextureManagerImpl); | 151 DISALLOW_COPY_AND_ASSIGN(SurfaceTextureManagerImpl); |
139 }; | 152 }; |
140 | 153 |
141 // Chrome actually uses the renderer code path for all of its child | 154 // Chrome actually uses the renderer code path for all of its child |
142 // processes such as renderers, plugins, etc. | 155 // processes such as renderers, plugins, etc. |
143 void InternalInitChildProcessImpl(JNIEnv* env, | 156 void InternalInitChildProcessImpl(JNIEnv* env, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 | 193 |
181 bool RegisterChildProcessServiceImpl(JNIEnv* env) { | 194 bool RegisterChildProcessServiceImpl(JNIEnv* env) { |
182 return RegisterNativesImpl(env); | 195 return RegisterNativesImpl(env); |
183 } | 196 } |
184 | 197 |
185 void ShutdownMainThread(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 198 void ShutdownMainThread(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
186 ChildThreadImpl::ShutdownThread(); | 199 ChildThreadImpl::ShutdownThread(); |
187 } | 200 } |
188 | 201 |
189 } // namespace content | 202 } // namespace content |
OLD | NEW |