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..05be0f6c97184ccb0c4c6d22ab06e795ef1981cc 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,51 @@ namespace content { |
| namespace { |
| -class SurfaceTexturePeerChildImpl : public SurfaceTexturePeer, |
| - public GpuSurfaceLookup, |
| - public SurfaceTextureLookup { |
| +class SurfaceTextureManagerImpl : public SurfaceTextureManager, |
| + public SurfaceTexturePeer, |
| + public GpuSurfaceLookup { |
|
reveman
2014/10/06 19:05:15
I decided to consolidate these into one implementa
|
| 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); |
| } |
| - |
| - virtual ~SurfaceTexturePeerChildImpl() { |
| + virtual ~SurfaceTextureManagerImpl() { |
| + SurfaceTexturePeer::InitInstance(NULL); |
| GpuSurfaceLookup::InitInstance(NULL); |
| - 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); |
| + Java_ChildProcessService_registerSurfaceTexture( |
| + env, |
| + service_.obj(), |
| + surface_texture_id, |
| + client_id, |
| + surface_texture->j_surface_texture().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_unregisterSurfaceTexture( |
| + 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 +89,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 +131,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 +155,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); |
| } |