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

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

Issue 1398703003: Fix an issue that an invalid surface could be passed to MediaPlayerBridge (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
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
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 JNIEnv* env = base::android::AttachCurrentThread(); 68 JNIEnv* env = base::android::AttachCurrentThread();
69 j_surface_.Reset(env, other.j_surface_.Release()); 69 j_surface_.Reset(env, other.j_surface_.Release());
70 auto_release_ = other.auto_release_; 70 auto_release_ = other.auto_release_;
71 is_protected_ = other.is_protected_; 71 is_protected_ = other.is_protected_;
72 } 72 }
73 73
74 bool ScopedJavaSurface::IsEmpty() const { 74 bool ScopedJavaSurface::IsEmpty() const {
75 return j_surface_.is_null(); 75 return j_surface_.is_null();
76 } 76 }
77 77
78 bool ScopedJavaSurface::IsValid() const {
79 // Null surface are considered valid as it can be passed to a MediaPlayer.
80 if (IsEmpty())
81 return true;
82 JNIEnv* env = base::android::AttachCurrentThread();
83 return JNI_Surface::Java_Surface_isValid(env, j_surface_.obj());
no sievers 2015/10/08 23:00:27 Are you sure we need to check this? Or is it good
qinmin 2015/10/08 23:47:23 removed this function. When surfaceDestroyed() is
84 }
85
78 // static 86 // static
79 ScopedJavaSurface ScopedJavaSurface::AcquireExternalSurface(jobject surface) { 87 ScopedJavaSurface ScopedJavaSurface::AcquireExternalSurface(jobject surface) {
80 JNIEnv* env = base::android::AttachCurrentThread(); 88 JNIEnv* env = base::android::AttachCurrentThread();
81 ScopedJavaLocalRef<jobject> surface_ref; 89 ScopedJavaLocalRef<jobject> surface_ref;
82 surface_ref.Reset(env, surface); 90 surface_ref.Reset(env, surface);
83 gfx::ScopedJavaSurface scoped_surface(surface_ref); 91 gfx::ScopedJavaSurface scoped_surface(surface_ref);
84 scoped_surface.auto_release_ = false; 92 scoped_surface.auto_release_ = false;
85 scoped_surface.is_protected_ = true; 93 scoped_surface.is_protected_ = true;
86 return scoped_surface; 94 return scoped_surface;
87 } 95 }
88 96
89 } // namespace gfx 97 } // namespace gfx
OLDNEW
« media/base/android/media_player_bridge.cc ('K') | « ui/gl/android/scoped_java_surface.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698