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 #include "egl_wrapper_surface.h"
16 #include "external_window.h"
17 #include "surface.h"
18 #include "window.h"
19 #include "wrapper_log.h"
20
21 namespace OHOS {
EglWrapperSurface(EglWrapperDisplay * disp,EGLSurface surf,NativeWindowType window)22 EglWrapperSurface::EglWrapperSurface(EglWrapperDisplay *disp, EGLSurface surf, NativeWindowType window)
23 : EglWrapperObject(disp), surf_(surf), window_(window)
24 {
25 WLOGD("");
26 if (window_) {
27 OHOS::RefBase *ref = reinterpret_cast<OHOS::RefBase *>(window_);
28 ref->IncStrongRef(ref);
29 }
30 }
31
~EglWrapperSurface()32 EglWrapperSurface::~EglWrapperSurface()
33 {
34 WLOGD("");
35 if (window_ != nullptr) {
36 OHOS::RefBase *ref = reinterpret_cast<OHOS::RefBase *>(window_);
37 ref->DecStrongRef(ref);
38 }
39 surf_ = nullptr;
40 window_ = nullptr;
41 }
42
GetWrapperSurface(EGLSurface surf)43 EglWrapperSurface *EglWrapperSurface::GetWrapperSurface(EGLSurface surf)
44 {
45 WLOGD("");
46 return reinterpret_cast<EglWrapperSurface *>(surf);
47 }
48
Disconnect(OHNativeWindow * window)49 void EglWrapperSurface::Disconnect(OHNativeWindow *window)
50 {
51 if (window != nullptr) {
52 NativeWindowDisconnect(window);
53 }
54 }
55
56 } // namespace OHOS
57