| 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 "gpu/ipc/client/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 | 14 |
| 15 namespace gpu { | 15 namespace gpu { |
| 16 | 16 |
| 17 // static | 17 // static |
| 18 InProcessSurfaceTextureManager* InProcessSurfaceTextureManager::GetInstance() { | 18 InProcessSurfaceTextureManager* InProcessSurfaceTextureManager::GetInstance() { |
| 19 return base::Singleton< | 19 return base::Singleton< |
| 20 InProcessSurfaceTextureManager, | 20 InProcessSurfaceTextureManager, |
| 21 base::LeakySingletonTraits<InProcessSurfaceTextureManager>>::get(); | 21 base::LeakySingletonTraits<InProcessSurfaceTextureManager>>::get(); |
| 22 } | 22 } |
| 23 | 23 |
| 24 void InProcessSurfaceTextureManager::RegisterSurfaceTexture( | 24 void InProcessSurfaceTextureManager::RegisterSurfaceTexture( |
| 25 int surface_texture_id, | 25 int surface_texture_id, |
| 26 int client_id, | 26 int client_id, |
| 27 gfx::SurfaceTexture* surface_texture) { | 27 gl::SurfaceTexture* surface_texture) { |
| 28 base::AutoLock lock(lock_); | 28 base::AutoLock lock(lock_); |
| 29 | 29 |
| 30 DCHECK(surface_textures_.find(surface_texture_id) == surface_textures_.end()); | 30 DCHECK(surface_textures_.find(surface_texture_id) == surface_textures_.end()); |
| 31 surface_textures_.add( | 31 surface_textures_.add( |
| 32 surface_texture_id, | 32 surface_texture_id, |
| 33 base::WrapUnique(new gfx::ScopedJavaSurface(surface_texture))); | 33 base::WrapUnique(new gl::ScopedJavaSurface(surface_texture))); |
| 34 } | 34 } |
| 35 | 35 |
| 36 void InProcessSurfaceTextureManager::UnregisterSurfaceTexture( | 36 void InProcessSurfaceTextureManager::UnregisterSurfaceTexture( |
| 37 int surface_texture_id, | 37 int surface_texture_id, |
| 38 int client_id) { | 38 int client_id) { |
| 39 base::AutoLock lock(lock_); | 39 base::AutoLock lock(lock_); |
| 40 | 40 |
| 41 DCHECK(surface_textures_.find(surface_texture_id) != surface_textures_.end()); | 41 DCHECK(surface_textures_.find(surface_texture_id) != surface_textures_.end()); |
| 42 surface_textures_.erase(surface_texture_id); | 42 surface_textures_.erase(surface_texture_id); |
| 43 } | 43 } |
| 44 | 44 |
| 45 gfx::AcceleratedWidget | 45 gfx::AcceleratedWidget |
| 46 InProcessSurfaceTextureManager::AcquireNativeWidgetForSurfaceTexture( | 46 InProcessSurfaceTextureManager::AcquireNativeWidgetForSurfaceTexture( |
| 47 int surface_texture_id) { | 47 int surface_texture_id) { |
| 48 base::AutoLock lock(lock_); | 48 base::AutoLock lock(lock_); |
| 49 | 49 |
| 50 DCHECK(surface_textures_.find(surface_texture_id) != surface_textures_.end()); | 50 DCHECK(surface_textures_.find(surface_texture_id) != surface_textures_.end()); |
| 51 JNIEnv* env = base::android::AttachCurrentThread(); | 51 JNIEnv* env = base::android::AttachCurrentThread(); |
| 52 return ANativeWindow_fromSurface( | 52 return ANativeWindow_fromSurface( |
| 53 env, surface_textures_.get(surface_texture_id)->j_surface().obj()); | 53 env, surface_textures_.get(surface_texture_id)->j_surface().obj()); |
| 54 } | 54 } |
| 55 | 55 |
| 56 InProcessSurfaceTextureManager::InProcessSurfaceTextureManager() {} | 56 InProcessSurfaceTextureManager::InProcessSurfaceTextureManager() {} |
| 57 | 57 |
| 58 InProcessSurfaceTextureManager::~InProcessSurfaceTextureManager() {} | 58 InProcessSurfaceTextureManager::~InProcessSurfaceTextureManager() {} |
| 59 | 59 |
| 60 } // namespace gpu | 60 } // namespace gpu |
| OLD | NEW |