132a6e48fSopenharmony_ci/*
232a6e48fSopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd.
332a6e48fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
432a6e48fSopenharmony_ci * you may not use this file except in compliance with the License.
532a6e48fSopenharmony_ci * You may obtain a copy of the License at
632a6e48fSopenharmony_ci *
732a6e48fSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
832a6e48fSopenharmony_ci *
932a6e48fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1032a6e48fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1132a6e48fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1232a6e48fSopenharmony_ci * See the License for the specific language governing permissions and
1332a6e48fSopenharmony_ci * limitations under the License.
1432a6e48fSopenharmony_ci */
1532a6e48fSopenharmony_ci
1632a6e48fSopenharmony_ci#ifndef INTERFACES_INNERKITS_SURFACE_NATIVE_SURFACE_H
1732a6e48fSopenharmony_ci#define INTERFACES_INNERKITS_SURFACE_NATIVE_SURFACE_H
1832a6e48fSopenharmony_ci
1932a6e48fSopenharmony_ci#include <future>
2032a6e48fSopenharmony_ci#include <refbase.h>
2132a6e48fSopenharmony_ci
2232a6e48fSopenharmony_cinamespace OHOS {
2332a6e48fSopenharmony_ciclass NativeSurface : public RefBase {
2432a6e48fSopenharmony_ci    friend class SurfaceDelegate;
2532a6e48fSopenharmony_ci
2632a6e48fSopenharmony_cipublic:
2732a6e48fSopenharmony_ci    /*
2832a6e48fSopenharmony_ci     * Constructor of native surface.
2932a6e48fSopenharmony_ci     */
3032a6e48fSopenharmony_ci    NativeSurface();
3132a6e48fSopenharmony_ci
3232a6e48fSopenharmony_ci    /*
3332a6e48fSopenharmony_ci     * Destructor of native surface.
3432a6e48fSopenharmony_ci     */
3532a6e48fSopenharmony_ci    ~NativeSurface();
3632a6e48fSopenharmony_ci
3732a6e48fSopenharmony_ci    /*
3832a6e48fSopenharmony_ci     * Get compat native window.
3932a6e48fSopenharmony_ci     *
4032a6e48fSopenharmony_ci     * @return native window.
4132a6e48fSopenharmony_ci     */
4232a6e48fSopenharmony_ci    void* GetNativeWindow();
4332a6e48fSopenharmony_ci
4432a6e48fSopenharmony_ci    /*
4532a6e48fSopenharmony_ci     * Get compat native window(for compatbility).
4632a6e48fSopenharmony_ci     *
4732a6e48fSopenharmony_ci     * @return native window.
4832a6e48fSopenharmony_ci     */
4932a6e48fSopenharmony_ci    void* Get();
5032a6e48fSopenharmony_ci
5132a6e48fSopenharmony_ciprivate:
5232a6e48fSopenharmony_ci    /*
5332a6e48fSopenharmony_ci     * Callback when the compat native window is created.
5432a6e48fSopenharmony_ci     *
5532a6e48fSopenharmony_ci     * @param nativeWindow the native window.
5632a6e48fSopenharmony_ci     */
5732a6e48fSopenharmony_ci    void OnNativeWindowCreated(void* nativeWindow);
5832a6e48fSopenharmony_ci
5932a6e48fSopenharmony_ci    /*
6032a6e48fSopenharmony_ci     * Callback when the compat native window is destroyed.
6132a6e48fSopenharmony_ci     */
6232a6e48fSopenharmony_ci    void OnNativeWindowDestroyed();
6332a6e48fSopenharmony_ci
6432a6e48fSopenharmony_ci    /*
6532a6e48fSopenharmony_ci     * Release native window.
6632a6e48fSopenharmony_ci     */
6732a6e48fSopenharmony_ci    void ReleaseNativeWindow();
6832a6e48fSopenharmony_ci
6932a6e48fSopenharmony_ci    void* nativeWindow_ = nullptr;
7032a6e48fSopenharmony_ci
7132a6e48fSopenharmony_ci    std::condition_variable condVar_;
7232a6e48fSopenharmony_ci
7332a6e48fSopenharmony_ci    std::mutex mutex_;
7432a6e48fSopenharmony_ci};
7532a6e48fSopenharmony_ci} // namespace OHOS
7632a6e48fSopenharmony_ci#endif // INTERFACES_INNERKITS_SURFACE_NATIVE_SURFACE_H