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_context.h"
16 
17 #include "wrapper_log.h"
18 namespace OHOS {
EglWrapperContext(EglWrapperDisplay * disp,EGLContext context,EGLint version)19 EglWrapperContext::EglWrapperContext(EglWrapperDisplay *disp, EGLContext context, EGLint version)
20     : EglWrapperObject(disp), context_(context), read_(nullptr), draw_(nullptr), version_(version)
21 {
22     WLOGD("");
23 }
24 
~EglWrapperContext()25 EglWrapperContext::~EglWrapperContext()
26 {
27     WLOGD("");
28     context_ = nullptr;
29     draw_ = nullptr;
30     read_ = nullptr;
31 }
32 
SetCurrentSurface(EGLSurface draw,EGLSurface read)33 void EglWrapperContext::SetCurrentSurface(EGLSurface draw, EGLSurface read)
34 {
35     WLOGD("");
36     draw_ = draw;
37     read_ = read;
38 }
39 
GetWrapperContext(EGLContext ctx)40 EglWrapperContext *EglWrapperContext::GetWrapperContext(EGLContext ctx)
41 {
42     WLOGD("");
43     return reinterpret_cast<EglWrapperContext *>(ctx);
44 }
45 
GetCurrentSurface(EGLint type) const46 EGLSurface EglWrapperContext::GetCurrentSurface(EGLint type) const
47 {
48     WLOGD("");
49     switch (type) {
50         case EGL_READ: {
51             return read_;
52         }
53         case EGL_DRAW: {
54             return draw_;
55         }
56         default: {
57             WLOGE("type error!");
58             return EGL_NO_SURFACE;
59         }
60     }
61 }
62 } // namespace OHOS
63