OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 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 CONTENT_COMMON_ANDROID_SURFACE_CALLBACK_H_ |
| 6 #define CONTENT_COMMON_ANDROID_SURFACE_CALLBACK_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <jni.h> |
| 10 |
| 11 #include "base/callback.h" |
| 12 #include "content/common/android/surface_texture_peer.h" |
| 13 |
| 14 struct ANativeWindow; |
| 15 |
| 16 namespace base { |
| 17 class MessageLoopProxy; |
| 18 class WaitableEvent; |
| 19 } |
| 20 |
| 21 namespace content { |
| 22 |
| 23 // This file implements support for passing surface handles from Java |
| 24 // to the correct thread on the native side. On Android, these surface |
| 25 // handles can only be passed across processes through Java IPC (Binder), |
| 26 // which means calls from Java come in on arbitrary threads. Hence the |
| 27 // static nature and the need for the client to register a callback with |
| 28 // the corresponding message loop. |
| 29 |
| 30 // Asynchronously sets the Surface. This can be called from any thread. |
| 31 // The Surface will be set to the proper thread based on the type. The |
| 32 // nature of primary_id and secondary_id depend on the type of surface |
| 33 // and are used to route the surface to the correct client. |
| 34 // This method will call release() on the jsurface object to release |
| 35 // all the resources. So after calling this method, the caller should |
| 36 // not use the jsurface object again. |
| 37 void SetSurfaceAsync(JNIEnv* env, |
| 38 jobject jsurface, |
| 39 SurfaceTexturePeer::SurfaceTextureTarget type, |
| 40 int primary_id, |
| 41 int secondary_id, |
| 42 base::WaitableEvent* completion); |
| 43 |
| 44 void ReleaseSurface(jobject surface); |
| 45 |
| 46 typedef base::Callback<void(int, int, ANativeWindow*, base::WaitableEvent*)> |
| 47 NativeWindowCallback; |
| 48 void RegisterNativeWindowCallback(base::MessageLoopProxy* loop, |
| 49 NativeWindowCallback& callback); |
| 50 |
| 51 typedef base::Callback<void(int, int, jobject surface)> VideoSurfaceCallback; |
| 52 void RegisterVideoSurfaceCallback(base::MessageLoopProxy* loop, |
| 53 VideoSurfaceCallback& callback); |
| 54 |
| 55 bool RegisterSurfaceCallback(JNIEnv* env); |
| 56 |
| 57 } // namespace content |
| 58 |
| 59 #endif // CONTENT_COMMON_ANDROID_SURFACE_CALLBACK_H_ |
OLD | NEW |