| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/browser/android/in_process_surface_texture_manager.h" | 5 #include "gpu/ipc/client/android/in_process_surface_texture_manager.h" |
| 6 | 6 |
| 7 #include <android/native_window.h> | 7 #include <android/native_window.h> |
| 8 #include <android/native_window_jni.h> | 8 #include <android/native_window_jni.h> |
| 9 | 9 |
| 10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| 11 #include "base/containers/scoped_ptr_hash_map.h" | 11 #include "base/containers/scoped_ptr_hash_map.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "content/browser/media/android/browser_media_player_manager.h" | |
| 15 #include "content/public/browser/browser_thread.h" | |
| 16 | 14 |
| 17 namespace content { | 15 namespace gpu { |
| 18 | 16 |
| 19 // static | 17 // static |
| 20 InProcessSurfaceTextureManager* InProcessSurfaceTextureManager::GetInstance() { | 18 InProcessSurfaceTextureManager* InProcessSurfaceTextureManager::GetInstance() { |
| 21 return base::Singleton< | 19 return base::Singleton< |
| 22 InProcessSurfaceTextureManager, | 20 InProcessSurfaceTextureManager, |
| 23 base::LeakySingletonTraits<InProcessSurfaceTextureManager>>::get(); | 21 base::LeakySingletonTraits<InProcessSurfaceTextureManager>>::get(); |
| 24 } | 22 } |
| 25 | 23 |
| 26 void InProcessSurfaceTextureManager::RegisterSurfaceTexture( | 24 void InProcessSurfaceTextureManager::RegisterSurfaceTexture( |
| 27 int surface_texture_id, | 25 int surface_texture_id, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 48 InProcessSurfaceTextureManager::AcquireNativeWidgetForSurfaceTexture( | 46 InProcessSurfaceTextureManager::AcquireNativeWidgetForSurfaceTexture( |
| 49 int surface_texture_id) { | 47 int surface_texture_id) { |
| 50 base::AutoLock lock(lock_); | 48 base::AutoLock lock(lock_); |
| 51 | 49 |
| 52 DCHECK(surface_textures_.find(surface_texture_id) != surface_textures_.end()); | 50 DCHECK(surface_textures_.find(surface_texture_id) != surface_textures_.end()); |
| 53 JNIEnv* env = base::android::AttachCurrentThread(); | 51 JNIEnv* env = base::android::AttachCurrentThread(); |
| 54 return ANativeWindow_fromSurface( | 52 return ANativeWindow_fromSurface( |
| 55 env, surface_textures_.get(surface_texture_id)->j_surface().obj()); | 53 env, surface_textures_.get(surface_texture_id)->j_surface().obj()); |
| 56 } | 54 } |
| 57 | 55 |
| 58 void InProcessSurfaceTextureManager::EstablishSurfaceTexturePeer( | 56 InProcessSurfaceTextureManager::InProcessSurfaceTextureManager() {} |
| 59 base::ProcessHandle render_process_handle, | |
| 60 scoped_refptr<gfx::SurfaceTexture> surface_texture, | |
| 61 int render_frame_id, | |
| 62 int player_id) { | |
| 63 if (!surface_texture.get()) | |
| 64 return; | |
| 65 | 57 |
| 66 BrowserThread::PostTask( | 58 InProcessSurfaceTextureManager::~InProcessSurfaceTextureManager() {} |
| 67 BrowserThread::UI, FROM_HERE, | |
| 68 base::Bind(&BrowserMediaPlayerManager::SetSurfacePeer, surface_texture, | |
| 69 render_process_handle, render_frame_id, player_id)); | |
| 70 } | |
| 71 | 59 |
| 72 InProcessSurfaceTextureManager::InProcessSurfaceTextureManager() { | 60 } // namespace gpu |
| 73 SurfaceTexturePeer::InitInstance(this); | |
| 74 } | |
| 75 | |
| 76 InProcessSurfaceTextureManager::~InProcessSurfaceTextureManager() { | |
| 77 SurfaceTexturePeer::InitInstance(nullptr); | |
| 78 } | |
| 79 | |
| 80 } // namespace content | |
| OLD | NEW |