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

Side by Side Diff: content/app/android/child_process_service_impl.cc

Issue 2285593002: Add ScopedSurfaceRequestManager (Closed)
Patch Set: Simplified manager interface. Renamed to Conduit. Created 4 years, 3 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 (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_conduit.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::ScopedSurfaceRequestConduit,
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::ScopedSurfaceRequestConduit::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::ScopedSurfaceRequestConduit::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
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 ScopedSurfaceRequestConduit:
105 void FulfillScopedSurfaceRequest(
106 uint64_t request_id,
107 gl::SurfaceTexture* surface_texture) override {
108 JNIEnv* env = base::android::AttachCurrentThread();
109 content::Java_ChildProcessServiceImpl_fulfillScopedSurfaceRequest(
110 env, service_impl_, request_id, surface_texture->j_surface_texture());
111 }
112
100 // Overridden from GpuSurfaceLookup: 113 // Overridden from GpuSurfaceLookup:
101 gfx::AcceleratedWidget AcquireNativeWidget(int surface_id) override { 114 gfx::AcceleratedWidget AcquireNativeWidget(int surface_id) override {
102 JNIEnv* env = base::android::AttachCurrentThread(); 115 JNIEnv* env = base::android::AttachCurrentThread();
103 gl::ScopedJavaSurface surface( 116 gl::ScopedJavaSurface surface(
104 content::Java_ChildProcessServiceImpl_getViewSurface(env, service_impl_, 117 content::Java_ChildProcessServiceImpl_getViewSurface(env, service_impl_,
105 surface_id)); 118 surface_id));
106 119
107 if (surface.j_surface().is_null()) 120 if (surface.j_surface().is_null())
108 return NULL; 121 return NULL;
109 122
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 187
175 bool RegisterChildProcessServiceImpl(JNIEnv* env) { 188 bool RegisterChildProcessServiceImpl(JNIEnv* env) {
176 return RegisterNativesImpl(env); 189 return RegisterNativesImpl(env);
177 } 190 }
178 191
179 void ShutdownMainThread(JNIEnv* env, const JavaParamRef<jobject>& obj) { 192 void ShutdownMainThread(JNIEnv* env, const JavaParamRef<jobject>& obj) {
180 ChildThreadImpl::ShutdownThread(); 193 ChildThreadImpl::ShutdownThread();
181 } 194 }
182 195
183 } // namespace content 196 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698