| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/browser_surface_texture_manager.h" | 5 #include "content/browser/android/browser_surface_texture_manager.h" |
| 6 | 6 |
| 7 #include <android/native_window_jni.h> | 7 #include <android/native_window_jni.h> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "content/browser/android/child_process_launcher_android.h" | 10 #include "content/browser/android/child_process_launcher_android.h" |
| 11 #include "content/browser/frame_host/render_frame_host_impl.h" | 11 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 12 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
| 12 #include "content/browser/media/android/browser_media_player_manager.h" | 13 #include "content/browser/media/android/browser_media_player_manager.h" |
| 13 #include "content/browser/media/media_web_contents_observer.h" | 14 #include "content/browser/media/media_web_contents_observer.h" |
| 14 #include "content/browser/renderer_host/render_view_host_impl.h" | 15 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 15 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 16 #include "content/public/browser/render_process_host.h" | 17 #include "content/public/browser/render_process_host.h" |
| 17 #include "media/base/android/media_player_android.h" | 18 #include "media/base/android/media_player_android.h" |
| 18 #include "ui/gl/android/scoped_java_surface.h" | 19 #include "ui/gl/android/scoped_java_surface.h" |
| 19 #include "ui/gl/android/surface_texture.h" | 20 #include "ui/gl/android/surface_texture.h" |
| 20 | 21 |
| 21 namespace content { | 22 namespace content { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 content::CreateSurfaceTextureSurface( | 88 content::CreateSurfaceTextureSurface( |
| 88 surface_texture_id, client_id, surface_texture); | 89 surface_texture_id, client_id, surface_texture); |
| 89 } | 90 } |
| 90 | 91 |
| 91 void BrowserSurfaceTextureManager::UnregisterSurfaceTexture( | 92 void BrowserSurfaceTextureManager::UnregisterSurfaceTexture( |
| 92 int surface_texture_id, | 93 int surface_texture_id, |
| 93 int client_id) { | 94 int client_id) { |
| 94 content::DestroySurfaceTextureSurface(surface_texture_id, client_id); | 95 content::DestroySurfaceTextureSurface(surface_texture_id, client_id); |
| 95 } | 96 } |
| 96 | 97 |
| 97 gfx::AcceleratedWidget BrowserSurfaceTextureManager::AcquireNativeWidget( | 98 gfx::AcceleratedWidget |
| 98 int surface_texture_id, | 99 BrowserSurfaceTextureManager::AcquireNativeWidgetForSurfaceTexture( |
| 99 int client_id) { | 100 int surface_texture_id) { |
| 100 gfx::ScopedJavaSurface surface( | 101 gfx::ScopedJavaSurface surface( |
| 101 content::GetSurfaceTextureSurface(surface_texture_id, client_id)); | 102 content::GetSurfaceTextureSurface( |
| 103 surface_texture_id, |
| 104 BrowserGpuChannelHostFactory::instance()->GetGpuChannelId())); |
| 102 if (surface.j_surface().is_null()) | 105 if (surface.j_surface().is_null()) |
| 103 return NULL; | 106 return NULL; |
| 104 | 107 |
| 105 JNIEnv* env = base::android::AttachCurrentThread(); | 108 JNIEnv* env = base::android::AttachCurrentThread(); |
| 106 // Note: This ensures that any local references used by | 109 // Note: This ensures that any local references used by |
| 107 // ANativeWindow_fromSurface are released immediately. This is needed as a | 110 // ANativeWindow_fromSurface are released immediately. This is needed as a |
| 108 // workaround for https://code.google.com/p/android/issues/detail?id=68174 | 111 // workaround for https://code.google.com/p/android/issues/detail?id=68174 |
| 109 base::android::ScopedJavaLocalFrame scoped_local_reference_frame(env); | 112 base::android::ScopedJavaLocalFrame scoped_local_reference_frame(env); |
| 110 ANativeWindow* native_window = | 113 ANativeWindow* native_window = |
| 111 ANativeWindow_fromSurface(env, surface.j_surface().obj()); | 114 ANativeWindow_fromSurface(env, surface.j_surface().obj()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 124 BrowserThread::PostTask(BrowserThread::UI, | 127 BrowserThread::PostTask(BrowserThread::UI, |
| 125 FROM_HERE, | 128 FROM_HERE, |
| 126 base::Bind(&SetSurfacePeer, | 129 base::Bind(&SetSurfacePeer, |
| 127 surface_texture, | 130 surface_texture, |
| 128 render_process_handle, | 131 render_process_handle, |
| 129 render_frame_id, | 132 render_frame_id, |
| 130 player_id)); | 133 player_id)); |
| 131 } | 134 } |
| 132 | 135 |
| 133 } // namespace content | 136 } // namespace content |
| OLD | NEW |