- add sources.
[platform/framework/web/crosswalk.git] / src / ui / gl / android / surface_texture_listener.h
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
3 // found in the LICENSE file.
4
5 #ifndef UI_GL_ANDROID_SURFACE_TEXTURE_LISTENER_H_
6 #define UI_GL_ANDROID_SURFACE_TEXTURE_LISTENER_H_
7
8 #include <jni.h>
9 #include "base/callback.h"
10 #include "base/memory/ref_counted.h"
11 #include "ui/gl/gl_export.h"
12
13 namespace base {
14 class MessageLoopProxy;
15 }
16
17 namespace gfx {
18
19 // Listener class for all the callbacks from android SurfaceTexture.
20 class GL_EXPORT SurfaceTextureListener {
21  public:
22   // Destroy this listener.
23   void Destroy(JNIEnv* env, jobject obj);
24
25   // A new frame is available to consume.
26   void FrameAvailable(JNIEnv* env, jobject obj);
27
28   static bool RegisterSurfaceTextureListener(JNIEnv* env);
29
30  private:
31   // Native code should not hold any reference to this object, and instead pass
32   // it up to Java for being referenced by a SurfaceTexture instance.
33   SurfaceTextureListener(const base::Closure& callback);
34   ~SurfaceTextureListener();
35
36   friend class SurfaceTexture;
37
38   base::Closure callback_;
39
40   scoped_refptr<base::MessageLoopProxy> browser_loop_;
41
42   DISALLOW_IMPLICIT_CONSTRUCTORS(SurfaceTextureListener);
43 };
44
45 }  // namespace gfx
46
47 #endif  // UI_GL_ANDROID_SURFACE_TEXTURE_LISTENER_H_