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

Unified Diff: content/common/android/scoped_java_surface.cc

Issue 12388038: Android: Remove Surface cruft (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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
« no previous file with comments | « content/common/android/scoped_java_surface.h ('k') | content/common/android/surface_callback.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/android/scoped_java_surface.cc
diff --git a/content/common/android/scoped_java_surface.cc b/content/common/android/scoped_java_surface.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ca84f72617ff060ca2cbb8228fb7ce74aa634e2c
--- /dev/null
+++ b/content/common/android/scoped_java_surface.cc
@@ -0,0 +1,54 @@
+// Copyright (c) 2013 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/common/android/scoped_java_surface.h"
+
+#include "base/logging.h"
+#include "content/common/android/surface_texture_bridge.h"
+#include "jni/Surface_jni.h"
+
+namespace {
+
+bool g_jni_initialized = false;
+
+void RegisterNativesIfNeeded(JNIEnv* env) {
+ if (!g_jni_initialized) {
+ JNI_Surface::RegisterNativesImpl(env);
+ g_jni_initialized = true;
+ }
+}
+
+} // anonymous namespace
+
+namespace content {
+
+ScopedJavaSurface::ScopedJavaSurface() {
+}
+
+ScopedJavaSurface::ScopedJavaSurface(
+ const base::android::JavaRef<jobject>& surface) {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ RegisterNativesIfNeeded(env);
+ DCHECK(env->IsInstanceOf(surface.obj(), g_Surface_clazz));
+ j_surface_.Reset(surface);
+}
+
+ScopedJavaSurface::ScopedJavaSurface(
+ const SurfaceTextureBridge* surface_texture) {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ RegisterNativesIfNeeded(env);
+ ScopedJavaLocalRef<jobject> tmp(JNI_Surface::Java_Surface_Constructor(
+ env, surface_texture->j_surface_texture().obj()));
+ DCHECK(!tmp.is_null());
+ j_surface_.Reset(tmp);
+}
+
+ScopedJavaSurface::~ScopedJavaSurface() {
+ if (!j_surface_.is_null()) {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ JNI_Surface::Java_Surface_release(env, j_surface_.obj());
+ }
+}
+
+} // namespace content
« no previous file with comments | « content/common/android/scoped_java_surface.h ('k') | content/common/android/surface_callback.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698