OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 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/surface.h" |
| 6 |
| 7 #include "jni/Surface_jni.h" |
| 8 |
| 9 namespace { |
| 10 |
| 11 bool g_jni_initialized = false; |
| 12 |
| 13 void RegisterNativesIfNeeded(JNIEnv* env) { |
| 14 if (!g_jni_initialized) { |
| 15 JNI_Surface::RegisterNativesImpl(env); |
| 16 g_jni_initialized = true; |
| 17 } |
| 18 } |
| 19 |
| 20 } // anonymous namespace |
| 21 |
| 22 namespace content { |
| 23 |
| 24 // static |
| 25 void Surface::Release(jobject surface) { |
| 26 if (surface == NULL) |
| 27 return; |
| 28 |
| 29 JNIEnv* env = base::android::AttachCurrentThread(); |
| 30 RegisterNativesIfNeeded(env); |
| 31 JNI_Surface::Java_Surface_release(env, surface); |
| 32 } |
| 33 |
| 34 Surface::Surface(const base::android::JavaRef<jobject>& surface_texture) { |
| 35 JNIEnv* env = base::android::AttachCurrentThread(); |
| 36 RegisterNativesIfNeeded(env); |
| 37 |
| 38 ScopedJavaLocalRef<jobject> tmp( |
| 39 JNI_Surface::Java_Surface_Constructor(env, surface_texture.obj())); |
| 40 DCHECK(!tmp.is_null()); |
| 41 j_surface_.Reset(tmp); |
| 42 } |
| 43 |
| 44 Surface::~Surface() { |
| 45 } |
| 46 |
| 47 void Surface::Release() { |
| 48 Release(j_surface_.obj()); |
| 49 } |
| 50 |
| 51 } // namespace content |
OLD | NEW |