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 "base/unguessable_token.h" |
16 #include "content/child/child_thread_impl.h" | 17 #include "content/child/child_thread_impl.h" |
17 #include "content/public/common/content_descriptors.h" | 18 #include "content/public/common/content_descriptors.h" |
| 19 #include "gpu/ipc/common/android/scoped_surface_request_conduit.h" |
18 #include "gpu/ipc/common/android/surface_texture_manager.h" | 20 #include "gpu/ipc/common/android/surface_texture_manager.h" |
19 #include "gpu/ipc/common/android/surface_texture_peer.h" | 21 #include "gpu/ipc/common/android/surface_texture_peer.h" |
20 #include "gpu/ipc/common/gpu_surface_lookup.h" | 22 #include "gpu/ipc/common/gpu_surface_lookup.h" |
21 #include "ipc/ipc_descriptors.h" | 23 #include "ipc/ipc_descriptors.h" |
22 #include "jni/ChildProcessServiceImpl_jni.h" | 24 #include "jni/ChildProcessServiceImpl_jni.h" |
23 #include "ui/gl/android/scoped_java_surface.h" | 25 #include "ui/gl/android/scoped_java_surface.h" |
24 | 26 |
25 using base::android::AttachCurrentThread; | 27 using base::android::AttachCurrentThread; |
26 using base::android::CheckException; | 28 using base::android::CheckException; |
27 using base::android::JavaIntArrayToIntVector; | 29 using base::android::JavaIntArrayToIntVector; |
28 using base::android::JavaParamRef; | 30 using base::android::JavaParamRef; |
29 | 31 |
30 namespace content { | 32 namespace content { |
31 | 33 |
32 namespace { | 34 namespace { |
33 | 35 |
34 // TODO(sievers): Use two different implementations of this depending on if | 36 // TODO(sievers): Use two different implementations of this depending on if |
35 // we're in a renderer or gpu process. | 37 // we're in a renderer or gpu process. |
36 class SurfaceTextureManagerImpl : public gpu::SurfaceTextureManager, | 38 class SurfaceTextureManagerImpl : public gpu::SurfaceTextureManager, |
37 public gpu::SurfaceTexturePeer, | 39 public gpu::SurfaceTexturePeer, |
| 40 public gpu::ScopedSurfaceRequestConduit, |
38 public gpu::GpuSurfaceLookup { | 41 public gpu::GpuSurfaceLookup { |
39 public: | 42 public: |
40 // |service impl| is the instance of | 43 // |service impl| is the instance of |
41 // org.chromium.content.app.ChildProcessServiceImpl. | 44 // org.chromium.content.app.ChildProcessServiceImpl. |
42 explicit SurfaceTextureManagerImpl( | 45 explicit SurfaceTextureManagerImpl( |
43 const base::android::JavaRef<jobject>& service_impl) | 46 const base::android::JavaRef<jobject>& service_impl) |
44 : service_impl_(service_impl) { | 47 : service_impl_(service_impl) { |
45 SurfaceTexturePeer::InitInstance(this); | 48 SurfaceTexturePeer::InitInstance(this); |
46 gpu::GpuSurfaceLookup::InitInstance(this); | 49 gpu::GpuSurfaceLookup::InitInstance(this); |
| 50 gpu::ScopedSurfaceRequestConduit::SetInstance(this); |
47 } | 51 } |
48 ~SurfaceTextureManagerImpl() override { | 52 ~SurfaceTextureManagerImpl() override { |
49 SurfaceTexturePeer::InitInstance(NULL); | 53 SurfaceTexturePeer::InitInstance(NULL); |
50 gpu::GpuSurfaceLookup::InitInstance(NULL); | 54 gpu::GpuSurfaceLookup::InitInstance(NULL); |
| 55 gpu::ScopedSurfaceRequestConduit::SetInstance(nullptr); |
51 } | 56 } |
52 | 57 |
53 // Overridden from SurfaceTextureManager: | 58 // Overridden from SurfaceTextureManager: |
54 void RegisterSurfaceTexture(int surface_texture_id, | 59 void RegisterSurfaceTexture(int surface_texture_id, |
55 int client_id, | 60 int client_id, |
56 gl::SurfaceTexture* surface_texture) override { | 61 gl::SurfaceTexture* surface_texture) override { |
57 JNIEnv* env = base::android::AttachCurrentThread(); | 62 JNIEnv* env = base::android::AttachCurrentThread(); |
58 Java_ChildProcessServiceImpl_createSurfaceTextureSurface( | 63 Java_ChildProcessServiceImpl_createSurfaceTextureSurface( |
59 env, service_impl_, surface_texture_id, client_id, | 64 env, service_impl_, surface_texture_id, client_id, |
60 surface_texture->j_surface_texture()); | 65 surface_texture->j_surface_texture()); |
(...skipping 29 matching lines...) Expand all Loading... |
90 base::ProcessHandle pid, | 95 base::ProcessHandle pid, |
91 scoped_refptr<gl::SurfaceTexture> surface_texture, | 96 scoped_refptr<gl::SurfaceTexture> surface_texture, |
92 int primary_id, | 97 int primary_id, |
93 int secondary_id) override { | 98 int secondary_id) override { |
94 JNIEnv* env = base::android::AttachCurrentThread(); | 99 JNIEnv* env = base::android::AttachCurrentThread(); |
95 content::Java_ChildProcessServiceImpl_establishSurfaceTexturePeer( | 100 content::Java_ChildProcessServiceImpl_establishSurfaceTexturePeer( |
96 env, service_impl_, pid, surface_texture->j_surface_texture(), | 101 env, service_impl_, pid, surface_texture->j_surface_texture(), |
97 primary_id, secondary_id); | 102 primary_id, secondary_id); |
98 } | 103 } |
99 | 104 |
| 105 // Overriden from ScopedSurfaceRequestConduit: |
| 106 void ForwardSurfaceTextureForSurfaceRequest( |
| 107 const base::UnguessableToken& request_token, |
| 108 const gl::SurfaceTexture* surface_texture) override { |
| 109 JNIEnv* env = base::android::AttachCurrentThread(); |
| 110 |
| 111 content:: |
| 112 Java_ChildProcessServiceImpl_forwardSurfaceTextureForSurfaceRequest( |
| 113 env, service_impl_, request_token.GetHighForSerialization(), |
| 114 request_token.GetLowForSerialization(), |
| 115 surface_texture->j_surface_texture()); |
| 116 } |
| 117 |
100 // Overridden from GpuSurfaceLookup: | 118 // Overridden from GpuSurfaceLookup: |
101 gfx::AcceleratedWidget AcquireNativeWidget(int surface_id) override { | 119 gfx::AcceleratedWidget AcquireNativeWidget(int surface_id) override { |
102 JNIEnv* env = base::android::AttachCurrentThread(); | 120 JNIEnv* env = base::android::AttachCurrentThread(); |
103 gl::ScopedJavaSurface surface( | 121 gl::ScopedJavaSurface surface( |
104 content::Java_ChildProcessServiceImpl_getViewSurface(env, service_impl_, | 122 content::Java_ChildProcessServiceImpl_getViewSurface(env, service_impl_, |
105 surface_id)); | 123 surface_id)); |
106 | 124 |
107 if (surface.j_surface().is_null()) | 125 if (surface.j_surface().is_null()) |
108 return NULL; | 126 return NULL; |
109 | 127 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 | 192 |
175 bool RegisterChildProcessServiceImpl(JNIEnv* env) { | 193 bool RegisterChildProcessServiceImpl(JNIEnv* env) { |
176 return RegisterNativesImpl(env); | 194 return RegisterNativesImpl(env); |
177 } | 195 } |
178 | 196 |
179 void ShutdownMainThread(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 197 void ShutdownMainThread(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
180 ChildThreadImpl::ShutdownThread(); | 198 ChildThreadImpl::ShutdownThread(); |
181 } | 199 } |
182 | 200 |
183 } // namespace content | 201 } // namespace content |
OLD | NEW |