Chromium Code Reviews| Index: content/app/android/child_process_service.cc |
| diff --git a/content/app/android/child_process_service.cc b/content/app/android/child_process_service.cc |
| index 62c04d6623eb179a6d7b7103e614a97839042f46..b5985a1a4f5f3a21173ae47588e561462fcc7a66 100644 |
| --- a/content/app/android/child_process_service.cc |
| +++ b/content/app/android/child_process_service.cc |
| @@ -13,7 +13,7 @@ |
| #include "base/logging.h" |
| #include "base/posix/global_descriptors.h" |
| #include "content/child/child_thread.h" |
| -#include "content/common/android/surface_texture_lookup.h" |
| +#include "content/common/android/surface_texture_manager.h" |
| #include "content/common/android/surface_texture_peer.h" |
| #include "content/common/gpu/gpu_surface_lookup.h" |
| #include "content/public/app/android_library_loader_hooks.h" |
| @@ -30,44 +30,52 @@ namespace content { |
| namespace { |
| -class SurfaceTexturePeerChildImpl : public SurfaceTexturePeer, |
| - public GpuSurfaceLookup, |
| - public SurfaceTextureLookup { |
| +class SurfaceTextureManagerImpl : public SurfaceTextureManager, |
| + public SurfaceTexturePeer, |
| + public GpuSurfaceLookup { |
| public: |
| // |service| is the instance of |
| // org.chromium.content.app.ChildProcessService. |
| - explicit SurfaceTexturePeerChildImpl( |
| + explicit SurfaceTextureManagerImpl( |
| const base::android::ScopedJavaLocalRef<jobject>& service) |
| : service_(service) { |
| + SurfaceTexturePeer::InitInstance(this); |
| GpuSurfaceLookup::InitInstance(this); |
| - SurfaceTextureLookup::InitInstance(this); |
| } |
|
no sievers
2014/10/07 22:12:45
One thing I don't like so much is that this class
reveman
2014/10/08 15:56:39
Done.
|
| - |
| - virtual ~SurfaceTexturePeerChildImpl() { |
| + virtual ~SurfaceTextureManagerImpl() { |
| + SurfaceTexturePeer::InitInstance(NULL); |
| GpuSurfaceLookup::InitInstance(NULL); |
|
no sievers
2014/10/07 22:12:45
Should it also do SurfaceTextureManager::InitInsta
reveman
2014/10/08 15:56:39
That's the responsibility of InternalInitChildProc
|
| - SurfaceTextureLookup::InitInstance(NULL); |
| } |
| - // Overridden from SurfaceTexturePeer: |
| - virtual void EstablishSurfaceTexturePeer( |
| - base::ProcessHandle pid, |
| - scoped_refptr<gfx::SurfaceTexture> surface_texture, |
| - int primary_id, |
| - int secondary_id) OVERRIDE { |
| + // Overridden from SurfaceTextureManager: |
| + virtual void RegisterSurfaceTexture( |
| + int surface_texture_id, |
| + int client_id, |
| + gfx::SurfaceTexture* surface_texture) OVERRIDE { |
| JNIEnv* env = base::android::AttachCurrentThread(); |
| - content::Java_ChildProcessService_establishSurfaceTexturePeer( |
| - env, service_.obj(), pid, |
| - surface_texture->j_surface_texture().obj(), primary_id, |
| - secondary_id); |
| - CheckException(env); |
| + gfx::ScopedJavaSurface surface(surface_texture); |
| + Java_ChildProcessService_registerSurfaceTextureSurface( |
| + env, |
| + service_.obj(), |
| + surface_texture_id, |
| + client_id, |
| + surface.j_surface().obj()); |
| + DCHECK(!base::android::HasException(env)); |
| } |
| - |
| - // Overridden from GpuSurfaceLookup: |
| - virtual gfx::AcceleratedWidget AcquireNativeWidget(int surface_id) OVERRIDE { |
| + virtual void UnregisterSurfaceTexture(int surface_texture_id, |
| + int client_id) OVERRIDE { |
| + JNIEnv* env = base::android::AttachCurrentThread(); |
| + Java_ChildProcessService_unregisterSurfaceTextureSurface( |
| + env, service_.obj(), surface_texture_id, client_id); |
| + DCHECK(!base::android::HasException(env)); |
| + } |
| + virtual gfx::AcceleratedWidget AcquireNativeWidget(int surface_texture_id, |
| + int client_id) OVERRIDE { |
| JNIEnv* env = base::android::AttachCurrentThread(); |
| gfx::ScopedJavaSurface surface( |
| - content::Java_ChildProcessService_getViewSurface( |
| - env, service_.obj(), surface_id)); |
| + Java_ChildProcessService_getSurfaceTextureSurface( |
| + env, service_.obj(), surface_texture_id, client_id)); |
| + DCHECK(!base::android::HasException(env)); |
| if (surface.j_surface().is_null()) |
| return NULL; |
| @@ -82,14 +90,30 @@ class SurfaceTexturePeerChildImpl : public SurfaceTexturePeer, |
| return native_window; |
| } |
| - // Overridden from SurfaceTextureLookup: |
| - virtual gfx::AcceleratedWidget AcquireNativeWidget(int primary_id, |
| - int secondary_id) |
| - OVERRIDE { |
| + // Overridden from SurfaceTexturePeer: |
| + virtual void EstablishSurfaceTexturePeer( |
| + base::ProcessHandle pid, |
| + scoped_refptr<gfx::SurfaceTexture> surface_texture, |
| + int primary_id, |
| + int secondary_id) OVERRIDE { |
| + JNIEnv* env = base::android::AttachCurrentThread(); |
| + content::Java_ChildProcessService_establishSurfaceTexturePeer( |
| + env, |
| + service_.obj(), |
| + pid, |
| + surface_texture->j_surface_texture().obj(), |
| + primary_id, |
| + secondary_id); |
| + DCHECK(!base::android::HasException(env)); |
| + } |
| + |
| + // Overridden from GpuSurfaceLookup: |
| + virtual gfx::AcceleratedWidget AcquireNativeWidget(int surface_id) OVERRIDE { |
| JNIEnv* env = base::android::AttachCurrentThread(); |
| gfx::ScopedJavaSurface surface( |
| - content::Java_ChildProcessService_getSurfaceTextureSurface( |
| - env, service_.obj(), primary_id, secondary_id)); |
| + content::Java_ChildProcessService_getViewSurface( |
| + env, service_.obj(), surface_id)); |
| + DCHECK(!base::android::HasException(env)); |
| if (surface.j_surface().is_null()) |
| return NULL; |
| @@ -108,7 +132,7 @@ class SurfaceTexturePeerChildImpl : public SurfaceTexturePeer, |
| // The instance of org.chromium.content.app.ChildProcessService. |
| base::android::ScopedJavaGlobalRef<jobject> service_; |
| - DISALLOW_COPY_AND_ASSIGN(SurfaceTexturePeerChildImpl); |
| + DISALLOW_COPY_AND_ASSIGN(SurfaceTextureManagerImpl); |
| }; |
| // Chrome actually uses the renderer code path for all of its child |
| @@ -132,11 +156,7 @@ void InternalInitChildProcess(const std::vector<int>& file_ids, |
| for (size_t i = 0; i < file_ids.size(); ++i) |
| base::GlobalDescriptors::GetInstance()->Set(file_ids[i], file_fds[i]); |
| - // SurfaceTexturePeerChildImpl implements the SurfaceTextureLookup interface, |
| - // which need to be set before we create a compositor thread that could be |
| - // using it to initialize resources. |
| - content::SurfaceTexturePeer::InitInstance( |
| - new SurfaceTexturePeerChildImpl(service)); |
| + SurfaceTextureManager::InitInstance(new SurfaceTextureManagerImpl(service)); |
| base::android::MemoryPressureListenerAndroid::RegisterSystemCallback(env); |
| } |