| 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" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 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 void InProcessSurfaceTextureManager::RegisterBrowserSurfaceTexture( |
| 46 int surface_texture_id, |
| 47 gl::SurfaceTexture* surface_texture) { |
| 48 base::AutoLock lock(lock_); |
| 49 |
| 50 DCHECK(browser_surface_textures_.find(surface_texture_id) == |
| 51 browser_surface_textures_.end()); |
| 52 browser_surface_textures_.insert(std::make_pair( |
| 53 surface_texture_id, gl::ScopedJavaSurface(surface_texture))); |
| 54 }; |
| 55 |
| 56 void InProcessSurfaceTextureManager::UnregisterBrowserSurfaceTexture( |
| 57 int surface_texture_id) { |
| 58 base::AutoLock lock(lock_); |
| 59 |
| 60 DCHECK(browser_surface_textures_.find(surface_texture_id) != |
| 61 browser_surface_textures_.end()); |
| 62 browser_surface_textures_.erase(surface_texture_id); |
| 63 }; |
| 64 |
| 65 gl::ScopedJavaSurface InProcessSurfaceTextureManager::GetBrowserSurfaceTexture( |
| 66 int surface_texture_id) { |
| 67 base::AutoLock lock(lock_); |
| 68 |
| 69 DCHECK(browser_surface_textures_.find(surface_texture_id) != |
| 70 browser_surface_textures_.end()); |
| 71 browser_surface_textures_.erase(surface_texture_id); |
| 72 // TODO(tguilbert): multiple calls using the same |surface_texture_id| will |
| 73 // probably not work. |
| 74 // Fix before commiting if the general strategy in this CL is accepted. |
| 75 return std::move(browser_surface_textures_.find(surface_texture_id)->second); |
| 76 }; |
| 77 |
| 45 gfx::AcceleratedWidget | 78 gfx::AcceleratedWidget |
| 46 InProcessSurfaceTextureManager::AcquireNativeWidgetForSurfaceTexture( | 79 InProcessSurfaceTextureManager::AcquireNativeWidgetForSurfaceTexture( |
| 47 int surface_texture_id) { | 80 int surface_texture_id) { |
| 48 base::AutoLock lock(lock_); | 81 base::AutoLock lock(lock_); |
| 49 | 82 |
| 50 DCHECK(surface_textures_.find(surface_texture_id) != surface_textures_.end()); | 83 DCHECK(surface_textures_.find(surface_texture_id) != surface_textures_.end()); |
| 51 JNIEnv* env = base::android::AttachCurrentThread(); | 84 JNIEnv* env = base::android::AttachCurrentThread(); |
| 52 return ANativeWindow_fromSurface( | 85 return ANativeWindow_fromSurface( |
| 53 env, surface_textures_.get(surface_texture_id)->j_surface().obj()); | 86 env, surface_textures_.get(surface_texture_id)->j_surface().obj()); |
| 54 } | 87 } |
| 55 | 88 |
| 56 InProcessSurfaceTextureManager::InProcessSurfaceTextureManager() {} | 89 InProcessSurfaceTextureManager::InProcessSurfaceTextureManager() {} |
| 57 | 90 |
| 58 InProcessSurfaceTextureManager::~InProcessSurfaceTextureManager() {} | 91 InProcessSurfaceTextureManager::~InProcessSurfaceTextureManager() {} |
| 59 | 92 |
| 60 } // namespace gpu | 93 } // namespace gpu |
| OLD | NEW |