1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef INTERFACES_INNERKITS_SURFACE_NATIVE_SURFACE_H
17 #define INTERFACES_INNERKITS_SURFACE_NATIVE_SURFACE_H
18 
19 #include <future>
20 #include <refbase.h>
21 
22 namespace OHOS {
23 class NativeSurface : public RefBase {
24     friend class SurfaceDelegate;
25 
26 public:
27     /*
28      * Constructor of native surface.
29      */
30     NativeSurface();
31 
32     /*
33      * Destructor of native surface.
34      */
35     ~NativeSurface();
36 
37     /*
38      * Get compat native window.
39      *
40      * @return native window.
41      */
42     void* GetNativeWindow();
43 
44     /*
45      * Get compat native window(for compatbility).
46      *
47      * @return native window.
48      */
49     void* Get();
50 
51 private:
52     /*
53      * Callback when the compat native window is created.
54      *
55      * @param nativeWindow the native window.
56      */
57     void OnNativeWindowCreated(void* nativeWindow);
58 
59     /*
60      * Callback when the compat native window is destroyed.
61      */
62     void OnNativeWindowDestroyed();
63 
64     /*
65      * Release native window.
66      */
67     void ReleaseNativeWindow();
68 
69     void* nativeWindow_ = nullptr;
70 
71     std::condition_variable condVar_;
72 
73     std::mutex mutex_;
74 };
75 } // namespace OHOS
76 #endif // INTERFACES_INNERKITS_SURFACE_NATIVE_SURFACE_H