1 /* 2 * Copyright (c) 2022-2023 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 16 #ifndef RENDER_SERVICE_BASE_CORE_COMMON_RS_SHARED_CONTEXT_H 17 #define RENDER_SERVICE_BASE_CORE_COMMON_RS_SHARED_CONTEXT_H 18 19 #include <memory> 20 #include <thread> 21 22 #include "common/rs_macros.h" 23 #include "include/core/SkRefCnt.h" 24 #include "include/gpu/GrContext.h" 25 26 typedef void* EGLSurface; 27 typedef void* EGLContext; 28 typedef void* EGLDisplay; 29 30 namespace OHOS::Rosen { 31 32 class RSB_EXPORT RSSharedContext final : public std::enable_shared_from_this<RSSharedContext> { 33 public: 34 static std::shared_ptr<RSSharedContext> MakeSharedGLContext(EGLContext context); 35 36 ~RSSharedContext(); 37 void MakeCurrent(); 38 sk_sp<GrContext> MakeGrContext(); 39 40 private: RSSharedContext(EGLDisplay display,EGLContext context,EGLSurface surface)41 RSSharedContext(EGLDisplay display, EGLContext context, EGLSurface surface) 42 : display_(display), context_(context), surface_(surface) {} 43 44 EGLDisplay display_ = nullptr; 45 EGLContext context_ = nullptr; 46 EGLSurface surface_ = nullptr; 47 }; 48 } // namespace OHOS::Rosen 49 #endif // RENDER_SERVICE_BASE_CORE_COMMON_RS_SHARED_CONTEXT_H 50