OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/browser/android/in_process_surface_texture_manager.h" |
| 6 |
| 7 #include <android/native_window.h> |
| 8 #include <android/native_window_jni.h> |
| 9 |
| 10 #include "base/android/jni_android.h" |
| 11 #include "base/containers/scoped_ptr_hash_map.h" |
| 12 #include "base/logging.h" |
| 13 |
| 14 namespace content { |
| 15 |
| 16 // static |
| 17 InProcessSurfaceTextureManager* InProcessSurfaceTextureManager::GetInstance() { |
| 18 return Singleton<InProcessSurfaceTextureManager, |
| 19 LeakySingletonTraits<InProcessSurfaceTextureManager>>::get(); |
| 20 } |
| 21 |
| 22 void InProcessSurfaceTextureManager::RegisterSurfaceTexture( |
| 23 int surface_texture_id, |
| 24 int client_id, |
| 25 gfx::SurfaceTexture* surface_texture) { |
| 26 base::AutoLock lock(lock_); |
| 27 |
| 28 DCHECK(surface_textures_.find(surface_texture_id) == surface_textures_.end()); |
| 29 surface_textures_.add( |
| 30 surface_texture_id, |
| 31 make_scoped_ptr(new gfx::ScopedJavaSurface(surface_texture))); |
| 32 } |
| 33 |
| 34 void InProcessSurfaceTextureManager::UnregisterSurfaceTexture( |
| 35 int surface_texture_id, |
| 36 int client_id) { |
| 37 base::AutoLock lock(lock_); |
| 38 |
| 39 DCHECK(surface_textures_.find(surface_texture_id) != surface_textures_.end()); |
| 40 surface_textures_.erase(surface_texture_id); |
| 41 } |
| 42 |
| 43 gfx::AcceleratedWidget |
| 44 InProcessSurfaceTextureManager::AcquireNativeWidgetForSurfaceTexture( |
| 45 int surface_texture_id) { |
| 46 base::AutoLock lock(lock_); |
| 47 |
| 48 DCHECK(surface_textures_.find(surface_texture_id) != surface_textures_.end()); |
| 49 JNIEnv* env = base::android::AttachCurrentThread(); |
| 50 return ANativeWindow_fromSurface( |
| 51 env, surface_textures_.get(surface_texture_id)->j_surface().obj()); |
| 52 } |
| 53 |
| 54 void InProcessSurfaceTextureManager::EstablishSurfaceTexturePeer( |
| 55 base::ProcessHandle render_process_handle, |
| 56 scoped_refptr<gfx::SurfaceTexture> surface_texture, |
| 57 int render_frame_id, |
| 58 int player_id) { |
| 59 NOTIMPLEMENTED(); |
| 60 } |
| 61 |
| 62 InProcessSurfaceTextureManager::InProcessSurfaceTextureManager() { |
| 63 SurfaceTexturePeer::InitInstance(this); |
| 64 } |
| 65 |
| 66 InProcessSurfaceTextureManager::~InProcessSurfaceTextureManager() { |
| 67 SurfaceTexturePeer::InitInstance(nullptr); |
| 68 } |
| 69 |
| 70 } // namespace content |
OLD | NEW |