• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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,EGLint colorSpace)22 EglWrapperSurface::EglWrapperSurface(EglWrapperDisplay *disp, EGLSurface surf,
23                                      NativeWindowType window, EGLint colorSpace)
24     : EglWrapperObject(disp), surf_(surf), window_(window), colorSpace_(colorSpace)
25 {
26     WLOGD("");
27     if (window_) {
28         OHOS::RefBase *ref = reinterpret_cast<OHOS::RefBase *>(window_);
29         ref->IncStrongRef(ref);
30     }
31 }
32 
~EglWrapperSurface()33 EglWrapperSurface::~EglWrapperSurface()
34 {
35     WLOGD("");
36     if (window_ != nullptr) {
37         OHOS::RefBase *ref = reinterpret_cast<OHOS::RefBase *>(window_);
38         ref->DecStrongRef(ref);
39     }
40     surf_ = nullptr;
41     window_ = nullptr;
42 }
43 
GetWrapperSurface(EGLSurface surf)44 EglWrapperSurface *EglWrapperSurface::GetWrapperSurface(EGLSurface surf)
45 {
46     WLOGD("");
47     return reinterpret_cast<EglWrapperSurface *>(surf);
48 }
49 
Disconnect(OHNativeWindow * window)50 void EglWrapperSurface::Disconnect(OHNativeWindow *window)
51 {
52     if (window != nullptr) {
53         NativeWindowDisconnect(window);
54     }
55 }
56 
GetColorSpaceAttribute(EGLint attribute,EGLint * value) const57 EGLBoolean EglWrapperSurface::GetColorSpaceAttribute(EGLint attribute, EGLint* value) const
58 {
59     if (attribute == EGL_GL_COLORSPACE_KHR) {
60         *value = colorSpace_;
61         return EGL_TRUE;
62     }
63     return EGL_FALSE;
64 }
65 
66 } // namespace OHOS
67