Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Unified Diff: content/browser/android/in_process_surface_texture_manager.cc

Issue 1120873002: Re-land: content: Single process support for native GpuMemoryBuffers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dm-browsertests-refactor
Patch Set: files Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/android/in_process_surface_texture_manager.cc
diff --git a/content/browser/android/in_process_surface_texture_manager.cc b/content/browser/android/in_process_surface_texture_manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a12af6c8f9dd3c574ea740e6795c320b235fa912
--- /dev/null
+++ b/content/browser/android/in_process_surface_texture_manager.cc
@@ -0,0 +1,70 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/android/in_process_surface_texture_manager.h"
+
+#include <android/native_window.h>
+#include <android/native_window_jni.h>
+
+#include "base/android/jni_android.h"
+#include "base/containers/scoped_ptr_hash_map.h"
+#include "base/logging.h"
+
+namespace content {
+
+// static
+InProcessSurfaceTextureManager* InProcessSurfaceTextureManager::GetInstance() {
+ return Singleton<InProcessSurfaceTextureManager,
+ LeakySingletonTraits<InProcessSurfaceTextureManager>>::get();
+}
+
+void InProcessSurfaceTextureManager::RegisterSurfaceTexture(
+ int surface_texture_id,
+ int client_id,
+ gfx::SurfaceTexture* surface_texture) {
+ base::AutoLock lock(lock_);
+
+ DCHECK(surface_textures_.find(surface_texture_id) == surface_textures_.end());
+ surface_textures_.add(
+ surface_texture_id,
+ make_scoped_ptr(new gfx::ScopedJavaSurface(surface_texture)));
+}
+
+void InProcessSurfaceTextureManager::UnregisterSurfaceTexture(
+ int surface_texture_id,
+ int client_id) {
+ base::AutoLock lock(lock_);
+
+ DCHECK(surface_textures_.find(surface_texture_id) != surface_textures_.end());
+ surface_textures_.erase(surface_texture_id);
+}
+
+gfx::AcceleratedWidget
+InProcessSurfaceTextureManager::AcquireNativeWidgetForSurfaceTexture(
+ int surface_texture_id) {
+ base::AutoLock lock(lock_);
+
+ DCHECK(surface_textures_.find(surface_texture_id) != surface_textures_.end());
+ JNIEnv* env = base::android::AttachCurrentThread();
+ return ANativeWindow_fromSurface(
+ env, surface_textures_.get(surface_texture_id)->j_surface().obj());
+}
+
+void InProcessSurfaceTextureManager::EstablishSurfaceTexturePeer(
+ base::ProcessHandle render_process_handle,
+ scoped_refptr<gfx::SurfaceTexture> surface_texture,
+ int render_frame_id,
+ int player_id) {
+ NOTIMPLEMENTED();
+}
+
+InProcessSurfaceTextureManager::InProcessSurfaceTextureManager() {
+ SurfaceTexturePeer::InitInstance(this);
+}
+
+InProcessSurfaceTextureManager::~InProcessSurfaceTextureManager() {
+ SurfaceTexturePeer::InitInstance(NULL);
Avi (use Gerrit) 2015/06/09 22:05:38 nullptr
reveman 2015/06/09 22:15:16 Done.
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698