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

Side by Side Diff: ui/gl/android/scoped_java_surface.cc

Issue 2202033002: ui: Remove unneeded RegisterNatives() call on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@jnireg1
Patch Set: rebase, unused headers Created 4 years, 4 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
« no previous file with comments | « ui/gl/android/gl_jni_registrar.cc ('k') | ui/gl/android/surface_texture.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 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 "ui/gl/android/scoped_java_surface.h" 5 #include "ui/gl/android/scoped_java_surface.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "jni/Surface_jni.h" 8 #include "jni/Surface_jni.h"
9 #include "ui/gl/android/surface_texture.h" 9 #include "ui/gl/android/surface_texture.h"
10 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 gl { 11 namespace gl {
25 12
26 ScopedJavaSurface::ScopedJavaSurface() { 13 ScopedJavaSurface::ScopedJavaSurface() {
27 } 14 }
28 15
29 ScopedJavaSurface::ScopedJavaSurface( 16 ScopedJavaSurface::ScopedJavaSurface(
30 const base::android::JavaRef<jobject>& surface) 17 const base::android::JavaRef<jobject>& surface)
31 : auto_release_(true), 18 : auto_release_(true),
32 is_protected_(false) { 19 is_protected_(false) {
33 JNIEnv* env = base::android::AttachCurrentThread(); 20 JNIEnv* env = base::android::AttachCurrentThread();
34 RegisterNativesIfNeeded(env);
35 DCHECK(env->IsInstanceOf(surface.obj(), Surface_clazz(env))); 21 DCHECK(env->IsInstanceOf(surface.obj(), Surface_clazz(env)));
36 j_surface_.Reset(surface); 22 j_surface_.Reset(surface);
37 } 23 }
38 24
39 ScopedJavaSurface::ScopedJavaSurface( 25 ScopedJavaSurface::ScopedJavaSurface(
40 const SurfaceTexture* surface_texture) 26 const SurfaceTexture* surface_texture)
41 : auto_release_(true), 27 : auto_release_(true),
42 is_protected_(false) { 28 is_protected_(false) {
43 JNIEnv* env = base::android::AttachCurrentThread(); 29 JNIEnv* env = base::android::AttachCurrentThread();
44 RegisterNativesIfNeeded(env);
45 ScopedJavaLocalRef<jobject> tmp(JNI_Surface::Java_Surface_Constructor( 30 ScopedJavaLocalRef<jobject> tmp(JNI_Surface::Java_Surface_Constructor(
46 env, surface_texture->j_surface_texture().obj())); 31 env, surface_texture->j_surface_texture().obj()));
47 DCHECK(!tmp.is_null()); 32 DCHECK(!tmp.is_null());
48 j_surface_.Reset(tmp); 33 j_surface_.Reset(tmp);
49 } 34 }
50 35
51 ScopedJavaSurface::ScopedJavaSurface(ScopedJavaSurface&& rvalue) { 36 ScopedJavaSurface::ScopedJavaSurface(ScopedJavaSurface&& rvalue) {
52 MoveFrom(rvalue); 37 MoveFrom(rvalue);
53 } 38 }
54 39
(...skipping 25 matching lines...) Expand all
80 JNIEnv* env = base::android::AttachCurrentThread(); 65 JNIEnv* env = base::android::AttachCurrentThread();
81 ScopedJavaLocalRef<jobject> surface_ref; 66 ScopedJavaLocalRef<jobject> surface_ref;
82 surface_ref.Reset(env, surface); 67 surface_ref.Reset(env, surface);
83 ScopedJavaSurface scoped_surface(surface_ref); 68 ScopedJavaSurface scoped_surface(surface_ref);
84 scoped_surface.auto_release_ = false; 69 scoped_surface.auto_release_ = false;
85 scoped_surface.is_protected_ = true; 70 scoped_surface.is_protected_ = true;
86 return scoped_surface; 71 return scoped_surface;
87 } 72 }
88 73
89 } // namespace gl 74 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/android/gl_jni_registrar.cc ('k') | ui/gl/android/surface_texture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698