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/scoped_surface_request_manager.h" |
18 #include "gpu/ipc/common/android/surface_texture_manager.h" | 19 #include "gpu/ipc/common/android/surface_texture_manager.h" |
19 #include "gpu/ipc/common/android/surface_texture_peer.h" | 20 #include "gpu/ipc/common/android/surface_texture_peer.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 using base::android::JavaParamRef; | 29 using base::android::JavaParamRef; |
29 | 30 |
30 namespace content { | 31 namespace content { |
31 | 32 |
32 namespace { | 33 namespace { |
33 | 34 |
34 // TODO(sievers): Use two different implementations of this depending on if | 35 // TODO(sievers): Use two different implementations of this depending on if |
35 // we're in a renderer or gpu process. | 36 // we're in a renderer or gpu process. |
36 class SurfaceTextureManagerImpl : public gpu::SurfaceTextureManager, | 37 class SurfaceTextureManagerImpl : public gpu::SurfaceTextureManager, |
37 public gpu::SurfaceTexturePeer, | 38 public gpu::SurfaceTexturePeer, |
| 39 public gpu::ScopedSurfaceRequestManager, |
38 public gpu::GpuSurfaceLookup { | 40 public gpu::GpuSurfaceLookup { |
39 public: | 41 public: |
40 // |service impl| is the instance of | 42 // |service impl| is the instance of |
41 // org.chromium.content.app.ChildProcessServiceImpl. | 43 // org.chromium.content.app.ChildProcessServiceImpl. |
42 explicit SurfaceTextureManagerImpl( | 44 explicit SurfaceTextureManagerImpl( |
43 const base::android::JavaRef<jobject>& service_impl) | 45 const base::android::JavaRef<jobject>& service_impl) |
44 : service_impl_(service_impl) { | 46 : service_impl_(service_impl) { |
45 SurfaceTexturePeer::InitInstance(this); | 47 SurfaceTexturePeer::InitInstance(this); |
46 gpu::GpuSurfaceLookup::InitInstance(this); | 48 gpu::GpuSurfaceLookup::InitInstance(this); |
| 49 gpu::ScopedSurfaceRequestManager::SetInstance(this); |
47 } | 50 } |
48 ~SurfaceTextureManagerImpl() override { | 51 ~SurfaceTextureManagerImpl() override { |
49 SurfaceTexturePeer::InitInstance(NULL); | 52 SurfaceTexturePeer::InitInstance(NULL); |
50 gpu::GpuSurfaceLookup::InitInstance(NULL); | 53 gpu::GpuSurfaceLookup::InitInstance(NULL); |
| 54 gpu::ScopedSurfaceRequestManager::SetInstance(NULL); |
51 } | 55 } |
52 | 56 |
53 // Overridden from SurfaceTextureManager: | 57 // Overridden from SurfaceTextureManager: |
54 void RegisterSurfaceTexture(int surface_texture_id, | 58 void RegisterSurfaceTexture(int surface_texture_id, |
55 int client_id, | 59 int client_id, |
56 gl::SurfaceTexture* surface_texture) override { | 60 gl::SurfaceTexture* surface_texture) override { |
57 JNIEnv* env = base::android::AttachCurrentThread(); | 61 JNIEnv* env = base::android::AttachCurrentThread(); |
58 Java_ChildProcessServiceImpl_createSurfaceTextureSurface( | 62 Java_ChildProcessServiceImpl_createSurfaceTextureSurface( |
59 env, service_impl_, surface_texture_id, client_id, | 63 env, service_impl_, surface_texture_id, client_id, |
60 surface_texture->j_surface_texture()); | 64 surface_texture->j_surface_texture()); |
(...skipping 29 matching lines...) Expand all Loading... |
90 base::ProcessHandle pid, | 94 base::ProcessHandle pid, |
91 scoped_refptr<gl::SurfaceTexture> surface_texture, | 95 scoped_refptr<gl::SurfaceTexture> surface_texture, |
92 int primary_id, | 96 int primary_id, |
93 int secondary_id) override { | 97 int secondary_id) override { |
94 JNIEnv* env = base::android::AttachCurrentThread(); | 98 JNIEnv* env = base::android::AttachCurrentThread(); |
95 content::Java_ChildProcessServiceImpl_establishSurfaceTexturePeer( | 99 content::Java_ChildProcessServiceImpl_establishSurfaceTexturePeer( |
96 env, service_impl_, pid, surface_texture->j_surface_texture(), | 100 env, service_impl_, pid, surface_texture->j_surface_texture(), |
97 primary_id, secondary_id); | 101 primary_id, secondary_id); |
98 } | 102 } |
99 | 103 |
| 104 // Overriden from ScopedSurfaceRequestManager: |
| 105 void RegisterScopedSurfaceRequest( |
| 106 uint64_t request_id, |
| 107 ScopedSurfaceRequestCB request_cb) override { |
| 108 // This method should only be called from the browser process. |
| 109 NOTREACHED(); |
| 110 } |
| 111 ScopedSurfaceRequestCB GetAndUnregisterScopedSurfaceRequest( |
| 112 uint64_t request_id) override { |
| 113 // This method should only be called from the browser process. |
| 114 NOTREACHED(); |
| 115 return ScopedSurfaceRequestCB(); |
| 116 } |
| 117 void FulfillScopedSurfaceRequest( |
| 118 uint64_t request_id, |
| 119 gl::SurfaceTexture* surface_texture) override { |
| 120 JNIEnv* env = base::android::AttachCurrentThread(); |
| 121 content::Java_ChildProcessServiceImpl_fulfillScopedSurfaceRequest( |
| 122 env, service_impl_, request_id, surface_texture->j_surface_texture()); |
| 123 } |
| 124 |
100 // Overridden from GpuSurfaceLookup: | 125 // Overridden from GpuSurfaceLookup: |
101 gfx::AcceleratedWidget AcquireNativeWidget(int surface_id) override { | 126 gfx::AcceleratedWidget AcquireNativeWidget(int surface_id) override { |
102 JNIEnv* env = base::android::AttachCurrentThread(); | 127 JNIEnv* env = base::android::AttachCurrentThread(); |
103 gl::ScopedJavaSurface surface( | 128 gl::ScopedJavaSurface surface( |
104 content::Java_ChildProcessServiceImpl_getViewSurface(env, service_impl_, | 129 content::Java_ChildProcessServiceImpl_getViewSurface(env, service_impl_, |
105 surface_id)); | 130 surface_id)); |
106 | 131 |
107 if (surface.j_surface().is_null()) | 132 if (surface.j_surface().is_null()) |
108 return NULL; | 133 return NULL; |
109 | 134 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 | 199 |
175 bool RegisterChildProcessServiceImpl(JNIEnv* env) { | 200 bool RegisterChildProcessServiceImpl(JNIEnv* env) { |
176 return RegisterNativesImpl(env); | 201 return RegisterNativesImpl(env); |
177 } | 202 } |
178 | 203 |
179 void ShutdownMainThread(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 204 void ShutdownMainThread(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
180 ChildThreadImpl::ShutdownThread(); | 205 ChildThreadImpl::ShutdownThread(); |
181 } | 206 } |
182 | 207 |
183 } // namespace content | 208 } // namespace content |
OLD | NEW |