| 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" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 content::CreateSurfaceTextureSurface( | 31 content::CreateSurfaceTextureSurface( |
| 32 surface_texture_id, client_id, surface_texture); | 32 surface_texture_id, client_id, surface_texture); |
| 33 } | 33 } |
| 34 | 34 |
| 35 void BrowserSurfaceTextureManager::UnregisterSurfaceTexture( | 35 void BrowserSurfaceTextureManager::UnregisterSurfaceTexture( |
| 36 int surface_texture_id, | 36 int surface_texture_id, |
| 37 int client_id) { | 37 int client_id) { |
| 38 content::DestroySurfaceTextureSurface(surface_texture_id, client_id); | 38 content::DestroySurfaceTextureSurface(surface_texture_id, client_id); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void BrowserSurfaceTextureManager::RegisterBrowserSurfaceTexture( |
| 42 int surface_texture_id, |
| 43 gl::SurfaceTexture* stream_texture_surface) { |
| 44 // The browser shouldn't register SurfaceTextures for its own use. |
| 45 // The GPU process can register SurfaceTextures for the browser's use instead. |
| 46 // See ChildProcessServices::RegisterBrowserSurfaceTexture(). |
| 47 NOTREACHED(); |
| 48 }; |
| 49 |
| 50 void BrowserSurfaceTextureManager::UnregisterBrowserSurfaceTexture( |
| 51 int stream_texture_id) { |
| 52 // The GPU process is responsible for unregistering any SurfaceTextures it |
| 53 // registered. |
| 54 NOTREACHED(); |
| 55 }; |
| 56 |
| 57 gl::ScopedJavaSurface BrowserSurfaceTextureManager::GetBrowserSurfaceTexture( |
| 58 int stream_texture_id) { |
| 59 return content::GetBrowserSurfaceTextureSurface(stream_texture_id); |
| 60 }; |
| 61 |
| 41 gfx::AcceleratedWidget | 62 gfx::AcceleratedWidget |
| 42 BrowserSurfaceTextureManager::AcquireNativeWidgetForSurfaceTexture( | 63 BrowserSurfaceTextureManager::AcquireNativeWidgetForSurfaceTexture( |
| 43 int surface_texture_id) { | 64 int surface_texture_id) { |
| 44 gl::ScopedJavaSurface surface(content::GetSurfaceTextureSurface( | 65 gl::ScopedJavaSurface surface(content::GetSurfaceTextureSurface( |
| 45 surface_texture_id, | 66 surface_texture_id, |
| 46 BrowserGpuChannelHostFactory::instance()->GetGpuChannelId())); | 67 BrowserGpuChannelHostFactory::instance()->GetGpuChannelId())); |
| 47 if (surface.j_surface().is_null()) | 68 if (surface.j_surface().is_null()) |
| 48 return NULL; | 69 return NULL; |
| 49 | 70 |
| 50 JNIEnv* env = base::android::AttachCurrentThread(); | 71 JNIEnv* env = base::android::AttachCurrentThread(); |
| 51 // Note: This ensures that any local references used by | 72 // Note: This ensures that any local references used by |
| 52 // ANativeWindow_fromSurface are released immediately. This is needed as a | 73 // ANativeWindow_fromSurface are released immediately. This is needed as a |
| 53 // workaround for https://code.google.com/p/android/issues/detail?id=68174 | 74 // workaround for https://code.google.com/p/android/issues/detail?id=68174 |
| 54 base::android::ScopedJavaLocalFrame scoped_local_reference_frame(env); | 75 base::android::ScopedJavaLocalFrame scoped_local_reference_frame(env); |
| 55 ANativeWindow* native_window = | 76 ANativeWindow* native_window = |
| 56 ANativeWindow_fromSurface(env, surface.j_surface().obj()); | 77 ANativeWindow_fromSurface(env, surface.j_surface().obj()); |
| 57 | 78 |
| 58 return native_window; | 79 return native_window; |
| 59 } | 80 } |
| 60 | 81 |
| 61 BrowserSurfaceTextureManager::BrowserSurfaceTextureManager() { | 82 BrowserSurfaceTextureManager::BrowserSurfaceTextureManager() { |
| 62 } | 83 } |
| 63 | 84 |
| 64 BrowserSurfaceTextureManager::~BrowserSurfaceTextureManager() { | 85 BrowserSurfaceTextureManager::~BrowserSurfaceTextureManager() { |
| 65 } | 86 } |
| 66 | 87 |
| 67 } // namespace content | 88 } // namespace content |
| OLD | NEW |