Chromium Code Reviews| Index: content/common/android/scoped_java_surface.h |
| diff --git a/content/common/android/scoped_java_surface.h b/content/common/android/scoped_java_surface.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5509196b24426cf8e34109cf8076b416fc846f97 |
| --- /dev/null |
| +++ b/content/common/android/scoped_java_surface.h |
| @@ -0,0 +1,42 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_COMMON_ANDROID_SCOPED_JAVA_SURFACE_H_ |
| +#define CONTENT_COMMON_ANDROID_SCOPED_JAVA_SURFACE_H_ |
| + |
| +#include <jni.h> |
| + |
| +#include "base/android/scoped_java_ref.h" |
| + |
| +namespace content { |
| + |
| +class SurfaceTextureBridge; |
| + |
| +// A helper class for holding a scoped reference to a Java Surface instance. |
| +// When going out of scope, release() is called on the Java object to make |
| +// sure server-side references (esp. wrt graphics memory) are released. |
| +class ScopedJavaSurface { |
| + public: |
| + ScopedJavaSurface(); |
| + |
| + // Wraps an existing Java Surface object in a ScopedJavaSurface. |
| + ScopedJavaSurface(const base::android::JavaRef<jobject>& surface); |
|
piman
2013/03/04 22:56:29
nit: explicit
no sievers
2013/03/04 22:59:16
Done.
|
| + |
| + // Creates a Java Surface from a SurfaceTexture and wraps it in a |
| + // ScopedJavaSurface. |
| + ScopedJavaSurface(const SurfaceTextureBridge* surface_texture); |
|
piman
2013/03/04 22:56:29
nit:explicit
no sievers
2013/03/04 22:59:16
Done.
|
| + |
| + ~ScopedJavaSurface(); |
| + |
| + const base::android::JavaRef<jobject>& j_surface() const { |
| + return j_surface_; |
| + } |
| + |
| + private: |
| + base::android::ScopedJavaGlobalRef<jobject> j_surface_; |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_COMMON_ANDROID_SCOPED_JAVA_SURFACE_H_ |