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

Side by Side 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, 9 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/common/android/scoped_java_surface.h"
6
7 #include "base/logging.h"
8 #include "content/common/android/surface_texture_bridge.h"
9 #include "jni/Surface_jni.h"
10
11 namespace {
12
13 bool g_jni_initialized = false;
14
15 void RegisterNativesIfNeeded(JNIEnv* env) {
16 if (!g_jni_initialized) {
17 JNI_Surface::RegisterNativesImpl(env);
18 g_jni_initialized = true;
19 }
20 }
21
22 } // anonymous namespace
23
24 namespace content {
25
26 ScopedJavaSurface::ScopedJavaSurface() {
27 }
28
29 ScopedJavaSurface::ScopedJavaSurface(
30 const base::android::JavaRef<jobject>& surface) {
31 JNIEnv* env = base::android::AttachCurrentThread();
32 RegisterNativesIfNeeded(env);
33 DCHECK(env->IsInstanceOf(surface.obj(), g_Surface_clazz));
34 j_surface_.Reset(surface);
35 }
36
37 ScopedJavaSurface::ScopedJavaSurface(
38 const SurfaceTextureBridge* surface_texture) {
39 JNIEnv* env = base::android::AttachCurrentThread();
40 RegisterNativesIfNeeded(env);
41 ScopedJavaLocalRef<jobject> tmp(JNI_Surface::Java_Surface_Constructor(
42 env, surface_texture->j_surface_texture().obj()));
43 DCHECK(!tmp.is_null());
44 j_surface_.Reset(tmp);
45 }
46
47 ScopedJavaSurface::~ScopedJavaSurface() {
48 if (!j_surface_.is_null()) {
49 JNIEnv* env = base::android::AttachCurrentThread();
50 JNI_Surface::Java_Surface_release(env, j_surface_.obj());
51 }
52 }
53
54 } // namespace content
OLDNEW
« 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