18bf80f4bSopenharmony_ci/* 28bf80f4bSopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 38bf80f4bSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 48bf80f4bSopenharmony_ci * you may not use this file except in compliance with the License. 58bf80f4bSopenharmony_ci * You may obtain a copy of the License at 68bf80f4bSopenharmony_ci * 78bf80f4bSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 88bf80f4bSopenharmony_ci * 98bf80f4bSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 108bf80f4bSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 118bf80f4bSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 128bf80f4bSopenharmony_ci * See the License for the specific language governing permissions and 138bf80f4bSopenharmony_ci * limitations under the License. 148bf80f4bSopenharmony_ci */ 158bf80f4bSopenharmony_ci 168bf80f4bSopenharmony_ci#ifndef GLES_WGL_STATE_H 178bf80f4bSopenharmony_ci#define GLES_WGL_STATE_H 188bf80f4bSopenharmony_ci 198bf80f4bSopenharmony_ci#if _WIN32 208bf80f4bSopenharmony_ci 218bf80f4bSopenharmony_ci#include <base/containers/string.h> 228bf80f4bSopenharmony_ci#include <base/containers/string_view.h> 238bf80f4bSopenharmony_ci#include <base/containers/vector.h> 248bf80f4bSopenharmony_ci#include <render/gles/intf_device_gles.h> 258bf80f4bSopenharmony_ci#include <render/namespace.h> 268bf80f4bSopenharmony_ci 278bf80f4bSopenharmony_ciRENDER_BEGIN_NAMESPACE() 288bf80f4bSopenharmony_ciclass SwapchainGLES; 298bf80f4bSopenharmony_cistruct DeviceCreateInfo; 308bf80f4bSopenharmony_cistruct DevicePlatformData; 318bf80f4bSopenharmony_ci 328bf80f4bSopenharmony_cinamespace GlesImplementation { 338bf80f4bSopenharmony_cistruct SurfaceInfo; 348bf80f4bSopenharmony_ci} // namespace GlesImplementation 358bf80f4bSopenharmony_ci 368bf80f4bSopenharmony_cinamespace WGLHelpers { 378bf80f4bSopenharmony_ciclass WGLState final { 388bf80f4bSopenharmony_cipublic: 398bf80f4bSopenharmony_ci WGLState() = default; 408bf80f4bSopenharmony_ci ~WGLState() = default; 418bf80f4bSopenharmony_ci void CreateContext(DeviceCreateInfo const& createInfo); 428bf80f4bSopenharmony_ci bool IsValid(); 438bf80f4bSopenharmony_ci void GlInitialize(); 448bf80f4bSopenharmony_ci void DestroyContext(); 458bf80f4bSopenharmony_ci void SetSwapInterval(uint32_t interval); 468bf80f4bSopenharmony_ci const DevicePlatformData& GetPlatformData() const; 478bf80f4bSopenharmony_ci 488bf80f4bSopenharmony_ci void SaveContext(); 498bf80f4bSopenharmony_ci void SetContext(const SwapchainGLES* swapChain); 508bf80f4bSopenharmony_ci void RestoreContext(); 518bf80f4bSopenharmony_ci void* ErrorFilter() const; 528bf80f4bSopenharmony_ci 538bf80f4bSopenharmony_ci bool HasExtension(BASE_NS::string_view) const; 548bf80f4bSopenharmony_ci uintptr_t CreateSurface(uintptr_t window, uintptr_t instance) const noexcept; 558bf80f4bSopenharmony_ci void DestroySurface(uintptr_t surface) const noexcept; 568bf80f4bSopenharmony_ci bool GetSurfaceInformation(HDC surface, GlesImplementation::SurfaceInfo& res) const; 578bf80f4bSopenharmony_ci void SwapBuffers(const SwapchainGLES& swapChain); 588bf80f4bSopenharmony_ci 598bf80f4bSopenharmony_ciprotected: 608bf80f4bSopenharmony_ci bool GetInformation(HDC surface, int32_t configId, GlesImplementation::SurfaceInfo& res) const; 618bf80f4bSopenharmony_ci int ChoosePixelFormat(HDC dc, const BASE_NS::vector<int>& inattributes); 628bf80f4bSopenharmony_ci 638bf80f4bSopenharmony_ci HMODULE glModule_ = nullptr; 648bf80f4bSopenharmony_ci DevicePlatformDataGL plat_; 658bf80f4bSopenharmony_ci struct ContextState { 668bf80f4bSopenharmony_ci HGLRC context { nullptr }; 678bf80f4bSopenharmony_ci HDC display { nullptr }; 688bf80f4bSopenharmony_ci }; 698bf80f4bSopenharmony_ci ContextState oldContext_; 708bf80f4bSopenharmony_ci ContextState dummyContext_; 718bf80f4bSopenharmony_ci BASE_NS::string extensions_; 728bf80f4bSopenharmony_ci BASE_NS::vector<BASE_NS::string_view> extensionList_; 738bf80f4bSopenharmony_ci bool vSync_ = true; 748bf80f4bSopenharmony_ci bool oldIsSet_ = false; 758bf80f4bSopenharmony_ci bool hasSRGBFB_ = false; 768bf80f4bSopenharmony_ci bool hasColorSpace_ = false; 778bf80f4bSopenharmony_ci}; 788bf80f4bSopenharmony_ci} // namespace WGLHelpers 798bf80f4bSopenharmony_ciRENDER_END_NAMESPACE() 808bf80f4bSopenharmony_ci 818bf80f4bSopenharmony_ci#endif 828bf80f4bSopenharmony_ci#endif // GLES_WGL_STATE_H