1 /* 2 * Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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 16 #ifndef _ROSEN_CONTEXT_IMPL_H_ 17 #define _ROSEN_CONTEXT_IMPL_H_ 18 19 #include "ohos_context_i.h" 20 21 #include "ui/rs_display_node.h" 22 #include "ui/rs_surface_node.h" 23 24 #include "EGL/egl.h" 25 #include "EGL/eglext.h" 26 #include "GLES3/gl32.h" 27 28 namespace OHOS { 29 namespace Rosen { 30 31 class RosenContextImpl : public OHOS::OhosContextI { 32 public: 33 RosenContextImpl(); 34 35 bool SetConfig(int32_t w,int32_t h,RCI_GLES_VERSION ver,RCI_PIXEL_FORMAT pf,RCI_SURFACE_TYPE st,RCI_PROFILE tp,RCI_CONTEXT_FLAG flags) override; 36 bool InitNativeWindow() override; 37 bool InitEglSurface() override; 38 bool InitEglContext() override; 39 40 void MakeCurrent() override; 41 void SwapBuffer() override; 42 43 int32_t GetAttrib(int32_t attrType) override; 44 private: 45 void InitProducer(); 46 bool InitEgl(); 47 void ShowConfig(EGLConfig cfg); 48 49 RCI_GLES_VERSION glesVersion_; 50 RCI_PROFILE typeProfile_; 51 RCI_CONTEXT_FLAG contextFlags_; 52 RCI_SURFACE_TYPE surfaceType_; 53 int32_t width_; 54 int32_t height_; 55 RCI_PIXEL_FORMAT pixelFormat_; 56 EGLConfig *allConfigs_; 57 EGLint configCount_; 58 59 RSDisplayNode::SharedPtr displayNode_; 60 std::shared_ptr<RSSurfaceNode> surfaceNode_; 61 sptr<Surface> producer_; 62 63 EGLDisplay eglDisplay_; 64 65 EGLConfig config_; 66 67 struct NativeWindow* nativeWindow_ = nullptr; 68 69 EGLSurface eglSurface_ = EGL_NO_SURFACE; 70 71 EGLContext eglContext_ = EGL_NO_CONTEXT; 72 }; 73 74 } 75 } 76 77 #endif