OLD | NEW |
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 #ifndef UI_GL_ANDROID_SCOPED_JAVA_SURFACE_H_ | 5 #ifndef UI_GL_ANDROID_SCOPED_JAVA_SURFACE_H_ |
6 #define UI_GL_ANDROID_SCOPED_JAVA_SURFACE_H_ | 6 #define UI_GL_ANDROID_SCOPED_JAVA_SURFACE_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 | 9 |
10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
11 #include "base/move.h" | 11 #include "base/move.h" |
12 #include "ui/gl/gl_export.h" | 12 #include "ui/gl/gl_export.h" |
13 | 13 |
14 namespace gfx { | 14 namespace gfx { |
15 | 15 |
16 class SurfaceTexture; | 16 class SurfaceTexture; |
17 | 17 |
18 // A helper class for holding a scoped reference to a Java Surface instance. | 18 // A helper class for holding a scoped reference to a Java Surface instance. |
19 // When going out of scope, Surface.release() is called on the Java object to | 19 // When going out of scope, Surface.release() is called on the Java object to |
20 // make sure server-side references (esp. wrt graphics memory) are released. | 20 // make sure server-side references (esp. wrt graphics memory) are released. |
21 class GL_EXPORT ScopedJavaSurface { | 21 class GL_EXPORT ScopedJavaSurface { |
22 MOVE_ONLY_TYPE_FOR_CPP_03(ScopedJavaSurface, RValue); | 22 MOVE_ONLY_TYPE_FOR_CPP_03(ScopedJavaSurface); |
23 | 23 |
24 public: | 24 public: |
25 ScopedJavaSurface(); | 25 ScopedJavaSurface(); |
26 | 26 |
27 // Wraps an existing Java Surface object in a ScopedJavaSurface. | 27 // Wraps an existing Java Surface object in a ScopedJavaSurface. |
28 explicit ScopedJavaSurface(const base::android::JavaRef<jobject>& surface); | 28 explicit ScopedJavaSurface(const base::android::JavaRef<jobject>& surface); |
29 | 29 |
30 // Creates a Java Surface from a SurfaceTexture and wraps it in a | 30 // Creates a Java Surface from a SurfaceTexture and wraps it in a |
31 // ScopedJavaSurface. | 31 // ScopedJavaSurface. |
32 explicit ScopedJavaSurface(const SurfaceTexture* surface_texture); | 32 explicit ScopedJavaSurface(const SurfaceTexture* surface_texture); |
33 | 33 |
34 // Move constructor. Take the surface from another ScopedJavaSurface object, | 34 // Move constructor. Take the surface from another ScopedJavaSurface object, |
35 // the latter no longer owns the surface afterwards. | 35 // the latter no longer owns the surface afterwards. |
36 ScopedJavaSurface(RValue rvalue); | 36 ScopedJavaSurface(ScopedJavaSurface&& rvalue); |
37 ScopedJavaSurface& operator=(RValue rhs); | 37 ScopedJavaSurface& operator=(ScopedJavaSurface&& rhs); |
38 | 38 |
39 // Creates a ScopedJavaSurface that is owned externally, i.e., | 39 // Creates a ScopedJavaSurface that is owned externally, i.e., |
40 // someone else is responsible to call Surface.release(). | 40 // someone else is responsible to call Surface.release(). |
41 static ScopedJavaSurface AcquireExternalSurface(jobject surface); | 41 static ScopedJavaSurface AcquireExternalSurface(jobject surface); |
42 | 42 |
43 ~ScopedJavaSurface(); | 43 ~ScopedJavaSurface(); |
44 | 44 |
45 // Checks whether the surface is an empty one. | 45 // Checks whether the surface is an empty one. |
46 bool IsEmpty() const; | 46 bool IsEmpty() const; |
47 | 47 |
(...skipping 11 matching lines...) Expand all Loading... |
59 | 59 |
60 bool auto_release_; | 60 bool auto_release_; |
61 bool is_protected_; | 61 bool is_protected_; |
62 | 62 |
63 base::android::ScopedJavaGlobalRef<jobject> j_surface_; | 63 base::android::ScopedJavaGlobalRef<jobject> j_surface_; |
64 }; | 64 }; |
65 | 65 |
66 } // namespace gfx | 66 } // namespace gfx |
67 | 67 |
68 #endif // UI_GL_ANDROID_SCOPED_JAVA_SURFACE_H_ | 68 #endif // UI_GL_ANDROID_SCOPED_JAVA_SURFACE_H_ |
OLD | NEW |