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