OpenCAX/entry/src/main/cpp/NativeEGLOCCT/EGLCore.h
2026-04-02 19:40:03 +08:00

57 lines
1.6 KiB
C++

/*
* Copyright (c) 2025 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef EGLMGR_H
#define EGLMGR_H
#include <EGL/egl.h>
#include <GLES3/gl3.h>
#include <map>
#include <iostream>
#include <native_window/external_window.h>
namespace NativeOpenCAX {
enum EGL_TYPE{
EGL_MAIN,
EGL_SUB
};
class EGLCore {
public:
EGLCore();
~EGLCore();
bool InitEglCtx(OHNativeWindow* window,std::string id);
std::string GetCurrentXCompId();
void makeCurrent();
bool swapBuffers();
void destroy();
EGLSurface GetSurface();
EGLContext GetContext();
EGLDisplay GetDisplay();
EGLConfig GetConfig();
OHNativeWindow* GetOHNativeWindow();
private:
std::mutex crtMutex;
std::mutex swapMutex;
std::string eglCrtId;
std::string eglMainId;
EGLDisplay eglDisplay;
EGLConfig eglConfig;
std::unordered_map<std::string, EGLContext> eglCtx;
std::unordered_map<std::string, EGLSurface> eglSur;
std::unordered_map<std::string, OHNativeWindow*> eglWin;
};
} // namespace NativeOpenCAX
#endif // EGLCORE_H